1(* Title : Series.thy 2 Author : Jacques D. Fleuriot 3 Copyright : 1998 University of Cambridge 4 5Converted to Isar and polished by lcp 6Converted to sum and polished yet more by TNN 7Additional contributions by Jeremy Avigad 8*) 9 10section \<open>Infinite Series\<close> 11 12theory Series 13imports Limits Inequalities 14begin 15 16subsection \<open>Definition of infinite summability\<close> 17 18definition sums :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> 'a \<Rightarrow> bool" 19 (infixr "sums" 80) 20 where "f sums s \<longleftrightarrow> (\<lambda>n. \<Sum>i<n. f i) \<longlonglongrightarrow> s" 21 22definition summable :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> bool" 23 where "summable f \<longleftrightarrow> (\<exists>s. f sums s)" 24 25definition suminf :: "(nat \<Rightarrow> 'a::{topological_space, comm_monoid_add}) \<Rightarrow> 'a" 26 (binder "\<Sum>" 10) 27 where "suminf f = (THE s. f sums s)" 28 29text\<open>Variants of the definition\<close> 30lemma sums_def': "f sums s \<longleftrightarrow> (\<lambda>n. \<Sum>i = 0..n. f i) \<longlonglongrightarrow> s" 31 unfolding sums_def 32 apply (subst LIMSEQ_Suc_iff [symmetric]) 33 apply (simp only: lessThan_Suc_atMost atLeast0AtMost) 34 done 35 36lemma sums_def_le: "f sums s \<longleftrightarrow> (\<lambda>n. \<Sum>i\<le>n. f i) \<longlonglongrightarrow> s" 37 by (simp add: sums_def' atMost_atLeast0) 38 39lemma bounded_imp_summable: 40 fixes a :: "nat \<Rightarrow> 'a::{conditionally_complete_linorder,linorder_topology,linordered_comm_semiring_strict}" 41 assumes 0: "\<And>n. a n \<ge> 0" and bounded: "\<And>n. (\<Sum>k\<le>n. a k) \<le> B" 42 shows "summable a" 43proof - 44 have "bdd_above (range(\<lambda>n. \<Sum>k\<le>n. a k))" 45 by (meson bdd_aboveI2 bounded) 46 moreover have "incseq (\<lambda>n. \<Sum>k\<le>n. a k)" 47 by (simp add: mono_def "0" sum_mono2) 48 ultimately obtain s where "(\<lambda>n. \<Sum>k\<le>n. a k) \<longlonglongrightarrow> s" 49 using LIMSEQ_incseq_SUP by blast 50 then show ?thesis 51 by (auto simp: sums_def_le summable_def) 52qed 53 54 55subsection \<open>Infinite summability on topological monoids\<close> 56 57lemma sums_subst[trans]: "f = g \<Longrightarrow> g sums z \<Longrightarrow> f sums z" 58 by simp 59 60lemma sums_cong: "(\<And>n. f n = g n) \<Longrightarrow> f sums c \<longleftrightarrow> g sums c" 61 by (drule ext) simp 62 63lemma sums_summable: "f sums l \<Longrightarrow> summable f" 64 by (simp add: sums_def summable_def, blast) 65 66lemma summable_iff_convergent: "summable f \<longleftrightarrow> convergent (\<lambda>n. \<Sum>i<n. f i)" 67 by (simp add: summable_def sums_def convergent_def) 68 69lemma summable_iff_convergent': "summable f \<longleftrightarrow> convergent (\<lambda>n. sum f {..n})" 70 by (simp_all only: summable_iff_convergent convergent_def 71 lessThan_Suc_atMost [symmetric] LIMSEQ_Suc_iff[of "\<lambda>n. sum f {..<n}"]) 72 73lemma suminf_eq_lim: "suminf f = lim (\<lambda>n. \<Sum>i<n. f i)" 74 by (simp add: suminf_def sums_def lim_def) 75 76lemma sums_zero[simp, intro]: "(\<lambda>n. 0) sums 0" 77 unfolding sums_def by simp 78 79lemma summable_zero[simp, intro]: "summable (\<lambda>n. 0)" 80 by (rule sums_zero [THEN sums_summable]) 81 82lemma sums_group: "f sums s \<Longrightarrow> 0 < k \<Longrightarrow> (\<lambda>n. sum f {n * k ..< n * k + k}) sums s" 83 apply (simp only: sums_def sum.nat_group tendsto_def eventually_sequentially) 84 apply (erule all_forward imp_forward exE| assumption)+ 85 apply (rule_tac x="N" in exI) 86 by (metis le_square mult.commute mult.left_neutral mult_le_cancel2 mult_le_mono) 87 88lemma suminf_cong: "(\<And>n. f n = g n) \<Longrightarrow> suminf f = suminf g" 89 by (rule arg_cong[of f g], rule ext) simp 90 91lemma summable_cong: 92 fixes f g :: "nat \<Rightarrow> 'a::real_normed_vector" 93 assumes "eventually (\<lambda>x. f x = g x) sequentially" 94 shows "summable f = summable g" 95proof - 96 from assms obtain N where N: "\<forall>n\<ge>N. f n = g n" 97 by (auto simp: eventually_at_top_linorder) 98 define C where "C = (\<Sum>k<N. f k - g k)" 99 from eventually_ge_at_top[of N] 100 have "eventually (\<lambda>n. sum f {..<n} = C + sum g {..<n}) sequentially" 101 proof eventually_elim 102 case (elim n) 103 then have "{..<n} = {..<N} \<union> {N..<n}" 104 by auto 105 also have "sum f ... = sum f {..<N} + sum f {N..<n}" 106 by (intro sum.union_disjoint) auto 107 also from N have "sum f {N..<n} = sum g {N..<n}" 108 by (intro sum.cong) simp_all 109 also have "sum f {..<N} + sum g {N..<n} = C + (sum g {..<N} + sum g {N..<n})" 110 unfolding C_def by (simp add: algebra_simps sum_subtractf) 111 also have "sum g {..<N} + sum g {N..<n} = sum g ({..<N} \<union> {N..<n})" 112 by (intro sum.union_disjoint [symmetric]) auto 113 also from elim have "{..<N} \<union> {N..<n} = {..<n}" 114 by auto 115 finally show "sum f {..<n} = C + sum g {..<n}" . 116 qed 117 from convergent_cong[OF this] show ?thesis 118 by (simp add: summable_iff_convergent convergent_add_const_iff) 119qed 120 121lemma sums_finite: 122 assumes [simp]: "finite N" 123 and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 0" 124 shows "f sums (\<Sum>n\<in>N. f n)" 125proof - 126 have eq: "sum f {..<n + Suc (Max N)} = sum f N" for n 127 by (rule sum.mono_neutral_right) (auto simp: add_increasing less_Suc_eq_le f) 128 show ?thesis 129 unfolding sums_def 130 by (rule LIMSEQ_offset[of _ "Suc (Max N)"]) 131 (simp add: eq atLeast0LessThan del: add_Suc_right) 132qed 133 134corollary sums_0: "(\<And>n. f n = 0) \<Longrightarrow> (f sums 0)" 135 by (metis (no_types) finite.emptyI sum.empty sums_finite) 136 137lemma summable_finite: "finite N \<Longrightarrow> (\<And>n. n \<notin> N \<Longrightarrow> f n = 0) \<Longrightarrow> summable f" 138 by (rule sums_summable) (rule sums_finite) 139 140lemma 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)" 141 using sums_finite[of A "(\<lambda>r. if r \<in> A then f r else 0)"] by simp 142 143lemma summable_If_finite_set[simp, intro]: "finite A \<Longrightarrow> summable (\<lambda>r. if r \<in> A then f r else 0)" 144 by (rule sums_summable) (rule sums_If_finite_set) 145 146lemma 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)" 147 using sums_If_finite_set[of "{r. P r}"] by simp 148 149lemma summable_If_finite[simp, intro]: "finite {r. P r} \<Longrightarrow> summable (\<lambda>r. if P r then f r else 0)" 150 by (rule sums_summable) (rule sums_If_finite) 151 152lemma sums_single: "(\<lambda>r. if r = i then f r else 0) sums f i" 153 using sums_If_finite[of "\<lambda>r. r = i"] by simp 154 155lemma summable_single[simp, intro]: "summable (\<lambda>r. if r = i then f r else 0)" 156 by (rule sums_summable) (rule sums_single) 157 158context 159 fixes f :: "nat \<Rightarrow> 'a::{t2_space,comm_monoid_add}" 160begin 161 162lemma summable_sums[intro]: "summable f \<Longrightarrow> f sums (suminf f)" 163 by (simp add: summable_def sums_def suminf_def) 164 (metis convergent_LIMSEQ_iff convergent_def lim_def) 165 166lemma summable_LIMSEQ: "summable f \<Longrightarrow> (\<lambda>n. \<Sum>i<n. f i) \<longlonglongrightarrow> suminf f" 167 by (rule summable_sums [unfolded sums_def]) 168 169lemma summable_LIMSEQ': "summable f \<Longrightarrow> (\<lambda>n. \<Sum>i\<le>n. f i) \<longlonglongrightarrow> suminf f" 170 using sums_def_le by blast 171 172lemma sums_unique: "f sums s \<Longrightarrow> s = suminf f" 173 by (metis limI suminf_eq_lim sums_def) 174 175lemma sums_iff: "f sums x \<longleftrightarrow> summable f \<and> suminf f = x" 176 by (metis summable_sums sums_summable sums_unique) 177 178lemma summable_sums_iff: "summable f \<longleftrightarrow> f sums suminf f" 179 by (auto simp: sums_iff summable_sums) 180 181lemma sums_unique2: "f sums a \<Longrightarrow> f sums b \<Longrightarrow> a = b" 182 for a b :: 'a 183 by (simp add: sums_iff) 184 185lemma suminf_finite: 186 assumes N: "finite N" 187 and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 0" 188 shows "suminf f = (\<Sum>n\<in>N. f n)" 189 using sums_finite[OF assms, THEN sums_unique] by simp 190 191end 192 193lemma suminf_zero[simp]: "suminf (\<lambda>n. 0::'a::{t2_space, comm_monoid_add}) = 0" 194 by (rule sums_zero [THEN sums_unique, symmetric]) 195 196 197subsection \<open>Infinite summability on ordered, topological monoids\<close> 198 199lemma sums_le: "\<forall>n. f n \<le> g n \<Longrightarrow> f sums s \<Longrightarrow> g sums t \<Longrightarrow> s \<le> t" 200 for f g :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add,linorder_topology}" 201 by (rule LIMSEQ_le) (auto intro: sum_mono simp: sums_def) 202 203context 204 fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add,linorder_topology}" 205begin 206 207lemma suminf_le: "\<forall>n. f n \<le> g n \<Longrightarrow> summable f \<Longrightarrow> summable g \<Longrightarrow> suminf f \<le> suminf g" 208 by (auto dest: sums_summable intro: sums_le) 209 210lemma sum_le_suminf: 211 shows "summable f \<Longrightarrow> finite I \<Longrightarrow> \<forall>m\<in>- I. 0 \<le> f m \<Longrightarrow> sum f I \<le> suminf f" 212 by (rule sums_le[OF _ sums_If_finite_set summable_sums]) auto 213 214lemma suminf_nonneg: "summable f \<Longrightarrow> \<forall>n. 0 \<le> f n \<Longrightarrow> 0 \<le> suminf f" 215 using sum_le_suminf by force 216 217lemma suminf_le_const: "summable f \<Longrightarrow> (\<And>n. sum f {..<n} \<le> x) \<Longrightarrow> suminf f \<le> x" 218 by (metis LIMSEQ_le_const2 summable_LIMSEQ) 219 220lemma suminf_eq_zero_iff: "summable f \<Longrightarrow> \<forall>n. 0 \<le> f n \<Longrightarrow> suminf f = 0 \<longleftrightarrow> (\<forall>n. f n = 0)" 221proof 222 assume "summable f" "suminf f = 0" and pos: "\<forall>n. 0 \<le> f n" 223 then have f: "(\<lambda>n. \<Sum>i<n. f i) \<longlonglongrightarrow> 0" 224 using summable_LIMSEQ[of f] by simp 225 then have "\<And>i. (\<Sum>n\<in>{i}. f n) \<le> 0" 226 proof (rule LIMSEQ_le_const) 227 show "\<exists>N. \<forall>n\<ge>N. (\<Sum>n\<in>{i}. f n) \<le> sum f {..<n}" for i 228 using pos by (intro exI[of _ "Suc i"] allI impI sum_mono2) auto 229 qed 230 with pos show "\<forall>n. f n = 0" 231 by (auto intro!: antisym) 232qed (metis suminf_zero fun_eq_iff) 233 234lemma suminf_pos_iff: "summable f \<Longrightarrow> \<forall>n. 0 \<le> f n \<Longrightarrow> 0 < suminf f \<longleftrightarrow> (\<exists>i. 0 < f i)" 235 using sum_le_suminf[of "{}"] suminf_eq_zero_iff by (simp add: less_le) 236 237lemma suminf_pos2: 238 assumes "summable f" "\<forall>n. 0 \<le> f n" "0 < f i" 239 shows "0 < suminf f" 240proof - 241 have "0 < (\<Sum>n<Suc i. f n)" 242 using assms by (intro sum_pos2[where i=i]) auto 243 also have "\<dots> \<le> suminf f" 244 using assms by (intro sum_le_suminf) auto 245 finally show ?thesis . 246qed 247 248lemma suminf_pos: "summable f \<Longrightarrow> \<forall>n. 0 < f n \<Longrightarrow> 0 < suminf f" 249 by (intro suminf_pos2[where i=0]) (auto intro: less_imp_le) 250 251end 252 253context 254 fixes f :: "nat \<Rightarrow> 'a::{ordered_cancel_comm_monoid_add,linorder_topology}" 255begin 256 257lemma sum_less_suminf2: 258 "summable f \<Longrightarrow> \<forall>m\<ge>n. 0 \<le> f m \<Longrightarrow> n \<le> i \<Longrightarrow> 0 < f i \<Longrightarrow> sum f {..<n} < suminf f" 259 using sum_le_suminf[of f "{..< Suc i}"] 260 and add_strict_increasing[of "f i" "sum f {..<n}" "sum f {..<i}"] 261 and sum_mono2[of "{..<i}" "{..<n}" f] 262 by (auto simp: less_imp_le ac_simps) 263 264lemma sum_less_suminf: "summable f \<Longrightarrow> \<forall>m\<ge>n. 0 < f m \<Longrightarrow> sum f {..<n} < suminf f" 265 using sum_less_suminf2[of n n] by (simp add: less_imp_le) 266 267end 268 269lemma summableI_nonneg_bounded: 270 fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add,linorder_topology,conditionally_complete_linorder}" 271 assumes pos[simp]: "\<And>n. 0 \<le> f n" 272 and le: "\<And>n. (\<Sum>i<n. f i) \<le> x" 273 shows "summable f" 274 unfolding summable_def sums_def [abs_def] 275proof (rule exI LIMSEQ_incseq_SUP)+ 276 show "bdd_above (range (\<lambda>n. sum f {..<n}))" 277 using le by (auto simp: bdd_above_def) 278 show "incseq (\<lambda>n. sum f {..<n})" 279 by (auto simp: mono_def intro!: sum_mono2) 280qed 281 282lemma summableI[intro, simp]: "summable f" 283 for f :: "nat \<Rightarrow> 'a::{canonically_ordered_monoid_add,linorder_topology,complete_linorder}" 284 by (intro summableI_nonneg_bounded[where x=top] zero_le top_greatest) 285 286lemma suminf_eq_SUP_real: 287 assumes X: "summable X" "\<And>i. 0 \<le> X i" shows "suminf X = (SUP i. \<Sum>n<i. X n::real)" 288 by (intro LIMSEQ_unique[OF summable_LIMSEQ] X LIMSEQ_incseq_SUP) 289 (auto intro!: bdd_aboveI2[where M="\<Sum>i. X i"] sum_le_suminf X monoI sum_mono2) 290 291 292subsection \<open>Infinite summability on topological monoids\<close> 293 294context 295 fixes f g :: "nat \<Rightarrow> 'a::{t2_space,topological_comm_monoid_add}" 296begin 297 298lemma sums_Suc: 299 assumes "(\<lambda>n. f (Suc n)) sums l" 300 shows "f sums (l + f 0)" 301proof - 302 have "(\<lambda>n. (\<Sum>i<n. f (Suc i)) + f 0) \<longlonglongrightarrow> l + f 0" 303 using assms by (auto intro!: tendsto_add simp: sums_def) 304 moreover have "(\<Sum>i<n. f (Suc i)) + f 0 = (\<Sum>i<Suc n. f i)" for n 305 unfolding lessThan_Suc_eq_insert_0 306 by (simp add: ac_simps sum.atLeast1_atMost_eq image_Suc_lessThan) 307 ultimately show ?thesis 308 by (auto simp: sums_def simp del: sum.lessThan_Suc intro: LIMSEQ_Suc_iff[THEN iffD1]) 309qed 310 311lemma sums_add: "f sums a \<Longrightarrow> g sums b \<Longrightarrow> (\<lambda>n. f n + g n) sums (a + b)" 312 unfolding sums_def by (simp add: sum.distrib tendsto_add) 313 314lemma summable_add: "summable f \<Longrightarrow> summable g \<Longrightarrow> summable (\<lambda>n. f n + g n)" 315 unfolding summable_def by (auto intro: sums_add) 316 317lemma suminf_add: "summable f \<Longrightarrow> summable g \<Longrightarrow> suminf f + suminf g = (\<Sum>n. f n + g n)" 318 by (intro sums_unique sums_add summable_sums) 319 320end 321 322context 323 fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::{t2_space,topological_comm_monoid_add}" 324 and I :: "'i set" 325begin 326 327lemma sums_sum: "(\<And>i. i \<in> I \<Longrightarrow> (f i) sums (x i)) \<Longrightarrow> (\<lambda>n. \<Sum>i\<in>I. f i n) sums (\<Sum>i\<in>I. x i)" 328 by (induct I rule: infinite_finite_induct) (auto intro!: sums_add) 329 330lemma suminf_sum: "(\<And>i. i \<in> I \<Longrightarrow> summable (f i)) \<Longrightarrow> (\<Sum>n. \<Sum>i\<in>I. f i n) = (\<Sum>i\<in>I. \<Sum>n. f i n)" 331 using sums_unique[OF sums_sum, OF summable_sums] by simp 332 333lemma summable_sum: "(\<And>i. i \<in> I \<Longrightarrow> summable (f i)) \<Longrightarrow> summable (\<lambda>n. \<Sum>i\<in>I. f i n)" 334 using sums_summable[OF sums_sum[OF summable_sums]] . 335 336end 337 338lemma sums_If_finite_set': 339 fixes f g :: "nat \<Rightarrow> 'a::{t2_space,topological_ab_group_add}" 340 assumes "g sums S" and "finite A" and "S' = S + (\<Sum>n\<in>A. f n - g n)" 341 shows "(\<lambda>n. if n \<in> A then f n else g n) sums S'" 342proof - 343 have "(\<lambda>n. g n + (if n \<in> A then f n - g n else 0)) sums (S + (\<Sum>n\<in>A. f n - g n))" 344 by (intro sums_add assms sums_If_finite_set) 345 also have "(\<lambda>n. g n + (if n \<in> A then f n - g n else 0)) = (\<lambda>n. if n \<in> A then f n else g n)" 346 by (simp add: fun_eq_iff) 347 finally show ?thesis using assms by simp 348qed 349 350subsection \<open>Infinite summability on real normed vector spaces\<close> 351 352context 353 fixes f :: "nat \<Rightarrow> 'a::real_normed_vector" 354begin 355 356lemma sums_Suc_iff: "(\<lambda>n. f (Suc n)) sums s \<longleftrightarrow> f sums (s + f 0)" 357proof - 358 have "f sums (s + f 0) \<longleftrightarrow> (\<lambda>i. \<Sum>j<Suc i. f j) \<longlonglongrightarrow> s + f 0" 359 by (subst LIMSEQ_Suc_iff) (simp add: sums_def) 360 also have "\<dots> \<longleftrightarrow> (\<lambda>i. (\<Sum>j<i. f (Suc j)) + f 0) \<longlonglongrightarrow> s + f 0" 361 by (simp add: ac_simps lessThan_Suc_eq_insert_0 image_Suc_lessThan sum.atLeast1_atMost_eq) 362 also have "\<dots> \<longleftrightarrow> (\<lambda>n. f (Suc n)) sums s" 363 proof 364 assume "(\<lambda>i. (\<Sum>j<i. f (Suc j)) + f 0) \<longlonglongrightarrow> s + f 0" 365 with tendsto_add[OF this tendsto_const, of "- f 0"] show "(\<lambda>i. f (Suc i)) sums s" 366 by (simp add: sums_def) 367 qed (auto intro: tendsto_add simp: sums_def) 368 finally show ?thesis .. 369qed 370 371lemma summable_Suc_iff: "summable (\<lambda>n. f (Suc n)) = summable f" 372proof 373 assume "summable f" 374 then have "f sums suminf f" 375 by (rule summable_sums) 376 then have "(\<lambda>n. f (Suc n)) sums (suminf f - f 0)" 377 by (simp add: sums_Suc_iff) 378 then show "summable (\<lambda>n. f (Suc n))" 379 unfolding summable_def by blast 380qed (auto simp: sums_Suc_iff summable_def) 381 382lemma sums_Suc_imp: "f 0 = 0 \<Longrightarrow> (\<lambda>n. f (Suc n)) sums s \<Longrightarrow> (\<lambda>n. f n) sums s" 383 using sums_Suc_iff by simp 384 385end 386 387context (* Separate contexts are necessary to allow general use of the results above, here. *) 388 fixes f :: "nat \<Rightarrow> 'a::real_normed_vector" 389begin 390 391lemma sums_diff: "f sums a \<Longrightarrow> g sums b \<Longrightarrow> (\<lambda>n. f n - g n) sums (a - b)" 392 unfolding sums_def by (simp add: sum_subtractf tendsto_diff) 393 394lemma summable_diff: "summable f \<Longrightarrow> summable g \<Longrightarrow> summable (\<lambda>n. f n - g n)" 395 unfolding summable_def by (auto intro: sums_diff) 396 397lemma suminf_diff: "summable f \<Longrightarrow> summable g \<Longrightarrow> suminf f - suminf g = (\<Sum>n. f n - g n)" 398 by (intro sums_unique sums_diff summable_sums) 399 400lemma sums_minus: "f sums a \<Longrightarrow> (\<lambda>n. - f n) sums (- a)" 401 unfolding sums_def by (simp add: sum_negf tendsto_minus) 402 403lemma summable_minus: "summable f \<Longrightarrow> summable (\<lambda>n. - f n)" 404 unfolding summable_def by (auto intro: sums_minus) 405 406lemma suminf_minus: "summable f \<Longrightarrow> (\<Sum>n. - f n) = - (\<Sum>n. f n)" 407 by (intro sums_unique [symmetric] sums_minus summable_sums) 408 409lemma sums_iff_shift: "(\<lambda>i. f (i + n)) sums s \<longleftrightarrow> f sums (s + (\<Sum>i<n. f i))" 410proof (induct n arbitrary: s) 411 case 0 412 then show ?case by simp 413next 414 case (Suc n) 415 then have "(\<lambda>i. f (Suc i + n)) sums s \<longleftrightarrow> (\<lambda>i. f (i + n)) sums (s + f n)" 416 by (subst sums_Suc_iff) simp 417 with Suc show ?case 418 by (simp add: ac_simps) 419qed 420 421corollary sums_iff_shift': "(\<lambda>i. f (i + n)) sums (s - (\<Sum>i<n. f i)) \<longleftrightarrow> f sums s" 422 by (simp add: sums_iff_shift) 423 424lemma sums_zero_iff_shift: 425 assumes "\<And>i. i < n \<Longrightarrow> f i = 0" 426 shows "(\<lambda>i. f (i+n)) sums s \<longleftrightarrow> (\<lambda>i. f i) sums s" 427 by (simp add: assms sums_iff_shift) 428 429lemma summable_iff_shift: "summable (\<lambda>n. f (n + k)) \<longleftrightarrow> summable f" 430 by (metis diff_add_cancel summable_def sums_iff_shift [abs_def]) 431 432lemma sums_split_initial_segment: "f sums s \<Longrightarrow> (\<lambda>i. f (i + n)) sums (s - (\<Sum>i<n. f i))" 433 by (simp add: sums_iff_shift) 434 435lemma summable_ignore_initial_segment: "summable f \<Longrightarrow> summable (\<lambda>n. f(n + k))" 436 by (simp add: summable_iff_shift) 437 438lemma suminf_minus_initial_segment: "summable f \<Longrightarrow> (\<Sum>n. f (n + k)) = (\<Sum>n. f n) - (\<Sum>i<k. f i)" 439 by (rule sums_unique[symmetric]) (auto simp: sums_iff_shift) 440 441lemma suminf_split_initial_segment: "summable f \<Longrightarrow> suminf f = (\<Sum>n. f(n + k)) + (\<Sum>i<k. f i)" 442 by (auto simp add: suminf_minus_initial_segment) 443 444lemma suminf_split_head: "summable f \<Longrightarrow> (\<Sum>n. f (Suc n)) = suminf f - f 0" 445 using suminf_split_initial_segment[of 1] by simp 446 447lemma suminf_exist_split: 448 fixes r :: real 449 assumes "0 < r" and "summable f" 450 shows "\<exists>N. \<forall>n\<ge>N. norm (\<Sum>i. f (i + n)) < r" 451proof - 452 from LIMSEQ_D[OF summable_LIMSEQ[OF \<open>summable f\<close>] \<open>0 < r\<close>] 453 obtain N :: nat where "\<forall> n \<ge> N. norm (sum f {..<n} - suminf f) < r" 454 by auto 455 then show ?thesis 456 by (auto simp: norm_minus_commute suminf_minus_initial_segment[OF \<open>summable f\<close>]) 457qed 458 459lemma summable_LIMSEQ_zero: "summable f \<Longrightarrow> f \<longlonglongrightarrow> 0" 460 apply (drule summable_iff_convergent [THEN iffD1]) 461 apply (drule convergent_Cauchy) 462 apply (simp only: Cauchy_iff LIMSEQ_iff) 463 by (metis add.commute add_diff_cancel_right' diff_zero le_SucI sum.lessThan_Suc) 464 465lemma summable_imp_convergent: "summable f \<Longrightarrow> convergent f" 466 by (force dest!: summable_LIMSEQ_zero simp: convergent_def) 467 468lemma summable_imp_Bseq: "summable f \<Longrightarrow> Bseq f" 469 by (simp add: convergent_imp_Bseq summable_imp_convergent) 470 471end 472 473lemma summable_minus_iff: "summable (\<lambda>n. - f n) \<longleftrightarrow> summable f" 474 for f :: "nat \<Rightarrow> 'a::real_normed_vector" 475 by (auto dest: summable_minus) (* used two ways, hence must be outside the context above *) 476 477lemma (in bounded_linear) sums: "(\<lambda>n. X n) sums a \<Longrightarrow> (\<lambda>n. f (X n)) sums (f a)" 478 unfolding sums_def by (drule tendsto) (simp only: sum) 479 480lemma (in bounded_linear) summable: "summable (\<lambda>n. X n) \<Longrightarrow> summable (\<lambda>n. f (X n))" 481 unfolding summable_def by (auto intro: sums) 482 483lemma (in bounded_linear) suminf: "summable (\<lambda>n. X n) \<Longrightarrow> f (\<Sum>n. X n) = (\<Sum>n. f (X n))" 484 by (intro sums_unique sums summable_sums) 485 486lemmas sums_of_real = bounded_linear.sums [OF bounded_linear_of_real] 487lemmas summable_of_real = bounded_linear.summable [OF bounded_linear_of_real] 488lemmas suminf_of_real = bounded_linear.suminf [OF bounded_linear_of_real] 489 490lemmas sums_scaleR_left = bounded_linear.sums[OF bounded_linear_scaleR_left] 491lemmas summable_scaleR_left = bounded_linear.summable[OF bounded_linear_scaleR_left] 492lemmas suminf_scaleR_left = bounded_linear.suminf[OF bounded_linear_scaleR_left] 493 494lemmas sums_scaleR_right = bounded_linear.sums[OF bounded_linear_scaleR_right] 495lemmas summable_scaleR_right = bounded_linear.summable[OF bounded_linear_scaleR_right] 496lemmas suminf_scaleR_right = bounded_linear.suminf[OF bounded_linear_scaleR_right] 497 498lemma summable_const_iff: "summable (\<lambda>_. c) \<longleftrightarrow> c = 0" 499 for c :: "'a::real_normed_vector" 500proof - 501 have "\<not> summable (\<lambda>_. c)" if "c \<noteq> 0" 502 proof - 503 from that have "filterlim (\<lambda>n. of_nat n * norm c) at_top sequentially" 504 by (subst mult.commute) 505 (auto intro!: filterlim_tendsto_pos_mult_at_top filterlim_real_sequentially) 506 then have "\<not> convergent (\<lambda>n. norm (\<Sum>k<n. c))" 507 by (intro filterlim_at_infinity_imp_not_convergent filterlim_at_top_imp_at_infinity) 508 (simp_all add: sum_constant_scaleR) 509 then show ?thesis 510 unfolding summable_iff_convergent using convergent_norm by blast 511 qed 512 then show ?thesis by auto 513qed 514 515 516subsection \<open>Infinite summability on real normed algebras\<close> 517 518context 519 fixes f :: "nat \<Rightarrow> 'a::real_normed_algebra" 520begin 521 522lemma sums_mult: "f sums a \<Longrightarrow> (\<lambda>n. c * f n) sums (c * a)" 523 by (rule bounded_linear.sums [OF bounded_linear_mult_right]) 524 525lemma summable_mult: "summable f \<Longrightarrow> summable (\<lambda>n. c * f n)" 526 by (rule bounded_linear.summable [OF bounded_linear_mult_right]) 527 528lemma suminf_mult: "summable f \<Longrightarrow> suminf (\<lambda>n. c * f n) = c * suminf f" 529 by (rule bounded_linear.suminf [OF bounded_linear_mult_right, symmetric]) 530 531lemma sums_mult2: "f sums a \<Longrightarrow> (\<lambda>n. f n * c) sums (a * c)" 532 by (rule bounded_linear.sums [OF bounded_linear_mult_left]) 533 534lemma summable_mult2: "summable f \<Longrightarrow> summable (\<lambda>n. f n * c)" 535 by (rule bounded_linear.summable [OF bounded_linear_mult_left]) 536 537lemma suminf_mult2: "summable f \<Longrightarrow> suminf f * c = (\<Sum>n. f n * c)" 538 by (rule bounded_linear.suminf [OF bounded_linear_mult_left]) 539 540end 541 542lemma sums_mult_iff: 543 fixes f :: "nat \<Rightarrow> 'a::{real_normed_algebra,field}" 544 assumes "c \<noteq> 0" 545 shows "(\<lambda>n. c * f n) sums (c * d) \<longleftrightarrow> f sums d" 546 using sums_mult[of f d c] sums_mult[of "\<lambda>n. c * f n" "c * d" "inverse c"] 547 by (force simp: field_simps assms) 548 549lemma sums_mult2_iff: 550 fixes f :: "nat \<Rightarrow> 'a::{real_normed_algebra,field}" 551 assumes "c \<noteq> 0" 552 shows "(\<lambda>n. f n * c) sums (d * c) \<longleftrightarrow> f sums d" 553 using sums_mult_iff[OF assms, of f d] by (simp add: mult.commute) 554 555lemma sums_of_real_iff: 556 "(\<lambda>n. of_real (f n) :: 'a::real_normed_div_algebra) sums of_real c \<longleftrightarrow> f sums c" 557 by (simp add: sums_def of_real_sum[symmetric] tendsto_of_real_iff del: of_real_sum) 558 559 560subsection \<open>Infinite summability on real normed fields\<close> 561 562context 563 fixes c :: "'a::real_normed_field" 564begin 565 566lemma sums_divide: "f sums a \<Longrightarrow> (\<lambda>n. f n / c) sums (a / c)" 567 by (rule bounded_linear.sums [OF bounded_linear_divide]) 568 569lemma summable_divide: "summable f \<Longrightarrow> summable (\<lambda>n. f n / c)" 570 by (rule bounded_linear.summable [OF bounded_linear_divide]) 571 572lemma suminf_divide: "summable f \<Longrightarrow> suminf (\<lambda>n. f n / c) = suminf f / c" 573 by (rule bounded_linear.suminf [OF bounded_linear_divide, symmetric]) 574 575lemma summable_inverse_divide: "summable (inverse \<circ> f) \<Longrightarrow> summable (\<lambda>n. c / f n)" 576 by (auto dest: summable_mult [of _ c] simp: field_simps) 577 578lemma sums_mult_D: "(\<lambda>n. c * f n) sums a \<Longrightarrow> c \<noteq> 0 \<Longrightarrow> f sums (a/c)" 579 using sums_mult_iff by fastforce 580 581lemma summable_mult_D: "summable (\<lambda>n. c * f n) \<Longrightarrow> c \<noteq> 0 \<Longrightarrow> summable f" 582 by (auto dest: summable_divide) 583 584 585text \<open>Sum of a geometric progression.\<close> 586 587lemma geometric_sums: 588 assumes "norm c < 1" 589 shows "(\<lambda>n. c^n) sums (1 / (1 - c))" 590proof - 591 have neq_0: "c - 1 \<noteq> 0" 592 using assms by auto 593 then have "(\<lambda>n. c ^ n / (c - 1) - 1 / (c - 1)) \<longlonglongrightarrow> 0 / (c - 1) - 1 / (c - 1)" 594 by (intro tendsto_intros assms) 595 then have "(\<lambda>n. (c ^ n - 1) / (c - 1)) \<longlonglongrightarrow> 1 / (1 - c)" 596 by (simp add: nonzero_minus_divide_right [OF neq_0] diff_divide_distrib) 597 with neq_0 show "(\<lambda>n. c ^ n) sums (1 / (1 - c))" 598 by (simp add: sums_def geometric_sum) 599qed 600 601lemma summable_geometric: "norm c < 1 \<Longrightarrow> summable (\<lambda>n. c^n)" 602 by (rule geometric_sums [THEN sums_summable]) 603 604lemma suminf_geometric: "norm c < 1 \<Longrightarrow> suminf (\<lambda>n. c^n) = 1 / (1 - c)" 605 by (rule sums_unique[symmetric]) (rule geometric_sums) 606 607lemma summable_geometric_iff: "summable (\<lambda>n. c ^ n) \<longleftrightarrow> norm c < 1" 608proof 609 assume "summable (\<lambda>n. c ^ n :: 'a :: real_normed_field)" 610 then have "(\<lambda>n. norm c ^ n) \<longlonglongrightarrow> 0" 611 by (simp add: norm_power [symmetric] tendsto_norm_zero_iff summable_LIMSEQ_zero) 612 from order_tendstoD(2)[OF this zero_less_one] obtain n where "norm c ^ n < 1" 613 by (auto simp: eventually_at_top_linorder) 614 then show "norm c < 1" using one_le_power[of "norm c" n] 615 by (cases "norm c \<ge> 1") (linarith, simp) 616qed (rule summable_geometric) 617 618end 619 620lemma power_half_series: "(\<lambda>n. (1/2::real)^Suc n) sums 1" 621proof - 622 have 2: "(\<lambda>n. (1/2::real)^n) sums 2" 623 using geometric_sums [of "1/2::real"] by auto 624 have "(\<lambda>n. (1/2::real)^Suc n) = (\<lambda>n. (1 / 2) ^ n / 2)" 625 by (simp add: mult.commute) 626 then show ?thesis 627 using sums_divide [OF 2, of 2] by simp 628qed 629 630 631subsection \<open>Telescoping\<close> 632 633lemma telescope_sums: 634 fixes c :: "'a::real_normed_vector" 635 assumes "f \<longlonglongrightarrow> c" 636 shows "(\<lambda>n. f (Suc n) - f n) sums (c - f 0)" 637 unfolding sums_def 638proof (subst LIMSEQ_Suc_iff [symmetric]) 639 have "(\<lambda>n. \<Sum>k<Suc n. f (Suc k) - f k) = (\<lambda>n. f (Suc n) - f 0)" 640 by (simp add: lessThan_Suc_atMost atLeast0AtMost [symmetric] sum_Suc_diff) 641 also have "\<dots> \<longlonglongrightarrow> c - f 0" 642 by (intro tendsto_diff LIMSEQ_Suc[OF assms] tendsto_const) 643 finally show "(\<lambda>n. \<Sum>n<Suc n. f (Suc n) - f n) \<longlonglongrightarrow> c - f 0" . 644qed 645 646lemma telescope_sums': 647 fixes c :: "'a::real_normed_vector" 648 assumes "f \<longlonglongrightarrow> c" 649 shows "(\<lambda>n. f n - f (Suc n)) sums (f 0 - c)" 650 using sums_minus[OF telescope_sums[OF assms]] by (simp add: algebra_simps) 651 652lemma telescope_summable: 653 fixes c :: "'a::real_normed_vector" 654 assumes "f \<longlonglongrightarrow> c" 655 shows "summable (\<lambda>n. f (Suc n) - f n)" 656 using telescope_sums[OF assms] by (simp add: sums_iff) 657 658lemma telescope_summable': 659 fixes c :: "'a::real_normed_vector" 660 assumes "f \<longlonglongrightarrow> c" 661 shows "summable (\<lambda>n. f n - f (Suc n))" 662 using summable_minus[OF telescope_summable[OF assms]] by (simp add: algebra_simps) 663 664 665subsection \<open>Infinite summability on Banach spaces\<close> 666 667text \<open>Cauchy-type criterion for convergence of series (c.f. Harrison).\<close> 668 669lemma summable_Cauchy: "summable f \<longleftrightarrow> (\<forall>e>0. \<exists>N. \<forall>m\<ge>N. \<forall>n. norm (sum f {m..<n}) < e)" (is "_ = ?rhs") 670 for f :: "nat \<Rightarrow> 'a::banach" 671proof 672 assume f: "summable f" 673 show ?rhs 674 proof clarify 675 fix e :: real 676 assume "0 < e" 677 then obtain M where M: "\<And>m n. \<lbrakk>m\<ge>M; n\<ge>M\<rbrakk> \<Longrightarrow> norm (sum f {..<m} - sum f {..<n}) < e" 678 using f by (force simp add: summable_iff_convergent Cauchy_convergent_iff [symmetric] Cauchy_iff) 679 have "norm (sum f {m..<n}) < e" if "m \<ge> M" for m n 680 proof (cases m n rule: linorder_class.le_cases) 681 assume "m \<le> n" 682 then show ?thesis 683 by (metis (mono_tags, hide_lams) M atLeast0LessThan order_trans sum_diff_nat_ivl that zero_le) 684 next 685 assume "n \<le> m" 686 then show ?thesis 687 by (simp add: \<open>0 < e\<close>) 688 qed 689 then show "\<exists>N. \<forall>m\<ge>N. \<forall>n. norm (sum f {m..<n}) < e" 690 by blast 691 qed 692next 693 assume r: ?rhs 694 then show "summable f" 695 unfolding summable_iff_convergent Cauchy_convergent_iff [symmetric] Cauchy_iff 696 proof clarify 697 fix e :: real 698 assume "0 < e" 699 with r obtain N where N: "\<And>m n. m \<ge> N \<Longrightarrow> norm (sum f {m..<n}) < e" 700 by blast 701 have "norm (sum f {..<m} - sum f {..<n}) < e" if "m\<ge>N" "n\<ge>N" for m n 702 proof (cases m n rule: linorder_class.le_cases) 703 assume "m \<le> n" 704 then show ?thesis 705 by (metis Groups_Big.sum_diff N finite_lessThan lessThan_minus_lessThan lessThan_subset_iff norm_minus_commute \<open>m\<ge>N\<close>) 706 next 707 assume "n \<le> m" 708 then show ?thesis 709 by (metis Groups_Big.sum_diff N finite_lessThan lessThan_minus_lessThan lessThan_subset_iff \<open>n\<ge>N\<close>) 710 qed 711 then show "\<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. norm (sum f {..<m} - sum f {..<n}) < e" 712 by blast 713 qed 714qed 715 716lemma summable_Cauchy': 717 fixes f :: "nat \<Rightarrow> 'a :: banach" 718 assumes "eventually (\<lambda>m. \<forall>n\<ge>m. norm (sum f {m..<n}) \<le> g m) sequentially" 719 assumes "filterlim g (nhds 0) sequentially" 720 shows "summable f" 721proof (subst summable_Cauchy, intro allI impI, goal_cases) 722 case (1 e) 723 from order_tendstoD(2)[OF assms(2) this] and assms(1) 724 have "eventually (\<lambda>m. \<forall>n. norm (sum f {m..<n}) < e) at_top" 725 proof eventually_elim 726 case (elim m) 727 show ?case 728 proof 729 fix n 730 from elim show "norm (sum f {m..<n}) < e" 731 by (cases "n \<ge> m") auto 732 qed 733 qed 734 thus ?case by (auto simp: eventually_at_top_linorder) 735qed 736 737context 738 fixes f :: "nat \<Rightarrow> 'a::banach" 739begin 740 741text \<open>Absolute convergence imples normal convergence.\<close> 742 743lemma summable_norm_cancel: "summable (\<lambda>n. norm (f n)) \<Longrightarrow> summable f" 744 unfolding summable_Cauchy 745 apply (erule all_forward imp_forward ex_forward | assumption)+ 746 apply (fastforce simp add: order_le_less_trans [OF norm_sum] order_le_less_trans [OF abs_ge_self]) 747 done 748 749lemma summable_norm: "summable (\<lambda>n. norm (f n)) \<Longrightarrow> norm (suminf f) \<le> (\<Sum>n. norm (f n))" 750 by (auto intro: LIMSEQ_le tendsto_norm summable_norm_cancel summable_LIMSEQ norm_sum) 751 752text \<open>Comparison tests.\<close> 753 754lemma summable_comparison_test: 755 assumes fg: "\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n" and g: "summable g" 756 shows "summable f" 757proof - 758 obtain N where N: "\<And>n. n\<ge>N \<Longrightarrow> norm (f n) \<le> g n" 759 using assms by blast 760 show ?thesis 761 proof (clarsimp simp add: summable_Cauchy) 762 fix e :: real 763 assume "0 < e" 764 then obtain Ng where Ng: "\<And>m n. m \<ge> Ng \<Longrightarrow> norm (sum g {m..<n}) < e" 765 using g by (fastforce simp: summable_Cauchy) 766 with N have "norm (sum f {m..<n}) < e" if "m\<ge>max N Ng" for m n 767 proof - 768 have "norm (sum f {m..<n}) \<le> sum g {m..<n}" 769 using N that by (force intro: sum_norm_le) 770 also have "... \<le> norm (sum g {m..<n})" 771 by simp 772 also have "... < e" 773 using Ng that by auto 774 finally show ?thesis . 775 qed 776 then show "\<exists>N. \<forall>m\<ge>N. \<forall>n. norm (sum f {m..<n}) < e" 777 by blast 778 qed 779qed 780 781lemma summable_comparison_test_ev: 782 "eventually (\<lambda>n. norm (f n) \<le> g n) sequentially \<Longrightarrow> summable g \<Longrightarrow> summable f" 783 by (rule summable_comparison_test) (auto simp: eventually_at_top_linorder) 784 785text \<open>A better argument order.\<close> 786lemma summable_comparison_test': "summable g \<Longrightarrow> (\<And>n. n \<ge> N \<Longrightarrow> norm (f n) \<le> g n) \<Longrightarrow> summable f" 787 by (rule summable_comparison_test) auto 788 789 790subsection \<open>The Ratio Test\<close> 791 792lemma summable_ratio_test: 793 assumes "c < 1" "\<And>n. n \<ge> N \<Longrightarrow> norm (f (Suc n)) \<le> c * norm (f n)" 794 shows "summable f" 795proof (cases "0 < c") 796 case True 797 show "summable f" 798 proof (rule summable_comparison_test) 799 show "\<exists>N'. \<forall>n\<ge>N'. norm (f n) \<le> (norm (f N) / (c ^ N)) * c ^ n" 800 proof (intro exI allI impI) 801 fix n 802 assume "N \<le> n" 803 then show "norm (f n) \<le> (norm (f N) / (c ^ N)) * c ^ n" 804 proof (induct rule: inc_induct) 805 case base 806 with True show ?case by simp 807 next 808 case (step m) 809 have "norm (f (Suc m)) / c ^ Suc m * c ^ n \<le> norm (f m) / c ^ m * c ^ n" 810 using \<open>0 < c\<close> \<open>c < 1\<close> assms(2)[OF \<open>N \<le> m\<close>] by (simp add: field_simps) 811 with step show ?case by simp 812 qed 813 qed 814 show "summable (\<lambda>n. norm (f N) / c ^ N * c ^ n)" 815 using \<open>0 < c\<close> \<open>c < 1\<close> by (intro summable_mult summable_geometric) simp 816 qed 817next 818 case False 819 have "f (Suc n) = 0" if "n \<ge> N" for n 820 proof - 821 from that have "norm (f (Suc n)) \<le> c * norm (f n)" 822 by (rule assms(2)) 823 also have "\<dots> \<le> 0" 824 using False by (simp add: not_less mult_nonpos_nonneg) 825 finally show ?thesis 826 by auto 827 qed 828 then show "summable f" 829 by (intro sums_summable[OF sums_finite, of "{.. Suc N}"]) (auto simp: not_le Suc_less_eq2) 830qed 831 832end 833 834 835text \<open>Relations among convergence and absolute convergence for power series.\<close> 836 837lemma Abel_lemma: 838 fixes a :: "nat \<Rightarrow> 'a::real_normed_vector" 839 assumes r: "0 \<le> r" 840 and r0: "r < r0" 841 and M: "\<And>n. norm (a n) * r0^n \<le> M" 842 shows "summable (\<lambda>n. norm (a n) * r^n)" 843proof (rule summable_comparison_test') 844 show "summable (\<lambda>n. M * (r / r0) ^ n)" 845 using assms by (auto simp add: summable_mult summable_geometric) 846 show "norm (norm (a n) * r ^ n) \<le> M * (r / r0) ^ n" for n 847 using r r0 M [of n] dual_order.order_iff_strict 848 by (fastforce simp add: abs_mult field_simps) 849qed 850 851 852text \<open>Summability of geometric series for real algebras.\<close> 853 854lemma complete_algebra_summable_geometric: 855 fixes x :: "'a::{real_normed_algebra_1,banach}" 856 assumes "norm x < 1" 857 shows "summable (\<lambda>n. x ^ n)" 858proof (rule summable_comparison_test) 859 show "\<exists>N. \<forall>n\<ge>N. norm (x ^ n) \<le> norm x ^ n" 860 by (simp add: norm_power_ineq) 861 from assms show "summable (\<lambda>n. norm x ^ n)" 862 by (simp add: summable_geometric) 863qed 864 865 866subsection \<open>Cauchy Product Formula\<close> 867 868text \<open> 869 Proof based on Analysis WebNotes: Chapter 07, Class 41 870 \<^url>\<open>http://www.math.unl.edu/~webnotes/classes/class41/prp77.htm\<close> 871\<close> 872 873lemma Cauchy_product_sums: 874 fixes a b :: "nat \<Rightarrow> 'a::{real_normed_algebra,banach}" 875 assumes a: "summable (\<lambda>k. norm (a k))" 876 and b: "summable (\<lambda>k. norm (b k))" 877 shows "(\<lambda>k. \<Sum>i\<le>k. a i * b (k - i)) sums ((\<Sum>k. a k) * (\<Sum>k. b k))" 878proof - 879 let ?S1 = "\<lambda>n::nat. {..<n} \<times> {..<n}" 880 let ?S2 = "\<lambda>n::nat. {(i,j). i + j < n}" 881 have S1_mono: "\<And>m n. m \<le> n \<Longrightarrow> ?S1 m \<subseteq> ?S1 n" by auto 882 have S2_le_S1: "\<And>n. ?S2 n \<subseteq> ?S1 n" by auto 883 have S1_le_S2: "\<And>n. ?S1 (n div 2) \<subseteq> ?S2 n" by auto 884 have finite_S1: "\<And>n. finite (?S1 n)" by simp 885 with S2_le_S1 have finite_S2: "\<And>n. finite (?S2 n)" by (rule finite_subset) 886 887 let ?g = "\<lambda>(i,j). a i * b j" 888 let ?f = "\<lambda>(i,j). norm (a i) * norm (b j)" 889 have f_nonneg: "\<And>x. 0 \<le> ?f x" by auto 890 then have norm_sum_f: "\<And>A. norm (sum ?f A) = sum ?f A" 891 unfolding real_norm_def 892 by (simp only: abs_of_nonneg sum_nonneg [rule_format]) 893 894 have "(\<lambda>n. (\<Sum>k<n. a k) * (\<Sum>k<n. b k)) \<longlonglongrightarrow> (\<Sum>k. a k) * (\<Sum>k. b k)" 895 by (intro tendsto_mult summable_LIMSEQ summable_norm_cancel [OF a] summable_norm_cancel [OF b]) 896 then have 1: "(\<lambda>n. sum ?g (?S1 n)) \<longlonglongrightarrow> (\<Sum>k. a k) * (\<Sum>k. b k)" 897 by (simp only: sum_product sum.Sigma [rule_format] finite_lessThan) 898 899 have "(\<lambda>n. (\<Sum>k<n. norm (a k)) * (\<Sum>k<n. norm (b k))) \<longlonglongrightarrow> (\<Sum>k. norm (a k)) * (\<Sum>k. norm (b k))" 900 using a b by (intro tendsto_mult summable_LIMSEQ) 901 then have "(\<lambda>n. sum ?f (?S1 n)) \<longlonglongrightarrow> (\<Sum>k. norm (a k)) * (\<Sum>k. norm (b k))" 902 by (simp only: sum_product sum.Sigma [rule_format] finite_lessThan) 903 then have "convergent (\<lambda>n. sum ?f (?S1 n))" 904 by (rule convergentI) 905 then have Cauchy: "Cauchy (\<lambda>n. sum ?f (?S1 n))" 906 by (rule convergent_Cauchy) 907 have "Zfun (\<lambda>n. sum ?f (?S1 n - ?S2 n)) sequentially" 908 proof (rule ZfunI, simp only: eventually_sequentially norm_sum_f) 909 fix r :: real 910 assume r: "0 < r" 911 from CauchyD [OF Cauchy r] obtain N 912 where "\<forall>m\<ge>N. \<forall>n\<ge>N. norm (sum ?f (?S1 m) - sum ?f (?S1 n)) < r" .. 913 then have "\<And>m n. N \<le> n \<Longrightarrow> n \<le> m \<Longrightarrow> norm (sum ?f (?S1 m - ?S1 n)) < r" 914 by (simp only: sum_diff finite_S1 S1_mono) 915 then have N: "\<And>m n. N \<le> n \<Longrightarrow> n \<le> m \<Longrightarrow> sum ?f (?S1 m - ?S1 n) < r" 916 by (simp only: norm_sum_f) 917 show "\<exists>N. \<forall>n\<ge>N. sum ?f (?S1 n - ?S2 n) < r" 918 proof (intro exI allI impI) 919 fix n 920 assume "2 * N \<le> n" 921 then have n: "N \<le> n div 2" by simp 922 have "sum ?f (?S1 n - ?S2 n) \<le> sum ?f (?S1 n - ?S1 (n div 2))" 923 by (intro sum_mono2 finite_Diff finite_S1 f_nonneg Diff_mono subset_refl S1_le_S2) 924 also have "\<dots> < r" 925 using n div_le_dividend by (rule N) 926 finally show "sum ?f (?S1 n - ?S2 n) < r" . 927 qed 928 qed 929 then have "Zfun (\<lambda>n. sum ?g (?S1 n - ?S2 n)) sequentially" 930 apply (rule Zfun_le [rule_format]) 931 apply (simp only: norm_sum_f) 932 apply (rule order_trans [OF norm_sum sum_mono]) 933 apply (auto simp add: norm_mult_ineq) 934 done 935 then have 2: "(\<lambda>n. sum ?g (?S1 n) - sum ?g (?S2 n)) \<longlonglongrightarrow> 0" 936 unfolding tendsto_Zfun_iff diff_0_right 937 by (simp only: sum_diff finite_S1 S2_le_S1) 938 with 1 have "(\<lambda>n. sum ?g (?S2 n)) \<longlonglongrightarrow> (\<Sum>k. a k) * (\<Sum>k. b k)" 939 by (rule Lim_transform2) 940 then show ?thesis 941 by (simp only: sums_def sum.triangle_reindex) 942qed 943 944lemma Cauchy_product: 945 fixes a b :: "nat \<Rightarrow> 'a::{real_normed_algebra,banach}" 946 assumes "summable (\<lambda>k. norm (a k))" 947 and "summable (\<lambda>k. norm (b k))" 948 shows "(\<Sum>k. a k) * (\<Sum>k. b k) = (\<Sum>k. \<Sum>i\<le>k. a i * b (k - i))" 949 using assms by (rule Cauchy_product_sums [THEN sums_unique]) 950 951lemma summable_Cauchy_product: 952 fixes a b :: "nat \<Rightarrow> 'a::{real_normed_algebra,banach}" 953 assumes "summable (\<lambda>k. norm (a k))" 954 and "summable (\<lambda>k. norm (b k))" 955 shows "summable (\<lambda>k. \<Sum>i\<le>k. a i * b (k - i))" 956 using Cauchy_product_sums[OF assms] by (simp add: sums_iff) 957 958 959subsection \<open>Series on \<^typ>\<open>real\<close>s\<close> 960 961lemma summable_norm_comparison_test: 962 "\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n \<Longrightarrow> summable g \<Longrightarrow> summable (\<lambda>n. norm (f n))" 963 by (rule summable_comparison_test) auto 964 965lemma summable_rabs_comparison_test: "\<exists>N. \<forall>n\<ge>N. \<bar>f n\<bar> \<le> g n \<Longrightarrow> summable g \<Longrightarrow> summable (\<lambda>n. \<bar>f n\<bar>)" 966 for f :: "nat \<Rightarrow> real" 967 by (rule summable_comparison_test) auto 968 969lemma summable_rabs_cancel: "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> summable f" 970 for f :: "nat \<Rightarrow> real" 971 by (rule summable_norm_cancel) simp 972 973lemma summable_rabs: "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> \<bar>suminf f\<bar> \<le> (\<Sum>n. \<bar>f n\<bar>)" 974 for f :: "nat \<Rightarrow> real" 975 by (fold real_norm_def) (rule summable_norm) 976 977lemma summable_zero_power [simp]: "summable (\<lambda>n. 0 ^ n :: 'a::{comm_ring_1,topological_space})" 978proof - 979 have "(\<lambda>n. 0 ^ n :: 'a) = (\<lambda>n. if n = 0 then 0^0 else 0)" 980 by (intro ext) (simp add: zero_power) 981 moreover have "summable \<dots>" by simp 982 ultimately show ?thesis by simp 983qed 984 985lemma summable_zero_power' [simp]: "summable (\<lambda>n. f n * 0 ^ n :: 'a::{ring_1,topological_space})" 986proof - 987 have "(\<lambda>n. f n * 0 ^ n :: 'a) = (\<lambda>n. if n = 0 then f 0 * 0^0 else 0)" 988 by (intro ext) (simp add: zero_power) 989 moreover have "summable \<dots>" by simp 990 ultimately show ?thesis by simp 991qed 992 993lemma summable_power_series: 994 fixes z :: real 995 assumes le_1: "\<And>i. f i \<le> 1" 996 and nonneg: "\<And>i. 0 \<le> f i" 997 and z: "0 \<le> z" "z < 1" 998 shows "summable (\<lambda>i. f i * z^i)" 999proof (rule summable_comparison_test[OF _ summable_geometric]) 1000 show "norm z < 1" 1001 using z by (auto simp: less_imp_le) 1002 show "\<And>n. \<exists>N. \<forall>na\<ge>N. norm (f na * z ^ na) \<le> z ^ na" 1003 using z 1004 by (auto intro!: exI[of _ 0] mult_left_le_one_le simp: abs_mult nonneg power_abs less_imp_le le_1) 1005qed 1006 1007lemma summable_0_powser: "summable (\<lambda>n. f n * 0 ^ n :: 'a::real_normed_div_algebra)" 1008proof - 1009 have A: "(\<lambda>n. f n * 0 ^ n) = (\<lambda>n. if n = 0 then f n else 0)" 1010 by (intro ext) auto 1011 then show ?thesis 1012 by (subst A) simp_all 1013qed 1014 1015lemma summable_powser_split_head: 1016 "summable (\<lambda>n. f (Suc n) * z ^ n :: 'a::real_normed_div_algebra) = summable (\<lambda>n. f n * z ^ n)" 1017proof - 1018 have "summable (\<lambda>n. f (Suc n) * z ^ n) \<longleftrightarrow> summable (\<lambda>n. f (Suc n) * z ^ Suc n)" 1019 (is "?lhs \<longleftrightarrow> ?rhs") 1020 proof 1021 show ?rhs if ?lhs 1022 using summable_mult2[OF that, of z] 1023 by (simp add: power_commutes algebra_simps) 1024 show ?lhs if ?rhs 1025 using summable_mult2[OF that, of "inverse z"] 1026 by (cases "z \<noteq> 0", subst (asm) power_Suc2) (simp_all add: algebra_simps) 1027 qed 1028 also have "\<dots> \<longleftrightarrow> summable (\<lambda>n. f n * z ^ n)" by (rule summable_Suc_iff) 1029 finally show ?thesis . 1030qed 1031 1032lemma summable_powser_ignore_initial_segment: 1033 fixes f :: "nat \<Rightarrow> 'a :: real_normed_div_algebra" 1034 shows "summable (\<lambda>n. f (n + m) * z ^ n) \<longleftrightarrow> summable (\<lambda>n. f n * z ^ n)" 1035proof (induction m) 1036 case (Suc m) 1037 have "summable (\<lambda>n. f (n + Suc m) * z ^ n) = summable (\<lambda>n. f (Suc n + m) * z ^ n)" 1038 by simp 1039 also have "\<dots> = summable (\<lambda>n. f (n + m) * z ^ n)" 1040 by (rule summable_powser_split_head) 1041 also have "\<dots> = summable (\<lambda>n. f n * z ^ n)" 1042 by (rule Suc.IH) 1043 finally show ?case . 1044qed simp_all 1045 1046lemma powser_split_head: 1047 fixes f :: "nat \<Rightarrow> 'a::{real_normed_div_algebra,banach}" 1048 assumes "summable (\<lambda>n. f n * z ^ n)" 1049 shows "suminf (\<lambda>n. f n * z ^ n) = f 0 + suminf (\<lambda>n. f (Suc n) * z ^ n) * z" 1050 and "suminf (\<lambda>n. f (Suc n) * z ^ n) * z = suminf (\<lambda>n. f n * z ^ n) - f 0" 1051 and "summable (\<lambda>n. f (Suc n) * z ^ n)" 1052proof - 1053 from assms show "summable (\<lambda>n. f (Suc n) * z ^ n)" 1054 by (subst summable_powser_split_head) 1055 from suminf_mult2[OF this, of z] 1056 have "(\<Sum>n. f (Suc n) * z ^ n) * z = (\<Sum>n. f (Suc n) * z ^ Suc n)" 1057 by (simp add: power_commutes algebra_simps) 1058 also from assms have "\<dots> = suminf (\<lambda>n. f n * z ^ n) - f 0" 1059 by (subst suminf_split_head) simp_all 1060 finally show "suminf (\<lambda>n. f n * z ^ n) = f 0 + suminf (\<lambda>n. f (Suc n) * z ^ n) * z" 1061 by simp 1062 then show "suminf (\<lambda>n. f (Suc n) * z ^ n) * z = suminf (\<lambda>n. f n * z ^ n) - f 0" 1063 by simp 1064qed 1065 1066lemma summable_partial_sum_bound: 1067 fixes f :: "nat \<Rightarrow> 'a :: banach" 1068 and e :: real 1069 assumes summable: "summable f" 1070 and e: "e > 0" 1071 obtains N where "\<And>m n. m \<ge> N \<Longrightarrow> norm (\<Sum>k=m..n. f k) < e" 1072proof - 1073 from summable have "Cauchy (\<lambda>n. \<Sum>k<n. f k)" 1074 by (simp add: Cauchy_convergent_iff summable_iff_convergent) 1075 from CauchyD [OF this e] obtain N 1076 where N: "\<And>m n. m \<ge> N \<Longrightarrow> n \<ge> N \<Longrightarrow> norm ((\<Sum>k<m. f k) - (\<Sum>k<n. f k)) < e" 1077 by blast 1078 have "norm (\<Sum>k=m..n. f k) < e" if m: "m \<ge> N" for m n 1079 proof (cases "n \<ge> m") 1080 case True 1081 with m have "norm ((\<Sum>k<Suc n. f k) - (\<Sum>k<m. f k)) < e" 1082 by (intro N) simp_all 1083 also from True have "(\<Sum>k<Suc n. f k) - (\<Sum>k<m. f k) = (\<Sum>k=m..n. f k)" 1084 by (subst sum_diff [symmetric]) (simp_all add: sum.last_plus) 1085 finally show ?thesis . 1086 next 1087 case False 1088 with e show ?thesis by simp_all 1089 qed 1090 then show ?thesis by (rule that) 1091qed 1092 1093lemma powser_sums_if: 1094 "(\<lambda>n. (if n = m then (1 :: 'a::{ring_1,topological_space}) else 0) * z^n) sums z^m" 1095proof - 1096 have "(\<lambda>n. (if n = m then 1 else 0) * z^n) = (\<lambda>n. if n = m then z^n else 0)" 1097 by (intro ext) auto 1098 then show ?thesis 1099 by (simp add: sums_single) 1100qed 1101 1102lemma 1103 fixes f :: "nat \<Rightarrow> real" 1104 assumes "summable f" 1105 and "inj g" 1106 and pos: "\<And>x. 0 \<le> f x" 1107 shows summable_reindex: "summable (f \<circ> g)" 1108 and suminf_reindex_mono: "suminf (f \<circ> g) \<le> suminf f" 1109 and suminf_reindex: "(\<And>x. x \<notin> range g \<Longrightarrow> f x = 0) \<Longrightarrow> suminf (f \<circ> g) = suminf f" 1110proof - 1111 from \<open>inj g\<close> have [simp]: "\<And>A. inj_on g A" 1112 by (rule subset_inj_on) simp 1113 1114 have smaller: "\<forall>n. (\<Sum>i<n. (f \<circ> g) i) \<le> suminf f" 1115 proof 1116 fix n 1117 have "\<forall> n' \<in> (g ` {..<n}). n' < Suc (Max (g ` {..<n}))" 1118 by (metis Max_ge finite_imageI finite_lessThan not_le not_less_eq) 1119 then obtain m where n: "\<And>n'. n' < n \<Longrightarrow> g n' < m" 1120 by blast 1121 1122 have "(\<Sum>i<n. f (g i)) = sum f (g ` {..<n})" 1123 by (simp add: sum.reindex) 1124 also have "\<dots> \<le> (\<Sum>i<m. f i)" 1125 by (rule sum_mono2) (auto simp add: pos n[rule_format]) 1126 also have "\<dots> \<le> suminf f" 1127 using \<open>summable f\<close> 1128 by (rule sum_le_suminf) (simp_all add: pos) 1129 finally show "(\<Sum>i<n. (f \<circ> g) i) \<le> suminf f" 1130 by simp 1131 qed 1132 1133 have "incseq (\<lambda>n. \<Sum>i<n. (f \<circ> g) i)" 1134 by (rule incseq_SucI) (auto simp add: pos) 1135 then obtain L where L: "(\<lambda> n. \<Sum>i<n. (f \<circ> g) i) \<longlonglongrightarrow> L" 1136 using smaller by(rule incseq_convergent) 1137 then have "(f \<circ> g) sums L" 1138 by (simp add: sums_def) 1139 then show "summable (f \<circ> g)" 1140 by (auto simp add: sums_iff) 1141 1142 then have "(\<lambda>n. \<Sum>i<n. (f \<circ> g) i) \<longlonglongrightarrow> suminf (f \<circ> g)" 1143 by (rule summable_LIMSEQ) 1144 then show le: "suminf (f \<circ> g) \<le> suminf f" 1145 by(rule LIMSEQ_le_const2)(blast intro: smaller[rule_format]) 1146 1147 assume f: "\<And>x. x \<notin> range g \<Longrightarrow> f x = 0" 1148 1149 from \<open>summable f\<close> have "suminf f \<le> suminf (f \<circ> g)" 1150 proof (rule suminf_le_const) 1151 fix n 1152 have "\<forall> n' \<in> (g -` {..<n}). n' < Suc (Max (g -` {..<n}))" 1153 by(auto intro: Max_ge simp add: finite_vimageI less_Suc_eq_le) 1154 then obtain m where n: "\<And>n'. g n' < n \<Longrightarrow> n' < m" 1155 by blast 1156 have "(\<Sum>i<n. f i) = (\<Sum>i\<in>{..<n} \<inter> range g. f i)" 1157 using f by(auto intro: sum.mono_neutral_cong_right) 1158 also have "\<dots> = (\<Sum>i\<in>g -` {..<n}. (f \<circ> g) i)" 1159 by (rule sum.reindex_cong[where l=g])(auto) 1160 also have "\<dots> \<le> (\<Sum>i<m. (f \<circ> g) i)" 1161 by (rule sum_mono2)(auto simp add: pos n) 1162 also have "\<dots> \<le> suminf (f \<circ> g)" 1163 using \<open>summable (f \<circ> g)\<close> by (rule sum_le_suminf) (simp_all add: pos) 1164 finally show "sum f {..<n} \<le> suminf (f \<circ> g)" . 1165 qed 1166 with le show "suminf (f \<circ> g) = suminf f" 1167 by (rule antisym) 1168qed 1169 1170lemma sums_mono_reindex: 1171 assumes subseq: "strict_mono g" 1172 and zero: "\<And>n. n \<notin> range g \<Longrightarrow> f n = 0" 1173 shows "(\<lambda>n. f (g n)) sums c \<longleftrightarrow> f sums c" 1174 unfolding sums_def 1175proof 1176 assume lim: "(\<lambda>n. \<Sum>k<n. f k) \<longlonglongrightarrow> c" 1177 have "(\<lambda>n. \<Sum>k<n. f (g k)) = (\<lambda>n. \<Sum>k<g n. f k)" 1178 proof 1179 fix n :: nat 1180 from subseq have "(\<Sum>k<n. f (g k)) = (\<Sum>k\<in>g`{..<n}. f k)" 1181 by (subst sum.reindex) (auto intro: strict_mono_imp_inj_on) 1182 also from subseq have "\<dots> = (\<Sum>k<g n. f k)" 1183 by (intro sum.mono_neutral_left ballI zero) 1184 (auto simp: strict_mono_less strict_mono_less_eq) 1185 finally show "(\<Sum>k<n. f (g k)) = (\<Sum>k<g n. f k)" . 1186 qed 1187 also from LIMSEQ_subseq_LIMSEQ[OF lim subseq] have "\<dots> \<longlonglongrightarrow> c" 1188 by (simp only: o_def) 1189 finally show "(\<lambda>n. \<Sum>k<n. f (g k)) \<longlonglongrightarrow> c" . 1190next 1191 assume lim: "(\<lambda>n. \<Sum>k<n. f (g k)) \<longlonglongrightarrow> c" 1192 define g_inv where "g_inv n = (LEAST m. g m \<ge> n)" for n 1193 from filterlim_subseq[OF subseq] have g_inv_ex: "\<exists>m. g m \<ge> n" for n 1194 by (auto simp: filterlim_at_top eventually_at_top_linorder) 1195 then have g_inv: "g (g_inv n) \<ge> n" for n 1196 unfolding g_inv_def by (rule LeastI_ex) 1197 have g_inv_least: "m \<ge> g_inv n" if "g m \<ge> n" for m n 1198 using that unfolding g_inv_def by (rule Least_le) 1199 have g_inv_least': "g m < n" if "m < g_inv n" for m n 1200 using that g_inv_least[of n m] by linarith 1201 have "(\<lambda>n. \<Sum>k<n. f k) = (\<lambda>n. \<Sum>k<g_inv n. f (g k))" 1202 proof 1203 fix n :: nat 1204 { 1205 fix k 1206 assume k: "k \<in> {..<n} - g`{..<g_inv n}" 1207 have "k \<notin> range g" 1208 proof (rule notI, elim imageE) 1209 fix l 1210 assume l: "k = g l" 1211 have "g l < g (g_inv n)" 1212 by (rule less_le_trans[OF _ g_inv]) (use k l in simp_all) 1213 with subseq have "l < g_inv n" 1214 by (simp add: strict_mono_less) 1215 with k l show False 1216 by simp 1217 qed 1218 then have "f k = 0" 1219 by (rule zero) 1220 } 1221 with g_inv_least' g_inv have "(\<Sum>k<n. f k) = (\<Sum>k\<in>g`{..<g_inv n}. f k)" 1222 by (intro sum.mono_neutral_right) auto 1223 also from subseq have "\<dots> = (\<Sum>k<g_inv n. f (g k))" 1224 using strict_mono_imp_inj_on by (subst sum.reindex) simp_all 1225 finally show "(\<Sum>k<n. f k) = (\<Sum>k<g_inv n. f (g k))" . 1226 qed 1227 also { 1228 fix K n :: nat 1229 assume "g K \<le> n" 1230 also have "n \<le> g (g_inv n)" 1231 by (rule g_inv) 1232 finally have "K \<le> g_inv n" 1233 using subseq by (simp add: strict_mono_less_eq) 1234 } 1235 then have "filterlim g_inv at_top sequentially" 1236 by (auto simp: filterlim_at_top eventually_at_top_linorder) 1237 with lim have "(\<lambda>n. \<Sum>k<g_inv n. f (g k)) \<longlonglongrightarrow> c" 1238 by (rule filterlim_compose) 1239 finally show "(\<lambda>n. \<Sum>k<n. f k) \<longlonglongrightarrow> c" . 1240qed 1241 1242lemma summable_mono_reindex: 1243 assumes subseq: "strict_mono g" 1244 and zero: "\<And>n. n \<notin> range g \<Longrightarrow> f n = 0" 1245 shows "summable (\<lambda>n. f (g n)) \<longleftrightarrow> summable f" 1246 using sums_mono_reindex[of g f, OF assms] by (simp add: summable_def) 1247 1248lemma suminf_mono_reindex: 1249 fixes f :: "nat \<Rightarrow> 'a::{t2_space,comm_monoid_add}" 1250 assumes "strict_mono g" "\<And>n. n \<notin> range g \<Longrightarrow> f n = 0" 1251 shows "suminf (\<lambda>n. f (g n)) = suminf f" 1252proof (cases "summable f") 1253 case True 1254 with sums_mono_reindex [of g f, OF assms] 1255 and summable_mono_reindex [of g f, OF assms] 1256 show ?thesis 1257 by (simp add: sums_iff) 1258next 1259 case False 1260 then have "\<not>(\<exists>c. f sums c)" 1261 unfolding summable_def by blast 1262 then have "suminf f = The (\<lambda>_. False)" 1263 by (simp add: suminf_def) 1264 moreover from False have "\<not> summable (\<lambda>n. f (g n))" 1265 using summable_mono_reindex[of g f, OF assms] by simp 1266 then have "\<not>(\<exists>c. (\<lambda>n. f (g n)) sums c)" 1267 unfolding summable_def by blast 1268 then have "suminf (\<lambda>n. f (g n)) = The (\<lambda>_. False)" 1269 by (simp add: suminf_def) 1270 ultimately show ?thesis by simp 1271qed 1272 1273lemma summable_bounded_partials: 1274 fixes f :: "nat \<Rightarrow> 'a :: {real_normed_vector,complete_space}" 1275 assumes bound: "eventually (\<lambda>x0. \<forall>a\<ge>x0. \<forall>b>a. norm (sum f {a<..b}) \<le> g a) sequentially" 1276 assumes g: "g \<longlonglongrightarrow> 0" 1277 shows "summable f" unfolding summable_iff_convergent' 1278proof (intro Cauchy_convergent CauchyI', goal_cases) 1279 case (1 \<epsilon>) 1280 with g have "eventually (\<lambda>x. \<bar>g x\<bar> < \<epsilon>) sequentially" 1281 by (auto simp: tendsto_iff) 1282 from eventually_conj[OF this bound] obtain x0 where x0: 1283 "\<And>x. x \<ge> x0 \<Longrightarrow> \<bar>g x\<bar> < \<epsilon>" "\<And>a b. x0 \<le> a \<Longrightarrow> a < b \<Longrightarrow> norm (sum f {a<..b}) \<le> g a" 1284 unfolding eventually_at_top_linorder by auto 1285 1286 show ?case 1287 proof (intro exI[of _ x0] allI impI) 1288 fix m n assume mn: "x0 \<le> m" "m < n" 1289 have "dist (sum f {..m}) (sum f {..n}) = norm (sum f {..n} - sum f {..m})" 1290 by (simp add: dist_norm norm_minus_commute) 1291 also have "sum f {..n} - sum f {..m} = sum f ({..n} - {..m})" 1292 using mn by (intro Groups_Big.sum_diff [symmetric]) auto 1293 also have "{..n} - {..m} = {m<..n}" using mn by auto 1294 also have "norm (sum f {m<..n}) \<le> g m" using mn by (intro x0) auto 1295 also have "\<dots> \<le> \<bar>g m\<bar>" by simp 1296 also have "\<dots> < \<epsilon>" using mn by (intro x0) auto 1297 finally show "dist (sum f {..m}) (sum f {..n}) < \<epsilon>" . 1298 qed 1299qed 1300 1301end 1302