Skip to content

About

Lean 4 proof of the optimality condition for nonsmooth convex problems: x minimizes convex f over convex D iff 0 ∈ ∂f(x) + N_D(x) (MathOverflow 167745)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Optimality condition for nonsmooth convex problems in Lean 4

Lean build

A formal proof, in Lean 4 with Mathlib, of the first-order optimality condition for minimizing a convex, not necessarily differentiable function over a convex set:

Let f : ℝⁿ → ℝ be convex and D ⊆ ℝⁿ convex. A point x ∈ D minimizes f over D if and only if there is a subgradient v ∈ ∂f(x) with vᵀ(y − x) ≥ 0 for all y ∈ D, that is, 0 ∈ ∂f(x) + N_D(x).

This was asked on MathOverflow, question 167745 (2014), as the nonsmooth version of Boyd–Vandenberghe, Convex Optimization, Section 4.2.3.

Status: proved

theorem NonsmoothOptimality.isMinOn_iff_exists_subgradient : OptimalityStatement
-- where
def OptimalityStatement : Prop :=
  ∀ (n : ℕ) (f : EuclideanSpace ℝ (Fin n) → ℝ) (D : Set (EuclideanSpace ℝ (Fin n))),
    ConvexOn ℝ Set.univ f → Convex ℝ D → ∀ x ∈ D,
      (IsMinOn f D x ↔
        ∃ v : EuclideanSpace ℝ (Fin n),
          (∀ y, f x + inner ℝ v (y - x) ≤ f y) ∧ ∀ y ∈ D, 0 ≤ inner ℝ v (y - x))

#print axioms NonsmoothOptimality.isMinOn_iff_exists_subgradient reports only propext, Classical.choice, Quot.sound. CI enforces this, and it also fails on any warning, including a sorry.

Reading of the statement:

  • f is real valued and convex on all of ℝⁿ, as in the question. Then f is continuous and the sum rule ∂(f + δ_D) = ∂f + N_D needs no constraint qualification. For extended-valued f one would need one, for example ri(dom f) ∩ ri D ≠ ∅.
  • D is only assumed convex, not closed and not nonempty; x ∈ D is a hypothesis.
  • Optimality is Mathlib's IsMinOn f D x. Mathlib has no subdifferential, so v ∈ ∂f(x) is written out as the subgradient inequality f x + ⟪v, y − x⟫ ≤ f y for every y ∈ ℝⁿ.

A known result

This is a textbook theorem, not a new one: it is the case of finite f in Rockafellar, Convex Analysis (1970), Section 27, and the MathOverflow question was answered by its author in an edit, via the sum rule. What is new here is only the formal proof. Mathlib has no subdifferential; optlib has the unconstrained version (first_order_convex_iff_subgradient) and the sum rule for finite convex functions, but not this constrained form.

How the proof goes

The easy direction (⇐) is the subgradient inequality: f y ≥ f x + vᵀ(y − x) ≥ f x for y ∈ D. For (⇒), in NonsmoothOptimality/Main.lean:

  1. f is convex and finite on ℝⁿ, hence continuous (ConvexOn.continuousOn), so the strict epigraph S = {(y, t) : f(y) < t} is open and convex in ℝⁿ × ℝ;
  2. S is disjoint from the convex set T = D × {f(x)}, because x is optimal;
  3. Hahn–Banach (geometric_hahn_banach_open) gives a continuous linear φ and u with φ < u on S and u ≤ φ on T;
  4. write φ(y, r) = w(y) + α r. Testing with (x, f(x) + 1) gives α < 0, and letting ε → 0 in (y, f(y) + ε) ∈ S gives w(y) + α f(y) ≤ u ≤ w(x) + α f(x) for every y;
  5. hence v = w / (−α), a vector by the Riesz isomorphism, is a subgradient at x, and w(d − x) ≥ 0 for d ∈ D because (d, f(x)) ∈ T.
File Content
NonsmoothOptimality/Statement.lean the statement OptimalityStatement
NonsmoothOptimality/Main.lean the proof isMinOn_iff_exists_subgradient
verify/Axioms.lean, verify/check_axioms.py axiom check run by CI

Left to Solve

The same statement is problem mo-167745 on Left to Solve, which collects Lean statements of open and known problems. The proposition in Statement.lean is word for word the Lean statement submitted there, and the toolchain and Mathlib pins below are those of its checker (google-deepmind/formal-conjectures at commit 9097e2f), so the proof checks against the same Mathlib in both places.

Build

Toolchain leanprover/lean4:v4.33.1, Mathlib 0df444a.

lake exe cache get          # Mathlib build cache
lake build                  # under a minute after the cache
lake env lean verify/Axioms.lean

Use of AI

This repository was written with substantial assistance from Claude (Anthropic), including the statement and the Lean proof. A second model (Google Gemini) reviewed the formal statement against the question. Lean checks the proof; humans should still check that the statement in NonsmoothOptimality/Statement.lean says what is claimed.

License

Apache-2.0.

About

Lean 4 proof of the optimality condition for nonsmooth convex problems: x minimizes convex f over convex D iff 0 ∈ ∂f(x) + N_D(x) (MathOverflow 167745)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages