Sum#
- class discopy.cat.Sum(terms, dom=None, cod=None)[source]#
Bases:
Box
A sum is a tuple of arrows
terms
with the same domain and codomain.- Parameters:
terms (tuple[Arrow, ...]) – The terms of the formal sum.
dom (T) – The domain of the formal sum.
cod (T) – The codomain of the formal sum.
Example
>>> x, y, z = Ob('x'), Ob('y'), Ob('z') >>> f, g = Box('f', x, y), Box('g', y, z) >>> unit = Sum((), x, y) >>> assert f + unit == f == unit + f >>> assert f >> (g + g) == (f >> g) + (f >> g) == (f + f) >> g
Important
Domain and codomain are optional only if the terms are non-empty.
Note
The sum is non-commutative, i.e.
Sum([f, g]) != Sum([g, f])
.