Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Theorem 29.3(3), upper bound: every ERM learns in the realizable case with O((dlog⁡(kd/ϵ)+log⁡(1/δ))/ϵ)O((d\log(kd/\epsilon) + \log(1/\delta))/\epsilon)O((dlog(kd/ϵ)+log(1/δ))/ϵ) examples

Proved
UnderstandingML.multiclass_realizable_upper_bound

by Gabewhigham · Sep 25, 2026 · Mathlib 0df444a (Lean v4.33.1)

machine-learningmulticlass

This is the upper half of item 3 of the Multiclass Fundamental Theorem.

Let XXX be a domain with a σ\sigmaσ-algebra containing all singletons, let YYY be a finite label set with k=∣Y∣k = |Y|k=∣Y∣ (also with measurable singletons), and let H⊆YXH \subseteq Y^XH⊆YX be a class of measurable hypotheses with Natarajan dimension Ndim⁡(H)=d\operatorname{Ndim}(H) = dNdim(H)=d (Definition 29.2). The loss is the multiclass 000–111 loss ℓ(h,(x,y))=1[h(x)≠y]\ell(h,(x,y)) = \mathbb{1}[h(x) \ne y]ℓ(h,(x,y))=1[h(x)=y]. Assume moreover that HHH is nonempty and has the countable-approximation property (Remark 3.1).

There is an absolute constant C2>0C_2 > 0C2​>0 (independent of XXX, YYY, HHH and ddd) such that every ERM learner for HHH PAC learns HHH under the realizability assumption with sample complexity

mH(ϵ,δ)≤⌈C2 dlog⁡(kd/ϵ)+log⁡(1/δ)ϵ⌉.m_H(\epsilon,\delta) \le \left\lceil C_2\,\frac{d \log(kd/\epsilon) + \log(1/\delta)}{\epsilon} \right\rceil .mH​(ϵ,δ)≤⌈C2​ϵdlog(kd/ϵ)+log(1/δ)​⌉.

That is, for all ϵ,δ∈(0,1)\epsilon,\delta \in (0,1)ϵ,δ∈(0,1), every probability distribution D\mathcal DD over XXX, every measurable labeling function f:X→Yf : X \to Yf:X→Y for which some h⋆∈Hh^\star \in Hh⋆∈H satisfies D({h⋆≠f})=0\mathcal D(\{h^\star \ne f\}) = 0D({h⋆=f})=0, and every mmm at least this number, the ERM output hSh_ShS​ on S∼(D,f)mS \sim (\mathcal D, f)^mS∼(D,f)m satisfies D({hS≠f})≤ϵ\mathcal D(\{h_S \ne f\}) \le \epsilonD({hS​=f})≤ϵ with probability at least 1−δ1-\delta1−δ.

Formalization Note The realizable multiclass PAC property is the mission's IsMulticlassPACWith, in the shape of Definition 3.1 with error D({h≠f})\mathcal D(\{h \ne f\})D({h=f}). For d=0d = 0d=0 the term dlog⁡(kd/ϵ)d\log(kd/\epsilon)dlog(kd/ϵ) is 000.

Preamble
import Definitions.Def_UnderstandingML_MulticlassLearnability

open MeasureTheory
open scoped InnerProductSpace
Formal statement
universe u v

namespace UnderstandingML

/-- **Theorem 29.3, part 3 (upper bound)** (p. 403). There is an absolute constant `C₂ > 0` such
that for every nonempty measurable class `H` of functions from `X` to a finite label set `Y` with
the countable-approximation property and Natarajan dimension `d`, every ERM learner PAC learns
`H` in the realizable case with sample complexity
`m_H(ε, δ) ≤ ⌈C₂ (d log(|Y| d/ε) + log(1/δ))/ε⌉`. -/
theorem multiclass_realizable_upper_bound :
    ∃ C₂ : ℝ, 0 < C₂ ∧
      ∀ {X : Type u} {Y : Type v} [MeasurableSpace X] [MeasurableSingletonClass X]
        [MeasurableSpace Y] [MeasurableSingletonClass Y] [Fintype Y]
        (H : Set (X → Y)) (d : ℕ), H.Nonempty → (∀ h ∈ H, Measurable h) →
        NPointwiseSeparable H → ndim H = d →
        ∀ A : Learner (X × Y) (X → Y), IsERMLearner lossMulti H A →
          IsMulticlassPACWith H A (fun ε δ ↦
            ⌈C₂ * (d * Real.log (Fintype.card Y * d / ε) + Real.log (1 / δ)) / ε⌉₊) := by sorry

end UnderstandingML
Source
S. Shalev-Shwartz, S. Ben-David, Understanding Machine Learning: From Theory to Algorithms, Cambridge University Press 2014, doi:10.1017/CBO9781107298019, Chapter 29, Theorem 29.3 (The Multiclass Fundamental Theorem), p. 403, item 3 (upper bound on the realizable sample complexity)

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