TTo appear in EPTCS.
Distributive Laws, Spans and the ZX-Calculus
Cole ComfortDepartment of Computer Science, University of Oxford
We modularly build increasingly larger fragments of the ZX-calculus by modularly addingnew generators and relations, at each point, giving some concrete semantics in terms of somecategory of spans. This is performed using Lack’s technique of composing props via distribu-tive laws [16], as well as the technique of pushout cubes of Zanasi [22]. We do this for thefragment of the ZX-calculus with only the black π -phase (and no Hadamard gate) as well aswell as the fragment which additionally has the and gate as a generator (which is equivalent tothe natural number H-box fragment of the ZH-calculus). In the former case, we show that thisis equivalent to the full subcategory of spans of (possibly empty) free, finite dimensional affine F -vector spaces, where the objects are the non-empty affine vector spaces. In the latter case,we show that this is equivalent to the full subcategory of spans of finite sets where the objectsare powers of the two element set. Because these fragments of the ZX-calculus have semanticsin terms of full subcategories of categories of spans, they can not be presented by distributivelaws over groupoids. Instead, we first construct their subcategories of partial isomorphismsvia distributive laws over all isomorphims with subobjects adjoined. After which, the full sub-category of spans are obtained by freely adjoining units and counits the the semi-Frobeniusstructures given by the diagonal and codiagonal maps. We first review some basic theory involving the presentation of props. These results are mostlyfolklore, however, I will refer the reader to [22, §2] for a more comprehensive introduction.
Definition 0.1. A pro is a strict monoidal category generated by one object under the tensorproduct, and a prop is a strict symmetric monoidal category generated by one object under thetensor product Definition 0.2. A monoidal theory is a pair ( Σ , E ) of generators Σ and equations E. Eachgenerator f ∈ Σ has a chosen domain dom ( f ) ∈ N and codomain cod ( f ) ∈ N , so that f can beseen as a map from dom ( f ) to cod ( f ) .The free pro with signature Σ has maps in Σ ∗ obtained by inductively tensoring all the generatorsand composing all appropriately typed generators in Σ , The equations in E are pairs of parallelmaps in Σ ∗ . Any monoidal theory ( Σ , E ) generates a pro ( Σ , E ) given by the free pro with signature Σ modulo the equations in E.A symmetric monoidal theory is the symmetric version of a monoidal theory, which generatesa prop. Here the set Σ ∗ is obtained by composing and tensoring maps with symmetries, and thenquotienting by the axioms of a prop. Lemma 0.3.
Given two (symmetric) monoidal theories ( Σ , E ) and ( Σ , E ) the coproduct ofpro(p)s ( Σ , E ) + ( Σ , E ) is generated by the (symmetric) monoidal theory ( Σ + Σ , E + E ) . a r X i v : . [ m a t h . C T ] F e b Distributive Laws, Spans and the ZX-calculus
Lemma 0.4.
Given three (symmetric) monoidal theories ( Σ , E ) , ( Σ , E ) and ( Σ , E ) where ( Σ , E ) is a sub-pro(p) of both ( Σ , E ) and ( Σ , E ) . The pushout of the diagram of pro(p)s ( Σ , E ) ← ( Σ , E ) → ( Σ , E ) is generated by the (symmetric) monoidal theory ( Σ ∗ + Σ Σ ∗ , E + E ) . We recall the novel way to compose pro(p), first described in [16]:
Definition 0.5.
Suppose there three (symmetric) monoidal theories ( Σ , E ) , ( Σ , E ) and ( Σ , E ) where ( Σ , E ) is a sub-pro(p) of both ( Σ , E ) and ( Σ , E ) . A distributive law of pro(p)s is adistributive law λ : ( Σ , E ) ⊗ ( Σ , E ) ( Σ , E ) in Mon - Prof . Informally, this is a way to push all themaps in Σ ∗ past those of Σ ∗ modulo Σ and the equations E + E and the axioms of a pro(p). In [16] it is required that ( Σ , E ) is a groupoid; however, we must loosen this requirement (notethat when this is not a groupoid, there is no correspondence to factorization systems as in [19]). Lemma 0.6.
Suppose that we have three (symmetric) monoidal theories and a distribtuive law λ : ( Σ , E ) ⊗ ( Σ , E ) ( Σ , E ) as above.Then the induced pro(p) ( Σ , E ) ⊗ ( Σ , E ) ( Σ , E ) is presented by the monoidal theory ( Σ ∗ + Σ Σ ∗ , E + E + E λ ) , where E λ are all the equations needed to push elements of Σ ∗ past thoseof Σ ∗ up to Σ ∗ , dictated by λ . There is a folklore result that the prop for the free commutative monoid is equivalent to the categoryof finite sets and functions under the direct sum. The string diagrams correspond to drawing the“graphs” of functions.
Definition 0.7.
Let
Mono be the free prop with one generator of type → drawn as a black circle;and Epi be the prop generated by the free associative commutative binary operationm graphicallygenerated by the following : (1) = , (2) = Definition 0.8.
Let
Mono ( X ) and Epi ( X ) denote the subcategories of monomorphisms and epi-morphisms of X . Lemma 0.9.
The category ( Mono ( FinSet ) , +) is presented by the prop Mono and ( Epi ( FinSet ) , +) by the prop Epi . Moreover, ( FinSet , +) is presented by the distributive law: Epi ⊗ p Mono ; = (3) = Yielding the prop for the free commutative monoid, cm . Diagrams are read from bottom to top. ole Comfort ( FinSet , +) [16,§5.3, 5.4]: Definition 0.10.
Consider the following two distributive laws: cm op ⊗ p cm ; (4) = , (5) = , ( ) op = , (6) = cm ⊗ p cm op ; (7) = , = (8) = The former yields, cb , the prop for the free bicommutative bialgebra and the latter yields, scfa ,the prop for the free special commutative Frobenius algebra . Lemma 0.11. [16, §5.3, 5.4] cb is a presentation for ( Span ( FinSet ) , +) and scfa is a presentationfor ( Cospan ( FinSet ) , +) . The equations generating these distributive laws give us a recipe for how to generate all pushoutsand pullbacks along epics and monics. This category of spans can be seen from a slightly differentperspective:
Lemma 0.12.
There is an equivalence of props cb ∼ = ( Span ( FinSet ) , +) ∼ = ( Mat ( N ) , +) . Although we are quite sure that the second equivalence is also folklore, a similar result is given in[6].One way to see this is by interpreting the monoid as addition and 0 and the comonoid as copy-ing/deleting. For example, consider the interpretation of the following diagram in cm op ⊗ p cm as amatrix: (cid:117)(cid:118) (cid:125)(cid:126) = Definition 0.13.
Let cb denote the quotient of cb by the equation: (9) = Lemma 0.14. cb is a presentation for the prop ( Mat ( F ) , +) .Proof. As an Abelian group F ∼ = Z / Z ; which is generated by the equation 2 ≡
0, correspondingto this quotient of cb . Distributive Laws, Spans and the ZX-calculus
In this section we build up to giving a presentation for ( Span ( Mat ( F )) , +) in a modular way. Thiscategory is shown to be the same as the phase-free Hadamard free fragment of the ZX-calculus.Although this presentation of linear spans has already been discussed in great detail for arbitraryPIDs [22], our particular method of exposition is necessary to motivate the affine and full cases. Definition 1.1.
Consider the prop
Iso ( cb ) generated by the controlled not gate: (cid:115) (cid:123) = modulo the following relations: (10) = (11) = (12) = (13) = (14) = Lemma 1.2. [17, Thm. 6]
Iso ( cb ) is a presentation for the prop ( Iso ( Mat ( F ) , +)) Definition 1.3.
Consider the prop
Mono ( cb ) generated by the coproduct of props Iso ( cb )+ Mono modulo the equation: (15) = Lemma 1.4. [17, Thm. 7]
Mono ( cb ) is a presentation for the prop ( Mono ( Mat ( F )) , +) The white comultiplication can be derived in this fragment: (cid:115) (cid:123) = =
As a matter of notation, given a category X with finite limits, we refer to the subcategory of Span ( X ) where the left leg is monic as Par ( X ) , and the subcategory of spans where all legs aremonic by ParIso ( X ) . These two categories, respectively, give semantics for partial maps and par-tially invertible maps in X (see [9] for more details). Definition 1.5.
Consider the prop
ParIso ( cb ) generated by the distributive law of props: Mono ( cb ) op ⊗ Iso ( cb ) Mono ( cb ) ; (6) = To see that this is actually a distributive law, see Remark A.1.
Lemma 1.6.
ParIso ( cb ) is a presentation for the prop ( ParIso ( Mat ( F ) , +)) . We can get partial maps by freely adding a counit to the nonunital, noncounital special commutativeFrobenius algebra:
Definition 1.7.
Let
Par ( cb ) denote the pushout of the diagram of props: ParIso ( cb ) ← Epi op → cm op Lemma 1.8.
Par ( cb ) is a presentation for the prop ( Par ( Mat ( F ) , +)) . ole Comfort Definition 1.9.
Let
Span ( cb ) denote the pushout of the diagram of props: Par ( cb ) op ← ParIso ( cb ) → Par ( cb ) The following lemma holds because of [12, Lem. 4.3]:
Lemma 1.10.
Span ( cb ) is a presentation for the prop ( Span ( Mat ( F )) , +) . The proof is contained in §A.1.3. Given a PID k , the prop ( Span ( Mat ( k )) , +) is already known tohave a presentation given in terms of “interacting Hopf algebras” [22, Definition 3.13]. This is alsothe way in which the phase-free fragment of the ZX-calculus would be presented, in terms of twoFrobenius algebras corresponding to the Z and X observables, interacting to form Hopf algebras inaddition to a few more equations. Definition 2.1.
Consider the prop
Affcb given by adjoining the following generator to cb π modulo the equations: π ( ) op = π π π (6) = Lemma 2.2. [17, §4]
Affcb is a presentation for the prop ( AffMat ( F ) , +) . Note that this assumes that affine matrices are non-empty, as this is a prop. This will become aproblem later, when we wish to pull back affine spaces.
Definition 2.3.
Consider the prop
Iso ( Affcb ) generated by the controlled not gate, and the notgate (interpreted as matrices): (cid:115) (cid:123) = (cid:114) (cid:122) = π Modulo the relations of
Iso ( cb ) as well as the additional relations: (16) = (17) = (18) = Lemma 2.4. [17, Thm. 11]
Iso ( Affcb ) is a presentation for the prop ( Iso ( AffMat ( F ) , +)) . Definition 2.5.
Let
Mono ( Affcb ) denote the pushout of the diagram of props: Mono ( cb ) ← Iso ( cb ) → Iso ( Affcb ) Lemma 2.6.
Mono ( Affcb ) is a presentation for the prop ( Mono ( AffMat ( F )) , +) . Distributive Laws, Spans and the ZX-calculus
The proof is contained in §2.6.To define partial isomorphisms, we must add a point to the constituent props of the desired dis-tributive law, because the empty set can arise as a subobject by pullback (where the empty set isnot properly an object in the prop).
Definition 2.7.
Let
Iso ( Affcb ) + denote the prop obtained by adjoining the following generatorto Iso ( Affcb ) π modulo the equations: π π (19) = π , π (20) = π , π (21) = π , π (22) = π Lemma 2.8.
Iso ( Affcb ) + is a presentation for the subcategory of ( Span ( AffFdFVect ( F )) , +) generated by spans F n = F n f −→ ∼ = F n and F n (cid:111) (cid:111) ? (cid:111) (cid:111) /0 (cid:47) (cid:47) ? (cid:47) (cid:47) F n , for all n ∈ N and isomorphisms f .Proof. Identify this new generator with the span F ← /0 → F . If there is a factor of π , repeatedlyapply these identities from left to right until the diagram corresponding to the identity tensored by π is obtained, which is as a normal form. Definition 2.9.
Let
Mono ( Affcb ) + denote the pushout of the diagram of props: Mono ( Affcb ) ← Iso ( Affcb ) → Iso ( Affcb ) + Lemma 2.10.
Mono ( Affcb ) + is a presentation for the subcategory of ( Span ( AffFdFVect ( F )) , +) generated by spans F n = F n (cid:47) (cid:47) e (cid:47) (cid:47) F m and F n (cid:111) (cid:111) ? (cid:111) (cid:111) /0 (cid:47) (cid:47) ? (cid:47) (cid:47) F n , for all n , m ∈ N and monics e. The proof of this lemma is essentially the same for
Iso ( Affcb ) + , although diagrams with a factorof π are reduced to the following normal form: π n m ······ Unlike in the linear case, now we must consider a distributive law over a prop which is not agroupoid: we add a single idempotent corresponding to the empty set to the isomorphisms. To sat-isfy the requirement that this prop is a sub-prop of the left and right components of the distributivelaw, we also add this idempotent to the injections and the co-injections:
Definition 2.11.
Consider the prop piAffcb generated by the distributive law of props: ( Mono ( Affcb ) + ) op ⊗ Iso ( Affcb ) + Mono ( Affcb ) + Given by the equations of piAffcb as well as: π = π (23) = π To see that this is actually a distributive law, see Remark A.2.
Lemma 2.12.
ParIso ( Affcb ) is a presentation for the full subcategory ParIso ( AffFdFVect ( F )) ∗ of ParIso ( AffFdFVect ( F )) where the objects are nonempty affine vector spaces. ole Comfort Proof.
The obvious functor
ParIso ( Affcb ) → ParIso ( AffFdFVect ( F )) ∗ is clearly full, as well asan isomorphism on objects. It remains to show it is faihful. It is faithful on maps which are taken tospans with nonempty apex by the same argument as Lemma 1.6. For empty case, there is exactlyone diagram of each type with a factor of 0; and similarly, there is exactly one span with an emptyapex.By [8] in this the identities of Definition 2.7 can be replaced by the following identity, whilemaintaining completeness: π (24) = π ππ Definition 2.13.
Let pAffcb denote the pushout of the diagram of props: piAffcb ← Epi op → cm op Lemma 2.14. pAffcb is a presentation for the prop ( Par ( AffFdFVect ( F )) ∗ , +) . The proof is contained in §A.2.3.
Definition 2.15.
Let spAffcb denote the pushout of the diagram of props: pAffcb op ← piAffcb → pAffcb Lemma 2.16. spAffcb is a presentation for the prop ( Span ( AffFdFVect ( F )) ∗ , +) . The proof is contained in §A.2.4. This is almost equivalent to the presentation given in [3] whichgives a presentation for the full subcategory of relations of finite dimensional affine vector spaceswhere the objects are given by the nonempty vector spaces, and is much more in the spirit of theZX-calculus.
Recall that unlike when the tensor product is the coproduct; when the tensor product is induced bythe multiplication, to obtain a prop, one must consider the subcategory generated by tensoring afixed object with itsef.
Definition 3.1.
Let L F × be the prop generated by quotienting cb by the equation: & (25) = Where the components of the monoid are relabled as follows: (cid:18) & , π (cid:19) Lemma 3.2. L × F is a presentation for the Lawvere theory for the group of units of the field F . Definition 3.3.
Consider the prop f , generated by the distributive law:L F × ⊗ cm op cb ; & (26) = & & , & (27) = Distributive Laws, Spans and the ZX-calculus
Lemma 3.4. [17, Thm. 10] f is a presentation for the prop ( FinSet , × ) . Therefore in some sense, we are justified in thinking of this prop ( FinSet , × ) as a sort of categori-fication of boolean polynomials.To find larger fragments, it will be useful to first identify the isomorphisms and the monics of f . Definition 3.5.
Given a map f in f , the oracle for f , O f is defined as follows: f ······ Lemma 3.6.
The oracles in f are generated by the generalized controlled-not gates: π , , &nn ······ Proof.
Any Boolean function of n arguments can be represented by a polynomial in F [ x , . . . , x n ] / (cid:104) x − x , . . . x − x (cid:105) . Every polynomial in this quotient ring has a unique normalform given by sums of products (which is not true for arbitrary finite fields). Each product corre-sponds to a generalized controlled-not gate, and the sum corresponds to composing these general-ized controlled-not gates in sequence.In the quantum circuit notation the generalized controlled-not gates are drawn as follows (the firstbeing the not gate, and the second being the controlled-not gate): , , ··· n Lemma 3.7. [21, Thm. 5.1] The prop generated by the oracles in f generate Iso ( f ) . Denote a generalized controlled not gate controlled by wires indexed by X , operating on x by { X , x } Iwama et al [15] originally gave a complete set of identities for circuits generated by generalizedcontrolled not gates where the value of all-but-one output wires are fixed. It is worth mentioningthat Shende et al. later used the commutator to generalize some of these identities [20, Cor. 26].We conjecture that a very similar set of identities is complete for Boolean isomorphisms:
Conjecture 3.8.
Let
Iso ( FinSet ) denote the prop generated by all generalized controlled-not gatesmodulo the following identities: • { X , x }{ X , x } = If x / ∈ Y and y / ∈ X then { X , x }{ Y , y } = { Y , y }{ X , x } . ole Comfort If x / ∈ Y , then { X , x }{{ x } (cid:116) Y , y } = { X ∪ Y , y }{{ x } (cid:116) Y , y }{ X , x } . • If x / ∈ Y , then {{ x } (cid:116) Y , y }{ X , x } = { X , x }{{ x } (cid:116) Y , y }{ X ∪ Y , y } . • If x ∈ Y and y ∈ X , then { X , x }{ Y , y }{ X , x } = { Y , y }{ X , x }{ Y , y } . Note that the symmetry is derived in this fragment by composing 3 controlled not gates, as inDefinition . The axioms of a prop are derived, so we are justified in calling
Iso ( f ) a prop.Although we aren’t sure if these identities are complete, it doesn’t matter in the end. With eachgenerator we add, we add new enough identities to give a complete presentation, given that thereis a complete presentation for Iso ( f ) . However, eventually once we add enough generators andidentities, we get a finite, complete presentation. Definition 3.9.
Let
Mono ( f ) be the prop given by adjoining the black unit to Iso ( f ) modulo: ··· n (28) = ··· n Lemma 3.10.
Mono ( f ) is a presentation for the prop ( Mono ( FinSet ) , × ) . The pushout of a diagram of sets and functions 2 n (cid:111) (cid:111) (cid:111) (cid:111) k (cid:47) (cid:47) (cid:47) (cid:47) m is not always a power of 2. There-fore, one should not expect to construct categories of partial isomorphisms via a distributive lawof on Mono ( f ) ⊗ Iso ( f ) Mono ( f ) op . Instead one must add all of the nontrivial subobjects to theconstituent props forming the distributive law; as opposed to the affine case, there are more thanone such subobjects which arise in this way. Definition 3.11.
Consider the pro sub generated by endomorphisms such that for any n, sub ( n , n ) is the set described by all n-variable polynomials over F . Denote such a generator by a box withn inputs and n outputs labelled by the corresponding polynomial.We require that the following equations hold so that ∀ n , m ∈ N , p , r ∈ F [ x , . . . , x n ] , q ∈ F [ x n + , . . . , x n + m ] : nn (29) = nn rpnn (30) = p + r + prnn p qn mn m (31) = p · qn mn m As well as, for all n, the equations of the quotient rings F [ x , . . . , x n ] / (cid:104) x − x , . . . , x n − x n (cid:105) . Lemma 3.12. sub is a presentation for the pro of symmetric spans of monic functions, ie spans ofthe following form n e ←− k e −→ n , for all n , k ∈ N and monics e.Proof. Each polynomial p ∈ F [ x , . . . , x n ] / (cid:104) x − x , . . . , x n − x n (cid:105) corresponds to a function ev p : Z n → Z given by evaluation. Let k = | ev − ( ) | , then there chose a function f p : k (cid:26) n pickingout all the solutions which evaluate to 1. The functor from sub to this subcategory spans takes0 Distributive Laws, Spans and the ZX-calculus polynomials p (cid:55)→ ( n (cid:111) (cid:111) f p (cid:111) (cid:111) k (cid:47) (cid:47) f p (cid:47) (cid:47) n ) . Any two two spans induced by the same polynomial are isomor-phic, so this is actually well defined. It is clearly an isomorphism on objects, and it can easily beshown to be a monoidal functor.The fullness is easy and the faithfulness comes from the fact that we can reduce every map to apolynomial and then reduce the polynomial to algebraic normal form. Definition 3.13.
Let subIsof be the prop generated by a distributive law of pros: sub ⊗ Iso ( f ) ; ∀ n , m , k ∈ N , ∀ p ∈ F [ x , . . . , x n + + m ] , q ∈ F [ x , . . . , x n + m + + k ] , r ∈ F [ x , . . . , x n ] : p ( x ,..., x n , x n + , x n + , x n + ,..., x n + + m ) nn mm (32) = p ( x ,..., x n , x n + , x n + , x n + ,..., x n + + m ) nn mmq ( x ,..., x n + m + + k ) n kmn km (33) = q ( x ,..., x n + m , ( x n + ... x n + m − )+ x n + m + , x n + m + ,..., x n + m + + k ) n kmn km r (34) = r Lemma 3.14. subIsof is a presentation for the subcategory of ( Span ( FinSet ) , × ) generated byspans of the form n (cid:111) (cid:111) e (cid:111) (cid:111) k (cid:47) (cid:47) e (cid:47) (cid:47) m f −→ ∼ = m , for all n , mk ∈ N and all isomorphisms f and monics e.Proof. The obvious functor is clearly monoidal. Moreover, it is full by construction. For thefaithfulness, take two maps f and g in subIsof . Then one can just push everything to the end andthen use the decidability of equality on both factors of the distributive law to show that they areequal. Definition 3.15.
Consider the prop subMonof generated by a distributive law of props: subIsof ⊗ Iso ( f ) Mono ( f ) ; ∀ n , m ∈ N , p ∈ F [ x , . . . , x n + + m ] : p ( x ,..., x n + + m ) n mn m (35) = p ( x ,..., x n , , x n + ,..., x n + + m ) n mn m Lemma 3.16. subMonof is a presentation for the subcategory of ( Span ( FinSet ) , × ) generated byspans of the form n (cid:111) (cid:111) e (cid:111) (cid:111) k (cid:47) (cid:47) e (cid:47) (cid:47) n (cid:47) (cid:47) e (cid:48) (cid:47) (cid:47) m for all n , m , k ∈ N and all monics e , e (cid:48) . The proof is completely analogous to as in the case of subif .Any n variable polynomial p can be interpreted as a span of monics via the oracle O p , where thevalue of the target wire is restricted to have the value 0. Each such polynomial corresponds to asubobject, which complicates the matter further than in the affine case. ole Comfort Definition 3.17.
Consider the prop pif given by the distributive law of props: subMonof op ⊗ subIsof subMonof ; O p (36) = p Lemma 3.18. pif is a presentation for the full subcategory ( FPinj , × ) of ( ParIso ( FinSet ) , × ) with objects powers of two. Unlike the previous lemmas, this is not dependant on a complete presentation for the isomorphisms.The proof is a consequence of [11, Thm 7.6.14] where they give a finite, complete presentation forthis category. The identities up to this point are equivalent to this finite presentation, whether ornot the conjectured presentation for the isomorphisms is complete.
Definition 3.19.
Consider the prop pf given by the pushout of the following diagram of props,given by adding a counit to the diagonal map: pif ← Epi op → cm op Lemma 3.20. pf is a presentation for the the full subcategory ( FPar , × ) of ( Par ( FinSet ) , × ) withobjects powers of two. The proof is contained in §A.3.1.
Definition 3.21.
Let spf denote the pushout of the diagram of props: pf op ← pif → pf Lemma 3.22. [12] spf is a presentation for the full subcategory ( FSpan , × ) of ( Span ( FinSet ) , × ) with objects powers of two. See §A.3.2 for the proof. There is a particularly elegant finite presentation which is much moreZX-flavoured, dubbed ZX & . Based on a similar observation to one made in [6], the author of [12]remarks that this category is equivalent as a prop to the full subcategory of natural number matriceswhere the objects are powers of 2.As remarked in [12], this category is equivalent to the ”natural number H-box fragment” of the ZH-calculus. That is to say, the prop generated by the Z and X spiders (coresponding to (co)copyingand (co)addition) along with H-boxes which have values restricted to be natural numbers. Theinterpretation of these H-boxes is given in [12, Fig. 5], which we restate for reference:: = & n : = π &n Note that arbitrary arity H-boxes can be obtained by composition with and gates.2
Distributive Laws, Spans and the ZX-calculus
In this paper, we have devised a method to give modular presentations for full subcategories ofcategories of spans; albeit, this method is proven to work in full generality. In all three cases wewe have considered, there is a fully faithful symmetric monoidal functor F : X → Y between aprop X and a symmetric monoidal category Y . And the categories which we eventually build upto are the full subcategories of Span ( Y ) with objects in F ( X ) . In other words, these are structuredspan categories F Span ( Y ) , as considered in [2] (or structure cospan categories F op Cospan ( Y op ) ).We build up to F Span ( Y ) first by presenting the isos and monics in Y in terms of a symmetricmonoidal theory. Then we consider the subcategory of F Span ( Y ) generated by monic spans spansof the form FX (cid:111) (cid:111) e (cid:111) (cid:111) Y (cid:47) (cid:47) e (cid:47) (cid:47) FX , corresponding to the new subobjects created in pullback of maps in F ( X ) : presenting these as monoidal theories. Then we add these subobjects to the isos and monosby distributive law and again present these in terms of symmetric monoidal theories. After doingso, we are able to construct a distributive law between the monics and co-monics in F Span ( Y ) up to isomorphisms with subobjects adjoined to all three props (this is a crucial step because inthe nonlinear case, not all pullbacks exist, so one can not construct a distributive law over theisomorphisms). We then observe that the prop generated by such a distributive law is a discreteinverse category (as defined in [14, Def. 4.3.1]), thus one can complete it to a discrete Cartesianrestriction category by adding counits to the codiagonal map (as observed in [12, Lem. 3.5]).Finally, one can glue together the discrete inverse category to its opposite category up to the shareddiscrete inverse category to obtain F Span ( Y ) .This method is quite generic, and it would be useful to establish some criteria for when it canbe applied categories of structured spans. There are various ways in which this method couldpotentially be employed to give a modular presentation of such a category of structured spans.Possibly the easiest such class of examples would be that given by the functor ( AffMat ( k ) , +) → ( AffFVect ( k ) , +) , for an arbitrary field (or maybe even PID k ). More difficult, would be the classof examples given by FinSet p → ( FinSet , × ) , for arbitrary prime p >
2. As opposed to in thecase of p =
2, the presentation for the prop of subobjects would be less simple; only in this casecan systems of multivariate polynomials always be reduced to a single polynomial. To producea normal form in the more general case, we expect that one would have to employ the use ofGr¨obner bases. Another model which one could pursue is that given by the functor from free,finitely generated commutative semigroups to additive monoids. A presentation is given for thecorresponding category of relations in [18, §3.3]; however, it is not given a modular treatment.This would potentially be useful because of applications in concurrency theory.Other directions would be to try to add more phases in a modular fashion. Perhaps the work of [13]could help add more phases to this picture in a modular fashion.
Acknowledgements
The author thank Aleks Kissinger for useful discussions. ole Comfort References [1] M Backens and A Kissinger. Zh: A complete graphical calculus for quantum computations involvingclassical non-linearity.
Electronic Proceedings in Theoretical Computer Science , 287:23–42, 2019.[2] John C Baez and Kenny Courser. Structured cospans. arXiv preprint arXiv:1911.04630 , 2019.[3] Filippo Bonchi, Robin Piedeleu, Pawel Soboci´nski, and Fabio Zanasi. Graphical affine algebra. In , pages 1–12. IEEE,2019.[4] Filippo Bonchi, Pawel Sobocinski, and Fabio Zanasi. Lawvere categories as composed props. In
International Workshop on Coalgebraic Methods in Computer Science , pages 11–32. Springer, 2016.[5] Filippo Bonchi, Paweł Soboci´nski, and Fabio Zanasi. Interacting hopf algebras.
Journal of Pure andApplied Algebra , 221(1):144–184, 2017.[6] Roberto Bruni and Fabio Gadducci. Some algebraic laws for spans (and their connections with mul-tirelations).
Electronic Notes in Theoretical Computer Science , 44(3):175–193, 2003.[7] JRB Cockett and Cole Comfort. The category TOF. arXiv preprint arXiv:1804.10360 , 2018.[8] JRB Cockett, Cole Comfort, and Priyaa Srinivasan. The category CNOT. arXiv preprintarXiv:1707.02348 , 2017.[9] JRB Cockett and Stephen Lack. Restriction categories i: categories of partial maps.
Theoreticalcomputer science , 270(1-2):223–259, 2002.[10] Bob Coecke and Ross Duncan. Interacting quantum observables. In
International Colloquium onAutomata, Languages, and Programming , pages 298–310. Springer, 2008.[11] Cole Comfort. Classifying reversible logic gates with ancillary bits. 2019.[12] Cole Comfort. The zx& calculus: A complete graphical calculus for classical circuits using spiders. arXiv preprint arXiv:2004.05287 , 2020.[13] Ross Duncan and Kevin Dunne. Interacting frobenius algebras are hopf. In , pages 1–10. IEEE, 2016.[14] Brett Giles.
An investigation of some theoretical aspects of reversible computing . PhD thesis, Univer-sity of Calgary, 2014.[15] Kazuo Iwama, Yahiko Kambayashi, and Shigeru Yamashita. Transformation rules for designing cnot-based quantum circuits. In
Proceedings of the 39th annual Design Automation Conference , pages419–424, 2002.[16] Stephen Lack. Composing props.
Theory and Applications of Categories , 13(9):147–163, 2004.[17] Yves Lafont. Towards an algebraic theory of boolean circuits.
Journal of Pure and Applied Algebra ,184(2-3):257–310, 2003.[18] Robin Piedeleu.
Picturing resources in concurrency . PhD thesis, University of Oxford, 2018.[19] Robert Rosebrugh and Richard J Wood. Distributive laws and factorization.
Journal of Pure andApplied Algebra , 175(1-3):327–353, 2002.[20] Vivek V Shende, Aditya K Prasad, Igor L Markov, and John P Hayes. Synthesis of reversible logiccircuits.
IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems , 22(6):710–722, 2003. Distributive Laws, Spans and the ZX-calculus [21] Tommaso Toffoli. Reversible computing. In
International colloquium on automata, languages, andprogramming , pages 632–644. Springer, 1980.[22] Fabio Zanasi. Interacting hopf algebras: the theory of linear systems. arXiv preprint arXiv:1805.03032 ,2018.
A Proofs
A.1 Section 1
A.1.1 Remark on Definition 1.5Remark A.1.
This is actually a distributive law because the only only seemingly nontrivial situa-tion arises when controlled not gates are sandwiched by black units/counits on their target wires.However the following identity holds by induction on the number of controlled not gates. For thebase case of n = , this follows from the bone law which we added to the distributive law. Forn > , we have the following situation: ... ... ··· = ...... ··· ...... For n = , that is: = = = And for the base case for n = : = = = = = = = The inductive case is essentially the same as the base case for 2.
A.1.2 Proof of Lemma 1.8
Recall the statement of the result:
Lemma 1.8:
Par ( cb ) is a presentation for the prop ( Par ( Mat ( F ) , +)) ole Comfort Proof.
One must show that the following diagram commutes:
Epi op (cid:47) (cid:47) (cid:116) (cid:116) cm op (cid:116) (cid:116) ParIso ( cb ) (cid:47) (cid:47) ∼ = (cid:15) (cid:15) Par ( cb ) ∼ = (cid:15) (cid:15) Epi op (cid:116) (cid:116) (cid:47) (cid:47) cm op (cid:119) (cid:119) (cid:116) (cid:116) ParIso ( Mat ( F )) , +) (cid:46) (cid:46) (cid:47) (cid:47) ∼ = (cid:15) (cid:15) ( Par ( Mat ( F )) , +) It doesn’t take to much work to show that
ParIso ( cb ) ∼ = ParIso ( Mat ( F )) is a discrete inverse cat-egory (defined in [14, §4.3]). We know that the counital completion of a discrete inverse categoryis the same as its Cartesian completion from [12, Lem. 3.5]; moreover, the Cartesian completionof ParIso ( Mat ( F )) is Par ( Mat ( F )) . So this diagram commutes as a consequence. A.1.3 Proof of Lemma 1.10
Recall the statement of the result:
Lemma 1.10:
Span ( cb ) is a presentation for the prop ( Span ( Mat ( F )) , +) .Proof. Mono ( cb ) op ⊗ Iso ( cb ) Mono ( cb ) (cid:47) (cid:47) (cid:114) (cid:114) ∼ = (cid:15) (cid:15) Par ( cb ) ∼ = (cid:15) (cid:15) (cid:115) (cid:115) Par ( cb ) op (cid:47) (cid:47) ∼ = (cid:15) (cid:15) Span ( cb ) ∼ = (cid:15) (cid:15) ( ParIso ( Mat ( F )) , +) (cid:114) (cid:114) (cid:47) (cid:47) ( Par ( Mat ( F )) , +) (cid:117) (cid:117) (cid:115) (cid:115) ( Par ( Mat ( F )) , +) op (cid:47) (cid:47) (cid:47) (cid:47) ∼ = F (cid:15) (cid:15) ( Span ( Mat ( F )) , +) The cube easily commutes. What remains to be shown is that the universal map F is an isomor-phism of props. It is clearly the identity on objects, so we just need to show it is full and faithful.It is clearly full as any span n f ←− k g −→ m , we have: F (cid:16) ( n f ←− k = k ) ; ( k = k g −→ m ) (cid:17) = n f ←− k g −→ m Distributive Laws, Spans and the ZX-calculus
For faithfulness, we must observe given for any two isomorphic maps in
Span ( Mat ( F )) : k f (cid:48) (cid:121) (cid:121) ∼ = h (cid:15) (cid:15) g (cid:48) (cid:37) (cid:37) n mk f (cid:101) (cid:101) g (cid:57) (cid:57) Then in the domain of F , we have: k f (cid:125) (cid:125) n k ; k g (cid:34) (cid:34) k m = k f (cid:125) (cid:125) n k ; kk kk h (cid:97) (cid:97) h (cid:61) (cid:61) ∼ = h (cid:79) (cid:79) ; k g (cid:34) (cid:34) k m = k f (cid:125) (cid:125) n k ; k h (cid:125) (cid:125) k k ; k h (cid:33) (cid:33) k k ; k g (cid:34) (cid:34) k m = k h (cid:125) (cid:125) f (cid:48) (cid:15) (cid:15) k f (cid:125) (cid:125) k h (cid:125) (cid:125) n k k ; k h (cid:33) (cid:33) g (cid:48) (cid:16) (cid:16) k h (cid:33) (cid:33) k g (cid:34) (cid:34) k k m A.2 Section 2
A.2.1 Proof of Lemma 2.6
Recall the statement of the result:
Lemma 2.6:
Mono ( Affcb ) is a presentation for the prop ( Mono ( AffMat ( F )) , +) .Proof. Consider the following diagram:
Iso ( cb ) (cid:47) (cid:47) (cid:115) (cid:115) ∼ = (cid:15) (cid:15) Iso ( Affcb ) ∼ = (cid:15) (cid:15) (cid:114) (cid:114) Mono ( cb ) (cid:47) (cid:47) ∼ = (cid:15) (cid:15) Mono ( Affcb ) ∼ = (cid:15) (cid:15) ( Iso ( Mat ( F )) , +) (cid:115) (cid:115) (cid:47) (cid:47) ( Iso ( AffMat ( F )) , +) (cid:116) (cid:116) (cid:114) (cid:114) ( Mono ( Mat ( F )) , +) (cid:47) (cid:47) (cid:47) (cid:47) ∼ = F (cid:15) (cid:15) ( Mono ( AffMat ( F )) , +) The rear and left faces of the cube commute and the vertical maps are all isomorphisms. Therefore,the whole cube commutes via universal property of the pushout, with the upper universal map beingan isomorphism. ole Comfort F is also an isomorphism. It is clearly the identityon objects, so we just have to show fullness and faithfulness.For fullness, consider any map n (cid:47) (cid:47) ( A , x ) (cid:47) (cid:47) m in ( Mono ( AffMat ( F )) , +) . Note that this can be factoredinto: n (cid:47) (cid:47) ( A , ) (cid:47) (cid:47) m ( , x ) ∼ = (cid:47) (cid:47) m Which lies in the image of F as m ( , x ) ∼ = (cid:47) (cid:47) m is an isomorphism.For faithfulness, we show that every map in ( Iso ( AffMat ( F )) , +)+ ( Iso ( Mat ( F )) , +) ( Mono ( Mat ( F )) , +) can be factored uniquely in this way. There are two cases: (cid:18) n (cid:47) (cid:47) A (cid:47) (cid:47) m ; m ( B , x ) ∼ = (cid:47) (cid:47) m (cid:19) = (cid:18) n (cid:47) (cid:47) A (cid:47) (cid:47) m ; m ( B , ) ∼ = (cid:47) (cid:47) m ; m ( , x ) ∼ = (cid:47) (cid:47) m (cid:19) = (cid:18) n (cid:47) (cid:47) A ; B (cid:47) (cid:47) m ( , x ) ∼ = (cid:47) (cid:47) m (cid:19)(cid:18) n (cid:47) (cid:47) ( A , x ) (cid:47) (cid:47) m ; m B ∼ = (cid:47) (cid:47) m (cid:19) = (cid:18) n (cid:47) (cid:47) ( A , ) (cid:47) (cid:47) m ; m ( , x ) ∼ = (cid:47) (cid:47) m ; m B ∼ = (cid:47) (cid:47) m (cid:19) = (cid:18) n (cid:47) (cid:47) A (cid:47) (cid:47) m ; m ( B , B ( x )) ∼ = (cid:47) (cid:47) m (cid:19) = (cid:18) n (cid:47) (cid:47) A ; B (cid:47) (cid:47) m ; m ( , B ( x )) ∼ = (cid:47) (cid:47) m (cid:19) So every map in this pushout has the correct form, which is unique by construction.
A.2.2 Remark on Definition 2.11Remark A.2. ( Mono ( Affcb ) + ) op ⊗ Iso ( Affcb ) + Mono ( Affcb ) + is actually a distributive lawbecause the only only nontrivial situation arises when controlled-not gates are sandwiched betweenblack, or black π units/counits on their target wires. The case where there are no controlled notgates in between is resolved by the new axiom we have added. When there are more controlled-notgates, they can be pushed past each other as follows: ... ... π ··· = ... ... ··· = ... ... ··· = ... ... ··· = ··· ...... ...... = ππ ··· ...... ...... A.2.3 Proof of Lemma 2.14
Recall the statement of the result:
Lemma 2.14: pAffcb is a presentation for the prop ( Par ( AffFVect ( F )) ∗ , +) . Distributive Laws, Spans and the ZX-calculus
Proof.
Epi op (cid:47) (cid:47) (cid:115) (cid:115) cm op (cid:116) (cid:116) piAffcb (cid:47) (cid:47) ∼ = (cid:15) (cid:15) pAffcb ∼ = (cid:15) (cid:15) Epi op (cid:115) (cid:115) (cid:47) (cid:47) cm op (cid:118) (cid:118) (cid:116) (cid:116) ( ParIso ( AffFVect ( F )) ∗ , +) (cid:46) (cid:46) (cid:47) (cid:47) F ∼ = (cid:15) (cid:15) ( Par ( AffFVect ( F )) ∗ , +) We know that piAffcb ∼ = ParIso ( AffFVect ( F )) ∗ , +) is a discrete inverse category by [8, Prop.3.4].The cube commutes by the universal property of the pushout, as before.We just have to show that the universal map F is an isomorphism. It is clearly the identity onobjects, so we just have to show it is full and faithful. This follows from essentially the sameargument as in the linear case. A.2.4 Proof of Lemma 2.16
Recall the statement of the result:
Lemma 2.16: spAffcb is a presentation for the prop ( Span ( AffFVect ( F )) ∗ , +) .Proof. piAffcb (cid:47) (cid:47) (cid:114) (cid:114) ∼ = (cid:15) (cid:15) pAffcb ∼ = (cid:15) (cid:15) (cid:114) (cid:114) pAffcb op (cid:47) (cid:47) ∼ = (cid:15) (cid:15) spAffcb ∼ = (cid:15) (cid:15) ( ParIso ( AffFVect ( F )) ∗ , +) (cid:114) (cid:114) (cid:47) (cid:47) ( Par ( AffFVect ( F )) ∗ , +) (cid:116) (cid:116) (cid:114) (cid:114) ( Par ( AffFVect ( F )) ∗ , +) op (cid:47) (cid:47) (cid:47) (cid:47) F ∼ = (cid:15) (cid:15) ( Span ( AffFVect ( F )) ∗ , +) The rear and left faces of the cube commute and the vertical maps are all isomorphisms. Therefore,the whole cube commutes by the universal property of the pushout, with the upper universal mapbeing an isomorphism.We seek to show that the lower universal map F is also an isomorphism. It is clearly the identityon objects, so we just have to show fullness and faithfulness. ole Comfort F n ( A , x ) ←−−− F k ( B , y ) −−→ F m in ( Span ( AffFVect ( F )) ∗ , +) .This is in the image of the following diagram under F : ( F n ( A , x ) ←−−− F k = F k ) ; ( F k = F k ( B , y ) −−→ F m ) Otherwise, consider a map of the form F n ←− /0 ? −→ F m . This the image of the following diagram: ( F n ←− /0 ? −→ F ) ; ( F
02 ? ←− /0 ? −→ F m ) For faithfulness, again, we separate the proof into two cases. The functor is faithful on diagramsin ( Span ( AffFVect ( F )) ∗ , +) with nonempty apex by the same argument as in Lemma 1.10. Thecase for spans with empty apex follows immediately as the only endomorphism on the empty setis the identity; thus, isomorphic spans must be equal on the nose. A.3 Section 3
A.3.1 Proof of Lemma 3.20
Recall the statement of the result:
Lemma 3.20: pf is a presentation for the the full subcategory ( FPar , × ) of ( Par ( FinSet ) , × ) with objects powers of two.Proof. One has to show that the following diagram commutes:
Epi op (cid:47) (cid:47) (cid:118) (cid:118) cm op (cid:118) (cid:118) pif (cid:47) (cid:47) ∼ = (cid:15) (cid:15) pf ∼ = (cid:15) (cid:15) Epi op (cid:118) (cid:118) (cid:47) (cid:47) cm op (cid:121) (cid:121) (cid:118) (cid:118) ( FPinj , × ) (cid:47) (cid:47) (cid:47) (cid:47) ∼ = (cid:15) (cid:15) ( FPar , × ) Again, the proof is essentially the same as for the linear and affine cases; the only difference beingthat the Cartesian completion of
FPinj is FPar .0 Distributive Laws, Spans and the ZX-calculus
A.3.2 Proof of Lemma 3.22
Recall the statement of the result:
Lemma 3.22: spf is a presentation for the full subcategory ( FSpan , × ) of ( Span ( FinSet ) , × ) with objects powers of two. Proof.
One has to show that the following diagram commutes: pif (cid:47) (cid:47) (cid:117) (cid:117) ∼ = (cid:15) (cid:15) pf ∼ = (cid:15) (cid:15) (cid:117) (cid:117) pf op (cid:47) (cid:47) ∼ = (cid:15) (cid:15) spf ∼ = (cid:15) (cid:15) ( FPinj , × ) (cid:117) (cid:117) (cid:47) (cid:47) ( FPar , × ) (cid:120) (cid:120) (cid:117) (cid:117) ( FPar , × ) op (cid:47) (cid:47) (cid:47) (cid:47) ∼ = (cid:15) (cid:15) ( FSpan , × ))