The Structure of Sum-Over-Paths, its Consequences, and Completeness for Clifford

We show that the formalism of"Sum-Over-Path"(SOP), used for symbolically representing linear maps or quantum operators, together with a proper rewrite system, has a structure of dagger-compact PROP. Several consequences arise from this observation: 1) Morphisms of SOP are very close to the diagrams of the graphical calculus called ZH-Calculus, so we give a system of interpretation between the two; 2) A construction, called the discard construction, can be applied to enrich the formalism so that, in particular, it can represent the quantum measurement. We also enrich the rewrite system so as to get the completeness of the Clifford fragments of both the initial formalism and its enriched version.


Introduction
The "Sum-Over-Paths" (SOP) formalism [1] was introduced in order to perform verification on quantum circuits. It is inspired by Feynman's notion of path-integral, and can be conceived as a discrete version of it.
The core idea here is to represent unitary transformations in a symbolic way, so as to be able to simplify the term, which would for instance accelerate its evaluation. To do so, the formalism comes equipped with a rewrite system, which reduces any term into an equivalent one.
As pure quantum circuits (which represent unitary maps) can easily be mapped to an SOP morphism, one can try and perform verification: given a specification S and another SOP morphism t obtained from a circuit supposed to verify the specification, we can compute the term S • t † and try to reduce it to the identity. In a very similar way, one can check whether two quantum circuits perform the same unitary map.
The rewrite system is known to be complete for Clifford unitary maps, i.e. in the Clifford fragment of quantum mechanics, the term obtained from t 1 • t † 2 will reduce to the identity iff t 1 and t 2 represent the same unitary map. Moreover, this reduction terminates in time polynomial in the size of the SOP term (itself related to the size of the quantum circuit), and still performs well outside the Clifford fragment.
Another use for this formalism is quantum simulation, the problem of evaluating the unitary map represented by a quantum circuit. Doing this is exponential in the number of variables in the SOP term, but the rewrite strategy reduces this number of variables, so each step in the reduction roughly divides the evaluation time by two.
Something that the SOP formalism cannot do for now however is circuit simplification. Indeed, even though we can easily translate an arbitrary quantum circuit to an SOP term, and then reduce it, there is no known way to extract a quantum circuit from the result.
We show in this paper that the formalism, when considered as a category (denoted SOP), has the structure of a †-compact PROP. This structure is explained in details in Section 2. This structure is shared by a much larger set of maps than just unitary maps, namely Qubit, the category whose morphisms are linear maps of C 2 m ×C 2 n . In particular, we show that any morphism of Qubit could be expressed as a morphism of SOP.
Because the formalism is no longer restricted to unitary maps, we argue that it could benefit from a slight redefinition, which is done in Section 4.
Another "family" of categories that share this structure is the family of graphical languages for quantum computation: ZX-Calculus, ZW-Calculus and ZH-Calculus [3,6,7]. All three formalisms represent morphisms of Qubit using diagrams, and come with equational theories, proven to be complete for the whole category [3,10,16], i.e. whenever two diagrams represent the same morphism of Qubit, the first can be turned into the other using only the equational theory.
In Section 5, we show that any diagram of the ZH-Calculus can be interpreted as a morphism of SOP, and conversely, that any morphism of SOP can be turned into an equivalent ZH-diagram.
In Section 6, we realise that the rewrite system of SOP is not enough for the completeness of the Clifford fragment of Qubit. We define a restriction of SOP that captures exactly this fragment, and enrich the set of rules so as to get the completeness in this restriction.
In Section 7, we enrich the whole formalism using the discard construction [5], so as to be able to represent completely positive maps, as well as the operator of partial trace. Again, one can consider the Clifford fragment of this formalism. We give a new set of rewrite rules, and show that it makes the fragment complete.

