1 Introduction

Monoidal categories are one way of generalizing algebraic reasoning and they can be used to draw intuitive diagrams that encapsulate this reasoning graphically. That monoidal categories are a powerful abstraction has been demonstrated in countless areas, such as linear logic [19] or quantum mechanics [1], just to name a few, and are amenable to graphical reasoning [47] with diagrammatic languages such as the ZX-calculus [15]. Another abstraction of algebraic reasoning are monads [3, 37, 43] and their algebras, or representations thereof [21, 36], which are distinct from monoidal categories in that identities (like associativity) always hold strictly and they allow rather arbitrary algebraic operations. In this paper, we set out to combine these two approaches into one framework, in which monoidal category diagrams can be composed not only sequentially and in parallel with a tensor product but also with additional algebraic operations.

Fig. 1.
figure 1

Left: Probabilistic mix of a gate G with an error E. Right: Interaction of tensor and convex sum, where double wires visually indicate a tensor product

One such operation is the formation of convex combinations, which can be used to create a probabilistic mix of two or more diagrams. This occurs, for instance, when reasoning about the behaviour of noise in quantum circuits. Figure 1 shows on the left two quantum logic gates, one called G and one called E that, respectively, model the wanted behaviour and a possible error. These two gates are mixed, where G gets a probability of 0.9 and E of 0.1. The trapezoids delimit the combination of the gates, and A and B are the input and output types of the gatesFootnote 1. In monoidal categories, the gates in the picture represent morphisms \(G, E :A \rightarrow B\) and our aim is to interpret the trapezoid block as a convex sum \(G +_{0.9} E\) of these morphisms, where we define \(G +_{p} E = p G + (1-p) E\). Such sums should also nicely interact with the tensor product. For instance, if \(G_{1} :A \rightarrow B\) and \(G_{2} :C \rightarrow D\) are gates, then an identity such as \((G_{1} +_{0.9} E) \otimes G_{2} = (G_{1} \otimes G_{2}) +_{0.9} (E \otimes G_{2})\) should hold for these morphisms of type \(A \otimes C \rightarrow B \otimes D\), see Figure 1 on the right. Having an operation to form convex combinations together with intuitive identities enables reasoning about, for example, probabilistic combination and noise in quantum circuits.

The difficulty lies in combining monoidal diagrams with algebraic operations such that the algebraic identities and the monoidal identities interact coherently. We will handle this difficulty by using enriched monoidal categories, where the enrichment yields the algebraic operations and the monoidal structure the parallel composition. More precisely, we will assume that the algebraic theory is given by a monad T and that the monoidal categories are enriched over the Eilenberg-Moore category \(\textbf{Alg}^T\) of algebras for this monad. Our aim in this paper is to construct for an arbitrary monoidal category \(\textbf{C}\) an \(\textbf{Alg}^T\)-enriched monoidal category \(F\textbf{C}\) that is free in the sense that there is an inclusion \(\iota _{\textbf{C}} :\textbf{C}\rightarrow (F\textbf{C})_0\) into the underlying category of \(F\textbf{C}\) and for every \(\textbf{Alg}^T\)-enriched monoidal category \(\underline{\textbf{D}}\) and monoidal functor \(G :\textbf{C}\rightarrow \underline{\textbf{D}}_{0}\), there is a unique \(\textbf{Alg}^T\)-enriched monoidal functor \(\bar{G}_0 :F\textbf{C}\rightarrow \underline{\textbf{D}}\) that makes the following diagram commute.

figure a

This free construction does not work for all monads, but we show that the free enrichment always exists for monoidal \(\textbf{Set}\)-monads whose free T-algebra functor is left adjoint to the underlying category functor \(\textbf{Alg}^T(I,-):\textbf{Alg}^T\rightarrow \textbf{Set}\) for I the monoidal unit of \(\textbf{Alg}^T\).

Contributions  

Specifically, we contribute a construction for free enrichment over algebras for some monoidal monads in Theorem 1 and Corollary 1. We also show how the enrichment preserves symmetric monoidal structure in Theorem 3 and Corollary 2. Given this construction, we demonstrate how a graphical language for reasoning in monoidal categories can be enriched with the free algebras for these monads, which enables diagrammatic reasoning of the interaction between the sequential and parallel compositions with the algebraic structure. We show how the theory can be applied to obtain convex combinations of ZX-diagrams and what the resulting identities of diagrams are. By exploiting the mapping property of the free enrichment, we automatically obtain sound interpretations of these operations and identities. Lastly, we describe how we can use the enrichment of ZX-diagrams to reason about noise in quantum systems.

Related Work  

ZX-diagrams are universal in the sense that they can in principle represent any linear map between Hilbert spaces of dimension \(\mathbb {C}^{2^n}\) [15]. Indeed, sums and linear/convex combinations [25, 49] of ZX-diagrams can be encoded within the language, but in practice these representations oftentimes lead to either very large diagrams or to diagrams that do not reveal upon visual inspection the (linear/convex) structure that the diagram is representing. This, in return, diminishes the advantages gained by reasoning in terms of abstract graphical representations. Our perspective of using enrichment keeps the abstraction barrier and thus makes reasoning about convex combinations of diagrams tractable. In general, our theory also covers the recently developed linear combinations of ZX-diagrams such as [39, 50] and other, so far unexplored, algebraic operations such as those of join-semilattices. Moreover, the identities that have to be crafted carefully by hand and proven to be sound fall automatically out of our theory. Other related work is that of Sheet diagrams [16] and Tape diagrams [5], recently developed graphical languages for rig categories, which are categories with two monoidal structures – one for addition and one for multiplication.

Outline  

The paper is organised as follows. We start by introducing notation and recalling some background of enriched and monoidal categories in Section 2. In Section 3, we establish the necessary theory to define categories enriched over Eilenberg-Moore algebras and we construct a free enrichment over those algebras. Our next step in Section 4 is to extend these definitions and the free construction to also include monoidal structures on categories, which ensures that these enrichment and monoidal structure coherently interact. Section 5 is devoted to applying our theory to enrich ZX-diagrams with convex sums to reason about probabilistic processes such as quantum noise. We conclude the paper with directions for future work in Section 6.

2 Background

In this section, we recall some terminology from category theory [8, 34, 35, 45] and introduce some notation. We denote the collection of objects of a category C as \(|\textbf{C}|\), and the morphisms from object A to B as \(\textbf{C}(A,B)\). A monoidal category \((\textbf{C},\otimes , I )\) is a category C together with a functor \(\otimes :\textbf{C} \times \textbf{C} \rightarrow \textbf{C}\) called the tensor product and an object \( I \in |\textbf{C}|\) called the tensor unit subject to some conditions [28]. We will often refer to a monoidal category \((\textbf{C},\otimes , I )\) as just C. A monoidal category is a symmetric monoidal category (SMC) when it also has a braiding \(\sigma _{A,B}: A\otimes B \rightarrow B\otimes A\) such that \(\sigma _{B,A}\circ \sigma _{A,B} = \text {Id}_{A\otimes B}\) that is also subject to coherence conditions [28].

