Whether all the starred sub-expressions have a constant-term that admits a star value.
Postconditions:
See also:
The following funtion will help display the result of is_valid
.
In [1]:
import vcsn
from IPython.display import Latex
def valid(ctx, *rs):
eqs = []
for r in rs:
r = ctx.expression(r)
eqs.append(r'{0} &: \mathrm{{{1}}}'
.format(r.format('latex'),
"valid" if r.is_valid() else "invalid"))
return Latex(r'''\begin{{aligned}}
{0}
\end{{aligned}}'''.format(r'\\'.join(eqs)))
In $\mathbb{B}$ all the values have a star-power, so expressions are always valid.
In [2]:
b = vcsn.context('lal_char(ab), b')
valid(b, '\e*')
Out[2]:
In $\mathbb{Z}$, $0$ is the only weight that admit a star.
In [3]:
z = vcsn.context('lal_char(ab), z')
valid(z, '(<0>\e)*', '(<1>\e)*', '(<42>\e)*')
Out[3]:
In $\mathbb{Q}$ (and $\mathbb{R}$), only weights $w$ such that $|w| < 1$ admit a star.
In [4]:
q = vcsn.context('lal_char(ab), q')
valid(q, '(<1/2>\e)*', '(<99/100>\e)*', '(<-99/100>\e)*', '(<101/100>\e)*', '(<-101/100>\e)*')
Out[4]: