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:
In [1]:
import vcsn
import pandas as pd
pd.options.display.max_colwidth = 0
In [2]:
a = vcsn.B.expression('ab*c').standard()
a
Out[2]:
In [3]:
a.expression(algo = "naive")
Out[3]:
In [4]:
a.expression(algo = "best")
Out[4]:
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.
In [5]:
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}')
Out[5]:
In [6]:
a
Out[6]:
In [7]:
a.expression('trivial')
Out[7]:
In [8]:
a.expression('linear')
Out[8]: