Compositionality in Categorical Quantum Mechanics

Ross Duncan Simon Perdrix

Bob Coecke

Kevin Dunne Niel de Beaudrap Compositionality x 3

• Plain old monoidal theory: —— quantum computing in string diagrams

• Rewriting and substitution: —— taking the syntax seriously

• “Quantum theory” as a composite theory —— Lack’s composing PROPS

An application: compiling for quantum architecture 1. Quantum theory as string diagrams How much quantum theory can be expressed as an internal language in some ? PAST / HEAVEN

FUTURE / HELL F.D. Pure state QM

• States : Hilbert spaces

• Compound systems :

• Dynamics : Unitary maps

• Non-degenerate measurements : O.N. Bases F.D. Pure state QM

Ambient mathematical framework: †-symmetric monoidal categories • States : Hilbert spaces

• Compound systems : Tensor product

• Dynamics : Unitary maps

• Non-degenerate measurements : O.N. Bases F.D. Pure state QM

Ambient mathematical framework: †-symmetric monoidal categories • States : Hilbert spaces

• Compound systems : Tensor product

• Dynamics : Unitary maps

• Non-degenerate measurements : O.N. Bases

Choose some good generators and relations to capture this stuff Frobenius Algebras

Theorem: in fdHilb orthonormal bases are in bijection with †-special commutative Frobenius algebras. ! ! : A A Aµ: A A A ! ! ⌦ ⌦ ! ✏ : A I ⌘ : I A ! ! ! Via: ! :: a a a µ = † | ii!| ii⌦| ii ✏ :: a 1 ⌘ = ⌘† | ii!

Coecke, Pavlovic, and Vicary, “A new description of orthogonal bases”, MSCS 23(3), 2013. :0810.0812 Frobenius Algebras

Definition A -special commutativeFrobenius Frobenius Algebras algebra ( -SCFA) in ( , , I ) † Represent observables by †-special commutative† C ⌦ consists of: An objectFrobenius Aalgebras:, ! 2 C ! ! µ = , ⌘ =

µ† = , ⌘† = satisfying... of directed equations (f2,f1) (f Õ ,fÕ ) commuting morphisms of T2 past those æ 1 2 f-1 f-2 of T1. The composite PROP T1; T2 has morphisms of the form n z m where f1 is an arrow of T1 and f2 of T2; its syntactic presentation is that of T1 + T2 with the additional equations of ⁄. Example 1.4. As a simple example we can view P as a PRO with a single generator c :2 2 quotiented by c2 = id and the usual hexagon diagrams. Let Frobenius Algebrasæ G be some any; we define G◊ to be the PRO with hom-sets G◊(n, n)= n G, and G◊(n, m)= if n = m. Composition is done component-wise in G.The ÿ ” r generators of G◊ are just the elements g :1 1 for each g G quotiented by æ œ the equations of G. We can define the composite P; G◊ via the distributive law:

g1 g2 Definition ⁄ : = g2 g1 for each g andFrobeniusg in G. This yields the PROAlgebras – actually a -PROP – whose A -special commutative1 2 Frobenius algebra ( -SCFA)† in ( , , I ) morphisms n n are a permutation on n followed by an n-vector of elements of † Representæ observables by †-special commutative† C ⌦ G. It’s easy to see that this construction yields a functor P : Grp -PROP. Frobenius algebras: æ † consistsNotice of: An that objectPG is againA a groupoid,, and every morphism is unitary. ! 2 C Example 1.5.! A second cluster of examples, stolen shamelessly from [17], pro- vides the main! structures of interest of this paper. Let M denote the PROP of commutative monoids; it has two generators, µ :2 1 and ÷ :0: 1,whichwe µ = , ⌘æ = æ write graphically as and , subject to the equations:

= µ† = , = = ⌘† = = (M)

We can define the PROP of cocommutative comonoids as C = Mop. The gener- ators are ” :1 2 and ‘ :1 0; the equations are those of (M) but flipped æ æ satisfying...upside down. and Frobenius algebras combine a and comonoid in dierent ways; both can be built using distributive laws between M and C. The PROP B of commutative bialgebras is constructed via a distributive law ⁄B : M; C C; M generated by the equations æ

= = = = (B) where the dashed box represents the empty diagram. The PROP F of Frobenius algebras is also defined by distributive law, ⁄F : C; M M; C, given by the equations: æ

= = = (F)

= = = (F)

Frobenius Algebrasæ C M M C ; ; , given by the equations:

F F The PROP of Frobenius algebras is also defined by distributive law, : ⁄

where the dashed box represents the empty diagram.

= = = = (B)

æ

M C C M B

: ; ; generated by the equations

Definition⁄ Frobenius Algebras B The PROP of commutative bialgebras is constructed via a distributive law

M C

erent ways; both can be built using distributive laws between and .

in di Represent observables by †-special commutative

A -specialupside commutative down. Bialgebras and Frobenius Frobenius algebras algebra combine a monoid( -SCFA) and comonoid in ( , , I )

æ

Frobeniusæ algebras:

ators are :1 2 and :1 0; the equations are those of (M) but flipped ‘

† ”! † C ⌦

C M

We can define the PROP of cocommutative comonoids as = . The gener- consists of: An object! A , op

! 2 C

= = = (M)

= µ = , ⌘ =

write graphically as and , subject to the equations:

æ æ

commutative monoids; it has two generators, :2 1 and :0: 1,whichwe µ ÷

M vides the main structures of interest of this paper. Let denote the PROP of

A second cluster of examples, stolen shamelessly from [17], pro- Example 1.5. µ† = , ⌘† =

P Notice that is again a groupoid, and every morphism is unitary. G

æ †

P Grp PROP . It’s easy to see that this construction yields a functor : - . G

æ

morphisms are a permutation on followed by an -vector of elements of n n n n

1 2 for each and in . This yields the PRO – actually a -PROP – whose

g G satisfying... g

: = ⁄ 2 1 g g

1 2 g g

P ◊ the equations of . We can define the composite ; via the distributive law: G G

æ œ

◊ generators of are just the elements :1 1 for each quotiented by G g g G

r

ÿ ”

◊ and ( )= if = . Composition is done component-wise in .The G n, m n m G

n

◊ ◊ be some any; we define to be the PRO with hom-sets ( )= , G G G n, n G

æ

generator :2 2 quotiented by = id and the usual hexagon diagrams. Let c c

2

P Example 1.4. As a simple example we can view as a PRO with a single

T T 1 2 + with the additional equations of . ⁄

T T 1 1 2 2 where is an arrow of and of ; its syntactic presentation is that of f f

T T T 1 1 2 of . The composite PROP ; has morphisms of the form n z m

- -

1 2

f f

æ

1 2 T 2 1 2 Õ Õ of directed equations ( ) ( ) commuting morphisms of past those f ,f f ,f of directed equations (f2,f1) (f Õ ,fÕ ) commuting morphisms of T2 past those æ 1 2 f-1 f-2 of T1. The composite PROP T1; T2 has morphisms of the form n z m where f1 is an arrow of T1 and f2 of T2; its syntactic presentation is that of T1 + T2 with the additional equations of ⁄. Example 1.4. As a simple example we can view P as a PRO with a single generator c :2 2 quotiented by c2 = id and the usual hexagon diagrams. Let æ G be some any; we define G◊ to be the PRO with hom-sets G◊(n, n)= n G, and G◊(n, m)= if n = m. Composition is done component-wise in G.The ÿ ” r generators of G◊ are just the elements g :1 1 for each g G quotiented by æ œ the equations of G. We can define the composite P; G◊ via the distributive law:

g1 g2 ⁄ : = g2 g1 for each g and g in G. This yields the PRO – actually a -PROP – whose 1 2 † morphisms n n are a permutation on n followed by an n-vector of elements of æ G. It’s easy to see that this construction yields a functor P : Grp -PROP. æ † Notice that PG is again a groupoid, and every morphism is unitary. Example 1.5. A second cluster of examples, stolen shamelessly from [17], pro- vides the main structures of interest of this paper. Let M denote the PROP of commutative monoids; it has two generators, µ :2 1 and ÷ :0: 1,whichwe æ æ write graphically as and , subject to the equations:

= = = = (M)

We can define the PROP of cocommutative comonoids as C = Mop. The gener- ators are ” :1 2 and ‘ :1 0; the equations are those of (M) but flipped æ æ upside down.Frobenius Bialgebras Algebras and Frobenius algebras combine a monoid and comonoid in dierent ways; both can be built using distributive laws between M and C. The PROP B of commutative bialgebras is constructed via a distributive law ⁄B : M; C C; M generated by the equations æ DefinitionFrobenius Algebras A -special commutative Frobenius algebra ( -SCFA) in ( , , I ) † Represent observables by †-special† commutativeC ⌦ = consists of: An object= A , = = (B) Frobenius algebras:2 C ! ! µ = , ⌘ = where the dashed! box represents the empty diagram. The PROP of Frobenius algebras is also defined by distributive law, ⁄ : F µ† = , ⌘† = F C; M M; C, given by the equations: æ satisfying... = = = (F) Call Z↵ the phases for this Frobenius algebra

