6 #include <boost/bimap.hpp>
7 #include <boost/bimap/unordered_set_of.hpp>
9 #include <vcsn/algos/fwd.hh>
27 template <Automaton Aut>
41 template <std::size_t... I>
51 using delay_t = std::array<size_t, number_of_tapes>;
58 boost::bimap<boost::bimaps::unordered_set_of<state_name_t>,
59 boost::bimaps::unordered_set_of<state_t>>;
60 using map_t =
typename bimap_t::left_map;
77 static auto res =
symbol{
"delay_automaton<"
84 o <<
"delay_automaton<";
91 state_t state(const state_name_t& r)
93 if (r.first == aut_->post())
96 auto i = map_().find(r);
97 if (i == std::end(map_()))
99 res = super_t::new_state();
100 // Emplace is not available because of the internals of bimap
101 map_().insert({r, res});
109 using super_t::new_transition;
112 new_transition(const state_name_t& src, const state_name_t& dst,
113 const label_t& l, const weight_t& w)
115 super_t::new_transition(state(src), state(dst), l, w);
118 bool state_has_name(state_t s) const
120 return has(origins(), s);
124 print_state_name(state_t s, std::ostream& o,
128 auto ns = origins().at(s);
129 aut_->print_state_name(ns.first, o, fmt, true);
132 for (int i = 0; i < a.size() - 1; i++)
135 o << a[a.size() - 1];
140 delay_t delay_of(state_t s)
142 auto i = origins().find(s);
143 if (i == std::end(origins()))
146 return i->second.second;
162 std::stack<state_name_t, std::vector<state_name_t>> todo_;
169 template <Automaton Aut>
171 make_delay_automaton(const Aut& aut)
173 auto s = synchronize_checker<Aut>{aut};
174 return s.make_delay_automaton();
179 /*------------------.
181 `------------------*/
187 template <Automaton Aut>
189 make_delay_automaton(const Aut& aut)
190 -> decltype(detail::make_delay_automaton(aut))
192 return detail::make_delay_automaton(aut);
200 template <Automaton Aut>
201 automaton delay_automaton(const automaton& aut)
203 return make_automaton(vcsn::make_delay_automaton(aut->as<Aut>()));
typename labelset_t::template valueset_t< I > tape_labelset_t
static symbol sname()
Static name.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
static constexpr auto pre(Args &&...args) -> decltype(element_type::pre(std::forward< Args >(args)...))
static constexpr auto post(Args &&...args) -> decltype(element_type::post(std::forward< Args >(args)...))
auto print_set(Args &&...args) const -> decltype(aut_-> print_set(std::forward< Args >(args)...))
typename bimap_t::right_map origins_t
label_t_of< super_t > label_t
std::pair< state_t, delay_t > state_name_t
State + delay.
typename bimap_t::left_map map_t
labelset_t_of< super_t > labelset_t
context_t_of< super_t > context_t
boost::bimap< boost::bimaps::unordered_set_of< state_name_t >, boost::bimaps::unordered_set_of< state_t >> bimap_t
Symbolic states to state handlers.
static constexpr size_t number_of_tapes
Aggregate an automaton, and forward calls to it.
state_t_of< super_t > state_t
std::array< size_t, number_of_tapes > delay_t
The delay associated with each state.
delay_automaton_impl(const automaton_t &aut)
std::ostream & print_set(std::ostream &o, format fmt={}) const
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
An automaton whose states may be qualified by delays and/or prefixes.
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
automaton_t aut_
The original automaton.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
static constexpr index_t indices
weight_t_of< super_t > weight_t
An input/output format for valuesets.