Lean, informalized

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

Exercise 4.16 - The four by four matrices of a Hadamard gate on the first or on the second qubit

Matrices of a Hadamard on one of 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

Two qubits sit on the two wires of a circuit. A Hadamard gate acts on one wire, and nothing acts on the other. The exercise asks for the 4×44 \times 4 unitary matrix of this circuit in the computational basis |00⟩,|01⟩,|10⟩,|11⟩|00\rangle, |01\rangle, |10\rangle, |11\rangle, once with the Hadamard on the first qubit and once with it on the second. The library states both matrices.

Two Qubits

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

A pure state ψ\psi of SS is a unit vector in the state space of SS, ‖ψ‖=1\lVert \psi \rVert = 1.✦ 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 state |i⟩|i\rangle of the qubit, for a bit i∈{0,1}i \in \{0, 1\}, is the pure state whose vector is the standard basis vector eie_i of ℂ2\mathbb{C}^2.✦ The products |i1i2⟩=|i1⟩⊗|i2⟩|i_1 i_2\rangle = |i_1\rangle \otimes |i_2\rangle are the computational basis states of Q⊗QQ \otimes Q.

Gates on Two Qubits

A unitary UU of a system SS is an operator on the state space of SS with U†U=UU†=IU^\dagger U = U U^\dagger = I.✦ The identity evolution II of SS is the unitary whose operator is the identity.✦ For unitaries UU of SS and VV of TT, the product unitary U⊗VU \otimes V is the unitary of S⊗TS \otimes T whose operator is the tensor product of the operators of UU and VV.✦ The gate UU on the first wire of S⊗TS \otimes T is the product unitary U⊗IU \otimes I, with the identity evolution on TT; the gate VV on the last wire is I⊗VI \otimes V.

The Hadamard HH is the unitary of the qubit whose operator is the matrix H=12(111−1)H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}(1)✦ acting on ℂ2\mathbb{C}^2.

The matrix [U][U] of a gate UU on two qubits, a unitary of Q⊗QQ \otimes Q, is the complex matrix with rows and columns labelled by pairs of bits and entries [U](i1,i2),(j1,j2)=⟨i1i2|U|j1j2⟩.[U]_{(i_1, i_2),(j_1, j_2)} = \langle i_1 i_2 |\, U \,| j_1 j_2 \rangle .(2)✦ The 4×44 \times 4 matrix of a matrix MM labelled in this way relabels both its rows and its columns through (i,j)↦2i+j(i, j) \mapsto 2i + j, so that they run through |00⟩,|01⟩,|10⟩,|11⟩|00\rangle, |01\rangle, |10\rangle, |11\rangle in this order.✦

The Claim

Theorem 1. In the computational basis of two qubits, ordered |00⟩,|01⟩,|10⟩,|11⟩|00\rangle, |01\rangle, |10\rangle, |11\rangle, the 4×44 \times 4 matrix of the Hadamard on the first qubit is [H⊗I]=12(1010010110−10010−1),[H \otimes I] = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ 1 & 0 & -1 & 0 \\ 0 & 1 & 0 & -1 \end{pmatrix},(3)✦ and the 4×44 \times 4 matrix of the Hadamard on the second qubit is [I⊗H]=12(11001−1000011001−1).[I \otimes H] = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 & 0 & 0 \\ 1 & -1 & 0 & 0 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & -1 \end{pmatrix}.(4)✦

What Is Checked

The claim is stated over the Hadamard HH of the qubit, placed on the first or the last wire of Q⊗QQ \otimes Q as the product unitary H⊗IH \otimes I or I⊗HI \otimes H with the identity evolution, and over the matrix (2) of a gate on two qubits in the basis of product states |i1⟩⊗|i2⟩|i_1\rangle \otimes |i_2\rangle, relabelled as a 4×44 \times 4 matrix.

Of these constructions the library proves that the matrix (1) is unitary, so that its operator on ℂ2\mathbb{C}^2 is a unitary of the qubit; that the tensor product of two unitaries is unitary, so that H⊗IH \otimes I and I⊗HI \otimes H are unitaries of Q⊗QQ \otimes Q; and that each product |i1⟩⊗|i2⟩|i_1\rangle \otimes |i_2\rangle is a unit vector, since the norm of a product vector is the product of the norms.