Lean, informalized

Nielsen & Chuang · Chapter 6, Quantum search algorithms · p. 255

Exercise 6.5 - One call of a bit flip oracle between Hadamard, NOT and controlled NOT gates, and the sign it gives each basis state

Marking solutions only when the extra qubit is zero.

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 search over NN items, the indices x=0,1,…,N−1x = 0, 1, \dots, N-1, is posed by a function ff that assigns each index a bit; xx is a solution when f(x)=1f(x) = 1. The oracle OO is a unitary that flips an oracle qubit rr exactly when the index register, a system with NN levels whose basis states are the indices, holds a solution. Adjoin an extra qubit qq to the index, so that the items become the 2N2N pairs (x,q)(x, q). The exercise asks for an augmented oracle O′O', made from OO and elementary gates, that marks the pair (x,q)(x, q) with a minus sign when xx is a solution and q=0q = 0, and leaves every other pair unmarked.

Systems and States

A quantum system SS is described by its state space, a finite dimensional complex Hilbert space.✦ The composite system S⊗TS \otimes T of two systems SS and TT is the system whose state space is the tensor product of their state spaces.✦ The qudit with dd levels is the system with state space ℂd\mathbb{C}^d, and the qubit is the two level system, with state space ℂ2\mathbb{C}^2.

A pure state |ψ⟩|\psi\rangle of a system SS is a unit vector in the state space of SS.✦ For a level ii of the qudit with dd levels, the computational basis state |i⟩|i\rangle is the pure state whose vector is the standard basis vector of ℂd\mathbb{C}^d with entry 11 at ii and 00 elsewhere; on the qubit these are |0⟩|0\rangle and |1⟩|1\rangle.✦ Given pure states |ψ⟩|\psi\rangle of SS and |φ⟩|\varphi\rangle of TT, their product |ψ⟩⊗|φ⟩|\psi\rangle \otimes |\varphi\rangle is the pure state of S⊗TS \otimes T whose vector is the tensor product of the two vectors.✦

The oracles act on the composite system of an index register, the qudit with NN levels, and the two qubits qq and rr. The basis states of this composite system are the products |x⟩|a⟩|b⟩=|x⟩⊗(|a⟩⊗|b⟩)|x\rangle|a\rangle|b\rangle = |x\rangle \otimes (|a\rangle \otimes |b\rangle) of an index xx with a bit aa for qq and a bit bb for rr.

Unitaries and Gates

A unitary UU of a system SS is an operator on the state space of SS with U†U=UU†=1U^\dagger U = U U^\dagger = 1, and it carries a pure state |ψ⟩|\psi\rangle of SS to the pure state U|ψ⟩U|\psi\rangle. The identity 11 is a unitary of every system.✦ Of two unitaries UU and VV of SS, the product UVUV is the unitary that applies VV first and then UU.✦ Given unitaries UU of SS and VV of TT, the product unitary U⊗VU \otimes V of S⊗TS \otimes T is the tensor product of their operators; in particular 1⊗V1 \otimes V acts with VV on the last factor and leaves the first alone.

The Pauli gate XX, the quantum NOT, 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}.(1) 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 .(2)✦ The controlled NOT gate (CNOT) is the gate C(X)C(X) of two qubits, which flips the second qubit when the first is |1⟩|1\rangle.✦

Three gates act on the two qubits of the oracles alone, XX and HH on the oracle qubit and CNOT with qq as control and rr as target: Xr=1⊗(1⊗X),Hr=1⊗(1⊗H),CNOTq→r=1⊗CNOT.X_r = 1 \otimes (1 \otimes X), \qquad H_r = 1 \otimes (1 \otimes H), \qquad \mathrm{CNOT}_{q \to r} = 1 \otimes \mathrm{CNOT}.(3)

The Oracle and Its Augmentation

A unitary OO of the index register and the two qubits is a bit flip oracle for ff when, for every index xx and all bits aa and bb, O|x⟩|a⟩|b⟩=|x⟩|a⟩|b⊕f(x)⟩,O\,|x\rangle|a\rangle|b\rangle = |x\rangle|a\rangle|b \oplus f(x)\rangle ,(4)✦ with ⊕\oplus addition modulo 22. The augmented oracle O′O' of OO is the unitary O′=XrCNOTq→rHrOHrCNOTq→rXr.O' = X_r \, \mathrm{CNOT}_{q \to r} \, H_r \, O \, H_r \, \mathrm{CNOT}_{q \to r} \, X_r .(5)✦

The Claim

A pure state |ψ⟩|\psi\rangle of a system SS is an eigenstate of a unitary UU of SS, with eigenvalue a complex number μ\mu, when U|ψ⟩=μ|ψ⟩U|\psi\rangle = \mu|\psi\rangle.✦

Theorem 1. Let ff assign a bit to each index x∈{0,…,N−1}x \in \{0, \dots, N-1\}, and let OO be a bit flip oracle for ff. For every index xx and every bit qq, the basis state |x⟩|q⟩|0⟩|x\rangle|q\rangle|0\rangle is an eigenstate of the augmented oracle O′O': O′|x⟩|q⟩|0⟩={−|x⟩|q⟩|0⟩if f(x)=1 and q=0,−|x⟩|q⟩|0⟩otherwise.O'\,|x\rangle|q\rangle|0\rangle = \begin{cases} -\,|x\rangle|q\rangle|0\rangle & \text{if } f(x) = 1 \text{ and } q = 0, \\ \phantom{-\,}|x\rangle|q\rangle|0\rangle & \text{otherwise.} \end{cases}(6)✦

What Is Checked

The claim is stated over a bit flip oracle OO for an arbitrary ff, defined by (4), and over the augmented oracle (5) built from it with the gates (3), on the basis states |x⟩|q⟩|0⟩|x\rangle|q\rangle|0\rangle of the index register and the two qubits.

About these constructions the library proves that the controlled gate C(U)C(U) of (2) is unitary for every unitary UU, and that the matrices (1) are unitary. Products UVUV and U⊗VU \otimes V of unitaries are again unitary.