20 template <Automaton Aut,
typename ExpSet,
typename Tag>
22 inductive(
const ExpSet&
rs,
const typename ExpSet::value_t&
r,
32 template <Automaton Aut,
typename ExpSet,
typename Tag>
34 :
public ExpSet::const_visitor
50 using super_t =
typename expressionset_t::const_visitor;
53 constexpr
static const char*
me() {
return "inductive"; }
65 return std::move(
res_);
67 catch (
const std::runtime_error& e)
69 raise(e,
" while computing inductive of: ",
to_string(
rs_, v));
77 return std::move(
res_);
80 using tuple_t =
typename super_t::tuple_t;
81 template <
bool = context_t::is_lat,
82 typename Dummy =
void>
92 return ::vcsn::inductive<automaton_t>(
rs,
98 template <
size_t... I>
112 template <
typename Dummy>
143 template <Automaton AutSet>
145 decltype(std::declval<AutSet>()
146 .
compose(std::declval<typename AutSet::value_t>(),
147 std::declval<typename AutSet::value_t>()));
150 template <
typename AutSet>
156 detail::static_if<has_compose_mem_fn<automatonset_t>{}>
157 ([
this](
const auto& e)
160 for (
const auto& c: e.tail())
166 raise(
"compose: context is not composable");
173 detail::static_if<labelset_t::is_letterized()>
174 ([
this](
const auto& e)
177 for (
const auto& c: e.tail())
183 raise(
"conjunction: labelset must be letterized: ",
191 detail::static_if<labelset_t::is_letterized()>
192 ([
this](
const auto& e)
195 for (
const auto& c: e.tail())
201 raise(
"infiltrate: labelset must be letterized: ",
209 detail::static_if<labelset_t::is_letterized()>
210 ([
this](
const auto& e)
213 for (
const auto& c: e.tail())
219 raise(
"ldivide: labelset must be letterized: ",
227 detail::static_if<labelset_t::is_letterized()>
228 ([
this](
const auto& e)
231 for (
const auto& c: e.tail())
237 raise(
"shuffle: labelset must be letterized: ",
246 for (
const auto& c: e.tail())
254 for (
const auto& c: e.tail())
266 detail::static_if<labelset_t::is_free()>
267 ([
this](
const auto& e)
273 raise(
"complement: labelset must be free: ",
302 template <Automaton Aut,
typename ExpSet,
typename Tag>
304 inductive(
const ExpSet& rs,
const typename ExpSet::value_t& r, Tag)
315 template <
typename ExpSet,
typename Tag>
317 const typename ExpSet::value_t& r)
320 return ::vcsn::inductive<automaton_t>(
rs,
r, Tag{});
324 template <
typename ExpSet,
typename String>
330 using expressionset_t = ExpSet;
331 using expression_t =
typename expressionset_t::value_t;
332 const auto& e = exp->
as<expressionset_t>();
335 =
auto(
const expressionset_t&,
const expression_t&) ->
automaton;
338 "inductive algorithm",
340 {
"auto",
"standard"},
342 {
"standard", inductive_tag_<ExpSet, standard_tag>},
345 return map[algo](e.valueset(), e.value());
VCSN_RAT_VISIT(shuffle, e)
automaton inductive_tag_(const ExpSet &rs, const typename ExpSet::value_t &r)
Helper function to facilitate dispatch below.
context_t_of< expressionset_t > context_t
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
#define BUILTIN_UNREACHABLE()
void visit(const tuple_t &v, std::true_type) override
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
auto complement(const value_t &e, std::true_type) const -> value_t
Add a complement operator: e{c}.
Aut inductive(const ExpSet &rs, const typename ExpSet::value_t &r, Tag={})
Build a inductive automaton from an expression.
auto rweight(const value_t &e, const weight_t &w) const -> value_t
Right-multiplication by a weight.
An inner node implementing a weight.
void operator()(const tuple_t &)
auto conjunction(const value_t &l, const value_t &r) const -> value_t
Build an conjunction product: l & r.
auto tuple(Value &&...v) const -> value_t
Build a tuple: e | f | ....
auto tape_(const tuple_t &v)
One tape.
static auto mul(const value_t &l, const value_t &r) -> value_t
VCSN_RAT_VISIT(complement, e)
inductive_visitor(const expressionset_t &rs)
auto zero() const -> value_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto atom(const label_t &l) const -> value_t
auto shuffle(const value_t &l, const value_t &r) const -> value_t
Build a shuffle product: l : r.
auto star(const value_t &e) const -> value_t
Add a star operator: e*.
typename expressionset_t::value_t expression_t
automaton_t operator()(const expression_t &v)
auto compose(const value_t &l, const value_t &r) const -> std::enable_if_t< are_composable< Ctx, Ctx >
Build a composition: l @ r.
auto one() const -> value_t
static constexpr const char * me()
Name of this algorithm, for error messages.
VCSN_RAT_VISIT(conjunction, e)
auto tape_(const tuple_t &v, detail::index_sequence< I... >)
Sum of sizes for all tapes.
labelset_t_of< context_t > labelset_t
weight_t_of< context_t > weight_t
auto operator()(const tuple_t &v)
Entry point.
auto transposition(const value_t &e) const -> value_t
Add a transposition operator.
automaton inductive(const expression &exp, const std::string &algo)
Bridge.
VCSN_RAT_VISIT(ldivide, e)
std::string to_string(identities i)
Wrapper around operator<<.
automaton_t recurse(const expression_t &v)
static auto add(const value_t &l, const value_t &r) -> value_t
auto infiltrate(const value_t &l, const value_t &r) const -> value_t
Build an infiltration product: l &: r.
VCSN_RAT_VISIT(compose, e)
weightset_t_of< context_t > weightset_t
Build an automaton by induction from an expression.
decltype(std::declval< AutSet >().compose(std::declval< typename AutSet::value_t >(), std::declval< typename AutSet::value_t >())) compose_mem_fn_t
The type of the AutSet::compose() member function.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
auto & as()
Extract wrapped typed automaton.
An inner node with multiple children.
VCSN_RAT_VISIT(infiltrate, e)
A mapping from strings to Values.
auto lweight(const weight_t &w, const value_t &e) const -> value_t
Left-multiplication by a weight.
typename super_t::tuple_t tuple_t
VCSN_RAT_VISIT(lweight, e)
typename expressionset_t::const_visitor super_t
value_impl< detail::expression_tag > expression
VCSN_RAT_VISIT(transposition, e)
auto ldivide(const value_t &l, const value_t &r) const -> value_t
r`.
state_t_of< automaton_t > state_t
VCSN_RAT_VISIT(rweight, e)
weightset_mixin< detail::r_impl > r