Skip to content

Commit 9b58285

Browse files
committed
refactor: simplify code in PentagonalNumbers
1 parent 106c1fb commit 9b58285

1 file changed

Lines changed: 11 additions & 21 deletions

File tree

Mathlib/Combinatorics/Enumerative/PentagonalNumbers.lean

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/-
2-
Copyright (c) 2025 Beibei Xiong.
2+
Copyright (c) 2025 Beibei Xiong. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Beibei Xiong
55
-/
@@ -149,15 +149,10 @@ theorem exists_j_iff_exists_j_in_range (n : ℕ) :
149149
have h_nezero : (2 : ℤ) ≠ 0 := by norm_num
150150
refine Int.add_nonneg_iff_neg_le.mp ?_
151151
· by_cases hj : j > 0
152-
· refine Int.add_nonneg ?_ ?_
153-
linarith
154-
refine Int.add_nonneg ?_ ?_
155-
refine (ediv_nonneg_iff_of_pos ?_).mpr ?_
156-
linarith
157-
refine Int.mul_nonneg ?_ ?_
158-
linarith
159-
linarith
160-
linarith
152+
· refine Int.add_nonneg (by linarith) ?_
153+
· refine Int.add_nonneg ?_ (by linarith)
154+
· refine (ediv_nonneg_iff_of_pos (by linarith)).mpr ?_
155+
refine Int.mul_nonneg (by linarith) (by linarith)
161156
· have hle : j ≤ 0 := by linarith
162157
by_cases hj1 : j = 0
163158
· rw [hj1]
@@ -176,14 +171,13 @@ theorem exists_j_iff_exists_j_in_range (n : ℕ) :
176171
ring
177172

178173
rw [← add_assoc, h_bound1]
179-
refine Int.add_nonneg ?_ ?_
180-
refine (ediv_nonneg_iff_of_pos ?_).mpr ?_
181-
omega
174+
refine Int.add_nonneg (?_) (by linarith)
175+
refine (ediv_nonneg_iff_of_pos (by omega)).mpr ?_
182176
have h: 0 < j * (3 * j + 1) := by
183177
refine Int.mul_pos_of_neg_of_neg hj2 ?_
184178
linarith
185179
linarith
186-
omega
180+
187181

188182
have h_bound2 : j ≤ j * (3 * j - 1) / 2 + 1 := by
189183
have h_nezero : (2 : ℤ) ≠ 0 := by norm_num
@@ -203,9 +197,8 @@ theorem exists_j_iff_exists_j_in_range (n : ℕ) :
203197
ring
204198

205199
rw [h_aux]
206-
refine Int.add_nonneg ?_ ?_
207-
refine (ediv_nonneg_iff_of_pos ?_).mpr ?_
208-
omega
200+
refine Int.add_nonneg ?_ (by omega)
201+
refine (ediv_nonneg_iff_of_pos (by omega)).mpr ?_
209202
by_cases hj : j < 0
210203
· have hj1 : j - 1 < 0 := by linarith
211204
have h_mul_neg : j * (j - 1) > 0 := by
@@ -217,11 +210,8 @@ theorem exists_j_iff_exists_j_in_range (n : ℕ) :
217210
norm_num
218211
· have hj2 : j > 0 := by omega
219212
have h_mul_pos : 3 * j * (j - 1) ≥ 0 := by
220-
refine Int.mul_nonneg ?_ ?_
221-
linarith
222-
linarith
213+
refine Int.mul_nonneg (by omega) (by linarith)
223214
linarith
224-
linarith
225215
exact ⟨h_bound1, h_bound2⟩
226216

227217
· exact hn

0 commit comments

Comments
 (0)