Documentation

Pdl.Game

A General Theory for Determined Two-player Games #

Nothing here is specific about PDL, but we give a general definition of games and show that one of the two players must have a winning strategy: gamedet at the end.

Games #

inductive Player :

Two players, A and B.

Instances For
    Equations
    @[simp]
    theorem Player.ne_A_iff_eq_B {p : Player} :
    p A p = B
    @[simp]
    theorem Player.ne_B_iff_eq_A {p : Player} :
    p B p = A
    @[simp]
    @[simp]
    @[simp]
    theorem Player.not_eq_i_eq_other {p i : Player} :
    ¬p = i p = other i
    @[simp]
    theorem Player.not_eq_other_eq_i {p i : Player} :
    ¬p = other i p = i
    @[simp]
    @[simp]
    @[simp]
    theorem other_other {i : Player} :
    other (other i) = i
    class Game :

    Two-player game with

    • perfect information
    • sequential moves (i.e. only one player moves at each position)
    • finitely many moves at each step
    • a decreasing bound on the number of remaining steps
    Instances

      This seems a bit hacky, but makes termination_by (p : g.Pos) work in winner and elsewhere. If the instance causes trouble, change to termination_by g.wf.2.wrap p via WellFounded.wrap.

      Equations
      @[reducible, inline]
      abbrev Game.Pos.moves {g : Game} :

      Allow notation p.moves for g.moves p.

      Equations
      Instances For
        theorem Game.no_moves_of_no_rel {g : Game} {p : Pos} (no_rel : ∀ (q : Pos), ¬WellFoundedRelation.rel q p) :

        If the bound bound is zero then there are no more moves.

        instance instLTPos {g : Game} :
        Equations

        Strategies #

        def Strategy (g : Game) (i : Player) :

        A strategy in g for i, whenever it is i's turn, chooses a move, if there are any.

        Equations
        Instances For
          noncomputable def choose_move {g : Game} {p : Game.Pos} :
          Equations
          Instances For
            instance Strategy.instNonempty {g : Game} {i : Player} :

            There is always some strategy.

            @[irreducible]
            def winner {i : Player} {g : Game} (sI : Strategy g i) (sJ : Strategy g (other i)) (p : Game.Pos) :

            Winner of a game, if the given strategies are used. A player loses iff it is their turn and there are no moves. A player wins if the opponent loses.

            Equations
            Instances For
              def winning {g : Game} {i : Player} (sI : Strategy g i) (p : Game.Pos) :

              A strategy is winning at p if it wins against all strategies of the other player.

              Equations
              Instances For

                Good positions #

                @[irreducible]
                def good {g : Game} (i : Player) (p : Game.Pos) :
                Equations
                Instances For
                  theorem good_is_surviving {i : Player} {g : Game} {p : Game.Pos} :
                  good i pGame.turn p = ip.moves.Nonempty
                  noncomputable def good_strat {g : Game} (i : Player) :
                  Equations
                  Instances For

                    Cones #

                    inductive inMyCone {i : Player} {g : Game} (sI : Strategy g i) (p : Game.Pos) :

                    The cone of all positions reachable from p assuming that i plays sI.

                    Instances For
                      theorem inMyCone_trans {g : Game} {i : Player} {p q r : Game.Pos} {s : Strategy g i} :
                      inMyCone s p qinMyCone s q rinMyCone s p r
                      theorem good_cone {i : Player} {g : Game} {p r : Game.Pos} (W : good i p) (h : inMyCone (good_strat i) p r) :
                      good i r

                      The cone of the good_strat stays inside good positions.

                      Zermelo's Theorem #

                      @[irreducible]
                      theorem surviving_is_winning {g : Game} {i : Player} {p : Game.Pos} {sI : Strategy g i} (surv : ∀ (q : Game.Pos), inMyCone sI p qGame.turn q = iq.moves.Nonempty) :
                      winning sI p
                      theorem good_strat_winning {i : Player} {self✝ : Game} {p : Game.Pos} (W : good i p) :
                      theorem gamedet (g : Game) (p : Game.Pos) :
                      (∃ (s : Strategy g Player.A), winning s p) ∃ (s : Strategy g Player.B), winning s p

                      Zermelo's Theorem: In every Game position one of the two players has a winning strategy. https://en.wikipedia.org/wiki/Zermelo%27s_theorem_(game_theory)

                      Additional Helper Theorems #

                      theorem winning_has_moves {g : Game} {i : Player} {sI : Strategy g i} {p : Game.Pos} (h : Game.turn p = i) (sI_wins_p : winning sI p) :
                      theorem winning_of_winning_move {g : Game} {i : Player} {sI : Strategy g i} {p : Game.Pos} (h : Game.turn p = i) (sI_wins_p : winning sI p) :
                      winning sI (sI p h )
                      theorem not_in_cone_of_move {i : Player} {g : Game} {p q : Game.Pos} (q_in : q Game.moves p) (sI : Strategy g i) :
                      ¬inMyCone sI q p
                      @[irreducible]
                      theorem same_winner_of_same_in_cone {i : Player} {g : Game} {sI : Strategy g i} {sJ sJ' : Strategy g (other i)} {p : Game.Pos} (same_cone : ∀ (r : Game.Pos), inMyCone sJ p rsJ r = sJ' r) :
                      winner sI sJ p = winner sI sJ' p
                      theorem winning_of_whatever_other_move {g : Game} {i : Player} {sI : Strategy g i} {p : Game.Pos} (h : Game.turn p = other i) (sI_wins_p : winning sI p) (m : { x : Game.Pos // x Game.moves p }) :
                      winning sI m

                      Helper for gameP_general.