The Exercise
Two numbers and from are each held in two qubits, one qubit for each of their two binary digits. The exercise asks for a quantum circuit that adds to modulo and keeps , taking the basis state to .
The library builds such a circuit on four qubits from one Toffoli gate and two controlled NOT (CNOT) gates.
Four Qubits
A quantum system is a physical object whose state space is a finite dimensional complex Hilbert space.✦ The composite system of two quantum systems and is the quantum system whose state space is the tensor product of their state spaces.✦ The qubit is the two level quantum system with state space .✦
A pure state of a quantum system is a unit vector in the state space of , determined physically up to a global phase.✦ For a bit , the basis state of the qubit is the pure state whose vector is the standard basis vector of .✦ Given pure states of and of , their product is the pure state of whose vector is the tensor product of the two vectors.✦
The low binary digit of a number is and its high binary digit is , so that . The adder acts on four qubits, with state space , which hold in turn the low digits of and and then their high digits. The input of the adder for numbers and is the product of basis states (1)✦
Gates
A unitary of a quantum system is an operator on the state space of with , a closed system evolution of .✦ A unitary of applied to a pure state of gives the pure state , whose vector is that of acted on by .✦ For unitaries and of the same system, after is the unitary : first , then .✦ The identity evolution of is the unitary of .✦
For unitaries of and of , the product unitary is the unitary of whose operator is the tensor product of the operators of and .✦ With the identity evolution as one factor it places a gate on part of the qubits, each qubit being a wire of the circuit: the gate on the first qubits is , and the gate on the last qubits is .
The Pauli , the quantum NOT, is the unitary of the qubit whose matrix in the basis is (2)✦
For a unitary of a system , the controlled gate is the unitary of the composite of a control qubit and the target given by (3)✦ The CNOT gate is , a unitary of two qubits that flips the second qubit exactly when the first, the control, is .✦
The Adder Circuit
The four qubits are named by the digits they hold, . The carry Toffoli is (4)✦ a Toffoli gate controlled by and , with on and the identity on . The high CNOT is the CNOT gate on the last two wires, with control and target , (5) and the low CNOT is controlled by , with on : (6) The mod adder applies the three in this order: (7)✦
The Claim
What Is Checked
The claim is stated over the four qubits and the products (1) of their basis states, and over the circuit (7), built from the Pauli by controlled gates, gates on part of the wires and composition. The two sides of (8) are equal as unit vectors, with no global phase between them.
The library proves that the controlled gate of a unitary is unitary, ; with the unitarity of the Pauli and of the products and of unitaries, this makes each of the three gates and a unitary of the four qubits. A unitary preserves norms, and the norm of a product vector is the product of the norms, so and are again pure states.