PROPs and String Diagrams
The first kind of category we will be interested in is the PROP [11,17]. A PROP C is a strict symmetric monoidal category [12,15] generated by a single object, or equivalently, whose objects form N. Hence the morphisms of C are of the form f : n → m. They can be composed sequentially (. • .) or in parallel (. ⊗ .), and they satisfy the following axioms: The category is also equipped with a particular family of morphisms σ n,m : n + m → m + n. Intuitively, these allow morphisms to swap places. They satisfy additional axioms: σ n,m+p = (id m ⊗ σ n,p ) • (σ n,m ⊗ id p ) σ n+m,p = (σ n,p ⊗ id m ) • (id n ⊗ σ m,p ) σ m,n • σ n,m = id n+m (id p ⊗ f ) • σ n,p = σ m,p • (f ⊗ id p ) Monoidal categories, and subsequently PROPs, have the benefit of having a nice graphical representation, using string diagrams. The object n and equivalently id n is represented by n parallel wires:  The sequential composition (. • .) is obtained by plugging the outputs of the morphism on the right to the inputs of the morphism of the left. The parallel composition (. ⊗ .) is obtained by putting the two diagrams side by side.
The first set of axioms is for coherence: the two compositions are associative, so we can forget about the parentheses, and the following string diagram is well defined, as:

†-Compact PROPs
Some PROPs can have additional structure, such as a compact-closed structure, or having a †functor.
A †-PROP C is a PROP together with an involutive, identity-on-objects functor (.) † : Finally, we have σ † n,m = σ m,n . A †-compact PROP as two particular families of morphisms: η n : 0 → 2n and ǫ n : 2n → 0. These are dual by the †-functor: η † n = ǫ n . They satisfy the following axioms: The morphisms η n and ǫ n may be denoted ...  In this context, one can define the transpose operator of a morphism f as:  One can check that, thanks to the axioms of †-compact PROP, We can then compose (.) t and (.) † : (.) := (.) †t . Again using the axioms of †-compact PROP, one can check that (.) †t = (.) t † .

Example: Qubit
The usual example of a strict symmetric †-compact monoidal category is FHilb, the category whose objects are finite dimensional Hilbert spaces, and whose morphisms are linear maps between them. It is not, however, a PROP, as it is not generated by a single object.
One subcategory of FHilb that is a PROP, though, is Qubit the subcategory of FHilb generated by the object C 2 , considered as the object 1. A morphism f : n → m of Qubit is hence a linear map from C 2 n to C 2 m . (. • .) is then the usual composition of linear maps, and (. ⊗ .) is the usual tensor product of linear maps. One can check that the first set of axioms is satisfied. This is not enough to conclude that Qubit is a PROP. We still need to define a family of morphisms σ n,m . In the Dirac notation, given a basis B of C 2 , we can define σ n,m as σ n,m := (x,y)∈B n ×B m |y, x x, y|. One can then check that all the axioms of PROPs are satisfied.
Qubit is not only a PROP, but also †-compact. Indeed, first, given a morphism: f = (x,y)∈B n ×B m a x,y |y x| we can define its dagger f † := (x,y)∈B n ×B m a x,y |x y|, which is the usual definition of the dagger for linear maps.
Its compact structure can be given by η n := x∈B n |x, x , which implies ǫ n = η † n = x∈B n x, x|.
One can check that all the axioms of †-compact PROPs are satisfied. Since Qubit is †-compact, we can define the transpose (.) t which happens to be the usual transpose of linear maps, and the conjugate (.), which again is the usual conjugation in linear maps over C.
There is a subcategory of Qubit that is of importance: Stab. It is the smallest †-compact subcategory of Qubit (the compact structure is preserved) that contains: The Category SOP

SOP as a PROP
The point of the Sum-Over-Paths formalism [1], is to symbolically manipulate morphisms written in a form akin to the Dirac notation. Reasoning on symbolic terms allow us to detect where a term can be simplified in a "smaller" one, or to give a specification on a term.
A morphism of the category will be of the form |x → s y∈V k e 2iπP (x,y) |Q(x, y) where: . , x n is the input signature, it is a list of variables -V is a set of variables (hence y is a collection of these variables) -P is a multivariate polynomial, instantiated by the variables x and y -Q = Q 1 , . . . , Q m is the output signature, it is a multivariate, multivalued boolean polynomial -s is a real scalar We may denote V f a subset of the variables V used in f . Then by default, if V f and V g are used in the same term, we consider that V f ∩ V g = ∅. To distinguish the two sum operators (the one in P and the one in Q), we can denote the one in the output signature Q as ⊕. Moreover, it will sometimes be necessary to immerse one of the boolean polynomials Q i in the polynomial P . We hence define Q i inductively as x = x for a variable x, pq = p q and p ⊕ q = p + q − 2 pq.
Definition 1 (SOP). SOP is defined as the PROP where, given a set of variables V : -Identity morphisms are id n : |x → |x -Morphisms f : n → m are of the form f : |x → s y∈V k e 2iπP (x,y) |Q(x, y) where s ∈ R, -Tensor product is obtained as The polynomial P is called the phase polynomial, as it appears in the morphism in e 2iπ. . Because of this, we consider the polynomial modulo 1. We also consider the polynomial quotiented by X 2 − X for all its variables X, as these variables are to be evaluated in {0, 1}, so we consider Notice that the definition of the identities does not directly fit the description of the morphisms. However, we can rewrite it as |x → |x = |x → 1 y∈V 0 e 2iπ0 |x . Hence, when we sum over a single element, we may forget the sum operator, and when the phase polynomial is 0, we may not write it. Notice by the way that id 0 = | → | . Indeed, | is absolutely valid, it represents an empty register. Example 1. We can give the SOP version of the usual quantum gates: The previous definition contains a claim: that SOP is a PROP. To be so, one has to check all the axioms of PROPs. One has to be careful when doing so. Indeed, the sequential composition (. • .) induces a substitution. Hence, one has to check all the axioms in the presence of a "context", that is, one has to show that the axioms can be applied locally.

