Documentation

LeanMlir.Proofs.Certificates.Smoothing.Gaussian

The real Gaussian probit: Φ, Φ⁻¹, and the Cohen radius as a THEOREM #

Endpoint: smoothing_certified_radius_classifier — for a measurable classifier under N(0,σ²I) smoothing, every ‖δ‖ < σ·Φ⁻¹(p_A(x)) provably cannot flip the smoothed argmax, with Φ⁻¹ the genuine standard-normal quantile. The Cohen–Rosenfeld–Kolter (1/σ)-Lipschitz probit (hg of smoothing_certified_radius_probit, the Neyman–Pearson half) is a theorem here, smoothing_probit_lipschitz. The one remaining hypothesis on the smoothed classifier is hp: every class's smoothed probability lies in (0,1) at every point. Smoothing.NetSemantics discharges it for argmax nets.

Φ (stdNormalCDF, Mathlib's cdf (gaussianReal 0 1)), Φ⁻¹ (stdNormalQuantile) and their monotonicity, symmetry, two-sided inversion and continuity live in GaussianQuantile.lean. This file proves:

The quantile is total on ℝ (junk sSup outside (0,1)), and every use here is guarded by hp. smoothing_certified_radius_probit asks monotonicity of the probit only on (0,1) because no globally monotone function agrees with the true (unbounded) quantile there.

All results are propext / Classical.choice / Quot.sound-clean (tests/AuditAxioms.lean).

The analytic heart of Cohen 2019, in its 1-D normalized form. The classic proof needs no layer-cake and no rearrangement machinery: with h the halfspace indicator at the threshold t and LR the (monotone) Gaussian likelihood ratio, the pointwise inequality (f − h)·(LR − LR(t)) ≥ 0 — sign-checked on each side of t — integrates against the base Gaussian into exactly the Neyman–Pearson optimality of the halfspace.

The Gaussian likelihood ratio: pdf_{N(δ,1)}(z) = exp(δz − δ²/2) · pdf_{N(0,1)}(z) — monotone in z (for δ ≥ 0), which is all Neyman–Pearson needs.

The halfspace indicator's Gaussian mass is the cdf at the threshold.

theorem Proofs.smoothing_certified_radius_gaussian {k : ℕ} {E : Type u_1} [NormedAddCommGroup E] {σ : ℝ} (hσ : 0 < σ) {p : Fin k → E → ℝ} (hp : ∀ (c : Fin k) (y : E), p c y ∈ Set.Ioo 0 1) (hg : ∀ (c : Fin k), LipschitzL2 (1 / σ) fun (x : E) => stdNormalQuantile (p c x)) {x δ : E} {i : Fin k} (hrunner : ∀ (j : Fin k), j ≠ i → p j x ≤ 1 - p i x) (hδ : ‖δ‖ < σ * stdNormalQuantile (p i x)) (j : Fin k) :
j ≠ i → p j (x + δ) < p i (x + δ)

Randomized-smoothing certified radius at the true Gaussian probit. With every class probability p c y inside (0,1) at every point y (hp), per-class probit scores Φ⁻¹ ∘ p c each (1/σ)-Lipschitz (hg — for Gaussian-smoothed [0,1] scores this is smoothing_probit_lipschitz, applied in smoothing_certified_radius_cohen), and the runner-up bound, every ‖δ‖₂ < σ·Φ⁻¹(p_A(x)) keeps class i the strict argmax — where Φ⁻¹ is now the genuine standard-normal quantile, not an abstract stand-in. Exactly the σ·Φ⁻¹(p_A) radius the *-smooth drivers report.

The n-D Cohen bound ∫f(·+δ) dγ ≥ Φ(Φ⁻¹(∫f dγ) − ‖δ‖) for the standard Gaussian γ on EuclideanSpace ℝ (Fin (n+1)). Structure: (i) a 1-D Cameron–Martin change of variables turns the shifted integral into a monotone-likelihood-ratio-weighted one; (ii) Fubini over Measure.pi (split at coordinate 0 via piFinSuccAbove) lifts it to the iid pi measure — only coordinate 0 carries the shift; (iii) the same pointwise MLR trick as the 1-D case, now with the weight exp(d·z₀ − d²/2) and the halfspace {z₀ ≤ t}, gives the pi-space NP theorem; (iv) an adapted orthonormal basis (a reflection carries e₀ to δ/‖δ‖, and Mathlib's stdGaussian_eq_map_pi_orthonormalBasis says the standard Gaussian doesn't care) rotates the general shift onto coordinate 0.

@[reducible, inline]
noncomputable abbrev Proofs.stdGaussianPi (n : ℕ) :

The iid standard-Gaussian product measure on Fin (n+1) → ℝ.

Equations
Instances For

    The exponential weight is Gaussian-integrable.

    theorem Proofs.insertNth_zero_add_single {n : ℕ} (s d : ℝ) (w : Fin n → ℝ) :
    Fin.insertNth 0 s w + d • Pi.single 0 1 = Fin.insertNth 0 (s + d) w
    theorem Proofs.pi_gaussian_shift_eq {n : ℕ} {F : (Fin (n + 1) → ℝ) → ℝ} (hFm : Measurable F) (hFb : ∀ (z : Fin (n + 1) → ℝ), |F z| ≤ 1) (d : ℝ) :
    ∫ (z : Fin (n + 1) → ℝ), F (z + d • Pi.single 0 1) ∂stdGaussianPi n = ∫ (z : Fin (n + 1) → ℝ), Real.exp (d * z 0 - d ^ 2 / 2) * F z ∂stdGaussianPi n
    theorem Proofs.pi_gaussian_np_shift {n : ℕ} {F : (Fin (n + 1) → ℝ) → ℝ} (hFm : Measurable F) (hF0 : ∀ (z : Fin (n + 1) → ℝ), 0 ≤ F z) (hF1 : ∀ (z : Fin (n + 1) → ℝ), F z ≤ 1) {d t : ℝ} (hd : 0 ≤ d) (hp : stdNormalCDF t ≤ ∫ (z : Fin (n + 1) → ℝ), F z ∂stdGaussianPi n) :
    stdNormalCDF (t - d) ≤ ∫ (z : Fin (n + 1) → ℝ), F (z + d • Pi.single 0 1) ∂stdGaussianPi n
    theorem Proofs.stdGaussian_np_shift {n : ℕ} {f : EuclideanSpace ℝ (Fin (n + 1)) → ℝ} (hfm : Measurable f) (hf0 : ∀ (z : EuclideanSpace ℝ (Fin (n + 1))), 0 ≤ f z) (hf1 : ∀ (z : EuclideanSpace ℝ (Fin (n + 1))), f z ≤ 1) {δ : EuclideanSpace ℝ (Fin (n + 1))} {t : ℝ} (hp : stdNormalCDF t ≤ ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), f z ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1)))) :

    Assembly. stdNormalQuantile_cdf (the other inversion direction, Φ⁻¹(Φ s) = s, from strict monotonicity) plus stdNormalCDF_mem_Ioo let the n-D bound stdGaussian_np_shift be pushed through Φ⁻¹: applying it in both directions gives |Φ⁻¹(p(x)) − Φ⁻¹(p(y))| ≤ ‖x−y‖/σ — the Cohen/Salman (1/σ)-Lipschitz probit, smoothing_probit_lipschitz. Instantiating smoothing_certified_radius_gaussian with it yields smoothing_certified_radius_cohen (soft scores) and smoothing_certified_radius_classifier (hard classifier — the [0,1] bounds AND the runner-up bound come free from decision-region disjointness). The σ-smoothed mean is written ∫ f(x + σ•z) dγ(z) with γ the STANDARD Gaussian — i.e. noise N(0, σ²I), exactly what the *-smooth drivers sample.

    theorem Proofs.smoothing_probit_lipschitz {n : ℕ} {σ : ℝ} (hσ : 0 < σ) {f : EuclideanSpace ℝ (Fin (n + 1)) → ℝ} (hfm : Measurable f) (hf0 : ∀ (z : EuclideanSpace ℝ (Fin (n + 1))), 0 ≤ f z) (hf1 : ∀ (z : EuclideanSpace ℝ (Fin (n + 1))), f z ≤ 1) (hp : ∀ (x : EuclideanSpace ℝ (Fin (n + 1))), ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), f (x + σ • z) ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))) ∈ Set.Ioo 0 1) :

    The smoothed probit is (1/σ)-Lipschitz (Cohen 2019 / Salman 2019 Lemma 2). For measurable f : EuclideanSpace ℝ (Fin (n+1)) → [0,1] whose σ-smoothed mean p(x) = ∫ f(x + σz) dγ(z) lies inside (0,1) at every x, the probit score x ↦ Φ⁻¹(p x) is (1/σ)-Lipschitz in L2.

    theorem Proofs.smoothing_certified_radius_cohen {n k : ℕ} {σ : ℝ} (hσ : 0 < σ) {f : Fin k → EuclideanSpace ℝ (Fin (n + 1)) → ℝ} (hfm : ∀ (c : Fin k), Measurable (f c)) (hf0 : ∀ (c : Fin k) (z : EuclideanSpace ℝ (Fin (n + 1))), 0 ≤ f c z) (hf1 : ∀ (c : Fin k) (z : EuclideanSpace ℝ (Fin (n + 1))), f c z ≤ 1) (hp : ∀ (c : Fin k) (x : EuclideanSpace ℝ (Fin (n + 1))), ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), f c (x + σ • z) ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))) ∈ Set.Ioo 0 1) {x δ : EuclideanSpace ℝ (Fin (n + 1))} {i : Fin k} (hrunner : ∀ (j : Fin k), j ≠ i → ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), f j (x + σ • z) ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))) ≤ 1 - ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), f i (x + σ • z) ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1)))) (hδ : ‖δ‖ < σ * stdNormalQuantile (∫ (z : EuclideanSpace ℝ (Fin (n + 1))), f i (x + σ • z) ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))))) (j : Fin k) :
    j ≠ i → ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), f j (x + δ + σ • z) ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))) < ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), f i (x + δ + σ • z) ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1)))

    The Cohen radius, Neyman–Pearson side DISCHARGED. For a family of measurable [0,1] class scores whose σ-smoothed means stay in (0,1), the smoothed prediction cannot flip within ‖δ‖ < σ·Φ⁻¹(p_i(x)). No Lipschitz hypothesis: hg is now the theorem smoothing_probit_lipschitz.

    theorem Proofs.smoothing_certified_radius_classifier {n k : ℕ} {σ : ℝ} (hσ : 0 < σ) {C : EuclideanSpace ℝ (Fin (n + 1)) → Fin k} (hC : Measurable C) (hp : ∀ (c : Fin k) (x : EuclideanSpace ℝ (Fin (n + 1))), ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + σ • z) = c then 1 else 0 ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))) ∈ Set.Ioo 0 1) {x δ : EuclideanSpace ℝ (Fin (n + 1))} {i : Fin k} (hδ : ‖δ‖ < σ * stdNormalQuantile (∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + σ • z) = i then 1 else 0 ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))))) (j : Fin k) :
    j ≠ i → ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + δ + σ • z) = j then 1 else 0 ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))) < ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + δ + σ • z) = i then 1 else 0 ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1)))

    The classifier form. For a measurable hard classifier C, class scores are the decision-region indicators, so [0,1]-boundedness AND the runner-up bound are both automatic (regions are disjoint: p_j + p_i ≤ 1). Hypotheses: measurability of C; hp — every class's smoothed probability lies in (0,1) at every point, i.e. no decision region is Gaussian-null or conull (Φ⁻¹ is only meaningful on (0,1)); for an argmax net it follows from one strict-argmax witness per class (argmaxNet_smoothProb_mem_Ioo); and the margin ‖δ‖ < σ·Φ⁻¹(p_i(x)). The radius has the form the *-smooth drivers report, stated at the true class probability.

    theorem Proofs.measurableSet_smoothRegion {n k : ℕ} {C : EuclideanSpace ℝ (Fin (n + 1)) → Fin k} (hC : Measurable C) (x : EuclideanSpace ℝ (Fin (n + 1))) (σ : ℝ) (y : Fin k) :
    MeasurableSet {v : EuclideanSpace ℝ (Fin (n + 1)) | C (x + σ • v) = y}

    The decision region {v | C (x + σ•v) = y} of a measurable classifier is measurable.

    theorem Proofs.smoothProb_eq_real {n k : ℕ} {C : EuclideanSpace ℝ (Fin (n + 1)) → Fin k} (hC : Measurable C) (μ : MeasureTheory.Measure (EuclideanSpace ℝ (Fin (n + 1)))) (x : EuclideanSpace ℝ (Fin (n + 1))) (σ : ℝ) (y : Fin k) :
    μ.real {v : EuclideanSpace ℝ (Fin (n + 1)) | C (x + σ • v) = y} = ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + σ • z) = y then 1 else 0 ∂μ

    The indicator bridge: a class probability (the integral of the vote indicator) is the measure of the class's decision region.

    theorem Proofs.smoothing_certified_of_le {n k : ℕ} {σ : ℝ} (hσ : 0 < σ) {C : EuclideanSpace ℝ (Fin (n + 1)) → Fin k} (hC : Measurable C) (hp : ∀ (c : Fin k) (x : EuclideanSpace ℝ (Fin (n + 1))), ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + σ • z) = c then 1 else 0 ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))) ∈ Set.Ioo 0 1) {x δ : EuclideanSpace ℝ (Fin (n + 1))} {i : Fin k} {q : ℝ} (hq : q ≤ ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + σ • z) = i then 1 else 0 ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1)))) (hδ : ‖δ‖ < σ * stdNormalQuantile q) (j : Fin k) :
    j ≠ i → ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + δ + σ • z) = j then 1 else 0 ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1))) < ∫ (z : EuclideanSpace ℝ (Fin (n + 1))), if C (x + δ + σ • z) = i then 1 else 0 ∂ProbabilityTheory.stdGaussian (EuclideanSpace ℝ (Fin (n + 1)))

    Any lower bound certifies. smoothing_certified_radius_classifier at a radius σ·Φ⁻¹(q) for any q below the true class probability — the step every confidence bound (Hoeffding, Clopper–Pearson) takes: Φ⁻¹ is monotone on (0,1), and q ≤ 0 gives radius 0, which no δ beats.