19 template <
typename Aut>
28 template <
typename Ctx = context_t>
64 static symbol res(
"partition_automaton<"
71 o <<
"partition_automaton<";
76 bool state_has_name(state_t) const
82 print_state_name(state_t s, std::ostream& o,
84 bool delimit = false) const
86 const auto& set = origins_.at(s);
87 const char* separator = "";
93 input_->print_state_name(s, o, fmt, true);
102 const origins_t& origins() const
108 const automaton_t& input_automaton() const
113 using super_t::new_state;
117 state_t new_state(const state_name_t& set)
119 state_t res = new_state();
124 state_t new_state(const std::vector<state_t>& v)
126 return new_state(state_name_t{begin(v), end(v)});
131 const automaton_t input_;
134 }; // partition_automaton_impl
135 } // namespace detail
138 template <typename Aut>
139 using partition_automaton
140 = std::shared_ptr<detail::partition_automaton_impl<Aut>>;
147 template <typename Aut>
148 struct origins_t_of_impl;
152 template <typename Aut>
153 using origins_t_of = typename origins_t_of_impl<Aut>::type;
155 template <typename Aut>
156 struct origins_t_of_impl<partition_automaton<Aut>>
158 using type = typename partition_automaton<Aut>::element_type::origins_t;
161 template <typename Aut>
162 struct origins_t_of_impl<transpose_automaton<Aut>>
164 using type = origins_t_of<Aut>;
177 template <typename Aut>
178 struct partition_automaton_t_impl
180 using type = partition_automaton<Aut>;
183 template <typename Aut>
184 struct partition_automaton_t_impl<partition_automaton<Aut>>
185 : partition_automaton_t_impl<Aut>
188 template <typename Aut>
189 struct partition_automaton_t_impl<transpose_automaton<Aut>>
192 = transpose_automaton<typename partition_automaton_t_impl<Aut>::type>;
197 template <typename Aut>
198 using partition_automaton_t
199 = typename detail::partition_automaton_t_impl<Aut>::type;
207 template <typename Aut>
209 make_partition_automaton(const fresh_automaton_t_of<Aut>& res,
211 const typename detail::partition_automaton_impl<Aut>::origins_t origins)
212 -> partition_automaton_t<Aut>
214 return make_shared_ptr<partition_automaton<Aut>>(res, input, origins);
223 template <typename Aut>
225 make_partition_automaton(const fresh_automaton_t_of<Aut>& res,
226 const partition_automaton<Aut>& input,
227 const typename detail::partition_automaton_impl<Aut>::origins_t origins)
228 -> partition_automaton_t<Aut>
230 const auto& input_origins = input->origins();
232 = typename detail::partition_automaton_impl<Aut>::origins_t;
233 auto new_origins = origins_t{};
235 for (const auto& p: origins)
236 for (auto s: p.second)
238 .insert(begin(input_origins.at(s)), end(input_origins.at(s)));
240 return make_partition_automaton(res, input->input_automaton(), new_origins);
249 template <typename Aut>
251 make_partition_automaton(const fresh_automaton_t_of<transpose_automaton<Aut>>& res,
252 const transpose_automaton<Aut>& input,
253 const typename detail::partition_automaton_impl<Aut>::origins_t origins)
254 -> transpose_automaton<partition_automaton_t<Aut>>
256 return transpose(make_partition_automaton(res->naked_automaton(),
257 input->naked_automaton(),
const origins_t & origins() const
Accessor to the states' origins.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
static constexpr auto pre(Args &&...args) -> decltype(element_type::pre(std::forward< Args >(args)...))
origins_t origins_
A map from each state to the origin state set it stands for.
static constexpr auto post(Args &&...args) -> decltype(element_type::post(std::forward< Args >(args)...))
partition_automaton_impl(const automaton_t &input)
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
Aggregate an automaton, and forward calls to it.
const automaton_t input_
The input automaton.
label_t_of< automaton_t > label_t
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
partition_automaton_impl(const fresh_automaton_t<> &res, const automaton_t &input, const origins_t &origins)
Aut automaton_t
Input automaton type.
fresh_automaton_t_of< automaton_t, Ctx > fresh_automaton_t
Generated automaton type.
state_t_of< automaton_t > state_t
The underlying state type.
std::set< state_t > state_name_t
The state names: a set of the original automaton states.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
std::ostream & print_set(std::ostream &o, format fmt={}) const
context_t_of< automaton_t > context_t
std::map< state_t, state_name_t > origins_t
A map from each state to the origin state set it stands for.
static symbol sname()
Static name.
An automaton wrapper whose states form a partition of the state set of another automaton.