17 #ifndef AWALI_ALGOS_ISCONGRUENT_HH
18 # define AWALI_ALGOS_ISCONGRUENT_HH
35 template <
typename Aut>
36 bool is_congruence(
const Aut& aut,
const std::vector<std::vector<state_t>>& partition) {
38 using automaton_t = Aut;
44 std::vector<unsigned> part_of(aut->max_state()+1);
45 for(
unsigned i=0; i<partition.size(); ++i)
46 for(
auto s : partition[i]){
50 for(
auto part : partition) {
56 for(
auto tr : aut->all_out(s)) {
57 std::pair<unsigned, label_t> key{part_of[aut->dst_of(tr)], aut->label_of(tr)};
60 if(signature.
count(key))
61 signature[key] = aut->weightset()->add(signature[key], w);
65 for(
auto p: signature.
domain()) {
66 std::pair<label_t, weight_t> plw{p.second, signature[p]};
67 if(successors.
count(p.first) && successors[p.first].
count(plw))
68 ++successors[p.first][plw];
70 successors[p.first][plw]=1;
73 unsigned n=part.size();
74 for(
auto a:successors.
domain())
75 for(
auto b: successors[a].
domain())
76 if(successors[a][
b]!=
n)
The Boolean semring.
Definition: b.hh:38
The semiring of Natural numbers.
Definition: n.hh:34
automaton_t domain(transducer_t tdc)
Returns the automaton corresponding to the second tape of the transducer.
any_t label_t
Type for (transition) labels; it is an alias to any_t since its precise type depends on the weightset...
Definition: typedefs.hh:48
any_t weight_t
Type for (transition) weights; it is an alias to any_t since the its precise type depends on the weig...
Definition: typedefs.hh:61
bool is_congruence(const Aut &aut, const std::vector< std::vector< state_t >> &partition)
Definition: is_congruence.hh:36
typename internal::label_t_of_impl< internal::base_t< ValueSet > >::type label_t_of
Helper to retrieve the type of the labels of a value set.
Definition: traits.hh:71
typename internal::weight_t_of_impl< internal::base_t< ValueSet > >::type weight_t_of
Helper to retrieve the type of the weights of a value set.
Definition: traits.hh:81
Main namespace of Awali.
Definition: ato.hh:22
Definition: linkedhashmap.hh:31
unsigned count(const K &k) const
Definition: linkedhashmap.hh:46
const std::vector< K > & domain() const
Definition: linkedhashmap.hh:36