Given a monoidal category \((\textbf{V}, \times , *)\), a \(\textbf{V}\)-(enriched) category \(\underline{\textbf{C}}\) consists of

  • a class \(\left| \underline{\textbf{C}} \right| \) of objects,

  • for each pair \(A,B \in \left| \underline{\textbf{C}} \right| \), an object \(\underline{\textbf{C}}(A,B) \in \left| \textbf{V} \right| \) that we refer to as the hom-object,

  • for objects \(A,B,C \in \left| \underline{\textbf{C}} \right| \), a composition morphism \(\underline{\circ } :\underline{\textbf{C}}(B,C) \times \underline{\textbf{C}}(A,B) \rightarrow \underline{\textbf{C}}(A,C)\) in \(\textbf{V}\), and

  • for all \(A \in \left| \underline{\textbf{C}} \right| \), an identity element \(j_A :*\rightarrow \underline{\textbf{C}}(A,A)\)

subject to associativity and unit axioms [28]. We say that \(\textbf{V}\) is the base of enrichment for \(\underline{\textbf{C}}\). A way to look at the above definition is that we construct a \(\textbf{V}\)-enriched category \(\underline{\textbf{C}}\) by identifying morphisms of some category \(\textbf{C}\) as objects from \(\textbf{V}\), which we are able to compose by using the tensor product of \(\textbf{V}\). The most well-known example is that of locally small categories, in which the morphisms between two objects form a set, and thus we can see them as objects in the monoidal category (\(\textbf{Set},\times ,*\)) for \(\times \) the Cartesian product and \(*\) the singleton set.

With a suitable definition of \(\textbf{V}\)-functors and \(\textbf{V}\)-natural transformations, \(\textbf{V}\)-categories organise themselves into a 2-category [28], denoted by \(\textbf{V}\text {-}\textbf{Cat}\). For an SMC \((\textbf{V}, \times , *)\), \(\textbf{V}\text {-}\textbf{Cat}\) is also an SMC as follows. We define for \(\textbf{V}\)-categories \(\underline{\textbf{C}}\) and \(\underline{\textbf{D}}\) a \(\textbf{V}\)-category \(\underline{\textbf{C}}\otimes \underline{\textbf{D}}\) with objects \(\left| \underline{\textbf{C}}\otimes \underline{\textbf{D}} \right| \) being the categorical product and hom-objects \((\underline{\textbf{C}}\otimes \underline{\textbf{D}})((A, B), (C, D)) = \underline{\textbf{C}}(A, C) \times \underline{\textbf{D}}(B, D)\). The unit is given by \(j_{(A, B)} = *\cong *\times *\xrightarrow {u_{A} \times v_{B}} \underline{\textbf{C}}(A, A) \times \underline{\textbf{D}}(B,B)\) in terms of the units u of \(\underline{\textbf{C}}\) and v of \(\underline{\textbf{D}}\). Similarly, one also defines the composition for \(\underline{\textbf{C}}\otimes \underline{\textbf{D}}\) in terms of the composition morphisms of \(\underline{\textbf{C}}\) and \(\underline{\textbf{D}}\), appealing to the symmetry in \(\textbf{V}\) [28, Sec. 1.4]. The tensor product also extends to \(\textbf{V}\)-functors and \(\textbf{V}\)-natural transformations, which makes it a 2-functor. Finally, one defines \(I\) to be the unit \(\textbf{V}\)-category with one object 0 and \(I(0,0) = *\) and we thus obtain, with suitable definitions of associators etc., a symmetric monoidal 2-category \((\textbf{V}\text {-}\textbf{Cat}, \otimes , I)\).

Most of the categories we are interested in are also dagger-compact categories (\(\dagger \text {-}CC\)). These are SMCs \((\textbf{C},\otimes , I )\) with some additional structure. First, they are equipped with an endofunctor \(\dagger : \textbf{C}^{op} \rightarrow \textbf{C}\), that satisfies \((\text {Id}_A)^\dagger = \text {Id}_A\), \((g \circ f)^\dagger = f^\dagger \circ g^\dagger \), \((f^\dagger )^\dagger =f\), and \((f \otimes g)^\dagger = f^\dagger \otimes g^\dagger \). And secondly, for every object A there exists a dual \(A^*\) such that there exists unit \(\eta _A: I\rightarrow A \otimes A^*\) and counit \(\epsilon _A: A^*\otimes A \rightarrow I\) morphisms subject to some conditions [20].

We are interested in categories that let us reason about quantum mechanics. One of them is FdHilb, the category of finite dimensional Hilbert spaces of the form \(\mathbb {C}^n\) and linear maps as morphisms. The category \(\textbf{Qubit}\) is the (full) subcategory of FdHilb with objects Hilbert spaces of the form \(\mathbb {C}^{2^n}\) and linear maps. Similarly, the category \(\mathbf {CPM(\textbf{Qubit})}\) [48] has objects \(\mathbb {C}^{2^n}\) and morphisms completely positive linear maps between them [13]. We usually work in \(\textbf{Qubit}\) when reasoning about pure quantum evolutions and in \(\mathbf {CPM(\textbf{Qubit})}\) when impure quantum evolutions (such as noise) can take place. All of these categories are \(\dagger \text {-}CC\), with the monoidal structure \(\otimes \) given by the usual Kronecker product of vector spaces and the dagger \(\dagger \) being the conjugate transpose.

3 Algebraic Enrichment

In this section, we are going to recall the concept of monoidal and affine monads, and discuss some properties of the Eilenberg-Moore category of a monad. We also start applying the Distribution monad and the Multiset monad to running examples that will be of interest in later sections.

The Distribution monad \((\mathcal {D},\mu ,\eta )\)Footnote 2 contains the functor \(\mathcal {D}:\textbf{Set}\rightarrow \textbf{Set}\) that maps a set A to the set \(\mathcal {D}(A)\) of (finitely supported) probability distributions over elements of A. We write probability distributions as formal convex sums: \(\sum _{a} p_a [a]\in \mathcal {D}(A)\) such that \(a\in A, p_a \in [0,1]\), and \(\sum _a p_a = 1\). \(\mathcal {D}\) acts on a morphism f by simply applying f to the underlying set: \((\mathcal {D}f)(\sum _{a} p_a [a]) = \sum _{a} p_a [f(a)]\). The unit of the monad is the map \(\eta : A\rightarrow \mathcal {D}(A): a \mapsto 1[a]\) (the Dirac distribution), and the multiplication \(\mu \) “flattens” a distribution of distributions by multiplying the probabilities together: \(\mu : \mathcal {D}(\mathcal {D}(A)) \rightarrow \mathcal {D}(A): \sum _q p_q [\sum _a q_a [a]]\mapsto \sum _{a}r_a[a]\) where \(r_a = \sum _q p_q q_a\) [23].

