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 #
Cslib.Algorithms.Lean.Simplex.GameSolution: a value with a row and a column strategy.Cslib.Algorithms.Lean.Simplex.gameShift: the shift making every entry of the loss matrix at least1, exposed so thatsolveGamereduces in the kernel.Cslib.Algorithms.Lean.Simplex.solveGame: the value and optimal strategies of a game with at least one row and one column, computed with the simplex method.
Main results #
Cslib.Algorithms.Lean.Simplex.solveGame_spec: for a game with at least one row and one column, the strategies returned bysolveGameare mixed strategies (nonnegative weights summing to1), 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.Cslib.Algorithms.Lean.Simplex.isMinimaxValue_solveGame: the returned value is the value of the game.
References #
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
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
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
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).