The CNOT gate, or Controlled-NOT gate, is a two-qubit quantum logic gate that flips the target qubit if and only if the control qubit is in state 1, and leaves it unchanged otherwise. In quantum computing it is the standard entangling gate of the circuit model and, together with single-qubit gates, forms a universal gate set.
Within the topic of quantum gates & circuits, the CNOT gate is the reference point against which other two-qubit gates are compared, and CNOT count remains one of the most common measures of circuit cost.
How the CNOT gate acts on qubits
On computational basis states, the CNOT gate maps the pair (control, target) from |a, b⟩ to |a, a XOR b⟩. It therefore behaves like a reversible classical XOR, and its 4 by 4 unitary matrix is a permutation that swaps the basis states |10⟩ and |11⟩ while leaving |00⟩ and |01⟩ untouched.
The quantum character appears with superposition on the control. If a Hadamard gate first places the control in an equal superposition and the target starts in |0⟩, the CNOT gate produces the Bell state (|00⟩ + |11⟩) divided by the square root of two. Neither qubit then has a definite state of its own, which is the essence of entanglement. The truth table below shows the action on all basis inputs.
| Input control | Input target | Output control | Output target |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 |
The gate is its own inverse, so applying CNOT twice returns the identity. It is also Hermitian and belongs to the Clifford group, which means it maps Pauli operators to Pauli operators under conjugation.
Phase kickback and the role of basis
The labels control and target depend on the basis. In the Hadamard basis, the roles reverse: conjugating both qubits with Hadamard gates turns a CNOT from qubit A to qubit B into a CNOT from B to A. This symmetry explains phase kickback, in which a phase seemingly applied to the target appears on the control.
Phase kickback is the working principle of algorithms such as Deutsch-Jozsa, Bernstein-Vazirani and phase estimation. A target prepared in the state |−⟩ is an eigenstate of the NOT operation with eigenvalue −1, so a CNOT conditioned on the control writes a relative phase of −1 onto the control instead of changing the target. The table lists how Pauli errors propagate through the gate, which matters for both kickback reasoning and error correction.
| Operator before the gate | Operator after the gate | Interpretation |
|---|---|---|
| X on control | X on control and X on target | Bit flips spread forward |
| X on target | X on target | Target bit flips stay local |
| Z on control | Z on control | Control phase flips stay local |
| Z on target | Z on control and Z on target | Phase flips spread backward |
CNOT compared with related two-qubit gates
The CNOT gate is one member of a family of locally equivalent entangling gates. A controlled-Z gate differs from CNOT only by Hadamard gates on the target, and the SWAP gate equals three CNOT gates in alternating directions. Hardware platforms often implement a different native gate and compile CNOT from it, as the following comparison shows.
| Gate | Relation to CNOT | Typical native platform |
|---|---|---|
| Controlled-Z gate | CNOT with Hadamard gates on the target | Superconducting and neutral-atom processors |
| iSWAP gate | Two iSWAP gates plus single-qubit gates give CNOT | Some superconducting processors |
| Molmer-Sorensen gate | One gate plus single-qubit rotations gives CNOT | Trapped-ion processors |
| SWAP gate | Equals three CNOT gates | Compiled for routing |
| Toffoli gate | Needs six CNOT gates in standard decomposition | Compiled from Clifford and T gates |
Because these gates are interconvertible with single-qubit operations, compilers treat the number of entangling gates, rather than their exact type, as the main cost of a circuit.
Using CNOT gates in circuit design
Circuit designers rely on the CNOT gate for state preparation, error correction and arithmetic. Chains of CNOT gates create GHZ states, encode logical qubits in repetition and stabilizer codes, and compute parities onto ancilla qubits during syndrome measurement. Reversible adders and modular arithmetic in Shor-type algorithms also consist largely of CNOT and Toffoli gates.
Since two-qubit gates are typically five to ten times noisier than single-qubit gates on current hardware, minimizing CNOT count and CNOT depth is a central compiler objective. The decision table summarizes common optimization strategies.
| Situation | Recommended approach | Reason |
|---|---|---|
| Limited qubit connectivity | Qubit mapping and routing with minimal SWAP insertion | Each SWAP costs three CNOT gates |
| Adjacent CNOT pairs | Cancel identical gates | CNOT is self-inverse |
| Clifford-only subcircuits | Resynthesize with tableau methods | Often yields fewer entangling gates |
| Arbitrary two-qubit unitary | KAK decomposition | Never needs more than three CNOT gates |
Limitations and common misconceptions
A frequent misconception is that the CNOT gate copies quantum information. It copies basis values only; for a general superposition it creates entanglement, consistent with the no-cloning theorem. Another misconception is that CNOT alone gives quantum advantage. Circuits of CNOT, Hadamard and phase gates remain Clifford circuits, which the Gottesman-Knill theorem shows can be simulated efficiently on a classical computer.
- Direction matters on hardware: some devices support CNOT efficiently only in one direction.
- Errors spread: one faulty CNOT can propagate a single error to two qubits.
- Fault tolerance: logical CNOT gates are transversal in many codes but still need careful scheduling.
- Crosstalk: parallel CNOT gates on neighboring pairs can interfere and reduce fidelity.
In simple terms
Think of two light switches wired together in a special way. The first switch is the boss. If the boss is off, nothing happens to the second switch. If the boss is on, the second switch flips to the opposite position.
The quantum version becomes interesting when the boss is both on and off at once, as qubits can be. Then the second switch ends up flipped and not flipped at the same time, and the two switches become linked. This link, called entanglement, is what the CNOT gate creates, and almost every quantum program needs it.
A practical example
A quantum software engineer prepares a three-qubit bit-flip code on a cloud-accessible superconducting processor. The logical state is stored on one qubit, and two CNOT gates copy its basis value onto two partner qubits, so a single bit flip can later be detected and corrected by majority vote.
To read out errors without disturbing the data, the circuit uses two ancilla qubits and four more CNOT gates to compute the parities of qubit pairs. The device supports only nearest-neighbor coupling, so the compiler initially inserts two SWAP operations and the circuit grows to 12 CNOT gates.
By choosing a better physical layout that places each ancilla next to its data qubits, the engineer removes the SWAP operations and cuts the CNOT count to 6. Measured logical error rates fall noticeably, because each removed CNOT eliminates one of the noisiest operations in the circuit.