author | wenzelm |
Mon, 11 Feb 2013 14:39:04 +0100 | |
changeset 51085 | d90218288d51 |
parent 50819 | 5601ae592679 |
child 51000 | c9adb50f74ad |
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 |
|
8 |
header {* Extended real number line *} |
|
9 |
||
43920 | 10 |
theory Extended_Real |
43941 | 11 |
imports Complex_Main Extended_Nat |
41973 | 12 |
begin |
13 |
||
41980
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
14 |
text {* |
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
15 |
|
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
16 |
For more lemmas about the extended real numbers go to |
47082 | 17 |
@{file "~~/src/HOL/Multivariate_Analysis/Extended_Real_Limits.thy"} |
41980
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
18 |
|
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
19 |
*} |
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
20 |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
21 |
lemma (in complete_lattice) atLeast_eq_UNIV_iff: "{x..} = UNIV \<longleftrightarrow> x = bot" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
22 |
proof |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
23 |
assume "{x..} = UNIV" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
24 |
show "x = bot" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
25 |
proof (rule ccontr) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
26 |
assume "x \<noteq> bot" then have "bot \<notin> {x..}" by (simp add: le_less) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
27 |
then show False using `{x..} = UNIV` by simp |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
28 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
29 |
qed auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
30 |
|
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
31 |
lemma SUPR_pair: |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
32 |
"(SUP i : A. SUP j : B. f i j) = (SUP p : A \<times> B. f (fst p) (snd p))" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
33 |
by (rule antisym) (auto intro!: SUP_least SUP_upper2) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
34 |
|
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
35 |
lemma INFI_pair: |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
36 |
"(INF i : A. INF j : B. f i j) = (INF p : A \<times> B. f (fst p) (snd p))" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
37 |
by (rule antisym) (auto intro!: INF_greatest INF_lower2) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
38 |
|
41973 | 39 |
subsection {* Definition and basic properties *} |
40 |
||
43920 | 41 |
datatype ereal = ereal real | PInfty | MInfty |
41973 | 42 |
|
43920 | 43 |
instantiation ereal :: uminus |
41973 | 44 |
begin |
43920 | 45 |
fun uminus_ereal where |
46 |
"- (ereal r) = ereal (- r)" |
|
43923 | 47 |
| "- PInfty = MInfty" |
48 |
| "- MInfty = PInfty" |
|
41973 | 49 |
instance .. |
50 |
end |
|
51 |
||
43923 | 52 |
instantiation ereal :: infinity |
53 |
begin |
|
54 |
definition "(\<infinity>::ereal) = PInfty" |
|
55 |
instance .. |
|
56 |
end |
|
41973 | 57 |
|
43923 | 58 |
declare [[coercion "ereal :: real \<Rightarrow> ereal"]] |
41973 | 59 |
|
43920 | 60 |
lemma ereal_uminus_uminus[simp]: |
61 |
fixes a :: ereal shows "- (- a) = a" |
|
41973 | 62 |
by (cases a) simp_all |
63 |
||
43923 | 64 |
lemma |
65 |
shows PInfty_eq_infinity[simp]: "PInfty = \<infinity>" |
|
66 |
and MInfty_eq_minfinity[simp]: "MInfty = - \<infinity>" |
|
67 |
and MInfty_neq_PInfty[simp]: "\<infinity> \<noteq> - (\<infinity>::ereal)" "- \<infinity> \<noteq> (\<infinity>::ereal)" |
|
68 |
and MInfty_neq_ereal[simp]: "ereal r \<noteq> - \<infinity>" "- \<infinity> \<noteq> ereal r" |
|
69 |
and PInfty_neq_ereal[simp]: "ereal r \<noteq> \<infinity>" "\<infinity> \<noteq> ereal r" |
|
70 |
and PInfty_cases[simp]: "(case \<infinity> of ereal r \<Rightarrow> f r | PInfty \<Rightarrow> y | MInfty \<Rightarrow> z) = y" |
|
71 |
and MInfty_cases[simp]: "(case - \<infinity> of ereal r \<Rightarrow> f r | PInfty \<Rightarrow> y | MInfty \<Rightarrow> z) = z" |
|
72 |
by (simp_all add: infinity_ereal_def) |
|
41973 | 73 |
|
43933 | 74 |
declare |
75 |
PInfty_eq_infinity[code_post] |
|
76 |
MInfty_eq_minfinity[code_post] |
|
77 |
||
78 |
lemma [code_unfold]: |
|
79 |
"\<infinity> = PInfty" |
|
80 |
"-PInfty = MInfty" |
|
81 |
by simp_all |
|
82 |
||
43923 | 83 |
lemma inj_ereal[simp]: "inj_on ereal A" |
84 |
unfolding inj_on_def by auto |
|
41973 | 85 |
|
43920 | 86 |
lemma ereal_cases[case_names real PInf MInf, cases type: ereal]: |
87 |
assumes "\<And>r. x = ereal r \<Longrightarrow> P" |
|
41973 | 88 |
assumes "x = \<infinity> \<Longrightarrow> P" |
89 |
assumes "x = -\<infinity> \<Longrightarrow> P" |
|
90 |
shows P |
|
91 |
using assms by (cases x) auto |
|
92 |
||
43920 | 93 |
lemmas ereal2_cases = ereal_cases[case_product ereal_cases] |
94 |
lemmas ereal3_cases = ereal2_cases[case_product ereal_cases] |
|
41973 | 95 |
|
43920 | 96 |
lemma ereal_uminus_eq_iff[simp]: |
97 |
fixes a b :: ereal shows "-a = -b \<longleftrightarrow> a = b" |
|
98 |
by (cases rule: ereal2_cases[of a b]) simp_all |
|
41973 | 99 |
|
43920 | 100 |
function of_ereal :: "ereal \<Rightarrow> real" where |
101 |
"of_ereal (ereal r) = r" | |
|
102 |
"of_ereal \<infinity> = 0" | |
|
103 |
"of_ereal (-\<infinity>) = 0" |
|
104 |
by (auto intro: ereal_cases) |
|
41973 | 105 |
termination proof qed (rule wf_empty) |
106 |
||
107 |
defs (overloaded) |
|
43920 | 108 |
real_of_ereal_def [code_unfold]: "real \<equiv> of_ereal" |
41973 | 109 |
|
43920 | 110 |
lemma real_of_ereal[simp]: |
111 |
"real (- x :: ereal) = - (real x)" |
|
112 |
"real (ereal r) = r" |
|
43923 | 113 |
"real (\<infinity>::ereal) = 0" |
43920 | 114 |
by (cases x) (simp_all add: real_of_ereal_def) |
41973 | 115 |
|
43920 | 116 |
lemma range_ereal[simp]: "range ereal = UNIV - {\<infinity>, -\<infinity>}" |
41973 | 117 |
proof safe |
43920 | 118 |
fix x assume "x \<notin> range ereal" "x \<noteq> \<infinity>" |
41973 | 119 |
then show "x = -\<infinity>" by (cases x) auto |
120 |
qed auto |
|
121 |
||
43920 | 122 |
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:
41978
diff
changeset
|
123 |
proof safe |
43920 | 124 |
fix x :: ereal show "x \<in> range uminus" by (intro image_eqI[of _ _ "-x"]) auto |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
125 |
qed auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
126 |
|
43920 | 127 |
instantiation ereal :: abs |
41976 | 128 |
begin |
43920 | 129 |
function abs_ereal where |
130 |
"\<bar>ereal r\<bar> = ereal \<bar>r\<bar>" |
|
43923 | 131 |
| "\<bar>-\<infinity>\<bar> = (\<infinity>::ereal)" |
132 |
| "\<bar>\<infinity>\<bar> = (\<infinity>::ereal)" |
|
43920 | 133 |
by (auto intro: ereal_cases) |
41976 | 134 |
termination proof qed (rule wf_empty) |
135 |
instance .. |
|
136 |
end |
|
137 |
||
43923 | 138 |
lemma abs_eq_infinity_cases[elim!]: "\<lbrakk> \<bar>x :: ereal\<bar> = \<infinity> ; x = \<infinity> \<Longrightarrow> P ; x = -\<infinity> \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P" |
41976 | 139 |
by (cases x) auto |
140 |
||
43923 | 141 |
lemma abs_neq_infinity_cases[elim!]: "\<lbrakk> \<bar>x :: ereal\<bar> \<noteq> \<infinity> ; \<And>r. x = ereal r \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P" |
41976 | 142 |
by (cases x) auto |
143 |
||
43920 | 144 |
lemma abs_ereal_uminus[simp]: "\<bar>- x\<bar> = \<bar>x::ereal\<bar>" |
41976 | 145 |
by (cases x) auto |
146 |
||
50104 | 147 |
lemma ereal_infinity_cases: "(a::ereal) \<noteq> \<infinity> \<Longrightarrow> a \<noteq> -\<infinity> \<Longrightarrow> \<bar>a\<bar> \<noteq> \<infinity>" |
148 |
by auto |
|
149 |
||
41973 | 150 |
subsubsection "Addition" |
151 |
||
43920 | 152 |
instantiation ereal :: comm_monoid_add |
41973 | 153 |
begin |
154 |
||
43920 | 155 |
definition "0 = ereal 0" |
41973 | 156 |
|
43920 | 157 |
function plus_ereal where |
158 |
"ereal r + ereal p = ereal (r + p)" | |
|
43923 | 159 |
"\<infinity> + a = (\<infinity>::ereal)" | |
160 |
"a + \<infinity> = (\<infinity>::ereal)" | |
|
43920 | 161 |
"ereal r + -\<infinity> = - \<infinity>" | |
43923 | 162 |
"-\<infinity> + ereal p = -(\<infinity>::ereal)" | |
163 |
"-\<infinity> + -\<infinity> = -(\<infinity>::ereal)" |
|
41973 | 164 |
proof - |
165 |
case (goal1 P x) |
|
166 |
moreover then obtain a b where "x = (a, b)" by (cases x) auto |
|
167 |
ultimately show P |
|
43920 | 168 |
by (cases rule: ereal2_cases[of a b]) auto |
41973 | 169 |
qed auto |
170 |
termination proof qed (rule wf_empty) |
|
171 |
||
172 |
lemma Infty_neq_0[simp]: |
|
43923 | 173 |
"(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> (\<infinity>::ereal)" |
174 |
"-(\<infinity>::ereal) \<noteq> 0" "0 \<noteq> -(\<infinity>::ereal)" |
|
43920 | 175 |
by (simp_all add: zero_ereal_def) |
41973 | 176 |
|
43920 | 177 |
lemma ereal_eq_0[simp]: |
178 |
"ereal r = 0 \<longleftrightarrow> r = 0" |
|
179 |
"0 = ereal r \<longleftrightarrow> r = 0" |
|
180 |
unfolding zero_ereal_def by simp_all |
|
41973 | 181 |
|
182 |
instance |
|
183 |
proof |
|
47082 | 184 |
fix a b c :: ereal |
185 |
show "0 + a = a" |
|
43920 | 186 |
by (cases a) (simp_all add: zero_ereal_def) |
47082 | 187 |
show "a + b = b + a" |
43920 | 188 |
by (cases rule: ereal2_cases[of a b]) simp_all |
47082 | 189 |
show "a + b + c = a + (b + c)" |
43920 | 190 |
by (cases rule: ereal3_cases[of a b c]) simp_all |
41973 | 191 |
qed |
192 |
end |
|
193 |
||
43920 | 194 |
lemma real_of_ereal_0[simp]: "real (0::ereal) = 0" |
195 |
unfolding real_of_ereal_def zero_ereal_def by simp |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
196 |
|
43920 | 197 |
lemma abs_ereal_zero[simp]: "\<bar>0\<bar> = (0::ereal)" |
198 |
unfolding zero_ereal_def abs_ereal.simps by simp |
|
41976 | 199 |
|
43920 | 200 |
lemma ereal_uminus_zero[simp]: |
201 |
"- 0 = (0::ereal)" |
|
202 |
by (simp add: zero_ereal_def) |
|
41973 | 203 |
|
43920 | 204 |
lemma ereal_uminus_zero_iff[simp]: |
205 |
fixes a :: ereal shows "-a = 0 \<longleftrightarrow> a = 0" |
|
41973 | 206 |
by (cases a) simp_all |
207 |
||
43920 | 208 |
lemma ereal_plus_eq_PInfty[simp]: |
43923 | 209 |
fixes a b :: ereal shows "a + b = \<infinity> \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>" |
43920 | 210 |
by (cases rule: ereal2_cases[of a b]) auto |
41973 | 211 |
|
43920 | 212 |
lemma ereal_plus_eq_MInfty[simp]: |
43923 | 213 |
fixes a b :: ereal shows "a + b = -\<infinity> \<longleftrightarrow> |
41973 | 214 |
(a = -\<infinity> \<or> b = -\<infinity>) \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>" |
43920 | 215 |
by (cases rule: ereal2_cases[of a b]) auto |
41973 | 216 |
|
43920 | 217 |
lemma ereal_add_cancel_left: |
43923 | 218 |
fixes a b :: ereal assumes "a \<noteq> -\<infinity>" |
41973 | 219 |
shows "a + b = a + c \<longleftrightarrow> (a = \<infinity> \<or> b = c)" |
43920 | 220 |
using assms by (cases rule: ereal3_cases[of a b c]) auto |
41973 | 221 |
|
43920 | 222 |
lemma ereal_add_cancel_right: |
43923 | 223 |
fixes a b :: ereal assumes "a \<noteq> -\<infinity>" |
41973 | 224 |
shows "b + a = c + a \<longleftrightarrow> (a = \<infinity> \<or> b = c)" |
43920 | 225 |
using assms by (cases rule: ereal3_cases[of a b c]) auto |
41973 | 226 |
|
43920 | 227 |
lemma ereal_real: |
228 |
"ereal (real x) = (if \<bar>x\<bar> = \<infinity> then 0 else x)" |
|
41973 | 229 |
by (cases x) simp_all |
230 |
||
43920 | 231 |
lemma real_of_ereal_add: |
232 |
fixes a b :: ereal |
|
47082 | 233 |
shows "real (a + b) = |
234 |
(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 | 235 |
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:
41978
diff
changeset
|
236 |
|
43920 | 237 |
subsubsection "Linear order on @{typ ereal}" |
41973 | 238 |
|
43920 | 239 |
instantiation ereal :: linorder |
41973 | 240 |
begin |
241 |
||
47082 | 242 |
function less_ereal |
243 |
where |
|
244 |
" ereal x < ereal y \<longleftrightarrow> x < y" |
|
245 |
| "(\<infinity>::ereal) < a \<longleftrightarrow> False" |
|
246 |
| " a < -(\<infinity>::ereal) \<longleftrightarrow> False" |
|
247 |
| "ereal x < \<infinity> \<longleftrightarrow> True" |
|
248 |
| " -\<infinity> < ereal r \<longleftrightarrow> True" |
|
249 |
| " -\<infinity> < (\<infinity>::ereal) \<longleftrightarrow> True" |
|
41973 | 250 |
proof - |
251 |
case (goal1 P x) |
|
252 |
moreover then obtain a b where "x = (a,b)" by (cases x) auto |
|
43920 | 253 |
ultimately show P by (cases rule: ereal2_cases[of a b]) auto |
41973 | 254 |
qed simp_all |
255 |
termination by (relation "{}") simp |
|
256 |
||
43920 | 257 |
definition "x \<le> (y::ereal) \<longleftrightarrow> x < y \<or> x = y" |
41973 | 258 |
|
43920 | 259 |
lemma ereal_infty_less[simp]: |
43923 | 260 |
fixes x :: ereal |
261 |
shows "x < \<infinity> \<longleftrightarrow> (x \<noteq> \<infinity>)" |
|
262 |
"-\<infinity> < x \<longleftrightarrow> (x \<noteq> -\<infinity>)" |
|
41973 | 263 |
by (cases x, simp_all) (cases x, simp_all) |
264 |
||
43920 | 265 |
lemma ereal_infty_less_eq[simp]: |
43923 | 266 |
fixes x :: ereal |
267 |
shows "\<infinity> \<le> x \<longleftrightarrow> x = \<infinity>" |
|
41973 | 268 |
"x \<le> -\<infinity> \<longleftrightarrow> x = -\<infinity>" |
43920 | 269 |
by (auto simp add: less_eq_ereal_def) |
41973 | 270 |
|
43920 | 271 |
lemma ereal_less[simp]: |
272 |
"ereal r < 0 \<longleftrightarrow> (r < 0)" |
|
273 |
"0 < ereal r \<longleftrightarrow> (0 < r)" |
|
43923 | 274 |
"0 < (\<infinity>::ereal)" |
275 |
"-(\<infinity>::ereal) < 0" |
|
43920 | 276 |
by (simp_all add: zero_ereal_def) |
41973 | 277 |
|
43920 | 278 |
lemma ereal_less_eq[simp]: |
43923 | 279 |
"x \<le> (\<infinity>::ereal)" |
280 |
"-(\<infinity>::ereal) \<le> x" |
|
43920 | 281 |
"ereal r \<le> ereal p \<longleftrightarrow> r \<le> p" |
282 |
"ereal r \<le> 0 \<longleftrightarrow> r \<le> 0" |
|
283 |
"0 \<le> ereal r \<longleftrightarrow> 0 \<le> r" |
|
284 |
by (auto simp add: less_eq_ereal_def zero_ereal_def) |
|
41973 | 285 |
|
43920 | 286 |
lemma ereal_infty_less_eq2: |
43923 | 287 |
"a \<le> b \<Longrightarrow> a = \<infinity> \<Longrightarrow> b = (\<infinity>::ereal)" |
288 |
"a \<le> b \<Longrightarrow> b = -\<infinity> \<Longrightarrow> a = -(\<infinity>::ereal)" |
|
41973 | 289 |
by simp_all |
290 |
||
291 |
instance |
|
292 |
proof |
|
47082 | 293 |
fix x y z :: ereal |
294 |
show "x \<le> x" |
|
41973 | 295 |
by (cases x) simp_all |
47082 | 296 |
show "x < y \<longleftrightarrow> x \<le> y \<and> \<not> y \<le> x" |
43920 | 297 |
by (cases rule: ereal2_cases[of x y]) auto |
41973 | 298 |
show "x \<le> y \<or> y \<le> x " |
43920 | 299 |
by (cases rule: ereal2_cases[of x y]) auto |
41973 | 300 |
{ assume "x \<le> y" "y \<le> x" then show "x = y" |
43920 | 301 |
by (cases rule: ereal2_cases[of x y]) auto } |
47082 | 302 |
{ assume "x \<le> y" "y \<le> z" then show "x \<le> z" |
43920 | 303 |
by (cases rule: ereal3_cases[of x y z]) auto } |
41973 | 304 |
qed |
47082 | 305 |
|
41973 | 306 |
end |
307 |
||
43920 | 308 |
instance ereal :: ordered_ab_semigroup_add |
41978 | 309 |
proof |
43920 | 310 |
fix a b c :: ereal assume "a \<le> b" then show "c + a \<le> c + b" |
311 |
by (cases rule: ereal3_cases[of a b c]) auto |
|
41978 | 312 |
qed |
313 |
||
43920 | 314 |
lemma real_of_ereal_positive_mono: |
43923 | 315 |
fixes x y :: ereal shows "\<lbrakk>0 \<le> x; x \<le> y; y \<noteq> \<infinity>\<rbrakk> \<Longrightarrow> real x \<le> real y" |
43920 | 316 |
by (cases rule: ereal2_cases[of x y]) auto |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
317 |
|
43920 | 318 |
lemma ereal_MInfty_lessI[intro, simp]: |
43923 | 319 |
fixes a :: ereal shows "a \<noteq> -\<infinity> \<Longrightarrow> -\<infinity> < a" |
41973 | 320 |
by (cases a) auto |
321 |
||
43920 | 322 |
lemma ereal_less_PInfty[intro, simp]: |
43923 | 323 |
fixes a :: ereal shows "a \<noteq> \<infinity> \<Longrightarrow> a < \<infinity>" |
41973 | 324 |
by (cases a) auto |
325 |
||
43920 | 326 |
lemma ereal_less_ereal_Ex: |
327 |
fixes a b :: ereal |
|
328 |
shows "x < ereal r \<longleftrightarrow> x = -\<infinity> \<or> (\<exists>p. p < r \<and> x = ereal p)" |
|
41973 | 329 |
by (cases x) auto |
330 |
||
43920 | 331 |
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:
41978
diff
changeset
|
332 |
proof (cases x) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
333 |
case (real r) then show ?thesis |
41980
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
334 |
using reals_Archimedean2[of r] by simp |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
335 |
qed simp_all |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
336 |
|
43920 | 337 |
lemma ereal_add_mono: |
338 |
fixes a b c d :: ereal assumes "a \<le> b" "c \<le> d" shows "a + c \<le> b + d" |
|
41973 | 339 |
using assms |
340 |
apply (cases a) |
|
43920 | 341 |
apply (cases rule: ereal3_cases[of b c d], auto) |
342 |
apply (cases rule: ereal3_cases[of b c d], auto) |
|
41973 | 343 |
done |
344 |
||
43920 | 345 |
lemma ereal_minus_le_minus[simp]: |
346 |
fixes a b :: ereal shows "- a \<le> - b \<longleftrightarrow> b \<le> a" |
|
347 |
by (cases rule: ereal2_cases[of a b]) auto |
|
41973 | 348 |
|
43920 | 349 |
lemma ereal_minus_less_minus[simp]: |
350 |
fixes a b :: ereal shows "- a < - b \<longleftrightarrow> b < a" |
|
351 |
by (cases rule: ereal2_cases[of a b]) auto |
|
41973 | 352 |
|
43920 | 353 |
lemma ereal_le_real_iff: |
354 |
"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 | 355 |
by (cases y) auto |
356 |
||
43920 | 357 |
lemma real_le_ereal_iff: |
358 |
"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 | 359 |
by (cases y) auto |
360 |
||
43920 | 361 |
lemma ereal_less_real_iff: |
362 |
"x < real y \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> ereal x < y) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> x < 0))" |
|
41973 | 363 |
by (cases y) auto |
364 |
||
43920 | 365 |
lemma real_less_ereal_iff: |
366 |
"real y < x \<longleftrightarrow> ((\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> y < ereal x) \<and> (\<bar>y\<bar> = \<infinity> \<longrightarrow> 0 < x))" |
|
41973 | 367 |
by (cases y) auto |
368 |
||
43920 | 369 |
lemma real_of_ereal_pos: |
370 |
fixes x :: ereal 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:
41978
diff
changeset
|
371 |
|
43920 | 372 |
lemmas real_of_ereal_ord_simps = |
373 |
ereal_le_real_iff real_le_ereal_iff ereal_less_real_iff real_less_ereal_iff |
|
41973 | 374 |
|
43920 | 375 |
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:
42600
diff
changeset
|
376 |
by (cases x) auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
377 |
|
43920 | 378 |
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:
42600
diff
changeset
|
379 |
by (cases x) auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
380 |
|
43920 | 381 |
lemma abs_ereal_pos[simp]: "0 \<le> \<bar>x :: ereal\<bar>" |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
382 |
by (cases x) auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
383 |
|
43923 | 384 |
lemma real_of_ereal_le_0[simp]: "real (x :: ereal) \<le> 0 \<longleftrightarrow> (x \<le> 0 \<or> x = \<infinity>)" |
385 |
by (cases x) auto |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
386 |
|
43923 | 387 |
lemma abs_real_of_ereal[simp]: "\<bar>real (x :: ereal)\<bar> = real \<bar>x\<bar>" |
388 |
by (cases x) auto |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
389 |
|
43923 | 390 |
lemma zero_less_real_of_ereal: |
391 |
fixes x :: ereal shows "0 < real x \<longleftrightarrow> (0 < x \<and> x \<noteq> \<infinity>)" |
|
392 |
by (cases x) auto |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
393 |
|
43920 | 394 |
lemma ereal_0_le_uminus_iff[simp]: |
395 |
fixes a :: ereal shows "0 \<le> -a \<longleftrightarrow> a \<le> 0" |
|
396 |
by (cases rule: ereal2_cases[of a]) auto |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
397 |
|
43920 | 398 |
lemma ereal_uminus_le_0_iff[simp]: |
399 |
fixes a :: ereal shows "-a \<le> 0 \<longleftrightarrow> 0 \<le> a" |
|
400 |
by (cases rule: ereal2_cases[of a]) auto |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
401 |
|
43923 | 402 |
lemma ereal_dense2: "x < y \<Longrightarrow> \<exists>z. x < ereal z \<and> ereal z < y" |
403 |
using lt_ex gt_ex dense by (cases x y rule: ereal2_cases) auto |
|
404 |
||
43920 | 405 |
lemma ereal_dense: |
406 |
fixes x y :: ereal assumes "x < y" |
|
43923 | 407 |
shows "\<exists>z. x < z \<and> z < y" |
408 |
using ereal_dense2[OF `x < y`] by blast |
|
41973 | 409 |
|
43920 | 410 |
lemma ereal_add_strict_mono: |
411 |
fixes a b c d :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
412 |
assumes "a = b" "0 \<le> a" "a \<noteq> \<infinity>" "c < d" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
413 |
shows "a + c < b + d" |
43920 | 414 |
using assms 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:
41978
diff
changeset
|
415 |
|
43923 | 416 |
lemma ereal_less_add: |
417 |
fixes a b c :: ereal shows "\<bar>a\<bar> \<noteq> \<infinity> \<Longrightarrow> c < b \<Longrightarrow> a + c < a + b" |
|
43920 | 418 |
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:
41978
diff
changeset
|
419 |
|
43920 | 420 |
lemma ereal_uminus_eq_reorder: "- a = b \<longleftrightarrow> a = (-b::ereal)" by auto |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
421 |
|
43920 | 422 |
lemma ereal_uminus_less_reorder: "- a < b \<longleftrightarrow> -b < (a::ereal)" |
423 |
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:
41978
diff
changeset
|
424 |
|
43920 | 425 |
lemma ereal_uminus_le_reorder: "- a \<le> b \<longleftrightarrow> -b \<le> (a::ereal)" |
426 |
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:
41978
diff
changeset
|
427 |
|
43920 | 428 |
lemmas ereal_uminus_reorder = |
429 |
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:
41978
diff
changeset
|
430 |
|
43920 | 431 |
lemma ereal_bot: |
432 |
fixes x :: ereal assumes "\<And>B. x \<le> ereal B" shows "x = - \<infinity>" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
433 |
proof (cases x) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
434 |
case (real r) with assms[of "r - 1"] show ?thesis by auto |
47082 | 435 |
next |
436 |
case PInf with assms[of 0] show ?thesis by auto |
|
437 |
next |
|
438 |
case MInf then show ?thesis by simp |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
439 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
440 |
|
43920 | 441 |
lemma ereal_top: |
442 |
fixes x :: ereal assumes "\<And>B. x \<ge> ereal B" shows "x = \<infinity>" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
443 |
proof (cases x) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
444 |
case (real r) with assms[of "r + 1"] show ?thesis by auto |
47082 | 445 |
next |
446 |
case MInf with assms[of 0] show ?thesis by auto |
|
447 |
next |
|
448 |
case PInf then show ?thesis by simp |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
449 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
450 |
|
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
451 |
lemma |
43920 | 452 |
shows ereal_max[simp]: "ereal (max x y) = max (ereal x) (ereal y)" |
453 |
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:
41978
diff
changeset
|
454 |
by (simp_all add: min_def max_def) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
455 |
|
43920 | 456 |
lemma ereal_max_0: "max 0 (ereal r) = ereal (max 0 r)" |
457 |
by (auto simp: zero_ereal_def) |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
458 |
|
41978 | 459 |
lemma |
43920 | 460 |
fixes f :: "nat \<Rightarrow> ereal" |
41978 | 461 |
shows incseq_uminus[simp]: "incseq (\<lambda>x. - f x) \<longleftrightarrow> decseq f" |
462 |
and decseq_uminus[simp]: "decseq (\<lambda>x. - f x) \<longleftrightarrow> incseq f" |
|
463 |
unfolding decseq_def incseq_def by auto |
|
464 |
||
43920 | 465 |
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:
42600
diff
changeset
|
466 |
unfolding incseq_def by auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
467 |
|
43920 | 468 |
lemma ereal_add_nonneg_nonneg: |
469 |
fixes a b :: ereal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a + b" |
|
41978 | 470 |
using add_mono[of 0 a 0 b] by simp |
471 |
||
472 |
lemma image_eqD: "f ` A = B \<Longrightarrow> (\<forall>x\<in>A. f x \<in> B)" |
|
473 |
by auto |
|
474 |
||
475 |
lemma incseq_setsumI: |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
476 |
fixes f :: "nat \<Rightarrow> 'a::{comm_monoid_add, ordered_ab_semigroup_add}" |
41978 | 477 |
assumes "\<And>i. 0 \<le> f i" |
478 |
shows "incseq (\<lambda>i. setsum f {..< i})" |
|
479 |
proof (intro incseq_SucI) |
|
480 |
fix n have "setsum f {..< n} + 0 \<le> setsum f {..<n} + f n" |
|
481 |
using assms by (rule add_left_mono) |
|
482 |
then show "setsum f {..< n} \<le> setsum f {..< Suc n}" |
|
483 |
by auto |
|
484 |
qed |
|
485 |
||
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
486 |
lemma incseq_setsumI2: |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
487 |
fixes f :: "'i \<Rightarrow> nat \<Rightarrow> 'a::{comm_monoid_add, ordered_ab_semigroup_add}" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
488 |
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:
41978
diff
changeset
|
489 |
shows "incseq (\<lambda>i. \<Sum>n\<in>A. f n i)" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
490 |
using assms unfolding incseq_def by (auto intro: setsum_mono) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
491 |
|
41973 | 492 |
subsubsection "Multiplication" |
493 |
||
43920 | 494 |
instantiation ereal :: "{comm_monoid_mult, sgn}" |
41973 | 495 |
begin |
496 |
||
43920 | 497 |
definition "1 = ereal 1" |
41973 | 498 |
|
43920 | 499 |
function sgn_ereal where |
500 |
"sgn (ereal r) = ereal (sgn r)" |
|
43923 | 501 |
| "sgn (\<infinity>::ereal) = 1" |
502 |
| "sgn (-\<infinity>::ereal) = -1" |
|
43920 | 503 |
by (auto intro: ereal_cases) |
41976 | 504 |
termination proof qed (rule wf_empty) |
505 |
||
43920 | 506 |
function times_ereal where |
507 |
"ereal r * ereal p = ereal (r * p)" | |
|
508 |
"ereal r * \<infinity> = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)" | |
|
509 |
"\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then \<infinity> else -\<infinity>)" | |
|
510 |
"ereal r * -\<infinity> = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)" | |
|
511 |
"-\<infinity> * ereal r = (if r = 0 then 0 else if r > 0 then -\<infinity> else \<infinity>)" | |
|
43923 | 512 |
"(\<infinity>::ereal) * \<infinity> = \<infinity>" | |
513 |
"-(\<infinity>::ereal) * \<infinity> = -\<infinity>" | |
|
514 |
"(\<infinity>::ereal) * -\<infinity> = -\<infinity>" | |
|
515 |
"-(\<infinity>::ereal) * -\<infinity> = \<infinity>" |
|
41973 | 516 |
proof - |
517 |
case (goal1 P x) |
|
518 |
moreover then obtain a b where "x = (a, b)" by (cases x) auto |
|
43920 | 519 |
ultimately show P by (cases rule: ereal2_cases[of a b]) auto |
41973 | 520 |
qed simp_all |
521 |
termination by (relation "{}") simp |
|
522 |
||
523 |
instance |
|
524 |
proof |
|
47082 | 525 |
fix a b c :: ereal show "1 * a = a" |
43920 | 526 |
by (cases a) (simp_all add: one_ereal_def) |
47082 | 527 |
show "a * b = b * a" |
43920 | 528 |
by (cases rule: ereal2_cases[of a b]) simp_all |
47082 | 529 |
show "a * b * c = a * (b * c)" |
43920 | 530 |
by (cases rule: ereal3_cases[of a b c]) |
531 |
(simp_all add: zero_ereal_def zero_less_mult_iff) |
|
41973 | 532 |
qed |
533 |
end |
|
534 |
||
50104 | 535 |
lemma real_ereal_1[simp]: "real (1::ereal) = 1" |
536 |
unfolding one_ereal_def by simp |
|
537 |
||
43920 | 538 |
lemma real_of_ereal_le_1: |
539 |
fixes a :: ereal shows "a \<le> 1 \<Longrightarrow> real a \<le> 1" |
|
540 |
by (cases a) (auto simp: one_ereal_def) |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
541 |
|
43920 | 542 |
lemma abs_ereal_one[simp]: "\<bar>1\<bar> = (1::ereal)" |
543 |
unfolding one_ereal_def by simp |
|
41976 | 544 |
|
43920 | 545 |
lemma ereal_mult_zero[simp]: |
546 |
fixes a :: ereal shows "a * 0 = 0" |
|
547 |
by (cases a) (simp_all add: zero_ereal_def) |
|
41973 | 548 |
|
43920 | 549 |
lemma ereal_zero_mult[simp]: |
550 |
fixes a :: ereal shows "0 * a = 0" |
|
551 |
by (cases a) (simp_all add: zero_ereal_def) |
|
41973 | 552 |
|
43920 | 553 |
lemma ereal_m1_less_0[simp]: |
554 |
"-(1::ereal) < 0" |
|
555 |
by (simp add: zero_ereal_def one_ereal_def) |
|
41973 | 556 |
|
43920 | 557 |
lemma ereal_zero_m1[simp]: |
558 |
"1 \<noteq> (0::ereal)" |
|
559 |
by (simp add: zero_ereal_def one_ereal_def) |
|
41973 | 560 |
|
43920 | 561 |
lemma ereal_times_0[simp]: |
562 |
fixes x :: ereal shows "0 * x = 0" |
|
563 |
by (cases x) (auto simp: zero_ereal_def) |
|
41973 | 564 |
|
43920 | 565 |
lemma ereal_times[simp]: |
43923 | 566 |
"1 \<noteq> (\<infinity>::ereal)" "(\<infinity>::ereal) \<noteq> 1" |
567 |
"1 \<noteq> -(\<infinity>::ereal)" "-(\<infinity>::ereal) \<noteq> 1" |
|
43920 | 568 |
by (auto simp add: times_ereal_def one_ereal_def) |
41973 | 569 |
|
43920 | 570 |
lemma ereal_plus_1[simp]: |
571 |
"1 + ereal r = ereal (r + 1)" "ereal r + 1 = ereal (r + 1)" |
|
43923 | 572 |
"1 + -(\<infinity>::ereal) = -\<infinity>" "-(\<infinity>::ereal) + 1 = -\<infinity>" |
43920 | 573 |
unfolding one_ereal_def by auto |
41973 | 574 |
|
43920 | 575 |
lemma ereal_zero_times[simp]: |
576 |
fixes a b :: ereal shows "a * b = 0 \<longleftrightarrow> a = 0 \<or> b = 0" |
|
577 |
by (cases rule: ereal2_cases[of a b]) auto |
|
41973 | 578 |
|
43920 | 579 |
lemma ereal_mult_eq_PInfty[simp]: |
43923 | 580 |
shows "a * b = (\<infinity>::ereal) \<longleftrightarrow> |
41973 | 581 |
(a = \<infinity> \<and> b > 0) \<or> (a > 0 \<and> b = \<infinity>) \<or> (a = -\<infinity> \<and> b < 0) \<or> (a < 0 \<and> b = -\<infinity>)" |
43920 | 582 |
by (cases rule: ereal2_cases[of a b]) auto |
41973 | 583 |
|
43920 | 584 |
lemma ereal_mult_eq_MInfty[simp]: |
43923 | 585 |
shows "a * b = -(\<infinity>::ereal) \<longleftrightarrow> |
41973 | 586 |
(a = \<infinity> \<and> b < 0) \<or> (a < 0 \<and> b = \<infinity>) \<or> (a = -\<infinity> \<and> b > 0) \<or> (a > 0 \<and> b = -\<infinity>)" |
43920 | 587 |
by (cases rule: ereal2_cases[of a b]) auto |
41973 | 588 |
|
43920 | 589 |
lemma ereal_0_less_1[simp]: "0 < (1::ereal)" |
590 |
by (simp_all add: zero_ereal_def one_ereal_def) |
|
41973 | 591 |
|
43920 | 592 |
lemma ereal_zero_one[simp]: "0 \<noteq> (1::ereal)" |
593 |
by (simp_all add: zero_ereal_def one_ereal_def) |
|
41973 | 594 |
|
43920 | 595 |
lemma ereal_mult_minus_left[simp]: |
596 |
fixes a b :: ereal shows "-a * b = - (a * b)" |
|
597 |
by (cases rule: ereal2_cases[of a b]) auto |
|
41973 | 598 |
|
43920 | 599 |
lemma ereal_mult_minus_right[simp]: |
600 |
fixes a b :: ereal shows "a * -b = - (a * b)" |
|
601 |
by (cases rule: ereal2_cases[of a b]) auto |
|
41973 | 602 |
|
43920 | 603 |
lemma ereal_mult_infty[simp]: |
43923 | 604 |
"a * (\<infinity>::ereal) = (if a = 0 then 0 else if 0 < a then \<infinity> else - \<infinity>)" |
41973 | 605 |
by (cases a) auto |
606 |
||
43920 | 607 |
lemma ereal_infty_mult[simp]: |
43923 | 608 |
"(\<infinity>::ereal) * a = (if a = 0 then 0 else if 0 < a then \<infinity> else - \<infinity>)" |
41973 | 609 |
by (cases a) auto |
610 |
||
43920 | 611 |
lemma ereal_mult_strict_right_mono: |
43923 | 612 |
assumes "a < b" and "0 < c" "c < (\<infinity>::ereal)" |
41973 | 613 |
shows "a * c < b * c" |
614 |
using assms |
|
43920 | 615 |
by (cases rule: ereal3_cases[of a b c]) |
44142 | 616 |
(auto simp: zero_le_mult_iff) |
41973 | 617 |
|
43920 | 618 |
lemma ereal_mult_strict_left_mono: |
43923 | 619 |
"\<lbrakk> a < b ; 0 < c ; c < (\<infinity>::ereal)\<rbrakk> \<Longrightarrow> c * a < c * b" |
43920 | 620 |
using ereal_mult_strict_right_mono by (simp add: mult_commute[of c]) |
41973 | 621 |
|
43920 | 622 |
lemma ereal_mult_right_mono: |
623 |
fixes a b c :: ereal shows "\<lbrakk>a \<le> b; 0 \<le> c\<rbrakk> \<Longrightarrow> a*c \<le> b*c" |
|
41973 | 624 |
using assms |
625 |
apply (cases "c = 0") apply simp |
|
43920 | 626 |
by (cases rule: ereal3_cases[of a b c]) |
44142 | 627 |
(auto simp: zero_le_mult_iff) |
41973 | 628 |
|
43920 | 629 |
lemma ereal_mult_left_mono: |
630 |
fixes a b c :: ereal shows "\<lbrakk>a \<le> b; 0 \<le> c\<rbrakk> \<Longrightarrow> c * a \<le> c * b" |
|
631 |
using ereal_mult_right_mono by (simp add: mult_commute[of c]) |
|
41973 | 632 |
|
43920 | 633 |
lemma zero_less_one_ereal[simp]: "0 \<le> (1::ereal)" |
634 |
by (simp add: one_ereal_def zero_ereal_def) |
|
41978 | 635 |
|
43920 | 636 |
lemma ereal_0_le_mult[simp]: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> a * (b :: ereal)" |
637 |
by (cases rule: ereal2_cases[of a b]) (auto simp: mult_nonneg_nonneg) |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
638 |
|
43920 | 639 |
lemma ereal_right_distrib: |
640 |
fixes r a b :: ereal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> r * (a + b) = r * a + r * b" |
|
641 |
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:
41978
diff
changeset
|
642 |
|
43920 | 643 |
lemma ereal_left_distrib: |
644 |
fixes r a b :: ereal shows "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> (a + b) * r = a * r + b * r" |
|
645 |
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:
41978
diff
changeset
|
646 |
|
43920 | 647 |
lemma ereal_mult_le_0_iff: |
648 |
fixes a b :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
649 |
shows "a * b \<le> 0 \<longleftrightarrow> (0 \<le> a \<and> b \<le> 0) \<or> (a \<le> 0 \<and> 0 \<le> b)" |
43920 | 650 |
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:
41978
diff
changeset
|
651 |
|
43920 | 652 |
lemma ereal_zero_le_0_iff: |
653 |
fixes a b :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
654 |
shows "0 \<le> a * b \<longleftrightarrow> (0 \<le> a \<and> 0 \<le> b) \<or> (a \<le> 0 \<and> b \<le> 0)" |
43920 | 655 |
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:
41978
diff
changeset
|
656 |
|
43920 | 657 |
lemma ereal_mult_less_0_iff: |
658 |
fixes a b :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
659 |
shows "a * b < 0 \<longleftrightarrow> (0 < a \<and> b < 0) \<or> (a < 0 \<and> 0 < b)" |
43920 | 660 |
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:
41978
diff
changeset
|
661 |
|
43920 | 662 |
lemma ereal_zero_less_0_iff: |
663 |
fixes a b :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
664 |
shows "0 < a * b \<longleftrightarrow> (0 < a \<and> 0 < b) \<or> (a < 0 \<and> b < 0)" |
43920 | 665 |
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:
41978
diff
changeset
|
666 |
|
50104 | 667 |
lemma ereal_left_mult_cong: |
668 |
fixes a b c :: ereal |
|
669 |
shows "(c \<noteq> 0 \<Longrightarrow> a = b) \<Longrightarrow> c * a = c * b" |
|
670 |
by (cases "c = 0") simp_all |
|
671 |
||
672 |
lemma ereal_right_mult_cong: |
|
673 |
fixes a b c :: ereal |
|
674 |
shows "(c \<noteq> 0 \<Longrightarrow> a = b) \<Longrightarrow> a * c = b * c" |
|
675 |
by (cases "c = 0") simp_all |
|
676 |
||
43920 | 677 |
lemma ereal_distrib: |
678 |
fixes a b c :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
679 |
assumes "a \<noteq> \<infinity> \<or> b \<noteq> -\<infinity>" "a \<noteq> -\<infinity> \<or> b \<noteq> \<infinity>" "\<bar>c\<bar> \<noteq> \<infinity>" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
680 |
shows "(a + b) * c = a * c + b * c" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
681 |
using assms |
43920 | 682 |
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:
41978
diff
changeset
|
683 |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
684 |
instance ereal :: numeral .. |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
685 |
|
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
686 |
lemma numeral_eq_ereal [simp]: "numeral w = ereal (numeral w)" |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
687 |
apply (induct w rule: num_induct) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
688 |
apply (simp only: numeral_One one_ereal_def) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
689 |
apply (simp only: numeral_inc ereal_plus_1) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
690 |
done |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
691 |
|
43920 | 692 |
lemma ereal_le_epsilon: |
693 |
fixes x y :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
694 |
assumes "ALL e. 0 < e --> x <= y + e" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
695 |
shows "x <= y" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
696 |
proof- |
43920 | 697 |
{ assume a: "EX r. y = ereal r" |
47082 | 698 |
then obtain r where r_def: "y = ereal r" by auto |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
699 |
{ assume "x=(-\<infinity>)" hence ?thesis by auto } |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
700 |
moreover |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
701 |
{ assume "~(x=(-\<infinity>))" |
47082 | 702 |
then obtain p where p_def: "x = ereal p" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
703 |
using a assms[rule_format, of 1] by (cases x) auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
704 |
{ fix e have "0 < e --> p <= r + e" |
43920 | 705 |
using assms[rule_format, of "ereal e"] p_def r_def by auto } |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
706 |
hence "p <= r" apply (subst field_le_epsilon) by auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
707 |
hence ?thesis using r_def p_def by auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
708 |
} ultimately have ?thesis by blast |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
709 |
} |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
710 |
moreover |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
711 |
{ assume "y=(-\<infinity>) | y=\<infinity>" hence ?thesis |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
712 |
using assms[rule_format, of 1] by (cases x) auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
713 |
} ultimately show ?thesis by (cases y) auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
714 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
715 |
|
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
716 |
|
43920 | 717 |
lemma ereal_le_epsilon2: |
718 |
fixes x y :: ereal |
|
719 |
assumes "ALL e. 0 < e --> x <= y + ereal e" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
720 |
shows "x <= y" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
721 |
proof- |
43920 | 722 |
{ fix e :: ereal assume "e>0" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
723 |
{ assume "e=\<infinity>" hence "x<=y+e" by auto } |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
724 |
moreover |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
725 |
{ assume "e~=\<infinity>" |
47082 | 726 |
then obtain r where "e = ereal r" using `e>0` apply (cases e) by auto |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
727 |
hence "x<=y+e" using assms[rule_format, of r] `e>0` by auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
728 |
} ultimately have "x<=y+e" by blast |
47082 | 729 |
} then show ?thesis using ereal_le_epsilon by auto |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
730 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
731 |
|
43920 | 732 |
lemma ereal_le_real: |
733 |
fixes x y :: ereal |
|
734 |
assumes "ALL z. x <= ereal z --> y <= ereal z" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
735 |
shows "y <= x" |
44142 | 736 |
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:
41978
diff
changeset
|
737 |
|
43920 | 738 |
lemma ereal_le_ereal: |
739 |
fixes x y :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
740 |
assumes "\<And>B. B < x \<Longrightarrow> B <= y" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
741 |
shows "x <= y" |
43920 | 742 |
by (metis assms ereal_dense leD linorder_le_less_linear) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
743 |
|
43920 | 744 |
lemma ereal_ge_ereal: |
745 |
fixes x y :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
746 |
assumes "ALL B. B>x --> B >= y" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
747 |
shows "x >= y" |
43920 | 748 |
by (metis assms ereal_dense leD linorder_le_less_linear) |
41978 | 749 |
|
43920 | 750 |
lemma setprod_ereal_0: |
751 |
fixes f :: "'a \<Rightarrow> ereal" |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
752 |
shows "(\<Prod>i\<in>A. f i) = 0 \<longleftrightarrow> (finite A \<and> (\<exists>i\<in>A. f i = 0))" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
753 |
proof cases |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
754 |
assume "finite A" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
755 |
then show ?thesis by (induct A) auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
756 |
qed auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
757 |
|
43920 | 758 |
lemma setprod_ereal_pos: |
759 |
fixes f :: "'a \<Rightarrow> ereal" assumes pos: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" shows "0 \<le> (\<Prod>i\<in>I. f i)" |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
760 |
proof cases |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
761 |
assume "finite I" from this pos show ?thesis by induct auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
762 |
qed simp |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
763 |
|
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
764 |
lemma setprod_PInf: |
43923 | 765 |
fixes f :: "'a \<Rightarrow> ereal" |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
766 |
assumes "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> f i" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
767 |
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)" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
768 |
proof cases |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
769 |
assume "finite I" from this assms show ?thesis |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
770 |
proof (induct I) |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
771 |
case (insert i I) |
43920 | 772 |
then have pos: "0 \<le> f i" "0 \<le> setprod f I" by (auto intro!: setprod_ereal_pos) |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
773 |
from insert have "(\<Prod>j\<in>insert i I. f j) = \<infinity> \<longleftrightarrow> setprod f I * f i = \<infinity>" by auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
774 |
also have "\<dots> \<longleftrightarrow> (setprod f I = \<infinity> \<or> f i = \<infinity>) \<and> f i \<noteq> 0 \<and> setprod f I \<noteq> 0" |
43920 | 775 |
using setprod_ereal_pos[of I f] pos |
776 |
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:
42600
diff
changeset
|
777 |
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 | 778 |
using insert by (auto simp: setprod_ereal_0) |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
779 |
finally show ?case . |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
780 |
qed simp |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
781 |
qed simp |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
782 |
|
43920 | 783 |
lemma setprod_ereal: "(\<Prod>i\<in>A. ereal (f i)) = ereal (setprod f A)" |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
784 |
proof cases |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
785 |
assume "finite A" then show ?thesis |
43920 | 786 |
by induct (auto simp: one_ereal_def) |
787 |
qed (simp add: one_ereal_def) |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
788 |
|
41978 | 789 |
subsubsection {* Power *} |
790 |
||
43920 | 791 |
lemma ereal_power[simp]: "(ereal x) ^ n = ereal (x^n)" |
792 |
by (induct n) (auto simp: one_ereal_def) |
|
41978 | 793 |
|
43923 | 794 |
lemma ereal_power_PInf[simp]: "(\<infinity>::ereal) ^ n = (if n = 0 then 1 else \<infinity>)" |
43920 | 795 |
by (induct n) (auto simp: one_ereal_def) |
41978 | 796 |
|
43920 | 797 |
lemma ereal_power_uminus[simp]: |
798 |
fixes x :: ereal |
|
41978 | 799 |
shows "(- x) ^ n = (if even n then x ^ n else - (x^n))" |
43920 | 800 |
by (induct n) (auto simp: one_ereal_def) |
41978 | 801 |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
802 |
lemma ereal_power_numeral[simp]: |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
803 |
"(numeral num :: ereal) ^ n = ereal (numeral num ^ n)" |
43920 | 804 |
by (induct n) (auto simp: one_ereal_def) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
805 |
|
43920 | 806 |
lemma zero_le_power_ereal[simp]: |
807 |
fixes a :: ereal assumes "0 \<le> a" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
808 |
shows "0 \<le> a ^ n" |
43920 | 809 |
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:
41978
diff
changeset
|
810 |
|
41973 | 811 |
subsubsection {* Subtraction *} |
812 |
||
43920 | 813 |
lemma ereal_minus_minus_image[simp]: |
814 |
fixes S :: "ereal set" |
|
41973 | 815 |
shows "uminus ` uminus ` S = S" |
816 |
by (auto simp: image_iff) |
|
817 |
||
43920 | 818 |
lemma ereal_uminus_lessThan[simp]: |
819 |
fixes a :: ereal shows "uminus ` {..<a} = {-a<..}" |
|
47082 | 820 |
proof - |
821 |
{ |
|
822 |
fix x assume "-a < x" |
|
823 |
then have "- x < - (- a)" by (simp del: ereal_uminus_uminus) |
|
824 |
then have "- x < a" by simp |
|
825 |
} |
|
826 |
then show ?thesis by (auto intro!: image_eqI) |
|
827 |
qed |
|
41973 | 828 |
|
43920 | 829 |
lemma ereal_uminus_greaterThan[simp]: |
830 |
"uminus ` {(a::ereal)<..} = {..<-a}" |
|
831 |
by (metis ereal_uminus_lessThan ereal_uminus_uminus |
|
832 |
ereal_minus_minus_image) |
|
41973 | 833 |
|
43920 | 834 |
instantiation ereal :: minus |
41973 | 835 |
begin |
43920 | 836 |
definition "x - y = x + -(y::ereal)" |
41973 | 837 |
instance .. |
838 |
end |
|
839 |
||
43920 | 840 |
lemma ereal_minus[simp]: |
841 |
"ereal r - ereal p = ereal (r - p)" |
|
842 |
"-\<infinity> - ereal r = -\<infinity>" |
|
843 |
"ereal r - \<infinity> = -\<infinity>" |
|
43923 | 844 |
"(\<infinity>::ereal) - x = \<infinity>" |
845 |
"-(\<infinity>::ereal) - \<infinity> = -\<infinity>" |
|
41973 | 846 |
"x - -y = x + y" |
847 |
"x - 0 = x" |
|
848 |
"0 - x = -x" |
|
43920 | 849 |
by (simp_all add: minus_ereal_def) |
41973 | 850 |
|
43920 | 851 |
lemma ereal_x_minus_x[simp]: |
43923 | 852 |
"x - x = (if \<bar>x\<bar> = \<infinity> then \<infinity> else 0::ereal)" |
41973 | 853 |
by (cases x) simp_all |
854 |
||
43920 | 855 |
lemma ereal_eq_minus_iff: |
856 |
fixes x y z :: ereal |
|
41973 | 857 |
shows "x = z - y \<longleftrightarrow> |
41976 | 858 |
(\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y = z) \<and> |
41973 | 859 |
(y = -\<infinity> \<longrightarrow> x = \<infinity>) \<and> |
860 |
(y = \<infinity> \<longrightarrow> z = \<infinity> \<longrightarrow> x = \<infinity>) \<and> |
|
861 |
(y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>)" |
|
43920 | 862 |
by (cases rule: ereal3_cases[of x y z]) auto |
41973 | 863 |
|
43920 | 864 |
lemma ereal_eq_minus: |
865 |
fixes x y z :: ereal |
|
41976 | 866 |
shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x = z - y \<longleftrightarrow> x + y = z" |
43920 | 867 |
by (auto simp: ereal_eq_minus_iff) |
41973 | 868 |
|
43920 | 869 |
lemma ereal_less_minus_iff: |
870 |
fixes x y z :: ereal |
|
41973 | 871 |
shows "x < z - y \<longleftrightarrow> |
872 |
(y = \<infinity> \<longrightarrow> z = \<infinity> \<and> x \<noteq> \<infinity>) \<and> |
|
873 |
(y = -\<infinity> \<longrightarrow> x \<noteq> \<infinity>) \<and> |
|
41976 | 874 |
(\<bar>y\<bar> \<noteq> \<infinity>\<longrightarrow> x + y < z)" |
43920 | 875 |
by (cases rule: ereal3_cases[of x y z]) auto |
41973 | 876 |
|
43920 | 877 |
lemma ereal_less_minus: |
878 |
fixes x y z :: ereal |
|
41976 | 879 |
shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x < z - y \<longleftrightarrow> x + y < z" |
43920 | 880 |
by (auto simp: ereal_less_minus_iff) |
41973 | 881 |
|
43920 | 882 |
lemma ereal_le_minus_iff: |
883 |
fixes x y z :: ereal |
|
41973 | 884 |
shows "x \<le> z - y \<longleftrightarrow> |
885 |
(y = \<infinity> \<longrightarrow> z \<noteq> \<infinity> \<longrightarrow> x = -\<infinity>) \<and> |
|
41976 | 886 |
(\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x + y \<le> z)" |
43920 | 887 |
by (cases rule: ereal3_cases[of x y z]) auto |
41973 | 888 |
|
43920 | 889 |
lemma ereal_le_minus: |
890 |
fixes x y z :: ereal |
|
41976 | 891 |
shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x \<le> z - y \<longleftrightarrow> x + y \<le> z" |
43920 | 892 |
by (auto simp: ereal_le_minus_iff) |
41973 | 893 |
|
43920 | 894 |
lemma ereal_minus_less_iff: |
895 |
fixes x y z :: ereal |
|
41973 | 896 |
shows "x - y < z \<longleftrightarrow> |
897 |
y \<noteq> -\<infinity> \<and> (y = \<infinity> \<longrightarrow> x \<noteq> \<infinity> \<and> z \<noteq> -\<infinity>) \<and> |
|
898 |
(y \<noteq> \<infinity> \<longrightarrow> x < z + y)" |
|
43920 | 899 |
by (cases rule: ereal3_cases[of x y z]) auto |
41973 | 900 |
|
43920 | 901 |
lemma ereal_minus_less: |
902 |
fixes x y z :: ereal |
|
41976 | 903 |
shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y < z \<longleftrightarrow> x < z + y" |
43920 | 904 |
by (auto simp: ereal_minus_less_iff) |
41973 | 905 |
|
43920 | 906 |
lemma ereal_minus_le_iff: |
907 |
fixes x y z :: ereal |
|
41973 | 908 |
shows "x - y \<le> z \<longleftrightarrow> |
909 |
(y = -\<infinity> \<longrightarrow> z = \<infinity>) \<and> |
|
910 |
(y = \<infinity> \<longrightarrow> x = \<infinity> \<longrightarrow> z = \<infinity>) \<and> |
|
41976 | 911 |
(\<bar>y\<bar> \<noteq> \<infinity> \<longrightarrow> x \<le> z + y)" |
43920 | 912 |
by (cases rule: ereal3_cases[of x y z]) auto |
41973 | 913 |
|
43920 | 914 |
lemma ereal_minus_le: |
915 |
fixes x y z :: ereal |
|
41976 | 916 |
shows "\<bar>y\<bar> \<noteq> \<infinity> \<Longrightarrow> x - y \<le> z \<longleftrightarrow> x \<le> z + y" |
43920 | 917 |
by (auto simp: ereal_minus_le_iff) |
41973 | 918 |
|
43920 | 919 |
lemma ereal_minus_eq_minus_iff: |
920 |
fixes a b c :: ereal |
|
41973 | 921 |
shows "a - b = a - c \<longleftrightarrow> |
922 |
b = c \<or> a = \<infinity> \<or> (a = -\<infinity> \<and> b \<noteq> -\<infinity> \<and> c \<noteq> -\<infinity>)" |
|
43920 | 923 |
by (cases rule: ereal3_cases[of a b c]) auto |
41973 | 924 |
|
43920 | 925 |
lemma ereal_add_le_add_iff: |
43923 | 926 |
fixes a b c :: ereal |
927 |
shows "c + a \<le> c + b \<longleftrightarrow> |
|
41973 | 928 |
a \<le> b \<or> c = \<infinity> \<or> (c = -\<infinity> \<and> a \<noteq> \<infinity> \<and> b \<noteq> \<infinity>)" |
43920 | 929 |
by (cases rule: ereal3_cases[of a b c]) (simp_all add: field_simps) |
41973 | 930 |
|
43920 | 931 |
lemma ereal_mult_le_mult_iff: |
43923 | 932 |
fixes a b c :: ereal |
933 |
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 | 934 |
by (cases rule: ereal3_cases[of a b c]) (simp_all add: mult_le_cancel_left) |
41973 | 935 |
|
43920 | 936 |
lemma ereal_minus_mono: |
937 |
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:
41978
diff
changeset
|
938 |
shows "A - C \<le> B - D" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
939 |
using assms |
43920 | 940 |
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:
41978
diff
changeset
|
941 |
|
43920 | 942 |
lemma real_of_ereal_minus: |
43923 | 943 |
fixes a b :: ereal |
944 |
shows "real (a - b) = (if \<bar>a\<bar> = \<infinity> \<or> \<bar>b\<bar> = \<infinity> then 0 else real a - real b)" |
|
43920 | 945 |
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:
41978
diff
changeset
|
946 |
|
43920 | 947 |
lemma ereal_diff_positive: |
948 |
fixes a b :: ereal shows "a \<le> b \<Longrightarrow> 0 \<le> b - a" |
|
949 |
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:
41978
diff
changeset
|
950 |
|
43920 | 951 |
lemma ereal_between: |
952 |
fixes x e :: ereal |
|
41976 | 953 |
assumes "\<bar>x\<bar> \<noteq> \<infinity>" "0 < e" |
41973 | 954 |
shows "x - e < x" "x < x + e" |
955 |
using assms apply (cases x, cases e) apply auto |
|
47082 | 956 |
using assms apply (cases x, cases e) apply auto |
957 |
done |
|
41973 | 958 |
|
50104 | 959 |
lemma ereal_minus_eq_PInfty_iff: |
960 |
fixes x y :: ereal shows "x - y = \<infinity> \<longleftrightarrow> y = -\<infinity> \<or> x = \<infinity>" |
|
961 |
by (cases x y rule: ereal2_cases) simp_all |
|
962 |
||
41973 | 963 |
subsubsection {* Division *} |
964 |
||
43920 | 965 |
instantiation ereal :: inverse |
41973 | 966 |
begin |
967 |
||
43920 | 968 |
function inverse_ereal where |
969 |
"inverse (ereal r) = (if r = 0 then \<infinity> else ereal (inverse r))" | |
|
43923 | 970 |
"inverse (\<infinity>::ereal) = 0" | |
971 |
"inverse (-\<infinity>::ereal) = 0" |
|
43920 | 972 |
by (auto intro: ereal_cases) |
41973 | 973 |
termination by (relation "{}") simp |
974 |
||
43920 | 975 |
definition "x / y = x * inverse (y :: ereal)" |
41973 | 976 |
|
47082 | 977 |
instance .. |
41973 | 978 |
end |
979 |
||
43920 | 980 |
lemma real_of_ereal_inverse[simp]: |
981 |
fixes a :: ereal |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
982 |
shows "real (inverse a) = 1 / real a" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
983 |
by (cases a) (auto simp: inverse_eq_divide) |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
984 |
|
43920 | 985 |
lemma ereal_inverse[simp]: |
43923 | 986 |
"inverse (0::ereal) = \<infinity>" |
43920 | 987 |
"inverse (1::ereal) = 1" |
988 |
by (simp_all add: one_ereal_def zero_ereal_def) |
|
41973 | 989 |
|
43920 | 990 |
lemma ereal_divide[simp]: |
991 |
"ereal r / ereal p = (if p = 0 then ereal r * \<infinity> else ereal (r / p))" |
|
992 |
unfolding divide_ereal_def by (auto simp: divide_real_def) |
|
41973 | 993 |
|
43920 | 994 |
lemma ereal_divide_same[simp]: |
43923 | 995 |
fixes x :: ereal shows "x / x = (if \<bar>x\<bar> = \<infinity> \<or> x = 0 then 0 else 1)" |
41973 | 996 |
by (cases x) |
43920 | 997 |
(simp_all add: divide_real_def divide_ereal_def one_ereal_def) |
41973 | 998 |
|
43920 | 999 |
lemma ereal_inv_inv[simp]: |
43923 | 1000 |
fixes x :: ereal shows "inverse (inverse x) = (if x \<noteq> -\<infinity> then x else \<infinity>)" |
41973 | 1001 |
by (cases x) auto |
1002 |
||
43920 | 1003 |
lemma ereal_inverse_minus[simp]: |
43923 | 1004 |
fixes x :: ereal shows "inverse (- x) = (if x = 0 then \<infinity> else -inverse x)" |
41973 | 1005 |
by (cases x) simp_all |
1006 |
||
43920 | 1007 |
lemma ereal_uminus_divide[simp]: |
1008 |
fixes x y :: ereal shows "- x / y = - (x / y)" |
|
1009 |
unfolding divide_ereal_def by simp |
|
41973 | 1010 |
|
43920 | 1011 |
lemma ereal_divide_Infty[simp]: |
43923 | 1012 |
fixes x :: ereal shows "x / \<infinity> = 0" "x / -\<infinity> = 0" |
43920 | 1013 |
unfolding divide_ereal_def by simp_all |
41973 | 1014 |
|
43920 | 1015 |
lemma ereal_divide_one[simp]: |
1016 |
"x / 1 = (x::ereal)" |
|
1017 |
unfolding divide_ereal_def by simp |
|
41973 | 1018 |
|
43920 | 1019 |
lemma ereal_divide_ereal[simp]: |
1020 |
"\<infinity> / ereal r = (if 0 \<le> r then \<infinity> else -\<infinity>)" |
|
1021 |
unfolding divide_ereal_def by simp |
|
41973 | 1022 |
|
43920 | 1023 |
lemma zero_le_divide_ereal[simp]: |
1024 |
fixes a :: ereal assumes "0 \<le> a" "0 \<le> b" |
|
41978 | 1025 |
shows "0 \<le> a / b" |
43920 | 1026 |
using assms by (cases rule: ereal2_cases[of a b]) (auto simp: zero_le_divide_iff) |
41978 | 1027 |
|
43920 | 1028 |
lemma ereal_le_divide_pos: |
43923 | 1029 |
fixes x y z :: ereal shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> x * y \<le> z" |
43920 | 1030 |
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) |
41973 | 1031 |
|
43920 | 1032 |
lemma ereal_divide_le_pos: |
43923 | 1033 |
fixes x y z :: ereal shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> z \<le> x * y" |
43920 | 1034 |
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) |
41973 | 1035 |
|
43920 | 1036 |
lemma ereal_le_divide_neg: |
43923 | 1037 |
fixes x y z :: ereal shows "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> y \<le> z / x \<longleftrightarrow> z \<le> x * y" |
43920 | 1038 |
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) |
41973 | 1039 |
|
43920 | 1040 |
lemma ereal_divide_le_neg: |
43923 | 1041 |
fixes x y z :: ereal shows "x < 0 \<Longrightarrow> x \<noteq> -\<infinity> \<Longrightarrow> z / x \<le> y \<longleftrightarrow> x * y \<le> z" |
43920 | 1042 |
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) |
41973 | 1043 |
|
43920 | 1044 |
lemma ereal_inverse_antimono_strict: |
1045 |
fixes x y :: ereal |
|
41973 | 1046 |
shows "0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> inverse y < inverse x" |
43920 | 1047 |
by (cases rule: ereal2_cases[of x y]) auto |
41973 | 1048 |
|
43920 | 1049 |
lemma ereal_inverse_antimono: |
1050 |
fixes x y :: ereal |
|
41973 | 1051 |
shows "0 \<le> x \<Longrightarrow> x <= y \<Longrightarrow> inverse y <= inverse x" |
43920 | 1052 |
by (cases rule: ereal2_cases[of x y]) auto |
41973 | 1053 |
|
1054 |
lemma inverse_inverse_Pinfty_iff[simp]: |
|
43923 | 1055 |
fixes x :: ereal shows "inverse x = \<infinity> \<longleftrightarrow> x = 0" |
41973 | 1056 |
by (cases x) auto |
1057 |
||
43920 | 1058 |
lemma ereal_inverse_eq_0: |
43923 | 1059 |
fixes x :: ereal shows "inverse x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity>" |
41973 | 1060 |
by (cases x) auto |
1061 |
||
43920 | 1062 |
lemma ereal_0_gt_inverse: |
1063 |
fixes x :: ereal 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:
41978
diff
changeset
|
1064 |
by (cases x) auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1065 |
|
43920 | 1066 |
lemma ereal_mult_less_right: |
43923 | 1067 |
fixes a b c :: ereal |
41973 | 1068 |
assumes "b * a < c * a" "0 < a" "a < \<infinity>" |
1069 |
shows "b < c" |
|
1070 |
using assms |
|
43920 | 1071 |
by (cases rule: ereal3_cases[of a b c]) |
41973 | 1072 |
(auto split: split_if_asm simp: zero_less_mult_iff zero_le_mult_iff) |
1073 |
||
43920 | 1074 |
lemma ereal_power_divide: |
43923 | 1075 |
fixes x y :: ereal shows "y \<noteq> 0 \<Longrightarrow> (x / y) ^ n = x^n / y^n" |
43920 | 1076 |
by (cases rule: ereal2_cases[of x y]) |
1077 |
(auto simp: one_ereal_def zero_ereal_def power_divide not_le |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1078 |
power_less_zero_eq zero_le_power_iff) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1079 |
|
43920 | 1080 |
lemma ereal_le_mult_one_interval: |
1081 |
fixes x y :: ereal |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1082 |
assumes y: "y \<noteq> -\<infinity>" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1083 |
assumes z: "\<And>z. \<lbrakk> 0 < z ; z < 1 \<rbrakk> \<Longrightarrow> z * x \<le> y" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1084 |
shows "x \<le> y" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1085 |
proof (cases x) |
43920 | 1086 |
case PInf with z[of "1 / 2"] show "x \<le> y" by (simp add: one_ereal_def) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1087 |
next |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1088 |
case (real r) note r = this |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1089 |
show "x \<le> y" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1090 |
proof (cases y) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1091 |
case (real p) note p = this |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1092 |
have "r \<le> p" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1093 |
proof (rule field_le_mult_one_interval) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1094 |
fix z :: real assume "0 < z" and "z < 1" |
43920 | 1095 |
with z[of "ereal z"] |
1096 |
show "z * r \<le> p" 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:
41978
diff
changeset
|
1097 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1098 |
then show "x \<le> y" using p r by simp |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1099 |
qed (insert y, simp_all) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1100 |
qed simp |
41978 | 1101 |
|
45934 | 1102 |
lemma ereal_divide_right_mono[simp]: |
1103 |
fixes x y z :: ereal |
|
1104 |
assumes "x \<le> y" "0 < z" shows "x / z \<le> y / z" |
|
1105 |
using assms by (cases x y z rule: ereal3_cases) (auto intro: divide_right_mono) |
|
1106 |
||
1107 |
lemma ereal_divide_left_mono[simp]: |
|
1108 |
fixes x y z :: ereal |
|
1109 |
assumes "y \<le> x" "0 < z" "0 < x * y" |
|
1110 |
shows "z / x \<le> z / y" |
|
1111 |
using assms by (cases x y z rule: ereal3_cases) |
|
1112 |
(auto intro: divide_left_mono simp: field_simps sign_simps split: split_if_asm) |
|
1113 |
||
1114 |
lemma ereal_divide_zero_left[simp]: |
|
1115 |
fixes a :: ereal |
|
1116 |
shows "0 / a = 0" |
|
1117 |
by (cases a) (auto simp: zero_ereal_def) |
|
1118 |
||
1119 |
lemma ereal_times_divide_eq_left[simp]: |
|
1120 |
fixes a b c :: ereal |
|
1121 |
shows "b / c * a = b * a / c" |
|
1122 |
by (cases a b c rule: ereal3_cases) (auto simp: field_simps sign_simps) |
|
1123 |
||
41973 | 1124 |
subsection "Complete lattice" |
1125 |
||
43920 | 1126 |
instantiation ereal :: lattice |
41973 | 1127 |
begin |
43920 | 1128 |
definition [simp]: "sup x y = (max x y :: ereal)" |
1129 |
definition [simp]: "inf x y = (min x y :: ereal)" |
|
47082 | 1130 |
instance by default simp_all |
41973 | 1131 |
end |
1132 |
||
43920 | 1133 |
instantiation ereal :: complete_lattice |
41973 | 1134 |
begin |
1135 |
||
43923 | 1136 |
definition "bot = (-\<infinity>::ereal)" |
1137 |
definition "top = (\<infinity>::ereal)" |
|
41973 | 1138 |
|
43923 | 1139 |
definition "Sup S = (LEAST z. \<forall>x\<in>S. x \<le> z :: ereal)" |
1140 |
definition "Inf S = (GREATEST z. \<forall>x\<in>S. z \<le> x :: ereal)" |
|
41973 | 1141 |
|
43920 | 1142 |
lemma ereal_complete_Sup: |
1143 |
fixes S :: "ereal set" assumes "S \<noteq> {}" |
|
41973 | 1144 |
shows "\<exists>x. (\<forall>y\<in>S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>S. y \<le> z) \<longrightarrow> x \<le> z)" |
1145 |
proof cases |
|
43920 | 1146 |
assume "\<exists>x. \<forall>a\<in>S. a \<le> ereal x" |
1147 |
then obtain y where y: "\<And>a. a\<in>S \<Longrightarrow> a \<le> ereal y" by auto |
|
41973 | 1148 |
then have "\<infinity> \<notin> S" by force |
1149 |
show ?thesis |
|
1150 |
proof cases |
|
1151 |
assume "S = {-\<infinity>}" |
|
1152 |
then show ?thesis by (auto intro!: exI[of _ "-\<infinity>"]) |
|
1153 |
next |
|
1154 |
assume "S \<noteq> {-\<infinity>}" |
|
1155 |
with `S \<noteq> {}` `\<infinity> \<notin> S` obtain x where "x \<in> S - {-\<infinity>}" "x \<noteq> \<infinity>" by auto |
|
1156 |
with y `\<infinity> \<notin> S` have "\<forall>z\<in>real ` (S - {-\<infinity>}). z \<le> y" |
|
43920 | 1157 |
by (auto simp: real_of_ereal_ord_simps) |
44669
8e6cdb9c00a7
remove redundant lemma reals_complete2 in favor of complete_real
huffman
parents:
44520
diff
changeset
|
1158 |
with complete_real[of "real ` (S - {-\<infinity>})"] `x \<in> S - {-\<infinity>}` |
41973 | 1159 |
obtain s where s: |
1160 |
"\<forall>y\<in>S - {-\<infinity>}. real y \<le> s" "\<And>z. (\<forall>y\<in>S - {-\<infinity>}. real y \<le> z) \<Longrightarrow> s \<le> z" |
|
1161 |
by auto |
|
1162 |
show ?thesis |
|
43920 | 1163 |
proof (safe intro!: exI[of _ "ereal s"]) |
1164 |
fix z assume "z \<in> S" with `\<infinity> \<notin> S` show "z \<le> ereal s" |
|
41973 | 1165 |
proof (cases z) |
1166 |
case (real r) |
|
1167 |
then show ?thesis |
|
43920 | 1168 |
using s(1)[rule_format, of z] `z \<in> S` `z = ereal r` by auto |
41973 | 1169 |
qed auto |
1170 |
next |
|
1171 |
fix z assume *: "\<forall>y\<in>S. y \<le> z" |
|
43920 | 1172 |
with `S \<noteq> {-\<infinity>}` `S \<noteq> {}` show "ereal s \<le> z" |
41973 | 1173 |
proof (cases z) |
1174 |
case (real u) |
|
1175 |
with * have "s \<le> u" |
|
43920 | 1176 |
by (intro s(2)[of u]) (auto simp: real_of_ereal_ord_simps) |
41973 | 1177 |
then show ?thesis using real by simp |
1178 |
qed auto |
|
1179 |
qed |
|
1180 |
qed |
|
1181 |
next |
|
43920 | 1182 |
assume *: "\<not> (\<exists>x. \<forall>a\<in>S. a \<le> ereal x)" |
41973 | 1183 |
show ?thesis |
1184 |
proof (safe intro!: exI[of _ \<infinity>]) |
|
1185 |
fix y assume **: "\<forall>z\<in>S. z \<le> y" |
|
1186 |
with * show "\<infinity> \<le> y" |
|
1187 |
proof (cases y) |
|
1188 |
case MInf with * ** show ?thesis by (force simp: not_le) |
|
1189 |
qed auto |
|
1190 |
qed simp |
|
1191 |
qed |
|
1192 |
||
43920 | 1193 |
lemma ereal_complete_Inf: |
1194 |
fixes S :: "ereal set" assumes "S ~= {}" |
|
41973 | 1195 |
shows "EX x. (ALL y:S. x <= y) & (ALL z. (ALL y:S. z <= y) --> z <= x)" |
1196 |
proof- |
|
1197 |
def S1 == "uminus ` S" |
|
1198 |
hence "S1 ~= {}" using assms by auto |
|
47082 | 1199 |
then obtain x where x_def: "(ALL y:S1. y <= x) & (ALL z. (ALL y:S1. y <= z) --> x <= z)" |
43920 | 1200 |
using ereal_complete_Sup[of S1] by auto |
41973 | 1201 |
{ fix z assume "ALL y:S. z <= y" |
1202 |
hence "ALL y:S1. y <= -z" unfolding S1_def by auto |
|
1203 |
hence "x <= -z" using x_def by auto |
|
1204 |
hence "z <= -x" |
|
43920 | 1205 |
apply (subst ereal_uminus_uminus[symmetric]) |
1206 |
unfolding ereal_minus_le_minus . } |
|
41973 | 1207 |
moreover have "(ALL y:S. -x <= y)" |
1208 |
using x_def unfolding S1_def |
|
1209 |
apply simp |
|
43920 | 1210 |
apply (subst (3) ereal_uminus_uminus[symmetric]) |
1211 |
unfolding ereal_minus_le_minus by simp |
|
41973 | 1212 |
ultimately show ?thesis by auto |
1213 |
qed |
|
1214 |
||
43920 | 1215 |
lemma ereal_complete_uminus_eq: |
1216 |
fixes S :: "ereal set" |
|
41973 | 1217 |
shows "(\<forall>y\<in>uminus`S. y \<le> x) \<and> (\<forall>z. (\<forall>y\<in>uminus`S. y \<le> z) \<longrightarrow> x \<le> z) |
1218 |
\<longleftrightarrow> (\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> -x)" |
|
43920 | 1219 |
by simp (metis ereal_minus_le_minus ereal_uminus_uminus) |
41973 | 1220 |
|
43920 | 1221 |
lemma ereal_Sup_uminus_image_eq: |
1222 |
fixes S :: "ereal set" |
|
41973 | 1223 |
shows "Sup (uminus ` S) = - Inf S" |
1224 |
proof cases |
|
1225 |
assume "S = {}" |
|
43920 | 1226 |
moreover have "(THE x. All (op \<le> x)) = (-\<infinity>::ereal)" |
1227 |
by (rule the_equality) (auto intro!: ereal_bot) |
|
1228 |
moreover have "(SOME x. \<forall>y. y \<le> x) = (\<infinity>::ereal)" |
|
1229 |
by (rule some_equality) (auto intro!: ereal_top) |
|
1230 |
ultimately show ?thesis unfolding Inf_ereal_def Sup_ereal_def |
|
41973 | 1231 |
Least_def Greatest_def GreatestM_def by simp |
1232 |
next |
|
1233 |
assume "S \<noteq> {}" |
|
43920 | 1234 |
with ereal_complete_Sup[of "uminus`S"] |
41973 | 1235 |
obtain x where x: "(\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>z. (\<forall>y\<in>S. z \<le> y) \<longrightarrow> z \<le> -x)" |
43920 | 1236 |
unfolding ereal_complete_uminus_eq by auto |
41973 | 1237 |
show "Sup (uminus ` S) = - Inf S" |
43920 | 1238 |
unfolding Inf_ereal_def Greatest_def GreatestM_def |
41973 | 1239 |
proof (intro someI2[of _ _ "\<lambda>x. Sup (uminus`S) = - x"]) |
1240 |
show "(\<forall>y\<in>S. -x \<le> y) \<and> (\<forall>y. (\<forall>z\<in>S. y \<le> z) \<longrightarrow> y \<le> -x)" |
|
1241 |
using x . |
|
1242 |
fix x' assume "(\<forall>y\<in>S. x' \<le> y) \<and> (\<forall>y. (\<forall>z\<in>S. y \<le> z) \<longrightarrow> y \<le> x')" |
|
1243 |
then have "(\<forall>y\<in>uminus`S. y \<le> - x') \<and> (\<forall>y. (\<forall>z\<in>uminus`S. z \<le> y) \<longrightarrow> - x' \<le> y)" |
|
43920 | 1244 |
unfolding ereal_complete_uminus_eq by simp |
41973 | 1245 |
then show "Sup (uminus ` S) = -x'" |
43920 | 1246 |
unfolding Sup_ereal_def ereal_uminus_eq_iff |
41973 | 1247 |
by (intro Least_equality) auto |
1248 |
qed |
|
1249 |
qed |
|
1250 |
||
1251 |
instance |
|
1252 |
proof |
|
43920 | 1253 |
{ fix x :: ereal and A |
1254 |
show "bot <= x" by (cases x) (simp_all add: bot_ereal_def) |
|
1255 |
show "x <= top" by (simp add: top_ereal_def) } |
|
41973 | 1256 |
|
43920 | 1257 |
{ fix x :: ereal and A assume "x : A" |
1258 |
with ereal_complete_Sup[of A] |
|
41973 | 1259 |
obtain s where s: "\<forall>y\<in>A. y <= s" "\<forall>z. (\<forall>y\<in>A. y <= z) \<longrightarrow> s <= z" by auto |
1260 |
hence "x <= s" using `x : A` by auto |
|
43920 | 1261 |
also have "... = Sup A" using s unfolding Sup_ereal_def |
41973 | 1262 |
by (auto intro!: Least_equality[symmetric]) |
1263 |
finally show "x <= Sup A" . } |
|
1264 |
note le_Sup = this |
|
1265 |
||
43920 | 1266 |
{ fix x :: ereal and A assume *: "!!z. (z : A ==> z <= x)" |
41973 | 1267 |
show "Sup A <= x" |
1268 |
proof (cases "A = {}") |
|
1269 |
case True |
|
43920 | 1270 |
hence "Sup A = -\<infinity>" unfolding Sup_ereal_def |
41973 | 1271 |
by (auto intro!: Least_equality) |
1272 |
thus "Sup A <= x" by simp |
|
1273 |
next |
|
1274 |
case False |
|
43920 | 1275 |
with ereal_complete_Sup[of A] |
41973 | 1276 |
obtain s where s: "\<forall>y\<in>A. y <= s" "\<forall>z. (\<forall>y\<in>A. y <= z) \<longrightarrow> s <= z" by auto |
1277 |
hence "Sup A = s" |
|
43920 | 1278 |
unfolding Sup_ereal_def by (auto intro!: Least_equality) |
41973 | 1279 |
also have "s <= x" using * s by auto |
1280 |
finally show "Sup A <= x" . |
|
1281 |
qed } |
|
1282 |
note Sup_le = this |
|
1283 |
||
43920 | 1284 |
{ fix x :: ereal and A assume "x \<in> A" |
41973 | 1285 |
with le_Sup[of "-x" "uminus`A"] show "Inf A \<le> x" |
43920 | 1286 |
unfolding ereal_Sup_uminus_image_eq by simp } |
41973 | 1287 |
|
43920 | 1288 |
{ fix x :: ereal and A assume *: "!!z. (z : A ==> x <= z)" |
41973 | 1289 |
with Sup_le[of "uminus`A" "-x"] show "x \<le> Inf A" |
43920 | 1290 |
unfolding ereal_Sup_uminus_image_eq by force } |
41973 | 1291 |
qed |
43941 | 1292 |
|
41973 | 1293 |
end |
1294 |
||
43941 | 1295 |
instance ereal :: complete_linorder .. |
1296 |
||
43920 | 1297 |
lemma ereal_SUPR_uminus: |
1298 |
fixes f :: "'a => ereal" |
|
41973 | 1299 |
shows "(SUP i : R. -(f i)) = -(INF i : R. f i)" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1300 |
unfolding SUP_def INF_def |
43920 | 1301 |
using ereal_Sup_uminus_image_eq[of "f`R"] |
41973 | 1302 |
by (simp add: image_image) |
1303 |
||
43920 | 1304 |
lemma ereal_INFI_uminus: |
1305 |
fixes f :: "'a => ereal" |
|
41973 | 1306 |
shows "(INF i : R. -(f i)) = -(SUP i : R. f i)" |
43920 | 1307 |
using ereal_SUPR_uminus[of _ "\<lambda>x. - f x"] by simp |
41973 | 1308 |
|
43920 | 1309 |
lemma ereal_Inf_uminus_image_eq: "Inf (uminus ` S) = - Sup (S::ereal set)" |
1310 |
using ereal_Sup_uminus_image_eq[of "uminus ` S"] by (simp add: image_image) |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1311 |
|
43920 | 1312 |
lemma ereal_inj_on_uminus[intro, simp]: "inj_on uminus (A :: ereal set)" |
41973 | 1313 |
by (auto intro!: inj_onI) |
1314 |
||
43920 | 1315 |
lemma ereal_image_uminus_shift: |
1316 |
fixes X Y :: "ereal set" shows "uminus ` X = Y \<longleftrightarrow> X = uminus ` Y" |
|
41973 | 1317 |
proof |
1318 |
assume "uminus ` X = Y" |
|
1319 |
then have "uminus ` uminus ` X = uminus ` Y" |
|
1320 |
by (simp add: inj_image_eq_iff) |
|
1321 |
then show "X = uminus ` Y" by (simp add: image_image) |
|
1322 |
qed (simp add: image_image) |
|
1323 |
||
43920 | 1324 |
lemma Inf_ereal_iff: |
1325 |
fixes z :: ereal |
|
41973 | 1326 |
shows "(!!x. x:X ==> z <= x) ==> (EX x:X. x<y) <-> Inf X < y" |
1327 |
by (metis complete_lattice_class.Inf_greatest complete_lattice_class.Inf_lower less_le_not_le linear |
|
1328 |
order_less_le_trans) |
|
1329 |
||
1330 |
lemma Sup_eq_MInfty: |
|
43920 | 1331 |
fixes S :: "ereal set" shows "Sup S = -\<infinity> \<longleftrightarrow> S = {} \<or> S = {-\<infinity>}" |
41973 | 1332 |
proof |
1333 |
assume a: "Sup S = -\<infinity>" |
|
1334 |
with complete_lattice_class.Sup_upper[of _ S] |
|
1335 |
show "S={} \<or> S={-\<infinity>}" by auto |
|
1336 |
next |
|
1337 |
assume "S={} \<or> S={-\<infinity>}" then show "Sup S = -\<infinity>" |
|
43920 | 1338 |
unfolding Sup_ereal_def by (auto intro!: Least_equality) |
41973 | 1339 |
qed |
1340 |
||
1341 |
lemma Inf_eq_PInfty: |
|
43920 | 1342 |
fixes S :: "ereal set" shows "Inf S = \<infinity> \<longleftrightarrow> S = {} \<or> S = {\<infinity>}" |
41973 | 1343 |
using Sup_eq_MInfty[of "uminus`S"] |
43920 | 1344 |
unfolding ereal_Sup_uminus_image_eq ereal_image_uminus_shift by simp |
41973 | 1345 |
|
43923 | 1346 |
lemma Inf_eq_MInfty: |
1347 |
fixes S :: "ereal set" shows "-\<infinity> \<in> S \<Longrightarrow> Inf S = -\<infinity>" |
|
43920 | 1348 |
unfolding Inf_ereal_def |
41973 | 1349 |
by (auto intro!: Greatest_equality) |
1350 |
||
43923 | 1351 |
lemma Sup_eq_PInfty: |
1352 |
fixes S :: "ereal set" shows "\<infinity> \<in> S \<Longrightarrow> Sup S = \<infinity>" |
|
43920 | 1353 |
unfolding Sup_ereal_def |
41973 | 1354 |
by (auto intro!: Least_equality) |
1355 |
||
43920 | 1356 |
lemma ereal_SUPI: |
1357 |
fixes x :: ereal |
|
41973 | 1358 |
assumes "!!i. i : A ==> f i <= x" |
1359 |
assumes "!!y. (!!i. i : A ==> f i <= y) ==> x <= y" |
|
1360 |
shows "(SUP i:A. f i) = x" |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1361 |
unfolding SUP_def Sup_ereal_def |
41973 | 1362 |
using assms by (auto intro!: Least_equality) |
1363 |
||
43920 | 1364 |
lemma ereal_INFI: |
1365 |
fixes x :: ereal |
|
41973 | 1366 |
assumes "!!i. i : A ==> f i >= x" |
1367 |
assumes "!!y. (!!i. i : A ==> f i >= y) ==> x >= y" |
|
1368 |
shows "(INF i:A. f i) = x" |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1369 |
unfolding INF_def Inf_ereal_def |
41973 | 1370 |
using assms by (auto intro!: Greatest_equality) |
1371 |
||
43920 | 1372 |
lemma Sup_ereal_close: |
1373 |
fixes e :: ereal |
|
41976 | 1374 |
assumes "0 < e" and S: "\<bar>Sup S\<bar> \<noteq> \<infinity>" "S \<noteq> {}" |
41973 | 1375 |
shows "\<exists>x\<in>S. Sup S - e < x" |
41976 | 1376 |
using assms by (cases e) (auto intro!: less_Sup_iff[THEN iffD1]) |
41973 | 1377 |
|
43920 | 1378 |
lemma Inf_ereal_close: |
1379 |
fixes e :: ereal assumes "\<bar>Inf X\<bar> \<noteq> \<infinity>" "0 < e" |
|
41973 | 1380 |
shows "\<exists>x\<in>X. x < Inf X + e" |
1381 |
proof (rule Inf_less_iff[THEN iffD1]) |
|
1382 |
show "Inf X < Inf X + e" using assms |
|
41976 | 1383 |
by (cases e) auto |
41973 | 1384 |
qed |
1385 |
||
43920 | 1386 |
lemma SUP_nat_Infty: "(SUP i::nat. ereal (real i)) = \<infinity>" |
41973 | 1387 |
proof - |
43923 | 1388 |
{ fix x ::ereal assume "x \<noteq> \<infinity>" |
43920 | 1389 |
then have "\<exists>k::nat. x < ereal (real k)" |
41973 | 1390 |
proof (cases x) |
1391 |
case MInf then show ?thesis by (intro exI[of _ 0]) auto |
|
1392 |
next |
|
1393 |
case (real r) |
|
1394 |
moreover obtain k :: nat where "r < real k" |
|
1395 |
using ex_less_of_nat by (auto simp: real_eq_of_nat) |
|
1396 |
ultimately show ?thesis by auto |
|
1397 |
qed simp } |
|
1398 |
then show ?thesis |
|
43920 | 1399 |
using SUP_eq_top_iff[of UNIV "\<lambda>n::nat. ereal (real n)"] |
1400 |
by (auto simp: top_ereal_def) |
|
41973 | 1401 |
qed |
1402 |
||
43920 | 1403 |
lemma ereal_le_Sup: |
1404 |
fixes x :: ereal |
|
41973 | 1405 |
shows "(x <= (SUP i:A. f i)) <-> (ALL y. y < x --> (EX i. i : A & y <= f i))" |
1406 |
(is "?lhs <-> ?rhs") |
|
1407 |
proof- |
|
1408 |
{ assume "?rhs" |
|
1409 |
{ assume "~(x <= (SUP i:A. f i))" hence "(SUP i:A. f i)<x" by (simp add: not_le) |
|
47082 | 1410 |
then obtain y where y_def: "(SUP i:A. f i)<y & y<x" using ereal_dense by auto |
1411 |
then obtain i where "i : A & y <= f i" using `?rhs` by auto |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1412 |
hence "y <= (SUP i:A. f i)" using SUP_upper[of i A f] by auto |
41973 | 1413 |
hence False using y_def by auto |
1414 |
} hence "?lhs" by auto |
|
1415 |
} |
|
1416 |
moreover |
|
1417 |
{ assume "?lhs" hence "?rhs" |
|
45236
ac4a2a66707d
replacing metis proofs with facts xt1 by new proof with more readable names
bulwahn
parents:
45036
diff
changeset
|
1418 |
by (metis less_SUP_iff order_less_imp_le order_less_le_trans) |
41973 | 1419 |
} ultimately show ?thesis by auto |
1420 |
qed |
|
1421 |
||
43920 | 1422 |
lemma ereal_Inf_le: |
1423 |
fixes x :: ereal |
|
41973 | 1424 |
shows "((INF i:A. f i) <= x) <-> (ALL y. x < y --> (EX i. i : A & f i <= y))" |
1425 |
(is "?lhs <-> ?rhs") |
|
1426 |
proof- |
|
1427 |
{ assume "?rhs" |
|
1428 |
{ assume "~((INF i:A. f i) <= x)" hence "x < (INF i:A. f i)" by (simp add: not_le) |
|
47082 | 1429 |
then obtain y where y_def: "x<y & y<(INF i:A. f i)" using ereal_dense by auto |
1430 |
then obtain i where "i : A & f i <= y" using `?rhs` by auto |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1431 |
hence "(INF i:A. f i) <= y" using INF_lower[of i A f] by auto |
41973 | 1432 |
hence False using y_def by auto |
1433 |
} hence "?lhs" by auto |
|
1434 |
} |
|
1435 |
moreover |
|
1436 |
{ assume "?lhs" hence "?rhs" |
|
45236
ac4a2a66707d
replacing metis proofs with facts xt1 by new proof with more readable names
bulwahn
parents:
45036
diff
changeset
|
1437 |
by (metis INF_less_iff order_le_less order_less_le_trans) |
41973 | 1438 |
} ultimately show ?thesis by auto |
1439 |
qed |
|
1440 |
||
1441 |
lemma Inf_less: |
|
43920 | 1442 |
fixes x :: ereal |
41973 | 1443 |
assumes "(INF i:A. f i) < x" |
1444 |
shows "EX i. i : A & f i <= x" |
|
1445 |
proof(rule ccontr) |
|
1446 |
assume "~ (EX i. i : A & f i <= x)" |
|
1447 |
hence "ALL i:A. f i > x" by auto |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1448 |
hence "(INF i:A. f i) >= x" apply (subst INF_greatest) by auto |
41973 | 1449 |
thus False using assms by auto |
1450 |
qed |
|
1451 |
||
1452 |
lemma same_INF: |
|
1453 |
assumes "ALL e:A. f e = g e" |
|
1454 |
shows "(INF e:A. f e) = (INF e:A. g e)" |
|
1455 |
proof- |
|
1456 |
have "f ` A = g ` A" unfolding image_def using assms by auto |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1457 |
thus ?thesis unfolding INF_def by auto |
41973 | 1458 |
qed |
1459 |
||
1460 |
lemma same_SUP: |
|
1461 |
assumes "ALL e:A. f e = g e" |
|
1462 |
shows "(SUP e:A. f e) = (SUP e:A. g e)" |
|
1463 |
proof- |
|
1464 |
have "f ` A = g ` A" unfolding image_def using assms by auto |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1465 |
thus ?thesis unfolding SUP_def by auto |
41973 | 1466 |
qed |
1467 |
||
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1468 |
lemma SUPR_eq: |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1469 |
assumes "\<forall>i\<in>A. \<exists>j\<in>B. f i \<le> g j" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1470 |
assumes "\<forall>j\<in>B. \<exists>i\<in>A. g j \<le> f i" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1471 |
shows "(SUP i:A. f i) = (SUP j:B. g j)" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1472 |
proof (intro antisym) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1473 |
show "(SUP i:A. f i) \<le> (SUP j:B. g j)" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1474 |
using assms by (metis SUP_least SUP_upper2) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1475 |
show "(SUP i:B. g i) \<le> (SUP j:A. f j)" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1476 |
using assms by (metis SUP_least SUP_upper2) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1477 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1478 |
|
43920 | 1479 |
lemma SUP_ereal_le_addI: |
43923 | 1480 |
fixes f :: "'i \<Rightarrow> ereal" |
41978 | 1481 |
assumes "\<And>i. f i + y \<le> z" and "y \<noteq> -\<infinity>" |
1482 |
shows "SUPR UNIV f + y \<le> z" |
|
1483 |
proof (cases y) |
|
1484 |
case (real r) |
|
43920 | 1485 |
then have "\<And>i. f i \<le> z - y" using assms by (simp add: ereal_le_minus_iff) |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1486 |
then have "SUPR UNIV f \<le> z - y" by (rule SUP_least) |
43920 | 1487 |
then show ?thesis using real by (simp add: ereal_le_minus_iff) |
41978 | 1488 |
qed (insert assms, auto) |
1489 |
||
43920 | 1490 |
lemma SUPR_ereal_add: |
1491 |
fixes f g :: "nat \<Rightarrow> ereal" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1492 |
assumes "incseq f" "incseq g" and pos: "\<And>i. f i \<noteq> -\<infinity>" "\<And>i. g i \<noteq> -\<infinity>" |
41978 | 1493 |
shows "(SUP i. f i + g i) = SUPR UNIV f + SUPR UNIV g" |
43920 | 1494 |
proof (rule ereal_SUPI) |
41978 | 1495 |
fix y assume *: "\<And>i. i \<in> UNIV \<Longrightarrow> f i + g i \<le> y" |
1496 |
have f: "SUPR UNIV f \<noteq> -\<infinity>" using pos |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1497 |
unfolding SUP_def Sup_eq_MInfty by (auto dest: image_eqD) |
41978 | 1498 |
{ fix j |
1499 |
{ fix i |
|
1500 |
have "f i + g j \<le> f i + g (max i j)" |
|
1501 |
using `incseq g`[THEN incseqD] by (rule add_left_mono) auto |
|
1502 |
also have "\<dots> \<le> f (max i j) + g (max i j)" |
|
1503 |
using `incseq f`[THEN incseqD] by (rule add_right_mono) auto |
|
1504 |
also have "\<dots> \<le> y" using * by auto |
|
1505 |
finally have "f i + g j \<le> y" . } |
|
1506 |
then have "SUPR UNIV f + g j \<le> y" |
|
43920 | 1507 |
using assms(4)[of j] by (intro SUP_ereal_le_addI) auto |
41978 | 1508 |
then have "g j + SUPR UNIV f \<le> y" by (simp add: ac_simps) } |
1509 |
then have "SUPR UNIV g + SUPR UNIV f \<le> y" |
|
43920 | 1510 |
using f by (rule SUP_ereal_le_addI) |
41978 | 1511 |
then show "SUPR UNIV f + SUPR UNIV g \<le> y" by (simp add: ac_simps) |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1512 |
qed (auto intro!: add_mono SUP_upper) |
41978 | 1513 |
|
43920 | 1514 |
lemma SUPR_ereal_add_pos: |
1515 |
fixes f g :: "nat \<Rightarrow> ereal" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1516 |
assumes inc: "incseq f" "incseq g" and pos: "\<And>i. 0 \<le> f i" "\<And>i. 0 \<le> g i" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1517 |
shows "(SUP i. f i + g i) = SUPR UNIV f + SUPR UNIV g" |
43920 | 1518 |
proof (intro SUPR_ereal_add inc) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1519 |
fix i show "f i \<noteq> -\<infinity>" "g i \<noteq> -\<infinity>" using pos[of i] by auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1520 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1521 |
|
43920 | 1522 |
lemma SUPR_ereal_setsum: |
1523 |
fixes f g :: "'a \<Rightarrow> nat \<Rightarrow> ereal" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1524 |
assumes "\<And>n. n \<in> A \<Longrightarrow> incseq (f n)" and pos: "\<And>n i. n \<in> A \<Longrightarrow> 0 \<le> f n i" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1525 |
shows "(SUP i. \<Sum>n\<in>A. f n i) = (\<Sum>n\<in>A. SUPR UNIV (f n))" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1526 |
proof cases |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1527 |
assume "finite A" then show ?thesis using assms |
43920 | 1528 |
by induct (auto simp: incseq_setsumI2 setsum_nonneg SUPR_ereal_add_pos) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1529 |
qed simp |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1530 |
|
43920 | 1531 |
lemma SUPR_ereal_cmult: |
1532 |
fixes f :: "nat \<Rightarrow> ereal" assumes "\<And>i. 0 \<le> f i" "0 \<le> c" |
|
41978 | 1533 |
shows "(SUP i. c * f i) = c * SUPR UNIV f" |
43920 | 1534 |
proof (rule ereal_SUPI) |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1535 |
fix i have "f i \<le> SUPR UNIV f" by (rule SUP_upper) auto |
41978 | 1536 |
then show "c * f i \<le> c * SUPR UNIV f" |
43920 | 1537 |
using `0 \<le> c` by (rule ereal_mult_left_mono) |
41978 | 1538 |
next |
1539 |
fix y assume *: "\<And>i. i \<in> UNIV \<Longrightarrow> c * f i \<le> y" |
|
1540 |
show "c * SUPR UNIV f \<le> y" |
|
1541 |
proof cases |
|
1542 |
assume c: "0 < c \<and> c \<noteq> \<infinity>" |
|
1543 |
with * have "SUPR UNIV f \<le> y / c" |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1544 |
by (intro SUP_least) (auto simp: ereal_le_divide_pos) |
41978 | 1545 |
with c show ?thesis |
43920 | 1546 |
by (auto simp: ereal_le_divide_pos) |
41978 | 1547 |
next |
1548 |
{ assume "c = \<infinity>" have ?thesis |
|
1549 |
proof cases |
|
1550 |
assume "\<forall>i. f i = 0" |
|
1551 |
moreover then have "range f = {0}" by auto |
|
44918 | 1552 |
ultimately show "c * SUPR UNIV f \<le> y" using * |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1553 |
by (auto simp: SUP_def min_max.sup_absorb1) |
41978 | 1554 |
next |
1555 |
assume "\<not> (\<forall>i. f i = 0)" |
|
1556 |
then obtain i where "f i \<noteq> 0" by auto |
|
1557 |
with *[of i] `c = \<infinity>` `0 \<le> f i` show ?thesis by (auto split: split_if_asm) |
|
1558 |
qed } |
|
1559 |
moreover assume "\<not> (0 < c \<and> c \<noteq> \<infinity>)" |
|
1560 |
ultimately show ?thesis using * `0 \<le> c` by auto |
|
1561 |
qed |
|
1562 |
qed |
|
1563 |
||
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1564 |
lemma SUP_PInfty: |
43920 | 1565 |
fixes f :: "'a \<Rightarrow> ereal" |
1566 |
assumes "\<And>n::nat. \<exists>i\<in>A. ereal (real n) \<le> f i" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1567 |
shows "(SUP i:A. f i) = \<infinity>" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1568 |
unfolding SUP_def Sup_eq_top_iff[where 'a=ereal, unfolded top_ereal_def] |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1569 |
apply simp |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1570 |
proof safe |
43923 | 1571 |
fix x :: ereal assume "x \<noteq> \<infinity>" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1572 |
show "\<exists>i\<in>A. x < f i" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1573 |
proof (cases x) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1574 |
case PInf with `x \<noteq> \<infinity>` show ?thesis by simp |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1575 |
next |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1576 |
case MInf with assms[of "0"] show ?thesis by force |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1577 |
next |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1578 |
case (real r) |
43920 | 1579 |
with less_PInf_Ex_of_nat[of x] obtain n :: nat where "x < ereal (real n)" by auto |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1580 |
moreover from assms[of n] guess i .. |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1581 |
ultimately show ?thesis |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1582 |
by (auto intro!: bexI[of _ i]) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1583 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1584 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1585 |
|
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1586 |
lemma Sup_countable_SUPR: |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1587 |
assumes "A \<noteq> {}" |
43920 | 1588 |
shows "\<exists>f::nat \<Rightarrow> ereal. range f \<subseteq> A \<and> Sup A = SUPR UNIV f" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1589 |
proof (cases "Sup A") |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1590 |
case (real r) |
43920 | 1591 |
have "\<forall>n::nat. \<exists>x. x \<in> A \<and> Sup A < x + 1 / ereal (real n)" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1592 |
proof |
43920 | 1593 |
fix n ::nat have "\<exists>x\<in>A. Sup A - 1 / ereal (real n) < x" |
1594 |
using assms real by (intro Sup_ereal_close) (auto simp: one_ereal_def) |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1595 |
then guess x .. |
43920 | 1596 |
then show "\<exists>x. x \<in> A \<and> Sup A < x + 1 / ereal (real n)" |
1597 |
by (auto intro!: exI[of _ x] simp: ereal_minus_less_iff) |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1598 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1599 |
from choice[OF this] guess f .. note f = this |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1600 |
have "SUPR UNIV f = Sup A" |
43920 | 1601 |
proof (rule ereal_SUPI) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1602 |
fix i show "f i \<le> Sup A" using f |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1603 |
by (auto intro!: complete_lattice_class.Sup_upper) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1604 |
next |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1605 |
fix y assume bound: "\<And>i. i \<in> UNIV \<Longrightarrow> f i \<le> y" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1606 |
show "Sup A \<le> y" |
43920 | 1607 |
proof (rule ereal_le_epsilon, intro allI impI) |
1608 |
fix e :: ereal assume "0 < e" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1609 |
show "Sup A \<le> y + e" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1610 |
proof (cases e) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1611 |
case (real r) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1612 |
hence "0 < r" using `0 < e` by auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1613 |
then obtain n ::nat where *: "1 / real n < r" "0 < n" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1614 |
using ex_inverse_of_nat_less by (auto simp: real_eq_of_nat inverse_eq_divide) |
44918 | 1615 |
have "Sup A \<le> f n + 1 / ereal (real n)" using f[THEN spec, of n] |
1616 |
by auto |
|
43920 | 1617 |
also have "1 / ereal (real n) \<le> e" using real * by (auto simp: one_ereal_def ) |
1618 |
with bound have "f n + 1 / ereal (real n) \<le> y + e" by (rule add_mono) simp |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1619 |
finally show "Sup A \<le> y + e" . |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1620 |
qed (insert `0 < e`, auto) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1621 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1622 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1623 |
with f show ?thesis by (auto intro!: exI[of _ f]) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1624 |
next |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1625 |
case PInf |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1626 |
from `A \<noteq> {}` obtain x where "x \<in> A" by auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1627 |
show ?thesis |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1628 |
proof cases |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1629 |
assume "\<infinity> \<in> A" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1630 |
moreover then have "\<infinity> \<le> Sup A" by (intro complete_lattice_class.Sup_upper) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1631 |
ultimately show ?thesis by (auto intro!: exI[of _ "\<lambda>x. \<infinity>"]) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1632 |
next |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1633 |
assume "\<infinity> \<notin> A" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1634 |
have "\<exists>x\<in>A. 0 \<le> x" |
43920 | 1635 |
by (metis Infty_neq_0 PInf complete_lattice_class.Sup_least ereal_infty_less_eq2 linorder_linear) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1636 |
then obtain x where "x \<in> A" "0 \<le> x" by auto |
43920 | 1637 |
have "\<forall>n::nat. \<exists>f. f \<in> A \<and> x + ereal (real n) \<le> f" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1638 |
proof (rule ccontr) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1639 |
assume "\<not> ?thesis" |
43920 | 1640 |
then have "\<exists>n::nat. Sup A \<le> x + ereal (real n)" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1641 |
by (simp add: Sup_le_iff not_le less_imp_le Ball_def) (metis less_imp_le) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1642 |
then show False using `x \<in> A` `\<infinity> \<notin> A` PInf |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1643 |
by(cases x) auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1644 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1645 |
from choice[OF this] guess f .. note f = this |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1646 |
have "SUPR UNIV f = \<infinity>" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1647 |
proof (rule SUP_PInfty) |
43920 | 1648 |
fix n :: nat show "\<exists>i\<in>UNIV. ereal (real n) \<le> f i" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1649 |
using f[THEN spec, of n] `0 \<le> x` |
43920 | 1650 |
by (cases rule: ereal2_cases[of "f n" x]) (auto intro!: exI[of _ n]) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1651 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1652 |
then show ?thesis using f PInf by (auto intro!: exI[of _ f]) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1653 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1654 |
next |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1655 |
case MInf |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1656 |
with `A \<noteq> {}` have "A = {-\<infinity>}" by (auto simp: Sup_eq_MInfty) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1657 |
then show ?thesis using MInf by (auto intro!: exI[of _ "\<lambda>x. -\<infinity>"]) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1658 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1659 |
|
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1660 |
lemma SUPR_countable_SUPR: |
43920 | 1661 |
"A \<noteq> {} \<Longrightarrow> \<exists>f::nat \<Rightarrow> ereal. range f \<subseteq> g`A \<and> SUPR A g = SUPR UNIV f" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1662 |
using Sup_countable_SUPR[of "g`A"] by (auto simp: SUP_def) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1663 |
|
43920 | 1664 |
lemma Sup_ereal_cadd: |
1665 |
fixes A :: "ereal set" assumes "A \<noteq> {}" and "a \<noteq> -\<infinity>" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1666 |
shows "Sup ((\<lambda>x. a + x) ` A) = a + Sup A" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1667 |
proof (rule antisym) |
43920 | 1668 |
have *: "\<And>a::ereal. \<And>A. Sup ((\<lambda>x. a + x) ` A) \<le> a + Sup A" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1669 |
by (auto intro!: add_mono complete_lattice_class.Sup_least complete_lattice_class.Sup_upper) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1670 |
then show "Sup ((\<lambda>x. a + x) ` A) \<le> a + Sup A" . |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1671 |
show "a + Sup A \<le> Sup ((\<lambda>x. a + x) ` A)" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1672 |
proof (cases a) |
44918 | 1673 |
case PInf with `A \<noteq> {}` show ?thesis by (auto simp: image_constant min_max.sup_absorb1) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1674 |
next |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1675 |
case (real r) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1676 |
then have **: "op + (- a) ` op + a ` A = A" |
43920 | 1677 |
by (auto simp: image_iff ac_simps zero_ereal_def[symmetric]) |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1678 |
from *[of "-a" "(\<lambda>x. a + x) ` A"] real show ?thesis unfolding ** |
43920 | 1679 |
by (cases rule: ereal2_cases[of "Sup A" "Sup (op + a ` A)"]) auto |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1680 |
qed (insert `a \<noteq> -\<infinity>`, auto) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1681 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1682 |
|
43920 | 1683 |
lemma Sup_ereal_cminus: |
1684 |
fixes A :: "ereal set" assumes "A \<noteq> {}" and "a \<noteq> -\<infinity>" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1685 |
shows "Sup ((\<lambda>x. a - x) ` A) = a - Inf A" |
43920 | 1686 |
using Sup_ereal_cadd[of "uminus ` A" a] assms |
1687 |
by (simp add: comp_def image_image minus_ereal_def |
|
1688 |
ereal_Sup_uminus_image_eq) |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1689 |
|
43920 | 1690 |
lemma SUPR_ereal_cminus: |
43923 | 1691 |
fixes f :: "'i \<Rightarrow> ereal" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1692 |
fixes A assumes "A \<noteq> {}" and "a \<noteq> -\<infinity>" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1693 |
shows "(SUP x:A. a - f x) = a - (INF x:A. f x)" |
43920 | 1694 |
using Sup_ereal_cminus[of "f`A" a] assms |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1695 |
unfolding SUP_def INF_def image_image by auto |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1696 |
|
43920 | 1697 |
lemma Inf_ereal_cminus: |
1698 |
fixes A :: "ereal set" assumes "A \<noteq> {}" and "\<bar>a\<bar> \<noteq> \<infinity>" |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1699 |
shows "Inf ((\<lambda>x. a - x) ` A) = a - Sup A" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1700 |
proof - |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1701 |
{ fix x have "-a - -x = -(a - x)" using assms by (cases x) auto } |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1702 |
moreover then have "(\<lambda>x. -a - x)`uminus`A = uminus ` (\<lambda>x. a - x) ` A" |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1703 |
by (auto simp: image_image) |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1704 |
ultimately show ?thesis |
43920 | 1705 |
using Sup_ereal_cminus[of "uminus ` A" "-a"] assms |
1706 |
by (auto simp add: ereal_Sup_uminus_image_eq ereal_Inf_uminus_image_eq) |
|
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1707 |
qed |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1708 |
|
43920 | 1709 |
lemma INFI_ereal_cminus: |
43923 | 1710 |
fixes a :: ereal assumes "A \<noteq> {}" and "\<bar>a\<bar> \<noteq> \<infinity>" |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1711 |
shows "(INF x:A. a - f x) = a - (SUP x:A. f x)" |
43920 | 1712 |
using Inf_ereal_cminus[of "f`A" a] assms |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
1713 |
unfolding SUP_def INF_def image_image |
41979
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1714 |
by auto |
b10ec1f5e9d5
lemmas about addition, SUP on countable sets and infinite sums for extreal
hoelzl
parents:
41978
diff
changeset
|
1715 |
|
43920 | 1716 |
lemma uminus_ereal_add_uminus_uminus: |
1717 |
fixes a b :: ereal shows "a \<noteq> \<infinity> \<Longrightarrow> b \<noteq> \<infinity> \<Longrightarrow> - (- a + - b) = a + b" |
|
1718 |
by (cases rule: ereal2_cases[of a b]) auto |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1719 |
|
43920 | 1720 |
lemma INFI_ereal_add: |
43923 | 1721 |
fixes f :: "nat \<Rightarrow> ereal" |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1722 |
assumes "decseq f" "decseq g" and fin: "\<And>i. f i \<noteq> \<infinity>" "\<And>i. g i \<noteq> \<infinity>" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1723 |
shows "(INF i. f i + g i) = INFI UNIV f + INFI UNIV g" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1724 |
proof - |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1725 |
have INF_less: "(INF i. f i) < \<infinity>" "(INF i. g i) < \<infinity>" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1726 |
using assms unfolding INF_less_iff by auto |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1727 |
{ fix i from fin[of i] have "- ((- f i) + (- g i)) = f i + g i" |
43920 | 1728 |
by (rule uminus_ereal_add_uminus_uminus) } |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1729 |
then have "(INF i. f i + g i) = (INF i. - ((- f i) + (- g i)))" |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1730 |
by simp |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1731 |
also have "\<dots> = INFI UNIV f + INFI UNIV g" |
43920 | 1732 |
unfolding ereal_INFI_uminus |
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1733 |
using assms INF_less |
43920 | 1734 |
by (subst SUPR_ereal_add) |
1735 |
(auto simp: ereal_SUPR_uminus intro!: uminus_ereal_add_uminus_uminus) |
|
42950
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1736 |
finally show ?thesis . |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1737 |
qed |
6e5c2a3c69da
move lemmas to Extended_Reals and Extended_Real_Limits
hoelzl
parents:
42600
diff
changeset
|
1738 |
|
45934 | 1739 |
subsection "Relation to @{typ enat}" |
1740 |
||
1741 |
definition "ereal_of_enat n = (case n of enat n \<Rightarrow> ereal (real n) | \<infinity> \<Rightarrow> \<infinity>)" |
|
1742 |
||
1743 |
declare [[coercion "ereal_of_enat :: enat \<Rightarrow> ereal"]] |
|
1744 |
declare [[coercion "(\<lambda>n. ereal (real n)) :: nat \<Rightarrow> ereal"]] |
|
1745 |
||
1746 |
lemma ereal_of_enat_simps[simp]: |
|
1747 |
"ereal_of_enat (enat n) = ereal n" |
|
1748 |
"ereal_of_enat \<infinity> = \<infinity>" |
|
1749 |
by (simp_all add: ereal_of_enat_def) |
|
1750 |
||
1751 |
lemma ereal_of_enat_le_iff[simp]: |
|
1752 |
"ereal_of_enat m \<le> ereal_of_enat n \<longleftrightarrow> m \<le> n" |
|
1753 |
by (cases m n rule: enat2_cases) auto |
|
1754 |
||
50819
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1755 |
lemma ereal_of_enat_less_iff[simp]: |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1756 |
"ereal_of_enat m < ereal_of_enat n \<longleftrightarrow> m < n" |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1757 |
by (cases m n rule: enat2_cases) auto |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1758 |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
1759 |
lemma numeral_le_ereal_of_enat_iff[simp]: |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
47082
diff
changeset
|
1760 |
shows "numeral m \<le> ereal_of_enat n \<longleftrightarrow> numeral m \<le> n" |
45934 | 1761 |
by (cases n) (auto dest: natceiling_le intro: natceiling_le_eq[THEN iffD1]) |
1762 |
||
50819
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1763 |
lemma numeral_less_ereal_of_enat_iff[simp]: |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1764 |
shows "numeral m < ereal_of_enat n \<longleftrightarrow> numeral m < n" |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1765 |
by (cases n) (auto simp: real_of_nat_less_iff[symmetric]) |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1766 |
|
45934 | 1767 |
lemma ereal_of_enat_ge_zero_cancel_iff[simp]: |
1768 |
"0 \<le> ereal_of_enat n \<longleftrightarrow> 0 \<le> n" |
|
1769 |
by (cases n) (auto simp: enat_0[symmetric]) |
|
1770 |
||
1771 |
lemma ereal_of_enat_gt_zero_cancel_iff[simp]: |
|
1772 |
"0 < ereal_of_enat n \<longleftrightarrow> 0 < n" |
|
1773 |
by (cases n) (auto simp: enat_0[symmetric]) |
|
1774 |
||
1775 |
lemma ereal_of_enat_zero[simp]: |
|
1776 |
"ereal_of_enat 0 = 0" |
|
1777 |
by (auto simp: enat_0[symmetric]) |
|
1778 |
||
50819
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1779 |
lemma ereal_of_enat_inf[simp]: |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1780 |
"ereal_of_enat n = \<infinity> \<longleftrightarrow> n = \<infinity>" |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1781 |
by (cases n) auto |
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1782 |
|
5601ae592679
added some ereal_of_enat_* lemmas (from $AFP/thys/Girth_Chromatic)
noschinl
parents:
50104
diff
changeset
|
1783 |
|
45934 | 1784 |
lemma ereal_of_enat_add: |
1785 |
"ereal_of_enat (m + n) = ereal_of_enat m + ereal_of_enat n" |
|
1786 |
by (cases m n rule: enat2_cases) auto |
|
1787 |
||
1788 |
lemma ereal_of_enat_sub: |
|
1789 |
assumes "n \<le> m" shows "ereal_of_enat (m - n) = ereal_of_enat m - ereal_of_enat n " |
|
1790 |
using assms by (cases m n rule: enat2_cases) auto |
|
1791 |
||
1792 |
lemma ereal_of_enat_mult: |
|
1793 |
"ereal_of_enat (m * n) = ereal_of_enat m * ereal_of_enat n" |
|
1794 |
by (cases m n rule: enat2_cases) auto |
|
1795 |
||
1796 |
lemmas ereal_of_enat_pushin = ereal_of_enat_add ereal_of_enat_sub ereal_of_enat_mult |
|
1797 |
lemmas ereal_of_enat_pushout = ereal_of_enat_pushin[symmetric] |
|
1798 |
||
1799 |
||
43920 | 1800 |
subsection "Limits on @{typ ereal}" |
41973 | 1801 |
|
1802 |
subsubsection "Topological space" |
|
1803 |
||
43920 | 1804 |
instantiation ereal :: topological_space |
41973 | 1805 |
begin |
1806 |
||
43920 | 1807 |
definition "open A \<longleftrightarrow> open (ereal -` A) |
1808 |
\<and> (\<infinity> \<in> A \<longrightarrow> (\<exists>x. {ereal x <..} \<subseteq> A)) |
|
1809 |
\<and> (-\<infinity> \<in> A \<longrightarrow> (\<exists>x. {..<ereal x} \<subseteq> A))" |
|
41973 | 1810 |
|
43920 | 1811 |
lemma open_PInfty: "open A \<Longrightarrow> \<infinity> \<in> A \<Longrightarrow> (\<exists>x. {ereal x<..} \<subseteq> A)" |
1812 |
unfolding open_ereal_def by auto |
|
41973 | 1813 |
|
43920 | 1814 |
lemma open_MInfty: "open A \<Longrightarrow> -\<infinity> \<in> A \<Longrightarrow> (\<exists>x. {..<ereal x} \<subseteq> A)" |
1815 |
unfolding open_ereal_def by auto |
|
41973 | 1816 |
|
43920 | 1817 |
lemma open_PInfty2: assumes "open A" "\<infinity> \<in> A" obtains x where "{ereal x<..} \<subseteq> A" |
41973 | 1818 |
using open_PInfty[OF assms] by auto |
1819 |
||
43920 | 1820 |
lemma open_MInfty2: assumes "open A" "-\<infinity> \<in> A" obtains x where "{..<ereal x} \<subseteq> A" |
41973 | 1821 |
using open_MInfty[OF assms] by auto |
1822 |
||
43920 | 1823 |
lemma ereal_openE: assumes "open A" obtains x y where |
1824 |
"open (ereal -` A)" |
|
1825 |
"\<infinity> \<in> A \<Longrightarrow> {ereal x<..} \<subseteq> A" |
|
1826 |
"-\<infinity> \<in> A \<Longrightarrow> {..<ereal y} \<subseteq> A" |
|
1827 |
using assms open_ereal_def by auto |
|
41973 | 1828 |
|
1829 |
instance |
|
1830 |
proof |
|
43920 | 1831 |
let ?U = "UNIV::ereal set" |
1832 |
show "open ?U" unfolding open_ereal_def |
|
41975 | 1833 |
by (auto intro!: exI[of _ 0]) |
41973 | 1834 |
next |
43920 | 1835 |
fix S T::"ereal set" assume "open S" and "open T" |
1836 |
from `open S`[THEN ereal_openE] guess xS yS . |
|
1837 |
moreover from `open T`[THEN ereal_openE] guess xT yT . |
|
41975 | 1838 |
ultimately have |
43920 | 1839 |
"open (ereal -` (S \<inter> T))" |
1840 |
"\<infinity> \<in> S \<inter> T \<Longrightarrow> {ereal (max xS xT) <..} \<subseteq> S \<inter> T" |
|
1841 |
"-\<infinity> \<in> S \<inter> T \<Longrightarrow> {..< ereal (min yS yT)} \<subseteq> S \<inter> T" |
|
41975 | 1842 |
by auto |
43920 | 1843 |
then show "open (S Int T)" unfolding open_ereal_def by blast |
41973 | 1844 |
next |
43920 | 1845 |
fix K :: "ereal set set" assume "\<forall>S\<in>K. open S" |
1846 |
then have *: "\<forall>S. \<exists>x y. S \<in> K \<longrightarrow> open (ereal -` S) \<and> |
|
1847 |
(\<infinity> \<in> S \<longrightarrow> {ereal x <..} \<subseteq> S) \<and> (-\<infinity> \<in> S \<longrightarrow> {..< ereal y} \<subseteq> S)" |
|
1848 |
by (auto simp: open_ereal_def) |
|
1849 |
then show "open (Union K)" unfolding open_ereal_def |
|
41975 | 1850 |
proof (intro conjI impI) |
43920 | 1851 |
show "open (ereal -` \<Union>K)" |
41980
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
1852 |
using *[THEN choice] by (auto simp: vimage_Union) |
41975 | 1853 |
qed ((metis UnionE Union_upper subset_trans *)+) |
41973 | 1854 |
qed |
1855 |
end |
|
1856 |
||
43920 | 1857 |
lemma open_ereal: "open S \<Longrightarrow> open (ereal ` S)" |
1858 |
by (auto simp: inj_vimage_image_eq open_ereal_def) |
|
41976 | 1859 |
|
43920 | 1860 |
lemma open_ereal_vimage: "open S \<Longrightarrow> open (ereal -` S)" |
1861 |
unfolding open_ereal_def by auto |
|
41976 | 1862 |
|
43920 | 1863 |
lemma open_ereal_lessThan[intro, simp]: "open {..< a :: ereal}" |
41975 | 1864 |
proof - |
43920 | 1865 |
have "\<And>x. ereal -` {..<ereal x} = {..< x}" |
1866 |
"ereal -` {..< \<infinity>} = UNIV" "ereal -` {..< -\<infinity>} = {}" by auto |
|
1867 |
then show ?thesis by (cases a) (auto simp: open_ereal_def) |
|
41975 | 1868 |
qed |
1869 |
||
43920 | 1870 |
lemma open_ereal_greaterThan[intro, simp]: |
1871 |
"open {a :: ereal <..}" |
|
41975 | 1872 |
proof - |
43920 | 1873 |
have "\<And>x. ereal -` {ereal x<..} = {x<..}" |
1874 |
"ereal -` {\<infinity><..} = {}" "ereal -` {-\<infinity><..} = UNIV" by auto |
|
1875 |
then show ?thesis by (cases a) (auto simp: open_ereal_def) |
|
41975 | 1876 |
qed |
1877 |
||
43920 | 1878 |
lemma ereal_open_greaterThanLessThan[intro, simp]: "open {a::ereal <..< b}" |
41973 | 1879 |
unfolding greaterThanLessThan_def by auto |
1880 |
||
43920 | 1881 |
lemma closed_ereal_atLeast[simp, intro]: "closed {a :: ereal ..}" |
41973 | 1882 |
proof - |
1883 |
have "- {a ..} = {..< a}" by auto |
|
1884 |
then show "closed {a ..}" |
|
43920 | 1885 |
unfolding closed_def using open_ereal_lessThan by auto |
41973 | 1886 |
qed |
1887 |
||
43920 | 1888 |
lemma closed_ereal_atMost[simp, intro]: "closed {.. b :: ereal}" |
41973 | 1889 |
proof - |
1890 |
have "- {.. b} = {b <..}" by auto |
|
1891 |
then show "closed {.. b}" |
|
43920 | 1892 |
unfolding closed_def using open_ereal_greaterThan by auto |
41973 | 1893 |
qed |
1894 |
||
43920 | 1895 |
lemma closed_ereal_atLeastAtMost[simp, intro]: |
1896 |
shows "closed {a :: ereal .. b}" |
|
41973 | 1897 |
unfolding atLeastAtMost_def by auto |
1898 |
||
43920 | 1899 |
lemma closed_ereal_singleton: |
1900 |
"closed {a :: ereal}" |
|
1901 |
by (metis atLeastAtMost_singleton closed_ereal_atLeastAtMost) |
|
41973 | 1902 |
|
43920 | 1903 |
lemma ereal_open_cont_interval: |
43923 | 1904 |
fixes S :: "ereal set" |
41976 | 1905 |
assumes "open S" "x \<in> S" "\<bar>x\<bar> \<noteq> \<infinity>" |
41973 | 1906 |
obtains e where "e>0" "{x-e <..< x+e} \<subseteq> S" |
1907 |
proof- |
|
43920 | 1908 |
from `open S` have "open (ereal -` S)" by (rule ereal_openE) |
1909 |
then obtain e where "0 < e" 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:
41979
diff
changeset
|
1910 |
using assms unfolding open_dist by force |
41975 | 1911 |
show thesis |
1912 |
proof (intro that subsetI) |
|
43920 | 1913 |
show "0 < ereal e" using `0 < e` by auto |
1914 |
fix y assume "y \<in> {x - ereal e<..<x + ereal e}" |
|
1915 |
with assms obtain t where "y = ereal t" "dist t (real x) < e" |
|
41980
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
1916 |
apply (cases y) by (auto simp: dist_real_def) |
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
1917 |
then show "y \<in> S" using e[of t] by auto |
41975 | 1918 |
qed |
41973 | 1919 |
qed |
1920 |
||
43920 | 1921 |
lemma ereal_open_cont_interval2: |
43923 | 1922 |
fixes S :: "ereal set" |
41976 | 1923 |
assumes "open S" "x \<in> S" and x: "\<bar>x\<bar> \<noteq> \<infinity>" |
41973 | 1924 |
obtains a b where "a < x" "x < b" "{a <..< b} \<subseteq> S" |
1925 |
proof- |
|
43920 | 1926 |
guess e using ereal_open_cont_interval[OF assms] . |
1927 |
with that[of "x-e" "x+e"] ereal_between[OF x, of e] |
|
41973 | 1928 |
show thesis by auto |
1929 |
qed |
|
1930 |
||
43920 | 1931 |
instance ereal :: t2_space |
41973 | 1932 |
proof |
43920 | 1933 |
fix x y :: ereal assume "x ~= y" |
1934 |
let "?P x (y::ereal)" = "EX U V. open U & open V & x : U & y : V & U Int V = {}" |
|
41973 | 1935 |
|
43920 | 1936 |
{ fix x y :: ereal assume "x < y" |
1937 |
from ereal_dense[OF this] obtain z where z: "x < z" "z < y" by auto |
|
41973 | 1938 |
have "?P x y" |
1939 |
apply (rule exI[of _ "{..<z}"]) |
|
1940 |
apply (rule exI[of _ "{z<..}"]) |
|
1941 |
using z by auto } |
|
1942 |
note * = this |
|
1943 |
||
1944 |
from `x ~= y` |
|
1945 |
show "EX U V. open U & open V & x : U & y : V & U Int V = {}" |
|
1946 |
proof (cases rule: linorder_cases) |
|
1947 |
assume "x = y" with `x ~= y` show ?thesis by simp |
|
1948 |
next assume "x < y" from *[OF this] show ?thesis by auto |
|
1949 |
next assume "y < x" from *[OF this] show ?thesis by auto |
|
1950 |
qed |
|
1951 |
qed |
|
1952 |
||
1953 |
subsubsection {* Convergent sequences *} |
|
1954 |
||
43920 | 1955 |
lemma lim_ereal[simp]: |
1956 |
"((\<lambda>n. ereal (f n)) ---> ereal x) net \<longleftrightarrow> (f ---> x) net" (is "?l = ?r") |
|
41973 | 1957 |
proof (intro iffI topological_tendstoI) |
1958 |
fix S assume "?l" "open S" "x \<in> S" |
|
1959 |
then show "eventually (\<lambda>x. f x \<in> S) net" |
|
43920 | 1960 |
using `?l`[THEN topological_tendstoD, OF open_ereal, OF `open S`] |
41973 | 1961 |
by (simp add: inj_image_mem_iff) |
1962 |
next |
|
43920 | 1963 |
fix S assume "?r" "open S" "ereal x \<in> S" |
1964 |
show "eventually (\<lambda>x. ereal (f x) \<in> S) net" |
|
1965 |
using `?r`[THEN topological_tendstoD, OF open_ereal_vimage, OF `open S`] |
|
1966 |
using `ereal x \<in> S` by auto |
|
41973 | 1967 |
qed |
1968 |
||
43920 | 1969 |
lemma lim_real_of_ereal[simp]: |
1970 |
assumes lim: "(f ---> ereal x) net" |
|
41973 | 1971 |
shows "((\<lambda>x. real (f x)) ---> x) net" |
1972 |
proof (intro topological_tendstoI) |
|
1973 |
fix S assume "open S" "x \<in> S" |
|
43920 | 1974 |
then have S: "open S" "ereal x \<in> ereal ` S" |
41973 | 1975 |
by (simp_all add: inj_image_mem_iff) |
43920 | 1976 |
have "\<forall>x. f x \<in> ereal ` S \<longrightarrow> real (f x) \<in> S" by auto |
1977 |
from this lim[THEN topological_tendstoD, OF open_ereal, OF S] |
|
41973 | 1978 |
show "eventually (\<lambda>x. real (f x) \<in> S) net" |
1979 |
by (rule eventually_mono) |
|
1980 |
qed |
|
1981 |
||
43920 | 1982 |
lemma Lim_PInfty: "f ----> \<infinity> <-> (ALL B. EX N. ALL n>=N. f n >= ereal B)" (is "?l = ?r") |
43923 | 1983 |
proof |
1984 |
assume ?r |
|
1985 |
show ?l |
|
1986 |
apply(rule topological_tendstoI) |
|
41973 | 1987 |
unfolding eventually_sequentially |
43923 | 1988 |
proof- |
1989 |
fix S :: "ereal set" assume "open S" "\<infinity> : S" |
|
41973 | 1990 |
from open_PInfty[OF this] guess B .. note B=this |
1991 |
from `?r`[rule_format,of "B+1"] guess N .. note N=this |
|
1992 |
show "EX N. ALL n>=N. f n : S" apply(rule_tac x=N in exI) |
|
1993 |
proof safe case goal1 |
|
43920 | 1994 |
have "ereal B < ereal (B + 1)" by auto |
41973 | 1995 |
also have "... <= f n" using goal1 N by auto |
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
44669
diff
changeset
|
1996 |
finally show ?case using B by fastforce |
41973 | 1997 |
qed |
1998 |
qed |
|
43923 | 1999 |
next |
2000 |
assume ?l |
|
2001 |
show ?r |
|
43920 | 2002 |
proof fix B::real have "open {ereal B<..}" "\<infinity> : {ereal B<..}" by auto |
41973 | 2003 |
from topological_tendstoD[OF `?l` this,unfolded eventually_sequentially] |
2004 |
guess N .. note N=this |
|
43920 | 2005 |
show "EX N. ALL n>=N. ereal B <= f n" apply(rule_tac x=N in exI) using N by auto |
41973 | 2006 |
qed |
2007 |
qed |
|
2008 |
||
2009 |
||
43920 | 2010 |
lemma Lim_MInfty: "f ----> (-\<infinity>) <-> (ALL B. EX N. ALL n>=N. f n <= ereal B)" (is "?l = ?r") |
43923 | 2011 |
proof |
2012 |
assume ?r |
|
2013 |
show ?l |
|
2014 |
apply(rule topological_tendstoI) |
|
41973 | 2015 |
unfolding eventually_sequentially |
43923 | 2016 |
proof- |
2017 |
fix S :: "ereal set" |
|
2018 |
assume "open S" "(-\<infinity>) : S" |
|
41973 | 2019 |
from open_MInfty[OF this] guess B .. note B=this |
2020 |
from `?r`[rule_format,of "B-(1::real)"] guess N .. note N=this |
|
2021 |
show "EX N. ALL n>=N. f n : S" apply(rule_tac x=N in exI) |
|
2022 |
proof safe case goal1 |
|
43920 | 2023 |
have "ereal (B - 1) >= f n" using goal1 N by auto |
2024 |
also have "... < ereal B" by auto |
|
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
44669
diff
changeset
|
2025 |
finally show ?case using B by fastforce |
41973 | 2026 |
qed |
2027 |
qed |
|
2028 |
next assume ?l show ?r |
|
43920 | 2029 |
proof fix B::real have "open {..<ereal B}" "(-\<infinity>) : {..<ereal B}" by auto |
41973 | 2030 |
from topological_tendstoD[OF `?l` this,unfolded eventually_sequentially] |
2031 |
guess N .. note N=this |
|
43920 | 2032 |
show "EX N. ALL n>=N. ereal B >= f n" apply(rule_tac x=N in exI) using N by auto |
41973 | 2033 |
qed |
2034 |
qed |
|
2035 |
||
2036 |
||
43920 | 2037 |
lemma Lim_bounded_PInfty: assumes lim:"f ----> l" and "!!n. f n <= ereal B" shows "l ~= \<infinity>" |
41973 | 2038 |
proof(rule ccontr,unfold not_not) let ?B = "B + 1" assume as:"l=\<infinity>" |
2039 |
from lim[unfolded this Lim_PInfty,rule_format,of "?B"] |
|
2040 |
guess N .. note N=this[rule_format,OF le_refl] |
|
43920 | 2041 |
hence "ereal ?B <= ereal B" using assms(2)[of N] by(rule order_trans) |
2042 |
hence "ereal ?B < ereal ?B" apply (rule le_less_trans) by auto |
|
41973 | 2043 |
thus False by auto |
2044 |
qed |
|
2045 |
||
2046 |
||
43920 | 2047 |
lemma Lim_bounded_MInfty: assumes lim:"f ----> l" and "!!n. f n >= ereal B" shows "l ~= (-\<infinity>)" |
41973 | 2048 |
proof(rule ccontr,unfold not_not) let ?B = "B - 1" assume as:"l=(-\<infinity>)" |
2049 |
from lim[unfolded this Lim_MInfty,rule_format,of "?B"] |
|
2050 |
guess N .. note N=this[rule_format,OF le_refl] |
|
43920 | 2051 |
hence "ereal B <= ereal ?B" using assms(2)[of N] order_trans[of "ereal B" "f N" "ereal(B - 1)"] by blast |
41973 | 2052 |
thus False by auto |
2053 |
qed |
|
2054 |
||
2055 |
||
2056 |
lemma tendsto_explicit: |
|
2057 |
"f ----> f0 <-> (ALL S. open S --> f0 : S --> (EX N. ALL n>=N. f n : S))" |
|
2058 |
unfolding tendsto_def eventually_sequentially by auto |
|
2059 |
||
2060 |
||
2061 |
lemma tendsto_obtains_N: |
|
2062 |
assumes "f ----> f0" |
|
2063 |
assumes "open S" "f0 : S" |
|
2064 |
obtains N where "ALL n>=N. f n : S" |
|
2065 |
using tendsto_explicit[of f f0] assms by auto |
|
2066 |
||
2067 |
||
2068 |
lemma tail_same_limit: |
|
2069 |
fixes X Y N |
|
2070 |
assumes "X ----> L" "ALL n>=N. X n = Y n" |
|
2071 |
shows "Y ----> L" |
|
2072 |
proof- |
|
2073 |
{ fix S assume "open S" and "L:S" |
|
47082 | 2074 |
then obtain N1 where "ALL n>=N1. X n : S" |
41973 | 2075 |
using assms unfolding tendsto_def eventually_sequentially by auto |
2076 |
hence "ALL n>=max N N1. Y n : S" using assms by auto |
|
2077 |
hence "EX N. ALL n>=N. Y n : S" apply(rule_tac x="max N N1" in exI) by auto |
|
2078 |
} |
|
2079 |
thus ?thesis using tendsto_explicit by auto |
|
2080 |
qed |
|
2081 |
||
2082 |
||
2083 |
lemma Lim_bounded_PInfty2: |
|
43920 | 2084 |
assumes lim:"f ----> l" and "ALL n>=N. f n <= ereal B" |
41973 | 2085 |
shows "l ~= \<infinity>" |
2086 |
proof- |
|
43920 | 2087 |
def g == "(%n. if n>=N then f n else ereal B)" |
41973 | 2088 |
hence "g ----> l" using tail_same_limit[of f l N g] lim by auto |
43920 | 2089 |
moreover have "!!n. g n <= ereal B" using g_def assms by auto |
41973 | 2090 |
ultimately show ?thesis using Lim_bounded_PInfty by auto |
2091 |
qed |
|
2092 |
||
43920 | 2093 |
lemma Lim_bounded_ereal: |
2094 |
assumes lim:"f ----> (l :: ereal)" |
|
41973 | 2095 |
and "ALL n>=M. f n <= C" |
2096 |
shows "l<=C" |
|
2097 |
proof- |
|
2098 |
{ assume "l=(-\<infinity>)" hence ?thesis by auto } |
|
2099 |
moreover |
|
2100 |
{ assume "~(l=(-\<infinity>))" |
|
2101 |
{ assume "C=\<infinity>" hence ?thesis by auto } |
|
2102 |
moreover |
|
2103 |
{ assume "C=(-\<infinity>)" hence "ALL n>=M. f n = (-\<infinity>)" using assms by auto |
|
2104 |
hence "l=(-\<infinity>)" using assms |
|
41980
28b51effc5ed
split Extended_Reals into parts for Library and Multivariate_Analysis
hoelzl
parents:
41979
diff
changeset
|
2105 |
tendsto_unique[OF trivial_limit_sequentially] tail_same_limit[of "\<lambda>n. -\<infinity>" "-\<infinity>" M f, OF tendsto_const] by auto |
41973 | 2106 |
hence ?thesis by auto } |
2107 |
moreover |
|
43920 | 2108 |
{ assume "EX B. C = ereal B" |
47082 | 2109 |
then obtain B where B_def: "C=ereal B" by auto |
41973 | 2110 |
hence "~(l=\<infinity>)" using Lim_bounded_PInfty2 assms by auto |
47082 | 2111 |
then obtain m where m_def: "ereal m=l" using `~(l=(-\<infinity>))` by (cases l) auto |
2112 |
then obtain N where N_def: "ALL n>=N. f n : {ereal(m - 1) <..< ereal(m+1)}" |
|
43920 | 2113 |
apply (subst tendsto_obtains_N[of f l "{ereal(m - 1) <..< ereal(m+1)}"]) using assms by auto |
41973 | 2114 |
{ fix n assume "n>=N" |
43920 | 2115 |
hence "EX r. ereal r = f n" using N_def by (cases "f n") auto |
47082 | 2116 |
} then obtain g where g_def: "ALL n>=N. ereal (g n) = f n" by metis |
43920 | 2117 |
hence "(%n. ereal (g n)) ----> l" using tail_same_limit[of f l N] assms by auto |
41973 | 2118 |
hence *: "(%n. g n) ----> m" using m_def by auto |
2119 |
{ fix n assume "n>=max N M" |
|
43920 | 2120 |
hence "ereal (g n) <= ereal B" using assms g_def B_def by auto |
41973 | 2121 |
hence "g n <= B" by auto |
2122 |
} hence "EX N. ALL n>=N. g n <= B" by blast |
|
2123 |
hence "m<=B" using * LIMSEQ_le_const2[of g m B] by auto |
|
2124 |
hence ?thesis using m_def B_def by auto |
|
2125 |
} ultimately have ?thesis by (cases C) auto |
|
2126 |
} ultimately show ?thesis by blast |
|
2127 |
qed |
|
2128 |
||
43920 | 2129 |
lemma real_of_ereal_mult[simp]: |
2130 |
fixes a b :: ereal shows "real (a * b) = real a * real b" |
|
2131 |
by (cases rule: ereal2_cases[of a b]) auto |
|
41973 | 2132 |
|
43920 | 2133 |
lemma real_of_ereal_eq_0: |
43923 | 2134 |
fixes x :: ereal shows "real x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity> \<or> x = 0" |
41973 | 2135 |
by (cases x) auto |
2136 |
||
43920 | 2137 |
lemma tendsto_ereal_realD: |
2138 |
fixes f :: "'a \<Rightarrow> ereal" |
|
2139 |
assumes "x \<noteq> 0" and tendsto: "((\<lambda>x. ereal (real (f x))) ---> x) net" |
|
41973 | 2140 |
shows "(f ---> x) net" |
2141 |
proof (intro topological_tendstoI) |
|
2142 |
fix S assume S: "open S" "x \<in> S" |
|
2143 |
with `x \<noteq> 0` have "open (S - {0})" "x \<in> S - {0}" by auto |
|
2144 |
from tendsto[THEN topological_tendstoD, OF this] |
|
2145 |
show "eventually (\<lambda>x. f x \<in> S) net" |
|
44142 | 2146 |
by (rule eventually_rev_mp) (auto simp: ereal_real) |
41973 | 2147 |
qed |
2148 |
||
43920 | 2149 |
lemma tendsto_ereal_realI: |
2150 |
fixes f :: "'a \<Rightarrow> ereal" |
|
41976 | 2151 |
assumes x: "\<bar>x\<bar> \<noteq> \<infinity>" and tendsto: "(f ---> x) net" |
43920 | 2152 |
shows "((\<lambda>x. ereal (real (f x))) ---> x) net" |
41973 | 2153 |
proof (intro topological_tendstoI) |
2154 |
fix S assume "open S" "x \<in> S" |
|
2155 |
with x have "open (S - {\<infinity>, -\<infinity>})" "x \<in> S - {\<infinity>, -\<infinity>}" by auto |
|
2156 |
from tendsto[THEN topological_tendstoD, OF this] |
|
43920 | 2157 |
show "eventually (\<lambda>x. ereal (real (f x)) \<in> S) net" |
2158 |
by (elim eventually_elim1) (auto simp: ereal_real) |
|
41973 | 2159 |
qed |
2160 |
||
43920 | 2161 |
lemma ereal_mult_cancel_left: |
2162 |
fixes a b c :: ereal shows "a * b = a * c \<longleftrightarrow> |
|
41976 | 2163 |
((\<bar>a\<bar> = \<infinity> \<and> 0 < b * c) \<or> a = 0 \<or> b = c)" |
43920 | 2164 |
by (cases rule: ereal3_cases[of a b c]) |
41973 | 2165 |
(simp_all add: zero_less_mult_iff) |
2166 |
||
43920 | 2167 |
lemma ereal_inj_affinity: |
43923 | 2168 |
fixes m t :: ereal |
41976 | 2169 |
assumes "\<bar>m\<bar> \<noteq> \<infinity>" "m \<noteq> 0" "\<bar>t\<bar> \<noteq> \<infinity>" |
41973 | 2170 |
shows "inj_on (\<lambda>x. m * x + t) A" |
2171 |
using assms |
|
43920 | 2172 |
by (cases rule: ereal2_cases[of m t]) |
2173 |
(auto intro!: inj_onI simp: ereal_add_cancel_right ereal_mult_cancel_left) |
|
41973 | 2174 |
|
43920 | 2175 |
lemma ereal_PInfty_eq_plus[simp]: |
43923 | 2176 |
fixes a b :: ereal |
41973 | 2177 |
shows "\<infinity> = a + b \<longleftrightarrow> a = \<infinity> \<or> b = \<infinity>" |
43920 | 2178 |
by (cases rule: ereal2_cases[of a b]) auto |
41973 | 2179 |
|
43920 | 2180 |
lemma ereal_MInfty_eq_plus[simp]: |
43923 | 2181 |
fixes a b :: ereal |
41973 | 2182 |
shows "-\<infinity> = a + b \<longleftrightarrow> (a = -\<infinity> \<and> b \<noteq> \<infinity>) \<or> (b = -\<infinity> \<and> a \<noteq> \<infinity>)" |
43920 | 2183 |
by (cases rule: ereal2_cases[of a b]) auto |
41973 | 2184 |
|
43920 | 2185 |
lemma ereal_less_divide_pos: |
43923 | 2186 |
fixes x y :: ereal |
2187 |
shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y < z / x \<longleftrightarrow> x * y < z" |
|
43920 | 2188 |
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) |
41973 | 2189 |
|
43920 | 2190 |
lemma ereal_divide_less_pos: |
43923 | 2191 |
fixes x y z :: ereal |
2192 |
shows "x > 0 \<Longrightarrow> x \<noteq> \<infinity> \<Longrightarrow> y / x < z \<longleftrightarrow> y < x * z" |
|
43920 | 2193 |
by (cases rule: ereal3_cases[of x y z]) (auto simp: field_simps) |
41973 | 2194 |
|
43920 | 2195 |
lemma ereal_divide_eq: |
43923 | 2196 |
fixes a b c :: ereal |
2197 |
shows "b \<noteq> 0 \<Longrightarrow> \<bar>b\<bar> \<noteq> \<infinity> \<Longrightarrow> a / b = c \<longleftrightarrow> a = b * c" |
|
43920 | 2198 |
by (cases rule: ereal3_cases[of a b c]) |
41973 | 2199 |
(simp_all add: field_simps) |
2200 |
||
43923 | 2201 |
lemma ereal_inverse_not_MInfty[simp]: "inverse (a::ereal) \<noteq> -\<infinity>" |
41973 | 2202 |
by (cases a) auto |
2203 |
||
43920 | 2204 |
lemma ereal_mult_m1[simp]: "x * ereal (-1) = -x" |
41973 | 2205 |
by (cases x) auto |
2206 |
||
43920 | 2207 |
lemma ereal_LimI_finite: |
43923 | 2208 |
fixes x :: ereal |
41976 | 2209 |
assumes "\<bar>x\<bar> \<noteq> \<infinity>" |
41973 | 2210 |
assumes "!!r. 0 < r ==> EX N. ALL n>=N. u n < x + r & x < u n + r" |
2211 |
shows "u ----> x" |
|
2212 |
proof (rule topological_tendstoI, unfold eventually_sequentially) |
|
43920 | 2213 |
obtain rx where rx_def: "x=ereal rx" using assms by (cases x) auto |
41973 | 2214 |
fix S assume "open S" "x : S" |
43920 | 2215 |
then have "open (ereal -` S)" unfolding open_ereal_def by auto |
2216 |
with `x \<in> S` obtain r where "0 < r" and dist: "!!y. dist y rx < r ==> ereal y \<in> S" |
|
41975 | 2217 |
unfolding open_real_def rx_def by auto |
41973 | 2218 |
then obtain n where |
43920 | 2219 |
upper: "!!N. n <= N ==> u N < x + ereal r" and |
2220 |
lower: "!!N. n <= N ==> x < u N + ereal r" using assms(2)[of "ereal r"] by auto |
|
41973 | 2221 |
show "EX N. ALL n>=N. u n : S" |
2222 |
proof (safe intro!: exI[of _ n]) |
|
2223 |
fix N assume "n <= N" |
|
2224 |
from upper[OF this] lower[OF this] assms `0 < r` |
|
2225 |
have "u N ~: {\<infinity>,(-\<infinity>)}" by auto |
|
47082 | 2226 |
then obtain ra where ra_def: "(u N) = ereal ra" by (cases "u N") auto |
41973 | 2227 |
hence "rx < ra + r" and "ra < rx + r" |
2228 |
using rx_def assms `0 < r` lower[OF `n <= N`] upper[OF `n <= N`] by auto |
|
41975 | 2229 |
hence "dist (real (u N)) rx < r" |
41973 | 2230 |
using rx_def ra_def |
2231 |
by (auto simp: dist_real_def abs_diff_less_iff field_simps) |
|
41976 | 2232 |
from dist[OF this] show "u N : S" using `u N ~: {\<infinity>, -\<infinity>}` |
43920 | 2233 |
by (auto simp: ereal_real split: split_if_asm) |
41973 | 2234 |
qed |
2235 |
qed |
|
2236 |
||
43920 | 2237 |
lemma ereal_LimI_finite_iff: |
43923 | 2238 |
fixes x :: ereal |
41976 | 2239 |
assumes "\<bar>x\<bar> \<noteq> \<infinity>" |
41973 | 2240 |
shows "u ----> x <-> (ALL r. 0 < r --> (EX N. ALL n>=N. u n < x + r & x < u n + r))" |
2241 |
(is "?lhs <-> ?rhs") |
|
41976 | 2242 |
proof |
2243 |
assume lim: "u ----> x" |
|
43920 | 2244 |
{ fix r assume "(r::ereal)>0" |
47082 | 2245 |
then obtain N where N_def: "ALL n>=N. u n : {x - r <..< x + r}" |
41973 | 2246 |
apply (subst tendsto_obtains_N[of u x "{x - r <..< x + r}"]) |
43920 | 2247 |
using lim ereal_between[of x r] assms `r>0` by auto |
41973 | 2248 |
hence "EX N. ALL n>=N. u n < x + r & x < u n + r" |
43920 | 2249 |
using ereal_minus_less[of r x] by (cases r) auto |
41976 | 2250 |
} then show "?rhs" by auto |
2251 |
next |
|
2252 |
assume ?rhs then show "u ----> x" |
|
43920 | 2253 |
using ereal_LimI_finite[of x] assms by auto |
41973 | 2254 |
qed |
2255 |
||
2256 |
||
2257 |
subsubsection {* @{text Liminf} and @{text Limsup} *} |
|
2258 |
||
2259 |
definition |
|
2260 |
"Liminf net f = (GREATEST l. \<forall>y<l. eventually (\<lambda>x. y < f x) net)" |
|
2261 |
||
2262 |
definition |
|
2263 |
"Limsup net f = (LEAST l. \<forall>y>l. eventually (\<lambda>x. f x < y) net)" |
|
2264 |
||
2265 |
lemma Liminf_Sup: |
|
43941 | 2266 |
fixes f :: "'a => 'b::complete_linorder" |
41973 | 2267 |
shows "Liminf net f = Sup {l. \<forall>y<l. eventually (\<lambda>x. y < f x) net}" |
2268 |
by (auto intro!: Greatest_equality complete_lattice_class.Sup_upper simp: less_Sup_iff Liminf_def) |
|
2269 |
||
2270 |
lemma Limsup_Inf: |
|
43941 | 2271 |
fixes f :: "'a => 'b::complete_linorder" |
41973 | 2272 |
shows "Limsup net f = Inf {l. \<forall>y>l. eventually (\<lambda>x. f x < y) net}" |
2273 |
by (auto intro!: Least_equality complete_lattice_class.Inf_lower simp: Inf_less_iff Limsup_def) |
|
2274 |
||
43920 | 2275 |
lemma ereal_SupI: |
2276 |
fixes x :: ereal |
|
41973 | 2277 |
assumes "\<And>y. y \<in> A \<Longrightarrow> y \<le> x" |
2278 |
assumes "\<And>y. (\<And>z. z \<in> A \<Longrightarrow> z \<le> y) \<Longrightarrow> x \<le> y" |
|
2279 |
shows "Sup A = x" |
|
43920 | 2280 |
unfolding Sup_ereal_def |
41973 | 2281 |
using assms by (auto intro!: Least_equality) |
2282 |
||
43920 | 2283 |
lemma ereal_InfI: |
2284 |
fixes x :: ereal |
|
41973 | 2285 |
assumes "\<And>i. i \<in> A \<Longrightarrow> x \<le> i" |
2286 |
assumes "\<And>y. (\<And>i. i \<in> A \<Longrightarrow> y \<le> i) \<Longrightarrow> y \<le> x" |
|
2287 |
shows "Inf A = x" |
|
43920 | 2288 |
unfolding Inf_ereal_def |
41973 | 2289 |
using assms by (auto intro!: Greatest_equality) |
2290 |
||
2291 |
lemma Limsup_const: |
|
43941 | 2292 |
fixes c :: "'a::complete_linorder" |
41973 | 2293 |
assumes ntriv: "\<not> trivial_limit net" |
2294 |
shows "Limsup net (\<lambda>x. c) = c" |
|
2295 |
unfolding Limsup_Inf |
|
2296 |
proof (safe intro!: antisym complete_lattice_class.Inf_greatest complete_lattice_class.Inf_lower) |
|
2297 |
fix x assume *: "\<forall>y>x. eventually (\<lambda>_. c < y) net" |
|
2298 |
show "c \<le> x" |
|
2299 |
proof (rule ccontr) |
|
2300 |
assume "\<not> c \<le> x" then have "x < c" by auto |
|
2301 |
then show False using ntriv * by (auto simp: trivial_limit_def) |
|
2302 |
qed |
|
2303 |
qed auto |
|
2304 |
||
2305 |
lemma Liminf_const: |
|
43941 | 2306 |
fixes c :: "'a::complete_linorder" |
41973 | 2307 |
assumes ntriv: "\<not> trivial_limit net" |
2308 |
shows "Liminf net (\<lambda>x. c) = c" |
|
2309 |
unfolding Liminf_Sup |
|
2310 |
proof (safe intro!: antisym complete_lattice_class.Sup_least complete_lattice_class.Sup_upper) |
|
2311 |
fix x assume *: "\<forall>y<x. eventually (\<lambda>_. y < c) net" |
|
2312 |
show "x \<le> c" |
|
2313 |
proof (rule ccontr) |
|
2314 |
assume "\<not> x \<le> c" then have "c < x" by auto |
|
2315 |
then show False using ntriv * by (auto simp: trivial_limit_def) |
|
2316 |
qed |
|
2317 |
qed auto |
|
2318 |
||
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44142
diff
changeset
|
2319 |
definition (in order) mono_set: |
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44142
diff
changeset
|
2320 |
"mono_set S \<longleftrightarrow> (\<forall>x y. x \<le> y \<longrightarrow> x \<in> S \<longrightarrow> y \<in> S)" |
41973 | 2321 |
|
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44142
diff
changeset
|
2322 |
lemma (in order) mono_greaterThan [intro, simp]: "mono_set {B<..}" unfolding mono_set by auto |
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44142
diff
changeset
|
2323 |
lemma (in order) mono_atLeast [intro, simp]: "mono_set {B..}" unfolding mono_set by auto |
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44142
diff
changeset
|
2324 |
lemma (in order) mono_UNIV [intro, simp]: "mono_set UNIV" unfolding mono_set by auto |
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44142
diff
changeset
|
2325 |
lemma (in order) mono_empty [intro, simp]: "mono_set {}" unfolding mono_set by auto |
41973 | 2326 |
|
43941 | 2327 |
lemma (in complete_linorder) mono_set_iff: |
2328 |
fixes S :: "'a set" |
|
41973 | 2329 |
defines "a \<equiv> Inf S" |
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44142
diff
changeset
|
2330 |
shows "mono_set S \<longleftrightarrow> (S = {a <..} \<or> S = {a..})" (is "_ = ?c") |
41973 | 2331 |
proof |
44170
510ac30f44c0
make Multivariate_Analysis work with separate set type
huffman
parents:
44142
diff
changeset
|
2332 |
assume "mono_set S" |
41973 | 2333 |
then have mono: "\<And>x y. x \<le> y \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S" by (auto simp: mono_set) |
2334 |
show ?c |
|
2335 |
proof cases |
|
2336 |
assume "a \<in> S" |
|
2337 |
show ?c |
|
2338 |
using mono[OF _ `a \<in> S`] |
|
43941 | 2339 |
by (auto intro: Inf_lower simp: a_def) |
41973 | 2340 |
next |
2341 |
assume "a \<notin> S" |
|
2342 |
have "S = {a <..}" |
|
2343 |
proof safe |
|
2344 |
fix x assume "x \<in> S" |
|
43941 | 2345 |
then have "a \<le> x" unfolding a_def by (rule Inf_lower) |
41973 | 2346 |
then show "a < x" using `x \<in> S` `a \<notin> S` by (cases "a = x") auto |
2347 |
next |
|
2348 |
fix x assume "a < x" |
|
2349 |
then obtain y where "y < x" "y \<in> S" unfolding a_def Inf_less_iff .. |
|
2350 |
with mono[of y x] show "x \<in> S" by auto |
|
2351 |
qed |
|
2352 |
then show ?c .. |
|
2353 |
qed |
|
2354 |
qed auto |
|
2355 |
||
2356 |
lemma lim_imp_Liminf: |
|
43920 | 2357 |
fixes f :: "'a \<Rightarrow> ereal" |
41973 | 2358 |
assumes ntriv: "\<not> trivial_limit net" |
2359 |
assumes lim: "(f ---> f0) net" |
|
2360 |
shows "Liminf net f = f0" |
|
2361 |
unfolding Liminf_Sup |
|
43920 | 2362 |
proof (safe intro!: ereal_SupI) |
41973 | 2363 |
fix y assume *: "\<forall>y'<y. eventually (\<lambda>x. y' < f x) net" |
2364 |
show "y \<le> f0" |
|
43920 | 2365 |
proof (rule ereal_le_ereal) |
41973 | 2366 |
fix B assume "B < y" |
2367 |
{ assume "f0 < B" |
|
2368 |
then have "eventually (\<lambda>x. f x < B \<and> B < f x) net" |
|
2369 |
using topological_tendstoD[OF lim, of "{..<B}"] *[rule_format, OF `B < y`] |
|
2370 |
by (auto intro: eventually_conj) |
|
2371 |
also have "(\<lambda>x. f x < B \<and> B < f x) = (\<lambda>x. False)" by (auto simp: fun_eq_iff) |
|
2372 |
finally have False using ntriv[unfolded trivial_limit_def] by auto |
|
2373 |
} then show "B \<le> f0" by (metis linorder_le_less_linear) |
|
2374 |
qed |
|
2375 |
next |
|
2376 |
fix y assume *: "\<forall>z. z \<in> {l. \<forall>y<l. eventually (\<lambda>x. y < f x) net} \<longrightarrow> z \<le> y" |
|
2377 |
show "f0 \<le> y" |
|
2378 |
proof (safe intro!: *[rule_format]) |
|
2379 |
fix y assume "y < f0" then show "eventually (\<lambda>x. y < f x) net" |
|
2380 |
using lim[THEN topological_tendstoD, of "{y <..}"] by auto |
|
2381 |
qed |
|
2382 |
qed |
|
2383 |
||
43920 | 2384 |
lemma ereal_Liminf_le_Limsup: |
2385 |
fixes f :: "'a \<Rightarrow> ereal" |
|
41973 | 2386 |
assumes ntriv: "\<not> trivial_limit net" |
2387 |
shows "Liminf net f \<le> Limsup net f" |
|
2388 |
unfolding Limsup_Inf Liminf_Sup |
|
2389 |
proof (safe intro!: complete_lattice_class.Inf_greatest complete_lattice_class.Sup_least) |
|
2390 |
fix u v assume *: "\<forall>y<u. eventually (\<lambda>x. y < f x) net" "\<forall>y>v. eventually (\<lambda>x. f x < y) net" |
|
2391 |
show "u \<le> v" |
|
2392 |
proof (rule ccontr) |
|
2393 |
assume "\<not> u \<le> v" |
|
2394 |
then obtain t where "t < u" "v < t" |
|
43920 | 2395 |
using ereal_dense[of v u] by (auto simp: not_le) |
41973 | 2396 |
then have "eventually (\<lambda>x. t < f x \<and> f x < t) net" |
2397 |
using * by (auto intro: eventually_conj) |
|
2398 |
also have "(\<lambda>x. t < f x \<and> f x < t) = (\<lambda>x. False)" by (auto simp: fun_eq_iff) |
|
2399 |
finally show False using ntriv by (auto simp: trivial_limit_def) |
|
2400 |
qed |
|
2401 |
qed |
|
2402 |
||
2403 |
lemma Liminf_mono: |
|
43920 | 2404 |
fixes f g :: "'a => ereal" |
41973 | 2405 |
assumes ev: "eventually (\<lambda>x. f x \<le> g x) net" |
2406 |
shows "Liminf net f \<le> Liminf net g" |
|
2407 |
unfolding Liminf_Sup |
|
2408 |
proof (safe intro!: Sup_mono bexI) |
|
2409 |
fix a y assume "\<forall>y<a. eventually (\<lambda>x. y < f x) net" and "y < a" |
|
2410 |
then have "eventually (\<lambda>x. y < f x) net" by auto |
|
2411 |
then show "eventually (\<lambda>x. y < g x) net" |
|
2412 |
by (rule eventually_rev_mp) (rule eventually_mono[OF _ ev], auto) |
|
2413 |
qed simp |
|
2414 |
||
2415 |
lemma Liminf_eq: |
|
43920 | 2416 |
fixes f g :: "'a \<Rightarrow> ereal" |
41973 | 2417 |
assumes "eventually (\<lambda>x. f x = g x) net" |
2418 |
shows "Liminf net f = Liminf net g" |
|
2419 |
by (intro antisym Liminf_mono eventually_mono[OF _ assms]) auto |
|
2420 |
||
2421 |
lemma Liminf_mono_all: |
|
43920 | 2422 |
fixes f g :: "'a \<Rightarrow> ereal" |
41973 | 2423 |
assumes "\<And>x. f x \<le> g x" |
2424 |
shows "Liminf net f \<le> Liminf net g" |
|
2425 |
using assms by (intro Liminf_mono always_eventually) auto |
|
2426 |
||
2427 |
lemma Limsup_mono: |
|
43920 | 2428 |
fixes f g :: "'a \<Rightarrow> ereal" |
41973 | 2429 |
assumes ev: "eventually (\<lambda>x. f x \<le> g x) net" |
2430 |
shows "Limsup net f \<le> Limsup net g" |
|
2431 |
unfolding Limsup_Inf |
|
2432 |
proof (safe intro!: Inf_mono bexI) |
|
2433 |
fix a y assume "\<forall>y>a. eventually (\<lambda>x. g x < y) net" and "a < y" |
|
2434 |
then have "eventually (\<lambda>x. g x < y) net" by auto |
|
2435 |
then show "eventually (\<lambda>x. f x < y) net" |
|
2436 |
by (rule eventually_rev_mp) (rule eventually_mono[OF _ ev], auto) |
|
2437 |
qed simp |
|
2438 |
||
2439 |
lemma Limsup_mono_all: |
|
43920 | 2440 |
fixes f g :: "'a \<Rightarrow> ereal" |
41973 | 2441 |
assumes "\<And>x. f x \<le> g x" |
2442 |
shows "Limsup net f \<le> Limsup net g" |
|
2443 |
using assms by (intro Limsup_mono always_eventually) auto |
|
2444 |
||
2445 |
lemma Limsup_eq: |
|
43920 | 2446 |
fixes f g :: "'a \<Rightarrow> ereal" |
41973 | 2447 |
assumes "eventually (\<lambda>x. f x = g x) net" |
2448 |
shows "Limsup net f = Limsup net g" |
|
2449 |
by (intro antisym Limsup_mono eventually_mono[OF _ assms]) auto |
|
2450 |
||
2451 |
abbreviation "liminf \<equiv> Liminf sequentially" |
|
2452 |
||
2453 |
abbreviation "limsup \<equiv> Limsup sequentially" |
|
2454 |
||
2455 |
lemma liminf_SUPR_INFI: |
|
43920 | 2456 |
fixes f :: "nat \<Rightarrow> ereal" |
41973 | 2457 |
shows "liminf f = (SUP n. INF m:{n..}. f m)" |
2458 |
unfolding Liminf_Sup eventually_sequentially |
|
2459 |
proof (safe intro!: antisym complete_lattice_class.Sup_least) |
|
2460 |
fix x assume *: "\<forall>y<x. \<exists>N. \<forall>n\<ge>N. y < f n" show "x \<le> (SUP n. INF m:{n..}. f m)" |
|
43920 | 2461 |
proof (rule ereal_le_ereal) |
41973 | 2462 |
fix y assume "y < x" |
2463 |
with * obtain N where "\<And>n. N \<le> n \<Longrightarrow> y < f n" by auto |
|
2464 |
then have "y \<le> (INF m:{N..}. f m)" by (force simp: le_INF_iff) |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
2465 |
also have "\<dots> \<le> (SUP n. INF m:{n..}. f m)" by (intro SUP_upper) auto |
41973 | 2466 |
finally show "y \<le> (SUP n. INF m:{n..}. f m)" . |
2467 |
qed |
|
2468 |
next |
|
2469 |
show "(SUP n. INF m:{n..}. f m) \<le> Sup {l. \<forall>y<l. \<exists>N. \<forall>n\<ge>N. y < f n}" |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
2470 |
proof (unfold SUP_def, safe intro!: Sup_mono bexI) |
41973 | 2471 |
fix y n assume "y < INFI {n..} f" |
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
2472 |
from less_INF_D[OF this] show "\<exists>N. \<forall>n\<ge>N. y < f n" by (intro exI[of _ n]) auto |
41973 | 2473 |
qed (rule order_refl) |
2474 |
qed |
|
2475 |
||
2476 |
lemma tail_same_limsup: |
|
43920 | 2477 |
fixes X Y :: "nat => ereal" |
41973 | 2478 |
assumes "\<And>n. N \<le> n \<Longrightarrow> X n = Y n" |
2479 |
shows "limsup X = limsup Y" |
|
2480 |
using Limsup_eq[of X Y sequentially] eventually_sequentially assms by auto |
|
2481 |
||
2482 |
lemma tail_same_liminf: |
|
43920 | 2483 |
fixes X Y :: "nat => ereal" |
41973 | 2484 |
assumes "\<And>n. N \<le> n \<Longrightarrow> X n = Y n" |
2485 |
shows "liminf X = liminf Y" |
|
2486 |
using Liminf_eq[of X Y sequentially] eventually_sequentially assms by auto |
|
2487 |
||
2488 |
lemma liminf_mono: |
|
43920 | 2489 |
fixes X Y :: "nat \<Rightarrow> ereal" |
41973 | 2490 |
assumes "\<And>n. N \<le> n \<Longrightarrow> X n <= Y n" |
2491 |
shows "liminf X \<le> liminf Y" |
|
2492 |
using Liminf_mono[of X Y sequentially] eventually_sequentially assms by auto |
|
2493 |
||
2494 |
lemma limsup_mono: |
|
43920 | 2495 |
fixes X Y :: "nat => ereal" |
41973 | 2496 |
assumes "\<And>n. N \<le> n \<Longrightarrow> X n <= Y n" |
2497 |
shows "limsup X \<le> limsup Y" |
|
2498 |
using Limsup_mono[of X Y sequentially] eventually_sequentially assms by auto |
|
2499 |
||
41978 | 2500 |
lemma |
43920 | 2501 |
fixes X :: "nat \<Rightarrow> ereal" |
2502 |
shows ereal_incseq_uminus[simp]: "incseq (\<lambda>i. - X i) = decseq X" |
|
2503 |
and ereal_decseq_uminus[simp]: "decseq (\<lambda>i. - X i) = incseq X" |
|
41978 | 2504 |
unfolding incseq_def decseq_def by auto |
2505 |
||
41973 | 2506 |
lemma liminf_bounded: |
43920 | 2507 |
fixes X Y :: "nat \<Rightarrow> ereal" |
41973 | 2508 |
assumes "\<And>n. N \<le> n \<Longrightarrow> C \<le> X n" |
2509 |
shows "C \<le> liminf X" |
|
2510 |
using liminf_mono[of N "\<lambda>n. C" X] assms Liminf_const[of sequentially C] by simp |
|
2511 |
||
2512 |
lemma limsup_bounded: |
|
43920 | 2513 |
fixes X Y :: "nat => ereal" |
41973 | 2514 |
assumes "\<And>n. N \<le> n \<Longrightarrow> X n <= C" |
2515 |
shows "limsup X \<le> C" |
|
2516 |
using limsup_mono[of N X "\<lambda>n. C"] assms Limsup_const[of sequentially C] by simp |
|
2517 |
||
2518 |
lemma liminf_bounded_iff: |
|
43920 | 2519 |
fixes x :: "nat \<Rightarrow> ereal" |
41973 | 2520 |
shows "C \<le> liminf x \<longleftrightarrow> (\<forall>B<C. \<exists>N. \<forall>n\<ge>N. B < x n)" (is "?lhs <-> ?rhs") |
2521 |
proof safe |
|
2522 |
fix B assume "B < C" "C \<le> liminf x" |
|
2523 |
then have "B < liminf x" by auto |
|
2524 |
then obtain N where "B < (INF m:{N..}. x m)" |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
2525 |
unfolding liminf_SUPR_INFI SUP_def less_Sup_iff by auto |
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
2526 |
from less_INF_D[OF this] show "\<exists>N. \<forall>n\<ge>N. B < x n" by auto |
41973 | 2527 |
next |
2528 |
assume *: "\<forall>B<C. \<exists>N. \<forall>n\<ge>N. B < x n" |
|
2529 |
{ fix B assume "B<C" |
|
2530 |
then obtain N where "\<forall>n\<ge>N. B < x n" using `?rhs` by auto |
|
44928
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
2531 |
hence "B \<le> (INF m:{N..}. x m)" by (intro INF_greatest) auto |
7ef6505bde7f
renamed Complete_Lattices lemmas, removed legacy names
hoelzl
parents:
44918
diff
changeset
|
2532 |
also have "... \<le> liminf x" unfolding liminf_SUPR_INFI by (intro SUP_upper) simp |
41973 | 2533 |
finally have "B \<le> liminf x" . |
2534 |
} then show "?lhs" by (metis * leD liminf_bounded linorder_le_less_linear) |
|
2535 |
qed |
|
2536 |
||
2537 |
lemma liminf_subseq_mono: |
|
43920 | 2538 |
fixes X :: "nat \<Rightarrow> ereal" |
41973 | 2539 |
assumes "subseq r" |
2540 |
shows "liminf X \<le> liminf (X \<circ> r) " |
|
2541 |
proof- |
|
2542 |
have "\<And>n. (INF m:{n..}. X m) \<le> (INF m:{n..}. (X \<circ> r) m)" |
|
2543 |
proof (safe intro!: INF_mono) |
|
2544 |
fix n m :: nat assume "n \<le> m" then show "\<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m" |
|
2545 |
using seq_suble[OF `subseq r`, of m] by (intro bexI[of _ "r m"]) auto |
|
2546 |
qed |
|
2547 |
then show ?thesis by (auto intro!: SUP_mono simp: liminf_SUPR_INFI comp_def) |
|
2548 |
qed |
|
2549 |
||
43920 | 2550 |
lemma ereal_real': assumes "\<bar>x\<bar> \<noteq> \<infinity>" shows "ereal (real x) = x" |
41976 | 2551 |
using assms by auto |
41973 | 2552 |
|
43920 | 2553 |
lemma ereal_le_ereal_bounded: |
2554 |
fixes x y z :: ereal |
|
41978 | 2555 |
assumes "z \<le> y" |
2556 |
assumes *: "\<And>B. z < B \<Longrightarrow> B < x \<Longrightarrow> B \<le> y" |
|
2557 |
shows "x \<le> y" |
|
43920 | 2558 |
proof (rule ereal_le_ereal) |
41978 | 2559 |
fix B assume "B < x" |
2560 |
show "B \<le> y" |
|
2561 |
proof cases |
|
2562 |
assume "z < B" from *[OF this `B < x`] show "B \<le> y" . |
|
41976 | 2563 |
next |
41978 | 2564 |
assume "\<not> z < B" with `z \<le> y` show "B \<le> y" by auto |
41976 | 2565 |
qed |
41973 | 2566 |
qed |
2567 |
||
43920 | 2568 |
lemma fixes x y :: ereal |
41978 | 2569 |
shows Sup_atMost[simp]: "Sup {.. y} = y" |
2570 |
and Sup_lessThan[simp]: "Sup {..< y} = y" |
|
2571 |
and Sup_atLeastAtMost[simp]: "x \<le> y \<Longrightarrow> Sup { x .. y} = y" |
|
2572 |
and Sup_greaterThanAtMost[simp]: "x < y \<Longrightarrow> Sup { x <.. y} = y" |
|
2573 |
and Sup_atLeastLessThan[simp]: "x < y \<Longrightarrow> Sup { x ..< y} = y" |
|
43920 | 2574 |
by (auto simp: Sup_ereal_def intro!: Least_equality |
2575 |
intro: ereal_le_ereal ereal_le_ereal_bounded[of x]) |
|
41978 | 2576 |
|
2577 |
lemma Sup_greaterThanlessThan[simp]: |
|
43920 | 2578 |
fixes x y :: ereal assumes "x < y" shows "Sup { x <..< y} = y" |
2579 |
unfolding Sup_ereal_def |
|
2580 |
proof (intro Least_equality ereal_le_ereal_bounded[of _ _ y]) |
|
41978 | 2581 |
fix z assume z: "\<forall>u\<in>{x<..<y}. u \<le> z" |
43920 | 2582 |
from ereal_dense[OF `x < y`] guess w .. note w = this |
41978 | 2583 |
with z[THEN bspec, of w] show "x \<le> z" by auto |
2584 |
qed auto |
|
2585 |
||
43920 | 2586 |
lemma real_ereal_id: "real o ereal = id" |
41973 | 2587 |
proof- |
47082 | 2588 |
{ fix x have "(real o ereal) x = id x" by auto } |
2589 |
then show ?thesis using ext by blast |
|
41973 | 2590 |
qed |
2591 |
||
43923 | 2592 |
lemma open_image_ereal: "open(UNIV-{ \<infinity> , (-\<infinity> :: ereal)})" |
43920 | 2593 |
by (metis range_ereal open_ereal open_UNIV) |
41973 | 2594 |
|
43920 | 2595 |
lemma ereal_le_distrib: |
2596 |
fixes a b c :: ereal shows "c * (a + b) \<le> c * a + c * b" |
|
2597 |
by (cases rule: ereal3_cases[of a b c]) |
|
41973 | 2598 |
(auto simp add: field_simps not_le mult_le_0_iff mult_less_0_iff) |
2599 |
||
43920 | 2600 |
lemma ereal_pos_distrib: |
2601 |
fixes a b c :: ereal assumes "0 \<le> c" "c \<noteq> \<infinity>" shows "c * (a + b) = c * a + c * b" |
|
2602 |
using assms by (cases rule: ereal3_cases[of a b c]) |
|
41973 | 2603 |
(auto simp add: field_simps not_le mult_le_0_iff mult_less_0_iff) |
2604 |
||
43920 | 2605 |
lemma ereal_pos_le_distrib: |
2606 |
fixes a b c :: ereal |
|
41973 | 2607 |
assumes "c>=0" |
2608 |
shows "c * (a + b) <= c * a + c * b" |
|
43920 | 2609 |
using assms by (cases rule: ereal3_cases[of a b c]) |
41973 | 2610 |
(auto simp add: field_simps) |
2611 |
||
43920 | 2612 |
lemma ereal_max_mono: |
2613 |
"[| (a::ereal) <= b; c <= d |] ==> max a c <= max b d" |
|
2614 |
by (metis sup_ereal_def sup_mono) |
|
41973 | 2615 |
|
2616 |
||
43920 | 2617 |
lemma ereal_max_least: |
2618 |
"[| (a::ereal) <= x; c <= x |] ==> max a c <= x" |
|
2619 |
by (metis sup_ereal_def sup_least) |
|
41973 | 2620 |
|
43933 | 2621 |
subsubsection {* Tests for code generator *} |
2622 |
||
2623 |
(* A small list of simple arithmetic expressions *) |
|
2624 |
||
2625 |
value [code] "- \<infinity> :: ereal" |
|
2626 |
value [code] "\<bar>-\<infinity>\<bar> :: ereal" |
|
2627 |
value [code] "4 + 5 / 4 - ereal 2 :: ereal" |
|
2628 |
value [code] "ereal 3 < \<infinity>" |
|
2629 |
value [code] "real (\<infinity>::ereal) = 0" |
|
2630 |
||
41973 | 2631 |
end |