automaton.star(algo = "auto")

Build an automaton that recognizes the Kleene star of the input automaton.

The algorithm has to be one of these:

  • "general": general star, no additional preconditions.
  • "standard": standard star.
  • "auto": default parameter, same as "standard" if parameters fit the standard preconditions, "general" otherwise.

Preconditions:

  • "standard": automaton has to be standard.

Postconditions:

  • "standard": the result automaton is standard.
  • "general": the context of the result automaton is nullable.

See also:


In [1]:
import vcsn

This is what the general algorithm for star outputs, given an automaton A and s being a new state.

The transition from s to A represents each initial transition of A.

The transition from A to s represents each final transition of A.


In [2]:
%%automaton a
context = "lan_char, b"
$ -> s
s -> A \e
A -> s \e
s -> $


%3 I0 0 s I0->0 F0 0->F0 1 A 0->1 ε 1->0 ε

In [3]:
ctx = vcsn.context('lal_char, q')
aut = lambda e: ctx.expression(e).standard()

Examples

Standard


In [4]:
aut('a+b').star("standard")


Out[4]:
%3 I0 0 0 I0->0 F0 F1 F2 0->F0 1 1 0->1 a 2 2 0->2 b 1->F1 1->1 a 1->2 b 2->F2 2->1 a 2->2 b

General


In [5]:
aut('a+b').star("general")


Out[5]:
%3 I3 3 3 I3->3 F1 F2 F3 0 0 1 1 0->1 a 2 2 0->2 b 1->F1 1->3 ε 2->F2 2->3 ε 3->F3 3->0 ε