Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Complementary slackness

Proved
ConvexOptimization.complementary_slackness

by Shuze Chen · Aug 12, 2026 · Mathlib 0df444a (Lean v4.33.1)

convexoptimizationdualitykkt

Complementary slackness — condition (5.48) of Boyd & Vandenberghe.

For the standard problem, let x⋆x^{\star}x⋆ be feasible, let λ∈Rm\lambda \in \mathbb{R}^mλ∈Rm with λ⪰0\lambda \succeq 0λ⪰0 and ν∈Rp\nu \in \mathbb{R}^pν∈Rp, and suppose the duality gap vanishes, g(λ,ν)=f0(x⋆)g(\lambda,\nu) = f_0(x^{\star})g(λ,ν)=f0​(x⋆), where ggg is the Lagrange dual function. Then

λi fi(x⋆)  =  0(i=1,…,m).\lambda_i\, f_i(x^{\star}) \;=\; 0 \qquad (i = 1,\dots,m).λi​fi​(x⋆)=0(i=1,…,m).

Equivalently: λi>0⇒fi(x⋆)=0\lambda_i > 0 \Rightarrow f_i(x^{\star}) = 0λi​>0⇒fi​(x⋆)=0 and fi(x⋆)<0⇒λi=0f_i(x^{\star}) < 0 \Rightarrow \lambda_i = 0fi​(x⋆)<0⇒λi​=0. A constraint that is slack at the optimum carries no price, and a constraint with a positive price is active.

Beyond being one of the four KKT conditions, this is the result that gives dual variables their economic reading as shadow prices, and in practice it is what lets an algorithm identify the active set from a dual solution. No convexity is required: the hypothesis is a zero gap, however obtained.

Formalization Note The zero-gap hypothesis equates the EReal-valued dual function with the coercion of the real number f0(x⋆)f_0(x^{\star})f0​(x⋆), which also encodes finiteness of g(λ,ν)g(\lambda,\nu)g(λ,ν); feasibility of x⋆x^{\star}x⋆ is membership in the mission's feasible-set definition. Source: B&V §5.5.2, p. 242, eq. (5.48).

Preamble
import Mathlib
import Definitions.Def_ConvexOptimization_lagrangeDuality

open scoped RealInnerProductSpace ENNReal
open MeasureTheory

Formal statement
theorem ConvexOptimization.complementary_slackness {n mm p : ℕ}
    (f₀ : EuclideanSpace ℝ (Fin n) → ℝ)
    (fc : Fin mm → EuclideanSpace ℝ (Fin n) → ℝ)
    (a : Fin p → EuclideanSpace ℝ (Fin n)) (b : Fin p → ℝ)
    (xs : EuclideanSpace ℝ (Fin n)) (hxs : xs ∈ feasibleSet fc a b)
    (lam : Fin mm → ℝ) (hlam : ∀ i, 0 ≤ lam i) (nu : Fin p → ℝ)
    (hzero : dualFunction f₀ fc a b lam nu = (f₀ xs : EReal)) :
    ∀ i, lam i * fc i xs = 0 := by
  sorry
Source
Boyd & Vandenberghe 2004, Convex Optimization, Cambridge University Press (seventh printing with corrections, 2009), https://web.stanford.edu/~boyd/cvxbook/, pp. 242, §5.5.2 eq. (5.48) (complementary slackness)

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