String diagram explained

String diagrams are a formal graphical language for representing morphisms in monoidal categories, or more generally 2-cells in 2-categories. They are a prominent tool in applied category theory. When interpreted in the monoidal category of vector spaces and linear maps with the tensor product, string diagrams are called tensor networks or Penrose graphical notation. This has led to the development of categorical quantum mechanics where the axioms of quantum theory are expressed in the language of monoidal categories.

History

Günter Hotz gave the first mathematical definition of string diagrams in order to formalise electronic circuits.[1] However, the invention of string diagrams is usually credited to Roger Penrose,[2] with Feynman diagrams also described as a precursor. They were later characterised as the arrows of free monoidal categories in a seminal article by André Joyal and Ross Street.[3] While the diagrams in these first articles were hand-drawn, the advent of typesetting software such as LaTeX and PGF/TikZ made the publication of string diagrams more wide-spread.[4]

The existential graphs and diagrammatic reasoning of Charles Sanders Peirce are arguably the oldest form of string diagrams, they are interpreted in the monoidal category of finite sets and relations with the Cartesian product.[5] The lines of identity of Peirce's existential graphs can be axiomatised as a Frobenius algebra, the cuts are unary operators on homsets that axiomatise logical negation. This makes string diagrams a sound and complete two-dimensional deduction system for first-order logic,[6] invented independently from the one-dimensional syntax of Gottlob Frege's Begriffsschrift.

Intuition

String diagrams are made of boxes

f:x\toy

, which represent processes, with a list of wires

x

coming in at the top and

y

at the bottom, which represent the input and output systems being processed by the box

f

. Starting from a collection of wires and boxes, called a signature, one may generate the set of all string diagrams by induction:

f:x\toy

is a string diagram,

x

, the identity

id(x):x\tox

is a string diagram representing the process which does nothing to its input system, it is drawn as a bunch of parallel wires,

f:x\toy

and

f':x'\toy'

, their tensor

ff':xx'\toyy'

is a string diagram representing the parallel composition of processes, it is drawn as the horizontal concatenation of the two diagrams,

f:x\toy

and

g:y\toz

, their composition

g\circf:x\toz

is a string diagram representing the sequential composition of processes, it is drawn as the vertical concatenation of the two diagrams.

Definition

Algebraic

X\star

denote the free monoid, i.e. the set of lists with elements in a set

X

.

A monoidal signature

\Sigma

is given by:

\Sigma0

of generating objects, the lists of generating objects in \Sigma_0^\star are also called types,

\Sigma1

of generating arrows, also called boxes,

dom,cod:\Sigma1\to

\star
\Sigma
0
which assign a domain and codomain to each box, i.e. the input and output types.

A morphism of monoidal signature

F:\Sigma\to\Sigma'

is a pair of functions

F0:\Sigma0\to\Sigma'0

and

F1:\Sigma1\to\Sigma'1

which is compatible with the domain and codomain, i.e. such that

dom\circF1 =F0\circdom

and

cod\circF1 =F0\circcod

. Thus we get the category

MonSig

of monoidal signatures and their morphisms.

U:MonCat\toMonSig

which sends a monoidal category to its underlying signature and a monoidal functor to its underlying morphism of signatures, i.e. it forgets the identity, composition and tensor. The free functor

C-:MonSig\toMonCat

, i.e. the left adjoint to the forgetful functor, sends a monoidal signature

\Sigma

to the free monoidal category

C\Sigma

it generates.

String diagrams (with generators from

\Sigma

) are arrows in the free monoidal category

C\Sigma

.[7] The interpretation in a monoidal category

D

is a defined by a monoidal functor

F:C\Sigma\toD

, which by freeness is uniquely determined by a morphism of monoidal signatures

F:\Sigma\toU(D)

. Intuitively, once the image of generating objects and arrows are given, the image of every diagram they generate is fixed.

Geometric

A topological graph, also called a one-dimensional cell complex, is a tuple

