theory Extended_Real imports Complex_Main Extended_Nat Liminf_Limsup begin
text‹
This should be part of 🍋‹HOL-Library.Extended_Nat› or 🍋‹HOL-Library.Order_Continuity›, but then the AFP-entry ‹Jinja_Thread› fails, as it does overload
certain named from 🍋‹Complex_Main›. ›
lemma incseq_sumI2: fixes f :: "'i ==> nat ==> 'a::ordered_comm_monoid_add" shows"(∧n. n ∈ A ==> mono (f n)) ==> mono (λi. ∑n∈A. f n i)" unfolding incseq_def by (auto intro: sum_mono)
lemma incseq_sumI: fixes f :: "nat ==> 'a::ordered_comm_monoid_add" assumes"∧i. 0 ≤ f i" shows"incseq (λi. sum f {..< i})" proof (intro incseq_SucI) fix n have"sum f {..< n} + 0 ≤ sum f {..<n} + f n" using assms by (rule add_left_mono) thenshow"sum f {..< n} ≤ sum f {..< Suc n}" by auto qed
lemma continuous_at_left_imp_sup_continuous: fixes f :: "'a::{complete_linorder, linorder_topology} ==> 'b::{complete_linorder, linorder_topology}" assumes"mono f""∧x. continuous (at_left x) f" shows"sup_continuous f" unfolding sup_continuous_def proof safe fix M :: "nat ==> 'a"assume"incseq M"thenshow"f (SUP i. M i) = (SUP i. f (M i))" using continuous_at_Sup_mono [OF assms, of "range M"] by (simp add: image_comp) qed
lemma sup_continuous_at_left: fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} ==> 'b::{complete_linorder, linorder_topology}" assumes f: "sup_continuous f" shows"continuous (at_left x) f" proof cases assume"x = bot"thenshow ?thesis by (simp add: trivial_limit_at_left_bot) next assume x: "x ≠ bot" show ?thesis unfolding continuous_within proof (intro tendsto_at_left_sequentially[of bot]) fix S :: "nat ==> 'a"assume S: "incseq S"and S_x: "S <---- x" from S_x have x_eq: "x = (SUP i. S i)" by (rule LIMSEQ_unique) (intro LIMSEQ_SUP S) show"(λn. f (S n)) <---- f x" unfolding x_eq sup_continuousD[OF f S] using S sup_continuous_mono[OF f] by (intro LIMSEQ_SUP) (auto simp: mono_def) qed (insert x, auto simp: bot_less) qed
lemma sup_continuous_iff_at_left: fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} ==> 'b::{complete_linorder, linorder_topology}" shows"sup_continuous f ⟷ (∀x. continuous (at_left x) f) ∧ mono f" using continuous_at_left_imp_sup_continuous sup_continuous_at_left sup_continuous_mono by blast
lemma continuous_at_right_imp_inf_continuous: fixes f :: "'a::{complete_linorder, linorder_topology} ==> 'b::{complete_linorder, linorder_topology}" assumes"mono f""∧x. continuous (at_right x) f" shows"inf_continuous f" unfolding inf_continuous_def proof safe fix M :: "nat ==> 'a" assume"decseq M" thenshow"f (INF i. M i) = (INF i. f (M i))" using continuous_at_Inf_mono [OF assms, of "range M"] by (simp add: image_comp) qed
lemma inf_continuous_at_right: fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} ==> 'b::{complete_linorder, linorder_topology}" assumes f: "inf_continuous f" shows"continuous (at_right x) f" proof cases assume"x = top"thenshow ?thesis by (simp add: trivial_limit_at_right_top) next assume x: "x ≠ top" show ?thesis unfolding continuous_within proof (intro tendsto_at_right_sequentially[of _ top]) fix S :: "nat ==> 'a" assume S: "decseq S"and S_x: "S <---- x" thenhave x_eq: "x = (INF i. S i)" using INF_Lim by blast show"(λn. f (S n)) <---- f x" unfolding x_eq inf_continuousD[OF f S] using S inf_continuous_mono[OF f] by (intro LIMSEQ_INF) (auto simp: mono_def antimono_def) qed (insert x, auto simp: less_top) qed
lemma inf_continuous_iff_at_right: fixes f :: "'a::{complete_linorder, linorder_topology, first_countable_topology} ==> 'b::{complete_linorder, linorder_topology}" shows"inf_continuous f ⟷ (∀x. continuous (at_right x) f) ∧ mono f" using continuous_at_right_imp_inf_continuous inf_continuous_at_right inf_continuous_mono by blast
instantiation enat :: linorder_topology begin
definition open_enat :: "enat set ==> bool"where "open_enat = generate_topology (range lessThan ∪ range greaterThan)"
instance proofqed (rule open_enat_def)
end
lemma open_enat: "open {enat n}" proof (cases n) case0 thenhave"{enat n} = {..< eSuc 0}" by (auto simp: enat_0) thenshow ?thesis by simp next case (Suc n') thenhave"{enat n} = {enat n' <..< enat (Suc n)}" using enat_iless by (fastforce simp: set_eq_iff) thenshow ?thesis by simp qed
lemma open_enat_iff: fixes A :: "enat set" shows"open A ⟷ (∞∈ A ⟶ (∃n::nat. {n <..} ⊆ A))" proof safe assume"∞∉ A" thenhave"A = (∪n∈{n. enat n ∈ A}. {enat n})" by (simp add: set_eq_iff) (metis not_enat_eq) moreoverhave"open …" by (auto intro: open_enat) ultimatelyshow"open A" by simp next fix n assume"{enat n <..} ⊆ A" thenhave"A = (∪n∈{n. enat n ∈ A}. {enat n}) ∪ {enat n <..}" using enat_ile leI by (simp add: set_eq_iff) blast moreoverhave"open …" by (intro open_Un open_UN ballI open_enat open_greaterThan) ultimatelyshow"open A" by simp next assume"open A""∞∈ A" thenhave"generate_topology (range lessThan ∪ range greaterThan) A""∞∈ A" unfolding open_enat_def by auto thenshow"∃n::nat. {n <..} ⊆ A" proofinduction case (Int A B) thenobtain n m where"{enat n<..} ⊆ A""{enat m<..} ⊆ B" by auto thenhave"{enat (max n m) <..} ⊆ A ∩ B" by (auto simp: subset_eq Ball_def max_def simp flip: enat_ord_code(1)) thenshow ?case by auto next case (UN K) thenobtain k where"k ∈ K""∞∈ k" by auto with UN.IH[OF this] show ?case by auto qed auto qed
lemma nhds_enat: "nhds x = (if x = ∞ then INF i. principal {enat i..} else principal {x})" proof auto show"nhds ∞ = (INF i. principal {enat i..})" proof (rule antisym) show"nhds ∞≤ (INF i. principal {enat i..})" unfolding nhds_def using Ioi_le_Ico by (intro INF_greatest INF_lower) (auto simp: open_enat_iff) show"(INF i. principal {enat i..}) ≤ nhds ∞" unfolding nhds_def by (intro INF_greatest) (force intro: INF_lower2[of "Suc _"] simp add: open_enat_iff Suc_ile_eq) qed show"nhds (enat i) = principal {enat i}"for i by (simp add: nhds_discrete_open open_enat) qed
instance enat :: topological_comm_monoid_add proof have [simp]: "enat i ≤ aa ==> enat i ≤ aa + ba"for aa ba i by (rule order_trans[OF _ add_mono[of aa aa 0 ba]]) auto thenhave [simp]: "enat i ≤ ba ==> enat i ≤ aa + ba"for aa ba i by (metis add.commute) fix a b :: enat have"∀F x in INF m n. principal ({enat n..} × {enat m..}). enat i ≤ fst x + snd x" "∀F x in INF n. principal ({enat n..} × {enat j}). enat i ≤ fst x + snd x" "∀F x in INF n. principal ({enat j} × {enat n..}). enat i ≤ fst x + snd x" for i j by (auto intro!: eventually_INF1[of i] simp: eventually_principal) thenshow"((λx. fst x + snd x) ---> a + b) (nhds a ×F nhds b)" by (auto simp: nhds_enat filterlim_INF prod_filter_INF1 prod_filter_INF2
filterlim_principal principal_prod_principal eventually_principal) qed
text‹
For more lemmas about the extended real numbers see 🍋‹~~/src/HOL/Analysis/Extended_Real_Limits.thy›. ›
subsection‹Definition and basic properties›
datatype ereal = ereal real | PInfty | MInfty
instantiation ereal :: uminus begin
fun uminus_ereal where "- (ereal r) = ereal (- r)"
| "- PInfty = MInfty"
| "- MInfty = PInfty"
instance ..
end
instantiation ereal :: infinity begin
definition"(∞::ereal) = PInfty" instance ..
end
declare [[coercion "ereal :: real ==> ereal"]]
lemma ereal_uminus_uminus[simp]: fixes a :: ereal shows"- (- a) = a" by (cases a) simp_all
lemma shows PInfty_eq_infinity[simp]: "PInfty = ∞" and MInfty_eq_minfinity[simp]: "MInfty = -∞" and MInfty_neq_PInfty[simp]: "∞≠ - (∞::ereal)""-∞≠ (∞::ereal)" and MInfty_neq_ereal[simp]: "ereal r ≠ -∞""-∞≠ ereal r" and PInfty_neq_ereal[simp]: "ereal r ≠∞""∞≠ ereal r" and PInfty_cases[simp]: "(case ∞ of ereal r ==> f r | PInfty ==> y | MInfty ==> z) = y" and MInfty_cases[simp]: "(case -∞ of ereal r ==> f r | PInfty ==> y | MInfty ==> z) = z" by (simp_all add: infinity_ereal_def)
lemma ereal_all_split: "∧P. (∀x::ereal. P x) ⟷ P ∞∧ (∀x. P (ereal x)) ∧ P (-∞)" by (metis ereal_cases)
lemma ereal_ex_split: "∧P. (∃x::ereal. P x) ⟷ P ∞∨ (∃x. P (ereal x)) ∨ P (-∞)" by (metis ereal_cases)
lemma ereal_uminus_eq_iff[simp]: fixes a b :: ereal shows"-a = -b ⟷ a = b" by (cases rule: ereal2_cases[of a b]) simp_all
function real_of_ereal :: "ereal ==> real"where "real_of_ereal (ereal r) = r"
| "real_of_ereal ∞ = 0"
| "real_of_ereal (-∞) = 0" by (auto intro: ereal_cases) terminationby standard (rule wf_on_bot)
lemma real_of_ereal[simp]: "real_of_ereal (- x :: ereal) = - (real_of_ereal x)" by (cases x) simp_all
lemma range_ereal[simp]: "range ereal = UNIV - {∞, -∞}" proof safe fix x assume"x ∉ range ereal""x ≠∞" thenshow"x = -∞" by (cases x) auto qed auto
lemma ereal_range_uminus[simp]: "range uminus = (UNIV::ereal set)" proof safe fix x :: ereal show"x ∈ range uminus" by (intro image_eqI[of _ _ "-x"]) auto qed auto
instantiation ereal :: abs begin
function abs_ereal where "∣ereal r∣ = ereal ∣r∣"
| "∣-∞∣ = (∞::ereal)"
| "∣∞∣ = (∞::ereal)" by (auto intro: ereal_cases) terminationproofqed (rule wf_on_bot)
instance ..
end
lemma abs_eq_infinity_cases[elim!]: fixes x :: ereal assumes"∣x∣ = ∞" obtains"x = ∞" | "x = -∞" using assms by (cases x) auto
lemma abs_neq_infinity_cases[elim!]: fixes x :: ereal assumes"∣x∣≠∞" obtains r where"x = ereal r" using assms by (cases x) auto
lemma abs_ereal_uminus[simp]: fixes x :: ereal shows"∣- x∣ = ∣x∣" by (cases x) auto
lemma ereal_infinity_cases: fixes a :: ereal shows"a ≠∞==> a ≠ -∞==>∣a∣≠∞" by auto
subsubsection"Addition"
instantiation ereal :: "{one,comm_monoid_add,zero_neq_one}" begin
definition"0 = ereal 0" definition"1 = ereal 1"
function plus_ereal where "ereal r + ereal p = ereal (r + p)"
| "∞ + a = (∞::ereal)"
| "a + ∞ = (∞::ereal)"
| "ereal r + -∞ = -∞"
| "-∞ + ereal p = -(∞::ereal)"
| "-∞ + -∞ = -(∞::ereal)" proof goal_cases case prems: (1 P x) thenobtain a b where"x = (a, b)" by (cases x) auto with prems show P by (cases rule: ereal2_cases[of a b]) auto qed auto terminationby standard (rule wf_on_bot)
lemma ereal_eq_0[simp]: "ereal r = 0 ⟷ r = 0" "0 = ereal r ⟷ r = 0" unfolding zero_ereal_def by simp_all
lemma ereal_eq_1[simp]: "ereal r = 1 ⟷ r = 1" "1 = ereal r ⟷ r = 1" unfolding one_ereal_def by simp_all
instance proof fix a b c :: ereal show"0 + a = a" by (cases a) (simp_all add: zero_ereal_def) show"a + b = b + a" by (cases rule: ereal2_cases[of a b]) simp_all show"a + b + c = a + (b + c)" by (cases rule: ereal3_cases[of a b c]) simp_all show"0 ≠ (1::ereal)" by (simp add: one_ereal_def zero_ereal_def) qed
lemma real_of_ereal_0[simp]: "real_of_ereal (0::ereal) = 0" unfolding zero_ereal_def by simp
lemma abs_ereal_zero[simp]: "∣0∣ = (0::ereal)" unfolding zero_ereal_def abs_ereal.simps by simp
lemma ereal_uminus_zero[simp]: "- 0 = (0::ereal)" by (simp add: zero_ereal_def)
lemma ereal_uminus_zero_iff[simp]: fixes a :: ereal shows"-a = 0 ⟷ a = 0" by (cases a) simp_all
lemma ereal_plus_eq_PInfty[simp]: fixes a b :: ereal shows"a + b = ∞⟷ a = ∞∨ b = ∞" by (cases rule: ereal2_cases[of a b]) auto
lemma ereal_plus_eq_MInfty[simp]: fixes a b :: ereal shows"a + b = -∞⟷ (a = -∞∨ b = -∞) ∧ a ≠∞∧ b ≠∞" by (cases rule: ereal2_cases[of a b]) auto
lemma ereal_add_cancel_left: fixes a b :: ereal assumes"a ≠ -∞" shows"a + b = a + c ⟷ a = ∞∨ b = c" using assms by (cases rule: ereal3_cases[of a b c]) auto
lemma ereal_add_cancel_right: fixes a b :: ereal assumes"a ≠ -∞" shows"b + a = c + a ⟷ a = ∞∨ b = c" using assms by (cases rule: ereal3_cases[of a b c]) auto
lemma ereal_real: "ereal (real_of_ereal x) = (if ∣x∣ = ∞ then 0 else x)" by auto
lemma real_of_ereal_add: fixes a b :: ereal shows"real_of_ereal (a + b) = (if (∣a∣ = ∞) ∧ (∣b∣ = ∞) ∨ (∣a∣≠∞) ∧ (∣b∣≠∞) then real_of_ereal a + real_of_ereal b else 0)" by auto
subsubsection"Linear order on 🍋‹ereal›"
instantiation ereal :: linorder begin
function less_ereal where " ereal x < ereal y ⟷ x < y" | "(∞::ereal) < a ⟷ False" | " a < -(∞::ereal) ⟷ False" | "ereal x < ∞⟷ True" | " -∞ < ereal r ⟷ True" | " -∞ < (∞::ereal) ⟷ True" proof goal_cases case prems: (1 P x) then obtain a b where "x = (a,b)" by (cases x) auto with prems show P by (cases rule: ereal2_cases[of a b]) auto qed simp_all termination by (relation "{}") simp
definition "x ≤ (y::ereal) ⟷ x < y ∨ x = y"
lemma ereal_infty_less[simp]: fixes x :: ereal shows "x < ∞⟷ (x ≠∞)" "-∞ < x ⟷ (x ≠ -∞)" by (cases x, simp_all)+
lemma ereal_infty_less_eq[simp]: fixes x :: ereal shows "∞≤ x ⟷ x = ∞" and "x ≤ -∞⟷ x = -∞" by (auto simp: less_eq_ereal_def)
lemma ereal_less[simp]: "ereal r < 0⟷ (r < 0)" "0 < ereal r ⟷ (0 < r)" "ereal r < 1⟷ (r < 1)" "1 < ereal r ⟷ (1 < r)" "0 < (∞::ereal)" "-(∞::ereal) < 0" by (simp_all add: zero_ereal_def one_ereal_def)
lemma ereal_less_eq[simp]: "x ≤ (∞::ereal)" "-(∞::ereal) ≤ x" "ereal r ≤ ereal p ⟷ r ≤ p" "ereal r ≤0⟷ r ≤0" "0≤ ereal r ⟷0≤ r" "ereal r ≤1⟷ r ≤1" "1≤ ereal r ⟷1≤ r" by (auto simp: less_eq_ereal_def zero_ereal_def one_ereal_def)
lemma ereal_infty_less_eq2: "a ≤ b ==> a = ∞==> b = (∞::ereal)" "a ≤ b ==> b = -∞==> a = -(∞::ereal)" by simp_all
instance proof fix x y z :: ereal show "x ≤ x" by (cases x) simp_all show "x < y ⟷ x ≤ y ∧¬ y ≤ x" by (cases rule: ereal2_cases[of x y]) auto show "x ≤ y ∨ y ≤ x " by (cases rule: ereal2_cases[of x y]) auto assume "x ≤ y" then show "y ≤ x ==> x = y" by (cases rule: ereal2_cases[of x y]) auto show "y ≤ z ==> x ≤ z" using ‹x ≤ y› by (cases rule: ereal3_cases[of x y z]) auto qed
end
lemma ereal_dense2: "x < y ==>∃z. x < ereal z ∧ ereal z < y" using lt_ex gt_ex dense by (cases x y rule: ereal2_cases) auto
instance ereal :: dense_linorder by standard (blast dest: ereal_dense2)
instance ereal :: ordered_comm_monoid_add proof fix a b c :: ereal assume "a ≤ b" then show "c + a ≤ c + b" by (cases rule: ereal3_cases[of a b c]) auto qed
lemma ereal_one_not_less_zero_ereal[simp]: "¬1 < (0::ereal)" by (simp add: zero_ereal_def)
lemma real_of_ereal_positive_mono: fixes x y :: ereal shows "0≤ x ==> x ≤ y ==> y ≠∞==> real_of_ereal x ≤ real_of_ereal y" by (cases rule: ereal2_cases[of x y]) auto
lemma ereal_MInfty_lessI[intro, simp]: fixes a :: ereal shows "a ≠ -∞==> -∞ < a" by simp
lemma ereal_less_PInfty[intro, simp]: fixes a :: ereal shows "a ≠∞==> a < ∞" by simp
lemma ereal_less_ereal_Ex: fixes a b :: ereal shows "x < ereal r ⟷ x = -∞∨ (∃p. p < r ∧ x = ereal p)" by (cases x) auto
lemma less_PInf_Ex_of_nat: "x ≠∞⟷ (∃n::nat. x < ereal (real n))" proof (cases x) case (real r) then show ?thesis using reals_Archimedean2[of r] by simp qed simp_all
lemma ereal_add_strict_mono2: fixes a b c d :: ereal assumes "a < b" and "c < d" shows "a + c < b + d" using assms by (cases a; force simp: elim: less_ereal.elims)
lemma ereal_minus_le_minus[simp]: fixes a b :: ereal shows "- a ≤ - b ⟷ b ≤ a" by (cases rule: ereal2_cases[of a b]) auto
lemma ereal_minus_less_minus[simp]: fixes a b :: ereal shows "- a < - b ⟷ b < a" by (cases rule: ereal2_cases[of a b]) auto
lemma ereal_le_real_iff: "x ≤ real_of_ereal y ⟷ (∣y∣≠∞⟶ ereal x ≤ y) ∧ (∣y∣ = ∞⟶ x ≤0)" by (cases y) auto
lemma real_le_ereal_iff: "real_of_ereal y ≤ x ⟷ (∣y∣≠∞⟶ y ≤ ereal x) ∧ (∣y∣ = ∞⟶0≤ x)" by (cases y) auto
lemma ereal_less_real_iff: "x < real_of_ereal y ⟷ (∣y∣≠∞⟶ ereal x < y) ∧ (∣y∣ = ∞⟶ x < 0)" by (cases y) auto
lemma real_less_ereal_iff: "real_of_ereal y < x ⟷ (∣y∣≠∞⟶ y < ereal x) ∧ (∣y∣ = ∞⟶0 < x)" by (cases y) auto
text ‹ To help with inferences like prop‹a < ereal x ==> x < y ==> a < ereal y›, where x and y are real. \<close>
lemma le_ereal_le: "≤ ereal x ==> x ≤ y ==> a ≤ ereal y"
using ereal_less_eq(3) order.trans by blast
le_ereal_less: "a ≤ ereal x ==> x < y ==> a < ereal y"
by (simp add: le_less_trans)
less_ereal_le: "a < ereal x ==> x ≤ y ==> a < ereal y"
using ereal_less_ereal_Ex by auto
ereal_le_le: "ereal y ≤ a ==> x ≤ y ==> ereal x ≤ a"
by (simp add: order_subst2)
ereal_le_less: "ereal y ≤ a ==> x < y ==> ereal x < a"
by (simp add: dual_order.strict_trans1)
ereal_less_le: "ereal y < a ==> x ≤ y ==> ereal x < a"
using ereal_less_eq(3) le_less_trans by blast
real_of_ereal_pos:
fixes x :: ereal
shows "0 ≤ x ==> 0 ≤ real_of_ereal x"
by (cases x) auto
abs_ereal_ge0[simp]: "0 ≤ x ==>∣x :: ereal∣ = x"
by (cases x) auto
abs_ereal_less0[simp]: "x < 0 ==>∣x :: ereal∣ = -x"
by (cases x) auto
abs_ereal_pos[simp]: "0 ≤∣x :: ereal∣"
by (cases x) auto
ereal_abs_leI:
fixes x y :: ereal
shows "[ x ≤ y; -x ≤ y ]==>∣x∣≤ y"
by(cases x y rule: ereal2_cases)(simp_all)
ereal_abs_add:
fixes a b::ereal
shows "abs(a+b) ≤ abs a + abs b"
by (cases rule: ereal2_cases[of a b]) (auto)
real_of_ereal_le_0[simp]: "real_of_ereal (x :: ereal) ≤ 0 ⟷ x ≤ 0 ∨ x = ∞"
by (cases x) auto
abs_real_of_ereal[simp]: "∣real_of_ereal (x :: ereal)∣ = real_of_ereal ∣x∣"
by (cases x) auto
zero_less_real_of_ereal:
fixes x :: ereal
shows "0 < real_of_ereal x ⟷ 0 < x ∧ x ≠∞"
by (cases x) auto
ereal_0_le_uminus_iff[simp]:
fixes a :: ereal
shows "0 ≤ - a ⟷ a ≤ 0"
by (cases rule: ereal2_cases[of a]) auto
ereal_uminus_le_0_iff[simp]:
fixes a :: ereal
shows "- a ≤ 0 ⟷ 0 ≤ a"
by (cases rule: ereal2_cases[of a]) auto
ereal_add_strict_mono:
fixes a b c d :: ereal
assumes "a ≤ b"
and "0 ≤ a"
and "a ≠∞"
and "c < d"
shows "a + c < b + d"
using assms
by (cases rule: ereal3_cases[case_product ereal_cases, of a b c d]) auto
ereal_less_add:
fixes a b c :: ereal
shows "∣a∣≠∞==> c < b ==> a + c < a + b"
by (cases rule: ereal2_cases[of b c]) auto
ereal_uminus_eq_reorder: "- a = b ⟷ a = (-b::ereal)"
by auto
ereal_uminus_less_reorder: "- a < b ⟷ -b < a"
and ereal_less_uminus_reorder: "a < - b ⟷ b < - a"
and ereal_uminus_le_reorder: "- a ≤ b ⟷ -b ≤ a" for a::ereal
using ereal_minus_le_minus ereal_minus_less_minus by fastforce+
ereal_bot:
fixes x :: ereal
assumes "∧B. x ≤ ereal B"
shows "x = -∞"
(cases x)
case (real r)
with assms[of "r - 1"] show ?thesis
by auto
case PInf
with assms[of 0] show ?thesis
by auto
case MInf
then show ?thesis
by simp
ereal_top:
fixes x :: ereal
assumes "∧B. x ≥ ereal B"
shows "x = ∞"
(cases x)
case (real r)
with assms[of "r + 1"] show ?thesis
by auto
case MInf
with assms[of 0] show ?thesis
by auto
case PInf
then show ?thesis
by simp
shows ereal_max[simp]: "ereal (max x y) = max (ereal x) (ereal y)"
and ereal_min[simp]: "ereal (min x y) = min (ereal x) (ereal y)"
by (simp_all add: min_def max_def)
fixes f :: "nat ==> ereal"
shows ereal_incseq_uminus[simp]: "incseq (λx. - f x) ⟷ decseq f"
and ereal_decseq_uminus[simp]: "decseq (λx. - f x) ⟷ incseq f"
unfolding decseq_def incseq_def by auto
incseq_ereal: "incseq f ==> incseq (λx. ereal (f x))"
unfolding incseq_def by auto
sum_ereal[simp]: "(∑x∈A. ereal (f x)) = ereal (∑x∈A. f x)"
by (induction A rule: infinite_finite_induct) auto
sum_list_ereal [simp]: "sum_list (map (λx. ereal (f x)) xs) = ereal (sum_list (map f xs))"
by (induction xs) simp_all
sum_Pinfty:
fixes f :: "'a ==> ereal"
shows "(∑x∈P. f x) = ∞⟷ finite P ∧ (∃i∈P. f i = ∞)"
safe
assume *: "sum f P = ∞"
show "finite P"
by (metis "*" Infty_neq_0(2) sum.infinite)
show "∃i∈P. f i = ∞"
proof (rule ccontr)
assume "¬ ?thesis"
then have "∧i. i ∈ P ==> f i ≠∞"
by auto
with ‹finite P› have "sum f P ≠∞"
by induct auto
with * show False
by auto
qed
fix i
assume "finite P" and "i ∈ P" and "f i = ∞"
then show "sum f P = ∞"
proof induct
case (insert x A)
show ?case using insert by (cases "x = i") auto
qed simp
sum_Inf:
fixes f :: "'a ==> ereal"
shows "∣sum f A∣ = ∞⟷ finite A ∧ (∃i∈A. ∣f i∣ = ∞)"
assume *: "∣sum f A∣ = ∞"
have "finite A"
by (rule ccontr) (insert *, auto)
moreover have "∃i∈A. ∣f i∣ = ∞"
proof (rule ccontr)
assume "¬ ?thesis"
then have "∀i∈A. ∃r. f i = ereal r"
by auto
then obtain r where "∀x∈A. f x = ereal (r x)"
by metis
with * show False
by auto
qed
ultimately show "finite A ∧ (∃i∈A. ∣f i∣ = ∞)"
by auto
assume "finite A ∧ (∃i∈A. ∣f i∣ = ∞)"
then obtain i where "finite A" "i ∈ A" and "∣f i∣ = ∞"
by auto
then show "∣sum f A∣ = ∞"
proof induct
case (insert j A)
then show ?case
by (cases rule: ereal3_cases[of "f i" "f j" "sum f A"]) auto
qed simp
sum_real_of_ereal:
fixes f :: "'i ==> ereal"
assumes "∧x. x ∈ S ==>∣f x∣≠∞"
shows "(∑x∈S. real_of_ereal (f x)) = real_of_ereal (sum f S)"
-
have "∀x∈S. ∃r. f x = ereal r"
using assms by blast
then obtain r where "∀x∈S. f x = ereal (r x)"
by metis
then show ?thesis
by simp
"Multiplication"
ereal :: "{comm_monoid_mult,sgn}"
sgn_ereal :: "ereal ==> ereal" where
"sgn (ereal r) = ereal (sgn r)"
"sgn (∞::ereal) = 1"
"sgn (-∞::ereal) = -1"
(auto intro: ereal_cases)
by standard (rule wf_on_bot)
times_ereal where
"ereal r * ereal p = ereal (r * p)"
"ereal r * ∞ = (if r = 0 then 0 else if r > 0 then ∞ else -∞)"
"∞ * ereal r = (if r = 0 then 0 else if r > 0 then ∞ else -∞)"
"ereal r * -∞ = (if r = 0 then 0 else if r > 0 then -∞ else ∞)"
"-∞ * ereal r = (if r = 0 then 0 else if r > 0 then -∞ else ∞)"
"(∞::ereal) * ∞ = ∞"
"-(∞::ereal) * ∞ = -∞"
"(∞::ereal) * -∞ = -∞"
"-(∞::ereal) * -∞ = ∞"
goal_cases
case prems: (1 P x)
then obtain a b where "x = (a, b)"
by (cases x) auto
with prems show P
by (cases rule: ereal2_cases[of a b]) auto
simp_all
by (relation "{}") simp
fix a b c :: ereal
show "1 * a = a"
by (cases a) (simp_all add: one_ereal_def)
show "a * b = b * a"
by (cases rule: ereal2_cases[of a b]) simp_all
show "a * b * c = a * (b * c)"
by (cases rule: ereal3_cases[of a b c])
(simp_all add: zero_ereal_def zero_less_mult_iff)
[simp]:
shows ereal_1_times: "ereal 1 * x = x"
and times_ereal_1: "x * ereal 1 = x"
(simp_all flip: one_ereal_def)
one_not_le_zero_ereal[simp]: "¬ (1 ≤ (0::ereal))"
by (simp add: one_ereal_def zero_ereal_def)
real_ereal_1[simp]: "real_of_ereal (1::ereal) = 1"
unfolding one_ereal_def by simp
real_of_ereal_le_1:
fixes a :: ereal
shows "a ≤ 1 ==> real_of_ereal a ≤ 1"
by (cases a) (auto simp: one_ereal_def)
abs_ereal_one[simp]: "∣1∣ = (1::ereal)"
unfolding one_ereal_def by simp
ereal_mult_zero[simp]:
fixes a :: ereal
shows "a * 0 = 0"
by (cases a) (simp_all add: zero_ereal_def)
ereal_zero_mult[simp]:
fixes a :: ereal
shows "0 * a = 0"
by (metis ereal_mult_zero mult.commute)
ereal_m1_less_0[simp]: "-(1::ereal) < 0"
by (simp add: zero_ereal_def one_ereal_def)
ereal_plus_1[simp]:
"1 + ereal r = ereal (r + 1)"
"ereal r + 1 = ereal (r + 1)"
"1 + -(∞::ereal) = -∞"
"-(∞::ereal) + 1 = -∞"
unfolding one_ereal_def by auto
ereal_zero_times[simp]:
fixes a b :: ereal
shows "a * b = 0 ⟷ a = 0 ∨ b = 0"
by (cases rule: ereal2_cases[of a b]) auto
ereal_mult_eq_PInfty[simp]:
"a * b = (∞::ereal) ⟷
(a = ∞∧ b > 0) ∨ (a > 0 ∧ b = ∞) ∨ (a = -∞∧ b < 0) ∨ (a < 0 ∧ b = -∞)"
by (cases rule: ereal2_cases[of a b]) auto
ereal_mult_eq_MInfty[simp]:
"a * b = -(∞::ereal) ⟷
(a = ∞∧ b < 0) ∨ (a < 0 ∧ b = ∞) ∨ (a = -∞∧ b > 0) ∨ (a > 0 ∧ b = -∞)"
by (cases rule: ereal2_cases[of a b]) auto
ereal_abs_mult: "∣x * y :: ereal∣ = ∣x∣ * ∣y∣"
by (cases x y rule: ereal2_cases) (auto simp: abs_mult)
ereal_0_less_1[simp]: "0 < (1::ereal)"
by (simp add: zero_ereal_def one_ereal_def)
ereal_mult_minus_left[simp]:
fixes a b :: ereal
shows "-a * b = - (a * b)"
by (cases rule: ereal2_cases[of a b]) auto
ereal_mult_minus_right[simp]:
fixes a b :: ereal
shows "a * -b = - (a * b)"
by (cases rule: ereal2_cases[of a b]) auto
ereal_mult_infty[simp]:
"a * (∞::ereal) = (if a = 0 then 0 else if 0 < a then ∞ else -∞)"
by (cases a) auto
ereal_infty_mult[simp]:
"(∞::ereal) * a = (if a = 0 then 0 else if 0 < a then ∞ else -∞)"
by (cases a) auto
ereal_mult_strict_right_mono:
assumes "a < b"
and "0 < c"
and "c < (∞::ereal)"
shows "a * c < b * c"
using assms
by (cases rule: ereal3_cases[of a b c]) (auto simp: zero_le_mult_iff)
ereal_mult_strict_left_mono:
"a < b ==> 0 < c ==> c < (∞::ereal) ==> c * a < c * b"
using ereal_mult_strict_right_mono
by (simp add: mult.commute[of c])
ereal_mult_right_mono:
fixes a b c :: ereal
assumes "a ≤ b" "0 ≤ c"
shows "a * c ≤ b * c"
(cases "c = 0")
case False
with assms show ?thesis
by (cases rule: ereal3_cases[of a b c]) auto
auto
ereal_mult_left_mono:
fixes a b c :: ereal
shows "a ≤ b ==> 0 ≤ c ==> c * a ≤ c * b"
by (simp add: ereal_mult_right_mono mult.commute)
ereal_mult_mono:
fixes a b c d::ereal
assumes "b ≥ 0" "c ≥ 0" "a ≤ b" "c ≤ d"
shows "a * c ≤ b * d"
by (metis ereal_mult_right_mono mult.commute order_trans assms)
ereal_mult_mono':
fixes a b c d::ereal
assumes "a ≥ 0" "c ≥ 0" "a ≤ b" "c ≤ d"
shows "a * c ≤ b * d"
by (metis ereal_mult_right_mono mult.commute order_trans assms)
ereal_mult_mono_strict:
fixes a b c d::ereal
assumes "b > 0" "c > 0" "a < b" "c < d"
shows "a * c < b * d"
-
have "c < \∞" using ‹c < d›
by auto
then have "a * c < b * c"
by (metis ereal_mult_strict_left_mono[OF assms(3) assms(2)] mult.commute)
moreover have "b * c ≤ b * d"
using assms(1,4) ereal_mult_left_mono by force
ultimately show ?thesis by simp
ereal_mult_mono_strict':
fixes a b c d::ereal
assumes "a > 0" "c > 0" "a < b" "c < d"
shows "a * c < b * d"
using assms ereal_mult_mono_strict by auto
zero_less_one_ereal[simp]: "0 ≤ (1::ereal)"
by (simp add: one_ereal_def zero_ereal_def)
ereal_0_le_mult[simp]: "0 ≤ a ==> 0 ≤ b ==> 0 ≤ a * (b :: ereal)"
by (cases rule: ereal2_cases[of a b]) auto
ereal_right_distrib:
fixes r a b :: ereal
shows "0 ≤ a ==> 0 ≤ b ==> r * (a + b) = r * a + r * b"
by (cases rule: ereal3_cases[of r a b]) (simp_all add: field_simps)
ereal_left_distrib:
fixes r a b :: ereal
shows "0 ≤ a ==> 0 ≤ b ==> (a + b) * r = a * r + b * r"
by (cases rule: ereal3_cases[of r a b]) (simp_all add: field_simps)
ereal_mult_le_0_iff:
fixes a b :: ereal
shows "a * b ≤ 0 ⟷ (0 ≤ a ∧ b ≤ 0) ∨ (a ≤ 0 ∧ 0 ≤ b)"
by (cases rule: ereal2_cases[of a b]) (simp_all add: mult_le_0_iff)
ereal_zero_le_0_iff:
fixes a b :: ereal
shows "0 ≤ a * b ⟷ (0 ≤ a ∧ 0 ≤ b) ∨ (a ≤ 0 ∧ b ≤ 0)"
by (cases rule: ereal2_cases[of a b]) (simp_all add: zero_le_mult_iff)
ereal_mult_less_0_iff:
fixes a b :: ereal
shows "a * b < 0 ⟷ (0 < a ∧ b < 0) ∨ (a < 0 ∧ 0 < b)"
by (cases rule: ereal2_cases[of a b]) (simp_all add: mult_less_0_iff)
ereal_zero_less_0_iff:
fixes a b :: ereal
shows "0 < a * b ⟷ (0 < a ∧ 0 < b) ∨ (a < 0 ∧ b < 0)"
by (cases rule: ereal2_cases[of a b]) (simp_all add: zero_less_mult_iff)
ereal_left_mult_cong:
fixes a b c :: ereal
shows "c = d ==> (d ≠ 0 ==> a = b) ==> a * c = b * d"
by (cases "c = 0") simp_all
ereal_right_mult_cong:
fixes a b c :: ereal
shows "c = d ==> (d ≠ 0 ==> a = b) ==> c * a = d * b"
by (cases "c = 0") simp_all
ereal_distrib:
fixes a b c :: ereal
assumes "a ≠∞∨ b ≠ -∞"
and "a ≠ -∞∨ b ≠∞"
and "∣c∣≠∞"
shows "(a + b) * c = a * c + b * c"
using assms
by (cases rule: ereal3_cases[of a b c]) (simp_all add: field_simps)
numeral_eq_ereal [simp]: "numeral w = ereal (numeral w)"
(induct w rule: num_induct)
case One
then show ?case
by simp
case (inc x)
then show ?case
by (simp add: inc numeral_inc)
m1_ereal_less_iff [simp]:
"((-1::ereal) < numeral a) ⟷ ((-1::real) < numeral a)"
by (simp add: one_ereal_def)
m1_ereal_le_iff [simp]:
"((-1::ereal) ≤ numeral a) ⟷ ((-1::real) ≤ numeral a)"
by (simp add: one_ereal_def)
m1_ereal_eq_iff [simp]:
"((-1::ereal) = numeral a) ⟷ ((-1::real) = numeral a)"
by (simp add: one_ereal_def)
ereal_less_m1_iff [simp]:
"(numeral a < (-1::ereal)) ⟷ (numeral a < (-1::real))"
by (simp add: one_ereal_def)
ereal_le_m1_iff [simp]:
"(numeral a ≤ (-1::ereal)) ⟷ (numeral a ≤ (-1::real))"
by (simp add: one_ereal_def)
ereal_eq_m1_iff [simp]:
"(numeral a = (-1::ereal)) ⟷ (numeral a = (-1::real))"
by (simp add: one_ereal_def)
distrib_left_ereal_nn:
"c ≥ 0 ==> (x + y) * ereal c = x * ereal c + y * ereal c"
by(cases x y rule: ereal2_cases)(simp_all add: ring_distribs)
sum_ereal_right_distrib:
fixes f :: "'a ==> ereal"
shows "(∧i. i ∈ A ==> 0 ≤ f i) ==> r * sum f A = (∑n∈A. r * f n)"
by (induct A rule: infinite_finite_induct) (auto simp: ereal_right_distrib sum_nonneg)
sum_ereal_left_distrib:
"(∧i. i ∈ A ==> 0 ≤ f i) ==> sum f A * r = (∑n∈A. f n * r :: ereal)"
using sum_ereal_right_distrib[of A f r] by (simp add: mult_ac)
sum_distrib_right_ereal:
"c ≥ 0 ==> sum f A * ereal c = (∑x∈A. f x * c :: ereal)"
(subst sum_comp_morphism[where h="λx. x * ereal c", symmetric])(simp_all add: distrib_left_ereal_nn)
ereal_le_epsilon:
fixes x y :: ereal
assumes "∧e. 0 < e ==> x ≤ y + e"
shows "x ≤ y"
(cases "x = -∞∨ x = ∞∨ y = -∞∨ y = ∞")
case True
then show ?thesis
using assms[of 1] by auto
case False
then obtain p q where "x = ereal p" "y = ereal q"
by (metis MInfty_eq_minfinity ereal.distinct(3) uminus_ereal.elims)
then show ?thesis
by (metis assms field_le_epsilon ereal_less(2) ereal_less_eq(3) plus_ereal.simps(1))
ereal_le_epsilon2:
fixes x y :: ereal
assumes "∧e::real. 0 < e ==> x ≤ y + ereal e"
shows "x ≤ y"
(rule ereal_le_epsilon)
show "∧ε::ereal. 0 < \ε ==> x ≤ y + ε"
using assms less_ereal.elims(2) zero_less_real_of_ereal by fastforce
ereal_le_real:
fixes x y :: ereal
assumes "∧z. x ≤ ereal z ==> y ≤ ereal z"
shows "y ≤ x"
by (metis assms ereal_bot ereal_cases ereal_infty_less_eq(2) ereal_less_eq(1) linorder_le_cases)
prod_ereal_0:
fixes f :: "'a ==> ereal"
shows "(∏i∈A. f i) = 0 ⟷ finite A ∧ (∃i∈A. f i = 0)"
by (induction A rule: infinite_finite_induct) auto
prod_ereal_pos:
fixes f :: "'a ==> ereal"
assumes "∧i. i ∈ I ==> 0 ≤ f i"
shows "0 ≤ (∏i∈I. f i)"
using assms
by (induction I rule: infinite_finite_induct) auto
prod_PInf:
fixes f :: "'a ==> ereal"
assumes "∧i. i ∈ I ==> 0 ≤ f i"
shows "(∏i∈I. f i) = ∞⟷ finite I ∧ (∃i∈I. f i = ∞) ∧ (∀i∈I. f i ≠ 0)"
using assms
(induction I rule: infinite_finite_induct)
case (insert i I)
then have pos: "0 ≤ f i" "0 ≤ prod f I"
by (auto intro!: prod_ereal_pos)
from insert have "(∏j∈insert i I. f j) = ∞⟷ prod f I * f i = ∞"
by auto
also have "…⟷ (prod f I = ∞∨ f i = ∞) ∧ f i ≠ 0 ∧ prod f I ≠ 0"
using prod_ereal_pos[of I f] pos
by (cases rule: ereal2_cases[of "f i" "prod f I"]) auto
also have "…⟷ finite (insert i I) ∧ (∃j∈insert i I. f j = ∞) ∧ (∀j∈insert i I. f j ≠ 0)"
using insert by (auto simp: prod_ereal_0)
finally show ?case .
auto
prod_ereal: "(∏i∈A. ereal (f i)) = ereal (prod f A)"
by (induction A rule: infinite_finite_induct) (auto simp: one_ereal_def)
‹Power›
ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)"
by (induct n) (auto simp: one_ereal_def)
ereal_power_PInf[simp]: "(∞::ereal) ^ n = (if n = 0 then 1 else ∞)"
by (induct n) (auto simp: one_ereal_def)
ereal_power_uminus[simp]:
fixes x :: ereal
shows "(- x) ^ n = (if even n then x ^ n else - (x^n))"
by (induct n) (auto simp: one_ereal_def)
ereal_power_numeral[simp]:
"(numeral num :: ereal) ^ n = ereal (numeral num ^ n)"
by (induct n) (auto simp: one_ereal_def)
zero_le_power_ereal[simp]:
fixes a :: ereal
assumes "0 ≤ a"
shows "0 ≤ a ^ n"
using assms by (induct n) (auto simp: ereal_zero_le_0_iff)
‹Subtraction›
ereal_minus_minus_image[simp]:
fixes S :: "ereal set"
shows "uminus ` uminus ` S = S"
by (auto simp: image_iff)
ereal_uminus_lessThan[simp]:
fixes a :: ereal
shows "uminus ` {..<a} = {-a<..}"
by (force simp: ereal_uminus_less_reorder)
ereal_minus[simp]:
"ereal r - ereal p = ereal (r - p)"
"-∞ - ereal r = -∞"
"ereal r -∞ = -∞"
"(∞::ereal) - x = ∞"
"-(∞::ereal) -∞ = -∞"
"x - -y = x + y"
"x - 0 = x"
"0 - x = -x"
by (simp_all add: minus_ereal_def)
ereal_x_minus_x[simp]: "x - x = (if ∣x∣ = ∞ then ∞ else 0::ereal)"
by auto
ereal_eq_minus_iff:
fixes x y z :: ereal
shows "x = z - y ⟷
(∣y∣≠∞⟶ x + y = z) ∧
(y = -∞⟶ x = ∞) ∧
(y = ∞⟶ z = ∞⟶ x = ∞) ∧
(y = ∞⟶ z ≠∞⟶ x = -∞)"
by (cases rule: ereal3_cases[of x y z]) auto
ereal_eq_minus:
fixes x y z :: ereal
shows "∣y∣≠∞==> x = z - y ⟷ x + y = z"
by (auto simp: ereal_eq_minus_iff)
ereal_less_minus_iff:
fixes x y z :: ereal
shows "x < z - y ⟷
(y = ∞⟶ z = ∞∧ x ≠∞) ∧
(y = -∞⟶ x ≠∞) ∧
(∣y∣≠∞⟶ x + y < z)"
by (cases rule: ereal3_cases[of x y z]) auto
ereal_less_minus:
fixes x y z :: ereal
shows "∣y∣≠∞==> x < z - y ⟷ x + y < z"
by (auto simp: ereal_less_minus_iff)
ereal_le_minus_iff:
fixes x y z :: ereal
shows "x ≤ z - y ⟷ (y = ∞⟶ z ≠∞⟶ x = -∞) ∧ (∣y∣≠∞⟶ x + y ≤ z)"
by (cases rule: ereal3_cases[of x y z]) auto
ereal_le_minus:
fixes x y z :: ereal
shows "∣y∣≠∞==> x ≤ z - y ⟷ x + y ≤ z"
by (auto simp: ereal_le_minus_iff)
ereal_minus_less_iff:
fixes x y z :: ereal
shows "x - y < z ⟷ y ≠ -∞∧ (y = ∞⟶ x ≠∞∧ z ≠ -∞) ∧ (y ≠∞⟶ x < z + y)"
by (cases rule: ereal3_cases[of x y z]) auto
ereal_minus_less:
fixes x y z :: ereal
shows "∣y∣≠∞==> x - y < z ⟷ x < z + y"
by (auto simp: ereal_minus_less_iff)
ereal_minus_le_iff:
fixes x y z :: ereal
shows "x - y ≤ z ⟷
(y = -∞⟶ z = ∞) ∧
(y = ∞⟶ x = ∞⟶ z = ∞) ∧
(∣y∣≠∞⟶ x ≤ z + y)"
by (cases rule: ereal3_cases[of x y z]) auto
ereal_minus_le:
fixes x y z :: ereal
shows "∣y∣≠∞==> x - y ≤ z ⟷ x ≤ z + y"
by (auto simp: ereal_minus_le_iff)
ereal_minus_eq_minus_iff:
fixes a b c :: ereal
shows "a - b = a - c ⟷
b = c ∨ a = ∞∨ (a = -∞∧ b ≠ -∞∧ c ≠ -∞)"
by (cases rule: ereal3_cases[of a b c]) auto
ereal_add_le_add_iff:
fixes a b c :: ereal
shows "c + a ≤ c + b ⟷
a ≤ b ∨ c = ∞∨ (c = -∞∧ a ≠∞∧ b ≠∞)"
by (cases rule: ereal3_cases[of a b c]) (simp_all add: field_simps)
ereal_add_le_add_iff2:
fixes a b c :: ereal
shows "a + c ≤ b + c ⟷ a ≤ b ∨ c = ∞∨ (c = -∞∧ a ≠∞∧ b ≠∞)"
by (metis (no_types, lifting) add.commute ereal_add_le_add_iff)
ereal_mult_le_mult_iff:
fixes a b c :: ereal
shows "∣c∣≠∞==> c * a ≤ c * b ⟷ (0 < c ⟶ a ≤ b) ∧ (c < 0 ⟶ b ≤ a)"
by (cases rule: ereal3_cases[of a b c]) (simp_all add: mult_le_cancel_left)
ereal_minus_mono:
fixes A B C D :: ereal assumes "A ≤ B" "D ≤ C"
shows "A - C ≤ B - D"
using assms
by (cases rule: ereal3_cases[case_product ereal_cases, of A B C D]) simp_all
ereal_mono_minus_cancel:
fixes a b c :: ereal
shows "c - a ≤ c - b ==> 0 ≤ c ==> c < \∞==> b ≤ a"
by (cases a b c rule: ereal3_cases) auto
real_of_ereal_minus:
fixes a b :: ereal
shows "real_of_ereal (a - b) = (if ∣a∣ = ∞∨∣b∣ = ∞ then 0 else real_of_ereal a - real_of_ereal b)"
by (cases rule: ereal2_cases[of a b]) auto
real_of_ereal_minus': "∣x∣ = ∞⟷∣y∣ = ∞==> real_of_ereal x - real_of_ereal y = real_of_ereal (x - y :: ereal)"
(subst real_of_ereal_minus) auto
ereal_diff_positive:
fixes a b :: ereal shows "a ≤ b ==> 0 ≤ b - a"
by (cases rule: ereal2_cases[of a b]) auto
ereal_between:
fixes x e :: ereal
assumes "∣x∣≠∞" and "0 < e"
shows "x - e < x"
and "x < x + e"
using assms by (cases x, cases e, auto)+
ereal_minus_eq_PInfty_iff:
fixes x y :: ereal
shows "x - y = ∞⟷ y = -∞∨ x = ∞"
by (cases x y rule: ereal2_cases) simp_all
ereal_diff_add_eq_diff_diff_swap:
fixes x y z :: ereal
shows "∣y∣≠∞==> x - (y + z) = x - y - z"
by(cases x y z rule: ereal3_cases) simp_all
ereal_diff_add_assoc2:
fixes x y z :: ereal
shows "x + y - z = x - z + y"
by(cases x y z rule: ereal3_cases) simp_all
ereal_add_uminus_conv_diff: fixes x y z :: ereal shows "- x + y = y - x"
by (simp add: add.commute minus_ereal_def)
ereal_minus_diff_eq:
fixes x y :: ereal
shows "[ x = ∞⟶ y ≠∞; x = -∞⟶ y ≠ -∞]==> - (x - y) = y - x"
by(cases x y rule: ereal2_cases) simp_all
ediff_le_self [simp]: "x - y ≤ (x :: enat)"
by(cases x y rule: enat.exhaust[case_product enat.exhaust]) simp_all
ereal_abs_diff:
fixes a b::ereal
shows "abs(a-b) ≤ abs a + abs b"
by (cases rule: ereal2_cases[of a b]) (auto)
‹Division›
ereal :: inverse
inverse_ereal where
"inverse (ereal r) = (if r = 0 then ∞ else ereal (inverse r))"
"inverse (∞::ereal) = 0"
"inverse (-∞::ereal) = 0"
by (auto intro: ereal_cases)
by (relation "{}") simp
"x div y = x * inverse (y :: ereal)"
..
real_of_ereal_inverse[simp]:
fixes a :: ereal
shows "real_of_ereal (inverse a) = 1 / real_of_ereal a"
by (cases a) (auto simp: inverse_eq_divide)
zero_le_divide_ereal[simp]:
fixes a :: ereal
assumes "0 ≤ a" and "0 ≤ b"
shows "0 ≤ a / b"
by (simp add: assms divide_ereal_def ereal_inverse_nonneg_iff)
ereal_le_divide_pos:
fixes x y z :: ereal
shows "x > 0 ==> x ≠∞==> y ≤ z / x ⟷ x * y ≤ z"
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
ereal_divide_le_pos:
fixes x y z :: ereal
shows "x > 0 ==> x ≠∞==> z / x ≤ y ⟷ z ≤ x * y"
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
ereal_le_divide_neg:
fixes x y z :: ereal
shows "x < 0 ==> x ≠ -∞==> y ≤ z / x ⟷ z ≤ x * y"
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
ereal_divide_le_neg:
fixes x y z :: ereal
shows "x < 0 ==> x ≠ -∞==> z / x ≤ y ⟷ x * y ≤ z"
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps)
ereal_inverse_antimono_strict:
fixes x y :: ereal
shows "0 ≤ x ==> x < y ==> inverse y < inverse x"
by (cases rule: ereal2_cases[of x y]) auto
ereal_inverse_antimono:
fixes x y :: ereal
shows "0 ≤ x ==> x ≤ y ==> inverse y ≤ inverse x"
by (cases rule: ereal2_cases[of x y]) auto
inverse_inverse_Pinfty_iff[simp]:
fixes x :: ereal
shows "inverse x = ∞⟷ x = 0"
by (cases x) auto
ereal_inverse_eq_0:
fixes x :: ereal
shows "inverse x = 0 ⟷ x = ∞∨ x = -∞"
by (cases x) auto
ereal_0_gt_inverse:
fixes x :: ereal
shows "0 < inverse x ⟷ x ≠∞∧ 0 ≤ x"
by (cases x) auto
ereal_inverse_le_0_iff:
fixes x :: ereal
shows "inverse x ≤ 0 ⟷ x < 0 ∨ x = ∞"
by(cases x) auto
ereal_divide_eq_0_iff: "x / y = 0 ⟷ x = 0 ∨∣y :: ereal∣ = ∞"
(cases x y rule: ereal2_cases) simp_all
ereal_mult_less_right:
fixes a b c :: ereal
assumes "b * a < c * a" "0 < a" "a < \∞"
shows "b < c"
using assms
by (metis order.asym ereal_mult_strict_left_mono linorder_neqE mult.commute)
ereal_mult_divide:
fixes a b :: ereal
shows "0 < b ==> b < \∞==> b * (a / b) = a"
by (cases a b rule: ereal2_cases) auto
ereal_power_divide:
fixes x y :: ereal
shows "y ≠ 0 ==> (x / y) ^ n = x^n / y^n"
by (cases rule: ereal2_cases [of x y])
(auto simp: one_ereal_def zero_ereal_def power_divide zero_le_power_eq)
ereal_le_mult_one_interval:
fixes x y :: ereal
assumes y: "y ≠ -∞"
assumes z: "∧z. 0 < z ==> z < 1 ==> z * x ≤ y"
shows "x ≤ y"
(cases x)
case PInf
with z[of "1 / 2"] show "x ≤ y"
by (simp add: one_ereal_def)
case r: (real r)
show "x ≤ y"
proof (cases y)
case p: (real p)
have "r ≤ p"
proof (rule field_le_mult_one_interval)
fix z :: real
assume "0 < z" and "z < 1"
with z[of "ereal z"] show "z * r ≤ p"
using p r by (auto simp: zero_le_mult_iff one_ereal_def)
qed
then show "x ≤ y"
using p r by simp
qed (use y in simp_all)
simp
ereal_divide_right_mono[simp]:
fixes x y z :: ereal
assumes "x ≤ y"
and "0 < z"
shows "x / z ≤ y / z"
using assms by (cases x y z rule: ereal3_cases) (auto intro: divide_right_mono)
ereal_divide_left_mono[simp]:
fixes x y z :: ereal
assumes "y ≤ x"
and "0 < z"
and "0 < x * y"
shows "z / x ≤ z / y"
using assms
by (cases x y z rule: ereal3_cases)
(auto intro: divide_left_mono simp: field_simps zero_less_mult_iff mult_less_0_iff split: if_split_asm)
ereal_divide_zero_left[simp]:
fixes a :: ereal
shows "0 / a = 0"
using ereal_divide_eq_0_iff by blast
ereal_times_divide_eq_left[simp]:
fixes a b c :: ereal
shows "b / c * a = b * a / c"
by (metis divide_ereal_def mult.assoc mult.commute)
ereal_times_divide_eq: "a * (b / c :: ereal) = a * b / c"
by (metis ereal_times_divide_eq_left mult.commute)
ereal_inverse_real [simp]: "∣z∣≠∞==> z ≠ 0 ==> ereal (inverse (real_of_ereal z)) = inverse z"
by auto
ereal_inverse_mult:
"a ≠ 0 ==> b ≠ 0 ==> inverse (a * (b::ereal)) = inverse a * inverse b"
by (cases a; cases b) auto
ereal_distrib_left:
fixes a b c :: ereal
assumes "a ≠∞∨ b ≠ -∞"
and "a ≠ -∞∨ b ≠∞"
and "∣c∣≠∞"
shows "c * (a + b) = c * a + c * b"
by (metis assms ereal_distrib mult.commute)
ereal_distrib_minus_left:
fixes a b c :: ereal
assumes "a ≠∞∨ b ≠∞"
and "a ≠ -∞∨ b ≠ -∞"
and "∣c∣≠∞"
shows "c * (a - b) = c * a - c * b"
using assms ereal_distrib_left ereal_uminus_eq_reorder minus_ereal_def by auto
ereal_distrib_minus_right:
fixes a b c :: ereal
assumes "a ≠∞∨ b ≠∞"
and "a ≠ -∞∨ b ≠ -∞"
and "∣c∣≠∞"
shows "(a - b) * c = a * c - b * c"
by (metis assms ereal_distrib_minus_left mult.commute)
"Complete lattice"
ereal :: lattice
[simp]: "sup x y = (max x y :: ereal)"
[simp]: "inf x y = (min x y :: ereal)"
by standard simp_all
ereal :: complete_lattice
"bot = (-∞::ereal)"
"top = (∞::ereal)"
"Sup S = (SOME x :: ereal. (∀y∈S. y ≤ x) ∧ (∀z. (∀y∈S. y ≤ z) ⟶ x ≤ z))"
"Inf S = (SOME x :: ereal. (∀y∈S. x ≤ y) ∧ (∀z. (∀y∈S. z ≤ y) ⟶ z ≤ x))"
ereal_complete_Sup:
fixes S :: "ereal set"
shows "∃x. (∀y∈S. y ≤ x) ∧ (∀z. (∀y∈S. y ≤ z) ⟶ x ≤ z)"
(cases "∃x. ∀a∈S. a ≤ ereal x")
case True
then obtain y where y: "a ≤ ereal y" if "a∈S" for a
by auto
then have "∞∉ S"
by force
show ?thesis
proof (cases "S ≠ {-∞} ∧ S ≠ {}")
case True
with ‹∞∉ S› obtain x where x: "x ∈ S" "∣x∣≠∞"
by auto
obtain s where s: "∀x∈ereal -` S. x ≤ s" "(∀x∈ereal -` S. x ≤ z) ==> s ≤ z" for z
proof (atomize_elim, rule complete_real)
show "∃x. x ∈ ereal -` S"
using x by auto
show "∃z. ∀x∈ereal -` S. x ≤ z"
by (auto dest: y intro!: exI[of _ y])
qed
show ?thesis
proof (safe intro!: exI[of _ "ereal s"])
fix y
assume "y ∈ S"
with s ‹∞∉ S› show "y ≤ ereal s"
by (cases y) auto
next
fix z
assume "∀y∈S. y ≤ z"
with ‹S ≠ {-∞} ∧ S ≠ {}› show "ereal s ≤ z"
by (cases z) (auto intro!: s)
qed
next
case False
then show ?thesis
by (auto intro!: exI[of _ "-∞"])
qed
case False
then show ?thesis
by (fastforce intro!: exI[of _ ∞] ereal_top intro: order_trans dest: less_imp_le simp: not_le)
ereal_complete_uminus_eq:
fixes S :: "ereal set"
shows "(∀y∈uminus`S. y ≤ x) ∧ (∀z. (∀y∈uminus`S. y ≤ z) ⟶ x ≤ z) ⟷ (∀y∈S. -x ≤ y) ∧ (∀z. (∀y∈S. z ≤ y) ⟶ z ≤ -x)"
by simp (metis ereal_minus_le_minus ereal_uminus_uminus)
ereal_complete_Inf:
"∃x. (∀y∈S::ereal set. x ≤ y) ∧ (∀z. (∀y∈S. z ≤ y) ⟶ z ≤ x)"
using ereal_complete_Sup[of "uminus ` S"]
unfolding ereal_complete_uminus_eq
by auto
show "Sup {} = (bot::ereal)"
using ereal_bot by (auto simp: bot_ereal_def Sup_ereal_def)
show "Inf {} = (top::ereal)"
unfolding top_ereal_def Inf_ereal_def
using ereal_infty_less_eq(1) ereal_less_eq(1) by blast
show "∧x::ereal. ∧A. x ∈ A ==> Inf A ≤ x"
"∧A z. (∧x::ereal. x ∈ A ==> z ≤ x) ==> z ≤ Inf A"
by (auto intro: someI2_ex ereal_complete_Inf simp: Inf_ereal_def)
show "∧x::ereal. ∧A. x ∈ A ==> x ≤ Sup A"
"∧A z. (∧x::ereal. x ∈ A ==> x ≤ z) ==> Sup A ≤ z"
by (auto intro: someI2_ex ereal_complete_Sup simp: Sup_ereal_def)
ereal :: complete_linorder ..
ereal :: linear_continuum
show "∃a b::ereal. a ≠ b"
using zero_neq_one by blast
min_PInf [simp]: "min (∞::ereal) x = x"
by (metis min_top top_ereal_def)
min_PInf2 [simp]: "min x (∞::ereal) = x"
by (metis min_top2 top_ereal_def)
max_PInf [simp]: "max (∞::ereal) x = ∞"
by (metis max_top top_ereal_def)
max_PInf2 [simp]: "max x (∞::ereal) = ∞"
by (metis max_top2 top_ereal_def)
min_MInf [simp]: "min (-∞::ereal) x = -∞"
by (metis min_bot bot_ereal_def)
min_MInf2 [simp]: "min x (-∞::ereal) = -∞"
by (metis min_bot2 bot_ereal_def)
max_MInf [simp]: "max (-∞::ereal) x = x"
by (metis max_bot bot_ereal_def)
max_MInf2 [simp]: "max x (-∞::ereal) = x"
by (metis max_bot2 bot_ereal_def)
‹Extended real intervals›
real_greaterThanLessThan_infinity_eq:
"real_of_ereal ` {N::ereal<..<\<infinity>} =
(if N = ∞ then {} else if N = -∞ then UNIV else {real_of_ereal N<..})"
by (force simp: real_less_ereal_iff intro!: image_eqI[where x="ereal _"] elim!: less_ereal.elims)
real_greaterThanLessThan_minus_infinity_eq:
"real_of_ereal ` {-∞<..<N::ereal} =
(if N = ∞ then UNIV else if N = -∞ then {} else {..<real_of_ereal N})"
-
have "real_of_ereal ` {-∞<..<N::ereal} = uminus ` real_of_ereal ` {-N<..<\<infinity>}"
by (auto simp: ereal_uminus_less_reorder intro!: image_eqI[where x="-x" for x])
also note real_greaterThanLessThan_infinity_eq
finally show ?thesis by (auto intro!: image_eqI[where x="-x" for x])
real_atLeastGreaterThan_eq: "real_of_ereal ` {N<..<M::ereal} =
(if N = ∞ then {} else
if N = -∞ then
(if M = ∞ then UNIV
else if M = -∞ then {}
else {..< real_of_ereal M})
else if M = -∞ then {}
else if M = ∞ then {real_of_ereal N<..}
else {real_of_ereal N <..< real_of_ereal M})"
(cases "M = -∞∨ M = ∞∨ N = -∞∨ N = ∞")
case True
then show ?thesis
by (auto simp: real_greaterThanLessThan_minus_infinity_eq real_greaterThanLessThan_infinity_eq )
case False
then obtain p q where "M = ereal p" "N = ereal q"
by (metis MInfty_eq_minfinity ereal.distinct(3) uminus_ereal.elims)
moreover have "∧x. [q < x; x < p]==> x ∈ real_of_ereal ` {ereal q<..<ereal p}"
by (metis greaterThanLessThan_iff imageI less_ereal.simps(1) real_of_ereal.simps(1))
ultimately show ?thesis
by (auto elim!: less_ereal.elims)
real_image_ereal_ivl:
fixes a b::ereal
shows
"real_of_ereal ` {a<..<b} =
(if a < b then (if a = -∞ then if b = ∞ then UNIV else {..<real_of_ereal b}
else if b = ∞ then {real_of_ereal a<..} else {real_of_ereal a <..< real_of_ereal b}) else {})"
by (cases a; cases b; simp add: real_atLeastGreaterThan_eq not_less)
fixes a b c::ereal
shows not_inftyI: "a < b ==> b < c ==> abs b ≠∞"
by force
greaterThanLessThan_eq_iff:
fixes r s t u::real
shows "({r<..<s} = {t<..<u}) = (r ≥ s ∧ u ≤ t ∨ r = t ∧ s = u)"
by (metis cInf_greaterThanLessThan cSup_greaterThanLessThan greaterThanLessThan_empty_iff not_le)
real_of_ereal_image_greaterThanLessThan_iff:
"real_of_ereal ` {a <..< b} = real_of_ereal ` {c <..< d} ⟷ (a ≥ b ∧ c ≥ d ∨ a = c ∧ b = d)"
unfolding real_atLeastGreaterThan_eq
by (cases a; cases b; cases c; cases d;
simp add: greaterThanLessThan_eq_iff interval_neqs interval_neqs[symmetric])
add_image_real_of_ereal_image_greaterThanLessThan:
"(+) c ` real_of_ereal ` {l <..< u} = real_of_ereal ` {c + l <..< c + u}"
apply safe
subgoal for x
using ereal_less_add[of c]
by (force simp: real_of_ereal_add add.commute)
subgoal for _ x
by (force simp: add.commute real_of_ereal_minus ereal_minus_less ereal_less_minus
intro: image_eqI[where x="x - c"])
done
add2_image_real_of_ereal_image_greaterThanLessThan:
"(λx. x + c) ` real_of_ereal ` {l <..< u} = real_of_ereal ` {l + c <..< u + c}"
using add_image_real_of_ereal_image_greaterThanLessThan[of c l u]
by (metis add.commute image_cong)
minus_image_real_of_ereal_image_greaterThanLessThan:
"(-) c ` real_of_ereal ` {l <..< u} = real_of_ereal ` {c - u <..< c - l}"
(is "?l = ?r")
-
have "?l = (+) c ` uminus ` real_of_ereal ` {l <..< u}" by auto
also note uminus_image_real_of_ereal_image_greaterThanLessThan
also note add_image_real_of_ereal_image_greaterThanLessThan
finally show ?thesis by (simp add: minus_ereal_def)
real_ereal_bound_lemma_up:
assumes "s ∈ real_of_ereal ` {a<..<b}"
assumes "t ∉ real_of_ereal ` {a<..<b}"
assumes "s ≤ t"
shows "b ≠∞"
(cases b)
case PInf
then show ?thesis
using assms
by (metis UNIV_I empty_iff greaterThan_iff order_less_le_trans real_image_ereal_ivl)
auto
real_ereal_bound_lemma_down:
assumes s: "s ∈ real_of_ereal ` {a<..<b}"
and t: "t ∉ real_of_ereal ` {a<..<b}"
and "t ≤ s"
"a ≠ -∞"
by (metis UNIV_I assms empty_iff lessThan_iff order_le_less_trans
real_greaterThanLessThan_minus_infinity_eq)
"Topological space"
ereal :: linear_continuum_topology
"open_ereal" :: "ereal set ==> bool" where
open_ereal_generated: "open_ereal = generate_topology (range lessThan ∪ range greaterThan)"
by standard (simp add: open_ereal_generated)
continuous_on_ereal[continuous_intros]:
assumes f: "continuous_on s f" shows "continuous_on s (λx. ereal (f x))"
by (rule continuous_on_compose2 [OF continuous_onI_mono[of ereal UNIV] f]) auto
tendsto_ereal[tendsto_intros, simp, intro]: "(f ---> x) F ==> ((λx. ereal (f x))---> ereal x) F"
using isCont_tendsto_compose[of x ereal f F] continuous_on_ereal[of UNIV "λx. x"]
by (simp add: continuous_on_eq_continuous_at)
tendsto_uminus_ereal[tendsto_intros, simp, intro]:
assumes "(f ---> x) F"
shows "((λx. - f x::ereal) ---> - x) F"
(rule tendsto_compose[OF order_tendstoI assms])
show "∧a. a < - x ==>∀F x in at x. a < - x"
by (metis ereal_less_uminus_reorder eventually_at_topological lessThan_iff open_lessThan)
show "∧a. - x < a ==>∀F x in at x. - x < a"
by (metis ereal_uminus_reorder(2) eventually_at_topological greaterThan_iff open_greaterThan)
at_infty_ereal_eq_at_top: "at ∞ = filtermap ereal at_top"
-
have "∧P b. ∀z. b ≤ z ∧ b ≠ z ⟶ P (ereal z) ==>∃N. ∀n≥N. P (ereal n)"
by (metis gt_ex order_less_le order_less_le_trans)
then show ?thesis
unfolding filter_eq_iff eventually_at_filter eventually_at_top_linorder eventually_filtermap
top_ereal_def[symmetric]
apply (subst eventually_nhds_top[of 0])
apply (auto simp: top_ereal_def less_le ereal_all_split ereal_ex_split)
done
ereal_Lim_uminus: "(f ---> f0) net ⟷ ((λx. - f x::ereal) ---> - f0) net"
using tendsto_uminus_ereal[of f f0 net] tendsto_uminus_ereal[of "λx. - f x" "- f0" net]
by auto
ereal_divide_less_iff: "0 < (c::ereal) ==> c < \∞==> a / c < b ⟷ a < b * c"
by (cases a b c rule: ereal3_cases) (auto simp: field_simps)
ereal_less_divide_iff: "0 < (c::ereal) ==> c < \∞==> a < b / c ⟷ a * c < b"
by (cases a b c rule: ereal3_cases) (auto simp: field_simps)
tendsto_cmult_ereal[tendsto_intros, simp, intro]:
assumes c: "∣c∣≠∞" and f: "(f ---> x) F"
shows "((λx. c * f x::ereal) ---> c * x) F"
-
have *: "((λx. c * f x::ereal) ---> c * x) F" if "0 < c" "c < \∞" for c :: ereal
using that
apply (intro tendsto_compose[OF _ f])
apply (auto intro!: order_tendstoI simp: eventually_at_topological)
apply (rule_tac x="{a/c <..}" in exI)
apply (auto split: ereal.split simp: ereal_divide_less_iff mult.commute) []
apply (rule_tac x="{..< a/c}" in exI)
apply (auto split: ereal.split simp: ereal_less_divide_iff mult.commute) []
done
have "((0 < c ∧ c < \∞) ∨ (-∞ < c ∧ c < 0) ∨ c = 0)"
using c by (cases c) auto
then show ?thesis
proof (elim disjE conjE)
assume "-∞ < c" "c < 0"
then have "0 < - c" "- c < \∞"
by (auto simp: ereal_uminus_reorder ereal_less_uminus_reorder[of 0])
then have "((λx. (- c) * f x) ---> (- c) * x) F"
by (rule *) from tendsto_uminus_ereal[OF this] show ?thesis by simp qed (auto intro!: *) qed
lemma tendsto_cmult_ereal_not_0[tendsto_intros, simp, intro]: assumes"x ≠ 0"and f: "(f ---> x) F" shows"((λx. c * f x::ereal) ---> c * x) F" proof cases assume"∣c∣ = ∞" show ?thesis proof (rule filterlim_cong[THEN iffD1, OF refl refl _ tendsto_const]) have"0 < x ∨ x < 0" using‹x ≠ 0›by (auto simp: neq_iff) thenshow"eventually (λx'. c * x = c * f x') F" proof assume"0 < x"from order_tendstoD(1)[OF f this] show ?thesis by eventually_elim (use‹0<x\›‹∣c∣ = ∞›in auto) next assume"x < 0"from order_tendstoD(2)[OF f this] show ?thesis by eventually_elim (use‹x<0\›‹∣c∣ = ∞›in auto) qed qed qed (rule tendsto_cmult_ereal[OF _ f])
lemma tendsto_cadd_ereal[tendsto_intros, simp, intro]: assumes c: "y ≠ -∞""x ≠ -∞"and f: "(f ---> x) F" shows"((λx. f x + y::ereal) ---> x + y) F" apply (intro tendsto_compose[OF _ f]) apply (auto intro!: order_tendstoI simp: eventually_at_topological) apply (rule_tac x="{a - y <..}"in exI) apply (auto split: ereal.split simp: ereal_minus_less_iff c) [] apply (rule_tac x="{..< a - y}"in exI) apply (auto split: ereal.split simp: ereal_less_minus_iff c) [] done
lemma tendsto_add_left_ereal[tendsto_intros, simp, intro]: assumes c: "∣y∣≠∞"and f: "(f ---> x) F" shows"((λx. f x + y::ereal) ---> x + y) F" apply (intro tendsto_compose[OF _ f]) apply (auto intro!: order_tendstoI simp: eventually_at_topological) apply (rule_tac x="{a - y <..}"in exI) apply (insert c, auto split: ereal.split simp: ereal_minus_less_iff) [] apply (rule_tac x="{..< a - y}"in exI) apply (auto split: ereal.split simp: ereal_less_minus_iff c) [] done
lemma continuous_at_ereal[continuous_intros]: "continuous F f ==> continuous F (λx. ereal (f x))" unfolding continuous_def by auto
lemma ereal_Sup: assumes *: "∣SUP a∈A. ereal a∣≠∞" shows"ereal (Sup A) = (SUP a∈A. ereal a)" proof (rule continuous_at_Sup_mono) obtain r where r: "ereal r = (SUP a∈A. ereal a)""A ≠ {}" using * by (force simp: bot_ereal_def) thenshow"bdd_above A""A ≠ {}" by (auto intro!: SUP_upper bdd_aboveI[of _ r] simp flip: ereal_less_eq) qed (auto simp: mono_def continuous_at_imp_continuous_at_within continuous_at_ereal)
lemma ereal_SUP: "∣SUP a∈A. ereal (f a)∣≠∞==> ereal (SUP a∈A. f a) = (SUP a∈A. ereal (f a))" by (simp add: ereal_Sup image_comp)
lemma ereal_Inf: assumes *: "∣INF a∈A. ereal a∣≠∞" shows"ereal (Inf A) = (INF a∈A. ereal a)" proof (rule continuous_at_Inf_mono) obtain r where r: "ereal r = (INF a∈A. ereal a)""A ≠ {}" using * by (force simp: top_ereal_def) thenshow"bdd_below A""A ≠ {}" by (auto intro!: INF_lower bdd_belowI[of _ r] simp flip: ereal_less_eq) qed (auto simp: mono_def continuous_at_imp_continuous_at_within continuous_at_ereal)
lemma ereal_Inf': assumes *: "bdd_below A""A ≠ {}" shows"ereal (Inf A) = (INF a∈A. ereal a)" proof (rule ereal_Inf) from * obtain l u where"x ∈ A ==> l ≤ x""u ∈ A"for x by (auto simp: bdd_below_def) thenhave"l ≤ (INF x∈A. ereal x)""(INF x∈A. ereal x) ≤ u" by (auto intro!: INF_greatest INF_lower) thenshow"∣INF a∈A. ereal a∣≠∞" by auto qed
lemma ereal_INF: "∣INF a∈A. ereal (f a)∣≠∞==> ereal (INF a∈A. f a) = (INF a∈A. ereal (f a))" by (simp add: ereal_Inf image_comp)
lemma ereal_SUP_uminus_eq: fixes f :: "'a ==> ereal" shows"(SUP x∈S. uminus (f x)) = - (INF x∈S. f x)" using ereal_Sup_uminus_image_eq [of "f ` S"] by (simp add: image_comp)
lemma ereal_inj_on_uminus[intro, simp]: "inj_on uminus (A :: ereal set)" by (auto intro!: inj_onI)
lemma ereal_Inf_uminus_image_eq: "Inf (uminus ` S::ereal set) = - Sup S" using ereal_Sup_uminus_image_eq[of "uminus ` S"] by simp
lemma ereal_INF_uminus_eq: fixes f :: "'a ==> ereal" shows"(INF x∈S. - f x) = - (SUP x∈S. f x)" using ereal_Inf_uminus_image_eq [of "f ` S"] by (simp add: image_comp)
lemma ereal_SUP_not_infty: fixes f :: "_ ==> ereal" shows"A ≠ {} ==> l ≠ -∞==> u ≠∞==>∀a∈A. l ≤ f a ∧ f a ≤ u ==>∣Sup (f ` A)∣≠∞" using SUP_upper2[of _ A l f] SUP_least[of A f u] by (cases "Sup (f ` A)") auto
lemma ereal_INF_not_infty: fixes f :: "_ ==> ereal" shows"A ≠ {} ==> l ≠ -∞==> u ≠∞==>∀a∈A. l ≤ f a ∧ f a ≤ u ==>∣Inf (f ` A)∣≠∞" using INF_lower2[of _ A f u] INF_greatest[of A l f] by (cases "Inf (f ` A)") auto
lemma ereal_image_uminus_shift: fixes X Y :: "ereal set" shows"uminus ` X = Y ⟷ X = uminus ` Y" by (metis ereal_minus_minus_image)
lemma Sup_eq_MInfty: fixes S :: "ereal set" shows"Sup S = -∞⟷ S = {} ∨ S = {-∞}" unfolding bot_ereal_def[symmetric] by auto
lemma Inf_eq_PInfty: fixes S :: "ereal set" shows"Inf S = ∞⟷ S = {} ∨ S = {∞}" using Sup_eq_MInfty[of "uminus`S"] unfolding ereal_Sup_uminus_image_eq ereal_image_uminus_shift by simp
lemma Inf_eq_MInfty: fixes S :: "ereal set" shows"-∞∈ S ==> Inf S = -∞" unfolding bot_ereal_def[symmetric] by auto
lemma Sup_eq_PInfty: fixes S :: "ereal set" 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" and S: "∣Sup S∣≠∞""S ≠ {}" shows"∃x∈S. Sup S - e < x" using assms by (cases e) (auto intro!: less_Sup_iff[THEN iffD1])
lemma Inf_ereal_close: fixes e :: ereal assumes"∣Inf X∣≠∞" and"0 < e" shows"∃x∈X. x < Inf X + e" by (meson Inf_less_iff assms ereal_between(2))
lemma SUP_PInfty: "(∧n::nat. ∃i∈A. ereal (real n) ≤ f i) ==> (SUP i∈A. f i :: ereal) = ∞" by (meson SUP_upper2 less_PInf_Ex_of_nat linorder_not_less)
lemma SUP_nat_Infty: "(SUP i. ereal (real i)) = ∞" by (rule SUP_PInfty) auto
lemma SUP_ereal_add_left: assumes"I ≠ {}""c ≠ -∞" shows"(SUP i∈I. f i + c :: ereal) = (SUP i∈I. f i) + c" proof (cases "(SUP i∈I. f i) = -∞") case True thenhave"∧i. i ∈ I ==> f i = -∞" unfolding Sup_eq_MInfty by auto with True show ?thesis by (cases c) (auto simp: ‹I ≠ {}›) next case False thenshow ?thesis by (subst continuous_at_Sup_mono[where f="λx. x + c"])
(auto simp: continuous_at_imp_continuous_at_within continuous_at mono_def add_mono ‹I ≠ {}› ‹c ≠ -∞› image_comp) qed
lemma SUP_ereal_add_right: fixes c :: ereal shows"I ≠ {} ==> c ≠ -∞==> (SUP i∈I. c + f i) = c + (SUP i∈I. f i)" using SUP_ereal_add_left[of I c f] by (simp add: add.commute)
lemma SUP_ereal_minus_right: assumes"I ≠ {}""c ≠ -∞" shows"(SUP i∈I. c - f i :: ereal) = c - (INF i∈I. f i)" using SUP_ereal_add_right[OF assms, of "λi. - f i"] by (simp add: ereal_SUP_uminus_eq minus_ereal_def)
lemma SUP_ereal_minus_left: assumes"I ≠ {}""c ≠∞" shows"(SUP i∈I. f i - c:: ereal) = (SUP i∈I. f i) - c" using SUP_ereal_add_left[OF ‹I ≠ {}›, of "-c" f] by (simp add: ‹c ≠∞› minus_ereal_def)
lemma INF_ereal_minus_right: assumes"I ≠ {}"and"∣c∣≠∞" shows"(INF i∈I. c - f i) = c - (SUP i∈I. f i::ereal)" proof - have *: "(- c) + b = - (c - b)"for b using‹∣c∣≠∞›by (cases c b rule: ereal2_cases) auto show ?thesis using SUP_ereal_add_right[OF ‹I ≠ {}›, of "-c" f] ‹∣c∣≠∞› by (auto simp: * ereal_SUP_uminus_eq) qed
lemma SUP_ereal_le_addI: fixes f :: "'i ==> ereal" assumes"∧i. f i + y ≤ z"and"y ≠ -∞" shows"Sup (f ` UNIV) + y ≤ z" by (metis SUP_ereal_add_left SUP_least UNIV_not_empty assms)
lemma SUP_combine: fixes f :: "'a::semilattice_sup ==> 'a::semilattice_sup ==> 'b::complete_lattice" assumes mono: "∧a b c d. a ≤ b ==> c ≤ d ==> f a c ≤ f b d" shows"(SUP i∈UNIV. SUP j∈UNIV. f i j) = (SUP i. f i i)" proof (rule antisym) show"(SUP i j. f i j) ≤ (SUP i. f i i)" by (rule SUP_least SUP_upper2[where i="sup i j"for i j] UNIV_I mono sup_ge1 sup_ge2)+ show"(SUP i. f i i) ≤ (SUP i j. f i j)" by (rule SUP_least SUP_upper2 UNIV_I mono order_refl)+ qed
lemma SUP_ereal_add: fixes f g :: "nat ==> ereal" assumes inc: "incseq f""incseq g" and pos: "∧i. f i ≠ -∞""∧i. g i ≠ -∞" shows"(SUP i. f i + g i) = Sup (f ` UNIV) + Sup (g ` UNIV)" proof - have"∧i j k l. [i ≤ j; k ≤ l]==> f i + g k ≤ f j + g l" by (meson add_mono inc incseq_def) thenhave"(SUP i. f i + g i) = (SUP i j. f i + g j)" by (simp add: SUP_combine) alsohave"... = (SUP i j. g j + f i)" by (simp add: add.commute) alsohave"... = (SUP i. Sup (range g) + f i)" by (simp add: SUP_ereal_add_left pos(1)) alsohave"... = (SUP i. f i + Sup (range g))" by (simp add: add.commute) alsohave"... = Sup (f ` UNIV) + Sup (g ` UNIV)" by (simp add: SUP_eq_iff SUP_ereal_add_left pos(2)) finallyshow ?thesis . qed
lemma INF_eq_minf: "(INF i∈I. f i::ereal) ≠ -∞⟷ (∃b>-∞. ∀i∈I. b ≤ f i)" unfolding bot_ereal_def[symmetric] INF_eq_bot_iff by (auto simp: not_less)
lemma INF_ereal_add_left: assumes"I ≠ {}""c ≠ -∞""∧x. x ∈ I ==> 0 ≤ f x" shows"(INF i∈I. f i + c :: ereal) = (INF i∈I. f i) + c" proof - have"(INF i∈I. f i) ≠ -∞" unfolding INF_eq_minf using assms by (intro exI[of _ 0]) auto thenshow ?thesis by (subst continuous_at_Inf_mono[where f="λx. x + c"])
(auto simp: mono_def add_mono ‹I ≠ {}›‹c ≠ -∞› continuous_at_imp_continuous_at_within
continuous_at image_comp) qed
lemma INF_ereal_add_right: assumes"I ≠ {}""c ≠ -∞""∧x. x ∈ I ==> 0 ≤ f x" shows"(INF i∈I. c + f i :: ereal) = c + (INF i∈I. f i)" using INF_ereal_add_left[OF assms] by (simp add: ac_simps)
lemma INF_ereal_add_directed: fixes f g :: "'a ==> ereal" assumes nonneg: "∧i. i ∈ I ==> 0 ≤ f i""∧i. i ∈ I ==> 0 ≤ g i" assumes directed: "∧i j. i ∈ I ==> j ∈ I ==>∃k∈I. f i + g j ≥ f k + g k" shows"(INF i∈I. f i + g i) = (INF i∈I. f i) + (INF i∈I. g i)" proof (cases "I = {}") case False show ?thesis proof (rule antisym) show"(INF i∈I. f i) + (INF i∈I. g i) ≤ (INF i∈I. f i + g i)" by (rule INF_greatest; intro add_mono INF_lower) next have"(INF i∈I. f i + g i) ≤ (INF i∈I. (INF j∈I. f i + g j))" using directed by (intro INF_greatest) (blast intro: INF_lower2) alsohave"… = (INF i∈I. f i + (INF i∈I. g i))" using nonneg ‹I ≠ {}›by (auto simp: INF_ereal_add_right) alsohave"… = (INF i∈I. f i) + (INF i∈I. g i)" using nonneg by (intro INF_ereal_add_left ‹I ≠ {}›) (auto simp: INF_eq_minf intro!: exI[of _ 0]) finallyshow"(INF i∈I. f i + g i) ≤ (INF i∈I. f i) + (INF i∈I. g i)" . qed qed (simp add: top_ereal_def)
lemma INF_ereal_add: fixes f :: "nat ==> ereal" assumes"decseq f""decseq g" and fin: "∧i. f i ≠∞""∧i. g i ≠∞" shows"(INF i. f i + g i) = Inf (f ` UNIV) + Inf (g ` UNIV)" proof - have INF_less: "(INF i. f i) < ∞""(INF i. g i) < ∞" using assms unfolding INF_less_iff by auto have *: "- ((- a) + (- b)) = a + b"if"a ≠∞""b ≠∞"for a b :: ereal using that by (cases a b rule: ereal2_cases) auto have"(INF i. f i + g i) = (INF i. - ((- f i) + (- g i)))" by (simp add: fin *) alsohave"… = Inf (f ` UNIV) + Inf (g ` UNIV)" unfolding ereal_INF_uminus_eq using assms INF_less by (subst SUP_ereal_add) (auto simp: ereal_SUP_uminus_eq fin *) finallyshow ?thesis . qed
lemma SUP_ereal_add_pos: fixes f g :: "nat ==> ereal" assumes"incseq f""incseq g" and"∧i. 0 ≤ f i""∧i. 0 ≤ g i" shows"(SUP i. f i + g i) = Sup (f ` UNIV) + Sup (g ` UNIV)" by (simp add: SUP_ereal_add assms)
lemma SUP_ereal_sum: fixes f g :: "'a ==> nat ==> ereal" assumes"∧n. n ∈ A ==> incseq (f n)" and pos: "∧n i. n ∈ A ==> 0 ≤ f n i" shows"(SUP i. ∑n∈A. f n i) = (∑n∈A. Sup ((f n) ` UNIV))" using assms by (induction A rule: infinite_finite_induct) (auto simp: incseq_sumI2 sum_nonneg SUP_ereal_add_pos)
lemma SUP_ereal_mult_left: fixes f :: "'a ==> ereal" assumes"I ≠ {}" assumes f: "∧i. i ∈ I ==> 0 ≤ f i"and c: "0 ≤ c" shows"(SUP i∈I. c * f i) = c * (SUP i∈I. f i)" proof (cases "(SUP i ∈ I. f i) = 0") case True thenhave"∧i. i ∈ I ==> f i = 0" by (metis SUP_upper f antisym) with True show ?thesis by simp next case False thenshow ?thesis by (subst continuous_at_Sup_mono[where f="λx. c * x"])
(auto simp: mono_def continuous_at continuous_at_imp_continuous_at_within ‹I ≠ {}› image_comp
intro!: ereal_mult_left_mono c) qed
lemma countable_approach: fixes x :: ereal assumes"x ≠ -∞" shows"∃f. incseq f ∧ (∀i::nat. f i < x) ∧ (f <---- x)" proof (cases x) case (real r) moreoverhave"(λn. r - inverse (real (Suc n))) <---- r - 0" by (intro tendsto_intros LIMSEQ_inverse_real_of_nat) ultimatelyshow ?thesis by (intro exI[of _ "λn. x - inverse (Suc n)"]) (auto simp: incseq_def) next case PInf with LIMSEQ_SUP[of "λn::nat. ereal (real n)"] show ?thesis by (intro exI[of _ "λn. ereal (real n)"]) (auto simp: incseq_def SUP_nat_Infty) qed (simp add: assms)
lemma Sup_countable_SUP: assumes"A ≠ {}" shows"∃f::nat ==> ereal. incseq f ∧ range f ⊆ A ∧ Sup A = (SUP i. f i)" proof cases assume"Sup A = -∞" with‹A ≠ {}›have"A = {-∞}" by (auto simp: Sup_eq_MInfty) thenshow ?thesis by (auto intro!: exI[of _ "λ_. -∞"] simp: bot_ereal_def) next assume"Sup A ≠ -∞" thenobtain l where"incseq l"and l: "l i < Sup A"and l_Sup: "l <---- Sup A"for i :: nat by (auto dest: countable_approach)
have"∃f. ∀n. (f n ∈ A ∧ l n ≤ f n) ∧ (f n ≤ f (Suc n))" (is"∃f. ?P f") proof (rule dependent_nat_choice) show"∃x. x ∈ A ∧ l 0 ≤ x" using l[of 0] by (auto simp: less_Sup_iff) next fix x n assume"x ∈ A ∧ l n ≤ x" moreoverfrom l[of "Suc n"] obtain y where"y ∈ A""l (Suc n) < y" by (auto simp: less_Sup_iff) ultimatelyshow"∃y. (y ∈ A ∧ l (Suc n) ≤ y) ∧ x ≤ y" by (auto intro!: exI[of _ "max x y"] split: split_max) qed thenobtain f where f: "?P f" .. thenhave"range f ⊆ A""incseq f" by (auto simp: incseq_Suc_iff) thenhave"(SUP i. f i) = Sup A" by (meson LIMSEQ_SUP LIMSEQ_le Sup_subset_mono f l_Sup
order_class.order_eq_iff) thenshow ?thesis by (metis ‹incseq f›‹range f ⊆ A›) qed
lemma Inf_countable_INF: assumes"A ≠ {}"shows"∃f::nat ==> ereal. decseq f ∧ range f ⊆ A ∧ Inf A = (INF i. f i)" proof - obtain f where"incseq f""range f ⊆ uminus`A""Sup (uminus`A) = (SUP i. f i)" using Sup_countable_SUP[of "uminus ` A"] ‹A ≠ {}›by auto thenshow ?thesis by (intro exI[of _ "λx. - f x"])
(auto simp: ereal_Sup_uminus_image_eq ereal_INF_uminus_eq eq_commute[of "- _"]) qed
lemma SUP_countable_SUP: "A ≠ {} ==>∃f::nat ==> ereal. range f ⊆ g`A ∧ Sup (g ` A) = Sup (f ` UNIV)" using Sup_countable_SUP [of "g`A"] by auto
subsection"Relation to 🍋‹enat›"
definition "ereal_of_enat n = (case n of enat n ==> ereal (real n) | ∞==>∞)"
lemma ereal_of_enat_inf[simp]: "ereal_of_enat n = ∞⟷ n = ∞" by (cases n) auto
lemma ereal_of_enat_add: "ereal_of_enat (m + n) = ereal_of_enat m + ereal_of_enat n" by (cases m n rule: enat2_cases) auto
lemma ereal_of_enat_sub: assumes "n ≤ m" shows "ereal_of_enat (m - n) = ereal_of_enat m - ereal_of_enat n " using assms by (cases m n rule: enat2_cases) auto
lemma ereal_of_enat_mult: "ereal_of_enat (m * n) = ereal_of_enat m * ereal_of_enat n" by (cases m n rule: enat2_cases) auto
lemma ereal_of_enat_nonneg: "ereal_of_enat n ≥0" by simp
lemma ereal_of_enat_Sup: assumes "A ≠ {}" shows "ereal_of_enat (Sup A) = (SUP a ∈ A. ereal_of_enat a)" proof (intro antisym mono_Sup) show "ereal_of_enat (Sup A) ≤ (SUP a ∈ A. ereal_of_enat a)" proof cases assume "finite A" with ‹A ≠ {}› obtain a where "a ∈ A" "ereal_of_enat (Sup A) = ereal_of_enat a" using Max_in[of A] by (auto simp: Sup_enat_def simp del: Max_in) then show ?thesis by (auto intro: SUP_upper) next assume "¬ finite A" have [simp]: "(SUP a ∈ A. ereal_of_enat a) = top" unfolding SUP_eq_top_iff proof safe fix x :: ereal assume "x < top" then obtain n :: nat where "x < n" using less_PInf_Ex_of_nat top_ereal_def by auto obtain a where "a ∈ A - enat ` {.. n}" by (metis ‹¬ finite A› all_not_in_conv finite_Diff2 finite_atMost finite_imageI finite.emptyI) then have "a ∈ A" "ereal n ≤ ereal_of_enat a" by (auto simp: image_iff Ball_def) (metis enat_iless enat_ord_simps(1) ereal_of_enat_less_iff ereal_of_enat_simps(1) less_le not_less) with ‹x < n› show "∃i∈A. x < ereal_of_enat i" by (auto intro!: bexI[of _ a]) qed show ?thesis by simp qed qed (simp add: mono_def)
lemma ereal_of_enat_SUP: "A ≠ {} ==> ereal_of_enat (SUP a∈A. f a) = (SUP a ∈ A. ereal_of_enat (f a))" by (simp add: ereal_of_enat_Sup image_comp)
subsection "Limits on 🍋‹ereal›"
lemma open_PInfty: "open A ==>∞∈ A ==> (∃x. {ereal x<..} ⊆ A)" unfolding open_ereal_generated proof (induct rule: generate_topology.induct) case (Int A B) thenobtain x z where"∞∈ A ==> {ereal x <..} ⊆ A""∞∈ B ==> {ereal z <..} ⊆ B" by auto with Int show ?case by (intro exI[of _ "max x z"]) fastforce next case (Basis S) moreoverhave"x ≠∞==>∃t. x ≤ ereal t"for x by (cases x) auto ultimatelyshow ?case by (auto split: ereal.split) qed (fastforce simp: vimage_Union)+
lemma open_MInfty: "open A ==> -∞∈ A ==> (∃x. {..<ereal x} ⊆ A)" unfolding open_ereal_generated proof (induct rule: generate_topology.induct) case (Int A B) thenobtain x z where"-∞∈ A ==> {..< ereal x} ⊆ A""-∞∈ B ==> {..< ereal z} ⊆ B" by auto with Int show ?case by (intro exI[of _ "min x z"]) fastforce next case (Basis S) moreoverhave"x ≠ -∞==>∃t. ereal t ≤ x"for x by (cases x) auto ultimatelyshow ?case by (auto split: ereal.split) qed (fastforce simp: vimage_Union)+
lemma open_ereal_vimage: "open S ==> open (ereal -` S)" by (intro open_vimage continuous_intros)
lemma open_ereal: "open S ==> open (ereal ` S)" unfolding open_generated_order[where 'a=real] proof (induct rule: generate_topology.induct) case (Basis S) moreoverhave"∧x. ereal ` {..< x} = { -∞ <..< ereal x }" using ereal_less_ereal_Ex by auto moreoverhave"∧x. ereal ` {x <..} = { ereal x <..< ∞ }" using less_ereal.elims(2) by fastforce ultimatelyshow ?case by auto qed (auto simp: image_Union image_Int)
lemma open_image_real_of_ereal: fixes X::"ereal set" assumes"open X" assumes infty: "∞∉ X""-∞∉ X" shows"open (real_of_ereal ` X)" proof - have"real_of_ereal ` X = ereal -` X" using infty ereal_real by (force simp: set_eq_iff) thus ?thesis by (auto intro!: open_ereal_vimage assms) qed
lemma eventually_finite: fixes x :: ereal assumes"∣x∣≠∞""(f ---> x) F" shows"eventually (λx. ∣f x∣≠∞) F" proof - have"(f ---> ereal (real_of_ereal x)) F" using assms by (cases x) auto thenhave"eventually (λx. f x ∈ ereal ` UNIV) F" by (rule topological_tendstoD) (auto intro: open_ereal) alsohave"(λx. f x ∈ ereal ` UNIV) = (λx. ∣f x∣≠∞)" by auto finallyshow ?thesis . qed
lemma open_ereal_def: "open A ⟷ open (ereal -` A) ∧ (∞∈ A ⟶ (∃x. {ereal x <..} ⊆ A)) ∧ (-∞∈ A ⟶ (∃x. {..<ereal x} ⊆ A))"
(is"open A ⟷ ?rhs") proof assume"open A" thenshow ?rhs using open_PInfty open_MInfty open_ereal_vimage by auto next assume"?rhs" thenobtain x y where A: "open (ereal -` A)""∞∈ A ==> {ereal x<..} ⊆ A""-∞∈ A ==> {..< ereal y} ⊆ A" by auto have *: "A = ereal ` (ereal -` A) ∪ (if ∞∈ A then {ereal x<..} else {}) ∪ (if -∞∈ A then {..< ereal y} else {})" using A(2,3) by auto from open_ereal[OF A(1)] show"open A" by (subst *) (auto simp: open_Un) qed
lemma open_PInfty2: assumes"open A"and"∞∈ A" obtains x where"{ereal x<..} ⊆ A" using open_PInfty[OF assms] by auto
lemma open_MInfty2: assumes"open A"and"-∞∈ A" obtains x where"{..<ereal x} ⊆ A" using open_MInfty[OF assms] by auto
lemma ereal_openE: assumes"open A" obtains x y where"open (ereal -` A)" and"∞∈ A ==> {ereal x<..} ⊆ A" and"-∞∈ A ==> {..<ereal y} ⊆ A" using assms open_ereal_def by auto
lemma ereal_open_cont_interval: fixes S :: "ereal set" assumes"open S" and"x ∈ S" and"∣x∣≠∞" obtains e where"e > 0"and"{x-e <..< x+e} ⊆ S" proof - from‹open S› have"open (ereal -` S)" by (rule ereal_openE) thenobtain e where"e > 0"and e: "dist y (real_of_ereal x) < e ==> ereal y ∈ S"for y using assms unfolding open_dist by force show thesis proof (intro that subsetI) show"0 < ereal e" using‹0 < e›by auto fix y assume"y ∈ {x - ereal e<..<x + ereal e}" with assms obtain t where"y = ereal t""dist t (real_of_ereal x) < e" by (cases y) (auto simp: dist_real_def) thenshow"y ∈ S" using e[of t] by auto qed qed
lemma ereal_open_cont_interval2: fixes S :: "ereal set" assumes"open S"and"x ∈ S"and"∣x∣≠∞" obtains a b where"a < x"and"x < b"and"{a <..< b} ⊆ S" by (meson assms ereal_between ereal_open_cont_interval)
subsubsection‹Convergent sequences›
lemma lim_real_of_ereal[simp]: assumes lim: "(f ---> ereal x) net" shows"((λx. real_of_ereal (f x)) ---> x) net" proof (intro topological_tendstoI) fix S assume"open S"and"x ∈ S" thenhave S: "open S""ereal x ∈ ereal ` S" by (simp_all add: inj_image_mem_iff) show"eventually (λx. real_of_ereal (f x) ∈ S) net" by (auto intro: eventually_mono [OF lim[THEN topological_tendstoD, OF open_ereal, OF S]]) qed
lemma lim_ereal[simp]: "((λn. ereal (f n)) ---> ereal x) net ⟷ (f ---> x) net" by (auto dest!: lim_real_of_ereal)
lemma convergent_real_imp_convergent_ereal: assumes"convergent a" shows"convergent (λn. ereal (a n))"and"lim (λn. ereal (a n)) = ereal (lim a)" proof - from assms obtain L where L: "a <---- L"unfolding convergent_def .. hence lim: "(λn. ereal (a n)) <---- ereal L"using lim_ereal by auto thus"convergent (λn. ereal (a n))"unfolding convergent_def .. thus"lim (λn. ereal (a n)) = ereal (lim a)"using lim L limI by metis qed
lemma tendsto_PInfty: "(f --->∞) F ⟷ (∀r. eventually (λx. ereal r < f x) F)" proof -
{ fix l :: ereal assume"∀r. eventually (λx. ereal r < f x) F" from this[THEN spec, of "real_of_ereal l"] have"l ≠∞==> eventually (λx. l < f x) F" by (cases l) (auto elim: eventually_mono)
} thenshow ?thesis by (auto simp: order_tendsto_iff) qed
lemma tendsto_PInfty': "(f --->∞) F = (∀r>c. eventually (λx. ereal r < f x) F)" proof -
{ fix r :: real assume"∀r>c. eventually (λx. ereal r < f x) F" thenhave"eventually (λx. ereal r < f x) F" if"r > c"for r using that by blast thenhave"eventually (λx. ereal r < f x) F" by (smt (verit, del_insts) ereal_less_le eventually_mono gt_ex)
} thenshow ?thesis using tendsto_PInfty by blast qed
lemma tendsto_PInfty_eq_at_top: "((λz. ereal (f z)) --->∞) F ⟷ (LIM z F. f z :> at_top)" unfolding tendsto_PInfty filterlim_at_top_dense by simp
lemma tendsto_MInfty: "(f ---> -∞) F ⟷ (∀r. eventually (λx. f x < ereal r) F)" unfolding tendsto_def proof safe fix S :: "ereal set" assume"open S""-∞∈ S" from open_MInfty[OF this] obtain B where"{..<ereal B} ⊆ S" .. moreover assume"∀r::real. eventually (λz. f z < r) F" thenhave"eventually (λz. f z ∈ {..< B}) F" by auto ultimatelyshow"eventually (λz. f z ∈ S) F" by (auto elim!: eventually_mono) next fix x assume"∀S. open S ⟶ -∞∈ S ⟶ eventually (λx. f x ∈ S) F" from this[rule_format, of "{..< ereal x}"] show"eventually (λy. f y < ereal x) F" by auto qed
lemma tendsto_MInfty': "(f ---> -∞) F = (∀r<c. eventually (λx. ereal r > f x) F)" proof (subst tendsto_MInfty, intro iffI allI impI) assume A: "∀r<c. eventually (λx. ereal r > f x) F" fix r :: real from A have A: "eventually (λx. ereal r > f x) F"if"r < c"for r using that by blast show"eventually (λx. ereal r > f x) F" proof (cases "r < c") case False hence B: "ereal r ≥ ereal (c - 1)"by simp have"c > c - 1"by simp from A[OF this] show"eventually (λx. ereal r > f x) F" by eventually_elim (erule less_le_trans[OF _ B]) qed (simp add: A) qed simp
lemma Lim_PInfty: "f <----∞⟷ (∀B. ∃N. ∀n≥N. f n ≥ ereal B)" unfolding tendsto_PInfty eventually_sequentially proof safe fix r assume"∀r. ∃N. ∀n≥N. ereal r ≤ f n" thenobtain N where"∀n≥N. ereal (r + 1) ≤ f n" by blast moreoverhave"ereal r < ereal (r + 1)" by auto ultimatelyshow"∃N. ∀n≥N. ereal r < f n" by (blast intro: less_le_trans) qed (blast intro: less_imp_le)
lemma Lim_MInfty: "f <---- -∞⟷ (∀B. ∃N. ∀n≥N. ereal B ≥ f n)" unfolding tendsto_MInfty eventually_sequentially proof safe fix r assume"∀r. ∃N. ∀n≥N. f n ≤ ereal r" thenobtain N where"∀n≥N. f n ≤ ereal (r - 1)" by blast moreoverhave"ereal (r - 1) < ereal r" by auto ultimatelyshow"∃N. ∀n≥N. f n < ereal r" by (blast intro: le_less_trans) qed (blast intro: less_imp_le)
lemma Lim_bounded_PInfty: "f <---- l ==> (∧n. f n ≤ ereal B) ==> l ≠∞" using LIMSEQ_le_const2[of f l "ereal B"] by auto
lemma Lim_bounded_MInfty: "f <---- l ==> (∧n. ereal B ≤ f n) ==> l ≠ -∞" using LIMSEQ_le_const[of f l "ereal B"] by auto
lemma tendsto_zero_erealI: assumes"∧e. e > 0 ==> eventually (λx. ∣f x∣ < ereal e) F" shows"(f ---> 0) F" proof (subst filterlim_cong[OF refl refl]) from assms[OF zero_less_one] show"eventually (λx. f x = ereal (real_of_ereal (f x))) F" by eventually_elim (auto simp: ereal_real) hence"eventually (λx. abs (real_of_ereal (f x)) < e) F"if"e > 0"for e using assms[OF that] by eventually_elim (simp add: real_less_ereal_iff that) hence"((λx. real_of_ereal (f x)) ---> 0) F"unfolding tendsto_iff by (auto simp: tendsto_iff dist_real_def) thus"((λx. ereal (real_of_ereal (f x))) ---> 0) F"by (simp add: zero_ereal_def) qed
lemma Lim_bounded_PInfty2: "f <---- l ==>∀n≥N. f n ≤ ereal B ==> l ≠∞" using LIMSEQ_le_const2[of f l "ereal B"] by fastforce
lemma real_of_ereal_mult[simp]: fixes a b :: ereal shows"real_of_ereal (a * b) = real_of_ereal a * real_of_ereal b" by (cases rule: ereal2_cases[of a b]) auto
lemma real_of_ereal_eq_0: fixes x :: ereal shows"real_of_ereal x = 0 ⟷ x = ∞∨ x = -∞∨ x = 0" by (cases x) auto
lemma tendsto_ereal_realD: fixes f :: "'a ==> ereal" assumes"x ≠ 0" and tendsto: "((λx. ereal (real_of_ereal (f x))) ---> x) net" shows"(f ---> x) net" proof (intro topological_tendstoI) fix S assume S: "open S""x ∈ S" with‹x ≠ 0›have"open (S - {0})""x ∈ S - {0}" by auto from tendsto[THEN topological_tendstoD, OF this] show"eventually (λx. f x ∈ S) net" by (rule eventually_rev_mp) (auto simp: ereal_real) qed
lemma tendsto_ereal_realI: fixes f :: "'a ==> ereal" assumes x: "∣x∣≠∞"and tendsto: "(f ---> x) net" shows"((λx. ereal (real_of_ereal (f x))) ---> x) net" proof (intro topological_tendstoI) fix S assume"open S"and"x ∈ S" with x have"open (S - {∞, -∞})""x ∈ S - {∞, -∞}" by auto from tendsto[THEN topological_tendstoD, OF this] show"eventually (λx. ereal (real_of_ereal (f x)) ∈ S) net" by (elim eventually_mono) (auto simp: ereal_real) qed
lemma ereal_mult_cancel_left: fixes a b c :: ereal shows"a * b = a * c ⟷ (∣a∣ = ∞∧ 0 < b * c) ∨ a = 0 ∨ b = c" by (cases rule: ereal3_cases[of a b c]) (simp_all add: zero_less_mult_iff)
lemma tendsto_add_ereal: fixes x y :: ereal assumes x: "∣x∣≠∞"and y: "∣y∣≠∞" assumes f: "(f ---> x) F"and g: "(g ---> y) F" shows"((λx. f x + g x) ---> x + y) F" proof - from x obtain r where x': "x = ereal r"by (cases x) auto with f have"((λi. real_of_ereal (f i)) ---> r) F"by simp moreover from y obtain p where y': "y = ereal p"by (cases y) auto with g have"((λi. real_of_ereal (g i)) ---> p) F"by simp ultimatelyhave"((λi. real_of_ereal (f i) + real_of_ereal (g i)) ---> r + p) F" by (rule tendsto_add) moreover from eventually_finite[OF x f] eventually_finite[OF y g] have"eventually (λx. f x + g x = ereal (real_of_ereal (f x) + real_of_ereal (g x))) F" by eventually_elim auto ultimatelyshow ?thesis by (simp add: x' y' cong: filterlim_cong) qed
lemma tendsto_add_ereal_nonneg: fixes x y :: "ereal" assumes"x ≠ -∞""y ≠ -∞""(f ---> x) F""(g ---> y) F" shows"((λx. f x + g x) ---> x + y) F" proof (cases "x = ∞∨ y = ∞") case True moreover
{ fix y :: ereal and f g :: "'a ==> ereal"assume"y ≠ -∞""(f --->∞) F""(g ---> y) F" thenobtain y' where"-∞ < y'""y' < y" using dense[of "-∞" y] by auto have"((λx. f x + g x) --->∞) F" proof (rule tendsto_sandwich) have"∀F x in F. y' < g x" using order_tendstoD(1)[OF ‹(g ---> y) F›‹y' < y›] by auto thenshow"∀F x in F. f x + y' ≤ f x + g x" by eventually_elim (auto intro!: add_mono) show"∀F n in F. f n + g n ≤∞""((λn. ∞) --->∞) F" by auto show"((λx. f x + y') --->∞) F" using tendsto_cadd_ereal[of y' ∞ f F] ‹(f --->∞) F›‹-∞ < y'›by auto qed } note this[of y f g] this[of x g f] ultimatelyshow ?thesis using assms by (auto simp: add_ac) next case False with assms tendsto_add_ereal[of x y f F g] show ?thesis by auto qed
lemma ereal_inj_affinity: fixes m t :: ereal assumes"∣m∣≠∞" and"m ≠ 0" and"∣t∣≠∞" shows"inj_on (λx. m * x + t) A" using assms by (cases rule: ereal2_cases[of m t])
(auto intro!: inj_onI simp: ereal_add_cancel_right ereal_mult_cancel_left)
lemma ereal_PInfty_eq_plus[simp]: fixes a b :: ereal shows"∞ = a + b ⟷ a = ∞∨ b = ∞" by (cases rule: ereal2_cases[of a b]) auto
lemma ereal_MInfty_eq_plus[simp]: fixes a b :: ereal shows"-∞ = a + b ⟷ (a = -∞∧ b ≠∞) ∨ (b = -∞∧ a ≠∞)" by (cases rule: ereal2_cases[of a b]) auto
lemma ereal_less_divide_pos: fixes x y :: ereal shows"x > 0 ==> x ≠∞==> y < z / x ⟷ x * y < z" by (simp add: ereal_less_divide_iff mult.commute)
lemma ereal_divide_less_pos: fixes x y z :: ereal shows"x > 0 ==> x ≠∞==> y / x < z ⟷ y < x * z" by (simp add: ereal_divide_less_iff mult.commute)
lemma ereal_divide_eq: fixes a b c :: ereal shows"b ≠ 0 ==>∣b∣≠∞==> a / b = c ⟷ a = b * c" by (metis ereal_divide_same ereal_times_divide_eq mult.commute
mult.right_neutral)
lemma ereal_inverse_not_MInfty[simp]: "inverse (a::ereal) ≠ -∞" by (cases a) auto
lemma ereal_mult_m1[simp]: "x * ereal (-1) = -x" by (cases x) auto
lemma ereal_real': assumes"∣x∣≠∞" shows"ereal (real_of_ereal x) = x" using assms by auto
lemma real_ereal_id: "real_of_ereal ∘ ereal = id" by auto
lemma ereal_le_distrib: fixes a b c :: ereal shows"c * (a + b) ≤ c * a + c * b" by (cases rule: ereal3_cases[of a b c])
(auto simp: field_simps not_le mult_le_0_iff mult_less_0_iff)
lemma ereal_pos_distrib: fixes a b c :: ereal assumes"0 ≤ c" and"c ≠∞" shows"c * (a + b) = c * a + c * b" using assms by (cases rule: ereal3_cases[of a b c])
(auto simp: field_simps not_le mult_le_0_iff mult_less_0_iff)
lemma ereal_LimI_finite: fixes x :: ereal assumes"∣x∣≠∞" and"∧r. 0 < r ==>∃N. ∀n≥N. u n < x + r ∧ x < u n + r" shows"u <---- x" proof (rule topological_tendstoI, unfold eventually_sequentially) obtain rx where rx: "x = ereal rx" using assms by (cases x) auto fix S assume"open S"and"x ∈ S" thenhave"open (ereal -` S)" unfolding open_ereal_def by auto with‹x ∈ S›obtain r where"0 < r"and dist: "dist y rx < r ==> ereal y ∈ S"for y unfolding open_dist rx by auto thenobtain n where upper: "u N < x + ereal r" and lower: "x < u N + ereal r" if"n ≤ N"for N using assms(2)[of "ereal r"] by auto show"∃N. ∀n≥N. u n ∈ S" proof (safe intro!: exI[of _ n]) fix N assume"n ≤ N" from upper[OF this] lower[OF this] assms ‹0 < r› have"u N ∉ {∞,(-∞)}" by auto thenobtain ra where ra_def: "(u N) = ereal ra" by (cases "u N") auto thenhave"rx < ra + r"and"ra < rx + r" using rx assms ‹0 < r› lower[OF ‹n ≤ N›] upper[OF ‹n ≤ N›] by auto thenhave"dist (real_of_ereal (u N)) rx < r" using rx ra_def by (auto simp: dist_real_def abs_diff_less_iff field_simps) from dist[OF this] show"u N ∈ S" using‹u N ∉ {∞, -∞}› by (auto simp: ereal_real split: if_split_asm) qed qed
lemma tendsto_obtains_N: assumes"f <---- f0""open S""f0 ∈ S" obtains N where"∀n≥N. f n ∈ S" using assms lim_explicit by blast
lemma ereal_LimI_finite_iff: fixes x :: ereal assumes"∣x∣≠∞" shows"u <---- x ⟷ (∀r. 0 < r ⟶ (∃N. ∀n≥N. u n < x + r ∧ x < u n + r))"
(is"?lhs ⟷ ?rhs") proof assume lim: "u <---- x"
{ fix r :: ereal assume"r > 0" thenobtain N where"∀n≥N. u n ∈ {x - r <..< x + r}" using lim ereal_between[of x r] assms ‹r > 0› tendsto_obtains_N[of u x "{x - r <..< x + r}"] by auto thenhave"∃N. ∀n≥N. u n < x + r ∧ x < u n + r" using ereal_minus_less[of r x] by (cases r) auto
} thenshow ?rhs by auto next assume ?rhs thenshow"u <---- x" using ereal_LimI_finite[of x] assms by auto qed
lemma ereal_Limsup_uminus: fixes f :: "'a ==> ereal" shows"Limsup net (λx. - (f x)) = - Liminf net f" unfolding Limsup_def Liminf_def ereal_SUP_uminus_eq ereal_INF_uminus_eq ..
lemma liminf_bounded_iff: fixes x :: "nat ==> ereal" shows"C ≤ liminf x ⟷ (∀B<C. ∃N. ∀n≥N. B < x n)"
(is"?lhs ⟷ ?rhs") unfolding le_Liminf_iff eventually_sequentially ..
lemma Liminf_add_le: fixes f g :: "_ ==> ereal" assumes F: "F ≠ bot" assumes ev: "eventually (λx. 0 ≤ f x) F""eventually (λx. 0 ≤ g x) F" shows"Liminf F f + Liminf F g ≤ Liminf F (λx. f x + g x)" unfolding Liminf_def proof (subst SUP_ereal_add_left[symmetric]) let ?F = "{P. eventually P F}" let ?INF = "λP g. Inf (g ` (Collect P))" show"?F ≠ {}" by (auto intro: eventually_True) show"(SUP P∈?F. ?INF P g) ≠ -∞" unfolding bot_ereal_def[symmetric] SUP_bot_conv INF_eq_bot_iff by (auto intro!: exI[of _ 0] ev simp: bot_ereal_def) have"(SUP P∈?F. ?INF P f + (SUP P∈?F. ?INF P g)) ≤ (SUP P∈?F. (SUP P'∈?F. ?INF P f + ?INF P' g))" proof (safe intro!: SUP_mono bexI[of _ "λx. P x ∧ 0 ≤ f x"for P]) fix P let ?P' = "λx. P x ∧ 0 ≤ f x" assume"eventually P F" with ev show"eventually ?P' F" by eventually_elim auto have"?INF P f + (SUP P∈?F. ?INF P g) ≤ ?INF ?P' f + (SUP P∈?F. ?INF P g)" by (intro add_mono INF_mono) auto alsohave"… = (SUP P'∈?F. ?INF ?P' f + ?INF P' g)" proof (rule SUP_ereal_add_right[symmetric]) show"Inf (f ` {x. P x ∧ 0 ≤ f x}) ≠ -∞" unfolding bot_ereal_def[symmetric] INF_eq_bot_iff by (auto intro!: exI[of _ 0] ev simp: bot_ereal_def) qed fact finallyshow"?INF P f + (SUP P∈?F. ?INF P g) ≤ (SUP P'∈?F. ?INF ?P' f + ?INF P' g)" . qed alsohave"…≤ (SUP P∈?F. INF x∈Collect P. f x + g x)" proof (safe intro!: SUP_least) fix P Q assume *: "eventually P F""eventually Q F" show"?INF P f + ?INF Q g ≤ (SUP P∈?F. INF x∈Collect P. f x + g x)" proof (rule SUP_upper2) show"(λx. P x ∧ Q x) ∈ ?F" using * by (auto simp: eventually_conj) show"?INF P f + ?INF Q g ≤ (INF x∈{x. P x ∧ Q x}. f x + g x)" by (intro INF_greatest add_mono) (auto intro: INF_lower) qed qed finallyshow"(SUP P∈?F. ?INF P f + (SUP P∈?F. ?INF P g)) ≤ (SUP P∈?F. INF x∈Collect P. f x + g x)" . qed
lemma Sup_ereal_mult_right': assumes nonempty: "Y ≠ {}" and x: "x ≥ 0" shows"(SUP i∈Y. f i) * ereal x = (SUP i∈Y. f i * ereal x)" (is"?lhs = ?rhs") proof(cases "x = 0") case True thus ?thesis by(auto simp: nonempty zero_ereal_def[symmetric]) next case False show ?thesis proof(rule antisym) show"?rhs ≤ ?lhs" by(rule SUP_least)(simp add: ereal_mult_right_mono SUP_upper x) next have"?lhs / ereal x = (SUP i∈Y. f i) * (ereal x / ereal x)"by(simp only: ereal_times_divide_eq) alsohave"… = (SUP i∈Y. f i)"using False by simp alsohave"…≤ ?rhs / x" proof(rule SUP_least) fix i assume"i ∈ Y" have"f i = f i * (ereal x / ereal x)"using False by simp alsohave"… = f i * x / x"by(simp only: ereal_times_divide_eq) alsofrom‹i ∈ Y›have"f i * x ≤ ?rhs"by(rule SUP_upper) hence"f i * x / x ≤ ?rhs / x"using x False by simp finallyshow"f i ≤ ?rhs / x" . qed finallyhave"(?lhs / x) * x ≤ (?rhs / x) * x" by(rule ereal_mult_right_mono)(simp add: x) alsohave"… = ?rhs"using False ereal_divide_eq mult.commute by force alsohave"(?lhs / x) * x = ?lhs"using False ereal_divide_eq mult.commute by force finallyshow"?lhs ≤ ?rhs" . qed qed
lemma Sup_ereal_mult_left': "[ Y ≠ {}; x ≥ 0 ]==> ereal x * (SUP i∈Y. f i) = (SUP i∈Y. ereal x * f i)" by (smt (verit) Sup.SUP_cong Sup_ereal_mult_right' mult.commute)
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" shows"sup_continuous (λx. f x + g x)" unfolding sup_continuous_def proof safe fix M :: "nat ==> 'a"assume"incseq M" thenshow"f (SUP i. M i) + g (SUP i. M i) = (SUP i. f (M i) + g (M i))" using SUP_ereal_add_pos[of "λi. f (M i)""λi. g (M i)"] nn
cont[THEN sup_continuous_mono] cont[THEN sup_continuousD] by (auto simp: mono_def) qed
lemma sup_continuous_mult_right[order_continuous_intros]: "0 ≤ c ==> c < ∞==> sup_continuous f ==> sup_continuous (λx. f x * c :: ereal)" by (cases c) (auto simp: sup_continuous_def fun_eq_iff Sup_ereal_mult_right')
lemma sup_continuous_mult_left[order_continuous_intros]: "0 ≤ c ==> c < ∞==> sup_continuous f ==> sup_continuous (λx. c * f x :: ereal)" using sup_continuous_mult_right[of c f] by (simp add: mult_ac)
lemma sup_continuous_ereal_of_enat[order_continuous_intros]: assumes f: "sup_continuous f" shows"sup_continuous (λx. ereal_of_enat (f x))" by (metis UNIV_not_empty ereal_of_enat_SUP f sup_continuous_compose
sup_continuous_def)
subsubsection‹Sums›
lemma sums_ereal_positive: fixes f :: "nat ==> ereal" assumes"∧i. 0 ≤ f i" shows"f sums (SUP n. ∑i<n. f i)" by (simp add: LIMSEQ_SUP assms incseq_sumI sums_def)
lemma summable_ereal_pos: fixes f :: "nat ==> 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<n. f i)" using sums_ereal_positive[of f, OF assms, THEN sums_unique] by simp
lemma suminf_bound: fixes f :: "nat ==> ereal" assumes"∀N. (∑n<N. f n) ≤ x""∧n. 0 ≤ f n" shows"suminf f ≤ x" by (simp add: SUP_least assms suminf_ereal_eq_SUP)
lemma suminf_bound_add: fixes f :: "nat ==> ereal" assumes"∀N. (∑n<N. f n) + y ≤ x" and"∧n. 0 ≤ f n" and"y ≠ -∞" shows"suminf f + y ≤ x" by (simp add: SUP_ereal_le_addI assms suminf_ereal_eq_SUP)
lemma suminf_upper: fixes f :: "nat ==> ereal" assumes"∧n. 0 ≤ f n" shows"(∑n<N. f 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" by (meson assms order_trans suminf_le summable_ereal_pos)
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""∧i. 0 ≤ g i" shows"(∑i. f i + g i) = suminf f + suminf g" proof - have"(SUP n. ∑i<n. f i + g i) = (SUP n. sum f {..<n}) + (SUP n. sum g {..<n})" unfolding sum.distrib by (intro assms add_nonneg_nonneg SUP_ereal_add_pos incseq_sumI sum_nonneg ballI) with assms show ?thesis by (simp add: suminf_ereal_eq_SUP) qed
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 (simp add: assms sum_nonneg suminf_ereal_eq_SUP sum_ereal_right_distrib flip: 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<Suc i. f i) ≠∞" by auto thenshow ?thesis unfolding sum_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" by (metis abs_ereal_ge0 abs_neq_infinity_cases assms suminf_PInfty) thenshow ?thesis by metis 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 thenshow"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 - have0: "0 ≤ f i"for i using ord order_trans by blast moreover obtain f' where [simp]: "f = (λx. ereal (f' x))" using0 fin(1) suminf_PInfty_fun by presburger obtain g' where [simp]: "g = (λx. ereal (g' x))" using fin(2) ord(2) suminf_PInfty_fun by presburger have"0 ≤ f i - g i"for i using ord(1) by auto moreover have"suminf (λi. f i - g i) ≤ suminf f" using assms by (auto intro!: suminf_le_pos simp: field_simps) thenhave"suminf (λi. f i - g i) ≠∞" using fin by auto ultimatelyshow ?thesis using assms ‹∧i. 0 ≤ f i› apply simp apply (subst (123) suminf_ereal) apply (auto intro!: suminf_diff[symmetric] summable_ereal) done 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_of_ereal (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 have fin: "∣f i∣≠∞"for i by (simp add: assms(2) f suminf_PInfty) have"(λi. ereal (real_of_ereal (f i))) sums (∑i. ereal (real_of_ereal (f i)))" using f by (auto intro!: summable_ereal_pos simp: ereal_le_real_iff zero_ereal_def) alsohave"… = ereal r" using fin r by (auto simp: ereal_real) finallyshow"∃r. (λi. real_of_ereal (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 - have *: "∧n. (∑i<n. SUP k. f k i) = (SUP k. ∑i<n. f k i)" using assms by (auto intro!: SUP_ereal_sum [symmetric]) show ?thesis using assms by (auto simp: suminf_ereal_eq_SUP SUP_upper2 * intro!: SUP_commute) qed
lemma suminf_sum_ereal: fixes f :: "_ ==> _ ==> ereal" assumes nonneg: "∧i a. a ∈ A ==> 0 ≤ f i a" shows"(∑i. ∑a∈A. f i a) = (∑a∈A. ∑i. f i a)" using nonneg by (induction A rule: infinite_finite_induct; simp add: suminf_add_ereal sum_nonneg)
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) alsohave"f i = (∑j. if j = i then f i else 0)" by (subst suminf_finite[where N="{i}"]) auto alsohave"…≤ (∑i. f i)" using nneg by (auto intro!: suminf_le_pos) finallyhave False using‹(∑i. f i) = 0›by auto
} thenshow"∀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<n. f (i + k)) <---- (∑i. f (i + k))" using summable_sums[OF summable_ereal_pos] by (simp add: sums_def atLeast0LessThan f) moreoverhave"(λn. ∑i<n. f i) <---- (∑i. f i)" using summable_sums[OF summable_ereal_pos] by (simp add: sums_def atLeast0LessThan f) thenhave"(λn. ∑i<n + k. f i) <---- (∑i. f i)" by (rule LIMSEQ_ignore_initial_segment) ultimatelyshow ?thesis proof (rule LIMSEQ_le, safe intro!: exI[of _ k]) fix n assume"k ≤ n" have"(∑i<n. f (i + k)) = (∑i<n. (f ∘ plus k) i)" by (simp add: ac_simps) alsohave"… = (∑i∈(plus k) ` {..<n}. f i)" by (rule sum.reindex [symmetric]) simp alsohave"…≤ sum f {..<n + k}" by (intro sum_mono2) (auto simp: f) finallyshow"(∑i<n. f (i + k)) ≤ sum f {..<n + k}" . qed qed
lemma sums_suminf_ereal: "f sums x ==> (∑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: summable_def simp flip: sums_ereal sums_unique)
lemma SUP_ereal_add_directed: fixes f g :: "'a ==> ereal" assumes nonneg: "∧i. i ∈ I ==> 0 ≤ f i""∧i. i ∈ I ==> 0 ≤ g i" assumes directed: "∧i j. i ∈ I ==> j ∈ I ==>∃k∈I. f i + g j ≤ f k + g k" shows"(SUP i∈I. f i + g i) = (SUP i∈I. f i) + (SUP i∈I. g i)" proof cases assume"I = {}"thenshow ?thesis by (simp add: bot_ereal_def) next assume"I ≠ {}" show ?thesis proof (rule antisym) show"(SUP i∈I. f i + g i) ≤ (SUP i∈I. f i) + (SUP i∈I. g i)" by (rule SUP_least; intro add_mono SUP_upper) next have"bot < (SUP i∈I. g i)" using‹I ≠ {}› nonneg(2) by (auto simp: bot_ereal_def less_SUP_iff) thenhave"(SUP i∈I. f i) + (SUP i∈I. g i) = (SUP i∈I. f i + (SUP i∈I. g i))" by (intro SUP_ereal_add_left[symmetric] ‹I ≠ {}›) auto alsohave"… = (SUP i∈I. (SUP j∈I. f i + g j))" using nonneg(1) ‹I ≠ {}›by (simp add: SUP_ereal_add_right) alsohave"…≤ (SUP i∈I. f i + g i)" using directed by (intro SUP_least) (blast intro: SUP_upper2) finallyshow"(SUP i∈I. f i) + (SUP i∈I. g i) ≤ (SUP i∈I. f i + g i)" . qed qed
lemma SUP_ereal_sum_directed: fixes f g :: "'a ==> 'b ==> ereal" assumes"I ≠ {}" assumes directed: "∧N i j. N ⊆ A ==> i ∈ I ==> j ∈ I ==>∃k∈I. ∀n∈N. f n i ≤ f n k∧ f n j ≤ f n k" assumes nonneg: "∧n i. i ∈ I ==> n ∈ A ==> 0 ≤ f n i" shows"(SUP i∈I. ∑n∈A. f n i) = (∑n∈A. SUP i∈I. f n i)" proof - have"N ⊆ A ==> (SUP i∈I. ∑n∈N. f n i) = (∑n∈N. SUP i∈I. f n i)"for N proof (induction N rule: infinite_finite_induct) case (insert n N) have"(SUP i∈I. f n i + (∑l∈N. f l i)) = (SUP i∈I. f n i) + (SUP i∈I. ∑l∈N. f l i)" proof (rule SUP_ereal_add_directed) fix i assume"i ∈ I"thenshow"0 ≤ f n i""0 ≤ (∑l∈N. f l i)" using insert by (auto intro!: sum_nonneg nonneg) next fix i j assume"i ∈ I""j ∈ I" from directed[OF insert(4) this] show"∃k∈I. f n i + (∑l∈N. f l j) ≤ f n k + (∑l∈N. f l k)" by (auto intro!: add_mono sum_mono) qed with insert show ?case by simp qed (simp_all add: SUP_constant ‹I ≠ {}›) from this[of A] show ?thesis by simp qed
lemma suminf_SUP_eq_directed: fixes f :: "_ ==> nat ==> ereal" assumes"I ≠ {}" assumes directed: "∧N i j. i ∈ I ==> j ∈ I ==> finite N ==>∃k∈I. ∀n∈N. f i n ≤ f k n ∧ f j n ≤ f k n" assumes nonneg: "∧n i. 0 ≤ f n i" shows"(∑i. SUP n∈I. f n i) = (SUP n∈I. ∑i. f n i)" proof (subst (12) suminf_ereal_eq_SUP) show"∧n i. 0 ≤ f n i""∧i. 0 ≤ (SUP n∈I. f n i)" using‹I ≠ {}› nonneg by (auto intro: SUP_upper2) show"(SUP n. ∑i<n. SUP n∈I. f n i) = (SUP n∈I. SUP j. ∑i<j. f n i)" by (auto simp: finite_subset SUP_commute SUP_ereal_sum_directed assms) 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_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"continuous_on UNIV (λx. inverse m * (x + - t))" using m t by (intro continuous_at_imp_continuous_on ballI continuous_at[THEN iffD2]; force) thenhave"open ((λx. inverse m * (x + -t)) -` S)" using‹open S› open_vimage by blast alsohave"(λx. inverse m * (x + -t)) -` S = (λx. (x - t) / m) -` S" using m t by (auto simp: divide_ereal_def mult.commute minus_ereal_def
simp flip: uminus_ereal.simps) alsohave"(λ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) finallyshow ?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" thenshow ?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 thenhave 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: ― ‹RENAME› 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 assumes1: "limsup X ≤ L"and2: "L ≤ liminf X" shows"X <---- L" proof - from12have"limsup X ≤ liminf X"by auto hence3: "limsup X = liminf X" by (simp add: Liminf_le_Limsup order_class.order.antisym) hence4: "convergent (λn. ereal (X n))" by (subst convergent_ereal) hence"limsup X = lim (λn. ereal(X n))" by (rule convergent_limsup_cl) alsofrom123have"limsup X = L"by auto finallyhave"lim (λn. ereal(X n)) = L" .. hence"(λn. ereal (X n)) <---- L" using"4" convergent_LIMSEQ_iff by force 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 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" thenhave"(λi. ereal (f i)) <---- ereal x" by auto from SUP_Lim[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 thenshow ?thesis by (simp add: Liminf_const) next case (real r) thenshow ?thesis by (simp add: liminf_SUP_INF limsup_INF_SUP INF_ereal_minus_right SUP_ereal_minus_right) qed (use‹c ≠ -∞›in simp)
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)
lemma inverse_infty_ereal_tendsto_0: "inverse ←-∞→ (0::ereal)" proof - have **: "((λx. ereal (inverse x)) ---> ereal 0) at_infinity" by (intro tendsto_intros tendsto_inverse_0) thenhave"((λx. if x = 0 then ∞ else ereal (inverse x)) ---> 0) at_top" proof (rule filterlim_mono_eventually) show"nhds (ereal 0) ≤ nhds 0" by (simp add: zero_ereal_def) show"(at_top::real filter) ≤ at_infinity" by (simp add: at_top_le_at_infinity) qed auto thenshow ?thesis unfolding at_infty_ereal_eq_at_top tendsto_compose_filtermap[symmetric] comp_def by auto qed
lemma inverse_ereal_tendsto_pos: fixes x :: ereal assumes"0 < x" shows"inverse ←-x→ inverse x" proof (cases x) case (real r) with‹0 < x›have **: "(λx. ereal (inverse x)) ←-r→ ereal (inverse r)" by (auto intro!: tendsto_inverse) from real ‹0 < x›show ?thesis by (auto simp: at_ereal tendsto_compose_filtermap[symmetric] eventually_at_filter
intro!: Lim_transform_eventually[OF **] t1_space_nhds) qed (insert ‹0 < x›, auto intro!: inverse_infty_ereal_tendsto_0)
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_of_ereal" 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_of_ereal ∘ f)" proof assume L: "continuous_on A f" have"f ` A ⊆ UNIV - {∞, -∞}" using assms by force thenshow"continuous_on A (real_of_ereal ∘ f)" by (meson L continuous_on_compose continuous_on_real continuous_on_subset) next assume R: "continuous_on A (real_of_ereal ∘ f)" thenhave"continuous_on A (ereal ∘ (real_of_ereal ∘ f))" by (meson continuous_at_iff_ereal continuous_on_eq_continuous_within) thenshow"continuous_on A f" using assms ereal_real' by auto qed
lemma continuous_uminus_ereal [continuous_intros]: "continuous_on (A :: ereal set) uminus" unfolding continuous_on_def by (intro ballI tendsto_uminus_ereal[of "λx. x::ereal"]) simp
lemma continuous_on_inverse_ereal [continuous_intros]: "continuous_on {0::ereal ..} inverse" unfolding continuous_on_def proof clarsimp fix x :: ereal assume"0 ≤ x" moreoverhave"at 0 within {0 ..} = at_right (0::ereal)" by (auto simp: filter_eq_iff eventually_at_filter le_less) moreoverhave"at x within {0 ..} = at x"if"0 < x" using that by (intro at_within_nhd[of _ "{0<..}"]) auto ultimatelyshow"(inverse ---> inverse x) (at x within {0..})" by (auto simp: le_less inverse_ereal_tendsto_at_right_0 inverse_ereal_tendsto_pos) qed
lemma continuous_inverse_ereal_nonpos: "continuous_on ({..<0} :: ereal set) inverse" proof (subst continuous_on_cong[OF refl]) have"continuous_on {(0::ereal)<..} inverse" by (rule continuous_on_subset[OF continuous_on_inverse_ereal]) auto thus"continuous_on {..<(0::ereal)} (uminus ∘ inverse ∘ uminus)" by (intro continuous_intros) simp_all qed simp
lemma tendsto_inverse_ereal: assumes"(f ---> (c :: ereal)) F" assumes"eventually (λx. f x ≥ 0) F" shows"((λx. inverse (f x)) ---> inverse c) F" by (cases "F = bot")
(auto intro!: tendsto_lowerbound assms
continuous_on_tendsto_compose[OF continuous_on_inverse_ereal])
subsubsection‹liminf and limsup›
lemma Limsup_ereal_mult_right: assumes"F ≠ bot""(c::real) ≥ 0" shows"Limsup F (λn. f n * ereal c) = Limsup F f * ereal c" proof (rule Limsup_compose_continuous_mono) from assms show"continuous_on UNIV (λa. a * ereal c)" using tendsto_cmult_ereal[of "ereal c""λx. x" ] by (force simp: continuous_on_def mult_ac) qed (use assms in‹auto simp: mono_def ereal_mult_right_mono›)
lemma Liminf_ereal_mult_right: assumes"F ≠ bot""(c::real) ≥ 0" shows"Liminf F (λn. f n * ereal c) = Liminf F f * ereal c" proof (rule Liminf_compose_continuous_mono) from assms show"continuous_on UNIV (λa. a * ereal c)" using tendsto_cmult_ereal[of "ereal c""λx. x" ] by (force simp: continuous_on_def mult_ac) qed (use assms in‹auto simp: mono_def ereal_mult_right_mono›)
lemma Liminf_ereal_mult_left: assumes"F ≠ bot""(c::real) ≥ 0" shows"Liminf F (λn. ereal c * f n) = ereal c * Liminf F f" using Liminf_ereal_mult_right[OF assms] by (subst (12) mult.commute)
lemma Limsup_ereal_mult_left: assumes"F ≠ bot""(c::real) ≥ 0" shows"Limsup F (λn. ereal c * f n) = ereal c * Limsup F f" using Limsup_ereal_mult_right[OF assms] by (subst (12) mult.commute)
lemma limsup_ereal_mult_right: "(c::real) ≥ 0 ==> limsup (λn. f n * ereal c) = limsup f * ereal c" by (rule Limsup_ereal_mult_right) simp_all
lemma limsup_ereal_mult_left: "(c::real) ≥ 0 ==> limsup (λn. ereal c * f n) = ereal c * limsup f" by (simp add: Limsup_ereal_mult_left)
lemma Limsup_add_ereal_right: "F ≠ bot ==> abs c ≠∞==> Limsup F (λn. g n + (c :: ereal)) = Limsup F g + c" by (rule Limsup_compose_continuous_mono) (auto simp: mono_def add_mono continuous_on_def)
lemma Limsup_add_ereal_left: "F ≠ bot ==> abs c ≠∞==> Limsup F (λn. (c :: ereal) + g n) = c + Limsup F g" by (subst (12) add.commute) (rule Limsup_add_ereal_right)
lemma Liminf_add_ereal_right: "F ≠ bot ==> abs c ≠∞==> Liminf F (λn. g n + (c :: ereal)) = Liminf F g + c" by (rule Liminf_compose_continuous_mono) (auto simp: mono_def add_mono continuous_on_def)
lemma Liminf_add_ereal_left: "F ≠ bot ==> abs c ≠∞==> Liminf F (λn. (c :: ereal) + g n) = c + Liminf F g" by (subst (12) add.commute) (rule Liminf_add_ereal_right)
lemma assumes"F ≠ bot" assumes nonneg: "eventually (λx. f x ≥ (0::ereal)) F" shows Liminf_inverse_ereal: "Liminf F (λx. inverse (f x)) = inverse (Limsup F f)" and Limsup_inverse_ereal: "Limsup F (λx. inverse (f x)) = inverse (Liminf F f)" proof -
define inv where [abs_def]: "inv x = (if x ≤ 0 then ∞ else inverse x)"for x :: ereal have"continuous_on ({..0} ∪ {0..}) inv"unfolding inv_def by (intro continuous_on_If) (auto intro!: continuous_intros) alsohave"{..0} ∪ {0..} = (UNIV :: ereal set)"by auto finallyhave cont: "continuous_on UNIV inv" . have antimono: "antimono inv"unfolding inv_def antimono_def by (auto intro!: ereal_inverse_antimono)
have"Liminf F (λx. inverse (f x)) = Liminf F (λx. inv (f x))"using nonneg by (auto intro!: Liminf_eq elim!: eventually_mono simp: inv_def) alsohave"... = inv (Limsup F f)" by (simp add: assms(1) Liminf_compose_continuous_antimono[OF cont antimono]) alsofrom assms have"Limsup F f ≥ 0"by (intro le_Limsup) simp_all hence"inv (Limsup F f) = inverse (Limsup F f)"by (simp add: inv_def) finallyshow"Liminf F (λx. inverse (f x)) = inverse (Limsup F f)" .
have"Limsup F (λx. inverse (f x)) = Limsup F (λx. inv (f x))"using nonneg by (auto intro!: Limsup_eq elim!: eventually_mono simp: inv_def) alsohave"... = inv (Liminf F f)" by (simp add: assms(1) Limsup_compose_continuous_antimono[OF cont antimono]) alsofrom assms have"Liminf F f ≥ 0"by (intro Liminf_bounded) simp_all hence"inv (Liminf F f) = inverse (Liminf F f)"by (simp add: inv_def) finallyshow"Limsup F (λx. inverse (f x)) = inverse (Liminf F f)" . qed
lemma ereal_diff_le_mono_left: "[ x ≤ z; 0 ≤ y ]==> x - y ≤ (z :: ereal)" by(cases x y z rule: ereal3_cases) simp_all
lemma neg_0_less_iff_less_erea [simp]: "0 < - a ⟷ (a :: ereal) < 0" by(cases a) simp_all
lemma not_infty_ereal: "∣x∣≠∞⟷ (∃x'. x = ereal x')" by auto
lemma neq_PInf_trans: fixes x y :: ereal shows"[ y ≠∞; x ≤ y ]==> x ≠∞" by auto
lemma mult_2_ereal: "ereal 2 * x = x + x" by(cases x) simp_all
lemma ereal_diff_le_self: "0 ≤ y ==> x - y ≤ (x :: ereal)" by(cases x y rule: ereal2_cases) simp_all
lemma ereal_le_add_self: "0 ≤ y ==> x ≤ x + (y :: ereal)" by(cases x y rule: ereal2_cases) simp_all
lemma ereal_le_add_self2: "0 ≤ y ==> x ≤ y + (x :: ereal)" by(cases x y rule: ereal2_cases) simp_all
lemma ereal_diff_nonpos: fixes a b :: ereal shows"\<lbrakk> a \<le> b; a = \<infinity> \<Longrightarrow> b \<noteq> \<infinity>; a = -\<infinity> \<Longrightarrow> b \<noteq> -\<infinity> \<rbrakk> \<Longrightarrow> a - b \<le> 0"
by (cases rule: ereal2_cases[of a b]) auto
lemma ereal_diff_eq_0_iff: fixes a b :: ereal
shows "(\<bar>a\<bar> = \<infinity> \<Longrightarrow> \<bar>b\<bar> \<noteq> \<infinity>) \<Longrightarrow> a - b = 0 \<longleftrightarrow> a = b"
by(cases a b rule: ereal2_cases) simp_all
lemma SUP_ereal_eq_0_iff_nonneg:
fixes f :: "_ \<Rightarrow> ereal"and A
assumes nonneg: "\<forall>x\<in>A. f x \<ge> 0" and A:"A \<noteq> {}"
shows "(SUP x\<in>A. f x) = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)" (is "?lhs \<longleftrightarrow> _")
proof(intro iffI ballI)
fix x
assume "?lhs""x \<in> A"
from \<open>x \<in> A\<close> have "f x \<le> (SUP x\<in>A. f x)" by(rule SUP_upper)
with \<open>?lhs\<close> show "f x = 0"using nonneg \<open>x \<in> A\<close> by auto
qed (simp add: A)
lemma ereal_divide_le_posI:
fixes x y z :: ereal
shows "x > 0 \<Longrightarrow> z \<noteq> -\<infinity> \<Longrightarrow> z \<le> x * y \<Longrightarrow> z / x \<le> y"
by (cases rule: ereal3_cases[of x y z])(auto simp: field_simps split: if_split_asm)
lemma add_diff_eq_ereal:
fixes x y z :: ereal
shows "x + (y - z) = x + y - z"
by(cases x y z rule: ereal3_cases) simp_all
lemma ereal_diff_gr0:
fixes a b :: ereal
shows "a < b \<Longrightarrow> 0 < b - a"
by (cases rule: ereal2_cases[of a b]) auto
lemma ereal_minus_minus:
fixes x y z :: ereal shows "(\<bar>y\<bar> = \<infinity> \<Longrightarrow> \<bar>z\<bar> \<noteq> \<infinity>) \<Longrightarrow> x - (y - z) = x + z - y"
by(cases x y z rule: ereal3_cases) simp_all
lemma diff_diff_commute_ereal:
fixes x y z :: ereal
shows "x - y - z = x - z - y"
by (metis add_diff_eq_ereal ereal_add_uminus_conv_diff)
lemma ereal_diff_eq_MInfty_iff:
fixes x y :: ereal
shows "x - y = -\<infinity> \<longleftrightarrow> x = -\<infinity> \<and> y \<noteq> -\<infinity> \<or> y = \<infinity> \<and> \<bar>x\<bar> \<noteq> \<infinity>"
by(cases x y rule: ereal2_cases) simp_all
lemma ereal_diff_add_inverse:
fixes x y :: ereal
shows "\<bar>x\<bar> \<noteq> \<infinity> \<Longrightarrow> x + y - x = y"
by(cases x y rule: ereal2_cases) simp_all
lemma tendsto_diff_ereal:
fixes x y :: ereal
assumes x: "\<bar>x\<bar> \<noteq> \<infinity>"and y: "\<bar>y\<bar> \<noteq> \<infinity>"
assumes f: "(f \<longlongrightarrow> x) F"and g: "(g \<longlongrightarrow> y) F"
shows "((\<lambda>x. f x - g x) \<longlongrightarrow> x - y) F"
proof -
from x obtain r where x': "x = ereal r" by (cases x) auto
with f have "((\<lambda>i. real_of_ereal (f i)) \<longlongrightarrow> r) F" by simp
moreover
from y obtain p where y': "y = ereal p" by (cases y) auto
with g have "((\<lambda>i. real_of_ereal (g i)) \<longlongrightarrow> p) F" by simp
ultimately have "((\<lambda>i. real_of_ereal (f i) - real_of_ereal (g i)) \<longlongrightarrow> r - p) F"
by (rule tendsto_diff)
moreover
from eventually_finite[OF x f] eventually_finite[OF y g]
have "eventually (\<lambda>x. f x - g x = ereal (real_of_ereal (f x) - real_of_ereal (g x))) F"
by eventually_elim auto
ultimately show ?thesis
by (simp add: x' y' cong: filterlim_cong)
qed
lemma continuous_on_diff_ereal: "continuous_on A f \<Longrightarrow> continuous_on A g \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>) \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> \<bar>g x\<bar> \<noteq> \<infinity>) \<Longrightarrow> continuous_on A (\<lambda>z. f z - g z::ereal)"
by (auto simp: tendsto_diff_ereal continuous_on_def)
subsubsection \<open>Tests for code generator\<close>
text \<open>A small list of simple arithmetic expressions.\<close>
value "-\<infinity> :: ereal"
value "\<bar>-\<infinity>\<bar> :: ereal"
value "4 + 5 / 4 - ereal 2 :: ereal"
value "ereal 3 < \<infinity>"
value "real_of_ereal (\<infinity>::ereal) = 0"
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.