25 template <
typename Aut>
43 template <
typename Ctx = context_t>
47 template <
typename Ctx = context_t>
55 using weight_t =
typename weightset_t::value_t;
60 using pair_t = std::pair<state_t, state_t>;
71 auto ws =
ctx.weightset();
74 for (
auto s :
input_->states())
75 pair_states_.emplace(std::make_pair(s, s), this->new_state());
79 for (
auto l :
input_->labelset()->genset())
86 auto end = std::end(
states);
87 for (
auto i1 = std::begin(
states); i1 != end; ++i1)
93 for (++i2; i2 != end; ++i2)
102 auto pstates = ps.first;
103 auto cstate = ps.second;
108 state_(std::get<0>(p.second).dst,
109 std::get<1>(p.second).dst),
113 for (
const auto& p: pair_states_)
114 origins_.emplace(p.second, p.first);
117 for (
auto s :
input_->states())
125 static symbol res(
"pair_automaton<"
132 o <<
"pair_automaton<";
133 input_->print_set(o, fmt);
137 state_t get_q0() const
139 require(!keep_initials_,
149 return p.first == p.second;
186 bool delimit =
false)
const
195 input_->print_state_name(i->second.first, o, fmt);
199 input_->print_state_name(i->second.second, o, fmt);
234 template <
typename Aut>
236 = std::shared_ptr<detail::pair_automaton_impl<Aut>>;
242 template <
typename Aut>
245 return make_shared_ptr<pair_automaton<Aut>>(aut, keep_initials);
253 template <
typename Aut,
typename>
257 const auto& a = aut->as<Aut>();
std::pair< T, T > make_ordered_pair(T e1, T e2)
The pair automaton is used by several algorithms for synchronizing words.
std::ostream & print_set(std::ostream &o, format fmt={}) const
auto new_state(Args &&...args) -> decltype(aut_-> new_state(std::forward< Args >(args)...))
static constexpr auto null_state(Args &&...args) -> decltype(element_type::null_state(std::forward< Args >(args)...))
std::unordered_map< pair_t, state_t > pair_states_
transition_t_of< automaton_t > transition_t
weightset_t_of< automaton_t > weightset_t
auto states(Args &&...args) const -> decltype(aut_-> states(std::forward< Args >(args)...))
const std::vector< state_t > & singletons() const
context_t_of< automaton_t > context_t
std::ostream & print_state_name(state_t ss, std::ostream &o, format fmt={}, bool delimit=false) const
transition_map_t transition_map_
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::shared_ptr< detail::pair_automaton_impl< Aut >> pair_automaton
Aggregate an automaton, and forward calls to it.
state_t state_(state_t s1, state_t s2)
The state in the result automaton that corresponds to (s1, s2).
std::map< state_t, pair_t > origins_t
zipped_maps< Dereference, Maps...> zip_maps(Maps &&...maps)
auto print_state(Args &&...args) const -> decltype(aut_-> print_state(std::forward< Args >(args)...))
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
bool state_has_name(state_t s) const
static dyn::context ctx(const driver &d)
Get the context of the driver.
bool is_singleton(state_t s) const
const origins_t & origins() const
A map from result state to tuple of original states.
std::shared_ptr< detail::automaton_base > automaton
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
auto add_transition(Args &&...args) -> decltype(aut_-> add_transition(std::forward< Args >(args)...))
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
typename weightset_t::value_t weight_t
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
std::vector< state_t > singletons_
automaton_t input_
Input automaton.
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
state_t_of< automaton_t > state_t
const std::unordered_map< pair_t, state_t > & get_map_pair() const
ATTRIBUTE_PURE bool has(const std::deque< T, Allocator > &s, const T &e)
Whether e is member of s.
pair_automaton_impl(const automaton_t &aut, bool keep_initials=false)
mutable_automaton< Ctx > fresh_automaton_t
When creating a copy of this automaton type.
const pair_t get_origin(state_t s) const
std::pair< state_t, state_t > pair_t
The semantics of the result states: ordered pair of input states.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton