Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Corollary 4.1: the NP classifier under i.i.d. labelled sampling

Proved
NeymanPearsonClassification.random_sampling_oracle_inequality

by Xeroth · Nov 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

binary-classificationchance-constrained-optimizationconvex-surrogateempirical-processesneyman-pearson

Let φ,κ,δ,α\varphi,\kappa,\delta,\alphaφ,κ,δ,α and the base classifiers be as in Theorem 4.1, let Assumption 1 hold, and let εˉ\bar\varepsilonεˉ and n0n_0n0​ be as in Theorem 4.2. Let (X1,Y1),…,(Xn,Yn)(X_1,Y_1),\dots,(X_n,Y_n)(X1​,Y1​),…,(Xn​,Yn​) be independent copies of (X,Y)(X,Y)(X,Y), where Y∈{−1,1}Y\in\{-1,1\}Y∈{−1,1}, p=P(Y=1)∈(0,1)p=\mathbb P(Y=1)\in(0,1)p=P(Y=1)∈(0,1), and XXX has law P−P^-P− given Y=−1Y=-1Y=−1 and P+P^+P+ given Y=1Y=1Y=1. Let N−=#{i:Yi=−1}N^-=\#\{i:Y_i=-1\}N−=#{i:Yi​=−1} and N+=n−N−N^+=n-N^-N+=n−N−, and let h~nκ\tilde h^\kappa_nh~nκ​ be any solution of the program (3.4) built from the two label classes of the sample. If n>2n0/(1−p)n>2n_0/(1-p)n>2n0​/(1−p), then:

  1. With probability at least (1−2δ)(1−e−n(1−p)2/2)(1-2\delta)(1-e^{-n(1-p)^2/2})(1−2δ)(1−e−n(1−p)2/2),
R−(h~nκ)≤Rφ−(h~nκ)≤αandRφ+(h~nκ)−min⁡h∈Hφ,αRφ+(h)≤4φ(1)κ(1−εˉ)αN−+2κN+.R^-(\tilde h^\kappa_n)\le R^-_\varphi(\tilde h^\kappa_n)\le\alpha\quad\text{and}\quad R^+_\varphi(\tilde h^\kappa_n)-\min_{h\in\mathcal H^{\varphi,\alpha}}R^+_\varphi(h)\le\frac{4\varphi(1)\kappa}{(1-\bar\varepsilon)\alpha\sqrt{N^-}}+\frac{2\kappa}{\sqrt{N^+}}.R−(h~nκ​)≤Rφ−​(h~nκ​)≤αandRφ+​(h~nκ​)−h∈Hφ,αmin​Rφ+​(h)≤(1−εˉ)αN−​4φ(1)κ​+N+​2κ​.
  1. With probability at least 1−2δ−e−n(1−p)2/2−e−np2/21-2\delta-e^{-n(1-p)^2/2}-e^{-np^2/2}1−2δ−e−n(1−p)2/2−e−np2/2,
R−(h~nκ)≤Rφ−(h~nκ)≤αandRφ+(h~nκ)−min⁡h∈Hφ,αRφ+(h)≤42 φ(1)κ(1−εˉ)αn(1−p)+22 κnp.R^-(\tilde h^\kappa_n)\le R^-_\varphi(\tilde h^\kappa_n)\le\alpha\quad\text{and}\quad R^+_\varphi(\tilde h^\kappa_n)-\min_{h\in\mathcal H^{\varphi,\alpha}}R^+_\varphi(h)\le\frac{4\sqrt2\,\varphi(1)\kappa}{(1-\bar\varepsilon)\alpha\sqrt{n(1-p)}}+\frac{2\sqrt2\,\kappa}{\sqrt{np}}.R−(h~nκ​)≤Rφ−​(h~nκ​)≤αandRφ+​(h~nκ​)−h∈Hφ,αmin​Rφ+​(h)≤(1−εˉ)αn(1−p)​42​φ(1)κ​+np​22​κ​.

Formalization Note The law of each pair is given by P(Xi∈A,Yi=1)=p P+(A)\mathbb P(X_i\in A,Y_i=1)=p\,P^+(A)P(Xi​∈A,Yi​=1)=pP+(A) and P(Xi∈A,Yi=−1)=(1−p)P−(A)\mathbb P(X_i\in A,Y_i=-1)=(1-p)P^-(A)P(Xi​∈A,Yi​=−1)=(1−p)P−(A). In part 1 the paper's convention 1/0=+∞1/\sqrt0=+\infty1/0​=+∞ is made explicit. When N−=0N^-=0N−=0 the paper's program (3.4) is undefined; part 1 excludes that case by an explicit guard N−>0N^->0N−>0 (in Lean, with an empty sample the level α−κ/0\alpha-\kappa/\sqrt0α−κ/0​ evaluates to α\alphaα and R^φ−\hat R^-_\varphiR^φ−​ to 000, so junk solutions would exist). When N+=0N^+=0N+=0 the type II bound is +∞+\infty+∞, so only the type I bound is required. Part 2 has no guard: on {N−=0}\{N^-=0\}{N−=0} or {N+=0}\{N^+=0\}{N+=0} the Lean program has such junk solutions, but these events lie inside {N−<n(1−p)/2}\{N^-<n(1-p)/2\}{N−<n(1−p)/2} and {N+<np/2}\{N^+<np/2\}{N+<np/2}, whose probabilities are already part of the failure bound, so part 2 remains true as stated. "Any solution" is stated uniformly over all solutions, as in Theorem 4.2.

Preamble
import Mathlib
import Definitions.Def_NeymanPearsonClassification_Basic

open MeasureTheory ProbabilityTheory
Formal statement
namespace NeymanPearsonClassification

theorem random_sampling_oracle_inequality {d M : ℕ} (hM : 2 ≤ M)
    (h : Fin M → EuclideanSpace ℝ (Fin d) → ℝ) (hh : IsBaseFamily h)
    (Pm Pp : Measure (EuclideanSpace ℝ (Fin d))) [IsProbabilityMeasure Pm] [IsProbabilityMeasure Pp]
    (φ : ℝ → ℝ) (hφ : IsConvexSurrogate φ) (L : ℝ) (hL : 0 < L) (hLip : LipschitzOnWith (Real.toNNReal L) φ (Set.Icc (-1) 1))
    (δ α : ℝ) (hδ : δ ∈ Set.Ioo 0 1) (hα : α ∈ Set.Ioo 0 1)
    (hA1 : ∃ ε : ℝ, 0 < ε ∧ ε < 1 ∧ (Hphi h Pm φ (ε * α)).Nonempty)
    (p : ℝ) (hp : p ∈ Set.Ioo 0 1) {n : ℕ}
    (hn : 2 * (nZero (kappa L M δ) (epsBar h Pm φ α) α : ℝ) / (1 - p) < n)
    {Omega : Type*} [MeasurableSpace Omega] (μ : Measure Omega) [IsProbabilityMeasure μ]
    (X : Fin n → Omega → EuclideanSpace ℝ (Fin d)) (Y : Fin n → Omega → ℝ)
    (hXm : ∀ i, Measurable (X i)) (hYm : ∀ i, Measurable (Y i))
    (hind : iIndepFun (fun i ω => (X i ω, Y i ω)) μ)
    (hY : ∀ i ω, Y i ω = -1 ∨ Y i ω = 1)
    (hlawp : ∀ i (A : Set (EuclideanSpace ℝ (Fin d))), MeasurableSet A →
      μ {ω | X i ω ∈ A ∧ Y i ω = 1} = ENNReal.ofReal p * Pp A)
    (hlawm : ∀ i (A : Set (EuclideanSpace ℝ (Fin d))), MeasurableSet A →
      μ {ω | X i ω ∈ A ∧ Y i ω = -1} = ENNReal.ofReal (1 - p) * Pm A) :
    μ {ω | ¬ (0 < (labelIdx (fun i => Y i ω) (-1)).card →
        ∀ f, IsNPClassifier h φ α (kappa L M δ) (labelIdx (fun i => Y i ω) (-1)) (fun i => X i ω)
            (labelIdx (fun i => Y i ω) 1) (fun i => X i ω) f →
          (typeI Pm f ≤ phiTypeI Pm φ f ∧ phiTypeI Pm φ f ≤ α) ∧
          (0 < (labelIdx (fun i => Y i ω) 1).card →
            phiTypeII Pp φ f - minPhiTypeII h Pm Pp φ α ≤
              4 * φ 1 * kappa L M δ /
                  ((1 - epsBar h Pm φ α) * α * Real.sqrt (labelIdx (fun i => Y i ω) (-1)).card) +
                2 * kappa L M δ / Real.sqrt (labelIdx (fun i => Y i ω) 1).card))} ≤
      ENNReal.ofReal (1 - (1 - 2 * δ) * (1 - Real.exp (-(n * (1 - p) ^ 2 / 2)))) ∧
    μ {ω | ¬ ∀ f, IsNPClassifier h φ α (kappa L M δ) (labelIdx (fun i => Y i ω) (-1))
          (fun i => X i ω) (labelIdx (fun i => Y i ω) 1) (fun i => X i ω) f →
        (typeI Pm f ≤ phiTypeI Pm φ f ∧ phiTypeI Pm φ f ≤ α) ∧
        phiTypeII Pp φ f - minPhiTypeII h Pm Pp φ α ≤
          4 * Real.sqrt 2 * φ 1 * kappa L M δ /
              ((1 - epsBar h Pm φ α) * α * Real.sqrt (n * (1 - p))) +
            2 * Real.sqrt 2 * kappa L M δ / Real.sqrt (n * p)} ≤
      ENNReal.ofReal (2 * δ + Real.exp (-(n * (1 - p) ^ 2 / 2)) + Real.exp (-(n * p ^ 2 / 2))) := by sorry

