Farkas' lemma: exactly one of Ax = b, x ≥ 0 and Aᵀp ≥ 0, pᵀb < 0 is solvable
ProvedPolyhedral.farkas_lemmaFarkas' lemma. Let and . Exactly one of the following two systems is solvable:
Equivalently, lies in the cone generated by the columns of precisely when every vector having nonnegative inner product with each column also has nonnegative inner product with .
This transposition theorem is the algebraic core of linear programming: duality, the optimality conditions for a linear program in standard form, and the description of the normal cone of all follow from it. It is Theorem 4.6 (p. 165) of Bertsimas & Tsitsiklis, Introduction to Linear Optimization.
Formalization note. Xor is exclusive disjunction, so the statement asserts both that the alternatives are incompatible and that one of them holds. Vectors are functions out of Fin n, and 0 ≤ x is the pointwise order. The statement is the finitely generated (column) form of Farkas' lemma; it is not a specialization of the Hilbert-space separation theorem for closed convex cones, because closedness of the column cone is part of what has to be established.
import Mathlib open Matrix
theorem Polyhedral.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 sorryConfirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.