# mathlibdocumentation

set_theory.surreal

# Surreal numbers

The basic theory of surreal numbers, built on top of the theory of combinatorial (pre-)games.

A pregame is numeric if all the Left options are strictly smaller than all the Right options, and all those options are themselves numeric. In terms of combinatorial games, the numeric games have "frozen"; you can only make your position worse by playing, and Left is some definite "number" of moves ahead (or behind) Right.

A surreal number is an equivalence class of numeric pregames.

In fact, the surreals form a complete ordered field, containing a copy of the reals (and much else besides!) but we do not yet have a complete development.

## Order properties

Surreal numbers inherit the relations ≤ and < from games, and these relations satisfy the axioms of a partial order (recall that x < y ↔ x ≤ y ∧ ¬ y ≤ x did not hold for games).

## Algebraic operations

At this point, we have defined addition and negation (from pregames), and shown that surreals form an additive semigroup. It would be very little work to finish showing that the surreals form an ordered commutative group.

We define the operations of multiplication and inverse on surreals, but do not yet establish any of the necessary properties to show the surreals form an ordered field.

## Embeddings

It would be nice projects to define the group homomorphism surreal → game, and also ℤ → surreal, and then the homomorphic inclusion of the dyadic rationals into surreals, and finally via dyadic Dedekind cuts the homomorphic inclusion of the reals into the surreals.

One can also map all the ordinals into the surreals!

## References

• [Conway, On numbers and games][conway2001]

Multiplicative operations can be defined at the level of pre-games, but as they are only useful on surreal numbers, we define them here.

def pgame.mul  :
pgame

The product of x = {xL | xR} and y = {yL | yR} is {xL*y + x*yL - xL*yL, xR*y + x*yR - xR*yR | xL*y + x*yR - xL*yR, x*yL + xR*y - xR*yL }.

Equations
• x.mul y = pgame.rec (λ (xl xr : Type u_1) (xL : xl → pgame) (xR : xr → pgame) (IHxl : Π (a : xl), (λ (x : pgame), (xL a)) (IHxr : Π (a : xr), (λ (x : pgame), (xR a)) (y : pgame), pgame.rec (λ (yl yr : Type u_2) (yL : yl → pgame) (yR : yr → pgame) (IHyl : Π (a : yl), (λ (y : pgame), pgame) (yL a)) (IHyr : Π (a : yr), (λ (y : pgame), pgame) (yR a)), pgame.mk (xl × yl xr × yr) (xl × yr xr × yl) (λ (a : xl × yl xr × yr), a.cases_on (λ (a : xl × yl), a.cases_on (λ (i : xl) (j : yl), IHxl i (pgame.mk yl yr yL yR) + IHyl j - IHxl i (yL j))) (λ (a : xr × yr), a.cases_on (λ (i : xr) (j : yr), IHxr i (pgame.mk yl yr yL yR) + IHyr j - IHxr i (yR j)))) (λ (a : xl × yr xr × yl), a.cases_on (λ (a : xl × yr), a.cases_on (λ (i : xl) (j : yr), IHxl i (pgame.mk yl yr yL yR) + IHyr j - IHxl i (yR j))) (λ (a : xr × yl), a.cases_on (λ (i : xr) (j : yl), IHxr i (pgame.mk yl yr yL yR) + IHyl j - IHxr i (yL j))))) y) x y
@[instance]

Equations
inductive pgame.inv_ty  :
Type uType uboolType u
• zero : Π (l r : Type u), r ff
• left₁ : Π (l r : Type u), r → r ff r ff
• left₂ : Π (l r : Type u), l → r tt r ff
• right₁ : Π (l r : Type u), l → r ff r tt
• right₂ : Π (l r : Type u), r → r tt r tt

Because the two halves of the definition of inv produce more elements of each side, we have to define the two families inductively. This is the indexing set for the function, and inv_val is the function part.

def pgame.inv_val {l r : Type u_1} (L : l → pgame) (R : r → pgame) (IHl : l → pgame) (IHr : r → pgame) {b : bool} :
r bpgame

Because the two halves of the definition of inv produce more elements of each side, we have to define the two families inductively. This is the function part, defined by recursion on inv_ty.

Equations
• IHl IHr j) = (1 + (R i - r L R) * IHl IHr j) * IHr i
• IHl IHr j) = (1 + (L i - r L R) * IHl IHr j) * IHl i
• IHl IHr j) = (1 + (L i - r L R) * IHl IHr j) * IHl i
• IHl IHr j) = (1 + (R i - r L R) * IHl IHr j) * IHr i
• IHl IHr pgame.inv_ty.zero = 0
def pgame.inv'  :

