4 #include <unordered_map>
23 template <
typename Aut>
34 using weight_t =
typename weightset_t::value_t;
40 using pair_t = std::pair<state_t, state_t>;
50 auto ctx =
input_->context();
51 auto ws = ctx.weightset();
56 for (
auto l :
input_->labelset()->genset())
60 for (
auto s :
input_->states())
61 pair_states_.emplace(std::make_pair(s, s), this->new_state());
66 auto end = std::end(
states);
67 for (
auto i1 = std::begin(
states); i1 != end; ++i1)
73 for (++i2; i2 != end; ++i2)
82 auto pstates = ps.first;
83 auto cstate = ps.second;
88 state_(std::get<0>(p.second).dst,
89 std::get<1>(p.second).dst),
93 for (
const auto& p: pair_states_)
97 for (
auto s :
input_->states())
106 "can't get_q0() on a pairer that keeps origins");
115 return p.first == p.second;
131 std::string
vname(
bool full =
true)
const
133 return "pair_automaton<" +
input_->vname(full) +
">";
163 const std::string& fmt =
"text")
const
170 input_->print_state_name(i->second.first, o, fmt);
172 input_->print_state_name(i->second.second, o, fmt);
205 template <
typename Aut>
207 = std::shared_ptr<detail::pair_automaton_impl<Aut>>;
213 template <
typename Aut>
216 auto res = make_shared_ptr<pair_automaton<Aut>>(aut, keep_initials);
225 template <
typename Aut,
typename>
229 const auto& a = aut->as<Aut>();
typename weightset_t::value_t weight_t
bool state_has_name(state_t s) const
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
const origins_t & origins() const
A map from result state to tuple of original states.
std::vector< state_t > singletons_
auto states(Args &&...args) const -> decltype(aut_-> states(std::forward< Args >(args)...))
state_t_of< automaton_t > state_t
const std::unordered_map< pair_t, state_t > & get_map_pair() const
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
const pair_t get_origin(state_t s) const
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
automaton_t input_
Input automaton.
std::pair< state_t, state_t > pair_t
The semantics of the result states: ordered pair of input states.
static std::string sname()
auto new_state(Args &&...args) -> decltype(aut_-> new_state(std::forward< Args >(args)...))
std::string vname(bool full=true) const
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
pair_automaton_impl(const automaton_t &aut, bool keep_initials=false)
Aggregate an automaton, and forward calls to it.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
weightset_t_of< automaton_t > weightset_t
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
context_t_of< automaton_t > context_t
automaton pair(const automaton &aut, bool keep_initials=false)
Bridge.
transition_map_t transition_map_
The pair automaton is used by several algorithms for synchronizing words.
std::unordered_map< pair_t, state_t > pair_states_
transition_t_of< automaton_t > transition_t
std::shared_ptr< detail::pair_automaton_impl< Aut >> pair_automaton
zipped_maps< Dereference, Maps...> zip_maps(Maps &&...maps)
static constexpr auto pre(Args &&...args) -> decltype(automaton_t::element_type::pre(std::forward< Args >(args)...))
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
bool is_singleton(state_t s) const
std::ostream & print_state_name(state_t ss, std::ostream &o, const std::string &fmt="text") const
auto add_transition(Args &&...args) -> decltype(aut_-> add_transition(std::forward< Args >(args)...))
std::pair< T, T > make_ordered_pair(T e1, T e2)
auto print_state(Args &&...args) const -> decltype(aut_-> print_state(std::forward< Args >(args)...))
mutable_automaton< context_t_of< Aut >> automaton_nocv_t
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
static constexpr auto post(Args &&...args) -> decltype(automaton_t::element_type::post(std::forward< Args >(args)...))
state_t state_(state_t s1, state_t s2)
The state in the result automaton that corresponds to (s1, s2).
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
const std::vector< state_t > & singletons()
std::map< state_t, pair_t > origins_t