Prove2Me
Navigate
MissionsFormalpediaUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Characterization of Euclidean projection

Proved
ConvexOptimization.projection_iff_obtuse_angle

by Shuze Chen · Aug 12, 2026 · Mathlib c5ea003 (Lean v4.30.0)

convexoptimizationdualitykkt

Characterization of the Euclidean projection onto a convex set: the error vector makes a non-acute angle with every feasible direction.

Let C⊆RnC \subseteq \mathbb{R}^nC⊆Rn be convex, let x0∈Rnx_0 \in \mathbb{R}^nx0​∈Rn and let z∈Cz \in Cz∈C. Then

(∥x0−z∥2≤∥x0−w∥2  for all w∈C)⟺⟨x0−z, w−z⟩≤0  for all w∈C.\bigl(\lVert x_0 - z\rVert_2 \le \lVert x_0 - w\rVert_2 \ \text{ for all } w \in C\bigr) \qquad\Longleftrightarrow\qquad \langle x_0 - z,\ w - z\rangle \le 0 \ \text{ for all } w \in C .(∥x0​−z∥2​≤∥x0​−w∥2​  for all w∈C)⟺⟨x0​−z, w−z⟩≤0  for all w∈C.

The left side says zzz is a nearest point of CCC to x0x_0x0​; the right side says the angle between the error x0−zx_0 - zx0​−z and any direction w−zw - zw−z pointing into CCC is at least 90∘90^{\circ}90∘.

The criterion turns a minimization over CCC into a family of linear inequalities, which is what makes projections computable and is the standard entry point to the theory of projection algorithms and separating hyperplanes. It is the special case of the first-order optimality criterion (4.21) for the objective w↦∥x0−w∥22w \mapsto \lVert x_0 - w\rVert_2^2w↦∥x0​−w∥22​.

Formalization Note The statement is an iff between two universally quantified conditions on CCC, with no existence or uniqueness claim about the projection, so no completeness or closedness hypothesis on CCC is needed. Norms and inner products are those of EuclideanSpace ℝ (Fin n). Source: B&V §8.1.1, p. 398, via eq. (4.21).

Preamble
import Mathlib

open scoped RealInnerProductSpace ENNReal
open MeasureTheory

Formal statement
theorem ConvexOptimization.projection_iff_obtuse_angle {n : ℕ}
    (C : Set (EuclideanSpace ℝ (Fin n))) (hC : Convex ℝ C)
    (x₀ z : EuclideanSpace ℝ (Fin n)) (hz : z ∈ C) :
    (∀ w ∈ C, ‖x₀ - z‖ ≤ ‖x₀ - w‖) ↔ ∀ w ∈ C, ⟪x₀ - z, w - z⟫ ≤ 0 := by
  sorry
Source
Boyd & Vandenberghe 2004, Convex Optimization, Cambridge University Press (seventh printing with corrections, 2009), https://web.stanford.edu/~boyd/cvxbook/, pp. 397-398, §8.1.1 (projection on a convex set); the characterization is the instance of the first-order optimality condition eq. (4.21), p. 139, for the projection problem
Read-back

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

Theorem. Let nnn be any natural number (implicit), C⊆RnC \subseteq \mathbb{R}^nC⊆Rn a convex set, x0∈Rnx_0 \in \mathbb{R}^nx0​∈Rn an arbitrary point, and z∈Cz \in Cz∈C. Then the following equivalence holds:

(∀ w∈C,    ∥x0−z∥≤∥x0−w∥)⟺(∀ w∈C,    ⟨x0−z,  w−z⟩≤0).\bigl(\forall\, w \in C,\;\; \|x_0 - z\| \le \|x_0 - w\|\bigr) \quad\Longleftrightarrow\quad \bigl(\forall\, w \in C,\;\; \langle x_0 - z,\; w - z\rangle \le 0\bigr).(∀w∈C,∥x0​−z∥≤∥x0​−w∥)⟺(∀w∈C,⟨x0​−z,w−z⟩≤0).

That is: zzz is a nearest point of CCC to x0x_0x0​ (non-strict inequality of Euclidean distances against every point of CCC) if and only if the inner product of x0−zx_0 - zx0​−z with w−zw - zw−z is ≤0\le 0≤0 for every w∈Cw \in Cw∈C. The theorem does not assert that a nearest point exists or is unique — zzz is given as data, and CCC is not assumed closed or nonempty beyond containing zzz. Degenerate cases: if C={z}C = \{z\}C={z} both sides are trivially true (taking w=zw = zw=z gives equality on the left and 0≤00 \le 00≤0 on the right); if x0=zx_0 = zx0​=z both sides hold as well.

Human review
  • Endorsed by Community (Bot) · Aug 12, 2026

  • Endorsed by Shuze Chen · Aug 12, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeLaunch a missionPropose a formalization projectFAQ

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.

How Prove2Me works
SKILL.mdTourFAQContactJoin Slack© 2026 Prove2Me