# Colored props for large scale graphical reasoning

The prop formalism allows representation of processes withstring diagrams and has been successfully applied in various areas such as quantum computing, electric circuits and control flow graphs. However, these graphical approaches suffer from scalability problems when it comes to writing large diagrams. A proposal to tackle this issue has been investigated for ZX-calculus using colored props. This paper extends the approach to any prop, making it a general tool for graphical languages manipulation.

## Authors

• 2 publications
• 8 publications
07/02/2021

### Quantum Multiple-Valued Decision Diagrams in Graphical Calculi

Graphical calculi such as the ZH-calculus are powerful tools in the stud...
05/11/2022

### VyZX : A Vision for Verifying the ZX Calculus

Optimizing quantum circuits is a key challenge for quantum computing. Th...
03/11/2021

### Classifying Complexity with the ZX-Calculus: Jones Polynomials and Potts Partition Functions

The ZX-calculus is a graphical language which allows for reasoning about...
04/09/2020

### Coend Calculus and Open Diagrams

Morphisms in a monoidal category are usually interpreted as processes or...
03/14/2019

### The "Physics of Diagrams": Revealing the scientific basis of graphical representation design

Data is omnipresent in the modern, digital world and a significant numbe...
11/06/2021

### Graphical Piecewise-Linear Algebra

Graphical (Linear) Algebra is a family of diagrammatic languages allowin...
04/09/2020

### Open Diagrams via Coend Calculus

Morphisms in a monoidal category are usually interpreted as processes, a...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Colored graphical languages

This section lays out the mathematical foundation for colored graphical reasoning. Nothing here is new, we just restate for graphical languages well known results of categorical universal alegebra.

### 1.1 Colored props

We work in the setting of colored props.

###### definition 1 (Colored prop).

A colored prop is a small symmetric strict monoidal category together with a set of colors , such that the set of objects of is freely spanned by the elements of .

We use the term morphism to denote an arrow of a colored prop as a category. From now on, we will use the term prop for a colored prop. A prop is -colored when the set of colors is and monochromatic when is a singleton. The set of objects of a -colored prop is , the set of finite lists of elements of . A list of colors is denoted . We will write for the empty list and for the concatenation. This coincides with the monoidal structure in a -colored prop. We have for all . Given a color map we denote its extension to lists defined by , and .

A prop morphism is a symmetric strict monoidal functor mapping colors to colors. Formally, a prop morphism is a color map and a symmetric strict monoidal functor such that . Prop is the category of props and prop morphisms. This category is complete and co-complete. See [14] for a study of the category of props.

We will mainly work in subcategories of Prop where the set of colors is fixed. A -colored prop morphism is a prop morphism between two -colored props where . For any set of colors, -Prop is the category of -colored props and -colored prop morphisms. -Prop is a subcategory of Prop which is not full. By setting to be a singleton we recover the category of monochromatic props and monochromatic prop morphisms that is often simply called Prop in the literature.

We will use the term functor when using functors in SymCat (the category of small symmetric monoidal category and symmetric monoidal functors), which in general are not prop morphisms.

We now mention some remarkable props. is the codiscrete category over , it is a terminal object in -Prop. The terminal object for monochromatic props is denoted . is the category of permutations over finite lists of colors in . It is an initial object in -Prop. The initial object for monochromatic props is denoted .

### 1.2 String diagrams

Colored props admit a nice graphical representation with colored string diagrams. Let P be a -colored prop. The idea is that each color corresponds to a color of wire. In this sub-section, we will actually use various colors () to represent the wires: the identity map is represented as a wire of color , e.g.redid. Each morphism is represented as a diagram with input wires colored according to the s and output wires colored according to the s. Here is an example for a map: : fbox. The empty object and its identity map correspond to the empty diagramemptydiag. Diagrams of type have no inputs nor outputs, we call them scalars.

In this representation the tensor product of two morphisms is represented by juxtaposition:

. Thus the identity of the list , , is represented as: idredblue.

The composition of two morphisms is done by plugging the corresponding colored wires: .

