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>(
context());
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())};
const weightset_ptr & weightset() const
Accessor to the weightset.
auto transpose(const value_t &e) const -> value_t
The transposed of this rational expression.
expressionset< detail::project_context< Tape, Ctx >> project_t
The type of the expressionset for the Tape-th tape.
static auto unwrap_possible_lweight_(const value_t &e) -> value_t
If e is an lweight, then its child, otherwise e.
static constexpr bool is_letterized()
When used as a labelset.
type_t
The possible types of expressions.
The abstract parameterized, root for all rational expression types.
std::string type(const automaton &a)
The implementation type of a.
const context_t & context() const
Accessor to the context.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
auto add_linear_(const add_t &addends, const value_t &r) const -> value_t
weightset_mixin< rat::expressionset_impl< Context >> expressionset
static size_t size(const value_t &v)
The size of v.
static type value(const type &ls)
std::shared_ptr< const node_t > value_t
An expression usable with value semantics.
static bool is_special(const value_t &v)
When used as a LabelSet.
Implementation of labels are letters.
auto label_one(const LabelSet &ls) -> typename LabelSet::value_t
Enjoy type inference.
const values_t sub() const
auto project() const -> project_t< Tape >
The expressionset for the Tape-th tape.
rat::type_t type_t
The possible types of expressions.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
static constexpr bool is_free()
When used as WeightSet.
static constexpr bool has_lightening_weights()
When used as WeightSet.
static bool is_one(const value_t &v) ATTRIBUTE_PURE
Whether v is the \e.
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
auto conv(const letterset< GenSet > &ls, typename letterset< GenSet >::value_t v) const -> value_t
static constexpr bool is_expressionset()
When used as WeightSet.
A structure that implements the computation of join(V1, V2).
static type value(const type &ls)
auto power(const value_t &e, unsigned n) const -> value_t
Add a power operator: e{n}.
auto print_set(std::ostream &o, format fmt={}) const -> std::ostream &
Format the description of this expressionset.
typename node_t::type_t type_t
Type tag for AST classes.
auto letter_class_(const Args &&...chars, std::true_type) const -> value_t
If labelset is oneset.
auto concat_(const value_t &l, const value_t &r, std::true_type) const -> value_t
If labelset is wordset.
An inner node implementing a weight.
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
static value_t special()
When used as a LabelSet.
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_t type_ignoring_lweight_(const value_t &e)
The type of e, or the type of its child if e is a lweight.
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.
expressionset< Context > self_t
auto print(const value_t &v, std::ostream &o=std::cout, format fmt={}) const -> std::ostream &
static type join(const WeightSet &ws, const expressionset< Context > &rs)
void gather_(values_t &res, const value_t &v) const
Push v in res, applying associativity if possible.
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. ...
#define JOIN_IMPL_SIMPLE(WS)
static constexpr bool is_idempotent()
When used as WeightSet.
static type join(const b &, const expressionset< Context > &rhs)
The smallest nullableset which includes LabelSet.
typename node_t::values_t values_t
A list (vector) of expressions.
const labelset_ptr & labelset() const
Accessor to the labelset.
vcsn::rat::add< context_t > add_t
static symbol sname()
Static description key.
auto letter_class(Args &&...chars) const -> value_t
An expression matching one character amongst chars.
std::vector< value_t > values_t
label_t as_label_(const tuple_t &v, detail::index_sequence< I... >) const
static constexpr star_status_t star_status()
When used as WeightSet.
static type value(const self_t &self)
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
bool open(bool o) const
Whether unknown letters should be added, or rejected.
typename context_t::labelset_ptr labelset_ptr
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
static bool is_label_(const tuple_t &v, detail::index_sequence< I... >)
Are all the components on I... labels?
An input/output format for valuesets.
static self_t make(std::istream &is)
Build from the description in is.
bool is_zero(const value_t &v) const ATTRIBUTE_PURE
Whether v is the \z.
const identities_t ids_
The set of rewriting rules to apply.
An expressionset can implement several different sets of identities on expressions.
auto project(const value_t &v) const -> decltype(::vcsn::rat::project< Tape >(this->self(), v))
Project a multitape expression.
context_t ctx_
The context of the expressions.
static constexpr bool is_commutative()
When used as WeightSet.
static bool is_label(const tuple_t &v)
Are all the components labels?
The root from which to derive the final node types.
expressionset_impl(const context_t &ctx, identities_t ids={})
Constructor.
static auto atom(const label_t &v) -> value_t
Build a label.
identities_t identities() const
Accessor to the identities set.
bool is_letter(value_t) const
When used as a LabelSet.
rat::identities identities_t
labelset_t_of< context_t > labelset_t
void convs(std::istream &, Fun) const
Read a range of expressions.
auto word(label_t l) const -> word_t
Make a `word' out of an expression.
auto make_expressionset(const context< LabelSet, WeightSet > &ctx, rat::identities ids={}) -> expressionset< context< LabelSet, WeightSet >>
Shorthand to expressionset constructor.
identities meet(identities i1, identities i2)
Implementation of nodes of tuple of rational expressions.
static type join(const expressionset< Ctx1 > &lhs, const expressionset< Ctx2 > &rhs)
static size_t hash(const value_t &v)
Hash v.
context< LabelSet, WeightSet >
project_t< I >::label_t as_label_(const tuple_t &v) const
The expression on tape I is actually a label: get it.
Turn a tuple of expressions that are labels into a multi-tape label.
bool is_universal(const value_t &v) const ATTRIBUTE_PURE
Whether v is the 0{c}.
typename weightset_t::value_t weight_t
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
static weight_t possibly_implicit_lweight_(const value_t &e)
The weight of e if it's an lweight, otherwise the weight one().
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.
An inner node with multiple children.
auto zero() const -> value_t
weightset_t_of< context_t > weightset_t
static identities ids(const driver &d)
Get the identities of the driver.
typename context_t::weightset_ptr weightset_ptr
#define DEFINE(Type)
Type of expressions.
Provide a variadic mul on top of a binary mul(), and one().
auto rdivide(const value_t &l, const value_t &r) const -> value_t
Build a right division: l {/} r.
label_t_of< context_t > label_t
static constexpr bool show_one()
When used as WeightSet.
label_t as_label(const tuple_t &v) const
All the components are (single-tape) labels: make this a multitape label.
static bool less(const value_t &l, const value_t &r)
Whether l < r.
static constexpr bool has_one()
When used as WeightSet.
static type join(const letterset< GenSet1 > &a, const expressionset< Ctx2 > &b)
static dyn::context ctx(const driver &d)
Get the context of the driver.
static bool less_linear(const value_t &l, const value_t &r)
Whether l < r, ignoring lweight.