Functor

Functor#

class discopy.monoidal.Functor(ob_map=None, ar_map=None, dom=None, cod=None, colour_map=None)[source]#

Bases: discopy.cat.Functor

A monoidal functor is a functor that preserves the tensor product.

Parameters:
  • ob_map (Mapping[Ty, Ty]) – Map from atomic Ty to cod.ob.

  • ar_map (Mapping[Box, Diagram]) – Map from Box to cod.

  • cod (Category) – The codomain of the functor.

  • colour_map (Mapping[Colour, Colour]) – Map from region Colour to cod colour.

Important

The keys of the objects mapping must be atomic types, i.e. of length 1.

Note

Colour maps are expected to send colours to colours, so the image of an empty coloured identity Ty.id(c) keeps its (mapped) colour whenever cod.ob has an id method, e.g. F(Ty.id(c)) == Ty.id(F(c)).

Example

>>> x, y, z, w = Ty('x'), Ty('y'), Ty('z'), Ty('w')
>>> f0, f1 = Box('f0', x, y, data=0.1), Box('f1', z, w, data=1.1)
>>> F = Functor({x: z, y: w, z: x, w: y}, {f0: f1, f1: f0})
>>> assert F(f0) == f1 and F(f1) == f0
>>> assert F(F(f0)) == f0
>>> assert F(f0 @ f1) == f1 @ f0
>>> assert F(f0 >> f0[::-1]) == f1 >> f1[::-1]
>>> source, target = f0 >> f0[::-1], F(f0 >> f0[::-1])
>>> from discopy.drawing import Equation
>>> Equation(source, target, symbol='$\\mapsto$').draw(
...     path='docs/_static/monoidal/functor-example.png')
../_images/functor-example.png
dom#

alias of Diagram

cod#

alias of Diagram