Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Farkas' lemma

Proved
LinearOptimization.farkas_lemma

by Shuze Chen · 1 vote · Aug 5, 2026 · Mathlib c5ea003 (Lean v4.30.0)

dualityfarkaslinear-programming

(Theorem 4.6, Farkas' lemma — GOAL) Let AAA be a matrix of dimensions m×nm \times nm×n and let bbb be a vector in Rm\mathbb{R}^mRm. Then, exactly one of the following two alternatives holds:

  • (a) there exists some x≥0x \ge 0x≥0 such that Ax=bAx = bAx=b;
  • (b) there exists some vector ppp such that p′A≥0′p'A \ge 0'p′A≥0′ and p′b<0p'b < 0p′b<0.
Preamble
import Mathlib.Data.Matrix.Mul
import Mathlib.Data.Real.Basic


open Matrix

/-- **Bertsimas & Tsitsiklis, Theorem 4.6 (p. 165).** Farkas' lemma: exactly one of
(a) `∃ x ≥ 0, Ax = b` and (b) `∃ p, p'A ≥ 0' ∧ p'b < 0` holds. -/
Formal statement
theorem LinearOptimization.farkas_lemma {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ)
    (b : Fin m → ℝ) :
    Xor' (∃ x : Fin n → ℝ, 0 ≤ x ∧ A.mulVec x = b)
      (∃ p : Fin m → ℝ, 0 ≤ Aᵀ.mulVec p ∧ p ⬝ᵥ b < 0) := by
  sorry
Source
Bertsimas & Tsitsiklis, Introduction to Linear Optimization, Athena Scientific, 1997, Theorem 4.6, p. 165
Read-back

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

Farkas alternative, exclusive form. For all m,n≥0m, n \ge 0m,n≥0, every m×nm \times nm×n real matrix AAA, and every b∈Rmb \in \mathbb{R}^mb∈Rm, exactly one of the following two alternatives holds (the statement is an exclusive-or: one alternative is true and the other is false): (I) there exists x∈Rnx \in \mathbb{R}^nx∈Rn with x≥0x \ge 0x≥0 componentwise and Ax=bA x = bAx=b; (II) there exists p∈Rmp \in \mathbb{R}^mp∈Rm with ATp≥0A^{\mathsf T} p \ge 0ATp≥0 componentwise (i.e. ∑ipiAij≥0\sum_i p_i A_{ij} \ge 0∑i​pi​Aij​≥0 for every column jjj) and p⋅b<0p \cdot b < 0p⋅b<0 (strict). Degenerate cases are covered by the same claim: e.g. for n=0n = 0n=0 alternative (I) reduces to b=0b = 0b=0, and for m=0m = 0m=0 alternative (II) is unsatisfiable since p⋅bp \cdot bp⋅b is an empty sum =0= 0=0.

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

  • Endorsed by Shuze Chen · Aug 5, 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