Grundy value #
The Grundy value of an impartial game is recursively defined as the least nimber not among the Grundy values of either its left or right options. This map respects addition and multiplication.
We provide two definitions for the Grundy value. grundyAux is computed using either the left or
right options of the game, and is defined for all games. To make the API symmetric, we also provide
Impartial.grundy, which enforces that the game is impartial, and is thus equal to either of
grundyAux left or grundyAux right.
The Sprague-Grundy theorem Impartial.nim_grundy_equiv shows that any impartial game is
equivalent to a game of Nim, namely that corresponding to its Grundy value.
Grundy value #
The left or right Grundy value of a game is recursively defined as the minimum excluded value (the infimum of the complement) of the left or right Grundy values of its left or right options.
This is an auxiliary definition for reasoning about games not yet known to be impartial. Use
Impartial.grundy for an impartial game.
Equations
- IGame.grundyAux p x = sInf (Set.range fun (y : ↑(IGame.moves p x)) => IGame.grundyAux p ↑y)ᶜ
Instances For
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 its options.
This definition enforces that x is impartial. If you want to talk about the left or right Grundy
values of a game (e.g. if you don't yet know it to be impartial), use grundyAux.
The lemma grundyAux_eq_grundy shows that both definitions match in
the case of an impartial game.
Equations
Instances For
Alias of the reverse direction of IGame.Impartial.grundy_eq_iff_equiv_nim.