The ZX-calculus is complete for stabilizer quantum mechanics

The ZX-calculus is a graphical calculus for reasoning about quantum systems and processes. It is known to be universal for pure state qubit quantum mechanics, meaning any pure state, unitary operation and post-selected pure projective measurement can be expressed in the ZX-calculus. The calculus is also sound, i.e. any equality that can be derived graphically can also be derived using matrix mechanics. Here, we show that the ZX-calculus is complete for pure qubit stabilizer quantum mechanics, meaning any equality that can be derived using matrices can also be derived pictorially. The proof relies on bringing diagrams into a normal form based on graph states and local Clifford operations.


Introduction
The success of the quantum circuit notation shows the value of graphical languages for quantum processes. Using both dimensions of a sheet of paper allows the parallel composition of operations (say, several operations happening to different systems at the same time) to be separated from serial composition (say, different operations, possibly happening to the same system, but at different times). This makes graphical notation much easier for humans to read than the standard Dirac or matrix notations, where parallel and serial composition of operations are both represented in one dimension, namely a line of text. Yet the quantum circuit notation has one big disadvantage: There are no transformation rules for quantum circuit diagrams. The only way to simplify or compare quantum circuit diagrams is by translating them back into matrices, thereby losing the advantages of the graphical notation.
Unlike quantum circuit notation, the ZX-calculus developed in [5,6] is not just a graphical notation: It has built-in rewrite rules, which transform one diagram into a different diagram representing the same overall process. These rewrite rules make the ZX-calculus into a formal system with non-trivial equalities between diagrams. In the following, we will thus distinguish between diagrams which are identical -i.e. they consist of the same elements combined in the same way -and diagrams which are equal, meaning one can be rewritten into the other. Two identical diagrams are necessarily equal to each other, but two equal diagrams may not be identical. As a formal system modelling pure state qubit quantum mechanics (QM), there are several properties the ZX-calculus must have to be useful. One of these is universality: the question whether any pure state, unitary operator, or post-selected measurement can be represented by a ZX-calculus diagram. The ZXcalculus is indeed universal [6]. A second important property is soundness: can any equality which can be derived in the ZX-calculus also be derived using other formalisms, such as matrix mechanics? By considering the rewrite rules one-by-one, it is not too difficult to show that the ZX-calculus is sound [6]. As a result of this, the ZX-calculus can be used to analyse a variety of questions, e.g. quantum non-locality [7] and the verification of measurement-based quantum computations [6,10,12].
The converse of the soundness property is completeness: The ZX-calculus is complete if any equality that can be derived using matrices can also be derived graphically. It has been conjectured that the ZXcalculus is not complete for general pure state qubit QM, but in this paper we show that it is complete arXiv:1307.7025v1 [quant-ph] 26 Jul 2013 for qubit stabilizer quantum mechanics. Stabilizer QM is an extensively studied part of quantum theory, which can be operationally described as the fragment of pure state QM where the only allowed operations are preparations or measurements in the computational basis and unitary transformations belonging to the Clifford group. While stabilizer quantum computation is significantly less powerful than general quantum computation -it can be efficiently simulated on classical computers and is provably less powerful than even general classical computation [2] -stabilizer QM is nevertheless of central importance in areas such as error-correcting codes [14] or measurement-based quantum computation [16], and it is non-local.
A pure stabilizer state on n qubits is a state that can be created by applying some Clifford unitary to the state |0 ⊗n . Graph states are a special class of stabilizer states, whose entanglement structure can be described by a simple undirected graph. In the ZX-calculus, graph states have a particularly elegant representation [9]. Furthermore, any stabilizer state is equivalent to some graph state under local Clifford operations, which are tensor products of single qubit Clifford operators [13]. The first part of our completeness proof is a proof that this equivalence also holds in the ZX-calculus, i.e. there is a nonunique normal form for stabilizer state diagrams consisting of a graph state diagram and local Clifford operators. Based on work by Elliott et al. [11], we then show that even though this normal form is not unique, there is a straightforward algorithm for testing equality of diagrams given in this form. In particular, this algorithm shows that two diagrams are equal if and only if they correspond to the same quantum mechanical state. By the Choi-Jamiołkowski isomorphism, this result extends to diagrams which represent not states but operators. Thus, for any pair of ZX-calculus diagrams representing the same state or operator in stabilizer QM, the equality testing algorithm can be used to construct a sequence of rewrites obeying the rules of the calculus, which shows that the diagrams are equal. But this is just the definition of completeness, proving that the ZX-calculus for stabilizer QM is complete.
The basic definitions and properties of stabilizer quantum mechnics are given in section 2. In section 3, the elements and rules of the ZX-calculus are laid out. Section 4 contains the definition of graph state diagrams and the normal form, as well as the proof that any stabilizer state diagram can be brought into normal form. The completeness proof can be found in section 5, followed by an example in section 6 and conclusions in section 7.

