21 template <Automaton Aut>
25 const auto& ws = *res->weightset();
26 const auto& ls = *res->labelset();
28 auto initial = res->new_state();
31 res->new_transition(initial, res->dst_of(ti),
32 ls.one(), res->weight_of(ti));
33 res->del_transition(ti);
37 res->add_transition(res->src_of(tf), initial,
38 ls.one(), res->weight_of(tf));
39 res->del_transition(tf);
41 res->set_initial(initial, ws.one());
42 res->set_final(initial, ws.one());
49 template <Automaton Aut>
59 using automaton_t = Aut;
65 weightset_t ws(*res->context().weightset());
69 weight_t w = ws.star(res->get_final_weight(initial));
72 for (
auto ti:
out(res, initial))
74 res->lmul_weight(ti, w);
76 if (res->src_of(tf) != initial)
83 ws.mul(res->weight_of(tf), res->weight_of(ti)));
86 res->rmul_weight(tf, w);
87 res->set_final(initial, w);
92 template <Automaton Aut>
106 template <Automaton Aut,
typename Tag = general_tag>
108 star(
const Aut& aut, Tag tag = {})
122 template <Automaton Aut,
typename String>
126 const auto& aut = a->as<Aut>();
Tag for operations on all automata.
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
void copy_into(const AutIn &in, AutOut &out, KeepState keep_state, KeepTrans keep_trans)
Copy selected states and transitions of an automaton.
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
void standard_here(Aut &aut)
Turn aut into a standard automaton.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
auto determinize(const Aut &a, Tag={}, bool_constant< Lazy >={})
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
auto make_join_automaton(deterministic_tag, Auts &&...auts)
Make an empty automaton which is a supertype of others.
automaton star(const automaton &a, const std::string &algo)
Bridge.
auto initial_transitions(const Aut &aut) -> decltype(aut->all_out(aut->pre()))
Indexes of transitions to (visible) initial states.
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
std::shared_ptr< detail::automaton_base > automaton
auto star(const Aut &aut, Tag tag={}) -> decltype(detail::make_join_automaton(tag, aut))
Star of an automaton.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
Container::value_type front(const Container &container)
The first member of this Container.
Tag for operations on deterministic automata.
auto final_transitions(const Aut &aut) -> decltype(aut->all_in(aut->post()))
Indexes of transitions from (visible) final states.
bool is_standard(const Aut &a)
Whether a is standard.
Tag for operations on standard automata.
Aut & star_here(Aut &res, general_tag={})
In-place star of an automaton.
auto dispatch_tags(std::string algo, Operation op, Aut &&...auts)
Dispatch an operation between automata depending on their nature.