@@ -25,13 +25,12 @@ open scoped PGame
25
25
namespace PGame
26
26
27
27
/-- The definition for an impartial game, defined using Conway induction. -/
28
- def ImpartialAux : PGame → Prop
29
- | G => (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j)
30
- termination_by G => G -- Porting note: Added `termination_by`
28
+ def ImpartialAux (G : PGame) : Prop :=
29
+ (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j)
30
+ termination_by G
31
31
32
- theorem impartialAux_def {G : PGame} :
33
- G.ImpartialAux ↔
34
- (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j) := by
32
+ theorem impartialAux_def {G : PGame} : G.ImpartialAux ↔
33
+ (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j) := by
35
34
rw [ImpartialAux]
36
35
37
36
/-- A typeclass on impartial games. -/
@@ -47,18 +46,20 @@ theorem impartial_def {G : PGame} :
47
46
48
47
namespace Impartial
49
48
50
- instance impartial_zero : Impartial 0 := by rw [impartial_def]; dsimp; simp
49
+ instance impartial_zero : Impartial 0 := by
50
+ rw [impartial_def]
51
+ simp
51
52
52
53
instance impartial_star : Impartial star := by
53
- rw [impartial_def]; simpa using Impartial.impartial_zero
54
+ rw [impartial_def]
55
+ simpa using Impartial.impartial_zero
54
56
55
57
theorem neg_equiv_self (G : PGame) [h : G.Impartial] : G ≈ -G :=
56
58
(impartial_def.1 h).1
57
59
58
- -- Porting note: Changed `-⟦G⟧` to `-(⟦G⟧ : Quotient setoid)`
59
60
@[simp]
60
- theorem mk'_neg_equiv_self (G : PGame) [G.Impartial] : -(⟦G⟧ : Quotient setoid ) = ⟦G⟧ :=
61
- Quot.sound (Equiv.symm (neg_equiv_self G))
61
+ theorem mk'_neg_equiv_self (G : PGame) [G.Impartial] : -(⟦G⟧ : Game ) = ⟦G⟧ :=
62
+ game_eq (Equiv.symm (neg_equiv_self G))
62
63
63
64
instance moveLeft_impartial {G : PGame} [h : G.Impartial] (i : G.LeftMoves) :
64
65
(G.moveLeft i).Impartial :=
@@ -68,49 +69,47 @@ instance moveRight_impartial {G : PGame} [h : G.Impartial] (j : G.RightMoves) :
68
69
(G.moveRight j).Impartial :=
69
70
(impartial_def.1 h).2 .2 j
70
71
71
- theorem impartial_congr : ∀ {G H : PGame} (_ : G ≡r H) [G.Impartial], H.Impartial
72
- | G, H => fun e => by
73
- intro h
74
- exact impartial_def.2
75
- ⟨Equiv.trans e.symm.equiv (Equiv.trans (neg_equiv_self G) (neg_equiv_neg_iff.2 e.equiv)),
76
- fun i => impartial_congr (e.moveLeftSymm i), fun j => impartial_congr (e.moveRightSymm j)⟩
77
- termination_by G H => (G, H)
78
-
79
- instance impartial_add : ∀ (G H : PGame) [G.Impartial] [H.Impartial], (G + H).Impartial
80
- | G, H, _, _ => by
81
- rw [impartial_def]
82
- refine ⟨Equiv.trans (add_congr (neg_equiv_self G) (neg_equiv_self _))
83
- (Equiv.symm (negAddRelabelling _ _).equiv), fun k => ?_, fun k => ?_⟩
84
- · apply leftMoves_add_cases k
85
- all_goals
86
- intro i; simp only [add_moveLeft_inl, add_moveLeft_inr]
87
- apply impartial_add
88
- · apply rightMoves_add_cases k
89
- all_goals
90
- intro i; simp only [add_moveRight_inl, add_moveRight_inr]
91
- apply impartial_add
92
- termination_by G H => (G, H)
93
-
94
- instance impartial_neg : ∀ (G : PGame) [G.Impartial], (-G).Impartial
95
- | G, _ => by
96
- rw [impartial_def]
97
- refine ⟨?_, fun i => ?_, fun i => ?_⟩
98
- · rw [neg_neg]
99
- exact Equiv.symm (neg_equiv_self G)
100
- · rw [moveLeft_neg']
101
- apply impartial_neg
102
- · rw [moveRight_neg']
103
- apply impartial_neg
104
- termination_by G => G
72
+ theorem impartial_congr {G H : PGame} (e : G ≡r H) [G.Impartial] : H.Impartial :=
73
+ impartial_def.2
74
+ ⟨Equiv.trans e.symm.equiv (Equiv.trans (neg_equiv_self G) (neg_equiv_neg_iff.2 e.equiv)),
75
+ fun i => impartial_congr (e.moveLeftSymm i), fun j => impartial_congr (e.moveRightSymm j)⟩
76
+ termination_by G
77
+
78
+ instance impartial_add (G H : PGame) [G.Impartial] [H.Impartial] : (G + H).Impartial := by
79
+ rw [impartial_def]
80
+ refine ⟨Equiv.trans (add_congr (neg_equiv_self G) (neg_equiv_self _))
81
+ (Equiv.symm (negAddRelabelling _ _).equiv), fun k => ?_, fun k => ?_⟩
82
+ · apply leftMoves_add_cases k
83
+ all_goals
84
+ intro i; simp only [add_moveLeft_inl, add_moveLeft_inr]
85
+ apply impartial_add
86
+ · apply rightMoves_add_cases k
87
+ all_goals
88
+ intro i; simp only [add_moveRight_inl, add_moveRight_inr]
89
+ apply impartial_add
90
+ termination_by (G, H)
91
+
92
+ instance impartial_neg (G : PGame) [G.Impartial] : (-G).Impartial := by
93
+ rw [impartial_def]
94
+ refine ⟨?_, fun i => ?_, fun i => ?_⟩
95
+ · rw [neg_neg]
96
+ exact Equiv.symm (neg_equiv_self G)
97
+ · rw [moveLeft_neg']
98
+ exact impartial_neg _
99
+ · rw [moveRight_neg']
100
+ exact impartial_neg _
101
+ termination_by G
105
102
106
103
variable (G : PGame) [Impartial G]
107
104
108
- theorem nonpos : ¬0 < G := fun h => by
105
+ theorem nonpos : ¬0 < G := by
106
+ intro h
109
107
have h' := neg_lt_neg_iff.2 h
110
108
rw [neg_zero, lt_congr_left (Equiv.symm (neg_equiv_self G))] at h'
111
109
exact (h.trans h').false
112
110
113
- theorem nonneg : ¬G < 0 := fun h => by
111
+ theorem nonneg : ¬G < 0 := by
112
+ intro h
114
113
have h' := neg_lt_neg_iff.2 h
115
114
rw [neg_zero, lt_congr_right (Equiv.symm (neg_equiv_self G))] at h'
116
115
exact (h.trans h').false
@@ -134,22 +133,19 @@ theorem not_fuzzy_zero_iff : ¬G ‖ 0 ↔ (G ≈ 0) :=
134
133
theorem add_self : G + G ≈ 0 :=
135
134
Equiv.trans (add_congr_left (neg_equiv_self G)) (neg_add_cancel_equiv G)
136
135
137
- -- Porting note: Changed `⟦G⟧` to `(⟦G⟧ : Quotient setoid)`
138
136
@[simp]
139
- theorem mk'_add_self : (⟦G⟧ : Quotient setoid ) + ⟦G⟧ = 0 :=
140
- Quot.sound (add_self G)
137
+ theorem mk'_add_self : (⟦G⟧ : Game ) + ⟦G⟧ = 0 :=
138
+ game_eq (add_self G)
141
139
142
140
/-- This lemma doesn't require `H` to be impartial. -/
143
141
theorem equiv_iff_add_equiv_zero (H : PGame) : (H ≈ G) ↔ (H + G ≈ 0 ) := by
144
- rw [equiv_iff_game_eq, ← @add_right_cancel_iff _ _ _ ⟦G⟧, mk'_add_self, ← quot_add,
145
- equiv_iff_game_eq]
146
- rfl
142
+ rw [equiv_iff_game_eq, ← add_right_cancel_iff (a := ⟦G⟧), mk'_add_self, ← quot_add,
143
+ equiv_iff_game_eq, quot_zero]
147
144
148
145
/-- This lemma doesn't require `H` to be impartial. -/
149
146
theorem equiv_iff_add_equiv_zero' (H : PGame) : (G ≈ H) ↔ (G + H ≈ 0 ) := by
150
- rw [equiv_iff_game_eq, ← @add_left_cancel_iff _ _ _ ⟦G⟧, mk'_add_self, ← quot_add,
151
- equiv_iff_game_eq]
152
- exact ⟨Eq.symm, Eq.symm⟩
147
+ rw [equiv_iff_game_eq, ← add_left_cancel_iff, mk'_add_self, ← quot_add, equiv_iff_game_eq,
148
+ Eq.comm, quot_zero]
153
149
154
150
theorem le_zero_iff {G : PGame} [G.Impartial] : G ≤ 0 ↔ 0 ≤ G := by
155
151
rw [← zero_le_neg_iff, le_congr_right (neg_equiv_self G)]
0 commit comments