26 template <Automaton Aut>
33 && a->weightset()->is_one(a->weight_of(inis.front()))
35 &&
in(a, a->dst_of(inis.front())).empty();
39 template <Automaton Aut>
52 template <Automaton Aut>
56 const auto& a = aut->as<Aut>();
61 template <Automaton Aut>
65 const auto& a = aut->as<Aut>();
78 template <Automaton Aut>
85 const auto& ws = *aut->weightset();
87 std::vector<transition_t_of<Aut>> initials{begin(inits), end(inits)};
92 auto ini = aut->new_state();
93 for (
auto ti: initials)
96 auto i = aut->dst_of(ti);
97 auto wi = aut->weight_of(ti);
99 aut->new_transition(ini, aut->dst_of(t), aut->label_of(t),
100 ws.mul(wi, aut->weight_of(t)));
101 aut->del_transition(ti);
105 if (
all_in(aut, i).empty())
110 aut->set_initial(ini);
113 template <Automaton Aut>
117 auto res =
copy(aut);
122 template <Automaton Aut>
125 -> decltype(
copy(aut))
136 template <Automaton Aut>
140 const auto& a = aut->as<Aut>();
145 template <Automaton Aut>
149 const auto& a = aut->as<Aut>();
169 :
public ExpSet::const_visitor
178 using super_t =
typename expressionset_t::const_visitor;
181 constexpr
static const char*
me() {
return "standard"; }
204 virtual
void visit(const tuple_t&,
std::true_type)
override
206 raise(
me(),
": tuple is not supported");
216 auto i =
res_->new_state();
223 auto i =
res_->new_state();
224 auto f =
res_->new_state();
226 res_->new_transition(i, f, e.value());
236 res.insert(
res_->src_of(t));
243 e.head()->accept(*
this);
245 for (
auto c: e.tail())
251 res_->add_transition(initial,
268 e.head()->accept(*
this);
272 for (
auto c: e.tail())
283 if (!
has(other_finals,
res_->src_of(t1)))
297 auto s1 =
res_->src_of(t1);
298 auto w1 =
res_->weight_of(t1);
299 res_->del_transition(t1);
301 res_->set_transition(s1,
304 ws_.mul(w1,
res_->weight_of(t2)));
315 e.sub()->accept(*
this);
322 res_->lmul_weight(ti, w);
325 && !
has(other_finals,
res_->src_of(tf)))
335 ws_.mul(
res_->weight_of(tf),
res_->weight_of(ti)));
338 res_->rmul_weight(tf, w);
344 e.sub()->accept(*
this);
346 res_->lmul_weight(t, e.weight());
352 e.sub()->accept(*
this);
354 if (!
has(other_finals,
res_->src_of(t)))
355 res_->rmul_weight(t, e.weight());
386 template <
typename ExpSet>
392 using expressionset_t = ExpSet;
395 const auto& e = exp->as<expressionset_t>();
396 return make_automaton(::vcsn::standard<automaton_t>(e.expressionset(),
automaton_t operator()(const typename expressionset_t::value_t &v)
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
#define VCSN_RAT_UNSUPPORTED(Type)
auto costandard(const Aut &aut) -> decltype(copy(aut))
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
std::set< state_t > states_t
The current set of final states.
weightset_t_of< expressionset_t > weightset_t
static constexpr const char * me()
Name of this algorithm, for error messages.
bool is_standard(const automaton &aut)
Bridge.
void standard_here(Aut &aut)
Turn aut into a standard automaton.
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
SharedPtr make_shared_ptr(Args &&...args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
Provide a variadic mul on top of a binary mul(), and one().
An inner node with multiple children.
auto standard(const Aut &aut)
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
Aut transpose(const transpose_automaton< Aut > &aut)
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
auto initial_transitions(const Aut &aut) -> decltype(aut->all_out(aut->pre()))
Indexes of transitions to (visible) initial states.
weight_t_of< expressionset_t > weight_t
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
const expressionset_t & rs_
Build a standard automaton from an expression.
typename super_t::tuple_t tuple_t
std::shared_ptr< detail::automaton_base > automaton
automaton standard_expression(const expression &exp)
Bridge (standard).
VCSN_RAT_VISIT(lweight, e)
state_t_of< automaton_t > state_t
VCSN_RAT_VISIT(rweight, e)
An inner node implementing a weight.
automaton standard(const automaton &aut)
Bridge.
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
auto final_transitions(const Aut &aut) -> decltype(aut->all_in(aut->post()))
Indexes of transitions from (visible) final states.
std::shared_ptr< detail::expression_base > expression
automaton costandard(const automaton &aut)
Bridge.
standard_visitor(const expressionset_t &rs)
typename expressionset_t::const_visitor super_t
bool is_standard(const Aut &a)
Whether a is standard.
virtual void visit(const tuple_t &, std::true_type) override
auto in(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions arriving to state s.
bool is_costandard(const Aut &a)
Whether a is costandard.
bool is_costandard(const automaton &aut)
Bridge.
auto copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans) -> decltype(keep_state(input->null_state()), keep_trans(input->null_transition()), make_fresh_automaton< AutIn, AutOut >(input))
A copy of input keeping only its states that are accepted by keep_state, and transitions accepted by ...