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);
100 aut->add_transition(ini, aut->dst_of(t), aut->label_of(t),
101 ws.mul(wi, aut->weight_of(t)));
102 aut->del_transition(ti);
106 if (
all_in(aut, i).empty())
111 aut->set_initial(ini);
114 template <Automaton Aut>
123 template <Automaton Aut>
126 -> decltype(
copy(aut))
137 template <Automaton Aut>
141 const auto& a = aut->
as<Aut>();
146 template <Automaton Aut>
150 const auto& a = aut->
as<Aut>();
170 :
public ExpSet::const_visitor
180 using super_t =
typename expressionset_t::const_visitor;
183 constexpr
static const char*
me() {
return "standard"; }
197 return std::move(
res_);
199 catch (
const std::runtime_error& e)
202 " while computing standard automaton of: ",
216 void visit(const tuple_t&,
std::true_type)
override
218 raise(
me(),
": tuple is not supported");
228 auto i =
res_->new_state();
235 auto i =
res_->new_state();
236 auto f =
res_->new_state();
238 res_->new_transition(i, f, e.value());
248 res.insert(
res_->src_of(t));
255 e.head()->accept(*
this);
257 for (
const auto& c: e.tail())
263 res_->add_transition(initial,
280 e.head()->accept(*
this);
284 for (
const auto& c: e.tail())
295 if (!
has(other_finals,
res_->src_of(t1)))
309 auto s1 =
res_->src_of(t1);
310 auto w1 =
res_->weight_of(t1);
311 res_->del_transition(t1);
313 res_->set_transition(s1,
316 ws_.mul(w1,
res_->weight_of(t2)));
327 e.sub()->accept(*
this);
334 res_->lweight(ti, w);
337 && !
has(other_finals,
res_->src_of(tf)))
347 ws_.mul(
res_->weight_of(tf),
res_->weight_of(ti)));
350 res_->rweight(tf, w);
356 e.sub()->accept(*
this);
358 res_->lweight(t, e.weight());
364 e.sub()->accept(*
this);
366 if (!
has(other_finals,
res_->src_of(t)))
367 res_->rweight(t, e.weight());
398 template <
typename ExpSet>
404 using expressionset_t = ExpSet;
407 const auto& e = exp->
as<expressionset_t>();
408 return ::vcsn::standard<automaton_t>(e.valueset(), e.value());
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
typename expressionset_t::value_t expression_t
SharedPtr make_shared_ptr(Args &&...args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
weight_t_of< expressionset_t > weight_t
void standard_here(Aut &aut)
Turn aut into a standard automaton.
An inner node implementing a weight.
Aut standard(const ExpSet &rs, const typename ExpSet::value_t &r)
Build a standard automaton from an expression.
typename super_t::tuple_t tuple_t
automaton standard_expression(const expression &exp)
Bridge (standard).
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
standard_visitor(const expressionset_t &rs)
void visit(const tuple_t &, std::true_type) override
weightset_t_of< expressionset_t > weightset_t
auto final_transitions(const Aut &aut) -> decltype(aut->all_in(aut->post()))
Indexes of transitions from (visible) final states.
Provide a variadic mul on top of a binary mul(), and one().
Build a standard automaton from an expression.
auto costandard(const Aut &aut) -> decltype(copy(aut))
automaton costandard(const automaton &aut)
Bridge.
auto initial_transitions(const Aut &aut) -> decltype(aut->all_out(aut->pre()))
Indexes of transitions to (visible) initial states.
auto standard(const Aut &aut)
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
bool is_costandard(const automaton &aut)
Bridge.
auto in(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions arriving to state s.
automaton standard(const automaton &aut)
Bridge.
typename expressionset_t::const_visitor super_t
#define VCSN_RAT_UNSUPPORTED(Type)
bool is_costandard(const Aut &a)
Whether a is costandard.
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
const expressionset_t & rs_
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
automaton_t operator()(const expression_t &v)
The standard automaton of v.
VCSN_RAT_VISIT(lweight, e)
VCSN_RAT_VISIT(rweight, e)
state_t_of< automaton_t > state_t
An inner node with multiple children.
bool is_standard(const Aut &a)
Whether a is standard.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
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 ...
std::set< state_t > states_t
The current set of final states.
value_impl< detail::expression_tag > expression
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
static constexpr const char * me()
Name of this algorithm, for error messages.
bool is_standard(const automaton &aut)
Bridge.
auto & as()
Extract wrapped typed automaton.
std::string to_string(identities i)
Wrapper around operator<<.
Aut transpose(const transpose_automaton< Aut > &aut)
The transpose of a transpose automaton is the original automaton.