| author | wenzelm | 
| Wed, 21 Oct 2015 18:00:12 +0200 | |
| changeset 61500 | 56a167b31a7f | 
| parent 61245 | b77bf45efe21 | 
| child 61585 | a9599d3d7610 | 
| child 61609 | 77b453bd616f | 
| permissions | -rw-r--r-- | 
| 43920 | 1 | (* Title: HOL/Library/Extended_Real.thy | 
| 41983 | 2 | Author: Johannes Hölzl, TU München | 
| 3 | Author: Robert Himmelmann, TU München | |
| 4 | Author: Armin Heller, TU München | |
| 5 | Author: Bogdan Grechuk, University of Edinburgh | |
| 6 | *) | |
| 41973 | 7 | |
| 60500 | 8 | section \<open>Extended real number line\<close> | 
| 41973 | 9 | |
| 43920 | 10 | theory Extended_Real | 
| 60636 
ee18efe9b246
add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
 hoelzl parents: 
60580diff
changeset | 11 | imports Complex_Main Extended_Nat Liminf_Limsup | 
| 41973 | 12 | begin | 
| 13 | ||
| 60500 | 14 | text \<open> | 
| 51022 
78de6c7e8a58
replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
 hoelzl parents: 
51000diff
changeset | 15 | |
| 60172 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 16 | This should be part of @{theory Extended_Nat} or @{theory Order_Continuity}, but then the
 | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 17 | AFP-entry @{text "Jinja_Thread"} fails, as it does overload certain named from @{theory Complex_Main}.
 | 
| 59115 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 18 | |
| 60500 | 19 | \<close> | 
| 59115 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 20 | |
| 60172 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 21 | lemma continuous_at_left_imp_sup_continuous: | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 22 |   fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology}"
 | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 23 | assumes "mono f" "\<And>x. continuous (at_left x) f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 24 | shows "sup_continuous f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 25 | unfolding sup_continuous_def | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 26 | proof safe | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 27 | fix M :: "nat \<Rightarrow> 'a" assume "incseq M" then show "f (SUP i. M i) = (SUP i. f (M i))" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 28 | using continuous_at_Sup_mono[OF assms, of "range M"] by simp | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 29 | qed | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 30 | |
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 31 | lemma sup_continuous_at_left: | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 32 |   fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology, first_countable_topology}"
 | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 33 | assumes f: "sup_continuous f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 34 | shows "continuous (at_left x) f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 35 | proof cases | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 36 | assume "x = bot" then show ?thesis | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 37 | by (simp add: trivial_limit_at_left_bot) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 38 | next | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 39 | assume x: "x \<noteq> bot" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 40 | show ?thesis | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 41 | unfolding continuous_within | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 42 | proof (intro tendsto_at_left_sequentially[of bot]) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 43 | fix S :: "nat \<Rightarrow> 'a" assume S: "incseq S" and S_x: "S ----> x" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 44 | from S_x have x_eq: "x = (SUP i. S i)" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 45 | by (rule LIMSEQ_unique) (intro LIMSEQ_SUP S) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 46 | show "(\<lambda>n. f (S n)) ----> f x" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 47 | unfolding x_eq sup_continuousD[OF f S] | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 48 | using S sup_continuous_mono[OF f] by (intro LIMSEQ_SUP) (auto simp: mono_def) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 49 | qed (insert x, auto simp: bot_less) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 50 | qed | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 51 | |
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 52 | lemma sup_continuous_iff_at_left: | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 53 |   fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology, first_countable_topology}"
 | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 54 | shows "sup_continuous f \<longleftrightarrow> (\<forall>x. continuous (at_left x) f) \<and> mono f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 55 | using sup_continuous_at_left[of f] continuous_at_left_imp_sup_continuous[of f] | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 56 | sup_continuous_mono[of f] by auto | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 57 | |
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 58 | lemma continuous_at_right_imp_inf_continuous: | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 59 |   fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology}"
 | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 60 | assumes "mono f" "\<And>x. continuous (at_right x) f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 61 | shows "inf_continuous f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 62 | unfolding inf_continuous_def | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 63 | proof safe | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 64 | fix M :: "nat \<Rightarrow> 'a" assume "decseq M" then show "f (INF i. M i) = (INF i. f (M i))" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 65 | using continuous_at_Inf_mono[OF assms, of "range M"] by simp | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 66 | qed | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 67 | |
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 68 | lemma inf_continuous_at_right: | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 69 |   fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology, first_countable_topology}"
 | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 70 | assumes f: "inf_continuous f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 71 | shows "continuous (at_right x) f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 72 | proof cases | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 73 | assume "x = top" then show ?thesis | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 74 | by (simp add: trivial_limit_at_right_top) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 75 | next | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 76 | assume x: "x \<noteq> top" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 77 | show ?thesis | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 78 | unfolding continuous_within | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 79 | proof (intro tendsto_at_right_sequentially[of _ top]) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 80 | fix S :: "nat \<Rightarrow> 'a" assume S: "decseq S" and S_x: "S ----> x" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 81 | from S_x have x_eq: "x = (INF i. S i)" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 82 | by (rule LIMSEQ_unique) (intro LIMSEQ_INF S) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 83 | show "(\<lambda>n. f (S n)) ----> f x" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 84 | unfolding x_eq inf_continuousD[OF f S] | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 85 | using S inf_continuous_mono[OF f] by (intro LIMSEQ_INF) (auto simp: mono_def antimono_def) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 86 | qed (insert x, auto simp: less_top) | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 87 | qed | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 88 | |
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 89 | lemma inf_continuous_iff_at_right: | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 90 |   fixes f :: "'a \<Rightarrow> 'a::{complete_linorder, linorder_topology, first_countable_topology}"
 | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 91 | shows "inf_continuous f \<longleftrightarrow> (\<forall>x. continuous (at_right x) f) \<and> mono f" | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 92 | using inf_continuous_at_right[of f] continuous_at_right_imp_inf_continuous[of f] | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 93 | inf_continuous_mono[of f] by auto | 
| 
423273355b55
rename continuous and down_continuous in Order_Continuity to sup_/inf_continuous; relate them with topological continuity
 hoelzl parents: 
60060diff
changeset | 94 | |
| 59115 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 95 | instantiation enat :: linorder_topology | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 96 | begin | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 97 | |
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 98 | definition open_enat :: "enat set \<Rightarrow> bool" where | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 99 | "open_enat = generate_topology (range lessThan \<union> range greaterThan)" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 100 | |
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 101 | instance | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 102 | proof qed (rule open_enat_def) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 103 | |
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 104 | end | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 105 | |
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 106 | lemma open_enat: "open {enat n}"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 107 | proof (cases n) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 108 | case 0 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 109 |   then have "{enat n} = {..< eSuc 0}"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 110 | by (auto simp: enat_0) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 111 | then show ?thesis | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 112 | by simp | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 113 | next | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 114 | case (Suc n') | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 115 |   then have "{enat n} = {enat n' <..< enat (Suc n)}"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 116 | apply auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 117 | apply (case_tac x) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 118 | apply auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 119 | done | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 120 | then show ?thesis | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 121 | by simp | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 122 | qed | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 123 | |
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 124 | lemma open_enat_iff: | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 125 | fixes A :: "enat set" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 126 |   shows "open A \<longleftrightarrow> (\<infinity> \<in> A \<longrightarrow> (\<exists>n::nat. {n <..} \<subseteq> A))"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 127 | proof safe | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 128 | assume "\<infinity> \<notin> A" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 129 |   then have "A = (\<Union>n\<in>{n. enat n \<in> A}. {enat n})"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 130 | apply auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 131 | apply (case_tac x) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 132 | apply auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 133 | done | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 134 | moreover have "open \<dots>" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 135 | by (auto intro: open_enat) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 136 | ultimately show "open A" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 137 | by simp | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 138 | next | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 139 |   fix n assume "{enat n <..} \<subseteq> A"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 140 |   then have "A = (\<Union>n\<in>{n. enat n \<in> A}. {enat n}) \<union> {enat n <..}"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 141 | apply auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 142 | apply (case_tac x) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 143 | apply auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 144 | done | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 145 | moreover have "open \<dots>" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 146 | by (intro open_Un open_UN ballI open_enat open_greaterThan) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 147 | ultimately show "open A" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 148 | by simp | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 149 | next | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 150 | assume "open A" "\<infinity> \<in> A" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 151 | then have "generate_topology (range lessThan \<union> range greaterThan) A" "\<infinity> \<in> A" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 152 | unfolding open_enat_def by auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 153 |   then show "\<exists>n::nat. {n <..} \<subseteq> A"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 154 | proof induction | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 155 | case (Int A B) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 156 |     then obtain n m where "{enat n<..} \<subseteq> A" "{enat m<..} \<subseteq> B"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 157 | by auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 158 |     then have "{enat (max n m) <..} \<subseteq> A \<inter> B"
 | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 159 | by (auto simp add: subset_eq Ball_def max_def enat_ord_code(1)[symmetric] simp del: enat_ord_code(1)) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 160 | then show ?case | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 161 | by auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 162 | next | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 163 | case (UN K) | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 164 | then obtain k where "k \<in> K" "\<infinity> \<in> k" | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 165 | by auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 166 | with UN.IH[OF this] show ?case | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 167 | by auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 168 | qed auto | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 169 | qed | 
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 170 | |
| 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 171 | |
| 60500 | 172 | text \<open> | 
| 59115 
f65ac77f7e07
move topology on enat to Extended_Real, otherwise Jinja_Threads fails
 hoelzl parents: 
59023diff
changeset | 173 | |
| 51022 
78de6c7e8a58
replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
 hoelzl parents: 
51000diff
changeset | 174 | For more lemmas about the extended real numbers go to | 
| 
78de6c7e8a58
replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
 hoelzl parents: 
51000diff
changeset | 175 |   @{file "~~/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy"}
 | 
| 
78de6c7e8a58
replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
 hoelzl parents: 
51000diff
changeset | 176 | |
| 60500 | 177 | \<close> | 
| 178 | ||
| 179 | subsection \<open>Definition and basic properties\<close> | |
| 41973 | 180 | |
| 58310 | 181 | datatype ereal = ereal real | PInfty | MInfty | 
| 41973 | 182 | |
| 43920 | 183 | instantiation ereal :: uminus | 
| 41973 | 184 | begin | 
| 53873 | 185 | |
| 186 | fun uminus_ereal where | |
| 187 | "- (ereal r) = ereal (- r)" | |
| 188 | | "- PInfty = MInfty" | |
| 189 | | "- MInfty = PInfty" | |
| 190 | ||
| 191 | instance .. | |
| 192 | ||
| 41973 | 193 | end | 
| 194 | ||
| 43923 | 195 | instantiation ereal :: infinity | 
| 196 | begin | |
| 53873 | 197 | |
| 198 | definition "(\<infinity>::ereal) = PInfty" | |
| 199 | instance .. | |
| 200 | ||
| 43923 | 201 | end | 
| 41973 | 202 | |
| 43923 | 203 | declare [[coercion "ereal :: real \<Rightarrow> ereal"]] | 
| 41973 | 204 | |
| 43920 | 205 | lemma ereal_uminus_uminus[simp]: | 
| 53873 | 206 | fixes a :: ereal | 
| 207 | shows "- (- a) = a" | |
| 41973 | 208 | by (cases a) simp_all | 
| 209 | ||
| 43923 | 210 | lemma | 
| 211 | shows PInfty_eq_infinity[simp]: "PInfty = \<infinity>" | |
| 212 | and MInfty_eq_minfinity[simp]: "MInfty = - \<infinity>" | |
| 213 | and MInfty_neq_PInfty[simp]: "\<infinity> \<noteq> - (\<infinity>::ereal)" "- \<infinity> \<noteq> (\<infinity>::ereal)" | |
| 214 | and MInfty_neq_ereal[simp]: "ereal r \<noteq> - \<infinity>" "- \<infinity> \<noteq> ereal r" | |
| 215 | and PInfty_neq_ereal[simp]: "ereal r \<noteq> \<infinity>" "\<infinity> \<noteq> ereal r" | |
| 216 | and PInfty_cases[simp]: "(case \<infinity> of ereal r \<Rightarrow> f r | PInfty \<Rightarrow> y | MInfty \<Rightarrow> z) = y" | |
| 217 | and MInfty_cases[simp]: "(case - \<infinity> of ereal r \<Rightarrow> f r | PInfty \<Rightarrow> y | MInfty \<Rightarrow> z) = z" | |
| 218 | by (simp_all add: infinity_ereal_def) | |
| 41973 | 219 | |
| 43933 | 220 | declare | 
| 221 | PInfty_eq_infinity[code_post] | |
| 222 | MInfty_eq_minfinity[code_post] | |
| 223 | ||
| 224 | lemma [code_unfold]: | |
| 225 | "\<infinity> = PInfty" | |
| 53873 | 226 | "- PInfty = MInfty" | 
| 43933 | 227 | by simp_all | 
| 228 | ||
| 43923 | 229 | lemma inj_ereal[simp]: "inj_on ereal A" | 
| 230 | unfolding inj_on_def by auto | |
| 41973 | 231 | |
| 55913 | 232 | lemma ereal_cases[cases type: ereal]: | 
| 233 | obtains (real) r where "x = ereal r" | |
| 234 | | (PInf) "x = \<infinity>" | |
| 235 | | (MInf) "x = -\<infinity>" | |
| 41973 | 236 | using assms by (cases x) auto | 
| 237 | ||
| 43920 | 238 | lemmas ereal2_cases = ereal_cases[case_product ereal_cases] | 
| 239 | lemmas ereal3_cases = ereal2_cases[case_product ereal_cases] | |
| 41973 | 240 | |
| 57447 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57025diff
changeset | 241 | lemma ereal_all_split: "\<And>P. (\<forall>x::ereal. P x) \<longleftrightarrow> P \<infinity> \<and> (\<forall>x. P (ereal x)) \<and> P (-\<infinity>)" | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57025diff
changeset | 242 | by (metis ereal_cases) | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57025diff
changeset | 243 | |
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57025diff
changeset | 244 | lemma ereal_ex_split: "\<And>P. (\<exists>x::ereal. P x) \<longleftrightarrow> P \<infinity> \<or> (\<exists>x. P (ereal x)) \<or> P (-\<infinity>)" | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57025diff
changeset | 245 | by (metis ereal_cases) | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57025diff
changeset | 246 | |
| 43920 | 247 | lemma ereal_uminus_eq_iff[simp]: | 
| 53873 | 248 | fixes a b :: ereal | 
| 249 | shows "-a = -b \<longleftrightarrow> a = b" | |
| 43920 | 250 | by (cases rule: ereal2_cases[of a b]) simp_all | 
| 41973 | 251 | |
| 58042 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 252 | instantiation ereal :: real_of | 
| 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 253 | begin | 
| 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 254 | |
| 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 255 | function real_ereal :: "ereal \<Rightarrow> real" where | 
| 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 256 | "real_ereal (ereal r) = r" | 
| 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 257 | | "real_ereal \<infinity> = 0" | 
| 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 258 | | "real_ereal (-\<infinity>) = 0" | 
| 43920 | 259 | by (auto intro: ereal_cases) | 
| 60679 | 260 | termination by standard (rule wf_empty) | 
| 41973 | 261 | |
| 58042 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 262 | instance .. | 
| 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 263 | end | 
| 41973 | 264 | |
| 43920 | 265 | lemma real_of_ereal[simp]: | 
| 53873 | 266 | "real (- x :: ereal) = - (real x)" | 
| 58042 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 267 | by (cases x) simp_all | 
| 41973 | 268 | |
| 43920 | 269 | lemma range_ereal[simp]: "range ereal = UNIV - {\<infinity>, -\<infinity>}"
 | 
| 41973 | 270 | proof safe | 
| 53873 | 271 | fix x | 
| 272 | assume "x \<notin> range ereal" "x \<noteq> \<infinity>" | |
| 273 | then show "x = -\<infinity>" | |
| 274 | by (cases x) auto | |
| 41973 | 275 | qed auto | 
| 276 | ||
| 43920 | 277 | lemma ereal_range_uminus[simp]: "range uminus = (UNIV::ereal set)" | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 278 | proof safe | 
| 53873 | 279 | fix x :: ereal | 
| 280 | show "x \<in> range uminus" | |
| 281 | by (intro image_eqI[of _ _ "-x"]) auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 282 | qed auto | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 283 | |
| 43920 | 284 | instantiation ereal :: abs | 
| 41976 | 285 | begin | 
| 53873 | 286 | |
| 287 | function abs_ereal where | |
| 288 | "\<bar>ereal r\<bar> = ereal \<bar>r\<bar>" | |
| 289 | | "\<bar>-\<infinity>\<bar> = (\<infinity>::ereal)" | |
| 290 | | "\<bar>\<infinity>\<bar> = (\<infinity>::ereal)" | |
| 291 | by (auto intro: ereal_cases) | |
| 292 | termination proof qed (rule wf_empty) | |
| 293 | ||
| 294 | instance .. | |
| 295 | ||
| 41976 | 296 | end | 
| 297 | ||
| 53873 | 298 | lemma abs_eq_infinity_cases[elim!]: | 
| 299 | fixes x :: ereal | |
| 300 | assumes "\<bar>x\<bar> = \<infinity>" | |
| 301 | obtains "x = \<infinity>" | "x = -\<infinity>" | |
| 302 | using assms by (cases x) auto | |
| 41976 | 303 | |
| 53873 | 304 | lemma abs_neq_infinity_cases[elim!]: | 
| 305 | fixes x :: ereal | |
| 306 | assumes "\<bar>x\<bar> \<noteq> \<infinity>" | |
| 307 | obtains r where "x = ereal r" | |
| 308 | using assms by (cases x) auto | |
| 309 | ||
| 310 | lemma abs_ereal_uminus[simp]: | |
| 311 | fixes x :: ereal | |
| 312 | shows "\<bar>- x\<bar> = \<bar>x\<bar>" | |
| 41976 | 313 | by (cases x) auto | 
| 314 | ||
| 53873 | 315 | lemma ereal_infinity_cases: | 
| 316 | fixes a :: ereal | |
| 317 | shows "a \<noteq> \<infinity> \<Longrightarrow> a \<noteq> -\<infinity> \<Longrightarrow> \<bar>a\<bar> \<noteq> \<infinity>" | |
| 318 | by auto | |
| 41976 | 319 | |
| 50104 | 320 | |
| 41973 | 321 | subsubsection "Addition" | 
| 322 | ||
| 54408 | 323 | instantiation ereal :: "{one,comm_monoid_add,zero_neq_one}"
 | 
| 41973 | 324 | begin | 
| 325 | ||
| 43920 | 326 | definition "0 = ereal 0" | 
| 51351 | 327 | definition "1 = ereal 1" | 
| 41973 | 328 | |
| 43920 | 329 | function plus_ereal where | 
| 53873 | 330 | "ereal r + ereal p = ereal (r + p)" | 
| 331 | | "\<infinity> + a = (\<infinity>::ereal)" | |
| 332 | | "a + \<infinity> = (\<infinity>::ereal)" | |
| 333 | | "ereal r + -\<infinity> = - \<infinity>" | |
| 334 | | "-\<infinity> + ereal p = -(\<infinity>::ereal)" | |
| 335 | | "-\<infinity> + -\<infinity> = -(\<infinity>::ereal)" | |
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
61120diff
changeset | 336 | proof goal_cases | 
| 60580 | 337 | case prems: (1 P x) | 
| 53873 | 338 | then obtain a b where "x = (a, b)" | 
| 339 | by (cases x) auto | |
| 60580 | 340 | with prems show P | 
| 43920 | 341 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 342 | qed auto | 
| 60679 | 343 | termination by standard (rule wf_empty) | 
| 41973 | 344 | |
| 345 | lemma Infty_neq_0[simp]: | |
| 43923 | 346 | "(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> (\<infinity>::ereal)" | 
| 347 | "-(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> -(\<infinity>::ereal)" | |
| 43920 | 348 | by (simp_all add: zero_ereal_def) | 
| 41973 | 349 | |
| 43920 | 350 | lemma ereal_eq_0[simp]: | 
| 351 | "ereal r = 0 \<longleftrightarrow> r = 0" | |
| 352 | "0 = ereal r \<longleftrightarrow> r = 0" | |
| 353 | unfolding zero_ereal_def by simp_all | |
| 41973 | 354 | |
| 54416 | 355 | lemma ereal_eq_1[simp]: | 
| 356 | "ereal r = 1 \<longleftrightarrow> r = 1" | |
| 357 | "1 = ereal r \<longleftrightarrow> r = 1" | |
| 358 | unfolding one_ereal_def by simp_all | |
| 359 | ||
| 41973 | 360 | instance | 
| 361 | proof | |
| 47082 | 362 | fix a b c :: ereal | 
| 363 | show "0 + a = a" | |
| 43920 | 364 | by (cases a) (simp_all add: zero_ereal_def) | 
| 47082 | 365 | show "a + b = b + a" | 
| 43920 | 366 | by (cases rule: ereal2_cases[of a b]) simp_all | 
| 47082 | 367 | show "a + b + c = a + (b + c)" | 
| 43920 | 368 | by (cases rule: ereal3_cases[of a b c]) simp_all | 
| 54408 | 369 | show "0 \<noteq> (1::ereal)" | 
| 370 | by (simp add: one_ereal_def zero_ereal_def) | |
| 41973 | 371 | qed | 
| 53873 | 372 | |
| 41973 | 373 | end | 
| 374 | ||
| 60060 | 375 | lemma ereal_0_plus [simp]: "ereal 0 + x = x" | 
| 376 | and plus_ereal_0 [simp]: "x + ereal 0 = x" | |
| 377 | by(simp_all add: zero_ereal_def[symmetric]) | |
| 378 | ||
| 51351 | 379 | instance ereal :: numeral .. | 
| 380 | ||
| 43920 | 381 | lemma real_of_ereal_0[simp]: "real (0::ereal) = 0" | 
| 58042 
ffa9e39763e3
introduce real_of typeclass for real :: 'a => real
 hoelzl parents: 
57512diff
changeset | 382 | unfolding zero_ereal_def by simp | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 383 | |
| 43920 | 384 | lemma abs_ereal_zero[simp]: "\<bar>0\<bar> = (0::ereal)" | 
| 385 | unfolding zero_ereal_def abs_ereal.simps by simp | |
| 41976 | 386 | |
| 53873 | 387 | lemma ereal_uminus_zero[simp]: "- 0 = (0::ereal)" | 
| 43920 | 388 | by (simp add: zero_ereal_def) | 
| 41973 | 389 | |
| 43920 | 390 | lemma ereal_uminus_zero_iff[simp]: | 
| 53873 | 391 | fixes a :: ereal | 
| 392 | shows "-a = 0 \<longleftrightarrow> a = 0" | |
| 41973 | 393 | by (cases a) simp_all | 
| 394 | ||
| 43920 | 395 | lemma ereal_plus_eq_PInfty[simp]: | 
| 53873 | 396 | fixes a b :: ereal | 
| 397 | shows "a + b = \<infinity> \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>" | |
| 43920 | 398 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 399 | |
| 43920 | 400 | lemma ereal_plus_eq_MInfty[simp]: | 
| 53873 | 401 | fixes a b :: ereal | 
| 402 | shows "a + b = -\<infinity> \<longleftrightarrow> (a = -\<infinity> \<or> b = -\<infinity>) \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>" | |
| 43920 | 403 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 404 | |
| 43920 | 405 | lemma ereal_add_cancel_left: | 
| 53873 | 406 | fixes a b :: ereal | 
| 407 | assumes "a \<noteq> -\<infinity>" | |
| 408 | shows "a + b = a + c \<longleftrightarrow> a = \<infinity> \<or> b = c" | |
| 43920 | 409 | using assms by (cases rule: ereal3_cases[of a b c]) auto | 
| 41973 | 410 | |
| 43920 | 411 | lemma ereal_add_cancel_right: | 
| 53873 | 412 | fixes a b :: ereal | 
| 413 | assumes "a \<noteq> -\<infinity>" | |
| 414 | shows "b + a = c + a \<longleftrightarrow> a = \<infinity> \<or> b = c" | |
| 43920 | 415 | using assms by (cases rule: ereal3_cases[of a b c]) auto | 
| 41973 | 416 | |
| 53873 | 417 | lemma ereal_real: "ereal (real x) = (if \<bar>x\<bar> = \<infinity> then 0 else x)" | 
| 41973 | 418 | by (cases x) simp_all | 
| 419 | ||
| 43920 | 420 | lemma real_of_ereal_add: | 
| 421 | fixes a b :: ereal | |
| 47082 | 422 | shows "real (a + b) = | 
| 423 | (if (\<bar>a\<bar> = \<infinity>) \<and> (\<bar>b\<bar> = \<infinity>) \<or> (\<bar>a\<bar> \<noteq> \<infinity>) \<and> (\<bar>b\<bar> \<noteq> \<infinity>) then real a + real b else 0)" | |
| 43920 | 424 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 425 | |
| 53873 | 426 | |
| 43920 | 427 | subsubsection "Linear order on @{typ ereal}"
 | 
| 41973 | 428 | |
| 43920 | 429 | instantiation ereal :: linorder | 
| 41973 | 430 | begin | 
| 431 | ||
| 47082 | 432 | function less_ereal | 
| 433 | where | |
| 434 | " ereal x < ereal y \<longleftrightarrow> x < y" | |
| 435 | | "(\<infinity>::ereal) < a \<longleftrightarrow> False" | |
| 436 | | " a < -(\<infinity>::ereal) \<longleftrightarrow> False" | |
| 437 | | "ereal x < \<infinity> \<longleftrightarrow> True" | |
| 438 | | " -\<infinity> < ereal r \<longleftrightarrow> True" | |
| 439 | | " -\<infinity> < (\<infinity>::ereal) \<longleftrightarrow> True" | |
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
61120diff
changeset | 440 | proof goal_cases | 
| 60580 | 441 | case prems: (1 P x) | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 442 | then obtain a b where "x = (a,b)" by (cases x) auto | 
| 60580 | 443 | with prems show P by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 444 | qed simp_all | 
| 445 | termination by (relation "{}") simp
 | |
| 446 | ||
| 43920 | 447 | definition "x \<le> (y::ereal) \<longleftrightarrow> x < y \<or> x = y" | 
| 41973 | 448 | |
| 43920 | 449 | lemma ereal_infty_less[simp]: | 
| 43923 | 450 | fixes x :: ereal | 
| 451 | shows "x < \<infinity> \<longleftrightarrow> (x \<noteq> \<infinity>)" | |
| 452 | "-\<infinity> < x \<longleftrightarrow> (x \<noteq> -\<infinity>)" | |
| 41973 | 453 | by (cases x, simp_all) (cases x, simp_all) | 
| 454 | ||
| 43920 | 455 | lemma ereal_infty_less_eq[simp]: | 
| 43923 | 456 | fixes x :: ereal | 
| 457 | shows "\<infinity> \<le> x \<longleftrightarrow> x = \<infinity>" | |
| 53873 | 458 | and "x \<le> -\<infinity> \<longleftrightarrow> x = -\<infinity>" | 
| 43920 | 459 | by (auto simp add: less_eq_ereal_def) | 
| 41973 | 460 | |
| 43920 | 461 | lemma ereal_less[simp]: | 
| 462 | "ereal r < 0 \<longleftrightarrow> (r < 0)" | |
| 463 | "0 < ereal r \<longleftrightarrow> (0 < r)" | |
| 54416 | 464 | "ereal r < 1 \<longleftrightarrow> (r < 1)" | 
| 465 | "1 < ereal r \<longleftrightarrow> (1 < r)" | |
| 43923 | 466 | "0 < (\<infinity>::ereal)" | 
| 467 | "-(\<infinity>::ereal) < 0" | |
| 54416 | 468 | by (simp_all add: zero_ereal_def one_ereal_def) | 
| 41973 | 469 | |
| 43920 | 470 | lemma ereal_less_eq[simp]: | 
| 43923 | 471 | "x \<le> (\<infinity>::ereal)" | 
| 472 | "-(\<infinity>::ereal) \<le> x" | |
| 43920 | 473 | "ereal r \<le> ereal p \<longleftrightarrow> r \<le> p" | 
| 474 | "ereal r \<le> 0 \<longleftrightarrow> r \<le> 0" | |
| 475 | "0 \<le> ereal r \<longleftrightarrow> 0 \<le> r" | |
| 54416 | 476 | "ereal r \<le> 1 \<longleftrightarrow> r \<le> 1" | 
| 477 | "1 \<le> ereal r \<longleftrightarrow> 1 \<le> r" | |
| 478 | by (auto simp add: less_eq_ereal_def zero_ereal_def one_ereal_def) | |
| 41973 | 479 | |
| 43920 | 480 | lemma ereal_infty_less_eq2: | 
| 43923 | 481 | "a \<le> b \<Longrightarrow> a = \<infinity> \<Longrightarrow> b = (\<infinity>::ereal)" | 
| 482 | "a \<le> b \<Longrightarrow> b = -\<infinity> \<Longrightarrow> a = -(\<infinity>::ereal)" | |
| 41973 | 483 | by simp_all | 
| 484 | ||
| 485 | instance | |
| 486 | proof | |
| 47082 | 487 | fix x y z :: ereal | 
| 488 | show "x \<le> x" | |
| 41973 | 489 | by (cases x) simp_all | 
| 47082 | 490 | show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x" | 
| 43920 | 491 | by (cases rule: ereal2_cases[of x y]) auto | 
| 41973 | 492 | show "x \<le> y \<or> y \<le> x " | 
| 43920 | 493 | by (cases rule: ereal2_cases[of x y]) auto | 
| 53873 | 494 |   {
 | 
| 495 | assume "x \<le> y" "y \<le> x" | |
| 496 | then show "x = y" | |
| 497 | by (cases rule: ereal2_cases[of x y]) auto | |
| 498 | } | |
| 499 |   {
 | |
| 500 | assume "x \<le> y" "y \<le> z" | |
| 501 | then show "x \<le> z" | |
| 502 | by (cases rule: ereal3_cases[of x y z]) auto | |
| 503 | } | |
| 41973 | 504 | qed | 
| 47082 | 505 | |
| 41973 | 506 | end | 
| 507 | ||
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 508 | lemma ereal_dense2: "x < y \<Longrightarrow> \<exists>z. x < ereal z \<and> ereal z < y" | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 509 | using lt_ex gt_ex dense by (cases x y rule: ereal2_cases) auto | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 510 | |
| 53216 | 511 | instance ereal :: dense_linorder | 
| 60679 | 512 | by standard (blast dest: ereal_dense2) | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 513 | |
| 43920 | 514 | instance ereal :: ordered_ab_semigroup_add | 
| 41978 | 515 | proof | 
| 53873 | 516 | fix a b c :: ereal | 
| 517 | assume "a \<le> b" | |
| 518 | then show "c + a \<le> c + b" | |
| 43920 | 519 | by (cases rule: ereal3_cases[of a b c]) auto | 
| 41978 | 520 | qed | 
| 521 | ||
| 43920 | 522 | lemma real_of_ereal_positive_mono: | 
| 53873 | 523 | fixes x y :: ereal | 
| 524 | shows "0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<noteq> \<infinity> \<Longrightarrow> real x \<le> real y" | |
| 43920 | 525 | by (cases rule: ereal2_cases[of x y]) auto | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 526 | |
| 43920 | 527 | lemma ereal_MInfty_lessI[intro, simp]: | 
| 53873 | 528 | fixes a :: ereal | 
| 529 | shows "a \<noteq> -\<infinity> \<Longrightarrow> -\<infinity> < a" | |
| 41973 | 530 | by (cases a) auto | 
| 531 | ||
| 43920 | 532 | lemma ereal_less_PInfty[intro, simp]: | 
| 53873 | 533 | fixes a :: ereal | 
| 534 | shows "a \<noteq> \<infinity> \<Longrightarrow> a < \<infinity>" | |
| 41973 | 535 | by (cases a) auto | 
| 536 | ||
| 43920 | 537 | lemma ereal_less_ereal_Ex: | 
| 538 | fixes a b :: ereal | |
| 539 | shows "x < ereal r \<longleftrightarrow> x = -\<infinity> \<or> (\<exists>p. p < r \<and> x = ereal p)" | |
| 41973 | 540 | by (cases x) auto | 
| 541 | ||
| 43920 | 542 | lemma less_PInf_Ex_of_nat: "x \<noteq> \<infinity> \<longleftrightarrow> (\<exists>n::nat. x < ereal (real n))" | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 543 | proof (cases x) | 
| 53873 | 544 | case (real r) | 
| 545 | then show ?thesis | |
| 41980 
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
 hoelzl parents: 
41979diff
changeset | 546 | using reals_Archimedean2[of r] by simp | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 547 | qed simp_all | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 548 | |
| 43920 | 549 | lemma ereal_add_mono: | 
| 53873 | 550 | fixes a b c d :: ereal | 
| 551 | assumes "a \<le> b" | |
| 552 | and "c \<le> d" | |
| 553 | shows "a + c \<le> b + d" | |
| 41973 | 554 | using assms | 
| 555 | apply (cases a) | |
| 43920 | 556 | apply (cases rule: ereal3_cases[of b c d], auto) | 
| 557 | apply (cases rule: ereal3_cases[of b c d], auto) | |
| 41973 | 558 | done | 
| 559 | ||
| 43920 | 560 | lemma ereal_minus_le_minus[simp]: | 
| 53873 | 561 | fixes a b :: ereal | 
| 562 | shows "- a \<le> - b \<longleftrightarrow> b \<le> a" | |
| 43920 | 563 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 564 | |
| 43920 | 565 | lemma ereal_minus_less_minus[simp]: | 
| 53873 | 566 | fixes a b :: ereal | 
| 567 | shows "- a < - b \<longleftrightarrow> b < a" | |
| 43920 | 568 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 569 | |
| 43920 | 570 | lemma ereal_le_real_iff: | 
| 53873 | 571 | "x \<le> real y \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x \<le> y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x \<le> 0)" | 
| 41973 | 572 | by (cases y) auto | 
| 573 | ||
| 43920 | 574 | lemma real_le_ereal_iff: | 
| 53873 | 575 | "real y \<le> x \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y \<le> ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 \<le> x)" | 
| 41973 | 576 | by (cases y) auto | 
| 577 | ||
| 43920 | 578 | lemma ereal_less_real_iff: | 
| 53873 | 579 | "x < real y \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x < y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x < 0)" | 
| 41973 | 580 | by (cases y) auto | 
| 581 | ||
| 43920 | 582 | lemma real_less_ereal_iff: | 
| 53873 | 583 | "real y < x \<longleftrightarrow> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y < ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 < x)" | 
| 41973 | 584 | by (cases y) auto | 
| 585 | ||
| 43920 | 586 | lemma real_of_ereal_pos: | 
| 53873 | 587 | fixes x :: ereal | 
| 588 | shows "0 \<le> x \<Longrightarrow> 0 \<le> real x" by (cases x) auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 589 | |
| 43920 | 590 | lemmas real_of_ereal_ord_simps = | 
| 591 | ereal_le_real_iff real_le_ereal_iff ereal_less_real_iff real_less_ereal_iff | |
| 41973 | 592 | |
| 43920 | 593 | lemma abs_ereal_ge0[simp]: "0 \<le> x \<Longrightarrow> \<bar>x :: ereal\<bar> = x" | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 594 | by (cases x) auto | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 595 | |
| 43920 | 596 | lemma abs_ereal_less0[simp]: "x < 0 \<Longrightarrow> \<bar>x :: ereal\<bar> = -x" | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 597 | by (cases x) auto | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 598 | |
| 43920 | 599 | lemma abs_ereal_pos[simp]: "0 \<le> \<bar>x :: ereal\<bar>" | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 600 | by (cases x) auto | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 601 | |
| 53873 | 602 | lemma real_of_ereal_le_0[simp]: "real (x :: ereal) \<le> 0 \<longleftrightarrow> x \<le> 0 \<or> x = \<infinity>" | 
| 43923 | 603 | by (cases x) auto | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 604 | |
| 43923 | 605 | lemma abs_real_of_ereal[simp]: "\<bar>real (x :: ereal)\<bar> = real \<bar>x\<bar>" | 
| 606 | by (cases x) auto | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 607 | |
| 43923 | 608 | lemma zero_less_real_of_ereal: | 
| 53873 | 609 | fixes x :: ereal | 
| 610 | shows "0 < real x \<longleftrightarrow> 0 < x \<and> x \<noteq> \<infinity>" | |
| 43923 | 611 | by (cases x) auto | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 612 | |
| 43920 | 613 | lemma ereal_0_le_uminus_iff[simp]: | 
| 53873 | 614 | fixes a :: ereal | 
| 615 | shows "0 \<le> - a \<longleftrightarrow> a \<le> 0" | |
| 43920 | 616 | by (cases rule: ereal2_cases[of a]) auto | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 617 | |
| 43920 | 618 | lemma ereal_uminus_le_0_iff[simp]: | 
| 53873 | 619 | fixes a :: ereal | 
| 620 | shows "- a \<le> 0 \<longleftrightarrow> 0 \<le> a" | |
| 43920 | 621 | by (cases rule: ereal2_cases[of a]) auto | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 622 | |
| 43920 | 623 | lemma ereal_add_strict_mono: | 
| 624 | fixes a b c d :: ereal | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 625 | assumes "a \<le> b" | 
| 53873 | 626 | and "0 \<le> a" | 
| 627 | and "a \<noteq> \<infinity>" | |
| 628 | and "c < d" | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 629 | shows "a + c < b + d" | 
| 53873 | 630 | using assms | 
| 631 | by (cases rule: ereal3_cases[case_product ereal_cases, of a b c d]) auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 632 | |
| 53873 | 633 | lemma ereal_less_add: | 
| 634 | fixes a b c :: ereal | |
| 635 | shows "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b" | |
| 43920 | 636 | by (cases rule: ereal2_cases[of b c]) auto | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 637 | |
| 54416 | 638 | lemma ereal_add_nonneg_eq_0_iff: | 
| 639 | fixes a b :: ereal | |
| 640 | shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> a + b = 0 \<longleftrightarrow> a = 0 \<and> b = 0" | |
| 641 | by (cases a b rule: ereal2_cases) auto | |
| 642 | ||
| 53873 | 643 | lemma ereal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::ereal)" | 
| 644 | by auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 645 | |
| 43920 | 646 | lemma ereal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::ereal)" | 
| 647 | by (subst (3) ereal_uminus_uminus[symmetric]) (simp only: ereal_minus_less_minus) | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 648 | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 649 | lemma ereal_less_uminus_reorder: "a < - b \<longleftrightarrow> b < - (a::ereal)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 650 | by (subst (3) ereal_uminus_uminus[symmetric]) (simp only: ereal_minus_less_minus) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 651 | |
| 43920 | 652 | lemma ereal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::ereal)" | 
| 653 | by (subst (3) ereal_uminus_uminus[symmetric]) (simp only: ereal_minus_le_minus) | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 654 | |
| 43920 | 655 | lemmas ereal_uminus_reorder = | 
| 656 | ereal_uminus_eq_reorder ereal_uminus_less_reorder ereal_uminus_le_reorder | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 657 | |
| 43920 | 658 | lemma ereal_bot: | 
| 53873 | 659 | fixes x :: ereal | 
| 660 | assumes "\<And>B. x \<le> ereal B" | |
| 661 | shows "x = - \<infinity>" | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 662 | proof (cases x) | 
| 53873 | 663 | case (real r) | 
| 664 | with assms[of "r - 1"] show ?thesis | |
| 665 | by auto | |
| 47082 | 666 | next | 
| 53873 | 667 | case PInf | 
| 668 | with assms[of 0] show ?thesis | |
| 669 | by auto | |
| 47082 | 670 | next | 
| 53873 | 671 | case MInf | 
| 672 | then show ?thesis | |
| 673 | by simp | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 674 | qed | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 675 | |
| 43920 | 676 | lemma ereal_top: | 
| 53873 | 677 | fixes x :: ereal | 
| 678 | assumes "\<And>B. x \<ge> ereal B" | |
| 679 | shows "x = \<infinity>" | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 680 | proof (cases x) | 
| 53873 | 681 | case (real r) | 
| 682 | with assms[of "r + 1"] show ?thesis | |
| 683 | by auto | |
| 47082 | 684 | next | 
| 53873 | 685 | case MInf | 
| 686 | with assms[of 0] show ?thesis | |
| 687 | by auto | |
| 47082 | 688 | next | 
| 53873 | 689 | case PInf | 
| 690 | then show ?thesis | |
| 691 | by simp | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 692 | qed | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 693 | |
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 694 | lemma | 
| 43920 | 695 | shows ereal_max[simp]: "ereal (max x y) = max (ereal x) (ereal y)" | 
| 696 | and ereal_min[simp]: "ereal (min x y) = min (ereal x) (ereal y)" | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 697 | by (simp_all add: min_def max_def) | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 698 | |
| 43920 | 699 | lemma ereal_max_0: "max 0 (ereal r) = ereal (max 0 r)" | 
| 700 | by (auto simp: zero_ereal_def) | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 701 | |
| 41978 | 702 | lemma | 
| 43920 | 703 | fixes f :: "nat \<Rightarrow> ereal" | 
| 54416 | 704 | shows ereal_incseq_uminus[simp]: "incseq (\<lambda>x. - f x) \<longleftrightarrow> decseq f" | 
| 705 | and ereal_decseq_uminus[simp]: "decseq (\<lambda>x. - f x) \<longleftrightarrow> incseq f" | |
| 41978 | 706 | unfolding decseq_def incseq_def by auto | 
| 707 | ||
| 43920 | 708 | lemma incseq_ereal: "incseq f \<Longrightarrow> incseq (\<lambda>x. ereal (f x))" | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 709 | unfolding incseq_def by auto | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 710 | |
| 56537 | 711 | lemma ereal_add_nonneg_nonneg[simp]: | 
| 53873 | 712 | fixes a b :: ereal | 
| 713 | shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b" | |
| 41978 | 714 | using add_mono[of 0 a 0 b] by simp | 
| 715 | ||
| 53873 | 716 | lemma image_eqD: "f ` A = B \<Longrightarrow> \<forall>x\<in>A. f x \<in> B" | 
| 41978 | 717 | by auto | 
| 718 | ||
| 719 | lemma incseq_setsumI: | |
| 53873 | 720 |   fixes f :: "nat \<Rightarrow> 'a::{comm_monoid_add,ordered_ab_semigroup_add}"
 | 
| 41978 | 721 | assumes "\<And>i. 0 \<le> f i" | 
| 722 |   shows "incseq (\<lambda>i. setsum f {..< i})"
 | |
| 723 | proof (intro incseq_SucI) | |
| 53873 | 724 | fix n | 
| 725 |   have "setsum f {..< n} + 0 \<le> setsum f {..<n} + f n"
 | |
| 41978 | 726 | using assms by (rule add_left_mono) | 
| 727 |   then show "setsum f {..< n} \<le> setsum f {..< Suc n}"
 | |
| 728 | by auto | |
| 729 | qed | |
| 730 | ||
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 731 | lemma incseq_setsumI2: | 
| 53873 | 732 |   fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::{comm_monoid_add,ordered_ab_semigroup_add}"
 | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 733 | assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)" | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 734 | shows "incseq (\<lambda>i. \<Sum>n\<in>A. f n i)" | 
| 53873 | 735 | using assms | 
| 736 | unfolding incseq_def by (auto intro: setsum_mono) | |
| 737 | ||
| 59000 | 738 | lemma setsum_ereal[simp]: "(\<Sum>x\<in>A. ereal (f x)) = ereal (\<Sum>x\<in>A. f x)" | 
| 739 | proof (cases "finite A") | |
| 740 | case True | |
| 741 | then show ?thesis by induct auto | |
| 742 | next | |
| 743 | case False | |
| 744 | then show ?thesis by simp | |
| 745 | qed | |
| 746 | ||
| 747 | lemma setsum_Pinfty: | |
| 748 | fixes f :: "'a \<Rightarrow> ereal" | |
| 749 | shows "(\<Sum>x\<in>P. f x) = \<infinity> \<longleftrightarrow> finite P \<and> (\<exists>i\<in>P. f i = \<infinity>)" | |
| 750 | proof safe | |
| 751 | assume *: "setsum f P = \<infinity>" | |
| 752 | show "finite P" | |
| 753 | proof (rule ccontr) | |
| 754 | assume "\<not> finite P" | |
| 755 | with * show False | |
| 756 | by auto | |
| 757 | qed | |
| 758 | show "\<exists>i\<in>P. f i = \<infinity>" | |
| 759 | proof (rule ccontr) | |
| 760 | assume "\<not> ?thesis" | |
| 761 | then have "\<And>i. i \<in> P \<Longrightarrow> f i \<noteq> \<infinity>" | |
| 762 | by auto | |
| 60500 | 763 | with \<open>finite P\<close> have "setsum f P \<noteq> \<infinity>" | 
| 59000 | 764 | by induct auto | 
| 765 | with * show False | |
| 766 | by auto | |
| 767 | qed | |
| 768 | next | |
| 769 | fix i | |
| 770 | assume "finite P" and "i \<in> P" and "f i = \<infinity>" | |
| 771 | then show "setsum f P = \<infinity>" | |
| 772 | proof induct | |
| 773 | case (insert x A) | |
| 774 | show ?case using insert by (cases "x = i") auto | |
| 775 | qed simp | |
| 776 | qed | |
| 777 | ||
| 778 | lemma setsum_Inf: | |
| 779 | fixes f :: "'a \<Rightarrow> ereal" | |
| 780 | shows "\<bar>setsum f A\<bar> = \<infinity> \<longleftrightarrow> finite A \<and> (\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>)" | |
| 781 | proof | |
| 782 | assume *: "\<bar>setsum f A\<bar> = \<infinity>" | |
| 783 | have "finite A" | |
| 784 | by (rule ccontr) (insert *, auto) | |
| 785 | moreover have "\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>" | |
| 786 | proof (rule ccontr) | |
| 787 | assume "\<not> ?thesis" | |
| 788 | then have "\<forall>i\<in>A. \<exists>r. f i = ereal r" | |
| 789 | by auto | |
| 790 | from bchoice[OF this] obtain r where "\<forall>x\<in>A. f x = ereal (r x)" .. | |
| 791 | with * show False | |
| 792 | by auto | |
| 793 | qed | |
| 794 | ultimately show "finite A \<and> (\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>)" | |
| 795 | by auto | |
| 796 | next | |
| 797 | assume "finite A \<and> (\<exists>i\<in>A. \<bar>f i\<bar> = \<infinity>)" | |
| 798 | then obtain i where "finite A" "i \<in> A" and "\<bar>f i\<bar> = \<infinity>" | |
| 799 | by auto | |
| 800 | then show "\<bar>setsum f A\<bar> = \<infinity>" | |
| 801 | proof induct | |
| 802 | case (insert j A) | |
| 803 | then show ?case | |
| 804 | by (cases rule: ereal3_cases[of "f i" "f j" "setsum f A"]) auto | |
| 805 | qed simp | |
| 806 | qed | |
| 807 | ||
| 808 | lemma setsum_real_of_ereal: | |
| 809 | fixes f :: "'i \<Rightarrow> ereal" | |
| 810 | assumes "\<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>" | |
| 811 | shows "(\<Sum>x\<in>S. real (f x)) = real (setsum f S)" | |
| 812 | proof - | |
| 813 | have "\<forall>x\<in>S. \<exists>r. f x = ereal r" | |
| 814 | proof | |
| 815 | fix x | |
| 816 | assume "x \<in> S" | |
| 817 | from assms[OF this] show "\<exists>r. f x = ereal r" | |
| 818 | by (cases "f x") auto | |
| 819 | qed | |
| 820 | from bchoice[OF this] obtain r where "\<forall>x\<in>S. f x = ereal (r x)" .. | |
| 821 | then show ?thesis | |
| 822 | by simp | |
| 823 | qed | |
| 824 | ||
| 825 | lemma setsum_ereal_0: | |
| 826 | fixes f :: "'a \<Rightarrow> ereal" | |
| 827 | assumes "finite A" | |
| 828 | and "\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i" | |
| 829 | shows "(\<Sum>x\<in>A. f x) = 0 \<longleftrightarrow> (\<forall>i\<in>A. f i = 0)" | |
| 830 | proof | |
| 831 | assume "setsum f A = 0" with assms show "\<forall>i\<in>A. f i = 0" | |
| 832 | proof (induction A) | |
| 833 | case (insert a A) | |
| 834 | then have "f a = 0 \<and> (\<Sum>a\<in>A. f a) = 0" | |
| 835 | by (subst ereal_add_nonneg_eq_0_iff[symmetric]) (simp_all add: setsum_nonneg) | |
| 836 | with insert show ?case | |
| 837 | by simp | |
| 838 | qed simp | |
| 839 | qed auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 840 | |
| 41973 | 841 | subsubsection "Multiplication" | 
| 842 | ||
| 53873 | 843 | instantiation ereal :: "{comm_monoid_mult,sgn}"
 | 
| 41973 | 844 | begin | 
| 845 | ||
| 51351 | 846 | function sgn_ereal :: "ereal \<Rightarrow> ereal" where | 
| 43920 | 847 | "sgn (ereal r) = ereal (sgn r)" | 
| 43923 | 848 | | "sgn (\<infinity>::ereal) = 1" | 
| 849 | | "sgn (-\<infinity>::ereal) = -1" | |
| 43920 | 850 | by (auto intro: ereal_cases) | 
| 60679 | 851 | termination by standard (rule wf_empty) | 
| 41976 | 852 | |
| 43920 | 853 | function times_ereal where | 
| 53873 | 854 | "ereal r * ereal p = ereal (r * p)" | 
| 855 | | "ereal r * \<infinity> = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)" | |
| 856 | | "\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)" | |
| 857 | | "ereal r * -\<infinity> = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)" | |
| 858 | | "-\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)" | |
| 859 | | "(\<infinity>::ereal) * \<infinity> = \<infinity>" | |
| 860 | | "-(\<infinity>::ereal) * \<infinity> = -\<infinity>" | |
| 861 | | "(\<infinity>::ereal) * -\<infinity> = -\<infinity>" | |
| 862 | | "-(\<infinity>::ereal) * -\<infinity> = \<infinity>" | |
| 61166 
5976fe402824
renamed method "goals" to "goal_cases" to emphasize its meaning;
 wenzelm parents: 
61120diff
changeset | 863 | proof goal_cases | 
| 60580 | 864 | case prems: (1 P x) | 
| 53873 | 865 | then obtain a b where "x = (a, b)" | 
| 866 | by (cases x) auto | |
| 60580 | 867 | with prems show P | 
| 53873 | 868 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 869 | qed simp_all | 
| 870 | termination by (relation "{}") simp
 | |
