Lean, informalized

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

Exercise 4.18 - Swapping the two qubits before and after the controlled Z gate gives the same gate

The controlled Z gate is symmetric in its two qubits.

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 controlled Z gate acts on two qubits, a control and a target. When the control is in |0⟩|0\rangle the target is left alone; when it is in |1⟩|1\rangle the target undergoes the phase flip ZZ. The exercise is to show that the two qubits play the same part: the gate with the second qubit as control and the first as target is the same gate as the one with the first qubit as control.

A Quantum System

A quantum system SS is a physical object whose state space is a finite dimensional complex Hilbert space.✦ A pure state ψ\psi of SS is a vector of unit norm in the state space of SS, ‖ψ‖=1\lVert \psi \rVert = 1, determined physically up to a global phase.✦ The composite system S⊗TS \otimes T of two quantum systems SS and TT is the quantum system whose state space is the tensor product of the state spaces of SS and TT.✦

The qubit QQ is the two level quantum system with state space ℂ2\mathbb{C}^2.✦ For a bit ii, the basis state |i⟩|i\rangle of the qubit is the pure state whose vector is the standard basis vector eie_i of ℂ2\mathbb{C}^2, and |0⟩|0\rangle and |1⟩|1\rangle are the computational basis states.✦ Two qubits form the composite system Q⊗QQ \otimes Q.

Unitary Gates

A unitary UU of a quantum system SS is a closed evolution of SS: an operator on the state space of SS with U†U=UU†=1.U^\dagger U = U U^\dagger = 1 .(1)✦ For two unitaries UU and VV of the same system SS, the unitary UU after VV is the composite UVUV, which applies VV first and then UU.✦

The Pauli ZZ, the phase flip, is the unitary of the qubit whose matrix in the computational basis is Z=(100−1).Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} .(2)✦

For a unitary UU of a system SS, the controlled gate C(U)C(U) is the unitary of the composite system Q⊗SQ \otimes S of a control qubit and the target SS whose operator is C(U)=|0⟩⟨0|⊗1+|1⟩⟨1|⊗U,C(U) = |0\rangle\langle 0| \otimes 1 + |1\rangle\langle 1| \otimes U ,(3)✦ with |0⟩⟨0||0\rangle\langle 0| and |1⟩⟨1||1\rangle\langle 1| the projectors onto the basis states of the control and 11 the identity on the state space of SS. The controlled Z gate is CZ=C(Z)CZ = C(Z), with ZZ the Pauli matrix (2), a unitary of Q⊗QQ \otimes Q.✦

For a system SS, the swap SWAP\mathrm{SWAP} is the unitary of S⊗SS \otimes S that exchanges the two factors, so that for pure states |φ⟩|\varphi\rangle and |χ⟩|\chi\rangle of SS: SWAP(|φ⟩⊗|χ⟩)=|χ⟩⊗|φ⟩.\mathrm{SWAP}\,\bigl(|\varphi\rangle \otimes |\chi\rangle\bigr) = |\chi\rangle \otimes |\varphi\rangle .(4)✦ On Q⊗QQ \otimes Q it exchanges the two qubits.

The Claim

Exchanging the roles of the two qubits amounts to swapping them before the gate and swapping them back after it: the control then sits on the second qubit and the phase flip acts on the first.

Theorem 1. Let CZCZ be the controlled Z gate of two qubits and SWAP\mathrm{SWAP} the swap of Q⊗QQ \otimes Q. Then SWAPCZSWAP=CZ.\mathrm{SWAP}\; CZ \; \mathrm{SWAP} = CZ .(5)✦

What Is Checked

The claim (5) is stated over two unitaries of the two qubit system Q⊗QQ \otimes Q, the controlled Z gate C(Z)C(Z) of (3) and the swap (4), and over their product SWAPCZSWAP\mathrm{SWAP}\,CZ\,\mathrm{SWAP}, a composite of unitaries of Q⊗QQ \otimes Q.

The library proves that the operator (3) satisfies (1) for every unitary UU of every system SS, so that C(U)C(U) is a unitary, and that UU after VV is a unitary whenever UU and VV are, being a product of unitaries.