Lean, informalized

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

Problem 4.1 - Compute ff, put a phase on the answer, uncompute: what the circuit does and what it costs

Turning a reversible computation into a phase.

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

Let mm and nn be positive integers and ff a classical function from mm bits to nn bits, sending each x∈{0,…,2m−1}x \in \{0, \dots, 2^m - 1\} to f(x)∈{0,…,2n−1}f(x) \in \{0, \dots, 2^n - 1\}. A unitary UfU_f, built from TT classical reversible gates on a register of mm qubits and a register of nn qubits, computes ff: on |x⟩|0⟩|x\rangle|0\rangle it leaves the first register as it is and writes f(x)f(x) into the second. The problem asks for a circuit of 2T+n2T + n gates that multiplies |x⟩|x\rangle by the phase e−2πif(x)/2ne^{-2\pi i f(x)/2^n}, with the second register in |0⟩|0\rangle before and after.

Registers and Their States

A quantum system is given by its state space, a finite dimensional complex Hilbert space, and a pure state |ψ⟩|\psi\rangle of a system SS is a unit vector in the state space of SS. The qudit with dd levels is the quantum system whose state space is ℂd\mathbb{C}^d with its standard inner product; its computational basis state |i⟩|i\rangle, for i∈{0,…,d−1}i \in \{0, \dots, d - 1\}, is the pure state given by the iith standard basis vector. The qudit with 2m2^m levels is a register of mm qubits.

The composite system A⊗BA \otimes B of two systems AA and BB has as its state space the tensor product of their state spaces.✦ For pure states |ψ⟩|\psi\rangle of AA and |φ⟩|\varphi\rangle of BB, the product state |ψ⟩⊗|φ⟩|\psi\rangle \otimes |\varphi\rangle is the pure state of A⊗BA \otimes B whose vector is the tensor product of the two vectors.✦ The two registers form one composite system, and |x⟩|0⟩|x\rangle|0\rangle is the product of the basis states |x⟩|x\rangle and |0⟩|0\rangle.

Unitaries

A unitary UU of a system SS, an evolution of SS as a closed system, 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, UU after VV is the unitary UVUV of SS, which applies VV first and then UU, and the adjoint U†U^\dagger is the unitary of SS whose operator is the adjoint of that of UU. For a unitary UU of AA and a unitary VV of BB, the product unitary U⊗VU \otimes V is the unitary of A⊗BA \otimes B whose operator is the tensor product of those of UU and VV.✦

A pure state |ψ⟩|\psi\rangle of SS is an eigenstate of a unitary UU of SS with eigenvalue μ∈ℂ\mu \in \mathbb{C} when U|ψ⟩=μ|ψ⟩.U|\psi\rangle = \mu\,|\psi\rangle.(1)✦

The Circuit

For k∈{0,…,2n−1}k \in \{0, \dots, 2^n - 1\}, the phase angle θk\theta_k is θk=−2πk2n.\theta_k = -\frac{2\pi k}{2^n}.(2)✦ For real angles α0,…,αd−1\alpha_0, \dots, \alpha_{d-1}, the diagonal phase gate DD is the unitary of the qudit with dd levels that is diagonal in the computational basis: D|i⟩=eiαi|i⟩.D|i\rangle = e^{i\alpha_i}\,|i\rangle.(3)✦

For a unitary UfU_f of a register of mm qubits together with a register of nn qubits, and the identity unitary 11 of the first register, whose operator is the identity, the computable phase shift circuit CC is the unitary that applies UfU_f, then DD with the angles θk\theta_k of (2) on the second register, then Uf†U_f^\dagger: C=Uf†(1⊗D)Uf.C = U_f^\dagger\,(1 \otimes D)\,U_f.(4)✦

Counting Gates

Gates come in two kinds. The first are the classical reversible gates, NOT gates with at most two control qubits and the target outside them: the NOT, the controlled NOT and the Toffoli gate. A unitary UU of a register counts as tt gates of the first kind when it acts on the computational basis states as a circuit of tt classical reversible gates acts on bit strings. A gate of the second kind is a single qubit unitary gg on one qubit, or gg or g†g^\dagger controlled by a second qubit.

A unitary UU meets the gate budget (t,s)(t, s), written U∈𝒢(t,s)U \in \mathcal{G}(t, s), when it is a product of such pieces with at most tt gates of the first kind and at most ss of the second, up to identifications between systems, such as that of the two registers with one register of m+nm + n qubits.✦

The Claim

Theorem 1. Let mm and nn be natural numbers, ff a function from {0,…,2m−1}\{0, \dots, 2^m - 1\} to {0,…,2n−1}\{0, \dots, 2^n - 1\}, and UfU_f a unitary of a register of mm qubits together with a register of nn qubits such that Uf|x⟩|0⟩=|x⟩|f(x)⟩U_f|x\rangle|0\rangle = |x\rangle|f(x)\rangle for every xx. Then for every xx the state |x⟩|0⟩|x\rangle|0\rangle is an eigenstate of CC: C|x⟩|0⟩=eiθf(x)|x⟩|0⟩.C\,|x\rangle|0\rangle = e^{i\theta_{f(x)}}\,|x\rangle|0\rangle.(5)✦

Theorem 2. Let mm and nn be positive integers and UfU_f a unitary of a register of mm qubits together with a register of nn qubits that meets the gate budget (T,0)(T, 0). Then the circuit CC built from UfU_f satisfies C∈𝒢(2T,n).C \in \mathcal{G}(2T, n).(6)✦

For a unitary UfU_f that computes ff from TT classical reversible gates, the two theorems give the circuit the problem asks for, with the phase on |x⟩|x\rangle as the eigenvalue of CC on |x⟩|0⟩|x\rangle|0\rangle and the 2T+n2T + n gates split by kind.

What Is Checked

The claims are stated over the circuit CC of (4), which composes UfU_f, the product unitary 1⊗D1 \otimes D with the angles (2) and the adjoint Uf†U_f^\dagger; over the product states |x⟩|0⟩|x\rangle|0\rangle of computational basis states; and over the eigenstate condition (1) and the gate budget.

About these constructions the library proves that UU after VV, the adjoint of a unitary, the product unitary and the diagonal phase gate are unitaries, the last since its diagonal entries eiαie^{i\alpha_i} have modulus one. It proves that a unitary applied to a pure state is again a unit vector, since a unitary preserves norms, and that so is the product of two pure states, since the norm of a product vector is the product of the norms.