Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Theorem 14.8 (SGD): for convex f, an oracle with E_z g(w,z) ∈ ∂f(w) and ‖g‖ ≤ ρ, ‖w⋆‖ ≤ B and η = B/(ρ√T): E[f(w̄)] − f(w⋆) ≤ Bρ/√T; T ≥ B²ρ²/ε² gives ≤ ε

Proved
UnderstandingML.sgd_convex_lipschitz

by naimengye · Sep 24, 2026 · Mathlib 0df444a (Lean v4.33.1)

convex-optimizationlipschitzstochastic-gradient-descent

Theorem 14.8. Let B,ρ>0B, \rho > 0B,ρ>0. Let fff be a convex function and let w⋆∈argmin⁡∥w∥≤Bf(w)w^\star \in \operatorname{argmin}_{\|w\| \le B} f(w)w⋆∈argmin∥w∥≤B​f(w). Assume that SGD is run for TTT iterations with η=B2/(ρ2T)\eta = \sqrt{B^2/(\rho^2 T)}η=B2/(ρ2T)​. Assume also that for all ttt, ∥vt∥≤ρ\|v_t\| \le \rho∥vt​∥≤ρ with probability 111. Then E[f(wˉ)]−f(w⋆)≤Bρ/T\mathbb{E}[f(\bar w)] - f(w^\star) \le B\rho/\sqrt TE[f(wˉ)]−f(w⋆)≤Bρ/T​. Therefore, for any ϵ>0\epsilon > 0ϵ>0, to achieve E[f(wˉ)]−f(w⋆)≤ϵ\mathbb{E}[f(\bar w)] - f(w^\star) \le \epsilonE[f(wˉ)]−f(w⋆)≤ϵ it suffices to run SGD for T≥B2ρ2/ϵ2T \ge B^2\rho^2/\epsilon^2T≥B2ρ2/ϵ2 iterations.

Formally: the random directions are vt=g(w(t),zt)v_t = g(w^{(t)}, z_t)vt​=g(w(t),zt​) for i.i.d. zt∼Dz_t \sim Dzt​∼D and a measurable oracle ggg with Ezg(w,z)∈∂f(w)\mathbb{E}_z g(w, z) \in \partial f(w)Ez​g(w,z)∈∂f(w) for every www (the book's E[vt∣w(t)]∈∂f(w(t))\mathbb{E}[v_t \mid w^{(t)}] \in \partial f(w^{(t)})E[vt​∣w(t)]∈∂f(w(t))) and ∥g(w,z)∥≤ρ\|g(w,z)\| \le \rho∥g(w,z)∥≤ρ; the bound holds for every w⋆w^\starw⋆ with ∥w⋆∥≤B\|w^\star\| \le B∥w⋆∥≤B; the expectation is over DTD^TDT.

Preamble
import Definitions.Def_UnderstandingML_SGD

open MeasureTheory
open scoped InnerProductSpace
Formal statement
namespace UnderstandingML

/-- **Theorem 14.8** (p. 192). Let `B, ρ > 0`. Let `f` be a convex function and let `w⋆` satisfy
`‖w⋆‖ ≤ B` (the book takes a minimizer over the ball; the bound holds for every such `w⋆`).
Assume that SGD is run for `T` iterations with `η = √(B²/(ρ²T))`, with directions
`vₜ = g(w⁽ᵗ⁾, zₜ)` for i.i.d. `zₜ ∼ D` and an oracle `g` whose expectation `E_z g(w, z)` is a
subgradient of `f` at `w`, and that `‖vₜ‖ ≤ ρ`. Then `E[f(w̄)] − f(w⋆) ≤ Bρ/√T`; and for any
`ε > 0`, `T ≥ B²ρ²/ε²` iterations give `E[f(w̄)] − f(w⋆) ≤ ε`. -/
theorem sgd_convex_lipschitz {d : ℕ} {Z : Type*} [MeasurableSpace Z] (f : Vec d → ℝ)
    (hf : ConvexOn ℝ Set.univ f) (D : Measure Z) [IsProbabilityMeasure D]
    (g : Vec d → Z → Vec d) (hg : Measurable (Function.uncurry g))
    (horacle : IsSubgradientOracle f D g) {ρ B : ℝ} (hρ : 0 < ρ) (hB : 0 < B)
    (hbound : ∀ w z, ‖g w z‖ ≤ ρ) (wstar : Vec d) (hw : ‖wstar‖ ≤ B) (T : ℕ) (hT : 0 < T) :
    (∫ S, f (sgdAverage (B / (ρ * Real.sqrt T)) g S) ∂(iidLaw D T)) - f wstar ≤
        B * ρ / Real.sqrt T ∧
    ∀ ε : ℝ, 0 < ε → B ^ 2 * ρ ^ 2 / ε ^ 2 ≤ T →
      (∫ S, f (sgdAverage (B / (ρ * Real.sqrt T)) g S) ∂(iidLaw D T)) - f wstar ≤ ε := by sorry

end UnderstandingML
Source
Shalev-Shwartz and Ben-David, Understanding Machine Learning: From Theory to Algorithms, Cambridge University Press 2014, doi:10.1017/CBO9781107298019, §14.3.1 pp. 192-193, Theorem 14.8 with its proof
Human review
  • Endorsed by Shuze Chen · Sep 25, 2026

    Confirmed by the moderator at approval.

  • Endorsed by naimengye · Sep 25, 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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me