Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem (2.1) — generalized gradient and directional derivative of a max function

Proved
ClarkeGradients.MaxFunctions.max_function_generalized_gradient

by mikedeng1 · Sep 27, 2026 · Mathlib 0df444a (Lean v4.33.1)

danskinmax-functionnonsmooth-analysisp2o-batch-p100bp2o-gran-per-chapterp2o-plan-paperp2o-v1

Let UUU be a nonempty sequentially compact topological space, and let g:Rn×U→Rg:\mathbb R^n\times U\to\mathbb Rg:Rn×U→R have the following properties:

  • (a) g(x,u)g(x,u)g(x,u) is upper semicontinuous in (x,u)(x,u)(x,u);
  • (b) ggg is locally Lipschitz in xxx, uniformly for uuu in UUU: for each bounded B⊆RnB\subseteq\mathbb R^nB⊆Rn there is one KKK with ∣g(x1,u)−g(x2,u)∣≤K∣x1−x2∣|g(x_1,u)-g(x_2,u)|\le K|x_1-x_2|∣g(x1​,u)−g(x2​,u)∣≤K∣x1​−x2​∣ for all x1,x2∈Bx_1,x_2\in Bx1​,x2​∈B, u∈Uu\in Uu∈U;
  • (c) gx∘(x,u;⋅)=gx′(x,u;⋅)g^\circ_x(x,u;\cdot)=g'_x(x,u;\cdot)gx∘​(x,u;⋅)=gx′​(x,u;⋅), the derivatives being with respect to xxx: for all x,u,vx,u,vx,u,v the one-sided directional derivative of y↦g(y,u)y\mapsto g(y,u)y↦g(y,u) at xxx in direction vvv exists and equals the generalized directional derivative;
  • (d) ∂xg(x,u)\partial_x g(x,u)∂x​g(x,u) is upper semicontinuous in (x,u)(x,u)(x,u): if (xi,ui)→(x,u)(x_i,u_i)\to(x,u)(xi​,ui​)→(x,u), ζi→ζ\zeta_i\to\zetaζi​→ζ and ζi∈∂xg(xi,ui)\zeta_i\in\partial_x g(x_i,u_i)ζi​∈∂x​g(xi​,ui​) for all iii, then ζ∈∂xg(x,u)\zeta\in\partial_x g(x,u)ζ∈∂x​g(x,u).

Let f(x)=max⁡{g(x,u):u∈U}f(x)=\max\{g(x,u):u\in U\}f(x)=max{g(x,u):u∈U} and M(x)={u∈U: g(x,u)=f(x)}M(x)=\{u\in U:\ g(x,u)=f(x)\}M(x)={u∈U: g(x,u)=f(x)}. Then

  1. fff is locally Lipschitz;
  2. for all x,vx,vx,v the one-sided directional derivative f′(x;v)f'(x;v)f′(x;v) exists;
  3. f′(x;v)=f∘(x;v)=max⁡{ζ⋅v: ζ∈∂xg(x,u), u∈M(x)}f'(x;v)=f^\circ(x;v)=\max\{\zeta\cdot v:\ \zeta\in\partial_x g(x,u),\ u\in M(x)\}f′(x;v)=f∘(x;v)=max{ζ⋅v: ζ∈∂x​g(x,u), u∈M(x)};
  4. for all xxx,
∂f(x)=co⁡{∂xg(x,u): u∈M(x)}.\partial f(x)=\operatorname{co}\{\partial_x g(x,u):\ u\in M(x)\}.∂f(x)=co{∂x​g(x,u): u∈M(x)}.

This is the paper's first main theorem. It computes the generalized gradient and the directional derivatives of a pointwise maximum of a family of nonsmooth functions. When ∇xg\nabla_x g∇x​g exists and is continuous in (x,u)(x,u)(x,u), it reduces to Danskin's theorem.

Formalization Note U≠∅U\neq\emptysetU=∅ is made explicit ([Nonempty U]); the paper uses it implicitly in "max". The max is ⨆ u, g x u, and "max" in (3) is IsGreatest, which asserts attainment. Conclusions (2) and (3) together are "f has one-sided directional derivative f∘(x;v)f^\circ(x;v)f∘(x;v) at xxx in direction vvv" plus the IsGreatest clause. Upper semicontinuity in (a) is Mathlib's UpperSemicontinuous on the product topology; in (d) it is the paper's sequential closed-graph property.

