Transformation#

class discopy.cat.Transformation(components, dom, cod)[source]#

Bases: discopy.abc.Category

A (not necessarily natural) transformation between two parallel functors.

Parameters:
  • components (Mapping[Ob, Arrow] | Callable[[Ob], Arrow]) – A mapping from objects x in the domain category to arrows components[x] : dom(x) -> cod(x) in the codomain category.

  • dom (C0) – The domain functor.

  • cod (C0) – The codomain functor.

Example

>>> x, y = Ob('x'), Ob('y')
>>> f = Box('f', x, y)
>>> F, G = Functor.id(), Functor({x: y, y: x}, {})
>>> alpha = Transformation({x: f, y: f[::-1]}, F, G)
>>> assert alpha(x) == f and alpha(y) == f[::-1]
>>> beta = Transformation.id(G)
>>> assert (alpha >> beta)(x) == alpha(x) >> beta(x)
ob#

alias of Functor

classmethod id(dom)[source]#

The identity transformation on a given functor dom, i.e. the transformation whose component at each object x is the identity arrow on dom(x).

Parameters:

dom (Functor) – The functor on which to take the identity transformation.

Return type:

Transformation

Example

>>> x, y = Ob('x'), Ob('y')
>>> F = Functor({x: y, y: x}, {})
>>> alpha = Transformation.id(F)
>>> alpha(x)
cat.Arrow.id(cat.Ob('y'))
>>> assert alpha(x) == F.cod.id(F(x))
then(other)[source]#

The vertical composition of a transformation with another.

Parameters:

other (Transformation) – The other transformation with which to compose.

Return type:

Transformation

ar#

alias of Transformation