Documentation

CombinatorialGames.Game.Impartial.Grundy

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 #

@[irreducible]

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
Instances For
    theorem IGame.mem_grundyAux_image_of_lt {p : Player} {x : IGame} {o : Nimber} (h : o < grundyAux p x) :
    theorem IGame.grundyAux_le_of_notMem {p : Player} {x : IGame} {o : Nimber} (h : ogrundyAux p '' moves p x) :
    theorem IGame.grundyAux_ne {p : Player} {x y : IGame} (hy : y moves p x) :
    @[simp, irreducible]
    theorem IGame.grundyAux_add (p : Player) (x y : IGame) :
    grundyAux p (x + y) = grundyAux p x + grundyAux p y
    @[simp, irreducible]
    theorem IGame.grundyAux_neg (p : Player) (x : IGame) :
    grundyAux p (-x) = grundyAux (-p) x
    @[simp]
    @[simp]
    theorem IGame.grundyAux_sub (p : Player) (x y : IGame) :
    grundyAux p (x - y) = grundyAux p x + grundyAux (-p) y

    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
      @[irreducible]

      The Sprague-Grundy theorem states that every impartial game is equivalent to a game of nim, namely the game of nim for the game's Grundy value.

      theorem IGame.Impartial.grundy_eq {x : IGame} [x.Impartial] {o : Nimber} :
      xnim ogrundy x = o

      Alias of the reverse direction of IGame.Impartial.grundy_eq_iff_equiv_nim.

      @[simp]
      @[simp]
      theorem IGame.nim_add_equiv (a b : Nimber) :
      nim a + nim bnim (a + b)
      theorem IGame.Impartial.grundy_moves_ne {p : Player} {x y : IGame} [x.Impartial] (hy : y moves p x) :
      have this := ; grundy y grundy x
      theorem IGame.Impartial.lt_of_numeric_of_pos (x : IGame) [x.Impartial] {y : IGame} [y.Numeric] (hy : 0 < y) :
      x < y

      One half of the lawnmower theorem for impartial games.

      theorem IGame.Impartial.lt_of_numeric_of_neg (x : IGame) [x.Impartial] {y : IGame} [y.Numeric] (hy : y < 0) :
      y < x

      One half of the lawnmower theorem for impartial games.

      If a game x has only impartial options, and its left Grundy value equals its right Grundy value, then it's impartial.