or, the -phases

Call Z↵ the phases for this Frobenius algebra

or, the -phases

Observables and Phases Observables and Phases Phases

, Abasis 0 1 A -SCFA Abasis 0 , 1 A -SCFA {| i | i } † { • Defn: a phase}{| isi unitary| i } map that commutes† with{ } the Frobenius algebra like this:

Z↵ 0 = 0 Z↵ Z↵ 0 Z=↵ 0 Z Z | i | i = , = | i | i ↵ = , = ↵ Z 1 = 1 Z↵ Z ↵ Z↵ 1 = 1 Z↵ Z↵ ↵| i | i | i | i

• Thm: the phases form an abelian group Example: Z-spin

• The following define a Frobenius algebra on the qubit: 0 00 0 1 : ✏ : |1i 7! |11i |1i 7! 1 | i 7! | i | i 7! • Its group of phases is:

0 0 Z : ↵ |1i 7! e| i↵i 1 | i 7! | i Example: Z-spin

0 0 00 0 1 : ✏ : | |1i 7! |11i |1i 7! 1 | i 7! | i | i 7!

10 1 Z = ↵ 0 ei↵ | ✓ ◆ = = =

= = =

=

– Frob. algebras + phases = – – + — Theorem: let f : n ⟶ m be connected.— ! –2 !

! –4 ! = i –i ! f = –1 ! q

–3 –5

1 Example: X-spin

• The following define a Frobenius algebra on the qubit: + ++ + 1 : ✏ : | i 7! | i | i 7! 1 |i 7! |i |i 7! • Its group of phases is:

+ + X : | i 7! e| ii |i 7! |i X and Z spins

0 00 0 1 : ✏ : |1i 7! |11i |1i 7! 1 | i 7! | i | i 7! 0 |

1 | X and Z spins

0 00 0 1 : ✏ : |1i 7! |11i |1i 7! 1 | i 7! | i | i 7! 0 |

0 1 0 + 1 | i| i | i | i

1 | X and Z spins

0 00 0 1 : ✏ : |1i 7! |11i |1i 7! 1 | i 7! | i | i 7! 0 |

0 1 0 + 1 | i| i | i | i

+ ++ + 1 : ✏ : | i 7! | i | i 7! 1 1 |i 7! |i |i 7! | Strongly Complementary Observables are Hopf algebras

Theorem 3: Two observables are strongly complementary iff they form a ! ! ! ” ‘ µ ÷ ! ! µ ÷ ” ‘

Coecke and Duncan, “Interacting Quantum Observables: categorical algebra and diagrammatics”, NJP 13(043016), 2011, arXiv:0906.4725.

1 Strongly Complementary Observables are Hopf algebras

Theorem 3: Two observables are strongly complementary iff they form a Hopf algebra ! ! !Frobenius ” ‘ µ ÷ ! ! Frobenius µ ÷ ” ‘

Coecke and Duncan, “Interacting Quantum Observables: categorical algebra and diagrammatics”, NJP 13(043016), 2011, arXiv:0906.4725.

1 Strongly Complementary Observables are Hopf algebras

Theorem 3: Two observables are strongly complementary iff they form a Hopf algebra ! ! ! ” ‘ µ ÷ ! ! µ ÷ ” ‘

Hopf Hopf

Coecke and Duncan, “Interacting Quantum Observables: categorical algebra and diagrammatics”, NJP 13(043016), 2011, arXiv:0906.4725.

1 4 Two Frobenius Algebras

We briefly consider the structure of the free -PROP FG + FH, i.e. the case of † two non-interacting Frobenius algebras.

Notation We will adopt the convention that elements in image of the first 4 Two Frobenius Algebras injection (i.e. from FG) are coloured green and the elements in the second (FH) are coloured red. In practice, the colour we call “green” may be light grey, and We briefly consider the structure of the free -PROP FG + FH, i.e. the case of “red” may be dark grey† depending how you read this document. two non-interacting Frobenius algebras. Morphisms of FG + FH are alternating sequences of morphisms from FG and FH;i.e.f = g1 h1 g2 h2 gn hn where gi FG and hj FH. Although Notation We will adopt the convention¶ ¶ that¶ elements¶ ···¶ in¶ image of theœ first œ no equations force the two components to interact, the spider theorem holds injection (i.e. from FG) are coloured green and the elements in the second (FH) are coloured red. In practice,separately the in colour each we colour, call “green” hence any may morphism be light grey, can and be reduced to a 2-coloured “red” may be dark greygraph, depending and any how 2-coloured you read (self-loop this document. free) graph is valid morphism. The following Morphisms of FG +isF aH consequenceare alternating of Lemma sequences 3.10. of morphisms from FG and FH;i.e.f = g1 h1 g2 h2 gn hn where gi FG and hj FH. Although ¶ ¶ Lemma¶ ¶ ··· 4.1.¶ ¶Let u : n nœbe unitary inœ FG + FH; then u is in PG + PH. no equations force the two components to interact,æ the spider theorem holds separately in each colour,As hence a special any morphism case of the can above, be reduced if u :1 to a 2-coloured1 is unitary, it is an element of graph, and any 2-coloured (self-loop free) graph is valid morphism. Theæ following the free product of groups G H. However, unlike in FG this group structure is ú is a consequence of Lemmanot reflected 3.10. back to the points, since we have to choose between µ and µ for Lemma 4.1. Let u : then multiplication,n be unitary in andFG the+ FH wrong; then colouru is in merelyPG + generatesPH. the free monoid on G In [11] this structurerather isæ called than a scaled reproducingbialgebra. the The group usual structure. definition can be restored by imposing (B’). We postpone a full discussion of the scalars but note As a special case of theIn F above,G + FH if uwe:1 have1 twois unitary, distinct it transposition is an element and of conjugation operations that equation (B’) is not true in the standardæ model CZD. However, having the free product of groupswhichG doH not. However, coincide, unlike i.e. f in =FGf this. group structure is belaboured the point that theú scalars are needed, we henceforward” omit them in notthe reflected name of back clarity to – the they points, can always since be we restored have to if choose needed: between see Backensµ [33].and µ for the multiplication, andLemma the wrong 4.2. colourLet f merely: n generatesn be a morphism the free monoid in F1+ onFG1; then f is -real i is æ ratherDefinition than reproducing 5.2. A bialgebragreen the and group on A -realis structure. called i it a Hopf is red. algebra and if there exists s : A A,calledtheantipode, satisfying the equation In FGæ+ FH we have two distinct transposition and conjugation operations which do not coincide,Corollary i.e. f = f 4.3.. In F1+F1, f = f implies f P1. ” œ Lemma 4.2. Let f : n n be a morphism in F1+F1; then f is -real i is æ s = (H) green and -real i it5 is red. InteractingStrongly FrobeniusComplementary Algebras Observables are Hopf algebras Corollary 4.3. In F1+F1, f = f implies f P1. G H We now impose some equationsœ on F + F governing their interaction. We Definition 5.3. Letwant(” , ‘FG,µand, ÷ )FbeH ato Frobenius jointly form a bialgebra as above; define so we impose: s 5the Interactingantipode as Frobenius Algebras s = =:= = = (B) We now impose some equations on FG + FH governing their interaction. We want FG and FH to jointly” , ‘ ,µ form, ÷ a bialgebra so we impose: ÷ ‘ Theorem 5.4. Let We( call the) resultingis a Hopf algebra structure if and a onlyFrobenius if =( bialgebra) : the pairs (” ,µ ) and and ‘ =(÷ ) , i.e. (” ,µ ) -SCFAs, while the pairs (” ,µ ) and (” ,µ ) are bialgebras. = =† = = = (+) (B) Remark 5.1. This definition diers from the usual one by the presence of the Remark 5.5. In the originalscalar factor paper on÷ interacting‘ in the quantum equations, observables and the [11 omission]the of the equation: Wecondition call the “ resulting-classical structure points are a Frobenius-real” formed bialgebra part of the: the definition pairs ( of” com-,µ ) and Coecke and Duncan, “Interacting Quantum Observables: categorical algebra and diagrammatics”, NJP 13(043016), 2011, arXiv:0906.4725. (” ,µplementarity;) -SCFAs, we while weaken the this pairs condition(” ,µ here.) and Notice(” that,µ ) theare condition bialgebras. (+) can † be restated as = (B’) Remark 5.1. This definition diers from the usual one by the presence of the scalar factor ÷ ‘ in the equations,= and the omission= of the equation: however by stating it in the form (+) we= emphasise that it is commutation of part (B’) of the red monoid and green monoid structures but not a complete distributive law.

We now define IF(G, H) as the PROP obtained quotienting FG + FH by the equations (B+). It contains two copies of the PROP B: one from (” , ‘ ) and one from (” , ‘ ). We’ll refer to the second as Bop. Note that for IF(1, 1) exchanging colours is the equivalent to the dagger. Now we focus on the Hopf algebra structure of B; everything also applies to Bop.

Proposition 5.6. Let s be the antipode of a commutative Hopf algebra; then

1. s is the unique map satisfying (H); 2. s is a bialgebra morphism; 3. s is an involution; ZX-calculus

