Generate the Thompson automaton from an expression.
Caveats:
Result.is_valid()
Properties:
Result.proper().is_isomorphic(r.standard())
See also:
The Thompson procedure generates an automaton with spontaneous-transitions, which requires a labelset that feature a "one" label. The nullableset and wordset labelsets (and their compositions) does support a "one" label.
In [1]:
import vcsn
from IPython.display import display
vcsn.context('lan_char, b').expression('a[bc]d').thompson()
Out[1]:
In [2]:
vcsn.context('law_char, b').expression("'aa'[bc]'dd'").thompson()
Out[2]:
You may, however, use a labelset which does not feature a "one", in which case the context of the automaton will be different from the one of the expression.
In [3]:
vcsn.context('lal_char, b').expression("a").thompson().context()
Out[3]:
Weights are supported.
In [4]:
r = vcsn.context('lan_char(abc), q').expression('(<1/6>a*+<1/3>b*)*')
r
Out[4]:
In [5]:
t = r.thompson()
t
Out[5]:
In [6]:
t.proper()
Out[6]:
In [7]:
r.standard()
Out[7]:
Note however that you may generate invalid automata:
In [8]:
t = vcsn.context('lan_char(abc), q').expression('\e*').thompson()
t
Out[8]:
In [9]:
t.is_valid()
Out[9]: