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

Commit 82b9c42

Browse files
committed
feat(set_theory/game/nim): Mark many lemmas as simp (#13844)
1 parent e104992 commit 82b9c42

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

src/set_theory/game/nim.lean

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ by { rw nim_def, exact λ i, ⟨_, ⟨ordinal.typein_lt_self i, rfl⟩⟩ }
9090
lemma exists_move_left_eq {O : ordinal} : ∀ O' < O, ∃ i, (nim O).move_left i = nim O' :=
9191
by { rw nim_def, exact λ _ h, ⟨(ordinal.principal_seg_out h).top, by simp⟩ }
9292

93-
lemma zero_first_loses : (nim (0 : ordinal)).first_loses :=
93+
@[simp] lemma zero_first_loses : (nim (0 : ordinal)).first_loses :=
9494
begin
9595
rw [impartial.first_loses_symm, nim_def, le_def_lt],
9696
exact ⟨@is_empty_elim (0 : ordinal).out.α _ _, @is_empty_elim pempty _ _⟩
@@ -103,7 +103,7 @@ begin
103103
exact or.inr ⟨(ordinal.principal_seg_out hO).top, by simpa using zero_first_loses.1
104104
end
105105

106-
lemma sum_first_loses_iff_eq (O₁ O₂ : ordinal) : (nim O₁ + nim O₂).first_loses ↔ O₁ = O₂ :=
106+
@[simp] lemma sum_first_loses_iff_eq (O₁ O₂ : ordinal) : (nim O₁ + nim O₂).first_loses ↔ O₁ = O₂ :=
107107
begin
108108
split,
109109
{ contrapose,
@@ -121,10 +121,10 @@ begin
121121
exact impartial.add_self (nim O₁) }
122122
end
123123

124-
lemma sum_first_wins_iff_neq (O₁ O₂ : ordinal) : (nim O₁ + nim O₂).first_wins ↔ O₁ ≠ O₂ :=
124+
@[simp] lemma sum_first_wins_iff_neq (O₁ O₂ : ordinal) : (nim O₁ + nim O₂).first_wins ↔ O₁ ≠ O₂ :=
125125
by rw [iff_not_comm, impartial.not_first_wins, sum_first_loses_iff_eq]
126126

127-
lemma equiv_iff_eq (O₁ O₂ : ordinal) : nim O₁ ≈ nim O₂ ↔ O₁ = O₂ :=
127+
@[simp] lemma equiv_iff_eq (O₁ O₂ : ordinal) : nim O₁ ≈ nim O₂ ↔ O₁ = O₂ :=
128128
⟨λ h, (sum_first_loses_iff_eq _ _).1 $
129129
by rw [first_loses_of_equiv_iff (add_congr h (equiv_refl _)), sum_first_loses_iff_eq],
130130
by { rintro rfl, refl }⟩
@@ -133,17 +133,17 @@ end nim
133133

134134
/-- The Grundy value of an impartial game, the ordinal which corresponds to the game of nim that the
135135
game is equivalent to -/
136-
noncomputable def grundy_value : Π (G : pgame.{u}) [G.impartial], ordinal.{u}
137-
| G := λ hG, by exactI ordinal.mex.{u u} (λ i, grundy_value (G.move_left i))
136+
noncomputable def grundy_value : Π (G : pgame.{u}), ordinal.{u}
137+
| G := ordinal.mex.{u u} (λ i, grundy_value (G.move_left i))
138138
using_well_founded { dec_tac := pgame_wf_tac }
139139

140-
lemma grundy_value_def (G : pgame) [G.impartial] :
140+
lemma grundy_value_def (G : pgame) :
141141
grundy_value G = ordinal.mex.{u u} (λ i, grundy_value (G.move_left i)) :=
142142
by rw grundy_value
143143

144144
/-- The Sprague-Grundy theorem which states that every impartial game is equivalent to a game of
145145
nim, namely the game of nim corresponding to the games Grundy value -/
146-
theorem equiv_nim_grundy_value : ∀ (G : pgame.{u}) [G.impartial], by exactI G ≈ nim (grundy_value G)
146+
theorem equiv_nim_grundy_value : ∀ (G : pgame.{u}) [G.impartial], G ≈ nim (grundy_value G)
147147
| G :=
148148
begin
149149
introI hG,
@@ -182,25 +182,26 @@ begin
182182
end
183183
using_well_founded { dec_tac := pgame_wf_tac }
184184

185-
lemma equiv_nim_iff_grundy_value_eq (G : pgame) [G.impartial] (O : ordinal) :
186-
G ≈ nim O ↔ grundy_value G = O :=
187-
by { intro h, rw ←nim.equiv_iff_eq, exact equiv_trans (equiv_symm (equiv_nim_grundy_value G)) h },
188-
by { rintro rfl, exact equiv_nim_grundy_value G }⟩
185+
@[simp] lemma grundy_value_eq_iff_equiv_nim (G : pgame) [G.impartial] (O : ordinal) :
186+
grundy_value G = O ↔ G ≈ nim O :=
187+
by { rintro rfl, exact equiv_nim_grundy_value G },
188+
by { intro h, rw ←nim.equiv_iff_eq, exact equiv_trans (equiv_symm (equiv_nim_grundy_value G)) h }⟩
189189

190190
lemma nim.grundy_value (O : ordinal.{u}) : grundy_value (nim O) = O :=
191-
by rw ←equiv_nim_iff_grundy_value_eq
191+
by simp
192192

193-
lemma equiv_iff_grundy_value_eq (G H : pgame) [G.impartial] [H.impartial] :
194-
G ≈ H ↔ grundy_value G = grundy_value H :=
195-
(equiv_congr_left.1 (equiv_nim_grundy_value H) _).trans $ equiv_nim_iff_grundy_value_eq _ _
193+
@[simp] lemma grundy_value_eq_iff_equiv (G H : pgame) [G.impartial] [H.impartial] :
194+
grundy_value G = grundy_value H ↔ G ≈ H :=
195+
(grundy_value_eq_iff_equiv_nim _ _).trans (equiv_congr_left.1 (equiv_nim_grundy_value H) _).symm
196196

197-
lemma grundy_value_zero : grundy_value 0 = 0 :=
198-
by rw [(equiv_iff_grundy_value_eq 0 (nim 0)).1 (equiv_symm nim.zero_first_loses), nim.grundy_value]
197+
@[simp] lemma grundy_value_zero : grundy_value 0 = 0 :=
198+
by rw [(grundy_value_eq_iff_equiv 0 (nim 0)).2 (equiv_symm nim.zero_first_loses), nim.grundy_value]
199199

200-
lemma equiv_zero_iff_grundy_value (G : pgame) [G.impartial] : G ≈ 0grundy_value G = 0 :=
201-
by rw [equiv_iff_grundy_value_eq, grundy_value_zero]
200+
@[simp] lemma grundy_value_iff_equiv_zero (G : pgame) [G.impartial] : grundy_value G = 0G ≈ 0 :=
201+
by rw [←grundy_value_eq_iff_equiv, grundy_value_zero]
202202

203-
lemma grundy_value_nim_add_nim (n m : ℕ) : grundy_value (nim.{u} n + nim.{u} m) = nat.lxor n m :=
203+
@[simp] lemma grundy_value_nim_add_nim (n m : ℕ) :
204+
grundy_value (nim.{u} n + nim.{u} m) = nat.lxor n m :=
204205
begin
205206
induction n using nat.strong_induction_on with n hn generalizing m,
206207
induction m using nat.strong_induction_on with m hm,
@@ -271,12 +272,12 @@ begin
271272
end
272273

273274
lemma nim_add_nim_equiv {n m : ℕ} : nim n + nim m ≈ nim (nat.lxor n m) :=
274-
by rw [equiv_nim_iff_grundy_value_eq, grundy_value_nim_add_nim]
275+
by rw [←grundy_value_eq_iff_equiv_nim, grundy_value_nim_add_nim]
275276

276277
lemma grundy_value_add (G H : pgame) [G.impartial] [H.impartial] {n m : ℕ} (hG : grundy_value G = n)
277278
(hH : grundy_value H = m) : grundy_value (G + H) = nat.lxor n m :=
278279
begin
279-
rw [←nim.grundy_value (nat.lxor n m), ←equiv_iff_grundy_value_eq],
280+
rw [←nim.grundy_value (nat.lxor n m), grundy_value_eq_iff_equiv],
280281
refine equiv_trans _ nim_add_nim_equiv,
281282
convert add_congr (equiv_nim_grundy_value G) (equiv_nim_grundy_value H);
282283
simp only [hG, hH]

0 commit comments

Comments
 (0)