• Since we are interested in quantum computing we’ll focus on the X and Z observables.

• This is called the ZX-calculus ZX-calculus syntax

...... – – – – H H ......

↵ [0, 2⇡) FigureFigure 2: Interior2 2: Interior vertices vertices of diagrams of diagrams Defn: A diagram is an undirected open graph generated by the above vertices. X vertices with m inputs and n outputs, labelled by an angle – [0, 2fi); X vertices• with m inputs and n outputs, labelled by an angle – [0,œ2fi); • these are these are denotedm Xm(–), and shown graphicallyœ as (dark) red these are these are denoted Xn (–),n and shown graphically as (dark) red circles,circles, H (or Hadamard)H (or Hadamard) vertices, vertices, restricted restricted to degree to degree 2; shown 2; shown as squares. as squares. • • If a X Ifor aZXvertexor Z vertex has – has=0–then=0 thethen label the label is entirely is entirely omitted. omitted. The The allowed allowed vertices are shown in Figure ??. vertices are shown in Figure ??. Since the inputs and outputs of of a diagram are totally ordered, we can Since the inputs and outputs of of a diagram are totally ordered, we can identify them with natural numbers and speak of the kth input, etc. identify them with natural numbers and speak of the kth input, etc. Remark 3.4. When a vertex occurs inside the graph, the distinction between Remarkinputs 3.4. andWhen outputs a vertex is purely occurs conventional: inside the one graph, can the view distinction them simply between as vertices inputs andof degree outputsn + ism purely; however, conventional: this distinction one can allows view the them semantics simply to as be vertices stated more of degreedirectly,n + m; see however, below. this distinction allows the semantics to be stated more directly, see below. The collection of diagrams forms a compact category in the obvious way: the Theobjects collection are of natural diagrams numbers forms and a compact the arrows categorym inn theare obvious those diagrams way: the with æ objectsm areinputs natural and numbersn outputs; and composition the arrowsg mf is formedn are those by identifying diagrams the with inputs ¶ æ m inputsof g andwithn outputs; the outputs composition of f and erasingg f is the formed corresponding by identifying vertices; thef inputsg is the ¶ ¢ of g withdiagram the outputs formed of byf theand disjoint erasing union the corresponding of f and g with vertices;I orderedf beforeg is theI , and f ¢ g diagramsimilarly formed for by the the outputs. disjoint union This is of basicallyf and g thewith freeIf (self-dual)ordered before compactIg, category and similarlygenerated for the outputs. by the arrows This is shown basically in Figure the free??. (self-dual) compact category generatedWe by the can arrows make this shown category in Figure-compact??. by specifying that f † is the same † Wediagram can make as thisf, but category with the-compact inputs and by outputs specifying exchanged, that f † andis the all the same angles † diagramnegated. as f, but with the inputs and outputs exchanged, and all the angles negated. This construction yields a category that does not incorporate the algebraic Thisstructure construction of strongly yields complementary a category that observables. does not incorporate To obtain the the desired algebraic category structurewe of must strongly quotient complementary by the equations observables. shown in To Figure obtain??. the We desired denote category the category we mustso-obtained quotient by by theD. equations shown in Figure ??. We denote the category so-obtainedRemark by D 3.5.. The equations shown in Figure ?? are not exactly those described Remarkin Sections 3.5. The?? equationsand ??, however shown in they Figure are?? equivalentare not exactly to them. those We shall described therefore, in Sectionson occasion,?? and ?? use, however properties they discussed are equivalent earlier as to derived them. rules We shall in computations. therefore, on occasion,Since useD propertiesis a monoidal discussed category earlier we can as assign derived an rulesinterpretation in computations. to any diagram by providing a monoidal functor from to any other monoidal category. Since Since is a monoidal category we can assignD an interpretation to any diagram weD interested in quantum mechanics, the obvious target category is fdHilb. by providing a monoidal functor from D to any other monoidal category. Since we interestedDefinition in quantum 3.6. Let mechanics,: D fdHilb the obviousbe a symmetric target category monoidal is fdHilb functor. defined · æ on objects by Definition 3.6. Let : D fdHilb be a symmetric2 monoidal functor defined · æ 1 = C on objects by J K 2 J K 1 = C J K18

J K18 ZX-calculus semantics

... n m... 0 ⌦ 0 ⌦ – | i 7! | i – H n i↵ m 1 ⌦ e 1 ⌦ ... | i 7! | ...i

... Figure... 2: Interiorn verticesm of diagrams + ⌦ + ⌦ – – | i 7! | Hi n i↵ m ⌦ e ⌦ ...... |i 7! |i X vertices with m inputs and n outputs, labelled by an angle – [0, 2fi); • m œ Figurethese 2: Interior are these vertices are denoted of diagramsXn (–), and shown graphically as (dark) red circles, H (or Hadamard) vertices, restricted to degree 2; shown as squares. X vertices with m•inputs and n outputs, labelled by an angle – [0, 2fi); • m œ these are theseIf are a X denotedor Z vertexXn (– has), and– =0 shownthen graphically the label is as entirely (dark) omitted. red The allowed circles, vertices are shown in Figure ??. H (or Hadamard)Since vertices, the restricted inputs and to outputs degree of 2; shownof a diagram as squares. are totally ordered, we can • identify them with natural numbers and speak of the kth input, etc. If a X or Z vertex has – =0then the label is entirely omitted. The allowed vertices are shown inRemark Figure ?? 3.4.. When a vertex occurs inside the graph, the distinction between inputs and outputs is purely conventional: one can view them simply as vertices Since the inputsof and degree outputsn + m of; however, of a diagram this distinction are totally allows ordered, the semantics we can to be stated more identify them with naturaldirectly, numbers see below. and speak of the kth input, etc. Remark 3.4. When aThe vertex collection occurs of inside diagrams the graph, forms a the compact distinction category between in the obvious way: the inputs and outputs isobjects purely are conventional: natural numbers one can and view the them arrows simplym asn verticesare those diagrams with æ of degree n + m; however,m inputs this and distinctionn outputs; allows composition the semanticsg f tois be formed stated by more identifying the inputs ¶ directly, see below. of g with the outputs of f and erasing the corresponding vertices; f g is the ¢ diagram formed by the disjoint union of f and g with I ordered before I , and The collection of diagrams forms a compact category in the obvious way:f the g similarly for the outputs. This is basically the free (self-dual) compact category objects are natural numbers and the arrows m n are those diagrams with generated by the arrows shownæ in Figure ??. m inputs and n outputs; composition g f is formed by identifying the inputs We can make this¶ category -compact by specifying that f † is the same of g with the outputs of f and erasing the corresponding† vertices; f g is the diagram as f, but with the inputs and outputs exchanged,¢ and all the angles diagram formed by thenegated. disjoint union of f and g with If ordered before Ig, and similarly for the outputs.This This construction is basically yields the free a category (self-dual) that compact does not category incorporate the algebraic generated by the arrowsstructure shown of in strongly Figure complementary??. observables. To obtain the desired category We can make this category -compact by specifying that f † is the same we must quotient† by the equations shown in Figure ??. We denote the category diagram as f, but withso-obtained the inputs by D and. outputs exchanged, and all the angles negated. This constructionRemark yields a 3.5. categoryThe equations that does shown not incorporate in Figure ?? theare algebraic not exactly those described structure of stronglyin complementary Sections ?? and observables.??, however To they obtain are equivalentthe desired to category them. We shall therefore, on occasion, use properties discussed earlier as derived rules in computations. we must quotient by the equations shown in Figure ??. We denote the category so-obtained by D. Since D is a monoidal category we can assign an interpretation to any diagram by providing a monoidal functor from D to any other monoidal category. Since Remark 3.5. The equations shown in Figure ?? are not exactly those described we interested in quantum mechanics, the obvious target category is fdHilb. in Sections ?? and ??, however they are equivalent to them. We shall therefore, on occasion, use propertiesDefinition discussed 3.6. Let earlier: asD derivedfdHilb rulesbe a in symmetric computations. monoidal functor defined · æ on objects by Since is a monoidal category we can assign an interpretation2 to any diagram D J K 1 = C by providing a monoidal functor from D to any other monoidal category. Since we interested in quantum mechanics, the obvious target category is fdHilb. J K18 Definition 3.6. Let : D fdHilb be a symmetric monoidal functor defined · æ on objects by 2 J K 1 = C

J K18 Representing Qubits Representing Phase shifts Representing Paulis Representing CNot The ZX-calculus is universal

Theorem: Let U be a unitary map on n qubits; then there exists a ZX-calculus term D such that:

D = U

J K The ZX-calculus is universal

Theorem: Let U be a unitary map on n qubits; then there exists a ZX-calculus term D such that:

D = U

J 7!K

7!

7! Example 1.6 (The Z-gate). The Z-gate can be obtained by using a Hadamard · · gate to transform the target bit of a X gate. ·

H H

= H ‘æ TranslatingH H circuits

2 Translation and Simplification Steane code encoder:

6 5 4 3 H 2 H 1 H 0

(a) (b)

Figure 3: The encoder (a) as a circuit; (b) in the zx-calculus.

