Lean, informalized

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

Exercise 4.30 - A single qubit gate with many controls as a circuit of Toffoli, controlled NOT and single qubit gates, and its gate count

Multiply controlled gates from quadratically many elementary 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

Let UU be a unitary on one qubit. The gate Cn(U)C^n(U) acts on nn control qubits and a target qubit: it applies UU to the target when every control is in |1⟩|1\rangle and acts as the identity otherwise. The exercise asks for a circuit on these n+1n+1 qubits that implements Cn(U)C^n(U) with O(n2)O(n^2) gates, each a single qubit gate, a controlled NOT (CNOT) or a Toffoli gate, which is a NOT with two controls.

The library answers with an explicit circuit, made from a sequence of single qubit gates, and with a count of the gates that Cn(U)C^n(U) takes.

Qubits and Registers

A quantum system SS is a physical system whose state space is a finite dimensional complex Hilbert space.✦ A pure state ψ\psi of SS is a unit vector in the state space of SS, ‖ψ‖=1\lVert \psi \rVert = 1.✦ A unitary UU of SS is an operator on the state space of SS with U†U=UU†=1U^\dagger U = U U^\dagger = 1, the evolution of SS as a closed system.✦

The composite system S⊗TS \otimes T of two systems SS and TT has as its state space the tensor product of their state spaces.✦ The qubit is the two level system with state space ℂ2\mathbb{C}^2.✦ The basis states |0⟩|0\rangle and |1⟩|1\rangle of a qubit are the pure states given by the standard basis vectors e0e_0 and e1e_1 of ℂ2\mathbb{C}^2, and the single qubit gates are the unitaries of a qubit. For a system SS, the control register of nn qubits around SS is the system of nn control qubits composed with SS one at a time, on the left: it is SS itself for n=0n = 0, and for n+1n + 1 controls it is a qubit composed with the register of nn qubits around SS.✦

Controlled Gates

For a unitary UU of a system SS, the controlled gate C(U)C(U) is the unitary of the composite qubit⊗S\mathrm{qubit} \otimes S of a control qubit and 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 .(1)✦ For a unitary EE of SS, the gate Cn(E)C^n(E) with nn controls is the unitary of the control register of nn qubits around SS defined by C0(E)=E,Cn+1(E)=C(Cn(E)).C^0(E) = E, \qquad C^{n+1}(E) = C\bigl(C^n(E)\bigr).(2)✦ For a single qubit gate UU and n≥1n \ge 1 the recursion also writes Cn(U)C^n(U) as Cn−1(C(U))C^{n-1}\bigl(C(U)\bigr), the controlled gate C(U)C(U) under n−1n-1 further controls.

Counting Gates

A unitary EE of a system SS has gate budget (t,s)(t, s) when it is built from at most tt NOT gates with at most two controls (the NOT gate XX, the CNOT and the Toffoli gate) and at most ss single qubit gates, alone or with one control.✦ The NOT gates come in classical blocks. A classical block on a register of mm qubits is a unitary that sends each basis state |c1⟩⊗⋯⊗|cm⟩|c_1\rangle \otimes \cdots \otimes |c_m\rangle, for a string cc of bits, to the basis state of the string that a list of NOT gates makes of cc, each gate of the list having at most two controls and its target outside them; the block costs as many NOT gates as the list holds. A single qubit gate gg counts as one single qubit gate in each of four forms: gg under one control, g†g^\dagger under one control, gg beside a qubit on which the gate acts as the identity, and gg alone; in the first three forms further qubits on which the gate acts as the identity may surround it.

Budgets add under products: if EE has budget (t1,s1)(t_1, s_1) and FF has budget (t2,s2)(t_2, s_2), then EFEF, which applies FF and then EE, has budget (t1+t2,s1+s2)(t_1 + t_2, s_1 + s_2). If EE is a unitary of SS with budget (t,s)(t, s) and SS is identified with another system S′S' by a unitary map of state spaces, then the unitary of S′S' that corresponds to EE under this identification has the same budget. A budget (t,s)(t, s) is also a budget (t′,s′)(t', s') whenever t′≥tt' \ge t and s′≥ss' \ge s.

The Claim

For n≥1n \ge 1 and a sequence V=(V0,V1,V2,…)V = (V_0, V_1, V_2, \dots) of single qubit gates in which each Vj+1V_{j+1} is a square root of VjV_j, the Barenco circuit Bn(V)B_n(V) is a unitary of nn control qubits and a target qubit, defined by recursion on nn from V1,…,VnV_1, \dots, V_n: B1(V)B_1(V) is the circuit of single qubit gates and CNOT gates built from V1V_1 that acts on one control and the target, and Bn+1(V)B_{n+1}(V) applies a fixed block of CNOT, Toffoli and single qubit gates built from V1V_1 and then the circuit BnB_n built from V2,…,Vn+1V_2, \dots, V_{n+1}.✦

Theorem 1. Let UU be a single qubit gate and n≥1n \ge 1. There is a sequence VV of single qubit gates with V0=UV_0 = U for which Cn(U)=Bn(V).C^n(U) = B_n(V).(3)✦ For the same UU and nn, Cn(U)has gate budget(8n(n−1)+2,2n+1),C^n(U) \ \text{has gate budget}\ \bigl(8n(n-1) + 2,\; 2n + 1\bigr),(4)✦ and the total of the two counts satisfies (8n(n−1)+2)+(2n+1)=O(n2)(n→∞).\bigl(8n(n-1) + 2\bigr) + (2n + 1) = O(n^2) \qquad (n \to \infty).(5)✦

What Is Checked

The claims are stated over the gate Cn(U)C^n(U) of (2), built from the controlled gate (1) of a single qubit gate, over the Barenco circuit and over the gate budget. About these constructions the library proves that the controlled gate of a unitary UU of any system is unitary, C(U)†C(U)=C(U)C(U)†=1C(U)^\dagger C(U) = C(U)\, C(U)^\dagger = 1.✦