automaton.sum(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.
  • "general": general addition or union, no additional preconditions.
  • "standard": standard addition.

Preconditions:

  • "standard": automaton has to be standard.

Postconditions:

  • "standard": the result automaton is standard.
In [1]:
import vcsn
ctx = vcsn.context('lal_char, q')
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').sum(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 I2 2 2 I2->2 F1 F3 1 1 0->1 a 1->F1 ⟨2⟩ 1->0 b 3 3 2->3 a 3->F3 ⟨2⟩ 3->2 b