28 template <Automaton Aut1, Automaton Aut2>
43 template <Automaton Aut1, Automaton Aut2>
53 {b->pre(), res->pre()},
54 {b->post(), res->post()},
57 for (
auto s: b->states())
58 m.emplace(s, b->is_initial(s) ? initial : res->new_state());
62 if (b->dst_of(t) == b->post())
63 res->add_transition(m[b->src_of(t)], m[b->dst_of(t)],
65 res->weightset()->conv(*b->weightset(),
69 else if (b->src_of(t) != b->pre())
70 res->new_transition(m[b->src_of(t)], m[b->dst_of(t)],
72 res->weightset()->conv(*b->weightset(),
80 template <Automaton Aut1, Automaton Aut2>
93 template <Automaton Aut1, Automaton Aut2,
typename Tag = general_tag>
95 sum(
const Aut1& lhs,
const Aut2& rhs, Tag tag = {})
109 template <Automaton Lhs, Automaton Rhs,
typename String>
113 const auto& l = lhs->as<Lhs>();
114 const auto&
r = rhs->as<Rhs>();
131 template <
typename ValueSet>
132 typename ValueSet::value_t
134 const typename ValueSet::value_t& lhs,
135 const typename ValueSet::value_t& rhs)
137 return vs.add(lhs, rhs);
146 template <
typename PolynomialSetLhs,
typename PolynomialSetRhs>
150 auto join_elts = join<PolynomialSetLhs, PolynomialSetRhs>(lhs, rhs);
152 sum(std::get<0>(join_elts),
153 std::get<1>(join_elts),
154 std::get<2>(join_elts)));
169 template <
typename ExpansionSetLhs,
typename ExpansionSetRhs>
173 const auto& l = lhs->as<ExpansionSetLhs>();
174 const auto&
r = rhs->as<ExpansionSetRhs>();
175 auto rs =
join(l.expansionset(), r.expansionset());
176 auto lr = rs.conv(l.expansionset(), l.expansion());
177 auto rr = rs.conv(r.expansionset(), r.expansion());
192 template <
typename ExpSetLhs,
typename ExpSetRhs>
196 auto join_elts = join<ExpSetLhs, ExpSetRhs>(lhs, rhs);
199 std::get<1>(join_elts),
200 std::get<2>(join_elts)));
215 template <
typename WeightSetLhs,
typename WeightSetRhs>
219 const auto& l = lhs->as<WeightSetLhs>();
220 const auto&
r = rhs->as<WeightSetRhs>();
221 auto rs =
join(l.weightset(), r.weightset());
222 auto lr = rs.conv(l.weightset(), l.weight());
223 auto rr = rs.conv(r.weightset(), r.weight());
Tag for operations on all automata.
std::shared_ptr< const detail::polynomial_base > polynomial
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< const detail::weight_base > weight
auto sum(const Aut1 &lhs, const Aut2 &rhs, Tag tag={}) -> decltype(join_automata(lhs, rhs))
The sum of two automata.
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
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.
weight make_weight(const WeightSet &ws, const typename WeightSet::value_t &w)
std::shared_ptr< const detail::expansion_base > expansion
weightset_mixin< detail::r_impl > r
Provide a variadic mul on top of a binary mul(), and one().
auto determinize(const Aut &a, Tag={}, bool_constant< Lazy >={})
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto initial_transitions(const Aut &aut) -> decltype(aut->all_out(aut->pre()))
Indexes of transitions to (visible) initial states.
std::shared_ptr< detail::automaton_base > automaton
Aut1 & sum_here(Aut1 &res, const Aut2 &b, deterministic_tag)
Merge transitions of b into those of res.
weight sum_weight(const weight &lhs, const weight &rhs)
Bridge (sum).
polynomial sum_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge (sum).
expression sum_expression(const expression &lhs, const expression &rhs)
Bridge (sum).
Container::value_type front(const Container &container)
The first member of this Container.
Tag for operations on deterministic automata.
auto join_automata(Auts &&...auts) -> decltype(make_mutable_automaton(join(auts->context()...)))
An automaton whose type is the join between those of auts.
expansion sum_expansion(const expansion &lhs, const expansion &rhs)
Bridge (sum).
automaton sum(const automaton &lhs, const automaton &rhs, const std::string &algo)
Bridge.
std::shared_ptr< detail::expression_base > expression
expansion make_expansion(const ExpansionSet &ps, const typename ExpansionSet::value_t &expansion)
auto all_transitions(const Aut &aut)
All the transition indexes between all states (including pre and post).
context join(const context &c1, const context &c2)
Bridge.
bool is_standard(const Aut &a)
Whether a is standard.
Tag for operations on standard automata.
expression make_expression(const ExpSet &rs, const typename ExpSet::value_t &r)
auto dispatch_tags(std::string algo, Operation op, Aut &&...auts)
Dispatch an operation between automata depending on their nature.