ratexp
.derived_term(
algo
="expansion")
¶Generate the derived-term automaton from an expression.
The algorithm can be:
derivation
: rely on the ratexp.derivation
.breaking_derivation
: likewise, but split
the polynomials at each stepexpansion
: rely on the ratexp.expansion
.breaking_expansion
: likewise, but split
the polynomials at each stepAlso known as:
See also:
References:
import vcsn
In the classical case (labels are letters, and weights are Boolean), this is the construct as described by Antimirov.
b = vcsn.context('lal_char(ab), b')
r = b.ratexp('[ab]*a[ab]{3}')
a = r.derived_term()
a
The resulting automaton has its states decorated by their expressions, which can be stripped:
a.strip()
The result does not depend on the core computation: expansions and derivations compute the same terms:
r.derived_term('derivation')
Extended expressions are supported. For instance, words starting with a
s and then b
s, but not exactly ab
:
r = b.ratexp('a*b*&(ab){c}')
r
a = r.derived_term()
a
a.shortest(10)
The following example is taken from lombardy.2005.tcs
:
q = vcsn.context('lal_char(abc), q')
r = q.ratexp('(<1/6>a*+<1/3>b*)*')
r.derived_term()
"Breaking" variants of derivation and expansion "split" the polynomials at each step. In short, it means that no state will be labeled by an addition: rather the addition is split into several states. As a consequence, the automaton might have several initial states.
r = q.ratexp('[ab]{2}')
r.derived_term()
r.derived_term('breaking_expansion')