The Exercise
Let be a unitary on one qubit. The gate acts on control qubits and a target qubit: it applies to the target when every control is in and acts as the identity otherwise. The exercise asks for a circuit on these qubits that implements with 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 takes.
Qubits and Registers
A quantum system is a physical system whose state space is a finite dimensional complex Hilbert space.✦ A pure state of is a unit vector in the state space of , .✦ A unitary of is an operator on the state space of with , the evolution of as a closed system.✦
The composite system of two systems and has as its state space the tensor product of their state spaces.✦ The qubit is the two level system with state space .✦ The basis states and of a qubit are the pure states given by the standard basis vectors and of , and the single qubit gates are the unitaries of a qubit. For a system , the control register of qubits around is the system of control qubits composed with one at a time, on the left: it is itself for , and for controls it is a qubit composed with the register of qubits around .✦
Controlled Gates
For a unitary of a system , the controlled gate is the unitary of the composite of a control qubit and the target given by (1)✦ For a unitary of , the gate with controls is the unitary of the control register of qubits around defined by (2)✦ For a single qubit gate and the recursion also writes as , the controlled gate under further controls.
Counting Gates
A unitary of a system has gate budget when it is built from at most NOT gates with at most two controls (the NOT gate , the CNOT and the Toffoli gate) and at most single qubit gates, alone or with one control.✦ The NOT gates come in classical blocks. A classical block on a register of qubits is a unitary that sends each basis state , for a string of bits, to the basis state of the string that a list of NOT gates makes of , 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 counts as one single qubit gate in each of four forms: under one control, under one control, beside a qubit on which the gate acts as the identity, and alone; in the first three forms further qubits on which the gate acts as the identity may surround it.
Budgets add under products: if has budget and has budget , then , which applies and then , has budget . If is a unitary of with budget and is identified with another system by a unitary map of state spaces, then the unitary of that corresponds to under this identification has the same budget. A budget is also a budget whenever and .
The Claim
For and a sequence of single qubit gates in which each is a square root of , the Barenco circuit is a unitary of control qubits and a target qubit, defined by recursion on from : is the circuit of single qubit gates and CNOT gates built from that acts on one control and the target, and applies a fixed block of CNOT, Toffoli and single qubit gates built from and then the circuit built from .✦
Theorem 1. Let be a single qubit gate and . There is a sequence of single qubit gates with for which (3)✦ For the same and , (4)✦ and the total of the two counts satisfies (5)✦
What Is Checked
The claims are stated over the gate 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 of any system is unitary, .✦