Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 8c05ff8

Browse files
committed
feat(set_theory/surreal): add ordered_add_comm_group instance for surreal numbers (#7270)
[Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/Surreal.20numbers/near/235213851) Add ordered_add_comm_group instance for surreal numbers.
1 parent 96d5730 commit 8c05ff8

File tree

1 file changed

+36
-44
lines changed

1 file changed

+36
-44
lines changed

src/set_theory/surreal.lean

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -315,58 +315,50 @@ lift₂ (λ x y _ _, x < y) (λ x₁ y₁ x₂ y₂ _ _ _ _ hx hy, propext (lt_c
315315
theorem not_le : ∀ {x y : surreal}, ¬ le x y ↔ lt y x :=
316316
by rintro ⟨⟨x, ox⟩⟩ ⟨⟨y, oy⟩⟩; exact not_le
317317

318-
instance : preorder surreal :=
319-
{ le := le,
320-
lt := lt,
321-
le_refl := by rintro ⟨⟨x, ox⟩⟩; exact le_refl _,
322-
le_trans := by rintro ⟨⟨x, ox⟩⟩ ⟨⟨y, oy⟩⟩ ⟨⟨z, oz⟩⟩; exact le_trans,
323-
lt_iff_le_not_le := by rintro ⟨⟨x, ox⟩⟩ ⟨⟨y, oy⟩⟩; exact lt_iff_le_not_le ox oy }
324-
325-
instance : partial_order surreal :=
326-
{ le_antisymm := by rintro ⟨⟨x, ox⟩⟩ ⟨⟨y, oy⟩⟩ h₁ h₂; exact quot.sound ⟨h₁, h₂⟩,
327-
..surreal.preorder }
328-
329-
noncomputable instance : linear_order surreal :=
330-
{ le_total := by rintro ⟨⟨x, ox⟩⟩ ⟨⟨y, oy⟩⟩; classical; exact
331-
or_iff_not_imp_left.2 (λ h, le_of_lt oy ox (pgame.not_le.1 h)),
332-
decidable_le := classical.dec_rel _,
333-
..surreal.partial_order }
334-
335318
/-- Addition on surreals is inherited from pre-game addition:
336319
the sum of `x = {xL | xR}` and `y = {yL | yR}` is `{xL + y, x + yL | xR + y, x + yR}`. -/
337320
def add : surreal → surreal → surreal :=
338321
surreal.lift₂
339322
(λ (x y : pgame) (ox) (oy), ⟦⟨x + y, numeric_add ox oy⟩⟧)
340-
(λ x₁ y₁ x₂ y₂ _ _ _ _ hx hy, quot.sound (pgame.add_congr hx hy))
341-
342-
instance : has_add surreal := ⟨add⟩
343-
344-
theorem add_assoc : ∀ (x y z : surreal), (x + y) + z = x + (y + z) :=
345-
begin
346-
rintros ⟨x⟩ ⟨y⟩ ⟨z⟩,
347-
apply quot.sound,
348-
exact add_assoc_equiv,
349-
end
350-
351-
theorem zero_add : ∀ (x : surreal), 0 + x = x :=
352-
by { rintro ⟨x, ox⟩, exact quotient.sound (pgame.zero_add_equiv _) }
353-
354-
theorem add_zero : ∀ (x : surreal), x + 0 = x :=
355-
by { rintro ⟨x, ox⟩, exact quotient.sound (pgame.add_zero_equiv _) }
356-
357-
instance : add_monoid surreal :=
358-
{ add := surreal.add,
359-
add_assoc := surreal.add_assoc,
360-
zero := 0,
361-
zero_add := surreal.zero_add,
362-
add_zero := surreal.add_zero }
323+
(λ x₁ y₁ x₂ y₂ _ _ _ _ hx hy, quotient.sound (pgame.add_congr hx hy))
324+
325+
/-- Negation for surreal numbers is inherited from pre-game negation:
326+
the negation of `{L | R}` is `{-R | -L}`. -/
327+
def neg : surreal → surreal :=
328+
surreal.lift
329+
(λ x ox, ⟦⟨-x, pgame.numeric_neg ox⟩⟧)
330+
(λ _ _ _ _ a, quotient.sound (pgame.neg_congr a))
331+
332+
instance : has_le surreal := ⟨le⟩
333+
instance : has_lt surreal := ⟨lt⟩
334+
instance : has_add surreal := ⟨add⟩
335+
instance : has_neg surreal := ⟨neg⟩
336+
337+
instance : ordered_add_comm_group surreal :=
338+
{ add := (+),
339+
add_assoc := by { rintros ⟨_⟩ ⟨_⟩ ⟨_⟩, exact quotient.sound add_assoc_equiv },
340+
zero := 0,
341+
zero_add := by { rintros ⟨_⟩, exact quotient.sound (pgame.zero_add_equiv _) },
342+
add_zero := by { rintros ⟨_⟩, exact quotient.sound (pgame.add_zero_equiv _) },
343+
neg := has_neg.neg,
344+
add_left_neg := by { rintros ⟨_⟩, exact quotient.sound pgame.add_left_neg_equiv },
345+
add_comm := by { rintros ⟨_⟩ ⟨_⟩, exact quotient.sound pgame.add_comm_equiv },
346+
le := (≤),
347+
lt := (<),
348+
le_refl := by { rintros ⟨_⟩, refl },
349+
le_trans := by { rintros ⟨_⟩ ⟨_⟩ ⟨_⟩, exact pgame.le_trans },
350+
lt_iff_le_not_le := by { rintros ⟨_, ox⟩ ⟨_, oy⟩, exact pgame.lt_iff_le_not_le ox oy },
351+
le_antisymm := by { rintros ⟨_⟩ ⟨_⟩ h₁ h₂, exact quotient.sound ⟨h₁, h₂⟩ },
352+
add_le_add_left := by { rintros ⟨_⟩ ⟨_⟩ hx ⟨_⟩, exact pgame.add_le_add_left hx } }
353+
354+
noncomputable instance : linear_ordered_add_comm_group surreal :=
355+
{ le_total := by rintro ⟨⟨x, ox⟩⟩ ⟨⟨y, oy⟩⟩; classical; exact
356+
or_iff_not_imp_left.2 (λ h, le_of_lt oy ox (pgame.not_le.1 h)),
357+
decidable_le := classical.dec_rel _,
358+
..surreal.ordered_add_comm_group }
363359

364360
-- We conclude with some ideas for further work on surreals; these would make fun projects.
365361

366-
-- TODO replace the `add_monoid` instance above with a stronger instance:
367-
-- add_group, add_comm_semigroup, add_comm_group, ordered_add_comm_group,
368-
-- as per the instances for `game`
369-
370362
-- TODO define the inclusion of groups `surreal → game`
371363

372364
-- TODO define the dyadic rationals, and show they map into the surreals via the formula

0 commit comments

Comments
 (0)