15 template <
typename Context>
16 mutable_automaton<Context>
17 u(
const Context&
ctx,
unsigned n)
19 using context_t = Context;
22 require(2 <= n,
"u: n must be at least 3");
23 const auto& ls = *ctx.labelset();
24 const auto& gens = ls.generators();
25 std::vector<label_t_of<context_t>> letters;
27 letters.emplace_back(ls.value(l));
28 require(3 <= letters.size(),
"u: the alphabet needs at least 3 letters");
29 automaton_t res = make_shared_ptr<automaton_t>(
ctx);
32 std::vector<state_t> states;
33 for (
unsigned i = 0; i < n; ++i)
34 states.push_back(res->new_state());
35 res->set_initial(states[0]);
36 res->set_final(states[n-1]);
40 for (
unsigned i = 0; i < n; ++i)
41 res->new_transition(states[i], states[(i+1) % n], a);
45 res->new_transition(states[0], states[1],
b);
46 res->new_transition(states[1], states[0],
b);
47 for (
unsigned i = 2; i < n; ++i)
48 res->new_transition(states[i], states[i],
b);
52 for (
unsigned i = 0; i < n - 1; ++i)
53 res->new_transition(states[i], states[i], c);
54 res->new_transition(states[n - 1], states[0], c);
68 template <
typename Ctx,
typename Un
signed>
72 const auto& c = ctx->as<Ctx>();
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
mutable_automaton< Context > u(const Context &ctx, unsigned n)
The Brzozowski universal witness.
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().
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
std::shared_ptr< const detail::context_base > context
A dyn::context.
std::shared_ptr< detail::automaton_base > automaton
static dyn::context ctx(const driver &d)
Get the context of the driver.
automaton u(const context &ctx, unsigned n)
Bridge.