| 871 | ||
| 872 | instance | |
| 873 | proof | |
| 53873 | 874 | fix a b c :: ereal | 
| 875 | show "1 * a = a" | |
| 43920 | 876 | by (cases a) (simp_all add: one_ereal_def) | 
| 47082 | 877 | show "a * b = b * a" | 
| 43920 | 878 | by (cases rule: ereal2_cases[of a b]) simp_all | 
| 47082 | 879 | show "a * b * c = a * (b * c)" | 
| 43920 | 880 | by (cases rule: ereal3_cases[of a b c]) | 
| 881 | (simp_all add: zero_ereal_def zero_less_mult_iff) | |
| 41973 | 882 | qed | 
| 53873 | 883 | |
| 41973 | 884 | end | 
| 885 | ||
| 59000 | 886 | lemma one_not_le_zero_ereal[simp]: "\<not> (1 \<le> (0::ereal))" | 
| 887 | by (simp add: one_ereal_def zero_ereal_def) | |
| 888 | ||
| 50104 | 889 | lemma real_ereal_1[simp]: "real (1::ereal) = 1" | 
| 890 | unfolding one_ereal_def by simp | |
| 891 | ||
| 43920 | 892 | lemma real_of_ereal_le_1: | 
| 53873 | 893 | fixes a :: ereal | 
| 894 | shows "a \<le> 1 \<Longrightarrow> real a \<le> 1" | |
| 43920 | 895 | by (cases a) (auto simp: one_ereal_def) | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 896 | |
| 43920 | 897 | lemma abs_ereal_one[simp]: "\<bar>1\<bar> = (1::ereal)" | 
| 898 | unfolding one_ereal_def by simp | |
| 41976 | 899 | |
| 43920 | 900 | lemma ereal_mult_zero[simp]: | 
| 53873 | 901 | fixes a :: ereal | 
| 902 | shows "a * 0 = 0" | |
| 43920 | 903 | by (cases a) (simp_all add: zero_ereal_def) | 
| 41973 | 904 | |
| 43920 | 905 | lemma ereal_zero_mult[simp]: | 
| 53873 | 906 | fixes a :: ereal | 
| 907 | shows "0 * a = 0" | |
| 43920 | 908 | by (cases a) (simp_all add: zero_ereal_def) | 
| 41973 | 909 | |
| 53873 | 910 | lemma ereal_m1_less_0[simp]: "-(1::ereal) < 0" | 
| 43920 | 911 | by (simp add: zero_ereal_def one_ereal_def) | 
| 41973 | 912 | |
| 43920 | 913 | lemma ereal_times[simp]: | 
| 43923 | 914 | "1 \<noteq> (\<infinity>::ereal)" "(\<infinity>::ereal) \<noteq> 1" | 
| 915 | "1 \<noteq> -(\<infinity>::ereal)" "-(\<infinity>::ereal) \<noteq> 1" | |
| 61120 | 916 | by (auto simp: one_ereal_def) | 
| 41973 | 917 | |
| 43920 | 918 | lemma ereal_plus_1[simp]: | 
| 53873 | 919 | "1 + ereal r = ereal (r + 1)" | 
| 920 | "ereal r + 1 = ereal (r + 1)" | |
| 921 | "1 + -(\<infinity>::ereal) = -\<infinity>" | |
| 922 | "-(\<infinity>::ereal) + 1 = -\<infinity>" | |
| 43920 | 923 | unfolding one_ereal_def by auto | 
| 41973 | 924 | |
| 43920 | 925 | lemma ereal_zero_times[simp]: | 
| 53873 | 926 | fixes a b :: ereal | 
| 927 | shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0" | |
| 43920 | 928 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 929 | |
| 43920 | 930 | lemma ereal_mult_eq_PInfty[simp]: | 
| 53873 | 931 | "a * b = (\<infinity>::ereal) \<longleftrightarrow> | 
| 41973 | 932 | (a = \<infinity> \<and> b > 0) \<or> (a > 0 \<and> b = \<infinity>) \<or> (a = -\<infinity> \<and> b < 0) \<or> (a < 0 \<and> b = -\<infinity>)" | 
| 43920 | 933 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 934 | |
| 43920 | 935 | lemma ereal_mult_eq_MInfty[simp]: | 
| 53873 | 936 | "a * b = -(\<infinity>::ereal) \<longleftrightarrow> | 
| 41973 | 937 | (a = \<infinity> \<and> b < 0) \<or> (a < 0 \<and> b = \<infinity>) \<or> (a = -\<infinity> \<and> b > 0) \<or> (a > 0 \<and> b = -\<infinity>)" | 
| 43920 | 938 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 939 | |
| 54416 | 940 | lemma ereal_abs_mult: "\<bar>x * y :: ereal\<bar> = \<bar>x\<bar> * \<bar>y\<bar>" | 
| 941 | by (cases x y rule: ereal2_cases) (auto simp: abs_mult) | |
| 942 | ||
| 43920 | 943 | lemma ereal_0_less_1[simp]: "0 < (1::ereal)" | 
| 944 | by (simp_all add: zero_ereal_def one_ereal_def) | |
| 41973 | 945 | |
| 43920 | 946 | lemma ereal_mult_minus_left[simp]: | 
| 53873 | 947 | fixes a b :: ereal | 
| 948 | shows "-a * b = - (a * b)" | |
| 43920 | 949 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 950 | |
| 43920 | 951 | lemma ereal_mult_minus_right[simp]: | 
| 53873 | 952 | fixes a b :: ereal | 
| 953 | shows "a * -b = - (a * b)" | |
| 43920 | 954 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 955 | |
| 43920 | 956 | lemma ereal_mult_infty[simp]: | 
| 43923 | 957 | "a * (\<infinity>::ereal) = (if a = 0 then 0 else if 0 < a then \<infinity> else - \<infinity>)" | 
| 41973 | 958 | by (cases a) auto | 
| 959 | ||
| 43920 | 960 | lemma ereal_infty_mult[simp]: | 
| 43923 | 961 | "(\<infinity>::ereal) * a = (if a = 0 then 0 else if 0 < a then \<infinity> else - \<infinity>)" | 
| 41973 | 962 | by (cases a) auto | 
| 963 | ||
| 43920 | 964 | lemma ereal_mult_strict_right_mono: | 
| 53873 | 965 | assumes "a < b" | 
| 966 | and "0 < c" | |
| 967 | and "c < (\<infinity>::ereal)" | |
| 41973 | 968 | shows "a * c < b * c" | 
| 969 | using assms | |
| 53873 | 970 | by (cases rule: ereal3_cases[of a b c]) (auto simp: zero_le_mult_iff) | 
| 41973 | 971 | |
| 43920 | 972 | lemma ereal_mult_strict_left_mono: | 
| 53873 | 973 | "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c < (\<infinity>::ereal) \<Longrightarrow> c * a < c * b" | 
| 974 | using ereal_mult_strict_right_mono | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57447diff
changeset | 975 | by (simp add: mult.commute[of c]) | 
| 41973 | 976 | |
| 43920 | 977 | lemma ereal_mult_right_mono: | 
| 53873 | 978 | fixes a b c :: ereal | 
| 979 | shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> a * c \<le> b * c" | |
| 41973 | 980 | using assms | 
| 53873 | 981 | apply (cases "c = 0") | 
| 982 | apply simp | |
| 983 | apply (cases rule: ereal3_cases[of a b c]) | |
| 984 | apply (auto simp: zero_le_mult_iff) | |
| 985 | done | |
| 41973 | 986 | |
| 43920 | 987 | lemma ereal_mult_left_mono: | 
| 53873 | 988 | fixes a b c :: ereal | 
| 989 | shows "a \<le> b \<Longrightarrow> 0 \<le> c \<Longrightarrow> c * a \<le> c * b" | |
| 990 | using ereal_mult_right_mono | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57447diff
changeset | 991 | by (simp add: mult.commute[of c]) | 
| 41973 | 992 | |
| 43920 | 993 | lemma zero_less_one_ereal[simp]: "0 \<le> (1::ereal)" | 
| 994 | by (simp add: one_ereal_def zero_ereal_def) | |
| 41978 | 995 | |
| 43920 | 996 | lemma ereal_0_le_mult[simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * (b :: ereal)" | 
| 56536 | 997 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 998 | |
| 43920 | 999 | lemma ereal_right_distrib: | 
| 53873 | 1000 | fixes r a b :: ereal | 
| 1001 | shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> r * (a + b) = r * a + r * b" | |
| 43920 | 1002 | by (cases rule: ereal3_cases[of r a b]) (simp_all add: field_simps) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1003 | |
| 43920 | 1004 | lemma ereal_left_distrib: | 
| 53873 | 1005 | fixes r a b :: ereal | 
| 1006 | shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> (a + b) * r = a * r + b * r" | |
| 43920 | 1007 | by (cases rule: ereal3_cases[of r a b]) (simp_all add: field_simps) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1008 | |
| 43920 | 1009 | lemma ereal_mult_le_0_iff: | 
| 1010 | fixes a b :: ereal | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1011 | shows "a * b \<le> 0 \<longleftrightarrow> (0 \<le> a \<and> b \<le> 0) \<or> (a \<le> 0 \<and> 0 \<le> b)" | 
| 43920 | 1012 | by (cases rule: ereal2_cases[of a b]) (simp_all add: mult_le_0_iff) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1013 | |
| 43920 | 1014 | lemma ereal_zero_le_0_iff: | 
| 1015 | fixes a b :: ereal | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1016 | shows "0 \<le> a * b \<longleftrightarrow> (0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0)" | 
| 43920 | 1017 | by (cases rule: ereal2_cases[of a b]) (simp_all add: zero_le_mult_iff) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1018 | |
| 43920 | 1019 | lemma ereal_mult_less_0_iff: | 
| 1020 | fixes a b :: ereal | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1021 | shows "a * b < 0 \<longleftrightarrow> (0 < a \<and> b < 0) \<or> (a < 0 \<and> 0 < b)" | 
| 43920 | 1022 | by (cases rule: ereal2_cases[of a b]) (simp_all add: mult_less_0_iff) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1023 | |
| 43920 | 1024 | lemma ereal_zero_less_0_iff: | 
| 1025 | fixes a b :: ereal | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1026 | shows "0 < a * b \<longleftrightarrow> (0 < a \<and> 0 < b) \<or> (a < 0 \<and> b < 0)" | 
| 43920 | 1027 | by (cases rule: ereal2_cases[of a b]) (simp_all add: zero_less_mult_iff) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1028 | |
| 50104 | 1029 | lemma ereal_left_mult_cong: | 
| 1030 | fixes a b c :: ereal | |
| 59002 
2c8b2fb54b88
cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
 hoelzl parents: 
59000diff
changeset | 1031 | shows "c = d \<Longrightarrow> (d \<noteq> 0 \<Longrightarrow> a = b) \<Longrightarrow> a * c = b * d" | 
| 50104 | 1032 | by (cases "c = 0") simp_all | 
| 1033 | ||
| 59000 | 1034 | lemma ereal_right_mult_cong: | 
| 59002 
2c8b2fb54b88
cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
 hoelzl parents: 
59000diff
changeset | 1035 | fixes a b c :: ereal | 
| 59000 | 1036 | shows "c = d \<Longrightarrow> (d \<noteq> 0 \<Longrightarrow> a = b) \<Longrightarrow> c * a = d * b" | 
| 59002 
2c8b2fb54b88
cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
 hoelzl parents: 
59000diff
changeset | 1037 | by (cases "c = 0") simp_all | 
| 50104 | 1038 | |
| 43920 | 1039 | lemma ereal_distrib: | 
| 1040 | fixes a b c :: ereal | |
| 53873 | 1041 | assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>" | 
| 1042 | and "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>" | |
| 1043 | and "\<bar>c\<bar> \<noteq> \<infinity>" | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1044 | shows "(a + b) * c = a * c + b * c" | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1045 | using assms | 
| 43920 | 1046 | by (cases rule: ereal3_cases[of a b c]) (simp_all add: field_simps) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1047 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
47082diff
changeset | 1048 | lemma numeral_eq_ereal [simp]: "numeral w = ereal (numeral w)" | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
47082diff
changeset | 1049 | apply (induct w rule: num_induct) | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
47082diff
changeset | 1050 | apply (simp only: numeral_One one_ereal_def) | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
47082diff
changeset | 1051 | apply (simp only: numeral_inc ereal_plus_1) | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
47082diff
changeset | 1052 | done | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
47082diff
changeset | 1053 | |
| 59000 | 1054 | lemma setsum_ereal_right_distrib: | 
| 1055 | fixes f :: "'a \<Rightarrow> ereal" | |
| 1056 | shows "(\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i) \<Longrightarrow> r * setsum f A = (\<Sum>n\<in>A. r * f n)" | |
| 1057 | by (induct A rule: infinite_finite_induct) (auto simp: ereal_right_distrib setsum_nonneg) | |
| 1058 | ||
| 59002 
2c8b2fb54b88
cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
 hoelzl parents: 
59000diff
changeset | 1059 | lemma setsum_ereal_left_distrib: | 
| 
2c8b2fb54b88
cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
 hoelzl parents: 
59000diff
changeset | 1060 | "(\<And>i. i \<in> A \<Longrightarrow> 0 \<le> f i) \<Longrightarrow> setsum f A * r = (\<Sum>n\<in>A. f n * r :: ereal)" | 
| 
2c8b2fb54b88
cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
 hoelzl parents: 
59000diff
changeset | 1061 | using setsum_ereal_right_distrib[of A f r] by (simp add: mult_ac) | 
| 
2c8b2fb54b88
cleaning up some theorem names; remove unnecessary assumptions; more complete pmf theory
 hoelzl parents: 
59000diff
changeset | 1062 | |
| 43920 | 1063 | lemma ereal_le_epsilon: | 
| 1064 | fixes x y :: ereal | |
| 53873 | 1065 | assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + e" | 
| 1066 | shows "x \<le> y" | |
| 1067 | proof - | |
| 1068 |   {
 | |
| 1069 | assume a: "\<exists>r. y = ereal r" | |
| 1070 | then obtain r where r_def: "y = ereal r" | |
| 1071 | by auto | |
| 1072 |     {
 | |
| 1073 | assume "x = -\<infinity>" | |
| 1074 | then have ?thesis by auto | |
| 1075 | } | |
| 1076 | moreover | |
| 1077 |     {
 | |
| 1078 | assume "x \<noteq> -\<infinity>" | |
| 1079 | then obtain p where p_def: "x = ereal p" | |
| 1080 | using a assms[rule_format, of 1] | |
| 1081 | by (cases x) auto | |
| 1082 |       {
 | |
| 1083 | fix e | |
| 1084 | have "0 < e \<longrightarrow> p \<le> r + e" | |
| 1085 | using assms[rule_format, of "ereal e"] p_def r_def by auto | |
| 1086 | } | |
| 1087 | then have "p \<le> r" | |
| 1088 | apply (subst field_le_epsilon) | |
| 1089 | apply auto | |
| 1090 | done | |
| 1091 | then have ?thesis | |
| 1092 | using r_def p_def by auto | |
| 1093 | } | |
| 1094 | ultimately have ?thesis | |
| 1095 | by blast | |
| 1096 | } | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1097 | moreover | 
| 53873 | 1098 |   {
 | 
| 1099 | assume "y = -\<infinity> | y = \<infinity>" | |
| 1100 | then have ?thesis | |
| 1101 | using assms[rule_format, of 1] by (cases x) auto | |
| 1102 | } | |
| 1103 | ultimately show ?thesis | |
| 1104 | by (cases y) auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1105 | qed | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1106 | |
| 43920 | 1107 | lemma ereal_le_epsilon2: | 
| 1108 | fixes x y :: ereal | |
| 53873 | 1109 | assumes "\<forall>e. 0 < e \<longrightarrow> x \<le> y + ereal e" | 
| 1110 | shows "x \<le> y" | |
| 1111 | proof - | |
| 1112 |   {
 | |
| 1113 | fix e :: ereal | |
| 1114 | assume "e > 0" | |
| 1115 |     {
 | |
| 1116 | assume "e = \<infinity>" | |
| 1117 | then have "x \<le> y + e" | |
| 1118 | by auto | |
| 1119 | } | |
| 1120 | moreover | |
| 1121 |     {
 | |
| 1122 | assume "e \<noteq> \<infinity>" | |
| 1123 | then obtain r where "e = ereal r" | |
| 60500 | 1124 | using \<open>e > 0\<close> by (cases e) auto | 
| 53873 | 1125 | then have "x \<le> y + e" | 
| 60500 | 1126 | using assms[rule_format, of r] \<open>e>0\<close> by auto | 
| 53873 | 1127 | } | 
| 1128 | ultimately have "x \<le> y + e" | |
| 1129 | by blast | |
| 1130 | } | |
| 1131 | then show ?thesis | |
| 1132 | using ereal_le_epsilon by auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1133 | qed | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1134 | |
| 43920 | 1135 | lemma ereal_le_real: | 
| 1136 | fixes x y :: ereal | |
| 53873 | 1137 | assumes "\<forall>z. x \<le> ereal z \<longrightarrow> y \<le> ereal z" | 
| 1138 | shows "y \<le> x" | |
| 1139 | by (metis assms ereal_bot ereal_cases ereal_infty_less_eq(2) ereal_less_eq(1) linorder_le_cases) | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1140 | |
| 43920 | 1141 | lemma setprod_ereal_0: | 
| 1142 | fixes f :: "'a \<Rightarrow> ereal" | |
| 53873 | 1143 | shows "(\<Prod>i\<in>A. f i) = 0 \<longleftrightarrow> finite A \<and> (\<exists>i\<in>A. f i = 0)" | 
| 1144 | proof (cases "finite A") | |
| 1145 | case True | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1146 | then show ?thesis by (induct A) auto | 
| 53873 | 1147 | next | 
| 1148 | case False | |
| 1149 | then show ?thesis by auto | |
| 1150 | qed | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1151 | |
| 43920 | 1152 | lemma setprod_ereal_pos: | 
| 53873 | 1153 | fixes f :: "'a \<Rightarrow> ereal" | 
| 1154 | assumes pos: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" | |
| 1155 | shows "0 \<le> (\<Prod>i\<in>I. f i)" | |
| 1156 | proof (cases "finite I") | |
| 1157 | case True | |
| 1158 | from this pos show ?thesis | |
| 1159 | by induct auto | |
| 1160 | next | |
| 1161 | case False | |
| 1162 | then show ?thesis by simp | |
| 1163 | qed | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1164 | |
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1165 | lemma setprod_PInf: | 
| 43923 | 1166 | fixes f :: "'a \<Rightarrow> ereal" | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1167 | assumes "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1168 | shows "(\<Prod>i\<in>I. f i) = \<infinity> \<longleftrightarrow> finite I \<and> (\<exists>i\<in>I. f i = \<infinity>) \<and> (\<forall>i\<in>I. f i \<noteq> 0)" | 
| 53873 | 1169 | proof (cases "finite I") | 
| 1170 | case True | |
| 1171 | from this assms show ?thesis | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1172 | proof (induct I) | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1173 | case (insert i I) | 
| 53873 | 1174 | then have pos: "0 \<le> f i" "0 \<le> setprod f I" | 
| 1175 | by (auto intro!: setprod_ereal_pos) | |
| 1176 | from insert have "(\<Prod>j\<in>insert i I. f j) = \<infinity> \<longleftrightarrow> setprod f I * f i = \<infinity>" | |
| 1177 | by auto | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1178 | also have "\<dots> \<longleftrightarrow> (setprod f I = \<infinity> \<or> f i = \<infinity>) \<and> f i \<noteq> 0 \<and> setprod f I \<noteq> 0" | 
| 43920 | 1179 | using setprod_ereal_pos[of I f] pos | 
| 1180 | by (cases rule: ereal2_cases[of "f i" "setprod f I"]) auto | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1181 | also have "\<dots> \<longleftrightarrow> finite (insert i I) \<and> (\<exists>j\<in>insert i I. f j = \<infinity>) \<and> (\<forall>j\<in>insert i I. f j \<noteq> 0)" | 
| 43920 | 1182 | using insert by (auto simp: setprod_ereal_0) | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1183 | finally show ?case . | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1184 | qed simp | 
| 53873 | 1185 | next | 
| 1186 | case False | |
| 1187 | then show ?thesis by simp | |
| 1188 | qed | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1189 | |
| 43920 | 1190 | lemma setprod_ereal: "(\<Prod>i\<in>A. ereal (f i)) = ereal (setprod f A)" | 
| 53873 | 1191 | proof (cases "finite A") | 
| 1192 | case True | |
| 1193 | then show ?thesis | |
| 43920 | 1194 | by induct (auto simp: one_ereal_def) | 
| 53873 | 1195 | next | 
| 1196 | case False | |
| 1197 | then show ?thesis | |
| 1198 | by (simp add: one_ereal_def) | |
| 1199 | qed | |
| 1200 | ||
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1201 | |
| 60500 | 1202 | subsubsection \<open>Power\<close> | 
| 41978 | 1203 | |
| 43920 | 1204 | lemma ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)" | 
| 1205 | by (induct n) (auto simp: one_ereal_def) | |
| 41978 | 1206 | |
| 43923 | 1207 | lemma ereal_power_PInf[simp]: "(\<infinity>::ereal) ^ n = (if n = 0 then 1 else \<infinity>)" | 
| 43920 | 1208 | by (induct n) (auto simp: one_ereal_def) | 
| 41978 | 1209 | |
| 43920 | 1210 | lemma ereal_power_uminus[simp]: | 
| 1211 | fixes x :: ereal | |
| 41978 | 1212 | shows "(- x) ^ n = (if even n then x ^ n else - (x^n))" | 
| 43920 | 1213 | by (induct n) (auto simp: one_ereal_def) | 
| 41978 | 1214 | |
| 47108 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
47082diff
changeset | 1215 | lemma ereal_power_numeral[simp]: | 
| 
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
 huffman parents: 
47082diff
changeset | 1216 | "(numeral num :: ereal) ^ n = ereal (numeral num ^ n)" | 
| 43920 | 1217 | by (induct n) (auto simp: one_ereal_def) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1218 | |
| 43920 | 1219 | lemma zero_le_power_ereal[simp]: | 
| 53873 | 1220 | fixes a :: ereal | 
| 1221 | assumes "0 \<le> a" | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1222 | shows "0 \<le> a ^ n" | 
| 43920 | 1223 | using assms by (induct n) (auto simp: ereal_zero_le_0_iff) | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1224 | |
| 53873 | 1225 | |
| 60500 | 1226 | subsubsection \<open>Subtraction\<close> | 
| 41973 | 1227 | |
| 43920 | 1228 | lemma ereal_minus_minus_image[simp]: | 
| 1229 | fixes S :: "ereal set" | |
| 41973 | 1230 | shows "uminus ` uminus ` S = S" | 
| 1231 | by (auto simp: image_iff) | |
| 1232 | ||
| 43920 | 1233 | lemma ereal_uminus_lessThan[simp]: | 
| 53873 | 1234 | fixes a :: ereal | 
| 1235 |   shows "uminus ` {..<a} = {-a<..}"
 | |
| 47082 | 1236 | proof - | 
| 1237 |   {
 | |
| 53873 | 1238 | fix x | 
| 1239 | assume "-a < x" | |
| 1240 | then have "- x < - (- a)" | |
| 1241 | by (simp del: ereal_uminus_uminus) | |
| 1242 | then have "- x < a" | |
| 1243 | by simp | |
| 47082 | 1244 | } | 
| 53873 | 1245 | then show ?thesis | 
| 54416 | 1246 | by force | 
| 47082 | 1247 | qed | 
| 41973 | 1248 | |
| 53873 | 1249 | lemma ereal_uminus_greaterThan[simp]: "uminus ` {(a::ereal)<..} = {..<-a}"
 | 
| 1250 | by (metis ereal_uminus_lessThan ereal_uminus_uminus ereal_minus_minus_image) | |
| 41973 | 1251 | |
| 43920 | 1252 | instantiation ereal :: minus | 
| 41973 | 1253 | begin | 
| 53873 | 1254 | |
| 43920 | 1255 | definition "x - y = x + -(y::ereal)" | 
| 41973 | 1256 | instance .. | 
| 53873 | 1257 | |
| 41973 | 1258 | end | 
| 1259 | ||
| 43920 | 1260 | lemma ereal_minus[simp]: | 
| 1261 | "ereal r - ereal p = ereal (r - p)" | |
| 1262 | "-\<infinity> - ereal r = -\<infinity>" | |
| 1263 | "ereal r - \<infinity> = -\<infinity>" | |
| 43923 | 1264 | "(\<infinity>::ereal) - x = \<infinity>" | 
| 1265 | "-(\<infinity>::ereal) - \<infinity> = -\<infinity>" | |
| 41973 | 1266 | "x - -y = x + y" | 
| 1267 | "x - 0 = x" | |
| 1268 | "0 - x = -x" | |
| 43920 | 1269 | by (simp_all add: minus_ereal_def) | 
| 41973 | 1270 | |
| 53873 | 1271 | lemma ereal_x_minus_x[simp]: "x - x = (if \<bar>x\<bar> = \<infinity> then \<infinity> else 0::ereal)" | 
| 41973 | 1272 | by (cases x) simp_all | 
| 1273 | ||
| 43920 | 1274 | lemma ereal_eq_minus_iff: | 
| 1275 | fixes x y z :: ereal | |
| 41973 | 1276 | shows "x = z - y \<longleftrightarrow> | 
| 41976 | 1277 | (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y = z) \<and> | 
| 41973 | 1278 | (y = -\<infinity> \<longrightarrow> x = \<infinity>) \<and> | 
| 1279 | (y = \<infinity> \<longrightarrow> z = \<infinity> \<longrightarrow> x = \<infinity>) \<and> | |
| 1280 | (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>)" | |
| 43920 | 1281 | by (cases rule: ereal3_cases[of x y z]) auto | 
| 41973 | 1282 | |
| 43920 | 1283 | lemma ereal_eq_minus: | 
| 1284 | fixes x y z :: ereal | |
| 41976 | 1285 | shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x = z - y \<longleftrightarrow> x + y = z" | 
| 43920 | 1286 | by (auto simp: ereal_eq_minus_iff) | 
| 41973 | 1287 | |
| 43920 | 1288 | lemma ereal_less_minus_iff: | 
| 1289 | fixes x y z :: ereal | |
| 41973 | 1290 | shows "x < z - y \<longleftrightarrow> | 
| 1291 | (y = \<infinity> \<longrightarrow> z = \<infinity> \<and> x \<noteq> \<infinity>) \<and> | |
| 1292 | (y = -\<infinity> \<longrightarrow> x \<noteq> \<infinity>) \<and> | |
| 41976 | 1293 | (\<bar>y\<bar> \<noteq> \<infinity>\<longrightarrow> x + y < z)" | 
| 43920 | 1294 | by (cases rule: ereal3_cases[of x y z]) auto | 
| 41973 | 1295 | |
| 43920 | 1296 | lemma ereal_less_minus: | 
| 1297 | fixes x y z :: ereal | |
| 41976 | 1298 | shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x < z - y \<longleftrightarrow> x + y < z" | 
| 43920 | 1299 | by (auto simp: ereal_less_minus_iff) | 
| 41973 | 1300 | |
| 43920 | 1301 | lemma ereal_le_minus_iff: | 
| 1302 | fixes x y z :: ereal | |
| 53873 | 1303 | shows "x \<le> z - y \<longleftrightarrow> (y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>) \<and> (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y \<le> z)" | 
| 43920 | 1304 | by (cases rule: ereal3_cases[of x y z]) auto | 
| 41973 | 1305 | |
| 43920 | 1306 | lemma ereal_le_minus: | 
| 1307 | fixes x y z :: ereal | |
| 41976 | 1308 | shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x \<le> z - y \<longleftrightarrow> x + y \<le> z" | 
| 43920 | 1309 | by (auto simp: ereal_le_minus_iff) | 
| 41973 | 1310 | |
| 43920 | 1311 | lemma ereal_minus_less_iff: | 
| 1312 | fixes x y z :: ereal | |
| 53873 | 1313 | shows "x - y < z \<longleftrightarrow> y \<noteq> -\<infinity> \<and> (y = \<infinity> \<longrightarrow> x \<noteq> \<infinity> \<and> z \<noteq> -\<infinity>) \<and> (y \<noteq> \<infinity> \<longrightarrow> x < z + y)" | 
| 43920 | 1314 | by (cases rule: ereal3_cases[of x y z]) auto | 
| 41973 | 1315 | |
| 43920 | 1316 | lemma ereal_minus_less: | 
| 1317 | fixes x y z :: ereal | |
| 41976 | 1318 | shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y < z \<longleftrightarrow> x < z + y" | 
| 43920 | 1319 | by (auto simp: ereal_minus_less_iff) | 
| 41973 | 1320 | |
| 43920 | 1321 | lemma ereal_minus_le_iff: | 
| 1322 | fixes x y z :: ereal | |
| 41973 | 1323 | shows "x - y \<le> z \<longleftrightarrow> | 
| 1324 | (y = -\<infinity> \<longrightarrow> z = \<infinity>) \<and> | |
| 1325 | (y = \<infinity> \<longrightarrow> x = \<infinity> \<longrightarrow> z = \<infinity>) \<and> | |
| 41976 | 1326 | (\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x \<le> z + y)" | 
| 43920 | 1327 | by (cases rule: ereal3_cases[of x y z]) auto | 
| 41973 | 1328 | |
| 43920 | 1329 | lemma ereal_minus_le: | 
| 1330 | fixes x y z :: ereal | |
| 41976 | 1331 | shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y \<le> z \<longleftrightarrow> x \<le> z + y" | 
| 43920 | 1332 | by (auto simp: ereal_minus_le_iff) | 
| 41973 | 1333 | |
| 43920 | 1334 | lemma ereal_minus_eq_minus_iff: | 
| 1335 | fixes a b c :: ereal | |
| 41973 | 1336 | shows "a - b = a - c \<longleftrightarrow> | 
| 1337 | b = c \<or> a = \<infinity> \<or> (a = -\<infinity> \<and> b \<noteq> -\<infinity> \<and> c \<noteq> -\<infinity>)" | |
| 43920 | 1338 | by (cases rule: ereal3_cases[of a b c]) auto | 
| 41973 | 1339 | |
| 43920 | 1340 | lemma ereal_add_le_add_iff: | 
| 43923 | 1341 | fixes a b c :: ereal | 
| 1342 | shows "c + a \<le> c + b \<longleftrightarrow> | |
| 41973 | 1343 | a \<le> b \<or> c = \<infinity> \<or> (c = -\<infinity> \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>)" | 
| 43920 | 1344 | by (cases rule: ereal3_cases[of a b c]) (simp_all add: field_simps) | 
| 41973 | 1345 | |
| 59023 | 1346 | lemma ereal_add_le_add_iff2: | 
| 1347 | fixes a b c :: ereal | |
| 1348 | shows "a + c \<le> b + c \<longleftrightarrow> a \<le> b \<or> c = \<infinity> \<or> (c = -\<infinity> \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>)" | |
| 1349 | by(cases rule: ereal3_cases[of a b c])(simp_all add: field_simps) | |
| 1350 | ||
| 43920 | 1351 | lemma ereal_mult_le_mult_iff: | 
| 43923 | 1352 | fixes a b c :: ereal | 
| 1353 | shows "\<bar>c\<bar> \<noteq> \<infinity> \<Longrightarrow> c * a \<le> c * b \<longleftrightarrow> (0 < c \<longrightarrow> a \<le> b) \<and> (c < 0 \<longrightarrow> b \<le> a)" | |
| 43920 | 1354 | by (cases rule: ereal3_cases[of a b c]) (simp_all add: mult_le_cancel_left) | 
| 41973 | 1355 | |
| 43920 | 1356 | lemma ereal_minus_mono: | 
| 1357 | fixes A B C D :: ereal assumes "A \<le> B" "D \<le> C" | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1358 | shows "A - C \<le> B - D" | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1359 | using assms | 
| 43920 | 1360 | by (cases rule: ereal3_cases[case_product ereal_cases, of A B C D]) simp_all | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1361 | |
| 43920 | 1362 | lemma real_of_ereal_minus: | 
| 43923 | 1363 | fixes a b :: ereal | 
| 1364 | shows "real (a - b) = (if \<bar>a\<bar> = \<infinity> \<or> \<bar>b\<bar> = \<infinity> then 0 else real a - real b)" | |
| 43920 | 1365 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1366 | |
| 60060 | 1367 | lemma real_of_ereal_minus': "\<bar>x\<bar> = \<infinity> \<longleftrightarrow> \<bar>y\<bar> = \<infinity> \<Longrightarrow> real x - real y = real (x - y :: ereal)" | 
| 1368 | by(subst real_of_ereal_minus) auto | |
| 1369 | ||
| 43920 | 1370 | lemma ereal_diff_positive: | 
| 1371 | fixes a b :: ereal shows "a \<le> b \<Longrightarrow> 0 \<le> b - a" | |
| 1372 | by (cases rule: ereal2_cases[of a b]) auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1373 | |
| 43920 | 1374 | lemma ereal_between: | 
| 1375 | fixes x e :: ereal | |
| 53873 | 1376 | assumes "\<bar>x\<bar> \<noteq> \<infinity>" | 
| 1377 | and "0 < e" | |
| 1378 | shows "x - e < x" | |
| 1379 | and "x < x + e" | |
| 1380 | using assms | |
| 1381 | apply (cases x, cases e) | |
| 1382 | apply auto | |
| 1383 | using assms | |
| 1384 | apply (cases x, cases e) | |
| 1385 | apply auto | |
| 1386 | done | |
| 41973 | 1387 | |
| 50104 | 1388 | lemma ereal_minus_eq_PInfty_iff: | 
| 53873 | 1389 | fixes x y :: ereal | 
| 1390 | shows "x - y = \<infinity> \<longleftrightarrow> y = -\<infinity> \<or> x = \<infinity>" | |
| 50104 | 1391 | by (cases x y rule: ereal2_cases) simp_all | 
| 1392 | ||
| 53873 | 1393 | |
| 60500 | 1394 | subsubsection \<open>Division\<close> | 
| 41973 | 1395 | |
| 43920 | 1396 | instantiation ereal :: inverse | 
| 41973 | 1397 | begin | 
| 1398 | ||
| 43920 | 1399 | function inverse_ereal where | 
| 53873 | 1400 | "inverse (ereal r) = (if r = 0 then \<infinity> else ereal (inverse r))" | 
| 1401 | | "inverse (\<infinity>::ereal) = 0" | |
| 1402 | | "inverse (-\<infinity>::ereal) = 0" | |
| 43920 | 1403 | by (auto intro: ereal_cases) | 
| 41973 | 1404 | termination by (relation "{}") simp
 | 
| 1405 | ||
| 60429 
d3d1e185cd63
uniform _ div _ as infix syntax for ring division
 haftmann parents: 
