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>
85 template <exp::type_t Type>
87 template <exp::type_t Type>
89 using ratexp_t = std::shared_ptr<const node_t>;
105 static std::string
sname();
107 std::string
vname(
bool full =
true)
const;
120 bool open(
bool o)
const;
137 return atom(labelset_t::special());
186 template <
typename GenSet>
193 template <
typename Ctx2>
199 std::set<value_t>
convs(std::istream&)
const
201 raise(
vname(),
": ranges not implemented");
205 const std::string&
format =
"text")
const;
215 case identities_t::trivial:
216 case identities_t::associativity:
219 case identities_t::series:
229 else if (
format ==
"text") {
232 case identities_t::trivial:
233 case identities_t::associativity:
236 case identities_t::series:
247 raise(
"invalid format: ",
format);
253 template<
unsigned version = version::fsm_json>
257 version::check_fsmjson<version>();
261 =
context().template to_json<version>()->object();
265 case identities_t::trivial:
266 case identities_t::associativity:
267 res->
push_back(
"Rational Expression",obj);
269 case identities_t::series:
281 template<
unsigned version = version::fsm_json>
297 template<
unsigned version = version::fsm_json>
317 parse(
const std::string & s,
size_t& p)
const {
365 template <
typename... Args>
371 void require_weightset_commutativity()
const;
374 typename ratexps_t::iterator i)
const;
384 bool is_unweighted_nonsum_(
value_t v)
const;
385 bool is_nonsum_(
value_t v)
const;
401 template <exp::type_t Type>
408 template <exp::type_t Type>
417 template <
typename LabelSet_,
typename... Args>
418 value_t letter_class_(
const Args&&... chars, std::true_type)
const;
421 template <
typename LabelSet_>
423 letter_class_(std::set<
std::pair<
typename LabelSet_::letter_t,
424 typename LabelSet_::letter_t>> chars,
426 std::false_type)
const;
435 template <
typename Ctx1,
typename Ctx2>
441 return {
meet(a.context(),
b.context()),
442 meet(a.identities(),
b.identities())};
446 template <
typename Ctx1,
typename Ctx2>
452 return {
join(a.context(),
b.context()),
453 join(a.identities(),
b.identities())};
457 template <
typename GenSet1,
typename Ctx2>
466 return {ctx_t{
join(a, *
b.labelset()), *
b.weightset()},
470 template <
typename Ctx1,
typename GenSet2>
474 -> decltype(
join(
b, a))
481 template <
typename Context>
489 template <
typename Context>
498 template <
typename Context>
507 return {ctx_t{*rs.labelset(),
join(*rs.weightset(), ws)},
511 template <
typename Context>
521 template <
typename Context>
530 return {ctx_t{*rs.labelset(),
join(*rs.weightset(), ws)},
534 template <
typename Context>
544 template <
typename Context>
553 return {ctx_t{*rs.labelset(),
join(*rs.weightset(), ws)},
557 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:155
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:95
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:283
static constexpr bool is_ratexpset()
Definition: ratexpset.hh:170
std::string to_string(value_t e) const
Definition: ratexpset.hxx:810
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:165
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:98
value_t transpose(value_t e) const
The transposed of this rational expression.
Definition: ratexpset.hxx:939
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:828
value_t maybe(value_t e) const
Definition: ratexpset.hxx:655
value_t transposition(value_t e) const
Add a transposition operator.
Definition: ratexpset.hxx:695
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:761
std::set< value_t > convs(std::istream &) const
Definition: ratexpset.hh:199
json::node_t * to_json() const
Definition: ratexpset.hh:254
static constexpr bool show_one()
Definition: ratexpset.hh:160
label_t_of< context_t > label_t
Definition: ratexpset.hh:55
typename context_t::labelset_ptr labelset_ptr
Definition: ratexpset.hh:53
value_t plus(value_t e) const
Definition: ratexpset.hxx:666
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:299
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:208
value_t lmul(const weight_t &w, value_t e) const
Left-multiplication by a weight.
Definition: ratexpset.hxx:719
typename node_t::type_t type_t
Definition: ratexpset.hh:91
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:860
const context_t & context() const
Definition: ratexpset.hxx:121
value_t complement(value_t e) const
Add a complement operator.
Definition: ratexpset.hxx:682
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:834
static value_t special()
When used as a LabelSet for automata.
Definition: ratexpset.hh:135
static bool is_special(value_t v)
When used as a LabelSet for automata.
Definition: ratexpset.hh:142
bool is_zero(value_t v) const ATTRIBUTE_PURE
Definition: ratexpset.hxx:822
value_t parse(const std::string &s, size_t &p) const
Definition: ratexpset.hh:317
value_t conv(std::istream &is) const
Definition: ratexpset.hxx:924
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:147
word_t word(label_t l) const
Make a ‘word’ out of a ratexp.
Definition: ratexpset.hh:359
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:89
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:932
typename node_t::ratexps_t ratexps_t
Definition: ratexpset.hh:92
typename weightset_t::value_t weight_t
Definition: ratexpset.hh:56
static constexpr bool is_free()
Definition: ratexpset.hh:175
value_t add(value_t l, value_t r) const
Definition: ratexpset.hxx:199
static constexpr star_status_t star_status()
Definition: ratexpset.hh:180
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:851
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:449
auto meet(const ratexpset< Ctx1 > &a, const ratexpset< Ctx2 > &b) -> ratexpset< meet_t< Ctx1, Ctx2 >>
The meet of two ratexpsets.
Definition: ratexpset.hh:438
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:99
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