automaton.add(aut,algo="auto")

Build an automaton whose behavior is the sum of the behaviors of the input automata.

The algorithm has to be one of these:

  • "auto": default parameter, same as "standard" if parameters fit the standard preconditions, "general" otherwise.
  • "deterministic": deterministic sum of two deterministic automata.
  • "general": general addition or union, no additional preconditions.
  • "standard": standard addition.

Preconditions:

  • "determistic": both automata have to be determinism.
  • "standard": automaton has to be standard.

Postconditions:

  • "standard": the result automaton is standard.

If algo is "deterministic" and the weightset is Boolean, a more efficient algorithm based on the conjunction is used.

In [1]:
import vcsn
ctx = vcsn.context('lal_char, b')
aut = lambda e: ctx.expression(e).standard()

Examples

Sum of standard automata.

In [2]:
aut('a') + aut('b')
Out[2]:
%3 I0 0 0 I0->0 F1 F2 1 1 0->1 a 2 2 0->2 b 1->F1 2->F2
In [3]:
aut('a').add(aut('b'), "general")
Out[3]:
%3 I0 0 0 I0->0 I2 2 2 I2->2 F1 F3 1 1 0->1 a 1->F1 3 3 2->3 b 3->F3

Sum of non standard automata.

In [4]:
%%automaton -s a
context = "lal_char, q"
$ -> 0
1 -> 0 b
0 -> 1 a
1 -> $ <2>
%3 I0 0 0 I0->0 F1 1 1 0->1 a 1->F1 ⟨2⟩ 1->0 b
In [5]:
a+a
Out[5]:
%3 I0 0 0 I0->0 F1 1 1 0->1 a 1->F1 ⟨4⟩ 1->0 b

Sum of deterministic automata.

In [6]:
aut('ab').add(aut('ac'), algo='deterministic')
Out[6]:
%3 I0 0 0, 0 I0->0 F2 F3 1 1, 1 0->1 a 2 3, post 1->2 b 3 post, 3 1->3 c 2->F2 3->F3