The symmetry maps are represented by crossing the corresponding colored wires, for example is represented as : swapredblue. Its inverse is , graphically: .

In this representation, the axioms of symmetric monoidal categories correspond to topological properties. The naturality of the symmetry corresponds to equations of the form: . If two diagrams with colored wires are isomorphic then the corresponding morphisms are equal according to the axioms of -colored props. See [23] for an overview of the different ways to draw categories.

### 1.3 Graphical languages

We describe props with their presentations by generators and equations. We call such an equational theory a graphical language. We start by defining colored signatures.

###### definition 2 (Signature).

A colored signature is a set of colors together with a family of sets indexed by . The elements of are called generators of type . We write for , the set of all generators.

A signature is a way to present a collection of morphisms of a colored prop that will be used later as building blocks, hence the name generators. We use the same terminology as props, in particular signature stands for colored signature and we say that a signature is monochromatic when the set of colors is a singleton. A way to present a signature is as a functor , where is a discrete category. Thus, there is a category of -colored signatures - which is just another name for the functor category . The -colored signature morphisms are natural transformations between signatures. In other words is a familly of functions .

The interest of this definition comes from the following result presented in [2].

###### theorem 1.

[2] Let be the forgetful functor sending a -colored prop P to the -colored signature such that for each . has a left adjoint and is equivalent to the Eilenberg-Moore category of the monad . We denote the unit, the counit and the multiplication.

The main interest of the theorem is to provide us with the free functor sending a -colored signature to the free -colored prop spanned by this signature. Intuitively, a morphism in the free prop is a string diagram built from generators in linked by wires and swaps. From now on, by diagram we mean a morphism in . Such diagrams are identified up to the topological moves corresponding to the symmetric monoidal axioms. can be used to define equational theories for props.

###### definition 3 (equation).

An equation of type with respect to a signature is a pair where .

A set of equations over a signature can be presented as a pair of signature morphisms . A graphical calculus is then formed by a signature and a set of equations over this signature.

###### definition 4 (C-colored graphical language).

A -colored graphical language is a tuple where and are -colored signatures and and are -colored signature morphisms of type .

To any graphical language corresponds an underlying prop L, defined as the coequalizer: coeqp.

It is defined only up to prop isomorphism. Given we write iff in L, this means that using the equations as local rewriting rules we can transform the diagram into .

We say that two graphical languages and are equipotent iff .

We define a translation between two graphical calculi as a signature morphism satisfying the soundness condition: . This asserts that equivalent diagrams in are sent to equivalent diagrams in . The coequalizer property of Y gives a unique prop morphism such that . In fact, the soundness condition is equivalent to the existence of .

###### lemma 1.

There is a category GL of graphical languages and translations and an essentially surjective full functor .

A proof is given in A.1.

This functor allows us to define props and prop morphism using graphical languages and translations. Furthermore any prop and prop morphism admit such a description, but it is not unique.

-Prop is a cocomplete category thus it has sums and coequalizers. These can be described with graphical languages:

###### definition 5 (Sum of graphical languages).

The sum of two -colored graphical languages and is defined as , where and .

The sum of two graphical languages has the generators and equations of both languages.

###### lemma 2.

is a coproduct in -Prop.

A proof is given in A.1.

Usually when we build new graphical languages we take the sum of other graphical languages and then add more equations.

###### definition 6 (Quotient of a graphical language by equations).

Given a -colored graphical languages and a set of equations over , the quotient of by is defined as .

###### lemma 3.

is a coequalizer of and in -Prop.

A proof is given in A.1.

The semantics of a graphical language is given by interpretation functors.

###### definition 7.

An interpretation of a graphical language is a functor . A language is said complete, respectively universal, for the category C if there exists an interpretation which is full, respectively faithful.

A natural question, given a graphical language, is to find an interpretaion for which the language is universal and complete. Such examples will be given in section 3. We are now ready to introduce the scalable construction.

## 2 The scalable construction

From now on, our set of colors will always be . In this setting we will say size instead of color. We will use string diagrams to represent morphisms. A wire of size is said simple and a wire of size is said big. To simplify the notations, a thin wire will always be simple when a bold one without label can be of any size. We will only use size labels when absolutely necessary.

