src/HOL/Hyperreal/Series.thy
author huffman
Mon, 02 Oct 2006 23:15:35 +0200
changeset 20848 27a09c3eca1f
parent 20792 add17d26151b
child 21141 f0b5e6254a1f
permissions -rw-r--r--
generalize summability lemmas using class banach
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     1
(*  Title       : Series.thy
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     2
    Author      : Jacques D. Fleuriot
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     3
    Copyright   : 1998  University of Cambridge
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
     4
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
     5
Converted to Isar and polished by lcp
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
     6
Converted to setsum and polished yet more by TNN
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
     7
Additional contributions by Jeremy Avigad
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     8
*) 
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     9
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    10
header{*Finite Summation and Infinite Series*}
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    11
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15085
diff changeset
    12
theory Series
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
    13
imports SEQ Lim
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15085
diff changeset
    14
begin
15561
045a07ac35a7 another reorganization of setsums and intervals
nipkow
parents: 15546
diff changeset
    15
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    16
definition
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    17
   sums  :: "(nat \<Rightarrow> 'a::real_normed_vector) \<Rightarrow> 'a \<Rightarrow> bool"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    18
     (infixr "sums" 80)
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    19
   "f sums s = (%n. setsum f {0..<n}) ----> s"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    20
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    21
   summable :: "(nat \<Rightarrow> 'a::real_normed_vector) \<Rightarrow> bool"
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    22
   "summable f = (\<exists>s. f sums s)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    23
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    24
   suminf   :: "(nat \<Rightarrow> 'a::real_normed_vector) \<Rightarrow> 'a"
20688
690d866a165d change definitions from SOME to THE
huffman
parents: 20552
diff changeset
    25
   "suminf f = (THE s. f sums s)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    26
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
    27
syntax
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    28
  "_suminf" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a" ("\<Sum>_. _" [0, 10] 10)
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
    29
translations
20770
2c583720436e fixed translations: CONST;
wenzelm
parents: 20692
diff changeset
    30
  "\<Sum>i. b" == "CONST suminf (%i. b)"
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
    31
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    32
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    33
lemma sumr_diff_mult_const:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    34
 "setsum f {0..<n} - (real n*r) = setsum (%i. f i - r) {0..<n::nat}"
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15360
diff changeset
    35
by (simp add: diff_minus setsum_addf real_of_nat_def)
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15360
diff changeset
    36
15542
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    37
lemma real_setsum_nat_ivl_bounded:
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    38
     "(!!p. p < n \<Longrightarrow> f(p) \<le> K)
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    39
      \<Longrightarrow> setsum f {0..<n::nat} \<le> real n * K"
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    40
using setsum_bounded[where A = "{0..<n}"]
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    41
by (auto simp:real_of_nat_def)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    42
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    43
(* Generalize from real to some algebraic structure? *)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    44
lemma sumr_minus_one_realpow_zero [simp]:
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
    45
  "(\<Sum>i=0..<2*n. (-1) ^ Suc i) = (0::real)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
    46
