Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat: more PGame.identical PGame.memₗ PGame.memᵣ APIs #5901

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
3cc4bd5
feat: add lemmas about `Relator.LeftTotal` `Relator.RightTotal` `Rela…
FR-vdash-bot Jul 14, 2023
088ac08
feat: define `pgame.identical` `pgame.memₗ` `pgame.memᵣ`
FR-vdash-bot Jul 14, 2023
e6c9820
Merge branch 'master' into FR_game_identical
FR-vdash-bot Jul 31, 2023
e9e6636
Merge branch 'master' into FR_game_identical
FR-vdash-bot Sep 10, 2023
3dba08d
diffs
FR-vdash-bot Sep 10, 2023
a6bec11
inherit_doc
FR-vdash-bot Sep 14, 2023
1bc0b50
missing lemma
FR-vdash-bot Sep 14, 2023
c66a20e
fix
FR-vdash-bot Sep 14, 2023
1fa2e1f
simp
FR-vdash-bot Sep 14, 2023
c1d9143
missing lemmas
FR-vdash-bot Sep 14, 2023
35c10e7
lemmas
FR-vdash-bot Sep 16, 2023
69b7f4a
golf
FR-vdash-bot Sep 16, 2023
32fb3f1
Merge branch 'master' into FR_game_identical
FR-vdash-bot Sep 17, 2023
af2a948
golf
FR-vdash-bot Sep 18, 2023
70f52f5
golf
FR-vdash-bot Sep 18, 2023
d9c0632
golf
FR-vdash-bot Sep 18, 2023
5734b28
golf
FR-vdash-bot Sep 18, 2023
2815373
fix name
FR-vdash-bot Sep 18, 2023
b1201aa
reduce diffs
FR-vdash-bot Sep 18, 2023
52d35c2
reduce diffs
FR-vdash-bot Sep 18, 2023
c3e983f
reorder
FR-vdash-bot Sep 19, 2023
a3c5bb1
fix
FR-vdash-bot Sep 19, 2023
7a45fcb
missing `#align`
FR-vdash-bot Sep 19, 2023
cd4b649
Merge branch 'master' into FR_game_identical
FR-vdash-bot Jan 24, 2024
f3a25a3
Merge branch 'master' into FR_game_identical
FR-vdash-bot Jun 3, 2024
646abcf
Merge branch 'master' into FR_game_identical
FR-vdash-bot Jul 14, 2024
d93c384
Merge branch 'master' into FR_game_identical
FR-vdash-bot Jul 14, 2024
1fb6bfa
fix
FR-vdash-bot Jul 14, 2024
9cfe585
Update style-exceptions.txt
FR-vdash-bot Jul 14, 2024
4214c48
fix
FR-vdash-bot Jul 14, 2024
f2787cd
more
FR-vdash-bot Jul 15, 2024
2c6625d
Merge branch 'master' into FR_game_identical
hwatheod Jul 20, 2024
3b64d0c
Merge branch 'master' into FR_game_identical
hwatheod Jul 20, 2024
1c82554
refine' -> refine
hwatheod Jul 20, 2024
51997dc
Merge branch 'master' into FR_game_identical
FR-vdash-bot Jul 24, 2024
02857f7
Update PGame.lean
FR-vdash-bot Jul 24, 2024
9faebf8
Update PGame.lean
FR-vdash-bot Jul 24, 2024
4890303
remove `Equiv.ext''`
FR-vdash-bot Jul 24, 2024
ea5291f
docs, golf
FR-vdash-bot Jul 24, 2024
fc1fb21
docs
FR-vdash-bot Jul 24, 2024
34f0137
docs
FR-vdash-bot Jul 27, 2024
f39a50b
Update Basic.lean
FR-vdash-bot Jul 28, 2024
db63470
Merge branch 'master' into FR_game_identical
FR-vdash-bot Aug 3, 2024
e34173e
Merge branch 'master' into FR_game_identical
vihdzp Aug 14, 2024
b1c0c26
Merge branch 'master' into FR_game_identical
FR-vdash-bot Aug 27, 2024
9707644
suggestions
FR-vdash-bot Aug 27, 2024
dc6c71a
more
FR-vdash-bot Aug 27, 2024
18cfc87
more
FR-vdash-bot Aug 27, 2024
5189561
fix
FR-vdash-bot Aug 27, 2024
b3f6aa3
Update PGame.lean
FR-vdash-bot Aug 27, 2024
a47f30e
Update Impartial.lean
FR-vdash-bot Aug 27, 2024
bf0d644
more reduce diffs
FR-vdash-bot Aug 27, 2024
4ff819f
more
FR-vdash-bot Aug 27, 2024
fa76689
Merge branch 'master' into FR_game_identical
FR-vdash-bot Sep 25, 2024
4659495
reduce diffs
FR-vdash-bot Sep 25, 2024
784a1e7
Update PGame.lean
FR-vdash-bot Sep 25, 2024
58c1635
suggestion
FR-vdash-bot Sep 25, 2024
317d91f
lint
FR-vdash-bot Sep 25, 2024
22a1136
Merge branch 'master' into FR_game_identical
FR-vdash-bot Dec 1, 2024
19448c4
Merge branch 'master' into FR_game_identical
FR-vdash-bot Dec 26, 2024
b3b0fce
fix
FR-vdash-bot Dec 29, 2024
456c364
suggestions
FR-vdash-bot Jan 2, 2025
c35994d
Merge branch 'master' into FR_game_identical
FR-vdash-bot Jan 20, 2025
0fc94eb
suggestions
FR-vdash-bot Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 63 additions & 8 deletions Mathlib/SetTheory/Game/Basic.lean
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/-
Copyright (c) 2019 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Reid Barton, Mario Carneiro, Isabel Longbottom, Kim Morrison, Apurva Nakade
Authors: Reid Barton, Mario Carneiro, Isabel Longbottom, Kim Morrison, Apurva Nakade, Yuyang Zhao
-/
import Mathlib.Algebra.Order.Group.Defs
import Mathlib.SetTheory.Game.PGame
Expand All @@ -27,8 +27,6 @@ namespace SetTheory

