Documentation

LeanPool.Lean4GlCoalgebras.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 #

Two players, A and B.

Instances For
    @[implicit_reducible]
    Equations

    Two-player game with

    • perfect information
    • sequential moves (i.e. only one player moves at each position)
    • finitely many moves at each step (aka finitely branching)
    • a well-founded relation to ensure that the game ends.
    Instances
      @[implicit_reducible]

      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]

      Allow notation p.moves for g.moves p.

      Equations
      Instances For

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

        Strategies #

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

        Equations
        Instances For
          noncomputable def Lean4GlCoalgebras.chooseMove {g : Game} {p : Game.Pos} :
          p.moves.Nonemptyp.moves

          Auxiliary declaration used in the GL coalgebra development.

          Equations
          Instances For

            There is always some strategy.

            @[irreducible]
            def Lean4GlCoalgebras.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
            • One or more equations did not get rendered due to their size.
            Instances For
              def Lean4GlCoalgebras.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]

                Auxiliary declaration used in the GL coalgebra development.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  noncomputable def Lean4GlCoalgebras.goodStrat {g : Game} (i : Player) :

                  Auxiliary declaration used in the GL coalgebra development.

                  Equations
                  Instances For

                    Cones #

                    inductive Lean4GlCoalgebras.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 Lean4GlCoalgebras.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 Lean4GlCoalgebras.good_cone {i : Player} {g : Game} {p r : Game.Pos} (W : good i p) (h : inMyCone (goodStrat i) p r) :
                      good i r

                      The cone of the goodStrat stays inside good positions.

                      Zermelo's Theorem #

                      theorem Lean4GlCoalgebras.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 Lean4GlCoalgebras.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.

                      Additional Helper Theorems #

                      theorem Lean4GlCoalgebras.winning_has_moves {i : Player} {g : Game} {sI : Strategy g i} {p : Game.Pos} (h : Game.turn p = i) (sI_wins_p : winning sI p) :
                      theorem Lean4GlCoalgebras.winning_of_winning_move {i : Player} {g : Game} {sI : Strategy g i} {p : Game.Pos} (h : Game.turn p = i) (sI_wins_p : winning sI p) :
                      winning sI (sI p h )
                      theorem Lean4GlCoalgebras.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
                      theorem Lean4GlCoalgebras.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 Lean4GlCoalgebras.winning_of_whatever_other_move {i : Player} {g : Game} {sI : Strategy g i} {p : Game.Pos} (h : Game.turn p = other i) (sI_wins_p : winning sI p) (m : (Game.moves p)) :
                      winning sI m

                      Helper for gameP_general.

                      theorem Lean4GlCoalgebras.winning_of_in_cone_winning {g : Game} {i : Player} {p q : Game.Pos} {sI : Strategy g i} (in_cone : inMyCone sI p q) (h : winning sI p) :
                      winning sI q