28 template <
typename Context>
40 using weight_t =
typename weightset_t::value_t;
49 #define DEFINE(Type) \
50 using Type ## _t = vcsn::rat::Type<context_t>
78 template <type_t Type>
80 template <type_t Type>
100 bool open(
bool o)
const;
116 return atom(labelset_t::special());
161 return weightset_t::is_idempotent();
173 return weightset_t::has_lightening_weights();
200 template <
typename GenSet>
209 template <
typename Ctx2>
238 auto
add(const value_t& l, const value_t&
r) const -> value_t;
239 auto
mul(const value_t& l, const value_t&
r) const -> value_t;
250 auto
concat(const value_t& l, const value_t&
r) const -> value_t;
252 auto
conjunction(const value_t& l, const value_t&
r) const -> value_t;
253 auto
infiltration(const value_t& l, const value_t&
r) const -> value_t;
254 auto
shuffle(const value_t& l, const value_t&
r) const -> value_t;
255 template <typename... Value>
256 auto
tuple(Value&&...
v) const -> value_t;
258 auto
power(const value_t& e,
unsigned n) const -> value_t;
259 auto
ldiv(const value_t& l, const value_t&
r) const -> value_t;
260 auto
rdiv(const value_t& l, const value_t&
r) const -> value_t;
261 auto
star(const value_t& e) const -> value_t;
263 auto
complement(const value_t& e) const -> value_t;
267 auto
rmul(const value_t& e, const
weight_t& w) const -> value_t;
269 auto
lmul(const
weight_t& w, const value_t& e) const -> value_t;
271 auto
transpose(const value_t& e) const -> value_t;
280 template <
typename... Args>
284 auto
conv(
std::istream&
is,
bool = true) const -> value_t;
287 auto
conv(const
self_t&, const value_t&
v) const -> value_t;
290 template <typename Fun>
293 raise(
sname(),
": ranges not implemented");
304 template <
unsigned Tape,
typename Ctx = context_t>
309 template <
typename Sequence>
312 template <
size_t... I>
320 return {detail::project<I>(
self)...};
325 template <
typename Ctx = context_t>
330 template <
typename Ctx = context_t>
348 const self_t&
self()
const {
return static_cast<const self_t&
>(*this); }
360 auto
add_linear_(const value_t& l, const value_t&
r) const -> value_t;
386 auto
concat_(const value_t& l, const value_t&
r,
std::true_type) const -> value_t;
388 auto
concat_(const value_t& l, const value_t& r,
std::false_type) const -> value_t;
391 template <typename LabelSet_, typename... Args>
395 template <typename LabelSet_>
398 typename LabelSet_::letter_t>> chars,
400 std::false_type) const;
403 template <typename Dummy =
void>
409 return is_label_(v, labelset_t::indices);
416 return as_label_(v, labelset_t::indices);
419 template <
size_t... I>
424 && labelset_t::template valueset_t<I>::has_one()))...})
430 template <
size_t... I>
443 (std::get<I>(v.
sub()))->value();
458 template <
typename Ctx>
469 template <
typename Ctx>
480 template <
typename Ctx1,
typename Ctx2>
488 return {
vcsn::join(lhs.context(), rhs.context()),
489 vcsn::join(lhs.identities(), rhs.identities())};
495 template <
typename GenSet1,
typename Ctx2>
505 return {context_t{
vcsn::join(a, *b.labelset()), *b.weightset()},
511 template <
typename Context>
521 template <
typename W1,
typename W2>
524 template <
typename WeightSet,
typename Context>
532 return {context_t{*rs.labelset(),
vcsn::join(ws, *rs.weightset())},
536 #define JOIN_IMPL_SIMPLE(WS) \
537 template <typename Context> \
538 struct join_impl<WS, expressionset<Context>> \
539 : public join_impl_simple<WS, expressionset<Context>> \
548 #undef JOIN_IMPL_SIMPLE
553 template <
typename Context>
561 template <
typename Ctx1,
typename Ctx2>
567 return {
meet(a.context(),
b.context()),
568 meet(a.identities(),
b.identities())};
labelset_t_of< context_t > labelset_t
static constexpr bool is_expressionset()
When used as WeightSet.
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
auto power(const value_t &e, unsigned n) const -> value_t
Add a power operator.
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
static label_t as_label_(const tuple_t &v, detail::index_sequence< I... >)
static type value(const type &ls)
static bool is_label_(const tuple_t &v, detail::index_sequence< I... >)
#define DEFINE(Type)
Type of expressions.
vcsn::rat::sum< context_t > sum_t
Turn a tuple of expressions that are labels into a multi-tape label.
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
static constexpr star_status_t star_status()
When used as WeightSet.
typename weightset_t::value_t weight_t
auto rdiv(const value_t &l, const value_t &r) const -> value_t
static constexpr bool show_one()
When used as WeightSet.
static bool less(const value_t &l, const value_t &r)
Whether l < r.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::vector< value_t > values_t
auto zero() const -> value_t
auto concat_(const value_t &l, const value_t &r, std::true_type) const -> value_t
If labelset is wordset.
auto add(const value_t &l, const value_t &r) const -> value_t
static value_t special()
When used as a LabelSet.
static bool is_one(const value_t &v) ATTRIBUTE_PURE
Whether v is the \e.
type_t
The possible types of expressions.
const weightset_ptr & weightset() const
Accessor to the weightset.
auto transpose(const value_t &e) const -> value_t
The transposed of this rational expression.
An expressionset can implement several different sets of identities on expressions.
static type join(const expressionset< Ctx1 > &lhs, const expressionset< Ctx2 > &rhs)
expressionset< detail::project_context< Tape, Ctx >> project_t
The type of the expressionset for the Tape-th tape.
typename node_t::type_t type_t
Type tag for AST classes.
expressionset_impl(const context_t &ctx, identities_t ids={})
Constructor.
static constexpr bool has_one()
When used as WeightSet.
static constexpr bool is_letterized()
When used as a labelset.
rat::identities identities_t
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.
auto word(label_t l) const -> word_t
Make a `word' out of an expression.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
std::string type(const automaton &a)
The implementation type of a.
void gather_(values_t &res, const value_t &v) const
Push v in res, applying associativity if possible.
static constexpr bool is_free()
When used as WeightSet.
An input/output format for valuesets.
weightset_t_of< context_t > weightset_t
Provide a variadic mul on top of a binary mul(), and one().
An inner node with multiple children.
typename node_t::value_t value_t
An expression (a shared pointer to a tree).
typename node_t::values_t values_t
A list (vector) of expressions.
const labelset_ptr & labelset() const
Accessor to the labelset.
static constexpr bool is_commutative()
When used as WeightSet.
const context_t & context() const
Accessor to the context.
std::shared_ptr< const node_t > value_t
An expression usable with value semantics.
typename context_t::labelset_ptr labelset_ptr
identities_t identities() const
Accessor to the identities set.
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.
A structure that implements the computation of join(V1, V2).
auto print(const value_t &v, std::ostream &o, format fmt={}) const -> std::ostream &
#define JOIN_IMPL_SIMPLE(WS)
auto rmul(const value_t &e, const weight_t &w) const -> value_t
Right-multiplication by a weight.
static type join(const letterset< GenSet1 > &a, const expressionset< Ctx2 > &b)
auto conv(const letterset< GenSet > &ls, typename letterset< GenSet >::value_t v) const -> value_t
identities meet(identities i1, identities i2)
bool is_letter(value_t) const
When used as a LabelSet.
static size_t hash(const value_t &v)
Hash v.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
context_t ctx_
The context of the expressions.
auto add_(values_t &&vs) const -> value_t
From a list of values, build a sum, taking care of the empty and singleton cases. ...
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.
static project_t< I >::label_t as_label_(const tuple_t &v)
static type value(const type &ls)
auto label_one() -> std::enable_if_t< LabelSet::has_one(), typename LabelSet::value_t >
This LabelSet's one(), if supported.
static size_t size(const value_t &v)
The size of v.
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 letter_class(Args &&...chars) const -> value_t
An expression matching one character amongst chars.
bool is_universal(const value_t &v) const ATTRIBUTE_PURE
Whether v is the 0{c}.
std::istringstream is
The input stream: the specification to translate.
expressionset< Context > make_expressionset(const Context &ctx, rat::identities identities={})
Shorthand to expressionset constructor.
static type value(const self_t &self)
static weight_t possibly_implicit_lweight_(const value_t &e)
The weight of e if it's an lweight, otherwise the weight one().
bool open(bool o) const
Whether unknown letters should be added, or rejected.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
static dyn::context ctx(const driver &d)
Get the context of the driver.
typename context_t::weightset_ptr weightset_ptr
An inner node implementing a weight.
static bool less_linear(const value_t &l, const value_t &r)
Whether l < r, ignoring lweight.
const values_t sub() const
static bool is_special(const value_t &v)
When used as a LabelSet.
Implementation of labels are letters.
static void convs(std::istream &, Fun)
Read a range of expressions.
The root from which to derive the final node types.
auto lmul(const weight_t &w, const value_t &e) const -> value_t
Left-multiplication by a weight.
static auto unwrap_possible_lweight_(const value_t &e) -> value_t
If e is an lweight, then its child, otherwise e.
auto as_tupleset() const -> std::enable_if_t< Ctx::is_lat, as_tupleset_t< Ctx >>
If we are multitape, ourself as a tupleset.
auto letter_class_(const Args &&...chars, std::true_type) const -> value_t
If labelset is oneset.
static self_t make(std::istream &is)
Build from the description in is.
static constexpr bool has_lightening_weights()
When used as WeightSet.
static bool is_label(const tuple_t &v)
Are all the components labels?
rat::type_t type_t
The possible types of expressions.
The smallest nullableset which includes LabelSet.
expressionset< Context > self_t
auto add_linear_(const sum_t &addends, const value_t &r) const -> value_t
auto print_set(std::ostream &o, format fmt={}) const -> std::ostream &
Format the description of this expressionset.
static identities ids(const driver &d)
Get the identities of the driver.
label_t_of< context_t > label_t
auto mul(const value_t &l, const value_t &r) const -> value_t
static auto atom(const label_t &v) -> value_t
Build a label.
rat::identities identities(const expression &exp)
Bridge.
Implementation of nodes of tuple of rational expressions.
The abstract parameterized, root for all rational expression types.
static constexpr bool is_idempotent()
When used as WeightSet.
static label_t as_label(const tuple_t &v)
All the components are (single-tape) labels: make this a multitape label.
static type join(const b &, const expressionset< Context > &rhs)
static bool equal(const value_t &l, const value_t &r)
Whether l == r.
static type join(const WeightSet &ws, const expressionset< Context > &rs)
static symbol sname()
Static description key.