59 #include <vcsn/dyn/registries.hh>
83 #define VCSN_CTX_INSTANTIATE_PRINT(Format, Aut) \
84 MAYBE_EXTERN template \
86 std::ostream& Format<Aut>(const Aut& aut, std::ostream& out)
92 #define VCSN_CTX_INSTANTIATE_1(Ctx) \
93 MAYBE_EXTERN template \
94 class LIBVCSN_API mutable_automaton<Ctx>; \
97 MAYBE_EXTERN template \
99 to_expression<mutable_automaton<Ctx>> \
100 (const mutable_automaton<Ctx>& aut, \
101 const state_chooser_t<mutable_automaton<Ctx>>& next_state); \
104 VCSN_CTX_INSTANTIATE_PRINT(dot, mutable_automaton<Ctx>); \
107 VCSN_CTX_INSTANTIATE_PRINT(efsm, mutable_automaton<Ctx>); \
110 MAYBE_EXTERN template \
112 print<expressionset<Ctx>>(const expressionset<Ctx>& rs, \
113 const Ctx::expression_t& e, std::ostream& o, \
117 MAYBE_EXTERN template \
118 class rat::standard_visitor<mutable_automaton<Ctx>, Ctx>; \
121 VCSN_CTX_INSTANTIATE_PRINT(tikz, mutable_automaton<Ctx>); \
124 MAYBE_EXTERN template \
125 class LIBVCSN_API detail::transpose_automaton<mutable_automaton<Ctx>>; \
126 MAYBE_EXTERN template \
127 class LIBVCSN_API detail::transposer<expressionset<Ctx>>
134 #define REGISTER(Algo, ...) \
135 dyn::detail::Algo ## _register(ssignature<__VA_ARGS__>(), \
136 dyn::detail::Algo<__VA_ARGS__>)
144 template <Automaton Aut>
157 template <
typename ExpressionSet>
161 using rs_t = ExpressionSet;
199 template <
typename Ctx>
206 template <
typename Ctx>
226 REGISTER(conjunction, std::tuple<aut_t, aut_t>,
bool);
235 REGISTER(infiltrate, std::tuple<aut_t, aut_t>);
246 REGISTER(
shortest, aut_t, boost::optional<unsigned>, boost::optional<unsigned>);
247 REGISTER(shuffle, std::tuple<aut_t, aut_t>);
254 template <
typename Ctx>
261 template <
typename Ctx>
273 template <
typename Ctx>
288 template <
typename Ctx>
296 template <
typename Ctx>
304 template <
typename Ctx>
311 template <
typename Ctx>
329 register_automaton_functions<aut_t>();
330 register_expression_functions<rs_t>();
333 REGISTER(add, aut_t, aut_t,
const std::string);
348 REGISTER(lweight, ws_t, aut_t,
const std::string);
368 REGISTER(rweight, aut_t, ws_t,
const std::string);
371 REGISTER(star, aut_t,
const std::string);
379 register_functions_is_free<ctx_t>(is_free_t());
381 return register_kind_functions<ctx_t>(
typename ctx_t::kind_t());
388 #if VCSN_INSTANTIATION
389 # define VCSN_CTX_INSTANTIATE_2(Ctx) \
394 static bool registered ATTRIBUTE_USED \
395 = register_functions<Ctx>(); \
399 # define VCSN_CTX_INSTANTIATE_2(Ctx)
402 #define VCSN_CTX_INSTANTIATE(Ctx) \
404 VCSN_CTX_INSTANTIATE_2(Ctx)
407 # define MAYBE_EXTERN extern
filter_automaton< Aut > trim(const Aut &a)
Useful part of an automaton.
auto read_weight(const Context &ctx, std::istream &is) -> weight_t_of< Context >
auto push_weights(const Aut &aut) -> decltype(::vcsn::copy(aut))
The algorithm weight pushing.
auto complete(const Aut &aut) -> decltype(::vcsn::copy(aut))
bool is_complete(const Aut &aut)
Whether aut is complete.
Ctx make_context(const std::string &name)
Build a context from its name.
expression concatenate_expression(const expression &lhs, const expression &rhs)
Bridge (concatenate).
Aut transpose(const transpose_automaton< Aut > &aut)
bool register_kind_functions(labels_are_letters)
mutable_automaton< Context > divkbaseb(const Context &ctx, unsigned divisor, unsigned base)
Build the Boolean automaton which accepts a word n representing a number in base "base" if and only i...
detail::enumerater< Aut >::polynomial_t shortest(const Aut &aut, boost::optional< unsigned > num={}, boost::optional< unsigned > len={})
The approximated behavior of an automaton.
bool is_synchronizing(const Aut &aut)
Whether this automaton is synchronizing, i.e., has synchronizing words.
word_t_of< Aut > synchronizing_word(const Aut &aut, const std::string &algo="greedy")
Return a synchronizing word for aut using algo algo.
#define REGISTER(Algo,...)
auto multiply(const Aut1 &lhs, const Aut2 &rhs, Tag tag={}) -> decltype(lhs->null_state(), rhs->null_state(), detail::make_join_automaton(tag, lhs, rhs))
Concatenate two automata, general case.
auto proper(const Aut &aut, direction dir=direction::backward, bool prune=true, const std::string &algo="auto") -> fresh_automaton_t_of< Aut, detail::proper_context< context_t_of< Aut >>>
Eliminate spontaneous transitions.
std::ostream & print_label(const label &label, std::ostream &o, const std::string &fmt)
Bridge (print).
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
bool is_empty(const Aut &a) ATTRIBUTE_PURE
Whether has no states.
mutable_automaton< Context > u(const Context &ctx, unsigned n)
The Brzozowski universal witness.
context context_of(const automaton &aut)
Bridge.
ExpSet::value_t expand(const ExpSet &rs, const typename ExpSet::value_t &r)
Expand a typed expression, i.e., distribute multiplications over sums.
bool is_useless(const Aut &a)
Whether all no state is useful.
bool register_expression_functions()
Instantiate the core functions for expressions of type ExpSet.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
expression ldivide_expression(const expression &lhs, const expression &rhs)
Bridge (ldivide).
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
auto minimize(const Aut &a, brzozowski_tag) -> std::enable_if_t< is_free_boolean< Aut >(), determinized_automaton< codeterminized_automaton< Aut >, wet_kind_t::bitset >>
Brzozowski-based minimization.
Aut inductive(const ExpSet &rs, const typename ExpSet::value_t &r, Tag={})
Build a inductive automaton from an expression.
filter_automaton< Aut > accessible(const Aut &a)
Accessible part of an automaton.
automaton_editor * make_automaton_editor(const context &ctx)
Bridge.
auto read_polynomial(const Context &ctx, std::istream &is) -> typename polynomialset< Context >::value_t
bool is_ambiguous(const Aut &aut)
expression difference_expression(const expression &lhs, const expression &rhs)
Bridge (difference).
bool register_functions_is_free(std::true_type)
expression expression_one(const context &ctx, identities ids)
Bridge.
weight add_weight(const weight &lhs, const weight &rhs)
Bridge (add).
std::ostream & print_expression(const expression &exp, std::ostream &o, const std::string &fmt)
Bridge (print).
expression transpose_expression(const expression &exp)
Bridge (transpose).
weight multiply_weight(const weight &lhs, const weight &rhs)
Bridge (multiply).
mutable_automaton< Context > ladybird(const Context &ctx, unsigned n)
Build the ladybird automaton of n states.
Aut thompson(const context_t_of< Aut > &ctx, const ExpSet &rs, const typename ExpSet::value_t &r)
Build a Thompson automaton from an expression.
auto eliminate_state(const Aut &aut, state_t_of< Aut > s=Aut::element_type::null_state()) -> fresh_automaton_t_of< Aut >
A copy of automaton res without the state s.
expression expression_zero(const context &ctx, identities ids)
Bridge.
rat::expansionset< ExpSet >::value_t to_expansion(const ExpSet &rs, const typename ExpSet::value_t &e)
First order expansion.
bool is_standard(const Aut &a)
Whether a is standard.
bool is_deterministic(const Aut &aut, state_t_of< Aut > s)
Whether state s is deterministic in aut.
expression to_expression_class(const context &ctx, identities ids, const letter_class_t &letters, bool accept)
Bridge (to_expression).
expression rdivide_expression(const expression &lhs, const expression &rhs)
Bridge (rdivide).
std::ostream & print(const Aut &aut, std::ostream &out=std::cout, const std::string &fmt="default")
expression multiply_expression_repeated(const expression &re, int min, int max)
Bridge (multiply).
context make_word_context(const context &ctx)
Bridge.
auto copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans) -> decltype(keep_state(input->null_state()), keep_trans(input->null_transition()), make_fresh_automaton< AutIn, AutOut >(input))
A copy of input keeping only its states that are accepted by keep_state, and transitions accepted by ...
rat::expression_polynomial_t< ExpSet > derivation(const ExpSet &rs, const typename ExpSet::value_t &e, label_t_of< ExpSet > a, bool breaking=false)
Derive an expression wrt to a letter.
expression lweight_expression(const weight &weight, const expression &exp)
Bridge (lweight).
auto standard(const Aut &aut)
bool register_automaton_functions()
Instantiate the core functions for automata of type Aut.
std::ostream & print_expansion(const expansion &expansion, std::ostream &o, const std::string &fmt)
Bridge (print).
bool is_synchronized_by(const Aut &aut, const word_t_of< Aut > &w)
Whether w synchronizes automaton aut.
ATTRIBUTE_CONST std::enable_if_t< context_t_of< Aut >::has_one(), bool > is_eps_acyclic(const Aut &aut)
Detect epsilon-circuits.
std::ostream & list_polynomial(const polynomial &polynomial, std::ostream &o)
Bridge (list).
bool are_isomorphic(const Aut1 &a1, const Aut2 &a2)
identities identities_of(const expression &exp)
Bridge.
typename law_traits< LabelSet >::type law_t
The smallest wordset that includes LabelSet.
mutable_automaton< Ctx > cerny(const Ctx &ctx, unsigned num_states)
Cerny automata are automata whose synchronizing word length is always (n - 1)^2, the upper bound of t...
expression transposition_expression(const expression &exp)
Bridge (transposition).
mutable_automaton< Context > double_ring(const Context &ctx, unsigned n, const std::vector< unsigned > &finals)
expression shuffle_expression(const expression &lhs, const expression &rhs)
Bridge (shuffle).
auto eval(const Aut &a, const word_t_of< Aut > &w) -> std::enable_if_t<!context_t_of< Aut >::is_lao, weight_t_of< Aut >>
General case of evaluation.
expression add_expression(const expression &lhs, const expression &rhs)
Bridge (add).
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
auto determinize(const Aut &a, Tag={}, bool_constant< Lazy >={})
An expressionset can implement several different sets of identities on expressions.
unsigned star_height(const ExpSet &es, const typename ExpSet::value_t &e)
Star height of an expression.
expression conjunction_expression(const expression &lhs, const expression &rhs)
Bridge (conjunction).
auto read_label(const Context &ctx, std::istream &is, bool quoted=false) -> label_t_of< Context >
bool less_than_expression(const expression &lhs, const expression &rhs)
Bridge (less_than).
bool is_valid(const Aut &aut)
context context_of_expression(const expression &exp)
Bridge (context_of).
std::ostream & print_weight(const weight &weight, std::ostream &o, const std::string &fmt)
Bridge (print).
std::enable_if_t< labelset_t_of< ExpSet >::is_free(), expression_automaton< mutable_automaton< typename ExpSet::context_t > > > derived_term(const ExpSet &rs, const typename ExpSet::value_t &r, const std::string &algo="auto")
The derived-term automaton, for free labelsets.
bool is_out_sorted(const Aut &a)
Whether for each state, the outgoing transitions are sorted by increasing label.
rat::expression_polynomial_t< ExpSet > split(const ExpSet &rs, const typename ExpSet::value_t &e)
Split an expression.
expression to_expression_label(const context &ctx, identities ids, const label &lbl)
Bridge (to_expression).
bool is_proper(const Aut &aut)
Test whether an automaton is proper.
bool register_functions()
expression rweight_expression(const expression &exp, const weight &weight)
Bridge (rweight).
bool is_normalized(const Aut &a)
Whether a is standard and co-standard.
std::set< std::pair< std::string, std::string >> letter_class_t
A set of letter ranges.
automaton conjunction_repeated(const automaton &aut, unsigned n)
Bridge (conjunction).
automaton multiply_repeated(const automaton &a, int min, int max, const std::string &algo)
Bridge (multiply).
std::ostream & info_expression(const expression &exp, std::ostream &o)
Bridge (info).
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
automaton standard_expression(const expression &exp)
Bridge (standard).
expression complement_expression(const expression &exp)
Bridge (complement).
auto sort(const Aut &a) -> permutation_automaton< Aut >
filter_automaton< Aut > coaccessible(const Aut &a)
Coaccessible part of an automaton.
polynomial multiply_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge (multiply).
std::integral_constant< bool, B > bool_constant
std::ostream & info(const Aut &aut, std::ostream &out=std::cout, bool detailed=false)
Print info about an automaton.
Provide a variadic mul on top of a binary mul(), and one().
weight_t_of< ExpSet > constant_term(const ExpSet &rs, const typename ExpSet::value_t &e)
The constant term of e.
bool is_valid_expression(const expression &exp)
Bridge (is_valid).
std::ostream & print_polynomial(const polynomial &polynomial, std::ostream &o, const std::string &fmt)
Bridge (print).
expression infiltrate_expression(const expression &lhs, const expression &rhs)
Bridge (infiltrate).
expression multiply_expression(const expression &lhs, const expression &rhs)
Bridge (multiply).
bool is_trim(const Aut &a)
Whether all its states are useful.
constexpr auto num_tapes(const Ctx &) -> std::enable_if_t< Ctx::is_lat, size_t >
mutable_automaton< Context > de_bruijn(const Context &ctx, unsigned n)
ExpSet::value_t to_expression(Aut &a, Profiler &profiler)
std::ostream & print_context(const context &ctx, std::ostream &o, const std::string &fmt)
Bridge (print).