Lean, informalized

Nielsen & Chuang · Chapter 4, Quantum circuits · p. 179

Exercise 4.20 - The controlled NOT on products of plus and minus states, and between Hadamard gates

Hadamard gates turn the controlled NOT around.

Hover over a blue or green term in the text, or a node in the graph, to find it in the other. Select it to read its declaration both in Lean and in words.

The Exercise

A controlled NOT (CNOT) gate acts on two qubits: it flips the second, the target, exactly when the first, the control, is |1⟩|1\rangle.✦ That description is made in the computational basis |0⟩,|1⟩|0\rangle, |1\rangle. The exercise asks how the same gate looks in the basis of the eigenstates |+⟩|+\rangle and |−⟩|-\rangle of the Pauli operator XX: what it does to the four products of these states, and what it does to the computational basis once a Hadamard gate is applied to each qubit before and after it. The library answers with five equalities between pure states of two qubits.

Two Qubits

A quantum system SS is a physical system whose state space is a finite dimensional complex Hilbert space.✦ The qubit is the two level system whose state space is ℂ2\mathbb{C}^2.✦ The composite system S⊗TS \otimes T of two quantum systems SS and TT is the quantum system whose state space is the tensor product of the state spaces of SS and TT; the gates below act on the composite of two qubits, with state space ℂ2⊗ℂ2\mathbb{C}^2 \otimes \mathbb{C}^2.✦

A pure state |ψ⟩|\psi\rangle of a quantum system SS is a unit vector in the state space of SS.✦ For pure states |ψ⟩|\psi\rangle of SS and |φ⟩|\varphi\rangle of TT, the product state |ψ⟩⊗|φ⟩|\psi\rangle \otimes |\varphi\rangle is the pure state of S⊗TS \otimes T whose vector is the tensor product of the two vectors.✦ For two qubits we write |a,b⟩|a, b\rangle for |a⟩⊗|b⟩|a\rangle \otimes |b\rangle.

The basis state |i⟩|i\rangle of the qubit, for a bit i∈{0,1}i \in \{0, 1\}, is the pure state whose vector is the iith standard basis vector of ℂ2\mathbb{C}^2.✦ The states |+⟩|+\rangle and |−⟩|-\rangle of the qubit are the pure states whose vectors are |±⟩=12(1±1)=|0⟩±|1⟩2.|\pm\rangle = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ \pm 1 \end{pmatrix} = \frac{|0\rangle \pm |1\rangle}{\sqrt{2}}.(1)

Gates

A unitary UU of a quantum system SS is an operator on the state space of SS with U†U=UU†=1U^\dagger U = U U^\dagger = 1; it carries a pure state |ψ⟩|\psi\rangle of SS to the pure state U|ψ⟩U|\psi\rangle. For unitaries UU and VV of SS, the composite UVUV is the unitary of SS that applies VV first and then UU.✦ The product unitary U⊗VU \otimes V of a unitary UU of SS and a unitary VV of TT is the unitary of S⊗TS \otimes T whose operator is the tensor product of the two operators.✦

The Pauli XX gate and the Hadamard gate HH are the unitaries of the qubit whose matrices in the computational basis are X=(0110),H=12(111−1).X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, \qquad H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}.(2)

For a unitary UU of a system SS, the controlled gate C(U)C(U) is the unitary of the composite of a control qubit with the target SS given by C(U)=|0⟩⟨0|⊗1+|1⟩⟨1|⊗U.C(U) = |0\rangle\langle 0| \otimes 1 + |1\rangle\langle 1| \otimes U.(3)✦ The CNOT gate is the controlled gate C(X)C(X) of two qubits.✦

The Claim

Theorem 1. On products of the states |+⟩|+\rangle and |−⟩|-\rangle the CNOT gate acts with control and target exchanged: CNOT|−,−⟩=|+,−⟩,\mathrm{CNOT}\,|-,-\rangle = |+,-\rangle,(4)✦ CNOT|−,+⟩=|−,+⟩,\mathrm{CNOT}\,|-,+\rangle = |-,+\rangle,(5)✦ CNOT|+,−⟩=|−,−⟩,\mathrm{CNOT}\,|+,-\rangle = |-,-\rangle,(6)✦ CNOT|+,+⟩=|+,+⟩.\mathrm{CNOT}\,|+,+\rangle = |+,+\rangle.(7)✦ For bits cc and tt, with c⊕tc \oplus t their sum modulo 22, the product unitary H⊗HH \otimes H applied before and after the CNOT gate gives a controlled NOT with the second qubit as control and the first as target: (H⊗H)CNOT(H⊗H)|c,t⟩=|c⊕t,t⟩.(H \otimes H)\, \mathrm{CNOT}\, (H \otimes H)\, |c, t\rangle = |c \oplus t, t\rangle.(8)✦

What Is Checked

The claim is stated over the CNOT gate, which is the controlled gate (3) with the Pauli XX gate as UU, and over the composite of that gate with the product unitary H⊗HH \otimes H. The states it is stated over are the product states of two qubits built from the basis states |0⟩,|1⟩|0\rangle, |1\rangle and from the states (1).

The library proves that C(U)C(U) is unitary for every unitary UU of a system SS.✦ It proves the same of the matrices (2), of product unitaries and of composites, and it proves that the vectors (1) have unit norm, as do the tensor product of two unit vectors and the image of a unit vector under a unitary.