src/HOL/Hyperreal/Series.thy
author huffman
Wed, 23 Aug 2006 23:40:47 +0200
changeset 20410 4bd5cd97c547
parent 20254 58b71535ed00
child 20432 07ec57376051
permissions -rw-r--r--
speed up proof of summable_Cauchy
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
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    16
declare atLeastLessThan_iff[iff]
15561
045a07ac35a7 another reorganization of setsums and intervals
nipkow
parents: 15546
diff changeset
    17
declare setsum_op_ivl_Suc[simp]
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    18
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    19
definition
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
    20
   sums  :: "(nat => real) => real => bool"     (infixr "sums" 80)
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    21
   "f sums s = (%n. setsum f {0..<n}) ----> s"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    22
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    23
   summable :: "(nat=>real) => bool"
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    24
   "summable f = (\<exists>s. f sums s)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    25
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    26
   suminf   :: "(nat=>real) => real"
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    27
   "suminf f = (SOME s. f sums s)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    28
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
    29
syntax
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
    30
  "_suminf" :: "idt => real => real"    ("\<Sum>_. _" [0, 10] 10)
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
    31
translations
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
    32
  "\<Sum>i. b" == "suminf (%i. b)"
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
    33
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    34
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    35
lemma sumr_diff_mult_const:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    36
 "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
    37
by (simp add: diff_minus setsum_addf real_of_nat_def)
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15360
diff changeset
    38
15542
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    39
lemma real_setsum_nat_ivl_bounded:
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    40
     "(!!p. p < n \<Longrightarrow> f(p) \<le> K)
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    41
      \<Longrightarrow> setsum f {0..<n::nat} \<le> real n * K"
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    42
using setsum_bounded[where A = "{0..<n}"]
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
    43
by (auto simp:real_of_nat_def)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    44
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    45
(* Generalize from real to some algebraic structure? *)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    46
lemma sumr_minus_one_realpow_zero [simp]:
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
    47
  "(\<Sum>i=0..<2*n. (-1) ^ Suc i) = (0::real)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
    48
by (induct "n", auto)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    49
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    50
(* FIXME this is an awful lemma! *)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    51
lemma sumr_one_lb_realpow_zero [simp]:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    52
  "(\<Sum>n=Suc 0..<n. f(n) * (0::real) ^ n) = 0"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
    53
