The Exercise
Exercise 10.67, on page 487, shows two circuit diagrams and asks the reader to verify them. In the first, a Pauli sits on the top control line just before a Toffoli gate. The claim is that the same thing happens if the Toffoli acts first and is followed by an on that control together with a CNOT from the second control onto the target. In the second, a sits on the target line before the Toffoli, and the claim is that this equals the Toffoli followed by a on the target and a controlled- between the two controls.
These are the rules for pushing a Pauli error through a Toffoli, and the book uses them in the fault-tolerant constructions of Section 10.6: an error that arrives before the gate comes out the other side as a known pattern of Paulis and controlled gates, which can be corrected. There are no diagrams in the library. Each identity is an equation between two gates on three qubits, and these notes write the equations out.
Gates on Three Qubits
A qubit is the two-level system, and three qubits form the composite , bracketed to the right. A gate is a unitary on the whole register.✦ Composition is written and means first, then , the operator product ; in a chain the rightmost gate acts first, the opposite of reading a drawn circuit from left to right.✦ A single-qubit gate is put on the first wire as , the identity on the other two, and on the third wire as . Which wire a gate sits on is read off its position in the tensor product.
The controlled gate acts on a qubit and a system: it does nothing when the control is and applies when it is .✦ The control is always the first factor. Controlling twice gives the doubly controlled gate on three qubits, (1)✦ with the outer control on the first qubit and the inner one on the second. The Toffoli is the doubly controlled NOT, (2)✦ flipping the third qubit exactly when the first two are both . The CNOT is the singly controlled NOT, (3)✦ The book’s second identity needs a controlled- between the first two qubits of the register with the third left alone. The library defines it as a controlled gate whose target is on the second qubit, (4)✦ which on a basis state is the sign .
The Identities
An on the first control, followed by the Toffoli, equals the Toffoli followed by a CNOT from the second control to the target and then the : (5)✦=
A on the target, followed by the Toffoli, equals the Toffoli followed by a controlled- on the two controls and then the : (6)✦=
Theorem 1. On three qubits, and .
What Is Checked
Lean has checked that both equations are well typed: the two sides are gates on the same three-qubit register, built from the controlled gates, the Paulis and the placements defined above, and each of those definitions elaborates. It has checked nothing about a proof, since there is none. What it cannot check is that the equations are the book’s diagrams. The library has no diagrams; the formalisers read Figure 10.67 and wrote these terms, and whether, for instance, is the controlled- the drawing shows is a judgement for the reader, made easier by the fact that every gate here is one named definition.