The primal–dual pair / : slacks, feasibility, optimality
DefinitionVanderbeiLP_StrictComp_PrimalDualPairFix integers , an real matrix , a right-hand side and an objective vector . The primal linear program in standard form is
and its dual is
This file defines the objects every statement of the mission is phrased in:
- the primal slack , so that the primal reads , ;
- the dual slack (a left-hand side minus the corresponding right-hand side), so that the dual reads , ;
- primal feasibility of : and ;
- dual feasibility of : and ;
- primal optimality of : is primal feasible and for every primal feasible ;
- dual optimality of : is dual feasible and for every dual feasible .
All inequalities between vectors are componentwise.
These are the standard-form problem (5.1), its dual, and their slack forms (10.9)–(10.10). Weak and strong duality, complementary slackness and strict complementarity are all statements about these six objects.
Formalization Note Vectors are functions Fin n → ℝ, Fin m → ℝ and is a Matrix (Fin m) (Fin n) ℝ. The slacks are functions of (resp. ), not free variables, so a "solution " of the book is the vector together with the slack it determines. Optimality is attainment of the maximum (minimum) over the feasible set, as defined on p. 7; no value function or supremum is involved.
import Mathlib
open Matrix
namespace VanderbeiLP.StrictComp
/-- Primal slack vector `w = b - A x` of the standard-form LP (5.1)/(10.9):
`maximize cᵀx subject to Ax + w = b, x, w ≥ 0`. -/
def primalSlack {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ) (b : Fin m → ℝ) (x : Fin n → ℝ) :
Fin m → ℝ :=
b - A *ᵥ x
/-- Dual slack vector `z = Aᵀ y - c` of the dual (10.10):
`minimize bᵀy subject to Aᵀy - z = c, y, z ≥ 0`
(each dual slack is a left-hand side minus the corresponding right-hand side, p. 57). -/
def dualSlack {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ) (c : Fin n → ℝ) (y : Fin m → ℝ) :
Fin n → ℝ :=
Aᵀ *ᵥ y - c
/-- `x` is feasible for the primal (5.1): `x ≥ 0` and `w = b - Ax ≥ 0`. -/
def PrimalFeasible {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ) (b : Fin m → ℝ) (x : Fin n → ℝ) :
Prop :=
(∀ j, 0 ≤ x j) ∧ ∀ i, 0 ≤ primalSlack A b x i
/-- `y` is feasible for the dual of (5.1): `y ≥ 0` and `z = Aᵀy - c ≥ 0`. -/
def DualFeasible {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ) (c : Fin n → ℝ) (y : Fin m → ℝ) :
Prop :=
(∀ i, 0 ≤ y i) ∧ ∀ j, 0 ≤ dualSlack A c y j
/-- `x` is optimal for the primal: it is feasible and attains the maximum of `cᵀx`
over all primal feasible points (p. 7). -/
def PrimalOptimal {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ) (b : Fin m → ℝ) (c : Fin n → ℝ)
(x : Fin n → ℝ) : Prop :=
PrimalFeasible A b x ∧ ∀ x' : Fin n → ℝ, PrimalFeasible A b x' → c ⬝ᵥ x' ≤ c ⬝ᵥ x
/-- `y` is optimal for the dual: it is dual feasible and attains the minimum of `bᵀy`
over all dual feasible points. -/
def DualOptimal {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ) (b : Fin m → ℝ) (c : Fin n → ℝ)
(y : Fin m → ℝ) : Prop :=
DualFeasible A c y ∧ ∀ y' : Fin m → ℝ, DualFeasible A c y' → b ⬝ᵥ y ≤ b ⬝ᵥ y'
end VanderbeiLP.StrictComp