Stabilizer quantum mechanics 2.1 The Pauli group and the Clifford group
The Pauli operators The unitaries stabilizing a given quantum state can easily be seen to form a group. This group uniquely defines the state.
Definition 3. An n-qubit quantum state is called a stabilizer state if it is stabilized by a subgroup of P n .
Most unitary operators do not preserve stabilizer states, i.e. they map some stabilizer states to nonstabilizer states or conversely. Yet there are some unitary operators which map stabilizer states to stabilizer states. These operators form the Clifford group.
Definition 4. The Clifford group on n qubits, denoted C n , is the group of operators which normalize the Pauli group, i.e. C n = {U|∀g ∈ P n : UgU † ∈ P n }.
Any n-qubit stabilizer state can be expressed as U |0 ⊗n for some (non-unique) U ∈ C n . It can furthermore be shown that the Clifford group is generated by two single qubit operators and one two-qubit operator [14], namely the phase operator S = 1 0 0 i , the Hadamard operator H = 1 Ignoring global phases, the group C 1 of single qubit Clifford unitaries has 24 elements. It is generated by the phase and Hadamard operators, or, alternatively, by R Z and R X , where R Z = S and R X = HSH.
Definition 5. The local Clifford group on n qubits, C ⊗n 1 , consists of all n-fold tensor products of single qubit Clifford operators.
The Clifford group contains all unitary operators that map stabilizer states to stabilizer states. To generate all linear operators which do the same, we must also allow measurements whose results are stabilizer states. Like any n-qubit stabilizer state can be expressed as a Clifford unitary applied to the state |0 ⊗n , any measurement in stabilizer quantum mechanics can be realised by applying a Clifford unitary, followed by a measurement of some number of qubits in the computational (or Z-) basis {|0 , |1 }. Thus, stabilizer quantum mechanics encompasses the following three types of operations: preparation of qubits in the state |0 , Clifford unitaries, and measurements in the computational basis.

Graph states
An important subset of the stabilizer states are the graph states, which consist of a number of qubits entangled together according to the structure of a mathematical graph.
where V is a finite set of vertices and E is a collection of edges, which are denoted by pairs of vertices. A graph is undirected if its edges are unordered pairs of vertices. It is simple if it has no self-loops and there is at most one edge connecting any two vertices.
In the following, unless stated otherwise, all graphs will be assumed to be undirected and simple. For such graphs, the collection of edges is in fact a set (as opposed to, say, a multi-set) and each edge is an unordered set of size two (rather than a tuple). For an n-vertex graph, we will often take V = {1, 2, . . . , n}.
Definition 7. A simple undirected graph G with n = |V | vertices can be described by a symmetric n by n matrix θ with binary entries such that θ i j = 1 if and only if there is an edge connecting vertices i and j. This matrix is known as the adjacency matrix. Definition 8. Given a graph G = (V, E) with n = |V | vertices and adjacency matrix θ , the corresponding graph state |G is the n-qubit state whose stabilizer subgroup is generated by the operators Here, subscripts indicate to which qubit the operator is applied.
All graph states are pure stabilizer states by definition. On the other hand, it is obvious that not all stabilizer states are graph states. Yet there exists an interesting relationship between arbitrary stabilizer states and graph states. Consider the equivalence relation on stabilizer states given by the local Clifford group.
Definition 9. Two n-qubit stabilizer states |ψ and |φ are equivalent under local Clifford operations if there exists U ∈ C ⊗n 1 such that |ψ = U |φ . Theorem 1 ( [13]). Any pure stabilizer state is equivalent to some graph state under local Clifford operations, i.e. any n-qubit stabilizer state |ψ can be written, not generally uniquely, as U |G , where U ∈ C ⊗n 1 and |G is an n-qubit graph state.
A single stabilizer state may well be equivalent to more than one graph state under local Clifford operations. To organize these equivalence classes we require the following definition and theorem.
The local complementation about the vertex v is the operation that inverts the subgraph generated by the neighbourhood of v (but not including v itself). Formally, a local complementation about v ∈ V sends G to the graph where denotes the symmetric set difference, i.e. A B contains all elements that are contained either in A or in B but not in both.
Example. Consider the line graph on four vertices. Applying local complementations about vertex 3 and then vertex 2 yields the following sequence of graphs: 3 The ZX-calculus for stabilizer theory 3

.1 Categorical quantum mechanics
In 2004, Abramsky and Coecke introduced a formalism for describing quantum mechanics using category theory [3]. This formalism gives rise to a graphical calculus, i.e. a graphical representation of quantum states and operations which can be manipulated according to some set of rules. Selinger shows in [17] that this graphical calculus is indeed equivalent to the equational reasoning in dagger compact closed categories, which are the category theoretical framework for quantum mechanics.
The graphical calculus is interesting not just because it can make computations more straightforward for humans to follow, but also because it allows mechanised reasoning, e.g. using a software system like Quantomatic [1].
There are different graphical calculi for categorical quantum mechanics; the one we are using here is that of Coecke and Duncan in [5,6]. It is based on maps in the computational (or Z-) basis {|0 , |1 } and the complementary X-basis {|+ , |− }, and therefore known as the ZX-calculus. In this work, we do not consider the ZX-calculus for all of quantum mechanics, but only the subcategory that represents pure state stabilizer quantum mechanics. The elements of stabilizer ZX-calculus diagrams are introduced in section 3.2 and the rules for manipulating these diagrams in section 3.3. In section 3.4, we discuss properties of the ZX-calculus as a formal system.

