automaton.eval(w)

Evaluates the weight of the given word through the automata.

Preconditions:

  • $w$ must be a valid word in the labelset
  • automaton must be proper
  • labelset must be free

Examples

In [1]:
import vcsn
In [2]:
a = vcsn.context('lal(ab), b').de_bruijn(2)
a
Out[2]:
%3 I0 0 0 I0->0 F3 0->0 a, b 1 1 0->1 a 2 2 1->2 a, b 3 3 2->3 a, b 3->F3
In [3]:
a.eval('b')
Out[3]:
$\bot$
In [4]:
a.eval('bbabb')
Out[4]:
$\top$

You can also write automaton('word') to evaluate a word:

In [5]:
a('bbabb')
Out[5]:
$\top$
In [6]:
a = vcsn.Z.expression('(<2>C+c)los(<3>e(s+<4>d)+ing)').standard()
a.shortest(10)
Out[6]:
$\left\langle 24\right\rangle \mathit{Closed} \oplus \left\langle 6\right\rangle \mathit{Closes} \oplus \left\langle 12\right\rangle \mathit{closed} \oplus \left\langle 3\right\rangle \mathit{closes} \oplus \left\langle 2\right\rangle \mathit{Closing} \oplus \mathit{closing}$
In [7]:
a.eval('Closing')
Out[7]:
$2$
In [8]:
a.eval('close') # but not enough
Out[8]:
$0$