expression.shortest(num = None, len = None)

Return a (finite) approximation of the series denoted by the expression.

This is equivalent to calling expression.derived_term().shortest. See its documentation for more details.

See also:

Examples

Boolean Expressions


In [1]:
import vcsn


:0: FutureWarning: IPython widgets are experimental and may change in the future.

In [2]:
e = vcsn.B.expression('[ab]*a[ab]')
e.shortest()


Out[2]:
$\mathit{aa}$

In [3]:
e.shortest(4)


Out[3]:
$\mathit{aa} \oplus \mathit{ab} \oplus \mathit{aaa} \oplus \mathit{aab}$

In [4]:
e.shortest(len = 4)


Out[4]:
$\mathit{aa} \oplus \mathit{ab} \oplus \mathit{aaa} \oplus \mathit{aab} \oplus \mathit{baa} \oplus \mathit{bab} \oplus \mathit{aaaa} \oplus \mathit{aaab} \oplus \mathit{abaa} \oplus \mathit{abab} \oplus \mathit{baaa} \oplus \mathit{baab} \oplus \mathit{bbaa} \oplus \mathit{bbab}$

In [5]:
e.shortest(num = 10, len = 4)


Out[5]:
$\mathit{aa} \oplus \mathit{ab} \oplus \mathit{aaa} \oplus \mathit{aab} \oplus \mathit{baa} \oplus \mathit{bab} \oplus \mathit{aaaa} \oplus \mathit{aaab} \oplus \mathit{abaa} \oplus \mathit{abab}$

In [6]:
e.shortest(num = 10, len = 3)


Out[6]:
$\mathit{aa} \oplus \mathit{ab} \oplus \mathit{aaa} \oplus \mathit{aab} \oplus \mathit{baa} \oplus \mathit{bab}$

Weighted Expressions


In [7]:
e = vcsn.Z.expression('(<2>a)*')
e.shortest(len = 3)


Out[7]:
$\varepsilon \oplus \left\langle 2\right\rangle \mathit{a} \oplus \left\langle 4\right\rangle \mathit{aa} \oplus \left\langle 8\right\rangle \mathit{aaa}$

In [8]:
e.shortest(num = 10)


Out[8]:
$\varepsilon \oplus \left\langle 2\right\rangle \mathit{a} \oplus \left\langle 4\right\rangle \mathit{aa} \oplus \left\langle 8\right\rangle \mathit{aaa} \oplus \left\langle 16\right\rangle \mathit{aaaa} \oplus \left\langle 32\right\rangle \mathit{aaaaa} \oplus \left\langle 64\right\rangle \mathit{aaaaaa} \oplus \left\langle 128\right\rangle \mathit{aaaaaaa} \oplus \left\langle 256\right\rangle \mathit{aaaaaaaa} \oplus \left\langle 512\right\rangle \mathit{aaaaaaaaa}$