The Klee–Minty cube and Dantzig's rule
DefinitionSmaleNinth_KleeMintyThe Klee–Minty cube is the family of linear programs on which the simplex method with the classical entering rule visits exponentially many vertices. In the presentation used here it is, for each ,
Geometrically the feasible region is a combinatorial -cube whose facets have been sheared by the powers of , so that the objective orders its vertices along a Hamiltonian path.
Standard form. This module records the instance in the equality standard form used by the platform's simplex development, and with -based indices throughout. Variables are the original variables and variables are slacks, so the constraint matrix has rows and columns, with
right-hand side , and cost vector on the original variables and on the slacks, the sign turning the maximization into a minimization. The all-slack basis selects the slack columns, ; its associated point sets every original variable to and every slack to , which is the vertex at the origin of the cube.
Dantzig's rule. The platform's notion of a simplex pivot commits to no tie-breaking: it relates a basis-and-point pair to a successor whenever some nonbasic column with negative reduced cost enters and some row attaining the ratio test leaves. Dantzig's rule — the largest-coefficient, or most-negative-reduced-cost, rule — is the refinement in which the entering column additionally satisfies
where denotes the reduced cost of column at the current basis. The minimization ranges over all columns rather than only the nonbasic ones; this is equivalent to the usual formulation, since basic columns have reduced cost while the entering column has negative reduced cost. Ties among minimizers, and among rows attaining the ratio test, remain unconstrained, so the notion covers every implementation of the rule.
import Definitions.Def_Polyhedron
import Definitions.Def_LinearOptimization_SimplexPivot
/-!
The Klee–Minty cube in standard form, the all-slack initial basis, and
Dantzig's pivoting rule.
Source: V. Klee, G.J. Minty, *How good is the simplex algorithm?*, in:
Inequalities III (O. Shisha, ed.), Academic Press 1972, pp. 159–175, in the
standard presentation of V. Chvátal, *Linear Programming*, Freeman 1983,
Chapter 4 ("How fast is the simplex method?"), problem (4.6):
maximize ∑_{j=1}^{n} 10^{n−j} x_j
subject to 2 ∑_{j=1}^{i−1} 10^{i−j} x_j + x_i ≤ 100^{i−1} (i = 1,…,n)
x_j ≥ 0,
which Dantzig's largest-coefficient entering rule solves in exactly 2ⁿ − 1
simplex iterations from the all-slack starting dictionary.
Here the problem is put in the standard form `min c'x, Ax = b, x ≥ 0` of the
platform's `LinearOptimization` simplex development (Bertsimas–Tsitsiklis
Chapter 3): with 0-based indexing, variables `0, …, n−1` are the original
`x`-variables, variables `n, …, 2n−1` are the slacks, row `i` reads
`2 ∑_{j<i} 10^{i−j} x_j + x_i + s_i = 100^i`, and the objective is
`min −∑_j 10^{n−1−j} x_j`.
`IsDantzigPivot` strengthens the platform's `IsSimplexPivot` (which commits
to no pivoting rule) by requiring the entering index to have the **most
negative** reduced cost — Dantzig's original rule (Bertsimas–Tsitsiklis
§3.4, "largest coefficient" rule; Chvátal Chapter 4). Ties, if any, remain
unconstrained.
-/
open Matrix LinearOptimization
namespace SmaleNinth
/-- The Klee–Minty constraint matrix in standard form (`n` rows, `2n`
columns): row `i` is `2·10^{i−j}` at column `j < i`, `1` at column `i`
(the original variables), and `1` at the slack column `n + i`. -/
def kleeMintyA (n : ℕ) : Matrix (Fin n) (Fin (2 * n)) ℝ :=
fun i j =>
if (j : ℕ) < n then
if (j : ℕ) < (i : ℕ) then 2 * 10 ^ ((i : ℕ) - (j : ℕ))
else if (j : ℕ) = (i : ℕ) then 1
else 0
else if (j : ℕ) = n + (i : ℕ) then 1 else 0
/-- The Klee–Minty right-hand side: `b_i = 100^i` (0-based). -/
def kleeMintyb (n : ℕ) : Fin n → ℝ := fun i => 100 ^ (i : ℕ)
/-- The Klee–Minty cost vector for the minimization form:
`c_j = −10^{n−1−j}` on the original variables, `0` on the slacks. -/
def kleeMintyc (n : ℕ) : Fin (2 * n) → ℝ :=
fun j => if (j : ℕ) < n then -(10 : ℝ) ^ (n - 1 - (j : ℕ)) else 0
/-- The all-slack starting basis: basic column `i` is the slack column
`n + i`. -/
def kleeMintySlackBasis (n : ℕ) : Fin n ↪ Fin (2 * n) :=
⟨fun i => ⟨n + (i : ℕ), by omega⟩, by
intro a b hab
have := congrArg (fun x : Fin (2 * n) => (x : ℕ)) hab
simp only at this
exact Fin.ext (by omega)⟩
/-- The basic feasible solution of the all-slack basis: every original
variable is `0` and each slack equals its right-hand side `100^i`. -/
def kleeMintySlackSolution (n : ℕ) : Fin (2 * n) → ℝ :=
fun j => if (j : ℕ) < n then 0 else (100 : ℝ) ^ ((j : ℕ) - n)
/-- **Dantzig's pivoting rule** (largest-coefficient entering rule;
Bertsimas–Tsitsiklis §3.4, Chvátal Chapter 4): a simplex pivot whose
entering index has the most negative reduced cost. The exiting row is
constrained by the ratio test exactly as in `IsSimplexPivot`. -/
def IsDantzigPivot {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℝ) (c : Fin n → ℝ)
(B : Fin m ↪ Fin n) (x : Fin n → ℝ) (B' : Fin m ↪ Fin n)
(x' : Fin n → ℝ) : Prop :=
∃ j ℓ, IsPivotStepAt A c B x B' x' j ℓ ∧
(∀ i, 0 < pivotColumn A B j i →
x (B ℓ) / pivotColumn A B j ℓ ≤ x (B i) / pivotColumn A B j i) ∧
∀ j' : Fin n, reducedCost A c B j ≤ reducedCost A c B j'
end SmaleNinth
Read-back
What the Lean code literally says, in plain math · claude-fable-5
Read-back: Def_SmaleNinth_KleeMinty
All indices below are 0-based: row indices range over and column indices over . When every one of these index sets is empty, so all five data definitions are the empty matrix/vector/map and are trivially well-formed.
kleeMintyA
For each natural number , this is the real matrix whose entry in row and column is
The exponent is natural-number (truncated) subtraction, but it is only used in the branch where , where it agrees with ordinary subtraction and is at least . So row reads: entries in the columns , a in column , zeros in columns , a in column , and zeros in the remaining columns .
kleeMintyb
For each natural number , the vector with
so in particular (when ).
kleeMintyc
For each natural number , the vector with
The exponent is again natural-number truncated subtraction; in the branch one has , so it agrees with the ordinary value . Thus , decreasing in magnitude down to , and on the last coordinates. (For there are no coordinates at all.)
kleeMintySlackBasis
For each natural number , the injective map given by
This is only a function selecting of the column indices (the last of them), packaged with a proof of injectivity. Nothing in the definition asserts that the corresponding columns of any matrix form a basis, are linearly independent, or that any associated basis matrix is invertible.
kleeMintySlackSolution
For each natural number , the vector with
where is natural subtraction, well-defined in the used branch since ; equivalently for . Nothing in the definition asserts that this vector is feasible for any system, or that it is the basic solution associated with any basis; it is just this explicit vector.
IsDantzigPivot
Fix natural numbers , a real matrix , a cost vector , an injective map , a vector , a second injective map of the same type, and a vector . (Injectivity of and is built into their type; no other property of them — and no property of such as feasibility, nonnegativity, or being a basic solution — is assumed.)
Two auxiliary quantities, both defined via Lean's total matrix inverse:
- the basis matrix is the matrix with (columns of selected by );
- denotes Lean's matrix inverse, which is the true inverse when is invertible and the zero matrix otherwise (a junk value; no hypothesis in this predicate rules that case out);
- the pivot column at index is the vector , where is the -th column of (so identically when is not invertible);
- the reduced cost of index is
which degenerates to when is not invertible;
- the basic direction at is the vector
where is the -th standard basis vector (this formula is applied as written, with no separate assumption inside it that avoids the range of ).
The predicate asserts: there exist an index and a row such that all of the following hold (writing throughout):
-
Pivot step core (the unfolded at ), a conjunction of six conditions:
- is not in the range of (i.e. for every );
- ;
- ;
- for every ;
- ;
- as an exact equality of vectors in (the division is well-defined in the real numbers since is asserted; note the step length is , whatever the sign of , with no requirement that it be nonnegative).
-
Ratio test on the exit row: for every row with ,
- Entering-index minimality: for every column index — the quantifier ranges over all indices, basic ones and itself included, not only nonbasic ones —
That is, is a minimum of the reduced costs over all columns; nothing constrains which minimizer is chosen when several attain the minimum, and the comparison is non-strict throughout.
Since the whole predicate is a bare existential over and , it holds as soon as some such pair exists; it does not assert uniqueness of , of , or of .
Confirmed by the mission captain (proposal self-audit).