Documentation

CslibFrontier.GameTheory.Bimatrix.LexicoLemkeHowson

Lexicographic integer Lemke–Howson algorithm for arbitrary bimatrix games #

This module implements the standalone Lemke–Howson complementary pivoting algorithm using exact integer tableaux (IntegerTableau) and lexicographic perturbation ([vS07], Sections 3.5–3.6, eqs. (3.8)–(3.19), Exercise 3.10).

For a bimatrix game (A, B) with integer payoffs satisfying condition (3.5) of [vS07] (nonnegative matrices with no zero column in A or Bᵀ), the best-response polytopes (P, Q) in slack equality form (3.8) are Bᵀ x + s = 1 (lexLHMatP B) and r + A y = 1 (lexLHMatQ A), with variables indexed by Fin m ⊕ Fin n. A basis pair (S_P, S_Q) is completely labelled when Disjoint S_P S_Q (so every label in Fin m ⊕ Fin n is nonbasic in at least one tableau), and k-almost completely labelled when S_P ∩ S_Q ⊆ {k}.

By exact involution of lexicographic pivoting (IntegerTableau.IsValid.lexPivot_involutive) and boundedness of (P, Q) under (3.5), the lexicographic Lemke–Howson graph lexGraph A B k on k-almost completely labelled lexicographically feasible basis pairs has degree 1 at completely labelled nodes and degree 2 at all other nodes. This gives:

Main definitions #

Main results #

References #

Standard equality-form matrices (3.8) and boundedness under (3.5) #

Equality-form constraint matrix [Bᵀ | I_n] for Bᵀ x + s = 1 ([vS07], eq. (3.8)).

Equality-form constraint matrix [I_m | A] for r + A y = 1 ([vS07], eq. (3.8)).

theorem Cslib.GameTheory.BimatrixGame.eq_zero_of_lexLHMatP_mulVec_eq_zero {m n : ℕ} {B : Matrix (Fin m) (Fin n) ℤ} (hBnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ B i j) (hBcol : ∀ (i : Fin m), ∃ (j : Fin n), 0 < B i j) {z : Fin m ⊕ Fin n → ℚ} (hz : ∀ (l : Fin m ⊕ Fin n), 0 ≤ z l) (hAz : ((lexLHMatP B).map Int.cast).mulVec z = 0) :
z = 0

Under condition (3.5) for Bᵀ (B ≥ 0 and every row of B has a positive entry), the homogeneous cone {z ≥ 0 | [Bᵀ | I] z = 0} is trivial.

theorem Cslib.GameTheory.BimatrixGame.eq_zero_of_lexLHMatQ_mulVec_eq_zero {m n : ℕ} {A : Matrix (Fin m) (Fin n) ℤ} (hAnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ A i j) (hAcol : ∀ (j : Fin n), ∃ (i : Fin m), 0 < A i j) {z : Fin m ⊕ Fin n → ℚ} (hz : ∀ (l : Fin m ⊕ Fin n), 0 ≤ z l) (hAz : ((lexLHMatQ A).map Int.cast).mulVec z = 0) :
z = 0

Under condition (3.5) for A (A ≥ 0 and every column of A has a positive entry), the homogeneous cone {z ≥ 0 | [I | A] z = 0} is trivial.

Basis-set invariance and lexicographic pivoting graph #

S is a lexicographically feasible basis set for player 1's equality system Bᵀ x + s = 1.

S is a lexicographically feasible basis set for player 2's equality system r + A y = 1.

def Cslib.GameTheory.BimatrixGame.LexBasisAdjP {m n : ℕ} (B : Matrix (Fin m) (Fin n) ℤ) (S₁ S₂ : Finset (Fin m ⊕ Fin n)) :

Two lexicographically feasible basis sets of P are adjacent if one is obtained from the other by a single lexicographic minimum-ratio pivot on some nonbasic variable.

def Cslib.GameTheory.BimatrixGame.LexBasisAdjQ {m n : ℕ} (A : Matrix (Fin m) (Fin n) ℤ) (S₁ S₂ : Finset (Fin m ⊕ Fin n)) :

Two lexicographically feasible basis sets of Q are adjacent if one is obtained from the other by a single lexicographic minimum-ratio pivot on some nonbasic variable.