60352diff
changeset | 1406 | definition "x div y = x * inverse (y :: ereal)" | 
| 41973 | 1407 | |
| 47082 | 1408 | instance .. | 
| 53873 | 1409 | |
| 41973 | 1410 | end | 
| 1411 | ||
| 43920 | 1412 | lemma real_of_ereal_inverse[simp]: | 
| 1413 | fixes a :: ereal | |
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1414 | shows "real (inverse a) = 1 / real a" | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1415 | by (cases a) (auto simp: inverse_eq_divide) | 
| 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 1416 | |
| 43920 | 1417 | lemma ereal_inverse[simp]: | 
| 43923 | 1418 | "inverse (0::ereal) = \<infinity>" | 
| 43920 | 1419 | "inverse (1::ereal) = 1" | 
| 1420 | by (simp_all add: one_ereal_def zero_ereal_def) | |
| 41973 | 1421 | |
| 43920 | 1422 | lemma ereal_divide[simp]: | 
| 1423 | "ereal r / ereal p = (if p = 0 then ereal r * \<infinity> else ereal (r / p))" | |
| 1424 | unfolding divide_ereal_def by (auto simp: divide_real_def) | |
| 41973 | 1425 | |
| 43920 | 1426 | lemma ereal_divide_same[simp]: | 
| 53873 | 1427 | fixes x :: ereal | 
| 1428 | shows "x / x = (if \<bar>x\<bar> = \<infinity> \<or> x = 0 then 0 else 1)" | |
| 1429 | by (cases x) (simp_all add: divide_real_def divide_ereal_def one_ereal_def) | |
| 41973 | 1430 | |
| 43920 | 1431 | lemma ereal_inv_inv[simp]: | 
| 53873 | 1432 | fixes x :: ereal | 
| 1433 | shows "inverse (inverse x) = (if x \<noteq> -\<infinity> then x else \<infinity>)" | |
| 41973 | 1434 | by (cases x) auto | 
| 1435 | ||
| 43920 | 1436 | lemma ereal_inverse_minus[simp]: | 
| 53873 | 1437 | fixes x :: ereal | 
| 1438 | shows "inverse (- x) = (if x = 0 then \<infinity> else -inverse x)" | |
| 41973 | 1439 | by (cases x) simp_all | 
| 1440 | ||
| 43920 | 1441 | lemma ereal_uminus_divide[simp]: | 
| 53873 | 1442 | fixes x y :: ereal | 
| 1443 | shows "- x / y = - (x / y)" | |
| 43920 | 1444 | unfolding divide_ereal_def by simp | 
| 41973 | 1445 | |
| 43920 | 1446 | lemma ereal_divide_Infty[simp]: | 
| 53873 | 1447 | fixes x :: ereal | 
| 1448 | shows "x / \<infinity> = 0" "x / -\<infinity> = 0" | |
| 43920 | 1449 | unfolding divide_ereal_def by simp_all | 
| 41973 | 1450 | |
| 53873 | 1451 | lemma ereal_divide_one[simp]: "x / 1 = (x::ereal)" | 
| 43920 | 1452 | unfolding divide_ereal_def by simp | 
| 41973 | 1453 | |
| 53873 | 1454 | lemma ereal_divide_ereal[simp]: "\<infinity> / ereal r = (if 0 \<le> r then \<infinity> else -\<infinity>)" | 
| 43920 | 1455 | unfolding divide_ereal_def by simp | 
| 41973 | 1456 | |
| 59000 | 1457 | lemma ereal_inverse_nonneg_iff: "0 \<le> inverse (x :: ereal) \<longleftrightarrow> 0 \<le> x \<or> x = -\<infinity>" | 
| 1458 | by (cases x) auto | |
| 1459 | ||
| 43920 | 1460 | lemma zero_le_divide_ereal[simp]: | 
| 53873 | 1461 | fixes a :: ereal | 
| 1462 | assumes "0 \<le> a" | |
| 1463 | and "0 \<le> b" | |
| 41978 | 1464 | shows "0 \<le> a / b" | 
| 43920 | 1465 | using assms by (cases rule: ereal2_cases[of a b]) (auto simp: zero_le_divide_iff) | 
| 41978 | 1466 | |
| 43920 | 1467 | lemma ereal_le_divide_pos: | 
| 53873 | 1468 | fixes x y z :: ereal | 
| 1469 | shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> x * y \<le> z" | |
| 43920 | 1470 | by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) | 
| 41973 | 1471 | |
| 43920 | 1472 | lemma ereal_divide_le_pos: | 
| 53873 | 1473 | fixes x y z :: ereal | 
| 1474 | shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> z \<le> x * y" | |
| 43920 | 1475 | by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) | 
| 41973 | 1476 | |
| 43920 | 1477 | lemma ereal_le_divide_neg: | 
| 53873 | 1478 | fixes x y z :: ereal | 
| 1479 | shows "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> z \<le> x * y" | |
| 43920 | 1480 | by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) | 
| 41973 | 1481 | |
| 43920 | 1482 | lemma ereal_divide_le_neg: | 
| 53873 | 1483 | fixes x y z :: ereal | 
| 1484 | shows "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> x * y \<le> z" | |
| 43920 | 1485 | by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) | 
| 41973 | 1486 | |
| 43920 | 1487 | lemma ereal_inverse_antimono_strict: | 
| 1488 | fixes x y :: ereal | |
| 41973 | 1489 | shows "0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> inverse y < inverse x" | 
| 43920 | 1490 | by (cases rule: ereal2_cases[of x y]) auto | 
| 41973 | 1491 | |
| 43920 | 1492 | lemma ereal_inverse_antimono: | 
| 1493 | fixes x y :: ereal | |
| 53873 | 1494 | shows "0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> inverse y \<le> inverse x" | 
| 43920 | 1495 | by (cases rule: ereal2_cases[of x y]) auto | 
| 41973 | 1496 | |
| 1497 | lemma inverse_inverse_Pinfty_iff[simp]: | |
| 53873 | 1498 | fixes x :: ereal | 
| 1499 | shows "inverse x = \<infinity> \<longleftrightarrow> x = 0" | |
| 41973 | 1500 | by (cases x) auto | 
| 1501 | ||
| 43920 | 1502 | lemma ereal_inverse_eq_0: | 
| 53873 | 1503 | fixes x :: ereal | 
| 1504 | shows "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>" | |
| 41973 | 1505 | by (cases x) auto | 
| 1506 | ||
| 43920 | 1507 | lemma ereal_0_gt_inverse: | 
| 53873 | 1508 | fixes x :: ereal | 
| 1509 | shows "0 < inverse x \<longleftrightarrow> x \<noteq> \<infinity> \<and> 0 \<le> x" | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1510 | by (cases x) auto | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1511 | |
| 60060 | 1512 | lemma ereal_inverse_le_0_iff: | 
| 1513 | fixes x :: ereal | |
| 1514 | shows "inverse x \<le> 0 \<longleftrightarrow> x < 0 \<or> x = \<infinity>" | |
| 1515 | by(cases x) auto | |
| 1516 | ||
| 1517 | lemma ereal_divide_eq_0_iff: "x / y = 0 \<longleftrightarrow> x = 0 \<or> \<bar>y :: ereal\<bar> = \<infinity>" | |
| 1518 | by(cases x y rule: ereal2_cases) simp_all | |
| 1519 | ||
| 43920 | 1520 | lemma ereal_mult_less_right: | 
| 43923 | 1521 | fixes a b c :: ereal | 
| 53873 | 1522 | assumes "b * a < c * a" | 
| 1523 | and "0 < a" | |
| 1524 | and "a < \<infinity>" | |
| 41973 | 1525 | shows "b < c" | 
| 1526 | using assms | |
| 43920 | 1527 | by (cases rule: ereal3_cases[of a b c]) | 
| 41973 | 1528 | (auto split: split_if_asm simp: zero_less_mult_iff zero_le_mult_iff) | 
| 1529 | ||
| 59000 | 1530 | lemma ereal_mult_divide: fixes a b :: ereal shows "0 < b \<Longrightarrow> b < \<infinity> \<Longrightarrow> b * (a / b) = a" | 
| 1531 | by (cases a b rule: ereal2_cases) auto | |
| 1532 | ||
| 43920 | 1533 | lemma ereal_power_divide: | 
| 53873 | 1534 | fixes x y :: ereal | 
| 1535 | shows "y \<noteq> 0 \<Longrightarrow> (x / y) ^ n = x^n / y^n" | |
| 58787 | 1536 | by (cases rule: ereal2_cases [of x y]) | 
| 1537 | (auto simp: one_ereal_def zero_ereal_def power_divide zero_le_power_eq) | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1538 | |
| 43920 | 1539 | lemma ereal_le_mult_one_interval: | 
| 1540 | fixes x y :: ereal | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1541 | assumes y: "y \<noteq> -\<infinity>" | 
| 53873 | 1542 | assumes z: "\<And>z. 0 < z \<Longrightarrow> z < 1 \<Longrightarrow> z * x \<le> y" | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1543 | shows "x \<le> y" | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1544 | proof (cases x) | 
| 53873 | 1545 | case PInf | 
| 1546 | with z[of "1 / 2"] show "x \<le> y" | |
| 1547 | by (simp add: one_ereal_def) | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1548 | next | 
| 53873 | 1549 | case (real r) | 
| 1550 | note r = this | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1551 | show "x \<le> y" | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1552 | proof (cases y) | 
| 53873 | 1553 | case (real p) | 
| 1554 | note p = this | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1555 | have "r \<le> p" | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1556 | proof (rule field_le_mult_one_interval) | 
| 53873 | 1557 | fix z :: real | 
| 1558 | assume "0 < z" and "z < 1" | |
| 1559 | with z[of "ereal z"] show "z * r \<le> p" | |
| 1560 | using p r by (auto simp: zero_le_mult_iff one_ereal_def) | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1561 | qed | 
| 53873 | 1562 | then show "x \<le> y" | 
| 1563 | using p r by simp | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1564 | qed (insert y, simp_all) | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 1565 | qed simp | 
| 41978 | 1566 | |
| 45934 | 1567 | lemma ereal_divide_right_mono[simp]: | 
| 1568 | fixes x y z :: ereal | |
| 53873 | 1569 | assumes "x \<le> y" | 
| 1570 | and "0 < z" | |
| 1571 | shows "x / z \<le> y / z" | |
| 1572 | using assms by (cases x y z rule: ereal3_cases) (auto intro: divide_right_mono) | |
| 45934 | 1573 | |
| 1574 | lemma ereal_divide_left_mono[simp]: | |
| 1575 | fixes x y z :: ereal | |
| 53873 | 1576 | assumes "y \<le> x" | 
| 1577 | and "0 < z" | |
| 1578 | and "0 < x * y" | |
| 45934 | 1579 | shows "z / x \<le> z / y" | 
| 53873 | 1580 | using assms | 
| 1581 | by (cases x y z rule: ereal3_cases) | |
| 54416 | 1582 | (auto intro: divide_left_mono simp: field_simps zero_less_mult_iff mult_less_0_iff split: split_if_asm) | 
| 45934 | 1583 | |
| 1584 | lemma ereal_divide_zero_left[simp]: | |
| 1585 | fixes a :: ereal | |
| 1586 | shows "0 / a = 0" | |
| 1587 | by (cases a) (auto simp: zero_ereal_def) | |
| 1588 | ||
| 1589 | lemma ereal_times_divide_eq_left[simp]: | |
| 1590 | fixes a b c :: ereal | |
| 1591 | shows "b / c * a = b * a / c" | |
| 54416 | 1592 | by (cases a b c rule: ereal3_cases) (auto simp: field_simps zero_less_mult_iff mult_less_0_iff) | 
| 45934 | 1593 | |
| 59000 | 1594 | lemma ereal_times_divide_eq: "a * (b / c :: ereal) = a * b / c" | 
| 1595 | by (cases a b c rule: ereal3_cases) | |
| 1596 | (auto simp: field_simps zero_less_mult_iff) | |
| 53873 | 1597 | |
| 41973 | 1598 | subsection "Complete lattice" | 
| 1599 | ||
| 43920 | 1600 | instantiation ereal :: lattice | 
| 41973 | 1601 | begin | 
| 53873 | 1602 | |
| 43920 | 1603 | definition [simp]: "sup x y = (max x y :: ereal)" | 
| 1604 | definition [simp]: "inf x y = (min x y :: ereal)" | |
| 60679 | 1605 | instance by standard simp_all | 
| 53873 | 1606 | |
| 41973 | 1607 | end | 
| 1608 | ||
| 43920 | 1609 | instantiation ereal :: complete_lattice | 
| 41973 | 1610 | begin | 
| 1611 | ||
| 43923 | 1612 | definition "bot = (-\<infinity>::ereal)" | 
| 1613 | definition "top = (\<infinity>::ereal)" | |
| 41973 | 1614 | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1615 | definition "Sup S = (SOME x :: ereal. (\<forall>y\<in>S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>S. y \<le> z) \<longrightarrow> x \<le> z))" | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1616 | definition "Inf S = (SOME x :: ereal. (\<forall>y\<in>S. x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> x))" | 
| 41973 | 1617 | |
| 43920 | 1618 | lemma ereal_complete_Sup: | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1619 | fixes S :: "ereal set" | 
| 41973 | 1620 | shows "\<exists>x. (\<forall>y\<in>S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>S. y \<le> z) \<longrightarrow> x \<le> z)" | 
| 53873 | 1621 | proof (cases "\<exists>x. \<forall>a\<in>S. a \<le> ereal x") | 
| 1622 | case True | |
| 1623 | then obtain y where y: "\<And>a. a\<in>S \<Longrightarrow> a \<le> ereal y" | |
| 1624 | by auto | |
| 1625 | then have "\<infinity> \<notin> S" | |
| 1626 | by force | |
| 41973 | 1627 | show ?thesis | 
| 53873 | 1628 |   proof (cases "S \<noteq> {-\<infinity>} \<and> S \<noteq> {}")
 | 
| 1629 | case True | |
| 60500 | 1630 | with \<open>\<infinity> \<notin> S\<close> obtain x where x: "x \<in> S" "\<bar>x\<bar> \<noteq> \<infinity>" | 
| 53873 | 1631 | by auto | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1632 | obtain s where s: "\<forall>x\<in>ereal -` S. x \<le> s" "\<And>z. (\<forall>x\<in>ereal -` S. x \<le> z) \<Longrightarrow> s \<le> z" | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1633 | proof (atomize_elim, rule complete_real) | 
| 53873 | 1634 | show "\<exists>x. x \<in> ereal -` S" | 
| 1635 | using x by auto | |
| 1636 | show "\<exists>z. \<forall>x\<in>ereal -` S. x \<le> z" | |
| 1637 | by (auto dest: y intro!: exI[of _ y]) | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1638 | qed | 
| 41973 | 1639 | show ?thesis | 
| 43920 | 1640 | proof (safe intro!: exI[of _ "ereal s"]) | 
| 53873 | 1641 | fix y | 
| 1642 | assume "y \<in> S" | |
| 60500 | 1643 | with s \<open>\<infinity> \<notin> S\<close> show "y \<le> ereal s" | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1644 | by (cases y) auto | 
| 41973 | 1645 | next | 
| 53873 | 1646 | fix z | 
| 1647 | assume "\<forall>y\<in>S. y \<le> z" | |
| 60500 | 1648 |       with \<open>S \<noteq> {-\<infinity>} \<and> S \<noteq> {}\<close> show "ereal s \<le> z"
 | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1649 | by (cases z) (auto intro!: s) | 
| 41973 | 1650 | qed | 
| 53873 | 1651 | next | 
| 1652 | case False | |
| 1653 | then show ?thesis | |
| 1654 | by (auto intro!: exI[of _ "-\<infinity>"]) | |
| 1655 | qed | |
| 1656 | next | |
| 1657 | case False | |
| 1658 | then show ?thesis | |
| 1659 | by (fastforce intro!: exI[of _ \<infinity>] ereal_top intro: order_trans dest: less_imp_le simp: not_le) | |
| 1660 | qed | |
| 41973 | 1661 | |
| 43920 | 1662 | lemma ereal_complete_uminus_eq: | 
| 1663 | fixes S :: "ereal set" | |
| 41973 | 1664 | shows "(\<forall>y\<in>uminus`S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>uminus`S. y \<le> z) \<longrightarrow> x \<le> z) | 
| 1665 | \<longleftrightarrow> (\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> -x)" | |
| 43920 | 1666 | by simp (metis ereal_minus_le_minus ereal_uminus_uminus) | 
| 41973 | 1667 | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1668 | lemma ereal_complete_Inf: | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1669 | "\<exists>x. (\<forall>y\<in>S::ereal set. x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> x)" | 
| 53873 | 1670 | using ereal_complete_Sup[of "uminus ` S"] | 
| 1671 | unfolding ereal_complete_uminus_eq | |
| 1672 | by auto | |
| 41973 | 1673 | |
| 1674 | instance | |
| 52729 
412c9e0381a1
factored syntactic type classes for bot and top (by Alessandro Coglio)
 haftmann parents: 
51775diff
changeset | 1675 | proof | 
| 
412c9e0381a1
factored syntactic type classes for bot and top (by Alessandro Coglio)
 haftmann parents: 
51775diff
changeset | 1676 |   show "Sup {} = (bot::ereal)"
 | 
| 53873 | 1677 | apply (auto simp: bot_ereal_def Sup_ereal_def) | 
| 1678 | apply (rule some1_equality) | |
| 1679 | apply (metis ereal_bot ereal_less_eq(2)) | |
| 1680 | apply (metis ereal_less_eq(2)) | |
| 1681 | done | |
| 52729 
412c9e0381a1
factored syntactic type classes for bot and top (by Alessandro Coglio)
 haftmann parents: 
51775diff
changeset | 1682 |   show "Inf {} = (top::ereal)"
 | 
| 53873 | 1683 | apply (auto simp: top_ereal_def Inf_ereal_def) | 
| 1684 | apply (rule some1_equality) | |
| 1685 | apply (metis ereal_top ereal_less_eq(1)) | |
| 1686 | apply (metis ereal_less_eq(1)) | |
| 1687 | done | |
| 52729 
412c9e0381a1
factored syntactic type classes for bot and top (by Alessandro Coglio)
 haftmann parents: 
51775diff
changeset | 1688 | qed (auto intro: someI2_ex ereal_complete_Sup ereal_complete_Inf | 
| 
412c9e0381a1
factored syntactic type classes for bot and top (by Alessandro Coglio)
 haftmann parents: 
51775diff
changeset | 1689 | simp: Sup_ereal_def Inf_ereal_def bot_ereal_def top_ereal_def) | 
| 43941 | 1690 | |
| 41973 | 1691 | end | 
| 1692 | ||
| 43941 | 1693 | instance ereal :: complete_linorder .. | 
| 1694 | ||
| 51775 
408d937c9486
revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
 hoelzl parents: 
51774diff
changeset | 1695 | instance ereal :: linear_continuum | 
| 
408d937c9486
revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
 hoelzl parents: 
51774diff
changeset | 1696 | proof | 
| 
408d937c9486
revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
 hoelzl parents: 
51774diff
changeset | 1697 | show "\<exists>a b::ereal. a \<noteq> b" | 
| 54416 | 1698 | using zero_neq_one by blast | 
| 51775 
408d937c9486
revert #916271d52466; add non-topological linear_continuum type class; show linear_continuum_topology is a perfect_space
 hoelzl parents: 