Preamble
import Mathlib
import Definitions.Def_ClarkeGradients_Shared_LipschitzOnBounded
import Definitions.Def_ClarkeGradients_Shared_generalizedGradient
import Definitions.Def_ClarkeGradients_Shared_genDirDeriv
import Definitions.Def_ClarkeGradients_MaxFunctions_HasOneSidedDirDeriv
import Definitions.Def_ClarkeGradients_MaxFunctions_SeqUpperSemicontinuous
import Definitions.Def_ClarkeGradients_MaxFunctions_maxFunction
Formal statement
namespace ClarkeGradients.MaxFunctions

/-- Clarke (1975), Theorem (2.1). Let `U` be a (nonempty) sequentially compact space and
`g : ℝⁿ × U → ℝ` satisfy
(a) `g` is upper semicontinuous in `(x, u)`;
(b) `g` is locally Lipschitz in `x`, uniformly for `u ∈ U`;
(c) `g°ₓ(x, u; ·) = g'ₓ(x, u; ·)` (the one-sided derivative in `x` exists and equals the
    generalized directional derivative in `x`), for all `x, u`;
(d) `(x, u) ↦ ∂ₓg(x, u)` is upper semicontinuous (sequential closed graph).
Then, with `f(x) = max_u g(x, u)` and `M(x) = {u : g(x, u) = f(x)}`:
(1) `f` is locally Lipschitz; (2) `f'(x; v)` exists; (3)
`f'(x; v) = f°(x; v) = max {ζ · v : ζ ∈ ∂ₓg(x, u), u ∈ M(x)}`; (4) `∂f(x)` is the convex
hull of `{∂ₓg(x, u) : u ∈ M(x)}`. -/
theorem max_function_generalized_gradient
    {n : ℕ} {U : Type*} [TopologicalSpace U] [SeqCompactSpace U] [Nonempty U]
    (g : EuclideanSpace ℝ (Fin n) → U → ℝ)
    (ha : UpperSemicontinuous (fun p : EuclideanSpace ℝ (Fin n) × U => g p.1 p.2))
    (hb : ∀ B : Set (EuclideanSpace ℝ (Fin n)), Bornology.IsBounded B →
      ∃ K : NNReal, ∀ u : U, LipschitzOnWith K (fun y => g y u) B)
    (hc : ∀ (x : EuclideanSpace ℝ (Fin n)) (u : U) (v : EuclideanSpace ℝ (Fin n)),
      HasOneSidedDirDeriv (fun y => g y u) x v (Shared.genDirDeriv (fun y => g y u) x v))
    (hd : SeqUpperSemicontinuous
      (fun p : EuclideanSpace ℝ (Fin n) × U => Shared.generalizedGradient (fun y => g y p.2) p.1)) :
    Shared.LipschitzOnBounded (maxFunction g) ∧
    (∀ x v : EuclideanSpace ℝ (Fin n),
      HasOneSidedDirDeriv (maxFunction g) x v (Shared.genDirDeriv (maxFunction g) x v) ∧
      IsGreatest {r : ℝ | ∃ u ∈ maximizers g x, ∃ ζ ∈ Shared.generalizedGradient (fun y => g y u) x,
          r = inner ℝ ζ v}
        (Shared.genDirDeriv (maxFunction g) x v)) ∧
    (∀ x : EuclideanSpace ℝ (Fin n),
      Shared.generalizedGradient (maxFunction g) x =
        convexHull ℝ (⋃ u ∈ maximizers g x, Shared.generalizedGradient (fun y => g y u) x)) := by sorry

end ClarkeGradients.MaxFunctions
Source
Clarke, Generalized gradients and applications, Trans. Amer. Math. Soc. 205 (1975), p. 251, Theorem (2.1)
Read-back

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

Setting. Fix a natural number nnn, which may be 000. Let Rn\mathbb{R}^nRn be Euclidean space, with the standard inner product ⟨⋅,⋅⟩\langle \cdot,\cdot\rangle⟨⋅,⋅⟩ and the Euclidean norm. Let UUU be any type with a topology, subject to two conditions:

  • UUU is sequentially compact: every sequence in UUU has a subsequence that converges in UUU.
  • UUU is nonempty.