The objects of an -colored prop are lists of positive integers. The list with times the integer : is denoted . We have but and in particular . In fact corresponds to simple wires and to one big wire of size . Given a family of wires of arbitrary size, which corresponds to an arbitrary object in an -colored prop, we define a notion of global size.

###### definition 8.

Given an -colored prop P, the global size functor is the unique functor satisfying: and .

Intuitively big wires of size are ribbon cables, representing simple wires together, the global size functor just counts the overall number of simple wires. This intuition is made precise by the wire calculus.

### 2.1 The wire calculus

###### definition 9 (D and G).

The graphical languages and (for dividers and gatherers) are respectively freely generated by the signatures and for all . The generator is called the divider of size and is depicted: deltan. The generator is called the gatherer of size and is depicted: gamman. We take the conventions: and .

We have . We then define how those props interact in the spirit of [17]. The expansion equation of size , is the equation , pictorially: . The set of all expansion equations for each is denoted . The elimination equation of size , is the equation , pictorially: . The set of all elimination equations for each is denoted .

The convention for and makes and trivially true.

###### definition 10 (The wire calculus W).

The -colored graphical language is defined as .

In , the role of dividers and gatherers is perfectly symmetric, thus we have . W is a groupoid, in fact the elimination and expansion rules exactly state that the generators are invertible. We also note that the generators preserve the global size so there is no morphism of type when . In fact we can go further: when , the morphisms of type are the permutations of .

###### theorem 2 (Rewiring theorem).

W is a full subcategory of the permutation category , satisfying .

A proof is given in A.2.

This gives us a clear understanding of what W looks like as a category. The rewiring theorem works as a coherence result in the sense that any equation is true up to permutations as soon as the types match. This gives us total freedom to rewire the way we want.

The way the dividers and gatherers are defined, taking the wires one by one, is useful to come up with a normal form but is still quite restrictive. The rewiring theorem allows us to unambiguously generalize dividers and gatherers to any wire size. Furthermore we can define a divider with an arbitrary number of outputs since the associativity equation holds: . We define inductively by , and . The diagram is a sequence of dividers of decreasing size. For any object we define . Dually, we define by , and , which is a sequence of gatherers of increasing size. For any object we define .

We now proceed to making a monochromatic prop interacting with dividers and gatherers through the scalable construction.

### 2.2 The scalable construction

Intuitively, the scalable construction is the free embedding of a monochromatic graphical language into the simple wires of W.

###### definition 11 (SL).

Given a monochromatic graphical language , we define an -colored graphical language by:

The scalable graphical calculus is defined as: . The underlying prop is denoted .

The scalable construction was first introduced in [9] to allow a compact representation of large diagrams with an identifiable large scale structure. In fact, starting from we can add syntactic sugar to handle large scale graphical rewriting.

Given a diagram , its scaled version of size is a diagram inductively defined by: and . This transformation has been called monoidal multiplexing in [10]. Notice that these structures require a way to cross wires, here we have a symmetry but a braiding would also work.

###### lemma 4.

For every , there is a functor , such that and .

A proof is given in A.2.

These functors ensure that any equation between diagrams still holds at large scale where one application of the scaled rule is in fact hiding parallel applications of the original rule.

We can go further, if is a family of diagrams indexed by some parameter then we can index the scaled version by an element . This is defined inductively by and: , with and .

Notice that this is how scale spiders are defined in the scalable ZX-calculus [7]. We see here that this general construction applies without difficulties to the other kinds of indexed spiders one can find in ZW or ZH calculi, and to the boxes indexed by numbers in [6]. The associated scaled rule, if any, should be a priori defined inthe same way. For example, in the ZX-calculus, the phases and of two spiders add up when they fuse, so the lists of phases and add up pointwisely when scaled spiders fuse.

This construction applies naturally to generators but can be applied to any diagrams that we want to see acting at a large scale.

We can refine the global size functor into a functor from to L which forgets dividers and gatherers.

###### definition 12 (Wire stripper).

