Documentation

CombinatorialGames.Game.Graph

Combinatorial games from a type of states #

In the literature, mathematicians often describe games as graphs, consisting of a set of states, as well as move relations for the left and right players. We define a structure GameGraph which facilitates this construction, bundling the left and right set functions along with the type, as well as functions GameGraph.toLGame and GameGraph.toIGame which turn them into the appropriate type of game.

Mathematically, GameGraph.toLGame is nothing but the corecursor on loopy games, while GameGraph.toIGame is defined inductively.

Design notes #

When working with any "specific" game (nim, domineering, etc.) you can use GameGraph to set up the basic theorems and definitions, but the intent is that you're not working with GameGraph directly most of the time.

structure GameGraph (α : Type v) :

A game graph is a type of states endowed with move sets for the left and right players.

You can use GameGraph.toLGame and GameGraph.toIGame to turn this structure into the appropriate game type.

  • moves : PlayerαSet α

    The sets of options for the players.

Instances For
    def GameGraph.IsOption {α : Type v} (c : GameGraph α) (a b : α) :

    IsOption a b means that a is either a left or a right move for b.

    Equations
    Instances For
      theorem GameGraph.IsOption.of_mem_moves {α : Type v} {c : GameGraph α} {p : Player} {a b : α} (h : a c.moves p b) :
      c.IsOption a b
      theorem GameGraph.isWellFounded_isOption_of_eq {α : Type v} {c : GameGraph α} (r : ααProp) [Hr : IsWellFounded α r] (hr : ∀ (p : Player) (x : α), c.moves p x = {y : α | r y x}) :
      instance GameGraph.instSmallSubtypeIsOption {α : Type v} {c : GameGraph α} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] (b : α) :

      Loopy games #

      def GameGraph.toLGame {α : Type v} (c : GameGraph α) [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] (a : α) :

      Turns a state of a GameGraph into an LGame.

      Equations
      Instances For
        @[simp]
        theorem GameGraph.moves_toLGame {α : Type v} (c : GameGraph α) (p : Player) [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] (a : α) :
        theorem GameGraph.toLGame_def' {α : Type v} {c : GameGraph α} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] (a : α) :
        c.toLGame a = !{fun (p : Player) => c.toLGame '' c.moves p a}
        theorem GameGraph.toLGame_def {α : Type v} {c : GameGraph α} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] (a : α) :
        theorem GameGraph.mem_moves_toLGame_of_mem {α : Type v} {c : GameGraph α} {p : Player} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] {a b : α} (hab : b c.moves p a) :
        theorem GameGraph.neg_toLGame {α : Type v} {c : GameGraph α} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] (h : c.moves Player.left = c.moves Player.right) (a : α) :

        Well-founded games #

        def GameGraph.moveRecOn {α : Type v} (c : GameGraph α) [H : IsWellFounded α c.IsOption] {motive : αSort u_1} (x : α) (mk : (x : α) → ((p : Player) → (y : α) → y c.moves p xmotive y)motive x) :
        motive x

        Conway recursion: build data for a game by recursively building it on its left and right sets.

        Equations
        Instances For
          theorem GameGraph.moveRecOn_eq {α : Type v} {c : GameGraph α} [H : IsWellFounded α c.IsOption] {motive : αSort u_1} (x : α) (mk : (x : α) → ((p : Player) → (y : α) → y c.moves p xmotive y)motive x) :
          c.moveRecOn x mk = mk x fun (x_1 : Player) (y : α) (x : y c.moves x_1 x) => c.moveRecOn y mk
          def GameGraph.toIGame {α : Type v} (c : GameGraph α) [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] [H : IsWellFounded α c.IsOption] (a : α) :

          Turns a state of a GameGraph into an IGame.

          Equations
          Instances For
            theorem GameGraph.toIGame_def' {α : Type v} {c : GameGraph α} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] [H : IsWellFounded α c.IsOption] (a : α) :
            c.toIGame a = !{fun (p : Player) => c.toIGame '' c.moves p a}
            theorem GameGraph.toIGame_def {α : Type v} {c : GameGraph α} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] [H : IsWellFounded α c.IsOption] (a : α) :
            @[simp]
            theorem GameGraph.moves_toIGame {α : Type v} (c : GameGraph α) (p : Player) [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] [H : IsWellFounded α c.IsOption] (a : α) :
            theorem GameGraph.mem_moves_toIGame_of_mem {α : Type v} {c : GameGraph α} {p : Player} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] [H : IsWellFounded α c.IsOption] {a b : α} (hab : b c.moves p a) :
            @[simp]
            theorem GameGraph.toLGame_toIGame {α : Type v} (c : GameGraph α) [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] [H : IsWellFounded α c.IsOption] (a : α) :
            theorem GameGraph.neg_toIGame {α : Type v} {c : GameGraph α} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] [H : IsWellFounded α c.IsOption] (h : c.moves Player.left = c.moves Player.right) (a : α) :
            theorem GameGraph.impartial_toIGame {α : Type v} {c : GameGraph α} [Hl : ∀ (a : α), Small.{u, v} (c.moves Player.left a)] [Hr : ∀ (a : α), Small.{u, v} (c.moves Player.right a)] [H : IsWellFounded α c.IsOption] (h : c.moves Player.left = c.moves Player.right) (a : α) :