The encoder 6 6 5 5 5 1 4 4 0 3 = 3 = 6 H 2 2 3 H 1 1 2 H 0 0 4

The error corrector This diagram can be substantially simplified; to do so we rely on some easy lemmas:

Lemma 2.1.

fi,v fi,v fi,v H H = = H H ......

4 Equations Equations Generalised Spider Equations Equations “Strong Complementarity” Equations

··· ⇡ ··· ⇡ 2 2 2 2 n ↵ + 2 = ↵

⇡ ⇡ 2 2 2 2 ··· ··· (colour change) Equations A weird one specific to ZX

··· ⇡ ··· ⇡ 2 2 2 2 n ↵ + 2 = ↵

⇡ ⇡ 2 2 2 2 ··· ··· (colour change) = = =

= = =

Example: CNOTS

? == = =

= = =

= – – + — —

–2 = –4

= i –i –1 q – –3 –5

= – – + — —

–2

–4 1

= i –i –1 q

–3 –5

1 Example: CNOTS

= = =

= = = =

= – – + — —

–2

–4

= i –i –1 q

–3 –5

1 ··· ···

x y x y x y k1 k1 k2 k2 k3 k3

fi fi fi

XXX XY Y YXY Y YX

fi fi fi

Graph States fi Let G = (V,E) be a simple, undirected graph. Then define: ! ! G = CZ + | i vufi | i ! (v,u) E = v V Or in 2D: O2 ” O2

2 STOP! QUANTO-TIME! A good reference A good reference A good reference

⌦ ⌦ 2. Composition in graphical syntax Proof. It suces to show that there are zx-calculus terms for the matrices Z–, H and X.Wehave · Proof. It suces to show that there are zx-calculus terms for the matrices Z–, H and X.Wehave · H = H, – = Z and = X – · H = H, – = Z and = X – · J K J K J K which can be verified by direct calculation. Note that J K J K J K which can be verified by direct calculation. Note that

= = J K J K so the presentation of X is unambiguous. J K J K · X Example 3.12 (Theso theZ-gate) presentation. The ofZ-gateis can unambiguous. be obtained by using a ·Composing· · diagrams Hadamard (H) gateExample to transform 3.12 the(The second qubitZ-gate) of. aTheX gate.Z-gate We can obtain be a obtained by using a · · · simpler representationHadamard using• ZX-calculus the ( colour-changeH) gate terms to are transform rulearrows in the PROP second qubit of a X gate. We obtain a · simpler— Compose representation them push-out using the style colour-change rule

H I2

= H H I2

H O2 = H

H From the presentation of Z in the zx-calculus, we can immediately read o · I1 that it is symmetricFrom in its inputs. the presentation Furthermore, of Z wein can the provezx-calculus, one of the we basic can= immediately= read o = properties of the Z gate, namely that is self-inverse.· · that it is symmetric in its inputs.= Furthermore, we= can prove one= of the basic properties of the Z gate, namely that is self-inverse. O1 H · H H H H O1 H H = =H =H = = H H H H = H = H = = = H H H H H = = = Example 3.13 (Bell state). The following is a zx-calculus= term representing= a = quantum circuit which produces a Bell state, 00 + 11 . We can verify this fact Example 3.13 (Bell state)| Í. The| Í following is a zx-calculus term representing a by the equations of thequantum calculus. circuit which produces a Bell state, 00 + 11 . We can verify this fact | Í | Í by the equations of the calculus.

H = = = H = = = = = The corresponding zx-calculus derivation is a proof of the correctness of this circuit. The corresponding zx-calculus derivation is a proof of the correctness of this circuit. The zx-calculus can represent many things which do not– correspond to quantum circuits. We nowThe presentzx-calculus a criterion– can represent to recognise many which things diagrams which do do not correspond to correspond to quantumquantum circuits. circuits. We now present a criterion to recognise which diagrams do correspond to quantum circuits. = 21 – = – + — 21 – – + — — — –2

–2 –4

–4 = i –i –1 = i –i q –1 q –3 –5 –3 –5

1 1 Proof. It suces to show that there are zx-calculus terms for the matrices Z–, H and X.Wehave · Proof. It suces to show that there are zx-calculus terms for the matrices Z–, H = H, H–and =XZ.Wehave– and = X · · J K J K J K which can be verified by direct calculation.H Note= H, that – = Z and = X – · J K J K J K which can be verified by direct calculation. Note that =

J K J K = so the presentation of X is unambiguous. · Example 3.12 (The Z-gate). The Z-gate can beJ obtainedK by usingJ a K · Composing· diagrams Hadamard (H) gate to transformso the the presentation second qubit of ofX a isX unambiguous.gate. We obtain a · · simpler representation using• theZX-calculus colour-change terms rule are arrows in PROP Example 3.12 (The Z-gate). The Z-gate can be obtained by using a — Tensor them push-out· style · Hadamard (H) gate to transform the second qubit of a X gate. We obtain a H · simpler representationI2 using the colour-change rule = H

H O2 H

= = H = = From the presentation of Z in the zx-calculus, we can immediately read o · I1 H that it is symmetric in its inputs. Furthermore, we can prove one of the basic properties of the Z gate, namely that is self-inverse. = = = · From the presentation of Z in the zx-calculus, we can immediately read o · that it is symmetric in its inputs. Furthermore, we can prove one of the basic H H H H properties ofO the Z gate, namelyH that is self-inverse. = = = 1 · = = H H H = = = H H H H H H H = = = = = Example 3.13 (Bell state). The following is a zx-calculus term representing a H H = = = H quantum circuit which produces a Bell state, 00 + 11 . We can verifyH this fact H | Í | Í by the equations of the calculus. Example 3.13 (Bell state). The following is a zx-calculus term representing a quantum circuit which produces a Bell state, =00 + 11 . We can verify this fact H | Í | Í = by the equations= of the= calculus.

H = = = = The corresponding zx-calculus derivation is a proof of the correctness of this circuit. –

The zx-calculus can representThe corresponding many things whichzx-calculus do not derivation correspond is a to proof of the correctness of this quantum circuits. We now presentcircuit. a criterion– to recognise which diagrams do correspond to quantum circuits. = The zx-calculus can represent many things which do not– correspond to – — quantum circuits. We now present a criterion to+ recognise which diagrams do 21 — correspond to quantum circuits. = – – – + — 2 21 — –4

–2 = i –i –1

–4 q

–3 – = –5 i i –1 q

–3 –5

1

1 Equational= Reasoning= =

= = = =

= – – + — —

–2

–4

= i –i –1 q

–3 –5

1 Equational= Reasoning= =

= = = =

= – – + — —

–2

–4

= i –i –1 q

–3 –5

1 Equational Reasoning

= = =

= = = =

= – – + — —

–2

–4

= i –i –1 q

–3 –5

1 1

Equational Reasoning

= = = =

— –

= = = =

” “

— –

= –

– + —

“ — ”

–2

— –

–4

= i –i “ –1

q ”

X –3

–5

– — Z Z

“ X

1

1 1

Equational Reasoning

= =

— — – –

” ” “ “

— — – –

” ” “ “

” ”

— — – –

“ “

” ” X X

– – — — Z Z Z Z

“ “ X X

1 1

Equational Reasoning =

== = =

— — – –

= = = =

” ” “ “

— — – –

=

” ”

“ “ – + —

— ” ”

— — – – –2

–4

“ “ = i –i

–1

” ” X X q

– – – — — Z Z Z Z 3

–5

“ “ X X

1

1 1

Equational Reasoning =

======

— — – –

======

” ” “ “

— — – –

– –

= =

– –

” ”

“ “ – + — – + —

— — ” ”

— — – – –2 –2

–4 –4

“ “ = i –i = i –i

–1 –1

” ” X X q q

– – – – — — Z Z Z Z 3 3

–5 –5

“ “ X X

1 1

1 1

Equational Reasoning

= = = = =

======

— — – –

= = = =

======

” ” “ “

— — – –

– – –

= = = –

– – + — – ” ” “

“ – + — – + — —

— — ” ”

–2

— — – – –2 –2

–4 –4 –4

= i –i “ “ –1 = i –i = i –i

–1 –1 q

” ” X X q q –3

–5 – – – – — — Z Z Z Z 3 3

–5 –5

“ “ X X

1 1 1

1 1

Equational Reasoning

= = = = =

======

— — – – Double Pushout Rewriting

= = = =

======

” ” “ “

— — – –

– – –

= = = –

– – + — – ” ” “

“ – + — – + — —

— — ” ”

–2

— — – – –2 –2

–4 –4 –4

= i –i “ “ –1 = i –i = i –i

–1 –1 q

” ” X X q q –3

–5 – – – – — — Z Z Z Z 3 3

–5 –5

“ “ X X

1 1 1 Equational Reasoning

X Equational Reasoning

X = = =

= = = = X

= – – + — —

–2

–4

= i –i –1 q

–3 –5

1 Equational Reasoning

X =Y = = = = =

======X Y

– –

= = – – – + — – + — — —

–2 –2

–4 –4

= = i –i i –i –1 –1 q q

–3 –3 –5 –5

1 1 3. Composite Theories I learned all this from Pawel: thanks mate! PROPs