theorem Cslib.GameTheory.BimatrixGame.LexBasisAdjP.symm {m n : ℕ} {B : Matrix (Fin m) (Fin n) ℤ} {S₁ S₂ : Finset (Fin m ⊕ Fin n)} (h : LexBasisAdjP B S₁ S₂) :
LexBasisAdjP B S₂ S₁
theorem Cslib.GameTheory.BimatrixGame.LexBasisAdjQ.symm {m n : ℕ} {A : Matrix (Fin m) (Fin n) ℤ} {S₁ S₂ : Finset (Fin m ⊕ Fin n)} (h : LexBasisAdjQ A S₁ S₂) :
LexBasisAdjQ A S₂ S₁
theorem Cslib.GameTheory.BimatrixGame.LexBasisAdjP.ne {m n : ℕ} {B : Matrix (Fin m) (Fin n) ℤ} {S₁ S₂ : Finset (Fin m ⊕ Fin n)} (h : LexBasisAdjP B S₁ S₂) :
S₁ ≠ S₂
theorem Cslib.GameTheory.BimatrixGame.LexBasisAdjQ.ne {m n : ℕ} {A : Matrix (Fin m) (Fin n) ℤ} {S₁ S₂ : Finset (Fin m ⊕ Fin n)} (h : LexBasisAdjQ A S₁ S₂) :
S₁ ≠ S₂
structure Cslib.GameTheory.BimatrixGame.LexNode {m n : ℕ} (A B : Matrix (Fin m) (Fin n) ℤ) (k : Fin m ⊕ Fin n) :

A node of the lexicographic Lemke–Howson graph for missing label k: a pair of lexicographically feasible basis sets (basisP, basisQ) with basisP ∩ basisQ ⊆ {k} (equivalently, every label other than k is nonbasic in at least one tableau).

theorem Cslib.GameTheory.BimatrixGame.LexNode.ext {m n : ℕ} {A B : Matrix (Fin m) (Fin n) ℤ} {k : Fin m ⊕ Fin n} {x y : LexNode A B k} (basisP : x.basisP = y.basisP) (basisQ : x.basisQ = y.basisQ) :
x = y
theorem Cslib.GameTheory.BimatrixGame.LexNode.ext_iff {m n : ℕ} {A B : Matrix (Fin m) (Fin n) ℤ} {k : Fin m ⊕ Fin n} {x y : LexNode A B k} :

A LexNode is completely labelled iff its basic variable sets are disjoint (every label in Fin m ⊕ Fin n is nonbasic in at least one tableau).

def Cslib.GameTheory.BimatrixGame.originLexNode {m n : ℕ} (A B : Matrix (Fin m) (Fin n) ℤ) (k : Fin m ⊕ Fin n) :
LexNode A B k

The artificial origin node (inr, inl) of the lexicographic Lemke–Howson graph.

def Cslib.GameTheory.BimatrixGame.lexGraph {m n : ℕ} (A B : Matrix (Fin m) (Fin n) ℤ) (k : Fin m ⊕ Fin n) :

The lexicographic Lemke–Howson graph on k-almost completely labelled basis pairs ([vS07], Sections 3.4 and 3.6).

theorem Cslib.GameTheory.BimatrixGame.lexNode_card_basisP {m n : ℕ} {A B : Matrix (Fin m) (Fin n) ℤ} {k : Fin m ⊕ Fin n} (u : LexNode A B k) :
theorem Cslib.GameTheory.BimatrixGame.lexNode_card_basisQ {m n : ℕ} {A B : Matrix (Fin m) (Fin n) ℤ} {k : Fin m ⊕ Fin n} (u : LexNode A B k) :
theorem Cslib.GameTheory.BimatrixGame.fintype_card_lexNode_le {m n : ℕ} (A B : Matrix (Fin m) (Fin n) ℤ) (k : Fin m ⊕ Fin n) [Fintype (LexNode A B k)] :
Fintype.card (LexNode A B k) ≤ (m + n).choose n * (m + n).choose m

Upper bound on the total number of LexNodes: at most choose (m + n) n * choose (m + n) m.

theorem Cslib.GameTheory.BimatrixGame.existsUnique_adj_of_isCompletelyLabeled {m n : ℕ} {A B : Matrix (Fin m) (Fin n) ℤ} (hAnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ A i j) (hAcol : ∀ (j : Fin n), ∃ (i : Fin m), 0 < A i j) (hBnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ B i j) (hBcol : ∀ (i : Fin m), ∃ (j : Fin n), 0 < B i j) {k : Fin m ⊕ Fin n} {u : LexNode A B k} (hcl : u.IsCompletelyLabeled) :
∃! v : LexNode A B k, (lexGraph A B k).Adj u v

Under condition (3.5), every completely labelled node of lexGraph A B k has a unique neighbor (degree 1).

theorem Cslib.GameTheory.BimatrixGame.exists_two_adj_of_not_isCompletelyLabeled {m n : ℕ} {A B : Matrix (Fin m) (Fin n) ℤ} (hAnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ A i j) (hAcol : ∀ (j : Fin n), ∃ (i : Fin m), 0 < A i j) (hBnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ B i j) (hBcol : ∀ (i : Fin m), ∃ (j : Fin n), 0 < B i j) {k : Fin m ⊕ Fin n} {u : LexNode A B k} (hncl : ¬u.IsCompletelyLabeled) :
∃ (v₁ : LexNode A B k) (v₂ : LexNode A B k), v₁ ≠ v₂ ∧ ∀ (v : LexNode A B k), (lexGraph A B k).Adj u v ↔ v = v₁ ∨ v = v₂

Under condition (3.5), every non-completely-labelled node of lexGraph A B k has exactly two distinct neighbors: one pivoting the unique duplicate label into P and one into Q.

theorem Cslib.GameTheory.BimatrixGame.even_ncard_lexCompletelyLabeled {m n : ℕ} [NeZero (m + n)] {A B : Matrix (Fin m) (Fin n) ℤ} (hAnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ A i j) (hAcol : ∀ (j : Fin n), ∃ (i : Fin m), 0 < A i j) (hBnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ B i j) (hBcol : ∀ (i : Fin m), ∃ (j : Fin n), 0 < B i j) :

Parity of lexicographically completely labelled basis pairs ([vS07], Sections 3.4 and 3.6): for any bimatrix game satisfying (3.5) (without assuming nondegeneracy), the number of lexicographically feasible completely labelled basis pairs is even.

theorem Cslib.GameTheory.BimatrixGame.odd_ncard_lexCompletelyLabeled_ne_origin {m n : ℕ} [NeZero (m + n)] {A B : Matrix (Fin m) (Fin n) ℤ} (hAnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ A i j) (hAcol : ∀ (j : Fin n), ∃ (i : Fin m), 0 < A i j) (hBnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ B i j) (hBcol : ∀ (i : Fin m), ∃ (j : Fin n), 0 < B i j) :

Odd number of non-origin lexicographically completely labelled basis pairs for any (possibly degenerate) bimatrix game satisfying (3.5).

Standalone executable lexicographic Lemke–Howson solver #

Fuel-bounded inner loop of the lexicographic integer Lemke–Howson algorithm ([vS07], Algorithm 3.6 with Sections 3.5–3.6). side = false pivots in P; side = true pivots in Q. Terminates as soon as the initial missing label k leaves a basis.

Run lexicographic integer Lemke–Howson from the artificial origin (0, 0) with missing label k, returning the terminal completely labelled integer tableau pair.

Extract normalized rational mixed strategies (x / ∑ x, y / ∑ y) from a terminal tableau pair (tabP, tabQ).

def Cslib.GameTheory.BimatrixGame.lexLHRun {m n : ℕ} (A B : Matrix (Fin m) (Fin n) ℤ) (k : Fin m ⊕ Fin n) :
Option ((Fin m → ℚ) × (Fin n → ℚ))

Standalone executable lexicographic integer Lemke–Howson algorithm for integer payoff matrices (A, B) satisfying condition (3.5) and any missing label k.

theorem Cslib.GameTheory.BimatrixGame.lexLHTableaux_spec {m n : ℕ} {A B : Matrix (Fin m) (Fin n) ℤ} (hAnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ A i j) (hAcol : ∀ (j : Fin n), ∃ (i : Fin m), 0 < A i j) (hBnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ B i j) (hBcol : ∀ (i : Fin m), ∃ (j : Fin n), 0 < B i j) (k : Fin m ⊕ Fin n) :

