| author | blanchet | 
| Thu, 26 Aug 2010 14:58:45 +0200 | |
| changeset 38819 | 71c9f61516cd | 
| parent 36660 | 1cc4ab4b7ff7 | 
| child 41970 | 47d6e13d1710 | 
| permissions | -rw-r--r-- | 
| 10751 | 1  | 
(* Title : Series.thy  | 
2  | 
Author : Jacques D. Fleuriot  | 
|
3  | 
Copyright : 1998 University of Cambridge  | 
|
| 14416 | 4  | 
|
5  | 
Converted to Isar and polished by lcp  | 
|
| 15539 | 6  | 
Converted to setsum and polished yet more by TNN  | 
| 16819 | 7  | 
Additional contributions by Jeremy Avigad  | 
| 10751 | 8  | 
*)  | 
9  | 
||
| 14416 | 10  | 
header{*Finite Summation and Infinite Series*}
 | 
| 10751 | 11  | 
|
| 15131 | 12  | 
theory Series  | 
| 
33271
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
13  | 
imports SEQ Deriv  | 
| 15131 | 14  | 
begin  | 
| 15561 | 15  | 
|
| 19765 | 16  | 
definition  | 
| 20692 | 17  | 
sums :: "(nat \<Rightarrow> 'a::real_normed_vector) \<Rightarrow> 'a \<Rightarrow> bool"  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21141 
diff
changeset
 | 
18  | 
(infixr "sums" 80) where  | 
| 19765 | 19  | 
   "f sums s = (%n. setsum f {0..<n}) ----> s"
 | 
| 10751 | 20  | 
|
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21141 
diff
changeset
 | 
21  | 
definition  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21141 
diff
changeset
 | 
22  | 
summable :: "(nat \<Rightarrow> 'a::real_normed_vector) \<Rightarrow> bool" where  | 
| 19765 | 23  | 
"summable f = (\<exists>s. f sums s)"  | 
| 14416 | 24  | 
|
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21141 
diff
changeset
 | 
25  | 
definition  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
21141 
diff
changeset
 | 
26  | 
suminf :: "(nat \<Rightarrow> 'a::real_normed_vector) \<Rightarrow> 'a" where  | 
| 20688 | 27  | 
"suminf f = (THE s. f sums s)"  | 
| 14416 | 28  | 
|
| 15546 | 29  | 
syntax  | 
| 20692 | 30  | 
  "_suminf" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a" ("\<Sum>_. _" [0, 10] 10)
 | 
| 15546 | 31  | 
translations  | 
| 20770 | 32  | 
"\<Sum>i. b" == "CONST suminf (%i. b)"  | 
| 15546 | 33  | 
|
| 14416 | 34  | 
|
| 
32877
 
6f09346c7c08
New lemmas connected with the reals and infinite series
 
paulson 
parents: 
32707 
diff
changeset
 | 
35  | 
lemma [trans]: "f=g ==> g sums z ==> f sums z"  | 
| 
 
6f09346c7c08
New lemmas connected with the reals and infinite series
 
paulson 
parents: 
32707 
diff
changeset
 | 
36  | 
by simp  | 
| 
 
6f09346c7c08
New lemmas connected with the reals and infinite series
 
paulson 
parents: 
32707 
diff
changeset
 | 
37  | 
|
| 15539 | 38  | 
lemma sumr_diff_mult_const:  | 
39  | 
 "setsum f {0..<n} - (real n*r) = setsum (%i. f i - r) {0..<n::nat}"
 | 
|
| 15536 | 40  | 
by (simp add: diff_minus setsum_addf real_of_nat_def)  | 
41  | 
||
| 15542 | 42  | 
lemma real_setsum_nat_ivl_bounded:  | 
43  | 
"(!!p. p < n \<Longrightarrow> f(p) \<le> K)  | 
|
44  | 
      \<Longrightarrow> setsum f {0..<n::nat} \<le> real n * K"
 | 
|
45  | 
using setsum_bounded[where A = "{0..<n}"]
 | 