by (induct "n", auto)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    47
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    48
(* FIXME this is an awful lemma! *)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    49
lemma sumr_one_lb_realpow_zero [simp]:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    50
  "(\<Sum>n=Suc 0..<n. f(n) * (0::real) ^ n) = 0"
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    51
by (rule setsum_0', simp)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    52
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
    53
lemma sumr_group:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    54
     "(\<Sum>m=0..<n::nat. setsum f {m * k ..< m*k + k}) = setsum f {0 ..< n * k}"
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
    55
apply (subgoal_tac "k = 0 | 0 < k", auto)
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
    56
apply (induct "n")
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    57
apply (simp_all add: setsum_add_nat_ivl add_commute)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    58
done
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    59
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    60
lemma sumr_offset3:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    61
  "setsum f {0::nat..<n+k} = (\<Sum>m=0..<n. f (m+k)) + setsum f {0..<k}"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    62
apply (subst setsum_shift_bounds_nat_ivl [symmetric])
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    63
apply (simp add: setsum_add_nat_ivl add_commute)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    64
done
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    65
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    66
lemma sumr_offset:
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    67
  fixes f :: "nat \<Rightarrow> 'a::ab_group_add"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    68
  shows "(\<Sum>m=0..<n. f(m+k)) = setsum f {0..<n+k} - setsum f {0..<k}"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    69
by (simp add: sumr_offset3)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    70
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    71
lemma sumr_offset2:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    72
 "\<forall>f. (\<Sum>m=0..<n::nat. f(m+k)::real) = setsum f {0..<n+k} - setsum f {0..<k}"
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    73
by (simp add: sumr_offset)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    74
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    75
lemma sumr_offset4:
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    76
  "\<forall>n f. setsum f {0::nat..<n+k} = (\<Sum>m=0..<n. f (m+k)::real) + setsum f {0..<k}"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
    77
by (clarify, rule sumr_offset3)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    78
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    79
(*
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    80
lemma sumr_from_1_from_0: "0 < n ==>
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    81
      (\<Sum>n=Suc 0 ..< Suc n. if even(n) then 0 else
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    82
             ((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n =
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    83
      (\<Sum>n=0..<Suc n. if even(n) then 0 else
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    84
             ((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    85
by (rule_tac n1 = 1 in sumr_split_add [THEN subst], auto)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    86
*)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    87
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    88
subsection{* Infinite Sums, by the Properties of Limits*}
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    89
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    90
(*----------------------
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    91
   suminf is the sum   
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    92
 ---------------------*)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    93
lemma sums_summable: "f sums l ==> summable f"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    94
by (simp add: sums_def summable_def, blast)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    95
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    96
lemma summable_sums: "summable f ==> f sums (suminf f)"
20688
690d866a165d change definitions from SOME to THE
huffman
parents: 20552
diff changeset
    97
apply (simp add: summable_def suminf_def sums_def)
690d866a165d change definitions from SOME to THE
huffman
parents: 20552
diff changeset
    98
apply (blast intro: theI LIMSEQ_unique)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    99
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   100
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   101
lemma summable_sumr_LIMSEQ_suminf: 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   102
     "summable f ==> (%n. setsum f {0..<n}) ----> (suminf f)"
20688
690d866a165d change definitions from SOME to THE
huffman
parents: 20552
diff changeset
   103
by (rule summable_sums [unfolded sums_def])
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   104
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   105
(*-------------------
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   106
    sum is unique                    
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   107
 ------------------*)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   108
lemma sums_unique: "f sums s ==> (s = suminf f)"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   109
apply (frule sums_summable [THEN summable_sums])
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   110
apply (auto intro!: LIMSEQ_unique simp add: sums_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   111
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   112
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   113
lemma sums_split_initial_segment: "f sums s ==> 
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   114
  (%n. f(n + k)) sums (s - (SUM i = 0..< k. f i))"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   115
  apply (unfold sums_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   116
  apply (simp add: sumr_offset); 
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   117
  apply (rule LIMSEQ_diff_const)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   118
  apply (rule LIMSEQ_ignore_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   119
  apply assumption
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   120
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   121
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   122
lemma summable_ignore_initial_segment: "summable f ==> 
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   123
    summable (%n. f(n + k))"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   124
  apply (unfold summable_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   125
  apply (auto intro: sums_split_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   126
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   127
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   128
lemma suminf_minus_initial_segment: "summable f ==>
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   129
    suminf f = s ==> suminf (%n. f(n + k)) = s - (SUM i = 0..< k. f i)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   130
  apply (frule summable_ignore_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   131
  apply (rule sums_unique [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   132
  apply (frule summable_sums)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   133
  apply (rule sums_split_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   134
  apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   135
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   136
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   137
lemma suminf_split_initial_segment: "summable f ==> 
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   138
    suminf f = (SUM i = 0..< k. f i) + suminf (%n. f(n + k))"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   139
by (auto simp add: suminf_minus_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   140
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   141
lemma series_zero: 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   142
     "(\<forall>m. n \<le> m --> f(m) = 0) ==> f sums (setsum f {0..<n})"
15537
5538d3244b4d continued eliminating sumr
nipkow
parents: 15536
diff changeset
   143
apply (simp add: sums_def LIMSEQ_def diff_minus[symmetric], safe)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   144
apply (rule_tac x = n in exI)
15542
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
   145
apply (clarsimp simp add:setsum_diff[symmetric] cong:setsum_ivl_cong)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   146
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   147
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   148
lemma sums_zero: "(%n. 0) sums 0";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   149
  apply (unfold sums_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   150
  apply simp;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   151
  apply (rule LIMSEQ_const);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   152
done;
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   153
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   154
lemma summable_zero: "summable (%n. 0)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   155
  apply (rule sums_summable);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   156
  apply (rule sums_zero);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   157
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   158
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   159
lemma suminf_zero: "suminf (%n. 0) = 0";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   160
  apply (rule sym);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   161
  apply (rule sums_unique);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   162
  apply (rule sums_zero);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   163
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   164
  
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   165
lemma sums_mult:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   166
  fixes c :: "'a::real_normed_algebra"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   167
  shows "f sums a \<Longrightarrow> (\<lambda>n. c * f n) sums (c * a)"
19279
48b527d0331b Renamed setsum_mult to setsum_right_distrib.
ballarin
parents: 19106
diff changeset
   168
by (auto simp add: sums_def setsum_right_distrib [symmetric]
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   169
         intro!: LIMSEQ_mult intro: LIMSEQ_const)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   170
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   171
lemma summable_mult:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   172
  fixes c :: "'a::real_normed_algebra"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   173
  shows "summable f \<Longrightarrow> summable (%n. c * f n)";
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   174
  apply (unfold summable_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   175
  apply (auto intro: sums_mult);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   176
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   177
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   178
lemma suminf_mult:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   179
  fixes c :: "'a::real_normed_algebra"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   180
  shows "summable f \<Longrightarrow> suminf (\<lambda>n. c * f n) = c * suminf f";
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   181
  apply (rule sym);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   182
  apply (rule sums_unique);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   183
  apply (rule sums_mult);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   184
  apply (erule summable_sums);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   185
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   186
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   187
lemma sums_mult2:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   188
  fixes c :: "'a::real_normed_algebra"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   189
  shows "f sums a \<Longrightarrow> (\<lambda>n. f n * c) sums (a * c)"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   190
by (auto simp add: sums_def setsum_left_distrib [symmetric]
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   191
         intro!: LIMSEQ_mult LIMSEQ_const)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   192
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   193
lemma summable_mult2:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   194
  fixes c :: "'a::real_normed_algebra"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   195
  shows "summable f \<Longrightarrow> summable (\<lambda>n. f n * c)"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   196
  apply (unfold summable_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   197
  apply (auto intro: sums_mult2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   198
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   199
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   200
lemma suminf_mult2:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   201
  fixes c :: "'a::real_normed_algebra"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   202
  shows "summable f \<Longrightarrow> suminf f * c = (\<Sum>n. f n * c)"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   203
by (auto intro!: sums_unique sums_mult2 summable_sums)
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   204
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   205
lemma sums_divide:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   206
  fixes c :: "'a::real_normed_field"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   207
  shows "f sums a \<Longrightarrow> (\<lambda>n. f n / c) sums (a / c)"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   208
by (simp add: divide_inverse sums_mult2)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   209
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   210
lemma summable_divide:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   211
  fixes c :: "'a::real_normed_field"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   212
  shows "summable f \<Longrightarrow> summable (\<lambda>n. f n / c)"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   213
  apply (unfold summable_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   214
  apply (auto intro: sums_divide);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   215
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   216
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   217
lemma suminf_divide:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   218
  fixes c :: "'a::real_normed_field"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   219
  shows "summable f \<Longrightarrow> suminf (\<lambda>n. f n / c) = suminf f / c"
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   220
  apply (rule sym);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   221
  apply (rule sums_unique);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   222
  apply (rule sums_divide);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   223
  apply (erule summable_sums);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   224
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   225
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   226
lemma sums_add: "[| x sums x0; y sums y0 |] ==> (%n. x n + y n) sums (x0+y0)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   227
by (auto simp add: sums_def setsum_addf intro: LIMSEQ_add)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   228
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   229
lemma summable_add: "summable f ==> summable g ==> summable (%x. f x + g x)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   230
  apply (unfold summable_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   231
  apply clarify;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   232
  apply (rule exI);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   233
  apply (erule sums_add);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   234
  apply assumption;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   235
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   236
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   237
lemma suminf_add:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   238
     "[| summable f; summable g |]   
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   239
      ==> suminf f + suminf g  = (\<Sum>n. f n + g n)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   240
by (auto intro!: sums_add sums_unique summable_sums)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   241
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   242
lemma sums_diff: "[| x sums x0; y sums y0 |] ==> (%n. x n - y n) sums (x0-y0)"
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15360
diff changeset
   243
by (auto simp add: sums_def setsum_subtractf intro: LIMSEQ_diff)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   244
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   245
lemma summable_diff: "summable f ==> summable g ==> summable (%x. f x - g x)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   246
  apply (unfold summable_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   247
  apply clarify;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   248
  apply (rule exI);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   249
  apply (erule sums_diff);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   250
  apply assumption;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   251
done;
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   252
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   253
lemma suminf_diff:
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   254
     "[| summable f; summable g |]   
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
   255
      ==> suminf f - suminf g  = (\<Sum>n. f n - g n)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   256
by (auto intro!: sums_diff sums_unique summable_sums)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   257
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   258
lemma sums_minus: "f sums s ==> (%x. - f x) sums (- s)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   259
  by (simp add: sums_def setsum_negf LIMSEQ_minus);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   260
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   261
lemma summable_minus: "summable f ==> summable (%x. - f x)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   262
  by (auto simp add: summable_def intro: sums_minus);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   263
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   264
lemma suminf_minus: "summable f ==> suminf (%x. - f x) = - (suminf f)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   265
  apply (rule sym);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   266
  apply (rule sums_unique);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   267
  apply (rule sums_minus);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   268
  apply (erule summable_sums);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   269
done;
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   270
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   271
lemma sums_group:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   272
     "[|summable f; 0 < k |] ==> (%n. setsum f {n*k..<n*k+k}) sums (suminf f)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   273
apply (drule summable_sums)
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   274
apply (simp only: sums_def sumr_group)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   275
apply (unfold LIMSEQ_def, safe)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   276
apply (drule_tac x="r" in spec, safe)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   277
apply (rule_tac x="no" in exI, safe)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   278
apply (drule_tac x="n*k" in spec)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   279
apply (erule mp)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   280
apply (erule order_trans)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   281
apply simp
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   282
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   283
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   284
text{*A summable series of positive terms has limit that is at least as
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   285
great as any partial sum.*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   286
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   287
lemma series_pos_le:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   288
  fixes f :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   289
  shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 \<le> f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} \<le> suminf f"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   290
apply (drule summable_sums)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   291
apply (simp add: sums_def)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   292
apply (cut_tac k = "setsum f {0..<n}" in LIMSEQ_const)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   293
apply (erule LIMSEQ_le, blast)
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   294
apply (rule_tac x="n" in exI, clarify)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   295
apply (rule setsum_mono2)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   296
apply auto
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   297
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   298
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   299
lemma series_pos_less:
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   300
  fixes f :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   301
  shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 < f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} < suminf f"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   302
apply (rule_tac y="setsum f {0..<Suc n}" in order_less_le_trans)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   303
apply simp
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   304
apply (erule series_pos_le)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   305
apply (simp add: order_less_imp_le)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   306
done
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   307
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   308
lemma suminf_gt_zero:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   309
  fixes f :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   310
  shows "\<lbrakk>summable f; \<forall>n. 0 < f n\<rbrakk> \<Longrightarrow> 0 < suminf f"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   311
by (drule_tac n="0" in series_pos_less, simp_all)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   312
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   313
lemma suminf_ge_zero:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   314
  fixes f :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   315
  shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> 0 \<le> suminf f"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   316
by (drule_tac n="0" in series_pos_le, simp_all)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   317
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   318
lemma sumr_pos_lt_pair:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   319
  fixes f :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   320
  shows "\<lbrakk>summable f;
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   321
        \<forall>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc(Suc 0) * d) + 1))\<rbrakk>
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   322
      \<Longrightarrow> setsum f {0..<k} < suminf f"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   323
apply (subst suminf_split_initial_segment [where k="k"])
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   324
apply assumption
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   325
apply simp
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   326
apply (drule_tac k="k" in summable_ignore_initial_segment)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   327
apply (drule_tac k="Suc (Suc 0)" in sums_group, simp)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   328
apply simp
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   329
apply (frule sums_unique)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   330
apply (drule sums_summable)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   331
apply simp
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   332
apply (erule suminf_gt_zero)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   333
apply (simp add: add_ac)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   334
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   335
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   336
text{*Sum of a geometric progression.*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   337
17149
e2b19c92ef51 Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents: 16819
diff changeset
   338
lemmas sumr_geometric = geometric_sum [where 'a = real]
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   339
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   340
lemma geometric_sums:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   341
  fixes x :: "'a::{real_normed_field,recpower,division_by_zero}"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   342
  shows "norm x < 1 \<Longrightarrow> (\<lambda>n. x ^ n) sums (1 / (1 - x))"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   343
proof -
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   344
  assume less_1: "norm x < 1"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   345
  hence neq_1: "x \<noteq> 1" by auto
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   346
  hence neq_0: "x - 1 \<noteq> 0" by simp
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   347
  from less_1 have lim_0: "(\<lambda>n. x ^ n) ----> 0"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   348
    by (rule LIMSEQ_power_zero)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   349
  hence "(\<lambda>n. x ^ n / (x - 1) - 1 / (x - 1)) ----> 0 / (x - 1) - 1 / (x
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   350
- 1)"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   351
    using neq_0 by (intro LIMSEQ_divide LIMSEQ_diff LIMSEQ_const)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   352
  hence "(\<lambda>n. (x ^ n - 1) / (x - 1)) ----> 1 / (1 - x)"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   353
    by (simp add: nonzero_minus_divide_right [OF neq_0] diff_divide_distrib)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   354
  thus "(\<lambda>n. x ^ n) sums (1 / (1 - x))"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   355
    by (simp add: sums_def geometric_sum neq_1)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   356
qed
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   357
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   358
lemma summable_geometric:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   359
  fixes x :: "'a::{real_normed_field,recpower,division_by_zero}"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   360
  shows "norm x < 1 \<Longrightarrow> summable (\<lambda>n. x ^ n)"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   361
by (rule geometric_sums [THEN sums_summable])
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   362
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   363
text{*Cauchy-type criterion for convergence of series (c.f. Harrison)*}
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   364
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   365
lemma summable_convergent_sumr_iff:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   366
 "summable f = convergent (%n. setsum f {0..<n})"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   367
by (simp add: summable_def sums_def convergent_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   368
20689
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   369
lemma summable_LIMSEQ_zero: "summable f \<Longrightarrow> f ----> 0"
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   370
apply (drule summable_convergent_sumr_iff [THEN iffD1])
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   371
apply (drule convergent_Cauchy)
20689
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   372
apply (simp only: Cauchy_def LIMSEQ_def, safe)
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   373
apply (drule_tac x="r" in spec, safe)
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   374
apply (rule_tac x="M" in exI, safe)
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   375
apply (drule_tac x="Suc n" in spec, simp)
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   376
apply (drule_tac x="n" in spec, simp)
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   377
done
4950e45442b8 add proof of summable_LIMSEQ_zero
huffman
parents: 20688
diff changeset
   378
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   379
lemma summable_Cauchy:
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   380
     "summable (f::nat \<Rightarrow> 'a::banach) =  
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   381
      (\<forall>e > 0. \<exists>N. \<forall>m \<ge> N. \<forall>n. norm (setsum f {m..<n}) < e)"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   382
apply (simp only: summable_convergent_sumr_iff Cauchy_convergent_iff [symmetric] Cauchy_def, safe)
20410
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   383
apply (drule spec, drule (1) mp)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   384
apply (erule exE, rule_tac x="M" in exI, clarify)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   385
apply (rule_tac x="m" and y="n" in linorder_le_cases)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   386
apply (frule (1) order_trans)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   387
apply (drule_tac x="n" in spec, drule (1) mp)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   388
apply (drule_tac x="m" in spec, drule (1) mp)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   389
apply (simp add: setsum_diff [symmetric])
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   390
apply simp
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   391
apply (drule spec, drule (1) mp)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   392
apply (erule exE, rule_tac x="N" in exI, clarify)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   393
apply (rule_tac x="m" and y="n" in linorder_le_cases)
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   394
apply (subst norm_minus_commute)
20410
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   395
apply (simp add: setsum_diff [symmetric])
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   396
apply (simp add: setsum_diff [symmetric])
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   397
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   398
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   399
text{*Comparison test*}
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   400
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   401
lemma norm_setsum:
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   402
  fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   403
  shows "norm (setsum f A) \<le> (\<Sum>i\<in>A. norm (f i))"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   404
apply (case_tac "finite A")
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   405
apply (erule finite_induct)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   406
apply simp
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   407
apply simp
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   408
apply (erule order_trans [OF norm_triangle_ineq add_left_mono])
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   409
apply simp
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   410
done
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   411
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   412
lemma summable_comparison_test:
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   413
  fixes f :: "nat \<Rightarrow> 'a::banach"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   414
  shows "\<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable f"
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   415
apply (simp add: summable_Cauchy, safe)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   416
apply (drule_tac x="e" in spec, safe)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   417
apply (rule_tac x = "N + Na" in exI, safe)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   418
apply (rotate_tac 2)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   419
apply (drule_tac x = m in spec)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   420
apply (auto, rotate_tac 2, drule_tac x = n in spec)
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   421
apply (rule_tac y = "\<Sum>k=m..<n. norm (f k)" in order_le_less_trans)
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   422
apply (rule norm_setsum)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   423
apply (rule_tac y = "setsum g {m..<n}" in order_le_less_trans)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   424
apply (auto intro: setsum_mono simp add: abs_interval_iff)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   425
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   426
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   427
lemma summable_norm_comparison_test:
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   428
  fixes f :: "nat \<Rightarrow> 'a::banach"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   429
  shows "\<lbrakk>\<exists>N. \<forall>n\<ge>N. norm (f n) \<le> g n; summable g\<rbrakk>
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   430
         \<Longrightarrow> summable (\<lambda>n. norm (f n))"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   431
apply (rule summable_comparison_test)
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   432
apply (auto)
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   433
done
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   434
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   435
lemma summable_rabs_comparison_test:
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   436
  fixes f :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   437
  shows "\<lbrakk>\<exists>N. \<forall>n\<ge>N. \<bar>f n\<bar> \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable (\<lambda>n. \<bar>f n\<bar>)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   438
apply (rule summable_comparison_test)
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   439
apply (auto)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   440
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   441
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   442
text{*Limit comparison property for series (c.f. jrh)*}
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   443
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   444
lemma summable_le:
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   445
  fixes f g :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   446
  shows "\<lbrakk>\<forall>n. f n \<le> g n; summable f; summable g\<rbrakk> \<Longrightarrow> suminf f \<le> suminf g"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   447
apply (drule summable_sums)+
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   448
apply (simp only: sums_def, erule (1) LIMSEQ_le)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   449
apply (rule exI)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   450
apply (auto intro!: setsum_mono)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   451
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   452
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   453
lemma summable_le2:
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   454
  fixes f g :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   455
  shows "\<lbrakk>\<forall>n. \<bar>f n\<bar> \<le> g n; summable g\<rbrakk> \<Longrightarrow> summable f \<and> suminf f \<le> suminf g"
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   456
apply (subgoal_tac "summable f")
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   457
apply (auto intro!: summable_le)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   458
apply (simp add: abs_le_interval_iff)
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   459
apply (rule_tac g="g" in summable_comparison_test, simp_all)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   460
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   461
19106
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   462
(* specialisation for the common 0 case *)
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   463
lemma suminf_0_le:
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   464
  fixes f::"nat\<Rightarrow>real"
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   465
  assumes gt0: "\<forall>n. 0 \<le> f n" and sm: "summable f"
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   466
  shows "0 \<le> suminf f"
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   467
proof -
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   468
  let ?g = "(\<lambda>n. (0::real))"
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   469
  from gt0 have "\<forall>n. ?g n \<le> f n" by simp
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   470
  moreover have "summable ?g" by (rule summable_zero)
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   471
  moreover from sm have "summable f" .
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   472
  ultimately have "suminf ?g \<le> suminf f" by (rule summable_le)
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   473
  then show "0 \<le> suminf f" by (simp add: suminf_zero)
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   474
qed 
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   475
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   476
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   477
text{*Absolute convergence imples normal convergence*}
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   478
lemma summable_norm_cancel:
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   479
  fixes f :: "nat \<Rightarrow> 'a::banach"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   480
  shows "summable (\<lambda>n. norm (f n)) \<Longrightarrow> summable f"
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   481
apply (simp only: summable_Cauchy, safe)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   482
apply (drule_tac x="e" in spec, safe)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   483
apply (rule_tac x="N" in exI, safe)
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   484
apply (drule_tac x="m" in spec, safe)
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   485
apply (rule order_le_less_trans [OF norm_setsum])
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   486
apply (rule order_le_less_trans [OF abs_ge_self])
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   487
apply simp
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   488
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   489
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   490
lemma summable_rabs_cancel:
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   491
  fixes f :: "nat \<Rightarrow> real"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   492
  shows "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> summable f"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   493
by (rule summable_norm_cancel, simp)
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   494
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   495
text{*Absolute convergence of series*}
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   496
lemma summable_norm:
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   497
  fixes f :: "nat \<Rightarrow> 'a::banach"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   498
  shows "summable (\<lambda>n. norm (f n)) \<Longrightarrow> norm (suminf f) \<le> (\<Sum>n. norm (f n))"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   499
by (auto intro: LIMSEQ_le LIMSEQ_norm summable_norm_cancel
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   500
                summable_sumr_LIMSEQ_suminf norm_setsum)
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   501
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   502
lemma summable_rabs:
20692
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   503
  fixes f :: "nat \<Rightarrow> real"
6df83a636e67 generalized types of sums, summable, and suminf
huffman
parents: 20689
diff changeset
   504
  shows "summable (\<lambda>n. \<bar>f n\<bar>) \<Longrightarrow> \<bar>suminf f\<bar> \<le> (\<Sum>n. \<bar>f n\<bar>)"
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   505
by (fold real_norm_def, rule summable_norm)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   506
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   507
subsection{* The Ratio Test*}
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   508
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   509
lemma norm_ratiotest_lemma:
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   510
  fixes x y :: "'a::normed"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   511
  shows "\<lbrakk>c \<le> 0; norm x \<le> c * norm y\<rbrakk> \<Longrightarrow> x = 0"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   512
apply (subgoal_tac "norm x \<le> 0", simp)
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   513
apply (erule order_trans)
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   514
apply (simp add: mult_le_0_iff)
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   515
done
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   516
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   517
lemma rabs_ratiotest_lemma: "[| c \<le> 0; abs x \<le> c * abs y |] ==> x = (0::real)"
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   518
by (erule norm_ratiotest_lemma, simp)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   519
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   520
lemma le_Suc_ex: "(k::nat) \<le> l ==> (\<exists>n. l = k + n)"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   521
apply (drule le_imp_less_or_eq)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   522
apply (auto dest: less_imp_Suc_add)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   523
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   524
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   525
lemma le_Suc_ex_iff: "((k::nat) \<le> l) = (\<exists>n. l = k + n)"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   526
by (auto simp add: le_Suc_ex)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   527
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   528
(*All this trouble just to get 0<c *)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   529
lemma ratio_test_lemma2:
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   530
  fixes f :: "nat \<Rightarrow> 'a::banach"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   531
  shows "\<lbrakk>\<forall>n\<ge>N. norm (f (Suc n)) \<le> c * norm (f n)\<rbrakk> \<Longrightarrow> 0 < c \<or> summable f"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   532
apply (simp (no_asm) add: linorder_not_le [symmetric])
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   533
apply (simp add: summable_Cauchy)
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   534
apply (safe, subgoal_tac "\<forall>n. N < n --> f (n) = 0")
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   535
 prefer 2
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   536
 apply clarify
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   537
 apply(erule_tac x = "n - 1" in allE)
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   538
 apply (simp add:diff_Suc split:nat.splits)
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   539
 apply (blast intro: norm_ratiotest_lemma)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   540
apply (rule_tac x = "Suc N" in exI, clarify)
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   541
apply(simp cong:setsum_ivl_cong)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   542
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   543
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   544
lemma ratio_test:
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   545
  fixes f :: "nat \<Rightarrow> 'a::banach"
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   546
  shows "\<lbrakk>c < 1; \<forall>n\<ge>N. norm (f (Suc n)) \<le> c * norm (f n)\<rbrakk> \<Longrightarrow> summable f"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   547
apply (frule ratio_test_lemma2, auto)
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   548
apply (rule_tac g = "%n. (norm (f N) / (c ^ N))*c ^ n" 
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   549
       in summable_comparison_test)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   550
apply (rule_tac x = N in exI, safe)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   551
apply (drule le_Suc_ex_iff [THEN iffD1])
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   552
apply (auto simp add: power_add realpow_not_zero)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   553
apply (induct_tac "na", auto)
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   554
apply (rule_tac y = "c * norm (f (N + n))" in order_trans)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   555
apply (auto intro: mult_right_mono simp add: summable_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   556
apply (simp add: mult_ac)
20848
27a09c3eca1f generalize summability lemmas using class banach
huffman
parents: 20792
diff changeset
   557
apply (rule_tac x = "norm (f N) * (1/ (1 - c)) / (c ^ N)" in exI)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   558
apply (rule sums_divide) 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   559
apply (rule sums_mult) 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   560
apply (auto intro!: geometric_sums)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   561
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   562
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   563
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   564
text{*Differentiation of finite sum*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   565
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   566
lemma DERIV_sumr [rule_format (no_asm)]:
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   567
     "(\<forall>r. m \<le> r & r < (m + n) --> DERIV (%x. f r x) x :> (f' r x))  
20792
add17d26151b add type annotations for DERIV
huffman
parents: 20770
diff changeset
   568
      --> DERIV (%x. \<Sum>n=m..<n::nat. f n x :: real) x :> (\<Sum>r=m..<n. f' r x)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
   569
apply (induct "n")
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   570
apply (auto intro: DERIV_add)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   571
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   572
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   573
end