Documentation

CslibFrontier.Algorithms.Lean.Simplex.Minimax

Solving finite zero-sum games with the simplex method #

This module computes the value and optimal mixed strategies of a finite zero-sum game with the simplex method of CslibFrontier.Algorithms.Lean.Simplex.LinearProgram, and proves the output correct: the returned value is the value of the game (Cslib.Probability.IsMinimaxValue) and the returned strategies witness it.

Algorithm #

The game has the loss matrix M : Fin m → Fin n → K over a linearly ordered field K: the row player picks i, the column player picks j, and the row player pays M i j. With the shift s = 1 - min (0, min_{i,j} M i j) (gameShift), every entry of M i j + s is at least 1. solveGame runs the simplex method with Bland's rule on the slack dictionary of the canonical program

max ∑ i, x i subject to x ≥ 0 and ∑ i, x i * (M i j + s) ≤ 1 for every column j,

whose right-hand side 1 ≥ 0 makes the slack dictionary feasible, so no phase I is needed. The program is bounded, since ∑ i, x i ≤ ∑ i, x i * (M i j + s) ≤ 1 for any column j, so the simplex method stops at an optimal dictionary D with optimum V = D.objConst > 0. The primal optimum x (the first m coordinates of the basic solution of D) and the dual optimum y read off the reduced costs of the slack variables (Dictionary.slackDual) are normalized to the strategies x / V and y / V, and the value is 1 / V - s, by Cslib.Probability.strategies_of_canonical_pair. This is the reduction of Cslib.Probability.exists_isMinimaxValue ([MG07], Section 8.1), with the existence of an optimal primal-dual pair replaced by the run of the simplex method.

Main definitions #

Main results #

References #

structure Cslib.Algorithms.Lean.Simplex.GameSolution (K : Type u_2) (m n : ℕ) :
Type u_2

A solution of a zero-sum game with m rows and n columns: a value together with the weight vectors of a row strategy and a column strategy.

  • value : K

    The value of the game.

  • row : Fin m → K

    The weights of the row player's mixed strategy.

  • col : Fin n → K

    The weights of the column player's mixed strategy.

Instances For
    def Cslib.Algorithms.Lean.Simplex.gameShift {K : Type u_1} [Field K] [LinearOrder K] {m n : ℕ} (M : Fin m → Fin n → K) :
    K

    The shift 1 - min (0, min_{i,j} M i j), after which every entry M i j + gameShift M of the loss matrix is at least 1. It is public and exposed because its client is the body of solveGame, which the kernel must be able to unfold to evaluate the solver (as in decide +kernel checks); an exposed definition cannot refer to a private one.

    Instances For
      def Cslib.Algorithms.Lean.Simplex.solveGame {K : Type u_1} [Field K] [LinearOrder K] {m n : ℕ} (M : Fin m → Fin n → K) :

      The value and optimal strategies of a zero-sum game with at least one row and one column (0 < m and 0 < n), computed with the simplex method. When m = 0 or n = 0 the game has no mixed strategies and the result is a junk value with no guarantee; solveGame_spec and isMinimaxValue_solveGame assume [NeZero m] [NeZero n].

      With s = gameShift M, the simplex method with Bland's rule maximizes ∑ i, x i subject to x ≥ 0 and ∑ i, x i * (M i j + s) ≤ 1, from its slack dictionary; with optimum V, the row strategy is the primal optimum divided by V, the column strategy is the dual optimum Dictionary.slackDual divided by V, and the value is 1 / V - s. For a nonempty game the outcomes other than optimal do not occur.

      Instances For
        theorem Cslib.Algorithms.Lean.Simplex.solveGame_spec {K : Type u_1} [Field K] [LinearOrder K] [IsStrictOrderedRing K] {m n : ℕ} [NeZero m] [NeZero n] (M : Fin m → Fin n → K) :
        (∀ (i : Fin m), 0 ≤ (solveGame M).row i) ∧ ∑ i : Fin m, (solveGame M).row i = 1 ∧ (∀ (j : Fin n), ∑ i : Fin m, (solveGame M).row i * M i j ≤ (solveGame M).value) ∧ (∀ (j : Fin n), 0 ≤ (solveGame M).col j) ∧ ∑ j : Fin n, (solveGame M).col j = 1 ∧ ∀ (i : Fin m), (solveGame M).value ≤ ∑ j : Fin n, (solveGame M).col j * M i j

        The output of solveGame is correct: for a game with at least one row and one column, the returned row and column strategies have nonnegative weights summing to 1, the row strategy pays at most the returned value against every column, and the column strategy collects at least the returned value against every row.

        The simplex method computes the value of a finite zero-sum game over a linearly ordered field: (solveGame M).value is the value of the game M, witnessed by the strategies (solveGame M).row and (solveGame M).col (solveGame_spec).