Documentation

CombinatorialGames.Game.Computability.FGame

Computably short games #

We already have a definition of short games at IGame.Short, but it is, regrettably, noncomputable. Here, we provide a computable definition of short games from the ground up, following a similar construction method presented in IGame.lean.

We define FGame and its auxiliary backing type SGame as data, providing data for the left and right moves of a game in the form of an auxiliary SGame type. This makes us capable of performing some basic computations on IGame. Since we would like to use the same standard interface for theorem proving in combinatorial games, we restrict this file only for computability usage and FGame generation. Since some of IGame's basic definitions are computable, these theorems suffice for most of the computability we need.

In general, You should not build any substantial theory based off of this file. The theorems here are intended to check for definitional correctness over theory building.

For Mathlib #

instance instDecidableLeftTotalOfForallExists_combinatorialGames {α : Type u_1} {β : Type u_2} (r : αβProp) [H : Decidable (∀ (a : α), ∃ (b : β), r a b)] :
Equations
instance instDecidableRightTotalOfForallExists_combinatorialGames {α : Type u_1} {β : Type u_2} (r : αβProp) [H : Decidable (∀ (b : β), ∃ (a : α), r a b)] :
Equations
instance instDecidableBiTotalOfForallOfForallExists_combinatorialGames {α : Type u_1} {β : Type u_2} (r : αβProp) [H₁ : Decidable (∀ (a : α), ∃ (b : β), r a b)] [H : Decidable (∀ (b : β), ∃ (a : α), r a b)] :
Equations
inductive SGame :

The type of "short pre-games", before we have quotiented by equivalence (identicalSetoid).

This serves the exact purpose that PGame does for IGame. However, unlike PGame's relatively short construction, we must prove some extra definitions for computing on top of SGame.

This could perfectly well have been in Type 0, but we make it universe polymorphic for convenience when building quotient types. However, conversions from computable games to their noncomputable counterparts are squeezed to Type 0.

