Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

§17.2.4: the generalized hinge loss upper bounds Δ(h_w(x), y), with equality under margins ≥ Δ, is convex in w and ρ-Lipschitz with ρ = max_{y'} ‖Ψ(x,y') − Ψ(x,y)‖

Proved
UnderstandingML.generalized_hinge_properties

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

convexitygeneralized-hinge-lossmulticlasssurrogate-loss

§17.2.4 (Generalized hinge loss). For ℓ(w,(x,y))=max⁡y′∈Y(Δ(y′,y)+⟨w,Ψ(x,y′)−Ψ(x,y)⟩)\ell(w,(x,y)) = \max_{y' \in Y}(\Delta(y',y) + \langle w, \Psi(x,y') - \Psi(x,y)\rangle)ℓ(w,(x,y))=maxy′∈Y​(Δ(y′,y)+⟨w,Ψ(x,y′)−Ψ(x,y)⟩) (17.3): ℓ(w,(x,y))≥Δ(hw(x),y)\ell(w,(x,y)) \ge \Delta(h_w(x), y)ℓ(w,(x,y))≥Δ(hw​(x),y); equality holds whenever the score of the correct label is larger than the score of any other label y′y'y′ by at least Δ(y′,y)\Delta(y',y)Δ(y′,y); ℓ(w,(x,y))\ell(w,(x,y))ℓ(w,(x,y)) is convex with respect to www (a maximum of linear functions); and it is ρ\rhoρ-Lipschitz with ρ=max⁡y′∥Ψ(x,y′)−Ψ(x,y)∥\rho = \max_{y'}\|\Psi(x,y') - \Psi(x,y)\|ρ=maxy′​∥Ψ(x,y′)−Ψ(x,y)∥.

Formally: the first two clauses hold for every argmax predictor hwh_whw​, the second given Δ(y,y)=0\Delta(y,y) = 0Δ(y,y)=0.

The equality clause assumes the book's standing conditions on the cost, Δ≥0\Delta \ge 0Δ≥0 and Δ(y,y)=0\Delta(y, y) = 0Δ(y,y)=0 (§17.2.2: Δ:Y×Y→R+\Delta : Y \times Y \to \mathbb{R}_+Δ:Y×Y→R+​). Without Δ≥0\Delta \ge 0Δ≥0 it fails: with two labels, Δ(b,a)=−1\Delta(b, a) = -1Δ(b,a)=−1, scores ⟨w,Ψ(x,b)⟩=1/2\langle w, \Psi(x, b)\rangle = 1/2⟨w,Ψ(x,b)⟩=1/2 and ⟨w,Ψ(x,a)⟩=0\langle w, \Psi(x, a)\rangle = 0⟨w,Ψ(x,a)⟩=0, and correct label aaa, the margin condition holds, the argmax is bbb, and ℓ=0≠−1=Δ(b,a)\ell = 0 \ne -1 = \Delta(b, a)ℓ=0=−1=Δ(b,a).

Preamble
import Definitions.Def_UnderstandingML_Multiclass

open MeasureTheory
open scoped InnerProductSpace
Formal statement
namespace UnderstandingML

/-- **§17.2.4, Equation (17.3)** (p. 233). The generalized hinge loss
`ℓ(w, (x, y)) = max_{y'} (Δ(y', y) + ⟨w, Ψ(x, y') − Ψ(x, y)⟩)` satisfies `ℓ(w, (x, y)) ≥ Δ(h_w(x), y)` for
every argmax predictor `h_w`; equality holds whenever the score of the correct label exceeds the
score of every other label `y'` by at least `Δ(y', y)` (given the book's `Δ ≥ 0` and
`Δ(y, y) = 0`; with a negative `Δ(y', y)` an argmax `y'` has `Δ(y', y) < 0 = ℓ`); `ℓ(w, (x, y))` is
convex in `w`; and it is `ρ`-Lipschitz in `w` with `ρ = max_{y'} ‖Ψ(x, y') − Ψ(x, y)‖`. -/
theorem generalized_hinge_properties {d : ℕ} {X Y : Type*} [Fintype Y] [Nonempty Y]
    (Δ : Y → Y → ℝ) (Ψ : X → Y → Vec d) (w : Vec d) (z : X × Y) :
    (∀ h : X → Y, IsArgmaxPredictor Ψ w h → Δ (h z.1) z.2 ≤ genHingeLoss Δ Ψ w z) ∧
    ((∀ y', 0 ≤ Δ y' z.2) → Δ z.2 z.2 = 0 →
      (∀ y', y' ≠ z.2 → ⟪w, Ψ z.1 y'⟫_ℝ + Δ y' z.2 ≤ ⟪w, Ψ z.1 z.2⟫_ℝ) →
      ∀ h : X → Y, IsArgmaxPredictor Ψ w h → genHingeLoss Δ Ψ w z = Δ (h z.1) z.2) ∧
    ConvexOn ℝ Set.univ (fun w ↦ genHingeLoss Δ Ψ w z) ∧
    ∀ w₁ w₂ : Vec d, |genHingeLoss Δ Ψ w₁ z - genHingeLoss Δ Ψ w₂ z| ≤
      (⨆ y' : Y, ‖Ψ z.1 y' - Ψ z.1 z.2‖) * ‖w₁ - w₂‖ := 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, §17.2.4 pp. 233-234, Equation (17.3) and the properties stated after it
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