open Function PGame

open PGame

universe u

-- Porting note: moved the setoid instance to PGame.lean
Expand Down Expand Up @@ -340,25 +338,25 @@ theorem mul_moveRight_inr {x y : PGame} {i j} :
cases y
rfl

-- @[simp] -- Porting note: simpNF linter complains
@[simp]
theorem neg_mk_mul_moveLeft_inl {xl xr yl yr} {xL xR yL yR} {i j} :
(-(mk xl xr xL xR * mk yl yr yL yR)).moveLeft (Sum.inl (i, j)) =
-(xL i * mk yl yr yL yR + mk xl xr xL xR * yR j - xL i * yR j) :=
rfl

-- @[simp] -- Porting note: simpNF linter complains
@[simp]
theorem neg_mk_mul_moveLeft_inr {xl xr yl yr} {xL xR yL yR} {i j} :
(-(mk xl xr xL xR * mk yl yr yL yR)).moveLeft (Sum.inr (i, j)) =
-(xR i * mk yl yr yL yR + mk xl xr xL xR * yL j - xR i * yL j) :=
rfl

-- @[simp] -- Porting note: simpNF linter complains
@[simp]
theorem neg_mk_mul_moveRight_inl {xl xr yl yr} {xL xR yL yR} {i j} :
(-(mk xl xr xL xR * mk yl yr yL yR)).moveRight (Sum.inl (i, j)) =
-(xL i * mk yl yr yL yR + mk xl xr xL xR * yL j - xL i * yL j) :=
rfl

-- @[simp] -- Porting note: simpNF linter complains
@[simp]
theorem neg_mk_mul_moveRight_inr {xl xr yl yr} {xL xR yL yR} {i j} :
(-(mk xl xr xL xR * mk yl yr yL yR)).moveRight (Sum.inr (i, j)) =
-(xR i * mk yl yr yL yR + mk xl xr xL xR * yR j - xR i * yR j) :=
Expand All @@ -380,6 +378,17 @@ theorem rightMoves_mul_cases {x y : PGame} (k) {P : (x * y).RightMoves → Prop}
· apply hl
· apply hr

/-- `x * y` and `y * x` have the same moves. -/
protected lemma mul_comm (x y : PGame) : x * y ≡ y * x :=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small note to maintainers: since the ultimate goal is to replace Relabelling in favor of Identical, this proof is preferrable to the more direct one that makes use of mulCommRelabelling.

match x, y with
| ⟨xl, xr, xL, xR⟩, ⟨yl, yr, yL, yR⟩ => by
refine Identical.of_equiv ((Equiv.prodComm _ _).sumCongr (Equiv.prodComm _ _))
((Equiv.sumComm _ _).trans ((Equiv.prodComm _ _).sumCongr (Equiv.prodComm _ _))) ?_ ?_ <;>
· rintro (⟨_, _⟩ | ⟨_, _⟩) <;>
exact ((((PGame.mul_comm _ (mk _ _ _ _)).add (PGame.mul_comm (mk _ _ _ _) _)).trans
(PGame.add_comm _ _)).sub (PGame.mul_comm _ _))
termination_by (x, y)

/-- `x * y` and `y * x` have the same moves. -/
def mulCommRelabelling (x y : PGame.{u}) : x * y ≡r y * x :=
match x, y with
Expand Down Expand Up @@ -415,6 +424,9 @@ instance isEmpty_rightMoves_mul (x y : PGame.{u})
cases y
assumption

/-- `x * 0` has exactly the same moves as `0`. -/
protected lemma mul_zero (x : PGame) : x * 0 ≡ 0 := identical_zero _

/-- `x * 0` has exactly the same moves as `0`. -/
def mulZeroRelabelling (x : PGame) : x * 0 ≡r 0 :=
Relabelling.isEmpty _
Expand All @@ -427,6 +439,9 @@ theorem mul_zero_equiv (x : PGame) : x * 0 ≈ 0 :=
theorem quot_mul_zero (x : PGame) : (⟦x * 0⟧ : Game) = 0 :=
game_eq x.mul_zero_equiv

/-- `0 * x` has exactly the same moves as `0`. -/
protected lemma zero_mul (x : PGame) : 0 * x ≡ 0 := identical_zero _

