automaton.transpose

Transpose the automaton, i.e., change the direction of all the arrows (i.e., change the direction of the transitions, and exchance initial and final states), and transpose their labels and weights.

Also known as:

  • reverse

Preconditions:

  • None

Properties:

  • involution

See also:

Examples

In [1]:
import vcsn
lb = vcsn.context('lal_char(a-z), b')
wb = vcsn.context('law_char(a-z), b')
In [2]:
lba = lb.expression('(ab)(cd)(ef)').derived_term()
lba
Out[2]:
%3 I0 0 abcdef I0->0 F6 1 bcdef 0->1 a 2 cdef 1->2 b 3 def 2->3 c 4 ef 3->4 d 5 f 4->5 e 6 ε 5->6 f 6->F6
In [3]:
lba.transpose()
Out[3]:
%3 I6 6 ε I6->6 F0 0 abcdef 0->F0 1 bcdef 1->0 a 2 cdef 2->1 b 3 def 3->2 c 4 ef 4->3 d 5 f 5->4 e 6->5 f

Transposing a transposed automaton returns the original automaton.

In [4]:
lba.transpose().transpose()
Out[4]:
%3 I0 0 abcdef I0->0 F6 1 bcdef 0->1 a 2 cdef 1->2 b 3 def 2->3 c 4 ef 3->4 d 5 f 4->5 e 6 ε 5->6 f 6->F6
In [5]:
lba == lba.transpose().transpose()
Out[5]:
True

Of course labels and weights are transposed too when it applies.

In [6]:
wb.expression('(abc)(def)').derived_term()
Out[6]:
%3 I0 0 (abc)(def) I0->0 F2 1 def 0->1 abc 2 ε 1->2 def 2->F2
In [7]:
_.transpose()
Out[7]:
%3 I2 2 ε I2->2 F0 0 (abc)(def) 0->F0 1 def 1->0 cba 2->1 fed