40 static const auto map = std::map<std::string, derived_term_algo>
44 {
"breaking_derivation", {
derivation,
true,
false}},
45 {
"breaking_expansion", {
expansion,
true,
false}},
47 {
"derivation,breaking", {
derivation,
true,
false}},
48 {
"derivation,deterministic",{
derivation,
false,
true}},
49 {
"derivation_breaking", {
derivation,
true,
false}},
51 {
"expansion,breaking", {
expansion,
true,
false}},
52 {
"expansion,deterministic", {
expansion,
false,
true}},
53 {
"expansion_breaking", {
expansion,
true,
false}},
55 *
this =
getargs(
"derived-term algorithm",
map, algo);
101 template <
typename ExpSet>
116 ,
res_{make_shared_ptr<automaton_t>(
rs_)}
134 const auto& ls =
rs_.labelset()->genset();
135 while (!
res_->todo_.empty())
146 auto m =
ps_.determinize(p);
150 for (
const auto& m: p)
165 while (!
res_->todo_.empty())
169 auto s =
res_->state(src);
175 for (
const auto& p:
expansion.polynomials)
177 for (
const auto& m1: p.second)
183 auto m =
ps_.determinize(p.second);
187 for (
const auto& m: p.second)
197 for (
const auto& p:
split(
rs_, expression))
200 res_->set_initial(expression,
ws_.one());
222 template <
typename ExpSet>
227 const typename ExpSet::value_t&
r,
228 const std::string& algo =
"auto")
240 template <
typename ExpSet>
243 expression_automaton<mutable_automaton<typename ExpSet::context_t>>>
245 const typename ExpSet::value_t&
r,
246 const std::string& algo =
"auto")
250 "derived_term: cannot use derivation on non-free labelsets");
255 return dt.via_expansion(r);
263 template <
typename ExpSet,
typename String>
267 const auto& e = exp->as<ExpSet>();
268 const auto&
rs = e.expressionset();
269 const auto&
r = e.expression();
bool breaking
Whether to break sums.
state_t_of< automaton_t > state_t
void init_(const expression_t &expression)
std::shared_ptr< detail::expression_automaton_impl< Aut >> expression_automaton
An expression automaton as a shared pointer.
automaton_t via_derivation(const expression_t &expression)
Compute the derived-term automaton via derivation.
auto label_of(const welement< Label, Weight > &m) -> decltype(m.label())
auto map(const std::tuple< Ts...> &ts, Fun f) -> decltype(map_tuple_(f, ts, make_index_sequence< sizeof...(Ts)>()))
Map a function on a tuple, return tuple of the results.
weightset_t ws_
Its weightset.
C::mapped_type getargs(const std::string &kind, const C &map, const std::string &key)
Find a correspondance in a 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
Compute the derived-term automaton from an expression.
vcsn::enable_if_t< labelset_t_of< ExpSet >::is_free(), expression_automaton< mutable_automaton< typename ExpSet::context_t > > > derived_term(const ExpSet &rs, const typename ExpSet::value_t &r, const std::string &algo="auto")
The derived-term automaton, for free labelsets.
typename std::enable_if< Cond, T >::type enable_if_t
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< const node< Context >> expression
rat::expression_polynomial_t< ExpSet > derivation(const ExpSet &rs, const typename ExpSet::value_t &e, label_t_of< ExpSet > a, bool breaking=false)
Derive an expression wrt to a letter.
Functor to compute the expansion of an expression.
Provide a variadic mul on top of a binary mul(), and one().
expression_polynomialset_t< ExpSet > make_expression_polynomialset(const ExpSet &rs)
From a ExpSet to its polynomialset.
std::shared_ptr< detail::automaton_base > automaton
std::shared_ptr< const detail::expansion_base > expansion
rat::expression_polynomial_t< ExpSet > split(const ExpSet &rs, const typename ExpSet::value_t &e)
Split an expression.
auto weight_of(const welement< Label, Weight > &m) -> decltype(m.weight())
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.
derived_term_algo(algo_t a, bool b, bool d)
weight_t_of< ExpSet > constant_term(const ExpSet &rs, const typename ExpSet::value_t &e)
The constant term of e.
Specify a variety of derived-term construction.
derived_term_algo(const std::string &algo)
From algo name to algo.
automaton_t operator()(const expression_t &expression)
Compute the derived-term automaton.
derived_termer(const expressionset_t &rs, derived_term_algo algo)
automaton_t res_
The resulting automaton.
context_t_of< expressionset_t > context_t
expressionset_t rs_
The expression's set.
weightset_t_of< context_t > weightset_t
expression_automaton< mutable_automaton< context_t >> automaton_t
std::shared_ptr< detail::expression_base > expression
bool determinize
Whether to determinize the expansions and produce a deterministic automaton, at the expense of possib...
rat::expansionset< ExpSet >::value_t to_expansion(const ExpSet &rs, const typename ExpSet::value_t &e)
First order expansion.
algo_t algo
Core algorithm.
typename expressionset_t::value_t expression_t
derived_term_algo algo_
How derived terms are computed.
automaton_t via_expansion(const expression_t &expression)
Compute the derived-term automaton via expansion.