Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 45910
Kernel: Python 3

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(E)B(\mathsf{E}). It was renamed split in Vcsn to avoid clashes with the break keyword in both C++ and Python.

Examples

import vcsn qexp = vcsn.Q.expression e = qexp('a* + <3>ab + a*', 'associative') e

a+3ab+a{a}^{*} + \left\langle 3 \right\rangle \,a \, b + {a}^{*}

e.split()

2a3ab\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 aa^* and abab.

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

e = qexp('(a+b)(a+b)') e

(a+b)2\left(a + b\right)^{2}

e.split()

a(a+b)b(a+b)a \, \left(a + b\right) \oplus b \, \left(a + b\right)

e = qexp(r'a?b?c?') e

(ε+a)(ε+b)(ε+c)\left(\varepsilon + a\right) \, \left(\varepsilon + b\right) \, \left(\varepsilon + c\right)

e.split()

εcb(ε+c)a(ε+b)(ε+c)\varepsilon \oplus c \oplus b \, \left(\varepsilon + c\right) \oplus a \, \left(\varepsilon + b\right) \, \left(\varepsilon + c\right)