-
Notifications
You must be signed in to change notification settings - Fork 254
Expand file tree
/
Copy pathSection_6_1.lean
More file actions
624 lines (495 loc) · 21.8 KB
/
Copy pathSection_6_1.lean
File metadata and controls
624 lines (495 loc) · 21.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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
import Mathlib.Tactic
import Analysis.Section_5_1
import Analysis.Section_5_3
import Analysis.Section_5_epilogue
/-!
# Analysis I, Section 6.1: Convergence and limit laws
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:
- Definition of $`ε`-closeness, $`ε`-steadiness, and their eventual counterparts.
- Notion of a Cauchy sequence, convergent sequence, and bounded sequence of reals.
-/
/- Definition 6.1.1 (Distance). Here we use the Mathlib distance. -/
#check Real.dist_eq
abbrev Real.Close (ε x y : ℝ) : Prop := dist x y ≤ ε
/--
Definition 6.1.2 (ε-close). This is similar to the previous notion of ε-closeness, but where
all quantities are real instead of rational.
-/
theorem Real.close_def (ε x y : ℝ) : ε.Close x y ↔ dist x y ≤ ε := by rfl
namespace Chapter6
/--
Definition 6.1.3 (Sequence). This is similar to the Chapter 5 sequence, except that now the
sequence is real-valued. As with Chapter 5, we start sequences from 0 by default.
-/
@[ext]
structure Sequence where
m : ℤ
seq : ℤ → ℝ
vanish : ∀ n < m, seq n = 0
/-- Sequences can be thought of as functions from {lean}`ℤ` to {lean}`ℝ`. -/
instance Sequence.instCoeFun : CoeFun Sequence (fun _ ↦ ℤ → ℝ) where
coe a := a.seq
@[coe]
abbrev Sequence.ofNatFun (a:ℕ → ℝ) : Sequence :=
{
m := 0
seq n := if n ≥ 0 then a n.toNat else 0
vanish := by simp_all
}
/-- Functions from {lean}`ℕ` to {lean}`ℝ` can be thought of as sequences. -/
instance Sequence.instCoe : Coe (ℕ → ℝ) Sequence where
coe := ofNatFun
abbrev Sequence.mk' (m:ℤ) (a: { n // n ≥ m } → ℝ) : Sequence where
m := m
seq n := if h : n ≥ m then a ⟨n, h⟩ else 0
vanish := by simp_all
lemma Sequence.eval_mk {n m:ℤ} (a: { n // n ≥ m } → ℝ) (h: n ≥ m) :
(Sequence.mk' m a) n = a ⟨ n, h ⟩ := by simp [h]
@[simp]
lemma Sequence.eval_coe (n:ℕ) (a: ℕ → ℝ) : (a:Sequence) n = a n := by simp
/--
{given -show}`n₁, n₀`
{lean}`a.from n₁` starts {lean}`a : Sequence` from {name}`n₁`. It is intended for use when {lean}`n₁ ≥ n₀`, but returns
the "junk" value of the original sequence {name}`a` otherwise.
-/
abbrev Sequence.from (a:Sequence) (m₁:ℤ) : Sequence := mk' (max a.m m₁) (a ↑·)
lemma Sequence.from_eval (a:Sequence) {m₁ n:ℤ} (hn: n ≥ m₁) :
(a.from m₁) n = a n := by
simp [hn]; intros; symm; solve_by_elim [a.vanish]
end Chapter6
/-- Definition 6.1.3 (ε-steady) -/
abbrev Real.Steady (ε: ℝ) (a: Chapter6.Sequence) : Prop :=
∀ n ≥ a.m, ∀ m ≥ a.m, ε.Close (a n) (a m)
/-- Definition 6.1.3 (ε-steady) -/
lemma Real.steady_def (ε: ℝ) (a: Chapter6.Sequence) :
ε.Steady a ↔ ∀ n ≥ a.m, ∀ m ≥ a.m, ε.Close (a n) (a m) := by rfl
/-- Definition 6.1.3 (Eventually ε-steady) -/
abbrev Real.EventuallySteady (ε: ℝ) (a: Chapter6.Sequence) : Prop :=
∃ N ≥ a.m, ε.Steady (a.from N)
/-- Definition 6.1.3 (Eventually ε-steady) -/
lemma Real.eventuallySteady_def (ε: ℝ) (a: Chapter6.Sequence) :
ε.EventuallySteady a ↔ ∃ N, (N ≥ a.m) ∧ ε.Steady (a.from N) := by rfl
/-- For fixed {name}`a`, the function `ε ↦ ε.Steady s` is monotone -/
theorem Real.Steady.mono {a: Chapter6.Sequence} {ε₁ ε₂: ℝ} (hε: ε₁ ≤ ε₂) (hsteady: ε₁.Steady a) :
ε₂.Steady a := by grind
/-- For fixed {name}`a`, the function `ε ↦ ε.EventuallySteady s` is monotone -/
theorem Real.EventuallySteady.mono {a: Chapter6.Sequence} {ε₁ ε₂: ℝ} (hε: ε₁ ≤ ε₂)
(hsteady: ε₁.EventuallySteady a) :
ε₂.EventuallySteady a := by peel 2 hsteady; grind [Steady.mono]
namespace Chapter6
/-- Definition 6.1.3 (Cauchy sequence) -/
abbrev Sequence.IsCauchy (a:Sequence) : Prop := ∀ ε > (0:ℝ), ε.EventuallySteady a
/-- Definition 6.1.3 (Cauchy sequence) -/
lemma Sequence.isCauchy_def (a:Sequence) :
a.IsCauchy ↔ ∀ ε > (0:ℝ), ε.EventuallySteady a := by rfl
/-- This is almost the same as {name}`Chapter5.Sequence.IsCauchy.coe` -/
lemma Sequence.IsCauchy.coe (a:ℕ → ℝ) :
(a:Sequence).IsCauchy ↔ ∀ ε > 0, ∃ N, ∀ j ≥ N, ∀ k ≥ N, dist (a j) (a k) ≤ ε := by
peel with ε hε
constructor
· rintro ⟨ N, hN, h' ⟩
lift N to ℕ using hN; use N
intro j hj k hk
simp [Real.steady_def] at h'
specialize h' j ?_ k ?_ <;> try omega
simp_all
rintro ⟨ N, h' ⟩; refine ⟨ max N 0, by simp, ?_ ⟩
intro n hn m hm; simp at hn hm
have npos : 0 ≤ n := by omega
have mpos : 0 ≤ m := by omega
simp [hn, hm, npos, mpos]
lift n to ℕ using npos
lift m to ℕ using mpos
specialize h' n ?_ m ?_ <;> try grind
lemma Sequence.IsCauchy.mk {n₀:ℤ} (a: {n // n ≥ n₀} → ℝ) :
(mk' n₀ a).IsCauchy
↔ ∀ ε > 0, ∃ N ≥ n₀, ∀ j ≥ N, ∀ k ≥ N, dist (mk' n₀ a j) (mk' n₀ a k) ≤ ε := by
peel with ε hε
constructor
· rintro ⟨ N, hN, h' ⟩; refine ⟨ N, hN, ?_ ⟩
dsimp at hN
intro j hj k hk
simp only [Real.Steady, show max n₀ N = N by omega] at h'
specialize h' j ?_ k ?_ <;> try omega
simp_all [show n₀ ≤ j by omega, show n₀ ≤ k by omega]
rintro ⟨ N, _, _ ⟩; use max n₀ N; grind
@[coe]
abbrev Sequence.ofChapter5Sequence (a: Chapter5.Sequence) : Sequence :=
{
m := a.n₀
seq n := a n
vanish n hn := by simp [a.vanish n hn]
}
instance Chapter5.Sequence.inst_coe_sequence : Coe Chapter5.Sequence Sequence where
coe := Sequence.ofChapter5Sequence
@[simp]
theorem Chapter5.coe_sequence_eval (a: Chapter5.Sequence) (n:ℤ) : (a:Sequence) n = (a n:ℝ) := rfl
theorem Sequence.is_steady_of_rat (ε:ℚ) (a: Chapter5.Sequence) :
ε.Steady a ↔ (ε:ℝ).Steady (a:Sequence) := by sorry
theorem Sequence.is_eventuallySteady_of_rat (ε:ℚ) (a: Chapter5.Sequence) :
ε.EventuallySteady a ↔ (ε:ℝ).EventuallySteady (a:Sequence) := by sorry
/-- Proposition 6.1.4 -/
theorem Sequence.isCauchy_of_rat (a: Chapter5.Sequence) : a.IsCauchy ↔ (a:Sequence).IsCauchy := by
-- This proof is written to follow the structure of the original text.
constructor
swap
. intro h; rw [isCauchy_def] at h
rw [Chapter5.Sequence.isCauchy_def]
intro ε hε
specialize h ε (by positivity)
rwa [is_eventuallySteady_of_rat]
intro h
rw [Chapter5.Sequence.isCauchy_def] at h
rw [isCauchy_def]
intro ε hε
choose ε' hε' hlt using exists_pos_rat_lt hε
specialize h ε' hε'
rw [is_eventuallySteady_of_rat] at h
exact h.mono (le_of_lt hlt)
end Chapter6
/-- Definition 6.1.5 -/
abbrev Real.CloseSeq (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop := ∀ n ≥ a.m, ε.Close (a n) L
/-- Definition 6.1.5 -/
theorem Real.closeSeq_def (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) :
ε.CloseSeq a L ↔ ∀ n ≥ a.m, dist (a n) L ≤ ε := by rfl
/-- Definition 6.1.5 -/
abbrev Real.EventuallyClose (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) : Prop :=
∃ N ≥ a.m, ε.CloseSeq (a.from N) L
/-- Definition 6.1.5 -/
theorem Real.eventuallyClose_def (ε: ℝ) (a: Chapter6.Sequence) (L:ℝ) :
ε.EventuallyClose a L ↔ ∃ N, (N ≥ a.m) ∧ ε.CloseSeq (a.from N) L := by rfl
theorem Real.CloseSeq.coe (ε : ℝ) (a : ℕ → ℝ) (L : ℝ):
(ε.CloseSeq a L) ↔ ∀ n, dist (a n) L ≤ ε := by
constructor
. intro h n; specialize h n; grind
. intro h n hn; lift n to ℕ using (by omega); specialize h n; grind
theorem Real.CloseSeq.mono {a: Chapter6.Sequence} {ε₁ ε₂ L: ℝ} (hε: ε₁ ≤ ε₂)
(hclose: ε₁.CloseSeq a L) :
ε₂.CloseSeq a L := by peel 2 hclose; rw [Real.Close, Real.dist_eq] at *; linarith
theorem Real.EventuallyClose.mono {a: Chapter6.Sequence} {ε₁ ε₂ L: ℝ} (hε: ε₁ ≤ ε₂)
(hclose: ε₁.EventuallyClose a L) :
ε₂.EventuallyClose a L := by peel 2 hclose; grind [CloseSeq.mono]
namespace Chapter6
abbrev Sequence.TendsTo (a:Sequence) (L:ℝ) : Prop :=
∀ ε > (0:ℝ), ε.EventuallyClose a L
theorem Sequence.tendsTo_def (a:Sequence) (L:ℝ) :
a.TendsTo L ↔ ∀ ε > (0:ℝ), ε.EventuallyClose a L := by rfl
/-- Exercise 6.1.2 -/
theorem Sequence.tendsTo_iff (a:Sequence) (L:ℝ) :
a.TendsTo L ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, |a n - L| ≤ ε := by sorry
noncomputable def seq_6_1_6 : Sequence := (fun (n:ℕ) ↦ 1-(10:ℝ)^(-(n:ℤ)-1):Sequence)
/-- Examples 6.1.6 -/
example : (0.1:ℝ).CloseSeq seq_6_1_6 1 := by
rw [seq_6_1_6, Real.CloseSeq.coe]
intro n
rw [Real.dist_eq, abs_sub_comm, abs_of_nonneg (by
rw [sub_nonneg]
rw (occs := .pos [2]) [show (1:ℝ) = 1 - 0 by norm_num]
gcongr
positivity
), sub_sub_cancel, show (0.1:ℝ) = (10:ℝ)^(-1:ℤ) by norm_num]
gcongr <;> grind
/-- Examples 6.1.6 -/
example : ¬ (0.01:ℝ).CloseSeq seq_6_1_6 1 := by
intro h; specialize h 0 (by positivity); simp [seq_6_1_6] at h; norm_num at h
/-- Examples 6.1.6 -/
example : (0.01:ℝ).EventuallyClose seq_6_1_6 1 := by sorry
/-- Examples 6.1.6 -/
example : seq_6_1_6.TendsTo 1 := by sorry
/-- Proposition 6.1.7 (Uniqueness of limits) -/
theorem Sequence.tendsTo_unique (a:Sequence) {L L':ℝ} (h:L ≠ L') :
¬ (a.TendsTo L ∧ a.TendsTo L') := by
-- This proof is written to follow the structure of the original text.
by_contra this
choose hL hL' using this
replace h : L - L' ≠ 0 := by grind
replace h : |L-L'| > 0 := by positivity
set ε := |L-L'| / 3
have hε : ε > 0 := by positivity
rw [tendsTo_iff] at hL hL'
specialize hL ε hε; choose N hN using hL
specialize hL' ε hε; choose M hM using hL'
set n := max N M
specialize hN n (by omega)
specialize hM n (by omega)
have : |L-L'| ≤ 2 * |L-L'|/3 := calc
_ = dist L L' := by rw [Real.dist_eq]
_ ≤ dist L (a.seq n) + dist (a.seq n) L' := dist_triangle _ _ _
_ ≤ ε + ε := by rw [←Real.dist_eq] at hN hM; rw [dist_comm] at hN; gcongr
_ = 2 * |L-L'|/3 := by grind
linarith
/-- Definition 6.1.8 -/
abbrev Sequence.Convergent (a:Sequence) : Prop := ∃ L, a.TendsTo L
/-- Definition 6.1.8 -/
theorem Sequence.convergent_def (a:Sequence) : a.Convergent ↔ ∃ L, a.TendsTo L := by rfl
/-- Definition 6.1.8 -/
abbrev Sequence.Divergent (a:Sequence) : Prop := ¬ a.Convergent
/-- Definition 6.1.8 -/
theorem Sequence.divergent_def (a:Sequence) : a.Divergent ↔ ¬ a.Convergent := by rfl
open Classical in
/--
Definition 6.1.8. We give the limit of a sequence the junk value of {lean}`0` if it is not convergent.
-/
noncomputable abbrev lim (a:Sequence) : ℝ := if h: a.Convergent then h.choose else 0
/-- Definition 6.1.8 -/
theorem Sequence.lim_def {a:Sequence} (h: a.Convergent) : a.TendsTo (lim a) := by
simp [lim, h]; exact h.choose_spec
/-- Definition 6.1.8-/
theorem Sequence.lim_eq {a:Sequence} {L:ℝ} :
a.TendsTo L ↔ a.Convergent ∧ lim a = L := by
constructor
. intro h; by_contra! eq
have : a.Convergent := by rw [convergent_def]; use L
replace eq := a.tendsTo_unique (eq this)
apply lim_def at this; tauto
intro ⟨ h, rfl ⟩; convert lim_def h
/-- Proposition 6.1.11 -/
theorem Sequence.lim_harmonic :
((fun (n:ℕ) ↦ (n+1:ℝ)⁻¹):Sequence).Convergent ∧ lim ((fun (n:ℕ) ↦ (n+1:ℝ)⁻¹):Sequence) = 0 := by
-- This proof is written to follow the structure of the original text.
rw [←lim_eq, tendsTo_iff]
intro ε hε
choose N hN using exists_int_gt (1 / ε); use N; intro n hn
have hNpos : (N:ℝ) > 0 := by apply LT.lt.trans _ hN; positivity
simp at hNpos
have hnpos : n ≥ 0 := by linarith
simp [hnpos, abs_inv]
calc
_ ≤ (N:ℝ)⁻¹ := by
rw [inv_le_inv₀] <;> try positivity
calc
_ ≤ (n:ℝ) := by simp [hn]
_ = (n.toNat:ℤ) := by simp [hnpos]
_ = n.toNat := rfl
_ ≤ (n.toNat:ℝ) + 1 := by linarith
_ ≤ _ := le_abs_self _
_ ≤ ε := by
rw [inv_le_comm₀] <;> try positivity
rw [←inv_eq_one_div _] at hN; order
/-- Proposition 6.1.12 / Exercise 6.1.5 -/
theorem Sequence.IsCauchy.convergent {a:Sequence} (h:a.Convergent) : a.IsCauchy := by
sorry
/-- Example 6.1.13 -/
example : ¬ (0.1:ℝ).EventuallySteady ((fun n ↦ (-1:ℝ)^n):Sequence) := by sorry
/-- Example 6.1.13 -/
example : ¬ ((fun n ↦ (-1:ℝ)^n):Sequence).IsCauchy := by sorry
/-- Example 6.1.13 -/
example : ¬ ((fun n ↦ (-1:ℝ)^n):Sequence).Convergent := by sorry
/-- Proposition 6.1.15 / Exercise 6.1.6 (Formal limits are genuine limits)-/
theorem Sequence.lim_eq_LIM {a:ℕ → ℚ} (h: (a:Chapter5.Sequence).IsCauchy) :
((a:Chapter5.Sequence):Sequence).TendsTo (Chapter5.Real.equivR (Chapter5.LIM a)) := by sorry
/-- Definition 6.1.16 -/
abbrev Sequence.BoundedBy (a:Sequence) (M:ℝ) : Prop :=
∀ n, |a n| ≤ M
/-- Definition 6.1.16 -/
lemma Sequence.boundedBy_def (a:Sequence) (M:ℝ) :
a.BoundedBy M ↔ ∀ n, |a n| ≤ M := by rfl
/-- Definition 6.1.16 -/
abbrev Sequence.IsBounded (a:Sequence) : Prop := ∃ M ≥ 0, a.BoundedBy M
/-- Definition 6.1.16 -/
lemma Sequence.isBounded_def (a:Sequence) :
a.IsBounded ↔ ∃ M ≥ 0, a.BoundedBy M := by rfl
theorem Sequence.bounded_of_cauchy {a:Sequence} (h: a.IsCauchy) : a.IsBounded := by
sorry
/-- Corollary 6.1.17 -/
theorem Sequence.bounded_of_convergent {a:Sequence} (h: a.Convergent) : a.IsBounded := by
sorry
/-- Example 6.1.18 -/
example : ¬ ((fun (n:ℕ) ↦ (n+1:ℝ)):Sequence).IsBounded := by sorry
/-- Example 6.1.18 -/
example : ¬ ((fun (n:ℕ) ↦ (n+1:ℝ)):Sequence).Convergent := by sorry
instance Sequence.inst_add : Add Sequence where
add a b := {
m := min a.m b.m
seq n := a n + b n
vanish n hn := by simp [a.vanish n (by grind), b.vanish n (by grind)]
}
@[simp]
theorem Sequence.add_eval {a b: Sequence} (n:ℤ) : (a + b) n = a n + b n := rfl
theorem Sequence.add_coe (a b: ℕ → ℝ) : (a:Sequence) + (b:Sequence) = (fun n ↦ a n + b n) := by
ext n; rfl
by_cases h:n ≥ 0 <;> simp [h]
/-- Theorem 6.1.19(a) (limit laws). The {name}`Sequence.TendsTo` version is more usable than the {name}`lim` version
in applications. -/
theorem Sequence.tendsTo_add {a b:Sequence} {L M:ℝ} (ha: a.TendsTo L) (hb: b.TendsTo M) :
(a+b).TendsTo (L+M) := by
sorry
theorem Sequence.lim_add {a b:Sequence} (ha: a.Convergent) (hb: b.Convergent) :
(a + b).Convergent ∧ lim (a + b) = lim a + lim b := by
sorry
instance Sequence.inst_mul : Mul Sequence where
mul a b := {
m := min a.m b.m
seq n := a n * b n
vanish n hn := by simp [a.vanish n (by grind), b.vanish n (by grind)]
}
@[simp]
theorem Sequence.mul_eval {a b: Sequence} (n:ℤ) : (a * b) n = a n * b n := rfl
theorem Sequence.mul_coe (a b: ℕ → ℝ) : (a:Sequence) * (b:Sequence) = (fun n ↦ a n * b n) := by
ext n; rfl
by_cases h:n ≥ 0 <;> simp [h]
/-- Theorem 6.1.19(b) (limit laws). The {name}`Sequence.TendsTo` version is more usable than the {name}`lim` version
in applications. -/
theorem Sequence.tendsTo_mul {a b:Sequence} {L M:ℝ} (ha: a.TendsTo L) (hb: b.TendsTo M) :
(a * b).TendsTo (L * M) := by
sorry
theorem Sequence.lim_mul {a b:Sequence} (ha: a.Convergent) (hb: b.Convergent) :
(a * b).Convergent ∧ lim (a * b) = lim a * lim b := by
sorry
instance Sequence.inst_smul : SMul ℝ Sequence where
smul c a := {
m := a.m
seq n := c * a n
vanish n hn := by simp [a.vanish n hn]
}
@[simp]
theorem Sequence.smul_eval {a: Sequence} (c: ℝ) (n:ℤ) : (c • a) n = c * a n := rfl
theorem Sequence.smul_coe (c:ℝ) (a:ℕ → ℝ) : (c • (a:Sequence)) = (fun n ↦ c * a n) := by
ext n; rfl
by_cases h:n ≥ 0 <;> simp [h, HSMul.hSMul, SMul.smul]
/-- Theorem 6.1.19(c) (limit laws). The {name}`Sequence.TendsTo` version is more usable than the {name}`lim` version
in applications. -/
theorem Sequence.tendsTo_smul (c:ℝ) {a:Sequence} {L:ℝ} (ha: a.TendsTo L) :
(c • a).TendsTo (c * L) := by
sorry
theorem Sequence.lim_smul (c:ℝ) {a:Sequence} (ha: a.Convergent) :
(c • a).Convergent ∧ lim (c • a) = c * lim a := by
sorry
instance Sequence.inst_sub : Sub Sequence where
sub a b := {
m := min a.m b.m
seq n := a n - b n
vanish n hn := by simp [a.vanish n (by grind), b.vanish n (by grind)]
}
@[simp]
theorem Sequence.sub_eval {a b: Sequence} (n:ℤ) : (a - b) n = a n - b n := rfl
theorem Sequence.sub_coe (a b: ℕ → ℝ) : (a:Sequence) - (b:Sequence) = (fun n ↦ a n - b n) := by
ext n; rfl
by_cases h:n ≥ 0 <;> simp [h]
/-- Theorem 6.1.19(d) (limit laws). The {name}`Sequence.TendsTo` version is more usable than the {name}`lim` version
in applications. -/
theorem Sequence.tendsTo_sub {a b:Sequence} {L M:ℝ} (ha: a.TendsTo L) (hb: b.TendsTo M) :
(a - b).TendsTo (L - M) := by
sorry
theorem Sequence.LIM_sub {a b:Sequence} (ha: a.Convergent) (hb: b.Convergent) :
(a - b).Convergent ∧ lim (a - b) = lim a - lim b := by
sorry
noncomputable instance Sequence.inst_inv : Inv Sequence where
inv a := {
m := a.m
seq n := (a n)⁻¹
vanish n hn := by simp [a.vanish n hn]
}
@[simp]
theorem Sequence.inv_eval {a: Sequence} (n:ℤ) : (a⁻¹) n = (a n)⁻¹ := rfl
theorem Sequence.inv_coe (a: ℕ → ℝ) : (a:Sequence)⁻¹ = (fun n ↦ (a n)⁻¹) := by
ext n; rfl
by_cases h:n ≥ 0 <;> simp [h]
/-- Theorem 6.1.19(e) (limit laws). The {name}`Sequence.TendsTo` version is more usable than the {name}`lim` version
in applications. -/
theorem Sequence.tendsTo_inv {a:Sequence} {L:ℝ} (ha: a.TendsTo L) (hnon: L ≠ 0) :
(a⁻¹).TendsTo (L⁻¹) := by
sorry
theorem Sequence.lim_inv {a:Sequence} (ha: a.Convergent) (hnon: lim a ≠ 0) :
(a⁻¹).Convergent ∧ lim (a⁻¹) = (lim a)⁻¹ := by
sorry
noncomputable instance Sequence.inst_div : Div Sequence where
div a b := {
m := min a.m b.m
seq n := a n / b n
vanish n hn := by simp [a.vanish n (by grind), b.vanish n (by grind)]
}
@[simp]
theorem Sequence.div_eval {a b: Sequence} (n:ℤ) : (a / b) n = a n / b n := rfl
theorem Sequence.div_coe (a b: ℕ → ℝ) : (a:Sequence) / (b:Sequence) = (fun n ↦ a n / b n) := by
ext n; rfl
by_cases h:n ≥ 0 <;> simp [h]
/-- Theorem 6.1.19(f) (limit laws). The {name}`Sequence.TendsTo` version is more usable than the {name}`lim` version
in applications. -/
theorem Sequence.tendsTo_div {a b:Sequence} {L M:ℝ} (ha: a.TendsTo L) (hb: b.TendsTo M) (hnon: M ≠ 0) :
(a / b).TendsTo (L / M) := by
sorry
theorem Sequence.lim_div {a b:Sequence} (ha: a.Convergent) (hb: b.Convergent) (hnon: lim b ≠ 0) :
(a / b).Convergent ∧ lim (a / b) = lim a / lim b := by
sorry
instance Sequence.inst_max : Max Sequence where
max a b := {
m := min a.m b.m
seq n := max (a n) (b n)
vanish n hn := by simp [a.vanish n (by grind), b.vanish n (by grind)]
}
@[simp]
theorem Sequence.max_eval {a b: Sequence} (n:ℤ) : (a ⊔ b) n = (a n) ⊔ (b n) := rfl
theorem Sequence.max_coe (a b: ℕ → ℝ) : (a:Sequence) ⊔ (b:Sequence) = (fun n ↦ max (a n) (b n)) := by
ext n; rfl
by_cases h:n ≥ 0 <;> simp [h]
/-- Theorem 6.1.19(g) (limit laws). The {name}`Sequence.TendsTo` version is more usable than the {name}`lim` version
in applications. -/
theorem Sequence.tendsTo_max {a b:Sequence} {L M:ℝ} (ha: a.TendsTo L) (hb: b.TendsTo M) :
(max a b).TendsTo (max L M) := by
sorry
theorem Sequence.lim_max {a b:Sequence} (ha: a.Convergent) (hb: b.Convergent) :
(max a b).Convergent ∧ lim (max a b) = max (lim a) (lim b) := by
sorry
instance Sequence.inst_min : Min Sequence where
min a b := {
m := min a.m b.m
seq n := min (a n) (b n)
vanish n hn := by simp [a.vanish n (by grind), b.vanish n (by grind)]
}
@[simp]
theorem Sequence.min_eval {a b: Sequence} (n:ℤ) : (a ⊓ b) n = (a n) ⊓ (b n) := rfl
theorem Sequence.min_coe (a b: ℕ → ℝ) : (a:Sequence) ⊓ (b:Sequence) = (fun n ↦ min (a n) (b n)) := by
ext n; rfl
by_cases h:n ≥ 0 <;> simp [h]
/-- Theorem 6.1.19(h) (limit laws) -/
theorem Sequence.tendsTo_min {a b:Sequence} {L M:ℝ} (ha: a.TendsTo L) (hb: b.TendsTo M) :
(min a b).TendsTo (min L M) := by
sorry
theorem Sequence.lim_min {a b:Sequence} (ha: a.Convergent) (hb: b.Convergent) :
(min a b).Convergent ∧ lim (min a b) = min (lim a) (lim b) := by
sorry
/-- Exercise 6.1.1 -/
theorem Sequence.mono_if {a: ℕ → ℝ} (ha: ∀ n, a (n+1) > a n) {n m:ℕ} (hnm: m > n) : a m > a n := by
sorry
/-- Exercise 6.1.3 -/
theorem Sequence.tendsTo_of_from {a: Sequence} {c:ℝ} (m:ℤ) :
a.TendsTo c ↔ (a.from m).TendsTo c := by
sorry
/-- Exercise 6.1.4 -/
theorem Sequence.tendsTo_of_shift {a: Sequence} {c:ℝ} (k:ℕ) :
a.TendsTo c ↔ (Sequence.mk' a.m (fun n : {n // n ≥ a.m} ↦ a (n+k))).TendsTo c := by
sorry
/-- Exercise 6.1.7 -/
theorem Sequence.isBounded_of_rat (a: Chapter5.Sequence) :
a.IsBounded ↔ (a:Sequence).IsBounded := by
sorry
/-- Exercise 6.1.9 -/
theorem Sequence.lim_div_fail :
∃ a b, a.Convergent
∧ b.Convergent
∧ lim b = 0
∧ ¬ ((a / b).Convergent ∧ lim (a / b) = lim a / lim b) := by
sorry
theorem Chapter5.Sequence.IsCauchy_iff (a:Chapter5.Sequence) :
a.IsCauchy ↔ ∀ ε > (0:ℝ), ∃ N ≥ a.n₀, ∀ n ≥ N, ∀ m ≥ N, |a n - a m| ≤ ε := by
sorry
end Chapter6
-- additional definitions for exercise 6.1.10
abbrev Real.SeqCloseSeq (ε: ℝ) (a b: Chapter5.Sequence) : Prop :=
∀ n, n ≥ a.n₀ → n ≥ b.n₀ → ε.Close (a n) (b n)
abbrev Real.SeqEventuallyClose (ε: ℝ) (a b: Chapter5.Sequence): Prop :=
∃ N, ε.SeqCloseSeq (a.from N) (b.from N)
-- extended definition of rational sequences equivalence but with positive real ε
abbrev Chapter5.Sequence.RatEquiv (a b: ℕ → ℚ) : Prop :=
∀ (ε:ℝ), ε > 0 → ε.SeqEventuallyClose (a:Chapter5.Sequence) (b:Chapter5.Sequence)
namespace Chapter6
/-- Exercise 6.1.10 -/
theorem Chapter5.Sequence.equiv_rat (a b: ℕ → ℚ) :
Chapter5.Sequence.Equiv a b ↔ Chapter5.Sequence.RatEquiv a b := by sorry
end Chapter6