Functor

Contents

Functor#

class discopy.markov.Functor(ob=None, ar=None, dom=None, cod=None)[source]#

Bases: discopy.symmetric.Functor

A Markov functor is a symmetric functor that preserves copies.

Parameters:

Example

We build a functor into python functions.

>>> x = Ty('x')
>>> add = Box('add', x @ x, x)
>>> from discopy import python
>>> F = Functor({x: int}, {add: lambda a, b: a + b},
...             cod=Category(python.Ty, python.Function))
>>> copy = Copy(x)
>>> bialgebra_l = copy @ copy >> Id(x) @ Swap(x, x) @ Id(x) >> add @ add
>>> bialgebra_r = add >> copy
>>> assert F(bialgebra_l)(54, 46) == F(bialgebra_r)(54, 46)
>>> from discopy.drawing import Equation
>>> Equation(bialgebra_l, bialgebra_r, symbol="=").draw(
...     path="docs/_static/markov/bialgebra.png")
../_images/bialgebra.png