No Hausdorff, metrizability or other separation condition is imposed on UUU. Let g:Rn×U→Rg : \mathbb{R}^n \times U \to \mathbb{R}g:Rn×U→R be any real-valued function, written g(x,u)g(x,u)g(x,u). For each u∈Uu \in Uu∈U, write gu:=g(⋅,u):Rn→Rg_u := g(\cdot, u) : \mathbb{R}^n \to \mathbb{R}gu​:=g(⋅,u):Rn→R.

Definitions from the bundle. The statement uses six notions whose definitions come from the bundle and are not shown here. Their exact content is fixed by that code, not by their names. They are:

  • LipschitzOnBounded⁡(h)\operatorname{LipschitzOnBounded}(h)LipschitzOnBounded(h), a property of a function h:Rn→Rh : \mathbb{R}^n \to \mathbb{R}h:Rn→R.
  • ∂h(x):=generalizedGradient⁡(h,x)\partial h(x) := \operatorname{generalizedGradient}(h, x)∂h(x):=generalizedGradient(h,x), a subset of Rn\mathbb{R}^nRn.
  • h∘(x;v):=genDirDeriv⁡(h,x,v)h^\circ(x; v) := \operatorname{genDirDeriv}(h, x, v)h∘(x;v):=genDirDeriv(h,x,v), a real number. It is real-valued, so it is always some real number, even where a supremum or limsup behind it would be infinite.
  • HasOneSidedDirDeriv⁡(h,x,v,r)\operatorname{HasOneSidedDirDeriv}(h, x, v, r)HasOneSidedDirDeriv(h,x,v,r), a relation between a function, a point, a direction and a real number rrr.
  • SeqUpperSemicontinuous⁡(Φ)\operatorname{SeqUpperSemicontinuous}(\Phi)SeqUpperSemicontinuous(Φ), a property of a set-valued map Φ:Rn×U→P(Rn)\Phi : \mathbb{R}^n \times U \to \mathcal{P}(\mathbb{R}^n)Φ:Rn×U→P(Rn).
  • f:=maxFunction⁡(g):Rn→Rf := \operatorname{maxFunction}(g) : \mathbb{R}^n \to \mathbb{R}f:=maxFunction(g):Rn→R, and M(x):=maximizers⁡(g,x)⊆UM(x) := \operatorname{maximizers}(g, x) \subseteq UM(x):=maximizers(g,x)⊆U.

The statement itself never ties fff to a maximum or supremum of g(x,⋅)g(x,\cdot)g(x,⋅), and never ties M(x)M(x)M(x) to the points where such a maximum is attained. Any such link lives only in the unseen bundle definitions.

Hypotheses. Assume all of the following:

  • (a) Upper semicontinuity. The map (x,u)↦g(x,u)(x,u) \mapsto g(x,u)(x,u)↦g(x,u) is upper semicontinuous on Rn×U\mathbb{R}^n \times URn×U with the product topology. That is, for every point ppp and every real c>g(p)c > g(p)c>g(p), the inequality g<cg < cg<c holds on a neighbourhood of ppp.
  • (b) Uniform Lipschitz bounds on bounded sets. For every bounded set B⊆RnB \subseteq \mathbb{R}^nB⊆Rn there is a constant K≥0K \ge 0K≥0 such that