.
In the case of the axioms of PROPs, this can further be reduced to showing the axioms without context, as neither id n nor σ n,m introduce variables or phases. For the other axioms, however, the context will have to be taken into account.
A fairly straightforward but tedious verification gives that, indeed, SOP is a PROP. We give as an example the proof of associativity of the sequential composition (without context for simplicity): or that σ swaps the places of morphisms:

From SOP to Qubit
To check the soundness of what we are going to do in the following, it may be interesting to have a way of interpreting morphisms of SOP as morphisms of Qubit.
Definition 2. The functor . : SOP → Qubit is defined as being identity on objects, and such that, for f = |x → s y∈V k e 2iπP (x,y) |Q(x, y) : The interpretation of H is as intended the Hadamard gate: The interpretation . is a PROP-functor, meaning: Proof. This is a straightforward verification.

Towards a Compact Structure
It is tempting to try and adapt the compact structure of Qubit to SOP. To do so, we can first define η n := | → y∈V n |y, y . However, we cannot as easily define ǫ n . What ǫ 1 intuitively does in Qubit is: given two inputs x 1 and x 2 , it checks if they are equal, if so it returns the scalar 1, if not, the scalar 0.
In SOP we can force two variables to be equal, using a third fresh variable y. Indeed, consider the sum e 2iπ( We can check that ǫ 1 = ǫ 1 : Similarly, ǫ n = ǫ n . We can now try to check whether the axioms of †-compact PROPs (at least the ones that do not require the †, as we have not defined it yet) are satisfied: These two equations were shown without a context for simplicity, but still hold with it.
However, the equation: is not satisfied, as: Qubit hints at a way to rewrite the first term as the second in SOP.

An Equational Theory
A rewrite strategy is given in [1], and we show in Figure 1 the ones we are going to use in the paper. Each rewrite rule contains a condition, which usually ensures that a variable (the one we want to get rid of) does not appear in some polynomials. We hence use Var as the operator that gets all the variables from a sequence of polynomials: For simplicity, the input signature is omitted, as well as the parameters in the polynomials. −→ Clif denotes the rewrite system formed by the three rules (Elim), (HH) and (ω). *

−→
Clif is the transitive closure of the rewrite system. Notice that all the rules remove at least one variable from the morphism, so we know −→ Clif terminates.
When the rules are not oriented, we get an equivalence relation on the morphisms of SOP. We denote this equivalence ∼ Clif . We denote SOP/ ∼ Clif the category SOP quotiented by the equivalence relation ∼ Clif . This newly obtained category is still a PROP. It even has a compact structure, as the last necessary axiom is now derivable: Remember that we defined (.) as (.) †t . Since we have a compact structure, we can already define the functor (.) t . Thanks to the new equivalence relation ∼ Clif , this functor is involutive. Hence, we t . An appropriate definition of the conjugation can be given: This gives a definition of the †. For the record, if f is of the above form: These three functors are the expected ones: In appendix at page 23.
We can finally prove the wanted result: Proof. In appendix, at page 23.

Redefinition of SOP
In Qubit, and hence in SOP, it may feel unnatural to have asymmetrical input and outputs.
Why not have morphisms of the form f = s y e 2iπP |O I|? In this case, we have to change the definition of the composition, and, because of this, the SOP morphisms do not form a category. However, it is a category when quotiented by ∼

Clif
. This is the reason why we did not define SOP like this at first, although it greatly simplifies the notions of compact structure and †-functor. We now redefine SOP, and will use this new definition in the rest of the paper: Definition 4 (SOP). We redefine SOP as the collection of objects N and morphisms between them: -Identity morphisms are id n : As announced, this is not a category, as id • id = 1 2 y e 2iπ y 1 +y 2 2 y3 |y 2 y 1 | = y |y y| = id. This problem is solved by reintroducing the rewrite rules, that we adapt to the new formalism in Figure 2.
Again, we give the same name to the rewrite system, but this last one is the one we will use in the rest of the paper.

Proposition 3. SOP/ ∼
Clif is a †-compact PROP, and . is a †-compact PROP-functor. Remark 1. In this new formalism, it is fairly easy to perform weak simulation: given a quantum circuit C and two quantum states |ψ i and |ψ o , what is the probability of outputting |ψ o when the circuit C is applied to the input |ψ i ?
Given SOP-morphisms t C for the circuit and t i and t o for the states |ψ i and |ψ o , one simply needs to compute t † o • t C • t i and simplify the term (which represents a scalar), before evaluating it. Obviously, the efficiency of this method is conditioned by the simplification strategy used before evaluation.

Remark 2.
When building a SOP morphism t from a circuit (or a diagram as we will show in the following) in this formalism, the resulting t is always of size O(d × n) where n is the size of the register, and d the depth of the circuit (and for a diagram in O(G × a) where G is the number of generators and a the maximum arity of these generators).
This contrasts with the first definition of SOP, where the size of the constructed SOP term is polynomial for fixed restrictions of quantum mechanics (where the gates R Z are restricted to parameters that are multiples of π 2 p−1 for a fixed p), but exponential in general. This is due to the substitution [x ← Q] in the composition. Indeed, if Q contains ℓ monomials, Q contains in the worst case 2 ℓ − 1 monomials. In the considered fragment, the size is constrained as 1 2 p Q mod 1 has at most p k=1 ℓ k ≤ pℓ p monomials.

SOP and Graphical Languages
The sum-over-paths formalism was initially intended to be used for isometries. As such, it was given a weak form of completeness -as we will discuss in the next section. However, if transforming a quantum circuit -that describes an isometry -into an SOP morphism is easy, the converse, transforming a SOP morphism into a circuit is not. And actually, all SOP morphisms do not represent an isometry. For instance, the morphism ǫ 1 described above is not an isometry. An even smaller example is y | y| which is a valid SOP morphism, but clearly does not represent an isometry.
The fact that SOP is †-compact hints at another (family) of language(s) more suited for representing it: the Z * -Calculi: ZX, ZW and ZH. These are all †-compact graphical languages, that have an interpretation in Qubit, and are universal for Qubit. This means that any morphism of Qubit can be represented as a morphism of either of these 3 languages.
The language that happens to be the closest to SOP is the ZH-Calculus. This is the one we are going to present in the following. However, bear in mind that, as we have semantics-preserving functors between any two of these three languages, one can do the same work with ZX and ZW-Calculi.

The ZH-Calculus
ZH is a PROP whose morphisms are composed (sequentially (. • .) or in parallel (. ⊗ .)) from Z-spiders and H-spiders: When r is not specified, the parameter in the H-spider is taken to be −1.
ZH is made a †-compact PROP, which means it also has the symmetric structure σ, the compact structure (η, ǫ), and a †-functor (.) † : ZH op → ZH. It is defined by:  The language comes with a way of interpreting the morphisms as morphisms of Qubit. The standard interpretation . : ZH → Qubit is a †-compact-PROP-functor, defined as: Notice that we used the same symbol for two different functors: the two interpretations . : SOP → Qubit and . : ZH → Qubit. It should be clear from the context which one is to be used. The language is universal: ∀f ∈ Qubit, ∃D f ∈ ZH, D f = f . In other words, the interpretation . is onto. This is shown using a notion of normal form. This means there is a functor N : Qubit → ZH.
The language comes with an equational theory, which in particular gives the axioms for a †-compact PROP. We will not present it here.

From ZH to SOP
We show in this section how any ZH morphism can be turned into a SOP morphism in a way that preserves the semantics. We define [.] sop : ZH → SOP as the †-compact PROP-functor such that: This does not give a full description of [.] sop , as we did not describe the interpretation of the H-spider for all parameters, but only for phases and 0. However, any H-spider can be decomposed using the previous ones: Proof. In appendix at page 24.
As a consequence, we extend the definition of . In other words, the following diagram commutes: Proof. This is a straightforward verification.

From SOP to ZH
As we explained previously, there exists a functor from Qubit to ZH. Hence, we have the following (non commutative) diagram: ZH .

N
We could hence define the interpretation from SOP to ZH as N ( . ). This would preserve the semantics, as N does. However, this would yield in general a diagram of exponential size in the size of the SOP morphism. Instead, we define in the following an interpretation of SOP morphisms as ZH-diagrams of roughly the same size. We define [.] ZH : SOP → ZH on arbitrary SOP morphisms as:  The nodes I i are defined similarly, but upside-down. The node P can be inductively defined as:

SOP for Clifford
The Clifford fragment of Quantum Mechanics is the one that represents Stab. We would like to have a characterisation of this fragment for SOP. Thankfully, this fragment is well known in ZH. It can hence be inferred in SOP thanks to [.] sop .

The Subcategories of ZH and SOP for Clifford
Definition 5. ZH Clif is the †-compact subPROP of ZH with the same objects, and generated by: ...
We hence propose a restriction of SOP for the Clifford fragment, and show afterwards that it does indeed capture exactly Stab. Definition 6. SOP Clif is the subPROP of SOP with the same objects, and whose morphisms are of the form: where P (i) is a polynomial with integer coefficients of degree at most i (hence P (0) is in fact merely an integer); and where all the O i and I i are linear.
Proposition 7. . : SOP Clif → Stab, the restriction of the standard interpretation to SOP Clif is onto Stab.
Proof. In appendix at page 25.
Hence, SOP Clif does capture the Clifford fragment of quantum mechanics.

A Complete Rewrite System for Clifford
In [1], where the rewrite rules are introduced, the author gives a notion of completeness for Clifford unitaries, that we will refer to in the following as "weak completeness": Proposition 8 (Weak Completeness for Clifford Unitaries). Given two terms t 1 , In practice, this is sufficient for deciding the equivalence of two Clifford quantum circuits, as they are represented as unitary morphisms of SOP Clif . However, in our case, where we deal with more than unitaries, we cannot use this trick. Instead, we aim at a result like "t 1 * . In other words, we want a rewrite system that will transform any term of SOP Clif into a unique normal form.
The rewrite system −→ Clif is not enough for this: There exist t 1 and t 2 two morphisms of SOP Clif such that: Proof. An example of such behaviour can be obtained with: 2 ) |y y 1 , y 2 | t 2 := e 2iπ y 2 y 2 |y 1 ⊕y y 1 , y 2 | To palliate this problem, we propose to add three rewrite rules to the previously presented ones. These new rewrite rules are shown in Figure 3. The last rule (Z) describes what happens for a term that represents the linear map 0. Rule (bra) is simply the continuation of (ket). They explain how to operate suitable changes of variables. Proof. In appendix at page 26.
Not only does this rewrite system terminate, it is confluent in SOP Clif and the induced equivalence relation ∼ Clif+ is complete for Clifford. We prove this by showing that any morphism of SOP Clif reduces to a normal form that is unique.
Proof. In appendix at page 26.
To start with, we deal with the case where the term represents the null map. Before moving on to the completeness by normal forms theorem, we need a result for the uniqueness of the phase polynomial:

Pivoting and Local Complementation
We show here how, in the Clifford case, the rule (HH) corresponds to the operation of pivoting [9], and the rule (ω) to that of local complementation [2,13]. To do so, we realise that graph states are easily representable in SOP, for instance by interpreting the ZH-version of the graph state as a SOP morphism. Let G = (V, E) be a graph, with vertices V and edges E ⊆ V × V . The associated SOP morphism is: Pivoting The operation of pivoting can be used to simplify a diagram of ZH Clif (or equivalently a Clifford diagram of the ZX-Calculus, as described in [9]). Informally, pivoting can be applied on any neighbouring pair of white nodes (where at least one of them is internal i.e. not linked to an input/output, for it to actually simplify the diagram). In the process, we complement the exclusive neighbours of both nodes with the other neighbours. Moreover, the common neighbours get an additional phase of π.
Let us see how it translates in SOP. Let t = s e 2iπ( y 0 y i Q0i+R) |O I| be a Clifford term, where the phase polynomial is already factorised by y 0 and y i , the pair of variables/white dots on which to apply the pivoting. We consider that y 0 is internal y 0 / ∈ Var(O, I). The fact that y 0 and y i are neighbours is captured by the term y0yi 2 in the phase polynomial. We can distinguish the exclusive neighbours of y 0 (resp. y i ) by Q 0 (resp. Q i ), and their common neighbours by Q 0i .
The rule (HH) can be applied, with the substitution [y i ← Q 0 ⊕ Q 0i ]. The result is The term 1 2 Q 0 Q i creates the monomial y k y ℓ 2 for all y k ∈ Var(Q 0 ) and y ℓ ∈ Var(Q i ). If this monomial was already in R, it gets cancelled. This performs the complementation between the groups of variables in Q 0 and those in Q i , and similarly for 1 2 Q 0i Q i and 1 2 Q 0 Q 0i . On the other hand, the term 1 2 Q 0i creates a π phase for all the common neighbours of y 0 and y i .

