Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Density matrices are exactly the unit-trace positive semidefinite matrices

Proved
QAlgorithms.Nannicini.densityMatrix_iff

by Goku · Oct 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

lecture-notesnanniciniquantum-information

Let ρ\rhoρ be a complex 2q×2q2^q\times 2^q2q×2q matrix acting on qqq qubits. An ensemble of pure states is a family {pj,∣ψj⟩}j=1,…,m\{p_j,|\psi_j\rangle\}_{j=1,\dots,m}{pj​,∣ψj​⟩}j=1,…,m​ of unit vectors ∣ψj⟩∈(C2)⊗q|\psi_j\rangle\in(\mathbb C^2)^{\otimes q}∣ψj​⟩∈(C2)⊗q with probabilities pj≥0p_j\ge 0pj​≥0, ∑jpj=1\sum_j p_j=1∑j​pj​=1. Its density matrix is ∑jpj∣ψj⟩⟨ψj∣\sum_j p_j|\psi_j\rangle\langle\psi_j|∑j​pj​∣ψj​⟩⟨ψj​∣ (Definition 1.55). Then

∃ m, {pj,∣ψj⟩}j=1m an ensemble with ρ=∑j=1mpj∣ψj⟩⟨ψj∣  ⟺  Tr⁡ρ=1 and ρ⪰0.\exists\, m,\ \{p_j,|\psi_j\rangle\}_{j=1}^m \text{ an ensemble with } \rho=\sum_{j=1}^m p_j|\psi_j\rangle\langle\psi_j| \iff \operatorname{Tr}\rho=1 \text{ and } \rho\succeq 0.∃m, {pj​,∣ψj​⟩}j=1m​ an ensemble with ρ=j=1∑m​pj​∣ψj​⟩⟨ψj​∣⟺Trρ=1 and ρ⪰0.

This is the standard intrinsic description of mixed states. Later chapters use it to recognize a matrix as a quantum state without exhibiting an ensemble.

Formalization Note Positive semidefiniteness is Mathlib's Matrix.PosSemidef, which includes Hermiticity.

Preamble
import Definitions.Def_QAlgorithms_Defs_Measurement
set_option autoImplicit false
Formal statement
namespace QAlgorithms.Nannicini

open QAlgorithms

open scoped ComplexOrder


/-- Nannicini p.36, Theorem 1.60 (characterization of density matrices): a `q`-qubit matrix `ρ`
is the density matrix `∑_j p_j |ψ_j⟩⟨ψ_j|` of some ensemble `{p_j, |ψ_j⟩}_{j=1..m}` of pure
states (unit vectors) with probabilities `p_j ≥ 0`, `∑_j p_j = 1`, for some `m`, if and only if
`ρ` has unit trace and is positive semidefinite. -/
theorem densityMatrix_iff {q : ℕ} (ρ : Matrix (Qubits q) (Qubits q) ℂ) :
    (∃ (m : ℕ) (p : Fin m → ℝ) (ψ : Fin m → EuclideanSpace ℂ (Qubits q)),
        (∀ j, 0 ≤ p j) ∧ ∑ j, p j = 1 ∧ (∀ j, IsState (ψ j)) ∧ ρ = ensembleDensity p ψ) ↔
      ρ.trace = 1 ∧ ρ.PosSemidef := by sorry



end QAlgorithms.Nannicini
Source
Giacomo Nannicini, Quantum algorithms for optimizers, 2025, v5; notes dated 9 July 2025, PDF p. 36, Theorem 1.60. https://arxiv.org/pdf/2408.07086v5
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Setting. Let q≥0q \ge 0q≥0 and let ρ\rhoρ be a complex 2q×2q2^q \times 2^q2q×2q matrix whose rows and columns are indexed by {0,1}q\{0,1\}^q{0,1}q.

Claim. The following two conditions are equivalent.

  1. Ensemble form. There exist a natural number mmm, real weights p0,…,pm−1p_0,\dots,p_{m-1}p0​,…,pm−1​ and vectors ψ0,…,ψm−1∈C{0,1}q\psi_0,\dots,\psi_{m-1} \in \mathbb{C}^{\{0,1\}^q}ψ0​,…,ψm−1​∈C{0,1}q such that:
    • every pj≥0p_j \ge 0pj​≥0,
    • ∑jpj=1\sum_j p_j = 1∑j​pj​=1 (this forces m≥1m \ge 1m≥1),
    • every ψj\psi_jψj​ has norm 111,
    • and
ρ=∑j=0m−1pj ψjψj∗,\rho = \sum_{j=0}^{m-1} p_j\, \psi_j \psi_j^{*},ρ=j=0∑m−1​pj​ψj​ψj∗​,

meaning the (a,b)(a,b)(a,b) entry of ρ\rhoρ is ∑jpj (ψj)a(ψj)b‾\sum_j p_j\, (\psi_j)_a \overline{(\psi_j)_b}∑j​pj​(ψj​)a​(ψj​)b​​.

  1. Matrix conditions. tr⁡ρ=1\operatorname{tr}\rho = 1trρ=1 and ρ\rhoρ is positive semidefinite. Positive semidefinite means ρ\rhoρ is Hermitian and x∗ρx≥0x^{*}\rho x \ge 0x∗ρx≥0 for every complex vector xxx.

No bound on mmm is imposed, and the ψj\psi_jψj​ need not be distinct or orthogonal.

Human review
  • Endorsed by Shuze Chen · Oct 13, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Goku · Oct 13, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me