The functor \(\mathcal {D}\) is also a monoidal functor, which makes \((\mathcal {D},\mu ,\eta )\) a monoidal monad. In particular, this means that there exists a map:

$$\nabla : \mathcal {D}(A)\times \mathcal {D}(B)\rightarrow \mathcal {D}(A\times B): \left( \sum _{a} p_a [a], \sum _{b} p_b [b] \right) \mapsto \sum _{a,b} p_ap_b [(a,b)]$$

for every \(A,B\in |\textbf{Set}|\).

A monad \(T:\textbf{C}\rightarrow \textbf{C}\) is affine if there is an isomorphism \(T(*) \cong *\) for \(*\) the terminal object of \(\textbf{C}\) [24]. This is the case for \(\mathcal {D}\).

If \(\mathcal {D}\) is a monad for expressing convex combinations of elements of a set, the Multiset monad \(\mathcal {M}\) is its analogue for linear combinations with coefficients over some semiring.

We recall that given any monad \(T\) in \(\textbf{C}\) we can construct its Eilenberg-Moore category, with objects \(T\)-algebras of the form \((A,\alpha _A)\) for \(A\in \left| \textbf{C} \right| \) and \(T\)-action \(\alpha _A:T(A)\rightarrow A\) such that \(\alpha _A \circ T(\alpha _{A}) = \alpha _A \circ \mu _A\) and \(\alpha _A \circ \eta _A = \text {Id}_A\). Algebra homomorphisms \(f:(A,\alpha _A)\rightarrow (B,\alpha _B)\) are morphisms of the underlying objects \(f: A\rightarrow B\) that commute with the action: \(f \circ \alpha _A = \alpha _B \circ T(f)\). The identity and composition follow from the ones for the underlying objects [35].

For a monad \(T\) on \(\textbf{C}\), we have that \(\textbf{Alg}^T\) is complete whenever \(\textbf{C}\) is complete. Cocompleteness is not as immediate, but if \(\textbf{C}= \textbf{Set}\) then \(\textbf{Alg}^T\) is also cocomplete [3, 22]. This makes \(\textbf{Alg}^T\) over monads on \(\textbf{Set}\) a complete and cocomplete category and in particular, \(\textbf{Alg}^T\) has reflexive coequalizers, which we use to define the tensor product of algebras.

When \(T\) is a monoidal monad on a monoidal category \((\textbf{C},\otimes ,I)\), the tensor product of \(T\) algebras (Aa), (Bb), denoted \((A,a)\otimes ^T(B,b)\), is (if it exists) defined as the coequalizer diagram [10, 46]

(1)

where \(F:\textbf{C}\rightarrow \textbf{Alg}^T: A\mapsto (T(A),\mu )\) is the left adjoint to the forgetful functor \(U:\textbf{Alg}^T\rightarrow \textbf{C}: (A,\alpha _A)\mapsto A\) that maps objects to their free algebras over \(T\). Given that we need \(\textbf{Alg}^T\) to be monoidal in order to use it as a base of enrichment, diagram (1) above is a convenient representation of the tensor product of algebras. The rest of the structure to make \(\textbf{Alg}^T\) a (symmetric) monoidal category follows under certain conditions, in particular when \((\textbf{C},\otimes ,I)\) is a closed (S)MC and the coequalizer (1) exists for all algebras (Aa), (Bb) [46].

We can define (symmetric) monoidal structure in the category of free algebras as follows. Using (1) for the category of free algebras over a monoidal monad, we have that the following diagram forms a coequalizer.

(2)

Therefore, \((T(A),\mu )\otimes ^T(T(B),\mu ) \cong F(A \otimes B)\) [46, Prop. 2.5.2]. The monoidal unit is \(I^T= (T(I),\mu )\), while the associator, unitor, and symmetry (if present) are the images of the ones in \((\textbf{C},\otimes ,I)\) under F. We then have that \((\textbf{Alg}^T, \otimes ^T, I^T)\) is the (symmetric) monoidal category of free \(T\)-algebras.

A functor \(F: (\textbf{V}_1,\otimes _{\textbf{V}_1},I_{\textbf{V}_1}) \rightarrow (\textbf{V}_2,\otimes _{\textbf{V}_2},I_{\textbf{V}_2})\) between two monoidal categories can be lifted to a 2-functor \(F_*: \textbf{V}_1\text {-}\textbf{Cat}\rightarrow \textbf{V}_2\text {-}\textbf{Cat}\) [7]. This is called a change of enriching, where we turn a \(\textbf{V}_1\)-category into a \(\textbf{V}_2\)-category. Indeed, given a \(\textbf{V}_1\)-category \(\underline{\textbf{C}}\), we can construct the \(\textbf{V}_2\)-category \(F_*\underline{\textbf{C}}\) by defining \(\left| F_*\underline{\textbf{C}} \right| := \left| \underline{\textbf{C}} \right| \) and, for every \(A, B \in \left| F_*\underline{\textbf{C}} \right| \), the hom-objects are \(F_*\underline{\textbf{C}}(A,B) := F(\underline{\textbf{C}}(A,B))\) with composition and identity element following from the ones in \(\underline{\textbf{C}}\) under F. For a symmetric monoidal category \((\textbf{V},\otimes ,I)\), an important instance is the functor \(\textbf{V}(I, -)_{*} :\textbf{V}\text {-}\textbf{Cat}\rightarrow \textbf{Cat}\) called the underlying category functor and it is denoted by \((-)_{0}\).

The following lemma states explicitly the case when one of the enriching categories is \(\textbf{Set}\).

Lemma 1

([7, Prop. 6.4.7]). Let \((\textbf{V},\otimes ,I)\) be a closed symmetric monoidal category with coproducts. Then the hom-functor \(\textbf{V}(I,-) :\textbf{V}\rightarrow \textbf{Set}\) has a left adjoint F that sends a set X to \(F(X)=\coprod _X I\), the X-th fold copower of I. Moreover, F is a strong morphism of symmetric monoidal categories and the induced 2-functor \(F_{*}\) is left-adjoint to the underlying category functor \((-)_{0}\).

Theorem 1

A monoidal monad \(T\) on \((\textbf{Set},\times ,*)\) endows the category of \(T\)-algebras \(\textbf{Alg}^T\) with a bicomplete (complete and cocomplete) closed SMC structure. This allows to lift the free-forgetful adjunction of Lemma 1 as a change of enriching between \(\textbf{Alg}^T\)-categories and \(\textbf{Set}\)-categories for a monoidal \(T\).

Proof

The proof follows from Lemma 1 and previous arguments. Given that \(\textbf{Alg}^T\) for T a monad on \(\textbf{Set}\) is bicomplete, then coequalizer (1) exists and we can define tensor products of algebras. We can then make \(\textbf{Alg}^T\) a symmetric monoidal category given that \(\textbf{Set}\) is closed symmetric monoidal. Finally, \(\textbf{Alg}^T\) can be made into a closed category following [32] given that \(\textbf{Set}\) has equalizers. We can then use Lemma 1 to create a change of enriching between \(\textbf{Alg}^T\)-categories and \(\textbf{Set}\)-categories.

Corollary 1

Let \(T\) be a monoidal monad on \(\textbf{Set}\) defined by a free-forgetful adjunction \(U: \textbf{Alg}^T\rightleftarrows \textbf{Set}: L\). If L is naturally isomorphic to the functor F from Lemma 1, that is \((T(-),\mu )\cong \coprod _{(-)} (TI,\mu )\), then the induced 2-functor \(L_*\) is left adjoint to the underlying category functor \((-)_{0}\). This lets us use Theorem 1 to enrich locally small categories with the free algebras over T. The condition \(L \cong F\) holds, in particular, when T is an affine monad.

Proof

