Documentation

CslibFrontier.Computability.Circuit.Quantum.GateMatrix

Bit-indexed matrices of the NOT, Hadamard and CNOT gates #

The register gates of CslibFrontier/Computability/Circuit/Quantum/Basic.lean are indexed by bit strings Fin k → Bool. Small protocols are easier to state with one basis index per qubit, as Bool for one qubit and Bool × Bool for two. This file provides the Bool × Bool-indexed CNOT matrix |a, b⟩ ↦ |a, b ⊕ a⟩ (Cslib.Quantum.Gate.cnotMatrix), the action of the Hadamard matrix Cslib.Quantum.Gate.hadamardMatrix on vectors, the identifications of the register gates Cslib.Quantum.Gate.cnot and Cslib.Quantum.Gate.not with cnotMatrix and the Pauli matrix X (Cslib.Quantum.pauliX) under the reindexings Fin 2 → Bool ≃ Bool × Bool and Fin 1 → Bool ≃ Bool (de Wolf, Section 1.4), and the computational-basis column characterization Cslib.Quantum.mem_unitaryGroup_iff_orthonormal_toEuclideanCLM_ket of unitarity (Arora and Barak, Claim 20.11).

Main definitions #

Main results #

References #

theorem Cslib.Quantum.toEuclideanCLM_ket {ι : Type u_1} [Fintype ι] [DecidableEq ι] (U : Matrix ι ι ℂ) (j : ι) :
(Matrix.toEuclideanCLM U) (ket j) = WithLp.toLp 2 fun (i : ι) => U i j

A matrix maps the computational basis state |j⟩ to its j-th column in Euclidean space.

A square complex matrix is unitary if and only if the images U |j⟩ of the computational basis vectors form an orthonormal family in EuclideanSpace ℂ ι Arora and Barak, Claim 20.11.

The Hadamard matrix maps v to ((v₀ + (-1)^b v₁)/√2)_b.

The CNOT matrix |a, b⟩ ↦ |a, b ⊕ a⟩ on two qubits indexed by Bool × Bool, the first qubit being the control.

theorem Cslib.Quantum.Gate.cnotMatrix_apply (p q : Bool × Bool) :
cnotMatrix p q = if p.1 = q.1 ∧ p.2 = (q.2 ^^ q.1) then 1 else 0
@[simp]
theorem Cslib.Quantum.Gate.cnot_apply (y x : Fin 2 → Bool) :
↑cnot y x = if y = Function.update x 1 (x 1 ^^ x 0) then 1 else 0
theorem Cslib.Quantum.Gate.not_apply (y x : Fin 1 → Bool) :
↑not y x = if y = fun (x_1 : Fin 1) => !x 0 then 1 else 0

The register gate cnot is the CNOT matrix, reindexed by Fin 2 → Bool ≃ Bool × Bool.

The register gate not is the Pauli matrix X, reindexed by Fin 1 → Bool ≃ Bool.