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
rat::expansionset< ExpSet >::value_t to_expansion(const ExpSet &rs, const typename ExpSet::value_t &e)
First order expansion.
bool is_synchronizing(const Aut &aut)
Whether this automaton is synchronizing, i.e., has synchronizing words.
bool is_valid_expression(const expression &exp)
Bridge (is_valid).
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.
automaton_editor * make_automaton_editor(const context &ctx)
Bridge.
expression expression_zero(const context &ctx, identities ids)
Bridge.
bool is_out_sorted(const Aut &a)
Whether for each state, the outgoing transitions are sorted by increasing label.
bool register_functions()
context context_of(const automaton &aut)
Bridge.
expression add_expression(const expression &lhs, const expression &rhs)
Bridge (add).
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.
mutable_automaton< Context > ladybird(const Context &ctx, unsigned n)
Build the ladybird automaton of n states.
mutable_automaton< Context > u(const Context &ctx, unsigned n)
The Brzozowski universal witness.
bool is_valid(const Aut &aut)
ExpSet::value_t to_expression(Aut &a, Profiler &profiler)
identities identities_of(const expression &exp)
Bridge.
std::ostream & print_polynomial(const polynomial &polynomial, std::ostream &o, const std::string &fmt)
Bridge (print).
context make_word_context(const context &ctx)
Bridge.
expression multiply_expression_repeated(const expression &re, int min, int max)
Bridge (multiply).
expression transpose_expression(const expression &exp)
Bridge (transpose).
unsigned star_height(const ExpSet &es, const typename ExpSet::value_t &e)
Star height of an expression.
bool is_synchronized_by(const Aut &aut, const word_t_of< Aut > &w)
Whether w synchronizes automaton aut.
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.
bool is_deterministic(const Aut &aut, state_t_of< Aut > s)
Whether state s is deterministic in aut.
Aut inductive(const ExpSet &rs, const typename ExpSet::value_t &r, Tag={})
Build a inductive automaton from an expression.
expression rweight_expression(const expression &exp, const weight &weight)
Bridge (rweight).
automaton standard_expression(const expression &exp)
Bridge (standard).
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
bool register_automaton_functions()
Instantiate the core functions for automata of type Aut.
expression lweight_expression(const weight &weight, const expression &exp)
Bridge (lweight).
bool is_normalized(const Aut &a)
Whether a is standard and co-standard.
expression multiply_expression(const expression &lhs, const expression &rhs)
Bridge (multiply).
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 determinize(const Aut &a, Tag={}, bool_constant< Lazy >={})
Provide a variadic mul on top of a binary mul(), and one().
weight multiply_weight(const weight &lhs, const weight &rhs)
Bridge (multiply).
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.
std::ostream & list_polynomial(const polynomial &polynomial, std::ostream &o)
Bridge (list).
ATTRIBUTE_CONST std::enable_if_t< context_t_of< Aut >::has_one(), bool > is_eps_acyclic(const Aut &aut)
Detect epsilon-circuits.
rat::expression_polynomial_t< ExpSet > split(const ExpSet &rs, const typename ExpSet::value_t &e)
Split an expression.
expression transposition_expression(const expression &exp)
Bridge (transposition).
expression complement_expression(const expression &exp)
Bridge (complement).
bool are_isomorphic(const Aut1 &a1, const Aut2 &a2)
std::ostream & print_expansion(const expansion &expansion, std::ostream &o, const std::string &fmt)
Bridge (print).
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
auto read_polynomial(const Context &ctx, std::istream &is) -> typename polynomialset< Context >::value_t
bool is_proper(const Aut &aut)
Test whether an automaton is proper.
word_t_of< Aut > synchronizing_word(const Aut &aut, const std::string &algo="greedy")
Return a synchronizing word for aut using algo algo.
bool register_kind_functions(labels_are_letters)
auto standard(const Aut &aut)
std::ostream & print_expression(const expression &exp, std::ostream &o, const std::string &fmt)
Bridge (print).
bool is_complete(const Aut &aut)
Whether aut is complete.
expression ldivide_expression(const expression &lhs, const expression &rhs)
Bridge (ldivide).
std::ostream & print(const Aut &aut, std::ostream &out=std::cout, const std::string &fmt="default")
expression infiltrate_expression(const expression &lhs, const expression &rhs)
Bridge (infiltrate).
filter_automaton< Aut > accessible(const Aut &a)
Accessible part of an automaton.
bool less_than_expression(const expression &lhs, const expression &rhs)
Bridge (less_than).
context context_of_expression(const expression &exp)
Bridge (context_of).
filter_automaton< Aut > trim(const Aut &a)
Useful part of an automaton.
std::ostream & info_expression(const expression &exp, std::ostream &o)
Bridge (info).
auto complete(const Aut &aut) -> decltype(::vcsn::copy(aut))
A complete copy of aut.
bool is_ambiguous(const Aut &aut)
Whether an automaton is ambiguous.
detail::enumerater< Aut >::polynomial_t shortest(const Aut &aut, boost::optional< unsigned > num={}, boost::optional< unsigned > len={})
The approximated behavior of an automaton.
ExpSet::value_t expand(const ExpSet &rs, const typename ExpSet::value_t &r)
Expand a typed expression, i.e., distribute multiplications over sums.
expression to_expression_class(const context &ctx, identities ids, const letter_class_t &letters, bool accept)
Bridge (to_expression).
typename law_traits< LabelSet >::type law_t
The smallest wordset that includes LabelSet.
std::set< std::pair< std::string, std::string >> letter_class_t
A set of letter ranges.
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
bool is_useless(const Aut &a)
Whether all no state is useful.
std::ostream & print_context(const context &ctx, std::ostream &o, const std::string &fmt)
Bridge (print).
weight_t_of< ExpSet > constant_term(const ExpSet &rs, const typename ExpSet::value_t &e)
The constant term of e.
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.
#define REGISTER(Algo,...)
std::enable_if_t< labelset_t_of< ExpSet >::is_letterized(), 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 letterized labelsets.
expression to_expression_label(const context &ctx, identities ids, const label &lbl)
Bridge (to_expression).
std::integral_constant< bool, B > bool_constant
expression rdivide_expression(const expression &lhs, const expression &rhs)
Bridge (rdivide).
automaton multiply_repeated(const automaton &a, int min, int max, const std::string &algo)
Bridge (multiply).
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...
An expressionset can implement several different sets of identities on expressions.
std::ostream & print_label(const label &label, std::ostream &o, const std::string &fmt)
Bridge (print).
expression concatenate_expression(const expression &lhs, const expression &rhs)
Bridge (concatenate).
expression shuffle_expression(const expression &lhs, const expression &rhs)
Bridge (shuffle).
bool is_standard(const Aut &a)
Whether a is standard.
bool is_empty(const Aut &a) ATTRIBUTE_PURE
Whether has no states.
mutable_automaton< Context > double_ring(const Context &ctx, unsigned n, const std::vector< unsigned > &finals)
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...
filter_automaton< Aut > coaccessible(const Aut &a)
Coaccessible part of an automaton.
expression difference_expression(const expression &lhs, const expression &rhs)
Bridge (difference).
std::ostream & info(const Aut &aut, std::ostream &out=std::cout, unsigned details=2)
Print info about an automaton.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
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 ...
std::ostream & print_weight(const weight &weight, std::ostream &o, const std::string &fmt)
Bridge (print).
polynomial multiply_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge (multiply).
expression expression_one(const context &ctx, identities ids)
Bridge.
auto evaluate(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.
auto sort(const Aut &a) -> permutation_automaton< Aut >
bool register_functions_is_free(std::true_type)
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
mutable_automaton< Context > de_bruijn(const Context &ctx, unsigned n)
auto push_weights(const Aut &aut) -> decltype(::vcsn::copy(aut))
The algorithm weight pushing.
expression conjunction_expression(const expression &lhs, const expression &rhs)
Bridge (conjunction).
bool register_expression_functions()
Instantiate the core functions for expressions of type ExpSet.
auto read_label(const Context &ctx, std::istream &is, bool quoted=false) -> label_t_of< Context >
constexpr auto num_tapes(const Ctx &) -> std::enable_if_t< Ctx::is_lat, size_t >
auto read_weight(const Context &ctx, std::istream &is) -> weight_t_of< Context >
bool is_trim(const Aut &a)
Whether all its states are useful.
Ctx make_context(const std::string &name)
Build a context from its name.
automaton conjunction_repeated(const automaton &aut, unsigned n)
Bridge (conjunction).
weight add_weight(const weight &lhs, const weight &rhs)
Bridge (add).
Aut transpose(const transpose_automaton< Aut > &aut)
The transpose of a transpose automaton is the original automaton.