Local Complementation
The operation of local complementation is another operation that can be used to simplify the Clifford term at hand. Consider an internal white node in a Clifford diagram. If this node has a phase of ± π 2 , it can be removed. Doing so will add a phase of ∓ π 2 to all the neighbours of the node, and at the same time, will perform a local complementation on them (all the nodes connected through an H will get disconnected, and vice-versa). A global phase is also created.
A SOP morphism in this situation is of the form t = s e 2iπ( y 0 4 + y 0 2 ( xi)+R) |O I| with y 0 an internal variable and x i its neighbours. The rule (ω) can hence be applied, and the resulted term is: The constant 1 8 corresponds to the global phase, the term − 1 4 ( x i ) represents an additional − π 2 phase to all the neighbours of y 0 , and term 1 2 ( i =j x i x j ) performs the local complementation on them.
In the case where y 0 holds a − π 2 phase, the term can also be simplified like this.

The Discard Construction on SOP
In [5], a construction is given to extend any †-compact PROP for pure quantum mechanics to another †-compact PROP for quantum mechanics with environment. This new formalism can also be understood as the previous one, but where on top of it, one can discard the qubits. Because SOP fits the requirements, the construction can be applied to it. First, we have to create the subcategory SOP iso of SOP that contains all its isometries. The objects of the new category are the same, and its morphisms are These are important, as the isometries are exactly the pure quantum operators that can be discarded. The next step in the construction does just that. We perform the affine completion of SOP iso , that is, for every object n, we add a new morphism ! n : n → 0, and we impose that ! • f =! for any f in the new category, that we denote SOP ! iso . We also need to impose that ! n ⊗! m =! n+m and ! 0 = id 0 .
Finally, the category SOP is obtained as the pushout: where the additional D is a set of multivariate polynomials of F 2 . The fact that it is a set, and not a list, already captures some rules on the discard: first permuting qubits and then discarding them is equivalent to discarding them right away. Similarly, copying data and discarding the copies is equivalent to discarding the data right away. Pure morphisms are those such that D = {}. In those, no qubits are discarded. We hence easily induce usual morphisms such as H and CZ in the new formalism.
The new morphisms ! n are given by: . . , y n } y 1 , . . . , y n | In the new formalism, the compositions are obtained by: It might be useful to be able to give an interpretation to the morphisms of the new formalism. To do so, we use the CPM construction [14] to map morphisms of SOP to morphisms of SOP.

