Documentation

CslibFrontier.Foundations.LinearAlgebra.Matrix.FourierMotzkin

Fourier–Motzkin elimination #

Fourier–Motzkin elimination removes one variable from a finite system of linear inequalities over a linearly ordered field. A variable occurring with coefficients a i is eliminated by keeping the rows with a i = 0 and adding, for every pair of rows p, q with a p > 0 > a q, the nonnegative combination -a q • row p + a p • row q, in which the variable cancels. The new system is solvable exactly when the old one is solvable for some value of the eliminated variable. Iterating this step eliminates any finite block of variables.

The combinations are recorded as an explicit matrix with nonnegative entries, so that every consequence of the projected system is a nonnegative combination of the original rows. This is what the algebraic proofs of Farkas' lemma and linear-programming duality in CslibFrontier.Foundations.LinearAlgebra.Matrix.Farkas and CslibFrontier.Foundations.LinearAlgebra.Matrix.LinearProgramming use. Unlike Mathlib's topological Farkas lemma ProperCone.hyperplane_separation, everything here works over any linearly ordered field, in particular over ℚ.

Main definitions #

Main results #

References #

@[reducible, inline]
abbrev Matrix.FourierMotzkin.Row {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} (a : ι → K) :
Type u_2

The rows produced by eliminating a variable whose coefficient column is a: the rows i with a i = 0, and the pairs (p, q) with a p > 0 > a q.

Instances For
    def Matrix.FourierMotzkin.combination {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} [DecidableEq ι] (a : ι → K) :
    Matrix (Row a) ι K

    The combination matrix of one Fourier–Motzkin step for the column a. A row i with a i = 0 is kept, and a pair (p, q) with a p > 0 > a q gives -a q • row p + a p • row q.

    Instances For
      @[simp]
      theorem Matrix.FourierMotzkin.combination_inl {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} [DecidableEq ι] (a : ι → K) (i : { i : ι // a i = 0 }) :

      A row with zero coefficient is kept unchanged.

      @[simp]
      theorem Matrix.FourierMotzkin.combination_inr {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} [DecidableEq ι] (a : ι → K) (p : { p : ι // 0 < a p }) (q : { q : ι // a q < 0 }) :
      combination a (Sum.inr (p, q)) = Pi.single (↑p) (-a ↑q) + Pi.single (↑q) (a ↑p)

      A pair (p, q) combines rows p and q with weights -a q and a p.

      theorem Matrix.FourierMotzkin.combination_nonneg {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} [DecidableEq ι] [IsStrictOrderedRing K] (a : ι → K) (r : Row a) (i : ι) :

      The entries of a Fourier–Motzkin combination matrix are nonnegative.

      theorem Matrix.FourierMotzkin.combination_mulVec_inl {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} [DecidableEq ι] [Fintype ι] (a v : ι → K) (i : { i : ι // a i = 0 }) :
      (combination a).mulVec v (Sum.inl i) = v ↑i

      The kept row i of combination a *ᵥ v is v i.

      theorem Matrix.FourierMotzkin.combination_mulVec_inr {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} [DecidableEq ι] [Fintype ι] (a v : ι → K) (p : { p : ι // 0 < a p }) (q : { q : ι // a q < 0 }) :
      (combination a).mulVec v (Sum.inr (p, q)) = -a ↑q * v ↑p + a ↑p * v ↑q

      The combined row (p, q) of combination a *ᵥ v is -a q * v p + a p * v q.

      theorem Matrix.FourierMotzkin.combination_mulVec_self {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} [DecidableEq ι] [Fintype ι] (a : ι → K) :

      The eliminated variable cancels in every combined row.

      theorem Matrix.FourierMotzkin.exists_smul_add_le_iff {K : Type u_1} [Field K] [LinearOrder K] {ι : Type u_2} [DecidableEq ι] [Fintype ι] [IsStrictOrderedRing K] (a v b : ι → K) :
      (∃ (t : K), t • a + v ≤ b) ↔ (combination a).mulVec v ≤ (combination a).mulVec b

      One step of Fourier–Motzkin elimination: the system t • a + v ≤ b is solvable in t exactly when the combined system without t holds.

      theorem Matrix.FourierMotzkin.exists_projection {K : Type u_1} [Field K] [LinearOrder K] [IsStrictOrderedRing K] {ι : Type u} [Fintype ι] {κ : Type v} [Fintype κ] {μ : Type w} [Fintype μ] (A : Matrix ι κ K) (B : Matrix ι μ K) (b : ι → K) :
      ∃ (ρ : Type u) (x : Fintype ρ) (T : Matrix ρ ι K), (∀ (r : ρ) (i : ι), 0 ≤ T r i) ∧ T * A = 0 ∧ ∀ (z : μ → K), (∃ (y : κ → K), A.mulVec y + B.mulVec z ≤ b) ↔ (T * B).mulVec z ≤ T.mulVec b

      Fourier–Motzkin projection. Eliminating a finite block of variables y from the system A *ᵥ y + B *ᵥ z ≤ b yields a finite system (T * B) *ᵥ z ≤ T *ᵥ b in the remaining variables z, whose rows are nonnegative combinations T of the original rows cancelling every column of A [Schrijver1986, Section 12.2].