Whenever we have that \(L \cong F\), the enrichment over free T-algebras comes simply from substituting F with L in Lemma 1 and Theorem 1. To see that this condition holds when T is affine, we construct hom isomorphisms \(\textbf{Alg}^T(L(X),Y)\cong \textbf{Set}(X,U(Y))\cong \textbf{Set}(X,\textbf{Alg}^T(I^T,Y))\cong \textbf{Alg}^T(F(X),Y)\) for some \(X\in \left| \textbf{Set} \right| , Y\in \left| \textbf{Alg}^T \right| \), with the second and last isomorphism coming from their respective adjunctions. The remaining one is due to \(T(*)\cong *\), which allows us to get algebra homomorphisms \(h: (T(*),\mu ) \mapsto (T(Y),\mu )\) from maps \(h': * \mapsto Y\), while the other direction just requires to forget the homomorphism structure.

Let us construct an example for Theorem 1 and relate it to graphical languages. If we have a locally small monoidal category \(\textbf{C}\) with morphisms \(f,g:A\rightarrow B, h:B\rightarrow C\), represented graphically as , we can freely enrich \(\textbf{C}\) over \(\textbf{Alg}^\mathcal {D}\) following the change of enriching category method above. Then, we can realize graphically a probabilistic process involving f and g with probability 0.9 and 0.1 respectively, followed by applying h deterministically (that is, it occurs with probability 1) afterwards as follows.

(3)

Intuitively, we distinguish between probabilistic and deterministic processes by having the former enclosed within distribution brackets (in the same way as we would represent them as a formal sum \(0.9[f] + 0.1[g]\)), that we choose to depict as trapezoids in this paper. Deterministic processes are depicted without the bracket enclosing mostly as syntactic sugar, otherwise they would simply have a single choice with probability 1. We can see how wires can have weights inside this environment, and how each wire represents a probabilistic choice. Intuition also tells us that we could for example rewrite the diagram above by distributing h over the two probabilistic branches. We will discuss in later sections which graphical rules capture the interactions present in these enriched categories.

It is natural to then ask if our enriched category \(\textbf{C}\) maintained its monoidal structure, and if other desired properties (such as braiding and symmetry, if present) would still hold too. We will address this in the next section.

4 Enriched Monoidal Categories

Recall from Section 2 that a symmetric monoidal category \(\textbf{V}\) gives rise to a symmetric monoidal 2-category \((\textbf{V}\text {-}\textbf{Cat}, \otimes , I)\) of \(\textbf{V}\)-categories. This structure allows us to define an enriched (symmetric) monoidal category to be a (symmetric) pseudo-monoid in \(\textbf{V}\text {-}\textbf{Cat}\) [18], which amounts to the following explicit definition [33, 38]. Let us denote by S the symmetry isomorphism of \(\textbf{V}\text {-}\textbf{Cat}\). A symmetric monoidal \(\textbf{V}\)-category is a tuple \((\underline{\textbf{C}}, \odot , U, \alpha , \lambda , \rho , \sigma )\) consisting of:

  • a \(\textbf{V}\)-enriched category \(\underline{\textbf{C}}\)

  • a \(\textbf{V}\)-functor \(U:I\rightarrow \underline{\textbf{C}}\)

  • a \(\textbf{V}\)-functor \(\odot :\underline{\textbf{C}}\otimes \underline{\textbf{C}}\rightarrow \underline{\textbf{C}}\)

  • \(\textbf{V}\)-natural isomorphisms \(\alpha :\odot \circ (\odot \otimes \textrm{Id}_{\underline{\textbf{C}}}) \rightarrow \odot \circ (\textrm{Id}_{\underline{\textbf{C}}} \otimes \odot )\) (associator), \(\lambda :\odot \circ (U \otimes \textrm{Id}_{\underline{\textbf{C}}}) \rightarrow \textrm{Id}_{\underline{\textbf{C}}}\) (left unitor), \(\rho :\odot \circ (\textrm{Id}_{\underline{\textbf{C}}} \otimes U) \rightarrow \textrm{Id}_{\underline{\textbf{C}}}\) (right unitor), and \(\sigma :\odot \rightarrow \odot \circ S\) (symmetry)

subject to the expected coherence axioms [18]. A (symmetric) monoidal \(\textbf{V}\)-functor \((\underline{\textbf{C}}, \odot _{1}, U_{1}) \rightarrow (\underline{\textbf{D}}, \odot _{2}, U_{2})\) is a lax (symmetric) pseudo-monoid homomorphism, which means that it consists of a \(\textbf{V}\)-functor \(h :\underline{\textbf{C}}\rightarrow \underline{\textbf{D}}\) and two \(\textbf{V}\)-natural transformations \(h^{0} :U_{2} \rightarrow h \circ U_{1}\) and \(h^{2} :\odot _{2} \circ (h \otimes h) \rightarrow h \circ \odot _{1}\) that are coherent with the associators, unitors and symmetries [33]. Together, symmetric monoidal \(\textbf{V}\)-categories and functors form a category \(\textbf{V}\text {-}\textbf{SMCat}\).

Our goal is now to lift the adjunction between enriched categories from Theorem 1 to also include enriched monoidal structure. To this end, we introduce lax monoidal strict 2-functors, which are tuples \((G, G^{0}, G^{2})\) where \(G :\textbf{V}\rightarrow \textbf{W}\) is a strict functor of 2-categories and \((G, G^{0}, G^{2}) :(\textbf{V}, \otimes , I) \rightarrow (\textbf{W}, \times , *)\) is a lax monoidal functor on the underlying 1-categories.

Theorem 2

Lax monoidal strict 2-functors \((G, G^{0}, G^{2}) :(\textbf{V}, \otimes , I) \rightarrow (\textbf{W}, \times , *)\) induce 2-functors \(\textbf{PMon}(G) :\textbf{PMon}(\textbf{V}, \otimes , I) \rightarrow \textbf{PMon}(\textbf{W}, \times , *)\) between 2-categories of pseudo-monoids, lax homomorphisms and 2-cells that are compatible with the homomorphism structures. If a G has a monoidal left adjoint F, then \(\textbf{PMon}(F)\) is left adjoint to \(\textbf{PMon}(G)\). Finally, if the monoidal categories and functors are symmetric, then the adjunction can be improved to one between symmetric pseudo-monoids.

Proof

The details and appropriate diagram chases are written in [51, Appendix A], which go through the following steps. We begin by showing that \(\textbf{PMon}(G)\) maps a pseudo-monoid \((\underline{\textbf{C}}, \odot , U, \alpha , \lambda , \rho , \sigma )\) in \((\textbf{V}\text {-}\textbf{Cat}, \otimes , I)\) to a pseudo-monoid \((G\underline{\textbf{C}}, G(\odot ) \circ G^{2}, G(U) \circ G^{0}, G\alpha , G\lambda , G\rho , G\sigma )\) in \((\textbf{W}\text {-}\textbf{Cat},\times ,*)\) by checking that it fulfills the pseudo-monoid axioms [18].

Similarly, we check that \((G,G^{0},G^{2})\) maps a pseudo-monoid homomorphism \((h,h^{0},h^{2})\) to a pseudo-monoid homomorphism \((G(h),G(h^{0}),G(h^{2}))\).

If G has a strict left adjoint F, which is also strong monoidal, we show that \((F, F^{0}, F^{2}) \dashv (G, G^{0}, G^{2})\) is a monoidal 2-adjunction if the mates [27] of \(G^{0}\) and \(G^{2}\) are the inverses of \(F^{0}\) and \(F^{2}\), respectively, as in the following equations, where \(\beta _{A,B}\) is the natural isomorphism \(\textbf{W}(A, GB) \xrightarrow {\cong } \textbf{V}(FA, B)\) and \(\eta \) the unit of the adjunction:

$$\begin{aligned} (F^{0})^{-1} = \beta (G^{0}) \quad \text {and} \quad (F^{2})^{-1} = \beta (G^{2}) \circ F(\eta \times \eta ). \end{aligned}$$

The following theorem, which shows that the change of enrichment extends to monoidal enriched categories, follows from Theorem 2 using that \(\textbf{V}\text {-}\textbf{SMCat}= \textbf{PMon}(\textbf{V}\text {-}\textbf{Cat}, \otimes , I)\) and that the change of enrichment gives a lax monoidal 2-adjunction [7, 17].

Theorem 3

If \((G, G^{0}, G^{2}) :(\textbf{V}, \otimes , I) \rightarrow (\textbf{W}, \times , *)\) is a symmetric monoidal functor between symmetric monoidal categories with a monoidal left adjoint \((F, F^{0}, F^{2})\), then there are adjunctions that commute with the forgetful functors as in the following diagram.

figure c

From this theorem and combining the results from Section 3 we can derive the following corollary, which is our main tool for building monoidal diagrams that are enriched with algebraic operations.

Corollary 2

A monoidal monad \(T\) on \(\textbf{Set}\) with an adjunction between the free T-algebra functor and the underlying category functor (see Corollary 1) gives a free-underlying adjunction \((-)_0:\textbf{Alg}^T\text {-}\textbf{Cat}\rightleftarrows \textbf{Cat}:F_*\). This adjunction lifts to an adjunction between the 2-categories of symmetric monoidal \(\textbf{Alg}^T\)-enriched and \(\textbf{Set}\)-enriched categories \((-)_0: \textbf{Alg}^T\text {-}\textbf{SMCat}\rightleftarrows \textbf{SMCat}: F_*\). More explicitly, given such a monad T on \(\textbf{Set}\) and a SMC \((\textbf{C}, \otimes , I, \alpha , \lambda , \rho , \sigma )\) we can construct the freely \(\textbf{Alg}^T\)-enriched SMC \((\underline{\textbf{C}}, \underline{\otimes }, \underline{I}, \underline{\alpha }, \underline{\lambda }, \underline{\rho }, \underline{\sigma })\).

Knowing that we keep the symmetric monoidal structure after doing the free enrichment, we can justify drawing parallel composition of probabilistic operations in diagram form. Continuing example (3), let us have another probabilistic process in which \(f'\) and \(g'\) occur with probabilities 0.7 and 0.3 (respectively) parallelly composed. Then we can draw the following picture.

(4)

5 Applications: ZX-calculus

In this section, we show an example application of the categorical constructions of the previous sections. In particular, we are interested in demonstrating how we can take the Distribution monad and enrich the quantum categories of interest for reasoning about probabilistic processes in quantum systems. Most importantly, we show how the ZX-calculus, a graphical calculus for reasoning about quantum processes, can be appropriately extended to accommodate the extra structure on said categories and how additional graphical rewrite rules capture the interaction of probabilistic and deterministic quantum operations. We begin with a general introduction to quantum computing and ZX-calculus, and then follow with the enrichment of our categories of interest, together with the introduction of the extended notation, and we finish by giving an example of how we can use this for diagrammatic reasoning of noise in quantum systems.

5.1 Quantum Computing

When referring to quantum systems and operations, we have to make a distinction whenever we take impure operations into account. In the pure states formalisms, quantum states are normalized vectors in a Hilbert space of dimension \(\mathbb {C}^{2^n}\), with n the number of qubits (quantum bits) of the system. It is common to use Dirac bra-ket notation to represent states, for example, some important single-qubit states are . We operate on qubits by performing unitary transformations U on the quantum states. A multi-qubit quantum system with states \(|\psi \rangle \) and \(|\phi \rangle \) corresponds to the tensor (Kronecker) product of the quantum states: \(|\psi \rangle \otimes |\phi \rangle \). We will represent the n-fold tensor product of a state \(|\psi \rangle \) by \(|\psi ^{n}\rangle \). Simultaneous (but independent) operations also follow from tensoring unitaries.

When we take into consideration the possibility of applying non-unitary operations we require a more general framework, which is the density matrix and completely positive maps formalism. In this case, quantum states are positive semi-definite Hermitian matrices \(\rho \) of trace one. We write them as \(\rho = \sum _i p_i {|\psi _i \rangle }{\langle \psi _i |}\) (where \(\langle \psi _i| = |\psi _i\rangle ^\dagger \), for \(\dagger \) the conjugate transpose), that is, a statistical ensemble of quantum states \(|\psi _i\rangle \) (as density matrices) with probability \(p_i\). Operations on density matrices are completely positive (CP) maps of the form \(\varPhi : \rho \rightarrow \sum _i K_i\rho K_i^\dagger \) with the condition \(\sum _i K_iK_i^\dagger \le 1\) (notice how unitary maps fall inside this description too). When we want to reason about quantum systems in the presence of noise, we then have to use the density matrix and CP map formalism. For more information on quantum computing, we refer the reader to [40], and for a more categorical introduction to [20].

5.2 The ZX-calculus

The ZX-calculus [15] is a graphical language for reasoning about quantum states and processes as diagrams. The language consists of a set of generators, which are the green and redFootnote 3 spiders (also called Z and X spiders), the Hadamard box, the identity wire, the swap, the cup, the cap, and the empty diagram. In Figure 2 we can see the generators of the ZX-calculus and their signature, with input wire(s) coming from the top and outputs going to the bottom. Spiders have a phase \(\alpha \in [0,2\pi )\), which as we will see later is omitted when \(\alpha =0\). We can also see how to sequentially compose (\(\circ \)) arbitrary diagrams by connecting inputs with outputs, and how to parallely compose diagrams (as a tensor product \(\otimes \)) by placing them side by side.

Fig. 2.
figure 2

ZX-diagrams generators and how to compose them.

Each of the generators has a standard interpretation \(\llbracket \cdot \rrbracket \) as a linear map in \(\mathbb {C}^{2^n}\) that we can find in Figure 3.

Fig. 3.
figure 3

Standard interpretation of ZX-diagrams.

Categorically, ZX-diagrams form the category ZX with \(|\textbf{ZX}|=\mathbb {N}\) (where some \(n\in \mathbb {N}\) is the number of wires, which we can think of as an n-qubit quantum system) and morphisms being the generators. The standard interpretation is a (monoidal) functor \(\llbracket \cdot \rrbracket : \textbf{ZX}\rightarrow \textbf{Qubit}\) that acts on objects as \(\llbracket n \rrbracket =n\) and on morphisms as defined in Figure 3 [53].

ZX-diagrams come with a set of rewrite rules that form the ZX-calculus. These rewrite rules let us transform a diagram into a different one while preserving the semantics (i.e. the interpretation). We have collected the rules in Figure 4. There is also an important additional rule that can be summarized as the only connectivity matters rule, which states that we can deform diagrams at will without changing their meaning, as long as we maintain the connectivity between the generators unchanged. For a thorough explanation of each rule we refer the reader to [15, 52].

Fig. 4.
figure 4

ZX-calculus ruleset. All rules also hold when swapping the colors of the spiders. In (eu) we omit the calculation of the angles, which can be found in [52].

The ZX-calculus satisfies important properties. ZX-diagrams are universal, meaning that any linear map f of the form \(f: \mathbb {C}^{2^n}\rightarrow \mathbb {C}^{2^m}\) can be represented as a ZX-diagram. The rewrite rules are sound, meaning that they do not change the interpretation of the diagram as a linear map. They are also complete, which ensures that if two diagrams have the same interpretation, the ruleset is powerful enough to always let us transform one diagram into the other. These properties ensure that the ZX-calculus can be used as a tool for reasoning about quantum computing, as it has been already demonstrated in tasks such as quantum circuit optimisation [30], verification of quantum circuits [41], simulation [31], and as a reasoning tool [4, 29].

In (5) we have example one- and two-qubit gates as ZX-diagrams. We also see the computational basis \(\{|0\rangle ,|1\rangle \}\) and Hadamard basis \(\{|+\rangle ,|-\rangle \}\) states.

(5)

5.3 Enriching the Categories \(\textbf{Qubit}\) and \(\mathbf {CPM(\textbf{Qubit})}\)

Our motivation is to highlight certain types of relevant physical phenomena (probabilistic processes) that are present in quantum systems within our categories. It is then natural to use the Distribution monad \(\mathcal {D}\) together with the construction explained in the previous sections to enrich our categories for quantum reasoning.

Indeed, we take \(\mathbf {CPM(\textbf{Qubit})}\) and perform a free enrichment over \(\mathcal {D}\). What we get is the category \((F_*\mathbf {CPM(\textbf{Qubit})}, \underline{\otimes }, I)\) consisting of the same objects as \(\mathbf {CPM(\textbf{Qubit})}\) and morphisms (incl. identity) for objects AB the free algebras over \(\mathcal {D}\) of the hom-set \(\mathbf {CPM(\textbf{Qubit})}(A,B)\). Composites of morphisms are the free algebra over the composite in \(\mathbf {CPM(\textbf{Qubit})}\), and the SMC structure is preserved thanks to Corollary 2.

We also define the non-freely enriched category \(\underline{\mathbf {CPM(\textbf{Qubit})}}\) so we can interpret probability distributions as CP maps. For this, we define SMC-structure in the non-free \((\textbf{Alg}^\mathcal {D},\otimes ^\mathcal {D},\mathcal {D}(*))\), with a tensor product of algebras defined by the coequalizer (1), with a more detailed description in [51, Appendix B]. The category \((\underline{\mathbf {CPM(\textbf{Qubit})}},\odot ,U)\) has the same objects as \(\mathbf {CPM(\textbf{Qubit})}\) and for every pair of objects AB the hom-object is an algebra \((\mathbf {CPM(\textbf{Qubit})}(A,B),\alpha )\) with the \(\mathcal {D}\)-action turning a formal convex sum of linear maps into an actual sum by scalar multiplication and addition. Composition of hom-objects follows from composition in \(\mathbf {CPM(\textbf{Qubit})}\), and for an object A the identity element is \(j_A:(*,\alpha )\rightarrow ({\text {Id}}_A,\alpha )\). We define now its symmetric monoidal structure following the definition of enriched SMC from the beginning of Section 4. The tensor product \(\odot \) on objects is the same as in \(\mathbf {CPM(\textbf{Qubit})}\), and on hom-objects it is the tensor product in \(\mathbf {CPM(\textbf{Qubit})}\) to the underlying sets: \(\odot : (\mathbf {CPM(\textbf{Qubit})}(A,A'),\alpha )\otimes ^\mathcal {D}(\mathbf {CPM(\textbf{Qubit})}(B,B'),\alpha )\) \(\rightarrow \) \( (\mathbf {CPM(\textbf{Qubit})}(A\otimes B, A'\otimes B'),\alpha )\). The unit U is the one in \(\mathbf {CPM(\textbf{Qubit})}\). The associator, unitors, and symmetry all follow from applying the ones in \(\mathbf {CPM(\textbf{Qubit})}\).

In the following sections, we will interpret ZX-diagrams into \(F_*\mathbf {CPM(\textbf{Qubit})}\) as probability distributions of CP maps. From there, to interpret probability distributions as CP maps, we define the functor that sends objects to themselves and applies the monad algebra to hom-objects i.e. we “evaluate” a probability distribution over CP maps by multiplying the probabilities with the corresponding map and then adding all maps together.

Technically, we can also enrich \(\textbf{Qubit}\) in the same way as we did with \(\mathbf {CPM(\textbf{Qubit})}\), but density matrices and CP maps are the more sensible choices to talk about probabilistic mixtures of operations. On the other hand, enriching \(\textbf{Qubit}\) (or \(\mathbf {CPM(\textbf{Qubit})}\)) over algebras of the multiset monad \(\mathcal {M}\) leads to an enrichment over commutative monoids that exposes addition of linear maps [20]. This was recently formulated in [39, 50] as a way to “split” parameterised Pauli rotation gates in ZX-calculus in such a way that the parameter relocates from its place inside the spider as a phase to a scalar on a wire using the identity \(e^{i\alpha P} = \cos \alpha I + i \sin \alpha P\) for P a Pauli matrix (or any matrix satisfying \(P^2=I\)).

5.4 Enriched ZX-diagrams and Their Interpretation

In the same manner as the ZX-calculus is a language for reasoning in \(\textbf{Qubit}\), we can create a graphical language with extra structure to reason in our enriched categories. Since we are going to be enriching \(\mathbf {CPM(\textbf{Qubit})}\), we first need to see how to turn the ZX-calculus into a graphical language for CP maps. This is done straightforwardly by adding a discard operation to the list of generators of Figure 2 plus additional rewrite rules (that we choose to omit here) stating that isometries can be discarded [13]. The interpretation of a ZX-diagram D as a CP map is then a superoperator \(\rho \rightarrow \llbracket D \rrbracket \ \rho \ \llbracket D \rrbracket ^\dagger \), for \(\llbracket D \rrbracket \) the standard interpretation of D as in Figure 3 [9].

We then construct an enriched graphical language for \(\underline{\mathbf {CPM(\textbf{Qubit})}}\) by building on top of the ZX-calculus for CP maps. The notation will be similar to the running examples we have given throughout the text (cf. 1,3,4). The main idea is as follows. We take the generators of the ZX-calculus and allow them to be freely wrapped between opening and closing distribution brackets.

Intuitively, we interpret diagrams that are within distribution brackets as a probabilistic mixture of operations: diagrams placed side by side correspond to different probabilistic choices with some weight attached to the corresponding wires. Within each choice, sequential (and as we will see later, parallel) composition is allowed. The main difference to the usual graphical languages for monoidal categories is that the parallel composition of each choice does not correspond to the tensor product. In a way, we also subsume ZX-diagrams by drawing diagrams that are not enclosed by distribution brackets, which are then interpreted as an operation that occurs with probability 1.

For example, we can represent the single-qubit depolarizing channel [40] \(\varPhi :\rho \mapsto (1-p)\rho + \frac{p}{3}(X\rho X + Y\rho Y + Z\rho Z)\) that leaves a quantum state \(\rho \) unchanged with probability \((1-p)\) or applies an XY or Z error with probability \(\frac{p}{3}\) each with the diagram on the left in Figure 5.

Fig. 5.
figure 5

Left: Diagrammatic representation of the depolarizing channel. Right: Diagrammatic representation of a mixture of two-qubit gates.

We need to take extra care when handling scalars inside the brackets. Indeed, what we have inside distribution brackets is a formal convex sum of ZX-diagrams (or, in the general case, string diagrams), meaning that the SMC rewriting axioms apply to each summand independently. Since summands are also juxtaposed, it might seem like this notation allows for the transfer of scalars from one summand to another. The crux is that, since what is enclosed by trapezoids is a formal sum, we cannot drag scalars from one summand to another using those same monoidal category axioms. This means that we can consider the probabilities (and any scalar factor if present, such as the imaginary unit in Figure 5) to be bound to the wires themselves, and only interact with the ZX-diagrams (or generally string diagrams) that belong to that summand. An alternative is to encapsulate each summand in “bubbles” for stronger visual separation [39, 50].

A probabilistic mixture of operations with multiple inputs or outputs looks similar to the 1-to-1 case, with the caveat that we need to be more careful in the positioning of the wires as to distinguish between tensor product and probabilistic choice.Footnote 4 For example, if we want to represent applying the CNOT gate and the CZ gate with probabilities p and \(1-p\) respectively we would get the diagram on the right in Figure 5.

We can consider this extra notation as the result of a free enrichment of \(\textbf{ZX}\) over \(\textbf{Alg}^\mathcal {D}\) giving us the category of enriched ZX-diagrams \(F_*\textbf{ZX}\). We can then define the interpretation \(\llbracket \cdot \rrbracket _\mathcal {D}\) of an \(\textbf{Alg}^\mathcal {D}\)-enriched diagram as a monoidal functor from the category of enriched ZX-diagrams to \(\underline{\mathbf {CPM(\textbf{Qubit})}}\). This functor factors through \(F_*\mathbf {CPM(\textbf{Qubit})}\) as follows:

figure i

Where interprets an enriched ZX-diagram as a probabilistic mixture of operations which is then evaluated by as explained in Section 5.3. An example of the interpretation of an arbitrary distribution of ZX-diagrams of arbitrary size can be seen in (6). When using the multiset monad \(\mathcal {M}\) instead the interpretation \(\llbracket \cdot \rrbracket _\mathcal {M}\) is similar.

(6)

Enriched ZX-diagrams are universal, that is, any morphism in \(\underline{\mathbf {CPM(\textbf{Qubit})}}\) can be represented by an enriched ZX-diagram. Indeed, since \(\underline{\mathbf {CPM(\textbf{Qubit})}}\) is still made of CP maps between Hilbert spaces, we can use universality of the ZX-calculus alone to represent any morphism in \(\underline{\mathbf {CPM(\textbf{Qubit})}}\).

5.5 Additional Rules for Enriched ZX-diagrams

With the new notation we can have new rewrite rules too, some of which were already introduced in [39, 50] ((es), (ep), (ec), and (e\(\delta \))) for the case of linear combinations. We will display them here, including additional rules. The ruleset of the enriched ZX-calculus for the distribution and multiset monads is the same as the one for ZX-calculus plus additional rules that capture the interaction between sums, products, tensor products, and scalars. We can see the additional rules arising from the enrichment in Figure 6, which intuitively state:

  • (es): The enriched sequential composition rule shows how to sequentially compose distributions. Intuitively this rule follows from products distributing over addition.

  • (ep): The enriched parallel composition rule is the same as (es), but for parallel composition instead of sequential.

  • (ec): The enriched commutativity rule shows that bracketed diagrams are invariant under permutation of the branches.

  • (e\(\delta \)): The enriched Dirac delta distribution rule provides a shorthand for the trivial Dirac delta distribution.

  • (e\(+\)): The enriched addition rule shows that we can remove a branch if it is identical to some other by adding the probabilities.

  • (e0): The enriched 0-probability rule allows us to remove branches with 0 probability .

Fig. 6.
figure 6

Additional rules for the enriched ZX-calculus, alongside the ones of Figure 4. Diagrams \(D, D'\) are arbitrary ZX-diagrams and weights pq are probabilities.

Rules (es),(ep),(ec) and (e\(\delta \)) were proven to be sound in [39] but in the context of linear combinations of diagrams interpreted in \(\textbf{Qubit}\). We show that these rules still hold as an enrichment in \(\textbf{Alg}^\mathcal {D}\) and interpreted in \(\underline{\mathbf {CPM(\textbf{Qubit})}}\) in [51, Appendix C]. Finding a complete ruleset (i.e. one that can show \(D_1 = D_2\) whenever \(\llbracket D_1 \rrbracket _\mathcal {D}= \llbracket D_2 \rrbracket _\mathcal {D}\)) for enriched diagrams remains to be done. A possible direction to tackle this problem would be to translate enriched diagrams into ZXW [49] diagrams, which is a complete diagrammatic language with a W-spider that can encode addition of phases. Another alternative would be to translate into the controlled form of [25].

We conclude with a demonstration of how we can use this extension of the ZX-calculus to study the effectiveness of Quantum Error Mitigation (QEM) techniques for different noise models. Quantum Error Mitigation [11] are the series of techniques that are used to reduce the effects of noise in near-term quantum systems. One such technique is Symmetry Verification [6], which states that given a Hamiltonian (Hermitian operator that determines the evolution of a system) \(\hat{H}\), and a symmetry S (an operator that commutes with \(\hat{H}\) i.e. \([\hat{H},S] = \hat{H}S - S\hat{H} = 0\)), one can perform measurements of S to verify if the state that (ideally) evolves under \(\hat{H}\) was affected by errors. Indeed, under the assumption that the initial state is a \((+1)\) eigenvector of S, then it will stay that way under ideal evolution under \(\hat{H}\). This implies that if there is an error E that anti-commutes with S (i.e. \(\{E,S\} = ES + SE = 0\)) at some point in the computation, we can measure S to detect a change in the eigenvalue. Symmetry verification then proposes to perform a postselection on the result \((+1)\), meaning that we discard computations that give a \((-1)\) outcome when measuring S.

Given a noisy state \(\rho _{\text {noisy}}\) and a symmetry S, the probability of outcome \((+1)\) when measuring S is given by \(p(+1)={\text {tr}}(P_{+1}\rho _{noisy})\), for \(P_{+1} = \frac{I+S}{2}\) the projector onto the \((+1)\) eigenspace of S and \({\text {tr}}\) the trace operator. This value tells us then with which probability the measurement “accepts” a noisy state, and can be used to compare the effectiveness of different choices of S given a certain noise model [26]. Let us consider \(\rho _{\text {noisy}} = \varPhi (U|0\rangle )\) for \(\varPhi \) the depolarizing noise channel and U some single-qubit unitary – in other words, we have a single layer of depolarizing noise at the end of our computation. For simplicity, let us further assume that our state before the depolarizing channel is the \((+1)\) eigenvector of some Pauli operator e.g. the Pauli X, then we have \(U=H\) (the Hadamard gate) and we can draw \(p(+1)={\text {tr}}(\frac{I+S}{2}\rho _{noisy})\) diagrammatically (up to scalar factor, see [51, Appendix D]) as the following diagram:

figure l

From top to bottom, the diagram represents applying H to the \(|0\rangle \) state, followed by a depolarizing noise channel and the verification of X in the form of a CNOT gate controlled on an auxiliary qubit. The auxiliary qubit on the right starts in the \(|0\rangle \) state and has a Hadamard gate applied to it before and after the CNOT. It is then postselected into \(\langle 0|\), which is the corresponding state for the \((+1)\) outcome. The last operation in the form of corresponds to the trace. The full diagrammatic calculation is in [51, Appendix D]. With similar diagrams, we can study diagrammatically how well different QEM techniques mitigate certain noise models, and apply them to representations of quantum algorithms that, for example, have one layer of errors for every time step.

6 Discussion and Future Work

In this work, we have shown how to construct freely enriched symmetric monoidal categories over the algebras of a monoidal monad on \(\textbf{Set}\) that satisfies \(F \dashv \textbf{Alg}^T(I,-)\) for F the free T-algebra functor and I the unit of the monoidal structure, which is the case in particular when T is an affine monad. We have then taken this construction and developed a graphical language that captures the additional algebraic structure of the morphisms for the case of the Distribution monad. We then show how we can use this to study classical probabilistic processes in quantum systems, a highly relevant type of operation for near-term quantum applications. In particular, we extend the ZX-calculus to make it a language for reasoning in an enriched version of \(\mathbf {CPM(\textbf{Qubit})}\).

We believe that this work opens several directions for future research. The most evident one is to prove completeness of the enriched diagrams, which in turn would facilitate automated implementations for tasks such as simulation of noisy quantum systems, fine-tuned quantum circuit optimization techniques for specific quantum devices, or comparison of the effectiveness of different Quantum Error Mitigation techniques. An interesting venue would be to use enrichment over \(\mathcal {M}\) to reason about quantum circuit pre- and post-processing techniques, such as circuit cutting [42, 44], in which quantum circuits are “split” into linear combinations of smaller ones that are executed separately. We also believe that it could be possible to integrate monads that capture quantum behaviours into our construction to represent in enriched ZX-diagrams phenomena such as superposition of execution orders, like what is done in the Many-Worlds calculus [14].

Strongly related to completeness is to have presentations of the diagrams in terms of generators and equations. We achieved this by hand in Section 5 by using that the algebras for the distribution monad can be presented as convex algebras with a family of operations \(+_{p}\). The question is then what the analogue of convex monads is when using algebras presented by Lawvere theories or sketches [21, 36].

We are also interested in finding other monads that could capture interesting processes outside of the quantum realm. For example, the non-empty powerset monad could be used to encode non-deterministic operations and be used for reasoning about a third party operating on a shared quantum system.