(\Gamma,\Gamma0,\Gamma1)

of a Hausdorff space

\Gamma

, a closed discrete subset

\Gamma0\subseteq\Gamma

of nodes and a set of connected components

\Gamma1

called edges, each homeomorphic to an open interval with boundary in

\Gamma0

and such that \Gamma - \Gamma_0 = \coprod \Gamma_1

.

A plane graph between two real numbers

a,b\inR

with

a<b

is a finite topological graph embedded in

R x [a,b]

such that every point

x\in\Gamma\capR x \{a,b\}

is also a node

x\in\Gamma0

and belongs to the closure of exactly one edge in

\Gamma1

. Such points are called outer nodes, they define the domain and codomain

dom(\Gamma),cod(\Gamma)\in

\star
\Gamma
1
of the string diagram, i.e. the list of edges that are connected to the top and bottom boundary. The other nodes

f\in\Gamma0 -\{a,b\} x R

are called inner nodes.

A plane graph is progressive, also called recumbent, when the vertical projection

e\to[a,b]

is injective for every edge

e\in\Gamma1

. Intuitively, the edges in a progressive plane graph go from top to bottom without bending backward. In that case, each edge can be given a top-to-bottom orientation with designated nodes as source and target. One can then define the domain and codomain

dom(f),cod(f)\in

\star
\Gamma
1
of each inner node

f

, given by the list of edges that have source and target.

A plane graph is generic when the vertical projection

\Gamma0-\{a,b\} x R\to[a,b]

is injective, i.e. no two inner nodes are at the same height. In that case, one can define a list

boxes(\Gamma)\in

\star
\Gamma
0
of the inner nodes ordered from top to bottom.

A progressive plane graph is labeled by a monoidal signature

\Sigma

if it comes equipped with a pair of functions

v0:\Gamma1\to\Sigma0

from edges to generating objects and

v1:\Gamma0-\{a,b\} x R\to\Sigma1

from inner nodes to generating arrows, in a way compatible with domain and codomain.

h:\Gamma x [0,1]\to[a,b] x R

such that

h(-,t)

defines a plane graph for all

t\in[0,1]

,

x\in\Gamma0

, if

h(x,t)

is an inner node for some

t

it is inner for all

t\in[0,1]

.

A deformation is progressive (generic, labeled) if

h(-,t)

is progressive (generic, labeled) for all

t\in[0,1]

. Deformations induce an equivalence relation with

\Gamma\sim\Gamma'

if and only if there is some

h

with

h(-,0)=\Gamma

and

h(-,1)=\Gamma'

. String diagrams are equivalence classes of labeled progressive plane graphs. Indeed, one can define:

id(x)

as a set of parallel edges labeled by some type

x\in

\star
\Sigma
0
,

Combinatorial

While the geometric definition makes explicit the link between category theory and low-dimensional topology, a combinatorial definition is necessary to formalise string diagrams in computer algebra systems and use them to define computational problems. One such definition is to define string diagrams as equivalence classes of well-typed formulae generated by the signature, identity, composition and tensor. In practice, it is more convenient to encode string diagrams as formulae in generic form, which are in bijection with the labeled generic progressive plane graphs defined above.

Fix a monoidal signature

\Sigma

. A layer is defined as a triple

(x,f,y)\in

\star
\Sigma
0

x \Sigma1 x

\star
\Sigma
0

=:L(\Sigma)

of a type

x

on the left, a box

f

in the middle and a type

y

on the right. Layers have a domain and codomain

dom,cod:L(\Sigma)\to

\star
\Sigma
0
defined in the obvious way. This forms a directed multigraph, also known as a quiver, with the types as vertices and the layers as edges. A string diagram

d

is encoded as a path in this multigraph
, i.e. it is given by:

dom(d)\in

\star
\Sigma
0
as starting point

len(d)=n\geq0

,

layers(d)=d1...dn\inL(\Sigma)

such that

