Lean, informalized

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

Exercise 4.27 - A three qubit circuit that fixes the all zero state and moves the other seven basis states along one cycle

Eight CNOT and Toffoli gates cycle seven basis states.

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

The exercise asks for a quantum circuit on three qubits that leaves the basis state |000⟩|000\rangle alone and moves each of the other seven computational basis states one step along a single cycle. On the labels this is the partial cyclic permutation π\pi of triples of bits: π(000)=000,001↦010↦011↦100↦101↦110↦111↦001.\pi(000) = 000, \qquad 001 \mapsto 010 \mapsto 011 \mapsto 100 \mapsto 101 \mapsto 110 \mapsto 111 \mapsto 001 .(1)✦ The library’s answer is a circuit of eight gates, each a controlled NOT (CNOT) gate or a Toffoli gate on some of the three qubits.

Three Qubits

A quantum system SS is described by its state space, a finite dimensional complex Hilbert space.✦ The composite system S⊗TS \otimes T of two systems SS and TT has for its state space the tensor product of their state spaces.✦ The qubit QQ is the system whose state space is ℂ2\mathbb{C}^2, and three qubits form the composite system Q⊗(Q⊗Q)Q \otimes (Q \otimes Q).

A pure state ψ\psi of a system SS is a unit vector in the state space of SS.✦ For pure states ψ\psi of SS and φ\varphi of TT, the product ψ⊗φ\psi \otimes \varphi is the pure state of S⊗TS \otimes T whose vector is the tensor product of the two vectors.✦ The basis states |0⟩|0\rangle and |1⟩|1\rangle of the qubit are the pure states given by the standard basis vectors e0e_0 and e1e_1 of ℂ2\mathbb{C}^2, and for bits q1q_1, q2q_2, q3q_3 the basis state of three qubits is the product |q1q2q3⟩=|q1⟩⊗(|q2⟩⊗|q3⟩).|q_1 q_2 q_3\rangle = |q_1\rangle \otimes \bigl(|q_2\rangle \otimes |q_3\rangle\bigr).(2)

Gates

A unitary UU of a system SS is an operator on the state space of SS with U†U=UU†=1U^\dagger U = U U^\dagger = 1; it carries a pure state ψ\psi of SS to the pure state UψU\psi. The composite UVUV of two unitaries UU and VV of SS applies first VV, then UU, and the identity evolution of SS is the unitary 11. For unitaries UU of SS and VV of TT, the product unitary U⊗VU \otimes V of S⊗TS \otimes T is the tensor product of the two operators.✦ A gate GG on a system of qubits is a unitary of that system; on a composite system, a gate acting on the first factor alone is U⊗1U \otimes 1, and one acting on the last factor alone is 1⊗V1 \otimes V.

The Pauli XX, the quantum NOT, is the unitary of the qubit with matrix X=(0110).X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}.(3)✦ For a unitary UU of a system SS, the controlled gate C(U)C(U) is the unitary of Q⊗SQ \otimes S, with the qubit as control and SS as target, given by C(U)=|0⟩⟨0|⊗1+|1⟩⟨1|⊗U.C(U) = |0\rangle\langle 0| \otimes 1 + |1\rangle\langle 1| \otimes U.(4)✦ The CNOT gate of two qubits is C(X)C(X).✦ For a unitary UU of the qubit, controlling once more gives the doubly controlled gate C2(U)=C(C(U))C^2(U) = C(C(U)) of three qubits, which applies UU to the third qubit when the first two are both |1⟩|1\rangle; the Toffoli gate is C2(X)C^2(X).

A unitary UU of a system SS is the same thing as a linear isometric bijection of the state space of SS onto itself.✦ The SWAP of two copies of SS is the unitary of S⊗SS \otimes S given by the isometry that exchanges the factors, SWAP(u⊗v)=v⊗u\mathrm{SWAP}(u \otimes v) = v \otimes u.✦ The reversed CNOT CNOTrev\mathrm{CNOT}^{\mathrm{rev}} of two qubits, the CNOT with its control on the second qubit and its target on the first, is the unitary of Q⊗QQ \otimes Q obtained by conjugating the CNOT with the SWAP of two qubits: CNOTrev=SWAPCNOTSWAP.\mathrm{CNOT}^{\mathrm{rev}} = \mathrm{SWAP}\;\mathrm{CNOT}\;\mathrm{SWAP}.(5)✦