The ZX-calculus elements
The diagrams of the ZX-calculus consist of nodes connected by edges and are read from bottom to top. Some edges may only be connected to a node at one end, these are considered to be inputs (if the open end is pointing down) or outputs (if the open end is pointing up) for the whole diagram. There are three types of nodes: • green nodes with n inputs and m outputs and a phase α ∈ {0, π/2, π, −π/2}, representing the maps . . .
• red nodes with n inputs and m outputs and a phase α ∈ {0, π/2, π, −π/2}, representing the maps . . . If a node has phase zero, the phase label is usually left out. Note that π/2 corresponds to R Z and π/2 corresponds to R X . Red or green nodes with one input and one output are occasionally called phase operators. Diagrams with no inputs denote states, in particular is |+ and denotes |0 .
The Hermitian conjugate of a diagram, denoted by a superscript †, is the diagram that results by interchanging the roles of inputs and outputs in the original diagram (i.e. mirroring the diagram in a horizontal line), and flipping the signs of all phases.
Measurements are represented in the ZX-calculus in post-selected form. A diagram D with m inputs and no outputs is called an effect on m qubits. The interpretation of the effect D is that of having found state D † upon performing some apropriate measurement.
The ZX-calculus for all of quantum mechanics has the same elements as the calculus for stabilizer quantum mechanics, the only difference being that arbitrary phases α in the interval −π < α ≤ π are allowed.

Rules of the ZX-calculus
The diagrams of the ZX-calculus satisfy a number of rewrite rules, i.e. purely graphical rules for manipulating diagrams. All rules are also true with the colours red and green reversed, or with inputs and outputs reversed. Subdiagrams with no inputs or outputs are global phase and normalization factors. Since global phases have no physical effect and the normalization of pure states is fixed, we will ignore them. The nodes π and π denote a global factor of 0, these can of course not be ignored.
Only the topology matters: As long as the topology of the diagram remains the same, nodes and lines can be moved around freely.
Spider rule and identity rules: Two adjacent nodes of the same colour merge, their phases add. A node with phase zero and exactly two incident edges can be removed.
Bialgebra law, Hopf law and copying: The bialgebra law allows a certain pattern of two red and two green nodes to be replaced by just one red and green node. If two nodes of different colours are connected by exactly two edges, then by the Hopf law those edges can be removed. Finally, a node of one colour with one input and two outputs copies the zero phase state of the other colour.

= = =
π-copy rule, π-commutation and colour change: A π phase operator is copied by a node of the other colour. It can also be moved past any phase operator of the other colour, flipping the sign of that phase in the process. The Hadamard gate changes the colour of nodes when it is applied to each input and output. From this and the identity rule we can deduce that the Hadamard gate is self-inverse.

Euler decomposition of the Hadamard operator:
This rule is special in that it does not have a category-theoretical meaning, but follows from the fact that any unitary single qubit operator can be decomposed as a sequence of three rotations around two orthogonal axes. The Euler decomposition rule cannot be derived from any combination of the other ZX-calculus rules [9].

The ZX-calculus as a formal system
The elements of the ZX-calculus, together with their interpretations in terms of matrix mechanics, allow quantum mechanical states and operators to be expressed in diagrammatic form. The rules given in section 3.3 turn this graphical notation into a formal system in its own right, justifying the name "calculus". As such, there are a number of properties of the ZX-calculus that interest us: • Universality: Is any stabilizer state or stabilizer operation expressible as a ZX-calculus diagram?
• Soundness: Does any equation derived in the ZX-calculus hold true when translated back into matrix mechanics? • Completeness: Is any equation between two ZX-calculus diagrams which is true when translated into matrix mechanics derivable using the rules of the ZX-calculus?
Of these properties, soundness is clearly the most important, as a new formalism is of little use if it disagrees with the original. Fortunately, it can easily be checked that the rules of the ZX-calculus are sound, from which it follows that any equality derived in the ZX-calculus is true. Also, the ZX-calculus is indeed universal for stabilizer quantum mechanics. To see this, note that any Clifford operator can be represented by a quantum circuit consisting of controlled-X, Hadamard and phase gates [14]. Any pure n-qubit stabilizer state can be represented by a Clifford operator applied to the state |0 ⊗n . Now both the Hadamard gate and the phase gate can be expressed in the ZX-calculus. Furthermore, it is easy to see that = = is the controlled-X gate. Thus any Clifford circuit can be translated easily into the ZX-calculus. As . . . |0 ⊗n = we can also represent any pure stabilizer state. Postselected Z-basis measurements are given by and π .
Proof. Rewritability follows from straightforward application of the spider rule, the π-commutation rule and the Euler decomposition rule, noting that R ±1 Z = R ∓1 Z Z. Uniqueness is due to the fact that the number of distinct normal forms in (1), namely 24, is exactly equal to |C 1 |.
In the following sections we will show that the ZX-calculus is complete for all stabilizer quantum mechanics.

Graph states and local Clifford operators
Graph states can be represented in the graphical calculus in an especially elegant way.
is an n-vertex graph, is represented in the graphical calculus as follows: • for each vertex v ∈ V , a green node with one output, and • for each edge {u, v} ∈ E, a Hadamard node connected to the green nodes representing vertices u and v.
Proof (Sketch). By definition 8, the graph state determined by a graph G = (V, E) with adjacency matrix θ must be an eigenstate of the operators Now in the ZX-calculus, Z is represented by π and X is π . By the spider law, green phase operators can be moved past any green nodes. Thus, by the π-copy and the colour change laws, the state defined above is indeed an eigenstate of the given operators.
We will occasionally use a white ellipse labelled with the name of the graph as short-hand notation for a graph state in diagrams, i.e. G . . . denotes the state |G .
Example. Let G be the graph The corresponding graph state is the 4-qubit state whose stabilizer group is generated by the operators By proposition 4, the corresponding diagram in the ZX-calculus is where the vertices are rearranged so that the qubits are in the correct order. We check whether this is an eigenstate of the operator using the π-copy law and the spider rule in the first step, the colour change law in the second step, and the spider rule again in the third step. The same process can be applied to the other Pauli operators given above.
Definition 11. A diagram in the stabilizer ZX-calculus is called a GS-LC diagram if it consists of a graph state (cf. proposition 4) with arbitrary single qubit Clifford operators applied to each output. Following [4], we call the Clifford operator associated with one of the qubits in the graph state its vertex operator.

Theorem 5 ([9]
). Let G = (V, E) be a graph with adjacency matrix θ and let G v be the graph that results from applying a local complementation about some v ∈ V . Then the equality

Equivalence transformations of GS-LC diagrams
It is useful to set out explicitly three equivalence transformations of GS-LC diagrams, i.e. operations that take a GS-LC diagram to an equal but generally not identical GS-LC diagram: Local complementation about a qubit v: Let G v denote the graph that results from G through application of the graph-theoretical local complementation about some vertex v ∈ V . Then by theorem 5, where α u = θ uv π/2 for u ∈ V \ {v}. In the following, when we say "local complementation", we usually mean this transformation, which consists of a graph operation and a change to the local Clifford operators. Fixpoint operation on a qubit v: Let v ∈ V , then where α u = θ uv π for u ∈ V \ {v}. This equality holds by the definition of graph states, or, alternatively, by a double local complementation about v. Local complementation along an edge {v, w}: and G = (V, E ) satisfies the following properties This is an equivalence transformation because it consists of three subsequent local complementations on qubits, but it is worth a separate mention because of non-obvious properties like the symmetry under interchange of v and w.

Any stabilizer state diagram is equal to some GS-LC diagram
From standard stabilizer quantum mechanics, we know that any stabilizer state is local Clifford-equivalent to some graph state (cf. theorem 1). In the following, we will show that a corresponding statement holds in the ZX-calculus: any stabilizer state diagram is equal to some GS-LC diagram. The proof of this result is strongly inspired by Anders and Briegel's proof that stabilizer quantum mechanics can be simulated efficiently on classical computers using a representation based on graph states and local Clifford operators [4]. First, note that ZX-calculus diagrams can be decomposed into five types of basic elements.
Lemma 6. Any ZX-calculus diagram can be written as a combination of four basic spiders (2) and the 24 single qubit Clifford unitaries.
Proof. Using the spider law, any green spider with phase 0 can be "pulled apart" into a diagram composed of the four elements given above. By the identity law, cups and caps can be replaced with green spiders.
Any red spider of phase 0 can be turned into a green spider using the colour change law, introducing a Hadamard operator on each leg. Thus any red spider can be written as a combination of Hadamard operators and the basic green spiders.
If a red or green spider has a non-zero phase, it can be decomposed into a phase 0 spider and a single qubit phase operator. Therefore, any diagram in the ZX-calculus for stabilizer quantum mechanics can be written as a combination of the four spiders given in (2) and the 24 single qubit Clifford unitaries.
Theorem 7. Any stabilizer state diagram is equal to some GS-LC diagram within the ZX-calculus.
Proof. For clarity, the proof has been split into various lemmas, which are stated and proved after the theorem.
By lemma 6, any ZX-calculus diagram can be written in terms of five basic elements. Recall that a ZX-calculus diagram represents a quantum state if and only if it has no inputs. Of the basic elements given in lemma 6, is the only one with no inputs. Thus any diagram representing a state must contain at least one such component (or a cup, which can be replaced by spiders). Clearly is a GS-LC diagram. We can now proceed by induction: If, for each of the basic components, applying it to a GS-LC diagram yields a diagram that is equal to some GS-LC diagram, then any stabilizer state diagram is equal to some GS-LC diagram. Lemmas 8, 9, 10, 11 and 12 show these inductive steps. Therefore any stabilizer state diagram can be decomposed into the basic elements and then converted, step by step, into a GS-LC diagram.
Lemma 8. A stabilizer state diagram which consists of a GS-LC diagram and is equal to some GS-LC diagram within the ZX-calculus.
Proof. Adding a vertex to a graph yields another graph, so adding to a graph state diagram yields another graph state diagram. The same holds for GS-LC diagrams.
Lemma 9. A stabilizer state diagram which consists of a single qubit Clifford unitary applied to some GS-LC diagram is equal to a GS-LC diagram within the ZX-calculus.
Proof. This follows directly from definition 11, the definition of GS-LC diagrams.
Lemma 10. A stabilizer state diagram which consists of applied to some GS-LC diagram is equal to a GS-LC diagram or to the zero diagram within the ZX-calculus.
Proof. Call the vertex of the GS-LC diagram to which the post-selected measurement is applied the operand vertex. There are two cases.
The operand vertex has no neighbours: There are six single qubit pure stabilizer states. If the operand vertex is in state π , the result of the measurement is zero. Otherwise the measurement operator combines with the single qubit state to a non-zero global factor, which can be ignored.
The operand vertex has at least one neighbour: It is well known that Z-basis measurements on graph states are easy.
In the ZX-calculus, the Z-basis states are denoted (somewhat counter-intuitively) by red effects: denotes |0 and π represents 1|. By the copy rule, and by the π-copy rule, the same holds for π . Thus if the vertex operator of the operand vertex is H or H π the measured vertex is simply removed from the graph state. Otherwise, we can pick one neighbour of the operand vertex; following [4], this neighbour will be called the swapping partner. A local complementation about the operand vertex adds π/2 to its vertex operator. A local complementation about the swapping partner adds −π/2 to the vertex operator on the operand vertex. Now these two single qubit operators together generate all of C 1 . Note that local complementations about the operand vertex or its swapping partner do not remove the edge between these two vertices. Therefore, after each local complementation, the operand vertex still has a neighbour, enabling further local complementations. Hence it is always possible to change the vertex operator on the operand vertex to H using local complementations. Then, the measurement is easy.
Lemma 11. A stabilizer state diagram which consists of applied to some GS-LC diagram is equal to a GS-LC diagram within the ZX-calculus.
Proof. As before, call the vertex we are acting upon the operand vertex. Again, there are two cases.
The operand vertex has no neighbours: In this case, the part of the diagram representing the nonoperand qubits does not change, hence if it is in GS-LC form originally, it will remain that way. The overall diagram will be in GS-LC form if and only if applied to the operand vertex can be transformed into a GS-LC diagram. Now, the six single qubit stabilizer states can be written as By the spider law, the identity law, and the self-inverse property of the Hadamard operator, α α H H = for α ∈ {0, π/2, π, −π/2}. Using the copy law and the π-copy law, for β ∈ {0, π}, In each of these cases, the right hand side of the equation can easily be seen to be a GS-LC diagram.
The operand vertex has at least one neighbour: Note that = H H so if the vertex operator on the operand vertex is trivial, we just add a new vertex and edge to the graph. Now, as described in the proof for lemma 10, we can use local complementations about the operand vertex and a swapping partner to change the vertex operator on the operand vertex to the identity. Thus whenever we apply to a GS-LC diagram, the result is equal to some GS-LC diagram.
Lemma 12. A stabilizer state diagram which consists of applied to some GS-LC diagram is equal to a GS-LC diagram or the zero diagram within the ZX-calculus.
Proof. As usual, call the qubits to which is applied the operand qubits. This time there are two of them, and there are four cases to consider.
Operand vertices are connected only to each other: Since neither operand vertex is connected to any other vertex, we can neglect all non-operand vertices. Now, for any U,V ∈ C 1 , where W is again in C 1 . Using the π-commutation rule, the colour change law and the Euler decomposition of the Hadamard operator, it is easy to show that any single qubit Clifford unitary can be written as for some α, β , γ ∈ {0, π/2, π, −π/2}. Thus, using the spider law and the Hopf law, Hence if β = π, the resulting diagram is zero, otherwise it is a GS-LC diagram.
One operand vertex has no neighbours: If one of the operand vertices has no neighbours, it must be in one of the six single qubit states given in (3). Now for α ∈ {0, π/2, π, −π/2} and β ∈ {0, π}, Both operand vertices have non-operand neighbours: Denote the two operand vertices by a and b. Pick one of a's non-operand neighbours to be a swapping partner. As laid out in the proof of lemma 10, we can use local complementations about a and its swapping partner to change the vertex operator of a to the identity. We can then do the same for b, picking a new swapping partner from among its neighbours. If a is connected to b or to b's swapping partner, these operations may result in adding some phase operators of the form −π/2 to a's vertex operator. This is not a problem, as green phase operators commute with . Once the vertex operators for both operand vertices are identities or green phase operators, we can move the green phases through the spider and then merge the vertices. Note that One operand vertex is connected only to the other, but the latter has a non-operand neighbour: We can change the vertex operator of the second operand vertex to the identity as in the previous case. In the process, the first operand vertex may aquire one or more non-operand neighbours; in that case we proceed as above. Else, by (4), for any vertex operator V on the first operand qubit,  where W = V • H and we have used the spider law and the Hopf law. Again, if β = π the resulting diagram is the zero diagram, otherwise it is equal to some GS-LC diagram. The four cases we have considered cover all the possible configurations of the graph underlying the original GS-LC diagram, hence the proof is complete.

Reduced GS-LC states
Following [11], we now define a more normalized form of GS-LC diagrams. The resulting diagrams are still not unique, but the number of equivalent diagrams is significantly smaller.

Definition 12.
A stabilizer state diagram in reduced GS-LC (or rGS-LC) form is a diagram in GS-LC form satisfying the following additional constraints: 1. All vertex operators belong to the set 2. Two adjacent vertices must not both have vertex operators that include red nodes.
Theorem 13. Any stabilizer state diagram is equal to some rGS-LC diagram within the ZX-calculus.
Proof. By theorem 7, any stabilizer state diagram is equal to some GS-LC diagram within the ZXcalculus. Lemma 3 shows that each vertex operator in the GS-LC diagram can be brought into one of the forms α β π/2 ±π/2 γ or Note that the cases β = 0 and γ = 0 of the above normal forms correspond exactly to the elements of R, the restricted set of vertex operators given in (5). A local complementation about a vertex v premultiplies the vertex operator of v with −π/2 , so any vertex operator can be brought into one of the forms (5) by some number of local complementations about the corresponding vertex. The other effects of local complementations are to toggle some of the edges in the graph state and to pre-multiply the vertex operators of neighbouring vertices by π/2 . The set R is not mapped to itself under repeated pre-multiplication with green phase operators: this operation sends the set { α } to itself, but it maps ±π/2 The normal form of a vertex operator contains at most two red nodes. Once a vertex operator is in one of the forms in R, pre-multiplication by green phase operators does not change the number of red nodes it contains when expressed in normal form. Thus the process of removing red nodes from the vertex operators by applying local complementations must terminate after at most 2n steps for an n-qubit diagram, at which point all vertex operators are elements of the set R.
With all vertex operators in R, suppose there are two adjacent qubits u and v which both have red nodes in their vertex operators, i.e. there is a subdiagram of the form for a, b ∈ {±1}. A local complementation along the edge {u, v} maps the vertex operator of u to and similarly for v. If a = 1, we apply a fixpoint operation to u and if b = 1, we apply one to v. After this, the vertex operators on both u and v are green phase operators. Vertex operators of qubits adjacent to u or v are pre-multiplied with some power of π . Thus each such operation removes the red nodes from a pair of adjacent qubits and leaves all vertex operators in the set R. Hence after at most n/2 such operations, it will be impossible to find a subdiagram as in (6). Thus, the diagram is in reduced GS-LC form. Proof. Consider first the effect of the two local complementations on the vertex operators of p and q.

Equivalence transformations of rGS-LC diagrams
We have π/2 −π/2 aπ/2 −π/2 (a + 1)π/2 = (a + 1)π/2 (a + 1)π/2 bπ −π/2 and If a = +1, we apply a fixpoint operation to p and if b = 0, we apply a fixpoint operation to q; then the vertex operators of p and q are in R. The fixpoint operations add π to neighbouring qubits, which maps the set R to itself. As fixpoint operations do not change any edges, we do not have to worry about them when considering whether the rest of the diagram satisfies definition 12.
We first need to check that the two local complementations map all vertex operators to allowed ones. Vertices not adjacent to p or q can safely be ignored because their vertex operators remain unchanged. As the local complementations and fixpoint operations add only green phase operators to vertices other than p and q, any vertex operator on another qubit that started out as a green phase will remain a green phase. It remains to check the effect of the transformation on qubits whose vertex operator contains a red node and which are adjacent to p or q. By definition 12, such qubits cannot be adjacent to p. So suppose w is a qubit in the original graph state with a red node in its vertex operator and suppose the initial diagram contains an edge {w, q}. Then the local complementation about q adds a phase factor π/2 to the vertex operator of w and it creates an edge between w and p. The complementation about p adds another π/2 to w and removes the edge between w and q. Thus the vertex operator of w remains in the set R, i.e. the transformation preserves property 1 of the definition of rGS-LC diagrams.
Suppose there are two qubits v, w in the original graph state, both of which have red nodes in their vertex operators and are adjacent to q. Since the original diagram is in rGS-LC form, there is no edge between v and w. Now the local complementation about q adds an edge between v and w and creates edges {p, v} and {p, w}. The local complementation about p removes the edge {v, w}, so once again v and w are not adjacent. Edges involving any qubits that are not adjacent to p or q remain unchanged. Thus the transformation preserves property 2 of definition 12. Hence, the resulting diagram is in rGS-LC form. Proof. After the local complementation along the edge, the vertex operator of p is given by (7). For the vertex operator of q, we have Thus if a = 1, we apply a fixpoint operation to p and if b = −1, we apply a fixpoint operation to q. From the properties of local complementations along edges (see section 4.2) it follows that this transformation preserves the two properties of rGS-LC states.

