17 #ifndef AWALI_CORE_RAT_RATEXPSET_HH
18 # define AWALI_CORE_RAT_RATEXPSET_HH
44 template <
typename Context>
56 using weight_t =
typename weightset_t::value_t;
64 # define DEFINE(Type) \
65 using Type ## _t = ::awali::sttc::rat::Type<label_t, weight_t>
83 template <exp::type_t Type>
85 template <exp::type_t Type>
87 using ratexp_t = std::shared_ptr<const node_t>;
103 static std::string
sname();
105 std::string
vname(
bool full =
true)
const;
118 bool open(
bool o)
const;
135 return atom(labelset_t::special());
184 template <
typename GenSet>
191 template <
typename Ctx2>
197 std::set<value_t>
convs(std::istream&)
const
199 raise(
vname(),
": ranges not implemented");
203 const std::string&
format =
"text")
const;
213 case identities_t::trivial:
214 case identities_t::associativity:
217 case identities_t::series:
227 else if (
format ==
"text") {
230 case identities_t::trivial:
231 case identities_t::associativity:
234 case identities_t::series:
245 raise(
"invalid format: ",
format);
251 template<
unsigned version = version::fsm_json>
255 version::check_fsmjson<version>();
259 =
context().template to_json<version>()->object();
263 case identities_t::trivial:
264 case identities_t::associativity:
265 res->
push_back(
"Rational Expression",obj);
267 case identities_t::series:
279 template<
unsigned version = version::fsm_json>
295 template<
unsigned version = version::fsm_json>
315 parse(
const std::string & s,
size_t& p)
const {
361 template <
typename... Args>
367 void require_weightset_commutativity()
const;
370 typename ratexps_t::iterator i)
const;
380 bool is_unweighted_nonsum_(
value_t v)
const;
381 bool is_nonsum_(
value_t v)
const;
397 template <exp::type_t Type>
404 template <exp::type_t Type>
413 template <
typename LabelSet_,
typename... Args>
414 value_t letter_class_(
const Args&&... chars, std::true_type)
const;
417 template <
typename LabelSet_>
419 letter_class_(std::set<
std::pair<
typename LabelSet_::letter_t,
420 typename LabelSet_::letter_t>> chars,
422 std::false_type)
const;
431 template <
typename Ctx1,
typename Ctx2>
437 return {
meet(a.context(),
b.context()),
438 meet(a.identities(),
b.identities())};
442 template <
typename Ctx1,
typename Ctx2>
448 return {
join(a.context(),
b.context()),
449 join(a.identities(),
b.identities())};
453 template <
typename GenSet1,
typename Ctx2>
462 return {ctx_t{
join(a, *
b.labelset()), *
b.weightset()},
466 template <
typename Ctx1,
typename GenSet2>
470 -> decltype(
join(
b, a))
477 template <
typename Context>
485 template <
typename Context>
494 template <
typename Context>
503 return {ctx_t{*rs.labelset(),
join(*rs.weightset(), ws)},
507 template <
typename Context>
517 template <
typename Context>
526 return {ctx_t{*rs.labelset(),
join(*rs.weightset(), ws)},
530 template <
typename Context>
540 template <
typename Context>
549 return {ctx_t{*rs.labelset(),
join(*rs.weightset(), ws)},
553 template <
typename Context>
object_t * push_back(std::string key, node_t *node)
Definition: qfraction.hh:26
The Boolean semring.
Definition: b.hh:38
bool value_t
Definition: b.hh:56
carries the algebraic settings of automata
Definition: context.hh:40
Implementation of labels are letters.
Definition: letterset.hh:43
letter_t value_t
Definition: letterset.hh:53
The semiring of rational numbers.
Definition: q.hh:42
The semiring of floating Numbers.
Definition: r.hh:35
double value_t
Definition: r.hh:56
Definition: ratexp.hh:280
Definition: visitor.hh:30
Definition: ratexp.hh:262
rat::type_t type_t
The possible types of ratexps.
Definition: ratexp.hh:43
An inner node.
Definition: ratexp.hh:96
Definition: json_visitor.hxx:40
The root from which to derive the final node types.
Definition: ratexp.hh:248
The abstract parameterized, root for all rational expression types.
Definition: ratexp.hh:74
std::shared_ptr< const node_t > value_t
Definition: ratexp.hh:79
std::vector< value_t > ratexps_t
Definition: ratexp.hh:82
A typed ratexp set.
Definition: ratexpset.hh:46
static constexpr bool is_commutative_semiring()
Definition: ratexpset.hh:153
identities_t identities() const
Definition: ratexpset.hxx:126
value_t star(value_t e) const
Definition: ratexpset.hxx:639
typename node_t::value_t value_t
The value this is a set of: typeful shared pointers.
Definition: ratexpset.hh:93
value_t conv(const ratexpset_impl< Ctx2 > &ws, typename ratexpset_impl< Ctx2 >::value_t v) const
bool is_series() const
Definition: ratexpset.hxx:131
typename context_t::weightset_ptr weightset_ptr
Definition: ratexpset.hh:54
value_t letter_class(Args &&... chars) const
A ratexp matching one character amongst chars.
static std::string sname()
Static description key.
Definition: ratexpset.hxx:66
value_t conjunction(value_t l, value_t r) const
Definition: ratexpset.hxx:503
const labelset_ptr & labelset() const
Definition: ratexpset.hxx:136
json::node_t * value_to_json(value_t v) const
Definition: ratexpset.hh:281
static constexpr bool is_ratexpset()
Definition: ratexpset.hh:168
std::string to_string(value_t e) const
Definition: ratexpset.hxx:783
value_t concat(value_t l, value_t r) const
Definition: ratexpset.hxx:588
labelset_t_of< context_t > labelset_t
Definition: ratexpset.hh:50
static constexpr bool has_one()
Definition: ratexpset.hh:163
bool open(bool o) const
Whether unknown letters should be added, or rejected.
Definition: ratexpset.hxx:115
std::vector< value_t > values_t
A value sequence.
Definition: ratexpset.hh:96
value_t transpose(value_t e) const
The transposed of this rational expression.
Definition: ratexpset.hxx:912
value_t ldiv(value_t l, value_t r) const
Definition: ratexpset.hxx:542
static bool is_one(value_t v) ATTRIBUTE_PURE
Definition: ratexpset.hxx:801
value_t transposition(value_t e) const
Add a transposition operator.
Definition: ratexpset.hxx:668
value_t mul(value_t l, value_t r) const
Definition: ratexpset.hxx:334
value_t rmul(value_t e, const weight_t &w) const
Right-multiplication by a weight.
Definition: ratexpset.hxx:734
std::set< value_t > convs(std::istream &) const
Definition: ratexpset.hh:197
json::node_t * to_json() const
Definition: ratexpset.hh:252
static constexpr bool show_one()
Definition: ratexpset.hh:158
label_t_of< context_t > label_t
Definition: ratexpset.hh:55
typename context_t::labelset_ptr labelset_ptr
Definition: ratexpset.hh:53
value_t conv(const letterset< GenSet > &ls, typename letterset< GenSet >::value_t v) const
Context context_t
Definition: ratexpset.hh:49
std::string vname(bool full=true) const
Dynamic description key.
Definition: ratexpset.hxx:72
value_t value_from_json(json::node_t const *p) const
Definition: ratexpset.hh:297
ratexpset_impl(const context_t &ctx, identities_t identities)
Constructor.
Definition: ratexpset.hxx:44
std::ostream & print_set(std::ostream &o, const std::string &format="text") const
Definition: ratexpset.hh:206
value_t lmul(const weight_t &w, value_t e) const
Left-multiplication by a weight.
Definition: ratexpset.hxx:692
typename node_t::type_t type_t
Definition: ratexpset.hh:89
value_t shuffle(value_t l, value_t r) const
Definition: ratexpset.hxx:567
static size_t hash(const value_t &l)
Hash l.
Definition: ratexpset.hxx:833
const context_t & context() const
Definition: ratexpset.hxx:121
value_t complement(value_t e) const
Add a complement operator.
Definition: ratexpset.hxx:655
value_t zero() const
Definition: ratexpset.hxx:154
static auto atom(const label_t &v) -> value_t
Definition: ratexpset.hxx:146
static bool less_than(value_t l, value_t r)
Whether l < r.
Definition: ratexpset.hxx:807
static value_t special()
When used as a LabelSet for automata.
Definition: ratexpset.hh:133
static bool is_special(value_t v)
When used as a LabelSet for automata.
Definition: ratexpset.hh:140
bool is_zero(value_t v) const ATTRIBUTE_PURE
Definition: ratexpset.hxx:795
value_t parse(const std::string &s, size_t &p) const
Definition: ratexpset.hh:315
value_t conv(std::istream &is) const
Definition: ratexpset.hxx:897
static self_type make(std::istream &is)
Build from the description in is.
Definition: ratexpset.hxx:98
bool is_letter(value_t) const
Definition: ratexpset.hh:145
word_t word(label_t l) const
Make a ‘word’ out of a ratexp.
Definition: ratexpset.hh:355
weightset_t_of< context_t > weightset_t
Definition: ratexpset.hh:51
ratexpset< Context > self_type
Definition: ratexpset.hh:48
static value_t one()
Definition: ratexpset.hxx:160
std::shared_ptr< const node_t > ratexp_t
Definition: ratexpset.hh:87
const weightset_ptr & weightset() const
Definition: ratexpset.hxx:141
std::ostream & print(const value_t v, std::ostream &o, const std::string &format="text") const
Definition: ratexpset.hxx:905
typename node_t::ratexps_t ratexps_t
Definition: ratexpset.hh:90
typename weightset_t::value_t weight_t
Definition: ratexpset.hh:56
static constexpr bool is_free()
Definition: ratexpset.hh:173
value_t add(value_t l, value_t r) const
Definition: ratexpset.hxx:199
static constexpr star_status_t star_status()
Definition: ratexpset.hh:178
value_t rdiv(value_t l, value_t r) const
Definition: ratexpset.hxx:560
static bool equals(value_t l, value_t r)
Whether l == r.
Definition: ratexpset.hxx:824
Definition: ratexp.hh:176
An inner node with multiple children.
Definition: ratexp.hh:115
An inner node implementing a weight.
Definition: ratexp.hh:208
The semiring of Integers.
Definition: z.hh:35
int value_t
Definition: z.hh:56
#define DEFINE(Type)
Type of ratexps.
Definition: ratexpset.hh:64
star_status_t
The different behaviours a weightset may have with respect to the star.
Definition: enums.hh:163
@ STARRABLE
The star of every element exists.
Definition: enums.hh:165
type_t
The possible types of ratexps.
Definition: fwd.hh:48
identities
A ratexpset can implement several different sets of identities on expressions.
Definition: identities.hh:32
std::string to_string(identities i)
typename internal::label_t_of_impl< internal::base_t< ValueSet > >::type label_t_of
Helper to retrieve the type of the labels of a value set.
Definition: traits.hh:71
decltype(join(std::declval< ValueSets >()...)) join_t
Computation of the join of some value sets.
Definition: context.hh:210
auto join(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< join_t< Ctx1, Ctx2 >>
The union of two ratexpsets.
Definition: ratexpset.hh:445
auto meet(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< meet_t< Ctx1, Ctx2 >>
The meet of two ratexpsets.
Definition: ratexpset.hh:434
typename internal::labelset_t_of_impl< internal::base_t< ValueSet > >::type labelset_t_of
Helper to retrieve the type of the labelset of a value set.
Definition: traits.hh:76
RatExpSet::ratexp_t js_parse_exp_content(const RatExpSet &rs, json::node_t const *p)
Definition: js_parser.hh:95
auto format(const ValueSet &vs, const typename ValueSet::value_t &v, Args &&... args) -> std::string
Format v via vs.print.
Definition: stream.hh:109
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
Definition: synchronizing_word.hh:266
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
static const std::string full
Completely version of Awali as a std::string.
Definition: version.hh:42
Main namespace of Awali.
Definition: ato.hh:22
Exceptions thrown during parsing.
Definition: parse_exception.hh:26
Definition: exp_parser.hh:59
marker type for labelsets where labels are rational expressions
Definition: kind.hh:82
Provide a variadic mul on top of a binary mul(), and one().
Definition: weightset.hh:38