SOP with Discards for Clifford
The discard construction can be applied to the subcategory SOP Clif . We end up with a new category SOP Clif , such that the following diagram, whose arrows are inclusions, commutes: Following the characterisation of SOP Clif morphisms, we can determine that all the morphisms of SOP Clif are of the form: where p ∈ Z, where P (i) is a polynomial with integer coefficients and of degree at most i, and where the polynomials of O, D and I are linear.
The rewrite system presented previously can obviously be adapted to the new formalism (when there is a substitution, it has to be applied in !D as well). On top of that, the condition that makes SOP ! iso terminal can be translated as the meta rule: As you can see, this rule is not easy to apply. Thankfully, the last part of [5] is devoted to showing that the big meta rule can sometimes be replaced by a few small ones. The idea is that, in some cases (in particular in the Clifford fragment), all the isometries can be generated from a finite set of generators. In particular, it is enough to impose that: We give in Figure 4 the updated set of rewrite rules.
Proof. In appendix at page 28. Proof. In appendix at page 28.
Corollary 4. Any morphism of SOP Clif eventually reduces to a morphism of the form given in Lemma 6.
Proof. As the rewrite system terminates, and since every morphism of SOP Clif can be reduced into the form of Lemma 6, the rewrite system terminates in a term of the form of Lemma 6.
Lemma 7. Any morphism t of SOP Clif such that t = 0 reduces to: y0 e 2iπ( y 0 2 ) |0, · · · , 0 !{} 0, · · · , 0| Proof. In appendix at page 29. Theorem 3 (Completeness for Clifford). Let t 1 and t 2 be two morphisms of SOP Clif such that t 1 = t 2 . If t ′ 1 and t ′ 2 are terminal such that To prove this theorem, we suggest to use the similar result in SOP Clif , and transport it to our case. To do so, we need some additional constructions.
Definition 9. We define SOP Clif as the set of morphisms of SOP Clif in the form given in Lemma 6. We define the function F on SOP Clif such that, for any morphism This new functor F can be seen as a simplified CPM construction, in the case where the term is already simplified.
then G(t) is defined, and: The function G is designed to be an inverse of F for some morphisms, while at the same being impervious to some rewrite rules.
Proposition 13. Let t be terminal with −→ Clif . Then, the following diagram commutes up to αconversion: for any t ′ obtained by reducing F (t).
Proof. In appendix at page 29.
Proof (Theorem 3). Let t 1 and t 2 be two morphisms of SOP Clif such that t 1 = t 2 . Since −→ Clif terminates by Proposition 13, both t 1 and t 2 reduce to respectively t ′ 1 and t ′ 2 , two terminal morphisms of SOP Clif . By soundness, t ′ 1 = t ′ 2 , so, by Proposition 12, ) up to α-conversion. Finally, by Proposition 13, t ′ 1 = G(t ′ ) = t ′ 2 up to α-conversion: Remark 3. Interestingly, the previous proposition and theorem show that the simplification of a term of SOP Clif can be operated in the "pure" setting, and then G can be used to retrieve the normal form. More precisely:

