expression
.star_normal_form()
¶Compute the star normal form of a (Boolean) expression: an equivalent expression where the star operator is applied only on proper expressions (i.e., expressions whose constant term is null).
Preconditions:
Postconditions:
See also:
Caveat:
exp
.standard().expression()
.The following function allows to display nicely expressions and their star-normal form.
import vcsn
from IPython.display import Latex
def snf(*es):
eqs = []
for e in es:
e = vcsn.B.expression(e)
eqs.append(r'{e:x} &\Rightarrow {snf:x}'
.format(e=e, snf=e.star_normal_form()))
return Latex(r'''\begin{{aligned}}
{eqs}
\end{{aligned}}'''.format(eqs = r'\\'.join(eqs)))
snf('a**', 'a?{+}', '(a+b*)*', '(a*+b*)*', '(ab)*', '(ab?)*', '(a?b?)*', '(a*b*c*)**')
Of course, expressions already in star-normal form are returned unmodified.
snf('a*', '(a+b+c)*')
An expression and its star-normal form have the same standard automaton.
r = vcsn.b.expression('(a*b*)*')
r.standard()
r.star_normal_form().standard()