Toffoli Gate (CCNOT)
Track: Quantum Gates & Circuits · Difficulty: Beginner · Est: 15 min
Toffoli Gate (CCNOT)
Overview
CNOT introduced one control qubit. The Toffoli gate adds a second control qubit.
It is also called CCNOT:
- two controls (C, C),
- one NOT on a target (NOT).
This gate is important because it:
- mirrors a key idea from classical logic (“flip the output if both conditions are true”),
- provides a clean bridge between reversible classical computation and quantum gates,
- and is a standard example of how multi-qubit control scales.
Intuition
Label the three qubits as:
- control 1
- control 2
- target
Toffoli follows a simple conditional rule:
- If both controls are , apply X to the target.
- Otherwise, do nothing.
So it’s a coherent, unitary version of:
- “if (c1 AND c2) then flip t.”
The quantum twist is that the controls can be in superposition. That means “the condition” can be in superposition too, and the gate can create correlations among three qubits.
This connects back to Foundations:
- Multi-qubit states live in tensor-product spaces.
- Entanglement is about the joint state not factorizing.
Toffoli is not “a circuit model”—it’s just one more unitary mapping of multi-qubit basis states.
Formal Description
Action on computational basis states
A three-qubit basis state is
where we interpret:
- = control 1
- = control 2
- = target
Toffoli acts as:
- If , flip .
- Otherwise, leave the state unchanged.
So:
and all other basis states (like , , ) are unchanged.
What happens to amplitudes
If a general three-qubit state has amplitudes spread over many basis vectors, Toffoli only swaps the amplitudes of the two basis states that differ by the target bit when both controls are 1.
Concretely, it swaps the amplitudes of:
- and ,
and leaves all other amplitudes attached to their basis states.
A full matrix form exists (it is 8×8), but the basis-state rule is usually the most readable definition.
Worked Example
Start with a simple superposition in the controls and a definite target:
Write it as a three-qubit state:
Apply CCNOT:
- stays (controls not both 1).
- becomes (controls both 1, so target flips).
So
Interpretation:
- The target is now correlated with the joint control condition.
- Measuring in the computational basis gives either 000 or 111, perfectly correlated across all three qubits.
This is an operational way to see how multi-control gates create structured correlations.
Turtle Tip
For controlled gates, always separate the idea into:
- which qubits are controls,
- what condition triggers the operation,
- what operation is applied to the target.
Common Pitfalls
- Don’t think “Toffoli measures the controls.” It does not; it conditions evolution coherently.
- Don’t assume the target must start in . The gate is defined for any target state; is just a convenient example.
Quick Check
- Which basis states are changed by CCNOT?
- In plain language, what classical logic idea does Toffoli resemble?
What’s Next
You now know the fundamental multi-qubit gate ideas:
- conditional evolution (CNOT, CZ, controlled-),
- reordering (SWAP),
- multi-control logic (Toffoli).
Next we’ll introduce circuits as a full model: composing gates in time and tracking how multi-qubit states evolve step by step.