Instances For

    The number of left moves on a SGame.

    Equations
    Instances For

      The number of right moves on a SGame.

      Equations
      Instances For

        Perform a left move.

        Equations
        Instances For

          Perform a right move.

          Equations
          Instances For
            @[simp]
            theorem SGame.leftMoves_mk (m n : ) (f : Fin mSGame) (g : Fin nSGame) :
            (mk m n f g).LeftMoves = m
            @[simp]
            theorem SGame.rightMoves_mk (m n : ) (f : Fin mSGame) (g : Fin nSGame) :
            (mk m n f g).RightMoves = n
            @[simp]
            theorem SGame.moveLeft_mk (m n : ) (f : Fin mSGame) (g : Fin nSGame) :
            (mk m n f g).moveLeft = f
            @[simp]
            theorem SGame.moveRight_mk (m n : ) (f : Fin mSGame) (g : Fin nSGame) :
            (mk m n f g).moveRight = g
            inductive SGame.IsOption :
            SGameSGameProp

            A well-founded relation on SGame. While this goes against minimizing SGame code, this enables well-defined recursion in SGame.

            Instances For
              Equations
              • One or more equations did not get rendered due to their size.

              The identical relation on short games. See PGame.Identical.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                The identical relation on short games. See PGame.Identical.

                Equations
                Instances For
                  theorem SGame.identical_iff {x y : SGame} :
                  x.Identical y (Relator.BiTotal fun (x1 : Fin x.LeftMoves) (x2 : Fin y.LeftMoves) => (x.moveLeft x1).Identical (y.moveLeft x2)) Relator.BiTotal fun (x1 : Fin x.RightMoves) (x2 : Fin y.RightMoves) => (x.moveRight x1).Identical (y.moveRight x2)
                  theorem SGame.Identical.trans {x y z : SGame} :
                  x.Identical yy.Identical zx.Identical z
                  theorem SGame.Identical.moveLeft {x y : SGame} :
                  x.Identical y∀ (i : Fin x.LeftMoves), ∃ (j : Fin y.LeftMoves), (x.moveLeft i).Identical (y.moveLeft j)

                  If x ≡ y, then a left move of x is identical to some left move of y.

                  theorem SGame.Identical.moveLeft_symm {x y : SGame} :
                  x.Identical y∀ (i : Fin y.LeftMoves), ∃ (j : Fin x.LeftMoves), (x.moveLeft j).Identical (y.moveLeft i)

                  If x ≡ y, then a left move of y is identical to some left move of x.

                  theorem SGame.Identical.moveRight {x y : SGame} :
                  x.Identical y∀ (i : Fin x.RightMoves), ∃ (j : Fin y.RightMoves), (x.moveRight i).Identical (y.moveRight j)

                  If x ≡ y, then a right move of x is identical to some right move of y.

                  theorem SGame.Identical.moveRight_symm {x y : SGame} :
                  x.Identical y∀ (i : Fin y.RightMoves), ∃ (j : Fin x.RightMoves), (x.moveRight j).Identical (y.moveRight i)

                  If x ≡ y, then a right move of y is identical to some right move of x.

                  @[irreducible]
                  Equations
                  • One or more equations did not get rendered due to their size.

                  Game moves #

                  def FGame :

                  Short games up to identity.

                  FGame uses the set-theoretic notion of equality on short games, similarly to how IGame is defined on top of PGame.

                  Here, we have the distinct advantage of being able to use finsets as our backing left and right sets over IGame's small sets.

                  Equations
                  Instances For
                    def FGame.mk (x : SGame) :

                    The quotient map from SGame into FGame.

                    Equations
                    Instances For
                      theorem FGame.mk_eq_mk {x y : SGame} :
                      mk x = mk y x.Identical y
                      theorem FGame.mk_eq {x y : SGame} :
                      x.Identical ymk x = mk y

                      Alias of the reverse direction of FGame.mk_eq_mk.

                      Alias of the reverse direction of FGame.mk_eq_mk.


                      Alias of the reverse direction of FGame.mk_eq_mk.

                      theorem FGame.ind {motive : FGameProp} (H : ∀ (y : SGame), motive (mk y)) (x : FGame) :
                      motive x
                      noncomputable def FGame.out (x : FGame) :

                      Choose an element of the equivalence class using the axiom of choice.

                      Equations
                      Instances For
                        @[simp]
                        theorem FGame.out_eq (x : FGame) :
                        mk x.out = x

                        The finset of left moves of the game.

                        Equations
                        Instances For

                          The finset of right moves of the game.

                          Equations
                          Instances For
                            theorem FGame.ext {x y : FGame} (hl : x.leftMoves = y.leftMoves) (hr : x.rightMoves = y.rightMoves) :
                            x = y

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

                            Equations
                            Instances For

                              Construct a FGame from its left and right lists. This is an auxiliary definition used to define the more general FGame.ofFinsets.

                              Equations
                              Instances For

                                Construct a FGame from its left and right finsets.

                                This is given notation {s | t}ꟳ, where the superscript F is to disambiguate from set builder notation, and from the analogous constructors on other game types.

                                Equations
                                Instances For

                                  Construct a FGame from its left and right finsets.

                                  This is given notation {s | t}ꟳ, where the superscript F is to disambiguate from set builder notation, and from the analogous constructors on other game types.

                                  Conventions for notations in identifiers:

                                  • The recommended spelling of {· | ·}ꟳ in identifiers is ofFinsets.
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    A (proper) subposition is any game in the transitive closure of IsOption.

                                    Equations
                                    Instances For
                                      theorem FGame.Subposition.trans {x y z : FGame} (h₁ : x.Subposition y) (h₂ : y.Subposition z) :

                                      Discharges proof obligations of the form Subposition .. arising in termination proofs of definitions using well-founded recursion on FGame.

                                      Equations
                                      Instances For

                                        Basic games #

                                        The game 0 = {∅ | ∅}ꟳ.

                                        Equations

                                        The game 1 = {{0} | ∅}ꟳ.

                                        Equations

                                        Repr #

                                        unsafe instance FGame.instRepr :

                                        The Repr of FGame. We confine inputs to {0} to make universe determinism easy on #eval, and we prefer our notation of games {{a, b, c}|{d, e, f}} over the usual flattened out one {a, b, c|d, e, f} to match with the IGame builder syntax.

                                        Equations