Multi-Controlled Gates
A controlled gate applies a single-qubit operation only when a designated control qubit is . Extending this idea to two or more control qubits produces multi-controlled gates — gates that fire only when every control qubit is . They are the quantum analogue of multi-input AND logic, and they are indispensable for constructing oracles, arithmetic circuits, and quantum error correction.
The Toffoli gate (CCX)
The most important multi-controlled gate is the Toffoli gate, also written CCX or doubly-controlled-NOT. It acts on three qubits: two controls , and one target .
In words: flip the target bit if and only if both controls are . The unitary matrix of CCX is the identity on all computational basis states except the swap (using the convention that qubit 0 is most significant). CCX is its own inverse: .
Controlled gates as conditional unitary maps
Any single-qubit gate can be lifted to a controlled version on two qubits:
Extending to control qubits gives , which applies to the target only when all controls are in state . The simulator provides the most common instances directly:
c.cx(control, target)— CNOT, i.e.c.cz(control, target)—c.ccx(c1, c2, target)— Toffoli, i.e.
Higher-degree multi-controlled gates can be synthesised from these primitives using ancilla qubits, a technique covered in the next lesson.
Doubly-controlled Z (CCZ)
A related gate, CCZ, flips the phase of by while leaving all other basis states unchanged:
CCZ and CCX are related by a Hadamard on the target qubit:
This conjugation identity is the multi-qubit generalisation of .
Try it
Build the Toffoli gate as a standalone 3-qubit circuit. The grader checks the full unitary matrix, so a do-nothing circuit will fail.
Sign in on the full site to ask questions and join the discussion.