Defn. A PROP is a strict symmetric monoidal category whose objects are the natural numbers. ! Defn. A †-PROP is a PROP which has a dagger. ! Let T be a PROP and let C be strict monoidal category. ! Defn: a T -algebra in C is a strict monoidal functor from T to C. PROPs

Syntactic presentation of a PROP: Generators! Relations ! (⌃,E) symbols with equations between arity! and coarity terms of same type ! The coproduct of PROPs is very simple: ! ! (⌃1,E1)+(⌃2,E2)=(⌃1 + ⌃2,E1 + E2) of directed equations (f2,f1) (f Õ ,fÕ ) commuting morphisms of T2 past those æ 1 2 f-1 f-2 of 1of. The directed composite equations PROP(f2,f11); 2(fhasÕ ,f morphismsÕ ) commuting of morphisms the form n of T2 pastz thosem T T æT 1 2 f-1 f-2 whereof Tf11.is The an composite arrow of PROPT1 andT1f; 2T2ofhasT2 morphisms; its syntactic of the presentation form n isz thatm of T1 +whereT2 withf1 is the an additional arrow of T equations1 and f2 of ofT⁄2.; its syntactic presentation is that of + with the additional equations of ⁄. ExampleT1 T 1.4.2 As a simple example we can view P as a PRO with a single generatorExamplec :2 1.4. As2 quotiented a simple example by c2 = weid and can the view usualP as hexagon a PRO diagrams. with a single Let æ 2 G begenerator some any;c :2 we define2 quotientedG to by bec the= PROid and with the hom-setsusual hexagonG (n, diagrams. n)= LetG, æ ◊ ◊ n and GG◊be(n, some m)= any;if wen define= m.G Composition◊ to be the PRO is done with component-wise hom-sets G◊(n, n in)=G.Then G, and G◊(n, m)=ÿ if” n = m. Composition is done component-wise in Gr.The generators of G◊ areÿ just the” elements g :1 1 for each g G quotientedr by of directed equations (f2,f1G) (f1Õ ,f2Õ ) commuting morphisms of T2gpastæ those gœ G ofgenerators directedof directed equations equations of(f2,f(◊f12),fare1)(f1Õ ,f just(f2Õ1Õ),fcommuting2Õ ) thecommuting elements morphisms morphisms of T:1 of2 pastT2 past those1 thosefor each quotiented by the equations of G.æ We can define the compositef1 f2 ; G◊ via the distributive law: æ æ - f1 f-1 æf2 Pf2 œ of T1. The composite PROP T1; T2 has morphisms of the form n z- - m- - oftheTof1.T The equations1. The composite composite PROP of PROPGT1.; T WeT21;hasT2 canhas morphisms morphisms define of the of the theform form compositen n z z mP;mG◊ via the distributive law: where f1 is an arrow of 1 and f2 of 2; its syntactic presentation is that of wherewheref1 isf1 anis arrow an arrowT of T of1 andT1 andf2Toff2Tof2;T its2; syntactic its syntactic presentation presentation is that is that of of T1 + T2+with+with thewith additional the the additional additional equations equations equations of ⁄. of ⁄ of. ⁄. T1 T1T2 T2 g1 g2 ExampleExampleExample 1.4. 1.4.As 1.4. aAs simpleAs a simple a example simple example example we can we wecan view can viewgP viewas aas PROg aas PRO a with PRO with a single with a single a single 2 1 P P 2 generatorgeneratorgeneratorc :2c :22c quotiented:22 quotiented2 quotiented by c by=c byid2 =andc2id=and theid and usual the the usual hexagon usual hexagon hexagon diagrams. diagrams.g diagrams. Let Letg Let æ æ æ ⁄ : = 2 1 G be some any; we define G◊ to be the PRO with hom-sets G◊(n, n)= gn G, g G beG somebe some any; any; we define we defineG◊ Gto◊ beto the be⁄ the PRO: PRO with with hom-sets hom-setsG◊=(Gn,◊ n(n,)= n2)=n G,n G,1 and G◊(n, m)= if n = m. Composition is done component-wise in G.The andandG◊(Gn,◊ m(n,)=ÿ m)=if” nif=nm=. Compositionm. Composition is done is done component-wise component-wiser in G in.TheG.The generators of G◊ areÿ justÿ the” elements” g :1 1 for each g G quotiented byr r generatorsgenerators of G of◊ Gare◊ are just just the the elements elementsgæ:1g :11 for1 eachforœ eachg gG quotientedG quotiented by by the equations of G. We can define the composite æ; Gæ◊ via the distributiveœ œ law: forthe eachthe equations equationsg1 ofandG of. WeGg. We can2 in can define defineG the. This the composite compositeP yields; G◊; Gvia◊ the thevia the distributive PRO distributive – law: actually law: a -PROP – whose for each g1 and g2 in G. ThisP yieldsP the PRO – actually a † -PROP – whose morphisms n n are a permutation on n followed by an n-vector† of elements of morphisms n g1n areg2 a permutation on n followed by an n-vector of elements of æ g1 g1 g2 g2 ⁄ æ: = g2 g1 G. It’s easy to see⁄ that: ⁄ : this= construction=g2 g2 g1 g1 yields a functor P : Grp -PROP. G. It’s easy to see that this construction yields a functor P : Grp æ †-PROP. Notice that G is again a groupoid, and every morphism is unitary.æ † for eachNoticeg1 and thatg2Pin GP. ThisG is yields again the PRO a groupoid, – actually a and-PROP every – whose morphism is unitary. for eachfor eachg1 andg1 andg2 ing2Gin. ThisG. This yields yields the the PRO PRO – actually – actually† a -PROP a -PROP – whose – whose morphisms n n are a permutationExample on n followed by an n-vector of† elements† of morphismsmorphismsæn nn aren aare permutation a permutation on n onfollowedn followed by an byn an-vectorn-vector of elements of elements of of ExampleG. It’sExample easy to 1.5. seeæ that 1.5.æA this secondA construction second cluster yields cluster a functor of of examples,P examples,: Grp -PROP stolen stolen. shamelessly shamelessly from from [17],], pro- pro- G. It’sG. It’s easy easy to see to seethat that this this construction construction yields yields a functor a functorP : GrpPæ: Grp† -PROP-PROP. . Notice that PG is again a groupoid, and every morphism is unitary. æ †æ † videsNoticevidesThe theNotice PROP that the main thatP GofPis maincommutativeG againis structures again a structures groupoid, a groupoid, monoids and of and every interestof every interestM morphism morphism of is of unitary. this is this unitary. paper. paper. Let LetMMdenotedenote the the PROP PROP of of Example 1.5. A second cluster of examples, stolen shamelessly from [17], pro- commutativeExamplecommutativeExample 1.5. 1.5.A monoids secondA second monoids cluster cluster; itof; examples,! ofhas it examples, has two stolen two stolen generators, shamelessly generators, shamelessly from fromµ [17µ:2], [:217 pro-], pro-11andand÷÷:0::0: 11,whichwe,whichwe videsvides thevides main the the main structures main structures structures of interest of interest of interest of this of this paper. of this paper. Let paper.M Letdenote LetM denoteM thedenote PROP the the PROP of PROPæ ofæ of ææ commutativecommutativewritecommutative monoids graphically monoids monoids; it has; it two has; it as has generators,two two generators, generators,andµ :2µ :21µ,and:2 subject1 and÷ 1:0:and÷ :0:÷1 to,whichwe:0:1 the,whichwe1,whichwe equations: write graphicallyΣ as = { and , ,æ} subjectæ æ æ toæ theæ equations: writewrite graphicallywrite graphically graphically as asand as and,and subject, subject, to subject the to equations: the to the equations: equations: ! = = = = (M) E = { = = = , = == = , = = }= = (M)(M) = (M) ! = = = = (M) op We can define the PROP of cocommutative comonoids as = . Theop op gener- We! We can can define define the the PROP PROP of cocommutative of cocommutative comonoids comonoidsC as CM as=CM= M. The. The gener- gener- atorsators areators” are:1 are” :1”2 :1and2 and‘ 2:1and‘ :1‘0;:1 the0; equations the0; the equations equations are those are are those of those (M) of (M) but of (M) butflipped but flipped flipped ! æ æ æ æ æ æ upsideupside down.upside down. Bialgebras down. Bialgebras Bialgebras and Frobeniusand and Frobenius Frobenius algebras algebras algebras combine combine combine a monoid a monoid a and monoid comonoidand and comonoid comonoid op in diWeTheerent can ways; -algebras bothdefine can in be the built are PROP usingexactly distributive the of cocommutativemonoids laws between of and comonoids. as C = Mop . The gener- Wein can diinerent di defineMerent ways; ways; both the both canC PROP can be built be built using of using cocommutative distributive distributive laws laws betweenC betweenM M comonoidsandCM andC. C. as C = M . The gener- TheatorsThe PROPThe PROP areB PROPofBcommutative”ofB:1commutativeof commutative bialgebras2 and bialgebras bialgebrasis‘ constructed:1is constructedis constructed0 via; the a via distributive avia equations distributive a distributive law law laware those of (M) but flipped ators⁄B : ; are ”; :1generated2æ byand the equations‘ :1 æ0; the equations are those of (M) but flipped ⁄MB :C⁄MB ;:CMC;MCC; MC;generatedM generated by the by the equations equations upsideæ æ down.æ æ Bialgebras andæ Frobenius algebras combine a monoid and comonoid upside down. Bialgebras and Frobenius algebras combine a monoid and comonoid in dierent ways; both can be built using distributive laws between M and C. in di=erent= = ways;= both= = can be= built= = using= = distributive= (B) (B) (B) laws between and . The PROP B of commutative bialgebras is constructed via a distributiveM C law whereThe the dashed PROP box representsof commutative the empty diagram. bialgebras is constructed via a distributive law where⁄Bwhere the: M the dashed; C dashed boxBC box represents; M representsgenerated the the empty empty diagram. by diagram. the equations The PROP of Frobenius algebras is also defined by distributive law, ⁄F : TheThe PROPF PROPæof Frobeniusof Frobenius algebras algebrasis alsois also defined defined by distributive by distributive law, law,⁄F :⁄F : ⁄B : M; C FC;FM generated by the equations C; MC; MCM;;MCM, given; CM,; givenC by, given the by equations: the by the equations: equations: æ æ ææ = = = = (B) = = = (F) ======(F) (F) = (B) where the dashed box represents the empty diagram. where theThe dashed PROP boxF of representsFrobenius the algebras emptyis also diagram. defined by distributive law, ⁄F : C; M M; C, given by the equations: The PROPæ F of Frobenius algebras is also defined by distributive law, ⁄F : C; M M; C, given by the equations: æ = = = (F) = = = (F)