/-- `0 * x` has exactly the same moves as `0`. -/
def zeroMulRelabelling (x : PGame) : 0 * x ≡r 0 :=
Relabelling.isEmpty _
Expand Down Expand Up @@ -458,6 +473,23 @@ def negMulRelabelling (x y : PGame.{u}) : -x * y ≡r -(x * y) :=
exact (negMulRelabelling _ _).symm
termination_by (x, y)

/-- `x * -y` and `-(x * y)` have the same moves. -/
@[simp]
lemma mul_neg (x y : PGame) : x * -y = -(x * y) :=
match x, y with
| mk xl xr xL xR, mk yl yr yL yR => by
refine ext rfl rfl ?_ ?_ <;> rintro (⟨i, j⟩ | ⟨i, j⟩) _ ⟨rfl⟩
all_goals
dsimp
rw [PGame.neg_sub', PGame.neg_add]
congr
exacts [mul_neg _ (mk ..), mul_neg .., mul_neg ..]
termination_by (x, y)

/-- `-x * y` and `-(x * y)` have the same moves. -/
lemma neg_mul (x y : PGame) : -x * y ≡ -(x * y) :=
((PGame.mul_comm _ _).trans (of_eq (mul_neg _ _))).trans (PGame.mul_comm _ _).neg

@[simp]
theorem quot_neg_mul (x y : PGame) : (⟦-x * y⟧ : Game) = -⟦x * y⟧ :=
game_eq (negMulRelabelling x y).equiv
Expand All @@ -466,7 +498,6 @@ theorem quot_neg_mul (x y : PGame) : (⟦-x * y⟧ : Game) = -⟦x * y⟧ :=
def mulNegRelabelling (x y : PGame) : x * -y ≡r -(x * y) :=
(mulCommRelabelling x _).trans <| (negMulRelabelling _ x).trans (mulCommRelabelling y x).negCongr

@[simp]
theorem quot_mul_neg (x y : PGame) : ⟦x * -y⟧ = (-⟦x * y⟧ : Game) :=
game_eq (mulNegRelabelling x y).equiv

Expand Down Expand Up @@ -608,6 +639,18 @@ def mulOneRelabelling : ∀ x : PGame.{u}, x * 1 ≡r x
exact (addZeroRelabelling _).trans <|
(((mulOneRelabelling _).addCongr (mulZeroRelabelling _)).trans <| addZeroRelabelling _) }

/-- `1 * x` has the same moves as `x`. -/
protected lemma one_mul : ∀ (x : PGame), 1 * x ≡ x
| ⟨xl, xr, xL, xR⟩ => by
refine Identical.of_equiv ((Equiv.sumEmpty _ _).trans (Equiv.punitProd _))
((Equiv.sumEmpty _ _).trans (Equiv.punitProd _)) ?_ ?_ <;>
· rintro (⟨⟨⟩, _⟩ | ⟨⟨⟩, _⟩)
exact ((((PGame.zero_mul (mk _ _ _ _)).add (PGame.one_mul _)).trans (PGame.zero_add _)).sub
(PGame.zero_mul _)).trans (PGame.sub_zero _)

/-- `x * 1` has the same moves as `x`. -/
protected lemma mul_one (x : PGame) : x * 1 ≡ x := (x.mul_comm _).trans x.one_mul

@[simp]
theorem quot_mul_one (x : PGame) : (⟦x * 1⟧ : Game) = ⟦x⟧ :=
game_eq <| PGame.Relabelling.equiv <| mulOneRelabelling x
Expand Down Expand Up @@ -922,6 +965,13 @@ def inv'Zero : inv' 0 ≡r 1 := by
theorem inv'_zero_equiv : inv' 0 ≈ 1 :=
inv'Zero.equiv

/-- `inv' 1` has exactly the same moves as `1`. -/
lemma inv'_one : inv' 1 ≡ 1 := by
rw [Identical.ext_iff]
constructor
· simp [memₗ_def, inv', isEmpty_subtype]
· simp [memᵣ_def, inv', isEmpty_subtype]

/-- `inv' 1` has exactly the same moves as `1`. -/
def inv'One : inv' 1 ≡r (1 : PGame.{u}) := by
change Relabelling (mk _ _ _ _) 1
Expand Down Expand Up @@ -957,6 +1007,11 @@ theorem inv_eq_of_pos {x : PGame} (h : 0 < x) : x⁻¹ = inv' x := by
theorem inv_eq_of_lf_zero {x : PGame} (h : x ⧏ 0) : x⁻¹ = -inv' (-x) := by
classical exact (if_neg h.not_equiv).trans (if_neg h.not_gt)

/-- `1⁻¹` has exactly the same moves as `1`. -/
lemma inv_one : 1⁻¹ ≡ 1 := by
rw [inv_eq_of_pos PGame.zero_lt_one]
exact inv'_one

/-- `1⁻¹` has exactly the same moves as `1`. -/
def invOne : 1⁻¹ ≡r 1 := by
rw [inv_eq_of_pos PGame.zero_lt_one]
Expand Down
Loading
Loading