Awali
Another Weighted Automata library
min_quotient.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_ALGOS_MIN_QUOTIENT_HH
18 #define AWALI_ALGOS_MIN_QUOTIENT_HH
19 
20 #include <awali/common/enums.hh>
25 
26 namespace awali {
27  namespace sttc {
28  template <typename Aut>
29  Aut min_quotient(const Aut& aut, quotient_algo_t algo=MOORE,
30  bool keep_history=true)
31  {
32  std::vector<std::vector<state_t> > equiv;
33  std::vector<std::list<state_t> > equil;
34  switch(algo) {
35  case MOORE :
36  moore_quotient(aut, equiv);
37  return merge(aut, equiv, keep_history);
38  case HOPCROFT :
39  hopcroft_quotient(aut, equil);
40  return merge(aut, equil, keep_history);
41  default:
42  raise("Quotient algo is either MOORE or HOPCROFT");
43  }
44  }
45 
46  //For deterministic automata only
47  template <typename Aut>
48  Aut minimize(const Aut& aut, quotient_algo_t algo=MOORE,
49  bool keep_history=true)
50  {
51  std::vector<std::vector<state_t> > equiv;
52  std::vector<std::list<state_t> > equil;
53  switch(algo) {
54  case MOORE :
55  moore_det(aut, equiv);
56  return merge(aut, equiv, keep_history);
57  case HOPCROFT :
58  hopcroft_quotient(aut, equil, true);
59  return merge(aut, equil, keep_history);
60  default:
61  raise("Quotient algo is either MOORE or HOPCROFT");
62  }
63  }
64 
65  template <typename Aut>
66  Aut min_quotient_det(const Aut& aut, quotient_algo_t algo=MOORE, bool
67  keep_history=true)
68  {
69  return minimize(aut, algo, keep_history);
70  }
71 
72  }
73 }//end of ns awali::stc
74 
75 #endif // !AWALI_ALGOS_MIN_QUOTIENT_HH
quotient_algo_t
The different algorithms for computing the minimal quotient.
Definition: enums.hh:64
@ HOPCROFT
Definition: enums.hh:66
@ MOORE
Definition: enums.hh:65
auto merge(const Aut &a, std::vector< StateList > &classes, bool keep_history=true) -> Aut
Definition: merge.hh:123
Aut minimize(const Aut &aut, quotient_algo_t algo=MOORE, bool keep_history=true)
Definition: min_quotient.hh:48
void moore_det(const Aut &aut, std::vector< std::vector< state_t > > &states_in_part)
Moore algorithm for the minimization of deterministic Boolean automata (DFA), not necessarily complet...
Definition: congruence_det.hh:143
Aut min_quotient(const Aut &aut, quotient_algo_t algo=MOORE, bool keep_history=true)
Definition: min_quotient.hh:29
Aut min_quotient_det(const Aut &aut, quotient_algo_t algo=MOORE, bool keep_history=true)
Definition: min_quotient.hh:66
unsigned moore_quotient(const Aut &aut, std::vector< std::vector< state_t > > &states_in_part)
Definition: moore_quotient.hh:57
unsigned hopcroft_quotient(const Aut &aut, std::vector< std::list< state_t > > &states_in_part, bool cancellative=false)
Definition: hopcroft_quotient.hh:84
Main namespace of Awali.
Definition: ato.hh:22