Comparing rGS-LC diagrams
Theorem 13 shows that any stabilizer state diagram is equal to some rGS-LC diagram. Thus, the ZXcalculus is complete for stabilizer states if, given two rGS-LC diagrams representing the same state, we can show that they are equal using the rules of the ZX-calculus. Again, we follow [11].
Definition 13. A pair of rGS-LC diagrams on the same number of qubit is called simplified if there are no pairs of qubits p, q such that p has a red node in its vertex operator in the first diagram but not in the second, q has a red node in the second diagram but not in the first, and p and q are adjacent in at least one of the diagrams.
Proposition 16. Any pair of rGS-LC diagrams on n qubits can be simplified.
Proof. Suppose there exists a pair of qubits p, q such that p has a red node in its vertex operator in the first diagram but not in the second, q has a red node in the second diagram but not in the first, and p and q are adjacent in at least one of the diagrams. Then in the diagram in which they are adjacent, we can apply the apropriate one of the equivalence transformations given in section 4.5. The equivalence rules do not change the total number of red nodes among the vertex operators. Each such application pairs up red nodes between the two diagrams. Paired up qubits do not participate further in these transformations, therefore in less than n steps the pair of diagrams is simplified.
Lemma 17. Consider a simplified pair of rGS-LC diagrams and suppose there exists an unpaired red node, i.e. there is a qubit p which has a red node in its vertex operator in one of the diagrams, but not in the other. Then the two diagrams are not equal.
Proof. Let D 1 be the diagram in which p has the red node, D 2 the other diagram. There are multiple cases: In either diagram, p has no neighbours: In this case, the overall quantum state factorises and the two diagrams are equal only if the two states of p are the same. But π/2 = bπ/2 π/2 bπ/2 = for α ∈ {0, π/2, π, −π/2} and b ∈ {±1}, so the diagrams must be unequal.
p is isolated in one of the diagrams but not in the other: We know that two graph states are equal only if one can be transformed into the other via a sequence of local complementations. A local complementation never turns a vertex with neighbours into a vertex without neighbours, or conversely. Thus the two diagrams cannot be equal.
p has neighbours in both diagrams: Let N 1 be the set of all qubits that are adjacent to p in D 1 , and define N 2 similarly. The vertex operators of any qubit in N 1 must be green phases in both diagrams. In D 1 , this is because of the definition of rGS-LC states, in D 2 it is because the pair of diagrams is simplified. To both diagrams apply the operation where R p Z denotes π/2 on p, and ∧X v→p is a controlled-X operation with control v and target p. The controlled-X gates with different controls and the same target commute, so this is well-defined. Furthermore, U is invertible, so (in a slight abuse of notation) U • D 1 = U • D 2 ⇔ D 1 = D 2 . We will show that, no matter what the properties of D 1 and D 2 are (beyond the existence of an unpaired red node on p), • in U • D 1 , qubit p is in state or π ; • in U • D 2 , p is either entangled with other qubits, or in one of the states φ , where φ ∈ {0, π/2, π, −π/2}. By the arguments used in the first two cases, this implies that U • D 1 = U • D 2 and therefore D 1 = D 2 .
Let n = |N 1 |, m = |N 1 ∩ N 2 |, and suppose the qubits are arranged in such a way that the first m elements of N 1 are those which are also elements of N 2 , if there are any. Consider first the effect on diagram D 1 . The local Clifford operator on p combines with the R Z from U to where

· · · · · ·
Here, α k ∈ {0, π/2, π, −π/2} for k = 1, . . . , n and we have used the fact that green nodes can be moved past each other. Note that at the end, qubit p is isolated and in the state aπ . Next consider D 2 . As N 2 is not in general equal to N 1 , there may be qubits adjacent to p which do not have controlled-X gates applied to them, qubits which have controlled-X gates applied to them but are not adjacent to p, and qubits which are adjacent to p and have controlled-X gates applied to them. In the following diagram, β and γ 1 , . . . , γ n are multiples of π/2 as usual. The phase β is the combination of the original local Clifford operator on p and the R Z part of U. Similar to before, we do not care about edges that do not involve p. This time we also neglect edges between p and vertices not in N 1 : · · · γ n . . .

· · · · · ·
We will distinguish different cases, depending on the value of β . If β = π/2, apply a local complementation and a fixpoint operation about p. This does not change the edges incident on p: p has no more neighbours and is in the state −π/2 . This is not the same as the state p has in diagram 1, so the diagrams are not equal. Else, after the application of U, p still has some neighbours in diagram 2. Local complementations do not change this fact. Thus the two diagrams cannot be equal. The case β = −π/2 is entirely analogous, except that there is no fixpoint operation at the beginning.
If β = 0, there are two subcases. First, suppose there exists v ∈ N 2 such that v / ∈ N 1 . Apply a local complementation about this v. This operation changes the vertex operator on p to π/2 . It also changes the edges incident on p, but the important thing is that p will still have at least one neighbour. Thus we can proceed as in the case β = π/2. Secondly, suppose there is no v ∈ N 2 which is not in N 1 . Since N 2 = / 0 (N 2 = / 0 corresponds to the case "p has no neighbours in D 2 "), we must then be able to find v ∈ N 1 ∩ N 2 . The diagram looks as follows, where now m > 0 (again, we are ignoring edges that do not involve p): where for the second equality we have applied a local complementation and a fixpoint operation to v and used the Euler decomposition, the third equality follows by a local complementation on p, and the last one comes from the merging of p with the green node in the bottom left. Note that, in the end, p and v are still connected by an edge. None of the operations we ignored in picking out this part of the diagram will change that. Thus, as before, the state of p cannot be the same as in diagram 1. The two diagrams are unequal. The case β = π is analogous to β = 0, except we start with a fixpoint operation on the same qubit as the first local complementation.
We have shown that a simplified pair of rGS-LC diagrams are not equal if there are any unpaired red nodes.
Theorem 18. The two diagrams making up a simplified pair of rGS-LC diagram are equal, i.e. they correspond to the same quantum state, if and only if they are identical.
Proof. By lemma 17, the diagrams are unequal if there are any unpaired red nodes. We can therefore assume that all red nodes are paired up.
Let the diagrams be D 1 and D 2 . Suppose the graph underlying D 1 is G 1 = (V, E 1 ) and that underlying D 2 is G 2 = (V, E 2 ). For simplicity, suppose V = {1, 2, . . . , n}. We can draw the two diagrams as where, for all v ∈ V , α v ∈ {0, π/2} and . Now (W •U) • D 2 can be rewritten as follows Here, the white ellipse labelled G 1 denotes the graph state G 1 with an additional input for each vertex. E 1 E 2 is the symmetric difference of the two sets E 1 and E 2 , i.e. the graph (V, E 1 E 2 ) contains all edges which are contained in either G 1 or G 2 , but not in both. Clearly this is equal to a product of single qubit states only if E 1 E 2 = / 0. That condition is satisfied if and only if E 1 = E 2 , i.e. G 1 = G 2 . Assuming that the underlying graphs are equal, we have and only if D 1 and D 2 are identical. By unitarity of (W •U), this implies that the diagrams D 1 and D 2 are equal if and only if they are identical, as required.

