Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Lemma 5.3, proof — a projection matrix has trace(A)=rank(A)\mathrm{trace}(A) = \mathrm{rank}(A)trace(A)=rank(A)

Proved
TraceEstimation.ProjectionRank.trace_eq_rank

by mikedeng1 · Sep 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

linear-algebrap2o-batch-p200ap2o-gran-per-chapterp2o-plan-paperp2o-v1projection-matrixtrace

Let A∈Rn×nA \in \mathbb{R}^{n\times n}A∈Rn×n be an orthogonal projection matrix, that is, AAA is symmetric and A2=AA^2 = AA2=A. Then

trace(A)=rank(A).\mathrm{trace}(A) = \mathrm{rank}(A).trace(A)=rank(A).

In particular the trace of a projection is an integer. This is why estimating the trace of a projection to absolute error below 12\tfrac1221​ determines it exactly by rounding, which is the last step of Lemma 5.3.

Formalization Note "Projection matrix" is read as orthogonal projection (A.IsHermitian and A * A = A), as elsewhere in the mission. The identity also holds for oblique idempotents, but the mission uses only the symmetric case. The rank is Mathlib's Matrix.rank, cast to R\mathbb{R}R.

Preamble
import Mathlib
import Definitions.Def_TraceEstimation_Shared_gaussianEstimator
Formal statement
namespace TraceEstimation.ProjectionRank

open MeasureTheory ProbabilityTheory Matrix

/-- Avron–Toledo, Lemma 5.3, proof (p. 8:9), last paragraph: a projection matrix has
`trace(A) = rank(A)`. "Projection matrix" is read as an orthogonal projection: `A` symmetric
(`A.IsHermitian`) and idempotent (`A * A = A`), i.e. symmetric with eigenvalues in `{0, 1}`,
which is the form `A = Uᵀ diag(1,…,1,0,…,0) U` the proof uses. -/
theorem trace_eq_rank {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (hA : A.IsHermitian)
    (hA2 : A * A = A) :
    A.trace = (A.rank : ℝ) := by sorry

end TraceEstimation.ProjectionRank
Source
Avron and Toledo, Randomized algorithms for estimating the trace of an implicit symmetric positive semi-definite matrix, J. ACM 58(2), Article 8 (2011), p. 8:9, proof of Lemma 5.3, last paragraph
Human review
  • Endorsed by Shuze Chen · Oct 1, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 1, 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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me