apply (induct "n")
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    54
apply (case_tac [2] "n", auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    55
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    56
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
    57
lemma sumr_group:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    58
     "(\<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
    59
apply (subgoal_tac "k = 0 | 0 < k", auto)
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
    60
apply (induct "n")
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    61
apply (simp_all add: setsum_add_nat_ivl add_commute)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    62
done
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
    63
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    64
(* FIXME generalize? *)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    65
lemma sumr_offset:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    66
 "(\<Sum>m=0..<n::nat. f(m+k)::real) = setsum f {0..<n+k} - setsum f {0..<k}"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    67
by (induct "n", auto)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    68
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    69
lemma sumr_offset2:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    70
 "\<forall>f. (\<Sum>m=0..<n::nat. f(m+k)::real) = setsum f {0..<n+k} - setsum f {0..<k}"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    71
by (induct "n", auto)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    72
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    73
lemma sumr_offset3:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    74
  "setsum f {0::nat..<n+k} = (\<Sum>m=0..<n. f (m+k)::real) + setsum f {0..<k}"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    75
by (simp  add: sumr_offset)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    76
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    77
lemma sumr_offset4:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    78
 "\<forall>n f. setsum f {0::nat..<n+k} =
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    79
        (\<Sum>m=0..<n. f (m+k)::real) + setsum f {0..<k}"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    80
by (simp add: sumr_offset)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    81
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    82
(*
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    83
lemma sumr_from_1_from_0: "0 < n ==>
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    84
      (\<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
    85
             ((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n =
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    86
      (\<Sum>n=0..<Suc n. if even(n) then 0 else
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    87
             ((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
    88
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
    89
*)
14416
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
subsection{* Infinite Sums, by the Properties of Limits*}
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
(*----------------------
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    94
   suminf is the sum   
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 sums_summable: "f sums l ==> summable f"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    97
by (simp add: sums_def summable_def, blast)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    98
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
    99
lemma summable_sums: "summable f ==> f sums (suminf f)"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   100
apply (simp add: summable_def suminf_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   101
apply (blast intro: someI2)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   102
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   103
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   104
lemma summable_sumr_LIMSEQ_suminf: 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   105
     "summable f ==> (%n. setsum f {0..<n}) ----> (suminf f)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   106
apply (simp add: summable_def suminf_def sums_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   107
apply (blast intro: someI2)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   108
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   109
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   110
(*-------------------
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   111
    sum is unique                    
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   112
 ------------------*)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   113
lemma sums_unique: "f sums s ==> (s = suminf f)"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   114
apply (frule sums_summable [THEN summable_sums])
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   115
apply (auto intro!: LIMSEQ_unique simp add: sums_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   116
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   117
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   118
lemma sums_split_initial_segment: "f sums s ==> 
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   119
  (%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
   120
  apply (unfold sums_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   121
  apply (simp add: sumr_offset); 
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   122
  apply (rule LIMSEQ_diff_const)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   123
  apply (rule LIMSEQ_ignore_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   124
  apply assumption
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   125
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   126
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   127
lemma summable_ignore_initial_segment: "summable f ==> 
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   128
    summable (%n. f(n + k))"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   129
  apply (unfold summable_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   130
  apply (auto intro: sums_split_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   131
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   132
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   133
lemma suminf_minus_initial_segment: "summable f ==>
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   134
    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
   135
  apply (frule summable_ignore_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   136
  apply (rule sums_unique [THEN sym])
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   137
  apply (frule summable_sums)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   138
  apply (rule sums_split_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   139
  apply auto
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   140
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   141
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   142
lemma suminf_split_initial_segment: "summable f ==> 
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   143
    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
   144
by (auto simp add: suminf_minus_initial_segment)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   145
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   146
lemma series_zero: 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   147
     "(\<forall>m. n \<le> m --> f(m) = 0) ==> f sums (setsum f {0..<n})"
15537
5538d3244b4d continued eliminating sumr
nipkow
parents: 15536
diff changeset
   148
apply (simp add: sums_def LIMSEQ_def diff_minus[symmetric], safe)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   149
apply (rule_tac x = n in exI)
15542
ee6cd48cf840 more fine tuniung
nipkow
parents: 15539
diff changeset
   150
apply (clarsimp simp add:setsum_diff[symmetric] cong:setsum_ivl_cong)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   151
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   152
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   153
lemma sums_zero: "(%n. 0) sums 0";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   154
  apply (unfold sums_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   155
  apply simp;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   156
  apply (rule LIMSEQ_const);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   157
done;
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   158
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   159
lemma summable_zero: "summable (%n. 0)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   160
  apply (rule sums_summable);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   161
  apply (rule sums_zero);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   162
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   163
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   164
lemma suminf_zero: "suminf (%n. 0) = 0";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   165
  apply (rule sym);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   166
  apply (rule sums_unique);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   167
  apply (rule sums_zero);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   168
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   169
  
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   170
lemma sums_mult: "f sums a ==> (%n. c * f n) sums (c * a)"
19279
48b527d0331b Renamed setsum_mult to setsum_right_distrib.
ballarin
parents: 19106
diff changeset
   171
by (auto simp add: sums_def setsum_right_distrib [symmetric]
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   172
         intro!: LIMSEQ_mult intro: LIMSEQ_const)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   173
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   174
lemma summable_mult: "summable f ==> summable (%n. c * f n)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   175
  apply (unfold summable_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   176
  apply (auto intro: sums_mult);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   177
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   178
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   179
lemma suminf_mult: "summable f ==> suminf (%n. c * f n) = c * suminf f";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   180
  apply (rule sym);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   181
  apply (rule sums_unique);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   182
  apply (rule sums_mult);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   183
  apply (erule summable_sums);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   184
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   185
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   186
lemma sums_mult2: "f sums a ==> (%n. f n * c) sums (a * c)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   187
apply (subst mult_commute)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   188
apply (subst mult_commute);back;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   189
apply (erule sums_mult)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   190
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   191
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   192
lemma summable_mult2: "summable f ==> summable (%n. f n * c)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   193
  apply (unfold summable_def)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   194
  apply (auto intro: sums_mult2)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   195
done
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   196
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   197
lemma suminf_mult2: "summable f ==> suminf f * c = (\<Sum>n. f n * c)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   198
by (auto intro!: sums_unique sums_mult summable_sums simp add: mult_commute)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   199
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   200
lemma sums_divide: "f sums a ==> (%n. (f n)/c) sums (a/c)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   201
by (simp add: real_divide_def sums_mult mult_commute [of _ "inverse c"])
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   202
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   203
lemma summable_divide: "summable f ==> summable (%n. (f n) / c)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   204
  apply (unfold summable_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   205
  apply (auto intro: sums_divide);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   206
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   207
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   208
lemma suminf_divide: "summable f ==> suminf (%n. (f n) / c) = (suminf f) / c";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   209
  apply (rule sym);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   210
  apply (rule sums_unique);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   211
  apply (rule sums_divide);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   212
  apply (erule summable_sums);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   213
done;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   214
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   215
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
   216
by (auto simp add: sums_def setsum_addf intro: LIMSEQ_add)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   217
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   218
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
   219
  apply (unfold summable_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   220
  apply clarify;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   221
  apply (rule exI);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   222
  apply (erule sums_add);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   223
  apply assumption;
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 suminf_add:
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   227
     "[| summable f; summable g |]   
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   228
      ==> suminf f + suminf g  = (\<Sum>n. f n + g n)"
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   229
by (auto intro!: sums_add sums_unique summable_sums)
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   230
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   231
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
   232
by (auto simp add: sums_def setsum_subtractf intro: LIMSEQ_diff)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   233
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   234
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
   235
  apply (unfold summable_def);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   236
  apply clarify;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   237
  apply (rule exI);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   238
  apply (erule sums_diff);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   239
  apply assumption;
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   240
done;
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   241
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   242
lemma suminf_diff:
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   243
     "[| summable f; summable g |]   
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
   244
      ==> suminf f - suminf g  = (\<Sum>n. f n - g n)"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   245
by (auto intro!: sums_diff sums_unique summable_sums)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   246
16819
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   247
lemma sums_minus: "f sums s ==> (%x. - f x) sums (- s)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   248
  by (simp add: sums_def setsum_negf LIMSEQ_minus);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   249
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   250
lemma summable_minus: "summable f ==> summable (%x. - f x)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   251
  by (auto simp add: summable_def intro: sums_minus);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   252
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   253
lemma suminf_minus: "summable f ==> suminf (%x. - f x) = - (suminf f)";
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   254
  apply (rule sym);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   255
  apply (rule sums_unique);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   256
  apply (rule sums_minus);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   257
  apply (erule summable_sums);
00d8f9300d13 Additions to the Real (and Hyperreal) libraries:
avigad
parents: 16733
diff changeset
   258
done;
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   259
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   260
lemma sums_group:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   261
     "[|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
   262
apply (drule summable_sums)
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   263
apply (auto simp add: sums_def LIMSEQ_def sumr_group)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   264
apply (drule_tac x = r in spec, safe)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   265
apply (rule_tac x = no in exI, safe)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   266
apply (drule_tac x = "n*k" in spec)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   267
apply (auto dest!: not_leE)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   268
apply (drule_tac j = no in less_le_trans, auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   269
done
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 sumr_pos_lt_pair_lemma:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   272
  "[|\<forall>d. - f (n + (d + d)) < (f (Suc (n + (d + d))) :: real) |]
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   273
   ==> setsum f {0..<n+Suc(Suc 0)} \<le> setsum f {0..<Suc(Suc 0) * Suc no + n}"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
   274
apply (induct "no", auto)
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
   275
apply (drule_tac x = "Suc no" in spec)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   276
apply (simp add: add_ac)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   277
done
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
   278
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   279
lemma sumr_pos_lt_pair:
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   280
     "[|summable f; 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   281
        \<forall>d. 0 < (f(n + (Suc(Suc 0) * d))) + f(n + ((Suc(Suc 0) * d) + 1))|]  
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   282
      ==> setsum f {0..<n} < suminf f"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   283
apply (drule summable_sums)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   284
apply (auto simp add: sums_def LIMSEQ_def)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   285
apply (drule_tac x = "f (n) + f (n + 1)" in spec)
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   286
apply (auto iff: real_0_less_add_iff)
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   287
   --{*legacy proof: not necessarily better!*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   288
apply (rule_tac [2] ccontr, drule_tac [2] linorder_not_less [THEN iffD1])
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   289
apply (frule_tac [2] no=no in sumr_pos_lt_pair_lemma) 
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   290
apply (drule_tac x = 0 in spec, simp)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   291
apply (rotate_tac 1, drule_tac x = "Suc (Suc 0) * (Suc no) + n" in spec)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   292
apply (safe, simp)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   293
apply (subgoal_tac "suminf f + (f (n) + f (n + 1)) \<le>
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   294
 setsum f {0 ..< Suc (Suc 0) * (Suc no) + n}")
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   295
apply (rule_tac [2] y = "setsum f {0..<n+ Suc (Suc 0)}" in order_trans)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   296
prefer 3 apply assumption
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   297
apply (rule_tac [2] y = "setsum f {0..<n} + (f (n) + f (n + 1))" in order_trans)
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
   298
apply simp_all
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   299
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   300
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   301
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
   302
great as any partial sum.*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   303
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   304
lemma series_pos_le: 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   305
     "[| summable f; \<forall>m \<ge> n. 0 \<le> f(m) |] ==> setsum f {0..<n} \<le> suminf f"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   306
apply (drule summable_sums)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   307
apply (simp add: sums_def)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   308
apply (cut_tac k = "setsum f {0..<n}" in LIMSEQ_const)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   309
apply (erule LIMSEQ_le, blast)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   310
apply (rule_tac x = n in exI, clarify)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   311
apply (rule setsum_mono2)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   312
apply auto
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   313
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   314
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   315
lemma series_pos_less:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   316
     "[| summable f; \<forall>m \<ge> n. 0 < f(m) |] ==> setsum f {0..<n} < suminf f"
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   317
apply (rule_tac y = "setsum f {0..<Suc n}" in order_less_le_trans)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   318
apply (rule_tac [2] series_pos_le, auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   319
apply (drule_tac x = m in spec, auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   320
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   321
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   322
text{*Sum of a geometric progression.*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   323
17149
e2b19c92ef51 Lemmas on dvd, power and finite summation added or strengthened.
ballarin
parents: 16819
diff changeset
   324
lemmas sumr_geometric = geometric_sum [where 'a = real]
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   325
20254
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 20217
diff changeset
   326
ML {* fast_arith_split_limit := 0; *}  (* FIXME: needed because otherwise a premise gets simplified away *)
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 20217
diff changeset
   327
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   328
lemma geometric_sums: "abs(x) < 1 ==> (%n. x ^ n) sums (1/(1 - x))"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   329
apply (case_tac "x = 1")
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   330
apply (auto dest!: LIMSEQ_rabs_realpow_zero2 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   331
        simp add: sumr_geometric sums_def diff_minus add_divide_distrib)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   332
apply (subgoal_tac "1 / (1 + -x) = 0/ (x - 1) + - 1/ (x - 1) ")
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   333
apply (erule ssubst)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   334
apply (rule LIMSEQ_add, rule LIMSEQ_divide)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   335
apply (auto intro: LIMSEQ_const simp add: diff_minus minus_divide_right LIMSEQ_rabs_realpow_zero2)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   336
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   337
20254
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 20217
diff changeset
   338
ML {* fast_arith_split_limit := 9; *}  (* FIXME *)
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 20217
diff changeset
   339
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   340
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
   341
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   342
lemma summable_convergent_sumr_iff:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   343
 "summable f = convergent (%n. setsum f {0..<n})"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   344
by (simp add: summable_def sums_def convergent_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   345
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   346
lemma summable_Cauchy:
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   347
     "summable f =  
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   348
      (\<forall>e > 0. \<exists>N. \<forall>m \<ge> N. \<forall>n. abs(setsum f {m..<n}) < e)"
20410
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   349
apply (simp only: summable_convergent_sumr_iff Cauchy_convergent_iff [symmetric] Cauchy_def diff_minus [symmetric], safe)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   350
apply (drule spec, drule (1) mp)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   351
apply (erule exE, rule_tac x="M" in exI, clarify)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   352
apply (rule_tac x="m" and y="n" in linorder_le_cases)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   353
apply (frule (1) order_trans)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   354
apply (drule_tac x="n" in spec, drule (1) mp)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   355
apply (drule_tac x="m" in spec, drule (1) mp)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   356
apply (simp add: setsum_diff [symmetric])
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   357
apply simp
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   358
apply (drule spec, drule (1) mp)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   359
apply (erule exE, rule_tac x="N" in exI, clarify)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   360
apply (rule_tac x="m" and y="n" in linorder_le_cases)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   361
apply (subst abs_minus_commute)
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   362
apply (simp add: setsum_diff [symmetric])
4bd5cd97c547 speed up proof of summable_Cauchy
huffman
parents: 20254
diff changeset
   363
apply (simp add: setsum_diff [symmetric])
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   364
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   365
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   366
text{*Comparison test*}
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   367
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   368
lemma summable_comparison_test:
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
   369
     "[| \<exists>N. \<forall>n \<ge> N. abs(f n) \<le> g n; summable g |] ==> summable f"
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   370
apply (auto simp add: summable_Cauchy)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   371
apply (drule spec, auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   372
apply (rule_tac x = "N + Na" in exI, auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   373
apply (rotate_tac 2)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   374
apply (drule_tac x = m in spec)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   375
apply (auto, rotate_tac 2, drule_tac x = n in spec)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   376
apply (rule_tac y = "\<Sum>k=m..<n. abs(f k)" in order_le_less_trans)
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15360
diff changeset
   377
apply (rule setsum_abs)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   378
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
   379
apply (auto intro: setsum_mono simp add: abs_interval_iff)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   380
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   381
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   382
lemma summable_rabs_comparison_test:
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
   383
     "[| \<exists>N. \<forall>n \<ge> N. abs(f n) \<le> g n; summable g |] 
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   384
      ==> summable (%k. abs (f k))"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   385
apply (rule summable_comparison_test)
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   386
apply (auto)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   387
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   388
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   389
text{*Limit comparison property for series (c.f. jrh)*}
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   390
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   391
lemma summable_le:
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   392
     "[|\<forall>n. f n \<le> g n; summable f; summable g |] ==> suminf f \<le> suminf g"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   393
apply (drule summable_sums)+
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   394
apply (auto intro!: LIMSEQ_le simp add: sums_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   395
apply (rule exI)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   396
apply (auto intro!: setsum_mono)
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
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   399
lemma summable_le2:
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   400
     "[|\<forall>n. abs(f n) \<le> g n; summable g |]  
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   401
      ==> summable f & suminf f \<le> suminf g"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   402
apply (auto intro: summable_comparison_test intro!: summable_le)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   403
apply (simp add: abs_le_interval_iff)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   404
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   405
19106
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   406
(* 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
   407
lemma suminf_0_le:
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   408
  fixes f::"nat\<Rightarrow>real"
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   409
  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
   410
  shows "0 \<le> suminf f"
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   411
proof -
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   412
  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
   413
  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
   414
  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
   415
  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
   416
  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
   417
  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
   418
qed 
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   419
6e6b5b1fdc06 * added Library/ASeries (sum of arithmetic series with instantiation to nat and int)
kleing
parents: 17149
diff changeset
   420
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   421
text{*Absolute convergence imples normal convergence*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   422
lemma summable_rabs_cancel: "summable (%n. abs (f n)) ==> summable f"
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15360
diff changeset
   423
apply (auto simp add: summable_Cauchy)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   424
apply (drule spec, auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   425
apply (rule_tac x = N in exI, auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   426
apply (drule spec, auto)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   427
apply (rule_tac y = "\<Sum>n=m..<n. abs(f n)" in order_le_less_trans)
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15360
diff changeset
   428
apply (auto)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   429
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   430
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   431
text{*Absolute convergence of series*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   432
lemma summable_rabs:
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15543
diff changeset
   433
     "summable (%n. abs (f n)) ==> abs(suminf f) \<le> (\<Sum>n. abs(f n))"
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15360
diff changeset
   434
by (auto intro: LIMSEQ_le LIMSEQ_imp_rabs summable_rabs_cancel summable_sumr_LIMSEQ_suminf)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   435
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   436
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   437
subsection{* The Ratio Test*}
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   438
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   439
lemma rabs_ratiotest_lemma: "[| c \<le> 0; abs x \<le> c * abs y |] ==> x = (0::real)"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   440
apply (drule order_le_imp_less_or_eq, auto)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   441
apply (subgoal_tac "0 \<le> c * abs y")
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   442
apply (simp add: zero_le_mult_iff, arith)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   443
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   444
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   445
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
   446
apply (drule le_imp_less_or_eq)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   447
apply (auto dest: less_imp_Suc_add)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   448
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   449
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   450
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
   451
by (auto simp add: le_Suc_ex)
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
(*All this trouble just to get 0<c *)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   454
lemma ratio_test_lemma2:
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
   455
     "[| \<forall>n \<ge> N. abs(f(Suc n)) \<le> c*abs(f n) |]  
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   456
      ==> 0 < c | summable f"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   457
apply (simp (no_asm) add: linorder_not_le [symmetric])
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   458
apply (simp add: summable_Cauchy)
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   459
apply (safe, subgoal_tac "\<forall>n. N < n --> f (n) = 0")
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   460
 prefer 2
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   461
 apply clarify
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   462
 apply(erule_tac x = "n - 1" in allE)
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   463
 apply (simp add:diff_Suc split:nat.splits)
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   464
 apply (blast intro: rabs_ratiotest_lemma)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   465
apply (rule_tac x = "Suc N" in exI, clarify)
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   466
apply(simp cong:setsum_ivl_cong)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   467
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   468
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   469
lemma ratio_test:
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
   470
     "[| c < 1; \<forall>n \<ge> N. abs(f(Suc n)) \<le> c*abs(f n) |]  
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   471
      ==> summable f"
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   472
apply (frule ratio_test_lemma2, auto)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   473
apply (rule_tac g = "%n. (abs (f N) / (c ^ N))*c ^ n" 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   474
       in summable_comparison_test)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   475
apply (rule_tac x = N in exI, safe)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   476
apply (drule le_Suc_ex_iff [THEN iffD1])
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   477
apply (auto simp add: power_add realpow_not_zero)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   478
apply (induct_tac "na", auto)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   479
apply (rule_tac y = "c*abs (f (N + n))" in order_trans)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   480
apply (auto intro: mult_right_mono simp add: summable_def)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   481
apply (simp add: mult_ac)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   482
apply (rule_tac x = "abs (f N) * (1/ (1 - c)) / (c ^ N)" in exI)
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   483
apply (rule sums_divide) 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   484
apply (rule sums_mult) 
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   485
apply (auto intro!: geometric_sums)
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   486
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   487
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   488
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15053
diff changeset
   489
text{*Differentiation of finite sum*}
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   490
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   491
lemma DERIV_sumr [rule_format (no_asm)]:
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   492
     "(\<forall>r. m \<le> r & r < (m + n) --> DERIV (%x. f r x) x :> (f' r x))  
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15537
diff changeset
   493
      --> DERIV (%x. \<Sum>n=m..<n::nat. f n x) x :> (\<Sum>r=m..<n. f' r x)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
   494
apply (induct "n")
14416
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   495
apply (auto intro: DERIV_add)
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   496
done
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   497
1f256287d4f0 converted Hyperreal/Series to Isar script
paulson
parents: 12018
diff changeset
   498
end