Conclusion and Further Work
We have shown that SOP could represent any morphism of Qubit, and that it could be enriched using the discard construction to include measurements. We have shown a correspondence between this formalism and graphical languages such as the ZH-Calculus, and we have provided two rewrite strategies for simplifying terms. We have shown that these are complete in the Clifford case. This framework can be used to simplify Z*-diagrams: one simply needs to translate the diagram as a SOP-morphism, simplify it, then translate the result as a diagram in the target language.
By applying the discard construction, we have extended the domain of use of SOP to programs that contain measurements. For instance, schemes for error detection/correction can now be studied/verified/simplified in the framework.
One of the obvious further developments of the framework is to use the completeness of (fragments of) Z*-Calculi and their interpretation to generate rewrite strategies complete for fragments larger than Clifford. On can also transport constructions that are known in the Z*-Calculi to perform non trivial operations on SOP morphisms.
Another important development of the framework would be to more easily represent families of processes. The recent enrichment SZX [4] could be of help for this topic.
Next, it suffices to show that all the generators of Stab have a preimage by . in SOP Clif : Finally, the rule (Z) reduces the morphism to one whose tuple is (1, 0, . . . , 0, 0, . . . , 0, 1), and only from a morphism with a larger associated tuple.
Proof (Lemma 3). The rules (ket) and (bra) quite obviously enforce the form of O and I. Then, suppose y 0 is an internal variable. Then either: -the monomial 1 4 y 0 appears in the phase polynomial, in which case the rule (ω) can be applied -the monomial 1 2 y 0 y i appears in the phase polynomial, with some arbitrary y i , in which case the rule (HH) can be applied -the monomial 1 2 y 0 appears in the phase polynomial, as the only occurrence of y 0 , in which case the rule (Z) can be applied Proof (Proposition 10). By reductio ad absurdum, suppose that t reduces to t ′ = 1 Notice that: c (resp. 0) will be the first term of x 1 . Doing so repeatedly (building t (i+1) from t (i) ) first for the whole ket, and then for the whole bra, we end up with a term t (n+m) of the form t (n+m) = 1 √ 2 p e 2iπc with c a constant. In the process, we build x 1 and x 2 .
Proof (Lemma 4). Let us prove the result by induction on k: -If k = 0, the result is obvious -Suppose the result is true for k.
Proof (Theorem 2). If t 1 = 0 = t 2 , by Proposition 10, the two terms reduce to the same normal form.
Suppose now that t i = 0, and that t i reduce to  In parallel, we start building a particular operator that will be of use in the following. In the first case, the operator is built from op := +|, in the second case, from op := id.
We may notice that: Doing so inductively first for the whole ket, then for the whole bra, we get: -a matching of variables of t ′ 2 with variables of t ′ 1 . We may call δ the bijection that maps a variable of t ′ 2 to a variable of t ′ 1 . -the equalities O (1) = O (2) [y 2 ← δ(y 2 )] and I (1) = I (2) [y 2 ← δ(y 2 )] -the equality 1 which implies equality for the p i and the constants in the phase polynomials.
-two operators op 1 (for the ket) and op 2 (for the bra), such that Since the P i are considered modulo 1, we have ∀y ∈ {0, 1} k , P 1 (y) = P 2 (y). By Lemma 4, we finally get P 1 = P 2 .
Proof (Proposition 11). For a morphism s Proof (Lemma 6). The first and last conditions are verified just as in the pure case. Then, all the constants in the phase polynomial can be removed using rule (Z ). Then for the form of D, let us decompose it as D = {y 1 , . . . , y k } ∪ {D i1 , . . . , D is } where all the polynomials in the right hand side have mon(.) ≥ 2 (if 0 or 1 appears as a polynomial in D, it is removed using (Cst )). Consider D i1 . Either -D i1 contains at least one variable y k+1 / ∈ {y 1 , . . . , y k }, in which case (disc) can be used so D ′ = {y 1 , . . . , y k+1 } ∪ {D i2 , . . . , D is }[y k+1 ← D i1 ] -or D i1 contains only variables of {y 1 , . . . , y k }, in which case, using (⊕ ) repeatedly, it can be reduced to a constant that can then be removed using (Cst ), so D ′ = {y 1 , . . . , y k } ∪ {D i2 , . . . , D is } Hence, in any case, D can be reduced to the form D = {y 1 , . . . , y k }.
We then have to show that P can be reduced to the form above. Suppose y 0 appears both in !{y d } and in P (1) , then (Z ) can be used to remove it from P . The same goes for monomials of the form y 0 y ′ 0 in P (2) when {y 0 , y ′ 0 } ⊆ {y d }. Finally, if a variable of y d appears only in !{y d } and in P , then the rule (H ) can be applied to remove the variable.
Proof (Lemma 7). The proof is similar to that of Proposition 10, except now we have a set of discarded variables {y d }. However, since {y d } ⊆ Var(O, I), the set of discarded variables will deplete as the t (i) are built. The conclusion remains unchanged.
Proof (Proposition 13). First, let us prove that, if t ∈ SOP is terminal, G(F (t)) is defined and G(F (t)) = t. By definition: i2 we define δ(y ′ i2 ) := y i1 . We need to show that it completely and uniquely defines δ as a bijection. Consider the variable y i . Let K i be the first (from left to right) polynomial of (O(y, y d ), I(y, y d )) where y i appears. Then K i (y, y d ) = y i , otherwise, either (ket) or (bra) could be applied on t, which means t is not terminal. Hence K i (y, y d ) ⊕ K i (y ′ , y d ) = y i ⊕ y ′ i , so δ(y ′ i ) = y i , and y ′ i is the only possible preimage of y i by δ. Notice that δ(y ′ ) = y with no permutation on the indexes, so we obviously get (O(y, y d ) ⊕ O(y ′ , y d ), I(y, y d ) ⊕ I(y ′ , y d ))[y ′ ← δ(y ′ )] = 0.
Hence, G(F (t)) is well defined, and: We now need to show that for all the terms t ′ that are reduced from F (t), G(t ′ ) is defined, and G(t ′ ) = G(F (t)) = t. To do so, we show by induction that along any reduction path from F (t), some properties are preserved. Let e 2iπP |O 1 , O 2 I 1 , I 2 | such that F (t) * −→ Clif+ t ′ . We claim that: -p ′ = 2p y (t ′ ) = y, y ′ , y d , i.e. no variable is removed, and the partitioning by G does not change