25 template <Automaton Aut>
44 template <
typename Ctx = context_t>
48 template <
typename Ctx = context_t>
56 using weight_t =
typename weightset_t::value_t;
74 auto ws =
ctx.weightset();
77 for (
auto s :
input_->states())
78 pair_states_.emplace(std::make_pair(s, s), this->new_state());
82 for (
auto l :
input_->labelset()->generators())
89 auto end = std::end(
states);
90 for (
auto i1 = std::begin(
states); i1 != end; ++i1)
96 for (++i2; i2 != end; ++i2)
105 auto pstates = ps.first;
106 auto cstate = ps.second;
111 state_(std::get<0>(p.second).dst,
112 std::get<1>(p.second).dst),
116 for (
const auto& p: pair_states_)
117 origins_.emplace(p.second, p.first);
120 for (
auto s :
input_->states())
128 static auto res =
symbol{
"pair_automaton<"
135 o <<
"pair_automaton<";
136 input_->print_set(o, fmt);
140 state_t get_q0() const
142 require(!keep_initials_,
152 return p.first == p.second;
165 = std::unordered_map<state_name_t, state_t>;
192 bool delimit =
false)
const
201 input_->print_state_name(i->second.first, o, fmt);
205 input_->print_state_name(i->second.second, o, fmt);
242 template <Automaton Aut>
244 = std::shared_ptr<detail::pair_automaton_impl<Aut>>;
250 template <Automaton Aut>
253 return make_shared_ptr<pair_automaton<Aut>>(aut, keep_initials);
261 template <Automaton Aut,
typename>
265 const auto& a = aut->as<Aut>();
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
auto new_state(Args &&...args) -> decltype(aut_-> new_state(std::forward< Args >(args)...))
bool is_singleton(state_t s) const
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
const state_name_t & get_origin(state_t s) const
std::ostream & print_state_name(state_t ss, std::ostream &o, format fmt={}, bool delimit=false) const
state_t_of< automaton_t > state_t
std::map< state_t, state_name_t > origins_t
State index -> pair of input automaton states.
typename weightset_t::value_t weight_t
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
std::shared_ptr< detail::pair_automaton_impl< Aut >> pair_automaton
transition_map_t transition_map_
std::ostream & print_set(std::ostream &o, format fmt={}) const
automaton_t input_
Input automaton.
bool state_has_name(state_t s) const
std::unordered_map< state_name_t, state_t > pair_states_t
state_t state_(in_state_t s1, in_state_t s2)
The state in the result automaton that corresponds to (s1, s2).
An input/output format for valuesets.
mutable_automaton< Ctx > fresh_automaton_t
When creating a copy of this automaton type.
origins_t origins_
From state index to state name.
typename super_t::state_t state_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
pair_states_t pair_states_
From state name to state index.
auto print_state(Args &&...args) const -> decltype(aut_-> print_state(std::forward< Args >(args)...))
const origins_t & origins() const
A map from result state to tuple of original states.
pair_automaton_impl(const automaton_t &aut, bool keep_initials=false)
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
Aggregate an automaton, and forward calls to it.
static constexpr auto null_state(Args &&...args) -> decltype(element_type::null_state(std::forward< Args >(args)...))
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
std::shared_ptr< detail::automaton_base > automaton
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
weightset_t_of< automaton_t > weightset_t
static dyn::context ctx(const driver &d)
Get the context of the driver.
auto add_transition(Args &&...args) -> decltype(aut_-> add_transition(std::forward< Args >(args)...))
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
state_t_of< automaton_t > in_state_t
const singletons_t & singletons() const
std::pair< in_state_t, in_state_t > state_name_t
The semantics of the result states: unordered pair of input states.
std::vector< state_t > singletons_t
auto make_unordered_pair(T &&e1, T &&e2)
context_t_of< automaton_t > context_t
transition_t_of< automaton_t > in_transition_t
zipped_maps< Dereference, Maps... > zip_maps(Maps &&...maps)
auto states(Args &&...args) const -> decltype(aut_-> states(std::forward< Args >(args)...))
const pair_states_t & get_map_pair() const
The pair automaton is used by several algorithms for synchronizing words.