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