expansion.add(exp)

expansion + exp

An expansion which denotes the sum (or disjunction) of both denoted series.

Preconditions:

  • Both expansions have the same weightset.

See also:

In [1]:
import vcsn
e1 = vcsn.Z.expression('<3>abc+<4>d(a+<3>c)')
x1 = e1.expansion()
e2 = vcsn.Z.expression('<5>abc+<-2>d(<2>a+c)')
x2 = e2.expansion()
In [2]:
x1
Out[2]:
$a \odot \left[\left\langle 3\right\rangle b \, c\right] \oplus d \odot \left[\left\langle 4\right\rangle a + \left\langle 3 \right\rangle \,c\right]$
In [3]:
x2
Out[3]:
$a \odot \left[\left\langle 5\right\rangle b \, c\right] \oplus d \odot \left[\left\langle -2\right\rangle \left\langle 2 \right\rangle \,a + c\right]$
In [4]:
x1 + x2
Out[4]:
$a \odot \left[\left\langle 8\right\rangle b \, c\right] \oplus d \odot \left[\left\langle 4\right\rangle a + \left\langle 3 \right\rangle \,c \oplus \left\langle -2\right\rangle \left\langle 2 \right\rangle \,a + c\right]$

The sum of the expansions is the expansion of the sum.

In [5]:
(e1 + e2).expansion()
Out[5]:
$a \odot \left[\left\langle 8\right\rangle b \, c\right] \oplus d \odot \left[\left\langle 4\right\rangle a + \left\langle 3 \right\rangle \,c \oplus \left\langle -2\right\rangle \left\langle 2 \right\rangle \,a + c\right]$