Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Lemma 23.4 (Johnson–Lindenstrauss): for finite Q and ε = √(6 log(2|Q|/δ)/n) ≤ 3/4, a random N(0,1/n) matrix has sup_{x∈Q} |‖Wx‖²/‖x‖² − 1| < ε with probability ≥ 1 − δ

Proved
UnderstandingML.johnson_lindenstrauss

by naimengye · Sep 24, 2026 · Mathlib 0df444a (Lean v4.33.1)

concentrationjohnson-lindenstraussrandom-projections

Lemma 23.4 (Johnson-Lindenstrauss Lemma). Let QQQ be a finite set of vectors in Rd\mathbb{R}^dRd. Let δ∈(0,1)\delta \in (0,1)δ∈(0,1) and nnn be an integer such that ϵ=6log⁡(2∣Q∣/δ)/n≤3/4\epsilon = \sqrt{6\log(2|Q|/\delta)/n} \le 3/4ϵ=6log(2∣Q∣/δ)/n​≤3/4. Then, with probability of at least 1−δ1 - \delta1−δ over a choice of a random matrix W∈Rn×dW \in \mathbb{R}^{n \times d}W∈Rn×d such that each element of WWW is distributed normally with zero mean and variance of 1/n1/n1/n we have

sup⁡x∈Q∣∥Wx∥2∥x∥2−1∣<ϵ.\sup_{x \in Q}\Big|\frac{\|Wx\|^2}{\|x\|^2} - 1\Big| < \epsilon.x∈Qsup​​∥x∥2∥Wx∥2​−1​<ϵ.

Formally: the vectors of QQQ are nonzero, n≥1n \ge 1n≥1, and the failure event {∃x∈Q:∣∥Wx∥2/∥x∥2−1∣≥ϵ}\{\exists x \in Q : |\|Wx\|^2/\|x\|^2 - 1| \ge \epsilon\}{∃x∈Q:∣∥Wx∥2/∥x∥2−1∣≥ϵ} has probability at most δ\deltaδ.

Why ϵ≤3/4\epsilon \le 3/4ϵ≤3/4. The lemma is Lemma 23.3 with a union bound over QQQ. The printed condition ϵ≤3\epsilon \le 3ϵ≤3 inherits Lemma 23.3's false range: with ∣Q∣=1|Q| = 1∣Q∣=1, ϵ=1\epsilon = 1ϵ=1 and large nnn, P[χn2≥2n]P[\chi^2_n \ge 2n]P[χn2​≥2n] exceeds δ=2e−n/6\delta = 2e^{-n/6}δ=2e−n/6. The proofs that use the lemma (Lemma 23.12) apply it at ϵ/2<1/2\epsilon/2 < 1/2ϵ/2<1/2.

Preamble
import Definitions.Def_UnderstandingML_DimReduction

open MeasureTheory ProbabilityTheory
Formal statement
namespace UnderstandingML

/-- **Lemma 23.4 (Johnson-Lindenstrauss Lemma)** (p. 329). Let `Q` be a finite set of vectors in
`ℝ^d`. Let `δ ∈ (0, 1)` and `n` be an integer such that `ε = √(6 log(2|Q|/δ)/n) ≤ 3/4`. Then, with
probability of at least `1 − δ` over a choice of a random matrix `W ∈ ℝ^{n×d}` such that each
element of `W` is distributed normally with zero mean and variance of `1/n` we have
`sup_{x ∈ Q} |‖Wx‖²/‖x‖² − 1| < ε`. The vectors of `Q` are nonzero and `n ≥ 1`. The book's condition `ε ≤ 3` inherits the false range of
Lemma 23.3: for `|Q| = 1` and `ε = 1` it fails for large `n`. -/
theorem johnson_lindenstrauss {d : ℕ} (Q : Finset (Fin d → ℝ)) (hQ : ∀ x ∈ Q, x ≠ 0) (δ : ℝ)
    (hδ : 0 < δ) (hδ1 : δ < 1) (n : ℕ) (hn : 0 < n)
    (hε : Real.sqrt (6 * Real.log (2 * Q.card / δ) / n) ≤ 3 / 4) :
    gaussianMatrixLaw n d (n : NNReal)⁻¹
      {W | ∃ x ∈ Q, Real.sqrt (6 * Real.log (2 * Q.card / δ) / n) ≤
        |sqNorm ((Matrix.of W).mulVec x) / sqNorm x - 1|} ≤ ENNReal.ofReal δ := by sorry

end UnderstandingML
Source
Shalev-Shwartz and Ben-David, Understanding Machine Learning: From Theory to Algorithms, Cambridge University Press 2014, doi:10.1017/CBO9781107298019, §23.2 pp. 329-330, Lemma 23.4 with its proof
Human review
  • Endorsed by Shuze Chen · Sep 25, 2026

    Confirmed by the moderator at approval.

  • Endorsed by naimengye · Sep 25, 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