Functor#
- class discopy.monoidal.Functor(ob_map=None, ar_map=None, dom=None, cod=None, colour_map=None)[source]#
Bases:
discopy.cat.FunctorA monoidal functor is a functor that preserves the tensor product.
- Parameters:
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 whenevercod.obhas anidmethod, 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')