Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 6.2.1 — Hanson-Wright inequality

Proved
HighDimProb.QuadraticForms.hanson_wright

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

chaosconcentrationhanson-wrightprobabilityrandom-matrix-theory

This is the Hanson-Wright inequality, the capstone result of Chapter 6 of Vershynin's High-Dimensional Probability: a concentration inequality for a quadratic form ("chaos") in independent sub-gaussian random variables, playing the role for chaoses that Bernstein's inequality (Chapter 2) plays for linear sums.

Let X=(X1,…,Xn)∈RnX = (X_1, \dots, X_n) \in \mathbb R^nX=(X1​,…,Xn​)∈Rn be a random vector with independent, mean zero, sub-gaussian coordinates, and let K=max⁡i∥Xi∥ψ2K = \max_i \|X_i\|_{\psi_2}K=maxi​∥Xi​∥ψ2​​ be the largest of their sub-gaussian (Orlicz ψ2\psi_2ψ2​) norms. Let AAA be an n×nn \times nn×n matrix — with no constraint on its diagonal. Then, for every t≥0t \ge 0t≥0,

P{ ∣X⊤AX−E X⊤AX∣≥t }  ≤  2exp⁡ ⁣[−cmin⁡ ⁣(t2K4∥A∥F2, tK2∥A∥)],P\bigl\{\,|X^\top A X - \mathbb E\, X^\top A X| \ge t \,\bigr\} \;\le\; 2 \exp\!\left[-c \min\!\left(\frac{t^2}{K^4 \|A\|_F^2},\ \frac{t}{K^2 \|A\|}\right)\right],P{∣X⊤AX−EX⊤AX∣≥t}≤2exp[−cmin(K4∥A∥F2​t2​, K2∥A∥t​)],

where ∥A∥F\|A\|_F∥A∥F​ is the Frobenius norm and ∥A∥\|A\|∥A∥ the operator norm of AAA, and c>0c > 0c>0 is an absolute constant, not depending on nnn, XXX, AAA, or ttt.

The bound has the familiar two-regime shape of Bernstein's inequality: sub-gaussian (quadratic exponent) for small ttt, and sub-exponential (linear exponent) for large ttt, reflecting that a quadratic form in sub-gaussian variables behaves like a sub-exponential, not sub-gaussian, random variable. Unlike the Decoupling theorem's diagonal-free hypothesis, AAA here is a general matrix: its diagonal contributes to E X⊤AX=tr⁡(A)⋅(a common second moment when the Xi are i.i.d.)\mathbb E\, X^\top A X = \operatorname{tr}(A) \cdot (\text{a common second moment when the } X_i \text{ are i.i.d.})EX⊤AX=tr(A)⋅(a common second moment when the Xi​ are i.i.d.) (more precisely ∑iAii EXi2\sum_i A_{ii}\, \mathbb E X_i^2∑i​Aii​EXi2​ in general) and is handled by Bernstein's inequality directly in the proof, while the off-diagonal part is handled by decoupling; keeping AAA general is what makes this the actual content of the chapter, rather than a restatement of Bernstein's inequality for the special case of diagonal AAA.

