automaton
.expression(
identities
="default",
algo=
"auto")
¶Apply the Brzozowski-McCluskey procedure, to compute a (basic) expression from an automaton.
Arguments:
identities
: the identities of the resulting expressionalgo
: a heuristics to choose the order in which states are eliminated"best"
See also:
import vcsn
import pandas as pd
pd.options.display.max_colwidth = 0
a = vcsn.B.expression('ab*c').standard()
a
a.expression(algo = "naive")
a.expression(algo = "best")
Unfortunately there is no guarantee that the resulting expression is as simple as one could hope for. Note also that expression.derived_term tends to build automata which give nicer results than expression.standard.
def latex(e):
return '$' + e.format('latex') + '$'
def example(*es):
res = [[latex(e),
latex(e.standard().expression(algo="naive")),
latex(e.derived_term().expression(algo="naive"))]
for e in [vcsn.Q.expression(e) for e in es]]
return pd.DataFrame(res, columns=['Input', 'Via Standard', 'Via Derived Term'])
example('a', 'a+b+a', 'a+b+a', 'ab*c', '[ab]{2}')
You may pass the desired identities as an argument.
a
a.expression('trivial')
a.expression('linear')