closed

Contents

closed#

The free closed markov category, i.e. with copy, discard and exponentials.

Summary#

Ty

A closed type is a biclosed type in a symmetric category where left and right exponentials coincide, i.e. X << Y == X ** Y == Y >> X.

Exp

An exponential object in a markov category.

TermBase

A term in the internal language of a closed category, i.e. a lambda term which need not be linear: this module implements closed markov categories by design, so a variable may be copied and discarded, i.e. occur any number of times.

Constant

A constant term, evaluated in a context by discarding it.

Variable

A variable, evaluated in a context by discarding the other variables.

Application

The application func(args) of a term to another.

Abstraction

The abstraction var.cod(lambda var: body) of a variable in a term, which need not occur in it or may occur several times.

Substitution

The simultaneous, capture-avoiding substitution of terms for variables.

Diagram

A closed diagram is both a markov and a biclosed diagram.

Box

A closed box is a markov and biclosed box in a closed diagram.

Eval

The evaluation of an exponential type.

Coeval

The coevaluation of an exponential type, i.e. the dagger of an Eval.

Curry

The currying of a closed diagram, linear when its argument is.

Discard

A markov discard in a closed category.

Sum

A markov sum is a symmetric sum and a markov box, linear when every term is.

Functor

A closed functor is a markov functor that preserves evaluation and currying.

CMap

alias of CMap[Diagram]

Axioms#

Diagram.curry() and Diagram.uncurry() are inverses.

>>> x, y, z = map(Ty, "xyz")
>>> f, g = Box('f', x, z << y), Box('g', x @ y, z)
>>> Equation(f.uncurry().curry(), f).draw(
...     doctest='docs/_static/closed/curry-left.svg', margins=(0.1, 0.05))
../_images/curry-left1.svg
>>> Equation(g.curry().uncurry(), g).draw(
...     doctest='docs/_static/closed/uncurry.svg')
../_images/uncurry1.svg