Alexis TOUMI
JIQ'22, Paris

A box represents any process with a list of wires as input and output.
A signature is a collection of boxes and wires.
String diagrams can be defined by recursion:

![]()
from discopy import Ty, Word, Id, Cup
s, n = Ty('s'), Ty('n')
Alice, loves, Bob = Word('Alice', n), Word('loves', n.r @ s @ n.l), Word('Bob', n)
sentence = Alice @ loves @ Bob >> Cup(n, n.r) @ Id(s) @ Cup(n.l, n)
A monoidal category
dom and cod from arrows to objects,id from objects to arrows,then and tensor from pairs of arrows to arrows.For example:
(Ty, Diagram) is the free monoidal category on a given signature,(type, Function), (int, Matrix), (list[int], Tensor), etc.A monoidal functor
ob from objects of ar from arrows of For example (Ty, Diagram) (list[int], Tensor)
from discopy.tensor import Functor
F = Functor(ob={s: 1, n: 2},
ar={Alice: [1, 0], loves: [[0, 1], [1, 0]], Bob: [0, 1]})
assert F(sentence)
We define a QNLP model as a monoidal functor:

We define a QNLP model as a monoidal functor:
from discopy.quantum import qubit, Ket, H, X, CX, sqrt
from discopy.circuit import Functor
F_ = circuit.Functor(
ob={s: Ty(), n: qubit},
ar={Alice: Ket(0), loves: sqrt(2) @ Ket(0, 0) >> H @ X >> CX, Bob: Ket(1)})
assert F_(sentence).eval() == F(sentence)
We define a QNLP model as a parameterised monoidal functor:
Given a dataset
We call this functorial learning, a new category-theoretic approach to structured machine learning.
joint work with Richie Yeung and Giovanni de Felice

