Documentation

CslibFrontier.Algorithms.Lean.Simplex.IntegerTableau

Exact integer tableau pivoting and lexicographic minimum-ratio rule #

This module implements division-exact (Bareiss-style) integer tableau pivoting and the lexicographic minimum-ratio test for linear systems A z = b, z ≥ 0 ([vS07], Sections 3.5–3.6, eqs. (3.11)–(3.19), Exercises 3.8 and 3.10).

Given an integer constraint matrix A : Matrix (Fin r) ι ℤ and right-hand side b : Fin r → ℤ, an IntegerTableau r ι maintains an ordered array of basic variables basis : Fin r → ι, an integer tableau matrix mat : Matrix (Fin r) ι ℤ, an integer right-hand side rhs : Fin r → ℤ, and a positive basis determinant detVal : ℤ. The validity invariant (IntegerTableau.IsValid) asserts that with B := A.submatrix id T.basis and σ := B.det.sign, B.det ≠ 0, detVal = σ * B.det > 0, mat = (σ • B.adjugate) * A, and rhs = (σ • B.adjugate) *ᵥ b, so that the basic columns of mat equal detVal • 1 ([vS07], eq. (3.17)).

When pivoting on leaving row pRow and entering variable enter with positive pivot element p = T.mat pRow enter > 0, row pRow is kept unchanged, and every other row i ≠ pRow is replaced by (p * row_i - T.mat i enter * row_pRow) / T.detVal ([vS07], Exercise 3.8). The algebraic identity F * C = d • C' proves that T.detVal divides every numerator exactly (IsValid.detVal_dvd_pivotMat, IsValid.detVal_dvd_pivotRhs), that pivot preserves IsValid (IsValid.pivot), and that all intermediate integer entries satisfy the factorial determinant bound r! * H ^ r (IsValid.abs_mat_le, IsValid.abs_rhs_le).

When A contains an identity slack block A.submatrix id slack = 1, the cofactor matrix C = σ • B.adjugate is stored verbatim in the slack columns T.mat.submatrix id slack ([vS07], eq. (3.19)). Ordering the augmented right-hand side rows (rhs i, C i 0, ..., C i (r - 1)) lexicographically (lexRow, IsLexFeasible) resolves degeneracy without cycling: invertibility of C makes the integer cross-multiplied lexico-minimum ratio test (lexMinRatioRow?, [vS07], Exercise 3.10) yield a unique leaving row whenever the entering column has a positive entry (IsValid.lexMinRatioRow?_eq_some_iff), preserves lexicographic feasibility (IsValid.isLexFeasible_pivot), depends only on the basis set (IsValid.lex_perm), and is an exact involution (IsValid.lexPivot_involutive).

Main definitions #

Main results #

References #

Computable lexicographic order on Fin n → ℤ #

Computable strict lexicographic order on integer tuples Fin n → ℤ.