|
46  | 
by (auto simp:real_of_nat_def)  | 
|
| 14416 | 47  | 
|
| 15539 | 48  | 
(* Generalize from real to some algebraic structure? *)  | 
49  | 
lemma sumr_minus_one_realpow_zero [simp]:  | 
|
| 15543 | 50  | 
"(\<Sum>i=0..<2*n. (-1) ^ Suc i) = (0::real)"  | 
| 15251 | 51  | 
by (induct "n", auto)  | 
| 14416 | 52  | 
|
| 15539 | 53  | 
(* FIXME this is an awful lemma! *)  | 
54  | 
lemma sumr_one_lb_realpow_zero [simp]:  | 
|
55  | 
"(\<Sum>n=Suc 0..<n. f(n) * (0::real) ^ n) = 0"  | 
|
| 20692 | 56  | 
by (rule setsum_0', simp)  | 
| 14416 | 57  | 
|
| 15543 | 58  | 
lemma sumr_group:  | 
| 15539 | 59  | 
     "(\<Sum>m=0..<n::nat. setsum f {m * k ..< m*k + k}) = setsum f {0 ..< n * k}"
 | 
| 15543 | 60  | 
apply (subgoal_tac "k = 0 | 0 < k", auto)  | 
| 15251 | 61  | 
apply (induct "n")  | 
| 15539 | 62  | 
apply (simp_all add: setsum_add_nat_ivl add_commute)  | 
| 14416 | 63  | 
done  | 
| 15539 | 64  | 
|
| 20692 | 65  | 
lemma sumr_offset3:  | 
66  | 
  "setsum f {0::nat..<n+k} = (\<Sum>m=0..<n. f (m+k)) + setsum f {0..<k}"
 | 
|
67  | 
apply (subst setsum_shift_bounds_nat_ivl [symmetric])  | 
|
68  | 
apply (simp add: setsum_add_nat_ivl add_commute)  | 
|
69  | 
done  | 
|
70  | 
||
| 16819 | 71  | 
lemma sumr_offset:  | 
| 20692 | 72  | 
fixes f :: "nat \<Rightarrow> 'a::ab_group_add"  | 
73  | 
  shows "(\<Sum>m=0..<n. f(m+k)) = setsum f {0..<n+k} - setsum f {0..<k}"
 | 
|
74  | 
by (simp add: sumr_offset3)  | 
|
| 16819 | 75  | 
|
76  | 
lemma sumr_offset2:  | 
|
77  | 
 "\<forall>f. (\<Sum>m=0..<n::nat. f(m+k)::real) = setsum f {0..<n+k} - setsum f {0..<k}"
 | 
|
| 20692 | 78  | 
by (simp add: sumr_offset)  | 
| 16819 | 79  | 
|
80  | 
lemma sumr_offset4:  | 
|
| 20692 | 81  | 
  "\<forall>n f. setsum f {0::nat..<n+k} = (\<Sum>m=0..<n. f (m+k)::real) + setsum f {0..<k}"
 | 
82  | 
by (clarify, rule sumr_offset3)  | 
|
| 16819 | 83  | 
|
84  | 
(*  | 
|
85  | 
lemma sumr_from_1_from_0: "0 < n ==>  | 
|
86  | 
(\<Sum>n=Suc 0 ..< Suc n. if even(n) then 0 else  | 
|
87  | 
((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n =  | 
|
88  | 
(\<Sum>n=0..<Suc n. if even(n) then 0 else  | 
|
89  | 
((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n"  | 
|
90  | 
by (rule_tac n1 = 1 in sumr_split_add [THEN subst], auto)  | 
|
91  | 
*)  | 
|
| 14416 | 92  | 
|
93  | 
subsection{* Infinite Sums, by the Properties of Limits*}
 | 
|
94  | 
||
95  | 
(*----------------------  | 
|
96  | 
suminf is the sum  | 
|
97  | 
---------------------*)  | 
|
98  | 
lemma sums_summable: "f sums l ==> summable f"  | 
|
99  | 
by (simp add: sums_def summable_def, blast)  | 
|
100  | 
||
101  | 
lemma summable_sums: "summable f ==> f sums (suminf f)"  | 
|
| 20688 | 102  | 
apply (simp add: summable_def suminf_def sums_def)  | 
| 
36660
 
1cc4ab4b7ff7
make (X ----> L) an abbreviation for (X ---> L) sequentially
 
huffman 
parents: 
36657 
diff
changeset
 | 
103  | 
apply (fast intro: theI LIMSEQ_unique)  | 
| 14416 | 104  | 
done  | 
105  | 
||
106  | 
lemma summable_sumr_LIMSEQ_suminf:  | 
|
| 15539 | 107  | 
     "summable f ==> (%n. setsum f {0..<n}) ----> (suminf f)"
 | 
| 20688 | 108  | 
by (rule summable_sums [unfolded sums_def])  | 
| 14416 | 109  | 
|
| 
32707
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
110  | 
lemma suminf_eq_lim: "suminf f = lim (%n. setsum f {0..<n})"
 | 
| 
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
111  | 
by (simp add: suminf_def sums_def lim_def)  | 
| 
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
112  | 
|
| 14416 | 113  | 
(*-------------------  | 
114  | 
sum is unique  | 
|
115  | 
------------------*)  | 
|
116  | 
lemma sums_unique: "f sums s ==> (s = suminf f)"  | 
|
117  | 
apply (frule sums_summable [THEN summable_sums])  | 
|
118  | 
apply (auto intro!: LIMSEQ_unique simp add: sums_def)  | 
|
119  | 
done  | 
|
120  | 
||
| 
32707
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
121  | 
lemma sums_iff: "f sums x \<longleftrightarrow> summable f \<and> (suminf f = x)"  | 
| 
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
122  | 
by (metis summable_sums sums_summable sums_unique)  | 
| 
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
123  | 
|
| 16819 | 124  | 
lemma sums_split_initial_segment: "f sums s ==>  | 
125  | 
(%n. f(n + k)) sums (s - (SUM i = 0..< k. f i))"  | 
|
126  | 
apply (unfold sums_def);  | 
|
127  | 
apply (simp add: sumr_offset);  | 
|
128  | 
apply (rule LIMSEQ_diff_const)  | 
|
129  | 
apply (rule LIMSEQ_ignore_initial_segment)  | 
|
130  | 
apply assumption  | 
|
131  | 
done  | 
|
132  | 
||
133  | 
lemma summable_ignore_initial_segment: "summable f ==>  | 
|
134  | 
summable (%n. f(n + k))"  | 
|
135  | 
apply (unfold summable_def)  | 
|
136  | 
apply (auto intro: sums_split_initial_segment)  | 
|
137  | 
done  | 
|
138  | 
||
139  | 
lemma suminf_minus_initial_segment: "summable f ==>  | 
|
140  | 
suminf f = s ==> suminf (%n. f(n + k)) = s - (SUM i = 0..< k. f i)"  | 
|
141  | 
apply (frule summable_ignore_initial_segment)  | 
|
142  | 
apply (rule sums_unique [THEN sym])  | 
|
143  | 
apply (frule summable_sums)  | 
|
144  | 
apply (rule sums_split_initial_segment)  | 
|
145  | 
apply auto  | 
|
146  | 
done  | 
|
147  | 
||
148  | 
lemma suminf_split_initial_segment: "summable f ==>  | 
|
149  | 
suminf f = (SUM i = 0..< k. f i) + suminf (%n. f(n + k))"  | 
|
150  | 
by (auto simp add: suminf_minus_initial_segment)  | 
|
151  | 
||
| 
29803
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
152  | 
lemma suminf_exist_split: fixes r :: real assumes "0 < r" and "summable a"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
153  | 
shows "\<exists> N. \<forall> n \<ge> N. \<bar> \<Sum> i. a (i + n) \<bar> < r"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
154  | 
proof -  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
155  | 
from LIMSEQ_D[OF summable_sumr_LIMSEQ_suminf[OF `summable a`] `0 < r`]  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
156  | 
  obtain N :: nat where "\<forall> n \<ge> N. norm (setsum a {0..<n} - suminf a) < r" by auto
 | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
157  | 
thus ?thesis unfolding suminf_minus_initial_segment[OF `summable a` refl] abs_minus_commute real_norm_def  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
158  | 
by auto  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
159  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
160  | 
|
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
161  | 
lemma sums_Suc: assumes sumSuc: "(\<lambda> n. f (Suc n)) sums l" shows "f sums (l + f 0)"  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
162  | 
proof -  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
163  | 
from sumSuc[unfolded sums_def]  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
164  | 
have "(\<lambda>i. \<Sum>n = Suc 0..<Suc i. f n) ----> l" unfolding setsum_reindex[OF inj_Suc] image_Suc_atLeastLessThan[symmetric] comp_def .  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
165  | 
from LIMSEQ_add_const[OF this, where b="f 0"]  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
166  | 
have "(\<lambda>i. \<Sum>n = 0..<Suc i. f n) ----> l + f 0" unfolding add_commute setsum_head_upt_Suc[OF zero_less_Suc] .  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
167  | 
thus ?thesis unfolding sums_def by (rule LIMSEQ_imp_Suc)  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
168  | 
qed  | 
| 
 
c56a5571f60a
Added derivation lemmas for power series and theorems for the pi, arcus tangens and logarithm series
 
hoelzl 
parents: 
29197 
diff
changeset
 | 
169  | 
|
| 14416 | 170  | 
lemma series_zero:  | 
| 15539 | 171  | 
     "(\<forall>m. n \<le> m --> f(m) = 0) ==> f sums (setsum f {0..<n})"
 | 
| 
31336
 
e17f13cd1280
generalize constants in SEQ.thy to class metric_space
 
huffman 
parents: 
31017 
diff
changeset
 | 
172  | 
apply (simp add: sums_def LIMSEQ_iff diff_minus[symmetric], safe)  | 
| 14416 | 173  | 
apply (rule_tac x = n in exI)  | 
| 15542 | 174  | 
apply (clarsimp simp add:setsum_diff[symmetric] cong:setsum_ivl_cong)  | 
| 14416 | 175  | 
done  | 
176  | 
||
| 23121 | 177  | 
lemma sums_zero: "(\<lambda>n. 0) sums 0"  | 
178  | 
unfolding sums_def by (simp add: LIMSEQ_const)  | 
|
| 15539 | 179  | 
|
| 23121 | 180  | 
lemma summable_zero: "summable (\<lambda>n. 0)"  | 
181  | 
by (rule sums_zero [THEN sums_summable])  | 
|
| 16819 | 182  | 
|
| 23121 | 183  | 
lemma suminf_zero: "suminf (\<lambda>n. 0) = 0"  | 
184  | 
by (rule sums_zero [THEN sums_unique, symmetric])  | 
|
| 16819 | 185  | 
|
| 23119 | 186  | 
lemma (in bounded_linear) sums:  | 
187  | 
"(\<lambda>n. X n) sums a \<Longrightarrow> (\<lambda>n. f (X n)) sums (f a)"  | 
|
188  | 
unfolding sums_def by (drule LIMSEQ, simp only: setsum)  | 
|
189  | 
||
190  | 
lemma (in bounded_linear) summable:  | 
|
191  | 
"summable (\<lambda>n. X n) \<Longrightarrow> summable (\<lambda>n. f (X n))"  | 
|
192  | 
unfolding summable_def by (auto intro: sums)  | 
|
193  | 
||
194  | 
lemma (in bounded_linear) suminf:  | 
|
195  | 
"summable (\<lambda>n. X n) \<Longrightarrow> f (\<Sum>n. X n) = (\<Sum>n. f (X n))"  | 
|
| 23121 | 196  | 
by (intro sums_unique sums summable_sums)  | 
| 23119 | 197  | 
|
| 20692 | 198  | 
lemma sums_mult:  | 
199  | 
fixes c :: "'a::real_normed_algebra"  | 
|
200  | 
shows "f sums a \<Longrightarrow> (\<lambda>n. c * f n) sums (c * a)"  | 
|
| 23127 | 201  | 
by (rule mult_right.sums)  | 
| 14416 | 202  | 
|
| 20692 | 203  | 
lemma summable_mult:  | 
204  | 
fixes c :: "'a::real_normed_algebra"  | 
|
| 23121 | 205  | 
shows "summable f \<Longrightarrow> summable (%n. c * f n)"  | 
| 23127 | 206  | 
by (rule mult_right.summable)  | 
| 16819 | 207  | 
|
| 20692 | 208  | 
lemma suminf_mult:  | 
209  | 
fixes c :: "'a::real_normed_algebra"  | 
|
210  | 
shows "summable f \<Longrightarrow> suminf (\<lambda>n. c * f n) = c * suminf f";  | 
|
| 23127 | 211  | 
by (rule mult_right.suminf [symmetric])  | 
| 16819 | 212  | 
|
| 20692 | 213  | 
lemma sums_mult2:  | 
214  | 
fixes c :: "'a::real_normed_algebra"  | 
|
215  | 
shows "f sums a \<Longrightarrow> (\<lambda>n. f n * c) sums (a * c)"  | 
|
| 23127 | 216  | 
by (rule mult_left.sums)  | 
| 16819 | 217  | 
|
| 20692 | 218  | 
lemma summable_mult2:  | 
219  | 
fixes c :: "'a::real_normed_algebra"  | 
|
220  | 
shows "summable f \<Longrightarrow> summable (\<lambda>n. f n * c)"  | 
|
| 23127 | 221  | 
by (rule mult_left.summable)  | 
| 16819 | 222  | 
|
| 20692 | 223  | 
lemma suminf_mult2:  | 
224  | 
fixes c :: "'a::real_normed_algebra"  | 
|
225  | 
shows "summable f \<Longrightarrow> suminf f * c = (\<Sum>n. f n * c)"  | 
|
| 23127 | 226  | 
by (rule mult_left.suminf)  | 
| 16819 | 227  | 
|
| 20692 | 228  | 
lemma sums_divide:  | 
229  | 
fixes c :: "'a::real_normed_field"  | 
|
230  | 
shows "f sums a \<Longrightarrow> (\<lambda>n. f n / c) sums (a / c)"  | 
|
| 23127 | 231  | 
by (rule divide.sums)  | 
| 14416 | 232  | 
|
| 20692 | 233  | 
lemma summable_divide:  | 
234  | 
fixes c :: "'a::real_normed_field"  | 
|
235  | 
shows "summable f \<Longrightarrow> summable (\<lambda>n. f n / c)"  | 
|
| 23127 | 236  | 
by (rule divide.summable)  | 
| 16819 | 237  | 
|
| 20692 | 238  | 
lemma suminf_divide:  | 
239  | 
fixes c :: "'a::real_normed_field"  | 
|
240  | 
shows "summable f \<Longrightarrow> suminf (\<lambda>n. f n / c) = suminf f / c"  | 
|
| 23127 | 241  | 
by (rule divide.suminf [symmetric])  | 
| 16819 | 242  | 
|
| 23121 | 243  | 
lemma sums_add: "\<lbrakk>X sums a; Y sums b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n + Y n) sums (a + b)"  | 
244  | 
unfolding sums_def by (simp add: setsum_addf LIMSEQ_add)  | 
|
| 16819 | 245  | 
|
| 23121 | 246  | 
lemma summable_add: "\<lbrakk>summable X; summable Y\<rbrakk> \<Longrightarrow> summable (\<lambda>n. X n + Y n)"  | 
247  | 
unfolding summable_def by (auto intro: sums_add)  | 
|
| 16819 | 248  | 
|
249  | 
lemma suminf_add:  | 
|
| 23121 | 250  | 
"\<lbrakk>summable X; summable Y\<rbrakk> \<Longrightarrow> suminf X + suminf Y = (\<Sum>n. X n + Y n)"  | 
251  | 
by (intro sums_unique sums_add summable_sums)  | 
|
| 14416 | 252  | 
|
| 23121 | 253  | 
lemma sums_diff: "\<lbrakk>X sums a; Y sums b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n - Y n) sums (a - b)"  | 
254  | 
unfolding sums_def by (simp add: setsum_subtractf LIMSEQ_diff)  | 
|
255  | 
||
256  | 
lemma summable_diff: "\<lbrakk>summable X; summable Y\<rbrakk> \<Longrightarrow> summable (\<lambda>n. X n - Y n)"  | 
|
257  | 
unfolding summable_def by (auto intro: sums_diff)  | 
|
| 14416 | 258  | 
|
259  | 
lemma suminf_diff:  | 
|
| 23121 | 260  | 
"\<lbrakk>summable X; summable Y\<rbrakk> \<Longrightarrow> suminf X - suminf Y = (\<Sum>n. X n - Y n)"  | 
261  | 
by (intro sums_unique sums_diff summable_sums)  | 
|
| 14416 | 262  | 
|
| 23121 | 263  | 
lemma sums_minus: "X sums a ==> (\<lambda>n. - X n) sums (- a)"  | 
264  | 
unfolding sums_def by (simp add: setsum_negf LIMSEQ_minus)  | 
|
| 16819 | 265  | 
|
| 23121 | 266  | 
lemma summable_minus: "summable X \<Longrightarrow> summable (\<lambda>n. - X n)"  | 
267  | 
unfolding summable_def by (auto intro: sums_minus)  | 
|
| 16819 | 268  | 
|
| 23121 | 269  | 
lemma suminf_minus: "summable X \<Longrightarrow> (\<Sum>n. - X n) = - (\<Sum>n. X n)"  | 
270  | 
by (intro sums_unique [symmetric] sums_minus summable_sums)  | 
|
| 14416 | 271  | 
|
272  | 
lemma sums_group:  | 
|
| 15539 | 273  | 
     "[|summable f; 0 < k |] ==> (%n. setsum f {n*k..<n*k+k}) sums (suminf f)"
 | 
| 14416 | 274  | 
apply (drule summable_sums)  | 
| 20692 | 275  | 
apply (simp only: sums_def sumr_group)  | 
| 
31336
 
e17f13cd1280
generalize constants in SEQ.thy to class metric_space
 
huffman 
parents: 
31017 
diff
changeset
 | 
276  | 
apply (unfold LIMSEQ_iff, safe)  | 
| 20692 | 277  | 
apply (drule_tac x="r" in spec, safe)  | 
278  | 
apply (rule_tac x="no" in exI, safe)  | 
|
279  | 
apply (drule_tac x="n*k" in spec)  | 
|
280  | 
apply (erule mp)  | 
|
281  | 
apply (erule order_trans)  | 
|
282  | 
apply simp  | 
|
| 14416 | 283  | 
done  | 
284  | 
||
| 
15085
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
285  | 
text{*A summable series of positive terms has limit that is at least as
 | 
| 
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
286  | 
great as any partial sum.*}  | 
| 14416 | 287  | 
|
| 
33271
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
288  | 
lemma pos_summable:  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
289  | 
fixes f:: "nat \<Rightarrow> real"  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
290  | 
  assumes pos: "!!n. 0 \<le> f n" and le: "!!n. setsum f {0..<n} \<le> x"
 | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
291  | 
shows "summable f"  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
292  | 
proof -  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
293  | 
  have "convergent (\<lambda>n. setsum f {0..<n})" 
 | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
294  | 
proof (rule Bseq_mono_convergent)  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
295  | 
      show "Bseq (\<lambda>n. setsum f {0..<n})"
 | 
| 33536 | 296  | 
        by (rule f_inc_g_dec_Beq_f [of "(\<lambda>n. setsum f {0..<n})" "\<lambda>n. x"])
 | 
| 
33271
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
297  | 
(auto simp add: le pos)  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
298  | 
next  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
299  | 
      show "\<forall>m n. m \<le> n \<longrightarrow> setsum f {0..<m} \<le> setsum f {0..<n}"
 | 
| 33536 | 300  | 
by (auto intro: setsum_mono2 pos)  | 
| 
33271
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
301  | 
qed  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
302  | 
  then obtain L where "(%n. setsum f {0..<n}) ----> L"
 | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
303  | 
by (blast dest: convergentD)  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
304  | 
thus ?thesis  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
305  | 
by (force simp add: summable_def sums_def)  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
306  | 
qed  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
307  | 
|
| 20692 | 308  | 
lemma series_pos_le:  | 
309  | 
fixes f :: "nat \<Rightarrow> real"  | 
|
310  | 
  shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 \<le> f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} \<le> suminf f"
 | 
|
| 14416 | 311  | 
apply (drule summable_sums)  | 
312  | 
apply (simp add: sums_def)  | 
|
| 15539 | 313  | 
apply (cut_tac k = "setsum f {0..<n}" in LIMSEQ_const)
 | 
314  | 
apply (erule LIMSEQ_le, blast)  | 
|
| 20692 | 315  | 
apply (rule_tac x="n" in exI, clarify)  | 
| 15539 | 316  | 
apply (rule setsum_mono2)  | 
317  | 
apply auto  | 
|
| 14416 | 318  | 
done  | 
319  | 
||
320  | 
lemma series_pos_less:  | 
|
| 20692 | 321  | 
fixes f :: "nat \<Rightarrow> real"  | 
322  | 
  shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 < f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} < suminf f"
 | 
|
323  | 
apply (rule_tac y="setsum f {0..<Suc n}" in order_less_le_trans)
 | 
|
324  | 
apply simp  | 
|
325  | 
apply (erule series_pos_le)  | 
|
326  | 
apply (simp add: order_less_imp_le)  | 
|
327  | 
done  | 
|
328  | 
||
329  | 
lemma suminf_gt_zero:  | 
|
330  | 
fixes f :: "nat \<Rightarrow> real"  | 
|
331  | 
shows "\<lbrakk>summable f; \<forall>n. 0 < f n\<rbrakk> \<Longrightarrow> 0 < suminf f"  | 
|
332  | 
by (drule_tac n="0" in series_pos_less, simp_all)  | 
|
333  | 
||
334  | 
lemma suminf_ge_zero:  | 
|
335  | 
fixes f :: "nat \<Rightarrow> real"  | 
|
336  | 
shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> 0 \<le> suminf f"  | 
|
337  | 
by (drule_tac n="0" in series_pos_le, simp_all)  | 
|
338  | 
||
339  | 
lemma sumr_pos_lt_pair:  | 
|
340  | 
fixes f :: "nat \<Rightarrow> real"  | 
|
341  | 
shows "\<lbrakk>summable f;  | 
|
342  | 
\<forall>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc(Suc 0) * d) + 1))\<rbrakk>  | 
|
343  | 
      \<Longrightarrow> setsum f {0..<k} < suminf f"
 | 
|
| 
30082
 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 
huffman 
parents: 
29803 
diff
changeset
 | 
344  | 
unfolding One_nat_def  | 
| 20692 | 345  | 
apply (subst suminf_split_initial_segment [where k="k"])  | 
346  | 
apply assumption  | 
|
347  | 
apply simp  | 
|
348  | 
apply (drule_tac k="k" in summable_ignore_initial_segment)  | 
|
349  | 
apply (drule_tac k="Suc (Suc 0)" in sums_group, simp)  | 
|
350  | 
apply simp  | 
|
351  | 
apply (frule sums_unique)  | 
|
352  | 
apply (drule sums_summable)  | 
|
353  | 
apply simp  | 
|
354  | 
apply (erule suminf_gt_zero)  | 
|
355  | 
apply (simp add: add_ac)  | 
|
| 14416 | 356  | 
done  | 
357  | 
||
| 
15085
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
358  | 
text{*Sum of a geometric progression.*}
 | 
| 14416 | 359  | 
|
| 
17149
 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 
ballarin 
parents: 
16819 
diff
changeset
 | 
360  | 
lemmas sumr_geometric = geometric_sum [where 'a = real]  | 
| 14416 | 361  | 
|
| 20692 | 362  | 
lemma geometric_sums:  | 
| 31017 | 363  | 
  fixes x :: "'a::{real_normed_field}"
 | 
| 20692 | 364  | 
shows "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) sums (1 / (1 - x))"  | 
365  | 
proof -  | 
|
366  | 
assume less_1: "norm x < 1"  | 
|
367  | 
hence neq_1: "x \<noteq> 1" by auto  | 
|
368  | 
hence neq_0: "x - 1 \<noteq> 0" by simp  | 
|
369  | 
from less_1 have lim_0: "(\<lambda>n. x ^ n) ----> 0"  | 
|
370  | 
by (rule LIMSEQ_power_zero)  | 
|
| 
22719
 
c51667189bd3
lemma geometric_sum no longer needs class division_by_zero
 
huffman 
parents: 
21404 
diff
changeset
 | 
371  | 
hence "(\<lambda>n. x ^ n / (x - 1) - 1 / (x - 1)) ----> 0 / (x - 1) - 1 / (x - 1)"  | 
| 20692 | 372  | 
using neq_0 by (intro LIMSEQ_divide LIMSEQ_diff LIMSEQ_const)  | 
373  | 
hence "(\<lambda>n. (x ^ n - 1) / (x - 1)) ----> 1 / (1 - x)"  | 
|
374  | 
by (simp add: nonzero_minus_divide_right [OF neq_0] diff_divide_distrib)  | 
|
375  | 
thus "(\<lambda>n. x ^ n) sums (1 / (1 - x))"  | 
|
376  | 
by (simp add: sums_def geometric_sum neq_1)  | 
|
377  | 
qed  | 
|
378  | 
||
379  | 
lemma summable_geometric:  | 
|
| 31017 | 380  | 
  fixes x :: "'a::{real_normed_field}"
 | 
| 20692 | 381  | 
shows "norm x < 1 \<Longrightarrow> summable (\<lambda>n. x ^ n)"  | 
382  | 
by (rule geometric_sums [THEN sums_summable])  | 
|
| 14416 | 383  | 
|
| 36409 | 384  | 
lemma half: "0 < 1 / (2::'a::{number_ring,linordered_field_inverse_zero})"
 | 
| 
33271
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
385  | 
by arith  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
386  | 
|
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
387  | 
lemma power_half_series: "(\<lambda>n. (1/2::real)^Suc n) sums 1"  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
388  | 
proof -  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
389  | 
have 2: "(\<lambda>n. (1/2::real)^n) sums 2" using geometric_sums [of "1/2::real"]  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
390  | 
by auto  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
391  | 
have "(\<lambda>n. (1/2::real)^Suc n) = (\<lambda>n. (1 / 2) ^ n / 2)"  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
392  | 
by simp  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
393  | 
thus ?thesis using divide.sums [OF 2, of 2]  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
394  | 
by simp  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
395  | 
qed  | 
| 
 
7be66dee1a5a
New theory Probability, which contains a development of measure theory
 
paulson 
parents: 
32877 
diff
changeset
 | 
396  | 
|
| 
15085
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
397  | 
text{*Cauchy-type criterion for convergence of series (c.f. Harrison)*}
 | 
| 
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
398  | 
|
| 15539 | 399  | 
lemma summable_convergent_sumr_iff:  | 
400  | 
 "summable f = convergent (%n. setsum f {0..<n})"
 | 
|
| 14416 | 401  | 
by (simp add: summable_def sums_def convergent_def)  | 
402  | 
||
| 20689 | 403  | 
lemma summable_LIMSEQ_zero: "summable f \<Longrightarrow> f ----> 0"  | 
404  | 
apply (drule summable_convergent_sumr_iff [THEN iffD1])  | 
|
| 20692 | 405  | 
apply (drule convergent_Cauchy)  | 
| 
31336
 
e17f13cd1280
generalize constants in SEQ.thy to class metric_space
 
huffman 
parents: 
31017 
diff
changeset
 | 
406  | 
apply (simp only: Cauchy_iff LIMSEQ_iff, safe)  | 
| 20689 | 407  | 
apply (drule_tac x="r" in spec, safe)  | 
408  | 
apply (rule_tac x="M" in exI, safe)  | 
|
409  | 
apply (drule_tac x="Suc n" in spec, simp)  | 
|
410  | 
apply (drule_tac x="n" in spec, simp)  | 
|
411  | 
done  | 
|
412  | 
||
| 
32707
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
413  | 
lemma suminf_le:  | 
| 
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
414  | 
fixes x :: real  | 
| 
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
415  | 
  shows "summable f \<Longrightarrow> (!!n. setsum f {0..<n} \<le> x) \<Longrightarrow> suminf f \<le> x"
 | 
| 
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
416  | 
by (simp add: summable_convergent_sumr_iff suminf_eq_lim lim_le)  | 
| 
 
836ec9d0a0c8
New lemmas involving the real numbers, especially limits and series
 
paulson 
parents: 
31336 
diff
changeset
 | 
417  | 
|
| 14416 | 418  | 
lemma summable_Cauchy:  | 
| 20848 | 419  | 
"summable (f::nat \<Rightarrow> 'a::banach) =  | 
420  | 
      (\<forall>e > 0. \<exists>N. \<forall>m \<ge> N. \<forall>n. norm (setsum f {m..<n}) < e)"
 | 
|
| 
31336
 
e17f13cd1280
generalize constants in SEQ.thy to class metric_space
 
huffman 
parents: 
31017 
diff
changeset
 | 
421  | 
apply (simp only: summable_convergent_sumr_iff Cauchy_convergent_iff [symmetric] Cauchy_iff, safe)  | 
| 20410 | 422  | 
apply (drule spec, drule (1) mp)  | 
423  | 
apply (erule exE, rule_tac x="M" in exI, clarify)  | 
|
424  | 
apply (rule_tac x="m" and y="n" in linorder_le_cases)  | 
|
425  | 
apply (frule (1) order_trans)  | 
|
426  | 
apply (drule_tac x="n" in spec, drule (1) mp)  | 
|
427  | 
apply (drule_tac x="m" in spec, drule (1) mp)  | 
|
428  | 
apply (simp add: setsum_diff [symmetric])  | 
|
429  | 
apply simp  | 
|
430  | 
apply (drule spec, drule (1) mp)  | 
|
431  | 
apply (erule exE, rule_tac x="N" in exI, clarify)  | 
|
432  | 
apply (rule_tac x="m" and y="n" in linorder_le_cases)  | 
|
| 
20552
 
2c31dd358c21
generalized types of many constants to work over arbitrary vector spaces;
 
huffman 
parents: 
20432 
diff
changeset
 | 
433  | 
apply (subst norm_minus_commute)  | 
| 20410 | 434  | 
apply (simp add: setsum_diff [symmetric])  | 
435  | 
apply (simp add: setsum_diff [symmetric])  | 
|
| 14416 | 436  | 
done  | 
437  | 
||
| 
15085
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
438  | 
text{*Comparison test*}
 | 
| 
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
439  | 
|
| 20692 | 440  | 
lemma norm_setsum:  | 
441  | 
fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"  | 
|
442  | 
shows "norm (setsum f A) \<le> (\<Sum>i\<in>A. norm (f i))"  | 
|
443  | 
apply (case_tac "finite A")  | 
|
444  | 
apply (erule finite_induct)  | 
|
445  | 
apply simp  | 
|
446  | 
apply simp  | 
|
447  | 
apply (erule order_trans [OF norm_triangle_ineq add_left_mono])  | 
|
448  | 
apply simp  | 
|
449  | 
done  | 
|
450  | 
||
| 14416 | 451  | 
lemma summable_comparison_test:  | 
| 20848 | 452  | 
fixes f :: "nat \<Rightarrow> 'a::banach"  | 
453  | 
shows "\<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable f"  | 
|
| 20692 | 454  | 
apply (simp add: summable_Cauchy, safe)  | 
455  | 
apply (drule_tac x="e" in spec, safe)  | 
|
456  | 
apply (rule_tac x = "N + Na" in exI, safe)  | 
|
| 14416 | 457  | 
apply (rotate_tac 2)  | 
458  | 
apply (drule_tac x = m in spec)  | 
|
459  | 
apply (auto, rotate_tac 2, drule_tac x = n in spec)  | 
|
| 20848 | 460  | 
apply (rule_tac y = "\<Sum>k=m..<n. norm (f k)" in order_le_less_trans)  | 
461  | 
apply (rule norm_setsum)  | 
|
| 15539 | 462  | 
apply (rule_tac y = "setsum g {m..<n}" in order_le_less_trans)
 | 
| 22998 | 463  | 
apply (auto intro: setsum_mono simp add: abs_less_iff)  | 
| 14416 | 464  | 
done  | 
465  | 
||
| 20848 | 466  | 
lemma summable_norm_comparison_test:  | 
467  | 
fixes f :: "nat \<Rightarrow> 'a::banach"  | 
|
468  | 
shows "\<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk>  | 
|
469  | 
\<Longrightarrow> summable (\<lambda>n. norm (f n))"  | 
|
470  | 
apply (rule summable_comparison_test)  | 
|
471  | 
apply (auto)  | 
|
472  | 
done  | 
|
473  | 
||
| 14416 | 474  | 
lemma summable_rabs_comparison_test:  | 
| 20692 | 475  | 
fixes f :: "nat \<Rightarrow> real"  | 
476  | 
shows "\<lbrakk>\<exists>N. \<forall>n\<ge>N. \<bar>f n\<bar> \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable (\<lambda>n. \<bar>f n\<bar>)"  | 
|
| 14416 | 477  | 
apply (rule summable_comparison_test)  | 
| 15543 | 478  | 
apply (auto)  | 
| 14416 | 479  | 
done  | 
480  | 
||
| 23084 | 481  | 
text{*Summability of geometric series for real algebras*}
 | 
482  | 
||
483  | 
lemma complete_algebra_summable_geometric:  | 
|
| 31017 | 484  | 
  fixes x :: "'a::{real_normed_algebra_1,banach}"
 | 
| 23084 | 485  | 
shows "norm x < 1 \<Longrightarrow> summable (\<lambda>n. x ^ n)"  | 
486  | 
proof (rule summable_comparison_test)  | 
|
487  | 
show "\<exists>N. \<forall>n\<ge>N. norm (x ^ n) \<le> norm x ^ n"  | 
|
488  | 
by (simp add: norm_power_ineq)  | 
|
489  | 
show "norm x < 1 \<Longrightarrow> summable (\<lambda>n. norm x ^ n)"  | 
|
490  | 
by (simp add: summable_geometric)  | 
|
491  | 
qed  | 
|
492  | 
||
| 
15085
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
493  | 
text{*Limit comparison property for series (c.f. jrh)*}
 | 
| 
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
494  | 
|
| 14416 | 495  | 
lemma summable_le:  | 
| 20692 | 496  | 
fixes f g :: "nat \<Rightarrow> real"  | 
497  | 
shows "\<lbrakk>\<forall>n. f n \<le> g n; summable f; summable g\<rbrakk> \<Longrightarrow> suminf f \<le> suminf g"  | 
|
| 14416 | 498  | 
apply (drule summable_sums)+  | 
| 20692 | 499  | 
apply (simp only: sums_def, erule (1) LIMSEQ_le)  | 
| 14416 | 500  | 
apply (rule exI)  | 
| 15539 | 501  | 
apply (auto intro!: setsum_mono)  | 
| 14416 | 502  | 
done  | 
503  | 
||
504  | 
lemma summable_le2:  | 
|
| 20692 | 505  | 
fixes f g :: "nat \<Rightarrow> real"  | 
506  | 
shows "\<lbrakk>\<forall>n. \<bar>f n\<bar> \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable f \<and> suminf f \<le> suminf g"  | 
|
| 20848 | 507  | 
apply (subgoal_tac "summable f")  | 
508  | 
apply (auto intro!: summable_le)  | 
|
| 22998 | 509  | 
apply (simp add: abs_le_iff)  | 
| 20848 | 510  | 
apply (rule_tac g="g" in summable_comparison_test, simp_all)  | 
| 14416 | 511  | 
done  | 
512  | 
||
| 
19106
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
513  | 
(* specialisation for the common 0 case *)  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
514  | 
lemma suminf_0_le:  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
515  | 
fixes f::"nat\<Rightarrow>real"  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
516  | 
assumes gt0: "\<forall>n. 0 \<le> f n" and sm: "summable f"  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
517  | 
shows "0 \<le> suminf f"  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
518  | 
proof -  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
519  | 
let ?g = "(\<lambda>n. (0::real))"  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
520  | 
from gt0 have "\<forall>n. ?g n \<le> f n" by simp  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
521  | 
moreover have "summable ?g" by (rule summable_zero)  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
522  | 
moreover from sm have "summable f" .  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
523  | 
ultimately have "suminf ?g \<le> suminf f" by (rule summable_le)  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
524  | 
then show "0 \<le> suminf f" by (simp add: suminf_zero)  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
525  | 
qed  | 
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
526  | 
|
| 
 
6e6b5b1fdc06
* added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
 
kleing 
parents: 
17149 
diff
changeset
 | 
527  | 
|
| 
15085
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
528  | 
text{*Absolute convergence imples normal convergence*}
 | 
| 20848 | 529  | 
lemma summable_norm_cancel:  | 
530  | 
fixes f :: "nat \<Rightarrow> 'a::banach"  | 
|
531  | 
shows "summable (\<lambda>n. norm (f n)) \<Longrightarrow> summable f"  | 
|
| 20692 | 532  | 
apply (simp only: summable_Cauchy, safe)  | 
533  | 
apply (drule_tac x="e" in spec, safe)  | 
|
534  | 
apply (rule_tac x="N" in exI, safe)  | 
|
535  | 
apply (drule_tac x="m" in spec, safe)  | 
|
| 20848 | 536  | 
apply (rule order_le_less_trans [OF norm_setsum])  | 
537  | 
apply (rule order_le_less_trans [OF abs_ge_self])  | 
|
| 20692 | 538  | 
apply simp  | 
| 14416 | 539  | 
done  | 
540  | 
||
| 20848 | 541  | 
lemma summable_rabs_cancel:  | 
542  | 
fixes f :: "nat \<Rightarrow> real"  | 
|
543  | 
shows "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> summable f"  | 
|
544  | 
by (rule summable_norm_cancel, simp)  | 
|
545  | 
||
| 
15085
 
5693a977a767
removed some [iff] declarations from RealDef.thy, concerning inequalities
 
paulson 
parents: 
15053 
diff
changeset
 | 
546  | 
text{*Absolute convergence of series*}
 | 
| 20848 | 547  | 
lemma summable_norm:  | 
548  | 
fixes f :: "nat \<Rightarrow> 'a::banach"  | 
|
549  | 
shows "summable (\<lambda>n. norm (f n)) \<Longrightarrow> norm (suminf f) \<le> (\<Sum>n. norm (f n))"  | 
|
550  | 
by (auto intro: LIMSEQ_le LIMSEQ_norm summable_norm_cancel  | 
|
551  | 
summable_sumr_LIMSEQ_suminf norm_setsum)  | 
|
552  | 
||
| 14416 | 553  | 
lemma summable_rabs:  | 
| 20692 | 554  | 
fixes f :: "nat \<Rightarrow> real"  | 
555  | 
shows "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> \<bar>suminf f\<bar> \<le> (\<Sum>n. \<bar>f n\<bar>)"  | 
|
| 20848 | 556  | 
by (fold real_norm_def, rule summable_norm)  | 
| 14416 | 557  | 
|
558  | 
subsection{* The Ratio Test*}
 | 
|
559  | 
||
| 20848 | 560  | 
lemma norm_ratiotest_lemma:  | 
| 22852 | 561  | 
fixes x y :: "'a::real_normed_vector"  | 
| 20848 | 562  | 
shows "\<lbrakk>c \<le> 0; norm x \<le> c * norm y\<rbrakk> \<Longrightarrow> x = 0"  | 
563  | 
apply (subgoal_tac "norm x \<le> 0", simp)  | 
|
564  | 
apply (erule order_trans)  | 
|
565  | 
apply (simp add: mult_le_0_iff)  | 
|
566  | 
done  | 
|
567  | 
||
| 14416 | 568  | 
lemma rabs_ratiotest_lemma: "[| c \<le> 0; abs x \<le> c * abs y |] ==> x = (0::real)"  | 
| 20848 | 569  | 
by (erule norm_ratiotest_lemma, simp)  | 
| 14416 | 570  | 
|
571  | 
lemma le_Suc_ex: "(k::nat) \<le> l ==> (\<exists>n. l = k + n)"  | 
|
572  | 
apply (drule le_imp_less_or_eq)  | 
|
573  | 
apply (auto dest: less_imp_Suc_add)  | 
|
574  | 
done  | 
|
575  | 
||
576  | 
lemma le_Suc_ex_iff: "((k::nat) \<le> l) = (\<exists>n. l = k + n)"  | 
|
577  | 
by (auto simp add: le_Suc_ex)  | 
|
578  | 
||
579  | 
(*All this trouble just to get 0<c *)  | 
|
580  | 
lemma ratio_test_lemma2:  | 
|
| 20848 | 581  | 
fixes f :: "nat \<Rightarrow> 'a::banach"  | 
582  | 
shows "\<lbrakk>\<forall>n\<ge>N. norm (f (Suc n)) \<le> c * norm (f n)\<rbrakk> \<Longrightarrow> 0 < c \<or> summable f"  | 
|
| 14416 | 583  | 
apply (simp (no_asm) add: linorder_not_le [symmetric])  | 
584  | 
apply (simp add: summable_Cauchy)  | 
|
| 15543 | 585  | 
apply (safe, subgoal_tac "\<forall>n. N < n --> f (n) = 0")  | 
586  | 
prefer 2  | 
|
587  | 
apply clarify  | 
|
| 
30082
 
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
 
huffman 
parents: 
29803 
diff
changeset
 | 
588  | 
apply(erule_tac x = "n - Suc 0" in allE)  | 
| 15543 | 589  | 
apply (simp add:diff_Suc split:nat.splits)  | 
| 20848 | 590  | 
apply (blast intro: norm_ratiotest_lemma)  | 
| 14416 | 591  | 
apply (rule_tac x = "Suc N" in exI, clarify)  | 
| 15543 | 592  | 
apply(simp cong:setsum_ivl_cong)  | 
| 14416 | 593  | 
done  | 
594  | 
||
595  | 
lemma ratio_test:  | 
|
| 20848 | 596  | 
fixes f :: "nat \<Rightarrow> 'a::banach"  | 
597  | 
shows "\<lbrakk>c < 1; \<forall>n\<ge>N. norm (f (Suc n)) \<le> c * norm (f n)\<rbrakk> \<Longrightarrow> summable f"  | 
|
| 14416 | 598  | 
apply (frule ratio_test_lemma2, auto)  | 
| 20848 | 599  | 
apply (rule_tac g = "%n. (norm (f N) / (c ^ N))*c ^ n"  | 
| 
15234
 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 
paulson 
parents: 
15229 
diff
changeset
 | 
600  | 
in summable_comparison_test)  | 
| 14416 | 601  | 
apply (rule_tac x = N in exI, safe)  | 
602  | 
apply (drule le_Suc_ex_iff [THEN iffD1])  | 
|
| 22959 | 603  | 
apply (auto simp add: power_add field_power_not_zero)  | 
| 15539 | 604  | 
apply (induct_tac "na", auto)  | 
| 20848 | 605  | 
apply (rule_tac y = "c * norm (f (N + n))" in order_trans)  | 
| 14416 | 606  | 
apply (auto intro: mult_right_mono simp add: summable_def)  | 
| 20848 | 607  | 
apply (rule_tac x = "norm (f N) * (1/ (1 - c)) / (c ^ N)" in exI)  | 
| 
15234
 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 
paulson 
parents: 
15229 
diff
changeset
 | 
608  | 
apply (rule sums_divide)  | 
| 27108 | 609  | 
apply (rule sums_mult)  | 
| 
15234
 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
 
paulson 
parents: 
15229 
diff
changeset
 | 
610  | 
apply (auto intro!: geometric_sums)  | 
| 14416 | 611  | 
done  | 
612  | 
||
| 23111 | 613  | 
subsection {* Cauchy Product Formula *}
 | 
614  | 
||
615  | 
(* Proof based on Analysis WebNotes: Chapter 07, Class 41  | 
|
616  | 
http://www.math.unl.edu/~webnotes/classes/class41/prp77.htm *)  | 
|
617  | 
||
618  | 
lemma setsum_triangle_reindex:  | 
|
619  | 
fixes n :: nat  | 
|
620  | 
  shows "(\<Sum>(i,j)\<in>{(i,j). i+j < n}. f i j) = (\<Sum>k=0..<n. \<Sum>i=0..k. f i (k - i))"
 | 
|
621  | 
proof -  | 
|
622  | 
  have "(\<Sum>(i, j)\<in>{(i, j). i + j < n}. f i j) =
 | 
|
623  | 
    (\<Sum>(k, i)\<in>(SIGMA k:{0..<n}. {0..k}). f i (k - i))"
 | 
|
624  | 
proof (rule setsum_reindex_cong)  | 
|
625  | 
    show "inj_on (\<lambda>(k,i). (i, k - i)) (SIGMA k:{0..<n}. {0..k})"
 | 
|
626  | 
by (rule inj_on_inverseI [where g="\<lambda>(i,j). (i+j, i)"], auto)  | 
|
627  | 
    show "{(i,j). i + j < n} = (\<lambda>(k,i). (i, k - i)) ` (SIGMA k:{0..<n}. {0..k})"
 | 
|
628  | 
by (safe, rule_tac x="(a+b,a)" in image_eqI, auto)  | 
|
629  | 
show "\<And>a. (\<lambda>(k, i). f i (k - i)) a = split f ((\<lambda>(k, i). (i, k - i)) a)"  | 
|
630  | 
by clarify  | 
|
631  | 
qed  | 
|
632  | 
thus ?thesis by (simp add: setsum_Sigma)  | 
|
633  | 
qed  | 
|
634  | 
||
635  | 
lemma Cauchy_product_sums:  | 
|
636  | 
  fixes a b :: "nat \<Rightarrow> 'a::{real_normed_algebra,banach}"
 | 
|
637  | 
assumes a: "summable (\<lambda>k. norm (a k))"  | 
|
638  | 
assumes b: "summable (\<lambda>k. norm (b k))"  | 
|
639  | 
shows "(\<lambda>k. \<Sum>i=0..k. a i * b (k - i)) sums ((\<Sum>k. a k) * (\<Sum>k. b k))"  | 
|
640  | 
proof -  | 
|
641  | 
  let ?S1 = "\<lambda>n::nat. {0..<n} \<times> {0..<n}"
 | 
|
642  | 
  let ?S2 = "\<lambda>n::nat. {(i,j). i + j < n}"
 | 
|
643  | 
have S1_mono: "\<And>m n. m \<le> n \<Longrightarrow> ?S1 m \<subseteq> ?S1 n" by auto  | 
|
644  | 
have S2_le_S1: "\<And>n. ?S2 n \<subseteq> ?S1 n" by auto  | 
|
645  | 
have S1_le_S2: "\<And>n. ?S1 (n div 2) \<subseteq> ?S2 n" by auto  | 
|
646  | 
have finite_S1: "\<And>n. finite (?S1 n)" by simp  | 
|
647  | 
with S2_le_S1 have finite_S2: "\<And>n. finite (?S2 n)" by (rule finite_subset)  | 
|
648  | 
||
649  | 
let ?g = "\<lambda>(i,j). a i * b j"  | 
|
650  | 
let ?f = "\<lambda>(i,j). norm (a i) * norm (b j)"  | 
|
651  | 
have f_nonneg: "\<And>x. 0 \<le> ?f x"  | 
|
652  | 
by (auto simp add: mult_nonneg_nonneg)  | 
|
653  | 
hence norm_setsum_f: "\<And>A. norm (setsum ?f A) = setsum ?f A"  | 
|
654  | 
unfolding real_norm_def  | 
|
655  | 
by (simp only: abs_of_nonneg setsum_nonneg [rule_format])  | 
|
656  | 
||
657  | 
have "(\<lambda>n. (\<Sum>k=0..<n. a k) * (\<Sum>k=0..<n. b k))  | 
|
658  | 
----> (\<Sum>k. a k) * (\<Sum>k. b k)"  | 
|
659  | 
by (intro LIMSEQ_mult summable_sumr_LIMSEQ_suminf  | 
|
660  | 
summable_norm_cancel [OF a] summable_norm_cancel [OF b])  | 
|
661  | 
hence 1: "(\<lambda>n. setsum ?g (?S1 n)) ----> (\<Sum>k. a k) * (\<Sum>k. b k)"  | 
|
662  | 
by (simp only: setsum_product setsum_Sigma [rule_format]  | 
|
663  | 
finite_atLeastLessThan)  | 
|
664  | 
||
665  | 
have "(\<lambda>n. (\<Sum>k=0..<n. norm (a k)) * (\<Sum>k=0..<n. norm (b k)))  | 
|
666  | 
----> (\<Sum>k. norm (a k)) * (\<Sum>k. norm (b k))"  | 
|
667  | 
using a b by (intro LIMSEQ_mult summable_sumr_LIMSEQ_suminf)  | 
|
668  | 
hence "(\<lambda>n. setsum ?f (?S1 n)) ----> (\<Sum>k. norm (a k)) * (\<Sum>k. norm (b k))"  | 
|
669  | 
by (simp only: setsum_product setsum_Sigma [rule_format]  | 
|
670  | 
finite_atLeastLessThan)  | 
|
671  | 
hence "convergent (\<lambda>n. setsum ?f (?S1 n))"  | 
|
672  | 
by (rule convergentI)  | 
|
673  | 
hence Cauchy: "Cauchy (\<lambda>n. setsum ?f (?S1 n))"  | 
|
674  | 
by (rule convergent_Cauchy)  | 
|
| 36657 | 675  | 
have "Zfun (\<lambda>n. setsum ?f (?S1 n - ?S2 n)) sequentially"  | 
676  | 
proof (rule ZfunI, simp only: eventually_sequentially norm_setsum_f)  | 
|
| 23111 | 677  | 
fix r :: real  | 
678  | 
assume r: "0 < r"  | 
|
679  | 
from CauchyD [OF Cauchy r] obtain N  | 
|
680  | 
where "\<forall>m\<ge>N. \<forall>n\<ge>N. norm (setsum ?f (?S1 m) - setsum ?f (?S1 n)) < r" ..  | 
|
681  | 
hence "\<And>m n. \<lbrakk>N \<le> n; n \<le> m\<rbrakk> \<Longrightarrow> norm (setsum ?f (?S1 m - ?S1 n)) < r"  | 
|
682  | 
by (simp only: setsum_diff finite_S1 S1_mono)  | 
|
683  | 
hence N: "\<And>m n. \<lbrakk>N \<le> n; n \<le> m\<rbrakk> \<Longrightarrow> setsum ?f (?S1 m - ?S1 n) < r"  | 
|
684  | 
by (simp only: norm_setsum_f)  | 
|
685  | 
show "\<exists>N. \<forall>n\<ge>N. setsum ?f (?S1 n - ?S2 n) < r"  | 
|
686  | 
proof (intro exI allI impI)  | 
|
687  | 
fix n assume "2 * N \<le> n"  | 
|
688  | 
hence n: "N \<le> n div 2" by simp  | 
|
689  | 
have "setsum ?f (?S1 n - ?S2 n) \<le> setsum ?f (?S1 n - ?S1 (n div 2))"  | 
|
690  | 
by (intro setsum_mono2 finite_Diff finite_S1 f_nonneg  | 
|
691  | 
Diff_mono subset_refl S1_le_S2)  | 
|
692  | 
also have "\<dots> < r"  | 
|
693  | 
using n div_le_dividend by (rule N)  | 
|
694  | 
finally show "setsum ?f (?S1 n - ?S2 n) < r" .  | 
|
695  | 
qed  | 
|
696  | 
qed  | 
|
| 36657 | 697  | 
hence "Zfun (\<lambda>n. setsum ?g (?S1 n - ?S2 n)) sequentially"  | 
698  | 
apply (rule Zfun_le [rule_format])  | 
|
| 23111 | 699  | 
apply (simp only: norm_setsum_f)  | 
700  | 
apply (rule order_trans [OF norm_setsum setsum_mono])  | 
|
701  | 
apply (auto simp add: norm_mult_ineq)  | 
|
702  | 
done  | 
|
703  | 
hence 2: "(\<lambda>n. setsum ?g (?S1 n) - setsum ?g (?S2 n)) ----> 0"  | 
|
| 
36660
 
1cc4ab4b7ff7
make (X ----> L) an abbreviation for (X ---> L) sequentially
 
huffman 
parents: 
36657 
diff
changeset
 | 
704  | 
unfolding tendsto_Zfun_iff diff_0_right  | 
| 36657 | 705  | 
by (simp only: setsum_diff finite_S1 S2_le_S1)  | 
| 23111 | 706  | 
|
707  | 
with 1 have "(\<lambda>n. setsum ?g (?S2 n)) ----> (\<Sum>k. a k) * (\<Sum>k. b k)"  | 
|
708  | 
by (rule LIMSEQ_diff_approach_zero2)  | 
|
709  | 
thus ?thesis by (simp only: sums_def setsum_triangle_reindex)  | 
|
710  | 
qed  | 
|
711  | 
||
712  | 
lemma Cauchy_product:  | 
|
713  | 
  fixes a b :: "nat \<Rightarrow> 'a::{real_normed_algebra,banach}"
 | 
|
714  | 
assumes a: "summable (\<lambda>k. norm (a k))"  | 
|
715  | 
assumes b: "summable (\<lambda>k. norm (b k))"  | 
|
716  | 
shows "(\<Sum>k. a k) * (\<Sum>k. b k) = (\<Sum>k. \<Sum>i=0..k. a i * b (k - i))"  | 
|
| 23441 | 717  | 
using a b  | 
| 23111 | 718  | 
by (rule Cauchy_product_sums [THEN sums_unique])  | 
719  | 
||
| 14416 | 720  | 
end  |