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

expression.zpc(algo="auto")

Generate the ZPC automaton from an expression. Its initial state is final and has the weight of its constant term. It can take an optionnal argument valued with "compact" to enable the compact variant construction.

The algo can be:

  • "auto": same as "regular".

  • "compact": use an alternate implementation for sum and product which requires fewer states.

  • "regular": produce the "pure" version of the ZPC automaton.

Post-condition:

  • Result.is_eps_acyclic()

  • There is no spontaneous path from the initial state to final the state.

Caveats:

  • the context of the result might be different from the original context: spontaneous-transition support is required.

See also:

Examples

The ZPC 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.

import vcsn vcsn.B.expression('a[bc]d').zpc()
Image in a Jupyter notebook

You can also ask for the compact version of the algorithm that way:

vcsn.B.expression('a[bc]d').zpc('compact')
Image in a Jupyter notebook

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.

vcsn.B.expression("a").zpc().context()

({a,b,c,d,})?B(\{a, b, c, d, \ldots\})^?\to\mathbb{B}

Weighted expressions

Weights are supported.

r = vcsn.Q.expression('(<1/3>a*+<1/6>b*)*') r

(13a+16b)\left( \left\langle \frac{1}{3} \right\rangle \,{a}^{*} + \left\langle \frac{1}{6} \right\rangle \,{b}^{*}\right)^{*}

r.zpc()
Image in a Jupyter notebook

And the compact version:

r.zpc('compact')
Image in a Jupyter notebook