Completeness for stabilizer states
In section 4 we show that any stabilizer state diagram is equal to some rGS-LC diagram. By theorem 18, two rGS-LC diagrams represent the same quantum state if and only if simplifying the pair leads to two identical diagrams. Any rewrite rules used to prove these two results are invertible. Therefore, given two stabilizer state diagrams representing the same state, there exists a sequence of rewrite steps obeying the rules of the ZX-calculus, which transforms one diagram into the other. Thus: Theorem 19. The ZX-calculus is complete for stabilizer states.
There are many stabilizer diagrams which have a non-zero number of inputs, so they are not states and the previous arguments do not apply to them. To extend our results to those diagrams, we make use of the quantum mechanical map-state duality as laid out in the following section.

Map-state duality in the ZX-calculus
Map-state duality, also known as the Choi-Jamiołkowski isomorphism, relates quantum states and linear operators: Theorem 20 (Map-state duality or Choi-Jamiołkowski isomorphism). For any pair of positive integers n and m, there exists a bijection between the linear operators from n to m qubits and the states on n + m qubits.
In the ZX-calculus, states are diagrams with no inputs. Therefore the Choi-Jamiołkowski isomorphism as a transformation consists of just "bending around" the inputs of the operator so that they become outputs. This process can also be thought of as composing the operator with an apropriate entangled state. In the reverse direction, we bend around some of the outputs to become inputs, or alternatively compose the diagram with the apropriate effect.
The isomorphism implies that for any operator A from n to m qubits and for any n + m-qubit state B, This follows directly from the rule that only the topology matters, which allows us to "yank straight" any inputs and outputs.

Completeness for all stabilizer quantum mechanics
We can now assemble the main completeness proof: Theorem 21. The ZX-calculus is complete for stabilizer quantum mechanics.
Proof. By theorem 19 we know that the ZX-calculus is complete for stabilizer states. Now by theorem 20, two operators from n to m qubits are equal if and only if the corresponding n + m-qubit states are equal. Thus, given any two ZX-calculus diagrams that represent the same operator, we can show that the diagrams are equal using the rules of the ZX-calculus via the following sequence of steps: 1. Apply the Choi-Jamiołkowski isomorphism to turn the operators into states. 2. Transform the states into GS-LC and then rGS-LC form. 3. Simplify the pair of rGS-LC diagrams. 4. Apply the Choi-Jamiołkowski isomorphism again to transform the sequence of equal states derived in the previous step back into operators.
As the Choi-Jamiołkowski isomorphism preserves equalities, this yields a sequence of steps which are valid according to the rules of the ZX-calculus and which show that the two operators are equal. Thus, whenever two ZX-calculus diagrams represent the same quantum mechanical state or operator, they are equal according to the rules of the ZX-calculus, completing the proof.
6 Example 6.1 Two ZX-calulus diagrams for the controlled-Z operator In quantum circuit notation, there are two common ways of writing the controlled-Z gate in terms of controlled-NOT gates and different types of single qubit gates. The two quantum circuit diagrams translate straightforwardly to the following ZX-calculus diagrams: π/2 −π/2 π/2 and H H (8) Since these two diagrams have been constructed to represent the same operator, we expect them to be equal. To confirm this, we use the algorithm given in theorem 21.

Applying the equality testing algorithm
To bring the diagrams into GS-LC form, they first need to be mapped to the corresponding state diagrams via the Choi-Jamiołkowski isomorphism. It is useful to note that = = H H H H and to convert the elements of the diagrams into those given in lemma 6 before transforming the diagram to a state. Thus, the first diagram becomes In [8], categorical quantum mechanics is used to analyse the origin of non-locality in stabilizer quantum mechanics as compared to Spekkens' toy theory [18]. This, together with Pusey's work on a stabilizer formalism for the toy theory [15], suggests a "ZX-calculus" for that theory. It would be interesting to see whether the completeness result for the ZX-calculus for stabilizer quantum mechanics can be reproduced in the graphical calculus for Spekkens' toy theory.