# HG changeset patch # User hoelzl # Date 1437662350 -7200 # Node ID 8558e4a37b489ba38122b288389ed9722511fea9 # Parent 240563fbf41d9b03f877c415dcab2bdd9d781cd7 reorganized Extended_Real diff -r 240563fbf41d -r 8558e4a37b48 src/HOL/Library/Extended_Real.thy --- a/src/HOL/Library/Extended_Real.thy Thu Jul 23 14:25:05 2015 +0200 +++ b/src/HOL/Library/Extended_Real.thy Thu Jul 23 16:39:10 2015 +0200 @@ -1909,6 +1909,9 @@ shows "\ \ S \ Sup S = \" unfolding top_ereal_def[symmetric] by auto +lemma not_MInfty_nonneg[simp]: "0 \ (x::ereal) \ x \ - \" + by auto + lemma Sup_ereal_close: fixes e :: ereal assumes "0 < e" @@ -2803,9 +2806,6 @@ qed qed -lemma not_MInfty_nonneg[simp]: "0 \ (x::ereal) \ x \ - \" - by auto - lemma sup_continuous_add[order_continuous_intros]: fixes f g :: "'a::complete_lattice \ ereal" assumes nn: "\x. 0 \ f x" "\x. 0 \ g x" and cont: "sup_continuous f" "sup_continuous g" @@ -2832,6 +2832,747 @@ by (rule sup_continuous_compose[OF _ f]) (auto simp: sup_continuous_def ereal_of_enat_SUP) +subsubsection \Sums\ + +lemma sums_ereal_positive: + fixes f :: "nat \ ereal" + assumes "\i. 0 \ f i" + shows "f sums (SUP n. \ii. \j=0.. ereal" + assumes "\i. 0 \ f i" + shows "summable f" + using sums_ereal_positive[of f, OF assms] + unfolding summable_def + by auto + +lemma sums_ereal: "(\x. ereal (f x)) sums ereal x \ f sums x" + unfolding sums_def by simp + +lemma suminf_ereal_eq_SUP: + fixes f :: "nat \ ereal" + assumes "\i. 0 \ f i" + shows "(\x. f x) = (SUP n. \i ereal" + assumes "\N. (\n x" + and pos: "\n. 0 \ f n" + shows "suminf f \ x" +proof (rule Lim_bounded_ereal) + have "summable f" using pos[THEN summable_ereal_pos] . + then show "(\N. \n suminf f" + by (auto dest!: summable_sums simp: sums_def atLeast0LessThan) + show "\n\0. setsum f {.. x" + using assms by auto +qed + +lemma suminf_bound_add: + fixes f :: "nat \ ereal" + assumes "\N. (\n x" + and pos: "\n. 0 \ f n" + and "y \ -\" + shows "suminf f + y \ x" +proof (cases y) + case (real r) + then have "\N. (\n x - y" + using assms by (simp add: ereal_le_minus) + then have "(\ n. f n) \ x - y" + using pos by (rule suminf_bound) + then show "(\ n. f n) + y \ x" + using assms real by (simp add: ereal_le_minus) +qed (insert assms, auto) + +lemma suminf_upper: + fixes f :: "nat \ ereal" + assumes "\n. 0 \ f n" + shows "(\n (\n. f n)" + unfolding suminf_ereal_eq_SUP [OF assms] + by (auto intro: complete_lattice_class.SUP_upper) + +lemma suminf_0_le: + fixes f :: "nat \ ereal" + assumes "\n. 0 \ f n" + shows "0 \ (\n. f n)" + using suminf_upper[of f 0, OF assms] + by simp + +lemma suminf_le_pos: + fixes f g :: "nat \ ereal" + assumes "\N. f N \ g N" + and "\N. 0 \ f N" + shows "suminf f \ suminf g" +proof (safe intro!: suminf_bound) + fix n + { + fix N + have "0 \ g N" + using assms(2,1)[of N] by auto + } + have "setsum f {.. setsum g {.. \ suminf g" + using \\N. 0 \ g N\ + by (rule suminf_upper) + finally show "setsum f {.. suminf g" . +qed (rule assms(2)) + +lemma suminf_half_series_ereal: "(\n. (1/2 :: ereal) ^ Suc n) = 1" + using sums_ereal[THEN iffD2, OF power_half_series, THEN sums_unique, symmetric] + by (simp add: one_ereal_def) + +lemma suminf_add_ereal: + fixes f g :: "nat \ ereal" + assumes "\i. 0 \ f i" + and "\i. 0 \ g i" + shows "(\i. f i + g i) = suminf f + suminf g" + apply (subst (1 2 3) suminf_ereal_eq_SUP) + unfolding setsum.distrib + apply (intro assms ereal_add_nonneg_nonneg SUP_ereal_add_pos incseq_setsumI setsum_nonneg ballI)+ + done + +lemma suminf_cmult_ereal: + fixes f g :: "nat \ ereal" + assumes "\i. 0 \ f i" + and "0 \ a" + shows "(\i. a * f i) = a * suminf f" + by (auto simp: setsum_ereal_right_distrib[symmetric] assms + ereal_zero_le_0_iff setsum_nonneg suminf_ereal_eq_SUP + intro!: SUP_ereal_mult_left) + +lemma suminf_PInfty: + fixes f :: "nat \ ereal" + assumes "\i. 0 \ f i" + and "suminf f \ \" + shows "f i \ \" +proof - + from suminf_upper[of f "Suc i", OF assms(1)] assms(2) + have "(\i \" + by auto + then show ?thesis + unfolding setsum_Pinfty by simp +qed + +lemma suminf_PInfty_fun: + assumes "\i. 0 \ f i" + and "suminf f \ \" + shows "\f'. f = (\x. ereal (f' x))" +proof - + have "\i. \r. f i = ereal r" + proof + fix i + show "\r. f i = ereal r" + using suminf_PInfty[OF assms] assms(1)[of i] + by (cases "f i") auto + qed + from choice[OF this] show ?thesis + by auto +qed + +lemma summable_ereal: + assumes "\i. 0 \ f i" + and "(\i. ereal (f i)) \ \" + shows "summable f" +proof - + have "0 \ (\i. ereal (f i))" + using assms by (intro suminf_0_le) auto + with assms obtain r where r: "(\i. ereal (f i)) = ereal r" + by (cases "\i. ereal (f i)") auto + from summable_ereal_pos[of "\x. ereal (f x)"] + have "summable (\x. ereal (f x))" + using assms by auto + from summable_sums[OF this] + have "(\x. ereal (f x)) sums (\x. ereal (f x))" + by auto + then show "summable f" + unfolding r sums_ereal summable_def .. +qed + +lemma suminf_ereal: + assumes "\i. 0 \ f i" + and "(\i. ereal (f i)) \ \" + shows "(\i. ereal (f i)) = ereal (suminf f)" +proof (rule sums_unique[symmetric]) + from summable_ereal[OF assms] + show "(\x. ereal (f x)) sums (ereal (suminf f))" + unfolding sums_ereal + using assms + by (intro summable_sums summable_ereal) +qed + +lemma suminf_ereal_minus: + fixes f g :: "nat \ ereal" + assumes ord: "\i. g i \ f i" "\i. 0 \ g i" + and fin: "suminf f \ \" "suminf g \ \" + shows "(\i. f i - g i) = suminf f - suminf g" +proof - + { + fix i + have "0 \ f i" + using ord[of i] by auto + } + moreover + from suminf_PInfty_fun[OF \\i. 0 \ f i\ fin(1)] obtain f' where [simp]: "f = (\x. ereal (f' x))" .. + from suminf_PInfty_fun[OF \\i. 0 \ g i\ fin(2)] obtain g' where [simp]: "g = (\x. ereal (g' x))" .. + { + fix i + have "0 \ f i - g i" + using ord[of i] by (auto simp: ereal_le_minus_iff) + } + moreover + have "suminf (\i. f i - g i) \ suminf f" + using assms by (auto intro!: suminf_le_pos simp: field_simps) + then have "suminf (\i. f i - g i) \ \" + using fin by auto + ultimately show ?thesis + using assms \\i. 0 \ f i\ + apply simp + apply (subst (1 2 3) suminf_ereal) + apply (auto intro!: suminf_diff[symmetric] summable_ereal) + done +qed + +lemma suminf_ereal_PInf [simp]: "(\x. \::ereal) = \" +proof - + have "(\i) \ (\x. \::ereal)" + by (rule suminf_upper) auto + then show ?thesis + by simp +qed + +lemma summable_real_of_ereal: + fixes f :: "nat \ ereal" + assumes f: "\i. 0 \ f i" + and fin: "(\i. f i) \ \" + shows "summable (\i. real (f i))" +proof (rule summable_def[THEN iffD2]) + have "0 \ (\i. f i)" + using assms by (auto intro: suminf_0_le) + with fin obtain r where r: "ereal r = (\i. f i)" + by (cases "(\i. f i)") auto + { + fix i + have "f i \ \" + using f by (intro suminf_PInfty[OF _ fin]) auto + then have "\f i\ \ \" + using f[of i] by auto + } + note fin = this + have "(\i. ereal (real (f i))) sums (\i. ereal (real (f i)))" + using f + by (auto intro!: summable_ereal_pos simp: ereal_le_real_iff zero_ereal_def) + also have "\ = ereal r" + using fin r by (auto simp: ereal_real) + finally show "\r. (\i. real (f i)) sums r" + by (auto simp: sums_ereal) +qed + +lemma suminf_SUP_eq: + fixes f :: "nat \ nat \ ereal" + assumes "\i. incseq (\n. f n i)" + and "\n i. 0 \ f n i" + shows "(\i. SUP n. f n i) = (SUP n. \i. f n i)" +proof - + { + fix n :: nat + have "(\ii _ \ ereal" + assumes nonneg: "\i a. a \ A \ 0 \ f i a" + shows "(\i. \a\A. f i a) = (\a\A. \i. f i a)" +proof (cases "finite A") + case True + then show ?thesis + using nonneg + by induct (simp_all add: suminf_add_ereal setsum_nonneg) +next + case False + then show ?thesis by simp +qed + +lemma suminf_ereal_eq_0: + fixes f :: "nat \ ereal" + assumes nneg: "\i. 0 \ f i" + shows "(\i. f i) = 0 \ (\i. f i = 0)" +proof + assume "(\i. f i) = 0" + { + fix i + assume "f i \ 0" + with nneg have "0 < f i" + by (auto simp: less_le) + also have "f i = (\j. if j = i then f i else 0)" + by (subst suminf_finite[where N="{i}"]) auto + also have "\ \ (\i. f i)" + using nneg + by (auto intro!: suminf_le_pos) + finally have False + using \(\i. f i) = 0\ by auto + } + then show "\i. f i = 0" + by auto +qed simp + +lemma suminf_ereal_offset_le: + fixes f :: "nat \ ereal" + assumes f: "\i. 0 \ f i" + shows "(\i. f (i + k)) \ suminf f" +proof - + have "(\n. \i (\i. f (i + k))" + using summable_sums[OF summable_ereal_pos] by (simp add: sums_def atLeast0LessThan f) + moreover have "(\n. \i (\i. f i)" + using summable_sums[OF summable_ereal_pos] by (simp add: sums_def atLeast0LessThan f) + then have "(\n. \i (\i. f i)" + by (rule LIMSEQ_ignore_initial_segment) + ultimately show ?thesis + proof (rule LIMSEQ_le, safe intro!: exI[of _ k]) + fix n assume "k \ n" + have "(\ii (\i. i + k)) i)" + by simp + also have "\ = (\i\(\i. i + k) ` {.. \ setsum f {..i setsum f {.. (\i. ereal (f i)) = ereal x" + by (metis sums_ereal sums_unique) + +lemma suminf_ereal': "summable f \ (\i. ereal (f i)) = ereal (\i. f i)" + by (metis sums_ereal sums_unique summable_def) + +lemma suminf_ereal_finite: "summable f \ (\i. ereal (f i)) \ \" + by (auto simp: sums_ereal[symmetric] summable_def sums_unique[symmetric]) + +lemma suminf_ereal_finite_neg: + assumes "summable f" + shows "(\x. ereal (f x)) \ -\" +proof- + from assms obtain x where "f sums x" by blast + hence "(\x. ereal (f x)) sums ereal x" by (simp add: sums_ereal) + from sums_unique[OF this] have "(\x. ereal (f x)) = ereal x" .. + thus "(\x. ereal (f x)) \ -\" by simp_all +qed + + +lemma convergent_limsup_cl: + fixes X :: "nat \ 'a::{complete_linorder,linorder_topology}" + shows "convergent X \ limsup X = lim X" + by (auto simp: convergent_def limI lim_imp_Limsup) + +lemma lim_increasing_cl: + assumes "\n m. n \ m \ f n \ f m" + obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})" +proof + show "f ----> (SUP n. f n)" + using assms + by (intro increasing_tendsto) + (auto simp: SUP_upper eventually_sequentially less_SUP_iff intro: less_le_trans) +qed + +lemma lim_decreasing_cl: + assumes "\n m. n \ m \ f n \ f m" + obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})" +proof + show "f ----> (INF n. f n)" + using assms + by (intro decreasing_tendsto) + (auto simp: INF_lower eventually_sequentially INF_less_iff intro: le_less_trans) +qed + +lemma compact_complete_linorder: + fixes X :: "nat \ 'a::{complete_linorder,linorder_topology}" + shows "\l r. subseq r \ (X \ r) ----> l" +proof - + obtain r where "subseq r" and mono: "monoseq (X \ r)" + using seq_monosub[of X] + unfolding comp_def + by auto + then have "(\n m. m \ n \ (X \ r) m \ (X \ r) n) \ (\n m. m \ n \ (X \ r) n \ (X \ r) m)" + by (auto simp add: monoseq_def) + then obtain l where "(X \ r) ----> l" + using lim_increasing_cl[of "X \ r"] lim_decreasing_cl[of "X \ r"] + by auto + then show ?thesis + using \subseq r\ by auto +qed + +lemma ereal_dense3: + fixes x y :: ereal + shows "x < y \ \r::rat. x < real_of_rat r \ real_of_rat r < y" +proof (cases x y rule: ereal2_cases, simp_all) + fix r q :: real + assume "r < q" + from Rats_dense_in_real[OF this] show "\x. r < real_of_rat x \ real_of_rat x < q" + by (fastforce simp: Rats_def) +next + fix r :: real + show "\x. r < real_of_rat x" "\x. real_of_rat x < r" + using gt_ex[of r] lt_ex[of r] Rats_dense_in_real + by (auto simp: Rats_def) +qed + +lemma continuous_within_ereal[intro, simp]: "x \ A \ continuous (at x within A) ereal" + using continuous_on_eq_continuous_within[of A ereal] + by (auto intro: continuous_on_ereal continuous_on_id) + +lemma ereal_open_uminus: + fixes S :: "ereal set" + assumes "open S" + shows "open (uminus ` S)" + using \open S\[unfolded open_generated_order] +proof induct + have "range uminus = (UNIV :: ereal set)" + by (auto simp: image_iff ereal_uminus_eq_reorder) + then show "open (range uminus :: ereal set)" + by simp +qed (auto simp add: image_Union image_Int) + +lemma ereal_uminus_complement: + fixes S :: "ereal set" + shows "uminus ` (- S) = - uminus ` S" + by (auto intro!: bij_image_Compl_eq surjI[of _ uminus] simp: bij_betw_def) + +lemma ereal_closed_uminus: + fixes S :: "ereal set" + assumes "closed S" + shows "closed (uminus ` S)" + using assms + unfolding closed_def ereal_uminus_complement[symmetric] + by (rule ereal_open_uminus) + +lemma ereal_open_affinity_pos: + fixes S :: "ereal set" + assumes "open S" + and m: "m \ \" "0 < m" + and t: "\t\ \ \" + shows "open ((\x. m * x + t) ` S)" +proof - + have "open ((\x. inverse m * (x + -t)) -` S)" + using m t + apply (intro open_vimage \open S\) + apply (intro continuous_at_imp_continuous_on ballI tendsto_cmult_ereal continuous_at[THEN iffD2] + tendsto_ident_at tendsto_add_left_ereal) + apply auto + done + also have "(\x. inverse m * (x + -t)) -` S = (\x. (x - t) / m) -` S" + using m t by (auto simp: divide_ereal_def mult.commute uminus_ereal.simps[symmetric] minus_ereal_def + simp del: uminus_ereal.simps) + also have "(\x. (x - t) / m) -` S = (\x. m * x + t) ` S" + using m t + by (simp add: set_eq_iff image_iff) + (metis abs_ereal_less0 abs_ereal_uminus ereal_divide_eq ereal_eq_minus ereal_minus(7,8) + ereal_minus_less_minus ereal_mult_eq_PInfty ereal_uminus_uminus ereal_zero_mult) + finally show ?thesis . +qed + +lemma ereal_open_affinity: + fixes S :: "ereal set" + assumes "open S" + and m: "\m\ \ \" "m \ 0" + and t: "\t\ \ \" + shows "open ((\x. m * x + t) ` S)" +proof cases + assume "0 < m" + then show ?thesis + using ereal_open_affinity_pos[OF \open S\ _ _ t, of m] m + by auto +next + assume "\ 0 < m" then + have "0 < -m" + using \m \ 0\ + by (cases m) auto + then have m: "-m \ \" "0 < -m" + using \\m\ \ \\ + by (auto simp: ereal_uminus_eq_reorder) + from ereal_open_affinity_pos[OF ereal_open_uminus[OF \open S\] m t] show ?thesis + unfolding image_image by simp +qed + +lemma open_uminus_iff: + fixes S :: "ereal set" + shows "open (uminus ` S) \ open S" + using ereal_open_uminus[of S] ereal_open_uminus[of "uminus ` S"] + by auto + +lemma ereal_Liminf_uminus: + fixes f :: "'a \ ereal" + shows "Liminf net (\x. - (f x)) = - Limsup net f" + using ereal_Limsup_uminus[of _ "(\x. - (f x))"] by auto + +lemma Liminf_PInfty: + fixes f :: "'a \ ereal" + assumes "\ trivial_limit net" + shows "(f ---> \) net \ Liminf net f = \" + unfolding tendsto_iff_Liminf_eq_Limsup[OF assms] + using Liminf_le_Limsup[OF assms, of f] + by auto + +lemma Limsup_MInfty: + fixes f :: "'a \ ereal" + assumes "\ trivial_limit net" + shows "(f ---> -\) net \ Limsup net f = -\" + unfolding tendsto_iff_Liminf_eq_Limsup[OF assms] + using Liminf_le_Limsup[OF assms, of f] + by auto + +lemma convergent_ereal: + fixes X :: "nat \ 'a :: {complete_linorder,linorder_topology}" + shows "convergent X \ limsup X = liminf X" + using tendsto_iff_Liminf_eq_Limsup[of sequentially] + by (auto simp: convergent_def) + +lemma limsup_le_liminf_real: + fixes X :: "nat \ real" and L :: real + assumes 1: "limsup X \ L" and 2: "L \ liminf X" + shows "X ----> L" +proof - + from 1 2 have "limsup X \ liminf X" by auto + hence 3: "limsup X = liminf X" + apply (subst eq_iff, rule conjI) + by (rule Liminf_le_Limsup, auto) + hence 4: "convergent (\n. ereal (X n))" + by (subst convergent_ereal) + hence "limsup X = lim (\n. ereal(X n))" + by (rule convergent_limsup_cl) + also from 1 2 3 have "limsup X = L" by auto + finally have "lim (\n. ereal(X n)) = L" .. + hence "(\n. ereal (X n)) ----> L" + apply (elim subst) + by (subst convergent_LIMSEQ_iff [symmetric], rule 4) + thus ?thesis by simp +qed + +lemma liminf_PInfty: + fixes X :: "nat \ ereal" + shows "X ----> \ \ liminf X = \" + by (metis Liminf_PInfty trivial_limit_sequentially) + +lemma limsup_MInfty: + fixes X :: "nat \ ereal" + shows "X ----> -\ \ limsup X = -\" + by (metis Limsup_MInfty trivial_limit_sequentially) + +lemma ereal_lim_mono: + fixes X Y :: "nat \ 'a::linorder_topology" + assumes "\n. N \ n \ X n \ Y n" + and "X ----> x" + and "Y ----> y" + shows "x \ y" + using assms(1) by (intro LIMSEQ_le[OF assms(2,3)]) auto + +lemma incseq_le_ereal: + fixes X :: "nat \ 'a::linorder_topology" + assumes inc: "incseq X" + and lim: "X ----> L" + shows "X N \ L" + using inc + by (intro ereal_lim_mono[of N, OF _ tendsto_const lim]) (simp add: incseq_def) + +lemma decseq_ge_ereal: + assumes dec: "decseq X" + and lim: "X ----> (L::'a::linorder_topology)" + shows "X N \ L" + using dec by (intro ereal_lim_mono[of N, OF _ lim tendsto_const]) (simp add: decseq_def) + +lemma bounded_abs: + fixes a :: real + assumes "a \ x" + and "x \ b" + shows "abs x \ max (abs a) (abs b)" + by (metis abs_less_iff assms leI le_max_iff_disj + less_eq_real_def less_le_not_le less_minus_iff minus_minus) + +lemma ereal_Sup_lim: + fixes a :: "'a::{complete_linorder,linorder_topology}" + assumes "\n. b n \ s" + and "b ----> a" + shows "a \ Sup s" + by (metis Lim_bounded_ereal assms complete_lattice_class.Sup_upper) + +lemma ereal_Inf_lim: + fixes a :: "'a::{complete_linorder,linorder_topology}" + assumes "\n. b n \ s" + and "b ----> a" + shows "Inf s \ a" + by (metis Lim_bounded2_ereal assms complete_lattice_class.Inf_lower) + +lemma SUP_Lim_ereal: + fixes X :: "nat \ 'a::{complete_linorder,linorder_topology}" + assumes inc: "incseq X" + and l: "X ----> l" + shows "(SUP n. X n) = l" + using LIMSEQ_SUP[OF inc] tendsto_unique[OF trivial_limit_sequentially l] + by simp + +lemma INF_Lim_ereal: + fixes X :: "nat \ 'a::{complete_linorder,linorder_topology}" + assumes dec: "decseq X" + and l: "X ----> l" + shows "(INF n. X n) = l" + using LIMSEQ_INF[OF dec] tendsto_unique[OF trivial_limit_sequentially l] + by simp + +lemma SUP_eq_LIMSEQ: + assumes "mono f" + shows "(SUP n. ereal (f n)) = ereal x \ f ----> x" +proof + have inc: "incseq (\i. ereal (f i))" + using \mono f\ unfolding mono_def incseq_def by auto + { + assume "f ----> x" + then have "(\i. ereal (f i)) ----> ereal x" + by auto + from SUP_Lim_ereal[OF inc this] show "(SUP n. ereal (f n)) = ereal x" . + next + assume "(SUP n. ereal (f n)) = ereal x" + with LIMSEQ_SUP[OF inc] show "f ----> x" by auto + } +qed + +lemma liminf_ereal_cminus: + fixes f :: "nat \ ereal" + assumes "c \ -\" + shows "liminf (\x. c - f x) = c - limsup f" +proof (cases c) + case PInf + then show ?thesis + by (simp add: Liminf_const) +next + case (real r) + then show ?thesis + unfolding liminf_SUP_INF limsup_INF_SUP + apply (subst INF_ereal_minus_right) + apply auto + apply (subst SUP_ereal_minus_right) + apply auto + done +qed (insert \c \ -\\, simp) + + +subsubsection \Continuity\ + +lemma continuous_at_of_ereal: + "\x0 :: ereal\ \ \ \ continuous (at x0) real" + unfolding continuous_at + by (rule lim_real_of_ereal) (simp add: ereal_real) + +lemma nhds_ereal: "nhds (ereal r) = filtermap ereal (nhds r)" + by (simp add: filtermap_nhds_open_map open_ereal continuous_at_of_ereal) + +lemma at_ereal: "at (ereal r) = filtermap ereal (at r)" + by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) + +lemma at_left_ereal: "at_left (ereal r) = filtermap ereal (at_left r)" + by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) + +lemma at_right_ereal: "at_right (ereal r) = filtermap ereal (at_right r)" + by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) + +lemma + shows at_left_PInf: "at_left \ = filtermap ereal at_top" + and at_right_MInf: "at_right (-\) = filtermap ereal at_bot" + unfolding filter_eq_iff eventually_filtermap eventually_at_top_dense eventually_at_bot_dense + eventually_at_left[OF ereal_less(5)] eventually_at_right[OF ereal_less(6)] + by (auto simp add: ereal_all_split ereal_ex_split) + +lemma ereal_tendsto_simps1: + "((f \ real) ---> y) (at_left (ereal x)) \ (f ---> y) (at_left x)" + "((f \ real) ---> y) (at_right (ereal x)) \ (f ---> y) (at_right x)" + "((f \ real) ---> y) (at_left (\::ereal)) \ (f ---> y) at_top" + "((f \ real) ---> y) (at_right (-\::ereal)) \ (f ---> y) at_bot" + unfolding tendsto_compose_filtermap at_left_ereal at_right_ereal at_left_PInf at_right_MInf + by (auto simp: filtermap_filtermap filtermap_ident) + +lemma ereal_tendsto_simps2: + "((ereal \ f) ---> ereal a) F \ (f ---> a) F" + "((ereal \ f) ---> \) F \ (LIM x F. f x :> at_top)" + "((ereal \ f) ---> -\) F \ (LIM x F. f x :> at_bot)" + unfolding tendsto_PInfty filterlim_at_top_dense tendsto_MInfty filterlim_at_bot_dense + using lim_ereal by (simp_all add: comp_def) + +lemmas ereal_tendsto_simps = ereal_tendsto_simps1 ereal_tendsto_simps2 + +lemma continuous_at_iff_ereal: + fixes f :: "'a::t2_space \ real" + shows "continuous (at x0 within s) f \ continuous (at x0 within s) (ereal \ f)" + unfolding continuous_within comp_def lim_ereal .. + +lemma continuous_on_iff_ereal: + fixes f :: "'a::t2_space => real" + assumes "open A" + shows "continuous_on A f \ continuous_on A (ereal \ f)" + unfolding continuous_on_def comp_def lim_ereal .. + +lemma continuous_on_real: "continuous_on (UNIV - {\, -\::ereal}) real" + using continuous_at_of_ereal continuous_on_eq_continuous_at open_image_ereal + by auto + +lemma continuous_on_iff_real: + fixes f :: "'a::t2_space \ ereal" + assumes *: "\x. x \ A \ \f x\ \ \" + shows "continuous_on A f \ continuous_on A (real \ f)" +proof - + have "f ` A \ UNIV - {\, -\}" + using assms by force + then have *: "continuous_on (f ` A) real" + using continuous_on_real by (simp add: continuous_on_subset) + have **: "continuous_on ((real \ f) ` A) ereal" + by (intro continuous_on_ereal continuous_on_id) + { + assume "continuous_on A f" + then have "continuous_on A (real \ f)" + apply (subst continuous_on_compose) + using * + apply auto + done + } + moreover + { + assume "continuous_on A (real \ f)" + then have "continuous_on A (ereal \ (real \ f))" + apply (subst continuous_on_compose) + using ** + apply auto + done + then have "continuous_on A f" + apply (subst continuous_on_cong[of _ A _ "ereal \ (real \ f)"]) + using assms ereal_real + apply auto + done + } + ultimately show ?thesis + by auto +qed + + subsubsection \Tests for code generator\ (* A small list of simple arithmetic expressions *) diff -r 240563fbf41d -r 8558e4a37b48 src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy --- a/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Thu Jul 23 14:25:05 2015 +0200 +++ b/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy Thu Jul 23 16:39:10 2015 +0200 @@ -11,48 +11,6 @@ imports Topology_Euclidean_Space "~~/src/HOL/Library/Extended_Real" "~~/src/HOL/Library/Indicator_Function" begin -lemma convergent_limsup_cl: - fixes X :: "nat \ 'a::{complete_linorder,linorder_topology}" - shows "convergent X \ limsup X = lim X" - by (auto simp: convergent_def limI lim_imp_Limsup) - -lemma lim_increasing_cl: - assumes "\n m. n \ m \ f n \ f m" - obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})" -proof - show "f ----> (SUP n. f n)" - using assms - by (intro increasing_tendsto) - (auto simp: SUP_upper eventually_sequentially less_SUP_iff intro: less_le_trans) -qed - -lemma lim_decreasing_cl: - assumes "\n m. n \ m \ f n \ f m" - obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})" -proof - show "f ----> (INF n. f n)" - using assms - by (intro decreasing_tendsto) - (auto simp: INF_lower eventually_sequentially INF_less_iff intro: le_less_trans) -qed - -lemma compact_complete_linorder: - fixes X :: "nat \ 'a::{complete_linorder,linorder_topology}" - shows "\l r. subseq r \ (X \ r) ----> l" -proof - - obtain r where "subseq r" and mono: "monoseq (X \ r)" - using seq_monosub[of X] - unfolding comp_def - by auto - then have "(\n m. m \ n \ (X \ r) m \ (X \ r) n) \ (\n m. m \ n \ (X \ r) n \ (X \ r) m)" - by (auto simp add: monoseq_def) - then obtain l where "(X \ r) ----> l" - using lim_increasing_cl[of "X \ r"] lim_decreasing_cl[of "X \ r"] - by auto - then show ?thesis - using \subseq r\ by auto -qed - lemma compact_UNIV: "compact (UNIV :: 'a::{complete_linorder,linorder_topology,second_countable_topology} set)" using compact_complete_linorder @@ -94,21 +52,6 @@ by simp qed -lemma ereal_dense3: - fixes x y :: ereal - shows "x < y \ \r::rat. x < real_of_rat r \ real_of_rat r < y" -proof (cases x y rule: ereal2_cases, simp_all) - fix r q :: real - assume "r < q" - from Rats_dense_in_real[OF this] show "\x. r < real_of_rat x \ real_of_rat x < q" - by (fastforce simp: Rats_def) -next - fix r :: real - show "\x. r < real_of_rat x" "\x. real_of_rat x < r" - using gt_ex[of r] lt_ex[of r] Rats_dense_in_real - by (auto simp: Rats_def) -qed - instance ereal :: second_countable_topology proof (default, intro exI conjI) let ?B = "(\r\\. {{..< r}, {r <..}} :: ereal set set)" @@ -139,43 +82,6 @@ qed qed -lemma continuous_on_ereal[intro, simp]: "continuous_on A ereal" - unfolding continuous_on_topological open_ereal_def - by auto - -lemma continuous_at_ereal[intro, simp]: "continuous (at x) ereal" - using continuous_on_eq_continuous_at[of UNIV] - by auto - -lemma continuous_within_ereal[intro, simp]: "x \ A \ continuous (at x within A) ereal" - using continuous_on_eq_continuous_within[of A] - by auto - -lemma ereal_open_uminus: - fixes S :: "ereal set" - assumes "open S" - shows "open (uminus ` S)" - using \open S\[unfolded open_generated_order] -proof induct - have "range uminus = (UNIV :: ereal set)" - by (auto simp: image_iff ereal_uminus_eq_reorder) - then show "open (range uminus :: ereal set)" - by simp -qed (auto simp add: image_Union image_Int) - -lemma ereal_uminus_complement: - fixes S :: "ereal set" - shows "uminus ` (- S) = - uminus ` S" - by (auto intro!: bij_image_Compl_eq surjI[of _ uminus] simp: bij_betw_def) - -lemma ereal_closed_uminus: - fixes S :: "ereal set" - assumes "closed S" - shows "closed (uminus ` S)" - using assms - unfolding closed_def ereal_uminus_complement[symmetric] - by (rule ereal_open_uminus) - lemma ereal_open_closed_aux: fixes S :: "ereal set" assumes "open S" @@ -185,6 +91,7 @@ proof (rule ccontr) assume "\ ?thesis" then have *: "Inf S \ S" + by (metis assms(2) closed_contains_Inf_cl) { assume "Inf S = -\" @@ -243,54 +150,6 @@ by auto qed -lemma ereal_open_affinity_pos: - fixes S :: "ereal set" - assumes "open S" - and m: "m \ \" "0 < m" - and t: "\t\ \ \" - shows "open ((\x. m * x + t) ` S)" -proof - - have "open ((\x. inverse m * (x + -t)) -` S)" - using m t - apply (intro open_vimage \open S\) - apply (intro continuous_at_imp_continuous_on ballI tendsto_cmult_ereal continuous_at[THEN iffD2] - tendsto_ident_at tendsto_add_left_ereal) - apply auto - done - also have "(\x. inverse m * (x + -t)) -` S = (\x. (x - t) / m) -` S" - using m t by (auto simp: divide_ereal_def mult.commute uminus_ereal.simps[symmetric] minus_ereal_def - simp del: uminus_ereal.simps) - also have "(\x. (x - t) / m) -` S = (\x. m * x + t) ` S" - using m t - by (simp add: set_eq_iff image_iff) - (metis abs_ereal_less0 abs_ereal_uminus ereal_divide_eq ereal_eq_minus ereal_minus(7,8) - ereal_minus_less_minus ereal_mult_eq_PInfty ereal_uminus_uminus ereal_zero_mult) - finally show ?thesis . -qed - -lemma ereal_open_affinity: - fixes S :: "ereal set" - assumes "open S" - and m: "\m\ \ \" "m \ 0" - and t: "\t\ \ \" - shows "open ((\x. m * x + t) ` S)" -proof cases - assume "0 < m" - then show ?thesis - using ereal_open_affinity_pos[OF \open S\ _ _ t, of m] m - by auto -next - assume "\ 0 < m" then - have "0 < -m" - using \m \ 0\ - by (cases m) auto - then have m: "-m \ \" "0 < -m" - using \\m\ \ \\ - by (auto simp: ereal_uminus_eq_reorder) - from ereal_open_affinity_pos[OF ereal_open_uminus[OF \open S\] m t] show ?thesis - unfolding image_image by simp -qed - lemma ereal_open_atLeast: fixes x :: ereal shows "open {x..} \ x = -\" @@ -310,290 +169,6 @@ by (simp add: bot_ereal_def atLeast_eq_UNIV_iff) qed -lemma open_uminus_iff: - fixes S :: "ereal set" - shows "open (uminus ` S) \ open S" - using ereal_open_uminus[of S] ereal_open_uminus[of "uminus ` S"] - by auto - -lemma ereal_Liminf_uminus: - fixes f :: "'a \ ereal" - shows "Liminf net (\x. - (f x)) = - Limsup net f" - using ereal_Limsup_uminus[of _ "(\x. - (f x))"] by auto - -lemma Liminf_PInfty: - fixes f :: "'a \ ereal" - assumes "\ trivial_limit net" - shows "(f ---> \) net \ Liminf net f = \" - unfolding tendsto_iff_Liminf_eq_Limsup[OF assms] - using Liminf_le_Limsup[OF assms, of f] - by auto - -lemma Limsup_MInfty: - fixes f :: "'a \ ereal" - assumes "\ trivial_limit net" - shows "(f ---> -\) net \ Limsup net f = -\" - unfolding tendsto_iff_Liminf_eq_Limsup[OF assms] - using Liminf_le_Limsup[OF assms, of f] - by auto - -lemma convergent_ereal: - fixes X :: "nat \ 'a :: {complete_linorder,linorder_topology}" - shows "convergent X \ limsup X = liminf X" - using tendsto_iff_Liminf_eq_Limsup[of sequentially] - by (auto simp: convergent_def) - -lemma limsup_le_liminf_real: - fixes X :: "nat \ real" and L :: real - assumes 1: "limsup X \ L" and 2: "L \ liminf X" - shows "X ----> L" -proof - - from 1 2 have "limsup X \ liminf X" by auto - hence 3: "limsup X = liminf X" - apply (subst eq_iff, rule conjI) - by (rule Liminf_le_Limsup, auto) - hence 4: "convergent (\n. ereal (X n))" - by (subst convergent_ereal) - hence "limsup X = lim (\n. ereal(X n))" - by (rule convergent_limsup_cl) - also from 1 2 3 have "limsup X = L" by auto - finally have "lim (\n. ereal(X n)) = L" .. - hence "(\n. ereal (X n)) ----> L" - apply (elim subst) - by (subst convergent_LIMSEQ_iff [symmetric], rule 4) - thus ?thesis by simp -qed - -lemma liminf_PInfty: - fixes X :: "nat \ ereal" - shows "X ----> \ \ liminf X = \" - by (metis Liminf_PInfty trivial_limit_sequentially) - -lemma limsup_MInfty: - fixes X :: "nat \ ereal" - shows "X ----> -\ \ limsup X = -\" - by (metis Limsup_MInfty trivial_limit_sequentially) - -lemma ereal_lim_mono: - fixes X Y :: "nat \ 'a::linorder_topology" - assumes "\n. N \ n \ X n \ Y n" - and "X ----> x" - and "Y ----> y" - shows "x \ y" - using assms(1) by (intro LIMSEQ_le[OF assms(2,3)]) auto - -lemma incseq_le_ereal: - fixes X :: "nat \ 'a::linorder_topology" - assumes inc: "incseq X" - and lim: "X ----> L" - shows "X N \ L" - using inc - by (intro ereal_lim_mono[of N, OF _ tendsto_const lim]) (simp add: incseq_def) - -lemma decseq_ge_ereal: - assumes dec: "decseq X" - and lim: "X ----> (L::'a::linorder_topology)" - shows "X N \ L" - using dec by (intro ereal_lim_mono[of N, OF _ lim tendsto_const]) (simp add: decseq_def) - -lemma bounded_abs: - fixes a :: real - assumes "a \ x" - and "x \ b" - shows "abs x \ max (abs a) (abs b)" - by (metis abs_less_iff assms leI le_max_iff_disj - less_eq_real_def less_le_not_le less_minus_iff minus_minus) - -lemma ereal_Sup_lim: - fixes a :: "'a::{complete_linorder,linorder_topology}" - assumes "\n. b n \ s" - and "b ----> a" - shows "a \ Sup s" - by (metis Lim_bounded_ereal assms complete_lattice_class.Sup_upper) - -lemma ereal_Inf_lim: - fixes a :: "'a::{complete_linorder,linorder_topology}" - assumes "\n. b n \ s" - and "b ----> a" - shows "Inf s \ a" - by (metis Lim_bounded2_ereal assms complete_lattice_class.Inf_lower) - -lemma SUP_Lim_ereal: - fixes X :: "nat \ 'a::{complete_linorder,linorder_topology}" - assumes inc: "incseq X" - and l: "X ----> l" - shows "(SUP n. X n) = l" - using LIMSEQ_SUP[OF inc] tendsto_unique[OF trivial_limit_sequentially l] - by simp - -lemma INF_Lim_ereal: - fixes X :: "nat \ 'a::{complete_linorder,linorder_topology}" - assumes dec: "decseq X" - and l: "X ----> l" - shows "(INF n. X n) = l" - using LIMSEQ_INF[OF dec] tendsto_unique[OF trivial_limit_sequentially l] - by simp - -lemma SUP_eq_LIMSEQ: - assumes "mono f" - shows "(SUP n. ereal (f n)) = ereal x \ f ----> x" -proof - have inc: "incseq (\i. ereal (f i))" - using \mono f\ unfolding mono_def incseq_def by auto - { - assume "f ----> x" - then have "(\i. ereal (f i)) ----> ereal x" - by auto - from SUP_Lim_ereal[OF inc this] show "(SUP n. ereal (f n)) = ereal x" . - next - assume "(SUP n. ereal (f n)) = ereal x" - with LIMSEQ_SUP[OF inc] show "f ----> x" by auto - } -qed - -lemma liminf_ereal_cminus: - fixes f :: "nat \ ereal" - assumes "c \ -\" - shows "liminf (\x. c - f x) = c - limsup f" -proof (cases c) - case PInf - then show ?thesis - by (simp add: Liminf_const) -next - case (real r) - then show ?thesis - unfolding liminf_SUP_INF limsup_INF_SUP - apply (subst INF_ereal_minus_right) - apply auto - apply (subst SUP_ereal_minus_right) - apply auto - done -qed (insert \c \ -\\, simp) - - -subsubsection \Continuity\ - -lemma continuous_at_of_ereal: - fixes x0 :: ereal - assumes "\x0\ \ \" - shows "continuous (at x0) real" -proof - - { - fix T - assume T: "open T" "real x0 \ T" - def S \ "ereal ` T" - then have "ereal (real x0) \ S" - using T by auto - then have "x0 \ S" - using assms ereal_real by auto - moreover have "open S" - using open_ereal S_def T by auto - moreover have "\y\S. real y \ T" - using S_def T by auto - ultimately have "\S. x0 \ S \ open S \ (\y\S. real y \ T)" - by auto - } - then show ?thesis - unfolding continuous_at_open by blast -qed - -lemma nhds_ereal: "nhds (ereal r) = filtermap ereal (nhds r)" - by (simp add: filtermap_nhds_open_map open_ereal continuous_at_of_ereal) - -lemma at_ereal: "at (ereal r) = filtermap ereal (at r)" - by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) - -lemma at_left_ereal: "at_left (ereal r) = filtermap ereal (at_left r)" - by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) - -lemma at_right_ereal: "at_right (ereal r) = filtermap ereal (at_right r)" - by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) - -lemma - shows at_left_PInf: "at_left \ = filtermap ereal at_top" - and at_right_MInf: "at_right (-\) = filtermap ereal at_bot" - unfolding filter_eq_iff eventually_filtermap eventually_at_top_dense eventually_at_bot_dense - eventually_at_left[OF ereal_less(5)] eventually_at_right[OF ereal_less(6)] - by (auto simp add: ereal_all_split ereal_ex_split) - -lemma ereal_tendsto_simps1: - "((f \ real) ---> y) (at_left (ereal x)) \ (f ---> y) (at_left x)" - "((f \ real) ---> y) (at_right (ereal x)) \ (f ---> y) (at_right x)" - "((f \ real) ---> y) (at_left (\::ereal)) \ (f ---> y) at_top" - "((f \ real) ---> y) (at_right (-\::ereal)) \ (f ---> y) at_bot" - unfolding tendsto_compose_filtermap at_left_ereal at_right_ereal at_left_PInf at_right_MInf - by (auto simp: filtermap_filtermap filtermap_ident) - -lemma ereal_tendsto_simps2: - "((ereal \ f) ---> ereal a) F \ (f ---> a) F" - "((ereal \ f) ---> \) F \ (LIM x F. f x :> at_top)" - "((ereal \ f) ---> -\) F \ (LIM x F. f x :> at_bot)" - unfolding tendsto_PInfty filterlim_at_top_dense tendsto_MInfty filterlim_at_bot_dense - using lim_ereal by (simp_all add: comp_def) - -lemmas ereal_tendsto_simps = ereal_tendsto_simps1 ereal_tendsto_simps2 - -lemma continuous_at_iff_ereal: - fixes f :: "'a::t2_space \ real" - shows "continuous (at x0 within s) f \ continuous (at x0 within s) (ereal \ f)" - unfolding continuous_within comp_def lim_ereal .. - -lemma continuous_on_iff_ereal: - fixes f :: "'a::t2_space => real" - assumes "open A" - shows "continuous_on A f \ continuous_on A (ereal \ f)" - unfolding continuous_on_def comp_def lim_ereal .. - -lemma continuous_on_real: "continuous_on (UNIV - {\, -\::ereal}) real" - using continuous_at_of_ereal continuous_on_eq_continuous_at open_image_ereal - by auto - -lemma continuous_on_iff_real: - fixes f :: "'a::t2_space \ ereal" - assumes *: "\x. x \ A \ \f x\ \ \" - shows "continuous_on A f \ continuous_on A (real \ f)" -proof - - have "f ` A \ UNIV - {\, -\}" - using assms by force - then have *: "continuous_on (f ` A) real" - using continuous_on_real by (simp add: continuous_on_subset) - have **: "continuous_on ((real \ f) ` A) ereal" - using continuous_on_ereal continuous_on_subset[of "UNIV" "ereal" "(real \ f) ` A"] - by blast - { - assume "continuous_on A f" - then have "continuous_on A (real \ f)" - apply (subst continuous_on_compose) - using * - apply auto - done - } - moreover - { - assume "continuous_on A (real \ f)" - then have "continuous_on A (ereal \ (real \ f))" - apply (subst continuous_on_compose) - using ** - apply auto - done - then have "continuous_on A f" - apply (subst continuous_on_eq[of A "ereal \ (real \ f)" f]) - using assms ereal_real - apply auto - done - } - ultimately show ?thesis - by auto -qed - -lemma continuous_at_const: - fixes f :: "'a::t2_space \ ereal" - assumes "\x. f x = C" - shows "\x. continuous (at x) f" - unfolding continuous_at_open - using assms t1_space - by auto - lemma mono_closed_real: fixes S :: "real set" assumes mono: "\y z. y \ S \ y \ z \ z \ S" @@ -675,313 +250,6 @@ using mono_closed_real[of S] assms by auto qed - -subsection \Sums\ - -lemma sums_ereal_positive: - fixes f :: "nat \ ereal" - assumes "\i. 0 \ f i" - shows "f sums (SUP n. \ii. \j=0.. ereal" - assumes "\i. 0 \ f i" - shows "summable f" - using sums_ereal_positive[of f, OF assms] - unfolding summable_def - by auto - -lemma suminf_ereal_eq_SUP: - fixes f :: "nat \ ereal" - assumes "\i. 0 \ f i" - shows "(\x. f x) = (SUP n. \ix. ereal (f x)) sums ereal x \ f sums x" - unfolding sums_def by simp - -lemma suminf_bound: - fixes f :: "nat \ ereal" - assumes "\N. (\n x" - and pos: "\n. 0 \ f n" - shows "suminf f \ x" -proof (rule Lim_bounded_ereal) - have "summable f" using pos[THEN summable_ereal_pos] . - then show "(\N. \n suminf f" - by (auto dest!: summable_sums simp: sums_def atLeast0LessThan) - show "\n\0. setsum f {.. x" - using assms by auto -qed - -lemma suminf_bound_add: - fixes f :: "nat \ ereal" - assumes "\N. (\n x" - and pos: "\n. 0 \ f n" - and "y \ -\" - shows "suminf f + y \ x" -proof (cases y) - case (real r) - then have "\N. (\n x - y" - using assms by (simp add: ereal_le_minus) - then have "(\ n. f n) \ x - y" - using pos by (rule suminf_bound) - then show "(\ n. f n) + y \ x" - using assms real by (simp add: ereal_le_minus) -qed (insert assms, auto) - -lemma suminf_upper: - fixes f :: "nat \ ereal" - assumes "\n. 0 \ f n" - shows "(\n (\n. f n)" - unfolding suminf_ereal_eq_SUP [OF assms] - by (auto intro: complete_lattice_class.SUP_upper) - -lemma suminf_0_le: - fixes f :: "nat \ ereal" - assumes "\n. 0 \ f n" - shows "0 \ (\n. f n)" - using suminf_upper[of f 0, OF assms] - by simp - -lemma suminf_le_pos: - fixes f g :: "nat \ ereal" - assumes "\N. f N \ g N" - and "\N. 0 \ f N" - shows "suminf f \ suminf g" -proof (safe intro!: suminf_bound) - fix n - { - fix N - have "0 \ g N" - using assms(2,1)[of N] by auto - } - have "setsum f {.. setsum g {.. \ suminf g" - using \\N. 0 \ g N\ - by (rule suminf_upper) - finally show "setsum f {.. suminf g" . -qed (rule assms(2)) - -lemma suminf_half_series_ereal: "(\n. (1/2 :: ereal) ^ Suc n) = 1" - using sums_ereal[THEN iffD2, OF power_half_series, THEN sums_unique, symmetric] - by (simp add: one_ereal_def) - -lemma suminf_add_ereal: - fixes f g :: "nat \ ereal" - assumes "\i. 0 \ f i" - and "\i. 0 \ g i" - shows "(\i. f i + g i) = suminf f + suminf g" - apply (subst (1 2 3) suminf_ereal_eq_SUP) - unfolding setsum.distrib - apply (intro assms ereal_add_nonneg_nonneg SUP_ereal_add_pos incseq_setsumI setsum_nonneg ballI)+ - done - -lemma suminf_cmult_ereal: - fixes f g :: "nat \ ereal" - assumes "\i. 0 \ f i" - and "0 \ a" - shows "(\i. a * f i) = a * suminf f" - by (auto simp: setsum_ereal_right_distrib[symmetric] assms - ereal_zero_le_0_iff setsum_nonneg suminf_ereal_eq_SUP - intro!: SUP_ereal_mult_left) - -lemma suminf_PInfty: - fixes f :: "nat \ ereal" - assumes "\i. 0 \ f i" - and "suminf f \ \" - shows "f i \ \" -proof - - from suminf_upper[of f "Suc i", OF assms(1)] assms(2) - have "(\i \" - by auto - then show ?thesis - unfolding setsum_Pinfty by simp -qed - -lemma suminf_PInfty_fun: - assumes "\i. 0 \ f i" - and "suminf f \ \" - shows "\f'. f = (\x. ereal (f' x))" -proof - - have "\i. \r. f i = ereal r" - proof - fix i - show "\r. f i = ereal r" - using suminf_PInfty[OF assms] assms(1)[of i] - by (cases "f i") auto - qed - from choice[OF this] show ?thesis - by auto -qed - -lemma summable_ereal: - assumes "\i. 0 \ f i" - and "(\i. ereal (f i)) \ \" - shows "summable f" -proof - - have "0 \ (\i. ereal (f i))" - using assms by (intro suminf_0_le) auto - with assms obtain r where r: "(\i. ereal (f i)) = ereal r" - by (cases "\i. ereal (f i)") auto - from summable_ereal_pos[of "\x. ereal (f x)"] - have "summable (\x. ereal (f x))" - using assms by auto - from summable_sums[OF this] - have "(\x. ereal (f x)) sums (\x. ereal (f x))" - by auto - then show "summable f" - unfolding r sums_ereal summable_def .. -qed - -lemma suminf_ereal: - assumes "\i. 0 \ f i" - and "(\i. ereal (f i)) \ \" - shows "(\i. ereal (f i)) = ereal (suminf f)" -proof (rule sums_unique[symmetric]) - from summable_ereal[OF assms] - show "(\x. ereal (f x)) sums (ereal (suminf f))" - unfolding sums_ereal - using assms - by (intro summable_sums summable_ereal) -qed - -lemma suminf_ereal_minus: - fixes f g :: "nat \ ereal" - assumes ord: "\i. g i \ f i" "\i. 0 \ g i" - and fin: "suminf f \ \" "suminf g \ \" - shows "(\i. f i - g i) = suminf f - suminf g" -proof - - { - fix i - have "0 \ f i" - using ord[of i] by auto - } - moreover - from suminf_PInfty_fun[OF \\i. 0 \ f i\ fin(1)] obtain f' where [simp]: "f = (\x. ereal (f' x))" .. - from suminf_PInfty_fun[OF \\i. 0 \ g i\ fin(2)] obtain g' where [simp]: "g = (\x. ereal (g' x))" .. - { - fix i - have "0 \ f i - g i" - using ord[of i] by (auto simp: ereal_le_minus_iff) - } - moreover - have "suminf (\i. f i - g i) \ suminf f" - using assms by (auto intro!: suminf_le_pos simp: field_simps) - then have "suminf (\i. f i - g i) \ \" - using fin by auto - ultimately show ?thesis - using assms \\i. 0 \ f i\ - apply simp - apply (subst (1 2 3) suminf_ereal) - apply (auto intro!: suminf_diff[symmetric] summable_ereal) - done -qed - -lemma suminf_ereal_PInf [simp]: "(\x. \::ereal) = \" -proof - - have "(\i) \ (\x. \::ereal)" - by (rule suminf_upper) auto - then show ?thesis - by simp -qed - -lemma summable_real_of_ereal: - fixes f :: "nat \ ereal" - assumes f: "\i. 0 \ f i" - and fin: "(\i. f i) \ \" - shows "summable (\i. real (f i))" -proof (rule summable_def[THEN iffD2]) - have "0 \ (\i. f i)" - using assms by (auto intro: suminf_0_le) - with fin obtain r where r: "ereal r = (\i. f i)" - by (cases "(\i. f i)") auto - { - fix i - have "f i \ \" - using f by (intro suminf_PInfty[OF _ fin]) auto - then have "\f i\ \ \" - using f[of i] by auto - } - note fin = this - have "(\i. ereal (real (f i))) sums (\i. ereal (real (f i)))" - using f - by (auto intro!: summable_ereal_pos simp: ereal_le_real_iff zero_ereal_def) - also have "\ = ereal r" - using fin r by (auto simp: ereal_real) - finally show "\r. (\i. real (f i)) sums r" - by (auto simp: sums_ereal) -qed - -lemma suminf_SUP_eq: - fixes f :: "nat \ nat \ ereal" - assumes "\i. incseq (\n. f n i)" - and "\n i. 0 \ f n i" - shows "(\i. SUP n. f n i) = (SUP n. \i. f n i)" -proof - - { - fix n :: nat - have "(\ii _ \ ereal" - assumes nonneg: "\i a. a \ A \ 0 \ f i a" - shows "(\i. \a\A. f i a) = (\a\A. \i. f i a)" -proof (cases "finite A") - case True - then show ?thesis - using nonneg - by induct (simp_all add: suminf_add_ereal setsum_nonneg) -next - case False - then show ?thesis by simp -qed - -lemma suminf_ereal_eq_0: - fixes f :: "nat \ ereal" - assumes nneg: "\i. 0 \ f i" - shows "(\i. f i) = 0 \ (\i. f i = 0)" -proof - assume "(\i. f i) = 0" - { - fix i - assume "f i \ 0" - with nneg have "0 < f i" - by (auto simp: less_le) - also have "f i = (\j. if j = i then f i else 0)" - by (subst suminf_finite[where N="{i}"]) auto - also have "\ \ (\i. f i)" - using nneg - by (auto intro!: suminf_le_pos) - finally have False - using \(\i. f i) = 0\ by auto - } - then show "\i. f i = 0" - by auto -qed simp - lemma Liminf_within: fixes f :: "'a::metric_space \ 'b::complete_lattice" shows "Liminf (at x within S) f = (SUP e:{0<..}. INF y:(S \ ball x e - {x}). f y)" @@ -1045,50 +313,6 @@ apply (metis INF_absorb centre_in_ball) done - -lemma suminf_ereal_offset_le: - fixes f :: "nat \ ereal" - assumes f: "\i. 0 \ f i" - shows "(\i. f (i + k)) \ suminf f" -proof - - have "(\n. \i (\i. f (i + k))" - using summable_sums[OF summable_ereal_pos] by (simp add: sums_def atLeast0LessThan f) - moreover have "(\n. \i (\i. f i)" - using summable_sums[OF summable_ereal_pos] by (simp add: sums_def atLeast0LessThan f) - then have "(\n. \i (\i. f i)" - by (rule LIMSEQ_ignore_initial_segment) - ultimately show ?thesis - proof (rule LIMSEQ_le, safe intro!: exI[of _ k]) - fix n assume "k \ n" - have "(\ii (\i. i + k)) i)" - by simp - also have "\ = (\i\(\i. i + k) ` {.. \ setsum f {..i setsum f {.. (\i. ereal (f i)) = ereal x" - by (metis sums_ereal sums_unique) - -lemma suminf_ereal': "summable f \ (\i. ereal (f i)) = ereal (\i. f i)" - by (metis sums_ereal sums_unique summable_def) - -lemma suminf_ereal_finite: "summable f \ (\i. ereal (f i)) \ \" - by (auto simp: sums_ereal[symmetric] summable_def sums_unique[symmetric]) - -lemma suminf_ereal_finite_neg: - assumes "summable f" - shows "(\x. ereal (f x)) \ -\" -proof- - from assms obtain x where "f sums x" by blast - hence "(\x. ereal (f x)) sums ereal x" by (simp add: sums_ereal) - from sums_unique[OF this] have "(\x. ereal (f x)) = ereal x" .. - thus "(\x. ereal (f x)) \ -\" by simp_all -qed - subsection \monoset\ definition (in order) mono_set: @@ -1281,5 +505,4 @@ lemma indicator_inter_arith_ereal: "indicator A x * indicator B x = (indicator (A \ B) x :: ereal)" by (simp split: split_indicator) - end diff -r 240563fbf41d -r 8558e4a37b48 src/HOL/Probability/Borel_Space.thy --- a/src/HOL/Probability/Borel_Space.thy Thu Jul 23 14:25:05 2015 +0200 +++ b/src/HOL/Probability/Borel_Space.thy Thu Jul 23 16:39:10 2015 +0200 @@ -1111,7 +1111,7 @@ lemma borel_measurable_ereal[measurable (raw)]: assumes f: "f \ borel_measurable M" shows "(\x. ereal (f x)) \ borel_measurable M" - using continuous_on_ereal f by (rule borel_measurable_continuous_on) + using continuous_on_ereal f by (rule borel_measurable_continuous_on) (rule continuous_on_id) lemma borel_measurable_real_of_ereal[measurable (raw)]: fixes f :: "'a \ ereal"