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> 96 template <type_t Type>
98 template <type_t Type>
117 bool open(
bool o)
const;
133 return atom(labelset_t::special());
178 return weightset_t::is_idempotent();
190 return weightset_t::has_lightening_weights();
217 template <
typename GenSet>
226 template <
typename Ctx2>
284 template <
typename... Value>
317 template <
typename... Args>
321 auto conv(std::istream& is,
bool =
true)
const ->
value_t;
327 template <
typename Fun>
328 void convs(std::istream&, Fun)
const 330 raise(*
this,
": ranges not implemented");
334 std::ostream& o = std::cout,
format fmt = {})
const 342 template <
unsigned Tape,
typename Ctx = context_t>
347 template <
unsigned Tape>
351 return vcsn::detail::project<Tape>(
self());
355 template <
size_t Tape>
357 -> decltype(::vcsn::rat::project<Tape>(this->
self(), v))
359 return ::vcsn::rat::project<Tape>(
self(), v);
362 template <
typename Sequence>
365 template <
size_t... I>
373 return {detail::project<I>(
self)...};
378 template <
typename Ctx = context_t>
386 template <
typename Ctx = context_t>
419 template <type_t Type>
426 template <type_t Type>
435 template <
typename LabelSet_,
typename... Args>
439 template <
typename LabelSet_>
442 typename LabelSet_::letter_t>> chars,
444 std::false_type)
const;
447 template <
typename Dummy =
void>
453 return is_label_(v, labelset_t::indices);
460 return as_label_(v, labelset_t::indices);
464 template <
size_t... I>
469 && labelset_t::template valueset_t<I>::has_one()))...})
475 template <
size_t... I>
489 (std::get<I>(v.
sub()))->value();
505 template <
typename Ctx>
516 template <
typename Ctx>
527 template <
typename Ctx1,
typename Ctx2>
543 template <
typename GenSet1,
typename Ctx2>
560 template <
typename Context>
570 template <
typename W1,
typename W2>
573 template <
typename WeightSet,
typename Context>
587 #define JOIN_IMPL_SIMPLE(WS) \ 588 template <typename Context> \ 589 struct join_impl<WS, expressionset<Context>> \ 590 : public join_impl_simple<WS, expressionset<Context>> \ 599 #undef JOIN_IMPL_SIMPLE 604 template <
typename LabelSet,
typename WeightSet>
614 template <
typename Context>
620 return {rs.context(),
ids};
624 template <
typename Ctx1,
typename Ctx2>
629 return {
meet(a.context(),
b.context()),
630 meet(a.identities(),
b.identities())};
639 template <
typename Context,
640 typename RandomGenerator = std::default_random_engine>
643 RandomGenerator& gen = RandomGenerator())
auto transpose(const value_t &e) const -> value_t
The transposed of this rational expression.
auto zero() const -> value_t
auto letter_class_(const Args &&... chars, std::true_type) const -> value_t
If labelset is oneset.
auto transposition(const value_t &e) const -> value_t
Add a transposition operator.
std::shared_ptr< const node_t > value_t
An expression usable with value semantics.
typename node_t::type_t type_t
Type tag for AST classes.
::vcsn::rat::identities identities
Sets of identities on expressions.
context_t ctx_
The context of the expressions.
auto label_one(const LabelSet &ls) -> typename LabelSet::value_t
Enjoy type inference.
Implementation of nodes of tuple of rational expressions.
typename node_t::values_t values_t
A list (vector) of expressions.
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.
The abstract parameterized, root for all rational expression types.
auto concat_(const value_t &l, const value_t &r, std::true_type) const -> value_t
If labelset is wordset.
auto conjunction(const value_t &l, const value_t &r) const -> value_t
Build an conjunction product: l & r.
The smallest nullableset which includes LabelSet.
static type value(const self_t &self)
project_t< I >::label_t as_label_(const tuple_t &v) const
The expression on tape I is actually a label: get it.
typename weightset_t::value_t weight_t
auto rdivide(const value_t &l, const value_t &r) const -> value_t
Build a right division: l {/} r.
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.
identities meet(identities i1, identities i2)
identities_t identities() const
Accessor to the identities set.
auto star(const value_t &e) const -> value_t
Add a star operator: e*.
const identities_t ids_
The set of rewriting rules to apply.
static constexpr bool show_one()
When used as WeightSet.
auto ldivide(const value_t &l, const value_t &r) const -> value_t
r`.
static bool is_special(const value_t &v)
When used as a LabelSet.
static type join(const type1 &a, const type2 &b)
std::vector< value_t > values_t
static bool is_label_(const tuple_t &v, detail::index_sequence< I... >)
Are all the components on I... labels?
static auto atom(const label_t &v) -> value_t
Build a label.
expressionset_impl(const context_t &ctx, identities_t ids={})
Constructor.
bool open(bool o) const
Whether unknown letters should be added, or rejected.
An expressionset can implement several different sets of identities on expressions.
bool is_universal(const value_t &v) const ATTRIBUTE_PURE
Whether v is the 0{c}.
static auto one() -> value_t
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
static type value(const type &ls)
typename node_t::value_t value_t
An expression (a shared pointer to a tree).
static dyn::context ctx(const driver &d)
Get the context of the driver.
auto project(const value_t &v) const -> decltype(::vcsn::rat::project< Tape >(this->self(), v))
Project a multitape expression.
static auto equal(const value_t &l, const value_t &r) -> bool
Whether l == r.
auto infiltrate(const value_t &l, const value_t &r) const -> value_t
Build an infiltration product: l &: r.
label_t as_label_(const tuple_t &v, detail::index_sequence< I... >) const
void convs(std::istream &, Fun) const
Read a range of expressions.
static auto hash(const value_t &v) -> size_t
Hash v.
weightset_t_of< context_t > weightset_t
static bool is_one(const value_t &v) ATTRIBUTE_PURE
Whether v is the \\e.
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
static self_t make(std::istream &is)
Build from the description in is.
static symbol sname()
Static description key.
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
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
static identities ids(const driver &d)
Get the identities of the driver.
rat::type_t type_t
The possible types of expressions.
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
auto tuple(Value &&... v) const -> value_t
Build a tuple: e | f | ....
static value_t special()
When used as a LabelSet.
auto add(const value_t &l, const value_t &r) const -> value_t
#define DEFINE(Type)
Type of expressions.
const context_t & context() const
Accessor to the context.
auto word(label_t l) const -> word_t
Make a `word' out of an expression.
const values_t sub() const
labelset_t_of< context_t > labelset_t
The root from which to derive the final node types.
const labelset_ptr & labelset() const
Accessor to the labelset.
static constexpr bool is_commutative()
When used as WeightSet.
label_t_of< context_t > label_t
static auto less(const value_t &l, const value_t &r) -> bool
Whether l < r.
label_t as_label(const tuple_t &v) const
All the components are (single-tape) labels: make this a multitape label.
auto conv(const letterset< GenSet > &ls, typename letterset< GenSet >::value_t v) const -> value_t
static constexpr bool is_free()
When used as WeightSet.
auto letter_class(Args &&... chars) const -> value_t
An expression matching one character amongst chars.
An input/output format for valuesets.
static type value(const type &ls)
static constexpr bool is_expressionset()
When used as WeightSet.
Provide a variadic mul on top of a binary mul(), and one().
static constexpr bool is_idempotent()
When used as WeightSet.
static auto compare(const value_t &l, const value_t &r) -> int
Three-way comparison.
auto shuffle(const value_t &l, const value_t &r) const -> value_t
Build a shuffle product: l : r.
void gather_(values_t &res, const value_t &v) const
Push v in res, applying associativity if possible.
A structure that implements the computation of join(V1, V2).
static auto size(const value_t &v) -> size_t
The size of v.
static constexpr bool has_one()
When used as WeightSet.
auto compose(const value_t &l, const value_t &r) const -> value_t
Build a composition: l @ r.
An inner node with multiple children.
auto print(const value_t &v, std::ostream &o=std::cout, format fmt={}) const -> std::ostream &
auto project() const -> project_t< Tape >
The expressionset for the Tape-th tape.
#define JOIN_IMPL_SIMPLE(WS)
An inner node implementing a weight.
static auto unwrap_possible_lweight_(const value_t &e) -> value_t
If e is an lweight, then its child, otherwise e.
expressionset< Context >::value_t random_label(const expressionset< Context > &rs, RandomGenerator &gen=RandomGenerator())
Random label from expressionset: limited to a single label.
static bool less_linear(const value_t &l, const value_t &r)
Whether l < r, ignoring lweight.
auto print_set(std::ostream &o, format fmt={}) const -> std::ostream &
Format the description of this expressionset.
static bool is_label(const tuple_t &v)
Are all the components labels?
Implementation of labels are letters.
bool is_letter(value_t) const
When used as a LabelSet.
auto lweight(const weight_t &w, const value_t &e) const -> value_t
Left-multiplication by a weight.
static type join(const type1 &a, const type2 &b)
static constexpr bool is_letterized()
When used as a labelset.
std::string type(const automaton &a)
The implementation type of a.
static weight_t possibly_implicit_lweight_(const value_t &e)
The weight of e if it's an lweight, otherwise the weight one().
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).
typename context_t::labelset_ptr labelset_ptr
static type join(const type1 &ws, const type2 &rs)
static constexpr star_status_t star_status()
When used as WeightSet.
auto make_expressionset(const context< LabelSet, WeightSet > &ctx, rat::identities ids={}) -> expressionset< context< LabelSet, WeightSet >>
Shorthand to expressionset constructor.
static type join(const b &, const type &rhs)
const weightset_ptr & weightset() const
Accessor to the weightset.
auto add_(values_t &&vs) const -> value_t
From a list of values, build a sum, taking care of the empty and singleton cases. ...
Turn a tuple of expressions that are labels into a multi-tape label.
auto as_tupleset() const -> std::enable_if_t< Ctx::is_lat, as_tupleset_t< Ctx >>
If we are multitape, ourself as a tupleset.
auto add_linear_(const add_t &addends, const value_t &r) const -> value_t
typename context_t::weightset_ptr weightset_ptr
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
static constexpr bool has_lightening_weights()
When used as WeightSet.
auto complement(const value_t &e) const -> value_t
Add a complement operator: e{c}.
auto rweight(const value_t &e, const weight_t &w) const -> value_t
Right-multiplication by a weight.
auto mul(const value_t &l, const value_t &r) const -> value_t
bool is_zero(const value_t &v) const ATTRIBUTE_PURE
Whether v is the \\z.
auto power(const value_t &e, unsigned n) const -> value_t
Add a power operator: e{n}.