13 template <
typename Context>
14 mutable_automaton<Context>
15 u(
const Context&
ctx,
unsigned n)
17 using context_t = Context;
20 require(2 <= n,
"u: n must be at least 3");
21 const auto& ls = *ctx.labelset();
22 const auto& gens = ls.generators();
23 std::vector<label_t_of<context_t>> letters;
25 letters.emplace_back(ls.value(l));
26 require(3 <= letters.size(),
"u: the alphabet needs at least 3 letters");
27 automaton_t
res = make_shared_ptr<automaton_t>(
ctx);
30 std::vector<state_t> states;
31 for (
unsigned i = 0; i < n; ++i)
32 states.push_back(res->new_state());
33 res->set_initial(states[0]);
34 res->set_final(states[n-1]);
38 for (
unsigned i = 0; i < n; ++i)
39 res->new_transition(states[i], states[(i+1) % n], a);
43 res->new_transition(states[0], states[1],
b);
44 res->new_transition(states[1], states[0],
b);
45 for (
unsigned i = 2; i < n; ++i)
46 res->new_transition(states[i], states[i],
b);
50 for (
unsigned i = 0; i < n - 1; ++i)
51 res->new_transition(states[i], states[i], c);
52 res->new_transition(states[n - 1], states[0], c);
66 template <
typename Ctx,
typename Un
signed>
70 const auto& c = ctx->
as<Ctx>();
mutable_automaton< Context > u(const Context &ctx, unsigned n)
The Brzozowski universal witness.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
Provide a variadic mul on top of a binary mul(), and one().
automaton u(const context &ctx, unsigned n)
Bridge.
auto & as()
Downcast to the exact type.
Template-less root for contexts.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of