26 template <Automaton Aut>
45 template <
typename Ctx = context_t>
49 template <
typename Ctx = context_t>
57 using weight_t =
typename weightset_t::value_t;
75 auto ws =
ctx.weightset();
78 for (
auto s :
input_->states())
79 pair_states_.emplace(std::make_pair(s, s), this->new_state());
83 for (
auto l :
input_->labelset()->generators())
90 auto end = std::end(
states);
91 for (
auto i1 = std::begin(
states); i1 != end; ++i1)
97 for (++i2; i2 != end; ++i2)
106 auto pstates = ps.first;
107 auto cstate = ps.second;
112 state_(std::get<0>(p.second).dst,
113 std::get<1>(p.second).dst),
117 for (
const auto& p: pair_states_)
118 origins_.emplace(p.second, p.first);
121 for (
auto s :
input_->states())
129 static auto res =
symbol{
"pair_automaton<"
136 o <<
"pair_automaton<";
137 input_->print_set(o, fmt);
141 state_t get_q0() const
143 require(!keep_initials_,
153 return p.first == p.second;
166 = std::unordered_map<state_name_t, state_t>;
193 bool delimit =
false)
const
202 input_->print_state_name(i->second.first, o, fmt);
206 input_->print_state_name(i->second.second, o, fmt);
243 template <Automaton Aut>
245 = std::shared_ptr<detail::pair_automaton_impl<Aut>>;
251 template <Automaton Aut>
254 return make_shared_ptr<pair_automaton<Aut>>(aut, keep_initials);
262 template <Automaton Aut,
typename>
266 const auto& a = aut->
as<Aut>();
auto new_state(Args &&...args) -> decltype(aut_-> new_state(std::forward< Args >(args)...))
auto make_unordered_pair(T &&e1, T &&e2)
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
bool state_has_name(state_t s) const
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
state_t_of< automaton_t > state_t
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
transition_map_t transition_map_
std::pair< in_state_t, in_state_t > state_name_t
The semantics of the result states: unordered pair of input states.
std::ostream & print_state_name(state_t ss, std::ostream &o, format fmt={}, bool delimit=false) const
std::map< state_t, state_name_t > origins_t
State index -> pair of input automaton states.
std::ostream & print_set(std::ostream &o, format fmt={}) const
Aggregate an automaton, and forward calls to it.
automaton pair(const automaton &aut, bool keep_initials)
Bridge.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
std::unordered_map< state_name_t, state_t > pair_states_t
transition_t_of< automaton_t > in_transition_t
context_t_of< automaton_t > context_t
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
typename super_t::state_t state_t
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
weightset_t_of< automaton_t > weightset_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
state_t state_(in_state_t s1, in_state_t s2)
The state in the result automaton that corresponds to (s1, s2).
origins_t origins_
From state index to state name.
static constexpr auto null_state(Args &&...args) -> decltype(element_type::null_state(std::forward< Args >(args)...))
const state_name_t & get_origin(state_t s) const
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
The pair automaton is used by several algorithms for synchronizing words.
An input/output format for valuesets.
automaton_t input_
Input automaton.
const origins_t & origins() const
A map from result state to tuple of original states.
auto print_state(Args &&...args) const -> decltype(aut_-> print_state(std::forward< Args >(args)...))
const pair_states_t & get_map_pair() const
const singletons_t & singletons() const
pair_automaton_impl(const automaton_t &aut, bool keep_initials=false)
auto add_transition(Args &&...args) -> decltype(aut_-> add_transition(std::forward< Args >(args)...))
std::shared_ptr< detail::pair_automaton_impl< Aut >> pair_automaton
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
auto & as()
Extract wrapped typed automaton.
pair_states_t pair_states_
From state name to state index.
zipped_maps< Dereference, Maps... > zip_maps(Maps &&...maps)
std::vector< state_t > singletons_t
bool is_singleton(state_t s) const
state_t_of< automaton_t > in_state_t
auto states(Args &&...args) const -> decltype(aut_-> states(std::forward< Args >(args)...))
mutable_automaton< Ctx > fresh_automaton_t
When creating a copy of this automaton type.
typename weightset_t::value_t weight_t