51774diff
changeset | 1699 | qed | 
| 60720 | 1700 | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1701 | subsubsection "Topological space" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1702 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1703 | instantiation ereal :: linear_continuum_topology | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1704 | begin | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1705 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1706 | definition "open_ereal" :: "ereal set \<Rightarrow> bool" where | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1707 | open_ereal_generated: "open_ereal = generate_topology (range lessThan \<union> range greaterThan)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1708 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1709 | instance | 
| 60679 | 1710 | by standard (simp add: open_ereal_generated) | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1711 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1712 | end | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1713 | |
| 60720 | 1714 | lemma continuous_on_compose': | 
| 1715 | "continuous_on s f \<Longrightarrow> continuous_on t g \<Longrightarrow> f`s \<subseteq> t \<Longrightarrow> continuous_on s (\<lambda>x. g (f x))" | |
| 1716 | using continuous_on_compose[of s f g] continuous_on_subset[of t g "f`s"] by auto | |
| 1717 | ||
| 1718 | lemma continuous_on_ereal[continuous_intros]: | |
| 1719 | assumes f: "continuous_on s f" shows "continuous_on s (\<lambda>x. ereal (f x))" | |
| 1720 | by (rule continuous_on_compose'[OF f continuous_onI_mono[of ereal UNIV]]) auto | |
| 1721 | ||
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1722 | lemma tendsto_ereal[tendsto_intros, simp, intro]: "(f ---> x) F \<Longrightarrow> ((\<lambda>x. ereal (f x)) ---> ereal x) F" | 
| 60720 | 1723 | using isCont_tendsto_compose[of x ereal f F] continuous_on_ereal[of UNIV "\<lambda>x. x"] | 
| 1724 | by (simp add: continuous_on_eq_continuous_at) | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1725 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1726 | lemma tendsto_uminus_ereal[tendsto_intros, simp, intro]: "(f ---> x) F \<Longrightarrow> ((\<lambda>x. - f x::ereal) ---> - x) F" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1727 | apply (rule tendsto_compose[where g=uminus]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1728 | apply (auto intro!: order_tendstoI simp: eventually_at_topological) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1729 |   apply (rule_tac x="{..< -a}" in exI)
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1730 | apply (auto split: ereal.split simp: ereal_less_uminus_reorder) [] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1731 |   apply (rule_tac x="{- a <..}" in exI)
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1732 | apply (auto split: ereal.split simp: ereal_uminus_reorder) [] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1733 | done | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1734 | |
| 61245 | 1735 | lemma at_infty_ereal_eq_at_top: "at \<infinity> = filtermap ereal at_top" | 
| 1736 | unfolding filter_eq_iff eventually_at_filter eventually_at_top_linorder eventually_filtermap | |
| 1737 | top_ereal_def[symmetric] | |
| 1738 | apply (subst eventually_nhds_top[of 0]) | |
| 1739 | apply (auto simp: top_ereal_def less_le ereal_all_split ereal_ex_split) | |
| 1740 | apply (metis PInfty_neq_ereal(2) ereal_less_eq(3) ereal_top le_cases order_trans) | |
| 1741 | done | |
| 1742 | ||
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1743 | lemma ereal_Lim_uminus: "(f ---> f0) net \<longleftrightarrow> ((\<lambda>x. - f x::ereal) ---> - f0) net" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1744 | using tendsto_uminus_ereal[of f f0 net] tendsto_uminus_ereal[of "\<lambda>x. - f x" "- f0" net] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1745 | by auto | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1746 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1747 | lemma ereal_divide_less_iff: "0 < (c::ereal) \<Longrightarrow> c < \<infinity> \<Longrightarrow> a / c < b \<longleftrightarrow> a < b * c" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1748 | by (cases a b c rule: ereal3_cases) (auto simp: field_simps) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1749 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1750 | lemma ereal_less_divide_iff: "0 < (c::ereal) \<Longrightarrow> c < \<infinity> \<Longrightarrow> a < b / c \<longleftrightarrow> a * c < b" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1751 | by (cases a b c rule: ereal3_cases) (auto simp: field_simps) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1752 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1753 | lemma tendsto_cmult_ereal[tendsto_intros, simp, intro]: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1754 | assumes c: "\<bar>c\<bar> \<noteq> \<infinity>" and f: "(f ---> x) F" shows "((\<lambda>x. c * f x::ereal) ---> c * x) F" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1755 | proof - | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1756 |   { fix c :: ereal assume "0 < c" "c < \<infinity>"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1757 | then have "((\<lambda>x. c * f x::ereal) ---> c * x) F" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1758 | apply (intro tendsto_compose[OF _ f]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1759 | apply (auto intro!: order_tendstoI simp: eventually_at_topological) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1760 |       apply (rule_tac x="{a/c <..}" in exI)
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1761 | apply (auto split: ereal.split simp: ereal_divide_less_iff mult.commute) [] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1762 |       apply (rule_tac x="{..< a/c}" in exI)
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1763 | apply (auto split: ereal.split simp: ereal_less_divide_iff mult.commute) [] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1764 | done } | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1765 | note * = this | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1766 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1767 | have "((0 < c \<and> c < \<infinity>) \<or> (-\<infinity> < c \<and> c < 0) \<or> c = 0)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1768 | using c by (cases c) auto | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1769 | then show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1770 | proof (elim disjE conjE) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1771 | assume "- \<infinity> < c" "c < 0" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1772 | then have "0 < - c" "- c < \<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1773 | by (auto simp: ereal_uminus_reorder ereal_less_uminus_reorder[of 0]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1774 | then have "((\<lambda>x. (- c) * f x) ---> (- c) * x) F" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1775 | by (rule *) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1776 | from tendsto_uminus_ereal[OF this] show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1777 | by simp | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1778 | qed (auto intro!: *) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1779 | qed | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1780 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1781 | lemma tendsto_cmult_ereal_not_0[tendsto_intros, simp, intro]: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1782 | assumes "x \<noteq> 0" and f: "(f ---> x) F" shows "((\<lambda>x. c * f x::ereal) ---> c * x) F" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1783 | proof cases | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1784 | assume "\<bar>c\<bar> = \<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1785 | show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1786 | proof (rule filterlim_cong[THEN iffD1, OF refl refl _ tendsto_const]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1787 | have "0 < x \<or> x < 0" | 
| 60500 | 1788 | using \<open>x \<noteq> 0\<close> by (auto simp add: neq_iff) | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1789 | then show "eventually (\<lambda>x'. c * x = c * f x') F" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1790 | proof | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1791 | assume "0 < x" from order_tendstoD(1)[OF f this] show ?thesis | 
| 60500 | 1792 | by eventually_elim (insert \<open>0<x\<close> \<open>\<bar>c\<bar> = \<infinity>\<close>, auto) | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1793 | next | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1794 | assume "x < 0" from order_tendstoD(2)[OF f this] show ?thesis | 
| 60500 | 1795 | by eventually_elim (insert \<open>x<0\<close> \<open>\<bar>c\<bar> = \<infinity>\<close>, auto) | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1796 | qed | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1797 | qed | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1798 | qed (rule tendsto_cmult_ereal[OF _ f]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1799 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1800 | lemma tendsto_cadd_ereal[tendsto_intros, simp, intro]: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1801 | assumes c: "y \<noteq> - \<infinity>" "x \<noteq> - \<infinity>" and f: "(f ---> x) F" shows "((\<lambda>x. f x + y::ereal) ---> x + y) F" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1802 | apply (intro tendsto_compose[OF _ f]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1803 | apply (auto intro!: order_tendstoI simp: eventually_at_topological) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1804 |   apply (rule_tac x="{a - y <..}" in exI)
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1805 | apply (auto split: ereal.split simp: ereal_minus_less_iff c) [] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1806 |   apply (rule_tac x="{..< a - y}" in exI)
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1807 | apply (auto split: ereal.split simp: ereal_less_minus_iff c) [] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1808 | done | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1809 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1810 | lemma tendsto_add_left_ereal[tendsto_intros, simp, intro]: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1811 | assumes c: "\<bar>y\<bar> \<noteq> \<infinity>" and f: "(f ---> x) F" shows "((\<lambda>x. f x + y::ereal) ---> x + y) F" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1812 | apply (intro tendsto_compose[OF _ f]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1813 | apply (auto intro!: order_tendstoI simp: eventually_at_topological) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1814 |   apply (rule_tac x="{a - y <..}" in exI)
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1815 | apply (insert c, auto split: ereal.split simp: ereal_minus_less_iff) [] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1816 |   apply (rule_tac x="{..< a - y}" in exI)
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1817 | apply (auto split: ereal.split simp: ereal_less_minus_iff c) [] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1818 | done | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1819 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1820 | lemma continuous_at_ereal[continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. ereal (f x))" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1821 | unfolding continuous_def by auto | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1822 | |
| 59425 | 1823 | lemma ereal_Sup: | 
| 1824 | assumes *: "\<bar>SUP a:A. ereal a\<bar> \<noteq> \<infinity>" | |
| 1825 | shows "ereal (Sup A) = (SUP a:A. ereal a)" | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1826 | proof (rule continuous_at_Sup_mono) | 
| 59425 | 1827 |   obtain r where r: "ereal r = (SUP a:A. ereal a)" "A \<noteq> {}"
 | 
| 1828 | using * by (force simp: bot_ereal_def) | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1829 |   then show "bdd_above A" "A \<noteq> {}"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1830 | by (auto intro!: SUP_upper bdd_aboveI[of _ r] simp add: ereal_less_eq(3)[symmetric] simp del: ereal_less_eq) | 
| 60762 | 1831 | qed (auto simp: mono_def continuous_at_imp_continuous_at_within continuous_at_ereal) | 
| 59425 | 1832 | |
| 1833 | lemma ereal_SUP: "\<bar>SUP a:A. ereal (f a)\<bar> \<noteq> \<infinity> \<Longrightarrow> ereal (SUP a:A. f a) = (SUP a:A. ereal (f a))" | |
| 1834 | using ereal_Sup[of "f`A"] by auto | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1835 | |
| 59425 | 1836 | lemma ereal_Inf: | 
| 1837 | assumes *: "\<bar>INF a:A. ereal a\<bar> \<noteq> \<infinity>" | |
| 1838 | shows "ereal (Inf A) = (INF a:A. ereal a)" | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1839 | proof (rule continuous_at_Inf_mono) | 
| 59425 | 1840 |   obtain r where r: "ereal r = (INF a:A. ereal a)" "A \<noteq> {}"
 | 
| 1841 | using * by (force simp: top_ereal_def) | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1842 |   then show "bdd_below A" "A \<noteq> {}"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1843 | by (auto intro!: INF_lower bdd_belowI[of _ r] simp add: ereal_less_eq(3)[symmetric] simp del: ereal_less_eq) | 
| 60762 | 1844 | qed (auto simp: mono_def continuous_at_imp_continuous_at_within continuous_at_ereal) | 
| 59425 | 1845 | |
| 1846 | lemma ereal_INF: "\<bar>INF a:A. ereal (f a)\<bar> \<noteq> \<infinity> \<Longrightarrow> ereal (INF a:A. f a) = (INF a:A. ereal (f a))" | |
| 1847 | using ereal_Inf[of "f`A"] by auto | |
| 1848 | ||
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1849 | lemma ereal_Sup_uminus_image_eq: "Sup (uminus ` S::ereal set) = - Inf S" | 
| 56166 | 1850 | by (auto intro!: SUP_eqI | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1851 | simp: Ball_def[symmetric] ereal_uminus_le_reorder le_Inf_iff | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1852 | intro!: complete_lattice_class.Inf_lower2) | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1853 | |
| 56166 | 1854 | lemma ereal_SUP_uminus_eq: | 
| 1855 | fixes f :: "'a \<Rightarrow> ereal" | |
| 1856 | shows "(SUP x:S. uminus (f x)) = - (INF x:S. f x)" | |
| 1857 | using ereal_Sup_uminus_image_eq [of "f ` S"] by (simp add: comp_def) | |
| 1858 | ||
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1859 | lemma ereal_inj_on_uminus[intro, simp]: "inj_on uminus (A :: ereal set)" | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1860 | by (auto intro!: inj_onI) | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1861 | |
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1862 | lemma ereal_Inf_uminus_image_eq: "Inf (uminus ` S::ereal set) = - Sup S" | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1863 | using ereal_Sup_uminus_image_eq[of "uminus ` S"] by simp | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1864 | |
| 56166 | 1865 | lemma ereal_INF_uminus_eq: | 
| 1866 | fixes f :: "'a \<Rightarrow> ereal" | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1867 | shows "(INF x:S. - f x) = - (SUP x:S. f x)" | 
| 56166 | 1868 | using ereal_Inf_uminus_image_eq [of "f ` S"] by (simp add: comp_def) | 
| 1869 | ||
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1870 | lemma ereal_SUP_uminus: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1871 | fixes f :: "'a \<Rightarrow> ereal" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1872 | shows "(SUP i : R. - f i) = - (INF i : R. f i)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1873 | using ereal_Sup_uminus_image_eq[of "f`R"] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1874 | by (simp add: image_image) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1875 | |
| 54416 | 1876 | lemma ereal_SUP_not_infty: | 
| 1877 | fixes f :: "_ \<Rightarrow> ereal" | |
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 1878 |   shows "A \<noteq> {} \<Longrightarrow> l \<noteq> -\<infinity> \<Longrightarrow> u \<noteq> \<infinity> \<Longrightarrow> \<forall>a\<in>A. l \<le> f a \<and> f a \<le> u \<Longrightarrow> \<bar>SUPREMUM A f\<bar> \<noteq> \<infinity>"
 | 
| 54416 | 1879 | using SUP_upper2[of _ A l f] SUP_least[of A f u] | 
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 1880 | by (cases "SUPREMUM A f") auto | 
| 54416 | 1881 | |
| 1882 | lemma ereal_INF_not_infty: | |
| 1883 | fixes f :: "_ \<Rightarrow> ereal" | |
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 1884 |   shows "A \<noteq> {} \<Longrightarrow> l \<noteq> -\<infinity> \<Longrightarrow> u \<noteq> \<infinity> \<Longrightarrow> \<forall>a\<in>A. l \<le> f a \<and> f a \<le> u \<Longrightarrow> \<bar>INFIMUM A f\<bar> \<noteq> \<infinity>"
 | 
| 54416 | 1885 | using INF_lower2[of _ A f u] INF_greatest[of A l f] | 
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 1886 | by (cases "INFIMUM A f") auto | 
| 54416 | 1887 | |
| 43920 | 1888 | lemma ereal_image_uminus_shift: | 
| 53873 | 1889 | fixes X Y :: "ereal set" | 
| 1890 | shows "uminus ` X = Y \<longleftrightarrow> X = uminus ` Y" | |
| 41973 | 1891 | proof | 
| 1892 | assume "uminus ` X = Y" | |
| 1893 | then have "uminus ` uminus ` X = uminus ` Y" | |
| 1894 | by (simp add: inj_image_eq_iff) | |
| 53873 | 1895 | then show "X = uminus ` Y" | 
| 1896 | by (simp add: image_image) | |
| 41973 | 1897 | qed (simp add: image_image) | 
| 1898 | ||
| 1899 | lemma Sup_eq_MInfty: | |
| 53873 | 1900 | fixes S :: "ereal set" | 
| 1901 |   shows "Sup S = -\<infinity> \<longleftrightarrow> S = {} \<or> S = {-\<infinity>}"
 | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1902 | unfolding bot_ereal_def[symmetric] by auto | 
| 41973 | 1903 | |
| 1904 | lemma Inf_eq_PInfty: | |
| 53873 | 1905 | fixes S :: "ereal set" | 
| 1906 |   shows "Inf S = \<infinity> \<longleftrightarrow> S = {} \<or> S = {\<infinity>}"
 | |
| 41973 | 1907 | using Sup_eq_MInfty[of "uminus`S"] | 
| 43920 | 1908 | unfolding ereal_Sup_uminus_image_eq ereal_image_uminus_shift by simp | 
| 41973 | 1909 | |
| 53873 | 1910 | lemma Inf_eq_MInfty: | 
| 1911 | fixes S :: "ereal set" | |
| 1912 | shows "-\<infinity> \<in> S \<Longrightarrow> Inf S = -\<infinity>" | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1913 | unfolding bot_ereal_def[symmetric] by auto | 
| 41973 | 1914 | |
| 43923 | 1915 | lemma Sup_eq_PInfty: | 
| 53873 | 1916 | fixes S :: "ereal set" | 
| 1917 | shows "\<infinity> \<in> S \<Longrightarrow> Sup S = \<infinity>" | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 1918 | unfolding top_ereal_def[symmetric] by auto | 
| 41973 | 1919 | |
| 60771 | 1920 | lemma not_MInfty_nonneg[simp]: "0 \<le> (x::ereal) \<Longrightarrow> x \<noteq> - \<infinity>" | 
| 1921 | by auto | |
| 1922 | ||
| 43920 | 1923 | lemma Sup_ereal_close: | 
| 1924 | fixes e :: ereal | |
| 53873 | 1925 | assumes "0 < e" | 
| 1926 |     and S: "\<bar>Sup S\<bar> \<noteq> \<infinity>" "S \<noteq> {}"
 | |
| 41973 | 1927 | shows "\<exists>x\<in>S. Sup S - e < x" | 
| 41976 | 1928 | using assms by (cases e) (auto intro!: less_Sup_iff[THEN iffD1]) | 
| 41973 | 1929 | |
| 43920 | 1930 | lemma Inf_ereal_close: | 
| 53873 | 1931 | fixes e :: ereal | 
| 1932 | assumes "\<bar>Inf X\<bar> \<noteq> \<infinity>" | |
| 1933 | and "0 < e" | |
| 41973 | 1934 | shows "\<exists>x\<in>X. x < Inf X + e" | 
| 1935 | proof (rule Inf_less_iff[THEN iffD1]) | |
| 53873 | 1936 | show "Inf X < Inf X + e" | 
| 1937 | using assms by (cases e) auto | |
| 41973 | 1938 | qed | 
| 1939 | ||
| 59425 | 1940 | lemma SUP_PInfty: | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1941 | "(\<And>n::nat. \<exists>i\<in>A. ereal (real n) \<le> f i) \<Longrightarrow> (SUP i:A. f i :: ereal) = \<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1942 | unfolding top_ereal_def[symmetric] SUP_eq_top_iff | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1943 | by (metis MInfty_neq_PInfty(2) PInfty_neq_ereal(2) less_PInf_Ex_of_nat less_ereal.elims(2) less_le_trans) | 
| 59425 | 1944 | |
| 43920 | 1945 | lemma SUP_nat_Infty: "(SUP i::nat. ereal (real i)) = \<infinity>" | 
| 59425 | 1946 | by (rule SUP_PInfty) auto | 
| 41973 | 1947 | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1948 | lemma SUP_ereal_add_left: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1949 |   assumes "I \<noteq> {}" "c \<noteq> -\<infinity>"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1950 | shows "(SUP i:I. f i + c :: ereal) = (SUP i:I. f i) + c" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1951 | proof cases | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1952 | assume "(SUP i:I. f i) = - \<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1953 | moreover then have "\<And>i. i \<in> I \<Longrightarrow> f i = -\<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1954 | unfolding Sup_eq_MInfty Sup_image_eq[symmetric] by auto | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1955 | ultimately show ?thesis | 
| 60500 | 1956 |     by (cases c) (auto simp: \<open>I \<noteq> {}\<close>)
 | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1957 | next | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1958 | assume "(SUP i:I. f i) \<noteq> - \<infinity>" then show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1959 | unfolding Sup_image_eq[symmetric] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1960 | by (subst continuous_at_Sup_mono[where f="\<lambda>x. x + c"]) | 
| 60762 | 1961 |        (auto simp: continuous_at_imp_continuous_at_within continuous_at mono_def ereal_add_mono \<open>I \<noteq> {}\<close> \<open>c \<noteq> -\<infinity>\<close>)
 | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1962 | qed | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1963 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1964 | lemma SUP_ereal_add_right: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1965 | fixes c :: ereal | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1966 |   shows "I \<noteq> {} \<Longrightarrow> c \<noteq> -\<infinity> \<Longrightarrow> (SUP i:I. c + f i) = c + (SUP i:I. f i)"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1967 | using SUP_ereal_add_left[of I c f] by (simp add: add.commute) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1968 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1969 | lemma SUP_ereal_minus_right: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1970 |   assumes "I \<noteq> {}" "c \<noteq> -\<infinity>"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1971 | shows "(SUP i:I. c - f i :: ereal) = c - (INF i:I. f i)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1972 | using SUP_ereal_add_right[OF assms, of "\<lambda>i. - f i"] | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1973 | by (simp add: ereal_SUP_uminus minus_ereal_def) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1974 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1975 | lemma SUP_ereal_minus_left: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1976 |   assumes "I \<noteq> {}" "c \<noteq> \<infinity>"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1977 | shows "(SUP i:I. f i - c:: ereal) = (SUP i:I. f i) - c" | 
| 60500 | 1978 |   using SUP_ereal_add_left[OF \<open>I \<noteq> {}\<close>, of "-c" f] by (simp add: \<open>c \<noteq> \<infinity>\<close> minus_ereal_def)
 | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1979 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1980 | lemma INF_ereal_minus_right: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1981 |   assumes "I \<noteq> {}" and "\<bar>c\<bar> \<noteq> \<infinity>"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1982 | shows "(INF i:I. c - f i) = c - (SUP i:I. f i::ereal)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1983 | proof - | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1984 |   { fix b have "(-c) + b = - (c - b)"
 | 
| 60500 | 1985 | using \<open>\<bar>c\<bar> \<noteq> \<infinity>\<close> by (cases c b rule: ereal2_cases) auto } | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1986 | note * = this | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1987 | show ?thesis | 
| 60500 | 1988 |     using SUP_ereal_add_right[OF \<open>I \<noteq> {}\<close>, of "-c" f] \<open>\<bar>c\<bar> \<noteq> \<infinity>\<close>
 | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1989 | by (auto simp add: * ereal_SUP_uminus_eq) | 
| 41973 | 1990 | qed | 
| 1991 | ||
| 43920 | 1992 | lemma SUP_ereal_le_addI: | 
| 43923 | 1993 | fixes f :: "'i \<Rightarrow> ereal" | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1994 | assumes "\<And>i. f i + y \<le> z" and "y \<noteq> -\<infinity>" | 
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 1995 | shows "SUPREMUM UNIV f + y \<le> z" | 
| 60500 | 1996 | unfolding SUP_ereal_add_left[OF UNIV_not_empty \<open>y \<noteq> -\<infinity>\<close>, symmetric] | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1997 | by (rule SUP_least assms)+ | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1998 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 1999 | lemma SUP_combine: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2000 | fixes f :: "'a::semilattice_sup \<Rightarrow> 'a::semilattice_sup \<Rightarrow> 'b::complete_lattice" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2001 | assumes mono: "\<And>a b c d. a \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> f a c \<le> f b d" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2002 | shows "(SUP i:UNIV. SUP j:UNIV. f i j) = (SUP i. f i i)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2003 | proof (rule antisym) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2004 | show "(SUP i j. f i j) \<le> (SUP i. f i i)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2005 | by (rule SUP_least SUP_upper2[where i="sup i j" for i j] UNIV_I mono sup_ge1 sup_ge2)+ | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2006 | show "(SUP i. f i i) \<le> (SUP i j. f i j)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2007 | by (rule SUP_least SUP_upper2 UNIV_I mono order_refl)+ | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2008 | qed | 
| 41978 | 2009 | |
| 56212 
3253aaf73a01
consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
 haftmann parents: 
56166diff
changeset | 2010 | lemma SUP_ereal_add: | 
| 43920 | 2011 | fixes f g :: "nat \<Rightarrow> ereal" | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2012 | assumes inc: "incseq f" "incseq g" | 
| 53873 | 2013 | and pos: "\<And>i. f i \<noteq> -\<infinity>" "\<And>i. g i \<noteq> -\<infinity>" | 
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 2014 | shows "(SUP i. f i + g i) = SUPREMUM UNIV f + SUPREMUM UNIV g" | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2015 | apply (subst SUP_ereal_add_left[symmetric, OF UNIV_not_empty]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2016 | apply (metis SUP_upper UNIV_I assms(4) ereal_infty_less_eq(2)) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2017 | apply (subst (2) add.commute) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2018 | apply (subst SUP_ereal_add_left[symmetric, OF UNIV_not_empty assms(3)]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2019 | apply (subst (2) add.commute) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2020 | apply (rule SUP_combine[symmetric] ereal_add_mono inc[THEN monoD] | assumption)+ | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2021 | done | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2022 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2023 | lemma INF_ereal_add: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2024 | fixes f :: "nat \<Rightarrow> ereal" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2025 | assumes "decseq f" "decseq g" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2026 | and fin: "\<And>i. f i \<noteq> \<infinity>" "\<And>i. g i \<noteq> \<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2027 | shows "(INF i. f i + g i) = INFIMUM UNIV f + INFIMUM UNIV g" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2028 | proof - | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2029 | have INF_less: "(INF i. f i) < \<infinity>" "(INF i. g i) < \<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2030 | using assms unfolding INF_less_iff by auto | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2031 |   { fix a b :: ereal assume "a \<noteq> \<infinity>" "b \<noteq> \<infinity>"
 | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2032 | then have "- ((- a) + (- b)) = a + b" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2033 | by (cases a b rule: ereal2_cases) auto } | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2034 | note * = this | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2035 | have "(INF i. f i + g i) = (INF i. - ((- f i) + (- g i)))" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2036 | by (simp add: fin *) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2037 | also have "\<dots> = INFIMUM UNIV f + INFIMUM UNIV g" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2038 | unfolding ereal_INF_uminus_eq | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2039 | using assms INF_less | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2040 | by (subst SUP_ereal_add) (auto simp: ereal_SUP_uminus fin *) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2041 | finally show ?thesis . | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2042 | qed | 
| 41978 | 2043 | |
| 56212 
3253aaf73a01
consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
 haftmann parents: 
56166diff
changeset | 2044 | lemma SUP_ereal_add_pos: | 
| 43920 | 2045 | fixes f g :: "nat \<Rightarrow> ereal" | 
| 53873 | 2046 | assumes inc: "incseq f" "incseq g" | 
| 2047 | and pos: "\<And>i. 0 \<le> f i" "\<And>i. 0 \<le> g i" | |
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 2048 | shows "(SUP i. f i + g i) = SUPREMUM UNIV f + SUPREMUM UNIV g" | 
| 56212 
3253aaf73a01
consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
 haftmann parents: 
56166diff
changeset | 2049 | proof (intro SUP_ereal_add inc) | 
| 53873 | 2050 | fix i | 
| 2051 | show "f i \<noteq> -\<infinity>" "g i \<noteq> -\<infinity>" | |
| 2052 | using pos[of i] by auto | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 2053 | qed | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 2054 | |
| 56212 
3253aaf73a01
consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
 haftmann parents: 
56166diff
changeset | 2055 | lemma SUP_ereal_setsum: | 
| 43920 | 2056 | fixes f g :: "'a \<Rightarrow> nat \<Rightarrow> ereal" | 
| 53873 | 2057 | assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)" | 
| 2058 | and pos: "\<And>n i. n \<in> A \<Longrightarrow> 0 \<le> f n i" | |
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 2059 | shows "(SUP i. \<Sum>n\<in>A. f n i) = (\<Sum>n\<in>A. SUPREMUM UNIV (f n))" | 
| 53873 | 2060 | proof (cases "finite A") | 
| 2061 | case True | |
| 2062 | then show ?thesis using assms | |
| 56212 
3253aaf73a01
consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
 haftmann parents: 
56166diff
changeset | 2063 | by induct (auto simp: incseq_setsumI2 setsum_nonneg SUP_ereal_add_pos) | 
| 53873 | 2064 | next | 
| 2065 | case False | |
| 2066 | then show ?thesis by simp | |
| 2067 | qed | |
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 2068 | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2069 | lemma SUP_ereal_mult_left: | 
| 59000 | 2070 | fixes f :: "'a \<Rightarrow> ereal" | 
| 2071 |   assumes "I \<noteq> {}"
 | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2072 | assumes f: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" and c: "0 \<le> c" | 
| 59000 | 2073 | shows "(SUP i:I. c * f i) = c * (SUP i:I. f i)" | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2074 | proof cases | 
| 60060 | 2075 | assume "(SUP i: I. f i) = 0" | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2076 | moreover then have "\<And>i. i \<in> I \<Longrightarrow> f i = 0" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2077 | by (metis SUP_upper f antisym) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2078 | ultimately show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2079 | by simp | 
| 59000 | 2080 | next | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2081 | assume "(SUP i:I. f i) \<noteq> 0" then show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2082 | unfolding SUP_def | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2083 | by (subst continuous_at_Sup_mono[where f="\<lambda>x. c * x"]) | 
| 60762 | 2084 |        (auto simp: mono_def continuous_at continuous_at_imp_continuous_at_within \<open>I \<noteq> {}\<close>
 | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2085 | intro!: ereal_mult_left_mono c) | 
| 59000 | 2086 | qed | 
| 2087 | ||
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2088 | lemma countable_approach: | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2089 | fixes x :: ereal | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2090 | assumes "x \<noteq> -\<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2091 | shows "\<exists>f. incseq f \<and> (\<forall>i::nat. f i < x) \<and> (f ----> x)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2092 | proof (cases x) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2093 | case (real r) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2094 | moreover have "(\<lambda>n. r - inverse (real (Suc n))) ----> r - 0" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2095 | by (intro tendsto_intros LIMSEQ_inverse_real_of_nat) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2096 | ultimately show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2097 | by (intro exI[of _ "\<lambda>n. x - inverse (Suc n)"]) (auto simp: incseq_def) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2098 | next | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2099 | case PInf with LIMSEQ_SUP[of "\<lambda>n::nat. ereal (real n)"] show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2100 | by (intro exI[of _ "\<lambda>n. ereal (real n)"]) (auto simp: incseq_def SUP_nat_Infty) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2101 | qed (simp add: assms) | 
| 59000 | 2102 | |
| 56212 
3253aaf73a01
consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
 haftmann parents: 
56166diff
changeset | 2103 | lemma Sup_countable_SUP: | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 2104 |   assumes "A \<noteq> {}"
 | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2105 | shows "\<exists>f::nat \<Rightarrow> ereal. incseq f \<and> range f \<subseteq> A \<and> Sup A = (SUP i. f i)" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2106 | proof cases | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2107 | assume "Sup A = -\<infinity>" | 
| 60500 | 2108 |   with \<open>A \<noteq> {}\<close> have "A = {-\<infinity>}"
 | 
| 53873 | 2109 | by (auto simp: Sup_eq_MInfty) | 
| 2110 | then show ?thesis | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2111 | by (auto intro!: exI[of _ "\<lambda>_. -\<infinity>"] simp: bot_ereal_def) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2112 | next | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2113 | assume "Sup A \<noteq> -\<infinity>" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2114 | then obtain l where "incseq l" and l: "\<And>i::nat. l i < Sup A" and l_Sup: "l ----> Sup A" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2115 | by (auto dest: countable_approach) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2116 | |
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2117 | have "\<exists>f. \<forall>n. (f n \<in> A \<and> l n \<le> f n) \<and> (f n \<le> f (Suc n))" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2118 | proof (rule dependent_nat_choice) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2119 | show "\<exists>x. x \<in> A \<and> l 0 \<le> x" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2120 | using l[of 0] by (auto simp: less_Sup_iff) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2121 | next | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2122 | fix x n assume "x \<in> A \<and> l n \<le> x" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2123 | moreover from l[of "Suc n"] obtain y where "y \<in> A" "l (Suc n) < y" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2124 | by (auto simp: less_Sup_iff) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2125 | ultimately show "\<exists>y. (y \<in> A \<and> l (Suc n) \<le> y) \<and> x \<le> y" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2126 | by (auto intro!: exI[of _ "max x y"] split: split_max) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2127 | qed | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2128 | then guess f .. note f = this | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2129 | then have "range f \<subseteq> A" "incseq f" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2130 | by (auto simp: incseq_Suc_iff) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2131 | moreover | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2132 | have "(SUP i. f i) = Sup A" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2133 | proof (rule tendsto_unique) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2134 | show "f ----> (SUP i. f i)" | 
| 60500 | 2135 | by (rule LIMSEQ_SUP \<open>incseq f\<close>)+ | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2136 | show "f ----> Sup A" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2137 | using l f | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2138 | by (intro tendsto_sandwich[OF _ _ l_Sup tendsto_const]) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2139 | (auto simp: Sup_upper) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2140 | qed simp | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2141 | ultimately show ?thesis | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2142 | by auto | 
| 41979 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 2143 | qed | 
| 
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
 hoelzl parents: 
41978diff
changeset | 2144 | |
| 56212 
3253aaf73a01
consolidated theorem names containing INFI and SUPR: have INF and SUP instead uniformly
 haftmann parents: 
56166diff
changeset | 2145 | lemma SUP_countable_SUP: | 
| 56218 
1c3f1f2431f9
elongated INFI and SUPR, to reduced risk of confusing theorems names in the future while still being consistent with INTER and UNION
 haftmann parents: 
56212diff
changeset | 2146 |   "A \<noteq> {} \<Longrightarrow> \<exists>f::nat \<Rightarrow> ereal. range f \<subseteq> g`A \<and> SUPREMUM A g = SUPREMUM UNIV f"
 | 
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2147 | using Sup_countable_SUP [of "g`A"] by auto | 
| 42950 
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
 hoelzl parents: 
42600diff
changeset | 2148 | |
| 45934 | 2149 | subsection "Relation to @{typ enat}"
 | 
| 2150 | ||
| 2151 | definition "ereal_of_enat n = (case n of enat n \<Rightarrow> ereal (real n) | \<infinity> \<Rightarrow> \<infinity>)" | |
| 2152 | ||
| 2153 | declare [[coercion "ereal_of_enat :: enat \<Rightarrow> ereal"]] | |
| 2154 | declare [[coercion "(\<lambda>n. ereal (real n)) :: nat \<Rightarrow> ereal"]] | |
| 2155 | ||
| 2156 | lemma ereal_of_enat_simps[simp]: | |
| 2157 | "ereal_of_enat (enat n) = ereal n" | |
| 2158 | "ereal_of_enat \<infinity> = \<infinity>" | |
| 2159 | by (simp_all add: ereal_of_enat_def) | |
| 2160 | ||
| 53873 | 2161 | lemma ereal_of_enat_le_iff[simp]: "ereal_of_enat m \<le> ereal_of_enat n \<longleftrightarrow> m \<le> n" | 
| 2162 | by (cases m n rule: enat2_cases) auto | |
| 45934 | 2163 | |
| 53873 | 2164 | lemma ereal_of_enat_less_iff[simp]: "ereal_of_enat m < ereal_of_enat n \<longleftrightarrow> m < n" | 
| 2165 | by (cases m n rule: enat2_cases) auto | |
| 50819 
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
 noschinl parents: 
50104diff
changeset | 2166 | |
| 53873 | 2167 | lemma numeral_le_ereal_of_enat_iff[simp]: "numeral m \<le> ereal_of_enat n \<longleftrightarrow> numeral m \<le> n" | 
| 59587 
8ea7b22525cb
Removed the obsolete functions "natfloor" and "natceiling"
 nipkow parents: 
59452diff
changeset | 2168 | by (cases n) (auto) | 
| 45934 | 2169 | |
| 53873 | 2170 | lemma numeral_less_ereal_of_enat_iff[simp]: "numeral m < ereal_of_enat n \<longleftrightarrow> numeral m < n" | 
| 56889 
48a745e1bde7
avoid the Complex constructor, use the more natural Re/Im view; moved csqrt to Complex.
 hoelzl parents: 
56537diff
changeset | 2171 | by (cases n) auto | 
| 50819 
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
 noschinl parents: 
50104diff
changeset | 2172 | |
| 53873 | 2173 | lemma ereal_of_enat_ge_zero_cancel_iff[simp]: "0 \<le> ereal_of_enat n \<longleftrightarrow> 0 \<le> n" | 
| 2174 | by (cases n) (auto simp: enat_0[symmetric]) | |
| 45934 | 2175 | |
| 53873 | 2176 | lemma ereal_of_enat_gt_zero_cancel_iff[simp]: "0 < ereal_of_enat n \<longleftrightarrow> 0 < n" | 
| 2177 | by (cases n) (auto simp: enat_0[symmetric]) | |
| 45934 | 2178 | |
| 53873 | 2179 | lemma ereal_of_enat_zero[simp]: "ereal_of_enat 0 = 0" | 
| 2180 | by (auto simp: enat_0[symmetric]) | |
| 45934 | 2181 | |
| 53873 | 2182 | lemma ereal_of_enat_inf[simp]: "ereal_of_enat n = \<infinity> \<longleftrightarrow> n = \<infinity>" | 
| 50819 
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
 noschinl parents: 
50104diff
changeset | 2183 | by (cases n) auto | 
| 
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
 noschinl parents: 
50104diff
changeset | 2184 | |
| 53873 | 2185 | lemma ereal_of_enat_add: "ereal_of_enat (m + n) = ereal_of_enat m + ereal_of_enat n" | 
| 2186 | by (cases m n rule: enat2_cases) auto | |
| 45934 | 2187 | |
| 2188 | lemma ereal_of_enat_sub: | |
| 53873 | 2189 | assumes "n \<le> m" | 
| 2190 | shows "ereal_of_enat (m - n) = ereal_of_enat m - ereal_of_enat n " | |
| 2191 | using assms by (cases m n rule: enat2_cases) auto | |
| 45934 | 2192 | |
| 2193 | lemma ereal_of_enat_mult: | |
| 2194 | "ereal_of_enat (m * n) = ereal_of_enat m * ereal_of_enat n" | |
| 53873 | 2195 | by (cases m n rule: enat2_cases) auto | 
| 45934 | 2196 | |
| 2197 | lemmas ereal_of_enat_pushin = ereal_of_enat_add ereal_of_enat_sub ereal_of_enat_mult | |
| 2198 | lemmas ereal_of_enat_pushout = ereal_of_enat_pushin[symmetric] | |
| 2199 | ||
| 60637 | 2200 | lemma ereal_of_enat_Sup: | 
| 2201 |   assumes "A \<noteq> {}" shows "ereal_of_enat (Sup A) = (SUP a : A. ereal_of_enat a)"
 | |
| 2202 | proof (intro antisym mono_Sup) | |
| 2203 | show "ereal_of_enat (Sup A) \<le> (SUP a : A. ereal_of_enat a)" | |
| 2204 | proof cases | |
| 2205 | assume "finite A" | |
| 61188 | 2206 |     with \<open>A \<noteq> {}\<close> obtain a where "a \<in> A" "ereal_of_enat (Sup A) = ereal_of_enat a"
 | 
| 60637 | 2207 | using Max_in[of A] by (auto simp: Sup_enat_def simp del: Max_in) | 
| 2208 | then show ?thesis | |
| 2209 | by (auto intro: SUP_upper) | |
| 2210 | next | |
| 2211 | assume "\<not> finite A" | |
| 2212 | have [simp]: "(SUP a : A. ereal_of_enat a) = top" | |
| 2213 | unfolding SUP_eq_top_iff | |
| 2214 | proof safe | |
| 2215 | fix x :: ereal assume "x < top" | |
| 2216 | then obtain n :: nat where "x < n" | |
| 2217 | using less_PInf_Ex_of_nat top_ereal_def by auto | |
| 2218 |       obtain a where "a \<in> A - enat ` {.. n}"
 | |
| 61188 | 2219 | by (metis \<open>\<not> finite A\<close> all_not_in_conv finite_Diff2 finite_atMost finite_imageI finite.emptyI) | 
| 60637 | 2220 | then have "a \<in> A" "ereal n \<le> ereal_of_enat a" | 
| 2221 | by (auto simp: image_iff Ball_def) | |
| 2222 | (metis enat_iless enat_ord_simps(1) ereal_of_enat_less_iff ereal_of_enat_simps(1) less_le not_less) | |
| 61188 | 2223 | with \<open>x < n\<close> show "\<exists>i\<in>A. x < ereal_of_enat i" | 
| 60637 | 2224 | by (auto intro!: bexI[of _ a]) | 
| 2225 | qed | |
| 2226 | show ?thesis | |
| 2227 | by simp | |
| 2228 | qed | |
| 2229 | qed (simp add: mono_def) | |
| 2230 | ||
| 2231 | lemma ereal_of_enat_SUP: | |
| 2232 |   "A \<noteq> {} \<Longrightarrow> ereal_of_enat (SUP a:A. f a) = (SUP a : A. ereal_of_enat (f a))"
 | |
| 2233 | using ereal_of_enat_Sup[of "f`A"] by auto | |
| 45934 | 2234 | |
| 43920 | 2235 | subsection "Limits on @{typ ereal}"
 | 
| 41973 | 2236 | |
| 43920 | 2237 | lemma open_PInfty: "open A \<Longrightarrow> \<infinity> \<in> A \<Longrightarrow> (\<exists>x. {ereal x<..} \<subseteq> A)"
 | 
| 51000 | 2238 | unfolding open_ereal_generated | 
| 2239 | proof (induct rule: generate_topology.induct) | |
| 2240 | case (Int A B) | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 2241 |   then obtain x z where "\<infinity> \<in> A \<Longrightarrow> {ereal x <..} \<subseteq> A" "\<infinity> \<in> B \<Longrightarrow> {ereal z <..} \<subseteq> B"
 | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 2242 | by auto | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 2243 | with Int show ?case | 
| 51000 | 2244 | by (intro exI[of _ "max x z"]) fastforce | 
| 2245 | next | |
| 53873 | 2246 | case (Basis S) | 
| 2247 |   {
 | |
| 2248 | fix x | |
| 2249 | have "x \<noteq> \<infinity> \<Longrightarrow> \<exists>t. x \<le> ereal t" | |
| 2250 | by (cases x) auto | |
| 2251 | } | |
| 2252 | moreover note Basis | |
| 51000 | 2253 | ultimately show ?case | 
| 2254 | by (auto split: ereal.split) | |
| 2255 | qed (fastforce simp add: vimage_Union)+ | |
| 41973 | 2256 | |
| 43920 | 2257 | lemma open_MInfty: "open A \<Longrightarrow> -\<infinity> \<in> A \<Longrightarrow> (\<exists>x. {..<ereal x} \<subseteq> A)"
 | 
| 51000 | 2258 | unfolding open_ereal_generated | 
| 2259 | proof (induct rule: generate_topology.induct) | |
| 2260 | case (Int A B) | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 2261 |   then obtain x z where "-\<infinity> \<in> A \<Longrightarrow> {..< ereal x} \<subseteq> A" "-\<infinity> \<in> B \<Longrightarrow> {..< ereal z} \<subseteq> B"
 | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 2262 | by auto | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 2263 | with Int show ?case | 
| 51000 | 2264 | by (intro exI[of _ "min x z"]) fastforce | 
| 2265 | next | |
| 53873 | 2266 | case (Basis S) | 
| 2267 |   {
 | |
| 2268 | fix x | |
| 2269 | have "x \<noteq> - \<infinity> \<Longrightarrow> \<exists>t. ereal t \<le> x" | |
| 2270 | by (cases x) auto | |
| 2271 | } | |
| 2272 | moreover note Basis | |
| 51000 | 2273 | ultimately show ?case | 
| 2274 | by (auto split: ereal.split) | |
| 2275 | qed (fastforce simp add: vimage_Union)+ | |
| 2276 | ||
| 2277 | lemma open_ereal_vimage: "open S \<Longrightarrow> open (ereal -` S)" | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2278 | by (intro open_vimage continuous_intros) | 
| 51000 | 2279 | |
| 2280 | lemma open_ereal: "open S \<Longrightarrow> open (ereal ` S)" | |
| 2281 | unfolding open_generated_order[where 'a=real] | |
| 2282 | proof (induct rule: generate_topology.induct) | |
| 2283 | case (Basis S) | |
| 53873 | 2284 |   moreover {
 | 
| 2285 | fix x | |
| 2286 |     have "ereal ` {..< x} = { -\<infinity> <..< ereal x }"
 | |
| 2287 | apply auto | |
| 2288 | apply (case_tac xa) | |
| 2289 | apply auto | |
| 2290 | done | |
| 2291 | } | |
| 2292 |   moreover {
 | |
| 2293 | fix x | |
| 2294 |     have "ereal ` {x <..} = { ereal x <..< \<infinity> }"
 | |
| 2295 | apply auto | |
| 2296 | apply (case_tac xa) | |
| 2297 | apply auto | |
| 2298 | done | |
| 2299 | } | |
| 51000 | 2300 | ultimately show ?case | 
| 2301 | by auto | |
| 2302 | qed (auto simp add: image_Union image_Int) | |
| 2303 | ||
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2304 | |
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2305 | lemma eventually_finite: | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2306 | fixes x :: ereal | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2307 | assumes "\<bar>x\<bar> \<noteq> \<infinity>" "(f ---> x) F" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2308 | shows "eventually (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>) F" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2309 | proof - | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2310 | have "(f ---> ereal (real x)) F" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2311 | using assms by (cases x) auto | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2312 | then have "eventually (\<lambda>x. f x \<in> ereal ` UNIV) F" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2313 | by (rule topological_tendstoD) (auto intro: open_ereal) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2314 | also have "(\<lambda>x. f x \<in> ereal ` UNIV) = (\<lambda>x. \<bar>f x\<bar> \<noteq> \<infinity>)" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2315 | by auto | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2316 | finally show ?thesis . | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2317 | qed | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2318 | |
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2319 | |
| 53873 | 2320 | lemma open_ereal_def: | 
| 2321 |   "open A \<longleftrightarrow> open (ereal -` A) \<and> (\<infinity> \<in> A \<longrightarrow> (\<exists>x. {ereal x <..} \<subseteq> A)) \<and> (-\<infinity> \<in> A \<longrightarrow> (\<exists>x. {..<ereal x} \<subseteq> A))"
 | |
| 51000 | 2322 | (is "open A \<longleftrightarrow> ?rhs") | 
| 2323 | proof | |
| 53873 | 2324 | assume "open A" | 
| 2325 | then show ?rhs | |
| 51000 | 2326 | using open_PInfty open_MInfty open_ereal_vimage by auto | 
| 2327 | next | |
| 2328 | assume "?rhs" | |
| 2329 |   then obtain x y where A: "open (ereal -` A)" "\<infinity> \<in> A \<Longrightarrow> {ereal x<..} \<subseteq> A" "-\<infinity> \<in> A \<Longrightarrow> {..< ereal y} \<subseteq> A"
 | |
| 2330 | by auto | |
| 2331 |   have *: "A = ereal ` (ereal -` A) \<union> (if \<infinity> \<in> A then {ereal x<..} else {}) \<union> (if -\<infinity> \<in> A then {..< ereal y} else {})"
 | |
| 2332 | using A(2,3) by auto | |
| 2333 | from open_ereal[OF A(1)] show "open A" | |
| 2334 | by (subst *) (auto simp: open_Un) | |
| 2335 | qed | |
| 41973 | 2336 | |
| 53873 | 2337 | lemma open_PInfty2: | 
| 2338 | assumes "open A" | |
| 2339 | and "\<infinity> \<in> A" | |
| 2340 |   obtains x where "{ereal x<..} \<subseteq> A"
 | |
| 41973 | 2341 | using open_PInfty[OF assms] by auto | 
| 2342 | ||
| 53873 | 2343 | lemma open_MInfty2: | 
| 2344 | assumes "open A" | |
| 2345 | and "-\<infinity> \<in> A" | |
| 2346 |   obtains x where "{..<ereal x} \<subseteq> A"
 | |
| 41973 | 2347 | using open_MInfty[OF assms] by auto | 
| 2348 | ||
| 53873 | 2349 | lemma ereal_openE: | 
| 2350 | assumes "open A" | |
| 2351 | obtains x y where "open (ereal -` A)" | |
| 2352 |     and "\<infinity> \<in> A \<Longrightarrow> {ereal x<..} \<subseteq> A"
 | |
| 2353 |     and "-\<infinity> \<in> A \<Longrightarrow> {..<ereal y} \<subseteq> A"
 | |
| 43920 | 2354 | using assms open_ereal_def by auto | 
| 41973 | 2355 | |
| 51000 | 2356 | lemmas open_ereal_lessThan = open_lessThan[where 'a=ereal] | 
| 2357 | lemmas open_ereal_greaterThan = open_greaterThan[where 'a=ereal] | |
| 2358 | lemmas ereal_open_greaterThanLessThan = open_greaterThanLessThan[where 'a=ereal] | |
| 2359 | lemmas closed_ereal_atLeast = closed_atLeast[where 'a=ereal] | |
| 2360 | lemmas closed_ereal_atMost = closed_atMost[where 'a=ereal] | |
| 2361 | lemmas closed_ereal_atLeastAtMost = closed_atLeastAtMost[where 'a=ereal] | |
| 2362 | lemmas closed_ereal_singleton = closed_singleton[where 'a=ereal] | |
| 53873 | 2363 | |
| 43920 | 2364 | lemma ereal_open_cont_interval: | 
| 43923 | 2365 | fixes S :: "ereal set" | 
| 53873 | 2366 | assumes "open S" | 
| 2367 | and "x \<in> S" | |
| 2368 | and "\<bar>x\<bar> \<noteq> \<infinity>" | |
| 2369 |   obtains e where "e > 0" and "{x-e <..< x+e} \<subseteq> S"
 | |
| 2370 | proof - | |
| 60500 | 2371 | from \<open>open S\<close> | 
| 53873 | 2372 | have "open (ereal -` S)" | 
| 2373 | by (rule ereal_openE) | |
| 2374 | then obtain e where "e > 0" and e: "\<And>y. dist y (real x) < e \<Longrightarrow> ereal y \<in> S" | |
| 41980 
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
 hoelzl parents: 
41979diff
changeset | 2375 | using assms unfolding open_dist by force | 
| 41975 | 2376 | show thesis | 
| 2377 | proof (intro that subsetI) | |
| 53873 | 2378 | show "0 < ereal e" | 
| 60500 | 2379 | using \<open>0 < e\<close> by auto | 
| 53873 | 2380 | fix y | 
| 2381 |     assume "y \<in> {x - ereal e<..<x + ereal e}"
 | |
| 43920 | 2382 | with assms obtain t where "y = ereal t" "dist t (real x) < e" | 
| 53873 | 2383 | by (cases y) (auto simp: dist_real_def) | 
| 2384 | then show "y \<in> S" | |
| 2385 | using e[of t] by auto | |
| 41975 | 2386 | qed | 
| 41973 | 2387 | qed | 
| 2388 | ||
| 43920 | 2389 | lemma ereal_open_cont_interval2: | 
| 43923 | 2390 | fixes S :: "ereal set" | 
| 53873 | 2391 | assumes "open S" | 
| 2392 | and "x \<in> S" | |
| 2393 | and x: "\<bar>x\<bar> \<noteq> \<infinity>" | |
| 2394 |   obtains a b where "a < x" and "x < b" and "{a <..< b} \<subseteq> S"
 | |
| 53381 | 2395 | proof - | 
| 2396 |   obtain e where "0 < e" "{x - e<..<x + e} \<subseteq> S"
 | |
| 2397 | using assms by (rule ereal_open_cont_interval) | |
| 53873 | 2398 | with that[of "x - e" "x + e"] ereal_between[OF x, of e] | 
| 2399 | show thesis | |
| 2400 | by auto | |
| 41973 | 2401 | qed | 
| 2402 | ||
| 60500 | 2403 | subsubsection \<open>Convergent sequences\<close> | 
| 41973 | 2404 | |
| 43920 | 2405 | lemma lim_real_of_ereal[simp]: | 
| 2406 | assumes lim: "(f ---> ereal x) net" | |
| 41973 | 2407 | shows "((\<lambda>x. real (f x)) ---> x) net" | 
| 2408 | proof (intro topological_tendstoI) | |
| 53873 | 2409 | fix S | 
| 2410 | assume "open S" and "x \<in> S" | |
| 43920 | 2411 | then have S: "open S" "ereal x \<in> ereal ` S" | 
| 41973 | 2412 | by (simp_all add: inj_image_mem_iff) | 
| 53873 | 2413 | have "\<forall>x. f x \<in> ereal ` S \<longrightarrow> real (f x) \<in> S" | 
| 2414 | by auto | |
| 43920 | 2415 | from this lim[THEN topological_tendstoD, OF open_ereal, OF S] | 
| 41973 | 2416 | show "eventually (\<lambda>x. real (f x) \<in> S) net" | 
| 2417 | by (rule eventually_mono) | |
| 2418 | qed | |
| 2419 | ||
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2420 | lemma lim_ereal[simp]: "((\<lambda>n. ereal (f n)) ---> ereal x) net \<longleftrightarrow> (f ---> x) net" | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2421 | by (auto dest!: lim_real_of_ereal) | 
| 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2422 | |
| 51000 | 2423 | lemma tendsto_PInfty: "(f ---> \<infinity>) F \<longleftrightarrow> (\<forall>r. eventually (\<lambda>x. ereal r < f x) F)" | 
| 51022 
78de6c7e8a58
replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
 hoelzl parents: 
51000diff
changeset | 2424 | proof - | 
| 53873 | 2425 |   {
 | 
| 2426 | fix l :: ereal | |
| 2427 | assume "\<forall>r. eventually (\<lambda>x. ereal r < f x) F" | |
| 2428 | from this[THEN spec, of "real l"] have "l \<noteq> \<infinity> \<Longrightarrow> eventually (\<lambda>x. l < f x) F" | |
| 2429 | by (cases l) (auto elim: eventually_elim1) | |
| 2430 | } | |
| 51022 
78de6c7e8a58
replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
 hoelzl parents: 
51000diff
changeset | 2431 | then show ?thesis | 
| 
78de6c7e8a58
replace open_interval with the rule open_tendstoI; generalize Liminf/Limsup rules
 hoelzl parents: 
51000diff
changeset | 2432 | by (auto simp: order_tendsto_iff) | 
| 41973 | 2433 | qed | 
| 2434 | ||
| 57025 | 2435 | lemma tendsto_PInfty_eq_at_top: | 
| 2436 | "((\<lambda>z. ereal (f z)) ---> \<infinity>) F \<longleftrightarrow> (LIM z F. f z :> at_top)" | |
| 2437 | unfolding tendsto_PInfty filterlim_at_top_dense by simp | |
| 2438 | ||
| 51000 | 2439 | lemma tendsto_MInfty: "(f ---> -\<infinity>) F \<longleftrightarrow> (\<forall>r. eventually (\<lambda>x. f x < ereal r) F)" | 
| 2440 | unfolding tendsto_def | |
| 2441 | proof safe | |
| 53381 | 2442 | fix S :: "ereal set" | 
| 2443 | assume "open S" "-\<infinity> \<in> S" | |
| 2444 |   from open_MInfty[OF this] obtain B where "{..<ereal B} \<subseteq> S" ..
 | |
| 51000 | 2445 | moreover | 
| 2446 | assume "\<forall>r::real. eventually (\<lambda>z. f z < r) F" | |
| 53873 | 2447 |   then have "eventually (\<lambda>z. f z \<in> {..< B}) F"
 | 
| 2448 | by auto | |
| 2449 | ultimately show "eventually (\<lambda>z. f z \<in> S) F" | |
| 2450 | by (auto elim!: eventually_elim1) | |
| 51000 | 2451 | next | 
| 53873 | 2452 | fix x | 
| 2453 | assume "\<forall>S. open S \<longrightarrow> -\<infinity> \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) F" | |
| 2454 |   from this[rule_format, of "{..< ereal x}"] show "eventually (\<lambda>y. f y < ereal x) F"
 | |
| 2455 | by auto | |
| 41973 | 2456 | qed | 
| 2457 | ||
| 51000 | 2458 | lemma Lim_PInfty: "f ----> \<infinity> \<longleftrightarrow> (\<forall>B. \<exists>N. \<forall>n\<ge>N. f n \<ge> ereal B)" | 
| 2459 | unfolding tendsto_PInfty eventually_sequentially | |
| 2460 | proof safe | |
| 53873 | 2461 | fix r | 
| 2462 | assume "\<forall>r. \<exists>N. \<forall>n\<ge>N. ereal r \<le> f n" | |
| 2463 | then obtain N where "\<forall>n\<ge>N. ereal (r + 1) \<le> f n" | |
| 2464 | by blast | |
| 2465 | moreover have "ereal r < ereal (r + 1)" | |
| 2466 | by auto | |
| 51000 | 2467 | ultimately show "\<exists>N. \<forall>n\<ge>N. ereal r < f n" | 
| 2468 | by (blast intro: less_le_trans) | |
| 2469 | qed (blast intro: less_imp_le) | |
| 41973 | 2470 | |
| 51000 | 2471 | lemma Lim_MInfty: "f ----> -\<infinity> \<longleftrightarrow> (\<forall>B. \<exists>N. \<forall>n\<ge>N. ereal B \<ge> f n)" | 
| 2472 | unfolding tendsto_MInfty eventually_sequentially | |
| 2473 | proof safe | |
| 53873 | 2474 | fix r | 
| 2475 | assume "\<forall>r. \<exists>N. \<forall>n\<ge>N. f n \<le> ereal r" | |
| 2476 | then obtain N where "\<forall>n\<ge>N. f n \<le> ereal (r - 1)" | |
| 2477 | by blast | |
| 2478 | moreover have "ereal (r - 1) < ereal r" | |
| 2479 | by auto | |
| 51000 | 2480 | ultimately show "\<exists>N. \<forall>n\<ge>N. f n < ereal r" | 
| 2481 | by (blast intro: le_less_trans) | |
| 2482 | qed (blast intro: less_imp_le) | |
| 41973 | 2483 | |
| 51000 | 2484 | lemma Lim_bounded_PInfty: "f ----> l \<Longrightarrow> (\<And>n. f n \<le> ereal B) \<Longrightarrow> l \<noteq> \<infinity>" | 
| 2485 | using LIMSEQ_le_const2[of f l "ereal B"] by auto | |
| 41973 | 2486 | |
| 51000 | 2487 | lemma Lim_bounded_MInfty: "f ----> l \<Longrightarrow> (\<And>n. ereal B \<le> f n) \<Longrightarrow> l \<noteq> -\<infinity>" | 
| 2488 | using LIMSEQ_le_const[of f l "ereal B"] by auto | |
| 41973 | 2489 | |
| 2490 | lemma tendsto_explicit: | |
| 53873 | 2491 | "f ----> f0 \<longleftrightarrow> (\<forall>S. open S \<longrightarrow> f0 \<in> S \<longrightarrow> (\<exists>N. \<forall>n\<ge>N. f n \<in> S))" | 
| 41973 | 2492 | unfolding tendsto_def eventually_sequentially by auto | 
| 2493 | ||
| 53873 | 2494 | lemma Lim_bounded_PInfty2: "f ----> l \<Longrightarrow> \<forall>n\<ge>N. f n \<le> ereal B \<Longrightarrow> l \<noteq> \<infinity>" | 
| 51000 | 2495 | using LIMSEQ_le_const2[of f l "ereal B"] by fastforce | 
| 41973 | 2496 | |
| 53873 | 2497 | lemma Lim_bounded_ereal: "f ----> (l :: 'a::linorder_topology) \<Longrightarrow> \<forall>n\<ge>M. f n \<le> C \<Longrightarrow> l \<le> C" | 
| 51000 | 2498 | by (intro LIMSEQ_le_const2) auto | 
| 41973 | 2499 | |
| 51351 | 2500 | lemma Lim_bounded2_ereal: | 
| 53873 | 2501 | assumes lim:"f ----> (l :: 'a::linorder_topology)" | 
| 2502 | and ge: "\<forall>n\<ge>N. f n \<ge> C" | |
| 2503 | shows "l \<ge> C" | |
| 51351 | 2504 | using ge | 
| 2505 | by (intro tendsto_le[OF trivial_limit_sequentially lim tendsto_const]) | |
| 2506 | (auto simp: eventually_sequentially) | |
| 2507 | ||
| 43920 | 2508 | lemma real_of_ereal_mult[simp]: | 
| 53873 | 2509 | fixes a b :: ereal | 
| 2510 | shows "real (a * b) = real a * real b" | |
| 43920 | 2511 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 2512 | |
| 43920 | 2513 | lemma real_of_ereal_eq_0: | 
| 53873 | 2514 | fixes x :: ereal | 
| 2515 | shows "real x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity> \<or> x = 0" | |
| 41973 | 2516 | by (cases x) auto | 
| 2517 | ||
| 43920 | 2518 | lemma tendsto_ereal_realD: | 
| 2519 | fixes f :: "'a \<Rightarrow> ereal" | |
| 53873 | 2520 | assumes "x \<noteq> 0" | 
| 2521 | and tendsto: "((\<lambda>x. ereal (real (f x))) ---> x) net" | |
| 41973 | 2522 | shows "(f ---> x) net" | 
| 2523 | proof (intro topological_tendstoI) | |
| 53873 | 2524 | fix S | 
| 2525 | assume S: "open S" "x \<in> S" | |
| 60500 | 2526 |   with \<open>x \<noteq> 0\<close> have "open (S - {0})" "x \<in> S - {0}"
 | 
| 53873 | 2527 | by auto | 
| 41973 | 2528 | from tendsto[THEN topological_tendstoD, OF this] | 
| 2529 | show "eventually (\<lambda>x. f x \<in> S) net" | |
| 44142 | 2530 | by (rule eventually_rev_mp) (auto simp: ereal_real) | 
| 41973 | 2531 | qed | 
| 2532 | ||
| 43920 | 2533 | lemma tendsto_ereal_realI: | 
| 2534 | fixes f :: "'a \<Rightarrow> ereal" | |
| 41976 | 2535 | assumes x: "\<bar>x\<bar> \<noteq> \<infinity>" and tendsto: "(f ---> x) net" | 
| 43920 | 2536 | shows "((\<lambda>x. ereal (real (f x))) ---> x) net" | 
| 41973 | 2537 | proof (intro topological_tendstoI) | 
| 53873 | 2538 | fix S | 
| 2539 | assume "open S" and "x \<in> S" | |
| 2540 |   with x have "open (S - {\<infinity>, -\<infinity>})" "x \<in> S - {\<infinity>, -\<infinity>}"
 | |
| 2541 | by auto | |
| 41973 | 2542 | from tendsto[THEN topological_tendstoD, OF this] | 
| 43920 | 2543 | show "eventually (\<lambda>x. ereal (real (f x)) \<in> S) net" | 
| 2544 | by (elim eventually_elim1) (auto simp: ereal_real) | |
| 41973 | 2545 | qed | 
| 2546 | ||
| 43920 | 2547 | lemma ereal_mult_cancel_left: | 
| 53873 | 2548 | fixes a b c :: ereal | 
| 2549 | shows "a * b = a * c \<longleftrightarrow> (\<bar>a\<bar> = \<infinity> \<and> 0 < b * c) \<or> a = 0 \<or> b = c" | |
| 2550 | by (cases rule: ereal3_cases[of a b c]) (simp_all add: zero_less_mult_iff) | |
| 41973 | 2551 | |
| 56993 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2552 | lemma tendsto_add_ereal: | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2553 | fixes x y :: ereal | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2554 | assumes x: "\<bar>x\<bar> \<noteq> \<infinity>" and y: "\<bar>y\<bar> \<noteq> \<infinity>" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2555 | assumes f: "(f ---> x) F" and g: "(g ---> y) F" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2556 | shows "((\<lambda>x. f x + g x) ---> x + y) F" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2557 | proof - | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2558 | from x obtain r where x': "x = ereal r" by (cases x) auto | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2559 | with f have "((\<lambda>i. real (f i)) ---> r) F" by simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2560 | moreover | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2561 | from y obtain p where y': "y = ereal p" by (cases y) auto | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2562 | with g have "((\<lambda>i. real (g i)) ---> p) F" by simp | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2563 | ultimately have "((\<lambda>i. real (f i) + real (g i)) ---> r + p) F" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2564 | by (rule tendsto_add) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2565 | moreover | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2566 | from eventually_finite[OF x f] eventually_finite[OF y g] | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2567 | have "eventually (\<lambda>x. f x + g x = ereal (real (f x) + real (g x))) F" | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2568 | by eventually_elim auto | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2569 | ultimately show ?thesis | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2570 | by (simp add: x' y' cong: filterlim_cong) | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2571 | qed | 
| 
e5366291d6aa
introduce Bochner integral: generalizes Lebesgue integral from real-valued function to functions on real-normed vector spaces
 hoelzl parents: 
56927diff
changeset | 2572 | |
| 43920 | 2573 | lemma ereal_inj_affinity: | 
| 43923 | 2574 | fixes m t :: ereal | 
| 53873 | 2575 | assumes "\<bar>m\<bar> \<noteq> \<infinity>" | 
| 2576 | and "m \<noteq> 0" | |
| 2577 | and "\<bar>t\<bar> \<noteq> \<infinity>" | |
| 41973 | 2578 | shows "inj_on (\<lambda>x. m * x + t) A" | 
| 2579 | using assms | |
| 43920 | 2580 | by (cases rule: ereal2_cases[of m t]) | 
| 2581 | (auto intro!: inj_onI simp: ereal_add_cancel_right ereal_mult_cancel_left) | |
| 41973 | 2582 | |
| 43920 | 2583 | lemma ereal_PInfty_eq_plus[simp]: | 
| 43923 | 2584 | fixes a b :: ereal | 
| 41973 | 2585 | shows "\<infinity> = a + b \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>" | 
| 43920 | 2586 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 2587 | |
| 43920 | 2588 | lemma ereal_MInfty_eq_plus[simp]: | 
| 43923 | 2589 | fixes a b :: ereal | 
| 41973 | 2590 | shows "-\<infinity> = a + b \<longleftrightarrow> (a = -\<infinity> \<and> b \<noteq> \<infinity>) \<or> (b = -\<infinity> \<and> a \<noteq> \<infinity>)" | 
| 43920 | 2591 | by (cases rule: ereal2_cases[of a b]) auto | 
| 41973 | 2592 | |
| 43920 | 2593 | lemma ereal_less_divide_pos: | 
| 43923 | 2594 | fixes x y :: ereal | 
| 2595 | shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y < z / x \<longleftrightarrow> x * y < z" | |
| 43920 | 2596 | by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) | 
| 41973 | 2597 | |
| 43920 | 2598 | lemma ereal_divide_less_pos: | 
| 43923 | 2599 | fixes x y z :: ereal | 
| 2600 | shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y / x < z \<longleftrightarrow> y < x * z" | |
| 43920 | 2601 | by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) | 
| 41973 | 2602 | |
| 43920 | 2603 | lemma ereal_divide_eq: | 
| 43923 | 2604 | fixes a b c :: ereal | 
| 2605 | shows "b \<noteq> 0 \<Longrightarrow> \<bar>b\<bar> \<noteq> \<infinity> \<Longrightarrow> a / b = c \<longleftrightarrow> a = b * c" | |
| 43920 | 2606 | by (cases rule: ereal3_cases[of a b c]) | 
| 41973 | 2607 | (simp_all add: field_simps) | 
| 2608 | ||
| 43923 | 2609 | lemma ereal_inverse_not_MInfty[simp]: "inverse (a::ereal) \<noteq> -\<infinity>" | 
| 41973 | 2610 | by (cases a) auto | 
| 2611 | ||
| 43920 | 2612 | lemma ereal_mult_m1[simp]: "x * ereal (-1) = -x" | 
| 41973 | 2613 | by (cases x) auto | 
| 2614 | ||
| 53873 | 2615 | lemma ereal_real': | 
| 2616 | assumes "\<bar>x\<bar> \<noteq> \<infinity>" | |
| 2617 | shows "ereal (real x) = x" | |
| 41976 | 2618 | using assms by auto | 
| 41973 | 2619 | |
| 53873 | 2620 | lemma real_ereal_id: "real \<circ> ereal = id" | 
| 2621 | proof - | |
| 2622 |   {
 | |
| 2623 | fix x | |
| 2624 | have "(real o ereal) x = id x" | |
| 2625 | by auto | |
| 2626 | } | |
| 2627 | then show ?thesis | |
| 2628 | using ext by blast | |
| 41973 | 2629 | qed | 
| 2630 | ||
| 43923 | 2631 | lemma open_image_ereal: "open(UNIV-{ \<infinity> , (-\<infinity> :: ereal)})"
 | 
| 53873 | 2632 | by (metis range_ereal open_ereal open_UNIV) | 
| 41973 | 2633 | |
| 43920 | 2634 | lemma ereal_le_distrib: | 
| 53873 | 2635 | fixes a b c :: ereal | 
| 2636 | shows "c * (a + b) \<le> c * a + c * b" | |
| 43920 | 2637 | by (cases rule: ereal3_cases[of a b c]) | 
| 41973 | 2638 | (auto simp add: field_simps not_le mult_le_0_iff mult_less_0_iff) | 
| 2639 | ||
| 43920 | 2640 | lemma ereal_pos_distrib: | 
| 53873 | 2641 | fixes a b c :: ereal | 
| 2642 | assumes "0 \<le> c" | |
| 2643 | and "c \<noteq> \<infinity>" | |
| 2644 | shows "c * (a + b) = c * a + c * b" | |
| 2645 | using assms | |
| 2646 | by (cases rule: ereal3_cases[of a b c]) | |
| 2647 | (auto simp add: field_simps not_le mult_le_0_iff mult_less_0_iff) | |
| 41973 | 2648 | |
| 53873 | 2649 | lemma ereal_max_mono: "(a::ereal) \<le> b \<Longrightarrow> c \<le> d \<Longrightarrow> max a c \<le> max b d" | 
| 43920 | 2650 | by (metis sup_ereal_def sup_mono) | 
| 41973 | 2651 | |
| 53873 | 2652 | lemma ereal_max_least: "(a::ereal) \<le> x \<Longrightarrow> c \<le> x \<Longrightarrow> max a c \<le> x" | 
| 43920 | 2653 | by (metis sup_ereal_def sup_least) | 
| 41973 | 2654 | |
| 51000 | 2655 | lemma ereal_LimI_finite: | 
| 2656 | fixes x :: ereal | |
| 2657 | assumes "\<bar>x\<bar> \<noteq> \<infinity>" | |
| 53873 | 2658 | and "\<And>r. 0 < r \<Longrightarrow> \<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r" | 
| 51000 | 2659 | shows "u ----> x" | 
| 2660 | proof (rule topological_tendstoI, unfold eventually_sequentially) | |
| 53873 | 2661 | obtain rx where rx: "x = ereal rx" | 
| 2662 | using assms by (cases x) auto | |
| 2663 | fix S | |
| 2664 | assume "open S" and "x \<in> S" | |
| 2665 | then have "open (ereal -` S)" | |
| 2666 | unfolding open_ereal_def by auto | |
| 60500 | 2667 | with \<open>x \<in> S\<close> obtain r where "0 < r" and dist: "\<And>y. dist y rx < r \<Longrightarrow> ereal y \<in> S" | 
| 53873 | 2668 | unfolding open_real_def rx by auto | 
| 51000 | 2669 | then obtain n where | 
| 53873 | 2670 | upper: "\<And>N. n \<le> N \<Longrightarrow> u N < x + ereal r" and | 
| 2671 | lower: "\<And>N. n \<le> N \<Longrightarrow> x < u N + ereal r" | |
| 2672 | using assms(2)[of "ereal r"] by auto | |
| 2673 | show "\<exists>N. \<forall>n\<ge>N. u n \<in> S" | |
| 51000 | 2674 | proof (safe intro!: exI[of _ n]) | 
| 53873 | 2675 | fix N | 
| 2676 | assume "n \<le> N" | |
| 60500 | 2677 | from upper[OF this] lower[OF this] assms \<open>0 < r\<close> | 
| 53873 | 2678 |     have "u N \<notin> {\<infinity>,(-\<infinity>)}"
 | 
| 2679 | by auto | |
| 2680 | then obtain ra where ra_def: "(u N) = ereal ra" | |
| 2681 | by (cases "u N") auto | |
| 2682 | then have "rx < ra + r" and "ra < rx + r" | |
| 60500 | 2683 | using rx assms \<open>0 < r\<close> lower[OF \<open>n \<le> N\<close>] upper[OF \<open>n \<le> N\<close>] | 
| 53873 | 2684 | by auto | 
| 2685 | then have "dist (real (u N)) rx < r" | |
| 2686 | using rx ra_def | |
| 51000 | 2687 | by (auto simp: dist_real_def abs_diff_less_iff field_simps) | 
| 53873 | 2688 | from dist[OF this] show "u N \<in> S" | 
| 60500 | 2689 |       using \<open>u N  \<notin> {\<infinity>, -\<infinity>}\<close>
 | 
| 51000 | 2690 | by (auto simp: ereal_real split: split_if_asm) | 
| 2691 | qed | |
| 2692 | qed | |
| 2693 | ||
| 2694 | lemma tendsto_obtains_N: | |
| 2695 | assumes "f ----> f0" | |
| 53873 | 2696 | assumes "open S" | 
| 2697 | and "f0 \<in> S" | |
| 2698 | obtains N where "\<forall>n\<ge>N. f n \<in> S" | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 2699 | using assms using tendsto_def | 
| 51000 | 2700 | using tendsto_explicit[of f f0] assms by auto | 
| 2701 | ||
| 2702 | lemma ereal_LimI_finite_iff: | |
| 2703 | fixes x :: ereal | |
| 2704 | assumes "\<bar>x\<bar> \<noteq> \<infinity>" | |
| 53873 | 2705 | shows "u ----> x \<longleftrightarrow> (\<forall>r. 0 < r \<longrightarrow> (\<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r))" | 
| 2706 | (is "?lhs \<longleftrightarrow> ?rhs") | |
| 51000 | 2707 | proof | 
| 2708 | assume lim: "u ----> x" | |
| 53873 | 2709 |   {
 | 
| 2710 | fix r :: ereal | |
| 2711 | assume "r > 0" | |
| 2712 |     then obtain N where "\<forall>n\<ge>N. u n \<in> {x - r <..< x + r}"
 | |
| 51000 | 2713 |        apply (subst tendsto_obtains_N[of u x "{x - r <..< x + r}"])
 | 
| 60500 | 2714 | using lim ereal_between[of x r] assms \<open>r > 0\<close> | 
| 53873 | 2715 | apply auto | 
| 2716 | done | |
| 2717 | then have "\<exists>N. \<forall>n\<ge>N. u n < x + r \<and> x < u n + r" | |
| 2718 | using ereal_minus_less[of r x] | |
| 2719 | by (cases r) auto | |
| 2720 | } | |
| 2721 | then show ?rhs | |
| 2722 | by auto | |
| 51000 | 2723 | next | 
| 53873 | 2724 | assume ?rhs | 
| 2725 | then show "u ----> x" | |
| 51000 | 2726 | using ereal_LimI_finite[of x] assms by auto | 
| 2727 | qed | |
| 2728 | ||
| 51340 
5e6296afe08d
move Liminf / Limsup lemmas on complete_lattices to its own file
 hoelzl parents: 
51329diff
changeset | 2729 | lemma ereal_Limsup_uminus: | 
| 53873 | 2730 | fixes f :: "'a \<Rightarrow> ereal" | 
| 2731 | shows "Limsup net (\<lambda>x. - (f x)) = - Liminf net f" | |
| 59452 
2538b2c51769
ereal: tuned proofs concerning continuity and suprema
 hoelzl parents: 
59425diff
changeset | 2732 | unfolding Limsup_def Liminf_def ereal_SUP_uminus ereal_INF_uminus_eq .. | 
| 51000 | 2733 | |
| 51340 
5e6296afe08d
move Liminf / Limsup lemmas on complete_lattices to its own file
 hoelzl parents: 
51329diff
changeset | 2734 | lemma liminf_bounded_iff: | 
| 
5e6296afe08d
move Liminf / Limsup lemmas on complete_lattices to its own file
 hoelzl parents: 
51329diff
changeset | 2735 | fixes x :: "nat \<Rightarrow> ereal" | 
| 53873 | 2736 | shows "C \<le> liminf x \<longleftrightarrow> (\<forall>B<C. \<exists>N. \<forall>n\<ge>N. B < x n)" | 
| 2737 | (is "?lhs \<longleftrightarrow> ?rhs") | |
| 51340 
5e6296afe08d
move Liminf / Limsup lemmas on complete_lattices to its own file
 hoelzl parents: 
51329diff
changeset | 2738 | unfolding le_Liminf_iff eventually_sequentially .. | 
| 51000 | 2739 | |
| 59679 | 2740 | lemma Liminf_add_le: | 
| 2741 | fixes f g :: "_ \<Rightarrow> ereal" | |
| 2742 | assumes F: "F \<noteq> bot" | |
| 2743 | assumes ev: "eventually (\<lambda>x. 0 \<le> f x) F" "eventually (\<lambda>x. 0 \<le> g x) F" | |
| 2744 | shows "Liminf F f + Liminf F g \<le> Liminf F (\<lambda>x. f x + g x)" | |
| 2745 | unfolding Liminf_def | |
| 2746 | proof (subst SUP_ereal_add_left[symmetric]) | |
| 2747 |   let ?F = "{P. eventually P F}"
 | |
| 2748 | let ?INF = "\<lambda>P g. INFIMUM (Collect P) g" | |
| 2749 |   show "?F \<noteq> {}"
 | |
| 2750 | by (auto intro: eventually_True) | |
| 2751 | show "(SUP P:?F. ?INF P g) \<noteq> - \<infinity>" | |
| 2752 | unfolding bot_ereal_def[symmetric] SUP_bot_conv INF_eq_bot_iff | |
| 2753 | by (auto intro!: exI[of _ 0] ev simp: bot_ereal_def) | |
| 2754 | have "(SUP P:?F. ?INF P f + (SUP P:?F. ?INF P g)) \<le> (SUP P:?F. (SUP P':?F. ?INF P f + ?INF P' g))" | |
| 2755 | proof (safe intro!: SUP_mono bexI[of _ "\<lambda>x. P x \<and> 0 \<le> f x" for P]) | |
| 2756 | fix P let ?P' = "\<lambda>x. P x \<and> 0 \<le> f x" | |
| 2757 | assume "eventually P F" | |
| 2758 | with ev show "eventually ?P' F" | |
| 2759 | by eventually_elim auto | |
| 2760 | have "?INF P f + (SUP P:?F. ?INF P g) \<le> ?INF ?P' f + (SUP P:?F. ?INF P g)" | |
| 2761 | by (intro ereal_add_mono INF_mono) auto | |
| 2762 | also have "\<dots> = (SUP P':?F. ?INF ?P' f + ?INF P' g)" | |
| 2763 | proof (rule SUP_ereal_add_right[symmetric]) | |
| 2764 |       show "INFIMUM {x. P x \<and> 0 \<le> f x} f \<noteq> - \<infinity>"
 | |
| 2765 | unfolding bot_ereal_def[symmetric] INF_eq_bot_iff | |
| 2766 | by (auto intro!: exI[of _ 0] ev simp: bot_ereal_def) | |
| 2767 | qed fact | |
| 2768 | finally show "?INF P f + (SUP P:?F. ?INF P g) \<le> (SUP P':?F. ?INF ?P' f + ?INF P' g)" . | |
| 2769 | qed | |
| 2770 | also have "\<dots> \<le> (SUP P:?F. INF x:Collect P. f x + g x)" | |
| 2771 | proof (safe intro!: SUP_least) | |
| 2772 | fix P Q assume *: "eventually P F" "eventually Q F" | |
| 2773 | show "?INF P f + ?INF Q g \<le> (SUP P:?F. INF x:Collect P. f x + g x)" | |
| 2774 | proof (rule SUP_upper2) | |
| 2775 | show "(\<lambda>x. P x \<and> Q x) \<in> ?F" | |
| 2776 | using * by (auto simp: eventually_conj) | |
| 2777 |       show "?INF P f + ?INF Q g \<le> (INF x:{x. P x \<and> Q x}. f x + g x)"
 | |
| 2778 | by (intro INF_greatest ereal_add_mono) (auto intro: INF_lower) | |
| 2779 | qed | |
| 2780 | qed | |
| 2781 | finally show "(SUP P:?F. ?INF P f + (SUP P:?F. ?INF P g)) \<le> (SUP P:?F. INF x:Collect P. f x + g x)" . | |
| 2782 | qed | |
| 2783 | ||
| 60060 | 2784 | lemma Sup_ereal_mult_right': | 
| 2785 |   assumes nonempty: "Y \<noteq> {}"
 | |
| 2786 | and x: "x \<ge> 0" | |
| 2787 | shows "(SUP i:Y. f i) * ereal x = (SUP i:Y. f i * ereal x)" (is "?lhs = ?rhs") | |
| 2788 | proof(cases "x = 0") | |
| 2789 | case True thus ?thesis by(auto simp add: nonempty zero_ereal_def[symmetric]) | |
| 2790 | next | |
| 2791 | case False | |
| 2792 | show ?thesis | |
| 2793 | proof(rule antisym) | |
| 2794 | show "?rhs \<le> ?lhs" | |
| 2795 | by(rule SUP_least)(simp add: ereal_mult_right_mono SUP_upper x) | |
| 2796 | next | |
| 2797 | have "?lhs / ereal x = (SUP i:Y. f i) * (ereal x / ereal x)" by(simp only: ereal_times_divide_eq) | |
| 2798 | also have "\<dots> = (SUP i:Y. f i)" using False by simp | |
| 2799 | also have "\<dots> \<le> ?rhs / x" | |
| 2800 | proof(rule SUP_least) | |
| 2801 | fix i | |
| 2802 | assume "i \<in> Y" | |
| 2803 | have "f i = f i * (ereal x / ereal x)" using False by simp | |
| 2804 | also have "\<dots> = f i * x / x" by(simp only: ereal_times_divide_eq) | |
| 2805 | also from \<open>i \<in> Y\<close> have "f i * x \<le> ?rhs" by(rule SUP_upper) | |
| 2806 | hence "f i * x / x \<le> ?rhs / x" using x False by simp | |
| 2807 | finally show "f i \<le> ?rhs / x" . | |
| 2808 | qed | |
| 2809 | finally have "(?lhs / x) * x \<le> (?rhs / x) * x" | |
| 2810 | by(rule ereal_mult_right_mono)(simp add: x) | |
| 2811 | also have "\<dots> = ?rhs" using False ereal_divide_eq mult.commute by force | |
| 2812 | also have "(?lhs / x) * x = ?lhs" using False ereal_divide_eq mult.commute by force | |
| 2813 | finally show "?lhs \<le> ?rhs" . | |
| 2814 | qed | |
| 2815 | qed | |
| 53873 | 2816 | |
| 60637 | 2817 | lemma sup_continuous_add[order_continuous_intros]: | 
| 2818 | fixes f g :: "'a::complete_lattice \<Rightarrow> ereal" | |
| 2819 | assumes nn: "\<And>x. 0 \<le> f x" "\<And>x. 0 \<le> g x" and cont: "sup_continuous f" "sup_continuous g" | |
| 2820 | shows "sup_continuous (\<lambda>x. f x + g x)" | |
| 2821 | unfolding sup_continuous_def | |
| 2822 | proof safe | |
| 2823 | fix M :: "nat \<Rightarrow> 'a" assume "incseq M" | |
| 2824 | then show "f (SUP i. M i) + g (SUP i. M i) = (SUP i. f (M i) + g (M i))" | |
| 2825 | using SUP_ereal_add_pos[of "\<lambda>i. f (M i)" "\<lambda>i. g (M i)"] nn | |
| 2826 | cont[THEN sup_continuous_mono] cont[THEN sup_continuousD] | |
| 2827 | by (auto simp: mono_def) | |
| 2828 | qed | |
| 2829 | ||
| 2830 | lemma sup_continuous_mult_right[order_continuous_intros]: | |
| 2831 | "0 \<le> c \<Longrightarrow> c < \<infinity> \<Longrightarrow> sup_continuous f \<Longrightarrow> sup_continuous (\<lambda>x. f x * c :: ereal)" | |
| 60636 
ee18efe9b246
add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
 hoelzl parents: 
60580diff
changeset | 2832 | by (cases c) (auto simp: sup_continuous_def fun_eq_iff Sup_ereal_mult_right') | 
| 
ee18efe9b246
add named theorems order_continuous_intros; lfp/gfp_funpow; bounded variant for lfp/gfp transfer
 hoelzl parents: 
60580diff
changeset | 2833 | |
| 60637 | 2834 | lemma sup_continuous_mult_left[order_continuous_intros]: | 
| 2835 | "0 \<le> c \<Longrightarrow> c < \<infinity> \<Longrightarrow> sup_continuous f \<Longrightarrow> sup_continuous (\<lambda>x. c * f x :: ereal)" | |
| 2836 | using sup_continuous_mult_right[of c f] by (simp add: mult_ac) | |
| 2837 | ||
| 2838 | lemma sup_continuous_ereal_of_enat[order_continuous_intros]: | |
| 2839 | assumes f: "sup_continuous f" shows "sup_continuous (\<lambda>x. ereal_of_enat (f x))" | |
| 2840 | by (rule sup_continuous_compose[OF _ f]) | |
| 2841 | (auto simp: sup_continuous_def ereal_of_enat_SUP) | |
| 2842 | ||
| 60771 | 2843 | subsubsection \<open>Sums\<close> | 
| 2844 | ||
| 2845 | lemma sums_ereal_positive: | |
| 2846 | fixes f :: "nat \<Rightarrow> ereal" | |
| 2847 | assumes "\<And>i. 0 \<le> f i" | |
| 2848 | shows "f sums (SUP n. \<Sum>i<n. f i)" | |
| 2849 | proof - | |
| 2850 | have "incseq (\<lambda>i. \<Sum>j=0..<i. f j)" | |
| 2851 | using ereal_add_mono[OF _ assms] | |
| 2852 | by (auto intro!: incseq_SucI) | |
| 2853 | from LIMSEQ_SUP[OF this] | |
| 2854 | show ?thesis unfolding sums_def | |
| 2855 | by (simp add: atLeast0LessThan) | |
| 2856 | qed | |
| 2857 | ||
| 2858 | lemma summable_ereal_pos: | |
| 2859 | fixes f :: "nat \<Rightarrow> ereal" | |
| 2860 | assumes "\<And>i. 0 \<le> f i" | |
| 2861 | shows "summable f" | |
| 2862 | using sums_ereal_positive[of f, OF assms] | |
| 2863 | unfolding summable_def | |
| 2864 | by auto | |
| 2865 | ||
| 2866 | lemma sums_ereal: "(\<lambda>x. ereal (f x)) sums ereal x \<longleftrightarrow> f sums x" | |
| 2867 | unfolding sums_def by simp | |
| 2868 | ||
| 2869 | lemma suminf_ereal_eq_SUP: | |
| 2870 | fixes f :: "nat \<Rightarrow> ereal" | |
| 2871 | assumes "\<And>i. 0 \<le> f i" | |
| 2872 | shows "(\<Sum>x. f x) = (SUP n. \<Sum>i<n. f i)" | |
| 2873 | using sums_ereal_positive[of f, OF assms, THEN sums_unique] | |
| 2874 | by simp | |
| 2875 | ||
| 2876 | lemma suminf_bound: | |
| 2877 | fixes f :: "nat \<Rightarrow> ereal" | |
| 2878 | assumes "\<forall>N. (\<Sum>n<N. f n) \<le> x" | |
| 2879 | and pos: "\<And>n. 0 \<le> f n" | |
| 2880 | shows "suminf f \<le> x" | |
| 2881 | proof (rule Lim_bounded_ereal) | |
| 2882 | have "summable f" using pos[THEN summable_ereal_pos] . | |
| 2883 | then show "(\<lambda>N. \<Sum>n<N. f n) ----> suminf f" | |
| 2884 | by (auto dest!: summable_sums simp: sums_def atLeast0LessThan) | |
| 2885 |   show "\<forall>n\<ge>0. setsum f {..<n} \<le> x"
 | |
| 2886 | using assms by auto | |
| 2887 | qed | |
| 2888 | ||
| 2889 | lemma suminf_bound_add: | |
| 2890 | fixes f :: "nat \<Rightarrow> ereal" | |
| 2891 | assumes "\<forall>N. (\<Sum>n<N. f n) + y \<le> x" | |
| 2892 | and pos: "\<And>n. 0 \<le> f n" | |
| 2893 | and "y \<noteq> -\<infinity>" | |
| 2894 | shows "suminf f + y \<le> x" | |
| 2895 | proof (cases y) | |
| 2896 | case (real r) | |
| 2897 | then have "\<forall>N. (\<Sum>n<N. f n) \<le> x - y" | |
| 2898 | using assms by (simp add: ereal_le_minus) | |
| 2899 | then have "(\<Sum> n. f n) \<le> x - y" | |
| 2900 | using pos by (rule suminf_bound) | |
| 2901 | then show "(\<Sum> n. f n) + y \<le> x" | |
| 2902 | using assms real by (simp add: ereal_le_minus) | |
| 2903 | qed (insert assms, auto) | |
| 2904 | ||
| 2905 | lemma suminf_upper: | |
| 2906 | fixes f :: "nat \<Rightarrow> ereal" | |
| 2907 | assumes "\<And>n. 0 \<le> f n" | |
| 2908 | shows "(\<Sum>n<N. f n) \<le> (\<Sum>n. f n)" | |
| 2909 | unfolding suminf_ereal_eq_SUP [OF assms] | |
| 2910 | by (auto intro: complete_lattice_class.SUP_upper) | |
| 2911 | ||
| 2912 | lemma suminf_0_le: | |
| 2913 | fixes f :: "nat \<Rightarrow> ereal" | |
| 2914 | assumes "\<And>n. 0 \<le> f n" | |
| 2915 | shows "0 \<le> (\<Sum>n. f n)" | |
| 2916 | using suminf_upper[of f 0, OF assms] | |
| 2917 | by simp | |
| 2918 | ||
| 2919 | lemma suminf_le_pos: | |
| 2920 | fixes f g :: "nat \<Rightarrow> ereal" | |
| 2921 | assumes "\<And>N. f N \<le> g N" | |
| 2922 | and "\<And>N. 0 \<le> f N" | |
| 2923 | shows "suminf f \<le> suminf g" | |
| 2924 | proof (safe intro!: suminf_bound) | |
| 2925 | fix n | |
| 2926 |   {
 | |
| 2927 | fix N | |
| 2928 | have "0 \<le> g N" | |
| 2929 | using assms(2,1)[of N] by auto | |
| 2930 | } | |
| 2931 |   have "setsum f {..<n} \<le> setsum g {..<n}"
 | |
| 2932 | using assms by (auto intro: setsum_mono) | |
| 2933 | also have "\<dots> \<le> suminf g" | |
| 2934 | using \<open>\<And>N. 0 \<le> g N\<close> | |
| 2935 | by (rule suminf_upper) | |
| 2936 |   finally show "setsum f {..<n} \<le> suminf g" .
 | |
| 2937 | qed (rule assms(2)) | |
| 2938 | ||
| 2939 | lemma suminf_half_series_ereal: "(\<Sum>n. (1/2 :: ereal) ^ Suc n) = 1" | |
| 2940 | using sums_ereal[THEN iffD2, OF power_half_series, THEN sums_unique, symmetric] | |
| 2941 | by (simp add: one_ereal_def) | |
| 2942 | ||
| 2943 | lemma suminf_add_ereal: | |
| 2944 | fixes f g :: "nat \<Rightarrow> ereal" | |
| 2945 | assumes "\<And>i. 0 \<le> f i" | |
| 2946 | and "\<And>i. 0 \<le> g i" | |
| 2947 | shows "(\<Sum>i. f i + g i) = suminf f + suminf g" | |
| 2948 | apply (subst (1 2 3) suminf_ereal_eq_SUP) | |
| 2949 | unfolding setsum.distrib | |
| 2950 | apply (intro assms ereal_add_nonneg_nonneg SUP_ereal_add_pos incseq_setsumI setsum_nonneg ballI)+ | |
| 2951 | done | |
| 2952 | ||
| 2953 | lemma suminf_cmult_ereal: | |
| 2954 | fixes f g :: "nat \<Rightarrow> ereal" | |
| 2955 | assumes "\<And>i. 0 \<le> f i" | |
| 2956 | and "0 \<le> a" | |
| 2957 | shows "(\<Sum>i. a * f i) = a * suminf f" | |
| 2958 | by (auto simp: setsum_ereal_right_distrib[symmetric] assms | |
| 2959 | ereal_zero_le_0_iff setsum_nonneg suminf_ereal_eq_SUP | |
| 2960 | intro!: SUP_ereal_mult_left) | |
| 2961 | ||
| 2962 | lemma suminf_PInfty: | |
| 2963 | fixes f :: "nat \<Rightarrow> ereal" | |
| 2964 | assumes "\<And>i. 0 \<le> f i" | |
| 2965 | and "suminf f \<noteq> \<infinity>" | |
| 2966 | shows "f i \<noteq> \<infinity>" | |
| 2967 | proof - | |
| 2968 | from suminf_upper[of f "Suc i", OF assms(1)] assms(2) | |
| 2969 | have "(\<Sum>i<Suc i. f i) \<noteq> \<infinity>" | |
| 2970 | by auto | |
| 2971 | then show ?thesis | |
| 2972 | unfolding setsum_Pinfty by simp | |
| 2973 | qed | |
| 2974 | ||
| 2975 | lemma suminf_PInfty_fun: | |
| 2976 | assumes "\<And>i. 0 \<le> f i" | |
| 2977 | and "suminf f \<noteq> \<infinity>" | |
| 2978 | shows "\<exists>f'. f = (\<lambda>x. ereal (f' x))" | |
| 2979 | proof - | |
| 2980 | have "\<forall>i. \<exists>r. f i = ereal r" | |
| 2981 | proof | |
| 2982 | fix i | |
| 2983 | show "\<exists>r. f i = ereal r" | |
| 2984 | using suminf_PInfty[OF assms] assms(1)[of i] | |
| 2985 | by (cases "f i") auto | |
| 2986 | qed | |
| 2987 | from choice[OF this] show ?thesis | |
| 2988 | by auto | |
| 2989 | qed | |
| 2990 | ||
| 2991 | lemma summable_ereal: | |
| 2992 | assumes "\<And>i. 0 \<le> f i" | |
| 2993 | and "(\<Sum>i. ereal (f i)) \<noteq> \<infinity>" | |
| 2994 | shows "summable f" | |
| 2995 | proof - | |
| 2996 | have "0 \<le> (\<Sum>i. ereal (f i))" | |
| 2997 | using assms by (intro suminf_0_le) auto | |
| 2998 | with assms obtain r where r: "(\<Sum>i. ereal (f i)) = ereal r" | |
| 2999 | by (cases "\<Sum>i. ereal (f i)") auto | |
| 3000 | from summable_ereal_pos[of "\<lambda>x. ereal (f x)"] | |
| 3001 | have "summable (\<lambda>x. ereal (f x))" | |
| 3002 | using assms by auto | |
| 3003 | from summable_sums[OF this] | |
| 3004 | have "(\<lambda>x. ereal (f x)) sums (\<Sum>x. ereal (f x))" | |
| 3005 | by auto | |
| 3006 | then show "summable f" | |
| 3007 | unfolding r sums_ereal summable_def .. | |
| 3008 | qed | |
| 3009 | ||
| 3010 | lemma suminf_ereal: | |
| 3011 | assumes "\<And>i. 0 \<le> f i" | |
| 3012 | and "(\<Sum>i. ereal (f i)) \<noteq> \<infinity>" | |
| 3013 | shows "(\<Sum>i. ereal (f i)) = ereal (suminf f)" | |
| 3014 | proof (rule sums_unique[symmetric]) | |
| 3015 | from summable_ereal[OF assms] | |
| 3016 | show "(\<lambda>x. ereal (f x)) sums (ereal (suminf f))" | |
| 3017 | unfolding sums_ereal | |
| 3018 | using assms | |
| 3019 | by (intro summable_sums summable_ereal) | |
| 3020 | qed | |
| 3021 | ||
| 3022 | lemma suminf_ereal_minus: | |
| 3023 | fixes f g :: "nat \<Rightarrow> ereal" | |
| 3024 | assumes ord: "\<And>i. g i \<le> f i" "\<And>i. 0 \<le> g i" | |
| 3025 | and fin: "suminf f \<noteq> \<infinity>" "suminf g \<noteq> \<infinity>" | |
| 3026 | shows "(\<Sum>i. f i - g i) = suminf f - suminf g" | |
| 3027 | proof - | |
| 3028 |   {
 | |
| 3029 | fix i | |
| 3030 | have "0 \<le> f i" | |
| 3031 | using ord[of i] by auto | |
| 3032 | } | |
| 3033 | moreover | |
| 3034 | from suminf_PInfty_fun[OF \<open>\<And>i. 0 \<le> f i\<close> fin(1)] obtain f' where [simp]: "f = (\<lambda>x. ereal (f' x))" .. | |
| 3035 | from suminf_PInfty_fun[OF \<open>\<And>i. 0 \<le> g i\<close> fin(2)] obtain g' where [simp]: "g = (\<lambda>x. ereal (g' x))" .. | |
| 3036 |   {
 | |
| 3037 | fix i | |
| 3038 | have "0 \<le> f i - g i" | |
| 3039 | using ord[of i] by (auto simp: ereal_le_minus_iff) | |
| 3040 | } | |
| 3041 | moreover | |
| 3042 | have "suminf (\<lambda>i. f i - g i) \<le> suminf f" | |
| 3043 | using assms by (auto intro!: suminf_le_pos simp: field_simps) | |
| 3044 | then have "suminf (\<lambda>i. f i - g i) \<noteq> \<infinity>" | |
| 3045 | using fin by auto | |
| 3046 | ultimately show ?thesis | |
| 3047 | using assms \<open>\<And>i. 0 \<le> f i\<close> | |
| 3048 | apply simp | |
| 3049 | apply (subst (1 2 3) suminf_ereal) | |
| 3050 | apply (auto intro!: suminf_diff[symmetric] summable_ereal) | |
| 3051 | done | |
| 3052 | qed | |
| 3053 | ||
| 3054 | lemma suminf_ereal_PInf [simp]: "(\<Sum>x. \<infinity>::ereal) = \<infinity>" | |
| 3055 | proof - | |
| 3056 | have "(\<Sum>i<Suc 0. \<infinity>) \<le> (\<Sum>x. \<infinity>::ereal)" | |
| 3057 | by (rule suminf_upper) auto | |
| 3058 | then show ?thesis | |
| 3059 | by simp | |
| 3060 | qed | |
| 3061 | ||
| 3062 | lemma summable_real_of_ereal: | |
| 3063 | fixes f :: "nat \<Rightarrow> ereal" | |
| 3064 | assumes f: "\<And>i. 0 \<le> f i" | |
| 3065 | and fin: "(\<Sum>i. f i) \<noteq> \<infinity>" | |
| 3066 | shows "summable (\<lambda>i. real (f i))" | |
| 3067 | proof (rule summable_def[THEN iffD2]) | |
| 3068 | have "0 \<le> (\<Sum>i. f i)" | |
| 3069 | using assms by (auto intro: suminf_0_le) | |
| 3070 | with fin obtain r where r: "ereal r = (\<Sum>i. f i)" | |
| 3071 | by (cases "(\<Sum>i. f i)") auto | |
| 3072 |   {
 | |
| 3073 | fix i | |
| 3074 | have "f i \<noteq> \<infinity>" | |
| 3075 | using f by (intro suminf_PInfty[OF _ fin]) auto | |
| 3076 | then have "\<bar>f i\<bar> \<noteq> \<infinity>" | |
| 3077 | using f[of i] by auto | |
| 3078 | } | |
| 3079 | note fin = this | |
| 3080 | have "(\<lambda>i. ereal (real (f i))) sums (\<Sum>i. ereal (real (f i)))" | |
| 3081 | using f | |
| 3082 | by (auto intro!: summable_ereal_pos simp: ereal_le_real_iff zero_ereal_def) | |
| 3083 | also have "\<dots> = ereal r" | |
| 3084 | using fin r by (auto simp: ereal_real) | |
| 3085 | finally show "\<exists>r. (\<lambda>i. real (f i)) sums r" | |
| 3086 | by (auto simp: sums_ereal) | |
| 3087 | qed | |
| 3088 | ||
| 3089 | lemma suminf_SUP_eq: | |
| 3090 | fixes f :: "nat \<Rightarrow> nat \<Rightarrow> ereal" | |
| 3091 | assumes "\<And>i. incseq (\<lambda>n. f n i)" | |
| 3092 | and "\<And>n i. 0 \<le> f n i" | |
| 3093 | shows "(\<Sum>i. SUP n. f n i) = (SUP n. \<Sum>i. f n i)" | |
| 3094 | proof - | |
| 3095 |   {
 | |
| 3096 | fix n :: nat | |
| 3097 | have "(\<Sum>i<n. SUP k. f k i) = (SUP k. \<Sum>i<n. f k i)" | |
| 3098 | using assms | |
| 3099 | by (auto intro!: SUP_ereal_setsum [symmetric]) | |
| 3100 | } | |
| 3101 | note * = this | |
| 3102 | show ?thesis | |
| 3103 | using assms | |
| 3104 | apply (subst (1 2) suminf_ereal_eq_SUP) | |
| 3105 | unfolding * | |
| 3106 | apply (auto intro!: SUP_upper2) | |
| 3107 | apply (subst SUP_commute) | |
| 3108 | apply rule | |
| 3109 | done | |
| 3110 | qed | |
| 3111 | ||
| 3112 | lemma suminf_setsum_ereal: | |
| 3113 | fixes f :: "_ \<Rightarrow> _ \<Rightarrow> ereal" | |
| 3114 | assumes nonneg: "\<And>i a. a \<in> A \<Longrightarrow> 0 \<le> f i a" | |
| 3115 | shows "(\<Sum>i. \<Sum>a\<in>A. f i a) = (\<Sum>a\<in>A. \<Sum>i. f i a)" | |
| 3116 | proof (cases "finite A") | |
| 3117 | case True | |
| 3118 | then show ?thesis | |
| 3119 | using nonneg | |
| 3120 | by induct (simp_all add: suminf_add_ereal setsum_nonneg) | |
| 3121 | next | |
| 3122 | case False | |
| 3123 | then show ?thesis by simp | |
| 3124 | qed | |
| 3125 | ||
| 3126 | lemma suminf_ereal_eq_0: | |
| 3127 | fixes f :: "nat \<Rightarrow> ereal" | |
| 3128 | assumes nneg: "\<And>i. 0 \<le> f i" | |
| 3129 | shows "(\<Sum>i. f i) = 0 \<longleftrightarrow> (\<forall>i. f i = 0)" | |
| 3130 | proof | |
| 3131 | assume "(\<Sum>i. f i) = 0" | |
| 3132 |   {
 | |
| 3133 | fix i | |
| 3134 | assume "f i \<noteq> 0" | |
| 3135 | with nneg have "0 < f i" | |
| 3136 | by (auto simp: less_le) | |
| 3137 | also have "f i = (\<Sum>j. if j = i then f i else 0)" | |
| 3138 |       by (subst suminf_finite[where N="{i}"]) auto
 | |
| 3139 | also have "\<dots> \<le> (\<Sum>i. f i)" | |
| 3140 | using nneg | |
| 3141 | by (auto intro!: suminf_le_pos) | |
| 3142 | finally have False | |
| 3143 | using \<open>(\<Sum>i. f i) = 0\<close> by auto | |
| 3144 | } | |
| 3145 | then show "\<forall>i. f i = 0" | |
| 3146 | by auto | |
| 3147 | qed simp | |
| 3148 | ||
| 3149 | lemma suminf_ereal_offset_le: | |
| 3150 | fixes f :: "nat \<Rightarrow> ereal" | |
| 3151 | assumes f: "\<And>i. 0 \<le> f i" | |
| 3152 | shows "(\<Sum>i. f (i + k)) \<le> suminf f" | |
| 3153 | proof - | |
| 3154 | have "(\<lambda>n. \<Sum>i<n. f (i + k)) ----> (\<Sum>i. f (i + k))" | |
| 3155 | using summable_sums[OF summable_ereal_pos] by (simp add: sums_def atLeast0LessThan f) | |
| 3156 | moreover have "(\<lambda>n. \<Sum>i<n. f i) ----> (\<Sum>i. f i)" | |
| 3157 | using summable_sums[OF summable_ereal_pos] by (simp add: sums_def atLeast0LessThan f) | |
| 3158 | then have "(\<lambda>n. \<Sum>i<n + k. f i) ----> (\<Sum>i. f i)" | |
| 3159 | by (rule LIMSEQ_ignore_initial_segment) | |
| 3160 | ultimately show ?thesis | |
| 3161 | proof (rule LIMSEQ_le, safe intro!: exI[of _ k]) | |
| 3162 | fix n assume "k \<le> n" | |
| 3163 | have "(\<Sum>i<n. f (i + k)) = (\<Sum>i<n. (f \<circ> (\<lambda>i. i + k)) i)" | |
| 3164 | by simp | |
| 3165 |     also have "\<dots> = (\<Sum>i\<in>(\<lambda>i. i + k) ` {..<n}. f i)"
 | |
| 3166 | by (subst setsum.reindex) auto | |
| 3167 |     also have "\<dots> \<le> setsum f {..<n + k}"
 | |
| 3168 | by (intro setsum_mono3) (auto simp: f) | |
| 3169 |     finally show "(\<Sum>i<n. f (i + k)) \<le> setsum f {..<n + k}" .
 | |
| 3170 | qed | |
| 3171 | qed | |
| 3172 | ||
| 3173 | lemma sums_suminf_ereal: "f sums x \<Longrightarrow> (\<Sum>i. ereal (f i)) = ereal x" | |
| 3174 | by (metis sums_ereal sums_unique) | |
| 3175 | ||
| 3176 | lemma suminf_ereal': "summable f \<Longrightarrow> (\<Sum>i. ereal (f i)) = ereal (\<Sum>i. f i)" | |
| 3177 | by (metis sums_ereal sums_unique summable_def) | |
| 3178 | ||
| 3179 | lemma suminf_ereal_finite: "summable f \<Longrightarrow> (\<Sum>i. ereal (f i)) \<noteq> \<infinity>" | |
| 3180 | by (auto simp: sums_ereal[symmetric] summable_def sums_unique[symmetric]) | |
| 3181 | ||
| 3182 | lemma suminf_ereal_finite_neg: | |
| 3183 | assumes "summable f" | |
| 3184 | shows "(\<Sum>x. ereal (f x)) \<noteq> -\<infinity>" | |
| 3185 | proof- | |
| 3186 | from assms obtain x where "f sums x" by blast | |
| 3187 | hence "(\<lambda>x. ereal (f x)) sums ereal x" by (simp add: sums_ereal) | |
| 3188 | from sums_unique[OF this] have "(\<Sum>x. ereal (f x)) = ereal x" .. | |
| 3189 | thus "(\<Sum>x. ereal (f x)) \<noteq> -\<infinity>" by simp_all | |
| 3190 | qed | |
| 3191 | ||
| 3192 | ||
| 60772 | 3193 | lemma SUP_ereal_add_directed: | 
| 3194 | fixes f g :: "'a \<Rightarrow> ereal" | |
| 3195 | assumes nonneg: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> g i" | |
| 3196 | assumes directed: "\<And>i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> \<exists>k\<in>I. f i + g j \<le> f k + g k" | |
| 3197 | shows "(SUP i:I. f i + g i) = (SUP i:I. f i) + (SUP i:I. g i)" | |
| 3198 | proof cases | |
| 3199 |   assume "I = {}" then show ?thesis
 | |
| 3200 | by (simp add: bot_ereal_def) | |
| 3201 | next | |
| 3202 |   assume "I \<noteq> {}"
 | |
| 3203 | show ?thesis | |
| 3204 | proof (rule antisym) | |
| 3205 | show "(SUP i:I. f i + g i) \<le> (SUP i:I. f i) + (SUP i:I. g i)" | |
| 3206 | by (rule SUP_least; intro ereal_add_mono SUP_upper) | |
| 3207 | next | |
| 3208 | have "bot < (SUP i:I. g i)" | |
| 3209 |       using \<open>I \<noteq> {}\<close> nonneg(2) by (auto simp: bot_ereal_def less_SUP_iff)
 | |
| 3210 | then have "(SUP i:I. f i) + (SUP i:I. g i) = (SUP i:I. f i + (SUP i:I. g i))" | |
| 3211 |       by (intro SUP_ereal_add_left[symmetric] \<open>I \<noteq> {}\<close>) auto
 | |
| 3212 | also have "\<dots> = (SUP i:I. (SUP j:I. f i + g j))" | |
| 3213 |       using nonneg(1) by (intro SUP_cong refl SUP_ereal_add_right[symmetric] \<open>I \<noteq> {}\<close>) auto
 | |
| 3214 | also have "\<dots> \<le> (SUP i:I. f i + g i)" | |
| 3215 | using directed by (intro SUP_least) (blast intro: SUP_upper2) | |
| 3216 | finally show "(SUP i:I. f i) + (SUP i:I. g i) \<le> (SUP i:I. f i + g i)" . | |
| 3217 | qed | |
| 3218 | qed | |
| 3219 | ||
| 3220 | lemma SUP_ereal_setsum_directed: | |
| 3221 | fixes f g :: "'a \<Rightarrow> 'b \<Rightarrow> ereal" | |
| 3222 |   assumes "I \<noteq> {}"
 | |
| 3223 | assumes directed: "\<And>N i j. N \<subseteq> A \<Longrightarrow> i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> \<exists>k\<in>I. \<forall>n\<in>N. f n i \<le> f n k \<and> f n j \<le> f n k" | |
| 3224 | assumes nonneg: "\<And>n i. i \<in> I \<Longrightarrow> n \<in> A \<Longrightarrow> 0 \<le> f n i" | |
| 3225 | shows "(SUP i:I. \<Sum>n\<in>A. f n i) = (\<Sum>n\<in>A. SUP i:I. f n i)" | |
| 3226 | proof - | |
| 3227 | have "N \<subseteq> A \<Longrightarrow> (SUP i:I. \<Sum>n\<in>N. f n i) = (\<Sum>n\<in>N. SUP i:I. f n i)" for N | |
| 3228 | proof (induction N rule: infinite_finite_induct) | |
| 3229 | case (insert n N) | |
| 3230 | moreover have "(SUP i:I. f n i + (\<Sum>l\<in>N. f l i)) = (SUP i:I. f n i) + (SUP i:I. \<Sum>l\<in>N. f l i)" | |
| 3231 | proof (rule SUP_ereal_add_directed) | |
| 3232 | fix i assume "i \<in> I" then show "0 \<le> f n i" "0 \<le> (\<Sum>l\<in>N. f l i)" | |
| 3233 | using insert by (auto intro!: setsum_nonneg nonneg) | |
| 3234 | next | |
| 3235 | fix i j assume "i \<in> I" "j \<in> I" | |
| 3236 | from directed[OF \<open>insert n N \<subseteq> A\<close> this] guess k .. | |
| 3237 | then show "\<exists>k\<in>I. f n i + (\<Sum>l\<in>N. f l j) \<le> f n k + (\<Sum>l\<in>N. f l k)" | |
| 3238 | by (intro bexI[of _ k]) (auto intro!: ereal_add_mono setsum_mono) | |
| 3239 | qed | |
| 3240 | ultimately show ?case | |
| 3241 | by simp | |
| 3242 |   qed (simp_all add: SUP_constant \<open>I \<noteq> {}\<close>)
 | |
| 3243 | from this[of A] show ?thesis by simp | |
| 3244 | qed | |
| 3245 | ||
| 3246 | lemma suminf_SUP_eq_directed: | |
| 3247 | fixes f :: "_ \<Rightarrow> nat \<Rightarrow> ereal" | |
| 3248 |   assumes "I \<noteq> {}"
 | |
| 3249 | assumes directed: "\<And>N i j. i \<in> I \<Longrightarrow> j \<in> I \<Longrightarrow> finite N \<Longrightarrow> \<exists>k\<in>I. \<forall>n\<in>N. f i n \<le> f k n \<and> f j n \<le> f k n" | |
| 3250 | assumes nonneg: "\<And>n i. 0 \<le> f n i" | |
| 3251 | shows "(\<Sum>i. SUP n:I. f n i) = (SUP n:I. \<Sum>i. f n i)" | |
| 3252 | proof (subst (1 2) suminf_ereal_eq_SUP) | |
| 3253 | show "\<And>n i. 0 \<le> f n i" "\<And>i. 0 \<le> (SUP n:I. f n i)" | |
| 3254 |     using \<open>I \<noteq> {}\<close> nonneg by (auto intro: SUP_upper2)
 | |
| 3255 | show "(SUP n. \<Sum>i<n. SUP n:I. f n i) = (SUP n:I. SUP j. \<Sum>i<j. f n i)" | |
| 3256 | apply (subst SUP_commute) | |
| 3257 | apply (subst SUP_ereal_setsum_directed) | |
| 3258 | apply (auto intro!: assms simp: finite_subset) | |
| 3259 | done | |
| 3260 | qed | |
| 3261 | ||
| 3262 | subsection \<open>More Limits\<close> | |
| 3263 | ||
| 60771 | 3264 | lemma convergent_limsup_cl: | 
| 3265 |   fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
 | |
| 3266 | shows "convergent X \<Longrightarrow> limsup X = lim X" | |
| 3267 | by (auto simp: convergent_def limI lim_imp_Limsup) | |
| 3268 | ||
| 3269 | lemma lim_increasing_cl: | |
| 3270 | assumes "\<And>n m. n \<ge> m \<Longrightarrow> f n \<ge> f m" | |
| 3271 |   obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})"
 | |
| 3272 | proof | |
| 3273 | show "f ----> (SUP n. f n)" | |
| 3274 | using assms | |
| 3275 | by (intro increasing_tendsto) | |
| 3276 | (auto simp: SUP_upper eventually_sequentially less_SUP_iff intro: less_le_trans) | |
| 3277 | qed | |
| 3278 | ||
| 3279 | lemma lim_decreasing_cl: | |
| 3280 | assumes "\<And>n m. n \<ge> m \<Longrightarrow> f n \<le> f m" | |
| 3281 |   obtains l where "f ----> (l::'a::{complete_linorder,linorder_topology})"
 | |
| 3282 | proof | |
| 3283 | show "f ----> (INF n. f n)" | |
| 3284 | using assms | |
| 3285 | by (intro decreasing_tendsto) | |
| 3286 | (auto simp: INF_lower eventually_sequentially INF_less_iff intro: le_less_trans) | |
| 3287 | qed | |
| 3288 | ||
| 3289 | lemma compact_complete_linorder: | |
| 3290 |   fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
 | |
| 3291 | shows "\<exists>l r. subseq r \<and> (X \<circ> r) ----> l" | |
| 3292 | proof - | |
| 3293 | obtain r where "subseq r" and mono: "monoseq (X \<circ> r)" | |
| 3294 | using seq_monosub[of X] | |
| 3295 | unfolding comp_def | |
| 3296 | by auto | |
| 3297 | then have "(\<forall>n m. m \<le> n \<longrightarrow> (X \<circ> r) m \<le> (X \<circ> r) n) \<or> (\<forall>n m. m \<le> n \<longrightarrow> (X \<circ> r) n \<le> (X \<circ> r) m)" | |
| 3298 | by (auto simp add: monoseq_def) | |
| 3299 | then obtain l where "(X \<circ> r) ----> l" | |
| 3300 | using lim_increasing_cl[of "X \<circ> r"] lim_decreasing_cl[of "X \<circ> r"] | |
| 3301 | by auto | |
| 3302 | then show ?thesis | |
| 3303 | using \<open>subseq r\<close> by auto | |
| 3304 | qed | |
| 3305 | ||
| 3306 | lemma ereal_dense3: | |
| 3307 | fixes x y :: ereal | |
| 3308 | shows "x < y \<Longrightarrow> \<exists>r::rat. x < real_of_rat r \<and> real_of_rat r < y" | |
| 3309 | proof (cases x y rule: ereal2_cases, simp_all) | |
| 3310 | fix r q :: real | |
| 3311 | assume "r < q" | |
| 3312 | from Rats_dense_in_real[OF this] show "\<exists>x. r < real_of_rat x \<and> real_of_rat x < q" | |
| 3313 | by (fastforce simp: Rats_def) | |
| 3314 | next | |
| 3315 | fix r :: real | |
| 3316 | show "\<exists>x. r < real_of_rat x" "\<exists>x. real_of_rat x < r" | |
| 3317 | using gt_ex[of r] lt_ex[of r] Rats_dense_in_real | |
| 3318 | by (auto simp: Rats_def) | |
| 3319 | qed | |
| 3320 | ||
| 3321 | lemma continuous_within_ereal[intro, simp]: "x \<in> A \<Longrightarrow> continuous (at x within A) ereal" | |
| 3322 | using continuous_on_eq_continuous_within[of A ereal] | |
| 3323 | by (auto intro: continuous_on_ereal continuous_on_id) | |
| 3324 | ||
| 3325 | lemma ereal_open_uminus: | |
| 3326 | fixes S :: "ereal set" | |
| 3327 | assumes "open S" | |
| 3328 | shows "open (uminus ` S)" | |
| 3329 | using \<open>open S\<close>[unfolded open_generated_order] | |
| 3330 | proof induct | |
| 3331 | have "range uminus = (UNIV :: ereal set)" | |
| 3332 | by (auto simp: image_iff ereal_uminus_eq_reorder) | |
| 3333 | then show "open (range uminus :: ereal set)" | |
| 3334 | by simp | |
| 3335 | qed (auto simp add: image_Union image_Int) | |
| 3336 | ||
| 3337 | lemma ereal_uminus_complement: | |
| 3338 | fixes S :: "ereal set" | |
| 3339 | shows "uminus ` (- S) = - uminus ` S" | |
| 3340 | by (auto intro!: bij_image_Compl_eq surjI[of _ uminus] simp: bij_betw_def) | |
| 3341 | ||
| 3342 | lemma ereal_closed_uminus: | |
| 3343 | fixes S :: "ereal set" | |
| 3344 | assumes "closed S" | |
| 3345 | shows "closed (uminus ` S)" | |
| 3346 | using assms | |
| 3347 | unfolding closed_def ereal_uminus_complement[symmetric] | |
| 3348 | by (rule ereal_open_uminus) | |
| 3349 | ||
| 3350 | lemma ereal_open_affinity_pos: | |
| 3351 | fixes S :: "ereal set" | |
| 3352 | assumes "open S" | |
| 3353 | and m: "m \<noteq> \<infinity>" "0 < m" | |
| 3354 | and t: "\<bar>t\<bar> \<noteq> \<infinity>" | |
| 3355 | shows "open ((\<lambda>x. m * x + t) ` S)" | |
| 3356 | proof - | |
| 3357 | have "open ((\<lambda>x. inverse m * (x + -t)) -` S)" | |
| 3358 | using m t | |
| 3359 | apply (intro open_vimage \<open>open S\<close>) | |
| 3360 | apply (intro continuous_at_imp_continuous_on ballI tendsto_cmult_ereal continuous_at[THEN iffD2] | |
| 3361 | tendsto_ident_at tendsto_add_left_ereal) | |
| 3362 | apply auto | |
| 3363 | done | |
| 3364 | also have "(\<lambda>x. inverse m * (x + -t)) -` S = (\<lambda>x. (x - t) / m) -` S" | |
| 3365 | using m t by (auto simp: divide_ereal_def mult.commute uminus_ereal.simps[symmetric] minus_ereal_def | |
| 3366 | simp del: uminus_ereal.simps) | |
| 3367 | also have "(\<lambda>x. (x - t) / m) -` S = (\<lambda>x. m * x + t) ` S" | |
| 3368 | using m t | |
| 3369 | by (simp add: set_eq_iff image_iff) | |
| 3370 | (metis abs_ereal_less0 abs_ereal_uminus ereal_divide_eq ereal_eq_minus ereal_minus(7,8) | |
| 3371 | ereal_minus_less_minus ereal_mult_eq_PInfty ereal_uminus_uminus ereal_zero_mult) | |
| 3372 | finally show ?thesis . | |
| 3373 | qed | |
| 3374 | ||
| 3375 | lemma ereal_open_affinity: | |
| 3376 | fixes S :: "ereal set" | |
| 3377 | assumes "open S" | |
| 3378 | and m: "\<bar>m\<bar> \<noteq> \<infinity>" "m \<noteq> 0" | |
| 3379 | and t: "\<bar>t\<bar> \<noteq> \<infinity>" | |
| 3380 | shows "open ((\<lambda>x. m * x + t) ` S)" | |
| 3381 | proof cases | |
| 3382 | assume "0 < m" | |
| 3383 | then show ?thesis | |
| 3384 | using ereal_open_affinity_pos[OF \<open>open S\<close> _ _ t, of m] m | |
| 3385 | by auto | |
| 3386 | next | |
| 3387 | assume "\<not> 0 < m" then | |
| 3388 | have "0 < -m" | |
| 3389 | using \<open>m \<noteq> 0\<close> | |
| 3390 | by (cases m) auto | |
| 3391 | then have m: "-m \<noteq> \<infinity>" "0 < -m" | |
| 3392 | using \<open>\<bar>m\<bar> \<noteq> \<infinity>\<close> | |
| 3393 | by (auto simp: ereal_uminus_eq_reorder) | |
| 3394 | from ereal_open_affinity_pos[OF ereal_open_uminus[OF \<open>open S\<close>] m t] show ?thesis | |
| 3395 | unfolding image_image by simp | |
| 3396 | qed | |
| 3397 | ||
| 3398 | lemma open_uminus_iff: | |
| 3399 | fixes S :: "ereal set" | |
| 3400 | shows "open (uminus ` S) \<longleftrightarrow> open S" | |
| 3401 | using ereal_open_uminus[of S] ereal_open_uminus[of "uminus ` S"] | |
| 3402 | by auto | |
| 3403 | ||
| 3404 | lemma ereal_Liminf_uminus: | |
| 3405 | fixes f :: "'a \<Rightarrow> ereal" | |
| 3406 | shows "Liminf net (\<lambda>x. - (f x)) = - Limsup net f" | |
| 3407 | using ereal_Limsup_uminus[of _ "(\<lambda>x. - (f x))"] by auto | |
| 3408 | ||
| 3409 | lemma Liminf_PInfty: | |
| 3410 | fixes f :: "'a \<Rightarrow> ereal" | |
| 3411 | assumes "\<not> trivial_limit net" | |
| 3412 | shows "(f ---> \<infinity>) net \<longleftrightarrow> Liminf net f = \<infinity>" | |
| 3413 | unfolding tendsto_iff_Liminf_eq_Limsup[OF assms] | |
| 3414 | using Liminf_le_Limsup[OF assms, of f] | |
| 3415 | by auto | |
| 3416 | ||
| 3417 | lemma Limsup_MInfty: | |
| 3418 | fixes f :: "'a \<Rightarrow> ereal" | |
| 3419 | assumes "\<not> trivial_limit net" | |
| 3420 | shows "(f ---> -\<infinity>) net \<longleftrightarrow> Limsup net f = -\<infinity>" | |
| 3421 | unfolding tendsto_iff_Liminf_eq_Limsup[OF assms] | |
| 3422 | using Liminf_le_Limsup[OF assms, of f] | |
| 3423 | by auto | |
| 3424 | ||
| 3425 | lemma convergent_ereal: | |
| 3426 |   fixes X :: "nat \<Rightarrow> 'a :: {complete_linorder,linorder_topology}"
 | |
| 3427 | shows "convergent X \<longleftrightarrow> limsup X = liminf X" | |
| 3428 | using tendsto_iff_Liminf_eq_Limsup[of sequentially] | |
| 3429 | by (auto simp: convergent_def) | |
| 3430 | ||
| 3431 | lemma limsup_le_liminf_real: | |
| 3432 | fixes X :: "nat \<Rightarrow> real" and L :: real | |
| 3433 | assumes 1: "limsup X \<le> L" and 2: "L \<le> liminf X" | |
| 3434 | shows "X ----> L" | |
| 3435 | proof - | |
| 3436 | from 1 2 have "limsup X \<le> liminf X" by auto | |
| 3437 | hence 3: "limsup X = liminf X" | |
| 3438 | apply (subst eq_iff, rule conjI) | |
| 3439 | by (rule Liminf_le_Limsup, auto) | |
| 3440 | hence 4: "convergent (\<lambda>n. ereal (X n))" | |
| 3441 | by (subst convergent_ereal) | |
| 3442 | hence "limsup X = lim (\<lambda>n. ereal(X n))" | |
| 3443 | by (rule convergent_limsup_cl) | |
| 3444 | also from 1 2 3 have "limsup X = L" by auto | |
| 3445 | finally have "lim (\<lambda>n. ereal(X n)) = L" .. | |
| 3446 | hence "(\<lambda>n. ereal (X n)) ----> L" | |
| 3447 | apply (elim subst) | |
| 3448 | by (subst convergent_LIMSEQ_iff [symmetric], rule 4) | |
| 3449 | thus ?thesis by simp | |
| 3450 | qed | |
| 3451 | ||
| 3452 | lemma liminf_PInfty: | |
| 3453 | fixes X :: "nat \<Rightarrow> ereal" | |
| 3454 | shows "X ----> \<infinity> \<longleftrightarrow> liminf X = \<infinity>" | |
| 3455 | by (metis Liminf_PInfty trivial_limit_sequentially) | |
| 3456 | ||
| 3457 | lemma limsup_MInfty: | |
| 3458 | fixes X :: "nat \<Rightarrow> ereal" | |
| 3459 | shows "X ----> -\<infinity> \<longleftrightarrow> limsup X = -\<infinity>" | |
| 3460 | by (metis Limsup_MInfty trivial_limit_sequentially) | |
| 3461 | ||
| 3462 | lemma ereal_lim_mono: | |
| 3463 | fixes X Y :: "nat \<Rightarrow> 'a::linorder_topology" | |
| 3464 | assumes "\<And>n. N \<le> n \<Longrightarrow> X n \<le> Y n" | |
| 3465 | and "X ----> x" | |
| 3466 | and "Y ----> y" | |
| 3467 | shows "x \<le> y" | |
| 3468 | using assms(1) by (intro LIMSEQ_le[OF assms(2,3)]) auto | |
| 3469 | ||
| 3470 | lemma incseq_le_ereal: | |
| 3471 | fixes X :: "nat \<Rightarrow> 'a::linorder_topology" | |
| 3472 | assumes inc: "incseq X" | |
| 3473 | and lim: "X ----> L" | |
| 3474 | shows "X N \<le> L" | |
| 3475 | using inc | |
| 3476 | by (intro ereal_lim_mono[of N, OF _ tendsto_const lim]) (simp add: incseq_def) | |
| 3477 | ||
| 3478 | lemma decseq_ge_ereal: | |
| 3479 | assumes dec: "decseq X" | |
| 3480 | and lim: "X ----> (L::'a::linorder_topology)" | |
| 3481 | shows "X N \<ge> L" | |
| 3482 | using dec by (intro ereal_lim_mono[of N, OF _ lim tendsto_const]) (simp add: decseq_def) | |
| 3483 | ||
| 3484 | lemma bounded_abs: | |
| 3485 | fixes a :: real | |
| 3486 | assumes "a \<le> x" | |
| 3487 | and "x \<le> b" | |
| 3488 | shows "abs x \<le> max (abs a) (abs b)" | |
| 3489 | by (metis abs_less_iff assms leI le_max_iff_disj | |
| 3490 | less_eq_real_def less_le_not_le less_minus_iff minus_minus) | |
| 3491 | ||
| 3492 | lemma ereal_Sup_lim: | |
| 3493 |   fixes a :: "'a::{complete_linorder,linorder_topology}"
 | |
| 3494 | assumes "\<And>n. b n \<in> s" | |
| 3495 | and "b ----> a" | |
| 3496 | shows "a \<le> Sup s" | |
| 3497 | by (metis Lim_bounded_ereal assms complete_lattice_class.Sup_upper) | |
| 3498 | ||
| 3499 | lemma ereal_Inf_lim: | |
| 3500 |   fixes a :: "'a::{complete_linorder,linorder_topology}"
 | |
| 3501 | assumes "\<And>n. b n \<in> s" | |
| 3502 | and "b ----> a" | |
| 3503 | shows "Inf s \<le> a" | |
| 3504 | by (metis Lim_bounded2_ereal assms complete_lattice_class.Inf_lower) | |
| 3505 | ||
| 3506 | lemma SUP_Lim_ereal: | |
| 3507 |   fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
 | |
| 3508 | assumes inc: "incseq X" | |
| 3509 | and l: "X ----> l" | |
| 3510 | shows "(SUP n. X n) = l" | |
| 3511 | using LIMSEQ_SUP[OF inc] tendsto_unique[OF trivial_limit_sequentially l] | |
| 3512 | by simp | |
| 3513 | ||
| 3514 | lemma INF_Lim_ereal: | |
| 3515 |   fixes X :: "nat \<Rightarrow> 'a::{complete_linorder,linorder_topology}"
 | |
| 3516 | assumes dec: "decseq X" | |
| 3517 | and l: "X ----> l" | |
| 3518 | shows "(INF n. X n) = l" | |
| 3519 | using LIMSEQ_INF[OF dec] tendsto_unique[OF trivial_limit_sequentially l] | |
| 3520 | by simp | |
| 3521 | ||
| 3522 | lemma SUP_eq_LIMSEQ: | |
| 3523 | assumes "mono f" | |
| 3524 | shows "(SUP n. ereal (f n)) = ereal x \<longleftrightarrow> f ----> x" | |
| 3525 | proof | |
| 3526 | have inc: "incseq (\<lambda>i. ereal (f i))" | |
| 3527 | using \<open>mono f\<close> unfolding mono_def incseq_def by auto | |
| 3528 |   {
 | |
| 3529 | assume "f ----> x" | |
| 3530 | then have "(\<lambda>i. ereal (f i)) ----> ereal x" | |
| 3531 | by auto | |
| 3532 | from SUP_Lim_ereal[OF inc this] show "(SUP n. ereal (f n)) = ereal x" . | |
| 3533 | next | |
| 3534 | assume "(SUP n. ereal (f n)) = ereal x" | |
| 3535 | with LIMSEQ_SUP[OF inc] show "f ----> x" by auto | |
| 3536 | } | |
| 3537 | qed | |
| 3538 | ||
| 3539 | lemma liminf_ereal_cminus: | |
| 3540 | fixes f :: "nat \<Rightarrow> ereal" | |
| 3541 | assumes "c \<noteq> -\<infinity>" | |
| 3542 | shows "liminf (\<lambda>x. c - f x) = c - limsup f" | |
| 3543 | proof (cases c) | |
| 3544 | case PInf | |
| 3545 | then show ?thesis | |
| 3546 | by (simp add: Liminf_const) | |
| 3547 | next | |
| 3548 | case (real r) | |
| 3549 | then show ?thesis | |
| 3550 | unfolding liminf_SUP_INF limsup_INF_SUP | |
| 3551 | apply (subst INF_ereal_minus_right) | |
| 3552 | apply auto | |
| 3553 | apply (subst SUP_ereal_minus_right) | |
| 3554 | apply auto | |
| 3555 | done | |
| 3556 | qed (insert \<open>c \<noteq> -\<infinity>\<close>, simp) | |
| 3557 | ||
| 3558 | ||
| 3559 | subsubsection \<open>Continuity\<close> | |
| 3560 | ||
| 3561 | lemma continuous_at_of_ereal: | |
| 3562 | "\<bar>x0 :: ereal\<bar> \<noteq> \<infinity> \<Longrightarrow> continuous (at x0) real" | |
| 3563 | unfolding continuous_at | |
| 3564 | by (rule lim_real_of_ereal) (simp add: ereal_real) | |
| 3565 | ||
| 3566 | lemma nhds_ereal: "nhds (ereal r) = filtermap ereal (nhds r)" | |
| 3567 | by (simp add: filtermap_nhds_open_map open_ereal continuous_at_of_ereal) | |
| 3568 | ||
| 3569 | lemma at_ereal: "at (ereal r) = filtermap ereal (at r)" | |
| 3570 | by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) | |
| 3571 | ||
| 3572 | lemma at_left_ereal: "at_left (ereal r) = filtermap ereal (at_left r)" | |
| 3573 | by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) | |
| 3574 | ||
| 3575 | lemma at_right_ereal: "at_right (ereal r) = filtermap ereal (at_right r)" | |
| 3576 | by (simp add: filter_eq_iff eventually_at_filter nhds_ereal eventually_filtermap) | |
| 3577 | ||
| 3578 | lemma | |
| 3579 | shows at_left_PInf: "at_left \<infinity> = filtermap ereal at_top" | |
| 3580 | and at_right_MInf: "at_right (-\<infinity>) = filtermap ereal at_bot" | |
| 3581 | unfolding filter_eq_iff eventually_filtermap eventually_at_top_dense eventually_at_bot_dense | |
| 3582 | eventually_at_left[OF ereal_less(5)] eventually_at_right[OF ereal_less(6)] | |
| 3583 | by (auto simp add: ereal_all_split ereal_ex_split) | |
| 3584 | ||
| 3585 | lemma ereal_tendsto_simps1: | |
| 3586 | "((f \<circ> real) ---> y) (at_left (ereal x)) \<longleftrightarrow> (f ---> y) (at_left x)" | |
| 3587 | "((f \<circ> real) ---> y) (at_right (ereal x)) \<longleftrightarrow> (f ---> y) (at_right x)" | |
| 3588 | "((f \<circ> real) ---> y) (at_left (\<infinity>::ereal)) \<longleftrightarrow> (f ---> y) at_top" | |
| 3589 | "((f \<circ> real) ---> y) (at_right (-\<infinity>::ereal)) \<longleftrightarrow> (f ---> y) at_bot" | |
| 3590 | unfolding tendsto_compose_filtermap at_left_ereal at_right_ereal at_left_PInf at_right_MInf | |
| 3591 | by (auto simp: filtermap_filtermap filtermap_ident) | |
| 3592 | ||
| 3593 | lemma ereal_tendsto_simps2: | |
| 3594 | "((ereal \<circ> f) ---> ereal a) F \<longleftrightarrow> (f ---> a) F" | |
| 3595 | "((ereal \<circ> f) ---> \<infinity>) F \<longleftrightarrow> (LIM x F. f x :> at_top)" | |
| 3596 | "((ereal \<circ> f) ---> -\<infinity>) F \<longleftrightarrow> (LIM x F. f x :> at_bot)" | |
| 3597 | unfolding tendsto_PInfty filterlim_at_top_dense tendsto_MInfty filterlim_at_bot_dense | |
| 3598 | using lim_ereal by (simp_all add: comp_def) | |
| 3599 | ||
| 61245 | 3600 | lemma inverse_infty_ereal_tendsto_0: "inverse -- \<infinity> --> (0::ereal)" | 
| 3601 | proof - | |
| 3602 | have **: "((\<lambda>x. ereal (inverse x)) ---> ereal 0) at_infinity" | |
| 3603 | by (intro tendsto_intros tendsto_inverse_0) | |
| 3604 | ||
| 3605 | show ?thesis | |
| 3606 | by (simp add: at_infty_ereal_eq_at_top tendsto_compose_filtermap[symmetric] comp_def) | |
| 3607 | (auto simp: eventually_at_top_linorder exI[of _ 1] zero_ereal_def at_top_le_at_infinity | |
| 3608 | intro!: filterlim_mono_eventually[OF **]) | |
| 3609 | qed | |
| 3610 | ||
| 3611 | lemma inverse_ereal_tendsto_pos: | |
| 3612 | fixes x :: ereal assumes "0 < x" | |
| 3613 | shows "inverse -- x --> inverse x" | |
| 3614 | proof (cases x) | |
| 3615 | case (real r) | |
| 3616 | with `0 < x` have **: "(\<lambda>x. ereal (inverse x)) -- r --> ereal (inverse r)" | |
| 3617 | by (auto intro!: tendsto_inverse) | |
| 3618 | from real \<open>0 < x\<close> show ?thesis | |
| 3619 | by (auto simp: at_ereal tendsto_compose_filtermap[symmetric] eventually_at_filter | |
| 3620 | intro!: Lim_transform_eventually[OF _ **] t1_space_nhds) | |
| 3621 | qed (insert \<open>0 < x\<close>, auto intro!: inverse_infty_ereal_tendsto_0) | |
| 3622 | ||
| 3623 | lemma inverse_ereal_tendsto_at_right_0: "(inverse ---> \<infinity>) (at_right (0::ereal))" | |
| 3624 | unfolding tendsto_compose_filtermap[symmetric] at_right_ereal zero_ereal_def | |
| 3625 | by (subst filterlim_cong[OF refl refl, where g="\<lambda>x. ereal (inverse x)"]) | |
| 3626 | (auto simp: eventually_at_filter tendsto_PInfty_eq_at_top filterlim_inverse_at_top_right) | |
| 3627 | ||
| 60771 | 3628 | lemmas ereal_tendsto_simps = ereal_tendsto_simps1 ereal_tendsto_simps2 | 
| 3629 | ||
| 3630 | lemma continuous_at_iff_ereal: | |
| 3631 | fixes f :: "'a::t2_space \<Rightarrow> real" | |
| 3632 | shows "continuous (at x0 within s) f \<longleftrightarrow> continuous (at x0 within s) (ereal \<circ> f)" | |
| 3633 | unfolding continuous_within comp_def lim_ereal .. | |
| 3634 | ||
| 3635 | lemma continuous_on_iff_ereal: | |
| 3636 | fixes f :: "'a::t2_space => real" | |
| 3637 | assumes "open A" | |
| 3638 | shows "continuous_on A f \<longleftrightarrow> continuous_on A (ereal \<circ> f)" | |
| 3639 | unfolding continuous_on_def comp_def lim_ereal .. | |
| 3640 | ||
| 3641 | lemma continuous_on_real: "continuous_on (UNIV - {\<infinity>, -\<infinity>::ereal}) real"
 | |
| 3642 | using continuous_at_of_ereal continuous_on_eq_continuous_at open_image_ereal | |
| 3643 | by auto | |
| 3644 | ||
| 3645 | lemma continuous_on_iff_real: | |
| 3646 | fixes f :: "'a::t2_space \<Rightarrow> ereal" | |
| 3647 | assumes *: "\<And>x. x \<in> A \<Longrightarrow> \<bar>f x\<bar> \<noteq> \<infinity>" | |
| 3648 | shows "continuous_on A f \<longleftrightarrow> continuous_on A (real \<circ> f)" | |
| 3649 | proof - | |
| 3650 |   have "f ` A \<subseteq> UNIV - {\<infinity>, -\<infinity>}"
 | |
| 3651 | using assms by force | |
| 3652 | then have *: "continuous_on (f ` A) real" | |
| 3653 | using continuous_on_real by (simp add: continuous_on_subset) | |
| 3654 | have **: "continuous_on ((real \<circ> f) ` A) ereal" | |
| 3655 | by (intro continuous_on_ereal continuous_on_id) | |
| 3656 |   {
 | |
| 3657 | assume "continuous_on A f" | |
| 3658 | then have "continuous_on A (real \<circ> f)" | |
| 3659 | apply (subst continuous_on_compose) | |
| 3660 | using * | |
| 3661 | apply auto | |
| 3662 | done | |
| 3663 | } | |
| 3664 | moreover | |
| 3665 |   {
 | |
| 3666 | assume "continuous_on A (real \<circ> f)" | |
| 3667 | then have "continuous_on A (ereal \<circ> (real \<circ> f))" | |
| 3668 | apply (subst continuous_on_compose) | |
| 3669 | using ** | |
| 3670 | apply auto | |
| 3671 | done | |
| 3672 | then have "continuous_on A f" | |
| 3673 | apply (subst continuous_on_cong[of _ A _ "ereal \<circ> (real \<circ> f)"]) | |
| 3674 | using assms ereal_real | |
| 3675 | apply auto | |
| 3676 | done | |
| 3677 | } | |
| 3678 | ultimately show ?thesis | |
| 3679 | by auto | |
| 3680 | qed | |
| 3681 | ||
| 3682 | ||
| 60500 | 3683 | subsubsection \<open>Tests for code generator\<close> | 
| 43933 | 3684 | |
| 3685 | (* A small list of simple arithmetic expressions *) | |
| 3686 | ||
| 56927 | 3687 | value "- \<infinity> :: ereal" | 
| 3688 | value "\<bar>-\<infinity>\<bar> :: ereal" | |
| 3689 | value "4 + 5 / 4 - ereal 2 :: ereal" | |
| 3690 | value "ereal 3 < \<infinity>" | |
| 3691 | value "real (\<infinity>::ereal) = 0" | |
| 43933 | 3692 | |
| 41973 | 3693 | end |