17 #ifndef AWALI_ALGOS_DOUBLE_RING_HH
18 # define AWALI_ALGOS_DOUBLE_RING_HH
28 namespace awali {
namespace sttc {
54 template <
class Context>
55 mutable_automaton<Context>
57 const std::vector<unsigned>& finals)
59 using context_t = Context;
60 const auto& gens = ctx.labelset()->genset();
61 std::vector<typename context_t::labelset_t::letter_t> letters
62 {std::begin(gens), std::end(gens)};
64 "double_ring: the alphabet needs at least 2 letters");
66 "double_ring: the automaton should have at least one state");
71 automaton_t res = make_shared_ptr<automaton_t>(ctx);
74 auto p = res->add_state();
77 std::map<unsigned, state_t>
states;
82 for (
unsigned i = 1; i <
n; ++i)
85 res->new_transition(x, y, a);
86 res->new_transition(y, x,
b);
90 res->new_transition(x, p, a);
91 res->new_transition(p, x,
b);
96 require(f <
n,
"double_ring: invalid list of finals");
The Boolean semring.
Definition: b.hh:38
The semiring of Natural numbers.
Definition: n.hh:34
std::vector< state_t > states(abstract_automaton_t const *aut, bool all)
std::string to_string(identities i)
mutable_automaton< Context > double_ring(const Context &ctx, unsigned n, const std::vector< unsigned > &finals)
Returns a double ring automaton with n states.
Definition: double_ring.hh:56
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
unsigned state_t
Definition: types.hh:21