diagramification#

[1]:
from discopy import *
from discopy.drawing import diagramize

x, y, z, w = Ty('x'), Ty('y'), Ty('z'), Ty('w')
f, g, h = Box('f', x, y), Box('g', y, z), Box('h', y @ z, w)

@diagramize(dom=x @ y, cod=w, boxes=[f, g, h])
def diagram(left, right):
    return h(f(left), g(right))

diagram.draw(figsize=(3, 3))
../_images/notebooks_diagramification_1_0.png
[8]:
cap, cup = Cap(x, x.l), Cup(x.l, x)

@diagramize(dom=x, cod=x, boxes=[cup, cap])
def right_snake(right):
    left, middle = cap(offset=7)
    cup(middle, right)
    return left

right_snake.draw(figsize=(3, 3))
../_images/notebooks_diagramification_2_0.png
[5]:
cap, cup = Cap(x.r, x), Cup(x, x.r)

@diagramize(dom=x, cod=x, boxes=[cup, cap])
def left_snake(left):
    middle, right = cap(offset=1)
    cup(left, middle)
    return right

left_snake.draw(figsize=(3, 3))
../_images/notebooks_diagramification_3_0.png
[ ]: