Gates and Circuits
Two-qubit gates and CNOT
Flip the target when the control is 1
Everything so far moved one qubit at a time, which can never make two qubits depend on each other. The gate that finally couples them is the simplest imaginable: an if-statement across two wires. Look at the control qubit; if it is 1, flip the target; if it is 0, do nothing. That gate is CNOT, and running it on a superposition is where quantum computing stops looking like classical logic.
The tempting wrong answer
Run CNOT on plain bits and it behaves like a copier. With the target starting at : a control of leaves the target at , and a control of flips the target to . Either way the target ends up equal to the control. So it is natural to think CNOT copies the control, always.
CNOT with a |0> target copies a bit control into the target. So feeding it a |+> control gives two copies of |+>. Is that right?
Watch the control decide
Step the circuit for each input. For the four basis inputs the truth table fills in and the control simply decides whether the target flips. Then pick the control and watch the output refuse to factor into two separate qubits.
| input | CNOT output |
|---|---|
| |00> | |00> |
| |01> | |01> |
| |10> | |11>selected |
| |11> | |10> |
| |+>|0> | (|00> + |11>) / root2 |
For a basis input the control is definitely 0 or 1, so CNOT is just a conditional flip.
CNOT as a 4x4 matrix
Two qubits have four basis states, so a two-qubit gate is a matrix. The gate, with the top wire as control, permutes the basis states: it leaves and alone (control 0) and swaps (control 1, so the target flips).
It is a permutation matrix: one 1 in every row and column, so it is unitary (reversible and length-preserving) just like the single-qubit gates.[2] On the four basis states it does exactly what the truth table said, and there it really does copy a definite control into the target.
The move that is not copying
Now feed it a control in superposition. Start with on the control and on the target, and expand with the tensor product:
CNOT is linear, so it acts on each piece separately. It leaves untouched and sends to :
This is the . Look at what it is not: it is not , which would expand to , all four terms present. Two copies of would have the crossed terms and ; the Bell state has zero weight on both. The output cannot be split into a state for qubit one times a state for qubit two. That inseparability is entanglement, and it is the next lesson.[1]
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
qc = QuantumCircuit(2)
qc.h(0) # control -> |+>
qc.cx(0, 1) # CNOT: control 0, target 1
Statevector(qc)
# (|00> + |11>) / sqrt(2) -> the Bell state, amplitudes only on 00 and 11
# NOT (|00> + |01> + |10> + |11>)/2, which two copies of |+> would giveLock it in
- A two-qubit gate is a 4x4 matrix; CNOT is the permutation that flips the target exactly when the control is 1.
- On basis states CNOT copies a definite control into the target, which is the intuition that misleads.
- On a |+> control, CNOT produces the Bell state (|00> + |11>)/root2, whose crossed terms |01> and |10> vanish, so it is not two copies of |+>.
- That output does not factor into a state per qubit; the qubits are entangled.
Recall: what does CNOT do to the four basis states, and what does it make from |+>|0>?
The truth table plus the one entangling example you will keep reusing. Try to state it, then check.
CNOT is applied with the control qubit in state |1>. What happens to the target?
Why is CNOT on |+>|0> not two copies of |+>?
Match each CNOT input to its output.
Stays |00> (control 0, no flip).
Becomes |11> (control 1, target flips).
Becomes the entangled Bell state.
The qubit that decides whether the target flips.
Where this goes next
Primary source
Quirk, the drag-and-drop quantum circuit simulatorDrop an H then a CNOT onto two wires in Quirk and watch the amplitude display collapse to just |00> and |11>. Nothing builds the intuition for controlled gates and entanglement faster than nudging the gates yourself.
Sources