The Exercise
The Toffoli gate acts on three qubits. It flips the third qubit, the target, exactly when the first two, the controls, are both .✦ The exercise is to show that a circuit of seven gates implements the Toffoli gate up to relative phases: four rotations of the target about the axis, by angles , alternating with three controlled NOT (CNOT) gates whose target is the third qubit. The library states this for each computational basis input in turn.
Three Qubits
A quantum system is a physical system described by its state space, a finite dimensional complex Hilbert space.✦ Two systems and form the composite system , whose state space is the tensor product of theirs.✦ The qubit is the two level system with state space , and three qubits form the composite system .
A pure state of a system is a unit vector in the state space of .✦ For pure states of and of , the product state is the pure state of whose vector is the tensor product of the two vectors.✦ The basis states and of the qubit are the pure states given by the standard basis vectors and of .✦ For bits , and , the basis state of three qubits is the product (1)✦ and the eight of them form the computational basis of the three qubits.
Two pure states and of differ by a relative phase with respect to a family of pure states of , such as an orthonormal basis, if for every index there is a real number , which may depend on , with .✦
Gates
A unitary of a system is an operator on the state space of with ; it carries a pure state of to the pure state . The composite of unitaries and of is the unitary of that applies first and then .✦ For unitaries of and of , the product unitary is the unitary of whose operator is the tensor product of theirs.✦ For a system and a unitary of , the unitary of , with the identity of as first factor, applies to and leaves alone.✦
For a unitary of a system , the controlled gate is the unitary of , with the qubit as control and as target, whose operator is (2)✦ For a unitary of the qubit, the doubly controlled gate is the unitary of three qubits in which the first qubit controls the two qubit gate on the other two.✦
The Pauli matrices are (3) and the Pauli gate, the quantum NOT, is the unitary of the qubit whose matrix in the basis , is . For a real vector and a real angle , the rotation is the matrix built from the Pauli matrices (3) as (4)✦ written when the axis is a unit vector . For the unit vector , the rotation is the rotation about the axis, and the rotation gate is the unitary of the qubit with matrix .
The Circuit
The Toffoli gate is the unitary of three qubits, the doubly controlled NOT.✦ The CNOT gate is the unitary of two qubits, with the first as control; in the circuit acts on the second and third qubits.✦ The CNOT from the first qubit to the third is , in which the first qubit controls the Pauli on the third and the second is left alone.✦ A rotation of the third qubit alone is .✦ The relative phase Toffoli circuit is the product (5)✦ a unitary of three qubits.
The Claim
Theorem 1. Let , and be bits. Then the states and differ by a relative phase with respect to the computational basis of three qubits, that is, for every basis state there is a real with (6)✦
What Is Checked
The claim is stated over two unitaries of three qubits, the circuit of (5) and the Toffoli gate , applied to the basis states (1) and compared by the relation of a relative phase in the computational basis.
The library proves that the controlled gate of (2) is unitary for every unitary , and that the matrices and are unitary. Composites and tensor products of unitaries are again unitary. A unitary takes a pure state to a unit vector, since it preserves norms, and the product of two pure states is a unit vector, since the norm of a product vector is the product of the norms.