Documentation

CombinatorialGames.Game.Impartial.Basic

Basic definitions about impartial games #

We will define an impartial game, one in which left and right can make exactly the same moves. Our definition differs slightly by saying that the game is always equivalent to its negative, no matter what moves are played. This allows for games such as poker-nim to be classified as impartial.

An impartial game is one that's equivalent to its negative, such that each left and right move is also impartial.

Note that this is a slightly more general definition than the one that's usually in the literature, as we don't require x = -x. Despite this, the Sprague-Grundy theorem still holds: see IGame.equiv_nim_grundyValue.

In such a game, both players have the same payoffs at any subposition.

Instances
    theorem IGame.impartial_def {x : IGame} :
    x.Impartial -xx ∀ (p : Player), ymoves p x, y.Impartial
    theorem IGame.Impartial.mk {x : IGame} (h₁ : -xx) (h₂ : ∀ (p : Player), ymoves p x, y.Impartial) :
    @[simp]
    theorem IGame.Impartial.neg_equiv (x : IGame) [hx : x.Impartial] :
    -xx
    @[simp]
    theorem IGame.Impartial.equiv_neg (x : IGame) [hx : x.Impartial] :
    x-x
    theorem IGame.Impartial.sub_equiv (x y : IGame) [hy : y.Impartial] :
    x - yx + y
    @[simp]
    @[simp]
    theorem IGame.Impartial.sub_mk (y : IGame) [hy : y.Impartial] (x : Game) :
    x - Game.mk y = x + Game.mk y
    @[simp]
    theorem IGame.Impartial.of_mem_moves {p : Player} {x y : IGame} [h : x.Impartial] :
    y moves p xy.Impartial

    impartial eagerly adds all possible Impartial hypotheses.

    Equations
    Instances For
      @[irreducible]
      @[irreducible]
      instance IGame.Impartial.add (x y : IGame) [x.Impartial] [y.Impartial] :
      (x + y).Impartial
      theorem IGame.Impartial.le_comm {x y : IGame} [x.Impartial] [y.Impartial] :
      x y y x

      The product instance is proven in Game.Impartial.Grundy.

      @[simp]
      theorem IGame.Impartial.not_lt (x y : IGame) [hx : x.Impartial] [hy : y.Impartial] :
      ¬x < y
      theorem IGame.Impartial.equiv_or_fuzzy (x y : IGame) [hx : x.Impartial] [hy : y.Impartial] :
      xy xy

      By setting y = 0, we find that in an impartial game, either the first player always wins, or the second player always wins.

      theorem IGame.Impartial.equiv_iff_add_equiv_zero {x y : IGame} [y.Impartial] :
      xy x + y0

      This lemma doesn't require x to be impartial.

      theorem IGame.Impartial.equiv_iff_add_equiv_zero' {x y : IGame} [x.Impartial] :
      xy x + y0

      This lemma doesn't require y to be impartial.

      @[simp]
      theorem IGame.Impartial.not_equiv_iff {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] :
      ¬xy xy
      @[simp]
      theorem IGame.Impartial.not_fuzzy_iff {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] :
      ¬xy xy
      theorem IGame.Impartial.fuzzy_iff_add_fuzzy_zero {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] :
      xy x + y0
      @[simp]
      theorem IGame.Impartial.le_iff_equiv {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] :
      x y xy
      theorem IGame.Impartial.ge_iff_equiv {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] :
      y x xy
      theorem IGame.Impartial.lf_iff_fuzzy {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] :
      ¬y x xy
      theorem IGame.Impartial.gf_iff_fuzzy {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] :
      ¬x y xy
      theorem IGame.Impartial.fuzzy_of_mem_moves {x : IGame} [hx : x.Impartial] {y : IGame} {p : Player} (hy : y moves p x) :
      yx
      theorem IGame.Impartial.equiv_iff_forall_fuzzy {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] (p : Player) :
      xy (∀ zmoves p x, zy) zmoves (-p) y, xz
      theorem IGame.Impartial.fuzzy_iff_exists_equiv {x y : IGame} [hx : x.Impartial] [hy : y.Impartial] (p : Player) :
      xy (∃ zmoves p x, zy) zmoves (-p) y, xz
      theorem IGame.Impartial.equiv_zero {x : IGame} [hx : x.Impartial] (p : Player) :
      x0 ymoves p x, y0
      theorem IGame.Impartial.fuzzy_zero {x : IGame} [hx : x.Impartial] (p : Player) :
      x0 ymoves p x, y0
      theorem IGame.Impartial.fuzzy_zero_of_forall_exists {x : IGame} [hx : x.Impartial] {p : Player} {y : IGame} (hy : y moves p x) (H : zmoves p y, wmoves p x, zw) :
      x0

      A strategy stealing argument. If there's a move in x, such that any immediate move could have also been reached in the first turn, then x is won by the first player.