Formalization Note K=max⁡i∥Xi∥ψ2K = \max_i \|X_i\|_{\psi_2}K=maxi​∥Xi​∥ψ2​​ is written directly as sup⁡i∥Xi∥ψ2\sup_i \|X_i\|_{\psi_2}supi​∥Xi​∥ψ2​​ (⨆ i, HighDimProb.Concentration.subgaussianNorm P (X i), reusing this series' published sub-gaussian norm), and ccc is existentially quantified before nnn, Ω\OmegaΩ, PPP, XXX, and AAA, so it cannot depend on any of them, matching the book's "absolute constant". Each coordinate's sub-gaussianity is stated as membership in the admissible set of the sub-gaussian norm's own definition (some finite s>0s > 0s>0 with the exponential moment integrable and at most 222), the same idiom used for the sub-exponential hypothesis in this series' Bernstein's inequality. The quadratic form X⊤AXX^\top A XX⊤AX itself is required Integrable, so that E X⊤AX\mathbb E\, X^\top A XEX⊤AX is a genuine expectation and not Mathlib's junk value 000 for a non-integrable integrand — a fact that in principle follows from sub-gaussianity of the XiX_iXi​ but is not itself proved by this draft (:= by sorry). ∥A∥F\|A\|_F∥A∥F​ and ∥A∥\|A\|∥A∥ are this mission's own frobeniusNorm and opNorm. No hypothesis is imposed on AAA's diagonal: the general matrix case is the chapter's actual content, and restricting to diagonal-free AAA would collapse the statement to a restatement of Bernstein's inequality.

Preamble
import Mathlib
import Definitions.Def_HighDimProb_Concentration_SubgaussianNorm
import Definitions.Def_HighDimProb_QuadraticForms_FrobeniusNorm
import Definitions.Def_HighDimProb_QuadraticForms_OperatorNorm

open MeasureTheory ProbabilityTheory
Formal statement
namespace HighDimProb.QuadraticForms

/-- **Theorem 6.2.1** (Hanson-Wright inequality), Vershynin, *High-Dimensional Probability*
(2018), p. 139.

Let `X = (X₁, …, Xₙ) ∈ ℝⁿ` be a random vector with independent, mean zero, sub-gaussian
coordinates. Let `A` be an `n × n` matrix. Then, for every `t ≥ 0`,

`P{|XᵀAX − E XᵀAX| ≥ t} ≤ 2 exp[−c min(t²/(K⁴‖A‖_F²), t/(K²‖A‖))]`,

where `K = maxᵢ ‖Xᵢ‖_{ψ₂}` and `c > 0` is an absolute constant (not depending on `n`, `X`, `A`,
or `t`). -/
theorem hanson_wright :
    ∃ c : ℝ, 0 < c ∧
      ∀ {n : ℕ} {Ω : Type} [MeasurableSpace Ω] (P : Measure Ω) [IsProbabilityMeasure P]
        (X : Fin n → Ω → ℝ),
        (∀ i, Measurable (X i)) →
        iIndepFun X P →
        (∀ i, Integrable (X i) P) →
        (∀ i, ∫ ω, X i ω ∂P = 0) →
        (∀ i, ∃ s > 0, Integrable (fun ω => Real.exp ((X i ω) ^ 2 / s ^ 2)) P ∧
                       ∫ ω, Real.exp ((X i ω) ^ 2 / s ^ 2) ∂P ≤ 2) →
        ∀ (A : Matrix (Fin n) (Fin n) ℝ),
        Integrable (fun ω => ∑ i, ∑ j, A i j * X i ω * X j ω) P →
        ∀ {t : ℝ}, 0 ≤ t →
        P.real {ω | t ≤ |∑ i, ∑ j, A i j * X i ω * X j ω -
                          ∫ ω, ∑ i, ∑ j, A i j * X i ω * X j ω ∂P|} ≤
          2 * Real.exp (-(c * min
            (t ^ 2 / ((⨆ i, HighDimProb.Concentration.subgaussianNorm P (X i)) ^ 4 *
                       frobeniusNorm A ^ 2))
            (t / ((⨆ i, HighDimProb.Concentration.subgaussianNorm P (X i)) ^ 2 *
                   opNorm A)))) := by sorry

end HighDimProb.QuadraticForms
Source
Vershynin, High-Dimensional Probability (2018), Theorem 6.2.1, p. 139 (PDF p. 147)
Read-back

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

There exists a real number ccc with c>0c > 0c>0 such that the following holds for every natural number nnn, every type Ω\OmegaΩ equipped with a measurable-space structure, every measure PPP on Ω\OmegaΩ that is a probability measure, and every family X=(X1,…,Xn)X = (X_1, \dots, X_n)X=(X1​,…,Xn​) of real-valued functions Xi:Ω→RX_i : \Omega \to \mathbb{R}Xi​:Ω→R indexed by i∈{0,1,…,n−1}i \in \{0, 1, \dots, n-1\}i∈{0,1,…,n−1}, provided all of the following hypotheses hold:

  • each XiX_iXi​ is measurable;
  • the family (Xi)i(X_i)_i(Xi​)i​ is mutually independent under PPP (independence of the whole family, not merely pairwise);
  • each XiX_iXi​ is integrable with respect to PPP;
  • each XiX_iXi​ has vanishing integral: ∫ΩXi dP=0\int_\Omega X_i \, dP = 0∫Ω​Xi​dP=0;
  • each XiX_iXi​ satisfies the following sub-gaussian-style condition: there exists s>0s > 0s>0 such that ω↦exp⁡ ⁣(Xi(ω)2/s2)\omega \mapsto \exp\!\big(X_i(\omega)^2 / s^2\big)ω↦exp(Xi​(ω)2/s2) is PPP-integrable and ∫Ωexp⁡ ⁣(Xi(ω)2/s2) dP≤2\int_\Omega \exp\!\big(X_i(\omega)^2/s^2\big)\, dP \le 2∫Ω​exp(Xi​(ω)2/s2)dP≤2. Note that the witness sss is existentially quantified per coordinate and is not the quantity appearing later in the conclusion;

then for every n×nn \times nn×n real matrix AAA such that the quadratic form

Q(ω)  =  ∑i∑jAi,j Xi(ω) Xj(ω)Q(\omega) \;=\; \sum_{i} \sum_{j} A_{i,j}\, X_i(\omega)\, X_j(\omega)Q(ω)=i∑​j∑​Ai,j​Xi​(ω)Xj​(ω)

is PPP-integrable, and for every real ttt with t≥0t \ge 0t≥0,

P({ ω  :  t≤∣ Q(ω)−∫ΩQ dP ∣ })  ≤  2exp⁡ ⁣(− c⋅min⁡(t2K4 ∥A∥F2,  tK2 ∥A∥op)),P\Big(\big\{\, \omega \;:\; t \le \big|\, Q(\omega) - \textstyle\int_\Omega Q \, dP \,\big| \,\big\}\Big) \;\le\; 2\exp\!\left(-\, c \cdot \min\left( \frac{t^2}{K^4 \,\|A\|_F^2},\; \frac{t}{K^2\, \|A\|_{\mathrm{op}}} \right)\right),P({ω:t≤​Q(ω)−∫Ω​QdP​})≤2exp(−c⋅min(K4∥A∥F2​t2​,K2∥A∥op​t​)),

where the probability on the left is the real-valued measure of that set, and where the three quantities KKK, ∥A∥F\|A\|_F∥A∥F​, ∥A∥op\|A\|_{\mathrm{op}}∥A∥op​ are as follows.

KKK denotes the supremum over iii of a quantity written subgaussianNorm P (X i) — a definition imported from this bundle rather than a Mathlib standard, so its precise content is not visible in this statement; the read-back can only record that it is some real-valued function of the measure PPP and the coordinate function XiX_iXi​, and that KKK is the indexed supremum ⨆i\bigsqcup_i⨆i​ of those values over iii in the index type. Likewise frobeniusNorm A and opNorm A are definitions imported from this bundle, written here as ∥A∥F\|A\|_F∥A∥F​ and ∥A∥op\|A\|_{\mathrm{op}}∥A∥op​; nothing in this statement constrains what they compute, and no hypothesis asserts that either is nonzero, nor that KKK is finite, positive, or attained.

Note the exact structure of the quantifiers: the constant ccc is chosen once, outermost, before nnn, Ω\OmegaΩ, PPP, XXX, AAA and ttt, so it is uniform in all of them — this is the formal content of "absolute constant". The index type of the coordinates is {0,…,n−1}\{0,\dots,n-1\}{0,…,n−1} (a finite type of cardinality nnn), and both sums in QQQ range over that full index type. The inequality in the conclusion is non-strict (≤\le≤), the event is defined by the non-strict inequality t≤∣⋅∣t \le |\cdot|t≤∣⋅∣ (so the boundary case ∣Q−EQ∣=t|Q - \mathbb{E}Q| = t∣Q−EQ∣=t is included in the event), and the hypothesis on ttt is 0≤t0 \le t0≤t, admitting t=0t = 0t=0. The ambient type Ω\OmegaΩ is quantified over Type (the lowest universe), not over an arbitrary universe. No hypothesis requires AAA to be symmetric, to have zero diagonal, or to be nonzero; no hypothesis bounds nnn; no hypothesis asserts that Xi2X_i^2Xi2​ or XiXjX_iX_jXi​Xj​ are integrable beyond the single integrability assumption on the full quadratic form QQQ.

In the degenerate cases the hypotheses permit, the statement reads as follows. When n=0n = 0n=0 the index type is empty: the independence, measurability, centering and exponential-moment hypotheses are vacuously satisfied, AAA is the unique 0×00\times 00×0 matrix, QQQ is identically 000 (an empty sum) and integrable, and KKK is the supremum of the empty family, which in Lean's complete-lattice-style indexed supremum over R\mathbb{R}R is the default value 000 rather than −∞-\infty−∞; consequently both K4∥A∥F2K^4\|A\|_F^2K4∥A∥F2​ and K2∥A∥opK^2\|A\|_{\mathrm{op}}K2∥A∥op​ are 000, and both arguments of the minimum are divisions by zero, which in Lean evaluate to 000; the minimum is then 000, the right-hand side is 2exp⁡(0)=22\exp(0) = 22exp(0)=2, and the left-hand side is a probability, so the claim holds but carries no information. The same collapse to right-hand side 222 occurs whenever ∥A∥F=0\|A\|_F = 0∥A∥F​=0 or ∥A∥op=0\|A\|_{\mathrm{op}} = 0∥A∥op​=0 (for instance A=0A = 0A=0) or whenever K=0K = 0K=0: each quotient becomes 0/0=00/0 = 00/0=0 or x/0=0x/0 = 0x/0=0 by Lean's total division, so the bound degenerates to the trivial bound 222. When t=0t = 0t=0 the event is all of Ω\OmegaΩ and the left-hand side is 111, while the right-hand side is 2exp⁡(−c⋅min⁡(0,0))=22\exp(-c \cdot \min(0, 0)) = 22exp(−c⋅min(0,0))=2 if the denominators are nonzero, so the claim again holds trivially. If KKK is the supremum of an unbounded family of sub-gaussian norms, the indexed supremum over R\mathbb{R}R is not +∞+\infty+∞ but the junk default 000, again collapsing the bound to 222 — though for n≥1n \ge 1n≥1 the family is finite and hence bounded, so this arises only through the n=0n = 0n=0 case or through subgaussianNorm itself returning unexpected values. The hypothesis package is nonvacuous — the all-zero coordinate functions on any probability space satisfy every hypothesis, with ∫exp⁡(0/s2)=1≤2\int \exp(0/s^2) = 1 \le 2∫exp(0/s2)=1≤2 — so the theorem is not vacuously true by unsatisfiable premises; but nothing in the statement forces KKK to be an upper bound on the actual sub-gaussian behaviour of the XiX_iXi​, since subgaussianNorm is opaque here, and nothing links the existentially quantified witnesses sss in the fifth hypothesis to KKK.

Human review
  • Endorsed by Shuze Chen · Sep 28, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 28, 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