6 template <Automaton Aut>
8 to_automaton(
const LabelSet& ls,
const typename LabelSet::word_t& w)
15 template <Automaton Aut>
23 auto res = make_fresh_automaton<Aut>(aut);
26 if (s != aut->null_state())
28 require(aut->has_state(s),
"not a valid state: ", s);
29 s = copy.state_map().at(s);
44 template <Automaton Aut,
typename Int>
48 const auto& a = aut->
as<Aut>();
50 auto s = 0 <= state ? state_t(state + 2) : a->null_state();
64 typename ExpSet::value_t
71 return a->get_initial_weight(a->post());
73 catch (
const std::runtime_error& e)
75 raise(e,
" while making expression");
89 typename ExpSet::value_t
94 auto a =
lift(aut, ids);
100 raise(
"next_state: invalid algorithm: best");
104 auto profiler = delgado_t(a);
105 return to_expression<decltype(a), delgado_t, ExpSet>(a, profiler);
110 auto profiler = delgado_t(a,
true);
111 return to_expression<decltype(a), delgado_t, ExpSet>(a, profiler);
116 auto profiler = naive_t(a);
117 return to_expression<decltype(a), naive_t, ExpSet>(a, profiler);
125 typename ExpSet::value_t
131 typename ExpSet::value_t
best;
132 auto best_size = std::numeric_limits<size_t>::max();
137 auto r = to_expression_heuristic<Aut, ExpSet>(aut,
ids, a);
138 auto s = rat::size<ExpSet>(
r);
149 return to_expression_heuristic<Aut, ExpSet>(aut,
ids, algo);
155 typename ExpSet::value_t
157 const std::string& algo)
170 return to_expression<Aut, ExpSet>(a,
ids, map[algo]);
182 template <Automaton Aut,
typename Identities,
typename String>
185 const std::string& algo)
187 const auto& a = aut->
as<Aut>();
190 auto rs = expressionset_t{a->context(), ids};
206 template <
typename Context,
typename Identities,
typename Label>
211 const auto& c = ctx->
as<Context>();
212 const auto& l = lbl->
as<Label>();
214 return {rs, rs.atom(l.value())};
226 template <
typename ExpSet>
229 std::false_type, std::true_type)
230 ->
typename ExpSet::value_t
232 raise(
"letter_class: not implemented (is_expressionset)");
235 template <
typename ExpSet>
238 std::false_type, std::false_type)
239 ->
typename ExpSet::value_t
241 auto ls = *rs.labelset();
243 using labelset_t = decltype(ls);
244 using letter_t =
typename labelset_t::letter_t;
246 auto ccs = std::set<std::pair<letter_t, letter_t>>{};
247 for (
const auto& cc: chars)
249 std::istringstream i1{cc.first};
250 std::istringstream i2{cc.second};
251 letter_t l1 = ls.get_letter(i1,
false);
252 letter_t l2 = ls.get_letter(i2,
false);
255 return rs.letter_class(ccs, accept);
258 template <
typename ExpSet>
261 std::true_type, std::false_type)
262 ->
typename ExpSet::value_t
277 template <
typename ExpressionSet>
278 typename ExpressionSet::value_t
283 using is_one_t = std::is_same<labelset_t, vcsn::oneset>;
286 is_one_t{}, is_expset_t{});
294 template <
typename Context,
typename Identities,
295 typename Letters,
typename Bool>
300 const auto& c = ctx->
as<Context>();
std::shared_ptr< detail::mutable_automaton_impl< Context > > mutable_automaton
weightset_mixin< detail::r_impl > r
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
auto & as()
Extract wrapped typed value.
Aut & to_automaton(const LabelSet &ls, const typename LabelSet::word_t &w) -> mutable_automaton<>
In place removal of state s from automaton res.
state_eliminator< Aut, Profiler > make_state_eliminator(Aut &a, Profiler &profiler)
ExpressionSet::value_t to_expression(const ExpressionSet &rs, const letter_class_t &letters, bool accept=true)
An expression matching one letter in a letter class.
An expressionset can implement several different sets of identities on expressions.
typename detail::context_t_of_impl< base_t< ValueSet > >::type context_t_of
Provide a variadic mul on top of a binary mul(), and one().
auto letter_class_impl(const ExpSet &, const letter_class_t &, bool, std::false_type, std::true_type) -> typename ExpSet::value_t
Case where labelset is an expressionset.
Aut & eliminate_state_here(Aut &res, state_t_of< Aut > s=Aut::element_type::null_state())
In place removal of state s from automaton res.
std::integral_constant< bool, B > bool_constant
auto letter_class_impl(const ExpSet &rs, const letter_class_t &, bool, std::true_type, std::false_type) -> typename ExpSet::value_t
Case where labelset is oneset.
auto copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans) -> decltype(keep_state(input->null_state()), keep_trans(input->null_transition()), make_fresh_automaton< AutIn, AutOut >(input))
A copy of input keeping only its states that are accepted by keep_state, and transitions accepted by ...
expression to_expression_class(const context &ctx, identities ids, const letter_class_t &letters, bool accept)
Bridge (to_expression).
Template-less root for contexts.
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
automaton lift(const automaton &aut, const std::vector< unsigned > &tapes={}, identities ids={})
Lift some tapes of the transducer, or turn an automaton into a spontaneous automaton.
auto & as()
Downcast to the exact type.
expression to_expression_label(const context &ctx, identities ids, const label &lbl)
Bridge (to_expression).
std::set< std::pair< std::string, std::string > > letter_class_t
A set of letter ranges.
detail::copier< AutIn, AutOut > make_copier(const AutIn &in, AutOut &out, bool safe=true)
Build an automaton copier.
auto & as()
Extract wrapped typed automaton.
auto make_expressionset(const context< LabelSet, WeightSet > &ctx, rat::identities ids={}) -> expressionset< context< LabelSet, WeightSet >>
Shorthand to expressionset constructor.
auto eliminate_state(const Aut &aut, state_t_of< Aut > s=Aut::element_type::null_state()) -> fresh_automaton_t_of< Aut >
A copy of automaton res without the state s.
to_expression_heuristic_t
A mapping from strings to Values.
Compute a state profile for state-elimination based on connectivity.
automaton eliminate_state(const automaton &aut, int state)
Bridge.
value_impl< detail::expression_tag > expression
static identities ids(const driver &d)
Get the identities of the driver.
ExpSet::value_t to_expression_heuristic(const Aut &aut, vcsn::rat::identities ids, to_expression_heuristic_t algo)
void require(Bool b, Args &&... args)
If b is not verified, raise an error with args as message.
Compute a state profile for state-elimination based on the Delgado-Morais heuristic.
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
#define BUILTIN_UNREACHABLE()
expression to_expression(const automaton &aut, identities ids, const std::string &algo)
Bridge.