expression
.derived_term(
algo
="expansion")
Generate the derived-term automaton from an expression.
The algorithm can be:
"derivation"
: rely on the expression.derivation
."derivation,breaking"
: likewise, but split
the polynomials at each step"expansion"
: rely on the expression.expansion
."expansion,breaking"
: likewise, but split
the polynomials at each step"expansion,deterministic"
: rely on the expression.expansion
and force determinismPreconditions:
"expansion,deterministic"
might not terminate on some expressionsAlso known as:
See also:
References:
In [1]:
import vcsn
In the classical case (labels are letters, and weights are Boolean), this is the construct as described by Antimirov.
In [2]:
b = vcsn.context('lal_char(ab), b')
r = b.expression('[ab]*a[ab]{3}')
a = r.derived_term()
a
Out[2]:
The resulting automaton has its states decorated by their expressions, which can be stripped:
In [3]:
a.strip()
Out[3]:
The result does not depend on the core computation: expansions and derivations compute the same terms:
In [4]:
r.derived_term('derivation')
Out[4]:
In [5]:
r = vcsn.Q.expression('aba+a(a+<-1>ba)')
nfa = r.derived_term('expansion')
nfa
Out[5]:
In [6]:
dfa = r.derived_term('expansion,deterministic')
dfa
Out[6]:
In [7]:
nfa.determinize()
Out[7]:
In [8]:
r = b.expression('a*b*&(ab){c}')
r
Out[8]:
In [9]:
a = r.derived_term()
a
Out[9]:
In [10]:
a.shortest(10)
Out[10]:
The following example is taken from lombardy.2005.tcs:
In [11]:
q = vcsn.context('lal_char(abc), q')
r = q.expression('(<1/6>a*+<1/3>b*)*')
r.derived_term()
Out[11]:
In [12]:
r = q.expression('[ab]{2}')
r.derived_term()
Out[12]:
In [13]:
r.derived_term('expansion,breaking')
Out[13]: