XOR, Clifford, and Bottled Nonlinearity
Stabilizers, Magic States, and Why T Gates Are Expensive
Earlier today, a friend compared Toffoli gates to multiplications, and I was instantly nerdsniped.
As computer scientists, we know that XOR is not universal, but XOR+AND is. It is illuminating to think of XOR as addition modulo 2, and AND as multiplication modulo 2. We need both operations. And crucially, we cannot build multiplication out of addition alone.
Hearing that Toffoli is “multiplication” reminded me that this is exactly true in quantum computing.
This post is an attempt to explain why that analogy is so remarkably beautiful — and why cryptographers like me obsess over the number of Toffoli gates.
Stabilizers: start with one qubit
Before scaling anything up, let’s look carefully at a single qubit.
A quantum state is a generalization of a classical bit. A classical bit is either or . A qubit can be in a superposition of both.
For one qubit, a general state looks like
where and are complex numbers and .
The squared magnitudes and determine the probabilities of measuring or .
One standard way to describe a quantum state is by listing these complex amplitudes.
If this already feels abstract or slightly uncomfortable, that is normal. Quantum states are mathematically richer than classical bits, and the notation can feel heavy at first. But we need just this much structure to get to the fun computer science part.
Now let’s discuss quantum gates. A gate is just a linear transformation applied to this state. It is chosen so that the total probability still sums to one. For example:
- , the identity gate, which does nothing.
- , which flips and . It is the quantum version of the classical NOT gate.
- , which leaves unchanged and multiplies by . There is no classical analogue of the gate.
- , which combines the effects of and : it flips and and also introduces a sign change. You can think of simply as .
- The Hadamard gate sends
There is also no classical analogue of the Hadamard gate. It creates superpositions, something classical bits simply cannot do.1
If we track amplitudes directly, even this tiny example brings in square roots and complex numbers.
The stabilizer idea is to describe certain states in a completely different way.
Instead of listing amplitudes, we describe a state by the operators that leave it unchanged.
A state is stabilized by an operator if
For example:
- is stabilized by because .
- is stabilized by .
Now here is the crucial simplification.
The Pauli operators generate a group. We ignore overall constant factors when working in the stabilizer formalism.2
Each Pauli operator on one qubit can be encoded using two bits:
- corresponds to
- corresponds to
- corresponds to
- corresponds to (since )
Multiplying Pauli operators corresponds to adding these bit pairs modulo 2.
We have reduced part of quantum mechanics to arithmetic on bits. That is the key insight.
A complete one-qubit example
Start with . Its stabilizer is , which we encode as .
Now apply a Hadamard gate .
We know that
So under conjugation by , the stabilizer becomes .
And indeed,
which is stabilized by .
If we had tracked amplitudes, we would have computed
Instead, we just updated a two-bit description.
That is the stabilizer formalism in action.
Scaling to many qubits
For qubits, a completely general state requires complex amplitudes.
But an -qubit Pauli operator can be encoded using bits — two bits per qubit indicating where and appear.
A stabilizer state is defined by independent Pauli operators that all stabilize it. So instead of storing amplitudes, we store binary strings of length .
That is only bits — polynomial, not exponential.
Now comes the key structural fact:
Clifford gates (generated by (Hadamard), (a simple phase-rotation gate), and CNOT (the controlled-NOT gate, which flips one qubit depending on another)) map Pauli operators to Pauli operators.
So if you describe a quantum state by its stabilizers and apply only Clifford gates, you can track the entire computation using only binary linear algebra.
No amplitudes.
No exponential blowup.
This is the Gottesman–Knill theorem (see Gottesman (1998)), which shows that Clifford circuits can be simulated efficiently on a classical computer. If you want a clean and very readable presentation of how this simulation works in practice, see Aaronson and Gottesman (2004).
Clifford circuits are the XOR circuits of quantum computing.
They never leave the linear world.
Why Clifford is not universal
Clifford circuits can create entanglement. They can create Bell states. They can implement quantum teleportation. They are already surprisingly expressive.
But if you start with all zeros — or, as we like to say, — and apply only Clifford gates, you never leave the stabilizer world.
And stabilizer states have compact descriptions: bits suffice to describe them.
So this fragment of quantum computing is powerful. But it is not universal.
It is missing multiplication.
Enter the T gate: multiplication arrives
The T gate is
It is not a Clifford gate.
Conjugating a Pauli operator by — meaning computing — does not always produce another Pauli operator. The closed linear world of stabilizers breaks.
This is exactly the analogue of adding AND to XOR circuits.
In reversible classical computing, the Toffoli gate plays the role of multiplication. It computes . That term is the product of two bits. Toffoli makes reversible circuits universal.
Clifford gates correspond to linear reversible transformations. T gates are what allow you to build Toffoli.
So in a very literal sense, the T-count (the number of gates in your circuit) measures how much “multiplication” your quantum circuit contains.
Once you add T gates,
- the algebra is no longer linear,
- the stabilizer simulator no longer applies,
- and the gate set becomes universal.
Magic states: bottled multiplication
To understand why magic states matter, we need a tiny bit of fault-tolerance context. The leading approach to building large-scale quantum computers today is based on the surface code. In the surface code, logical qubits are encoded into large grids of physical qubits in a way that makes certain operations — notably Clifford gates — relatively natural and robust against noise.
In fault-tolerant quantum computing, Clifford gates are cheap.
T gates are expensive.
Why?
Many quantum error-correcting codes implement Clifford gates transversally — meaning you apply the same small gate ‘bitwise’ across the physical qubits of a logical qubit, without spreading errors in dangerous ways.
This limitation is formalized in the Eastin–Knill theorem (see Eastin and Knill (2009)), which shows that no quantum error-correcting code can implement a universal gate set using only transversal gates.
Instead, we prepare a special resource state
This is called a magic state (see Bravyi and Kitaev (2005)).
Magic states are not stabilizer states. They cannot be described using only the linear stabilizer machinery.
They sit just outside the linear world.
Using only Clifford gates plus magic states, you can implement gates via state injection (a fault-tolerant gadget that consumes a prepared magic state to enact the gate).
So magic states are pre-manufactured packets of multiplication.
They are the AND gates of fault-tolerant quantum computing.
The big picture
Both worlds share the same structure:
- There is a linear subset.
- That subset is efficiently simulable.
- It is not universal.
- Adding a small nonlinear ingredient makes it universal.
Classically, the nonlinear ingredient is multiplication of bits.
Quantumly, the nonlinear ingredient is the T gate — or equivalently, magic states.
The cost of classical simulation grows exponentially in the number of these nonlinear resources. That is why people obsess over T-count: it measures how much genuine nonlinearity your quantum circuit contains.
Nonlinearity is the scarce resource that turns simulable structure into universal computation.
And that is why we count T gates.
Footnotes
-
Superposition is not the same thing as probability. A classical bit can be with some probability and with some probability. A superposition is different: it is a single quantum state that can later interfere with itself. You can also have classical probability distributions over superpositions. The two notions are orthogonal. ↩
-
We ignore constant factors because multiplying a quantum state by a constant complex number does not change any measurement probabilities. Because of this, such overall constants do not affect the physics and can be safely ignored. ↩
I want to write more posts like this. You can follow along by email.