dom(d1)=dom(d)

and

cod(di)=dom(di+1)

for all

i<n

. In fact, the explicit list of layers is redundant, it is enough to specify the length of the type to the left of each layer, known as the offset. The whiskering

dz

of a diagram

d=(x1,f1,y1)...(xn,fn,yn)

by a type

z

is defined as the concatenation to the right of each layer

dz=(x1,f1,y1z)...(xn,fn,ynz)

and symmetrically for the whiskering

zd

on the left. One can then define:

id(x)

with

len(id(x))=0

and

dom(id(x))=x

,

dd'=ddom(d')\circcod(d)d'

.

Note that because the diagram is in generic form (i.e. each layer contains exactly one box) the definition of tensor is necessarily biased: the diagram on the left hand-side comes above the one on the right-hand side. One could have chosen the opposite definition d \otimes d' = \text(d) \otimes d' \ \circ \ d \otimes \text(d').

Two diagrams are equal (up to the axioms of monoidal categories) whenever they are in the same equivalence class of the congruence relation generated by the interchanger:d \otimes \text(d') \ \circ \ \text(d) \otimes d' \quad = \quad \text(d) \otimes d' \ \circ \ d \otimes \text(d')That is, if the boxes in two consecutive layers are not connected then their order can be swapped. Intuitively, if there is no communication between two parallel processes then the order in which they happen is irrelevant.

The word problem for free monoidal categories, i.e. deciding whether two given diagrams are equal, can be solved in polynomial time. The interchanger is a confluent rewriting system on the subset of boundary connected diagrams, i.e. whenever the plane graphs have no more than one connected component which is not connected to the domain or codomain and the Eckmann–Hilton argument does not apply.[8]

Extension to 2-categories

The idea is to represent structures of dimension d by structures of dimension 2-d, using Poincaré duality. Thus,

f:A\toB

is represented by a vertical segment—called a string—separating the plane in two (the right part corresponding to A and the left one to B),

\alpha:fg:A\toB

is represented by an intersection of strings (the strings corresponding to f above the link, the strings corresponding to g below the link).

The parallel composition of 2-cells corresponds to the horizontal juxtaposition of diagrams and the sequential composition to the vertical juxtaposition of diagrams.

A monoidal category is equivalent to a 2-category with a single 0-cell. Intuitively, going from monoidal categories to 2-categories amounts to adding colours to the background of string diagrams.

Examples

The snake equation

(F,G,η,\varepsilon)

between two categories

l{C}

and

l{D}

where

F:l{C}\leftarrowl{D}

is left adjoint of

G:l{C}l{D}

and the natural transformations

η:IGF

and

\varepsilon:FGI

are respectively the unit and the counit. The string diagrams corresponding to these natural transformations are:

The string corresponding to the identity functor is drawn as a dotted line and can be omitted.The definition of an adjunction requires the following equalities:

\begin{align} (\varepsilonF)\circF(η)&=1F\\ G(\varepsilon)\circ(ηG)&=1G \end{align}

The first one is depicted asA monoidal category where every object has a left and right adjoint is called a rigid category. String diagrams for rigid categories can be defined as non-progressive plane graphs, i.e. the edges can bend backward.

In the context of categorical quantum mechanics, this is known as the snake equation.

The category of Hilbert spaces is rigid, this fact underlies the proof of correctness for the quantum teleportation protocol. The unit and counit of the adjunction are an abstraction of the Bell state and the Bell measurement respectively. If Alice and Bob share two qubits Y and Z in an entangled state and Alice performs a (post-selected) entangled measurement between Y and another qubit X, then this qubit X will be teleported from Alice to Bob: quantum teleportation is an identity morphism.The same equation appears in the definition of pregroup grammars where it captures the notion of information flow in natural language semantics. This observation has led to the development of the DisCoCat framework and quantum natural language processing.

Hierarchy of graphical languages

Many extensions of string diagrams have been introduced to represent arrows in monoidal categories with extra structure, forming a hierarchy of graphical languages which is classified in Selinger's Survey of graphical languages for monoidal categories.

List of applications

String diagrams have been used to formalise the following objects of study.

See also

External links

Notes and References

  1. Hotz . Günter . 1965 . Eine Algebraisierung des Syntheseproblems von Schaltkreisen I. . Elektronische Informationsverarbeitung und Kybernetik . 1 . 3 . 185–205.
  2. Penrose . Roger . 1971 . Applications of negative dimensional tensors . Combinatorial Mathematics and Its Applications . 1 . 221–244.
  3. Joyal . André . Street . Ross . 1991 . The geometry of tensor calculus, I . . 88 . 1 . 55–112. 10.1016/0001-8708(91)90003-P .
  4. Web site: Categories: History of string diagrams (thread, 2017may02-...) . 2022-11-11 . angg.twu.net.
  5. Brady . Geraldine . Trimble . Todd H . 2000 . A categorical interpretation of CS Peirce's propositional logic Alpha . Journal of Pure and Applied Algebra . 149 . 3 . 213–239. 10.1016/S0022-4049(98)00179-0 .
  6. Haydon . Nathan . Sobociński . Pawe\l . 2020 . Compositional diagrammatic first-order logic . International Conference on Theory and Application of Diagrams . Springer . 402–418.
  7. Joyal . André . Street . Ross . 1988 . Planar diagrams and tensor algebra . Unpublished Manuscript, Available from Ross Street's Website.
  8. Vicary . Jamie . Delpeuch . Antonin . 2022 . Normalization for planar string diagrams and a quadratic equivalence algorithm . Logical Methods in Computer Science . 18.
  9. Abramsky . Samson . 1996 . Retracing some paths in process algebra . International Conference on Concurrency Theory . Springer . 1–17.
  10. Fong . Brendan . Spivak . David I. . Tuyéras . Rémy . 2019-05-01 . Backprop as Functor: A compositional perspective on supervised learning . math.CT . 1711.10455 .
  11. Book: Ghani . Neil . Hedges . Jules . Winschel . Viktor . Zahn . Philipp . Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science . Compositional Game Theory . 2018 . 472–481. 10.1145/3209108.3209165 . 9781450355834 . 17887510 .
  12. Coecke . Bob . Spekkens . Robert W . 2012 . Picturing classical and quantum Bayesian inference . Synthese . 186 . 3 . 651–696. 10.1007/s11229-011-9917-5 . 1102.2368 . 3736082 .
  13. Signorelli . Camilo Miguel . Wang . Quanlong . Coecke . Bob . 2021-10-01 . Reasoning about conscious experience with axiomatic and graphical mathematics . Consciousness and Cognition . en . 95 . 103168 . 10.1016/j.concog.2021.103168 . 34627099 . 235683270 . 1053-8100. free . 10230/53097 . free .
  14. Fritz . Tobias . August 2020 . A synthetic approach to Markov kernels, conditional independence and theorems on sufficient statistics . 1908.07021 . . 370 . 107239 . 10.1016/j.aim.2020.107239. 201103837 .
  15. Book: Bonchi . Filippo . Sobociński . Pawel . Zanasi . Fabio . CONCUR 2014 – Concurrency Theory . A Categorical Semantics of Signal Flow Graphs . September 2014 . https://hal.archives-ouvertes.fr/hal-02134182 . Lecture Notes in Computer Science . Rome, Italy . CONCUR 2014 - Concurrency Theory - 25th International Conference. 435–450 . 10.1007/978-3-662-44584-6_30 . 978-3-662-44583-9 . 18492893 .
  16. Bonchi . Filippo . Seeber . Jens . Sobocinski . Pawel . 2018-04-20 . Graphical Conjunctive Queries . cs.LO . 1804.07626 .
  17. 1809.00738 . Mitchell . Riley . Categories of optics . 2018. math.CT .