30 template <
typename Context>
42 using weight_t =
typename weightset_t::value_t;
57 const self_t&
self()
const {
return static_cast<const self_t&
>(*this); }
65 #define DEFINE(Type) \
66 using Type ## _t = vcsn::rat::Type<context_t>
95 template <type_t Type>
97 template <type_t Type>
116 bool open(
bool o)
const;
132 return atom(labelset_t::special());
177 return weightset_t::is_idempotent();
189 return weightset_t::has_lightening_weights();
216 template <
typename GenSet>
225 template <
typename Ctx2>
254 auto
add(const value_t& l, const value_t&
r) const -> value_t;
255 auto
mul(const value_t& l, const value_t&
r) const -> value_t;
266 auto
concat(const value_t& l, const value_t&
r) const -> value_t;
269 auto
compose(const value_t& l, const value_t&
r) const -> value_t;
272 auto
conjunction(const value_t& l, const value_t&
r) const -> value_t;
275 auto
infiltrate(const value_t& l, const value_t&
r) const -> value_t;
278 auto
shuffle(const value_t& l, const value_t&
r) const -> value_t;
281 template <typename... Value>
282 auto
tuple(Value&&...
v) const -> value_t;
285 auto
power(const value_t& e,
unsigned n) const -> value_t;
288 auto
ldivide(const value_t& l, const value_t&
r) const -> value_t;
291 auto
rdivide(const value_t& l, const value_t&
r) const -> value_t;
294 auto
star(const value_t& e) const -> value_t;
297 auto
complement(const value_t& e) const -> value_t;
305 auto
transpose(const value_t& e) const -> value_t;
314 template <
typename... Args>
318 auto
conv(
std::istream& is,
bool = true) const -> value_t;
321 auto
conv(const
self_t&, const value_t&
v) const -> value_t;
324 template <typename Fun>
327 raise(*
this,
": ranges not implemented");
331 std::ostream& o = std::cout,
format fmt = {})
const
339 template <
unsigned Tape,
typename Ctx = context_t>
344 template <
unsigned Tape>
348 return vcsn::detail::project<Tape>(
self());
352 template <
size_t Tape>
354 -> decltype(::vcsn::rat::project<Tape>(this->
self(), v))
356 return ::vcsn::rat::project<Tape>(
self(), v);
359 template <
typename Sequence>
362 template <
size_t... I>
370 return {detail::project<I>(
self)...};
375 template <
typename Ctx = context_t>
383 template <
typename Ctx = context_t>
401 auto
add_linear_(const value_t& l, const value_t&
r) const -> value_t;
427 auto
concat_(const value_t& l, const value_t&
r,
std::true_type) const -> value_t;
429 auto
concat_(const value_t& l, const value_t& r,
std::false_type) const -> value_t;
432 template <typename LabelSet_, typename... Args>
436 template <typename LabelSet_>
439 typename LabelSet_::letter_t>> chars,
441 std::false_type) const;
444 template <typename Dummy =
void>
450 return is_label_(v, labelset_t::indices);
457 return as_label_(v, labelset_t::indices);
461 template <
size_t... I>
466 && labelset_t::template valueset_t<I>::has_one()))...})
472 template <
size_t... I>
486 (std::get<I>(v.
sub()))->value();
502 template <
typename Ctx>
513 template <
typename Ctx>
524 template <
typename Ctx1,
typename Ctx2>
532 return {
vcsn::join(lhs.context(), rhs.context()),
533 vcsn::join(lhs.identities(), rhs.identities())};
539 template <
typename GenSet1,
typename Ctx2>
549 return {context_t{
vcsn::join(a, *b.labelset()), *b.weightset()},
555 template <
typename Context>
565 template <
typename W1,
typename W2>
568 template <
typename WeightSet,
typename Context>
576 return {context_t{*rs.labelset(),
vcsn::join(ws, *rs.weightset())},
580 #define JOIN_IMPL_SIMPLE(WS) \
581 template <typename Context> \
582 struct join_impl<WS, expressionset<Context>> \
583 : public join_impl_simple<WS, expressionset<Context>> \
592 #undef JOIN_IMPL_SIMPLE
597 template <
typename LabelSet,
typename WeightSet>
607 template <
typename Context>
611 -> expressionset<Context>
613 return {rs.context(),
ids};
617 template <
typename Ctx1,
typename Ctx2>
622 return {
meet(a.context(),
b.context()),
623 meet(a.identities(),
b.identities())};
632 template <
typename Context,
633 typename RandomGenerator = std::default_random_engine>
636 RandomGenerator& gen = RandomGenerator())
auto concat_(const value_t &l, const value_t &r, std::true_type) const -> value_t
If labelset is wordset.
static auto atom(const label_t &v) -> value_t
Build a label.
#define JOIN_IMPL_SIMPLE(WS)
typename as_tupleset_impl< typename labelset_t_of< Ctx >::indices_t::type >::type as_tupleset_t
If we are multitape, our type as a tupleset.
static type value(const type &ls)
static dyn::context ctx(const driver &d)
Get the context of the driver.
labelset_t_of< context_t > labelset_t
static symbol sname()
Static description key.
static constexpr bool is_idempotent()
When used as WeightSet.
Implementation of nodes of tuple of rational expressions.
std::shared_ptr< const node_t > value_t
An expression usable with value semantics.
typename weightset_t::value_t weight_t
typename node_t::type_t type_t
Type tag for AST classes.
std::vector< value_t > values_t
static constexpr bool show_one()
When used as WeightSet.
static identities ids(const driver &d)
Get the identities of the driver.
auto rdivide(const value_t &l, const value_t &r) const -> value_t
Build a right division: l {/} r.
auto make_expressionset(const context< LabelSet, WeightSet > &ctx, rat::identities ids={}) -> expressionset< context< LabelSet, WeightSet >>
Shorthand to expressionset constructor.
static type join(const expressionset< Ctx1 > &lhs, const expressionset< Ctx2 > &rhs)
identities meet(identities i1, identities i2)
expressionset_impl(const context_t &ctx, identities_t ids={})
Constructor.
An inner node implementing a weight.
static constexpr bool has_one()
When used as WeightSet.
identities_t identities() const
Accessor to the identities set.
static bool is_one(const value_t &v) ATTRIBUTE_PURE
Whether v is the \\e.
const labelset_ptr & labelset() const
Accessor to the labelset.
const weightset_ptr & weightset() const
Accessor to the weightset.
An input/output format for valuesets.
static constexpr star_status_t star_status()
When used as WeightSet.
rat::type_t type_t
The possible types of expressions.
static constexpr bool is_free()
When used as WeightSet.
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
static constexpr bool is_letterized()
When used as a labelset.
type_t
The possible types of expressions.
Provide a variadic mul on top of a binary mul(), and one().
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
static type join(const WeightSet &ws, const expressionset< Context > &rs)
label_t as_label_(const tuple_t &v, detail::index_sequence< I... >) const
static constexpr bool is_commutative()
When used as WeightSet.
auto word(label_t l) const -> word_t
Make a `word' out of an expression.
The smallest nullableset which includes LabelSet.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
#define DEFINE(Type)
Type of expressions.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
static bool less(const value_t &l, const value_t &r)
Whether l < r.
static type value(const type &ls)
auto zero() const -> value_t
rat::identities identities_t
context_t ctx_
The context of the expressions.
context< LabelSet, WeightSet >
auto letter_class(Args &&...chars) const -> value_t
An expression matching one character amongst chars.
static value_t special()
When used as a LabelSet.
auto conv(const letterset< GenSet > &ls, typename letterset< GenSet >::value_t v) const -> value_t
typename node_t::values_t values_t
A list (vector) of expressions.
std::string type(const automaton &a)
The implementation type of a.
auto transpose(const value_t &e) const -> value_t
The transposed of this rational expression.
static bool is_label(const tuple_t &v)
Are all the components labels?
auto add_linear_(const add_t &addends, const value_t &r) const -> value_t
static bool is_label_(const tuple_t &v, detail::index_sequence< I... >)
Are all the components on I... labels?
void gather_(values_t &res, const value_t &v) const
Push v in res, applying associativity if possible.
typename context_t::weightset_ptr weightset_ptr
bool is_zero(const value_t &v) const ATTRIBUTE_PURE
Whether v is the \\z.
static type_t type_ignoring_lweight_(const value_t &e)
The type of e, or the type of its child if e is a lweight.
project_t< I >::label_t as_label_(const tuple_t &v) const
The expression on tape I is actually a label: get it.
A structure that implements the computation of join(V1, V2).
bool open(bool o) const
Whether unknown letters should be added, or rejected.
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
static self_t make(std::istream &is)
Build from the description in is.
typename context_t::labelset_ptr labelset_ptr
weightset_t_of< context_t > weightset_t
static type value(const self_t &self)
typename node_t::value_t value_t
An expression (a shared pointer to a tree).
auto add_(values_t &&vs) const -> value_t
From a list of values, build a sum, taking care of the empty and singleton cases. ...
void convs(std::istream &, Fun) const
Read a range of expressions.
const context_t & context() const
Accessor to the context.
static type join(const letterset< GenSet1 > &a, const expressionset< Ctx2 > &b)
auto label_one(const LabelSet &ls) -> typename LabelSet::value_t
Enjoy type inference.
label_t as_label(const tuple_t &v) const
All the components are (single-tape) labels: make this a multitape label.
static weight_t possibly_implicit_lweight_(const value_t &e)
The weight of e if it's an lweight, otherwise the weight one().
bool is_letter(value_t) const
When used as a LabelSet.
static size_t hash(const value_t &v)
Hash v.
static bool less_linear(const value_t &l, const value_t &r)
Whether l < r, ignoring lweight.
const identities_t ids_
The set of rewriting rules to apply.
An expressionset can implement several different sets of identities on expressions.
weightset_mixin< rat::expressionset_impl< Context >> expressionset
auto concat(const value_t &l, const value_t &r) const -> value_t
Similar to mul, but in the case of LAW, merge the labels.
An inner node with multiple children.
auto print_set(std::ostream &o, format fmt={}) const -> std::ostream &
Format the description of this expressionset.
Turn a tuple of expressions that are labels into a multi-tape label.
Implementation of labels are letters.
The root from which to derive the final node types.
static size_t size(const value_t &v)
The size of v.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
static bool is_special(const value_t &v)
When used as a LabelSet.
auto print(const value_t &v, std::ostream &o=std::cout, format fmt={}) const -> std::ostream &
bool is_universal(const value_t &v) const ATTRIBUTE_PURE
Whether v is the 0{c}.
auto power(const value_t &e, unsigned n) const -> value_t
Add a power operator: e{n}.
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
static auto unwrap_possible_lweight_(const value_t &e) -> value_t
If e is an lweight, then its child, otherwise e.
const values_t sub() const
auto letter_class_(const Args &&...chars, std::true_type) const -> value_t
If labelset is oneset.
expressionset< Context >::value_t random_label(const expressionset< Context > &rs, RandomGenerator &gen=RandomGenerator())
Random label from expressionset: limited to a single label.
static type join(const b &, const expressionset< Context > &rhs)
static constexpr bool has_lightening_weights()
When used as WeightSet.
expressionset< Context > self_t
label_t_of< context_t > label_t
auto as_tupleset() const -> std::enable_if_t< Ctx::is_lat, as_tupleset_t< Ctx >>
If we are multitape, ourself as a tupleset.
static bool equal(const value_t &l, const value_t &r)
Whether l == r.
The abstract parameterized, root for all rational expression types.
vcsn::rat::add< context_t > add_t
auto project(const value_t &v) const -> decltype(::vcsn::rat::project< Tape >(this->self(), v))
Project a multitape expression.
static constexpr bool is_expressionset()
When used as WeightSet.
expressionset< detail::project_context< Tape, Ctx >> project_t
The type of the expressionset for the Tape-th tape.
auto project() const -> project_t< Tape >
The expressionset for the Tape-th tape.