Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Farkas' lemma

Proved
SmaleNinth.farkas_lemma

by Zexuan Liu · Sep 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

certificatesdualityfarkaslinear-programming

Let A∈Rm×nA \in \mathbb{R}^{m\times n}A∈Rm×n and b∈Rmb \in \mathbb{R}^mb∈Rm. Then exactly one of the following holds:

∃x∈Rn, Ax≥bor∃y∈Rm, y≥0, yTA=0, yTb>0.\exists x \in \mathbb{R}^n,\ Ax \ge b \qquad\text{or}\qquad \exists y \in \mathbb{R}^m,\ y \ge 0,\ y^{\mathsf T} A = 0,\ y^{\mathsf T} b > 0 .∃x∈Rn, Ax≥bor∃y∈Rm, y≥0, yTA=0, yTb>0.

The two alternatives exclude each other for a one-line reason: if Ax≥bAx \ge bAx≥b and y≥0y \ge 0y≥0 then yTb≤yTAx=0y^{\mathsf T} b \le y^{\mathsf T} A x = 0yTb≤yTAx=0. The content of the lemma is that one of them always holds, so that infeasibility of a linear system always admits a finite, checkable certificate: a nonnegative combination of the inequalities whose left-hand side cancels identically while the right-hand side stays positive, that is, an explicit derivation of 0≥ε>00 \ge \varepsilon > 00≥ε>0.

The vector yyy is the reason linear programming lies in NP ∩\cap∩ co-NP, it is the dual solution in linear programming duality, and it is what an algorithm exhibits when it reports that a system has no solution. In the setting of Smale's ninth problem it makes the decision problem symmetric: both answers can be certified, so the question is entirely one of finding a certificate in a number of arithmetic operations polynomial in mmm and nnn, not one of verifying it.

Formalization note. The proof is the classical constructive one by Fourier–Motzkin elimination, carried out by induction on the number of variables. Eliminating the last variable replaces the rows by those with vanishing last coefficient together with the pairwise combinations of rows whose last coefficients have opposite signs; multipliers for the reduced system lift to nonnegative multipliers for the original one, and the base case of zero variables is immediate. Both the elimination and the lifting are performed over an arbitrary finite index type, so that the pair index set of one step is available as the index type of the next.

Preamble
import Definitions.Def_Polyhedron

/-!
Farkas' lemma in the form used for linear inequalities: a system `Ax >= b` is
either feasible, or carries a nonnegative combination of its rows that is
identically zero with positive right-hand side, and never both.

Source: J. Farkas, *Theorie der einfachen Ungleichungen*, J. Reine Angew.
Math. 124 (1902) 1-27; see A. Schrijver, *Theory of Linear and Integer
Programming*, Wiley 1986, Corollary 7.1d, and Bertsimas-Tsitsiklis,
*Introduction to Linear Optimization*, Athena Scientific 1997, Section 4.6.
-/

open Matrix LinearOptimization

/-- **Farkas' lemma.** The system `Ax >= b` has a solution if and only if there
is no vector `y >= 0` with `y' A = 0` and `y' b > 0`. -/
Formal statement
theorem SmaleNinth.farkas_lemma {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ) (b : Fin m → ℝ) :
    (polyhedron A b).Nonempty ↔
      ¬ ∃ y : Fin m → ℝ, (∀ i, 0 ≤ y i) ∧ (∀ k, ∑ i, y i * A i k = 0) ∧
        0 < ∑ i, y i * b i := by sorry
Source
J. Farkas, Theorie der einfachen Ungleichungen, Journal fuer die reine und angewandte Mathematik 124 (1902) 1-27. See A. Schrijver, Theory of Linear and Integer Programming, Wiley 1986, Corollary 7.1d (the inequality form Ax >= b), and Bertsimas-Tsitsiklis, Introduction to Linear Optimization, Athena Scientific 1997, Section 4.6.

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