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