Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 9 — McDiarmid's inequality P{f−Ef≥t}≤e−2t2/∑ici2P\{f-\mathbf Ef\ge t\}\le e^{-2t^2/\sum_i c_i^2}P{f−Ef≥t}≤e−2t2/∑i​ci2​

Proved
RadGauss.RiskBound.mcdiarmid_inequality

by mikedeng1 · Oct 5, 2026 · Mathlib 0df444a (Lean v4.33.1)

concentration-inequalityp2o-batch-pfp2bp2o-gran-per-chapterp2o-plan-paperp2o-v1probability

Let X1,…,XnX_1, \dots, X_nX1​,…,Xn​ be independent random variables taking values in a measurable space AAA, where XiX_iXi​ has law μi\mu_iμi​ (the laws need not be equal). Let f:An→Rf : A^n \to \mathbb Rf:An→R be a measurable function with bounded differences: there are constants c1,…,cnc_1, \dots, c_nc1​,…,cn​ such that for every iii,

sup⁡x1,…,xn, xi′∈A∣f(x1,…,xn)−f(x1,…,xi−1,xi′,xi+1,…,xn)∣≤ci.\sup_{x_1, \dots, x_n,\, x'_i \in A}\bigl|f(x_1, \dots, x_n) - f(x_1, \dots, x_{i-1}, x'_i, x_{i+1}, \dots, x_n)\bigr| \le c_i .x1​,…,xn​,xi′​∈Asup​​f(x1​,…,xn​)−f(x1​,…,xi−1​,xi′​,xi+1​,…,xn​)​≤ci​.

Then for every t>0t > 0t>0,

P{f(X1,…,Xn)−Ef(X1,…,Xn)≥t}≤exp⁡ ⁣(−2t2∑i=1nci2).P\bigl\{f(X_1, \dots, X_n) - \mathbf E f(X_1, \dots, X_n) \ge t\bigr\} \le \exp\!\Bigl(-\frac{2t^2}{\sum_{i=1}^n c_i^2}\Bigr).P{f(X1​,…,Xn​)−Ef(X1​,…,Xn​)≥t}≤exp(−∑i=1n​ci2​2t2​).

This concentration inequality is applied twice in the proof of Theorem 8: to the uniform deviation over the centred cost class, and to the empirical mean of the cost of the fixed action 000.

Formalization Note Independence is the product measure μ1⊗⋯⊗μn\mu_1 \otimes \cdots \otimes \mu_nμ1​⊗⋯⊗μn​ of probability measures on AnA^nAn (Measure.pi μ), and the random vector is the identity. The function fff is assumed measurable, which the paper leaves implicit; bounded differences make it bounded, so Ef\mathbf E fEf is a genuine expectation. If every ci=0c_i = 0ci​=0 the printed exponent has a zero denominator; Lean reads x/0x/0x/0 as 000, so the bound becomes 111, which is true (and fff is then constant). This is the general, not-necessarily-identically-distributed form as printed; the platform's StabGen.Uniform.mcdiarmid_inequality is its i.i.d. special case and UnderstandingML.mcdiarmid_inequality_pi is a two-sided, uniform-ccc variant.

Preamble
import Mathlib

open MeasureTheory
Formal statement
namespace RadGauss.RiskBound

/-- **Theorem 9 (McDiarmid's inequality)** (p. 467). Let `X_1, …, X_n` be independent random
variables with values in `A` (the coordinates under the product `μ_1 ⊗ ⋯ ⊗ μ_n` of probability
measures, not necessarily equal), and let `f : A^n → ℝ` be measurable with
`|f(x) − f(x_1, …, x_{i−1}, x'_i, x_{i+1}, …, x_n)| ≤ c_i` for every `i`, `x` and `x'_i`. Then for every
`t > 0`, `P{f(X) − E f(X) ≥ t} ≤ exp(−2t² / Σ_i c_i²)`. -/
theorem mcdiarmid_inequality {A : Type*} [MeasurableSpace A] (n : ℕ)
    (μ : Fin n → Measure A) [∀ i, IsProbabilityMeasure (μ i)]
    (f : (Fin n → A) → ℝ) (hf : Measurable f) (c : Fin n → ℝ)
    (hc : ∀ (i : Fin n) (x : Fin n → A) (a : A), |f x - f (Function.update x i a)| ≤ c i)
    (t : ℝ) (ht : 0 < t) :
    Measure.pi μ {x | t ≤ f x - ∫ y, f y ∂(Measure.pi μ)} ≤
      ENNReal.ofReal (Real.exp (-2 * t ^ 2 / ∑ i, c i ^ 2)) := by sorry

end RadGauss.RiskBound
Source
Bartlett, Mendelson, Rademacher and Gaussian Complexities: Risk Bounds and Structural Results, J. Mach. Learn. Res. 3 (2002), p. 467 (PDF p. 5), Theorem 9 (McDiarmid's Inequality)
Human review
  • Endorsed by Shuze Chen · Oct 5, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 5, 2026

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

  • Endorsed by iris · Oct 31, 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