= = = (F)

= = = (F)

æ

C M M C ; ; , given by the equations:

æ

F

F The PROP of Frobenius algebras is also defined by distributive law, : ⁄ C M M C ; ; , given by the equations:

where the dashed box represents the empty diagram. F F The PROP of Frobenius algebras is also defined by distributive law, : ⁄

where the dashed box represents the empty diagram.

= = = = (B)

= = = = (B)

æ

M C C M B

: ; ; generated by the equations ⁄

æ

M C C M

B

: ; ; generated by the equations ⁄ B The PROP of commutative bialgebras is constructed via a distributive law

B

The PROP of commutative bialgebras is constructed via a distributive law

M C in dierent ways; both can be built using distributive laws between and .

M C

in dierent ways; both can be built using distributive laws between and .

= = = (F)

======(F) (F) upside down. Bialgebras and Frobenius algebras combine a monoid and comonoid

æ æ

upside down. Bialgebras and Frobenius algebras combine a monoid and comonoid

ators are :1 2 and :1 0; the equations are those of (M) but flipped æ æ

” ‘

æ

æ æ

C M M C

; ; , given by the equations:

ators are :1 2 and :1 0; the equations are those of (M) but flipped

” ‘ C MC MM CM C

; ; ; ,; given, given by the by the equations: equations:

C M

F We can define the PROP of cocommutative comonoids as = . The gener-

F

The PROP of Frobenius algebras is also defined by distributive law, :

F F

F F TheThe PROP PROPof Frobeniusof Frobenius algebras algebrasis alsois also defined defined by distributive by distributive law, law, : : ⁄ ⁄

C M op We can define the PROP of cocommutative comonoids as = . The gener-

where the dashed box represents the empty diagram.

op wherewhere the the dashed dashed box box represents represents the the empty empty diagram. diagram.

= = = = (B)

======(B) (B)

= = = = (M)

= = = (M)

Example=

æ

æ æ

M C C M

B

: ; ; generated by the equations

M CM CC MC M B B : ;: ; ; ;generatedgenerated by the by the equations equations ⁄ ⁄

B

The PROP of commutative bialgebras is constructed via a distributive law

B B The PROP of commutativeof commutative bialgebras bialgebrasis constructedis constructed via avia distributive a distributive law law The PROP op

C The PROP of cocommutative comonoids M

erent ways; both can be built using distributive laws between and . in di M

M M C C in diinerent dierent ways; ways; both both can can be built be built using using distributive distributive laws laws between betweenandand. .

upside down. Bialgebras and Frobenius algebras! combine a monoid and comonoid

upsideupside down. down. Bialgebras Bialgebras and and Frobenius Frobenius algebras algebras combine combine a monoid a monoid and and comonoid comonoid write graphically as and , subject to the equations:

æ æ

write graphically as and , subject to the equations:

æ æ æ æ

ators are :1 2 and :1 0; the equations are those of (M) but flipped

” ‘

æ æ

atorsators are are:1 :12 and2 and:1 :10; the0; the equations equations are are those those of (M) of (M) but but flipped flipped æ æ

” ” ‘ ‘

C M

We can define the PROP of cocommutative comonoids as = . The gener-

; it has two generators, :2 1 and :0: 1,whichwe commutative monoids { , } µ ÷

C CM M ; it has two generators, :2 1 and :0: 1,whichwe commutative monoidsΣ =

µ ÷

WeWe can can define define the the PROP PROP of cocommutative of cocommutative comonoids comonoids as as= = . The. The gener- gener- op

op op

M M vides the main structures of interest of this paper. Let denote the PROP of denote the PROP of

vides the main structures! of interest of this paper. Let

= = = = (M)

======(M)(M)

Example 1.5. A second cluster of examples, stolen shamelessly from [17], pro- A second cluster of examples, stolen shamelessly from [17], pro-

ExampleE = 1.5.{ , , }

! P

Notice that is again a groupoid, and every morphism is unitary.

P G write graphically as and , subject to the equations:

Notice that is again a groupoid, and every morphism is unitary.

G

writewrite graphically graphically as as andand, subject, subject to the to the equations: equations:

æ æ

æ †

æ æ æ æ

æ †

; it has two generators, :2 1 and :0: 1,whichwe

commutative! monoids µ ÷

P

commutativecommutative monoids monoids; it has; it has two two generators, generators,:2 :21 and1 and:0::0:1,whichwe1,whichwe

µ µ ÷ ÷

Grp PROP . It’s easy to see that this construction yields a functor : - .

G

P

Grp PROP . It’s easy to see that this construction yields a functor : - . G

M

vides the main structures of interest of this paper. Let denote the PROP of

æ

M ! M

videsvides the the main main structures structures of interest of interest of this of this paper. paper. Let Letdenotedenote the the PROP PROP of of

æ

Example 1.5. A second cluster of examples, stolen shamelessly from [17], pro- morphisms are a permutation on followed by an -vector of elements of

n n n

op n

ExampleExample 1.5. 1.5.A secondA second cluster cluster of examples, of examples, stolen stolen shamelessly shamelessly from from [17], [17 pro-], pro- morphisms are a permutation on followed by an -vector of elements of n n n

The -algebrasn in C are the comonoids of C

M †

P

Notice that is again a groupoid, and every morphism is unitary.

G

1 2

for each and in . This yields the PRO – actually a -PROP – whose

P P g g G

NoticeNotice that that is againis again a groupoid, a groupoid, and and every every morphism morphism is unitary. is unitary. G G

æ †

1 2

for each and in . This yields the PRO – actually a -PROP – whose g g G

æ †æ †

P

Grp PROP . It’s easy to see that this construction yields a functor : - .

G

P P GrpGrp PROPPROP . It’s. It’s easy easy to see to seethat that this this construction construction yields yields a functor a functor: : - - . . G G æ

æ æ

morphisms are a permutation on followed by an -vector of elements of

n n n n

morphismsmorphisms are aare permutation a permutation on onfollowedfollowed by an by an-vector-vector of elements of elements of of n nn n n n n n

† †

1 2

for each and in . This yields the PRO – actually a -PROP – whose

g g G

1 1 2 2 for eachfor eachandandin in. This. This yields yields the the PRO PRO – actually – actually a -PROP a -PROP – whose – whose

g g g g G G

: =

⁄ 2 1

g g

: = ⁄ 2 1 g g

: =

2 1

g g

: : = =

1 2 ⁄ ⁄ 2 2 1 1

g g g g g g

1 2 1 2

g g g g

1 1 2 2 g g g g

P

◊ the equations of . We can define the composite ; via the distributive law:

G G

P

P P ◊ ◊ ◊ the equations of . We can define the composite ; via the distributive law: thethe equations equations of of. We. We can can define define the the composite composite; ; via thevia the distributive distributive law: law:

G G G G G G

æ œ

æ æ œ œ

æ œ

◊ generators of are just the elements :1 1 for each quotiented by

G g g G

P ◊ ◊ generatorsgenerators of of areare just just the the elements elements:1 :11 for1 eachfor each quotientedquotiented by by G G g g g gG G ◊ the equations of . We can define the composite ; via the distributive law: r

G G

ÿ ”

r r

ÿ ÿ ” ”

◊ generators of are just the elements :1 1 for each quotiented by

G g g G ◊ and ( )= if = . Composition is done component-wise in .The

G n, m n m G

æ œ

◊ ◊ andand ( ( )=)=if if= =. Composition. Composition is done is done component-wise component-wise in in.The.The G Gn, mn, m n nm m G G

