In the previous chapter we saw that there were already a lot of interesting things to say about phase-free ZX-diagrams. However, interesting as they are, because there are no phases, these diagrams don’t allow us to do many cool quantum computing things. In this chapter we will remedy this problem and introduce some phases back into the picture. Instead of immediately allowing all possible phases, we will expand our scope to the Clifford ZX-diagrams. These are ZX-diagrams whose angles are all integer multiples of . At first, this might seem somewhat artificial, but we’ll see that in this special setting, even huge diagrams can always be simplified all the way down to a compact canonical form, called GSLC form. It turns out this reduced diagram only has spiders in it and wires, where is the number of qubits. A couple of magical things happen as a consequence. In particular, virtually everything we would want to do with such a diagram is efficient, from computing single matrix elements to comparing two such diagrams for equality. Related to this: any circuit which can be translated into a Clifford ZX-diagram can be efficiently classically simulated. We call such circuits Clifford circuits, and this is (a version of) the famous Gottesman-Knill theorem. Just because we can efficiently reason about Clifford diagrams does not mean they are not useful, far from it! We will see that Clifford diagrams form the backbone in measurement-based quantum computing (Chapter 8) and quantum error correction (Chapter 11). In a standard textbook on quantum computing, Clifford circuits and the technique for efficiently classically simulating them would be introduced in the context of stabiliser theory, a powerful collection of tools based on group-theoretic properties of the Pauli group. These techniques are important and ubiquitous in the quantum information literature, and we’ll go through them in detail in Chapter 6. However, it is interesting to note that we also have a purely graphical bag of tricks based on the ZX-calculus that are extremely useful for working with Clifford circuits, and in fact already suffice to prove the Gottesman-Knill theorem. Thus, in this chapter, we’ll deal with Clifford circuits using just the ZX-calculus.
In the previous chapter, we established a close correspondence between CNOT circuits and phase-free ZX-diagrams (see Section 4.2). Namely, we saw that any CNOT circuit translates into a phase-free ZX-diagram, and conversely any unitary phase-free ZX-diagram is equal to a CNOT circuit (Theorem 4.2.13). In this chapter we will see that a similar relationship exists if we generalise from only allowing the phase to allowing phases from the set . On one side of this correspondence, we have the following family of ZX-diagrams.
Definition 5.1.1. A Clifford ZX-diagram is a ZX-diagram where all the phases on the spiders are integer multiples of .
On the other side, we have a certain family of circuits, which generalises CNOT circuits.
Definition 5.1.2. A Clifford circuit is a circuit constructed from the following gates:
We will also refer to unitaries that can be built by composing these gates as Clifford unitaries.
It immediately follows that any Clifford circuit yields a Clifford ZX-diagram (as the Hadamard can be decomposed into a series of rotations, see Eq. (3.81)). That any unitary Clifford ZX-diagram can be realised by a Clifford circuit is less obvious, and proving this will in fact be one of the primary goals of this chapter.
Exercise 5.1. A single-qubit Clifford circuit is constructed out of just Hadamard and gates. Show that any single-qubit Clifford circuit can be rewritten to the form
for some integers , and . Hint: We know that a single or Hadamard can be brought to this form. So you just need to show that when you compose this normal form with an additional or Hadamard gate that the resulting circuit also be brought to this normal form. You probably will want to make a case distinction on the value of .
Exercise 5.2. Show that the following states are Clifford states. I.e. construct a Clifford circuit that when applied to gives the desired state.
.
.
.
.
.
When dealing with phase-free diagrams it turned out to be useful to simplify our diagrams somewhat in order to work more easily with them: we fused all the spiders and got rid of self-loops and double edges to get diagrams that we called two-coloured (Definition 4.2.3). In this chapter it will be useful to introduce a variation on this that allows us to more easily work with Hadamards. This type of diagram only contains Z-spiders. This can be achieved by changing the colour of every X-spider using the Hadamard colour-change rule . We can then cancel all double Hadamards that appear by the rule and fuse all connected Z-spiders using . In the resulting diagram all connections of spiders will then go via a Hadamard. It will be useful to have a special name and notation for this.
Definition 5.1.4. When two spiders in a ZX-diagram are connected via a Hadamard, we can denote this using a blue dotted line:
| (5.1) |
We call such a connection a Hadamard edge.
Hadamard edges have a couple of useful properties. First, we only have to deal with at most a single Hadamard edge between a pair of spiders, since any parallel pair of Hadamard edges cancels.
Second, we can always remove a “Hadamard edge self-loop.”
Proof. This is just Eq. (3.83). □
Now let’s give the definition of this special class of diagrams we are interested in.
Definition 5.1.7. We say a ZX-diagram is graph-like when
Every ZX-diagram can be efficiently reduced to an equivalent graph-like diagram.
Proposition 5.1.8. Let be an arbitrary ZX-diagram. Then the following sequence of steps reduces efficiently to an equivalent graph-like diagram.
Convert all X-spiders to Z-spiders using the rule.
Cancel all pairs of adjacent Hadamards using the rule.
Fuse all spiders by applying the rule until it can no longer be applied.
Remove parallel Hadamard edges using Lemma 5.1.5.
Remove self-loops using Eq. (3.39), and remove Hadamard self-loops using Lemma 5.1.6.
Introduce Z-spiders and Hadamards using and in reverse, in order to ensure every input and output is directly connected to a Z-spider and no Z-spiders are connected to multiple inputs/outputs.
Proof. It is clear that after this procedure there are only Z-spiders, as all X-spiders have been converted. Every connection between spiders must be via a Hadamard edge, since if it were a regular connection, then the spiders would have been fused in step 3, and if there were multiple Hadamards on the connection, then pairs of them would be cancelled in step 2. There is at most one Hadamard edge between each pair of spiders because of step 4, and there are no self-loops because of step 5. It could now still be that we have input/output wires that are connected via a Hadamard to a Z-spider, or wires that are not connected to a spider at all. We take care of these cases as follows:
Similarly, if a Z-spider is connected to multiple inputs or outputs, we can introduce an extra Z spider and a pair of Hadamards to fix it up:
Each of the steps of this algorithm touches each vertex or edge at most once, and hence this is all efficient in the size of the diagram. □
Example 5.1.9. We demonstrate how an example ZX-diagram is transformed into a graph-like diagram below. In the last step we write down its underlying graph.
The reason we call these diagrams graph-like is because they are neatly described by a structure that we call an open graph, a graph with a specified list of inputs and outputs. We will have more to say about open graphs in Chapter 8. For now, let’s just note that we can view each spider in a graph-like diagram as a vertex, and every Hadamard as an edge.
Show that every two-coloured diagram (see Definition 4.2.3) is transformed into a graph-like diagram by changing all the X-spiders into Z-spiders using , and then potentially introducing some more identities with and to the input and output wires.
Show that the converse is not true: find a graph-like ZX-diagram where it is not possible to rewrite it back into a two-coloured diagram using just .
Find a systematic way in which a graph-like diagram can be transformed into a two-coloured diagram.
A particularly useful subset of graph-like diagrams are the graph states. We can either describe these diagrammatically as a restricted set of graph-like diagrams, or directly as a type of quantum state. We will give the description as a quantum state first. For each simple undirected graph , where denotes the set of vertices of the graph, and the set of edges, we can define its corresponding graph state as
I.e. we prepare the state, where the number of qubits is equal to the number of vertices in the graph, and then for every edge in we apply a CZ gate between the corresponding qubits (recall the CZ from Exercise 2.13). A state as a ZX-diagram is just a phase-free Z-spider with a single output. A CZ gate is a pair of Z-spiders connected via a Hadamard gate:
To go from a graph to a graph state represented as a ZX-diagram is then straightforward:
| (5.2) |
Here we get the diagram on the right by simply fusing all the spiders together. To go from a graph to the graph state represented as a ZX-diagram we see then that every vertex becomes a phase-free Z-spider with an output attached to it and each edge in the graph becomes a Hadamard edge between the corresponding spiders. With this description in hand we can also define a graph state as a particular type of graph-like diagram (spend some time convincing yourself that this definition is indeed equivalent to the description given above):
Definition 5.1.10. A graph-like diagram is a graph state when
Some useful quantum states are not exactly graph states, but are instead merely very close to being a graph state. For instance, the GHZ-state (cf. (3.40)), is not a graph state, but we can construct it by starting with a graph state and then applying some Hadamard gates on a couple of the qubits:
| (5.3) |
In the context of graph states, we refer to the application of single-qubit unitaries on some of its outputs as local unitaries. Imagine for instance some quantum protocol where we start with a bunch of qubits in one spot, which are then entangled to make a graph state. We then give each of the qubits of this graph state to a different person, who are then allowed to take their qubit very far away from the others. While each of these people can’t change the graph state by applying some operation on multiple qubits at once, they can still modify the qubit they have access to by applying a unitary on just that qubit. Hence why we refer to single-qubit operations as ‘local’. Note furthermore that the operation we had to apply in the case of the GHZ state was not just any unitary but specifically a Clifford unitary. This leads us to our next definition of a useful subclass of states and ZX-diagrams.
Definition 5.1.11. A graph state with local Cliffords (GSLC) is a graph state to which some single-qubit Clifford unitaries have been applied on its outputs.
We will often say a ZX-diagram is in GSLC form or (at the risk of sounding like the kind of people that say “ATM machine”) that a quantum state is a GSLC state. Every single-qubit Clifford unitary can be written as a composition of three phase gates where the phases are multiples of (cf. Exercise 5.1). So an example of a GSLC state would be a composition of the graph state of (5.2) with any or phase gates:
Where here the Hadamard gate on the top qubit is a number of phase gates in disguise.
Exercise 5.4. Show that the graph state (5.2) is a Clifford state by finding a Clifford circuit that builds it when applied to .
Exercise 5.5. A graph state has no internal spiders, but a general graph-like diagram does. Show that any graph-like diagram with no inputs (i.e. a state) can be written as a graph-state where each internal spider becomes a post-selection by adapting the arguments from Section 3.4.1.
Now that we have all the tools we need, we will see how we can systematically simplify Clifford diagrams. Instead of rewriting arbitrary diagrams, we will work with graph-like diagrams. Thanks to Proposition 5.1.8, we can translate any ZX-diagram into a graph-like one, so we can do this without loss of generality. Because graph-like ZX-diagrams are pretty much just graphs with a bit of extra stuff, we can use some techniques from graph theory to simplify them. Before we do this in the general case, it pays to first look at the special case of GSLC states.
When looking at a graph state it might seem at first glance that the presence or absence of an edge between two qubits determines whether those qubits are entangled. Considering again the scenario where we have prepared a graph state and sent each of the qubits far away from each other. This might then seem to mean that there is no way in which we can get any more entanglement between these qubits. However, the structure of entanglement in a graph state can be deceiving. It turns out that just applying local Cliffords can greatly affect the connectivity of the underlying graph. For instance, in Eq. (5.3) we saw that we can represent a GHZ state as a graph state with some local Cliffords. Because the GHZ is of course symmetric in all three qubits, that means we can do this in three equivalent ways, and hence the following graph states are all equal up to the application of some local Cliffords:
A natural question is then how we can find out when two graph states can be transformed into each other just using local Clifford operations. One important graph transformation we can do just by using local operations is the local complementation.
Definition 5.2.1. Let be a graph, and a vertex in . The local complementation of about , which we write as , is the graph which has the same vertices and edges as , except that the neighbourhood of is complemented. In other words, two neighbours and of are connected in if and only if they are not connected in .
Example 5.2.2. Consider the graph below with vertices . In we see that the neighbourhood of , consisting of the vertices is complemented. So because and are not connected in , they are connected in , and because and are connected in , they are not in . In we see that the connection between and is not affected, as is not a neighbour of .
To transform a graph state so that its underlying graph is locally complemented about a vertex (i.e. qubit) , we only need to apply a gate on , and a gate on each of its neighbours:
| (5.4) |
Here denotes the neighbourhood of . In the remainder of this section we will prove that (5.4) indeed holds. To do this it will be helpful to introduce the family of fully connected ZX-diagrams.
Definition 5.2.3. We define to be the fully connected ZX-diagram on qubits, defined recursively as:
| (5.5) |
When we fuse all the spiders in we see that they indeed give totally-connected graphs of Hadamard edges:
Using this definition of we can state the equality that will allow us to do local complementations:
Before we prove this, see Example 5.2.5 for a demonstration of how this is related to doing local complementations. The crucial point is that the introduction of a fully connected graph by Eq. (5.6) makes a parallel Hadamard edge if there was already a Hadamard edge present, which is then subsequently removed by Lemma 5.1.5.
Example 5.2.5. Let us take the graph from Example 5.2.2, but now seen as the graph state .
We indeed end up with (up to local Cliffords).
For the proof of Lemma 5.2.4 we will need the following base case.
Exercise 5.6. Prove the following using the ZX-calculus.
| (5.7) |
Hint: Push the rightmost Hadamards to the right and decompose the middle Hadamard using one of the versions of the Euler decomposition from Exercise 3.12 to reveal a place where you can apply strong complementarity.
And now we can prove the general case.
Proof of Lemma 5.2.4. Note that for and this equation becomes:
Exercise 5.6 shows . We prove the other cases by induction. For our induction hypothesis, assume (5.6) holds for some fixed , which we indicate as (ih) below. Then, for we calculate:
Exercise 5.7. We say two -qubit quantum states and are equivalent under local operations when for a local quantum circuit consisting of just single-qubit gates. Show that the following two graph states are equivalent under local operations.
Hint: Use the fact that a local complementation can be done using just local unitaries.
It turns out that it is often useful to not just do a single local complementation, but to do a particular sequence on a pair of connected vertices.
Definition 5.2.6. Let be a graph and let and be a pair of connected vertices in . We define the pivot of along , written as , as the graph .
Note that in this definition, the ordering of and does not matter.
On a graph, pivoting consists in exchanging and , and complementing the edges between three particular subsets of the vertices: the common neighbourhood of and (i.e. ), the exclusive neighbourhood of (i.e. ), and exclusive neighbourhood of (i.e. ). Schematically:
As a pivot is just a series of local complementations, it can also be performed on a graph state by the application of a particular set of local Cliffords. Indeed, in terms of ZX-diagrams, we have:
| (5.8) |
I.e. we can perform a pivot on the graph state by applying a Hadamard to the vertices we pivot along, and applying a Z gate to the vertices in their common neighbourhood.
Exercise 5.9. Prove Eq. (5.8) by decomposing the Hadamards into sequences of phase gates and then applying a sequence of local complementations using Eq. (5.4).
It turns out we can prove (5.8) more directly by using strong complementarity.
Lemma 5.2.7. Eq. (5.8) holds in the ZX-calculus.
Proof. For clarity, let us first assume that the set of vertices connected to both and is empty.
| (5.9) |
We see that ends up connected to whatever was connected to and vice versa, and that the neighbourhoods of and are now fully connected, so that if there were connections they will get complemented in the same way as described in Example 5.2.5. Now, if there are spiders that are connected to both and , then we can unfuse spiders in a clever way to reduce it to the previous case:
For clarity we have only drawn the Hadamard edges that stay within the joint neighbourhood of and in the bottom two diagrams. We see that we end up with parallel Hadamard edges that can be removed using Lemma 5.1.5. The Hadamard self-loops are simplified to phases using Lemma 5.1.6, which indeed gives the expected result. □
In Sections 5.2.1 and 5.2.2 we saw that we can apply the graph operations of local complementation and pivoting on graph states by introducing some local Cliffords. It turns out that we can use some variations on these rules to greatly simplify graph-like diagrams. As this chapter deals with Clifford diagrams, we will focus here on the variations that are useful to simplify these diagrams, but later on we will introduce some additional variations that can also simplify generic graph-like diagrams. The rules we introduce in this section all serve to remove one or more spiders from a Clifford diagram. By repeatedly applying these rules we then get smaller and smaller diagrams until there are no longer any spiders to remove using these rules. For these rewrite rules it will be useful to introduce a distinction between two classes of spiders in graph-like diagrams (see also Definition 4.2.5).
Definition 5.2.8. Let be a graph-like diagram. We say a spider in is internal if it is not an input or output spider (i.e. it is not connected to any input or output wire). Conversely, we say a spider is a boundary spider when it is connected to at least one input or output wire.
Our first simplification rule is based on the local complementation rule (5.6).
Proof. We pull out all of the phases via then apply the local complementation rule (5.6) (from right to left) on the vertex marked by :
Using Eq. (3.84), the topmost spider in the right-hand side above becomes an X-spider, with phase , which combines with the phase below it into an phase, where if we started with and if we had started with . The resulting X-spider copies and fuses with the neighbours:
In words we can describe this rule as follows: if we have a spider (here marked on the left-hand side by a ) with a phase in a graph-like diagram that is internal, i.e. that is not connected to inputs or outputs but only to other spiders, then we can remove it from the diagram by complementing the connectivity on its neighbourhood and changing some phases. The reason we complement the neighbourhood, is because in Lemma 5.2.9 we get a fully connected graph on the right-hand side, but if there were already edges present between some of the spiders, then the resulting double edges would be removed by Lemma 5.1.5, so that we indeed complement the edges in the neighbourhood. For the remainder of this chapter, when we say we ‘apply’ Lemma 5.2.9 we mean that we apply it from left to right on some chosen vertex, and that we immediately follow it by Lemma 5.1.5 in order to cancel the introduced parallel edges, so that we are still left with a graph-like diagram.
Remark* 5.2.10. In this rule we ignored non-zero scalar factors (like we always do). However, when we applied Eq. (3.84), the actual equation with the correct scalar, Lemma 3.6.8, introduces an additional scalar spider. So in this sense, Lemma 5.2.9 is not really removing the spider, as it is just interchanging it for a spider that is not connected to any other spider, and hence is just a simple scalar. This is important for when we discuss completeness in Section 5.5.
In a Clifford diagram each spider has a phase for some . Using the rule above repeatedly on a graph-like Clifford diagram we can remove all internal spiders with a phase. Hence, the only internal spiders that remain are those that have a or phase. Most of these internal spiders can also be removed, by using a variation on the pivot rule (5.8).
Proof. We pull out all of the phases via and apply the pivot rule Lemma 5.2.7:
We then apply the colour-change rule to turn the Z-spiders with phases and into X-spiders. They can then be copied, colour-changed again and fused with their neighbours:
Note that the dangling scalar diagram appears because we copy twice and the vertices are connected. We simply ignore this non-zero scalar. □
Here, the marked spiders on the left-hand side are internal connected spiders with a or phase. On the right-hand side, these spiders are removed, at the cost of complementing their neighbourhood in the manner described by the pivot rule, and introducing some phases (again, the complementation happens because fully connected bipartite connectivity is introduced, and parallel edges are then removed using Lemma 5.1.5).
Exercise 5.10. Simplify the following circuit to a diagram that has no internal spiders with a phase or pairs of internal spiders with a or phase.
These simplification lemmas allow us to remove many of the spiders in a Clifford diagram. In fact, so many that the resulting types of diagrams deserve to be called normal forms for Clifford diagrams. In this section we will see two types of normal forms. The first is what you get if you just keep applying the local complementation and pivoting simplifications. The second requires an additional type of pivot operation that removes the final internal spiders.
Lemma 5.2.9 removes those internal spiders with a phase of so that if we started with a Clifford diagram, the only phases left on internal spiders are are . Then Lemma 5.2.11 can apply to any remaining internal spider that is connected to at least one other internal spider. Hence, once we are done applying Lemmas 5.2.9 and 5.2.11 on a Clifford diagram the only remaining internal spiders are then those that carry a or phase and are connected only to boundary spiders. These diagrams turn out to be rather useful, so let’s give them a name.
Definition 5.3.1. We say a graph-like Clifford diagram is in affine with phases form (AP form) when:
every boundary spider is connected to exactly one input or output,
every internal spider has a phase of or , and
no two internal spiders are connected to each other.
Our previous summary of the simplification procedure can then be summarised as follows.
In an AP form we have two groups of spiders. We have the boundary spiders and we have the internal spiders. The boundary spiders can be connected to any other spider (via a Hadamard edge) and carry any phase, but the internal spiders are only connected to the boundary spiders and can only have a phase of or .
Thanks to condition 1 of Definition 5.3.1, AP forms don’t treat inputs and outputs differently. Thus, from hence forth we will primarily study states in AP form. Here, we implicitly use the fact that we can treat arbitrary AP form maps as states by ‘bending wires’ to turn inputs into outputs. For example, the map from Example 5.3.3 can be treated as a state as follows:
Why do we call these diagrams ‘affine with phases’? To answer this we need to look at what types of states they encode. There are a couple of different things going on here, so for simplicity we’ll start with just the ‘affine’ part of AP forms then build up to the general case. Recall from Section 4.3.2 that a phase-free X-Z normal forms give us a state defined by a system of linear equations:
Importantly, is always defined by a homogeneous system of linear equations, meaning the right-hand side of every equation is 0. Equivalently, it is the set of bit vectors satisfying for some -matrix . We can generalise this form by additionally allowing the X spiders to carry or phases. This gives us almost the same thing, except now can be defined by an inhomogeneous system of linear equations. Each X spider with a phase gives us an equation with a on the right-hand side, whereas an X spider with a phase gives us an equation with a on the right-hand side. For example:
| (5.11) |
That is, we get the set of vectors satisfying for some fixed matrix and vector . In the example above, its:
Whereas the set of all solutions to a system of homogeneous linear equations always gives us a linear subspace of , the solutions to an inhomogeneous system will, in general, form an affine subspace. Intuitively, an affine subspace is like a linear subspace that has been shifted away from the origin by some fixed amount.
Definition 5.3.4. An affine subspace is either:
Just like in the case of linear spaces, we have two equivalent representations for an affine subspace, either in terms of a spanning set of vectors or a system of equations. As before, these correspond to Z-X normal forms and X-Z normal forms, respectively. In both cases, the extra data needed to define an affine space (as opposed to a linear one) is included by introducing phases on to some of the X spiders.
| (5.12) |
As before, we have decorated spiders with vectors to mean that there is an edge to the -th spider if the -th entry of the associated vector is 1. Note the second row is a general form for (5.11), since gives the XOR of the variables for which . Equivalently, the vectors correspond to the rows in a matrix such that .
Exercise 5.11. The bit strings appearing in the superposition in an AP state are described by the solutions to the affine system of equations . When we do row operations on and (as in a Gaussian elimination of the linear system) this does not change the solutions, and so this transformed system should still describe the same state. As the matrix corresponds to the connectivity of the internal spiders to the boundary spiders, show that these row operations can be implemented diagrammatically:
If we colour-change the X spiders, we see that we’re most of the way to an AP form:
| (5.13) |
Hence, if we do not have phases on the outputs or Hadamard edges between them, an AP form can always be described by an affine subspace. For a generic AP form, by spider (un)fusion, we can split off the affine part from the rest, which we’ll call the ‘phase’ part:
The reason for the name is that the ‘phase’ part always forms a diagonal unitary, which means all it will do to the state is introduce some phases on the computational basis states from (5.13). By unfusing some spiders, we can see that this phase part is generated by S gates, which introduce phases to individual outputs, and CZ gates, which introduce Hadamard edges between outputs. We can see that each of these gates affects the phase in a way that depends on the computational basis state:
We can describe the action of unitaries built out of these gates using certain polynomials, called phase polynomials. For example:
Here, each single-qubit gate (i.e. the gate on the first qubit and the gate on the second) contributes a linear term to , whereas each two-qubit CZ gate contributes a quandratic term, whose coefficient is always even. Note that, even though these polynomials can contain products of variables, they are always linear in each argument individually. For that reason, we call these phase polynomials in multilinear form. In Chapter 7 we will see phase polynomials in XOR-form, and in Chapter 9, we will see how these two forms are related. By applying a diagonal Clifford unitary to an affine state, the phase is applied to each of the terms in the same. So, if we combine the example above with (5.13) we get:
| (5.14) |
Exercise 5.12. Reduce the following diagram to AP-form:
What is its parity matrix and its phase polynomial?
In a diagram in AP form there are still some internal spiders. It turns out that we can actually also get rid of these. However this does come at a cost: we must then allow Hadamards on input and output wires, so that the diagram is not what we have defined to be a ’graph-like diagram’. Just as it was useful to define a ‘graph state with local Cliffords’, it will be useful here to define a diagram that is graph-like up to Hadamards on the boundary wires.
Definition 5.3.5. We say a diagram is graph-like with Hadamards when it satisfies all the conditions for being graph-like (Definition 5.1.7), except that inputs and outputs are also allowed to be connected to Z-spiders via a Hadamard.
Note that a graph-like diagram with Hadamards can be easily transformed into a graph-like diagram by introducing some additional Z-spiders using the rule. So how do we get rid of the final internal spiders in a Clifford diagram? Note that each of those spiders has a or phase and is only connected to boundary spiders (in particular, it is connected to at least one boundary spider, since otherwise it would just be a floating scalar we can ignore). The first step is to introduce some dummy Hadamards and identity spiders to make this boundary spider into an internal spider:
| (5.15) |
The diagram is now no longer just graph-like, but graph-like with Hadamards and the spider with the phase has become internal. Then we make two case distinctions. If or , we have an internal pair of / spiders, and we can remove them using the pivot simplification Lemma 5.2.11. If , then we can first remove that spider using the local complementation Lemma 5.2.9. As a result of this, the phase of the spider with the phase becomes so that its phase is also . We can then also remove this spider using local complementation. In both cases we see that we can remove both spiders, and hence that we get rid of the original internal spider. Note that in the second case, when , the other spiders it is connected to also gain a phase, so that this might also give some additional opportunities to remove internal spiders using local complementation. We can repeat this procedure for any remaining internal spider. This might result in multiple Hadamards appearing on the same input or output wire. In that case we can of course cancel these Hadamards using . Combining the simplifications so far we see that we can hence actually remove all internal spiders in a Clifford diagram. Let’s give a name to such a type of diagram.
Definition 5.3.6. We say a Clifford diagram is in GSLC form when it is graph-like with Hadamards and has no internal spiders.
As before, GSLC here stands for graph state with local Cliffords. This is a fitting name, because states in GSLC form are graph states with local Cliffords as defined in Definition 5.1.11. Indeed, if we have a state, so a diagram with no inputs, that is in GSLC form, then every spider must be connected to an output, possibly via a Hadamard, so after unfusing the phases on the spiders, we see that it is indeed a graph state followed by some single-qubit Clifford unitaries:
Let’s summarise what we have shown in a proposition.
Proposition 5.3.7. Any Clifford diagram can be efficiently rewritten to an equivalent diagram in GSLC form.
As a consequence of this, all Clifford states, those states that can be produced from applying a Clifford unitary to , must be equal to graph states with local Cliffords.
Theorem 5.3.8. Let a Clifford unitary (i.e. a circuit consisting of CNOTs, Hadamards and gates). Then is a graph state with local Cliffords.
Proof. We can easily represent as a Clifford diagram. Proposition 5.3.7 shows it can be reduced to GSLC form. Unfusing the phases then transforms this into a graph state with local Cliffords. □
In fact, we have something even stronger: we can apply the Clifford circuit to , and then also post-select some outputs to be (or , or for that matter), and still have a graph state with local Cliffords.
Proposition 5.3.9. Let be a state produced by applying a Clifford unitary to , and then post-selecting some qubits to . Then is (proportional to) a graph state with local Cliffords.
Proof. The rewrite strategy to bring the diagram to GSLC form works regardless of how we produced the Clifford ZX-diagram, so we can still apply it in this setting. □
This means that allowing Z-basis measurements on Clifford states doesn’t give us something more general or powerful: we get exactly the same class of states. Finally, let us write down an equivalence between two different notions of Clifford states.
Proposition 5.3.10. Let be a Clifford diagram without inputs (i.e. a state). Then is equal to a Clifford state for some Clifford unitary .
Proof. Rewrite to GSLC form so that it is a graph state with local Cliffords, and then build as the circuit that transforms into that graph state plus the local Cliffords. □
In the previous section we saw that if we simplify a Clifford state, that we get a graph state with local Cliffords. What happens if we simplify a Clifford unitary in the same manner? Again, there are no internal spiders in the diagram, so each spider must be connected to at least one input or output. By introducing some dummy spiders we can ensure that each spider is connected to exactly one input or output. The diagram will then look something like the following:
We have possible Hadamards on the inputs and outputs as our reduced diagram is graph-like with Hadamards. Each spider can carry a phase, and each spider is connected to exactly one input or output, so that we have two layers of spiders. There are no further (obvious) restrictions for how the spiders can be connected via Hadamard edges. We will now investigate how we can make diagrams like this look more like circuits. First, note that we can unfuse the phases on both sides so that the Hadamards and the phases form a layer of local Cliffords:
Second, we can unfuse the connections between the spiders in the same layer. This reveals those connections to be CZ gates:
It remains to see what is happening in the middle-part of the diagram. This should become clear once we change the colour of the layer of spiders on the right:
| (5.16) |
We recognise this middle part of the diagram as a parity normal form (Definition 4.2.2)! So far, all the steps we have done on this GSLC diagram work regardless of whether the diagram is unitary. However, when the diagram is unitary, then this parity normal form must represent a unitary matrix itself, and hence by Proposition 4.2.12, it is equivalent to a CNOT circuit. Summarising this analysis of GSLC unitary diagrams we see that we can represent any Clifford unitary as a particular sequence of gates.
Theorem 5.3.11. Let be a Clifford unitary. Then can be written as a circuit consisting of 8 layers of gates in the following order:
This is really surprising! For one thing, before we started this chapter you might think there are an infinite number of different unitaries you can build from the Hadamard, S and CNOT gate, as you can just make longer and longer circuits, but this result shows that we can always reduce such a long circuit to one consisting of just a few layers of gates. In particular, we need at most a quadratic number of gates in terms of the number of qubits.
Proposition 5.3.12. Any -qubit Clifford unitary can be represented by an equivalent circuit consisting of at most Hadamard, and CNOT gates.
Proof. A layer of Hadamard gates contains at most gates, and there are three of those. Each layer of gates has at most gates per qubits, corresponding to an , or gate, and there are again two of those layers. Hence, the single-qubit gates contribute at most gates. A circuit of CZ gates contains at most CZ gates (corresponding to all possible pairs of qubits there can be a CZ between). A CZ gate can be constructed from a CNOT and two Hadamards, and hence each CZ layer, of which there are two, contributes at most gates. The number of CNOTs needed in the CNOT circuit corresponds to how many Gaussian elimination row operations are needed to fully reduce the associated parity matrix. It is a little exercise to show that you need at most row operations to fully reduce any matrix. The total number of needed Hadamard, and CNOT gates is then:
Corollary 5.3.13. For any given number of qubits, there are only a finite number of different Clifford unitaries.
Exercise 5.13. Using Theorem 5.3.11, give an upper-bound on the number of different -qubit Clifford unitaries for any . Hint: See Section 4.5.1 for how you can count this.
We can also conclude another interesting fact from this extraction of a circuit from a GSLC normal form. The simplification procedure to get to this GSLC normal form works for any Clifford ZX-diagram, i.e. any ZX-diagram whose phases are multiples of , not just those coming from a Clifford circuit. If such a diagram happens to be unitary, then we can use the procedure above to transform it into a Clifford circuit. Hence, the following proposition immediately follows.
Exercise 5.14. Show that any Clifford ZX-diagram of an isometry can be transformed into a Clifford circuit with some ancilla qubits in state . That is, there exists come Clifford circuit such that , or graphically:
Hint: See Exercise 4.6.
Exercise 5.15. In Theorem 5.3.11 we had three layers of Hadamards. It turns out we only need two, because we can get rid of either the first or last one by doing some additional rewriting before extracting a circuit. To start, let’s assume we have a unitary Clifford ZX-diagram in GSLC form. We are going to progressively remove Hadamards on its input wires.
Suppose we have an input spider with a Hadamard on it, and that the phase of the spider is . Show that we can remove this Hadamard by doing a regular, non-vertex-removing, pivot (5.8) between this input and an output it is connected to. Why will it always be connected to an output? Argue that this does not introduce any Hadamards on other inputs.
Suppose we have an input spider with a Hadamard on it, and that the phase of the spider is . Show that you can remove the Hadamard by using a Euler decomposition and removing the resulting phase using a regular local complementation (5.4). Show that you can rewrite the diagram back into GSLC form, but now with one fewer Hadamard on an input wire.
Argue that if you do these steps for all the inputs with Hadamards on them, that you get a GSLC form diagram where extracting a circuit does not give any Hadamards in the first layer.
In the previous sections we saw that we can use two simple rewrites, local complementation and pivots, to reduce Clifford states to graph states with local Cliffords, and Clifford circuits to a normal form consisting of just a few layers of gates. There is a third class of relevant Clifford diagrams that we can simplify using these rewrite rules: scalars. Recall that a scalar diagram is any ZX-diagram that has no inputs or outputs. The reason we care about scalar diagrams is because they can represent amplitudes of a quantum computation. If we start with the basis state , then apply a unitary , and finally wish to know the amplitude of the state with respects to some computational basis effect we get the scalar . In our case we are interested in ’s that are Clifford unitaries, so that the resulting scalar ZX-diagram is also Clifford. So what happens if we feed a scalar Clifford diagram to the simplification procedure described in Section 5.2? Remember that the procedure allowed us to remove any internal Clifford spider. However, in a scalar Clifford diagram, all spiders are internal and Clifford, so after we are done simplifying there will be no spiders left! The diagram will have been simplified away completely. What does this mean? The empty diagram evaluates to the scalar . However, remember that all our rewrites also introduce some scalar factors, which in the case of Clifford diagrams are always multiples of and . So the end result is just a number, which is equal to the amplitude we were calculating. Let’s summarise all this in a proposition.
Proposition 5.4.1. Let be a Clifford circuit, and let for be any computational basis effect. Then we can efficiently calculate the amplitude .
This is really surprising! Clifford circuits contain essentially all the features we would expect from a quantum computation—entanglement, superpositions, and negative and complex amplitudes—and we can use Clifford circuits to realise many truly quantum protocols such as quantum teleportation or quantum key distribution, and yet, such circuits offer no computational benefit over classical computers. This result is known in the literature as the Gottesman-Knill theorem.
Gottesman-Knill theorem: A Clifford computation can be efficiently classically simulated.
Why is this the case? Well, on the surface we see it’s because we can just rewrite the corresponding diagrams very well. But why is it that we can do that? A hint is given by the affine with phases normal form of Clifford states. Apparently, Clifford circuits can only produce quantum states that are uniform superpositions of computational basis states that are efficiently described by an affine subspace of bit strings. This means there is a limit to how much we can actually use the complex amplitudes and entanglement present in Clifford states. There is for instance no way in which we can iteratively repeat a procedure to slowly add more and more amplitude to certain states like is done in Grover’s algorithm: the amplitudes are always distributed equally.
In Proposition 5.4.1 we said we could simulate a Clifford amplitude efficiently, but how efficient are we talking? The entire ‘simulation’ just consists of diagram simplification operations, so the complexity of the method, how expensive it is to actually calculate an amplitude, comes down to how hard it is to find the correct rewrite rule to apply, the number of rewrites we need to do, and how hard these rewrites are to perform. The first two of these questions are easily answered. First, how hard is it to find the correct rewrite rule to apply? Well, local complementation applies to any spider with a phase, so we simply have to loop over the spiders of the diagram until we encounter a spider with the correct phase. When we are done doing local complementations, any spider will have a or phase left, so all the spiders are suitable for a pivot, and we only need to look at any neighbour, so that finding a place where we can apply a rewrite rule is quite trivial in this setting: we can do it anywhere. The second question, how many rewrite rules need to be applied, is also easily answered. Each of the rewrite rules, local complementation and pivoting, removes at least one spider, so that the number of rewrite rules applied is bounded by the number of spiders. Finally, how hard is it actually to change the diagram based on the rewrite rules? We will measure this in terms of the number of elementary graph operations we need to perform: vertex and edge additions or removals. When we do a local complementation, we remove a single vertex, and we toggle the connectivity of all its neighbours. In the worst case, the spider we wish to remove is connected to pretty much all other spiders. In this case we end up changing the connectivity of the entire graph. So if there are spiders, then this could cost edge additions and removals. A similar cost estimation holds for pivoting: we remove two spiders, and we toggle connectivity between three groups of spiders that could also pretty much encompass the entire graph, so that it also costs graph operations to implement a pivot. So a single simplification costs about elementary graph operations in the worst case, and as we’ve seen, we will need about rewrite rules to fully simplify the graph, which means we will need graph operations in the worst case. In comparison to this, the cost of finding the right rewrite rules to apply is negligible (adding at most an cost to the application of every rewrite rule). We can now state a more detailed version of Proposition 5.4.1.
Proposition 5.4.2. Let be a scalar Clifford diagram containing spiders. Then we can calculate the value of in time . In particular, we can calculate amplitudes of a Clifford circuit containing gates in time .
Proof. The first claim follows from the discussion on the complexity of rewriting above. For the second claim we simply note that each gate in a Clifford circuit can be translated into a fixed small number of spiders, so that the ZX-diagram corresponding to the amplitude to be calculated has spiders. □
Now, is not too bad, but it does mean that once we start dealing with diagrams with, say, millions, of spiders, that we run into trouble. Can we do better? As it turns out: yes! With a more clever simplification strategy, we can actually obtain a significantly better upper bound. The reason we got this scaling, is because we weren’t telling the simplifier which spiders to target, so that we couldn’t limit the number of wires that end up in the diagram. There is a better strategy that we can use to simplify the diagram, which works when we know that the diagram came from a circuit. The idea is that once we have a GSLC diagram that we can very efficiently ‘absorb’ a Clifford gate and rewrite the whole thing as another GSLC diagram. So suppose we have a Clifford circuit consisting of CZ, Hadamard and gates (if your circuit contains CNOTs, then these can be converted into CZ gates surrounded by Hadamards). Now when we write this circuit as a ZX-diagram, it will only contain Z-spiders, so that it already looks a bit like a graph-like diagram. However, we will not actually reduce it to graph-like form like we did with our previous simplification algorithm. Instead we will keep the circuit structure intact. Now we will introduce some dummy spiders and Hadamards in order to insert a GSLC form diagram at the start of the circuit:
| (5.17) |
We will now consume gates one by one from the circuit and absorb them into the GSLC part of the diagram, transforming it into a different GSLC diagram, while not affecting the other parts of the diagram. Depending on the gate and on the specific configuration the GLSC part of the diagram is in, we will need to do different things. The easiest gate to deal with is the Hadamard. This is simply absorbed as part of the GSLC if there is no Hadamard already on that qubit, or cancelled if there is one:
| (5.18) |
For gates and CZ gates the situation is more complicated. If there are no Hadamards on the qubits they act on, then we can also absorb them as part of the GSLC:
| (5.19) |
For the CZ gate, as always, if there was already a Hadamard edge present between the spiders, then we simply toggle the connectivity. Now, if there is a Hadamard in the way then we can’t just fuse the or CZ gate into the GSLC. Instead, we will need to resort to our old friends, the local complementation and pivot. The reason we can use these, is because if there is a Hadamard in the way, with an or CZ gate on the right-hand side, then the spider that is part of the GSLC is ‘internal’ in the sense that all its connections are to other spiders via a Hadamard edge. Now, if this spider has a phase, this is straightforward enough: we just apply a local complementation on it to remove it. This connects the spider of the or CZ gate to all the neighbours of this internal spider, so that the or CZ spider takes its place in the GSLC diagram:
| (5.20) |
Now, if the spider we wish to remove has a or phase, then we need to apply a pivot to get rid of it. The spider must be connected to at least one input spider (since the diagram is unitary), so that we can apply the standard non-spider-removing pivot rule of (5.8). The end result is that the output Hadamard disappears, so that the spider of the gate can be fused and become part of the GSLC diagram. Combining these different options we see that we can always absorb a gate into the GSLC portion of the diagram. We can hence simplify the entire circuit into a GSLC diagram.
Exercise 5.16. Reduce the following Clifford circuit to GSLC form using the algorithm described in this section.
Crucially, the connectivity change resulting from these local complementations and pivots is now restricted to just the other spiders of the GSLC diagram and the spider corresponding to the gate to be absorbed, instead of potentially involving the entire diagram. Letting denote the number of qubits, there are qubits in the GSLC diagram, so that this requires toggling at most edges. We need to do such a rewrite potentially for every gate we absorb, so that the entire simplification costs elementary graph operations where is the number of gates in the circuit. Compare this to our previous method that required elementary graph operations. The number of gates is generally a lot more than the number of qubits, so this is a significant savings. Indeed, from Proposition 5.3.12 it follows that to represent an arbitrary Clifford unitary we need gates, so taking we see that we have improved the complexity from to .
Proposition 5.4.3. Let be a -qubit Clifford circuit with CNOT, Hadamard and gates. Then we can reduce it to GSLC form using elementary graph operations. Furthermore, assuming that , we can also write in the layered normal form of Theorem 5.3.11 in time.
Proof. The reduction to GSLC form in time follows from the algorithm described above. To rewrite a GSLC diagram into the layered Clifford normal form requires a Gaussian elimination of the central parity diagram (5.16). This takes time for a total cost of . As long as , this reduces to . □
Proposition 5.4.4. Let be a -qubit Clifford circuit with CNOT, Hadamard and gates. Then we can calculate any amplitude in time. If is given as a GSLC diagram then this reduces to .
Proof. We first reduce to GSLC form using the algorithm described above. This takes time. Then we compose the diagram with the ZX-diagrams for and . This adds spiders, so that the total diagram has spiders. Using the standard simplification algorithm on this diagram then requires graph operations. Assuming the total cost is then for fully reducing the diagram to a scalar. If were already given as a GSLC diagram, then only the final set of simplifications is necessary, requiring just graph operations. □
Exercise* 5.17. The bound on calculating amplitudes in Proposition 5.4.2 is just an upper-bound. In practice it might turn out not to be so bad. Implement a benchmark of random Clifford circuits with an increasing number of gates and/or qubits and measure what the actual exponent is more like. Does the exponent stay the same for different number of qubits? Can you find a different strategy for targeting spiders to remove that leads to better scaling?
In the previous sections we discussed how to calculate the amplitude corresponding to observing a particular effect on a Clifford state and we called this ‘simulating’ a Clifford computation. But this is not entirely correct. In order to truly say we are simulating a quantum computation we should be getting the same types of outcomes that we would get when we would actually run the quantum circuit. These outcomes come in the form of measurement samples. Namely, we would prepare a quantum state, execute quantum gates on it, and finally measure each qubit. The outcome is then a bit string specifying which measurement outcome we got for each qubit. By running the experiment many times we will see a particular distribution of bit strings as outcomes. To simulate a quantum computation is then to be able to generate a series of bit strings that have a similar distribution of outcomes.
Definition 5.4.5. Let be some unitary, and write
for the probabilities of observing the outcome when applying to the input state . We then say a probabilistic algorithm weakly simulates when it produces bit strings according to a distribution suitably close to .
In this definition ‘suitably close’ can be made exact, but that won’t be necessary for us for now. With what we have seen up to now, it is not obvious how we can actually efficiently weakly simulate Clifford unitaries. We are however quite close to being able to strongly simulate Clifford circuits.
Definition 5.4.6. Let be some unitary, and let be its associated probability distribution as above. Then we say an algorithm strongly simulates when it can calculate (or closely approximate) any marginal probability of .
Let’s explain this definition. Recall that a marginal probability distribution is one where we don’t care about the outcome of one or more of the variables of the distribution. For instance, if we have a distribution of three variables, then we can marginalise to get the distribution . When corresponds to the probabilities of observing particular measurement outcomes in a 3-qubit circuit, then this marginal tells us the probability of observing on qubit 1 and on qubit 2, when we don’t measure qubit 3 at all. The reason we require the ability to determine any marginal probability in the definition of strong simulation, is that if we can only calculate the non-marginal probabilities, then it will generally take exponential resources to determine marginal probabilities. Consider for instance an -variable distribution of Boolean variables. Then to calculate the marginal we have to sum the values of variables , and this summation contains terms. Okay, so now that we understand what the definition says, it might be helpful to answer why we call this ‘strong’ simulation as opposed to ‘weak’ simulation. First of all, note that being able to weakly simulate doesn’t seem to easily imply the ability to calculate the value of the probabilities: it might be that some probability is exponentially small (in ), and hence we would need to sample at least exponentially many bit strings using weak simulation to get an estimate of its value. But the converse is true: if we can strongly simulate a unitary, then we can also weakly simulate it. To see how to do this, we need to recall the concept of conditional probabilities. A conditional probability distribution tells us the probability of observing some outcome conditional on some other variables taking particular values. For instance , the probability of observing the particular values and given that , is equal to . Hence, since strong simulation allows us to calculate any marginal probability, we can then also calculate any conditional probability. So how do we use marginal and conditional probabilities to generate a sample bit string with the correct distribution? We do this by determining the value of each bit of in turn. First we ask for the probability , the marginal probability that we observe qubit 1 to give a value of . We then decide with probability to set and otherwise we set . We then calculate and set with probability and otherwise . This means that we have chosen and with probability
| (5.21) |
which is the correct distribution. We carry on and calculate and repeat the procedure until we have determined the entire bit string . Repeating the argument of Eq. (5.21) we see that we will have chosen this specific bit string with probability so that we are indeed sampling correctly from this distribution. To summarise:
So how do we actually do strong simulation of Clifford circuits with the ZX-diagram simplification strategies we have discussed in this chapter? Well, we have seen how to calculate an amplitude which allows us to calculate a non-marginal probability . But how do we calculate a marginal probability? To see this it first helps to expand in a way that allows us to more easily represent it as a diagram. Recall that for a complex number we have where is the conjugate. The conjugate of the inner product is . We can represent each of these by ZX-diagrams, and as they are scalar diagrams, their multiplication is implemented just by putting them next to each other:
| (5.22) |
We get these scalar factors of because the X-spiders only represent and up to a scalar. Note that these middle pairs of spiders correspond then (up to scalar) to operators . Now if we want to calculate a marginal probability then this corresponds to a sum of such diagrams where we vary the values of some of the . Remember that , hence on the diagram we can implement this summation by replacing the middle spiders by an identity wire:
| (5.23) |
Using this diagrammatic representation of a marginal probability allows to calculate the marginals of a Clifford computation.
Proposition 5.4.7. Let be a -qubit Clifford circuit with gates. Then we can calculate any marginal probability of using graph operations. If is given in GSLC form then it takes only operations.
Proof. First reduce to GSLC form using operations (see Proposition 5.4.3). Then construct the diagram as in (5.23) to represent the desired marginal probability. This diagram has spiders, so fully simplifying it requires graph operations. As we see that the total number of steps taken is . □
Since we can now calculate any marginal probability, we have also found a way to sample measurement outcomes from the Clifford circuit.
Proposition 5.4.8. Let be a -qubit Clifford circuit with gates. Then we can sample bit strings from its measurement distribution using graph operations.
Proof. We first reduce to GSLC form, which requires operations. Now in order to sample a bit string from its distribution (i.e. to perform weak simulation), we can use the method described above, which requires us to calculate marginals, each of which takes operations to calculate. So sampling a single bit string requires operations. We need to do this times, so the total cost is . □
It is perhaps a bit unsatisfying that the weak simulation seems to be more expensive than the so-called strong simulation. However, it turns out that there is a smarter way to perform weak simulation of Clifford circuits. To do this, we also need to simplify our unitary using ZX-calculus rewrites, but now instead of reducing to GSLC form, we want to reduce it to the affine with phases form (AP form) of Section 5.3.1. We can do this with the same order of graph operations as it takes to reduce to GSLC form. We can see this in two ways. Either we first reduce to GSLC form using Proposition 5.4.3, and then we do some final rewrites to reduce it to AP form. Or, we modify the algorithm used in Proposition 5.4.3 so that instead of absorbing gates into a GSLC part of the diagram, we absorb gates into an AP form diagram. We hence have the following.
Proposition 5.4.9. Let be a -qubit Clifford unitary with gates. Then we can write both and in AP form using operations.
Recall from Eq. (5.14) that a state in AP form can naturally be written as
for some phase function , parity matrix and bit string . This state is an equal superposition of those for which . Hence, if we measure all the qubits then the outcomes will correspond to one of those bit strings for which this parity condition is satisfied (the phase function is irrelevant for the outcomes). So we see that sampling from the distribution of boils down to being able to uniformly randomly select vectors that satisfy such parity conditions.
Proposition 5.4.10. Let be a -qubit Clifford unitary with gates. Then we can sample bit strings from its measurement distribution using operations.
Proof. First write in AP form using Proposition 5.4.9, which requires operations, and let and denote the parity matrix and bit string determining the AP form. Now we need to uniformly randomly return bit strings that satisfy . First find a single for which . This takes operations as is of size , and Gaussian elimination takes cubic time. Now do another Gaussian elimination of to find a basis for the kernel of , i.e. of those for which . This also takes time. Now to determine a uniformly random bit string satisfying we simply generate uniformly random bits and output (this is indeed uniformly random as each bit string in the kernel of can be written in a unique way as a combination of the basis vectors). Hence, each additional sample just requires generating some random bits and summing together bit strings of length for a total cost of per sample. □
Instead of casting this algorithm in terms of Gaussian elimination, we can also view it as a diagram rewriting exercise. In Eq. (5.12) we saw that we can relate the affine part of an AP form diagram, a X-Z normal form, to a different Z-X form:
From this latter type of diagram we can easily read of which computational basis states are part of the superposition making it up: each Z-spider represents a basis vector of the kernel of , where is precisely when the Z-spider is connected to output spider . While the spiders give the solution to , the phases on the output transform this into solutions to .
We have seen in this chapter that we can prove a lot about Clifford circuits using the ZX-calculus, but can we actually prove everything? In the previous chapter we saw that the phase-free ZX-calculus is complete, meaning we can prove all equations between phase-free ZX-diagrams using the rules of the phase-free ZX-calculus. It turns out the same is true for Clifford diagrams, when we use the Clifford rewrite rules. In this section we will adopt the scalar-accurate rewrite rules of Section 3.6.2. We will then show that these rewrite rules are complete for the Clifford fragment, meaning that if we can represent a linear map by a Clifford diagram, then any two ways to do so can be rewritten into one another. We show completeness in two steps. First we study scalar Clifford diagrams and show that these can be reduced to a form that uniquely encodes the number they are equal to. Hence, any two scalars representing the same number are reduced to the same diagram, which shows that we have completeness for these scalar diagrams. Then we show that we can refine the AP normal form so that every Clifford diagram can be reduced to a unique normal form. This means that if two diagrams represent the same linear map, that they will be reduced to the same normal form, and hence we have a path of rewriting from one to the other.
First let’s show that we can correctly deal with scalar Clifford diagrams, so that we are then again free to ignore them. For this we will use the results of Section 3.6.2, and hence we use the rules of Figure 3.0 there. We’ve seen in Proposition 3.6.5 that when the diagram contains a zero scalar , that the entire diagram can be reduced to a simple unique form. Hence, we may assume our scalar diagram is non-zero. Our strategy will be to simplify an arbitrarily complicated scalar Clifford diagram to a diagram that consists of small disconnected bits and pieces that can each be dealt with individually. It is straightforward enough to check that with the rules of Figure 3.0 we can prove all the rules of Figure 3.0 up to some scalar diagrams that contain at most two spiders. Hence, everything we have proven so far using the rules of Figure 3.0 remains true using our scalar-accurate set of rules, except that we might acquire some additional small scalar diagrams. This means that in particular our simplification strategy for Clifford diagrams still works, except for some small modifications. We can still use the local complementation simplification Lemma 5.2.9, but as noted in Remark 5.2.10, now it doesn’t actually remove the spider we complement on. Instead, the spider remains as an unconnected scalar. Hence, if we were to apply this rewrite to an unconnected spider (so where in that lemma), it would not remove the spider. In order for the simplification strategy to work we must then only apply this lemma to spiders with a phase that are connected to at least one other spider. The same consideration holds for the pivot simplification Lemma 5.2.11, where we should only apply it if at least one of the spiders being pivoted on is connected to some other spider. In Section 5.4 it was noted that if we apply the simplification strategy to a scalar Clifford diagram, that the entire diagram is simplified away. With our scalar-accurate calculus we see that this now becomes slightly different. We can still remove most connections between spiders, but there will generally be some small scalar subdiagrams left.
Proposition 5.5.1. Any scalar Clifford diagram can be rewritten to be a product of the following scalar subdiagrams:
Proof. First rewrite the ZX-diagram to graph-like form, except that we can’t remove the triple set of wires in . We leave those subdiagrams as is. Then apply the scalar-accurate version of the local complementation Lemma 5.2.9 to any spider with a phase that is connected to at least one other spider. After doing this, any connected spider must have a phase of or . Apply the pivot Lemma 5.2.11 to any such pair where at least one of the spiders has connections to other spiders. Hence, after we are done there can only be connections between pairs of spiders that aren’t connected to anything else. By simply enumerating the possibilities (and applying some colour-changes using ) we see that the only possible connected subdiagrams are then the ones listed above, , and . The first of these can be rewritten to using Lemma 3.6.4, and can be decomposed into a pair of ’s using Lemma 3.6.1. □
Now, if our scalar diagram contains a then it can already be rewritten to a normal form, so let’s assume it does not contain that subdiagram. Then our diagram is a composition of five different types of diagrams. By applying we can ensure that the diagram does not contain both a and a (as they are each others inverses). What other relations hold between these scalars? Using Lemma 3.6.7 we see that there can be at most one subdiagram of and using Lemma 3.6.9 we can make it so that there is at most one spider with a phase in our diagram.
Theorem 5.5.2. We can rewrite any non-zero scalar Clifford diagram to a unique normal form where , , and .
Proof. Apply Proposition 5.5.1 to rewrite the diagram to a product of pairs of spiders. Apply Lemma 3.6.9 so that the diagram contains at most one spider with a phase. If this one diagram with a is then apply Lemma 3.6.6 in reverse with and , so that the diagram is then . Apply Lemma 3.6.7 so that there is at most one instance of . Finally, cancel all pairs of and using . It is then straightforward to verify that the diagram must be of the form specified. To see this is a unique representation of the scalar let denote the value of the scalar the diagram represents. The type of tells us whether (), (), () or (). As by assumption must then be the same for any diagram representing in this normal form. Similarly tells us whether the real part of is positive (or the imaginary part in case ), since either represents or , so that this must also be the same diagram for every representation of . Finally, being or together with the value of tells us the magnitude of (or Im), and hence is also uniquely determined by . □
This theorem tells us that we can always rewrite any two scalar Clifford ZX-diagrams into one another if they represent the same scalar, since they can both be rewritten into this unique normal form.
The previous section settled the question of completeness for scalar Clifford diagrams. In this section we will do the same for non-scalar Clifford diagrams. Since the question of scalars is now settled, we will again revert back to not caring about these scalar subdiagrams. As before, we will write when we are denoting an equality up to a non-zero scalar factor. We will just work with states in this section, so diagrams that don’t have any inputs. Once we have completeness for states, completeness for all diagrams follows easily just by bending some wires (like we did in Theorem 4.3.6). What we will show in this section is that we can refine the AP form, rewriting it into something more canonical. We will then show that this reduced normal form is unique. In particular, we will rewrite our diagrams to the following form.
Definition 5.5.3. A non-zero diagram in AP-form defined by the triple is in reduced AP-form when:
is in reduced row echelon form (RREF) with no zero rows,
only contains free variables from the system .
all the coefficients of are in the interval .
Recall that the first non-zero element in a row of a matrix in RREF is called a pivot (no relation to the pivot graph rewrite rule). The variable is called a free variable if the th column of does not contain a pivot, otherwise it is called a bound variable. The utility of looking at the reduced AP-form is the following theorem.
Theorem 5.5.4. For any non-zero state , there is at most one triple satisfying the conditions of Definition 5.5.3 such that:
Proof. Since , the set is non-empty. Hence, there is a unique system of equations in RREF that define (why?). From this it follows that and are uniquely fixed. Now, for any assignment of free variables, there exists such that (this is why we call these variables ‘free’, they can be chosen without restrictions while still satisfying the constraints given by ). Hence:
for some fixed constant . From this it follows that, by inspection of , we can determine the value of at all inputs , modulo . This is enough to compute each of the coefficients of , modulo 2. (Q: How?) Since we require the coefficients of to be in the interval , we can drop the “modulo 2” and conclude that is uniquely fixed by . □
Our goal then will be to show that we can rewrite any Clifford diagram into reduced AP-form. We already know that we can rewrite the diagram to AP form using Proposition 5.3.2. Such a diagram is then fully described (up to scalar) by a parity matrix , a bit string vector and a phase function . We fully Gaussian eliminate the pair and do the corresponding transformation on the diagram as in Exercise 5.11, to bring it to RREF. If the Gaussian elimination shows that there is no solution to the affine system, then this corresponds to a scalar X-spider with phase appearing, which is equal to the scalar . In this case, we can bring the diagram to the zero normal form of Proposition 3.6.5. So let’s suppose that this is not the case, and the affine system is not inconsistent. We remove all the zero rows of (which correspond to scalar spiders). So now each row of is a linear independent bit string. The affine part of the diagram is then unique. It then remains to show that we can rewrite the phase part so that the phase function only depends on free variables. To do this it will be useful to introduce some notation. Each of the internal spiders in the diagram defines a parity set containing the spiders it is connected to. Since we have fully reduced the matrix , each contains a pivot spider that does not appear in any other parity set. We then need to rewrite the diagram so that the pivot spiders does not interact at all with . This means it must not have any phase, and not be involved with any CZs. First, if a pivot spider has a phase of , then this can be pushed to the other spiders of its parity set:
If instead its phase is then we can remove it by applying a local complementation type rewrite rule. We start by applying the local complementation Lemma 5.2.9 in reverse:
Here in the last step we also implicitly got rid of the scalar spiders that result after applying the copy rule . Now that all pivot spiders have no more phase, we will remove all the Hadamard edges that pivot spiders are involved in. First, we remove all the Hadamard edges from a pivot to a spider within its own parity set. We can do this by repeating the following rewrite:
After every such rewrite the number of Hadamard edges from a pivot strictly decreases, so that the procedure terminates. Finally, we can use a variation of this rewrite rule to remove Hadamard edges from a pivot to a spider outside its parity set:
Note that this rewrite can introduce new Hadamard edges to the pivot of the other parity set, namely when we apply the rewrite rule to two pivots that are connected to each other. However, the rewrite rule either decreases the total number of edges that are connected to a pivot or it decreases the number of pivots that are connected to each other, so that we can always keep applying it and it will always reduce one of these metrics, so that the procedure does terminate. In the end when we can no longer apply the rewrite rule anywhere, it must mean that there are no Hadamard edges attached to a pivot in the diagram.
Remark 5.5.5. The previous phase-removal and edge-removal rewrites also apply when the pivot spider is the only spider in its parity set, but then these rewrites become quite trivial:
We conclude then that we get a diagram in reduced AP form.
Proof. Suppose we have two diagrams and that represent the same linear map. Without loss of generality we may assume that they are states by bending all the wires to the right. We can rewrite the diagrams to reduced AP forms , respectively . The diagrams represent the same linear map and Theorem 5.5.4 shows that this linear map has a unique reduced AP form associated to it, so that and must be the same diagram. Furthermore, by reducing the scalars in the diagrams to a unique normal form (Theorem 5.5.2), we see that the scalar parts of the diagram are also equal. We then indeed have a set of rewrites from to : first go from to , which is equal to , and then do rewrites in reverse to go from to . □
Remark 5.5.8. The reader familiar with stabiliser theory might be wondering how it is that we get a unique normal form for Clifford states, as there is no really ‘canonical’ way to do this. The trick is that we fully Gaussian eliminate the parity matrix. This procedure makes a distinction between the qubits: the first qubit is much more ‘likely’ to be a pivot than the last qubit. A state that is symmetric in the qubits hence would not necessarily be reduced to a symmetric unique normal form (try to construct for instance the reduced AP form of the GHZ state).
You might wonder how these reduced AP forms relate to graph states. We have already seen that we can transform a state in AP form to one in GSLC form by doing some boundary pivots. If the diagram is in reduced AP form, the translation is even simpler: since for every internal spider we have a pivot spider that does not have a phase, it’s Z-spider is actually an identity, and we can do some identity removal and colour change to turn it into a GSLC state:
We see that that every internal spider in AP form translates into a Hadamard on the output of its corresponding pivot in the resulting graph state.
Clifford circuits are circuits consisting of CNOT, Hadamard and gates. Clifford states are the quantum states that can be produced by starting with and then applying a Clifford circuit to it.
Clifford circuits are represented by ZX-diagrams where all the phases are multiples of . We call these diagrams Clifford diagrams.
Any Clifford diagram that is unitary can be written as a Clifford circuit.
We can efficiently simplify Clifford diagrams by the graph-theoretic operations of local complementation and pivoting.
This allows us to
reduce each Clifford circuit to a normal-form consisting of just a few layers of Hadamard, , CNOT and CZ gates,
write each Clifford state in the affine with phases form,
write each Clifford state as a graph state with local Cliffords,
efficiently calculate amplitudes of Clifford states,
efficiently calculate marginal probabilities of Clifford states (strong simulation),
efficiently sample measurement outcomes from a Clifford state (weak simulation).
This scalar-accurate set of rewrites of the ZX-calculus is complete for Clifford ZX-diagrams, meaning that any two Clifford diagrams representing the same linear map can be rewritten into each other using these rewrite rules.
This follows from the existence of a unique normal form for Clifford states that we call the reduced AP form.
Classical simulation Clifford circuits were first shown to be efficiently classically simulable by [113], using what he called the Heisenberg representation, which is now more commonly called the stabiliser representation or stabiliser tableau. We will go into detail on this structure in Chapter 6. Notably, the classical simulation theorem itself appears in this single-author paper by Gottesman as “Knill’s theorem”, crediting Knill with the idea. These days it is called the Gottesman-Knill theorem.
Circuit normal forms The first Clifford circuit synthesis algorithm was given by [1], which produced a circuit with 11 layers of distinct gate types. This was subsequently improved to more compact forms [79, 226, 170]. The shallowest decompositions, at the time of this writing, are due to [171] have a 2-qubit gate depth of .
Graph states with local Cliffords The GSLC form for Clifford ZX diagrams is based on a result by [227], who showed that any stabiliser state, i.e. any state prepared from using a Clifford circuit, can be expressed as a graph state with local Cliffords. The definition of GSLC form for ZX diagrams is due to [19], who used it to prove completeness of the Clifford ZX calculus. The reduction of an arbitrary diagram to GSLC form is from [88].
Local complementation Local complementation, as a purely graph-theoretic concept, goes back to [158]. It’s relevance to quantum computing originates with [225], who showed that two graph states are equal up to local Cliffords if and only if one graph can be transformed into the other via local complementations. [94] showed that, furthermore, this sequence of local complementations can be found efficiently. The local complementation rule was proved in the ZX-calculus by [90]. A more accessible proof is provided in Ref. [62, Prop. 9.125]. The pivoting rule was introduced for ZX diagrams by [92], where it was used to show completeness of the “real stabiliser” fragment of the ZX-calculus, i.e. for ZX diagrams generated by phase-free spiders and the Hadamard gate. The simplification-versions of local complementation and pivot rules (i.e. the ones that delete spiders) were introduced by [88] to simplify non-Clifford circuits, and with some additional variations on the pivoting rule, they were used in [23] to simplify MBQC patterns (though note that the idea that ’a pivot deletes vertices’ was also present in [178]).
AP normal form The AP form and reduced AP form were introduced in a preprint of this book in 2022 to give, among other things, a simplified proof of Clifford completeness. It first appears in published form in [192] for the case of odd-prime-dimensional qudits. A circuit decomposition for Clifford state preparations, which is closely related to the AP normal form, appears more than ten years earlier, in a classical simulation paper by [226].