src/HOL/Hyperreal/Series.thy
changeset 15543 0024472afce7
parent 15542 ee6cd48cf840
child 15546 5188ce7316b7
equal deleted inserted replaced
15542:ee6cd48cf840 15543:0024472afce7
     9 header{*Finite Summation and Infinite Series*}
     9 header{*Finite Summation and Infinite Series*}
    10 
    10 
    11 theory Series
    11 theory Series
    12 imports SEQ Lim
    12 imports SEQ Lim
    13 begin
    13 begin
    14 
    14 thm atLeastLessThan_empty
    15 (* FIXME why not globally? *)
    15 (* FIXME why not globally? *)
    16 declare atLeastLessThan_empty[simp];
    16 declare atLeastLessThan_empty[simp];
    17 declare atLeastLessThan_iff[iff]
    17 declare atLeastLessThan_iff[iff]
    18 
    18 
    19 constdefs
    19 constdefs
    20    sums  :: "[nat=>real,real] => bool"     (infixr "sums" 80)
    20    sums  :: "(nat => real) => real => bool"     (infixr "sums" 80)
    21    "f sums s  == (%n. setsum f {0..<n}) ----> s"
    21    "f sums s  == (%n. setsum f {0..<n}) ----> s"
    22 
    22 
    23    summable :: "(nat=>real) => bool"
    23    summable :: "(nat=>real) => bool"
    24    "summable f == (\<exists>s. f sums s)"
    24    "summable f == (\<exists>s. f sums s)"
    25 
    25 
    40 using setsum_bounded[where A = "{0..<n}"]
    40 using setsum_bounded[where A = "{0..<n}"]
    41 by (auto simp:real_of_nat_def)
    41 by (auto simp:real_of_nat_def)
    42 
    42 
    43 (* Generalize from real to some algebraic structure? *)
    43 (* Generalize from real to some algebraic structure? *)
    44 lemma sumr_minus_one_realpow_zero [simp]:
    44 lemma sumr_minus_one_realpow_zero [simp]:
    45   "setsum (%i. (-1) ^ Suc i) {0..<2*n} = (0::real)"
    45   "(\<Sum>i=0..<2*n. (-1) ^ Suc i) = (0::real)"
    46 by (induct "n", auto)
    46 by (induct "n", auto)
    47 
       
    48 (* FIXME get rid of this one! *)
       
    49 lemma Suc_le_imp_diff_ge2:
       
    50      "[|\<forall>n \<ge> N. f (Suc n) = 0; Suc N \<le> m|] ==> setsum f {m..<n} = 0"
       
    51 apply (rule setsum_0')
       
    52 apply (case_tac "n", auto)
       
    53 apply(erule_tac x = "a - 1" in allE)
       
    54 apply (simp split:nat_diff_split)
       
    55 done
       
    56 
    47 
    57 (* FIXME this is an awful lemma! *)
    48 (* FIXME this is an awful lemma! *)
    58 lemma sumr_one_lb_realpow_zero [simp]:
    49 lemma sumr_one_lb_realpow_zero [simp]:
    59   "(\<Sum>n=Suc 0..<n. f(n) * (0::real) ^ n) = 0"
    50   "(\<Sum>n=Suc 0..<n. f(n) * (0::real) ^ n) = 0"
    60 apply (induct "n")
    51 apply (induct "n")
    61 apply (case_tac [2] "n", auto)
    52 apply (case_tac [2] "n", auto)
    62 done
    53 done
    63 
    54 
    64 (* FIXME a bit specialized for [simp]! *)
    55 lemma sumr_group:
    65 lemma sumr_group [simp]:
       
    66      "(\<Sum>m=0..<n::nat. setsum f {m * k ..< m*k + k}) = setsum f {0 ..< n * k}"
    56      "(\<Sum>m=0..<n::nat. setsum f {m * k ..< m*k + k}) = setsum f {0 ..< n * k}"
    67 apply (subgoal_tac "k = 0 | 0 < k", auto simp:setsum_0')
    57 apply (subgoal_tac "k = 0 | 0 < k", auto)
    68 apply (induct "n")
    58 apply (induct "n")
    69 apply (simp_all add: setsum_add_nat_ivl add_commute)
    59 apply (simp_all add: setsum_add_nat_ivl add_commute)
    70 done
    60 done
    71 
    61 
    72 
    62 
   130 by (auto simp add: sums_def intro!: LIMSEQ_minus simp add: setsum_negf)
   120 by (auto simp add: sums_def intro!: LIMSEQ_minus simp add: setsum_negf)
   131 
   121 
   132 lemma sums_group:
   122 lemma sums_group:
   133      "[|summable f; 0 < k |] ==> (%n. setsum f {n*k..<n*k+k}) sums (suminf f)"
   123      "[|summable f; 0 < k |] ==> (%n. setsum f {n*k..<n*k+k}) sums (suminf f)"
   134 apply (drule summable_sums)
   124 apply (drule summable_sums)
   135 apply (auto simp add: sums_def LIMSEQ_def)
   125 apply (auto simp add: sums_def LIMSEQ_def sumr_group)
   136 apply (drule_tac x = r in spec, safe)
   126 apply (drule_tac x = r in spec, safe)
   137 apply (rule_tac x = no in exI, safe)
   127 apply (rule_tac x = no in exI, safe)
   138 apply (drule_tac x = "n*k" in spec)
   128 apply (drule_tac x = "n*k" in spec)
   139 apply (auto dest!: not_leE)
   129 apply (auto dest!: not_leE)
   140 apply (drule_tac j = no in less_le_trans, auto)
   130 apply (drule_tac j = no in less_le_trans, auto)
   261 
   251 
   262 lemma summable_rabs_comparison_test:
   252 lemma summable_rabs_comparison_test:
   263      "[| \<exists>N. \<forall>n \<ge> N. abs(f n) \<le> g n; summable g |] 
   253      "[| \<exists>N. \<forall>n \<ge> N. abs(f n) \<le> g n; summable g |] 
   264       ==> summable (%k. abs (f k))"
   254       ==> summable (%k. abs (f k))"
   265 apply (rule summable_comparison_test)
   255 apply (rule summable_comparison_test)
   266 apply (auto simp add: abs_idempotent)
   256 apply (auto)
   267 done
   257 done
   268 
   258 
   269 text{*Limit comparison property for series (c.f. jrh)*}
   259 text{*Limit comparison property for series (c.f. jrh)*}
   270 
   260 
   271 lemma summable_le:
   261 lemma summable_le:
   319 lemma ratio_test_lemma2:
   309 lemma ratio_test_lemma2:
   320      "[| \<forall>n \<ge> N. abs(f(Suc n)) \<le> c*abs(f n) |]  
   310      "[| \<forall>n \<ge> N. abs(f(Suc n)) \<le> c*abs(f n) |]  
   321       ==> 0 < c | summable f"
   311       ==> 0 < c | summable f"
   322 apply (simp (no_asm) add: linorder_not_le [symmetric])
   312 apply (simp (no_asm) add: linorder_not_le [symmetric])
   323 apply (simp add: summable_Cauchy)
   313 apply (simp add: summable_Cauchy)
   324 apply (safe, subgoal_tac "\<forall>n. N \<le> n --> f (Suc n) = 0")
   314 apply (safe, subgoal_tac "\<forall>n. N < n --> f (n) = 0")
   325 prefer 2 apply (blast intro: rabs_ratiotest_lemma)
   315  prefer 2
       
   316  apply clarify
       
   317  apply(erule_tac x = "n - 1" in allE)
       
   318  apply (simp add:diff_Suc split:nat.splits)
       
   319  apply (blast intro: rabs_ratiotest_lemma)
   326 apply (rule_tac x = "Suc N" in exI, clarify)
   320 apply (rule_tac x = "Suc N" in exI, clarify)
   327 apply (drule_tac n=n in Suc_le_imp_diff_ge2, auto) 
   321 apply(simp cong:setsum_ivl_cong)
   328 done
   322 done
   329 
   323 
   330 lemma ratio_test:
   324 lemma ratio_test:
   331      "[| c < 1; \<forall>n \<ge> N. abs(f(Suc n)) \<le> c*abs(f n) |]  
   325      "[| c < 1; \<forall>n \<ge> N. abs(f(Suc n)) \<le> c*abs(f n) |]  
   332       ==> summable f"
   326       ==> summable f"
   361 val sums_def = thm"sums_def";
   355 val sums_def = thm"sums_def";
   362 val summable_def = thm"summable_def";
   356 val summable_def = thm"summable_def";
   363 val suminf_def = thm"suminf_def";
   357 val suminf_def = thm"suminf_def";
   364 
   358 
   365 val sumr_minus_one_realpow_zero = thm "sumr_minus_one_realpow_zero";
   359 val sumr_minus_one_realpow_zero = thm "sumr_minus_one_realpow_zero";
   366 val Suc_le_imp_diff_ge2 = thm "Suc_le_imp_diff_ge2";
       
   367 val sumr_one_lb_realpow_zero = thm "sumr_one_lb_realpow_zero";
   360 val sumr_one_lb_realpow_zero = thm "sumr_one_lb_realpow_zero";
   368 val sumr_group = thm "sumr_group";
   361 val sumr_group = thm "sumr_group";
   369 val sums_summable = thm "sums_summable";
   362 val sums_summable = thm "sums_summable";
   370 val summable_sums = thm "summable_sums";
   363 val summable_sums = thm "summable_sums";
   371 val summable_sumr_LIMSEQ_suminf = thm "summable_sumr_LIMSEQ_suminf";
   364 val summable_sumr_LIMSEQ_suminf = thm "summable_sumr_LIMSEQ_suminf";