ColouredMonoid#

class discopy.abc.ColouredMonoid[source]#

Bases: Category, Generic

A coloured monoid is a category whose sequential composition then is given by a monoidal tensor, with the objects C0 (its colours) as the boundaries of its morphisms.

An ordinary Monoid is the special case with a single, trivial colour, i.e. type(None). We do not enforce this so that e.g. monoidal.Ty can take colours as objects.

classmethod id(dom=None)[source]#

The monoidal unit, i.e. the empty tensor cls().

Parameters:

dom (C0)

Return type:

C1

classmethod unit(colour=None)[source]#

The unit at a colour, i.e. the identity on it.

It need not be an element of the monoid, which is why it may land in C0: the layers of monoidal.Layer are closed under tensor but the empty one is a type rather than a layer.

Parameters:

colour (C0)

Return type:

C0 | C1

abstract tensor(*objects)[source]#

The n-ary product of a monoid for n > 0.

Parameters:

objects (C1)

Return type:

C1

then(*others)[source]#

Sequential composition, given by the monoid product.

Parameters:

others (C1)

Return type:

C1

classmethod cast(atoms)[source]#

The element of a tuple of atoms, or of a single atom; an element of the monoid is unchanged.

Parameters:

atoms – An element, a tuple of atoms or a single atom.

Return type:

C1

>>> assert Nat.cast(2) == Nat(2) == Nat.cast(Nat(2))
classmethod whisker(other)[source]#

Do nothing if other is already a morphism else apply id().

Parameters:

other (C0 | C1) – The object or morphism to be tensored on the left or right.

Return type:

C1