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