17 #ifndef AWALI_ALGOS_LADYBIRD_HH
18 # define AWALI_ALGOS_LADYBIRD_HH
27 namespace awali {
namespace sttc {
52 template <
class Context>
53 mutable_automaton<Context>
56 using context_t = Context;
57 const auto& gens = ctx.labelset()->genset();
58 std::vector<typename context_t::labelset_t::letter_t> letters
59 {std::begin(gens), std::end(gens)};
61 "ladybird: the alphabet needs at least 3 letters");
63 "ladybird: the automaton should have at least one state");
69 automaton_t res = make_shared_ptr<automaton_t>(ctx);
71 auto p = res->add_state();
75 for (
unsigned i = 1; i <
n; ++i)
77 auto y = res->add_state();
78 res->new_transition(x, y, a);
79 res->new_transition(y, y,
b);
80 res->new_transition(y, y,
c);
81 res->new_transition(y, p,
c);
84 res->new_transition(x, p, a);
The Boolean semring.
Definition: b.hh:38
The semiring of complex numbers.
Definition: c.hh:44
The semiring of Natural numbers.
Definition: n.hh:34
std::string to_string(identities i)
mutable_automaton< Context > ladybird(const Context &ctx, unsigned n)
Returns a "ladybird" automaton with n states.
Definition: ladybird.hh:54
std::shared_ptr< internal::mutable_automaton_impl< Context > > mutable_automaton
Definition: mutable_automaton.hh:45
void require(bool b, Args &&... args)
If b is not verified, raise an error with args as message.
Definition: raise.hh:55
Main namespace of Awali.
Definition: ato.hh:22