Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Proposition (2.4) — a nonzero gradient of d_E points away from the unique closest point

Proved
ClarkeGradients.FlowInvariance.gradient_infDist_of_ne_zero

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

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

Let EEE be a nonempty closed subset of Rn\mathbb R^nRn and dE(y)=min⁡{∣y−e∣:e∈E}d_E(y)=\min\{|y-e|:e\in E\}dE​(y)=min{∣y−e∣:e∈E} its distance function. Suppose that dEd_EdE​ is differentiable at xxx and that ∇dE(x)≠0\nabla d_E(x)\ne 0∇dE​(x)=0. Then

  1. xxx belongs to the complement of EEE;
  2. there exists a unique point e∈Ee\in Ee∈E closest to xxx, i.e. with ∣x−e∣=dE(x)|x-e|=d_E(x)∣x−e∣=dE​(x);
  3. for that point,
∇dE(x)=x−e∣x−e∣.\nabla d_E(x)=\frac{x-e}{|x-e|}.∇dE​(x)=∣x−e∣x−e​.

This is the local description of dEd_EdE​ at its points of differentiability off EEE, and it is what Corollary (2.5) and the proof of Theorem (4.4) use to compute generalized gradients of dEd_EdE​.

Formalization Note dEd_EdE​ is Metric.infDist · E; "eee is closest to xxx" is e ∈ E ∧ dist x e = infDist x E. Part (2) is stated with ∃!, and part (3) is stated for every closest point (equivalently, by (2), the unique one). The formula is written ∥x−e∥−1⋅(x−e)\|x-e\|^{-1}\cdot(x-e)∥x−e∥−1⋅(x−e); the division is well defined because x∉Ex\notin Ex∈/E by (1). The paper proves (2)–(3) by applying Theorem (2.1) (mission I's goal); mission I is a separate draft, so that theorem is not a hypothesis here.

Preamble
import Mathlib
Formal statement
namespace ClarkeGradients.FlowInvariance

/-- Clarke (1975), Proposition (2.4): let `E ⊆ ℝⁿ` be nonempty and closed and
`d_E(y) = Metric.infDist y E`. If `∇d_E(x)` exists and is different from `0`, then
(1) `x ∉ E`; (2) there is a unique point `e ∈ E` closest to `x`; and
(3) `∇d_E(x) = (x - e)/|x - e|` for that point `e`. -/
theorem gradient_infDist_of_ne_zero {n : ℕ} (E : Set (EuclideanSpace ℝ (Fin n)))
    (hE : E.Nonempty) (hEc : IsClosed E) (x : EuclideanSpace ℝ (Fin n))
    (hdiff : DifferentiableAt ℝ (fun y => Metric.infDist y E) x)
    (hne : gradient (fun y => Metric.infDist y E) x ≠ 0) :
    x ∉ E ∧
      (∃! e : EuclideanSpace ℝ (Fin n), e ∈ E ∧ dist x e = Metric.infDist x E) ∧
      ∀ e ∈ E, dist x e = Metric.infDist x E →
        gradient (fun y => Metric.infDist y E) x = ‖x - e‖⁻¹ • (x - e) := by sorry

end ClarkeGradients.FlowInvariance
Source
Clarke, Generalized gradients and applications, Trans. Amer. Math. Soc. 205 (1975), p. 253, Proposition (2.4)
Read-back

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

The theorem takes:

  • n∈Nn \in \mathbb{N}n∈N;
  • a set E⊆RnE \subseteq \mathbb{R}^nE⊆Rn that is nonempty and closed;
  • a point x∈Rnx \in \mathbb{R}^nx∈Rn.

Let dE(y)=inf⁡z∈E∥y−z∥d_E(y) = \inf_{z\in E}\|y-z\|dE​(y)=infz∈E​∥y−z∥ be the Euclidean distance to EEE. There are two further hypotheses:

  • dEd_EdE​ is (Fréchet) differentiable at xxx;
  • its gradient ∇dE(x)\nabla d_E(x)∇dE​(x) (the vector representing the derivative through the inner product) is not the zero vector.

The theorem then asserts three things:

  1. x∉Ex \notin Ex∈/E.
  2. There is exactly one e∈Ee \in Ee∈E with ∥x−e∥=dE(x)\|x - e\| = d_E(x)∥x−e∥=dE​(x).
  3. For every e∈Ee \in Ee∈E with ∥x−e∥=dE(x)\|x - e\| = d_E(x)∥x−e∥=dE​(x),
∇dE(x)=x−e∥x−e∥.\nabla d_E(x) = \frac{x - e}{\|x - e\|}.∇dE​(x)=∥x−e∥x−e​.

(By item 1, x≠ex \neq ex=e, so the denominator is nonzero.)

Degenerate case: when n=0n = 0n=0, every gradient is the zero vector, so the hypothesis ∇dE(x)≠0\nabla d_E(x) \ne 0∇dE​(x)=0 can never hold and the theorem is vacuous.

Human review
  • Endorsed by Shuze Chen · Sep 28, 2026

    Confirmed by the moderator at approval.

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