Finite-dimensional quantum states, partial traces, entropies and erasure codes (Harlow TASI §4)
DefinitionHarlowTASI_QuantumBasicsBasic finite-dimensional quantum-information vocabulary used throughout Harlow's lectures, §4 and §5.
All Hilbert spaces are finite-dimensional and are modelled by coordinates: a space with orthonormal basis indexed by a finite set is , and operators are complex matrices. A bipartite space is , and is the Kronecker product.
- An isometry is a matrix with . A code subspace is represented by an isometry whose columns form an orthonormal basis of ; an operator on is a matrix, and the code state is .
- A unitary between two index sets is a matrix with and .
- A density matrix is a positive semidefinite matrix of trace one.
- Partial traces and of an operator on .
- The von Neumann entropy over the eigenvalues of a Hermitian (with ), eq. (5.14).
- The relative entropy , eq. (5.17), computed from spectral decompositions , as
with terms having or equal to , and terms having , , equal to . 7. Reduced density matrices of a pure state . 8. The reference state of eq. (4.18), , with the reference system indexed by the code basis. 9. For qudits of dimension and a set of sites, the splitting , and the predicate "the encoded information is accessible from ": every logical operator has an acting on alone with and for all code states (condition (1) of Theorem 4.1, as used in the derivation of the quantum Singleton bound).
These notions are shared by every statement of the mission.
Formalization Note Entropies are defined through the eigen-decomposition of a Hermitian matrix and take the junk value on non-Hermitian input; they are only ever applied to density matrices. The relative entropy is valued in EReal so that the value (support of not contained in that of ) is representable.
import Mathlib
/-!
# Harlow, TASI Lectures on the Emergence of Bulk Physics in AdS/CFT — basic quantum notions
Finite-dimensional Hilbert spaces are modelled as `ℂ^ι` for a finite index type `ι`, and
operators as complex matrices indexed by `ι`. A bipartite space `H_R ⊗ H_R̄` is indexed by the
product type `R × Rb`, and `X ⊗ₖ Y` is the Kronecker (tensor) product of matrices.
A code subspace `H_code ⊆ H_R ⊗ H_R̄` is described by an isometry `V : ℂ^C → H_R ⊗ H_R̄`
whose columns form an orthonormal basis `|ĩ⟩` of `H_code`.
-/
namespace HarlowTASI
open Matrix
open scoped Kronecker ComplexOrder
noncomputable section
/-- `V` is an isometry: `V† V = 1`. Its columns are then an orthonormal basis of its range. -/
def IsIsometry {m n : Type} [Fintype m] [DecidableEq n] (V : Matrix m n ℂ) : Prop :=
Vᴴ * V = 1
/-- `U` is unitary (possibly between two differently indexed spaces of equal dimension):
`U† U = 1` and `U U† = 1`. -/
def IsUnitaryMatrix {m n : Type} [Fintype m] [Fintype n] [DecidableEq m] [DecidableEq n]
(U : Matrix m n ℂ) : Prop :=
Uᴴ * U = 1 ∧ U * Uᴴ = 1
/-- A density matrix (mixed state): positive semidefinite with unit trace. -/
def IsDensityMatrix {n : Type} [Fintype n] (ρ : Matrix n n ℂ) : Prop :=
ρ.PosSemidef ∧ ρ.trace = 1
/-- Partial trace over the second tensor factor: `(Tr_B X)_{ij} = ∑_k X_{(i,k),(j,k)}`. -/
def traceRight {A B : Type} [Fintype B] (X : Matrix (A × B) (A × B) ℂ) : Matrix A A ℂ :=
fun i j => ∑ k, X (i, k) (j, k)
/-- Partial trace over the first tensor factor: `(Tr_A X)_{ij} = ∑_k X_{(k,i),(k,j)}`. -/
def traceLeft {A B : Type} [Fintype A] (X : Matrix (A × B) (A × B) ℂ) : Matrix B B ℂ :=
fun i j => ∑ k, X (k, i) (k, j)
/-- Von Neumann entropy `S(ρ) = -Tr(ρ log ρ) = -∑ λ log λ` over the eigenvalues `λ` of a
Hermitian matrix `ρ` (with `0 log 0 = 0`). Junk value `0` on non-Hermitian input. -/
noncomputable def vonNeumannEntropy {n : Type} [Fintype n] [DecidableEq n]
(ρ : Matrix n n ℂ) : ℝ :=
if h : ρ.IsHermitian then ∑ i, Real.negMulLog (h.eigenvalues i) else 0
/-- Quantum relative entropy `S(ρ|σ) = Tr(ρ log ρ) - Tr(ρ log σ)`, valued in the extended reals.
Writing `ρ = ∑ pᵢ |uᵢ⟩⟨uᵢ|`, `σ = ∑ qⱼ |vⱼ⟩⟨vⱼ|` (spectral decompositions) and
`wᵢⱼ = |⟨uᵢ, vⱼ⟩|²`, it is `∑ᵢⱼ wᵢⱼ pᵢ (log pᵢ - log qⱼ)`, where a term with `pᵢ = 0` or
`wᵢⱼ = 0` is `0`, and a term with `pᵢ ≠ 0`, `wᵢⱼ ≠ 0`, `qⱼ = 0` is `+∞` (so `S(ρ|σ) = +∞`
exactly when the support of `ρ` is not contained in that of `σ`, for density matrices).
Junk value `0` on non-Hermitian input. -/
noncomputable def relativeEntropy {n : Type} [Fintype n] [DecidableEq n]
(ρ σ : Matrix n n ℂ) : EReal :=
if h : ρ.IsHermitian ∧ σ.IsHermitian then
∑ i, ∑ j,
(if h.1.eigenvalues i = 0 ∨
‖inner ℂ (h.1.eigenvectorBasis i) (h.2.eigenvectorBasis j)‖ = 0 then (0 : EReal)
else if h.2.eigenvalues j = 0 then ⊤
else (((‖inner ℂ (h.1.eigenvectorBasis i) (h.2.eigenvectorBasis j)‖ ^ 2 *
h.1.eigenvalues i * (Real.log (h.1.eigenvalues i) - Real.log (h.2.eigenvalues j)) : ℝ))
: EReal))
else 0
/-- Reduced density matrix on `S ⊗ B` of the pure state `|ψ⟩ ∈ S ⊗ A ⊗ B` (trace over `A`):
`ρ_{SB}((s,b),(s',b')) = ∑_a ψ(s,a,b) · conj ψ(s',a,b')`. -/
def reducedSB {S A B : Type} [Fintype A] (ψ : S × A × B → ℂ) : Matrix (S × B) (S × B) ℂ :=
fun x y => ∑ a, ψ (x.1, a, x.2) * star (ψ (y.1, a, y.2))
/-- Reduced density matrix on `S` of the pure state `|ψ⟩ ∈ S ⊗ A ⊗ B`. -/
def reducedS {S A B : Type} [Fintype A] [Fintype B] (ψ : S × A × B → ℂ) : Matrix S S ℂ :=
fun s s' => ∑ a, ∑ b, ψ (s, a, b) * star (ψ (s', a, b))
/-- Reduced density matrix on `B` of the pure state `|ψ⟩ ∈ S ⊗ A ⊗ B`. -/
def reducedB {S A B : Type} [Fintype S] [Fintype A] (ψ : S × A × B → ℂ) : Matrix B B ℂ :=
fun b b' => ∑ s, ∑ a, ψ (s, a, b) * star (ψ (s, a, b'))
/-- The state `|φ⟩ = |S|^{-1/2} ∑ᵢ |i⟩_S |ĩ⟩_{RR̄}` of eq. (4.18), where the reference system
`S` is indexed by the same finite type `C` as the code basis, `|ĩ⟩ = V |i⟩`. As a function on
`S × R × R̄`: `φ(s, r, b) = |C|^{-1/2} V_{(r,b), s}`. -/
noncomputable def codeReferenceState {R Rb C : Type} [Fintype C]
(V : Matrix (R × Rb) C ℂ) : C × R × Rb → ℂ :=
fun x => ((Real.sqrt (Fintype.card C) : ℝ) : ℂ)⁻¹ * V (x.2.1, x.2.2) x.1
/-- Qudit systems: for a set `A` of sites among `n` qudits of dimension `d`, the
identification `(ℂ^d)^{⊗ n} ≅ (ℂ^d)^{⊗ A} ⊗ (ℂ^d)^{⊗ Aᶜ}` applied to the row index of an
encoding map `V : ℂ^{code} → (ℂ^d)^{⊗ n}`. -/
def splitAt {n d : ℕ} {C : Type} (A : Finset (Fin n)) (V : Matrix (Fin n → Fin d) C ℂ) :
Matrix (({i // i ∈ A} → Fin d) × ({i // i ∉ A} → Fin d)) C ℂ :=
V.submatrix (Equiv.piEquivPiSubtypeProd (fun i => i ∈ A) (fun _ => Fin d)).symm id
/-- The logical information encoded by `V` into `n` qudits is accessible from the set of
qudits `A` in the sense of condition (1) of Theorem 4.1: every logical operator `O` has a
representative `O_A` acting only on the qudits in `A` such that `O_A |ψ̃⟩ = O |ψ̃⟩` and
`O_A† |ψ̃⟩ = O† |ψ̃⟩` for every code state `|ψ̃⟩`. -/
def AccessibleFrom {n d : ℕ} {C : Type} [Fintype C] [DecidableEq C]
(V : Matrix (Fin n → Fin d) C ℂ) (A : Finset (Fin n)) : Prop :=
∀ O : Matrix C C ℂ, ∃ OA : Matrix ({i // i ∈ A} → Fin d) ({i // i ∈ A} → Fin d) ℂ,
(OA ⊗ₖ (1 : Matrix ({i // i ∉ A} → Fin d) ({i // i ∉ A} → Fin d) ℂ)) * splitAt A V
= splitAt A V * O ∧
(OAᴴ ⊗ₖ (1 : Matrix ({i // i ∉ A} → Fin d) ({i // i ∉ A} → Fin d) ℂ)) * splitAt A V
= splitAt A V * Oᴴ
end
end HarlowTASI
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic) - NON-BLIND: same agent that drafted the statements
Non-blind read-back — not independent testimony. This read-back was written by the same agent (Aristotle, by Harmonic) that drafted the Lean statements, with full knowledge of the source lectures and of the intended meaning. It was not produced blind by an independent auditor, so it must not be mistaken for independent testimony; reviewers should treat it as the drafter's own rendering of the code and check the Lean text directly.
This file introduces the following notions for finite index sets (all matrices have complex entries).
- Isometry. A matrix (rows indexed by , columns by ) is an isometry iff .
- Unitary. (rows , columns ) is unitary iff and .
- Density matrix. A square is a density matrix iff it is positive semidefinite (Hermitian with , in the complex order) and .
- Partial traces. For indexed by pairs : and .
- Von Neumann entropy. If is Hermitian with eigenvalues (listed with multiplicity), , using the convention (and, for negative , the real-logarithm convention ); if is not Hermitian, .
- Relative entropy (an extended real number). If are both Hermitian, with eigenvalues , and orthonormal eigenvector bases , (as chosen by the library), let . Then
If either matrix is not Hermitian, the value is .
- Reduced states of a tripartite vector. For : ; ; . No normalization of is assumed.
- Reference state. For with rows indexed by and columns by a finite set , for , where is the number of elements of (if is empty, is the empty function).
- Splitting qudits. For , a subset and a matrix whose rows are indexed by functions , is with rows re-indexed by pairs of functions on and on its complement (the row is the row of the function that agrees with on and with off ).
- Accessible from . For with columns indexed by a finite set : for every matrix there exists a matrix indexed by functions on such that
No isometry assumption is built into this predicate.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.