Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
algos.hh
Go to the documentation of this file.
1 #ifndef VCSN_DYN_ALGOS_HH
2 # define VCSN_DYN_ALGOS_HH
3 
4 # include <iosfwd>
5 # include <string>
6 # include <vector>
7 
8 # include <vcsn/algos/fwd.hh>
10 # include <vcsn/ctx/fwd.hh>
11 # include <vcsn/dyn/fwd.hh>
12 # include <vcsn/misc/direction.hh>
13 # include <vcsn/misc/export.hh>
14 
15 namespace vcsn
16 {
17  namespace dyn LIBVCSN_API
18  {
20  automaton accessible(const automaton& aut);
21 
23  label ambiguous_word(const automaton& aut);
24 
28  bool are_equivalent(const automaton& lhs, const automaton& rhs);
29 
33  bool are_equivalent(const ratexp& lhs, const ratexp& rhs);
34 
37  bool are_isomorphic(const automaton& lhs, const automaton& rhs);
38 
40  automaton blind(automaton& aut, unsigned tape);
41 
43  automaton cerny(const context& ctx, unsigned num_states);
44 
46  automaton chain(const automaton& aut, int min, int max);
47 
49  ratexp chain(const ratexp& e, int min, int max);
50 
52  automaton coaccessible(const automaton& aut);
53 
59  automaton complement(const automaton& aut);
60 
62  ratexp complement(const ratexp& r);
63 
66  automaton complete(const automaton& aut);
67 
70 
72  automaton concatenate(const automaton& lhs, const automaton& rhs);
73 
75  polynomial concatenate(const polynomial& lhs, const polynomial& rhs);
76 
78  ratexp concatenate(const ratexp& lhs, const ratexp& rhs);
79 
81  ratexp conjunction(const ratexp& lhs, const ratexp& rhs);
82 
84  weight constant_term(const ratexp& e);
85 
87  context context_of(const automaton& a);
88 
90  context context_of(const ratexp& r);
91 
93  automaton copy(const automaton& aut);
94 
96  automaton copy(const automaton& aut, const context& ctx);
97 
99  ratexp copy(const ratexp& exp, const ratexpset& rs);
100 
102  automaton costandard(const automaton& a);
103 
105  automaton de_bruijn(const context& ctx, unsigned n);
106 
112  polynomial derivation(const ratexp& exp, const label& l,
113  bool breaking = false);
114 
123  automaton derived_term(const ratexp& e,
124  const std::string& algo = "auto");
125 
134  automaton determinize(const automaton& aut,
135  const std::string& algo = "weighted");
136 
145  automaton codeterminize(const automaton& aut,
146  const std::string& algo = "weighted");
147 
153  automaton cominimize(const automaton& aut,
154  const std::string& algo = "auto");
155 
161  automaton difference(const automaton& lhs, const automaton& rhs);
162 
164  ratexp difference(const ratexp& lhs, const ratexp& rhs);
165 
168  automaton divkbaseb(const context& ctx, unsigned divisor, unsigned base);
169 
176  std::ostream& dot(const automaton& aut, std::ostream& out,
177  bool dot2tex = false);
178 
180  std::string dot(const automaton& aut);
181 
183  automaton double_ring(const context& ctx, unsigned n,
184  const std::vector<unsigned>& f);
185 
187  automaton eliminate_state(const automaton& aut, int s);
188 
190  std::ostream& efsm(const automaton& aut, std::ostream& out);
191 
193  polynomial enumerate(const automaton& aut, unsigned max);
194 
196  weight eval(const automaton& aut, const label& l);
197 
200  ratexp expand(const ratexp& e);
201 
203  automaton factor(const automaton& aut);
204 
206  std::ostream& fado(const automaton& aut, std::ostream& out);
207 
209  automaton filter(const automaton& aut, const std::vector<unsigned>& ss);
210 
212  std::ostream& grail(const automaton& aut, std::ostream& out);
213 
215  bool has_twins_property(const automaton& aut);
216 
218  rat::identities identities(const ratexp& exp);
219 
222  automaton infiltration(const automaton& lhs, const automaton& rhs);
223 
226  automaton infiltration(const std::vector<automaton>& as);
227 
233  std::ostream& info(const automaton& aut, std::ostream& out,
234  bool detailed = false);
235 
237  std::ostream& info(const ratexp& exp, std::ostream& out);
238 
243  automaton insplit(const automaton& aut);
244 
246  bool is_accessible(const automaton& aut);
247 
250  bool is_ambiguous(const automaton& aut);
251 
253  bool is_coaccessible(const automaton& aut);
254 
257  bool is_codeterministic(const automaton& aut);
258 
261  bool is_complete(const automaton& aut);
262 
265  bool is_costandard(const automaton& aut);
266 
268  bool is_cycle_ambiguous(const automaton& aut);
269 
272  bool is_deterministic(const automaton& aut);
273 
275  bool is_empty(const automaton& aut);
276 
278  bool is_eps_acyclic(const automaton& aut);
279 
282  bool is_functional(const automaton& aut);
283 
286  bool is_normalized(const automaton& aut);
287 
289  bool is_out_sorted(const automaton& aut);
290 
292  bool is_proper(const automaton& aut);
293 
296  bool is_standard(const automaton& aut);
297 
299  bool is_synchronized_by(const automaton& aut, const label& word);
300 
302  bool is_synchronizing(const automaton& aut);
303 
305  bool is_trim(const automaton& aut);
306 
308  bool is_useless(const automaton& aut);
309 
311  bool is_valid(const automaton& e);
312 
315  bool is_valid(const ratexp& e);
316 
322  automaton minimize(const automaton& aut,
323  const std::string& algo = "auto");
324 
326  automaton ladybird(const context& ctx, unsigned n);
327 
330  automaton left_mult(const weight& w, const automaton& aut);
331 
333  ratexp left_mult(const weight& w, const ratexp& aut);
334 
336  automaton lift(const automaton& aut);
337 
339  ratexp lift(const ratexp& e);
340 
342  context make_context(const std::string& name);
343 
345  automaton_editor* make_automaton_editor(const context& ctx);
346 
349 
351  context make_word_context(const context& ctx);
352 
354  weight multiply(const weight& lhs, const weight& rhs);
355 
357  automaton normalize(const automaton& aut);
358 
360  automaton pair(const automaton& aut, bool keep_initials = false);
361 
363  automaton prefix(const automaton& aut);
364 
366  automaton power(const automaton& aut, unsigned n);
367 
369  std::ostream& print(const automaton& a, std::ostream& o,
370  const std::string& format = "default");
371 
373  std::ostream& print(const context& c, std::ostream& o,
374  const std::string& format = "default");
375 
377  std::ostream& print(const expansion& e, std::ostream& o,
378  const std::string& format = "default");
379 
381  std::ostream& print(const label& l, std::ostream& o,
382  const std::string& format = "default");
383 
385  std::ostream& print(const polynomial& p, std::ostream& o,
386  const std::string& format = "default");
387 
389  std::ostream& print(const ratexp& e, std::ostream& o,
390  const std::string& format = "default");
391 
393  std::ostream& print(const weight& w, std::ostream& o,
394  const std::string& format = "default");
395 
397  void set_format(std::ostream& o, const std::string& format);
398 
400  std::string get_format(std::ostream& o);
401 
404  automaton product(const automaton& lhs, const automaton& rhs);
405 
408  automaton product(const std::vector<automaton>& as);
409 
414  automaton proper(const automaton& aut,
416  bool prune = true);
417 
419  automaton push_weights(const automaton& aut);
420 
439  unsigned num_states,
440  float density = 0.1,
441  unsigned num_initial = 1,
442  unsigned num_final = 1);
443 
450  unsigned num_states);
451 
455  automaton read_automaton(std::istream& is,
456  const std::string& format = "default");
457 
461  label read_label(std::istream& is, const context& ctx);
462 
467  ratexp read_ratexp(std::istream& is, const ratexpset& rs,
468  const std::string& format = "default");
469 
473  polynomial read_polynomial(std::istream& is, const context& ctx);
474 
478  weight read_weight(std::istream& is, const context& ctx);
479 
481  automaton reduce(const automaton& aut);
482 
485  automaton right_mult(const automaton& aut, const weight& w);
486 
488  ratexp right_mult(const ratexp& aut, const weight& w);
489 
491  std::size_t num_sccs(const automaton& aut);
492 
494  polynomial shortest(const automaton& aut, unsigned max = 1);
495 
498  automaton shuffle(const automaton& lhs, const automaton& rhs);
499 
502  automaton shuffle(const std::vector<automaton>& as);
503 
506  ratexp shuffle(const ratexp& lhs, const ratexp& rhs);
507 
509  automaton sort(const automaton& a);
510 
512  polynomial split(const polynomial& p);
513 
515  polynomial split(const ratexp& exp);
516 
518  automaton standard(const automaton& a);
519 
521  automaton standard(const ratexp& e);
522 
524  automaton star(const automaton& aut);
525 
527  unsigned star_height(const ratexp& rs);
528 
531  ratexp star_normal_form(const ratexp& e);
532 
534  automaton strip(const automaton& a);
535 
537  automaton suffix(const automaton& aut);
538 
543  automaton subword(const automaton& aut);
544 
546  automaton sum(const automaton& lhs, const automaton& rhs);
547 
549  polynomial sum(const polynomial& lhs, const polynomial& rhs);
550 
552  ratexp sum(const ratexp& lhs, const ratexp& rhs);
553 
555  weight sum(const weight& lhs, const weight& rhs);
556 
559  const std::string& algo = "greedy");
560 
562  automaton thompson(const ratexp& e);
563 
565  std::ostream& tikz(const automaton& aut, std::ostream& out);
566 
569  expansion to_expansion(const ratexp& exp);
570 
572  ratexp to_expression(const automaton& aut,
573  const std::string& algo = "auto");
574 
577 
579  ratexp transpose(const ratexp& e);
580 
582  ratexp transposition(const ratexp& r);
583 
585  automaton trim(const automaton& aut);
586 
588  automaton u(const context& ctx, unsigned n);
589 
592  automaton union_a(const automaton& lhs, const automaton& rhs);
593 
595  automaton universal(const automaton& aut);
596 
597  }
598 }
599 
600 namespace std LIBVCSN_API
601 {
603  std::ostream& operator<<(std::ostream& o, const vcsn::dyn::automaton& a);
604 
606  std::ostream& operator<<(std::ostream& o, const vcsn::dyn::context& c);
607 
609  std::ostream& operator<<(std::ostream& o, const vcsn::dyn::expansion& e);
610 
612  std::ostream& operator<<(std::ostream& o, const vcsn::dyn::label& l);
613 
615  std::ostream& operator<<(std::ostream& o, const vcsn::dyn::polynomial& p);
616 
618  std::ostream& operator<<(std::ostream& o, const vcsn::dyn::ratexp& e);
619 
621  std::ostream& operator<<(std::ostream& o, const vcsn::dyn::weight& w);
622 }
623 
624 #endif // !VCSN_DYN_ALGOS_HH
context make_context(const std::string &name)
Build a context from its name.
Definition: make-context.cc:38
bool is_standard(const automaton &aut)
Whether is standard (unique initial state, with weight one, no incoming transition).
Definition: standard.cc:16
automaton proper(const automaton &aut, direction dir=direction::backward, bool prune=true)
An equivalent automaton without spontaneous transitions.
Definition: proper.cc:13
bool are_equivalent(const automaton &lhs, const automaton &rhs)
Whether define the same language.
automaton suffix(const automaton &aut)
Create a suffix automaton from aut.
Definition: prefix.cc:25
automaton transpose(automaton &aut)
Transpose aut.
Definition: transpose.cc:16
automaton blind(automaton &aut, unsigned tape)
Focus on a specific tape of a tupleset automaton.
Definition: blind.cc:14
label read_label(std::istream &is, const context &ctx)
Read a label from a stream.
Definition: read.cc:52
automaton random_automaton_deterministic(const context &ctx, unsigned num_states)
Produce a random deterministic automaton.
Definition: random.cc:25
ratexp star_normal_form(const ratexp &e)
A normalized form where star is applied only to expression without null constant-term.
std::shared_ptr< detail::automaton_base > automaton
Definition: automaton.hh:71
automaton star(const automaton &aut)
Star of a standard automaton.
Definition: star.cc:13
std::string get_format(std::ostream &o)
Get the output format for o.
Definition: print.cc:211
bool is_useless(const automaton &aut)
Whether has no useful state.
Definition: accessible.cc:60
bool is_proper(const automaton &aut)
Whether has no spontaneous transition.
Definition: is-proper.cc:16
automaton product(const automaton &lhs, const automaton &rhs)
The product of automata lhs and rhs.
Definition: product.cc:16
bool is_out_sorted(const automaton &aut)
Whether the outgoing transitions of each state have increasing labels.
Definition: sort.cc:12
automaton minimize(const automaton &aut, const std::string &algo="auto")
The minimized automaton.
Definition: minimize.cc:13
automaton difference(const automaton &lhs, const automaton &rhs)
An automaton whose behavior is that of lhs on words not accepted by rhs.
std::ostream & operator<<(std::ostream &o, type_t t)
Definition: printer.hxx:16
bool is_trim(const automaton &aut)
Whether has no useless state.
Definition: accessible.cc:52
ratexpset make_ratexpset(const context &ctx,::vcsn::rat::identities is)
Build an ratexpset from its context.
Definition: make-context.cc:57
automaton random_automaton(const context &ctx, unsigned num_states, float density=0.1, unsigned num_initial=1, unsigned num_final=1)
Produce a random automaton.
Definition: random.cc:13
automaton ladybird(const context &ctx, unsigned n)
The ladybird automaton with n states.
Definition: ladybird.cc:13
bool is_functional(const automaton &aut)
Whether aut is functional.
std::ostream & print(const automaton &a, std::ostream &o, const std::string &format="default")
Print automaton a on o using format format.
Definition: print.cc:21
automaton shuffle(const automaton &lhs, const automaton &rhs)
The shuffle product of automata lhs and rhs.
Definition: product.cc:34
polynomial enumerate(const automaton &aut, unsigned max)
All the accepted words of at most max letters.
Definition: enumerate.cc:20
automaton push_weights(const automaton &aut)
The weight pushing automaton of aut.
Definition: push-weights.cc:17
automaton double_ring(const context &ctx, unsigned n, const std::vector< unsigned > &f)
The double_ring automaton with n states and f the list of finals.
Definition: double-ring.cc:15
automaton cominimize(const automaton &aut, const std::string &algo="auto")
The cominimized automaton.
Definition: minimize.cc:27
automaton union_a(const automaton &lhs, const automaton &rhs)
Union of two automata (plain graph union).
Definition: union.cc:12
automaton right_mult(const automaton &aut, const weight &w)
The right-mult automaton with w as weight.
Definition: left-mult.cc:26
context context_of(const automaton &a)
The context of this automaton.
Definition: make-context.cc:20
std::shared_ptr< const detail::weight_base > weight
Definition: fwd.hh:82
bool is_cycle_ambiguous(const automaton &aut)
Whether the automaton is cycle-ambiguous.
Definition: is-ambiguous.cc:25
bool is_normalized(const automaton &aut)
Whether is normalized (in the Thompson sense), i.e., standard and co-standard.
Definition: normalize.cc:17
automaton chain(const automaton &aut, int min, int max)
Repeated concatenation of aut with itself.
Definition: concatenate.cc:18
automaton filter(const automaton &aut, const std::vector< unsigned > &ss)
The subautomaton based on aut, with only states in ss visible.
Definition: filter.cc:18
polynomial split(const polynomial &p)
Break all the expressions in p.
Definition: derivation.cc:62
rat::identities identities(const ratexp &exp)
The identities of ratexp exp.
Definition: identities.cc:13
automaton determinize(const automaton &aut, const std::string &algo="weighted")
The determinized automaton.
Definition: determinize.cc:13
std::shared_ptr< detail::ratexp_base > ratexp
Definition: fwd.hh:64
bool is_complete(const automaton &aut)
Whether aut is complete.
Definition: is-complete.cc:17
automaton trim(const automaton &aut)
The useful subautomaton of aut.
Definition: accessible.cc:28
automaton divkbaseb(const context &ctx, unsigned divisor, unsigned base)
An automaton which accepts a word n representing a number in base b iff k|n.
Definition: divkbaseb.cc:13
expansion to_expansion(const ratexp &exp)
First order development of a exp.
Definition: derivation.cc:40
ratexp expand(const ratexp &e)
Distribute product over addition recursively under the starred subexpressions and group the equal mon...
Definition: expand.cc:16
automaton normalize(const automaton &aut)
Normalize automaton aut.
Definition: normalize.cc:32
automaton subword(const automaton &aut)
Create a subword automaton from aut.
Definition: prefix.cc:41
automaton standard(const automaton &a)
A standardized a.
Definition: standard.cc:38
bool is_codeterministic(const automaton &aut)
Whether aut is codeterministic.
bool is_valid(const automaton &e)
Whether automaton is valid (epsilon-cycles converge).
Definition: is-valid.cc:18
automaton prefix(const automaton &aut)
Create a prefix automaton from aut.
Definition: prefix.cc:17
automaton left_mult(const weight &w, const automaton &aut)
The left-multiplication of an automaton with w as weight.
Definition: left-mult.cc:12
automaton accessible(const automaton &aut)
The accessible subautomaton of aut.
Definition: accessible.cc:12
automaton sort(const automaton &a)
A copy of a with normalized state numbers.
Definition: sort.cc:19
weight constant_term(const ratexp &e)
The weight associated to the empty word in e.
automaton copy(const automaton &aut)
A copy of aut.
Definition: copy.cc:16
context make_word_context(const context &ctx)
The context for words.
Definition: make-context.cc:68
automaton costandard(const automaton &a)
A standardized transpositive a.
Definition: standard.cc:49
std::size_t num_sccs(const automaton &aut)
The number of strongly connected components.
Definition: scc.cc:18
bool is_accessible(const automaton &aut)
Whether aut is accessible.
Definition: accessible.cc:36
std::shared_ptr< const detail::expansion_base > expansion
Definition: expansion.hh:74
automaton pair(const automaton &aut, bool keep_initials=false)
Build the pair automaton of the given automaton.
automaton complete(const automaton &aut)
A completed copy of aut.
Definition: complete.cc:17
std::shared_ptr< const detail::ratexpset_base > ratexpset
Definition: fwd.hh:73
bool is_coaccessible(const automaton &aut)
Whether aut is coaccessible.
Definition: accessible.cc:44
automaton_editor * make_automaton_editor(const context &ctx)
Build an automatonset from its context.
automaton sum(const automaton &lhs, const automaton &rhs)
Sum of two standard automata.
Definition: sum.cc:13
bool are_isomorphic(const automaton &lhs, const automaton &rhs)
Whether there exists an isomorphism between the states of lhs and those of rhs.
weight read_weight(std::istream &is, const context &ctx)
Read a weight from a stream.
Definition: read.cc:89
std::istringstream is
The input stream: the specification to translate.
Definition: translate.cc:329
std::ostream & grail(const automaton &aut, std::ostream &out)
Output in Grail format.
Definition: grail.cc:17
label ambiguous_word(const automaton &aut)
An ambiguous word, or raise if there is none.
Definition: is-ambiguous.cc:11
std::ostream & fado(const automaton &aut, std::ostream &out)
Output in FAdo format.
Definition: fado.cc:109
automaton codeterminize(const automaton &aut, const std::string &algo="weighted")
The codeterminized automaton.
Definition: determinize.cc:21
automaton de_bruijn(const context &ctx, unsigned n)
A simple NFA for (a+b)*a(a+b)^n.
Definition: de-bruijn.cc:13
bool is_synchronized_by(const automaton &aut, const label &word)
Whether the word synchronizes aut.
ratexp to_expression(const automaton &aut, const std::string &algo="auto")
A ratexp denoting the language of aut.
polynomial read_polynomial(std::istream &is, const context &ctx)
Read a polynomial from a stream.
Definition: read.cc:78
bool is_synchronizing(const automaton &aut)
Whether is synchronizing.
bool has_twins_property(const automaton &aut)
Whether the automaton has the twins property.
std::shared_ptr< const detail::label_base > label
Definition: fwd.hh:46
automaton factor(const automaton &aut)
Create a factor automaton from aut.
Definition: prefix.cc:33
automaton derived_term(const ratexp &e, const std::string &algo="auto")
The derived-term automaton of e.
Definition: derivation.cc:29
automaton insplit(const automaton &aut)
Split automaton on the incoming transition.
Definition: insplit.cc:17
std::shared_ptr< const detail::context_base > context
Definition: context.hh:71
automaton power(const automaton &aut, unsigned n)
Repeated product of aut with itself.
Definition: product.cc:77
polynomial derivation(const ratexp &exp, const label &l, bool breaking=false)
Derive exp with respect to s.
Definition: derivation.cc:18
bool is_costandard(const automaton &aut)
Whether is costandard (unique final state, with weight one, no outcoming transition).
Definition: standard.cc:27
weight eval(const automaton &aut, const label &l)
Evaluate s on aut.
Definition: eval.cc:13
std::ostream & tikz(const automaton &aut, std::ostream &out)
Output aut in LaTeX's TikZ format.
Definition: tikz.cc:17
automaton infiltration(const automaton &lhs, const automaton &rhs)
The infiltration of automata lhs and rhs.
Definition: product.cc:59
automaton read_automaton(std::istream &is, const std::string &format="default")
Read an automaton from a stream.
Definition: read.cc:34
bool is_empty(const automaton &aut)
Whether has no state.
Definition: accessible.cc:68
label synchronizing_word(const automaton &aut, const std::string &algo="greedy")
A synchronizing word, or raise if there is none.
#define LIBVCSN_API
Definition: export.hh:9
ratexp read_ratexp(std::istream &is, const ratexpset &rs, const std::string &format="default")
Read a ratexp from a stream.
Definition: read.cc:62
automaton u(const context &ctx, unsigned n)
The Brzozowski universal witness.
Definition: u.cc:13
ratexp transposition(const ratexp &r)
Add the transposition operator to r.
Definition: transpose.cc:36
automaton complement(const automaton &aut)
The complement of aut.
Definition: complement.cc:12
direction
Orientation.
Definition: direction.hh:10
automaton cerny(const context &ctx, unsigned num_states)
Produce a Černý automaton of num_states states.
Looking upstream.
automaton universal(const automaton &aut)
The universal automaton of aut.
Definition: universal.cc:13
automaton lift(const automaton &aut)
The lifted LAO automaton from aut.
Definition: lift.cc:17
automaton thompson(const ratexp &e)
The Thompson automaton of e.
Definition: thompson.cc:13
automaton reduce(const automaton &aut)
Reduce aut.
Definition: minimize.cc:20
automaton compose(automaton &lhs, automaton &rhs)
The composition of transducers lhs and rhs.
Definition: compose.cc:13
weight multiply(const weight &lhs, const weight &rhs)
Multiply two weights.
Definition: concatenate.cc:46
std::ostream & dot(const automaton &aut, std::ostream &out, bool dot2tex=false)
Output aut in GraphViz' Dot format.
Definition: dot.cc:17
automaton concatenate(const automaton &lhs, const automaton &rhs)
Concatenate two standard automata.
Definition: concatenate.cc:11
bool is_eps_acyclic(const automaton &aut)
Whether has no cycle of spontaneous transitions.
identities
A ratexpset can implement several different sets of identities on expressions.
Definition: identities.hh:17
std::ostream & info(const automaton &aut, std::ostream &out, bool detailed=false)
Output various facts about an automaton.
Definition: info.cc:17
void set_format(std::ostream &o, const std::string &format)
Specify the output format for o.
Definition: print.cc:203
std::ostream & efsm(const automaton &aut, std::ostream &out)
Output in Extended FSM format.
Definition: efsm.cc:157
bool is_ambiguous(const automaton &aut)
Whether aut is ambiguous.
Definition: is-ambiguous.cc:18
automaton coaccessible(const automaton &aut)
The coaccessible subautomaton of aut.
Definition: accessible.cc:20
std::shared_ptr< const detail::polynomial_base > polynomial
Definition: fwd.hh:55
polynomial shortest(const automaton &aut, unsigned max=1)
The at-most max first accepted words.
Definition: enumerate.cc:12
variadic_mul_mixin< detail::r_impl > r
Definition: fwd.hh:42
automaton eliminate_state(const automaton &aut, int s)
The LAO automaton aut with state s removed.
bool is_deterministic(const automaton &aut)
Whether aut is deterministic.
automaton strip(const automaton &a)
The automaton in a with its metadata layers removed.
Definition: strip.cc:11
unsigned star_height(const ratexp &rs)
Star height of a ratexp.
Definition: star-height.cc:17
ratexp conjunction(const ratexp &lhs, const ratexp &rhs)
The Hadamard product of ratexps lhs and rhs.
Definition: product.cc:84