Functor#
- class discopy.biclosed.Functor(ob_map=None, ar_map=None, dom=None, cod=None, colour_map=None)[source]#
Bases:
discopy.monoidal.FunctorA biclosed functor is a monoidal functor that preserves evaluation and currying.
- Parameters:
Note
When the codomain objects are biclosed types, the functor sends terms to terms rather than evaluating them to morphisms:
>>> X, Y = Ty("X"), Ty("Y") >>> f, x = (Y << X)("f"), X("x") >>> F = Functor(ob_map={X: Ty("A"), Y: Ty("B")}, ... ar_map={f: (Ty("B") << Ty("A"))("g"), x: Ty("A")("a")}) >>> assert F(f(x)) == F(f)(F(x))
The image of a term is checked to have the image of its type:
>>> Functor(ob_map={X: Ty("A"), Y: Ty("B")}, ar_map={f: Ty("A")("a")})(f) Traceback (most recent call last): ... discopy.utils.AxiomError: Expected a term of type (B << A) for ...
- map_variable(variable, context)[source]#
The image of a variable, of the image of its type, renamed with underscores until it differs from the images already in the context.