Linear programs and their duals
Lax109476.LinearProgram · concepts/Lax109476/LinearProgram.lean · lax-109476
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A linear program in inequality form is
Its dual is
All vector inequalities are componentwise. A feasible maximization program is bounded above if one finite real number bounds the objective of every feasible point. A primal point is optimal if it is feasible and no feasible point has a larger objective.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Algebra.BigOperators.Ring.Finset |
| 2 | import Mathlib.Data.Real.Basic |
| 3 | import Mathlib.Data.Fintype.Basic |
| 4 | |
| 5 | /-! |
| 6 | --- |
| 7 | title: Linear programs and their duals |
| 8 | type: definition |
| 9 | --- |
| 10 | A linear program in inequality form is |
| 11 | |
| 12 | Its dual is |
| 13 | |
| 14 | All vector inequalities are componentwise. A feasible maximization program |
| 15 | is bounded above if one finite real number bounds the objective of every |
| 16 | feasible point. A primal point is optimal if it is feasible and no feasible |
| 17 | point has a larger objective. |
| 18 | |
| 19 | # Formalization notes |
| 20 | |
| 21 | There are `n` variables and `m` inequalities, indexed by `Fin n` and `Fin m`. |
| 22 | The coefficient data are shared by real and rational instances. Feasibility |
| 23 | and objective formulas are the same in either field. Both dimensions may be |
| 24 | zero. No feasibility, boundedness, optimizer, or optimum value is bundled |
| 25 | into the input data. Theorems state the necessary hypotheses explicitly. |
| 26 | Equality constraints and unrestricted variables can be represented by paired |
| 27 | inequalities and differences of nonnegative variables. |
| 28 | -/ |
| 29 | |
| 30 | open scoped BigOperators |
| 31 | |
| 32 | namespace Lax109476.LinearProgram |
| 33 | |
| 34 | /-- Coefficients of a maximization program with `m` inequalities and `n` |
| 35 | nonnegative variables. -/ |
| 36 | structure Program (K : Type) (m n : ℕ) where |
| 37 | /-- The constraint matrix. -/ |
| 38 | A : Fin m → Fin n → K |
| 39 | /-- The upper bounds on the constraint rows. -/ |
| 40 | b : Fin m → K |
| 41 | /-- The coefficients of the maximized objective. -/ |
| 42 | c : Fin n → K |
| 43 | |
| 44 | /-- The value of one constraint row at a primal point. -/ |
| 45 | def rowValue {K : Type} [Ring K] {m n : ℕ} (P : Program K m n) |
| 46 | (x : Fin n → K) (i : Fin m) : K := |
| 47 | ∑ j, P.A i j * x j |
| 48 | |
| 49 | /-- One component of the transposed matrix applied to a dual point. -/ |
| 50 | def columnValue {K : Type} [Ring K] {m n : ℕ} (P : Program K m n) |
| 51 | (y : Fin m → K) (j : Fin n) : K := |
| 52 | ∑ i, P.A i j * y i |
| 53 | |
| 54 | /-- The primal objective value. -/ |
| 55 | def primalValue {K : Type} [Ring K] {m n : ℕ} (P : Program K m n) |
| 56 | (x : Fin n → K) : K := |
| 57 | ∑ j, P.c j * x j |
| 58 | |
| 59 | /-- The dual objective value. -/ |
| 60 | def dualValue {K : Type} [Ring K] {m n : ℕ} (P : Program K m n) |
| 61 | (y : Fin m → K) : K := |
| 62 | ∑ i, P.b i * y i |
| 63 | |
| 64 | /-- A nonnegative primal point satisfies all row upper bounds. -/ |
| 65 | def PrimalFeasible {K : Type} [Ring K] [PartialOrder K] {m n : ℕ} |
| 66 | (P : Program K m n) (x : Fin n → K) : Prop := |
| 67 | (∀ j, 0 ≤ x j) ∧ ∀ i, rowValue P x i ≤ P.b i |
| 68 | |
| 69 | /-- A nonnegative dual point dominates every objective coefficient. -/ |
| 70 | def DualFeasible {K : Type} [Ring K] [PartialOrder K] {m n : ℕ} |
| 71 | (P : Program K m n) (y : Fin m → K) : Prop := |
| 72 | (∀ i, 0 ≤ y i) ∧ ∀ j, P.c j ≤ columnValue P y j |
| 73 | |
| 74 | /-- The real primal feasible set is nonempty. -/ |
| 75 | def IsFeasible {m n : ℕ} (P : Program ℝ m n) : Prop := |
| 76 | ∃ x, PrimalFeasible P x |
| 77 | |
| 78 | /-- A finite upper bound holds for every real primal feasible point. -/ |
| 79 | def IsBoundedAbove {m n : ℕ} (P : Program ℝ m n) : Prop := |
| 80 | ∃ B : ℝ, ∀ x, PrimalFeasible P x → primalValue P x ≤ B |
| 81 | |
| 82 | /-- A primal feasible point maximizes the objective over the feasible set. -/ |
| 83 | def IsPrimalOptimal {K : Type} [Ring K] [PartialOrder K] {m n : ℕ} |
| 84 | (P : Program K m n) (x : Fin n → K) : Prop := |
| 85 | PrimalFeasible P x ∧ ∀ z, PrimalFeasible P z → primalValue P z ≤ primalValue P x |
| 86 | |
| 87 | end Lax109476.LinearProgram |
| 88 |
Formalization notes
There are variables and inequalities, indexed by and . The coefficient data are shared by real and rational instances. Feasibility and objective formulas are the same in either field. Both dimensions may be zero. No feasibility, boundedness, optimizer, or optimum value is bundled into the input data. Theorems state the necessary hypotheses explicitly. Equality constraints and unrestricted variables can be represented by paired inequalities and differences of nonnegative variables.
Builds on
none
Used by
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments