Skip to content

Commit fee0c69

Browse files
eupruninu
andauthored
chore: avoid deprecated notation (∑ x in s, f x and ∏ x in s, f x) (#289)
Co-authored-by: u <u@h>
1 parent 0830fb0 commit fee0c69

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

MIL/C05_Elementary_Number_Theory/S02_Induction_and_Recursion.lean

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,16 @@ open BigOperators
198198
open Finset
199199

200200
-- EXAMPLES:
201-
example : s.sum f = ∑ x in s, f x :=
201+
example : s.sum f = ∑ x s, f x :=
202202
rfl
203203

204-
example : s.prod f = ∏ x in s, f x :=
204+
example : s.prod f = ∏ x s, f x :=
205205
rfl
206206

207-
example : (range n).sum f = ∑ x in range n, f x :=
207+
example : (range n).sum f = ∑ x range n, f x :=
208208
rfl
209209

210-
example : (range n).prod f = ∏ x in range n, f x :=
210+
example : (range n).prod f = ∏ x range n, f x :=
211211
rfl
212212
-- QUOTE.
213213

@@ -217,16 +217,16 @@ provide a recursive description of summation up to :math:`n`,
217217
and similarly for products.
218218
EXAMPLES: -/
219219
-- QUOTE:
220-
example (f : ℕ → ℕ) : ∑ x in range 0, f x = 0 :=
220+
example (f : ℕ → ℕ) : ∑ x range 0, f x = 0 :=
221221
Finset.sum_range_zero f
222222

223-
example (f : ℕ → ℕ) (n : ℕ) : ∑ x in range n.succ, f x = ∑ x in range n, f x + f n :=
223+
example (f : ℕ → ℕ) (n : ℕ) : ∑ x range n.succ, f x = ∑ x range n, f x + f n :=
224224
Finset.sum_range_succ f n
225225

226-
example (f : ℕ → ℕ) : ∏ x in range 0, f x = 1 :=
226+
example (f : ℕ → ℕ) : ∏ x range 0, f x = 1 :=
227227
Finset.prod_range_zero f
228228

229-
example (f : ℕ → ℕ) (n : ℕ) : ∏ x in range n.succ, f x = (∏ x in range n, f x) * f n :=
229+
example (f : ℕ → ℕ) (n : ℕ) : ∏ x range n.succ, f x = (∏ x range n, f x) * f n :=
230230
Finset.prod_range_succ f n
231231
-- QUOTE.
232232

@@ -237,7 +237,7 @@ you can replace the proofs by ``rfl``.
237237
The following expresses the factorial function that we defined as a product.
238238
EXAMPLES: -/
239239
-- QUOTE:
240-
example (n : ℕ) : fac n = ∏ i in range n, (i + 1) := by
240+
example (n : ℕ) : fac n = ∏ i range n, (i + 1) := by
241241
induction' n with n ih
242242
· simp [fac, prod_range_zero]
243243
simp [fac, ih, prod_range_succ, mul_comm]
@@ -276,7 +276,7 @@ because calculations with division generally have side conditions.
276276
(It is similarly useful to avoid using subtraction on the natural numbers when possible.)
277277
EXAMPLES: -/
278278
-- QUOTE:
279-
theorem sum_id (n : ℕ) : ∑ i in range (n + 1), i = n * (n + 1) / 2 := by
279+
theorem sum_id (n : ℕ) : ∑ i range (n + 1), i = n * (n + 1) / 2 := by
280280
symm; apply Nat.div_eq_of_eq_mul_right (by norm_num : 0 < 2)
281281
induction' n with n ih
282282
· simp
@@ -289,7 +289,7 @@ We encourage you to prove the analogous identity for sums of squares,
289289
and other identities you can find on the web.
290290
BOTH: -/
291291
-- QUOTE:
292-
theorem sum_sqr (n : ℕ) : ∑ i in range (n + 1), i ^ 2 = n * (n + 1) * (2 * n + 1) / 6 := by
292+
theorem sum_sqr (n : ℕ) : ∑ i range (n + 1), i ^ 2 = n * (n + 1) * (2 * n + 1) / 6 := by
293293
/- EXAMPLES:
294294
sorry
295295
SOLUTIONS: -/

MIL/C05_Elementary_Number_Theory/S03_Infinitely_Many_Primes.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ end
272272
/- TEXT:
273273
The theorem ``Finset.dvd_prod_of_mem`` tells us that if an
274274
``n`` is an element of a finite set ``s``, then ``n`` divides
275-
``∏ i in s, i``.
275+
``∏ i s, i``.
276276
EXAMPLES: -/
277277
-- QUOTE:
278-
example (s : Finset ℕ) (n : ℕ) (h : n ∈ s) : n ∣ ∏ i in s, i :=
278+
example (s : Finset ℕ) (n : ℕ) (h : n ∈ s) : n ∣ ∏ i s, i :=
279279
Finset.dvd_prod_of_mem _ h
280280
-- QUOTE.
281281

@@ -318,7 +318,7 @@ and then finish it off.
318318
BOTH: -/
319319
-- QUOTE:
320320
theorem mem_of_dvd_prod_primes {s : Finset ℕ} {p : ℕ} (prime_p : p.Prime) :
321-
(∀ n ∈ s, Nat.Prime n) → (p ∣ ∏ n in s, n) → p ∈ s := by
321+
(∀ n ∈ s, Nat.Prime n) → (p ∣ ∏ n s, n) → p ∈ s := by
322322
intro h₀ h₁
323323
induction' s using Finset.induction_on with a s ans ih
324324
· simp at h₁
@@ -372,7 +372,7 @@ theorem primes_infinite' : ∀ s : Finset Nat, ∃ p, Nat.Prime p ∧ p ∉ s :=
372372
intro n
373373
simp [s'_def]
374374
apply h
375-
have : 2 ≤ (∏ i in s', i) + 1 := by
375+
have : 2 ≤ (∏ i s', i) + 1 := by
376376
/- EXAMPLES:
377377
sorry
378378
SOLUTIONS: -/
@@ -383,7 +383,7 @@ SOLUTIONS: -/
383383
apply (mem_s'.mp ns').pos
384384
-- BOTH:
385385
rcases exists_prime_factor this with ⟨p, pp, pdvd⟩
386-
have : p ∣ ∏ i in s', i := by
386+
have : p ∣ ∏ i s', i := by
387387
/- EXAMPLES:
388388
sorry
389389
SOLUTIONS: -/
@@ -595,7 +595,7 @@ theorem primes_mod_4_eq_3_infinite : ∀ n, ∃ p > n, Nat.Prime p ∧ p % 4 = 3
595595
rcases hn with ⟨p, ⟨pp, p4⟩, pltn⟩
596596
exact ⟨p, pltn, pp, p4⟩
597597
rcases this with ⟨s, hs⟩
598-
have h₁ : ((4 * ∏ i in erase s 3, i) + 3) % 4 = 3 := by
598+
have h₁ : ((4 * ∏ i erase s 3, i) + 3) % 4 = 3 := by
599599
/- EXAMPLES:
600600
sorry
601601
SOLUTIONS: -/
@@ -624,7 +624,7 @@ SOLUTIONS: -/
624624
tauto
625625
simp at this
626626
-- BOTH:
627-
have : p ∣ 4 * ∏ i in erase s 3, i := by
627+
have : p ∣ 4 * ∏ i erase s 3, i := by
628628
/- EXAMPLES:
629629
sorry
630630
SOLUTIONS: -/

MIL/C10_Topology/S02_Metric_Spaces.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ theorem cauchySeq_of_le_geometric_two' {u : ℕ → X}
430430
obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn
431431
calc
432432
dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := sorry
433-
_ ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) := sorry
434-
_ ≤ ∑ i in range k, (1 / 2 : ℝ) ^ (N + i) := sorry
435-
_ = 1 / 2 ^ N * ∑ i in range k, (1 / 2 : ℝ) ^ i := sorry
433+
_ ≤ ∑ i range k, dist (u (N + i)) (u (N + (i + 1))) := sorry
434+
_ ≤ ∑ i range k, (1 / 2 : ℝ) ^ (N + i) := sorry
435+
_ = 1 / 2 ^ N * ∑ i range k, (1 / 2 : ℝ) ^ i := sorry
436436
_ ≤ 1 / 2 ^ N * 2 := sorry
437437
_ < ε := sorry
438438

@@ -456,10 +456,10 @@ example {u : ℕ → X} (hu : ∀ n : ℕ, dist (u n) (u (n + 1)) ≤ (1 / 2) ^
456456
obtain ⟨k, rfl : n = N + k⟩ := le_iff_exists_add.mp hn
457457
calc
458458
dist (u (N + k)) (u N) = dist (u (N + 0)) (u (N + k)) := by rw [dist_comm, add_zero]
459-
_ ≤ ∑ i in range k, dist (u (N + i)) (u (N + (i + 1))) :=
459+
_ ≤ ∑ i range k, dist (u (N + i)) (u (N + (i + 1))) :=
460460
(dist_le_range_sum_dist (fun i ↦ u (N + i)) k)
461-
_ ≤ ∑ i in range k, (1 / 2 : ℝ) ^ (N + i) := (sum_le_sum fun i _ ↦ hu <| N + i)
462-
_ = 1 / 2 ^ N * ∑ i in range k, (1 / 2 : ℝ) ^ i := by simp_rw [← one_div_pow, pow_add, ← mul_sum]
461+
_ ≤ ∑ i range k, (1 / 2 : ℝ) ^ (N + i) := (sum_le_sum fun i _ ↦ hu <| N + i)
462+
_ = 1 / 2 ^ N * ∑ i range k, (1 / 2 : ℝ) ^ i := by simp_rw [← one_div_pow, pow_add, ← mul_sum]
463463
_ ≤ 1 / 2 ^ N * 2 :=
464464
(mul_le_mul_of_nonneg_left (sum_geometric_two_le _)
465465
(one_div_nonneg.mpr (pow_nonneg (zero_le_two : (0 : ℝ) ≤ 2) _)))

0 commit comments

Comments
 (0)