Skip to content

Commit 84fade0

Browse files
committed
refactor: optimize proof about "simp"
1 parent 2c939d2 commit 84fade0

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

Mathlib/Combinatorics/Enumerative/Stirling.lean

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def stirlingFirst : ℕ → ℕ → ℕ
5454
| n + 1, k + 1 => n * stirlingFirst n (k + 1) + stirlingFirst n k
5555

5656
@[simp]
57-
theorem stirlingFirst_zero: stirlingFirst 0 0 = 1 :=
57+
theorem stirlingFirst_zero : stirlingFirst 0 0 = 1 :=
5858
rfl
5959

6060
@[simp]
@@ -88,23 +88,24 @@ theorem stirlingFirst_eq_zero_of_lt : ∀ {n k : ℕ}, n < k → stirlingFirst n
8888
| n + 1, k + 1, hk => by
8989
have hnk : n < k := Nat.lt_of_succ_lt_succ hk
9090
have hnk1 : n < k + 1 := Nat.lt_of_succ_lt hk
91-
simp [stirlingFirst_succ_succ, stirlingFirst_eq_zero_of_lt hnk,
92-
stirlingFirst_eq_zero_of_lt hnk1]
91+
rw [stirlingFirst_succ_succ, stirlingFirst_eq_zero_of_lt hnk,
92+
stirlingFirst_eq_zero_of_lt hnk1, mul_zero]
9393

9494
theorem stirlingFirst_self (n : ℕ) : stirlingFirst n n = 1 := by
95-
induction n <;> simp [*, stirlingFirst, stirlingFirst_eq_zero_of_lt (Nat.lt_succ_self _)]
95+
induction n <;> simp only [*, stirlingFirst, stirlingFirst_eq_zero_of_lt (Nat.lt_succ_self _),
96+
mul_zero]
9697

9798
theorem stirlingFirst_succ_self_left (n : ℕ) : stirlingFirst (n + 1) n = (n + 1).choose 2 := by
9899
induction' n with n ih
99-
· simp
100+
· simp only [zero_add, stirlingFirst_succ_zero, choose_succ_self]
100101
· rw [stirlingFirst_succ_succ, ih, stirlingFirst_self, mul_one, Nat.choose_succ_succ (n + 1),
101102
Nat.choose_one_right]
102103

103104
theorem stirlingFirst_one_right (n : ℕ) : stirlingFirst (n + 1) 1 = n.factorial := by
104105
induction' n with n hn
105106
· rfl
106107
· rw [stirlingFirst_succ_succ, zero_add, hn, stirlingFirst_succ_zero]
107-
simp [Nat.factorial_succ]
108+
simp only [Nat.factorial_succ, add_zero]
108109

109110

110111
/--
@@ -153,11 +154,13 @@ theorem stirlingSecond_eq_zero_of_lt : ∀ {n k : ℕ}, n < k → stirlingSecond
153154
| n + 1, k + 1, hk => by
154155
have hnk : n < k := Nat.lt_of_succ_lt_succ hk
155156
have hnk1 : n < k + 1 := Nat.lt_of_succ_lt hk
156-
simp [stirlingSecond_succ_succ, stirlingSecond_eq_zero_of_lt hnk,
157+
rw [stirlingSecond_succ_succ, stirlingSecond_eq_zero_of_lt hnk,
157158
stirlingSecond_eq_zero_of_lt hnk1]
159+
simp only [mul_zero, add_zero]
158160

159161
theorem stirlingSecond_self (n : ℕ) : stirlingSecond n n = 1 := by
160-
induction n <;> simp [*, stirlingSecond, stirlingSecond_eq_zero_of_lt (lt_succ_self _)]
162+
induction n <;> simp only [*, stirlingSecond, stirlingSecond_eq_zero_of_lt (lt_succ_self _),
163+
mul_zero]
161164

162165
theorem stirlingSecond_one_right (n : ℕ) : stirlingSecond (n + 1) 1 = 1 := by
163166
induction' n with n ih
@@ -167,7 +170,7 @@ theorem stirlingSecond_one_right (n : ℕ) : stirlingSecond (n + 1) 1 = 1 := by
167170
theorem stirlingSecond_succ_self_left (n : ℕ) :
168171
stirlingSecond (n + 1) n = (n + 1).choose 2 := by
169172
induction' n with n ih
170-
· simp
173+
· simp only [zero_add, stirlingSecond_succ_zero, choose_succ_self]
171174
· rw [stirlingSecond_succ_succ, ih, stirlingSecond_self, mul_one,
172175
Nat.choose_succ_succ (n + 1), Nat.choose_one_right]
173176

0 commit comments

Comments
 (0)