The inverse of a positive surreal number x = {L | R} is given by x⁻¹ = {0, (1 + (R - x) * x⁻¹L) * R, (1 + (L - x) * x⁻¹R) * L | (1 + (L - x) * x⁻¹L) * L, (1 + (R - x) * x⁻¹R) * R}. Because the two halves x⁻¹L, x⁻¹R of x⁻¹ are used in their own definition, the sets and elements are inductively generated.

Equations
def pgame.inv  :

The inverse of a surreal number in terms of the inverse on positive surreals.

Equations
@[instance]

Equations
@[instance]

Equations
def pgame.numeric  :
pgame → Prop

A pre-game is numeric if everything in the L set is less than everything in the R set, and all the elements of L and R are also numeric.

Equations
theorem pgame.numeric.move_left {x : pgame} (o : x.numeric) (i : x.left_moves) :

theorem pgame.numeric.move_right {x : pgame} (o : x.numeric) (j : x.right_moves) :

theorem pgame.numeric_rec {C : pgame → Prop} (H : ∀ (l r : Type u_1) (L : l → pgame) (R : r → pgame), (∀ (i : l) (j : r), L i < R j)(∀ (i : l), (L i).numeric)(∀ (i : r), (R i).numeric)(∀ (i : l), C (L i))(∀ (i : r), C (R i))C (pgame.mk l r L R)) (x : pgame) :
x.numericC x

theorem pgame.lt_asymm {x y : pgame} :
x.numericy.numericx < y¬y < x

theorem pgame.le_of_lt {x y : pgame} :
x.numericy.numericx < yx y

theorem pgame.lt_iff_le_not_le {x y : pgame} :
x.numericy.numeric(x < y x y ¬y x)

On numeric pre-games, < and ≤ satisfy the axioms of a partial order (even though they don't on all pre-games).

theorem pgame.numeric_neg {x : pgame} :
x.numeric → (-x).numeric

theorem pgame.numeric.move_left_lt {x : pgame} (o : x.numeric) (i : x.left_moves) :
x.move_left i < x

theorem pgame.numeric.move_left_le {x : pgame} (o : x.numeric) (i : x.left_moves) :

theorem pgame.numeric.lt_move_right {x : pgame} (o : x.numeric) (j : x.right_moves) :

theorem pgame.numeric.le_move_right {x : pgame} (o : x.numeric) (j : x.right_moves) :

w.numericx.numericy.numericz.numericw < xy < zw + y < x + z

theorem pgame.numeric_add {x y : pgame} :
x.numericy.numeric(x + y).numeric

def surreal.equiv  :
{x // x.numeric}{x // x.numeric} → Prop

The equivalence on numeric pre-games.

Equations
@[instance]
def surreal.setoid  :
setoid {x // x.numeric}

Equations
def surreal  :
Type (u_1+1)

The type of surreal numbers. These are the numeric pre-games quotiented by the equivalence relation x ≈ y ↔ x ≤ y ∧ y ≤ x. In the quotient, the order becomes a total order.

Equations
def surreal.mk (x : pgame) :

Construct a surreal number from a numeric pre-game.

Equations
@[instance]

Equations
@[instance]

Equations
@[instance]

Equations
def surreal.lift {α : Sort u_1} (f : Π (x : pgame), x.numeric → α) :
(∀ {x y : pgame} (hx : x.numeric) (hy : y.numeric), x.equiv yf x hx = f y hy)surreal → α

Lift an equivalence-respecting function on pre-games to surreals.

Equations
def surreal.lift₂ {α : Sort u_1} (f : Π (x : pgame) (y : pgame), x.numericy.numeric → α) :
(∀ {x₁ : pgame} {y₁ : pgame} {x₂ : pgame} {y₂ : pgame} (ox₁ : x₁.numeric) (oy₁ : y₁.numeric) (ox₂ : x₂.numeric) (oy₂ : y₂.numeric), x₁.equiv x₂y₁.equiv y₂f x₁ y₁ ox₁ oy₁ = f x₂ y₂ ox₂ oy₂)surrealsurreal → α

Lift a binary equivalence-respecting function on pre-games to surreals.

Equations
def surreal.le  :
surrealsurreal → Prop

The relation x ≤ y on surreals.

Equations
def surreal.lt  :
surrealsurreal → Prop

The relation x < y on surreals.

Equations
theorem surreal.not_le {x y : surreal} :
¬x.le y y.lt x

@[instance]

Equations
@[instance]

Equations
@[instance]

Equations
Addition on surreals is inherited from pre-game addition: the sum of x = {xL | xR} and y = {yL | yR} is {xL + y, x + yL | xR + y, x + yR}.