src/HOL/Library/Extended_Real.thy
changeset 61880 ff4d33058566
parent 61810 3c5040d5694a
child 61945 1135b8de26c3
equal deleted inserted replaced
61879:e4f9d8f094fe 61880:ff4d33058566
  2448 qed
  2448 qed
  2449 
  2449 
  2450 lemma lim_ereal[simp]: "((\<lambda>n. ereal (f n)) ---> ereal x) net \<longleftrightarrow> (f ---> x) net"
  2450 lemma lim_ereal[simp]: "((\<lambda>n. ereal (f n)) ---> ereal x) net \<longleftrightarrow> (f ---> x) net"
  2451   by (auto dest!: lim_real_of_ereal)
  2451   by (auto dest!: lim_real_of_ereal)
  2452 
  2452 
       
  2453 lemma convergent_real_imp_convergent_ereal:
       
  2454   assumes "convergent a"
       
  2455   shows "convergent (\<lambda>n. ereal (a n))" and "lim (\<lambda>n. ereal (a n)) = ereal (lim a)"
       
  2456 proof -
       
  2457   from assms obtain L where L: "a ----> L" unfolding convergent_def ..
       
  2458   hence lim: "(\<lambda>n. ereal (a n)) ----> ereal L" using lim_ereal by auto
       
  2459   thus "convergent (\<lambda>n. ereal (a n))" unfolding convergent_def ..
       
  2460   thus "lim (\<lambda>n. ereal (a n)) = ereal (lim a)" using lim L limI by metis
       
  2461 qed
       
  2462 
  2453 lemma tendsto_PInfty: "(f ---> \<infinity>) F \<longleftrightarrow> (\<forall>r. eventually (\<lambda>x. ereal r < f x) F)"
  2463 lemma tendsto_PInfty: "(f ---> \<infinity>) F \<longleftrightarrow> (\<forall>r. eventually (\<lambda>x. ereal r < f x) F)"
  2454 proof -
  2464 proof -
  2455   {
  2465   {
  2456     fix l :: ereal
  2466     fix l :: ereal
  2457     assume "\<forall>r. eventually (\<lambda>x. ereal r < f x) F"
  2467     assume "\<forall>r. eventually (\<lambda>x. ereal r < f x) F"
  3221   hence "(\<lambda>x. ereal (f x)) sums ereal x" by (simp add: sums_ereal)
  3231   hence "(\<lambda>x. ereal (f x)) sums ereal x" by (simp add: sums_ereal)
  3222   from sums_unique[OF this] have "(\<Sum>x. ereal (f x)) = ereal x" ..
  3232   from sums_unique[OF this] have "(\<Sum>x. ereal (f x)) = ereal x" ..
  3223   thus "(\<Sum>x. ereal (f x)) \<noteq> -\<infinity>" by simp_all
  3233   thus "(\<Sum>x. ereal (f x)) \<noteq> -\<infinity>" by simp_all
  3224 qed
  3234 qed
  3225 
  3235 
  3226 
       
  3227 lemma SUP_ereal_add_directed:
  3236 lemma SUP_ereal_add_directed:
  3228   fixes f g :: "'a \<Rightarrow> ereal"
  3237   fixes f g :: "'a \<Rightarrow> ereal"
  3229   assumes nonneg: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> g i"
  3238   assumes nonneg: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> g i"
  3230   assumes directed: "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> \<exists>k\<in>I. f i + g j \<le> f k + g k"
  3239   assumes directed: "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> \<exists>k\<in>I. f i + g j \<le> f k + g k"
  3231   shows "(SUP i:I. f i + g i) = (SUP i:I. f i) + (SUP i:I. g i)"
  3240   shows "(SUP i:I. f i + g i) = (SUP i:I. f i) + (SUP i:I. g i)"
  3289   show "(SUP n. \<Sum>i<n. SUP n:I. f n i) = (SUP n:I. SUP j. \<Sum>i<j. f n i)"
  3298   show "(SUP n. \<Sum>i<n. SUP n:I. f n i) = (SUP n:I. SUP j. \<Sum>i<j. f n i)"
  3290     apply (subst SUP_commute)
  3299     apply (subst SUP_commute)
  3291     apply (subst SUP_ereal_setsum_directed)
  3300     apply (subst SUP_ereal_setsum_directed)
  3292     apply (auto intro!: assms simp: finite_subset)
  3301     apply (auto intro!: assms simp: finite_subset)
  3293     done
  3302     done
  3294 qed
       
  3295 
       
  3296 subsection \<open>More Limits\<close>
       
  3297 
       
  3298 lemma convergent_limsup_cl:
       
  3299   fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
       
  3300   shows "convergent X \<Longrightarrow> limsup X = lim X"
       
  3301   by (auto simp: convergent_def limI lim_imp_Limsup)
       
  3302 
       
  3303 lemma lim_increasing_cl:
       
  3304   assumes "\<And>n m. n \<ge> m \<Longrightarrow> f n \<ge> f m"
       
  3305   obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})"
       
  3306 proof
       
  3307   show "f ----> (SUP n. f n)"
       
  3308     using assms
       
  3309     by (intro increasing_tendsto)
       
  3310        (auto simp: SUP_upper eventually_sequentially less_SUP_iff intro: less_le_trans)
       
  3311 qed
       
  3312 
       
  3313 lemma lim_decreasing_cl:
       
  3314   assumes "\<And>n m. n \<ge> m \<Longrightarrow> f n \<le> f m"
       
  3315   obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})"
       
  3316 proof
       
  3317   show "f ----> (INF n. f n)"
       
  3318     using assms
       
  3319     by (intro decreasing_tendsto)
       
  3320        (auto simp: INF_lower eventually_sequentially INF_less_iff intro: le_less_trans)
       
  3321 qed
       
  3322 
       
  3323 lemma compact_complete_linorder:
       
  3324   fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
       
  3325   shows "\<exists>l r. subseq r \<and> (X \<circ> r) ----> l"
       
  3326 proof -
       
  3327   obtain r where "subseq r" and mono: "monoseq (X \<circ> r)"
       
  3328     using seq_monosub[of X]
       
  3329     unfolding comp_def
       
  3330     by auto
       
  3331   then have "(\<forall>n m. m \<le> n \<longrightarrow> (X \<circ> r) m \<le> (X \<circ> r) n) \<or> (\<forall>n m. m \<le> n \<longrightarrow> (X \<circ> r) n \<le> (X \<circ> r) m)"
       
  3332     by (auto simp add: monoseq_def)
       
  3333   then obtain l where "(X \<circ> r) ----> l"
       
  3334      using lim_increasing_cl[of "X \<circ> r"] lim_decreasing_cl[of "X \<circ> r"]
       
  3335      by auto
       
  3336   then show ?thesis
       
  3337     using \<open>subseq r\<close> by auto
       
  3338 qed
  3303 qed
  3339 
  3304 
  3340 lemma ereal_dense3:
  3305 lemma ereal_dense3:
  3341   fixes x y :: ereal
  3306   fixes x y :: ereal
  3342   shows "x < y \<Longrightarrow> \<exists>r::rat. x < real_of_rat r \<and> real_of_rat r < y"
  3307   shows "x < y \<Longrightarrow> \<exists>r::rat. x < real_of_rat r \<and> real_of_rat r < y"