27 template <
typename ExpSet>
29 :
public ExpSet::const_visitor
36 static_assert(std::is_same<weightset_t, b>::value,
37 "star_normal_form: requires Boolean weights");
39 using weight_t =
typename weightset_t::value_t;
41 using super_t =
typename ExpSet::const_visitor;
44 constexpr
static const char* me() {
return "star_normal_form"; }
47 enum operation_t {
dot, box };
58 return std::move(res_);
68 res_ = operation_ == box ? rs_.zero() : rs_.one();
73 res_ = rs_.atom(v.value());
79 v.head()->accept(*
this);
81 for (
auto c: v.tail())
84 res = rs_.add(res, res_);
86 res_ = std::move(res);
99 void visit(const tuple_t&,
std::true_type)
override
101 raise(me(),
": tuple is not supported");
106 if (operation_ == box)
113 void box_of(
const mul_t& v)
130 v.head()->accept(*
this);
132 for (
auto c: v.tail())
135 res = rs_.add(res, res_);
137 res_ = std::move(res);
142 void dot_of(
const mul_t& v)
144 v.head()->accept(*
this);
146 for (
auto c: v.tail())
149 res = rs_.mul(res, res_);
151 res_ = std::move(res);
156 if (operation_ ==
dot)
159 v.sub()->accept(*
this);
160 res_ = rs_.star(res_);
161 res_ = rs_.lweight(ws_.star(
constant_term(rs_, v.sub())), res_);
166 v.sub()->accept(*
this);
177 operation_t operation_ =
dot;
183 template <
typename ExpSet>
184 typename ExpSet::value_t
196 template <
typename ExpSet>
200 const auto& e = exp->as<ExpSet>();
expression star_normal_form(const expression &exp)
Bridge.
#define VCSN_RAT_UNSUPPORTED(Type)
auto(const std::vector< automaton > &as) -> automaton tuple_t
ExpSet::value_t star_normal_form(const ExpSet &rs, const typename ExpSet::value_t &e)
Star-normal form of an expression.
context_t_of< expressionset_t > context_t
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::ostream & dot(const Aut &aut, std::ostream &out=std::cout, format fmt={}, bool mathjax=false)
Print an automaton in Graphviz's Dot format.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
typename expressionset_t::value_t expression_t
#define VCSN_RAT_VISIT(Type, Val)
bool any_of(const Range &r, Predicate p)
weight_t_of< ExpSet > constant_term(const ExpSet &rs, const typename ExpSet::value_t &e)
The constant term of e.
weightset_t_of< context_t > weightset_t
value_impl< detail::expression_tag > expression