Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 45896
Kernel: Python 3

expression.automaton(algo="auto")

Generate an automaton from an expression.

The algo can be:

Precondition:

  • "standard", "thompson", "zpc", "zpc,compact": the expression is not extended

See also:

Examples

import vcsn from IPython.display import display e = vcsn.Q.expression('\e+<2>a+<3>b') e

ε+⟨2⟩ a+⟨3⟩ b\varepsilon + \left\langle 2 \right\rangle \,a + \left\langle 3 \right\rangle \,b

e.automaton('derived_term')
Image in a Jupyter notebook
e.automaton('inductive')
Image in a Jupyter notebook
e.automaton('standard')
Image in a Jupyter notebook
e.automaton('thompson')
Image in a Jupyter notebook
e.automaton('zpc')
Image in a Jupyter notebook
e.automaton('zpc,compact')
Image in a Jupyter notebook

Trimming

The automata are guaranteed to be trim, even if the algorithm used by automaton generated useless states.

e = vcsn.Q.expression('abc&abd') e.derived_term()
Image in a Jupyter notebook
e.automaton('derived_term')
Image in a Jupyter notebook
e = vcsn.Q.expression('a?') e.zpc()
Image in a Jupyter notebook
e.automaton('zpc')
Image in a Jupyter notebook

Extended Rational Expressions

The derived-term based algorithms and "inductive" support extended expressions.

def aut(e): e = vcsn.context('lal, q').expression(e) for a in ['expansion', 'inductive']: print(a) display(e.automaton(a)) aut('(ab*c){T}')
expansion
Image in a Jupyter notebook
inductive
Image in a Jupyter notebook
aut('[ab]*a[ab]{1} & [ab]*a[ab]{2} & [ab]*a[ab]{3}')
expansion
Image in a Jupyter notebook
inductive
Image in a Jupyter notebook
aut('(a*b*){c}')
expansion
Image in a Jupyter notebook
inductive
Image in a Jupyter notebook