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 Algo ## _register(ssignature<__VA_ARGS__>(), Algo<__VA_ARGS__>)
143 template <Automaton Aut>
148 using namespace dyn::detail;
156 template <
typename Ctx>
163 template <
typename Ctx>
181 using namespace dyn::detail;
184 REGISTER(conjunction, std::tuple<aut_t, aut_t>,
bool);
193 REGISTER(infiltration, std::tuple<aut_t, aut_t>);
205 REGISTER(
shortest, aut_t, boost::optional<unsigned>, boost::optional<unsigned>);
206 REGISTER(shuffle, std::tuple<aut_t, aut_t>);
213 template <
typename Ctx>
220 template <
typename Ctx>
227 using namespace dyn::detail;
234 template <
typename Ctx>
240 using namespace dyn::detail;
251 template <
typename Ctx>
259 template <
typename Ctx>
267 template <
typename Ctx>
274 template <
typename Ctx>
292 using namespace dyn::detail;
294 register_automaton_functions<aut_t>();
356 REGISTER(star, aut_t,
const std::string);
358 REGISTER(sum, aut_t, aut_t,
const std::string);
372 register_functions_is_free<ctx_t>(is_free_t());
374 return register_kind_functions<ctx_t>(
typename ctx_t::kind_t());
381 #if VCSN_INSTANTIATION
382 # define VCSN_CTX_INSTANTIATE_2(Ctx) \
387 static bool registered ATTRIBUTE_USED \
388 = register_functions<Ctx>(); \
392 # define VCSN_CTX_INSTANTIATE_2(Ctx)
395 #define VCSN_CTX_INSTANTIATE(Ctx) \
397 VCSN_CTX_INSTANTIATE_2(Ctx)
400 # define MAYBE_EXTERN extern
auto complete(const Aut &aut) -> decltype(::vcsn::copy(aut))
bool is_proper(const Aut &aut)
Test whether an automaton is proper.
std::integral_constant< bool, B > bool_constant
expression complement_expression(const expression &exp)
Bridge (complement).
auto read_label(const Context &ctx, std::istream &is, bool quoted=false) -> label_t_of< Context >
detail::enumerater< Aut >::polynomial_t shortest(const Aut &aut, boost::optional< unsigned > num={}, boost::optional< unsigned > len={})
The approximated behavior of an automaton.
expression right_mult_expression(const expression &exp, const weight &weight)
Bridge (right_mult).
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
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...
mutable_automaton< Context > double_ring(const Context &ctx, unsigned n, const std::vector< unsigned > &finals)
std::ostream & print_expression(const expression &exp, std::ostream &o, const std::string &fmt)
Bridge (print).
filter_automaton< Aut > trim(const Aut &a)
Useful part of an automaton.
expression multiply_expression_repeated(const expression &re, int min, int max)
Bridge (multiply).
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
auto read_polynomial(const Context &ctx, std::istream &is) -> typename polynomialset< Context >::value_t
bool is_valid_expression(const expression &exp)
Bridge (is_valid).
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
context context_of(const automaton &aut)
Bridge.
auto left_mult(const weight_t_of< Aut > &w, const Aut &aut, Tag tag={}) -> fresh_automaton_t_of< Aut >
Left-multiplication of an automaton by a weight.
mutable_automaton< Context > u(const Context &ctx, unsigned n)
The Brzozowski universal witness.
bool is_synchronizing(const Aut &aut)
Whether this automaton is synchronizing, i.e., has synchronizing words.
An expressionset can implement several different sets of identities on expressions.
automaton_editor * make_automaton_editor(const context &ctx)
Bridge.
polynomial multiply_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge (multiply).
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.
filter_automaton< Aut > coaccessible(const Aut &a)
Coaccessible part of an automaton.
context context_of_expression(const expression &exp)
Bridge (context_of).
mutable_automaton< Context > de_bruijn(const Context &ctx, unsigned n)
std::ostream & print_polynomial(const polynomial &polynomial, std::ostream &o, const std::string &fmt)
Bridge (print).
bool is_trim(const Aut &a)
Whether all its states are useful.
#define REGISTER(Algo,...)
mutable_automaton< Context > ladybird(const Context &ctx, unsigned n)
expression transposition_expression(const expression &exp)
Bridge (transposition).
std::set< std::pair< std::string, std::string >> letter_class_t
A set of letter ranges.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
expression difference_expression(const expression &lhs, const expression &rhs)
Bridge (difference).
constexpr auto num_tapes(const Ctx &) -> std::enable_if_t< Ctx::is_lat, size_t >
Provide a variadic mul on top of a binary mul(), and one().
bool register_functions()
auto standard(const Aut &aut)
bool register_functions_is_free(std::true_type)
filter_automaton< Aut > accessible(const Aut &a)
Accessible part of an automaton.
weight_t_of< ExpSet > constant_term(const ExpSet &rs, const typename ExpSet::value_t &e)
The constant term of e.
Aut thompson(const context_t_of< Aut > &ctx, const ExpSet &rs, const typename ExpSet::value_t &r)
Build a Thompson automaton from an expression.
weight multiply_weight(const weight &lhs, const weight &rhs)
Bridge (multiply).
expression multiply_expression(const expression &lhs, const expression &rhs)
Bridge (multiply).
Aut transpose(const transpose_automaton< Aut > &aut)
ExpSet::value_t expand(const ExpSet &rs, const typename ExpSet::value_t &e)
Expand a typed expression.
ATTRIBUTE_CONST bool is_eps_acyclic(const Aut &aut)
auto determinize(const Aut &a, Tag={}, bool_constant< Lazy >={})
bool is_empty(const Aut &a) ATTRIBUTE_PURE
Whether has no states.
bool register_automaton_functions()
Instantiate the core functions for automata of type Aut.
bool is_normalized(const Aut &a)
Whether a is standard and co-standard.
automaton multiply_repeated(const automaton &a, int min, int max, const std::string &algo)
Bridge (multiply).
bool is_deterministic(const Aut &aut, state_t_of< Aut > s)
Whether state s is deterministic in aut.
expression concatenate_expression(const expression &lhs, const expression &rhs)
Bridge (concatenate).
ExpSet::value_t to_expression(Aut &a, Profiler &profiler)
expression expression_zero(const context &ctx, rat::identities ids)
Bridge.
automaton conjunction_repeated(const automaton &aut, unsigned n)
Bridge (conjunction).
expression left_mult_expression(const weight &weight, const expression &exp)
Bridge (left_mult).
bool is_out_sorted(const Aut &a)
Whether for each state, the outgoing transitions are sorted by increasing label.
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 rdiv_expression(const expression &lhs, const expression &rhs)
Bridge (rdiv).
expression transpose_expression(const expression &exp)
Bridge (transpose).
typename law_traits< LabelSet >::type law_t
The smallest wordset that includes LabelSet.
bool less_than_expression(const expression &lhs, const expression &rhs)
Bridge (less_than).
automaton standard_expression(const expression &exp)
Bridge (standard).
bool is_complete(const Aut &aut)
Whether aut is complete.
expression to_expression_class(const context &ctx, rat::identities ids, const letter_class_t &letters, bool accept)
Bridge (to_expression).
fresh_automaton_t_of< Aut > right_mult(const Aut &aut, const weight_t_of< Aut > &w, Tag tag={})
Right-multiplication of an automaton by a weight.
mutable_automaton< Ctx > random_automaton_deterministic(const Ctx &ctx, unsigned num_states)
std::ostream & print(const Aut &aut, std::ostream &out, const std::string &fmt)
auto push_weights(const Aut &aut) -> decltype(::vcsn::copy(aut))
The algorithm weight pushing.
weight sum_weight(const weight &lhs, const weight &rhs)
Bridge (sum).
expression to_expression_label(const context &ctx, rat::identities ids, const label &lbl)
Bridge (to_expression).
word_t_of< Aut > synchronizing_word(const Aut &aut, const std::string &algo="greedy")
Return a synchronizing word for aut using algo algo.
static dyn::context ctx(const driver &d)
Get the context of the driver.
std::ostream & info_expression(const expression &exp, std::ostream &o)
Bridge (info).
bool are_isomorphic(const Aut1 &a1, const Aut2 &a2)
bool is_valid(const Aut &aut)
expression sum_expression(const expression &lhs, const expression &rhs)
Bridge (sum).
expression ldiv_expression(const expression &lhs, const expression &rhs)
Bridge (ldiv).
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.
auto sort(const Aut &a) -> permutation_automaton< Aut >
std::ostream & print_context(const context &ctx, std::ostream &o, const std::string &fmt)
Bridge (print).
bool is_useless(const Aut &a)
Whether all no state is useful.
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.
bool is_ambiguous(const Aut &aut)
expression shuffle_expression(const expression &lhs, const expression &rhs)
Bridge (shuffle).
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 & print_label(const label &label, std::ostream &o, const std::string &fmt)
Bridge (print).
std::ostream & print_expansion(const expansion &expansion, std::ostream &o, const std::string &fmt)
Bridge (print).
std::ostream & info(const Aut &aut, std::ostream &out, bool detailed=false)
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.
expression expression_one(const context &ctx, rat::identities ids)
Bridge.
std::ostream & print_weight(const weight &weight, std::ostream &o, const std::string &fmt)
Bridge (print).
bool register_kind_functions(labels_are_letters)
auto read_weight(const Context &ctx, std::istream &is) -> weight_t_of< Context >
rat::expansionset< ExpSet >::value_t to_expansion(const ExpSet &rs, const typename ExpSet::value_t &e)
First order expansion.
mutable_automaton< Ctx > random_automaton(const Ctx &ctx, unsigned num_states, float density=0.1, unsigned num_initial=1, unsigned num_final=1, float loop_chance=0.0)
rat::identities identities(const expression &exp)
Bridge.
std::ostream & list_polynomial(const polynomial &polynomial, std::ostream &o)
Bridge (list).
bool is_standard(const Aut &a)
Whether a is standard.
unsigned star_height(const typename ExpSet::value_t &e)
Star height of an expression.
context make_word_context(const context &ctx)
Bridge.
bool is_synchronized_by(const Aut &aut, const word_t_of< Aut > &w)
Whether w synchronizes automaton aut.
expression conjunction_expression(const expression &lhs, const expression &rhs)
Bridge (conjunction).
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...
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 > split(const ExpSet &rs, const typename ExpSet::value_t &e)
Split an expression.
auto multiply(const Aut1 &lhs, const Aut2 &rhs, Tag tag={}) -> decltype(lhs->null_state(), detail::make_join_automaton(tag, lhs, rhs))
Concatenate two automata, general case.
Ctx make_context(const std::string &name)