end NeymanPearsonClassification
Source
Rigollet and Tong, Neyman-Pearson classification, convexity and stochastic constraints, arXiv:1102.5750v1 (2011), Section 4.3, Corollary 4.1, eqs. (4.7), (4.8), (4.9), p. 10; proof in Section 6.5, pp. 18-19
Read-back

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

Fix natural numbers ddd and MMM with M≥2M \ge 2M≥2, and identify the Euclidean space Rd\mathbb{R}^dRd with the space where the features live.

Base classifiers and measures.

  • h1,…,hM:Rd→Rh_1, \dots, h_M : \mathbb{R}^d \to \mathbb{R}h1​,…,hM​:Rd→R are measurable functions, each taking all its values in [−1,1][-1,1][−1,1].
  • P−P^-P− and P+P^+P+ are probability measures on Rd\mathbb{R}^dRd.
  • For λ\lambdaλ in the standard simplex Λ={λ∈RM:λj≥0, ∑jλj=1}\Lambda = \{\lambda \in \mathbb{R}^M : \lambda_j \ge 0,\ \sum_j \lambda_j = 1\}Λ={λ∈RM:λj​≥0, ∑j​λj​=1}, write hλ=∑jλjhjh_\lambda = \sum_{j} \lambda_j h_jhλ​=∑j​λj​hj​.
  • Hconv={hλ:λ∈Λ}H^{\mathrm{conv}} = \{h_\lambda : \lambda \in \Lambda\}Hconv={hλ​:λ∈Λ}.

The surrogate φ\varphiφ. φ:R→R\varphi : \mathbb{R} \to \mathbb{R}φ:R→R is a convex surrogate: on [−1,1][-1,1][−1,1] it is non‑negative, non‑decreasing, continuous and convex, and φ(0)=1\varphi(0) = 1φ(0)=1. Its values outside [−1,1][-1,1][−1,1] are unconstrained. In addition, L>0L > 0L>0 is a real number and φ\varphiφ is LLL‑Lipschitz on [−1,1][-1,1][−1,1].

Error functionals. For any f:Rd→Rf : \mathbb{R}^d \to \mathbb{R}f:Rd→R define:

  • the type I error R−(f)=P−({x:f(x)≥0})R^-(f) = P^-(\{x : f(x) \ge 0\})R−(f)=P−({x:f(x)≥0});
  • the φ\varphiφ‑type I error Rφ−(f)=∫φ(f(x)) dP−(x)R^-_\varphi(f) = \int \varphi(f(x))\,dP^-(x)Rφ−​(f)=∫φ(f(x))dP−(x);
  • the φ\varphiφ‑type II error Rφ+(f)=∫φ(−f(x)) dP+(x)R^+_\varphi(f) = \int \varphi(-f(x))\,dP^+(x)Rφ+​(f)=∫φ(−f(x))dP+(x).

