expression.split()

Split an expression into a polynomial of rational expressions, i.e., when an expression is actually a sum of expressions, breaks it in smaller expressions. This is used to implement "breaking derivatives/expansions".

See also:

References:

  • angrand.2010.jalc introduces split as "breaking" an expression, noted $B(\mathsf{E})$. It was renamed split in Vcsn to avoid clashes with the break keyword in both C++ and Python.

Examples

In [1]:
import vcsn
qexp = vcsn.Q.expression
e = qexp('a* + <3>ab + a*', 'associative')
e
Out[1]:
${a}^{*} + \left\langle 3 \right\rangle \,a \, b + {a}^{*}$
In [2]:
e.split()
Out[2]:
$\left\langle 2\right\rangle {a}^{*} \oplus \left\langle 3\right\rangle a \, b$

Note that the weights (2 and 3) are on the level of the polynomial: the expressions are $a^*$ and $ab$.

It also distributes when the top-level is a multiplication, or a conjunction, whose first term is a sum.

In [3]:
e = qexp('(a+b)(a+b)')
e
Out[3]:
$\left(a + b\right)^{2}$
In [4]:
e.split()
Out[4]:
$a \, \left(a + b\right) \oplus b \, \left(a + b\right)$
In [5]:
e = qexp(r'a?b?c?')
e
Out[5]:
$\left(\varepsilon + a\right) \, \left(\varepsilon + b\right) \, \left(\varepsilon + c\right)$
In [6]:
e.split()
Out[6]:
$\varepsilon \oplus c \oplus b \, \left(\varepsilon + c\right) \oplus a \, \left(\varepsilon + b\right) \, \left(\varepsilon + c\right)$