cat#

Implements free dagger categories and functors.

We can create boxes with objects as domain and codomain:

>>> x, y, z = Ob('x'), Ob('y'), Ob('z')
>>> f, g, h = Box('f', x, y), Box('g', y, z), Box('h', z, x)

We can create arbitrary arrows with composition:

>>> arrow = Arrow(x, x, [f, g, h])
>>> assert arrow == f >> g >> h == h << g << f

We can create dagger functors from the free category to itself:

>>> ob = {x: z, y: y, z: x}
>>> ar = {f: g[::-1], g: f[::-1], h: h[::-1]}
>>> F = Functor(ob, ar)
>>> assert F(arrow) == (h >> f >> g)[::-1]

discopy.cat.Ob(name)

Defines an object in a free category, only distinguished by its name.

discopy.cat.Arrow(dom, cod, boxes[, _scan])

Defines an arrow in a free dagger category.

discopy.cat.Id(dom)

Defines the identity arrow on dom, i.e. with an empty list of boxes.

discopy.cat.Box(name, dom, cod, **params)

Defines a box as an arrow with the list of only itself as boxes.

discopy.cat.Sum(terms[, dom, cod])

Implements enrichment over monoids, i.e. formal sums of diagrams.

discopy.cat.Bubble(inside[, dom, cod])

A unary operator on homsets.

discopy.cat.Functor(ob, ar[, ob_factory, ...])

Defines a dagger functor which can be applied to objects and arrows.

discopy.cat.AxiomError

This is raised whenever we try to build an invalid arrow.