These are Bochner integrals, which by convention equal 000 when the integrand is not integrable. For a real aaa, let Hφ,a={h∈Hconv:Rφ−(h)≤a}H^{\varphi,a} = \{h \in H^{\mathrm{conv}} : R^-_\varphi(h) \le a\}Hφ,a={h∈Hconv:Rφ−​(h)≤a}, and let

γ(a)=inf⁡{Rφ+(h):h∈Hφ,a}.\gamma(a) = \inf\{R^+_\varphi(h) : h \in H^{\varphi,a}\}.γ(a)=inf{Rφ+​(h):h∈Hφ,a}.

This is the real infimum, which by convention is 000 if the set is empty or unbounded below.

Parameters.

  • δ,α∈(0,1)\delta, \alpha \in (0,1)δ,α∈(0,1) (open intervals).
  • There exists ε\varepsilonε with 0<ε<10 < \varepsilon < 10<ε<1 and Hφ,εα≠∅H^{\varphi,\varepsilon\alpha} \neq \emptysetHφ,εα=∅.
  • p∈(0,1)p \in (0,1)p∈(0,1).

Set

κ=42 L log⁡(2M/δ),εˉ=inf⁡{ε∈R:Hφ,εα≠∅},\kappa = 4\sqrt{2}\,L\,\sqrt{\log(2M/\delta)}, \qquad \bar\varepsilon = \inf\{\varepsilon \in \mathbb{R} : H^{\varphi,\varepsilon\alpha} \ne \emptyset\},κ=42​Llog(2M/δ)​,εˉ=inf{ε∈R:Hφ,εα=∅},

where log⁡\loglog is the natural logarithm. Also set

n0=max⁡(0,⌈(4κ(1−εˉ)α)2⌉).n_0 = \max\Big(0, \Big\lceil \Big(\tfrac{4\kappa}{(1-\bar\varepsilon)\alpha}\Big)^2 \Big\rceil\Big).n0​=max(0,⌈((1−εˉ)α4κ​)2⌉).

The sample size nnn is a natural number with n>2n0/(1−p)n > 2 n_0/(1-p)n>2n0​/(1−p).

The sample. (Ω,μ)(\Omega, \mu)(Ω,μ) is a probability space, and X1,…,Xn:Ω→RdX_1,\dots,X_n : \Omega \to \mathbb{R}^dX1​,…,Xn​:Ω→Rd and Y1,…,Yn:Ω→RY_1,\dots,Y_n : \Omega \to \mathbb{R}Y1​,…,Yn​:Ω→R are measurable. They satisfy:

  • the pairs (X1,Y1),…,(Xn,Yn)(X_1,Y_1),\dots,(X_n,Y_n)(X1​,Y1​),…,(Xn​,Yn​) are mutually independent under μ\muμ;
  • every Yi(ω)Y_i(\omega)Yi​(ω) equals −1-1−1 or 111, for every ω\omegaω;
  • for every iii and every measurable A⊆RdA \subseteq \mathbb{R}^dA⊆Rd:
μ(Xi∈A, Yi=1)=p P+(A),μ(Xi∈A, Yi=−1)=(1−p) P−(A).\mu(X_i \in A,\ Y_i = 1) = p\,P^+(A), \qquad \mu(X_i \in A,\ Y_i = -1) = (1-p)\,P^-(A).μ(Xi​∈A, Yi​=1)=pP+(A),μ(Xi​∈A, Yi​=−1)=(1−p)P−(A).

For each outcome ω\omegaω, let I−(ω)={i:Yi(ω)=−1}I^-(\omega) = \{i : Y_i(\omega) = -1\}I−(ω)={i:Yi​(ω)=−1} and I+(ω)={i:Yi(ω)=1}I^+(\omega) = \{i : Y_i(\omega) = 1\}I+(ω)={i:Yi​(ω)=1}, with N−=∣I−(ω)∣N^- = |I^-(\omega)|N−=∣I−(ω)∣ and N+=∣I+(ω)∣N^+ = |I^+(\omega)|N+=∣I+(ω)∣. Define the empirical errors:

R^φ−(f)=1N−∑i∈I−φ(f(Xi(ω))),R^φ+(f)=1N+∑i∈I+φ(−f(Xi(ω))).\hat R^-_\varphi(f) = \frac{1}{N^-}\sum_{i \in I^-} \varphi(f(X_i(\omega))), \qquad \hat R^+_\varphi(f) = \frac{1}{N^+}\sum_{i \in I^+} \varphi(-f(X_i(\omega))).R^φ−​(f)=N−1​i∈I−∑​φ(f(Xi​(ω))),R^φ+​(f)=N+1​i∈I+∑​φ(−f(Xi​(ω))).

