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