Given a monochromatic graphical language , the wire stripper functor is defined on colors by and on morphisms by , and for all generators .

###### lemma 5.

For every morphism , we have .

A proof is given in A.2.

All the properties of follow from a structure theorem which can be seen as an extension to of the rewiring theorem.

###### theorem 3 (Structure of SL).

For every we have .

A proof is given in A.2.

Starting with a graphical language for permutations we have and then we recover the rewiring theorem. From this result it follows that the scalable construction enjoys a universal property:

###### lemma 6 (Universal property of SL).

The following diagram is a pullback square: pullback

A proof is given in A.2.

The universal property allows to lift interpretation functors.

###### lemma 7 (Scaled interpretation).

Given a monochromatic prop C and an interpretation , let the be the symmetric strict monoidal category whose objects are pairs where is a partition of , and such that . is an -colored prop and there is a unique -colored prop morphism such that . We call it the scaled interpretation and it is faithful iff is faithful.

A proof is given in A.2.

These results together point out that the scalable construction is just a tool allowing diagrammatical manipulation and is completely orthogonal to the original language. In fact, we even have an equivalence of categories.

###### lemma 8.

In SymMonCat we have .

A proof is given in A.2.

We expect most of the properties of L to be reflected in . Here are some specific examples. If L is a dagger category then inherits this structure by setting . Then we have and the expansion and elimination equations state that dividers and gatherers are unitary maps.

If L is a compact closed category then so is . Using the scaled version of the cups and caps, we have and then . However, note that some intuitive topological moves do not hold: .

Remark: Another possibility is to take . Then we recover the topology but we loose the correspondance between equations on simple wires and their scaled version.

## 3 The box construction

In this section, we focus on some fundamental graphical languages. We use the associated completeness results to compress the corresponding diagrams with a box construction. We consider a way to construct an -colored graphical language from a monochromatic one: the box construction. The idea is to blackbox a monochromatic prop into a large scale graphical language.

###### definition 13 (BoxP).

Given a monochromatic prop P, let be the -colored graphical language defined as , and no equation. For every morphism of P the corresponding generator in is denoted .

The box graphical language is defined as , where swap, Comp, Tens are the following equations:

The Swap equation is: , pictorially: .

The composition equation , associated to two morphisms and of P, is , pictorially: . The set of all composition equations for every and is denoted .

The tensor equation , associated to two morphisms and of P, is , pictorially: . The set of all tensor equations for every and is denoted .

The -colored prop associated to the box graphical language is denoted . Notice that the box graphical language has one generator for each morphism in P.

From this definition follows directly the existence of a functor defined on each morphism by . The equations of state exactly that is a symmetric strict monoidal functor. We also have a functor defined on generators by . We have .

As with scalable construction, we also have a structure theorem:

###### theorem 4 (Structure of BoxP).

For each we have .

A proof is given in A.3.

From this given a monochromatic graphical language we can define a functor by .

###### lemma 9.

is an equivalence of categories.

A proof is given in A.3.

So , as a consequence, the two constructions are essentially the same.

We will mostly use the box construction on substructures of to obtain box generators inside of . Of course they are expressible using the usual generators, but they are very useful for compressing diagrams and speed up graphical computations. We now give several examples of various kinds of boxes and some of their interactions with scaled generators.

### 3.1 Symmetries and permutations

We work in the setting of props so the graphical language of permutation is the free graphical language with no signature nor equations. Making an exception, we describe here the language in the setting of pros in order to start with a familiar example.

###### definition 14 (permutations).

The monochromatic graphical language has signature: and equations: and .

###### lemma 10.

The interpretation makes complete for the prop of permutations where each morphism is a permutation of . Composition is the composition of permutations and the tensor product is the disjoint union.

Given any monochromatic prop P there is a unique prop morphism from the prop of permutations. Thus in any scalable prop we can use permutation boxes from without ambiguity.

### 3.2 Monoid and functions

###### definition 15 (Commutative monoid).

The monochromatic graphical language has signature: and equations:

###### lemma 11.