By convention, division by 000 gives 000. So an empirical error over an empty index set is 000, and κ/0=0\kappa/\sqrt{0} = 0κ/0​=0.

NP classifiers. A function f:Rd→Rf : \mathbb{R}^d \to \mathbb{R}f:Rd→R is called an NP classifier at ω\omegaω if:

  • f∈Hconvf \in H^{\mathrm{conv}}f∈Hconv and R^φ−(f)≤α−κ/N−\hat R^-_\varphi(f) \le \alpha - \kappa/\sqrt{N^-}R^φ−​(f)≤α−κ/N−​;
  • R^φ+(f)≤R^φ+(g)\hat R^+_\varphi(f) \le \hat R^+_\varphi(g)R^φ+​(f)≤R^φ+​(g) for every g∈Hconvg \in H^{\mathrm{conv}}g∈Hconv with R^φ−(g)≤α−κ/N−\hat R^-_\varphi(g) \le \alpha - \kappa/\sqrt{N^-}R^φ−​(g)≤α−κ/N−​.

When N−=0N^- = 0N−=0 the constraint reduces to 0≤α0 \le \alpha0≤α. When N+=0N^+ = 0N+=0 every feasible fff is a minimizer. No existence of an NP classifier is asserted; if none exists, the conditions below hold vacuously.

Conclusion. The theorem asserts two bounds; μ\muμ is applied to sets whose measurability is not asserted, so these are outer‑measure bounds. Throughout, a negative right‑hand side is replaced by 000.

  1. Let E1E_1E1​ be the set of ω\omegaω with the following property: if N−>0N^- > 0N−>0, then every NP classifier fff at ω\omegaω satisfies R−(f)≤Rφ−(f)≤αR^-(f) \le R^-_\varphi(f) \le \alphaR−(f)≤Rφ−​(f)≤α, and, if moreover N+>0N^+ > 0N+>0,
Rφ+(f)−γ(α)≤4φ(1) κ(1−εˉ) α N−+2κN+.R^+_\varphi(f) - \gamma(\alpha) \le \frac{4\varphi(1)\,\kappa}{(1-\bar\varepsilon)\,\alpha\,\sqrt{N^-}} + \frac{2\kappa}{\sqrt{N^+}}.Rφ+​(f)−γ(α)≤(1−εˉ)αN−​4φ(1)κ​+N+​2κ​.

Then

μ(Ω∖E1)≤1−(1−2δ)(1−e−n(1−p)2/2).\mu(\Omega \setminus E_1) \le 1 - (1-2\delta)\big(1 - e^{-n(1-p)^2/2}\big).μ(Ω∖E1​)≤1−(1−2δ)(1−e−n(1−p)2/2).
  1. Let E2E_2E2​ be the set of ω\omegaω such that every NP classifier fff at ω\omegaω satisfies R−(f)≤Rφ−(f)≤αR^-(f) \le R^-_\varphi(f) \le \alphaR−(f)≤Rφ−​(f)≤α and
Rφ+(f)−γ(α)≤42 φ(1) κ(1−εˉ) α n(1−p)+22 κnp.R^+_\varphi(f) - \gamma(\alpha) \le \frac{4\sqrt{2}\,\varphi(1)\,\kappa}{(1-\bar\varepsilon)\,\alpha\,\sqrt{n(1-p)}} + \frac{2\sqrt{2}\,\kappa}{\sqrt{np}}.Rφ+​(f)−γ(α)≤(1−εˉ)αn(1−p)​42​φ(1)κ​+np​22​κ​.

Here there is no condition on N−N^-N− or N+N^+N+. Then

μ(Ω∖E2)≤2δ+e−n(1−p)2/2+e−np2/2.\mu(\Omega \setminus E_2) \le 2\delta + e^{-n(1-p)^2/2} + e^{-np^2/2}.μ(Ω∖E2​)≤2δ+e−n(1−p)2/2+e−np2/2.
Human review
  • Endorsed by Shuze Chen · Nov 23, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Xeroth · Nov 23, 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