Instances For

    Computable lexicographic positivity on Fin n → ℤ: the first nonzero coordinate is positive.

    Instances For
      @[instance_reducible]
      @[instance_reducible]
      theorem Cslib.Algorithms.Lean.Simplex.lexLt_asymm {n : ℕ} {u v : Fin n → ℤ} (h : LexLt u v) :
      theorem Cslib.Algorithms.Lean.Simplex.lexLt_trans {n : ℕ} {u v w : Fin n → ℤ} (huv : LexLt u v) (hvw : LexLt v w) :
      LexLt u w
      theorem Cslib.Algorithms.Lean.Simplex.isLexPos_smul_iff {n : ℕ} {c : ℤ} (hc : 0 < c) {v : Fin n → ℤ} :
      theorem Cslib.Algorithms.Lean.Simplex.lexLt_smul_iff {n : ℕ} {c : ℤ} (hc : 0 < c) {u v : Fin n → ℤ} :
      LexLt (c • u) (c • v) ↔ LexLt u v
      theorem Cslib.Algorithms.Lean.Simplex.isLexPos_add {n : ℕ} {u v : Fin n → ℤ} (hu : IsLexPos u) (hv : IsLexPos v) :
      IsLexPos (u + v)
      theorem Cslib.Algorithms.Lean.Simplex.isLexPos_add_smul_nonneg {n : ℕ} {u v : Fin n → ℤ} {c : ℤ} (hu : IsLexPos u) (hv : IsLexPos v) (hc : 0 ≤ c) :
      IsLexPos (u + c • v)
      theorem Cslib.Algorithms.Lean.Simplex.isLexPos_zero_le {n : ℕ} [NeZero n] {v : Fin n → ℤ} (hv : IsLexPos v) :
      0 ≤ v 0

      Exact integer tableau #

      An exact integer pivoting tableau for A z = b with r rows and variable index type ι ([vS07], Sections 3.5–3.6, eqs. (3.17) and (3.19), Exercise 3.10).

      • basis : Fin r → ι

        Ordered array of basic variables, one per row (Exercise 3.10).

      • mat : Matrix (Fin r) ι ℤ

        Current integer tableau matrix C * A.

      • rhs : Fin r → ℤ

        Current integer right-hand side C *ᵥ b.

      • detVal : ℤ

        Current positive basis determinant |det (A.submatrix id basis)|.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.ext {r : ℕ} {ι : Type u_1} {x y : IntegerTableau r ι} (basis : x.basis = y.basis) (mat : x.mat = y.mat) (rhs : x.rhs = y.rhs) (detVal : x.detVal = y.detVal) :
      x = y
      def Cslib.Algorithms.Lean.Simplex.IntegerTableau.init {r : ℕ} {ι : Type u_1} (A : Matrix (Fin r) ι ℤ) (b : Fin r → ℤ) (slack : Fin r → ι) :

      Initialize an integer tableau from (A, b) and an initial identity basis slack.

      def Cslib.Algorithms.Lean.Simplex.IntegerTableau.pivot {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (pRow : Fin r) (enter : ι) :

      Exact integer pivot on leaving row pRow and entering variable enter ([vS07], Section 3.5, Exercise 3.8): row pRow stays unchanged, and every row i ≠ pRow is replaced by (p * row_i - T.mat i enter * row_pRow) / T.detVal where p = T.mat pRow enter.

      @[simp]
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.pivot_basis {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (pRow : Fin r) (enter : ι) :
      (T.pivot pRow enter).basis = Function.update T.basis pRow enter
      @[simp]
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.pivot_detVal {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (pRow : Fin r) (enter : ι) :
      (T.pivot pRow enter).detVal = T.mat pRow enter
      @[simp]
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.pivot_mat_self {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (pRow : Fin r) (enter j : ι) :
      (T.pivot pRow enter).mat pRow j = T.mat pRow j
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.pivot_mat_of_ne {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) {pRow i : Fin r} (hi : i ≠ pRow) (enter j : ι) :
      (T.pivot pRow enter).mat i j = (T.mat pRow enter * T.mat i j - T.mat i enter * T.mat pRow j) / T.detVal
      @[simp]
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.pivot_rhs_self {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (pRow : Fin r) (enter : ι) :
      (T.pivot pRow enter).rhs pRow = T.rhs pRow
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.pivot_rhs_of_ne {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) {pRow i : Fin r} (hi : i ≠ pRow) (enter : ι) :
      (T.pivot pRow enter).rhs i = (T.mat pRow enter * T.rhs i - T.mat i enter * T.rhs pRow) / T.detVal

      The finite set of basic variables of T.

      structure Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid {r : ℕ} {ι : Type u_1} (A : Matrix (Fin r) ι ℤ) (b : Fin r → ℤ) (T : IntegerTableau r ι) :

      Validity invariant of an integer tableau for (A, b) ([vS07], eq. (3.17)): with basis matrix B = A.submatrix id T.basis and sign σ = B.det.sign, B.det ≠ 0, detVal = σ * B.det > 0, mat = (σ • adjugate B) * A, and rhs = (σ • adjugate B) *ᵥ b.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.isValid_init {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {slack : Fin r → ι} (hslack : A.submatrix id slack = 1) :
      IsValid A b (init A b slack)

      init is valid whenever the initial slack columns form the identity matrix 1.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.mat_submatrix_basis {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) :

      The basic columns of T.mat form T.detVal • 1.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.mat_basis_apply {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) (i j : Fin r) :
      T.mat i (T.basis j) = if i = j then T.detVal else 0

      Each basic column T.basis j equals T.detVal in row j and 0 elsewhere.

      The basis array T.basis is injective.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.card_basisSet {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} [DecidableEq ι] (hT : IsValid A b T) :

      The basis set has cardinality r.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.mat_submatrix_slack {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) {slack : Fin r → ι} (hslack : A.submatrix id slack = 1) :

      When A.submatrix id slack = 1, the slack columns of T.mat store the cofactor matrix σ • adjugate B ([vS07], eq. (3.19)).

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.eq_of_basis_eq {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T₁ T₂ : IntegerTableau r ι} (h₁ : IsValid A b T₁) (h₂ : IsValid A b T₂) (hb : T₁.basis = T₂.basis) :
      T₁ = T₂

      Two valid tableaux with the same ordered basis are identical.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.of_basis_comp_perm {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T₁ T₂ : IntegerTableau r ι} (h₁ : IsValid A b T₁) (h₂ : IsValid A b T₂) (π : Equiv.Perm (Fin r)) (hb : T₂.basis = T₁.basis ∘ ⇑π) :
      T₂.detVal = T₁.detVal ∧ (∀ (i : Fin r) (j : ι), T₂.mat i j = T₁.mat (π i) j) ∧ ∀ (i : Fin r), T₂.rhs i = T₁.rhs (π i)

      Permuting the ordered basis permutes the rows of a valid tableau without changing detVal.

      Exact pivot divisibility and invariant preservation (Section 3.5, Exercise 3.8) #

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.detVal_dvd_pivotMat {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) {pRow i : Fin r} (hi : i ≠ pRow) (enter j : ι) (hp : 0 < T.mat pRow enter) :
      T.detVal ∣ T.mat pRow enter * T.mat i j - T.mat i enter * T.mat pRow j

      Exact integer divisibility of tableau pivot numerators ([vS07], Section 3.5, pp. 64–65, Exercise 3.8): for every non-pivot row i ≠ pRow and column j, the previous determinant T.detVal divides T.mat pRow enter * T.mat i j - T.mat i enter * T.mat pRow j.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.detVal_dvd_pivotRhs {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) {pRow i : Fin r} (hi : i ≠ pRow) (enter : ι) (hp : 0 < T.mat pRow enter) :
      T.detVal ∣ T.mat pRow enter * T.rhs i - T.mat i enter * T.rhs pRow

      Exact integer divisibility of right-hand side pivot numerators ([vS07], Section 3.5, Exercise 3.8).

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.pivot {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) (pRow : Fin r) (enter : ι) (hp : 0 < T.mat pRow enter) :
      IsValid A b (T.pivot pRow enter)

      Integer pivoting preserves validity ([vS07], Section 3.5, eq. (3.17)): pivoting on a positive pivot element T.mat pRow enter > 0 yields a valid tableau for (A, b).

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.abs_mat_le {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) {H : ℕ} (hA : ∀ (i : Fin r) (j : ι), |A i j| ≤ ↑H) (i : Fin r) (j : ι) :
      |T.mat i j| ≤ ↑(r.factorial * H ^ r)

      Coefficient magnitude bound for integer tableau entries ([vS07], Section 3.5, p. 65): if every entry of A has absolute value at most H, then every entry of T.mat has absolute value at most r! * H ^ r.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.abs_rhs_le {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) {H : ℕ} (hA : ∀ (i : Fin r) (j : ι), |A i j| ≤ ↑H) (hb : ∀ (i : Fin r), |b i| ≤ ↑H) (i : Fin r) :
      |T.rhs i| ≤ ↑(r.factorial * H ^ r)

      Coefficient magnitude bound for integer tableau right-hand sides ([vS07], Section 3.5, p. 65).

      Rational basic solution and edge rays #

      The rational basic solution z : ι → ℚ of T: rhs i / detVal on basis i, and 0 on nonbasic variables.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.basicSolRat_basis {r : ℕ} {ι : Type u_1} [DecidableEq ι] {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) (i : Fin r) :
      T.basicSolRat (T.basis i) = ↑(T.rhs i) / ↑T.detVal
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.mulVec_basicSolRat {r : ℕ} {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) :
      (A.map Int.cast).mulVec T.basicSolRat = fun (i : Fin r) => ↑(b i)

      The rational basic solution of a valid tableau satisfies A *ᵥ z = b over ℚ.

      def Cslib.Algorithms.Lean.Simplex.IntegerTableau.rayRat {r : ℕ} {ι : Type u_1} [DecidableEq ι] (T : IntegerTableau r ι) (enter j : ι) :

      The nonbasic ray direction rayRat T enter obtained by increasing a nonbasic variable enter: it places 1 on enter, -T.mat k enter / T.detVal on T.basis k, and 0 elsewhere.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.mulVec_rayRat_eq_zero {r : ℕ} {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) {enter : ι} (henter : enter ∉ T.basisSet) :
      (A.map Int.cast).mulVec (T.rayRat enter) = 0

      For any nonbasic enter ∉ T.basisSet, rayRat T enter lies in the kernel of A over ℚ and satisfies rayRat T enter enter = 1.

      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.exists_mat_pos_of_bounded {r : ℕ} {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} (hT : IsValid A b T) (hrec : ∀ (z : ι → ℚ), (∀ (j : ι), 0 ≤ z j) → (A.map Int.cast).mulVec z = 0 → z = 0) {enter : ι} (henter : enter ∉ T.basisSet) :
      ∃ (i : Fin r), 0 < T.mat i enter

      If the homogeneous cone {z ≥ 0 | A z = 0} is trivial, then every nonbasic column enter has at least one strictly positive entry in any valid tableau.

      Lexicographic perturbation and lexico-minimum ratio test (Section 3.6, Exercise 3.10) #

      def Cslib.Algorithms.Lean.Simplex.IntegerTableau.lexRow {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (slack : Fin r → ι) (i : Fin r) :
      Fin (r + 1) → ℤ

      The (r + 1)-tuple (T.rhs i, C i 0, ..., C i (r - 1)) representing the lexicographically perturbed right-hand side of row i in eq. (3.19) of [vS07], where C is read directly from the slack columns T.mat i (slack k).

      @[simp]
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.lexRow_zero {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (slack : Fin r → ι) (i : Fin r) :
      T.lexRow slack i 0 = T.rhs i
      @[simp]
      theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.lexRow_succ {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (slack : Fin r → ι) (i k : Fin r) :
      T.lexRow slack i k.succ = T.mat i (slack k)

      Lexicographic feasibility of an integer tableau ([vS07], Section 3.6, eq. (3.19)): every perturbed right-hand side row (T.rhs i, C i 0, ..., C i (r - 1)) is lexicographically positive.

      Instances For
        @[instance_reducible]
        theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsLexFeasible.rhs_nonneg {r : ℕ} {ι : Type u_1} {T : IntegerTableau r ι} {slack : Fin r → ι} (hlex : T.IsLexFeasible slack) (i : Fin r) :
        0 ≤ T.rhs i

        Lexicographic feasibility implies ordinary nonnegativity 0 ≤ T.rhs i.

        theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsLexFeasible.basicSolRat_nonneg {r : ℕ} {ι : Type u_1} [DecidableEq ι] {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) (hlex : T.IsLexFeasible slack) (j : ι) :

        Lexicographic feasibility implies ordinary nonnegativity 0 ≤ T.basicSolRat j.

        theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.isLexFeasible_init {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {slack : Fin r → ι} (hslack : A.submatrix id slack = 1) (hb : ∀ (i : Fin r), 0 ≤ b i) :
        (init A b slack).IsLexFeasible slack

        init is lexicographically feasible whenever 0 ≤ b and A.submatrix id slack = 1.

        def Cslib.Algorithms.Lean.Simplex.IntegerTableau.lexRatioLt {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (slack : Fin r → ι) (enter : ι) (i₁ i₂ : Fin r) :

        Cross-multiplied integer lexicographic ratio comparison between rows i₁ and i₂ for entering column enter ([vS07], Section 3.6, Exercise 3.10): represents (1 / T.mat i₁ enter) • lexRow i₁ <_{lex} (1 / T.mat i₂ enter) • lexRow i₂ without fractions.

        Instances For
          @[instance_reducible]
          instance Cslib.Algorithms.Lean.Simplex.IntegerTableau.instDecidableLexRatioLt {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (slack : Fin r → ι) (enter : ι) (i₁ i₂ : Fin r) :
          Decidable (T.lexRatioLt slack enter i₁ i₂)
          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.lexRatioLt_asymm {r : ℕ} {ι : Type u_1} {T : IntegerTableau r ι} {slack : Fin r → ι} {enter : ι} {i₁ i₂ : Fin r} (h : T.lexRatioLt slack enter i₁ i₂) :
          ¬T.lexRatioLt slack enter i₂ i₁
          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.lexRatioLt_trans {r : ℕ} {ι : Type u_1} {T : IntegerTableau r ι} {slack : Fin r → ι} {enter : ι} {i₁ i₂ i₃ : Fin r} (hp₁ : 0 < T.mat i₁ enter) (hp₂ : 0 < T.mat i₂ enter) (hp₃ : 0 < T.mat i₃ enter) (h₁₂ : T.lexRatioLt slack enter i₁ i₂) (h₂₃ : T.lexRatioLt slack enter i₂ i₃) :
          T.lexRatioLt slack enter i₁ i₃
          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.lexRatio_ne_of_ne {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) (hslack : A.submatrix id slack = 1) (enter : ι) {i₁ i₂ : Fin r} (hne : i₁ ≠ i₂) (hp₂ : 0 < T.mat i₂ enter) :
          T.mat i₂ enter • T.lexRow slack i₁ ≠ T.mat i₁ enter • T.lexRow slack i₂

          Because the slack submatrix C = σ • adjugate B is nonsingular, no two distinct rows can tie in the lexicographic ratio test.

          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.lexRatioLt_or_gt {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) (hslack : A.submatrix id slack = 1) (enter : ι) {i₁ i₂ : Fin r} (hne : i₁ ≠ i₂) (hp₂ : 0 < T.mat i₂ enter) :
          T.lexRatioLt slack enter i₁ i₂ ∨ T.lexRatioLt slack enter i₂ i₁

          Distinct positive-pivot rows are strictly ordered by lexRatioLt.

          def Cslib.Algorithms.Lean.Simplex.IntegerTableau.lexMinRatioRow? {r : ℕ} {ι : Type u_1} (T : IntegerTableau r ι) (slack : Fin r → ι) (enter : ι) :

          Computable lexicographic minimum-ratio leaving-row selector ([vS07], Section 3.6, Exercise 3.10): returns the unique row minimizing (1 / T.mat i enter) • lexRow i lexicographically among all rows with 0 < T.mat i enter, or none if no positive pivot entry exists.

          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.lexMinRatioRow?_eq_some_iff {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) (hslack : A.submatrix id slack = 1) (enter : ι) (pRow : Fin r) :
          T.lexMinRatioRow? slack enter = some pRow ↔ 0 < T.mat pRow enter ∧ ∀ (i : Fin r), i ≠ pRow → 0 < T.mat i enter → T.lexRatioLt slack enter pRow i

          Specification of lexMinRatioRow?: it returns some pRow iff pRow is the unique strict lexicographic minimum-ratio row among rows with positive pivot entry ([vS07], Section 3.6, Exercise 3.10).

          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.lexMinRatioRow?_eq_none_iff {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) (hslack : A.submatrix id slack = 1) (enter : ι) :
          T.lexMinRatioRow? slack enter = none ↔ ∀ (i : Fin r), T.mat i enter ≤ 0
          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.exists_lexMinRatioRow?_of_bounded {r : ℕ} {ι : Type u_1} [Fintype ι] [DecidableEq ι] {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) (hslack : A.submatrix id slack = 1) (hrec : ∀ (z : ι → ℚ), (∀ (j : ι), 0 ≤ z j) → (A.map Int.cast).mulVec z = 0 → z = 0) {enter : ι} (henter : enter ∉ T.basisSet) :
          ∃ (pRow : Fin r), T.lexMinRatioRow? slack enter = some pRow

          In a bounded system, lexMinRatioRow? always selects a leaving row for any nonbasic entering variable.

          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.detVal_smul_pivot_lexRow {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) {pRow i : Fin r} (hi : i ≠ pRow) (enter : ι) (hp : 0 < T.mat pRow enter) :
          T.detVal • (T.pivot pRow enter).lexRow slack i = T.mat pRow enter • T.lexRow slack i - T.mat i enter • T.lexRow slack pRow

          Scaled update law for lexRow under an exact integer pivot: for i ≠ pRow, T.detVal • (T.pivot pRow enter).lexRow slack i = T.mat pRow enter • T.lexRow slack i - T.mat i enter • T.lexRow slack pRow.

          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.isLexFeasible_pivot {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) (hslack : A.submatrix id slack = 1) (hlex : T.IsLexFeasible slack) (enter : ι) {pRow : Fin r} (hrow : T.lexMinRatioRow? slack enter = some pRow) :
          (T.pivot pRow enter).IsLexFeasible slack

          Lexicographic feasibility is preserved by a lexico-minimum-ratio pivot ([vS07], Section 3.6, eq. (3.19)).

          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.lexPivot_involutive {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T : IntegerTableau r ι} {slack : Fin r → ι} (hT : IsValid A b T) (hslack : A.submatrix id slack = 1) (hlex : T.IsLexFeasible slack) (enter : ι) {pRow : Fin r} (hrow : T.lexMinRatioRow? slack enter = some pRow) :
          have T' := T.pivot pRow enter; T'.lexMinRatioRow? slack (T.basis pRow) = some pRow ∧ T'.pivot pRow (T.basis pRow) = T

          Exact involution of lexicographic integer pivoting: if enter enters and leave = T.basis pRow leaves via lexMinRatioRow?, then pivoting leave back into T.pivot pRow enter chooses the exact same row pRow and restores the exact tableau T.

          theorem Cslib.Algorithms.Lean.Simplex.IntegerTableau.IsValid.lex_perm {r : ℕ} {ι : Type u_1} {A : Matrix (Fin r) ι ℤ} {b : Fin r → ℤ} {T₁ T₂ : IntegerTableau r ι} {slack : Fin r → ι} (h₁ : IsValid A b T₁) (h₂ : IsValid A b T₂) (hslack : A.submatrix id slack = 1) (π : Equiv.Perm (Fin r)) (hb : T₂.basis = T₁.basis ∘ ⇑π) :
          (T₂.IsLexFeasible slack ↔ T₁.IsLexFeasible slack) ∧ ∀ (enter : ι), Option.map T₂.basis (T₂.lexMinRatioRow? slack enter) = Option.map T₁.basis (T₁.lexMinRatioRow? slack enter)

          Lexicographic feasibility and the leaving variable chosen by lexMinRatioRow? are invariant under permuting the ordered basis array.