automaton.project

Create a copy of the automaton and keeping only the selected tape of the original automaton's label.

Preconditions:

  • the original automaton has tuple labels.
  • the tape number is smaller than the tuples' size.

Examples

In [1]:
import vcsn
ctx = vcsn.context("lat<lal_char(ab), lan_char(cd), lal_char(ef)>, q")
In [2]:
a = ctx.expression("(a|c|f)(a|\e|f)+(b|c|e)*").automaton()
a
Out[2]:
%3 I0 0 0 I0->0 F0 F2 F3 0->F0 1 1 0->1 a|c|f 2 2 0->2 b|c|e 3 3 1->3 a|ε|f 2->F2 2->2 b|c|e 3->F3
In [3]:
a.project(0)
Out[3]:
%3 I0 0 0 I0->0 F0 F2 F3 0->F0 1 1 0->1 a 2 2 0->2 b 3 3 1->3 a 2->F2 2->2 b 3->F3
In [4]:
a.project(1)
Out[4]:
%3 I0 0 0 I0->0 F0 F2 F3 0->F0 1 1 0->1 c 2 2 0->2 c 3 3 1->3 ε 2->F2 2->2 c 3->F3
In [5]:
a.project(2)
Out[5]:
%3 I0 0 0 I0->0 F0 F2 F3 0->F0 1 1 0->1 f 2 2 0->2 e 3 3 1->3 f 2->F2 2->2 e 3->F3

If after the projection two transitions are equivalent, they are fused into one using the weightset's addition.

In [6]:
a = ctx.expression("a|c|e + a|c|f").automaton()
a
Out[6]:
%3 I0 0 0 I0->0 F1 1 1 0->1 a|c|e, a|c|f 1->F1
In [7]:
a.project(0)
Out[7]:
%3 I0 0 0 I0->0 F1 1 1 0->1 ⟨2⟩a 1->F1
In [8]:
a.project(1)
Out[8]:
%3 I0 0 0 I0->0 F1 1 1 0->1 ⟨2⟩c 1->F1
In [9]:
a.project(2)
Out[9]:
%3 I0 0 0 I0->0 F1 1 1 0->1 e, f 1->F1