Circuit Identities and Equivalences
A quantum circuit is nothing more than a product of unitary matrices read right to left, and two circuits do exactly the same physics precisely when those products are equal — or, more subtly, when they differ only by an overall phase that no measurement can ever reveal. A circuit identity is a proven instance of such an equality, written so that one side is shorter, more symmetric, or expressed in the gate set a given machine actually supports. Because unitary multiplication is associative but stubbornly non-commutative, the entire value of an identity is that it tells you, with certainty, which rearrangements are legal and which secretly change the computation. This article is the algebra of those legal moves. Three threads organize everything that follows. The single-qubit identities fall into involutions and powers (, ), basis-change conjugations (the Hadamard swapping the and axes), and same-axis rotation composition inherited from the geometry of the Bloch sphere. The two-qubit identities are where the algebra earns its keep: a controlled- conjugated by Hadamards on the target is a CNOT, three alternating CNOTs make a SWAP, and a control slides freely through anything diagonal in the computational basis. And treated systematically, the identities generated by , , and CNOT close into the Clifford group — the operations that map Pauli operators to Pauli operators under conjugation. That single closure property is the engine behind stabilizer simulation, Pauli-frame tracking in error correction, and the rewrite heuristics inside every modern quantum compiler.
- Two gate sequences are interchangeable exactly when their unitaries agree — up to a global phase that is physically invisible for a standalone circuit.
- Core single-qubit rules: the involutions , the Hadamard conjugations , , , and the powers , .
- Two-qubit rules connect the entanglers: , and — exactly three two-qubit gates.
- Pauli propagation is the master rewrite: , so an entire Clifford circuit is analyzed by tracking a handful of Pauli labels.
- These identities preserve the unitary exactly, so they are the legal moves of circuit optimization, compilation to a native gate set, and hand analysis of protocols like teleportation.
- The set generated by , , and CNOT is the Clifford group, whose Pauli-to-Pauli closure underlies the Gottesman–Knill theorem and fault-tolerant control software.
- Key idea: Two gate sequences are interchangeable exactly when their unitaries agree up to global phase; the catalogue of single- and two-qubit identities (involutions, Hadamard conjugations, control propagation, the 3-CNOT SWAP) gives the complete set of legal local rewrites for simplification, compilation, and analysis.
Where this lives today
Circuit identities are the arithmetic inside every quantum compiler. IBM's Qiskit transpiler and the Quantinuum tket compiler apply exactly these rewrites — cancelling adjacent inverses (, ), merging same-axis rotations, and converting CZ to CNOT — to lower a program onto a device's native gate set, since Google's chips supply CZ while IBM's supply CNOT and ECR. The ZX-calculus, and its implementation PyZX, recasts the same identities as graph rewrites and routinely removes a large fraction of the gates in a circuit, the gates that dominate the cost of fault-tolerant computation. In error correction, Craig Gidney's Stim simulator uses the CNOT and Hadamard propagation tables to push Pauli errors through Clifford encoders and sample syndromes for codes with millions of qubits — a direct application of the Gottesman–Knill machinery, far beyond any amplitude-vector simulator. And on connectivity-limited hardware, the three-CNOT SWAP identity is why routing is a real cost: a compiler inserts physical SWAPs to bring distant qubits together, and minimizing their number is a live optimization in every mapping pass, since each SWAP is three noisy entangling gates the algorithm never asked for.
The physical picture
Think of a circuit as a recipe and identities as the substitutions that leave the finished dish identical. Every substitution is certified by multiplying the relevant or matrices and confirming they agree — up to an overall phase that no measurement can detect. The Hadamard is the master key of the whole catalogue: it relabels the and axes of the Bloch sphere, so any rule stated in the basis has a mirror image in the basis obtained by sandwiching with . That is precisely why the controlled- and the controlled-NOT are, at bottom, the same gate wearing two different bases — the first figure makes that equivalence a picture rather than a matrix computation.
Commutation, meanwhile, is geometric rather than mysterious: single-qubit gates commute exactly when they rotate about the same Bloch axis and anticommute when their Pauli axes are orthogonal, so is not an accident but the statement that and point at right angles. Reordering gates is licensed precisely by this picture. The unifying move behind the two-qubit rules is "pushing a Pauli through a gate" — each of , , and CNOT carries a simple rule for how a Pauli entering one side re-emerges (possibly larger) on the other. The second figure follows a concrete basis state through the three-CNOT SWAP, watching the two bit values physically trade places.
The core equations
The starting point is the equivalence criterion itself: two gate sequences and implement the same physics exactly when their unitaries coincide up to an overall phase. That phase is unobservable for a closed circuit because measurement probabilities depend on , which is blind to a common factor .
where: — the two unitaries being compared; — a global phase, invisible to any measurement of the standalone circuit; — physical equivalence. Reading: an identity is a proof that two circuits satisfy this relation, so one may be substituted for the other anywhere it appears alone. The single-qubit backbone is a short table of involutions and powers. Each is verified by squaring or cubing a matrix, and each licenses a cancellation a compiler will use thousands of times.
where: — the Pauli gates; — Hadamard; and — the phase gates; — identity. Reading: any gate meeting its own inverse annihilates (), and the phase gates form a ladder in steps of on the Bloch -axis. The Pauli algebra records how the three flips multiply and, crucially, that distinct Paulis anticommute. This is the origin of every "you may not simply reorder these gates" warning.
where: — the anticommutator. Reading: , so swapping an adjacent and flips a sign; the products close the group with factors of that must be tracked when the block is later controlled. The Hadamard conjugations are the most-used identities in the whole catalogue, because they convert any -basis statement into its -basis mirror. They are the reason CZ and CNOT are interconvertible.
where: — conjugation of by the (self-inverse) Hadamard. Reading: exchanges the and axes of the Bloch sphere and reverses the axis; the minus sign on is a genuine operator sign, harmless alone but real inside a controlled gate. The phase gate rotates the equatorial Paulis into one another, sending while fixing . This is the other Clifford generator's conjugation rule.
where: — the inverse phase gate. Reading: is a rotation about the Bloch -axis, so it cycles the equatorial axes and leaves the pole axis untouched. The two flagship two-qubit identities connect the entanglers and the wire-exchange. The first rebuilds a CNOT from a CZ by a basis change on the target; the second realizes a SWAP with three alternating CNOTs.
where: — control qubit 1, target qubit 2; — controlled-, symmetric under exchange of its two qubits; — the map . Reading: CZ and CNOT differ only by a Hadamard frame on the target, and exchanging two wires costs exactly three two-qubit gates on hardware. Finally, the Pauli-propagation rule for CNOT is the atom of stabilizer simulation: a Pauli on one input line re-emerges as a (possibly two-qubit) Pauli on the output, and same-axis rotations simply add their angles.
where: — on the control, identity on the target; — on both qubits. Reading: an on the control copies onto the target and a on the target copies onto the control, while and pass through unchanged.
The goal is to prove that three alternating controlled-NOTs exchange two qubits, , by tracking an arbitrary computational-basis state (with ) through the product read right to left. Because the four basis states span the space and every CNOT is a permutation, agreeing on all of them proves the operator identity outright; we use only the rule that a CNOT adds its control into its target modulo 2 and the cancellation .
Step 1. The rightmost gate has control on qubit 1, so it adds into qubit 2: . Why: the control value is untouched while the target picks up a copy of it, the defining action of the gate.
Step 2. The middle gate now has its control on qubit 2, which currently holds , and adds that into qubit 1: , since . Why: reversing which line is the control is exactly what lets the two values start to cross over, and the cancellation is what makes qubit 1 collapse cleanly to .
Step 3. The leftmost gate again adds qubit 1 (now ) into qubit 2 (now ): . Why: the same cancellation finishes the exchange, leaving qubit 2 holding the original and qubit 1 holding the original .
Step 4. The map holds for all four inputs , which is the SWAP permutation, so the operator identity is established. Why: matching a unitary on a full basis is a proof, not a spot check — equivalently one can multiply the three permutation matrices and read off the SWAP matrix.
Go deeper · Derivation B · 1 minCNOT is a basis-changed CZ
The goal is to show that conjugating a controlled- by Hadamards on the target line turns it into a controlled-NOT, , using the controlled-gate decomposition and the single Hadamard fact . This is the identity that lets a compiler treat the two most common entangling gates as interchangeable, converting freely to whichever one a given chip supplies as its native two-qubit interaction.
Step 1. Write CZ in controlled form, : apply to the target only when the control is . Why: the projector form isolates the target operator ( or ) inside each control branch, exactly the thing the Hadamard frame will act on.
Step 2. Conjugate by . The control projectors and are untouched, and the 's land on the target operators: . Why: the tensor factor on qubit 1 commutes past , so only the target operator sees the basis change — this is what "a Hadamard frame on the target" means algebraically.
Step 3. Apply and to get , which is the control-1 / -on-target gate, namely . Why: the controlled- has become a controlled- purely because rotated the axis onto the axis; nothing about the control changed, confirming CZ and CNOT are one gate in two bases.
Go deeper · Derivation C · 1 minPauli pushing through a CNOT
The goal is to derive the Clifford rewrite rule , the atom of stabilizer simulation, by acting on basis states and using . The payoff is enormous: if a single-qubit Pauli always emerges from a CNOT as another Pauli, then any circuit built from Clifford gates can be analyzed by tracking a few Pauli labels instead of an exponentially large amplitude vector — the content of the Gottesman–Knill theorem.
Step 1. Compute the left side on a general basis state. First flips the control, then copies the flipped control onto the target: . Why: the acts before the CNOT reads the control, so the target inherits the already-flipped value .
Step 2. Compute the candidate right side acting after a CNOT: . Why: this produces the identical output ket for every , so the two operators agree as maps and therefore as matrices.
Step 3. Matching gives ; multiply on the right by and use to land on . Why: the same basis-state method gives the companion rules and , completing the CNOT propagation table that a stabilizer simulator applies as its update step.
Limiting cases
The identities are exact equalities, but several boundary conditions decide whether a given rewrite is actually valid in the surrounding context.
| Case | Result | Meaning |
|---|---|---|
| Global vs relative phase | Fine for a standalone block, but the phase becomes observable the moment the block is used as a controlled operation. | |
| Non-commutativity | Adjacent gates may not be freely swapped; reorder only when an identity explicitly licenses it. | |
| Clifford closure | Pauli-pushing is clean only for Clifford gates; a gate maps to a non-Pauli, so the simple rewrite stops. | |
| Locality / wiring | On hardware with limited connectivity an "algebraically free" SWAP still costs three noisy two-qubit gates. | |
| Same-axis rotations | Only rotations about a common axis merge; two different-axis rotations do not add their angles. |
Worked examples
1 · Cancelling a redundant circuit (confidence builder)
A compiler receives the single-wire sequence (applied left to right in time, so the operator is read right to left). Simplify it to a single gate up to global phase, and count the two-qubit gates saved.
Step 1. Cancel the adjacent Hadamards. Reading the operator right to left, the two 's meet: by equation (2), so the operator reduces to . Two single-qubit gates removed at no cost.
Step 2. Collapse the Pauli sandwich. Using the anticommutation from equation (3), push the left through the : , since . The whole five-gate sequence is therefore .
Step 3. Discard the phase. The factor is a global phase, invisible by equation (1), so as a standalone circuit . Result: a five-gate sequence compiles to the single gate — provided this wire is never used as the target of a later control, in which case the would have to be retained. The same cancellation logic () is what removes the expensive entangling gates in real circuits.
2 · The three-CNOT SWAP on a concrete input (fully worked)
Verify that exchanges the qubits by tracking the input , and confirm the two other nontrivial basis states.
Step 1. Input . First (control qubit 1) adds into qubit 2: .
Step 2. Then (control qubit 2, now ) adds into qubit 1: .
Step 3. Then (control qubit 1, now ) adds into qubit 2: . The output is , the exchange of the input . Input 1,0 → output 0,1, as a SWAP requires.
Step 4. Spot-check the rest: and trivially (symmetric, unchanged by exchange), and by the same arithmetic . All four basis states obey , confirming the identity and showing why a SWAP on connectivity-limited hardware costs three physical two-qubit gates rather than being free.
3 · Reversing a CNOT with Hadamards
Show that surrounding a CNOT with Hadamards on both wires exchanges control and target: .
Step 1. Write and rewrite the control projectors using : since and , conjugating the control factor by turns the -basis projectors into -basis projectors .
Step 2. Simultaneously conjugate the target factor: and by equation (4). So , which is a gate that applies to qubit 2 conditioned on qubit 1 being — equivalently, a -controlled operation with the roles of the lines reflected.
Step 3. Recognize the result. Because CZ is symmetric, this expression equals acting with control on qubit 2, i.e. . A CNOT sandwiched by Hadamards runs backward — a rewrite compilers use to match a fixed hardware control direction without a SWAP.
Physics of the portrait
The circuit-identity catalogue is not a random list; almost every entry is an instance of one structural fact — that a distinguished set of gates maps Pauli operators to Pauli operators under conjugation. That set is the Clifford group, and it is the organizing concept behind stabilizer codes, fault-tolerant control, and the classical simulability boundary of quantum computing.
Origins · 1 minthe Clifford group and how this was discovered
The Clifford group is the set of unitaries that send every Pauli operator to a (signed) Pauli operator under conjugation, — formally, the normalizer of the Pauli group. Its name honours William Kingdon Clifford, the Victorian geometer whose 1878 algebras of anticommuting generators are distant ancestors of the Pauli matrices. Those matrices were written down by Wolfgang Pauli in 1927 for electron spin, and it was Daniel Gottesman who, in his 1997 thesis, recognized that circuits built from , , and CNOT close into a group whose action on Paulis is tracked by a compact "tableau" of bits. The Gottesman–Knill theorem that followed is one of the most quoted results in the field: any circuit composed only of Clifford gates, computational-basis preparation, and measurement can be simulated efficiently on a classical computer. The circuit identities of this article are the working rules of that group — , , the CNOT propagation table — and the boundary is sharp: adjoin a single non-Clifford gate such as , and maps to a non-Pauli, simulability collapses, and universal quantum computation becomes possible. Aaronson and Gottesman's 2004 CHP simulator turned the tableau into practical software whose descendants track millions of qubits, and the whole edifice of quantum error correction — Pauli errors pushed through Clifford encoders into a classical frame — is the Clifford group put to work.
Going further
Texts. Nielsen & Chuang, Quantum Computation and Quantum Information, §4.2–4.3 (single- and two-qubit gates, circuit identities, Exercises 4.20–4.25) · Preskill, Lecture Notes on Quantum Computation, Ch. 5–6 · Watrous, The Theory of Quantum Information, Ch. 2 · Wilde, Quantum Information Theory, Ch. 3–4 (Clifford gates) · Kitaev, Shen & Vyalyi, Classical and Quantum Computation, §8 · Mermin, Quantum Computer Science, Ch. 2 · Gottesman, "The Heisenberg Representation of Quantum Computers" (1998) · Aaronson & Gottesman, "Improved Simulation of Stabilizer Circuits" (2004). All single-qubit identities (Pauli squares and products, , , , , , ) can be confirmed by direct matrix multiplication — in particular and , the two carrying real signs. The CNOT/CZ/SWAP relations of equation (6) and the propagation rules of equation (7) can be verified by multiplying the matrices or by checking all four basis states , as done in Derivations 1–3. The Clifford Pauli-conjugation closure is Gottesman's stabilizer formalism, and the same-axis rotation-composition law follows from the structure of the Bloch sphere.
Prerequisites. Quantum Circuit Model · Pauli Gates (X, Y, Z) · Hadamard Gate · CNOT Gate · Bloch Sphere Representation of Gates. Leads to. Universal Gate Sets · Controlled-U Gates · Z-Y Decomposition of Single-Qubit Gates · SWAP Gate.
Ask the tutor: Hand me any gate sequence and I will walk you through cancelling it to its shortest equivalent — or show you exactly why a reordering you tried is illegal.
What does "equal up to global phase" actually mean, and why is it safe?
A global phase is an overall factor multiplying the entire state. Every measurement outcome depends on a probability , and that squared modulus is blind to a common phase: . So two circuits whose unitaries differ only by give identical statistics and are physically the same operation. The caveat is that the phase must be global — shared by the whole state. A relative phase between two branches of a superposition is fully observable, which is why an ignorable phase turns dangerous once a gate sits inside a controlled block.
If CZ and CNOT are "the same gate", why do machines bother with both?
They are the same gate up to a Hadamard frame on the target, , but which one a device provides natively is set by physics, not convenience. Google's superconducting qubits implement a controlled-phase interaction, so CZ is native; IBM's use cross-resonance, giving CNOT (and ECR) natively. A compiler converts between them by adding two single-qubit Hadamards, which are cheap and high-fidelity, so the choice barely affects error budgets. CZ also has a pleasant symmetry — it is unchanged when you swap its two qubits — which sometimes makes it the more convenient object for hand analysis even on a CNOT machine.
Why exactly three CNOTs for a SWAP — can it be done in two?
No. A SWAP is an odd permutation of the two-qubit basis in a sense that forces at least three CNOTs when CNOT is your only two-qubit gate; two CNOTs can generate at most a partial entangling structure, not the full exchange. The derivation shows three alternating CNOTs suffice and how the bit values cross over via the cancellation . If you are allowed richer two-qubit gates the count can drop — for instance, three iSWAP-type interactions or certain native gates can realize a SWAP differently — but in the standard CNOT-plus-single-qubit gate model, three is both necessary and sufficient.
What makes the Clifford group special if it can't do universal computation?
Precisely its tractability. Because Clifford gates map Paulis to Paulis, a stabilizer state is fully described by a compact list of Pauli generators, and each gate updates that list by a simple rule — no exponentially large amplitude vector is needed. That is the Gottesman–Knill theorem: Clifford circuits are classically simulable in polynomial time. The flip side is that this efficiency means Clifford gates alone cannot deliver a quantum speedup; you must add a non-Clifford gate like (or inject "magic states") to reach universality. So the Clifford group marks the exact boundary between the classically easy and the quantumly powerful, which is why it is central to both error correction and complexity theory.
Why can't I just freely reorder gates the way I would numbers?
Because gate multiplication is matrix multiplication, which is non-commutative. Two single-qubit gates commute only when they rotate about the same Bloch axis; distinct Paulis actually anticommute, , so swapping their order flips a sign. That sign is a global phase when the pair acts alone, but a relative phase once the block is controlled — so an "innocent" reordering can silently change the computation. The identities in this article are exactly the licenses that say when a swap or substitution is legal. Outside those licensed moves, you must keep the order or track the phase you incur.
Do these algebraic identities really help on noisy real hardware?
Yes, decisively. Every two-qubit gate on today's devices carries an error of roughly to , so removing even one is worthwhile. Identities like cancel redundant entanglers, CZ-to-CNOT conversion matches the native coupler, and same-axis rotation merging collapses long single-qubit strings — all reducing gate count and therefore error. The three-CNOT SWAP identity works the other way, quantifying the cost of moving information across a limited-connectivity chip, which is why routing passes fight to insert as few SWAPs as possible. The algebra is not decorative; it is a direct lever on circuit fidelity.
What is the ZX-calculus, and how does it relate to these identities?
The ZX-calculus is a graphical language in which circuits become diagrams of "spiders" (Z-type and X-type nodes) joined by wires, with a small set of rewrite rules that are complete for Clifford circuits — any true identity between Clifford circuits can be proved by pushing the diagram around. The Hadamard conjugations and CNOT propagation rules of this article reappear there as elementary spider moves. Its practical payoff is -count reduction: tools like PyZX rewrite the diagram to eliminate non-Clifford resources before mapping to hardware, lowering the cost of fault-tolerant execution. It is the same algebra of legal rewrites, drawn instead of written.