src/HOL/Series.thy
changeset 50999 3de230ed0547
parent 50331 4b6dc5077e98
child 51477 2990382dc066
equal deleted inserted replaced
50998:501200635659 50999:3de230ed0547
   365 text{*A summable series of positive terms has limit that is at least as
   365 text{*A summable series of positive terms has limit that is at least as
   366 great as any partial sum.*}
   366 great as any partial sum.*}
   367 
   367 
   368 lemma pos_summable:
   368 lemma pos_summable:
   369   fixes f:: "nat \<Rightarrow> real"
   369   fixes f:: "nat \<Rightarrow> real"
   370   assumes pos: "!!n. 0 \<le> f n" and le: "!!n. setsum f {0..<n} \<le> x"
   370   assumes pos: "\<And>n. 0 \<le> f n" and le: "\<And>n. setsum f {0..<n} \<le> x"
   371   shows "summable f"
   371   shows "summable f"
   372 proof -
   372 proof -
   373   have "convergent (\<lambda>n. setsum f {0..<n})"
   373   have "convergent (\<lambda>n. setsum f {0..<n})"
   374     proof (rule Bseq_mono_convergent)
   374     proof (rule Bseq_mono_convergent)
   375       show "Bseq (\<lambda>n. setsum f {0..<n})"
   375       show "Bseq (\<lambda>n. setsum f {0..<n})"
   384   thus ?thesis
   384   thus ?thesis
   385     by (force simp add: summable_def sums_def)
   385     by (force simp add: summable_def sums_def)
   386 qed
   386 qed
   387 
   387 
   388 lemma series_pos_le:
   388 lemma series_pos_le:
   389   fixes f :: "nat \<Rightarrow> real"
   389   fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
   390   shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 \<le> f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} \<le> suminf f"
   390   shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 \<le> f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} \<le> suminf f"
   391 apply (drule summable_sums)
   391   apply (drule summable_sums)
   392 apply (simp add: sums_def)
   392   apply (simp add: sums_def)
   393 apply (cut_tac k = "setsum f {0..<n}" in tendsto_const)
   393   apply (rule LIMSEQ_le_const)
   394 apply (erule LIMSEQ_le, blast)
   394   apply assumption
   395 apply (rule_tac x="n" in exI, clarify)
   395   apply (intro exI[of _ n])
   396 apply (rule setsum_mono2)
   396   apply (auto intro!: setsum_mono2)
   397 apply auto
   397   done
   398 done
       
   399 
   398 
   400 lemma series_pos_less:
   399 lemma series_pos_less:
   401   fixes f :: "nat \<Rightarrow> real"
   400   fixes f :: "nat \<Rightarrow> 'a::{ordered_ab_semigroup_add_imp_le, ordered_comm_monoid_add, linorder_topology}"
   402   shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 < f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} < suminf f"
   401   shows "\<lbrakk>summable f; \<forall>m\<ge>n. 0 < f m\<rbrakk> \<Longrightarrow> setsum f {0..<n} < suminf f"
   403 apply (rule_tac y="setsum f {0..<Suc n}" in order_less_le_trans)
   402   apply (rule_tac y="setsum f {0..<Suc n}" in order_less_le_trans)
   404 apply simp
   403   using add_less_cancel_left [of "setsum f {0..<n}" 0 "f n"]
   405 apply (erule series_pos_le)
   404   apply simp
   406 apply (simp add: order_less_imp_le)
   405   apply (erule series_pos_le)
   407 done
   406   apply (simp add: order_less_imp_le)
       
   407   done
       
   408 
       
   409 lemma suminf_eq_zero_iff:
       
   410   fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
       
   411   shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> suminf f = 0 \<longleftrightarrow> (\<forall>n. f n = 0)"
       
   412 proof
       
   413   assume "summable f" "suminf f = 0" and pos: "\<forall>n. 0 \<le> f n"
       
   414   then have "f sums 0"
       
   415     by (simp add: sums_iff)
       
   416   then have f: "(\<lambda>n. \<Sum>i<n. f i) ----> 0"
       
   417     by (simp add: sums_def atLeast0LessThan)
       
   418   have "\<And>i. (\<Sum>n\<in>{i}. f n) \<le> 0"
       
   419   proof (rule LIMSEQ_le_const[OF f])
       
   420     fix i show "\<exists>N. \<forall>n\<ge>N. (\<Sum>n\<in>{i}. f n) \<le> setsum f {..<n}"
       
   421       using pos by (intro exI[of _ "Suc i"] allI impI setsum_mono2) auto
       
   422   qed
       
   423   with pos show "\<forall>n. f n = 0"
       
   424     by (auto intro!: antisym)
       
   425 next
       
   426   assume "\<forall>n. f n = 0"
       
   427   then have "f = (\<lambda>n. 0)"
       
   428     by auto
       
   429   then show "suminf f = 0"
       
   430     by simp
       
   431 qed
       
   432 
       
   433 lemma suminf_gt_zero_iff:
       
   434   fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
       
   435   shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> 0 < suminf f \<longleftrightarrow> (\<exists>i. 0 < f i)"
       
   436   using series_pos_le[of f 0] suminf_eq_zero_iff[of f]
       
   437   by (simp add: less_le)
   408 
   438 
   409 lemma suminf_gt_zero:
   439 lemma suminf_gt_zero:
   410   fixes f :: "nat \<Rightarrow> real"
   440   fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
   411   shows "\<lbrakk>summable f; \<forall>n. 0 < f n\<rbrakk> \<Longrightarrow> 0 < suminf f"
   441   shows "\<lbrakk>summable f; \<forall>n. 0 < f n\<rbrakk> \<Longrightarrow> 0 < suminf f"
   412 by (drule_tac n="0" in series_pos_less, simp_all)
   442   using suminf_gt_zero_iff[of f] by (simp add: less_imp_le)
   413 
   443 
   414 lemma suminf_ge_zero:
   444 lemma suminf_ge_zero:
   415   fixes f :: "nat \<Rightarrow> real"
   445   fixes f :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
   416   shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> 0 \<le> suminf f"
   446   shows "\<lbrakk>summable f; \<forall>n. 0 \<le> f n\<rbrakk> \<Longrightarrow> 0 \<le> suminf f"
   417 by (drule_tac n="0" in series_pos_le, simp_all)
   447   by (drule_tac n="0" in series_pos_le, simp_all)
   418 
   448 
   419 lemma sumr_pos_lt_pair:
   449 lemma sumr_pos_lt_pair:
   420   fixes f :: "nat \<Rightarrow> real"
   450   fixes f :: "nat \<Rightarrow> real"
   421   shows "\<lbrakk>summable f;
   451   shows "\<lbrakk>summable f;
   422         \<forall>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc(Suc 0) * d) + 1))\<rbrakk>
   452         \<forall>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc(Suc 0) * d) + 1))\<rbrakk>
   491 apply (drule_tac x="Suc n" in spec, simp)
   521 apply (drule_tac x="Suc n" in spec, simp)
   492 apply (drule_tac x="n" in spec, simp)
   522 apply (drule_tac x="n" in spec, simp)
   493 done
   523 done
   494 
   524 
   495 lemma suminf_le:
   525 lemma suminf_le:
   496   fixes x :: real
   526   fixes x :: "'a :: {ordered_comm_monoid_add, linorder_topology}"
   497   shows "summable f \<Longrightarrow> (!!n. setsum f {0..<n} \<le> x) \<Longrightarrow> suminf f \<le> x"
   527   shows "summable f \<Longrightarrow> (!!n. setsum f {0..<n} \<le> x) \<Longrightarrow> suminf f \<le> x"
   498   by (simp add: summable_convergent_sumr_iff suminf_eq_lim lim_le)
   528   apply (drule summable_sums)
       
   529   apply (simp add: sums_def)
       
   530   apply (rule LIMSEQ_le_const2)
       
   531   apply assumption
       
   532   apply auto
       
   533   done
   499 
   534 
   500 lemma summable_Cauchy:
   535 lemma summable_Cauchy:
   501      "summable (f::nat \<Rightarrow> 'a::banach) =
   536      "summable (f::nat \<Rightarrow> 'a::banach) =
   502       (\<forall>e > 0. \<exists>N. \<forall>m \<ge> N. \<forall>n. norm (setsum f {m..<n}) < e)"
   537       (\<forall>e > 0. \<exists>N. \<forall>m \<ge> N. \<forall>n. norm (setsum f {m..<n}) < e)"
   503 apply (simp only: summable_convergent_sumr_iff Cauchy_convergent_iff [symmetric] Cauchy_iff, safe)
   538 apply (simp only: summable_convergent_sumr_iff Cauchy_convergent_iff [symmetric] Cauchy_iff, safe)
   573 qed
   608 qed
   574 
   609 
   575 text{*Limit comparison property for series (c.f. jrh)*}
   610 text{*Limit comparison property for series (c.f. jrh)*}
   576 
   611 
   577 lemma summable_le:
   612 lemma summable_le:
   578   fixes f g :: "nat \<Rightarrow> real"
   613   fixes f g :: "nat \<Rightarrow> 'a::{ordered_comm_monoid_add, linorder_topology}"
   579   shows "\<lbrakk>\<forall>n. f n \<le> g n; summable f; summable g\<rbrakk> \<Longrightarrow> suminf f \<le> suminf g"
   614   shows "\<lbrakk>\<forall>n. f n \<le> g n; summable f; summable g\<rbrakk> \<Longrightarrow> suminf f \<le> suminf g"
   580 apply (drule summable_sums)+
   615 apply (drule summable_sums)+
   581 apply (simp only: sums_def, erule (1) LIMSEQ_le)
   616 apply (simp only: sums_def, erule (1) LIMSEQ_le)
   582 apply (rule exI)
   617 apply (rule exI)
   583 apply (auto intro!: setsum_mono)
   618 apply (auto intro!: setsum_mono)
   595 (* specialisation for the common 0 case *)
   630 (* specialisation for the common 0 case *)
   596 lemma suminf_0_le:
   631 lemma suminf_0_le:
   597   fixes f::"nat\<Rightarrow>real"
   632   fixes f::"nat\<Rightarrow>real"
   598   assumes gt0: "\<forall>n. 0 \<le> f n" and sm: "summable f"
   633   assumes gt0: "\<forall>n. 0 \<le> f n" and sm: "summable f"
   599   shows "0 \<le> suminf f"
   634   shows "0 \<le> suminf f"
   600 proof -
   635   using suminf_ge_zero[OF sm gt0] by simp
   601   let ?g = "(\<lambda>n. (0::real))"
       
   602   from gt0 have "\<forall>n. ?g n \<le> f n" by simp
       
   603   moreover have "summable ?g" by (rule summable_zero)
       
   604   moreover from sm have "summable f" .
       
   605   ultimately have "suminf ?g \<le> suminf f" by (rule summable_le)
       
   606   then show "0 \<le> suminf f" by simp
       
   607 qed
       
   608 
       
   609 
   636 
   610 text{*Absolute convergence imples normal convergence*}
   637 text{*Absolute convergence imples normal convergence*}
   611 lemma summable_norm_cancel:
   638 lemma summable_norm_cancel:
   612   fixes f :: "nat \<Rightarrow> 'a::banach"
   639   fixes f :: "nat \<Rightarrow> 'a::banach"
   613   shows "summable (\<lambda>n. norm (f n)) \<Longrightarrow> summable f"
   640   shows "summable (\<lambda>n. norm (f n)) \<Longrightarrow> summable f"