Fun is the prop of functions where each morphism is a function from to . Composition is the composition of functions and the tensor product is the disjoint union. The interpretation where is the unique function and is the unique function , makes complete for Fun.

From now on, we will depict boxes as arrows to fit the notation of [7]: . Every function arrow satisfies: and .

### 3.3 Bialgebras and matrices

###### definition 16 (Commutative bialgebra).

The monochromatic graphical language is defined as quotiented by the equations:

where the generators of are in white and those of in black.

###### lemma 12.

[22] is the prop of integer matrices where each morphism is a matrix in . Composition is the matrix product and the tensor product is the direct sum. The interpretation , , and makes complete for .

A matrix arrow indexed by corresponds to a bipartite multigraph between black vertices and white vertices. is nothing but the biadjacency matrix of this multigraph. Thus, in the presence of bialgebra, the box construction allows to compress a bipartite sub-diagram into a single matrix arrow. The properties of matrix arrows generalize the ones of function boxes. The following equations hold for any matrix :

 \tikzfigcopymat0=\tikzfigcopymat1 \tikzfigcoerasemat0=\tikzfigcoerasemat1 \tikzfigcocopymat0=\tikzfigcocopymat1 \tikzfigerasemat0=\tikzfigerasemat1

Furthermore: .

If we add to the generator and the equation we obtain the graphical language of Hopf algebras. is complete for matrices over with .

### 3.4 Interacting Hopf algebras and linear relations

###### definition 17 (Interacting Hopf algebras).

The monochromatic graphical language is defined as quotiented by the equations:

 \tikzfigbfrob0=\tikzfigbfrob1 \tikzfigbspe0=\tikzfigbspe1 \tikzfigwfrob0=\tikzfigwfrob1 \tikzfigwspe=\tikzfigwspe1 \tikzfigbsca0=\tikzfigsca1\tikzfignum0=\tikzfignum2=\tikzfignum1\tikzfigwsac0=\tikzfigsca1 \tikzfigint4=\tikzfigint5 \tikzfigint6=\tikzfigint7 \tikzfigint0=\tikzfigint1 \tikzfigint2=\tikzfigint3

The generators of are depicted as before and those of are depicted by exchanging black and white. The number of parallel wires must be at least .

###### lemma 13.

[6] LinRel is the prop of linear relation where each morphism is a linear subspace of . Composition is composition of relation and the tensor product is direct sum. The interpretation: , , , , , , and makes complete for LinRel.

We can interpret matrices in and thus have matrix arrows. Moreover we have a compact structure on simple wires given by and . We define backward matrix as .

Backward matrix arrows have the same properties as matrix arrows but in the reverse direction. We also have:

 A is injective ⇔\tikzfiginjcopy=\tikzfiginjcopy1⇔\tikzfiginjerase0=\tikzfiginjerase1 A is surjective⇔\tikzfigsurjcopy0=\tikzfigsurjcopy1⇔\tikzfigsurjerase0=\tikzfigsurjerase1

In practice we will not use linear relation boxes but only matrix arrows since any linear relation factorizes into matrix arrows. In fact, all the equations and properties given in this section so far can be summed up in the powerful formula from [24]:

 \tikzfigspan=\tikzfigcospan⇔Im(CD)=Ker(A−B)

## 4 Examples in graphical languages

In practice, when we identify a substructure in a graphical language we can use the scalable technics to manipulate boxes. However, in general those are not free and we can have extra equations between boxes. Moreover, sometimes the structures are a little different than expected and thus some adjustments need to be made on the properties of boxes. We illustrate this by considering three concrete examples of bialgebras from categorical quantum mechanics. They appear respectively in the ZH, ZW and ZX-calculus. Notice that we use the definitions of these bialgebras given in [8] which are essentially equivalent, but may slightly differ from the original ones. Each of the three graphical languages has an interpretation which make it complete for the prop of qubits where each morphism is a matrix in . The composition is the matrix product and the tensor is the tensor product of matrices. A basis of is denoted by the where is a binary word of size . is the binary word with everywhere except in the th coordinate where it is .

We recall that a bialgebra corresponds to matrices over the semiring