Termination and structural soundness of lexLHTableaux ([vS07], Algorithm 3.6 with Sections 3.5–3.6): under condition (3.5), for any missing label k, lexLHTableaux A B k terminates and outputs a valid, lexicographically feasible, completely labelled integer tableau pair distinct from the artificial origin.

Any valid, lexicographically feasible, completely labelled, non-origin tableau pair extracts via extractRatStrategies to an exact rational Nash equilibrium of (A, B).

theorem Cslib.GameTheory.BimatrixGame.lexLHRun_isNash {m n : ℕ} {A B : Matrix (Fin m) (Fin n) ℤ} (hAnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ A i j) (hAcol : ∀ (j : Fin n), ∃ (i : Fin m), 0 < A i j) (hBnn : ∀ (i : Fin m) (j : Fin n), 0 ≤ B i j) (hBcol : ∀ (i : Fin m), ∃ (j : Fin n), 0 < B i j) (k : Fin m ⊕ Fin n) :
∃ (x : Fin m → ℚ) (y : Fin n → ℚ), lexLHRun A B k = some (x, y) ∧ { A := A.map Int.cast, B := B.map Int.cast }.IsNash (fun (i : Fin m) => ↑(x i)) fun (j : Fin n) => ↑(y j)

Soundness and termination of standalone lexicographic Lemke–Howson ([vS07], Algorithm 3.6 with Sections 3.5–3.6): for any integer bimatrix game (A, B) satisfying (3.5) (even if degenerate) and any missing label k, lexLHRun A B k returns an exact rational Nash equilibrium.

Arbitrary integer and rational bimatrix games #

Explicit integer shift making all entries of A and B strictly positive.

def Cslib.GameTheory.BimatrixGame.lexLHOfInt {m n : ℕ} (A B : Matrix (Fin m) (Fin n) ℤ) (k : Fin m ⊕ Fin n) :
Option ((Fin m → ℚ) × (Fin n → ℚ))

Executable lexicographic Lemke–Howson solver for arbitrary integer bimatrix games (A, B): shifts all payoffs strictly positive and invokes lexLHRun.

theorem Cslib.GameTheory.BimatrixGame.lexLHOfInt_isNash {m n : ℕ} [NeZero m] [NeZero n] (A B : Matrix (Fin m) (Fin n) ℤ) (k : Fin m ⊕ Fin n) :
∃ (x : Fin m → ℚ) (y : Fin n → ℚ), lexLHOfInt A B k = some (x, y) ∧ { A := A.map Int.cast, B := B.map Int.cast }.IsNash (fun (i : Fin m) => ↑(x i)) fun (j : Fin n) => ↑(y j)

For any finite nonempty integer bimatrix game (A, B) and any missing label k, lexLHOfInt A B k terminates and returns an exact rational Nash equilibrium.

Common positive integer denominator clearing all entries of rational matrices A, B.

def Cslib.GameTheory.BimatrixGame.lexLHOfRat {m n : ℕ} (A B : Matrix (Fin m) (Fin n) ℚ) (k : Fin m ⊕ Fin n) :
Option ((Fin m → ℚ) × (Fin n → ℚ))

Executable lexicographic Lemke–Howson solver for arbitrary rational bimatrix games (A, B): clears denominators to integers and calls lexLHOfInt.

theorem Cslib.GameTheory.BimatrixGame.lexLHOfRat_isNash {m n : ℕ} [NeZero m] [NeZero n] (A B : Matrix (Fin m) (Fin n) ℚ) (k : Fin m ⊕ Fin n) :
∃ (x : Fin m → ℚ) (y : Fin n → ℚ), lexLHOfRat A B k = some (x, y) ∧ { A := A.map Rat.cast, B := B.map Rat.cast }.IsNash (fun (i : Fin m) => ↑(x i)) fun (j : Fin n) => ↑(y j)

Standalone exact rational Lemke–Howson theorem: for any finite nonempty rational bimatrix game (A, B) (possibly degenerate, arbitrary signs) and any missing label k, lexLHOfRat A B k terminates and outputs an exact rational Nash equilibrium.