Computing Library › Quantum Logic Gates
Quantum Logic Gates
Toffoli Gate (CCX)
The Toffoli gate flips the target only when both controls are |1⟩ — a reversible AND, and a universal gate for classical logic on a quantum computer.
Circuit symbol
Action on basis states
| input | output |
|---|---|
| |110⟩ | |111⟩ |
| |111⟩ | |110⟩ |
| |100⟩ | |100⟩ |
How it works
CCX computes a reversible AND into the target, so it implements classical boolean logic reversibly and underlies quantum arithmetic (adders, modular multipliers in Shor). It decomposes into 6 CNOTs plus T gates — its T-count is a key fault-tolerance cost.
In code (Qiskit)
python
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2) # Toffoli
three-qubituniversal-classicalarithmetic