r

ÿ ”

n

◊ ◊

be some any; we define to be the PRO with hom-sets ( )= ,

generators of are just the elements :1 1 for each quotiented by G G G n, n G

G g g G

n n

◊ ◊ ◊ ◊ be somebe some any; any; we define we define to beto the be the PRO PRO with with hom-sets hom-sets ( ()=)= , ,

G G G G G Gn, nn, n G G ◊

and ( )= if = . Composition is done component-wise in .The æ

G n, m n m G

r

æ æ

ÿ ”

generator :2 2 quotiented by = id and the usual hexagon diagrams. Let

c c

generatorgenerator:2 :22 quotiented2 quotiented by by= id=andid and the the usual usual hexagon hexagon diagrams. diagrams. Let Let c c c c

2

2 2

◊ and ( )= if = . Composition is done component-wise in .The

G n, m n m G n

P

◊ ◊ be some any; we define to be the PRO with hom-sets ( )= , Example 1.4. As a simple example we can view as a PRO with a single

G G G n, n G P P ExampleExample 1.4. 1.4.AsAs a simple a simple example example we wecan can view viewas aas PRO a PRO with with a single a single

æ

n

T T

◊ ◊

be some any; we define to be the PRO with hom-sets ( )= , 1 2

G G G n, n G

+ with the additional equations of .

generator :2 2 quotiented by = id and the usual hexagon diagrams. Let

c c T TT T 1 1 2 2 + +withwith the the additional additional equations equations of of. . ⁄ ⁄

æ

2

T T

1 1 2 2

where is an arrow of and of ; its syntactic presentation is that of

f f

T T T T

1 1 1 1 2 2 2 2

wherewhereis anis arrow an arrow of of andandof of; its; syntactic its syntactic presentation presentation is that is that of of f f f f

P

generator :2 2 quotiented by = id and the usual hexagon diagrams. Let

c c

Example 1.4. As a simple example we can view as a PRO with a single

T T T

1 1 2

of . The composite PROP ; has morphisms of the form

n z m

T T T TT T

2

1 1 1 21 2

of of. The. The composite composite PROP PROP; ;hashas morphisms morphisms of the of theform form

- -

n n z z m m

1 2

- - - - f f

æ

1 1 2 2

f f f f

æ æ

P

1 2

T

2 1 2

Õ Õ

Example 1.4. As a simple example we can view as a PRO with a single of directed equations ( ) ( ) commuting morphisms of past those

f ,f f ,f

1 21 2 T T

2 12 1 2 2

Õ ÕÕ Õ

of directedof directed equations equations( ( ) )( ( ) commuting) commuting morphisms morphisms of of pastpast those those

f ,ff ,f f ,ff ,f T T 1 2 + with the additional equations of . ⁄

T T 1 1 2 2 T T where is an arrow of and of ; its syntactic presentation is that of 1 2 f f + with the additional equations of . ⁄

T T T

1 1 2 of . The composite PROP ; has morphisms of the form n z m T T

1 1 2 2 where is an arrow of and of ; its syntactic presentation is that of

f f

- -

1 2

f f

æ

T T T 1 2 T 1 1 2 2 1 2 of . The composite PROP ; has morphisms of the form Õ Õ n z m of directed equations ( ) ( ) commuting morphisms of past those

f ,f f ,f

- -

1 2

f f

æ

1 2 T 2 1 2 Õ Õ of directed equations ( ) ( ) commuting morphisms of past those f ,f f ,f Theory and Applications of Categories, Vol. 13, No. 9, 2004, pp. 147–163.

COMPOSING PROPS Dedicated to Aurelio Carboni on the occasion of his sixtieth birthday

STEPHEN LACK

Abstract. A PROP is a way of encoding structure borne by an object of a symmetric monoidal category. We describe a notion of distributive law for PROPs, based on Beck’s distributive laws for monads. A distributive law between PROPs allows them to be composed, and an algebra for the composite PROP consists of a single object with an algebra structure for each of the original PROPs, subject to compatibility conditions encoded by the distributive law. An example is the PROP for bialgebras, which is a composite of the PROP for coalgebras and that for algebras.

1. Introduction 1.1 Monads provide a formalism for describing structure borne by an object of a category; the resulting structures are called algebras. A distributive law in the sense of Beck [1] allows two such monads to be “composed”; an algebra for the composite monad consists of an algebra for each of the original monads, subject to certain compatibility conditions between the two algebra structures. The fundamental example is the structure of a , which involves an abelian group (the additive structure) and a monoid (the multiplicative structure) subject to the compatibility condition of distributivity. There Lack, “Composingis a distributive PROPs”, Theory law and betweenApplications theof Categories monad 13(9), for 2004. abelian groups and the monad for monoids, and the composite monad is precisely the monad for rings. Not all such compatibility conditions can be expressed in terms of a distributive law, but in practice very many do so.

1.2 In this paper we consider a different formalism for describing structure borne by an object of a category; in our case the category is supposed to be symmetric monoidal. We shall write for the tensor product, I for the unit, and c for the symmetry, and write as if the monoidal⊗ structure were strict (this simplification is made legitimate by the coherence theorem for symmetric monoidal categories — see [9, Section VII.2]). The formalism, recalled below, is that of a PROP [8], or “one-sorted symmetric monoidal theory”. The m n structures on an object A involve morphisms A⊗ A⊗ ,calledoperations,between tensor powers of A, with these operations being subject→ to equations between derived such

Received by the editors 2003-08-07. Published on 2004-12-05. 2000 Mathematics Subject Classification: 18D10, 18C10, 18D35. Key words and phrases: symmetric monoidal category, PROP, monad, distributive law, algebra, bialgebra. c Stephen Lack, 2004. Permission to copy for private use granted. ⃝ 147 Composing PROPs

PROPs are monads in a certain (complicated) category. Distributive laws of monads produce composite monads — can do this for PROPs! ! ! : ; ; This boils down to an equation) ! t- s- ! n k m ! ! - + - n k0 m ! s0 t0 for every composable pair.

Lack, “Composing PROPs”, Theory and Applications of Categories 13(9), 2004. Composing PROPs

Proposition: Given a distributive law ! ! : ; ; Then ) s- t- ! f : n m = n k m ! ! ! Proposition: if =(⌃ ,E ) =(⌃ ,E ) ! then ; =(⌃ + ⌃ ,E + E + E)

Lack, “Composing PROPs”, Theory and Applications of Categories 13(9), 2004. Composing PROPs

Proposition: Given a distributive law ! ! : ; ; Then ) s- t- ! f : n m = n k m ! ! ! Proposition: if =(⌃ ,E ) =(⌃ ,E ) ! then ; =((⌃S ++T⌃)/E,E + E + E)

Lack, “Composing PROPs”, Theory and Applications of Categories 13(9), 2004. of directed equations (f2,f1) (f Õ ,fÕ ) commuting morphisms of T2 past those æ 1 2 f-1 f-2 of T1. The composite PROP T1; T2 has morphisms of the form n z m where f1 is an arrow of T1 and f2 of T2; its syntactic presentation is that of T1 + T2 with the additional equations of ⁄. Example 1.4. As a simple example we can view P as a PRO with a single generator c :2 2 quotiented by c2 = id and the usual hexagon diagrams. Let æ G be some any; we define G◊ to be the PRO with hom-sets G◊(n, n)= n G, and G◊(n, m)= if n = m. Composition is done component-wise in G.The ÿ ” r generators of G◊ are just the elements g :1 1 for each g G quotiented by æ œ the equations of G. We can define the composite P; G◊ via the distributive law:

g1 g2 ⁄ : = g2 g1 for each g and g in G. This yields the PRO – actually a -PROP – whose 1 2 † morphisms n n are a permutation on n followed by an n-vector of elements of æ G. It’s easy to see that this construction yields a functor P : Grp -PROP. æ † Notice that PG is again a groupoid, and every morphism is unitary. Example 1.5. A second cluster of examples, stolen shamelessly from [17], pro- vides the main structures of interest of this paper. Let M denote the PROP of commutative monoids; it has two generators, µ :2 1 and ÷ :0: 1,whichwe æ æ write graphically as and , subject to the equations:

= = = = (M)

We can define the PROP of cocommutative comonoids as C = Mop. The gener- ators are ” :1 2 and ‘ :1 0; the equations are those of (M) but flipped æ æ upside down. Bialgebras and Frobenius algebras combine a monoid and comonoid in dierent ways; both can be built using distributive laws between M and C. The PROP B of commutative bialgebras is constructed via a distributive law ⁄B : M; C C; M generated by the equations æ Frobenius Algebras = = = = (B) The PROP of special commutative Frobenius algebras arises by a distributive law ! where the dashed box represents theop empty diagram.op ! F : ; ; The PROP of Frobenius algebras is also defined by distributive law, ⁄F : F! ! C; M M; C, given by the equations: æ generated by the equations ! ! ! = = = (F) ! Phases Examples Let G be an abelian group. Define the PROP G Let G be an abelian group; define the PROP G ⇥ by ! ⌃ = g : 1 1 g G , E = g h = gh ⌃ =! g :1{ !1 g| G2 } E ={ g h =}gh ! { ! | 2 } { } ! Consider F + G and equations: Quotient F + G ⇥ by the equations ! ! g g = = (P) g g

