1 #ifndef VCSN_ALGOS_UNIVERSAL_HH
2 # define VCSN_ALGOS_UNIVERSAL_HH
16 template <
typename Aut>
21 "universal: requires free labelset");
23 "universal: requires Boolean weights");
29 using map_t = std::map<state_t, state_set_t>;
39 return work_(automaton);
49 state_t i = aut->dst_of(aut->initial_transitions().front());
55 map_t origin = codet->origins();
56 origin.erase(codet->pre());
67 automaton_t res = make_shared_ptr<automaton_t>(aut->context());
70 std::set<state_t> automaton_finals;
71 for (
auto t: aut->final_transitions())
72 automaton_finals.insert(aut->src_of(t));
78 for (
const auto s: univers_states)
81 state_t new_s = res->new_state();
82 subset_label[new_s] = s;
85 res->set_initial(new_s);
87 if (
subset(s, automaton_finals))
88 res->set_final(new_s);
92 for (
const auto x: res->states())
93 for (
const auto y: res->states())
94 for (
const auto a: *res->labelset())
98 for (
auto s: subset_label[x])
101 for (
auto t: aut->out(s, a))
104 delta_ret.insert(aut->dst_of(t));
116 if (
subset(delta_ret, subset_label[y]))
117 res->new_transition(x, y, a);
142 template <
typename Aut>
146 const auto& a = aut->as<Aut>();
157 #endif // !VCSN_ALGOS_UNIVERSAL_HH
bool is_deterministic(const Aut &aut, state_t_of< Aut > s)
Whether state s is deterministic in aut.
bool subset(const Container1 &set1, const Container2 &set2) ATTRIBUTE_PURE
Whether set1 ⊆ set2.
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
std::set< std::set< T, Compare, Alloc > > intersection_closure(std::set< std::set< T, Compare, Alloc >> pset)
The set of all the intersections of the sets in pset.
automaton universal(const automaton &aut)
std::set< state_set_t > pstate_t
Aut universal(const Aut &a)
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
bool is_complete(const Aut &aut)
Whether aut is complete.
automaton_t work_(const automaton_t &aut)
Work on aut, which is complete and deterministic.
automaton_t operator()(const Aut &automaton)
The universal automaton of automaton.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
auto complete(const Aut &aut) -> decltype(::vcsn::copy(aut))
std::set< state_t > state_set_t
auto determinize(const Aut &a) -> determinized_automaton< Aut >
Provide a variadic mul on top of a binary mul(), and one().
std::set< typename std::map< Key, Value, Comp, Alloc >::mapped_type > image(const std::map< Key, Value, Comp, Alloc > &m)
The set of values of a map.
Aut transpose(const transpose_automaton< Aut > &aut)
auto strip(const Aut &aut, int) -> decltype(aut->strip())
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
state_t_of< automaton_t > state_t
std::map< state_t, state_set_t > map_t