-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathSection_8_2.lean
More file actions
504 lines (457 loc) · 23.8 KB
/
Section_8_2.lean
File metadata and controls
504 lines (457 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
import Mathlib.Tactic
import Analysis.Section_7_2
import Analysis.Section_7_3
import Analysis.Section_7_4
import Analysis.Section_8_1
/-!
# Analysis I, Section 8.2: Summation on infinite sets
I have attempted to make the translation as faithful a paraphrasing as possible of the original
text. When there is a choice between a more idiomatic Lean solution and a more faithful
translation, I have generally chosen the latter. In particular, there will be places where the
Lean code could be "golfed" to be more elegant and idiomatic, but I have consciously avoided
doing so.
Main constructions and results of this section:
- Absolute convergence and summation on countably infinite or general sets.
- Connections with Mathlib's {name}`Summable` and {name}`tsum`.
- The Riemann rearrangement theorem.
Some non-trivial API is provided beyond what is given in the textbook in order connect these
notions with existing summation notions.
After this section, the summation notation developed here will be deprecated in favor of Mathlib's API for {name}`Summable` and {name}`tsum`.
-/
namespace Chapter8
open Chapter7 Chapter7.Series Finset Function Filter
/-- Definition 8.2.1 (Series on countable sets). Note that with this definition, functions defined
on finite sets will not be absolutely convergent; one should use {lit}`AbsConvergent'` instead for such
cases.-/
abbrev AbsConvergent {X:Type} (f: X → ℝ) : Prop := ∃ g: ℕ → X, Bijective g ∧ (f ∘ g: Series).absConverges
theorem AbsConvergent.mk {X: Type} {f:X → ℝ} {g:ℕ → X} (h: Bijective g) (hfg: (f ∘ g:Series).absConverges) : AbsConvergent f := by use g
open Classical in
/-- The definition has been chosen to give a sensible value when {name}`X` is finite, even though
{name}`AbsConvergent` is by definition false in this context. -/
noncomputable abbrev Sum {X:Type} (f: X → ℝ) : ℝ := if h: AbsConvergent f then (f ∘ h.choose:Series).sum else
if _hX: Finite X then (∑ x ∈ @univ X (Fintype.ofFinite X), f x) else 0
theorem Sum.of_finite {X:Type} [hX:Finite X] (f:X → ℝ) : Sum f = ∑ x ∈ @Finset.univ X (Fintype.ofFinite X), f x := by
have : ¬ AbsConvergent f := by
by_contra!; choose g hg _ using this
rw [←hg.finite_iff, ←not_infinite_iff_finite] at hX; apply hX; infer_instance
simp [Sum, this, hX]
theorem AbsConvergent.comp {X: Type} {f:X → ℝ} {g:ℕ → X} (h: Bijective g) (hf: AbsConvergent f) : (f ∘ g:Series).absConverges := by
choose g' hbij hconv using hf
choose g'_inv hleft hright using bijective_iff_has_inverse.mp hbij
have hG : Bijective (g'_inv ∘ g) := .comp ⟨hright.injective, hleft.surjective⟩ h
convert (absConverges_of_permute hconv hG).1 using 4 with n
simp [hright (g n.toNat)]
theorem Sum.eq {X: Type} {f:X → ℝ} {g:ℕ → X} (h: Bijective g) (hfg: (f ∘ g:Series).absConverges) : (f ∘ g:Series).convergesTo (Sum f) := by
have : AbsConvergent f := .mk h hfg
simp [Sum, this]
choose hbij hconv using this.choose_spec
set g' := this.choose
choose g'_inv hleft hright using bijective_iff_has_inverse.mp hbij
convert convergesTo_sum (converges_of_absConverges hfg) using 1
have hG : Bijective (g'_inv ∘ g) := .comp ⟨hright.injective, hleft.surjective⟩ h
convert (absConverges_of_permute hconv hG).2 using 4 with _ n
by_cases hn : n ≥ 0 <;> simp [hn, hright (g n.toNat)]
theorem Sum.of_comp {X Y:Type} {f:X → ℝ} (h: AbsConvergent f) {g: Y → X} (hbij: Bijective g) : AbsConvergent (f ∘ g) ∧ Sum f = Sum (f ∘ g) := by
choose g' hbij' hconv' using h
choose g_inv hleft hright using bijective_iff_has_inverse.mp hbij
have hbij_g_inv_g' : Bijective (g_inv ∘ g') := .comp ⟨hright.injective, hleft.surjective⟩ hbij'
have hident : (f ∘ g) ∘ g_inv ∘ g' = f ∘ g' := by ext n; simp [hright (g' n)]
refine ⟨ ⟨ g_inv ∘ g', ⟨ hbij_g_inv_g', by convert hconv' ⟩ ⟩, ?_ ⟩
have h := eq (f := f ∘ g) hbij_g_inv_g' (by convert hconv')
rw [hident] at h
solve_by_elim [convergesTo_uniq, eq]
@[simp]
theorem Finset.Icc_eq_cast (N:ℕ) : Icc 0 (N:ℤ) = map Nat.castEmbedding (.Icc 0 N) := by
ext n; simp; constructor
. intro ⟨ hn, _ ⟩; lift n to ℕ using hn; use n; simp_all
rintro ⟨ _, ⟨ _, rfl ⟩ ⟩; simp_all
theorem Finset.Icc_empty {N:ℤ} (h: ¬ N ≥ 0) : Icc 0 N = ∅ := by
ext; simp; intros; contrapose! h; linarith
/-- Theorem 8.2.2, preliminary version. The arguments here are rearranged slightly from the text. -/
theorem sum_of_sum_of_AbsConvergent_nonneg {f:ℕ × ℕ → ℝ} (hf:AbsConvergent f) (hpos: ∀ n m, 0 ≤ f (n, m)) :
(∀ n, ((fun m ↦ f (n, m)):Series).converges) ∧
(fun n ↦ ((fun m ↦ f (n, m)):Series).sum:Series).convergesTo (Sum f) := by
set L := Sum f
set a : ℕ → Series := fun n ↦ ((fun m ↦ f (n, m)):Series)
have hLpos : 0 ≤ L := by
simp [L, Sum, hf]; apply sum_of_nonneg; intro n; by_cases h: n ≥ 0 <;> simp [h]; grind
have hfinsum (X: Finset (ℕ × ℕ)) : ∑ p ∈ X, f p ≤ L := by sorry
have hfinsum' (n M:ℕ) : (a n).partial M ≤ L := by
simp [a, Series.partial, Finset.Icc_eq_cast]
convert_to ∑ x ∈ .map (Embedding.sectR n ℕ) (.Icc 0 M), f x ≤ L
. simp
solve_by_elim
have hnon (n:ℕ) : (a n).nonneg := by
simp [a, nonneg]; intro m; split_ifs <;> simp [hpos]
have hconv (n:ℕ) : (a n).converges := by
rw [converges_of_nonneg_iff (hnon n)]
use L; intro N; by_cases h: N ≥ 0
. lift N to ℕ using h; solve_by_elim
rw [partial_of_lt (by simp [a]; linarith)]; simp [hLpos]
have (N M:ℤ) : ∑ n ∈ Icc 0 N, (a n.toNat).partial M ≤ L := by
by_cases hN : N ≥ 0; swap
. simp [Finset.Icc_empty hN, hLpos]
lift N to ℕ using hN
by_cases hM : M ≥ 0; swap
. convert hLpos; unfold Series.partial
apply sum_eq_zero; intro n _
simp [a, Finset.Icc_empty hM]
lift M to ℕ using hM
convert_to ∑ x ∈ (Icc 0 N) ×ˢ (.Icc 0 M), f x ≤ L
. simp [a, sum_product, Series.partial]
solve_by_elim
replace (N:ℤ) : ∑ n ∈ Icc 0 N, (a n.toNat).sum ≤ L := by
apply le_of_tendsto' (x := .atTop) (tendsto_finset_sum _ _) (this N)
solve_by_elim [convergesTo_sum]
replace (N:ℤ) : (fun n ↦ (a n).sum:Series).partial N ≤ L := by
convert this N with n hn; simp_all
have hnon' : (fun n ↦ (a n).sum:Series).nonneg := by
intro n; simp; split_ifs
. exact sum_of_nonneg (hnon n.toNat)
simp
have hconv' : (fun n ↦ (a n).sum:Series).converges := by
rw [converges_of_nonneg_iff hnon']; use L
replace : (fun n ↦ (a n).sum:Series).sum ≤ L := le_of_tendsto' (convergesTo_sum hconv') this
replace : (fun n ↦ (a n).sum:Series).sum = L := by
apply le_antisymm this (le_of_forall_sub_le _); intro ε hε
replace : ∃ X, ∑ p ∈ X, f p ≥ L - ε := by
sorry
choose X hX using this
have : ∃ N, ∃ M, X ⊆ (Icc 0 N) ×ˢ (Icc 0 M) := by
sorry
choose N M hX' using this
calc
_ ≤ ∑ p ∈ X, f p := hX
_ ≤ ∑ p ∈ (Icc 0 N) ×ˢ (Icc 0 M), f p := sum_le_sum_of_subset_of_nonneg hX' (by solve_by_elim)
_ = ∑ n ∈ Icc 0 N, ∑ m ∈ Icc 0 M, f (n, m) := sum_product _ _ _
_ ≤ ∑ n ∈ Icc 0 N, (a n).sum := by
apply sum_le_sum; intro n _
convert partial_le_sum_of_nonneg (hnon n) (hconv n) M
simp [a, Series.partial]
_ = (fun n ↦ (a n).sum:Series).partial N := by simp [Series.partial]
_ ≤ _ := partial_le_sum_of_nonneg hnon' hconv' _
simp [a, hconv, ← this, Series.convergesTo_sum hconv']
/-- Theorem 8.2.2, second version -/
theorem sum_of_sum_of_AbsConvergent {f:ℕ × ℕ → ℝ} (hf:AbsConvergent f) :
(∀ n, ((fun m ↦ f (n, m)):Series).absConverges) ∧
(fun n ↦ ((fun m ↦ f (n, m)):Series).sum:Series).convergesTo (Sum f) := by
set fplus := max f 0
set fminus := max (-f) 0
have hfplus_nonneg : ∀ n m, 0 ≤ fplus (n, m) := by intro n m; simp [fplus]
have hfminus_nonneg : ∀ n m, 0 ≤ fminus (n, m) := by intro n m; simp [fminus]
have hdiff : f = fplus - fminus := by sorry
have hfplus_conv : AbsConvergent fplus := by sorry
have hfminus_conv : AbsConvergent fminus := by sorry
choose hfplus_conv' hfplus_sum using sum_of_sum_of_AbsConvergent_nonneg hfplus_conv hfplus_nonneg
choose hfminus_conv' hfminus_sum using sum_of_sum_of_AbsConvergent_nonneg hfminus_conv hfminus_nonneg
split_ands
. intro n
sorry
convert convergesTo.sub hfplus_sum hfminus_sum using 1
. -- encountered surprising difficulty with definitional equivalence here
simp [hdiff]
change (fun n ↦ ((fun m ↦ (fplus - fminus) (n, m)):Series).sum:Series) =
(fun n ↦ ((fun m ↦ fplus (n, m)):Series).sum:Series)
- (fun n ↦ ((fun m ↦ (fminus) (n, m)):Series).sum:Series)
convert_to (fun n ↦ ((fun m ↦ (fplus - fminus) (n, m)):Series).sum:Series) =
(((fun n ↦ ((fun m ↦ fplus (n, m)):Series).sum) - (fun n ↦ ((fun m ↦ (fminus) (n, m)):Series).sum):ℕ → ℝ):Series)
. convert sub_coe _ _
rcongr _ n; simp
convert (sub _ _).2 with m; rfl
split_ifs with h <;> simp [h, HSub.hSub, Sub.sub]
. solve_by_elim
convert hfminus_conv' n.toNat
have ⟨ g, hg, _ ⟩ := hf
have h1 := Sum.eq hg (hf.comp hg)
have hplus := Sum.eq hg (hfplus_conv.comp hg)
have hminus := Sum.eq hg (hfminus_conv.comp hg)
apply convergesTo_uniq h1 _
convert (convergesTo.sub hplus hminus) using 3 with n
split_ifs with h <;> simp [h, hdiff, HSub.hSub, Sub.sub]
/-- Theorem 8.2.2, third version -/
theorem sum_of_sum_of_AbsConvergent' {f:ℕ × ℕ → ℝ} (hf:AbsConvergent f) :
(∀ m, ((fun n ↦ f (n, m)):Series).absConverges) ∧
(fun m ↦ ((fun n ↦ f (n, m)):Series).sum:Series).convergesTo (Sum f) := by
set π: ℕ × ℕ → ℕ × ℕ := fun p ↦ (p.2, p.1)
have hπ: Bijective π := Involutive.bijective (congrFun rfl)
have ⟨ g, hg, hconv ⟩ := hf
convert sum_of_sum_of_AbsConvergent (f := f ∘ π) _ using 2
. exact (Sum.of_comp hf hπ).2
refine ⟨ _, hπ.comp hg, ?_ ⟩
convert hconv using 2
/-- Theorem 8.2.2, fourth version -/
theorem sum_comm {f:ℕ × ℕ → ℝ} (hf:AbsConvergent f) :
(fun n ↦ ((fun m ↦ f (n, m)):Series).sum:Series).sum = (fun m ↦ ((fun n ↦ f (n, m)):Series).sum:Series).sum := by
simp [sum_of_converges (sum_of_sum_of_AbsConvergent hf).2,
sum_of_converges (sum_of_sum_of_AbsConvergent' hf).2]
/-- Lemma 8.2.3 / Exercise 8.2.1 -/
theorem AbsConvergent.iff {X:Type} (hX:CountablyInfinite X) (f : X → ℝ) :
AbsConvergent f ↔ BddAbove ( (fun A ↦ ∑ x ∈ A, |f x|) '' .univ ) := by
sorry
abbrev AbsConvergent' {X:Type} (f: X → ℝ) : Prop := BddAbove ( (fun A ↦ ∑ x ∈ A, |f x|) '' .univ )
theorem AbsConvergent'.of_finite {X:Type} [Finite X] (f:X → ℝ) : AbsConvergent' f := by
have _ := Fintype.ofFinite X
simp [bddAbove_def]; use ∑ x, |f x|; intro A; apply Finset.sum_le_univ_sum_of_nonneg; simp
/-- Not in textbook, but should have been included. -/
theorem AbsConvergent'.of_countable {X:Type} (hX:CountablyInfinite X) {f:X → ℝ} :
AbsConvergent' f ↔ AbsConvergent f := by
constructor
. intro hf; simp [bddAbove_def] at hf; choose L hL using hf
have ⟨ g, hg ⟩ := hX.symm; refine ⟨ g, hg, ?_ ⟩
unfold absConverges; rw [converges_of_nonneg_iff]
. use L; intro N; by_cases hN: N ≥ 0
. lift N to ℕ using hN
set g':= Embedding.mk g hg.1
convert hL (map g' (Icc 0 N))
simp [Series.partial]; rfl
convert hL ∅
simp; apply partial_of_lt; grind
simp [nonneg]
intro n; by_cases h: n ≥ 0 <;> simp [h]
intro hf; rwa [AbsConvergent.iff hX f] at hf
/-- Lemma 8.2.5 / Exercise 8.2.2-/
theorem AbsConvergent'.countable_supp {X:Type} {f:X → ℝ} (hf: AbsConvergent' f) :
AtMostCountable { x | f x ≠ 0 } := by
sorry
/-- Compare with Mathlib's {name}`Summable.subtype`-/
theorem AbsConvergent'.subtype {X:Type} {f:X → ℝ} (hf: AbsConvergent' f) (A: Set X) :
AbsConvergent' (fun x:A ↦ f x) := by
apply BddAbove.mono _ hf
intro z hz; simp at *; choose A hA using hz
use A.map (Embedding.subtype _); simp [hA]
/-- A generalized sum. Note that this will give junk values if {name}`f` is not {name}`AbsConvergent'`. -/
noncomputable abbrev Sum' {X:Type} (f: X → ℝ) : ℝ := Sum (fun x : { x | f x ≠ 0 } ↦ f x)
/-- Not in textbook, but should have been included (the series laws are significantly harder
to establish without this) -/
theorem Sum'.of_finsupp {X:Type} {f:X → ℝ} {A: Finset X} (h: ∀ x ∉ A, f x = 0) : Sum' f = ∑ x ∈ A, f x := by
unfold Sum'
set E := { x | f x ≠ 0 }
have hE : E ⊆ A := by intro _; simp [E]; grind
have hfin : Finite E := Finite.Set.subset _ hE
set E' := E.toFinite.toFinset
rw [Sum.of_finite (fun x:E ↦ f x), ←E'.sum_subtype (by simp [E'])]
replace hE : E' ⊆ A := by aesop
apply sum_subset hE; aesop
/-- Not in textbook, but should have been included (the series laws are significantly harder
to establish without this) -/
theorem Sum'.of_countable_supp {X:Type} {f:X → ℝ} {A: Set X} (hA: CountablyInfinite A)
(hfA : ∀ x ∉ A, f x = 0) (hconv: AbsConvergent' f):
AbsConvergent' (fun x:A ↦ f x) ∧ Sum' f = Sum (fun x:A ↦ f x) := by
-- We can adapt the proof of `AbsConvergent'.of_countable` to establish absolute convergence on A.
have hconv' : AbsConvergent (fun x:A ↦ f x) :=
(AbsConvergent'.of_countable hA).mp (hconv.subtype A)
rw [AbsConvergent'.of_countable hA]
refine ⟨ hconv', ?_ ⟩
set E := { x | f x ≠ 0 }
-- The main challenge here is to relate a sum on E with a sum on A. First, we show containment.
have hE : E ⊆ A := by intro _; simp [E]; by_contra!; aesop
-- Now, we map A back to the natural numbers, thus identifying E with a subset E' of ℕ.
choose g hg using hA.symm
have hsum := Sum.eq hg (hconv'.comp hg)
set E' := { n | ↑(g n) ∈ E }
set ι : E' → E := fun ⟨ n, hn ⟩ ↦ ⟨ g n, by aesop ⟩
have hι: Bijective ι := by
split_ands
. intro ⟨ _, _ ⟩ ⟨ _, _ ⟩ h; simp [ι, E', Subtype.val_inj] at *; exact hg.1 h
. intro ⟨ x, hx ⟩; choose n hn using hg.2 ⟨ _, hE hx ⟩; use ⟨ n, by aesop ⟩; grind
-- The cases of infinite and finite E' are handled separately.
obtain hE' | hE' := Nat.atMostCountable_subset E'
. -- use Nat.monotone_enum_of_infinite to enumerate E'
-- show the partial sums of E' are a subsequence of the partial sums of A
set hinf : Infinite E' := hE'.toInfinite
choose a ha_bij ha_mono using (Nat.monotone_enum_of_infinite E').exists
have : atTop.Tendsto (Nat.cast ∘ Subtype.val ∘ a: ℕ → ℤ) atTop := by
apply tendsto_natCast_atTop_atTop.comp (StrictMono.tendsto_atTop _)
intro _ _ hnm; simp [ha_mono hnm]
apply tendsto_nhds_unique _ (hsum.comp this)
have hconv'' : AbsConvergent (fun x:E ↦ f x) := by
rw [←AbsConvergent'.of_countable]
. exact hconv.subtype E
apply (CountablyInfinite.equiv _).mp hE'; use ι
replace := Sum.eq (hι.comp ha_bij) (hconv''.comp (hι.comp ha_bij))
convert this.comp tendsto_natCast_atTop_atTop using 1; ext N
simp [Series.partial, ι]
calc
_ = ∑ x ∈ .image (Subtype.val ∘ a) (.Icc 0 N), f ↑(g x) := by
symm; apply sum_subset
. intro m hm; simp at hm ⊢; obtain ⟨ n, hn, rfl ⟩ := hm
simp [ha_mono.monotone hn]
intro x hx hx'; simp at hx hx'; contrapose! hx'
choose n hn using (hι.comp ha_bij).2 ⟨ g x, hx' ⟩
simp [ι, Subtype.val_inj] at hn
apply hg.1 at hn; subst hn
use n; simpa [ha_mono.le_iff_le] using hx
_ = _ := by
apply sum_image
intro _ _ _ _ h; simp [Subtype.val_inj] at h; exact ha_bij.1 h
-- When E' is finite, we show that all sufficiently large partial sums of A are equal to
-- the sum of E'.
let hEfin : Finite E := hι.finite_iff.mp hE'
let hE'fintype : Fintype E' := .ofFinite _
let hEfintype : Fintype E := .ofFinite _
apply convergesTo_uniq _ hsum
simp [Sum.of_finite, Series.convergesTo]
apply tendsto_nhds_of_eventually_eq
have hE'bound : BddAbove E' := Set.Finite.bddAbove hE'
rw [bddAbove_def] at hE'bound; choose N hN using hE'bound
rw [eventually_atTop]
use N; intro N' hN'
lift N' to ℕ using (LE.le.trans (by positivity) hN')
simp [Series.partial] at hN' ⊢
calc
_ = ∑ n ∈ E', f (g n) := by
symm; apply sum_subset
. intro x hx; simp at *; linarith [hN _ hx]
intro _ _ hx'; simpa [E',E] using hx'
_ = ∑ n:E', f (g n) := by convert (sum_set_coe _).symm
_ = ∑ n, f (ι n) := sum_congr rfl (by grind)
_ = _ := hι.sum_comp (g := fun x ↦ f x)
/-- Connection with Mathlib's {name}`Summable` property. Some version of this might be suitable
for Mathlib? -/
theorem AbsConvergent'.iff_Summable {X:Type} (f:X → ℝ) : AbsConvergent' f ↔ Summable f := by
simp [←summable_abs_iff, AbsConvergent']
simp [summable_iff_vanishing_norm]
classical
constructor
. intro h ε hε
set s := Set.range fun A ↦ ∑ x ∈ A, |f x|
have hnon : s.Nonempty := by simp [s]; use 0, ∅; simp
have : (sSup s)-ε < sSup s := by linarith
simp [lt_csSup_iff h hnon,s] at this; choose S hS using this
use S; intro T hT
rw [abs_of_nonneg (by positivity)]
have : ∑ x ∈ T, |f x| + ∑ x ∈ S, |f x| ≤ sSup s := by
apply le_csSup h
simp [s]; exact ⟨ T ∪ S, sum_union hT ⟩
linarith
intro h; choose S hS using h 1 (by norm_num)
rw [bddAbove_def]
use ∑ x ∈ S, |f x| + 1; simp; intro T
calc
_ = ∑ x ∈ (T ∩ S), |f x| + ∑ x ∈ (T \ S), |f x| := (sum_inter_add_sum_diff _ _ _).symm
_ ≤ _ := by
gcongr
. exact inter_subset_right
apply le_of_lt (lt_of_abs_lt (hS _ disjoint_sdiff_self_left))
/-- Maybe suitable for porting to Mathlib?-/
theorem Filter.Eventually.int_natCast_atTop (p: ℤ → Prop) :
(∀ᶠ n in .atTop, p n) ↔ ∀ᶠ n:ℕ in .atTop, p ↑n := by
refine ⟨ Eventually.natCast_atTop, ?_ ⟩
simp [eventually_atTop]
intro N hN; use N; intro n hn
lift n to ℕ using (by omega)
simp at hn; solve_by_elim
theorem Filter.Tendsto.int_natCast_atTop {R:Type} (f: ℤ → R) (l: Filter R) :
atTop.Tendsto f l ↔ atTop.Tendsto (f ∘ Nat.cast) l := by
simp [tendsto_iff_eventually]
peel with p h
simp [←eventually_atTop]
convert Eventually.int_natCast_atTop _
/-- Connection with Mathlib's {name}`tsum` (or {kw (of := «termΣ'_,_»)}`Σ'`) operation -/
theorem Sum'.eq_tsum {X:Type} (f:X → ℝ) (h: AbsConvergent' f) :
Sum' f = ∑' x, f x := by
set E := {x | f x ≠ 0}
obtain hE | hE := h.countable_supp
. simp [Sum']
choose g hg using hE.symm
have : ((f ∘ Subtype.val) ∘ g:Series).absConverges := by
apply AbsConvergent.comp hg
rw [←AbsConvergent'.of_countable hE]
exact h.subtype E
replace this := Sum.eq hg this
convert convergesTo_uniq this _ using 1
· replace : ∑' x, f x = ∑' n, f (g n) := calc
_ = ∑' x:E, f x := by
exact (tsum_subtype_eq_of_support_subset (fun x hx => hx)).symm
_ = _ := (Equiv.tsum_eq (Equiv.ofBijective _ hg) _).symm
rw [this]
unfold convergesTo; rw [Filter.Tendsto.int_natCast_atTop]
convert (Summable.tendsto_sum_tsum_nat ?_).comp (tendsto_add_atTop_nat 1) with n
. ext N; simp [Series.partial, Nat.range_succ_eq_Icc_zero]
rw [AbsConvergent'.iff_Summable] at h
exact h.comp_injective (i := Subtype.val ∘ g) (Subtype.val_injective.comp hg.1)
rw [of_finsupp (A := E.toFinite.toFinset)]; symm; apply tsum_eq_sum
all_goals simp [E]
/-- Proposition 8.2.6 (a) (Absolutely convergent series laws) / Exercise 8.2.3 -/
theorem Sum'.add {X:Type} {f g:X → ℝ} (hf: AbsConvergent' f) (hg: AbsConvergent' g) :
AbsConvergent' (f+g) ∧ Sum' (f + g) = Sum' f + Sum' g := by
sorry
/-- Proposition 8.2.6 (b) (Absolutely convergent series laws) / Exercise 8.2.3 -/
theorem Sum'.smul {X:Type} {f:X → ℝ} (hf: AbsConvergent' f) (c: ℝ) :
AbsConvergent' (c • f) ∧ Sum' (c • f) = c * Sum' f := by
sorry
/-- This law is not explicitly stated in Proposition 8.2.6, but follows easily from parts (a) and (b).-/
theorem Sum'.sub {X:Type} {f g:X → ℝ} (hf: AbsConvergent' f) (hg: AbsConvergent' g) :
AbsConvergent' (f-g) ∧ Sum' (f - g) = Sum' f - Sum' g := by
convert add hf (smul hg (-1)).1 using 2
. simp; abel
. congr; simp; abel
rw [(smul hg (-1)).2]; ring
/-- Proposition 8.2.6 (c) (Absolutely convergent series laws) / Exercise 8.2.3. The first
part of this proposition has been moved to {lean}`AbsConvergent'.subtype`. -/
theorem Sum'.of_disjoint_union {X:Type} {f:X → ℝ} (hf: AbsConvergent' f) {X₁ X₂ : Set X} (hdisj: Disjoint X₁ X₂):
Sum' (fun x: (X₁ ∪ X₂: Set X) ↦ f x) = Sum' (fun x : X₁ ↦ f x) + Sum' (fun x : X₂ ↦ f x) := by
sorry
/-- This technical claim, the analogue of {name}`tsum_univ`, is required due to the way Mathlib handles
sets.-/
theorem Sum'.of_univ {X:Type} {f:X → ℝ} (hf: AbsConvergent' f) :
Sum' (fun x: (.univ : Set X) ↦ f x) = Sum' f := by
sorry
theorem Sum'.of_comp {X Y:Type} {f:X → ℝ} (hf: AbsConvergent' f) {φ: Y → X}
(hφ: Function.Bijective φ) :
AbsConvergent' (f ∘ φ) ∧ Sum' f = Sum' (f ∘ φ) := by
sorry
/-- Lemma 8.2.7 / Exercise 8.2.4 -/
theorem divergent_parts_of_divergent {a: ℕ → ℝ} (ha: (a:Series).converges)
(ha': ¬ (a:Series).absConverges) :
¬ AbsConvergent (fun n : {n | a n ≥ 0} ↦ a n) ∧ ¬ AbsConvergent (fun n : {n | a n < 0} ↦ a n)
:= by
sorry
/-- Theorem 8.2.8 (Riemann rearrangement theorem) / Exercise 8.2.5 -/
theorem permute_convergesTo_of_divergent {a: ℕ → ℝ} (ha: (a:Series).converges)
(ha': ¬ (a:Series).absConverges) (L:ℝ) :
∃ f : ℕ → ℕ, Bijective f ∧ (a ∘ f:Series).convergesTo L
:= by
-- This proof is written to follow the structure of the original text.
choose h1 h2 using divergent_parts_of_divergent ha ha'
set A_plus := { n | a n ≥ 0 }
set A_minus := {n | a n < 0 }
have hdisj : Disjoint A_plus A_minus := by
rw [Set.disjoint_iff_inter_eq_empty]; ext; simp [A_plus, A_minus]
have hunion : A_plus ∪ A_minus = .univ := by
ext; simp [A_plus, A_minus]; grind
have hA_plus_inf : Infinite A_plus := sorry
have hA_minus_inf : Infinite A_minus := sorry
obtain ⟨ a_plus, ha_plus_bij, ha_plus_mono ⟩ := (Nat.monotone_enum_of_infinite A_plus).exists
obtain ⟨ a_minus, ha_minus_bij, ha_minus_mono ⟩ := (Nat.monotone_enum_of_infinite A_minus).exists
let F : (n : ℕ) → ((m : ℕ) → m < n → ℕ) → ℕ :=
fun j n' ↦ if ∑ i:Fin j, a (n' i (by simp)) < L then
Nat.min { n ∈ A_plus | ∀ i:Fin j, n ≠ n' i (by simp) }
else
Nat.min { n ∈ A_minus | ∀ i:Fin j, n ≠ n' i (by simp) }
let n' : ℕ → ℕ := Nat.strongRec F
have hn' (j:ℕ) : n' j = if ∑ i:Fin j, a (n' i) < L then
Nat.min { n ∈ A_plus | ∀ i:Fin j, n ≠ n' i }
else
Nat.min { n ∈ A_minus | ∀ i:Fin j, n ≠ n' i }
:= Nat.strongRec.eq_def _ j
have hn'_plus_inf (j:ℕ) : Infinite { n ∈ A_plus | ∀ i:Fin j, n ≠ n' i } := by sorry
have hn'_minus_inf (j:ℕ) : Infinite { n ∈ A_minus | ∀ i:Fin j, n ≠ n' i } := by sorry
have hn'_inj : Injective n' := by sorry
have h_case_I : Infinite { j | ∑ i:Fin j, a (n' i) < L } := by sorry
have h_case_II : Infinite { j | ∑ i:Fin j, a (n' i) ≥ L } := by sorry
have hn'_surj : Surjective n' := by sorry
have hconv : atTop.Tendsto (a ∘ n') (nhds 0) := by sorry
have hsum : (a ∘ n':Series).convergesTo L := by sorry
use n'
refine ⟨ ⟨ hn'_inj, hn'_surj ⟩, ?_ ⟩; convert hsum
/-- Exercise 8.2.6 -/
theorem permute_diverges_of_divergent {a: ℕ → ℝ} (ha: (a:Series).converges)
(ha': ¬ (a:Series).absConverges) :
∃ f : ℕ → ℕ, Bijective f ∧ atTop.Tendsto (fun N ↦ ((a ∘ f:Series).partial N : EReal)) (nhds ⊤) := by
sorry
theorem permute_diverges_of_divergent' {a: ℕ → ℝ} (ha: (a:Series).converges)
(ha': ¬ (a:Series).absConverges) :
∃ f : ℕ → ℕ, Bijective f ∧ atTop.Tendsto (fun N ↦ ((a ∘ f:Series).partial N : EReal)) (nhds ⊥) := by
sorry
end Chapter8