FG := (F + G)/P = M; G; Mop

“FGisthefreetheoryofanobservablewithphasegroupG”

“FG is the free theory phased Spiders” Notation. If – : A A and  : I A are respectively a -phase and an æ æ -unbiased point then are the same colour as their Frobenius algebra, e.g.

 – = –  =

Lemma 3.5. Let – : A A be a phase. Then there exists  : I A such that æ æ 1. – = »(Â); 2. – = –; 3. –† = »( ); 4. µ(  )=÷. ¢ Corollary 3.6. If – is a phase, then so is –†. Lemma 3.7. Let Õ denote the phases, and denote the unbiased points; then U (Õ, , id, ()†) and ( ,µ,÷, () ) are isomorphic abelian groups. ¶ U m n Theorem 3.8 (Generalised Spider). Let f : A¢ A¢ be a morphism æ built from ”, ‘,µ,÷, and some collection of phases –i by composition and tensor; if the graphical form of g is connected then f = ” – µ where n ¶ ¶ m – = – – 1 ¶ ···¶ k Proof. This follows from the above lemmas and the spider theorem. Therefore a Frobenius algebra and its group of phases generate a category of Õ-labelled spiders. Composition is given by fusing connected spiders and summing their labels. Note that every F-algebra has a group of phases, although it may be trivial. We now construct the PROP of Frobenius algebras with a given phase group G. Take any abelian group G and consider the -PROP PG as earlier; then the † equations () give a distributive law ⁄Õ : F; PG PG; F. As before this extends æ to a functor F : Ab -PROP , Frob. algebrasæ † with phases where F1 is the original PROP of Frobenius algebras. Note that since F itself is a composite we can profitably think of FG as a composite of M, C, and G◊ via op op an iterated distributiveRecall lawis itself [32F a:]. composite This; yields ; an so abstract we can view counterpart to Theorem ! op 3.8 as the following G as factorisation. an iterated distributive law for ; G ⇥ ; . ! Theorem 3.9. LetThis fyields: n a factorisation:nÕ in FG; then ! æ - g- ∆- ! f = n Ò m m nÕ ! op G⇥ where : n !m is in M, ∆ : m nÕ is in C, g : m m is in G◊and Ò æ So G is the PROP of Frob.algs.æ with phases. æ m n, nÕ. F Æ In particular, if n = nÕ =1in the above then f is either a phase map or a “projector” „ † for a pair of unbiased points „,  :0 1. The following is a ¶ æ consequence of Theorem 3.8. Lemma 3.10. Suppose f : n n is unitary in FG; then f PG æ œ 4 Two Frobenius Algebras

We briefly consider the structure of the free -PROP FG + FH, i.e. the case of † two non-interacting Frobenius algebras.

Notation We will adopt the convention that elements in image of the first injection (i.e. from FG) are coloured green and the elements in the second (FH) are coloured red. In practice, the colour we call “green” may be light grey, and “red” may be dark grey depending how you read this document. Morphisms of FG + FH are alternating sequences of morphisms from FG and FH;i.e.f = g1 h1 g2 h2 gn hn where gi FG and hj FH. Although 4 Two Frobenius Algebras ¶ ¶ ¶ ¶ ···¶ ¶ œ œ no equations force the two components to interact, the spider theorem holds separately in each colour, hence any morphism can be reduced to a 2-coloured We briefly consider the structure of the free -PROP FG + FH, i.e. the case of † two non-interacting Frobenius algebras. graph, and any 2-coloured (self-loop free) graph is valid morphism. The following is a consequence of Lemma 3.10. Notation We will adopt the convention that elements in image of the first Lemma 4.1. Let u : n n be unitary in FG + FH; then u is in PG + PH. injection (i.e. from FG) are coloured green and the elements in theæ second (FH) are coloured red. In practice, the colour we callAs “green” a special may case be of light the grey, above, and if u :1 1 is unitary, it is an element of “red” may be dark grey depending how you read this document. æ the free product of groups G H. However, unlike in FG this group structure is G H úG Morphisms of F + F are alternatingnot sequences reflected of morphisms back to the from points,F sinceand we have to choose between µ and µ for FH;i.e.f = g1 h1 g2 h2 gn hn where gi FG and hj FH. Although ¶ ¶ ¶ ¶ ···¶ ¶ the multiplication,œ andœ the wrong colour merely generates the free monoid on G no equations force the two components to interact, the spider theorem holds rather than reproducing the group structure. separately in each colour, hence any morphism can be reduced to a 2-coloured In G + H we have two distinct transposition and conjugation operations graph, and any 2-coloured (self-loop free) graph isF validF morphism. The following which do not coincide, i.e. f = f . is a consequence of Lemma 3.10. ” Lemma 4.2. Let f : n n be a morphism in F1+F1; then f is -real i is Lemma 4.1. Let u : n n be unitary in FG + FH; then u is in PæG + PH. æ green and -real i it is red. As a special case of the above, if u :1 1 is unitary, it is an element of æ the free product of groups G H. However,Corollary unlike in F 4.3.G thisIn groupF1+ structureF1, f = isf implies f P1. ú œ not reflected back to the points, since we have to choose between µ and µ for the multiplication, and the wrong colour merely generates the free monoid on G rather than reproducing the group structure.5 Interacting Frobenius Algebras In FG + FH we have two distinct transposition and conjugation operations which do not coincide, i.e. f = f . We now impose some equations on FG + FH governing their interaction. We ”Bialgebraswant FG and FH to jointly form a bialgebra so we impose: Lemma 4.2. Let f : n n be a morphism in F1+F1; then f is -real i is æ green and -real i it is red. = = = (B) Corollary 4.3. In F1+F1, f = f implies f P1. The PROP of bialgebrasœ arises by a distributive law We call the resulting structure a Frobenius bialgebra: the pairs (” ,µ ) and ! op op 5 Interacting FrobeniusB : Algebras; (” ,µ ) -SCFAs,; while the pairs (” ,µ ) and (” ,µ ) are bialgebras. ! !† We now imposegenerated some equations by the on equationsFG +RemarkFH governing 5.1. This their definition interaction. diers We from the usual one by the presence of the want FG and FH to jointly form a bialgebrascalar so we factor impose:÷ ‘ in the equations, and the omission of the equation: !

! = = = (B) = (B’) ! We call the! resulting structure a Frobenius bialgebra: the pairs (” ,µ ) and (” ,µ ) -SCFAs, while the pairs (” ,µ ) and (” ,µ ) are bialgebras. † Can do the same for Hopf algebras. Remark 5.1. This definition diers from the usual one by the presence of the scalar factor ÷ ‘ in the equations, and the omission of the equation:

= (B’) Two Frobenius Algebras?

We can form the coproduct i.e. non-interacting Frobenius algebras with phases. ! G + H ! ! ! Factorisation: ! ! g-1 h-1 g-2 h-2 gk- f = n d1 d2 d3 m ! ···

1 Sad Face :(

Theorem: does not arise as a distributive law ! : G; H H; G ! ) Proof: Recall we need: ! t s ! n - k - m ! ! - + - n k0 m ! s0 t0 ! for every composable pair — including the phase groups

RD + Kevin Dunne, “Interacting Frobenius Algebras are Hopf”, LiCS 2016. But the news is still pretty good • No distributive law for ZX-calculus — no nice normal forms for the full language — this would have been very surprising!

• But nice normal forms for every subtheory. — the monochrome theory = spiders — the phase-free theory = Z 2 -matrices — the Clifford fragment = ????

• This will be enough for some interesting applications! 4. Compiling Oh look, can do something useful! Circuit Perspective

X–

Z– Z–

X–

1 Circuit Perspective

Inputs

X–

Z– Z–

X– Outputs

1 X“

Z– Z— Circuit Perspective X” Inputs “

– —

Outputs

1 X“

Z– Z— Circuit Perspective X”

– —

1 X“

Z– Z— Circuit Perspective X”

– —

1 X“

Z– Z—

X”

– — ???” Perspective ” “

– —

1 X“

Z– Z—

X”

– — ???” Perspective ” “

– —

1 X“

Z– Z—

X”

– — ???” Perspective ” “

Hopf algebra expression

– —

1 X“

Z– Z—

X”

– —

” “

??? Perspective– — ” “

Hopf algebra normal form

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

Physical qubits

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

Prepared qubits

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

Prepared qubits

Measured qubits

– —

1 X“

Z– Z—

X”

– —

” “

MBQC Perspective– — ” “

Prepared qubits Any ZX-calculus term can be interpreted as an MBQC in this way Measured qubits

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

Few qubit ion traps

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

Optical interconnect Few qubit ion traps

– —

1 X“

Z– Z—

X”

– —

” “

NQIT Perspective– — ” “

Architecture

Optical interconnect Few qubit ion traps

– —

1 NQIT perspective(?)

• What about determinism? — unknown in general — use standard techniques for specific examples

• What are the trade-offs? — non-Clifford gates vs physical qubits — circuit depth vs complexity of entanglement