src/HOL/Series.thy
 changeset 56193 c726ecfb22b6 parent 56178 2a6f58938573 child 56194 9ffbb4004c81
```     1.1 --- a/src/HOL/Series.thy	Tue Mar 18 14:32:23 2014 +0100
1.2 +++ b/src/HOL/Series.thy	Tue Mar 18 15:53:48 2014 +0100
1.3 @@ -7,122 +7,109 @@
1.5  *)
1.6
1.7 -header{*Finite Summation and Infinite Series*}
1.8 +header {* Finite Summation and Infinite Series *}
1.9
1.10  theory Series
1.11  imports Limits
1.12  begin
1.13
1.14 -definition
1.15 -   sums  :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> 'a \<Rightarrow> bool"
1.16 -     (infixr "sums" 80) where
1.17 -   "f sums s = (%n. setsum f {0..<n}) ----> s"
1.18 -
1.19 -definition
1.20 -   summable :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> bool" where
1.21 -   "summable f = (\<exists>s. f sums s)"
1.22 -
1.23 -definition
1.24 -   suminf   :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> 'a" where
1.25 -   "suminf f = (THE s. f sums s)"
1.26 -
1.27 -notation suminf (binder "\<Sum>" 10)
1.28 -
1.29 -
1.30 -lemma [trans]: "f=g ==> g sums z ==> f sums z"
1.31 -  by simp
1.32 +(* TODO: MOVE *)
1.33 +lemma Suc_less_iff: "Suc n < m \<longleftrightarrow> (\<exists>m'. m = Suc m' \<and> n < m')"
1.34 +  by (cases m) auto
1.35
1.36 -lemma sumr_diff_mult_const:
1.37 - "setsum f {0..<n} - (real n*r) = setsum (%i. f i - r) {0..<n::nat}"
1.38 -  by (simp add: setsum_subtractf real_of_nat_def)
1.39 -
1.40 -lemma real_setsum_nat_ivl_bounded:
1.41 -     "(!!p. p < n \<Longrightarrow> f(p) \<le> K)
1.42 -      \<Longrightarrow> setsum f {0..<n::nat} \<le> real n * K"
1.43 -using setsum_bounded[where A = "{0..<n}"]
1.44 -by (auto simp:real_of_nat_def)
1.45 -
1.46 -(* Generalize from real to some algebraic structure? *)
1.47 -lemma sumr_minus_one_realpow_zero [simp]:
1.48 -  "(\<Sum>i=0..<2*n. (-1) ^ Suc i) = (0::real)"
1.49 -by (induct "n", auto)
1.50 -
1.51 -(* FIXME this is an awful lemma! *)
1.52 -lemma sumr_one_lb_realpow_zero [simp]:
1.53 -  "(\<Sum>n=Suc 0..<n. f(n) * (0::real) ^ n) = 0"
1.54 -by (rule setsum_0', simp)
1.55 -
1.56 -lemma sumr_group:
1.57 -     "(\<Sum>m=0..<n::nat. setsum f {m * k ..< m*k + k}) = setsum f {0 ..< n * k}"
1.58 -apply (subgoal_tac "k = 0 | 0 < k", auto)
1.59 -apply (induct "n")
1.61 +(* TODO: MOVE *)
1.62 +lemma norm_ratiotest_lemma:
1.63 +  fixes x y :: "'a::real_normed_vector"
1.64 +  shows "\<lbrakk>c \<le> 0; norm x \<le> c * norm y\<rbrakk> \<Longrightarrow> x = 0"
1.65 +apply (subgoal_tac "norm x \<le> 0", simp)
1.66 +apply (erule order_trans)
1.68  done
1.69
1.70 -lemma sumr_offset3:
1.71 -  "setsum f {0::nat..<n+k} = (\<Sum>m=0..<n. f (m+k)) + setsum f {0..<k}"
1.72 -apply (subst setsum_shift_bounds_nat_ivl [symmetric])
1.74 +(* TODO: MOVE *)
1.75 +lemma rabs_ratiotest_lemma: "[| c \<le> 0; abs x \<le> c * abs y |] ==> x = (0::real)"
1.76 +by (erule norm_ratiotest_lemma, simp)
1.77 +
1.78 +(* TODO: MOVE *)
1.79 +lemma le_Suc_ex: "(k::nat) \<le> l ==> (\<exists>n. l = k + n)"
1.80 +apply (drule le_imp_less_or_eq)
1.82  done
1.83
1.84 -lemma sumr_offset:
1.85 -  fixes f :: "nat \<Rightarrow> 'a::ab_group_add"
1.86 -  shows "(\<Sum>m=0..<n. f(m+k)) = setsum f {0..<n+k} - setsum f {0..<k}"
1.88 +(* MOVE *)
1.89 +lemma setsum_even_minus_one [simp]: "(\<Sum>i<2 * n. (-1) ^ Suc i) = (0::'a::ring_1)"
1.90 +  by (induct "n") auto
1.91 +
1.92 +(* MOVE *)
1.93 +lemma setsum_nat_group: "(\<Sum>m<n::nat. setsum f {m * k ..< m*k + k}) = setsum f {..< n * k}"
1.94 +  apply (subgoal_tac "k = 0 | 0 < k", auto)
1.95 +  apply (induct "n")
1.97 +  done
1.98
1.99 -lemma sumr_offset2:
1.100 - "\<forall>f. (\<Sum>m=0..<n::nat. f(m+k)::real) = setsum f {0..<n+k} - setsum f {0..<k}"
1.102 +(* MOVE *)
1.103 +lemma norm_setsum:
1.104 +  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
1.105 +  shows "norm (setsum f A) \<le> (\<Sum>i\<in>A. norm (f i))"
1.106 +  apply (case_tac "finite A")
1.107 +  apply (erule finite_induct)
1.108 +  apply simp
1.109 +  apply simp
1.110 +  apply (erule order_trans [OF norm_triangle_ineq add_left_mono])
1.111 +  apply simp
1.112 +  done
1.113
1.114 -lemma sumr_offset4:
1.115 -  "\<forall>n f. setsum f {0::nat..<n+k} = (\<Sum>m=0..<n. f (m+k)::real) + setsum f {0..<k}"
1.116 -by (clarify, rule sumr_offset3)
1.117 +(* MOVE *)
1.118 +lemma norm_bound_subset:
1.119 +  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
1.120 +  assumes "finite s" "t \<subseteq> s"
1.121 +  assumes le: "(\<And>x. x \<in> s \<Longrightarrow> norm(f x) \<le> g x)"
1.122 +  shows "norm (setsum f t) \<le> setsum g s"
1.123 +proof -
1.124 +  have "norm (setsum f t) \<le> (\<Sum>i\<in>t. norm (f i))"
1.125 +    by (rule norm_setsum)
1.126 +  also have "\<dots> \<le> (\<Sum>i\<in>t. g i)"
1.127 +    using assms by (auto intro!: setsum_mono)
1.128 +  also have "\<dots> \<le> setsum g s"
1.129 +    using assms order.trans[OF norm_ge_zero le]
1.130 +    by (auto intro!: setsum_mono3)
1.131 +  finally show ?thesis .
1.132 +qed
1.133
1.134 -subsection{* Infinite Sums, by the Properties of Limits*}
1.135 +(* MOVE *)
1.136 +lemma (in linorder) lessThan_minus_lessThan [simp]:
1.137 +  "{..< n} - {..< m} = {m ..< n}"
1.138 +  by auto
1.139 +
1.140 +definition
1.141 +  sums :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> 'a \<Rightarrow> bool"
1.142 +  (infixr "sums" 80)
1.143 +where
1.144 +  "f sums s \<longleftrightarrow> (\<lambda>n. \<Sum>i<n. f i) ----> s"
1.145
1.146 -(*----------------------
1.147 -   suminf is the sum
1.148 - ---------------------*)
1.149 -lemma sums_summable: "f sums l ==> summable f"
1.150 +definition summable :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> bool" where
1.151 +   "summable f \<longleftrightarrow> (\<exists>s. f sums s)"
1.152 +
1.153 +definition
1.154 +  suminf :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> 'a"
1.155 +  (binder "\<Sum>" 10)
1.156 +where
1.157 +  "suminf f = (THE s. f sums s)"
1.158 +
1.159 +lemma sums_subst[trans]: "f = g \<Longrightarrow> g sums z \<Longrightarrow> f sums z"
1.160 +  by simp
1.161 +
1.162 +lemma sums_summable: "f sums l \<Longrightarrow> summable f"
1.163    by (simp add: sums_def summable_def, blast)
1.164
1.165 -lemma summable_sums:
1.166 -  fixes f :: "nat \<Rightarrow> 'a::{t2_space, comm_monoid_add}"
1.167 -  assumes "summable f"
1.168 -  shows "f sums (suminf f)"
1.169 -proof -
1.170 -  from assms obtain s where s: "(\<lambda>n. setsum f {0..<n}) ----> s"
1.171 -    unfolding summable_def sums_def [abs_def] ..
1.172 -  then show ?thesis unfolding sums_def [abs_def] suminf_def
1.173 -    by (rule theI, auto intro!: tendsto_unique[OF trivial_limit_sequentially])
1.174 -qed
1.175 +lemma summable_iff_convergent: "summable f \<longleftrightarrow> convergent (\<lambda>n. \<Sum>i<n. f i)"
1.176 +  by (simp add: summable_def sums_def convergent_def)
1.177
1.178 -lemma summable_sumr_LIMSEQ_suminf:
1.179 -  fixes f :: "nat \<Rightarrow> 'a::{t2_space, comm_monoid_add}"
1.180 -  shows "summable f \<Longrightarrow> (\<lambda>n. setsum f {0..<n}) ----> suminf f"
1.181 -by (rule summable_sums [unfolded sums_def])
1.182 -
1.183 -lemma suminf_eq_lim: "suminf f = lim (%n. setsum f {0..<n})"
1.184 +lemma suminf_eq_lim: "suminf f = lim (\<lambda>n. \<Sum>i<n. f i)"
1.185    by (simp add: suminf_def sums_def lim_def)
1.186
1.187 -(*-------------------
1.188 -    sum is unique
1.189 - ------------------*)
1.190 -lemma sums_unique:
1.191 -  fixes f :: "nat \<Rightarrow> 'a::{t2_space, comm_monoid_add}"
1.192 -  shows "f sums s \<Longrightarrow> (s = suminf f)"
1.193 -apply (frule sums_summable[THEN summable_sums])
1.194 -apply (auto intro!: tendsto_unique[OF trivial_limit_sequentially] simp add: sums_def)
1.195 -done
1.196 -
1.197 -lemma sums_iff:
1.198 -  fixes f :: "nat \<Rightarrow> 'a::{t2_space, comm_monoid_add}"
1.199 -  shows "f sums x \<longleftrightarrow> summable f \<and> (suminf f = x)"
1.200 -  by (metis summable_sums sums_summable sums_unique)
1.201 -
1.202  lemma sums_finite:
1.203 -  assumes [simp]: "finite N"
1.204 -  assumes f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 0"
1.205 +  assumes [simp]: "finite N" and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 0"
1.206    shows "f sums (\<Sum>n\<in>N. f n)"
1.207  proof -
1.208    { fix n
1.209 @@ -146,266 +133,76 @@
1.211  qed
1.212
1.213 -lemma suminf_finite:
1.214 -  fixes f :: "nat \<Rightarrow> 'a::{comm_monoid_add,t2_space}"
1.215 -  assumes N: "finite N" and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 0"
1.216 -  shows "suminf f = (\<Sum>n\<in>N. f n)"
1.217 -  using sums_finite[OF assms, THEN sums_unique] by simp
1.218 -
1.219 -lemma sums_If_finite_set:
1.220 -  "finite A \<Longrightarrow> (\<lambda>r. if r \<in> A then f r else 0 :: 'a::{comm_monoid_add,t2_space}) sums (\<Sum>r\<in>A. f r)"
1.221 +lemma sums_If_finite_set: "finite A \<Longrightarrow> (\<lambda>r. if r \<in> A then f r else 0) sums (\<Sum>r\<in>A. f r)"
1.222    using sums_finite[of A "(\<lambda>r. if r \<in> A then f r else 0)"] by simp
1.223
1.224 -lemma sums_If_finite:
1.225 -  "finite {r. P r} \<Longrightarrow> (\<lambda>r. if P r then f r else 0 :: 'a::{comm_monoid_add,t2_space}) sums (\<Sum>r | P r. f r)"
1.226 -  using sums_If_finite_set[of "{r. P r}" f] by simp
1.227 -
1.228 -lemma sums_single:
1.229 -  "(\<lambda>r. if r = i then f r else 0::'a::{comm_monoid_add,t2_space}) sums f i"
1.230 -  using sums_If_finite[of "\<lambda>r. r = i" f] by simp
1.231 -
1.232 -lemma sums_split_initial_segment:
1.233 -  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.234 -  shows "f sums s ==> (\<lambda>n. f(n + k)) sums (s - (SUM i = 0..< k. f i))"
1.235 -  apply (unfold sums_def)
1.236 -  apply (simp add: sumr_offset)
1.237 -  apply (rule tendsto_diff [OF _ tendsto_const])
1.238 -  apply (rule LIMSEQ_ignore_initial_segment)
1.239 -  apply assumption
1.240 -done
1.241 -
1.242 -lemma summable_ignore_initial_segment:
1.243 -  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.244 -  shows "summable f ==> summable (%n. f(n + k))"
1.245 -  apply (unfold summable_def)
1.246 -  apply (auto intro: sums_split_initial_segment)
1.247 -done
1.248 -
1.249 -lemma suminf_minus_initial_segment:
1.250 -  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.251 -  shows "summable f ==>
1.252 -    suminf f = s ==> suminf (%n. f(n + k)) = s - (SUM i = 0..< k. f i)"
1.253 -  apply (frule summable_ignore_initial_segment)
1.254 -  apply (rule sums_unique [THEN sym])
1.255 -  apply (frule summable_sums)
1.256 -  apply (rule sums_split_initial_segment)
1.257 -  apply auto
1.258 -done
1.259 +lemma sums_If_finite: "finite {r. P r} \<Longrightarrow> (\<lambda>r. if P r then f r else 0) sums (\<Sum>r | P r. f r)"
1.260 +  using sums_If_finite_set[of "{r. P r}"] by simp
1.261
1.262 -lemma suminf_split_initial_segment:
1.263 -  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.264 -  shows "summable f ==>
1.265 -    suminf f = (SUM i = 0..< k. f i) + (\<Sum>n. f(n + k))"
1.266 -by (auto simp add: suminf_minus_initial_segment)
1.267 -
1.268 -lemma suminf_exist_split: fixes r :: real assumes "0 < r" and "summable a"
1.269 -  shows "\<exists> N. \<forall> n \<ge> N. \<bar> \<Sum> i. a (i + n) \<bar> < r"
1.270 -proof -
1.271 -  from LIMSEQ_D[OF summable_sumr_LIMSEQ_suminf[OF `summable a`] `0 < r`]
1.272 -  obtain N :: nat where "\<forall> n \<ge> N. norm (setsum a {0..<n} - suminf a) < r" by auto
1.273 -  thus ?thesis unfolding suminf_minus_initial_segment[OF `summable a` refl] abs_minus_commute real_norm_def
1.274 -    by auto
1.275 -qed
1.276 +lemma sums_single: "(\<lambda>r. if r = i then f r else 0) sums f i"
1.277 +  using sums_If_finite[of "\<lambda>r. r = i"] by simp
1.278
1.279 -lemma sums_Suc:
1.280 -  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.281 -  assumes sumSuc: "(\<lambda> n. f (Suc n)) sums l" shows "f sums (l + f 0)"
1.282 -proof -
1.283 -  from sumSuc[unfolded sums_def]
1.284 -  have "(\<lambda>i. \<Sum>n = Suc 0..<Suc i. f n) ----> l" unfolding setsum_reindex[OF inj_Suc] image_Suc_atLeastLessThan[symmetric] comp_def .
1.285 -  from tendsto_add[OF this tendsto_const, where b="f 0"]
1.286 -  have "(\<lambda>i. \<Sum>n = 0..<Suc i. f n) ----> l + f 0" unfolding add_commute setsum_head_upt_Suc[OF zero_less_Suc] .
1.287 -  thus ?thesis unfolding sums_def by (rule LIMSEQ_imp_Suc)
1.288 -qed
1.289 -
1.290 -lemma series_zero:
1.291 -  fixes f :: "nat \<Rightarrow> 'a::{t2_space, comm_monoid_add}"
1.292 -  assumes "\<forall>m. n \<le> m \<longrightarrow> f m = 0"
1.293 -  shows "f sums (setsum f {0..<n})"
1.294 -proof -
1.295 -  { fix k :: nat have "setsum f {0..<k + n} = setsum f {0..<n}"
1.296 -      using assms by (induct k) auto }
1.297 -  note setsum_const = this
1.298 -  show ?thesis
1.299 -    unfolding sums_def
1.300 -    apply (rule LIMSEQ_offset[of _ n])
1.301 -    unfolding setsum_const
1.302 -    apply (rule tendsto_const)
1.303 -    done
1.304 -qed
1.305 +lemma series_zero: (* REMOVE *)
1.306 +  "(\<And>m. n \<le> m \<Longrightarrow> f m = 0) \<Longrightarrow> f sums (\<Sum>i<n. f i)"
1.307 +  by (rule sums_finite) auto
1.308
1.309  lemma sums_zero[simp, intro]: "(\<lambda>n. 0) sums 0"
1.310    unfolding sums_def by (simp add: tendsto_const)
1.311
1.312  lemma summable_zero[simp, intro]: "summable (\<lambda>n. 0)"
1.313 -by (rule sums_zero [THEN sums_summable])
1.314 +  by (rule sums_zero [THEN sums_summable])
1.315 +
1.316 +lemma sums_group: "f sums s \<Longrightarrow> 0 < k \<Longrightarrow> (\<lambda>n. setsum f {n * k ..< n * k + k}) sums s"
1.317 +  apply (simp only: sums_def setsum_nat_group tendsto_def eventually_sequentially)
1.318 +  apply safe
1.319 +  apply (erule_tac x=S in allE)
1.320 +  apply safe
1.321 +  apply (rule_tac x="N" in exI, safe)
1.322 +  apply (drule_tac x="n*k" in spec)
1.323 +  apply (erule mp)
1.324 +  apply (erule order_trans)
1.325 +  apply simp
1.326 +  done
1.327 +
1.328 +context
1.329 +  fixes f :: "nat \<Rightarrow> 'a::{t2_space, comm_monoid_add}"
1.330 +begin
1.331 +
1.332 +lemma summable_sums[intro]: "summable f \<Longrightarrow> f sums (suminf f)"
1.333 +  by (simp add: summable_def sums_def suminf_def)
1.334 +     (metis convergent_LIMSEQ_iff convergent_def lim_def)
1.335 +
1.336 +lemma summable_LIMSEQ: "summable f \<Longrightarrow> (\<lambda>n. \<Sum>i<n. f i) ----> suminf f"
1.337 +  by (rule summable_sums [unfolded sums_def])
1.338 +
1.339 +lemma sums_unique: "f sums s \<Longrightarrow> s = suminf f"
1.340 +  by (metis limI suminf_eq_lim sums_def)
1.341 +
1.342 +lemma sums_iff: "f sums x \<longleftrightarrow> summable f \<and> (suminf f = x)"
1.343 +  by (metis summable_sums sums_summable sums_unique)
1.344 +
1.345 +lemma suminf_finite:
1.346 +  assumes N: "finite N" and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 0"
1.347 +  shows "suminf f = (\<Sum>n\<in>N. f n)"
1.348 +  using sums_finite[OF assms, THEN sums_unique] by simp
1.349 +
1.350 +end
1.351
1.352  lemma suminf_zero[simp]: "suminf (\<lambda>n. 0::'a::{t2_space, comm_monoid_add}) = 0"
1.353 -by (rule sums_zero [THEN sums_unique, symmetric])
1.354 -
1.355 -lemma (in bounded_linear) sums:
1.356 -  "(\<lambda>n. X n) sums a \<Longrightarrow> (\<lambda>n. f (X n)) sums (f a)"
1.357 -  unfolding sums_def by (drule tendsto, simp only: setsum)
1.358 -
1.359 -lemma (in bounded_linear) summable:
1.360 -  "summable (\<lambda>n. X n) \<Longrightarrow> summable (\<lambda>n. f (X n))"
1.361 -unfolding summable_def by (auto intro: sums)
1.362 -
1.363 -lemma (in bounded_linear) suminf:
1.364 -  "summable (\<lambda>n. X n) \<Longrightarrow> f (\<Sum>n. X n) = (\<Sum>n. f (X n))"
1.365 -by (intro sums_unique sums summable_sums)
1.366 -
1.367 -lemmas sums_of_real = bounded_linear.sums [OF bounded_linear_of_real]
1.368 -lemmas summable_of_real = bounded_linear.summable [OF bounded_linear_of_real]
1.369 -lemmas suminf_of_real = bounded_linear.suminf [OF bounded_linear_of_real]
1.370 -
1.371 -lemma sums_mult:
1.372 -  fixes c :: "'a::real_normed_algebra"
1.373 -  shows "f sums a \<Longrightarrow> (\<lambda>n. c * f n) sums (c * a)"
1.374 -  by (rule bounded_linear.sums [OF bounded_linear_mult_right])
1.375 -
1.376 -lemma summable_mult:
1.377 -  fixes c :: "'a::real_normed_algebra"
1.378 -  shows "summable f \<Longrightarrow> summable (%n. c * f n)"
1.379 -  by (rule bounded_linear.summable [OF bounded_linear_mult_right])
1.380 -
1.381 -lemma suminf_mult:
1.382 -  fixes c :: "'a::real_normed_algebra"
1.383 -  shows "summable f \<Longrightarrow> suminf (\<lambda>n. c * f n) = c * suminf f"
1.384 -  by (rule bounded_linear.suminf [OF bounded_linear_mult_right, symmetric])
1.385 -
1.386 -lemma sums_mult2:
1.387 -  fixes c :: "'a::real_normed_algebra"
1.388 -  shows "f sums a \<Longrightarrow> (\<lambda>n. f n * c) sums (a * c)"
1.389 -  by (rule bounded_linear.sums [OF bounded_linear_mult_left])
1.390 -
1.391 -lemma summable_mult2:
1.392 -  fixes c :: "'a::real_normed_algebra"
1.393 -  shows "summable f \<Longrightarrow> summable (\<lambda>n. f n * c)"
1.394 -  by (rule bounded_linear.summable [OF bounded_linear_mult_left])
1.395 -
1.396 -lemma suminf_mult2:
1.397 -  fixes c :: "'a::real_normed_algebra"
1.398 -  shows "summable f \<Longrightarrow> suminf f * c = (\<Sum>n. f n * c)"
1.399 -  by (rule bounded_linear.suminf [OF bounded_linear_mult_left])
1.400 -
1.401 -lemma sums_divide:
1.402 -  fixes c :: "'a::real_normed_field"
1.403 -  shows "f sums a \<Longrightarrow> (\<lambda>n. f n / c) sums (a / c)"
1.404 -  by (rule bounded_linear.sums [OF bounded_linear_divide])
1.405 -
1.406 -lemma summable_divide:
1.407 -  fixes c :: "'a::real_normed_field"
1.408 -  shows "summable f \<Longrightarrow> summable (\<lambda>n. f n / c)"
1.409 -  by (rule bounded_linear.summable [OF bounded_linear_divide])
1.410 -
1.411 -lemma suminf_divide:
1.412 -  fixes c :: "'a::real_normed_field"
1.413 -  shows "summable f \<Longrightarrow> suminf (\<lambda>n. f n / c) = suminf f / c"
1.414 -  by (rule bounded_linear.suminf [OF bounded_linear_divide, symmetric])
1.415 -
1.417 -  fixes a b :: "'a::real_normed_field"
1.418 -  shows "\<lbrakk>X sums a; Y sums b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n + Y n) sums (a + b)"
1.420 -
1.422 -  fixes X Y :: "nat \<Rightarrow> 'a::real_normed_field"
1.423 -  shows "\<lbrakk>summable X; summable Y\<rbrakk> \<Longrightarrow> summable (\<lambda>n. X n + Y n)"
1.424 -unfolding summable_def by (auto intro: sums_add)
1.425 +  by (rule sums_zero [THEN sums_unique, symmetric])
1.426
1.428 -  fixes X Y :: "nat \<Rightarrow> 'a::real_normed_field"
1.429 -  shows "\<lbrakk>summable X; summable Y\<rbrakk> \<Longrightarrow> suminf X + suminf Y = (\<Sum>n. X n + Y n)"
1.430 -by (intro sums_unique sums_add summable_sums)
1.431 -
1.432 -lemma sums_diff:
1.433 -  fixes X Y :: "nat \<Rightarrow> 'a::real_normed_field"
1.434 -  shows "\<lbrakk>X sums a; Y sums b\<rbrakk> \<Longrightarrow> (\<lambda>n. X n - Y n) sums (a - b)"
1.435 -  unfolding sums_def by (simp add: setsum_subtractf tendsto_diff)
1.436 -
1.437 -lemma summable_diff:
1.438 -  fixes X Y :: "nat \<Rightarrow> 'a::real_normed_field"
1.439 -  shows "\<lbrakk>summable X; summable Y\<rbrakk> \<Longrightarrow> summable (\<lambda>n. X n - Y n)"
1.440 -unfolding summable_def by (auto intro: sums_diff)
1.441 -
1.442 -lemma suminf_diff:
1.443 -  fixes X Y :: "nat \<Rightarrow> 'a::real_normed_field"
1.444 -  shows "\<lbrakk>summable X; summable Y\<rbrakk> \<Longrightarrow> suminf X - suminf Y = (\<Sum>n. X n - Y n)"
1.445 -by (intro sums_unique sums_diff summable_sums)
1.446 -
1.447 -lemma sums_minus:
1.448 -  fixes X :: "nat \<Rightarrow> 'a::real_normed_field"
1.449 -  shows "X sums a ==> (\<lambda>n. - X n) sums (- a)"
1.450 -  unfolding sums_def by (simp add: setsum_negf tendsto_minus)
1.451 -
1.452 -lemma summable_minus:
1.453 -  fixes X :: "nat \<Rightarrow> 'a::real_normed_field"
1.454 -  shows "summable X \<Longrightarrow> summable (\<lambda>n. - X n)"
1.455 -unfolding summable_def by (auto intro: sums_minus)
1.456 -
1.457 -lemma suminf_minus:
1.458 -  fixes X :: "nat \<Rightarrow> 'a::real_normed_field"
1.459 -  shows "summable X \<Longrightarrow> (\<Sum>n. - X n) = - (\<Sum>n. X n)"
1.460 -by (intro sums_unique [symmetric] sums_minus summable_sums)
1.461 +context
1.462 +  fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
1.463 +begin
1.464
1.465 -lemma sums_group:
1.466 -  fixes f :: "nat \<Rightarrow> 'a::real_normed_field"
1.467 -  shows "\<lbrakk>f sums s; 0 < k\<rbrakk> \<Longrightarrow> (\<lambda>n. setsum f {n*k..<n*k+k}) sums s"
1.468 -apply (simp only: sums_def sumr_group)
1.469 -apply (unfold LIMSEQ_iff, safe)
1.470 -apply (drule_tac x="r" in spec, safe)
1.471 -apply (rule_tac x="no" in exI, safe)
1.472 -apply (drule_tac x="n*k" in spec)
1.473 -apply (erule mp)
1.474 -apply (erule order_trans)
1.475 -apply simp
1.476 -done
1.477 -
1.478 -text{*A summable series of positive terms has limit that is at least as
1.479 -great as any partial sum.*}
1.480 -
1.481 -lemma pos_summable:
1.482 -  fixes f:: "nat \<Rightarrow> real"
1.483 -  assumes pos: "\<And>n. 0 \<le> f n" and le: "\<And>n. setsum f {0..<n} \<le> x"
1.484 -  shows "summable f"
1.485 -proof -
1.486 -  have "convergent (\<lambda>n. setsum f {0..<n})"
1.487 -    proof (rule Bseq_mono_convergent)
1.488 -      show "Bseq (\<lambda>n. setsum f {0..<n})"
1.489 -        by (intro BseqI'[of _ x]) (auto simp add: setsum_nonneg pos intro: le)
1.490 -    next
1.491 -      show "\<forall>m n. m \<le> n \<longrightarrow> setsum f {0..<m} \<le> setsum f {0..<n}"
1.492 -        by (auto intro: setsum_mono2 pos)
1.493 -    qed
1.494 -  thus ?thesis
1.495 -    by (force simp add: summable_def sums_def convergent_def)
1.496 -qed
1.497 -
1.498 -lemma series_pos_le:
1.499 -  fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
1.500 -  shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 \<le> f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} \<le> suminf f"
1.501 -  apply (drule summable_sums)
1.502 -  apply (simp add: sums_def)
1.503 -  apply (rule LIMSEQ_le_const)
1.504 +lemma series_pos_le: "summable f \<Longrightarrow> \<forall>m\<ge>n. 0 \<le> f m \<Longrightarrow> setsum f {..<n} \<le> suminf f"
1.505 +  apply (rule LIMSEQ_le_const[OF summable_LIMSEQ])
1.506    apply assumption
1.507    apply (intro exI[of _ n])
1.508 -  apply (auto intro!: setsum_mono2)
1.509 +  apply (auto intro!: setsum_mono2 simp: not_le[symmetric])
1.510    done
1.511
1.512 -lemma series_pos_less:
1.514 -  shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 < f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} < suminf f"
1.515 -  apply (rule_tac y="setsum f {0..<Suc n}" in order_less_le_trans)
1.516 -  using add_less_cancel_left [of "setsum f {0..<n}" 0 "f n"]
1.517 -  apply simp
1.518 -  apply (erule series_pos_le)
1.519 -  apply (simp add: order_less_imp_le)
1.520 -  done
1.521 -
1.522 -lemma suminf_eq_zero_iff:
1.523 -  fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
1.524 -  shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> suminf f = 0 \<longleftrightarrow> (\<forall>n. f n = 0)"
1.525 +lemma suminf_eq_zero_iff: "summable f \<Longrightarrow> \<forall>n. 0 \<le> f n \<Longrightarrow> suminf f = 0 \<longleftrightarrow> (\<forall>n. f n = 0)"
1.526  proof
1.527    assume "summable f" "suminf f = 0" and pos: "\<forall>n. 0 \<le> f n"
1.528    then have "f sums 0"
1.529 @@ -419,77 +216,208 @@
1.530    qed
1.531    with pos show "\<forall>n. f n = 0"
1.532      by (auto intro!: antisym)
1.533 -next
1.534 -  assume "\<forall>n. f n = 0"
1.535 -  then have "f = (\<lambda>n. 0)"
1.536 -    by auto
1.537 -  then show "suminf f = 0"
1.538 -    by simp
1.539 +qed (metis suminf_zero fun_eq_iff)
1.540 +
1.541 +lemma suminf_gt_zero_iff: "summable f \<Longrightarrow> \<forall>n. 0 \<le> f n \<Longrightarrow> 0 < suminf f \<longleftrightarrow> (\<exists>i. 0 < f i)"
1.542 +  using series_pos_le[of 0] suminf_eq_zero_iff by (simp add: less_le)
1.543 +
1.544 +lemma suminf_gt_zero: "summable f \<Longrightarrow> \<forall>n. 0 < f n \<Longrightarrow> 0 < suminf f"
1.545 +  using suminf_gt_zero_iff by (simp add: less_imp_le)
1.546 +
1.547 +lemma suminf_ge_zero: "summable f \<Longrightarrow> \<forall>n. 0 \<le> f n \<Longrightarrow> 0 \<le> suminf f"
1.548 +  by (drule_tac n="0" in series_pos_le) simp_all
1.549 +
1.550 +lemma suminf_le: "summable f \<Longrightarrow> (\<And>n. setsum f {..<n} \<le> x) \<Longrightarrow> suminf f \<le> x"
1.551 +  by (metis LIMSEQ_le_const2 summable_LIMSEQ)
1.552 +
1.553 +lemma summable_le: "\<lbrakk>\<forall>n. f n \<le> g n; summable f; summable g\<rbrakk> \<Longrightarrow> suminf f \<le> suminf g"
1.554 +  by (rule LIMSEQ_le) (auto intro: setsum_mono summable_LIMSEQ)
1.555 +
1.556 +end
1.557 +
1.558 +lemma series_pos_less:
1.560 +  shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 < f m\<rbrakk> \<Longrightarrow> setsum f {..<n} < suminf f"
1.561 +  apply simp
1.562 +  apply (rule_tac y="setsum f {..<Suc n}" in order_less_le_trans)
1.563 +  using add_less_cancel_left [of "setsum f {..<n}" 0 "f n"]
1.564 +  apply simp
1.565 +  apply (erule series_pos_le)
1.566 +  apply (simp add: order_less_imp_le)
1.567 +  done
1.568 +
1.569 +lemma sums_Suc_iff:
1.570 +  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.571 +  shows "(\<lambda>n. f (Suc n)) sums s \<longleftrightarrow> f sums (s + f 0)"
1.572 +proof -
1.573 +  have "f sums (s + f 0) \<longleftrightarrow> (\<lambda>i. \<Sum>j<Suc i. f j) ----> s + f 0"
1.574 +    by (subst LIMSEQ_Suc_iff) (simp add: sums_def)
1.575 +  also have "\<dots> \<longleftrightarrow> (\<lambda>i. (\<Sum>j<i. f (Suc j)) + f 0) ----> s + f 0"
1.576 +    by (simp add: ac_simps setsum_reindex image_iff lessThan_Suc_eq_insert_0)
1.577 +  also have "\<dots> \<longleftrightarrow> (\<lambda>n. f (Suc n)) sums s"
1.578 +  proof
1.579 +    assume "(\<lambda>i. (\<Sum>j<i. f (Suc j)) + f 0) ----> s + f 0"
1.580 +    with tendsto_add[OF this tendsto_const, of "- f 0"]
1.581 +    show "(\<lambda>i. f (Suc i)) sums s"
1.582 +      by (simp add: sums_def)
1.583 +  qed (auto intro: tendsto_add tendsto_const simp: sums_def)
1.584 +  finally show ?thesis ..
1.585  qed
1.586
1.587 -lemma suminf_gt_zero_iff:
1.588 -  fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
1.589 -  shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> 0 < suminf f \<longleftrightarrow> (\<exists>i. 0 < f i)"
1.590 -  using series_pos_le[of f 0] suminf_eq_zero_iff[of f]
1.591 -  by (simp add: less_le)
1.592 +context
1.593 +  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.594 +begin
1.595 +
1.596 +lemma sums_add: "f sums a \<Longrightarrow> g sums b \<Longrightarrow> (\<lambda>n. f n + g n) sums (a + b)"
1.598 +
1.599 +lemma summable_add: "summable f \<Longrightarrow> summable g \<Longrightarrow> summable (\<lambda>n. f n + g n)"
1.600 +  unfolding summable_def by (auto intro: sums_add)
1.601 +
1.602 +lemma suminf_add: "summable f \<Longrightarrow> summable g \<Longrightarrow> suminf f + suminf g = (\<Sum>n. f n + g n)"
1.603 +  by (intro sums_unique sums_add summable_sums)
1.604 +
1.605 +lemma sums_diff: "f sums a \<Longrightarrow> g sums b \<Longrightarrow> (\<lambda>n. f n - g n) sums (a - b)"
1.606 +  unfolding sums_def by (simp add: setsum_subtractf tendsto_diff)
1.607 +
1.608 +lemma summable_diff: "summable f \<Longrightarrow> summable g \<Longrightarrow> summable (\<lambda>n. f n - g n)"
1.609 +  unfolding summable_def by (auto intro: sums_diff)
1.610 +
1.611 +lemma suminf_diff: "summable f \<Longrightarrow> summable g \<Longrightarrow> suminf f - suminf g = (\<Sum>n. f n - g n)"
1.612 +  by (intro sums_unique sums_diff summable_sums)
1.613 +
1.614 +lemma sums_minus: "f sums a \<Longrightarrow> (\<lambda>n. - f n) sums (- a)"
1.615 +  unfolding sums_def by (simp add: setsum_negf tendsto_minus)
1.616 +
1.617 +lemma summable_minus: "summable f \<Longrightarrow> summable (\<lambda>n. - f n)"
1.618 +  unfolding summable_def by (auto intro: sums_minus)
1.619
1.620 -lemma suminf_gt_zero:
1.621 -  fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
1.622 -  shows "\<lbrakk>summable f; \<forall>n. 0 < f n\<rbrakk> \<Longrightarrow> 0 < suminf f"
1.623 -  using suminf_gt_zero_iff[of f] by (simp add: less_imp_le)
1.624 +lemma suminf_minus: "summable f \<Longrightarrow> (\<Sum>n. - f n) = - (\<Sum>n. f n)"
1.625 +  by (intro sums_unique [symmetric] sums_minus summable_sums)
1.626 +
1.627 +lemma sums_Suc: "(\<lambda> n. f (Suc n)) sums l \<Longrightarrow> f sums (l + f 0)"
1.628 +  by (simp add: sums_Suc_iff)
1.629 +
1.630 +lemma sums_iff_shift: "(\<lambda>i. f (i + n)) sums s \<longleftrightarrow> f sums (s + (\<Sum>i<n. f i))"
1.631 +proof (induct n arbitrary: s)
1.632 +  case (Suc n)
1.633 +  moreover have "(\<lambda>i. f (Suc i + n)) sums s \<longleftrightarrow> (\<lambda>i. f (i + n)) sums (s + f n)"
1.634 +    by (subst sums_Suc_iff) simp
1.635 +  ultimately show ?case
1.636 +    by (simp add: ac_simps)
1.637 +qed simp
1.638
1.639 -lemma suminf_ge_zero:
1.640 -  fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
1.641 -  shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> 0 \<le> suminf f"
1.642 -  by (drule_tac n="0" in series_pos_le, simp_all)
1.643 +lemma summable_iff_shift: "summable (\<lambda>n. f (n + k)) \<longleftrightarrow> summable f"
1.644 +  by (metis diff_add_cancel summable_def sums_iff_shift[abs_def])
1.645 +
1.646 +lemma sums_split_initial_segment: "f sums s \<Longrightarrow> (\<lambda>i. f (i + n)) sums (s - (\<Sum>i<n. f i))"
1.647 +  by (simp add: sums_iff_shift)
1.648 +
1.649 +lemma summable_ignore_initial_segment: "summable f \<Longrightarrow> summable (\<lambda>n. f(n + k))"
1.650 +  by (simp add: summable_iff_shift)
1.651 +
1.652 +lemma suminf_minus_initial_segment: "summable f \<Longrightarrow> (\<Sum>n. f (n + k)) = (\<Sum>n. f n) - (\<Sum>i<k. f i)"
1.653 +  by (rule sums_unique[symmetric]) (auto simp: sums_iff_shift)
1.654 +
1.655 +lemma suminf_split_initial_segment: "summable f \<Longrightarrow> suminf f = (\<Sum>n. f(n + k)) + (\<Sum>i<k. f i)"
1.656 +  by (auto simp add: suminf_minus_initial_segment)
1.657
1.658 -lemma sumr_pos_lt_pair:
1.659 -  fixes f :: "nat \<Rightarrow> real"
1.660 -  shows "\<lbrakk>summable f;
1.661 -        \<And>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc(Suc 0) * d) + 1))\<rbrakk>
1.662 -      \<Longrightarrow> setsum f {0..<k} < suminf f"
1.663 -unfolding One_nat_def
1.664 -apply (subst suminf_split_initial_segment [where k="k"])
1.665 -apply assumption
1.666 -apply simp
1.667 -apply (drule_tac k="k" in summable_ignore_initial_segment)
1.668 -apply (drule_tac k="Suc (Suc 0)" in sums_group [OF summable_sums], simp)
1.669 -apply simp
1.670 -apply (frule sums_unique)
1.671 -apply (drule sums_summable)
1.672 -apply simp
1.673 -apply (erule suminf_gt_zero)
1.675 -done
1.676 +lemma suminf_exist_split:
1.677 +  fixes r :: real assumes "0 < r" and "summable f"
1.678 +  shows "\<exists>N. \<forall>n\<ge>N. norm (\<Sum>i. f (i + n)) < r"
1.679 +proof -
1.680 +  from LIMSEQ_D[OF summable_LIMSEQ[OF `summable f`] `0 < r`]
1.681 +  obtain N :: nat where "\<forall> n \<ge> N. norm (setsum f {..<n} - suminf f) < r" by auto
1.682 +  thus ?thesis
1.683 +    by (auto simp: norm_minus_commute suminf_minus_initial_segment[OF `summable f`])
1.684 +qed
1.685 +
1.686 +lemma summable_LIMSEQ_zero: "summable f \<Longrightarrow> f ----> 0"
1.687 +  apply (drule summable_iff_convergent [THEN iffD1])
1.688 +  apply (drule convergent_Cauchy)
1.689 +  apply (simp only: Cauchy_iff LIMSEQ_iff, safe)
1.690 +  apply (drule_tac x="r" in spec, safe)
1.691 +  apply (rule_tac x="M" in exI, safe)
1.692 +  apply (drule_tac x="Suc n" in spec, simp)
1.693 +  apply (drule_tac x="n" in spec, simp)
1.694 +  done
1.695 +
1.696 +end
1.697 +
1.698 +lemma (in bounded_linear) sums: "(\<lambda>n. X n) sums a \<Longrightarrow> (\<lambda>n. f (X n)) sums (f a)"
1.699 +  unfolding sums_def by (drule tendsto, simp only: setsum)
1.700 +
1.701 +lemma (in bounded_linear) summable: "summable (\<lambda>n. X n) \<Longrightarrow> summable (\<lambda>n. f (X n))"
1.702 +  unfolding summable_def by (auto intro: sums)
1.703 +
1.704 +lemma (in bounded_linear) suminf: "summable (\<lambda>n. X n) \<Longrightarrow> f (\<Sum>n. X n) = (\<Sum>n. f (X n))"
1.705 +  by (intro sums_unique sums summable_sums)
1.706 +
1.707 +lemmas sums_of_real = bounded_linear.sums [OF bounded_linear_of_real]
1.708 +lemmas summable_of_real = bounded_linear.summable [OF bounded_linear_of_real]
1.709 +lemmas suminf_of_real = bounded_linear.suminf [OF bounded_linear_of_real]
1.710 +
1.711 +context
1.712 +  fixes f :: "nat \<Rightarrow> 'a::real_normed_algebra"
1.713 +begin
1.714 +
1.715 +lemma sums_mult: "f sums a \<Longrightarrow> (\<lambda>n. c * f n) sums (c * a)"
1.716 +  by (rule bounded_linear.sums [OF bounded_linear_mult_right])
1.717 +
1.718 +lemma summable_mult: "summable f \<Longrightarrow> summable (\<lambda>n. c * f n)"
1.719 +  by (rule bounded_linear.summable [OF bounded_linear_mult_right])
1.720 +
1.721 +lemma suminf_mult: "summable f \<Longrightarrow> suminf (\<lambda>n. c * f n) = c * suminf f"
1.722 +  by (rule bounded_linear.suminf [OF bounded_linear_mult_right, symmetric])
1.723 +
1.724 +lemma sums_mult2: "f sums a \<Longrightarrow> (\<lambda>n. f n * c) sums (a * c)"
1.725 +  by (rule bounded_linear.sums [OF bounded_linear_mult_left])
1.726 +
1.727 +lemma summable_mult2: "summable f \<Longrightarrow> summable (\<lambda>n. f n * c)"
1.728 +  by (rule bounded_linear.summable [OF bounded_linear_mult_left])
1.729 +
1.730 +lemma suminf_mult2: "summable f \<Longrightarrow> suminf f * c = (\<Sum>n. f n * c)"
1.731 +  by (rule bounded_linear.suminf [OF bounded_linear_mult_left])
1.732 +
1.733 +end
1.734 +
1.735 +context
1.736 +  fixes c :: "'a::real_normed_field"
1.737 +begin
1.738 +
1.739 +lemma sums_divide: "f sums a \<Longrightarrow> (\<lambda>n. f n / c) sums (a / c)"
1.740 +  by (rule bounded_linear.sums [OF bounded_linear_divide])
1.741 +
1.742 +lemma summable_divide: "summable f \<Longrightarrow> summable (\<lambda>n. f n / c)"
1.743 +  by (rule bounded_linear.summable [OF bounded_linear_divide])
1.744 +
1.745 +lemma suminf_divide: "summable f \<Longrightarrow> suminf (\<lambda>n. f n / c) = suminf f / c"
1.746 +  by (rule bounded_linear.suminf [OF bounded_linear_divide, symmetric])
1.747
1.748  text{*Sum of a geometric progression.*}
1.749
1.750 -lemmas sumr_geometric = geometric_sum [where 'a = real]
1.751 -
1.752 -lemma geometric_sums:
1.753 -  fixes x :: "'a::{real_normed_field}"
1.754 -  shows "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) sums (1 / (1 - x))"
1.755 +lemma geometric_sums: "norm c < 1 \<Longrightarrow> (\<lambda>n. c^n) sums (1 / (1 - c))"
1.756  proof -
1.757 -  assume less_1: "norm x < 1"
1.758 -  hence neq_1: "x \<noteq> 1" by auto
1.759 -  hence neq_0: "x - 1 \<noteq> 0" by simp
1.760 -  from less_1 have lim_0: "(\<lambda>n. x ^ n) ----> 0"
1.761 +  assume less_1: "norm c < 1"
1.762 +  hence neq_1: "c \<noteq> 1" by auto
1.763 +  hence neq_0: "c - 1 \<noteq> 0" by simp
1.764 +  from less_1 have lim_0: "(\<lambda>n. c^n) ----> 0"
1.765      by (rule LIMSEQ_power_zero)
1.766 -  hence "(\<lambda>n. x ^ n / (x - 1) - 1 / (x - 1)) ----> 0 / (x - 1) - 1 / (x - 1)"
1.767 +  hence "(\<lambda>n. c ^ n / (c - 1) - 1 / (c - 1)) ----> 0 / (c - 1) - 1 / (c - 1)"
1.768      using neq_0 by (intro tendsto_intros)
1.769 -  hence "(\<lambda>n. (x ^ n - 1) / (x - 1)) ----> 1 / (1 - x)"
1.770 +  hence "(\<lambda>n. (c ^ n - 1) / (c - 1)) ----> 1 / (1 - c)"
1.771      by (simp add: nonzero_minus_divide_right [OF neq_0] diff_divide_distrib)
1.772 -  thus "(\<lambda>n. x ^ n) sums (1 / (1 - x))"
1.773 +  thus "(\<lambda>n. c ^ n) sums (1 / (1 - c))"
1.774      by (simp add: sums_def geometric_sum neq_1)
1.775  qed
1.776
1.777 -lemma summable_geometric:
1.778 -  fixes x :: "'a::{real_normed_field}"
1.779 -  shows "norm x < 1 \<Longrightarrow> summable (\<lambda>n. x ^ n)"
1.780 -by (rule geometric_sums [THEN sums_summable])
1.781 +lemma summable_geometric: "norm c < 1 \<Longrightarrow> summable (\<lambda>n. c^n)"
1.782 +  by (rule geometric_sums [THEN sums_summable])
1.783
1.784 -lemma half: "0 < 1 / (2::'a::linordered_field)"
1.785 -  by simp
1.786 +lemma suminf_geometric: "norm c < 1 \<Longrightarrow> suminf (\<lambda>n. c^n) = 1 / (1 - c)"
1.787 +  by (rule sums_unique[symmetric]) (rule geometric_sums)
1.788 +
1.789 +end
1.790
1.791  lemma power_half_series: "(\<lambda>n. (1/2::real)^Suc n) sums 1"
1.792  proof -
1.793 @@ -503,110 +431,104 @@
1.794
1.795  text{*Cauchy-type criterion for convergence of series (c.f. Harrison)*}
1.796
1.797 -lemma summable_convergent_sumr_iff:
1.798 - "summable f = convergent (%n. setsum f {0..<n})"
1.799 -by (simp add: summable_def sums_def convergent_def)
1.800 +lemma summable_Cauchy:
1.801 +  fixes f :: "nat \<Rightarrow> 'a::banach"
1.802 +  shows "summable f \<longleftrightarrow> (\<forall>e>0. \<exists>N. \<forall>m\<ge>N. \<forall>n. norm (setsum f {m..<n}) < e)"
1.803 +  apply (simp only: summable_iff_convergent Cauchy_convergent_iff [symmetric] Cauchy_iff, safe)
1.804 +  apply (drule spec, drule (1) mp)
1.805 +  apply (erule exE, rule_tac x="M" in exI, clarify)
1.806 +  apply (rule_tac x="m" and y="n" in linorder_le_cases)
1.807 +  apply (frule (1) order_trans)
1.808 +  apply (drule_tac x="n" in spec, drule (1) mp)
1.809 +  apply (drule_tac x="m" in spec, drule (1) mp)
1.810 +  apply (simp_all add: setsum_diff [symmetric])
1.811 +  apply (drule spec, drule (1) mp)
1.812 +  apply (erule exE, rule_tac x="N" in exI, clarify)
1.813 +  apply (rule_tac x="m" and y="n" in linorder_le_cases)
1.814 +  apply (subst norm_minus_commute)
1.815 +  apply (simp_all add: setsum_diff [symmetric])
1.816 +  done
1.817
1.818 -lemma summable_LIMSEQ_zero:
1.819 -  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
1.820 -  shows "summable f \<Longrightarrow> f ----> 0"
1.821 -apply (drule summable_convergent_sumr_iff [THEN iffD1])
1.822 -apply (drule convergent_Cauchy)
1.823 -apply (simp only: Cauchy_iff LIMSEQ_iff, safe)
1.824 -apply (drule_tac x="r" in spec, safe)
1.825 -apply (rule_tac x="M" in exI, safe)
1.826 -apply (drule_tac x="Suc n" in spec, simp)
1.827 -apply (drule_tac x="n" in spec, simp)
1.828 -done
1.829 +context
1.830 +  fixes f :: "nat \<Rightarrow> 'a::banach"
1.831 +begin
1.832 +
1.833 +text{*Absolute convergence imples normal convergence*}
1.834
1.835 -lemma suminf_le:
1.836 -  fixes x :: "'a :: {ordered_comm_monoid_add, linorder_topology}"
1.837 -  shows "summable f \<Longrightarrow> (!!n. setsum f {0..<n} \<le> x) \<Longrightarrow> suminf f \<le> x"
1.838 -  apply (drule summable_sums)
1.839 -  apply (simp add: sums_def)
1.840 -  apply (rule LIMSEQ_le_const2)
1.841 -  apply assumption
1.842 -  apply auto
1.843 +lemma summable_norm_cancel:
1.844 +  "summable (\<lambda>n. norm (f n)) \<Longrightarrow> summable f"
1.845 +  apply (simp only: summable_Cauchy, safe)
1.846 +  apply (drule_tac x="e" in spec, safe)
1.847 +  apply (rule_tac x="N" in exI, safe)
1.848 +  apply (drule_tac x="m" in spec, safe)
1.849 +  apply (rule order_le_less_trans [OF norm_setsum])
1.850 +  apply (rule order_le_less_trans [OF abs_ge_self])
1.851 +  apply simp
1.852    done
1.853
1.854 -lemma summable_Cauchy:
1.855 -     "summable (f::nat \<Rightarrow> 'a::banach) =
1.856 -      (\<forall>e > 0. \<exists>N. \<forall>m \<ge> N. \<forall>n. norm (setsum f {m..<n}) < e)"
1.857 -apply (simp only: summable_convergent_sumr_iff Cauchy_convergent_iff [symmetric] Cauchy_iff, safe)
1.858 -apply (drule spec, drule (1) mp)
1.859 -apply (erule exE, rule_tac x="M" in exI, clarify)
1.860 -apply (rule_tac x="m" and y="n" in linorder_le_cases)
1.861 -apply (frule (1) order_trans)
1.862 -apply (drule_tac x="n" in spec, drule (1) mp)
1.863 -apply (drule_tac x="m" in spec, drule (1) mp)
1.864 -apply (simp add: setsum_diff [symmetric])
1.865 -apply simp
1.866 -apply (drule spec, drule (1) mp)
1.867 -apply (erule exE, rule_tac x="N" in exI, clarify)
1.868 -apply (rule_tac x="m" and y="n" in linorder_le_cases)
1.869 -apply (subst norm_minus_commute)
1.870 -apply (simp add: setsum_diff [symmetric])
1.871 -apply (simp add: setsum_diff [symmetric])
1.872 -done
1.873 +lemma summable_norm: "summable (\<lambda>n. norm (f n)) \<Longrightarrow> norm (suminf f) \<le> (\<Sum>n. norm (f n))"
1.874 +  by (auto intro: LIMSEQ_le tendsto_norm summable_norm_cancel summable_LIMSEQ norm_setsum)
1.875 +
1.876 +text {* Comparison tests *}
1.877
1.878 -text{*Comparison test*}
1.879 +lemma summable_comparison_test: "\<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable f"
1.880 +  apply (simp add: summable_Cauchy, safe)
1.881 +  apply (drule_tac x="e" in spec, safe)
1.882 +  apply (rule_tac x = "N + Na" in exI, safe)
1.883 +  apply (rotate_tac 2)
1.884 +  apply (drule_tac x = m in spec)
1.885 +  apply (auto, rotate_tac 2, drule_tac x = n in spec)
1.886 +  apply (rule_tac y = "\<Sum>k=m..<n. norm (f k)" in order_le_less_trans)
1.887 +  apply (rule norm_setsum)
1.888 +  apply (rule_tac y = "setsum g {m..<n}" in order_le_less_trans)
1.889 +  apply (auto intro: setsum_mono simp add: abs_less_iff)
1.890 +  done
1.891 +
1.892 +subsection {* The Ratio Test*}
1.893
1.894 -lemma norm_setsum:
1.895 -  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
1.896 -  shows "norm (setsum f A) \<le> (\<Sum>i\<in>A. norm (f i))"
1.897 -apply (case_tac "finite A")
1.898 -apply (erule finite_induct)
1.899 -apply simp
1.900 -apply simp
1.901 -apply (erule order_trans [OF norm_triangle_ineq add_left_mono])
1.902 -apply simp
1.903 -done
1.904 -
1.905 -lemma norm_bound_subset:
1.906 -  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
1.907 -  assumes "finite s" "t \<subseteq> s"
1.908 -  assumes le: "(\<And>x. x \<in> s \<Longrightarrow> norm(f x) \<le> g x)"
1.909 -  shows "norm (setsum f t) \<le> setsum g s"
1.910 -proof -
1.911 -  have "norm (setsum f t) \<le> (\<Sum>i\<in>t. norm (f i))"
1.912 -    by (rule norm_setsum)
1.913 -  also have "\<dots> \<le> (\<Sum>i\<in>t. g i)"
1.914 -    using assms by (auto intro!: setsum_mono)
1.915 -  also have "\<dots> \<le> setsum g s"
1.916 -    using assms order.trans[OF norm_ge_zero le]
1.917 -    by (auto intro!: setsum_mono3)
1.918 -  finally show ?thesis .
1.919 +lemma summable_ratio_test:
1.920 +  assumes "c < 1" "\<And>n. n \<ge> N \<Longrightarrow> norm (f (Suc n)) \<le> c * norm (f n)"
1.921 +  shows "summable f"
1.922 +proof cases
1.923 +  assume "0 < c"
1.924 +  show "summable f"
1.925 +  proof (rule summable_comparison_test)
1.926 +    show "\<exists>N'. \<forall>n\<ge>N'. norm (f n) \<le> (norm (f N) / (c ^ N)) * c ^ n"
1.927 +    proof (intro exI allI impI)
1.928 +      fix n assume "N \<le> n" then show "norm (f n) \<le> (norm (f N) / (c ^ N)) * c ^ n"
1.929 +      proof (induct rule: inc_induct)
1.930 +        case (step m)
1.931 +        moreover have "norm (f (Suc m)) / c ^ Suc m * c ^ n \<le> norm (f m) / c ^ m * c ^ n"
1.932 +          using `0 < c` `c < 1` assms(2)[OF `N \<le> m`] by (simp add: field_simps)
1.933 +        ultimately show ?case by simp
1.934 +      qed (insert `0 < c`, simp)
1.935 +    qed
1.936 +    show "summable (\<lambda>n. norm (f N) / c ^ N * c ^ n)"
1.937 +      using `0 < c` `c < 1` by (intro summable_mult summable_geometric) simp
1.938 +  qed
1.939 +next
1.940 +  assume c: "\<not> 0 < c"
1.941 +  { fix n assume "n \<ge> N"
1.942 +    then have "norm (f (Suc n)) \<le> c * norm (f n)"
1.943 +      by fact
1.944 +    also have "\<dots> \<le> 0"
1.945 +      using c by (simp add: not_less mult_nonpos_nonneg)
1.946 +    finally have "f (Suc n) = 0"
1.947 +      by auto }
1.948 +  then show "summable f"
1.949 +    by (intro sums_summable[OF sums_finite, of "{.. Suc N}"]) (auto simp: not_le Suc_less_iff)
1.950  qed
1.951
1.952 -lemma summable_comparison_test:
1.953 -  fixes f :: "nat \<Rightarrow> 'a::banach"
1.954 -  shows "\<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable f"
1.955 -apply (simp add: summable_Cauchy, safe)
1.956 -apply (drule_tac x="e" in spec, safe)
1.957 -apply (rule_tac x = "N + Na" in exI, safe)
1.958 -apply (rotate_tac 2)
1.959 -apply (drule_tac x = m in spec)
1.960 -apply (auto, rotate_tac 2, drule_tac x = n in spec)
1.961 -apply (rule_tac y = "\<Sum>k=m..<n. norm (f k)" in order_le_less_trans)
1.962 -apply (rule norm_setsum)
1.963 -apply (rule_tac y = "setsum g {m..<n}" in order_le_less_trans)
1.964 -apply (auto intro: setsum_mono simp add: abs_less_iff)
1.965 -done
1.966 +end
1.967
1.968  lemma summable_norm_comparison_test:
1.969 -  fixes f :: "nat \<Rightarrow> 'a::banach"
1.970 -  shows "\<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk>
1.971 -         \<Longrightarrow> summable (\<lambda>n. norm (f n))"
1.972 -apply (rule summable_comparison_test)
1.973 -apply (auto)
1.974 -done
1.975 +  "\<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable (\<lambda>n. norm (f n))"
1.976 +  by (rule summable_comparison_test) auto
1.977
1.978 -lemma summable_rabs_comparison_test:
1.979 +lemma summable_rabs_cancel:
1.980    fixes f :: "nat \<Rightarrow> real"
1.981 -  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>)"
1.982 -apply (rule summable_comparison_test)
1.983 -apply (auto)
1.984 -done
1.985 +  shows "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> summable f"
1.986 +  by (rule summable_norm_cancel) simp
1.987
1.988  text{*Summability of geometric series for real algebras*}
1.989
1.990 @@ -620,119 +542,34 @@
1.992  qed
1.993
1.994 -text{*Limit comparison property for series (c.f. jrh)*}
1.995
1.996 -lemma summable_le:
1.997 -  fixes f g :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
1.998 -  shows "\<lbrakk>\<forall>n. f n \<le> g n; summable f; summable g\<rbrakk> \<Longrightarrow> suminf f \<le> suminf g"
1.999 -apply (drule summable_sums)+
1.1000 -apply (simp only: sums_def, erule (1) LIMSEQ_le)
1.1001 -apply (rule exI)
1.1002 -apply (auto intro!: setsum_mono)
1.1003 -done
1.1004 -
1.1005 -lemma summable_le2:
1.1006 -  fixes f g :: "nat \<Rightarrow> real"
1.1007 -  shows "\<lbrakk>\<forall>n. \<bar>f n\<bar> \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable f \<and> suminf f \<le> suminf g"
1.1008 -apply (subgoal_tac "summable f")
1.1009 -apply (auto intro!: summable_le)
1.1011 -apply (rule_tac g="g" in summable_comparison_test, simp_all)
1.1012 -done
1.1013 +text{*A summable series of positive terms has limit that is at least as
1.1014 +great as any partial sum.*}
1.1015
1.1016 -(* specialisation for the common 0 case *)
1.1017 -lemma suminf_0_le:
1.1018 -  fixes f::"nat\<Rightarrow>real"
1.1019 -  assumes gt0: "\<forall>n. 0 \<le> f n" and sm: "summable f"
1.1020 -  shows "0 \<le> suminf f"
1.1021 -  using suminf_ge_zero[OF sm gt0] by simp
1.1022 +lemma pos_summable:
1.1023 +  fixes f:: "nat \<Rightarrow> real"
1.1024 +  assumes pos: "\<And>n. 0 \<le> f n" and le: "\<And>n. setsum f {..<n} \<le> x"
1.1025 +  shows "summable f"
1.1026 +proof -
1.1027 +  have "convergent (\<lambda>n. setsum f {..<n})"
1.1028 +  proof (rule Bseq_mono_convergent)
1.1029 +    show "Bseq (\<lambda>n. setsum f {..<n})"
1.1030 +      by (intro BseqI'[of _ x]) (auto simp add: setsum_nonneg pos intro: le)
1.1031 +  qed (auto intro: setsum_mono2 pos)
1.1032 +  thus ?thesis
1.1033 +    by (force simp add: summable_def sums_def convergent_def)
1.1034 +qed
1.1035
1.1036 -text{*Absolute convergence imples normal convergence*}
1.1037 -lemma summable_norm_cancel:
1.1038 -  fixes f :: "nat \<Rightarrow> 'a::banach"
1.1039 -  shows "summable (\<lambda>n. norm (f n)) \<Longrightarrow> summable f"
1.1040 -apply (simp only: summable_Cauchy, safe)
1.1041 -apply (drule_tac x="e" in spec, safe)
1.1042 -apply (rule_tac x="N" in exI, safe)
1.1043 -apply (drule_tac x="m" in spec, safe)
1.1044 -apply (rule order_le_less_trans [OF norm_setsum])
1.1045 -apply (rule order_le_less_trans [OF abs_ge_self])
1.1046 -apply simp
1.1047 -done
1.1048 -
1.1049 -lemma summable_rabs_cancel:
1.1050 +lemma summable_rabs_comparison_test:
1.1051    fixes f :: "nat \<Rightarrow> real"
1.1052 -  shows "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> summable f"
1.1053 -by (rule summable_norm_cancel, simp)
1.1054 -
1.1055 -text{*Absolute convergence of series*}
1.1056 -lemma summable_norm:
1.1057 -  fixes f :: "nat \<Rightarrow> 'a::banach"
1.1058 -  shows "summable (\<lambda>n. norm (f n)) \<Longrightarrow> norm (suminf f) \<le> (\<Sum>n. norm (f n))"
1.1059 -  by (auto intro: LIMSEQ_le tendsto_norm summable_norm_cancel
1.1060 -                summable_sumr_LIMSEQ_suminf norm_setsum)
1.1061 +  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>)"
1.1062 +  by (rule summable_comparison_test) auto
1.1063
1.1064  lemma summable_rabs:
1.1065    fixes f :: "nat \<Rightarrow> real"
1.1066    shows "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> \<bar>suminf f\<bar> \<le> (\<Sum>n. \<bar>f n\<bar>)"
1.1067  by (fold real_norm_def, rule summable_norm)
1.1068
1.1069 -subsection{* The Ratio Test*}
1.1070 -
1.1071 -lemma norm_ratiotest_lemma:
1.1072 -  fixes x y :: "'a::real_normed_vector"
1.1073 -  shows "\<lbrakk>c \<le> 0; norm x \<le> c * norm y\<rbrakk> \<Longrightarrow> x = 0"
1.1074 -apply (subgoal_tac "norm x \<le> 0", simp)
1.1075 -apply (erule order_trans)
1.1077 -done
1.1078 -
1.1079 -lemma rabs_ratiotest_lemma: "[| c \<le> 0; abs x \<le> c * abs y |] ==> x = (0::real)"
1.1080 -by (erule norm_ratiotest_lemma, simp)
1.1081 -
1.1082 -(* TODO: MOVE *)
1.1083 -lemma le_Suc_ex: "(k::nat) \<le> l ==> (\<exists>n. l = k + n)"
1.1084 -apply (drule le_imp_less_or_eq)
1.1086 -done
1.1087 -
1.1088 -lemma le_Suc_ex_iff: "((k::nat) \<le> l) = (\<exists>n. l = k + n)"
1.1089 -by (auto simp add: le_Suc_ex)
1.1090 -
1.1091 -(*All this trouble just to get 0<c *)
1.1092 -lemma ratio_test_lemma2:
1.1093 -  fixes f :: "nat \<Rightarrow> 'a::banach"
1.1094 -  shows "\<lbrakk>\<forall>n\<ge>N. norm (f (Suc n)) \<le> c * norm (f n)\<rbrakk> \<Longrightarrow> 0 < c \<or> summable f"
1.1095 -apply (simp (no_asm) add: linorder_not_le [symmetric])
1.1097 -apply (safe, subgoal_tac "\<forall>n. N < n --> f (n) = 0")
1.1098 - prefer 2
1.1099 - apply clarify
1.1100 - apply(erule_tac x = "n - Suc 0" in allE)
1.1101 - apply (simp add:diff_Suc split:nat.splits)
1.1102 - apply (blast intro: norm_ratiotest_lemma)
1.1103 -apply (rule_tac x = "Suc N" in exI, clarify)
1.1104 -apply(simp cong del: setsum_cong cong: setsum_ivl_cong)
1.1105 -done
1.1106 -
1.1107 -lemma ratio_test:
1.1108 -  fixes f :: "nat \<Rightarrow> 'a::banach"
1.1109 -  shows "\<lbrakk>c < 1; \<forall>n\<ge>N. norm (f (Suc n)) \<le> c * norm (f n)\<rbrakk> \<Longrightarrow> summable f"
1.1110 -apply (frule ratio_test_lemma2, auto)
1.1111 -apply (rule_tac g = "%n. (norm (f N) / (c ^ N))*c ^ n"
1.1112 -       in summable_comparison_test)
1.1113 -apply (rule_tac x = N in exI, safe)
1.1114 -apply (drule le_Suc_ex_iff [THEN iffD1])
1.1116 -apply (induct_tac "na", auto)
1.1117 -apply (rule_tac y = "c * norm (f (N + n))" in order_trans)
1.1118 -apply (auto intro: mult_right_mono simp add: summable_def)
1.1119 -apply (rule_tac x = "norm (f N) * (1/ (1 - c)) / (c ^ N)" in exI)
1.1120 -apply (rule sums_divide)
1.1121 -apply (rule sums_mult)
1.1122 -apply (auto intro!: geometric_sums)
1.1123 -done
1.1124 -
1.1125  subsection {* Cauchy Product Formula *}
1.1126
1.1127  text {*
1.1128 @@ -742,14 +579,14 @@
1.1129
1.1130  lemma setsum_triangle_reindex:
1.1131    fixes n :: nat
1.1132 -  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))"
1.1133 +  shows "(\<Sum>(i,j)\<in>{(i,j). i+j < n}. f i j) = (\<Sum>k<n. \<Sum>i=0..k. f i (k - i))"
1.1134  proof -
1.1135    have "(\<Sum>(i, j)\<in>{(i, j). i + j < n}. f i j) =
1.1136 -    (\<Sum>(k, i)\<in>(SIGMA k:{0..<n}. {0..k}). f i (k - i))"
1.1137 +    (\<Sum>(k, i)\<in>(SIGMA k:{..<n}. {0..k}). f i (k - i))"
1.1138    proof (rule setsum_reindex_cong)
1.1139 -    show "inj_on (\<lambda>(k,i). (i, k - i)) (SIGMA k:{0..<n}. {0..k})"
1.1140 +    show "inj_on (\<lambda>(k,i). (i, k - i)) (SIGMA k:{..<n}. {0..k})"
1.1141        by (rule inj_on_inverseI [where g="\<lambda>(i,j). (i+j, i)"], auto)
1.1142 -    show "{(i,j). i + j < n} = (\<lambda>(k,i). (i, k - i)) ` (SIGMA k:{0..<n}. {0..k})"
1.1143 +    show "{(i,j). i + j < n} = (\<lambda>(k,i). (i, k - i)) ` (SIGMA k:{..<n}. {0..k})"
1.1144        by (safe, rule_tac x="(a+b,a)" in image_eqI, auto)
1.1145      show "\<And>a. (\<lambda>(k, i). f i (k - i)) a = split f ((\<lambda>(k, i). (i, k - i)) a)"
1.1146        by clarify
1.1147 @@ -763,7 +600,7 @@
1.1148    assumes b: "summable (\<lambda>k. norm (b k))"
1.1149    shows "(\<lambda>k. \<Sum>i=0..k. a i * b (k - i)) sums ((\<Sum>k. a k) * (\<Sum>k. b k))"
1.1150  proof -
1.1151 -  let ?S1 = "\<lambda>n::nat. {0..<n} \<times> {0..<n}"
1.1152 +  let ?S1 = "\<lambda>n::nat. {..<n} \<times> {..<n}"
1.1153    let ?S2 = "\<lambda>n::nat. {(i,j). i + j < n}"
1.1154    have S1_mono: "\<And>m n. m \<le> n \<Longrightarrow> ?S1 m \<subseteq> ?S1 n" by auto
1.1155    have S2_le_S1: "\<And>n. ?S2 n \<subseteq> ?S1 n" by auto
1.1156 @@ -779,20 +616,15 @@
1.1157      unfolding real_norm_def
1.1158      by (simp only: abs_of_nonneg setsum_nonneg [rule_format])
1.1159
1.1160 -  have "(\<lambda>n. (\<Sum>k=0..<n. a k) * (\<Sum>k=0..<n. b k))
1.1161 -           ----> (\<Sum>k. a k) * (\<Sum>k. b k)"
1.1162 -    by (intro tendsto_mult summable_sumr_LIMSEQ_suminf
1.1163 -        summable_norm_cancel [OF a] summable_norm_cancel [OF b])
1.1164 +  have "(\<lambda>n. (\<Sum>k<n. a k) * (\<Sum>k<n. b k)) ----> (\<Sum>k. a k) * (\<Sum>k. b k)"
1.1165 +    by (intro tendsto_mult summable_LIMSEQ summable_norm_cancel [OF a] summable_norm_cancel [OF b])
1.1166    hence 1: "(\<lambda>n. setsum ?g (?S1 n)) ----> (\<Sum>k. a k) * (\<Sum>k. b k)"
1.1167 -    by (simp only: setsum_product setsum_Sigma [rule_format]
1.1168 -                   finite_atLeastLessThan)
1.1169 +    by (simp only: setsum_product setsum_Sigma [rule_format] finite_lessThan)
1.1170
1.1171 -  have "(\<lambda>n. (\<Sum>k=0..<n. norm (a k)) * (\<Sum>k=0..<n. norm (b k)))
1.1172 -       ----> (\<Sum>k. norm (a k)) * (\<Sum>k. norm (b k))"
1.1173 -    using a b by (intro tendsto_mult summable_sumr_LIMSEQ_suminf)
1.1174 +  have "(\<lambda>n. (\<Sum>k<n. norm (a k)) * (\<Sum>k<n. norm (b k))) ----> (\<Sum>k. norm (a k)) * (\<Sum>k. norm (b k))"
1.1175 +    using a b by (intro tendsto_mult summable_LIMSEQ)
1.1176    hence "(\<lambda>n. setsum ?f (?S1 n)) ----> (\<Sum>k. norm (a k)) * (\<Sum>k. norm (b k))"
1.1177 -    by (simp only: setsum_product setsum_Sigma [rule_format]
1.1178 -                   finite_atLeastLessThan)
1.1179 +    by (simp only: setsum_product setsum_Sigma [rule_format] finite_lessThan)
1.1180    hence "convergent (\<lambda>n. setsum ?f (?S1 n))"
1.1181      by (rule convergentI)
1.1182    hence Cauchy: "Cauchy (\<lambda>n. setsum ?f (?S1 n))"
```