17 #ifndef AWALI_ALGOS_STAR_NORMAL_FORM_HH
18 # define AWALI_ALGOS_STAR_NORMAL_FORM_HH
25 namespace awali {
namespace sttc {
40 template <
typename RatExpSet>
42 :
public RatExpSet::const_visitor
46 using ratexp_t =
typename ratexpset_t::value_t;
49 using weight_t =
typename weightset_t::value_t;
53 constexpr
static const char*
me() {
return "star_normal_form"; }
67 return std::move(res_);
77 res_ = operation_ ==
box ? rs_.zero() : rs_.one();
82 res_ = rs_.atom(v.value());
88 v.head()->accept(*
this);
90 for (
auto c: v.tail())
93 res = rs_.add(res, res_);
95 res_ = std::move(res);
106 if (operation_ ==
box)
115 if (std::any_of(std::begin(v), std::end(v),
129 v.head()->accept(*
this);
131 for (
auto c: v.tail())
134 res = rs_.add(res, res_);
136 res_ = std::move(res);
143 v.head()->accept(*
this);
145 for (
auto c: v.tail())
148 res = rs_.mul(res, res_);
150 res_ = std::move(res);
155 if (operation_ ==
dot)
158 v.sub()->accept(*
this);
159 res_ = rs_.star(res_);
160 res_ = rs_.lmul(ws_.star(
constant_term(rs_, v.sub())), res_);
165 v.sub()->accept(*
this);
171 v.sub()->accept(*
this);
172 res_ = rs_.lmul(v.weight(), std::move(res_));
177 v.sub()->accept(*
this);
178 res_ = rs_.rmul(std::move(res_), v.weight());
194 template <
typename RatExpSet>
195 typename RatExpSet::value_t
The semiring of complex numbers.
Definition: c.hh:44
The semiring of Natural numbers.
Definition: n.hh:34
Definition: ratexp.hh:280
Definition: ratexp.hh:262
Definition: ratexp.hh:176
An inner node with multiple children.
Definition: ratexp.hh:115
An inner node implementing a weight.
Definition: ratexp.hh:208
typename internal::context_t_of_impl< internal::base_t< ValueSet > >::type context_t_of
Helper to retrieve the type of the context of a value set.
Definition: traits.hh:66
weight_t_of< RatExpSet > constant_term(const RatExpSet &rs, const typename RatExpSet::ratexp_t &e)
Definition: constant_term.hh:155
RatExpSet::value_t star_normal_form(const RatExpSet &rs, const typename RatExpSet::value_t &e)
Star_Normal_Forming a typed ratexp shared_ptr.
Definition: star_normal_form.hh:196
typename internal::weightset_t_of_impl< internal::base_t< ValueSet > >::type weightset_t_of
Helper to retrieve the type of the weightset of a value set.
Definition: traits.hh:86
Main namespace of Awali.
Definition: ato.hh:22
#define AWALI_RAT_UNSUPPORTED(Type)
Definition: visitor.hh:73