DeepPractise
DeepPractise

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 1|1\rangle, 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

abcwitha,b,c{0,1},|abc\rangle\quad\text{with}\quad a,b,c\in\{0,1\},

where we interpret:

  • aa = control 1
  • bb = control 2
  • cc = target

Toffoli acts as:

  • If a=b=1a=b=1, flip cc.
  • Otherwise, leave the state unchanged.

So:

CCNOT110=111,\text{CCNOT}|110\rangle = |111\rangle, CCNOT111=110,\text{CCNOT}|111\rangle = |110\rangle,

and all other basis states (like 000|000\rangle, 010|010\rangle, 101|101\rangle) 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:

  • 110|110\rangle and 111|111\rangle,

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:

ψ=12(00+11)0.|\psi\rangle = \tfrac{1}{\sqrt{2}}(|00\rangle + |11\rangle)\otimes|0\rangle.

Write it as a three-qubit state:

ψ=12(000+110).|\psi\rangle = \tfrac{1}{\sqrt{2}}(|000\rangle + |110\rangle).

Apply CCNOT:

  • 000|000\rangle stays 000|000\rangle (controls not both 1).
  • 110|110\rangle becomes 111|111\rangle (controls both 1, so target flips).

So

CCNOTψ=12(000+111).\text{CCNOT}|\psi\rangle = \tfrac{1}{\sqrt{2}}(|000\rangle + |111\rangle).

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

Turtle Tip

For controlled gates, always separate the idea into:

  1. which qubits are controls,
  2. what condition triggers the operation,
  3. what operation is applied to the target.

Common Pitfalls

Common Pitfalls
  • Don’t think “Toffoli measures the controls.” It does not; it conditions evolution coherently.
  • Don’t assume the target must start in 0|0\rangle. The gate is defined for any target state; 0|0\rangle is just a convenient example.

Quick Check

Quick Check
  1. Which basis states are changed by CCNOT?
  2. 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-UU),
  • 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.