Nim and the Sprague-Grundy theorem #
In the game of nim o
, for o
an ordinal number, both players may move to nim a
for any a < o
.
We also define a Grundy value for an impartial game x
and prove the Sprague-Grundy theorem, that
x
is equivalent to nim (grundy x)
. Finally, we prove that the grundy value of a sum x + y
corresponds to the nimber sum of the individual grundy values.
Nim game #
The definition of single-heap nim, which can be viewed as a pile of stones where each player can take a positive number of stones from it on their turn.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Grundy value #
The Grundy value of an impartial game is recursively defined as the minimum excluded value (the infimum of the complement) of the Grundy values of either its left or right options.
This is the nimber which corresponds to the game of nim that the game is equivalent to.
Equations
- IGame.Impartial.grundy x = sInf (Set.range fun (y : ↑x.leftMoves) => IGame.Impartial.grundy ↑y)ᶜ
Instances For
This version is stated in terms of right moves of x
.