Understanding and Using Linear Programming IV: The Duality Theorem and Three Proofs of the Farkas LemmaTextbook
Motivation
Every linear program comes with a second linear program, its dual, whose feasible solutions certify bounds on the optimum of the first. The duality theorem of linear programming says that these certificates are perfect: when both programs are feasible, the best bound equals the optimum. The theorem underlies the analysis of the simplex method, sensitivity analysis and shadow prices in operations research, the minimax theorem for zero-sum games, max-flow/min-cut and König-type min-max theorems in combinatorial optimization, and the primal–dual design of approximation and online algorithms.
The Farkas lemma, a theorem of the alternative for linear systems, contains the essence of duality: a system of linear equations or inequalities either has a (nonnegative) solution, or a single linear combination of its rows proves that it has none. It goes back to Farkas (1902) and Minkowski's work on finitely generated cones; the duality theorem itself is due to von Neumann (1947) and Gale, Kuhn and Tucker (1951).
This mission formalizes Chapter 6 of Matoušek and Gärtner's textbook Understanding and Using Linear Programming (Springer, 2007): the duality theorem in the book's form, weak duality, the Farkas lemma in its algebraic, geometric and three-variant forms, and the lemmas of two self-contained proofs of the Farkas lemma, one analytic (nearest points in finitely generated cones) and one via minimally infeasible systems.
Setting
Let be a real matrix with rows and columns, , . Vector inequalities are componentwise. The primal and dual linear programs are
A feasible solution of (P) is an satisfying its constraints; an optimal solution is a feasible with for every feasible . (P) is unbounded if its objective takes arbitrarily large values on feasible solutions. For the minimization (D) the notions are mirrored: an optimal has for all feasible , and (D) is unbounded if takes arbitrarily small values.
For , the convex cone generated by them is ; a primitive cone is one generated by linearly independent vectors. A system of inequalities is minimally infeasible if it has no solution but dropping any one inequality makes it solvable.
Formalization targets
Goal: the duality theorem (§6.1, p. 83)
For (P) and (D) as above, exactly one of the following occurs:
- neither (P) nor (D) is feasible;
- (P) is unbounded and (D) is infeasible;
- (P) is infeasible and (D) is unbounded;
- both are feasible; then both have optimal solutions, and every optimal of (P) and optimal of (D) satisfy
Milestones
- Proposition 6.1.1 (weak duality). for all feasible of (P) and of (D); hence (P) unbounded forces (D) infeasible, and (D) unbounded forces (P) infeasible.
- Proposition 6.4.1 (Farkas lemma). Exactly one of: has a solution ; some has and . Already on the platform as
LinearOptimization.farkas_lemma(Proved) and linked as a reference. - Proposition 6.4.3 (three variants). Solvability of , ; of , ; and of with free, each characterized by a certificate condition on .
- Proposition 6.4.2 (geometric Farkas lemma). lies in the cone generated by , or a hyperplane through separates the cone from strictly — exactly one.
- Lemmas 6.5.4, 6.5.5, 6.5.3, 6.5.1. Primitive cones are closed; a finitely generated cone is a finite union of primitive cones; hence it is closed (6.5.3, on the platform as
Polyhedral.isClosed_conicSpan, Proved); hence it has a point nearest to any . - Lemmas 6.6.2 and 6.6.1. is solvable iff every with has ; in a minimally infeasible system, for every some satisfies all inequalities except the th with equality.
Significance
The result. The duality theorem converts optimality into feasibility: a pair of primal and dual feasible solutions with is a short, checkable certificate that both are optimal, and the theorem guarantees such a certificate exists whenever an optimum does. It classifies every primal–dual pair into four behaviours and excludes the other five combinations of feasible-bounded, unbounded and infeasible. Later chapters of the same book rest on it: the minimax theorem for zero-sum games, the integrality of bipartite matching polytopes, the LP rounding for unrelated-machine scheduling, and the Delsarte bound for codes.
Formalizing it. All results here are classical and fully proved in the book; the work is formalization. Mathlib contains a Farkas lemma for proper cones in Hilbert spaces and closedness facts for finitely generated cones, and the platform already has Bertsimas–Tsitsiklis-style duality for a general-form minimization (LinearOptimization.lp_strong_duality) and matrix Farkas lemmas. What is missing is the textbook statement in Matoušek's inequality form (P)/(D), with its four-case exclusive classification, together with the chain of named lemmas that make two different elementary proofs of the Farkas lemma machine-checkable. The analytic chain (6.5.x) and the minimally-infeasible chain (6.6.x) are reusable independently of LP.
Difficulty
Weak duality is a two-line computation. The difficulty is entirely in the reverse direction, that a feasible bounded (P) forces the dual to be feasible with the same value. Any proof must use something beyond linear algebra over : either the termination of the simplex method with an anticycling rule, a topological fact (a finitely generated cone is closed), or an extremal argument (an optimal solution of an auxiliary LP). The naive geometric argument — take the nearest point of the cone to — fails without closedness, and closedness of the cone generated by a set is false for infinitely generated cones (the cone over a disc touching the origin is an open half-plane plus a point), so finiteness has to be used, which is the role of the primitive-cone decomposition. In the four-case theorem itself, the remaining obstacle is attainment: "bounded and feasible" must be upgraded to "an optimum exists" for both programs, which is not a consequence of Farkas-type statements alone.
Formalization scope
- Vectors are
Fin n → ℝand matricesMatrix (Fin m) (Fin n) ℝ; the book's indices become . The row vector isAᵀ *ᵥ y, so is0 ≤ Aᵀ *ᵥ y; scalar products are⬝ᵥ. - Optimal solutions and unboundedness are stated against every feasible point; no
sSup/sInfis used, so no junk value of an empty or unbounded supremum enters. "Exactly one of the four cases" is∃! k : Fin 4, DualityCase A b c k, with the book's case at index ; a plain disjunction would be weaker than the book. - Cone items live in
EuclideanSpace ℝ (Fin m), so the nearest point of Lemma 6.5.1 is Euclidean and is the inner product. The convex cone generated by is the set of nonnegative combinations (it contains , also for ). - A trivializing formalization — case 4 read as "if both have optimal solutions then their values agree", which is weak duality plus nothing — is ruled out: case 4 asserts the existence of both optima from feasibility alone.
- Lemma 6.3.1 (the dual solution read off the final simplex tableau) and Lemma 6.5.2 (nearest point in a nonempty closed set, available in Mathlib as
IsClosed.exists_infDist_eq_dist) are not separate targets. The Fourier–Motzkin elimination of §6.7 has no numbered result. - Contributions welcome: proofs of any milestone, the two Farkas-lemma chains, and bridges to the general-form duality already on the platform.
Selected references
- J. Matoušek and B. Gärtner, Understanding and Using Linear Programming, Springer Universitext, 2007, Chapter 6. https://doi.org/10.1007/978-3-540-30717-4
- J. Farkas, Theorie der einfachen Ungleichungen, J. Reine Angew. Math. 124 (1902), 1–27. https://doi.org/10.1515/crll.1902.124.1
- D. Gale, H. W. Kuhn and A. W. Tucker, Linear programming and the theory of games, in Activity Analysis of Production and Allocation, Wiley, 1951, 317–329.
- M. Conforti, M. Di Summa and G. Zambelli, Minimally infeasible set-partitioning problems with balanced constraints, Mathematics of Operations Research (cited in the book as to appear; the source of the proof in §6.6).
- D. Bertsimas and J. N. Tsitsiklis, Introduction to Linear Optimization, Athena Scientific, 1997, Chapter 4.