∣g(y,u)−g(y′,u)∣≤K ∥y−y′∥for all u∈U and all y,y′∈B.|g(y,u) - g(y',u)| \le K\,\|y - y'\| \quad \text{for all } u \in U \text{ and all } y, y' \in B.∣g(y,u)−g(y′,u)∣≤K∥y−y′∥for all u∈U and all y,y′∈B.

The same KKK works for every uuu.

  • (c) One-sided derivative equals the generalized one. For every x∈Rnx \in \mathbb{R}^nx∈Rn, every u∈Uu \in Uu∈U and every direction v∈Rnv \in \mathbb{R}^nv∈Rn:
HasOneSidedDirDeriv⁡(gu, x, v, gu∘(x;v)).\operatorname{HasOneSidedDirDeriv}\big(g_u,\ x,\ v,\ g_u^\circ(x; v)\big).HasOneSidedDirDeriv(gu​, x, v, gu∘​(x;v)).
  • (d) Semicontinuity of the gradient map. The set-valued map (x,u)↦∂gu(x)(x,u) \mapsto \partial g_u(x)(x,u)↦∂gu​(x) satisfies SeqUpperSemicontinuous⁡\operatorname{SeqUpperSemicontinuous}SeqUpperSemicontinuous.

Conclusions. Under these hypotheses, all three of the following hold together:

  1. LipschitzOnBounded⁡(f)\operatorname{LipschitzOnBounded}(f)LipschitzOnBounded(f) holds.
  2. For every x,v∈Rnx, v \in \mathbb{R}^nx,v∈Rn, both parts below hold:
    • HasOneSidedDirDeriv⁡(f, x, v, f∘(x;v))\operatorname{HasOneSidedDirDeriv}\big(f,\ x,\ v,\ f^\circ(x; v)\big)HasOneSidedDirDeriv(f, x, v, f∘(x;v)).
    • f∘(x;v)f^\circ(x; v)f∘(x;v) is the greatest element (a maximum that is attained, not merely a supremum) of the set
S(x,v):={ ⟨ζ,v⟩  :  u∈M(x), ζ∈∂gu(x) }⊆R.S(x,v) := \big\{\, \langle \zeta, v\rangle \;:\; u \in M(x),\ \zeta \in \partial g_u(x) \,\big\} \subseteq \mathbb{R}.S(x,v):={⟨ζ,v⟩:u∈M(x), ζ∈∂gu​(x)}⊆R.
 Concretely, there exist $u \in M(x)$ and $\zeta \in \partial g_u(x)$ with $\langle \zeta, v\rangle = f^\circ(x;v)$, and $\langle \zeta', v\rangle \le f^\circ(x;v)$ for every $u' \in M(x)$ and every $\zeta' \in \partial g_{u'}(x)$.

 In particular, this asserts that $M(x)$ is nonempty, and that $\partial g_u(x)$ is nonempty for at least one $u \in M(x)$.

3. For every x∈Rnx \in \mathbb{R}^nx∈Rn:

∂f(x)=conv⁡(⋃u∈M(x)∂gu(x)).\partial f(x) = \operatorname{conv}\Big( \bigcup_{u \in M(x)} \partial g_u(x) \Big).∂f(x)=conv(u∈M(x)⋃​∂gu​(x)).

Here conv⁡\operatorname{conv}conv is the plain convex hull: all finite convex combinations. It is not the closed convex hull.

Degenerate cases.

  • Empty UUU. UUU cannot be empty; nonemptiness is an explicit assumption.
  • One-point U={u0}U = \{u_0\}U={u0​}. Hypothesis (b) reduces to gu0g_{u_0}gu0​​ being Lipschitz on each bounded set. The conclusions then concern f=maxFunction⁡(g)f = \operatorname{maxFunction}(g)f=maxFunction(g) and M(x)M(x)M(x) exactly as the bundle defines them. Whether f=gu0f = g_{u_0}f=gu0​​ and M(x)={u0}M(x) = \{u_0\}M(x)={u0​} depends on those unseen definitions.
  • n=0n = 0n=0. R0\mathbb{R}^0R0 is a single point, and only v=0v = 0v=0 is available. Every set is bounded, and (b) holds for any ggg. Conclusion 2 then asserts that f∘(0;0)f^\circ(0;0)f∘(0;0) is the greatest element of S(0,0)S(0,0)S(0,0), a set that can only be {0}\{0\}{0} or empty. So conclusion 2 forces f∘(0;0)=0f^\circ(0;0) = 0f∘(0;0)=0, forces M(0)≠∅M(0) \neq \emptysetM(0)=∅, and forces some ∂gu(0)\partial g_u(0)∂gu​(0) with u∈M(0)u \in M(0)u∈M(0) to be nonempty.
  • Default values of total functions. fff, f∘f^\circf∘ and gu∘g_u^\circgu∘​ are all real-valued. If the bundle builds any of them from a real supremum, infimum or limsup, then an unbounded or empty set yields a default real value, not ±∞\pm\infty±∞. The statement's claims about f∘f^\circf∘ and gu∘g_u^\circgu∘​ apply to whatever real numbers those definitions produce, default values included.
  • Other edge cases. No hypothesis excludes v=0v = 0v=0 or any particular xxx; every claim is made for all xxx and vvv. Nothing in the statement guarantees that ∂gu(x)\partial g_u(x)∂gu​(x) is nonempty, bounded or closed, except through the unseen definitions and hypothesis (d).
Human review
  • Endorsed by Shuze Chen · Sep 27, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 27, 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