The Circuit

Write CNOTi→j\mathrm{CNOT}_{i \to j} for a CNOT on three qubits with control on qubit ii and target on qubit jj, and TOFij→k\mathrm{TOF}_{ij \to k} for a Toffoli gate with controls on qubits ii and jj and target on qubit kk. On Q⊗(Q⊗Q)Q \otimes (Q \otimes Q), TOF12→3\mathrm{TOF}_{12 \to 3} is the Toffoli gate itself; CNOT1→2=C(X⊗1)\mathrm{CNOT}_{1 \to 2} = C(X \otimes 1) and TOF13→2=C(CNOTrev)\mathrm{TOF}_{13 \to 2} = C(\mathrm{CNOT}^{\mathrm{rev}}) are controlled by the first qubit; CNOT2→3=1⊗CNOT\mathrm{CNOT}_{2 \to 3} = 1 \otimes \mathrm{CNOT} and CNOT3→2=1⊗CNOTrev\mathrm{CNOT}_{3 \to 2} = 1 \otimes \mathrm{CNOT}^{\mathrm{rev}} act on the last two.

An identification ee of a system SS with a system TT is a linear isometric bijection of the state space of SS onto that of TT; its inverse e−1e^{-1} identifies TT with SS, and a unitary UU of SS is carried along ee to the unitary eUe−1e\,U\,e^{-1} of TT. The regrouping α\alpha of three systems S1S_1, S2S_2, S3S_3 is the identification of S1⊗(S2⊗S3)S_1 \otimes (S_2 \otimes S_3) with (S1⊗S2)⊗S3(S_1 \otimes S_2) \otimes S_3 that sends u⊗(v⊗w)u \otimes (v \otimes w) to (u⊗v)⊗w(u \otimes v) \otimes w.✦ The gate CNOT2→1\mathrm{CNOT}_{2 \to 1} is CNOTrev⊗1\mathrm{CNOT}^{\mathrm{rev}} \otimes 1 on (Q⊗Q)⊗Q(Q \otimes Q) \otimes Q carried along α−1\alpha^{-1} to three qubits: CNOT2→1=α−1(CNOTrev⊗1)α.\mathrm{CNOT}_{2 \to 1} = \alpha^{-1} \bigl(\mathrm{CNOT}^{\mathrm{rev}} \otimes 1\bigr)\, \alpha .(6)✦

The circuit UπU_\pi for the partial cyclic permutation is the unitary of three qubits that applies these gates in turn, the rightmost first: Uπ=CNOT2→3CNOT1→2TOF12→3CNOT3→2CNOT2→1TOF13→2CNOT2→1CNOT1→2.U_\pi = \mathrm{CNOT}_{2 \to 3}\, \mathrm{CNOT}_{1 \to 2}\, \mathrm{TOF}_{12 \to 3}\, \mathrm{CNOT}_{3 \to 2}\, \mathrm{CNOT}_{2 \to 1}\, \mathrm{TOF}_{13 \to 2}\, \mathrm{CNOT}_{2 \to 1}\, \mathrm{CNOT}_{1 \to 2} .(7)✦

The Claim

Theorem 1. Let q1q_1, q2q_2, q3q_3 be bits, and let (q1′,q2′,q3′)=π(q1,q2,q3)(q_1', q_2', q_3') = \pi(q_1, q_2, q_3) be their image under the partial cyclic permutation (1). Then the circuit UπU_\pi of (7) satisfies Uπ(|q1⟩⊗(|q2⟩⊗|q3⟩))=|q1′⟩⊗(|q2′⟩⊗|q3′⟩).U_\pi \bigl(|q_1\rangle \otimes (|q_2\rangle \otimes |q_3\rangle)\bigr) = |q_1'\rangle \otimes \bigl(|q_2'\rangle \otimes |q_3'\rangle\bigr).(8)✦

What Is Checked

The claim is stated over the circuit UπU_\pi of (7), the basis states (2) and the permutation π\pi of (1).

About these constructions the library proves that the controlled gate C(U)C(U) of (4) is unitary for every unitary UU of every system SS, C(U)†C(U)=C(U)C(U)†=1C(U)^\dagger C(U) = C(U)\,C(U)^\dagger = 1.✦ With it, and with the unitarity of XX, of composites and tensor products of unitaries and of a unitary carried along an identification, every gate of (7) and the circuit itself are unitaries of three qubits.