Documentation

CombinatorialGames.Surreal.Numeric

Dyadic games #

A combinatorial game that is both Short and Numeric is called dyadic. We show that the dyadic games are in correspondence with the Dyadic rationals, in the sense that there exists a map Dyadic.toIGame such that:

Todo #

Show the latter two bullet points.

For Mathlib #

theorem le_of_le_of_lt_of_lt {α : Type u_1} {β : Type u_2} [PartialOrder α] [Preorder β] {x y : α} {f : αβ} (h : x < yf x < f y) (hxy : x y) :
f x f y
theorem Nat.pow_log_eq_self_iff {b n : } (hb : b 0) :
b ^ log b n = n n Set.range fun (x : ) => b ^ x
theorem Set.range_if {α : Type u_1} {β : Type u_2} {p : αProp} [DecidablePred p] {x y : β} (hp : ∃ (a : α), p a) (hn : ∃ (a : α), ¬p a) :
(range fun (a : α) => if p a then x else y) = {x, y}
theorem range_zero_pow {M : Type u_1} [MonoidWithZero M] :
(Set.range fun (x : ) => 0 ^ x) = {1, 0}
theorem pos_of_mem_powers {n : } (h : n Submonoid.powers 2) :
0 < n
theorem dvd_iff_le_of_mem_powers {m n : } (hm : m Submonoid.powers 2) (hn : n Submonoid.powers 2) :
m n m n

Dyadic numbers #

This material belongs in Mathlib, though we do need to consider if the definition of Dyadic used here is the best one.

def IsDyadic (x : ) :

A dyadic rational number is one whose denominator is a power of two.

Equations
Instances For
    theorem IsDyadic.mkRat (x : ) {y : } (hy : y Submonoid.powers 2) :
    theorem IsDyadic.neg {x : } (hx : IsDyadic x) :
    @[simp]
    theorem IsDyadic.natCast (n : ) :
    theorem IsDyadic.intCast (n : ) :
    theorem IsDyadic.add {x y : } (hx : IsDyadic x) (hy : IsDyadic y) :
    IsDyadic (x + y)
    theorem IsDyadic.sub {x y : } (hx : IsDyadic x) (hy : IsDyadic y) :
    IsDyadic (x - y)
    theorem IsDyadic.mul {x y : } (hx : IsDyadic x) (hy : IsDyadic y) :
    IsDyadic (x * y)
    theorem IsDyadic.nsmul {x : } (n : ) (hx : IsDyadic x) :
    theorem IsDyadic.zsmul {x : } (n : ) (hx : IsDyadic x) :
    theorem IsDyadic.pow {x : } (hx : IsDyadic x) (n : ) :
    IsDyadic (x ^ n)
    @[reducible, inline]
    abbrev Dyadic :

    The subtype of IsDyadic numbers.

    We don't use Localization.Away 2, as this would not give us any computability, nor would it allow us to talk about numerators and denominators.

    Equations
    Instances For
      @[reducible, inline]
      abbrev Dyadic.num (x : Dyadic) :

      Numerator of a dyadic number.

      Equations
      Instances For
        @[reducible, inline]
        abbrev Dyadic.den (x : Dyadic) :

        Denominator of a dyadic number.

        Equations
        Instances For
          theorem Dyadic.den_pos (x : Dyadic) :
          0 < x.den
          @[simp]
          theorem Dyadic.ext {x y : Dyadic} (h : x = y) :
          x = y
          theorem Dyadic.ext_iff {x y : Dyadic} :
          x = y x = y
          Equations
          @[simp]
          theorem Dyadic.val_natCast (n : ) :
          n = n
          @[simp]
          theorem Dyadic.num_natCast (n : ) :
          (↑n).num = n
          @[simp]
          theorem Dyadic.den_natCast (n : ) :
          (↑n).den = 1
          Equations
          @[simp]
          theorem Dyadic.val_intCast (n : ) :
          n = n
          @[simp]
          theorem Dyadic.mk_intCast {n : } (h : IsDyadic n) :
          n, h = n
          @[simp]
          theorem Dyadic.num_intCast (n : ) :
          (↑n).num = n
          @[simp]
          theorem Dyadic.den_intCast (n : ) :
          (↑n).den = 1
          Equations
          @[simp]
          theorem Dyadic.val_zero :
          0 = 0
          @[simp]
          theorem Dyadic.mk_zero (h : IsDyadic 0) :
          0, h = 0
          @[simp]
          theorem Dyadic.num_zero :
          num 0 = 0
          @[simp]
          theorem Dyadic.den_zero :
          den 0 = 1
          Equations
          @[simp]
          theorem Dyadic.val_one :
          1 = 1
          @[simp]
          theorem Dyadic.mk_one (h : IsDyadic 1) :
          1, h = 1
          @[simp]
          theorem Dyadic.num_one :
          num 1 = 1
          @[simp]
          theorem Dyadic.den_one :
          den 1 = 1
          Equations
          @[simp]
          theorem Dyadic.val_neg (x : Dyadic) :
          ↑(-x) = -x
          @[simp]
          theorem Dyadic.neg_mk {x : } (hx : IsDyadic x) :
          -x, hx = -x,
          @[simp]
          theorem Dyadic.num_neg (x : Dyadic) :
          (-x).num = -x.num
          @[simp]
          theorem Dyadic.den_neg (x : Dyadic) :
          (-x).den = x.den
          Equations
          @[simp]
          theorem Dyadic.val_add (x y : Dyadic) :
          ↑(x + y) = x + y
          Equations
          @[simp]
          theorem Dyadic.val_sub (x y : Dyadic) :
          ↑(x - y) = x - y
          Equations
          @[simp]
          theorem Dyadic.val_mul (x y : Dyadic) :
          ↑(x * y) = x * y
          Equations
          @[simp]
          theorem Dyadic.val_nsmul (x : ) (y : Dyadic) :
          ↑(x y) = x y
          Equations
          @[simp]
          theorem Dyadic.val_zsmul (x : ) (y : Dyadic) :
          ↑(x y) = x y
          Equations
          @[simp]
          theorem Dyadic.val_pow (x : Dyadic) (y : ) :
          ↑(x ^ y) = x ^ y

          The dyadic number ½.

          Equations
          Instances For
            @[simp]
            @[simp]
            @[simp]
            def Dyadic.mkRat (m : ) {n : } (h : n Submonoid.powers 2) :

            Constructor for the fraction m / n.

            Equations
            Instances For
              @[simp]
              theorem Dyadic.val_mkRat (m : ) {n : } (h : n Submonoid.powers 2) :
              (Dyadic.mkRat m h) = mkRat m n
              @[simp]
              theorem Dyadic.mkRat_self (x : Dyadic) :
              @[simp]
              theorem Dyadic.mkRat_one (m : ) (h : 1 Submonoid.powers 2) :
              Dyadic.mkRat m h = m
              @[simp]
              theorem Dyadic.mkRat_lt_mkRat {m n : } {k : } (h₁ h₂ : k Submonoid.powers 2) :
              Dyadic.mkRat m h₁ < Dyadic.mkRat n h₂ m < n
              @[simp]
              theorem Dyadic.mkRat_le_mkRat {m n : } {k : } (h₁ h₂ : k Submonoid.powers 2) :
              Dyadic.mkRat m h₁ Dyadic.mkRat n h₂ m n
              Equations
              • One or more equations did not get rendered due to their size.
              theorem Dyadic.even_den {x : Dyadic} (hx : x.den 1) :
              theorem Dyadic.odd_num {x : Dyadic} (hx : x.den 1) :
              theorem Dyadic.num_eq_self_of_den_eq_one {x : Dyadic} (hx : x.den = 1) :
              x.num = x
              theorem Dyadic.eq_mkRat_of_den_le {x : Dyadic} {n : } (h : x.den n) (hn : n Submonoid.powers 2) :
              ∃ (m : ), x = Dyadic.mkRat m hn

              Dyadic games #

              For a dyadic number m / n, returns (m - 1) / n.

              Equations
              Instances For

                For a dyadic number m / n, returns (m + 1) / n.

                Equations
                Instances For
                  theorem Dyadic.den_lower_lt {x : Dyadic} (h : x.den 1) :
                  theorem Dyadic.den_upper_lt {x : Dyadic} (h : x.den 1) :

                  An auxiliary tactic for inducting on the denominator of a Dyadic.

                  Equations
                  Instances For
                    @[simp]
                    theorem Dyadic.lower_neg (x : Dyadic) :
                    @[simp]
                    theorem Dyadic.upper_neg (x : Dyadic) :
                    theorem Dyadic.le_lower_of_lt {x y : Dyadic} (hd : x.den y.den) (h : x < y) :
                    theorem Dyadic.upper_le_of_lt {x y : Dyadic} (hd : y.den x.den) (h : x < y) :
                    theorem Dyadic.lower_eq_of_den_eq_one {x : Dyadic} (h : x.den = 1) :
                    x.lower = x.num - 1
                    theorem Dyadic.upper_eq_of_den_eq_one {x : Dyadic} (h : x.den = 1) :
                    x.upper = x.num + 1
                    @[irreducible]
                    noncomputable def Dyadic.toIGame (x : Dyadic) :

                    Converts a dyadic rational into an IGame. This map is defined so that:

                    • If x : ℤ, then toIGame x = ↑x.
                    • Otherwise, if x = m / n with n even, then toIGame x = {(m - 1) / n | (m + 1) / n}ᴵ. Note that both options will have smaller denominators.
                    Equations
                    Instances For
                      theorem Dyadic.toIGame_of_den_eq_one {x : Dyadic} (hx : x.den = 1) :
                      x.toIGame = x.num
                      @[simp]
                      theorem Dyadic.toIGame_intCast (n : ) :
                      (↑n).toIGame = n
                      @[simp]
                      theorem Dyadic.toIGame_natCast (n : ) :
                      (↑n).toIGame = n
                      @[simp]
                      @[simp]
                      @[simp, irreducible]

                      A dyadic number x is always equivalent to {lower x | upper x}ᴵ, though this may not necessarily be the canonical form.

                      @[irreducible]
                      @[irreducible]
                      @[simp]
                      @[simp]
                      @[simp]
                      theorem Dyadic.toIGame_inj {x y : Dyadic} :