Sum#
- class discopy.cat.Sum(terms, dom=None, cod=None)[source]#
Bases:
Box
Implements enrichment over monoids, i.e. formal sums of diagrams.
- Parameters:
Examples
>>> x, y = Ob('x'), Ob('y') >>> f, g = Box('f', x, y), Box('g', x, y) >>> f + g Sum([Box('f', Ob('x'), Ob('y')), Box('g', Ob('x'), Ob('y'))]) >>> unit = Sum([], x, y) >>> assert (f + unit) == Sum([f]) == (unit + f) >>> print((f + g) >> (f + g)[::-1]) (f >> f[::-1]) + (f >> g[::-1]) + (g >> f[::-1]) + (g >> g[::-1])
Note
The sum is non-commutative, i.e.
Sum([f, g]) != Sum([g, f])
.A diagram is different from the sum of itself, i.e.
Sum([f]) != f