Lean, informalized

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

Exercise 4.29 - A circuit for the NOT with nn controls whose gate count grows as n2n^2

The multiply controlled NOT in quadratically many gates.

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

On qubits with computational basis |0⟩\lvert 0 \rangle, |1⟩\lvert 1 \rangle, the gate Cn(X)C^n(X) applies the NOT gate XX to a target qubit under nn control qubits: it flips the target between |0⟩\lvert 0 \rangle and |1⟩\lvert 1 \rangle exactly when every control is in |1⟩\lvert 1 \rangle. The exercise is to build it on its own n+1n+1 qubits, with no work qubits, from Toffoli gates (NOT gates with two controls), controlled NOT (CNOT) gates and single qubit gates, their number growing no faster than n2n^2.

Qubits and Gates

A quantum system is a physical system whose state space is a finite dimensional complex Hilbert space.✦ Two quantum systems SS and TT form the composite system S⊗TS \otimes T, whose state space is the tensor product of the state spaces of SS and TT.✦ A pure state |ψ⟩\lvert \psi \rangle of a quantum system SS is a unit vector in the state space of SS, determined physically up to a global phase.✦ A unitary UU of a quantum 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.✦

The qubit QQ is the two level system whose state space is ℂ2\mathbb{C}^2.✦ For a bit i∈{0,1}i \in \{0, 1\}, the basis state |i⟩\lvert i \rangle of the qubit is the pure state whose vector is the standard basis vector eie_i of ℂ2\mathbb{C}^2.✦ The Pauli XX, the quantum NOT, is the unitary of the qubit whose matrix in this basis is X=(0110).X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}.(1)✦

Controlled Gates

For a unitary UU of a system SS, the controlled gate C(U)C(U) is the unitary of the composite system Q⊗SQ \otimes S of a control qubit and the target SS with operator C(U)=|0⟩⟨0|⊗1+|1⟩⟨1|⊗U.C(U) = \lvert 0 \rangle\langle 0 \rvert \otimes 1 + \lvert 1 \rangle\langle 1 \rvert \otimes U .(2)✦ The CNOT is C(X)C(X).

For a system SS, the register of nn control qubits on SS is the system Q⊗n⊗SQ^{\otimes n} \otimes S, with Q⊗0⊗S=SQ^{\otimes 0} \otimes S = S and Q⊗(n+1)⊗S=Q⊗(Q⊗n⊗S)Q^{\otimes (n+1)} \otimes S = Q \otimes (Q^{\otimes n} \otimes S).✦ For a unitary EE of SS, the gate Cn(E)C^n(E) with nn controls is the unitary of Q⊗n⊗SQ^{\otimes n} \otimes S given by the recursion C0(E)=E,Cn+1(E)=C(Cn(E)),C^0(E) = E, \qquad C^{n+1}(E) = C\bigl(C^n(E)\bigr),(3)✦ It applies EE to SS when all nn controls are in |1⟩\lvert 1 \rangle and acts as the identity otherwise. The NOT with n=k+1n = k+1 controls of the exercise is the gate Ck(C(X))C^k(C(X)), that is kk further controls on a CNOT, acting on the k+2k+2 qubits of Q⊗k⊗(Q⊗Q)Q^{\otimes k} \otimes (Q \otimes Q).

Counting Gates

A unitary EE of a system SS has elementary gate budget (t,s)(t, s) when, after identifying SS with a register of qubits by an isomorphism of systems, that is, an identification of their state spaces, EE is a circuit of at most tt NOT gates with at most two controls and at most ss single qubit gates, each of the latter acting alone or under one control.✦

A classical block on mm qubits is a unitary UU of a register of mm qubits that acts on the computational basis as a list of ℓ\ell NOT gates, each with at most two controls and its target outside them, run as a classical reversible circuit: U(|c1⟩⊗⋯⊗|cm⟩)=|c1′⟩⊗⋯⊗|cm′⟩U \bigl( \lvert c_1 \rangle \otimes \cdots \otimes \lvert c_m \rangle \bigr) = \lvert c'_1 \rangle \otimes \cdots \otimes \lvert c'_m \rangle(4) for every string cc of mm bits, where c′c' is the output of the list on cc. Its budget is (ℓ,0)(\ell, 0).

A single qubit gate VV has budget (0,1)(0, 1), on its own or on one qubit beside idle ones, and so do the controlled gates C(V)C(V) and C(V†)C(V^\dagger), with idle qubits before the control and between the control and the target. Budgets add under composition. If EE and FF have budgets (t1,s1)(t_1, s_1) and (t2,s2)(t_2, s_2), the circuit FF followed by EE, the unitary EFEF, has budget (t1+t2,s1+s2)(t_1 + t_2, s_1 + s_2). A budget is kept when a unitary of SS is carried along an isomorphism of SS with another system TT, and a budget (t,s)(t, s) may be raised to any (t′,s′)(t', s') with t′≥tt' \ge t and s′≥ss' \ge s.

The Claim

Theorem 1. Let k≥0k \ge 0 be an integer. The NOT with k+1k+1 controls is built within an elementary gate budget, Ck(C(X))has budget(8k(k+1)+2,2k+3),C^k\bigl(C(X)\bigr) \ \text{has budget}\ \bigl(8k(k+1) + 2,\; 2k + 3\bigr),(5)✦ and the total number of gates in this budget grows no faster than k2k^2: (8k(k+1)+2)+(2k+3)=O(k2)(k→∞).\bigl(8k(k+1) + 2\bigr) + (2k + 3) = O(k^2) \qquad (k \to \infty).(6)✦

What Is Checked

The claim is stated over the gate Ck(C(X))C^k(C(X)), made by the recursion (3) from the controlled gate (2) and the Pauli XX of (1) on the register Q⊗k⊗(Q⊗Q)Q^{\otimes k} \otimes (Q \otimes Q), and over the elementary gate budget with its classical blocks (4).

About these constructions the library proves that C(U)C(U) is unitary for every unitary UU of a system SS, C(U)†C(U)=C(U)C(U)†=1C(U)^\dagger C(U) = C(U) C(U)^\dagger = 1 on the state space of Q⊗SQ \otimes S, and that the matrix (1) is unitary, so that XX, and through (3) every Ck(C(X))C^k(C(X)), is a unitary of its system.