31 template <
typename Context>
43 using weight_t =
typename weightset_t::value_t;
58 const self_t&
self()
const {
return static_cast<const self_t&
>(*this); }
66 #define DEFINE(Type) \ 67 using Type ## _t = vcsn::rat::Type<context_t> 97 template <type_t Type>
99 template <type_t Type>
118 bool open(
bool o)
const;
134 return atom(labelset_t::special());
179 return weightset_t::is_idempotent();
191 return weightset_t::has_lightening_weights();
218 template <
typename GenSet>
227 template <
typename Ctx2>
288 template <
typename... Value>
321 template <
typename... Args>
325 auto conv(std::istream& is,
bool =
true)
const ->
value_t;
331 template <
typename Fun>
332 void convs(std::istream&, Fun)
const 334 raise(*
this,
": ranges not implemented");
338 std::ostream& o = std::cout,
format fmt = {})
const 346 template <
unsigned Tape,
typename Ctx = context_t>
351 template <
unsigned Tape>
355 return vcsn::detail::project<Tape>(
self());
359 template <
size_t Tape>
361 -> decltype(::vcsn::rat::project<Tape>(this->
self(), v))
363 return ::vcsn::rat::project<Tape>(
self(), v);
366 template <
typename Sequence>
369 template <
size_t... I>
377 return {detail::project<I>(
self)...};
382 template <
typename Ctx = context_t>
390 template <
typename Ctx = context_t>
423 template <type_t Type>
430 template <type_t Type>
439 template <
typename LabelSet_,
typename... Args>
443 template <
typename LabelSet_>
446 typename LabelSet_::letter_t>> chars,
448 std::false_type)
const;
451 template <
typename Dummy =
void>
457 return is_label_(v, labelset_t::indices);
464 return as_label_(v, labelset_t::indices);
468 template <
size_t... I>
473 && labelset_t::template valueset_t<I>::has_one()))...})
479 template <
size_t... I>
493 (std::get<I>(v.
sub()))->value();
509 template <
typename Ctx>
520 template <
typename Ctx>
531 template <
typename Ctx1,
typename Ctx2>
547 template <
typename GenSet1,
typename Ctx2>
564 template <
typename Context>
574 template <
typename W1,
typename W2>
577 template <
typename WeightSet,
typename Context>
591 #define JOIN_IMPL_SIMPLE(WS) \ 592 template <typename Context> \ 593 struct join_impl<WS, expressionset<Context>> \ 594 : public join_impl_simple<WS, expressionset<Context>> \ 603 #undef JOIN_IMPL_SIMPLE 608 template <
typename LabelSet,
typename WeightSet>
618 template <
typename Context>
624 return {rs.context(),
ids};
628 template <
typename Context>
634 template <
typename Ctx1,
typename Ctx2>
639 return {
meet(a.context(),
b.context()),
640 meet(a.identities(),
b.identities())};
649 template <
typename Context,
650 typename RandomGenerator = std::default_random_engine>
653 RandomGenerator& gen = RandomGenerator())
static auto less(const value_t &l, const value_t &r) -> bool
Whether l < r.
static weight_t possibly_implicit_lweight_(const value_t &e)
The weight of e if it's an lweight, otherwise the weight one().
typename context_t::labelset_ptr labelset_ptr
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
rat::type_t type_t
The possible types of expressions.
auto concat_(const value_t &l, const value_t &r, std::true_type) const -> value_t
If labelset is wordset.
static bool is_label_(const tuple_t &v, detail::index_sequence< I... >)
Are all the components on I... labels?
void convs(std::istream &, Fun) const
Read a range of expressions.
static bool is_special(const value_t &v)
When used as a LabelSet.
static self_t make(std::istream &is)
Build from the description in is.
static type join(const b &, const type &rhs)
static constexpr star_status_t star_status()
When used as WeightSet.
static auto compare(const value_t &l, const value_t &r) -> int
Three-way comparison.
Implementation of labels are letters.
project_t< I >::label_t as_label_(const tuple_t &v) const
The expression on tape I is actually a label: get it.
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.
typename weightset_t::value_t weight_t
identities_t identities() const
Accessor to the identities set.
auto label_one(const LabelSet &ls) -> typename LabelSet::value_t
Enjoy type inference.
auto add(const value_t &l, const value_t &r) const -> value_t
std::vector< value_t > values_t
auto power(const value_t &e, unsigned n) const -> value_t
Add a power operator: e{n}.
An inner node with multiple children.
const identities_t ids_
The set of rewriting rules to apply.
#define DEFINE(Type)
Type of expressions.
static auto equal(const value_t &l, const value_t &r) -> bool
Whether l == r.
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.
Request the set implementation (bool weights).
const context_t & context() const
Accessor to the context.
auto project() const -> project_t< Tape >
The expressionset for the Tape-th tape.
static type value(const type &ls)
static auto zero() -> value_t
auto transpose(const value_t &e) const -> value_t
The transposed of this rational expression.
typename node_t::values_t values_t
A list (vector) of expressions.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
auto ldivide(const value_t &l, const value_t &r) const -> value_t
r`.
labelset_t_of< context_t > labelset_t
const labelset_ptr & labelset() const
Accessor to the labelset.
bool is_zero(const value_t &v) const ATTRIBUTE_PURE
Whether v is the \\z.
auto lweight(const weight_t &w, const value_t &e) const -> value_t
Left-multiplication by a weight.
static constexpr bool is_idempotent()
When used as WeightSet.
auto tuple(Value &&... v) const -> value_t
Build a tuple: e | f | ....
An inner node to name the subexpression.
auto add_linear_(const add_t &addends, const value_t &r) const -> value_t
static auto unwrap_possible_lweight_(const value_t &e) -> value_t
If e is an lweight, then its child, otherwise e.
context_t ctx_
The context of the expressions.
An expressionset can implement several different sets of identities on expressions.
static auto hash(const value_t &v) -> size_t
Hash v.
static constexpr bool has_one()
When used as WeightSet.
static constexpr bool has_lightening_weights()
When used as WeightSet.
An input/output format for valuesets.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
static constexpr bool is_letterized()
When used as a labelset.
Provide a variadic mul on top of a binary mul(), and one().
identities meet(identities i1, identities i2)
More restricted of these identities (min).
bool is_letter(value_t) const
When used as a LabelSet.
const values_t sub() const
static type join(const type1 &a, const type2 &b)
auto add_(values_t &&vs) const -> value_t
From a list of values, build a sum, taking care of the empty and singleton cases. ...
label_t_of< context_t > label_t
#define JOIN_IMPL_SIMPLE(WS)
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
A structure that implements the computation of join(V1, V2).
auto compose(const value_t &l, const value_t &r) const -> value_t
Build a composition: l @ r.
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
auto as_tupleset() const -> std::enable_if_t< Ctx::is_lat, as_tupleset_t< Ctx >>
If we are multitape, ourself as a tupleset.
static constexpr bool is_free()
When used as WeightSet.
auto star(const value_t &e) const -> value_t
Add a star operator: e*.
auto mul(const value_t &l, const value_t &r) const -> value_t
auto letter_class_(const Args &&... chars, std::true_type) const -> value_t
If labelset is oneset.
auto shuffle(const value_t &l, const value_t &r) const -> value_t
Build a shuffle product: l : r.
auto infiltrate(const value_t &l, const value_t &r) const -> value_t
Build an infiltration product: l &: r.
std::shared_ptr< const node_t > value_t
An expression usable with value semantics.
Implementation of nodes of tuple of rational expressions.
std::string type(const automaton &a)
The implementation type of a.
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
The abstract parameterized, root for all rational expression types.
static bool less_linear(const value_t &l, const value_t &r)
Whether l < r, ignoring lweight.
typename node_t::value_t value_t
An expression (a shared pointer to a tree).
static type join(const type1 &ws, const type2 &rs)
label_t as_label(const tuple_t &v) const
All the components are (single-tape) labels: make this a multitape label.
The smallest nullableset which includes LabelSet.
static type join(const type1 &a, const type2 &b)
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.
auto name(const value_t &v, symbol name) const -> value_t
Build a named expression.
bool is_universal(const value_t &v) const ATTRIBUTE_PURE
Whether v is the 0{c}.
An inner node implementing a weight.
auto make_expressionset(const context< LabelSet, WeightSet > &ctx, rat::identities ids={}) -> expressionset< context< LabelSet, WeightSet >>
Shorthand to expressionset constructor.
auto print_set(std::ostream &o, format fmt={}) const -> std::ostream &
Format the description of this expressionset.
auto conv(const letterset< GenSet > &ls, typename letterset< GenSet >::value_t v) const -> value_t
static bool is_one(const value_t &v) ATTRIBUTE_PURE
Whether v is the \\e.
weightset_t_of< context_t > weightset_t
auto rdivide(const value_t &l, const value_t &r) const -> value_t
Build a right division: l {/} r.
static dyn::context ctx(const driver &d)
Get the context of the driver.
Turn a tuple of expressions that are labels into a multi-tape label.
const weightset_ptr & weightset() const
Accessor to the weightset.
static type value(const self_t &self)
static auto size(const value_t &v) -> size_t
The size of v.
The root from which to derive the final node types.
static bool is_label(const tuple_t &v)
Are all the components labels?
auto project(const value_t &v) const -> decltype(::vcsn::rat::project< Tape >(this->self(), v))
Project a multitape expression.
static type value(const type &ls)
static symbol sname()
Static description key.
static identities ids(const driver &d)
Get the identities of the driver.
::vcsn::rat::identities identities
Sets of identities on expressions.
static constexpr bool is_commutative()
When used as WeightSet.
auto conjunction(const value_t &l, const value_t &r) const -> value_t
Build an conjunction product: l & r.
static constexpr bool show_one()
When used as WeightSet.
auto complement(const value_t &e) const -> value_t
Add a complement operator: e{c}.
static value_t special()
When used as a LabelSet.
void gather_(values_t &res, const value_t &v) const
Push v in res, applying associativity if possible.
Whether a ValueSet, or a context, is multitape.
auto letter_class(Args &&... chars) const -> value_t
An expression matching one character amongst chars.
static constexpr bool is_expressionset()
When used as WeightSet.
static auto atom(const label_t &v) -> value_t
Build a label.
static auto one() -> value_t
auto transposition(const value_t &e) const -> value_t
Add a transposition operator.
auto rweight(const value_t &e, const weight_t &w) const -> value_t
Right-multiplication by a weight.
expressionset_impl(const context_t &ctx, identities_t ids={})
Constructor.
typename context_t::weightset_ptr weightset_ptr
expressionset< Context >::value_t random_label(const expressionset< Context > &rs, RandomGenerator &gen=RandomGenerator())
Random label from expressionset: limited to a single label.
auto word(label_t l) const -> word_t
Make a `word' out of an expression.
auto print(const value_t &v, std::ostream &o=std::cout, format fmt={}) const -> std::ostream &
typename node_t::type_t type_t
Type tag for AST classes.
label_t as_label_(const tuple_t &v, detail::index_sequence< I... >) const