| author | haftmann | 
| Wed, 27 Jan 2010 14:03:08 +0100 | |
| changeset 34972 | cc1d4c3ca9db | 
| parent 34964 | 4e8be3c04d37 | 
| child 34999 | 5312d2ffee3b | 
| permissions | -rw-r--r-- | 
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 1 | (* title: HOL/Library/Topology_Euclidian_Space.thy | 
| 33175 | 2 | Author: Amine Chaieb, University of Cambridge | 
| 3 | Author: Robert Himmelmann, TU Muenchen | |
| 4 | *) | |
| 5 | ||
| 6 | header {* Elementary topology in Euclidean space. *}
 | |
| 7 | ||
| 8 | theory Topology_Euclidean_Space | |
| 9 | imports SEQ Euclidean_Space Product_Vector | |
| 10 | begin | |
| 11 | ||
| 12 | subsection{* General notion of a topology *}
 | |
| 13 | ||
| 14 | definition "istopology L \<longleftrightarrow> {} \<in> L \<and> (\<forall>S \<in>L. \<forall>T \<in>L. S \<inter> T \<in> L) \<and> (\<forall>K. K \<subseteq>L \<longrightarrow> \<Union> K \<in> L)"
 | |
| 15 | typedef (open) 'a topology = "{L::('a set) set. istopology L}"
 | |
| 16 | morphisms "openin" "topology" | |
| 17 | unfolding istopology_def by blast | |
| 18 | ||
| 19 | lemma istopology_open_in[intro]: "istopology(openin U)" | |
| 20 | using openin[of U] by blast | |
| 21 | ||
| 22 | lemma topology_inverse': "istopology U \<Longrightarrow> openin (topology U) = U" | |
| 23 | using topology_inverse[unfolded mem_def Collect_def] . | |
| 24 | ||
| 25 | lemma topology_inverse_iff: "istopology U \<longleftrightarrow> openin (topology U) = U" | |
| 26 | using topology_inverse[of U] istopology_open_in[of "topology U"] by auto | |
| 27 | ||
| 28 | lemma topology_eq: "T1 = T2 \<longleftrightarrow> (\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S)" | |
| 29 | proof- | |
| 30 |   {assume "T1=T2" hence "\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S" by simp}
 | |
| 31 | moreover | |
| 32 |   {assume H: "\<forall>S. openin T1 S \<longleftrightarrow> openin T2 S"
 | |
| 33 | hence "openin T1 = openin T2" by (metis mem_def set_ext) | |
| 34 | hence "topology (openin T1) = topology (openin T2)" by simp | |
| 35 | hence "T1 = T2" unfolding openin_inverse .} | |
| 36 | ultimately show ?thesis by blast | |
| 37 | qed | |
| 38 | ||
| 39 | text{* Infer the "universe" from union of all sets in the topology. *}
 | |
| 40 | ||
| 41 | definition "topspace T =  \<Union>{S. openin T S}"
 | |
| 42 | ||
| 43 | subsection{* Main properties of open sets *}
 | |
| 44 | ||
| 45 | lemma openin_clauses: | |
| 46 | fixes U :: "'a topology" | |
| 47 |   shows "openin U {}"
 | |
| 48 | "\<And>S T. openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S\<inter>T)" | |
| 49 | "\<And>K. (\<forall>S \<in> K. openin U S) \<Longrightarrow> openin U (\<Union>K)" | |
| 50 | using openin[of U] unfolding istopology_def Collect_def mem_def | |
| 51 | by (metis mem_def subset_eq)+ | |
| 52 | ||
| 53 | lemma openin_subset[intro]: "openin U S \<Longrightarrow> S \<subseteq> topspace U" | |
| 54 | unfolding topspace_def by blast | |
| 55 | lemma openin_empty[simp]: "openin U {}" by (simp add: openin_clauses)
 | |
| 56 | ||
| 57 | lemma openin_Int[intro]: "openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S \<inter> T)" | |
| 58 | by (simp add: openin_clauses) | |
| 59 | ||
| 60 | lemma openin_Union[intro]: "(\<forall>S \<in>K. openin U S) \<Longrightarrow> openin U (\<Union> K)" by (simp add: openin_clauses) | |
| 61 | ||
| 62 | lemma openin_Un[intro]: "openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S \<union> T)" | |
| 63 |   using openin_Union[of "{S,T}" U] by auto
 | |
| 64 | ||
| 65 | lemma openin_topspace[intro, simp]: "openin U (topspace U)" by (simp add: openin_Union topspace_def) | |
| 66 | ||
| 67 | lemma openin_subopen: "openin U S \<longleftrightarrow> (\<forall>x \<in> S. \<exists>T. openin U T \<and> x \<in> T \<and> T \<subseteq> S)" (is "?lhs \<longleftrightarrow> ?rhs") | |
| 68 | proof- | |
| 69 |   {assume ?lhs then have ?rhs by auto }
 | |
| 70 | moreover | |
| 71 |   {assume H: ?rhs
 | |
| 72 | then obtain t where t: "\<forall>x\<in>S. openin U (t x) \<and> x \<in> t x \<and> t x \<subseteq> S" | |
| 73 | unfolding Ball_def ex_simps(6)[symmetric] choice_iff by blast | |
| 74 | from t have th0: "\<forall>x\<in> t`S. openin U x" by auto | |
| 75 | have "\<Union> t`S = S" using t by auto | |
| 76 | with openin_Union[OF th0] have "openin U S" by simp } | |
| 77 | ultimately show ?thesis by blast | |
| 78 | qed | |
| 79 | ||
| 80 | subsection{* Closed sets *}
 | |
| 81 | ||
| 82 | definition "closedin U S \<longleftrightarrow> S \<subseteq> topspace U \<and> openin U (topspace U - S)" | |
| 83 | ||
| 84 | lemma closedin_subset: "closedin U S \<Longrightarrow> S \<subseteq> topspace U" by (metis closedin_def) | |
| 85 | lemma closedin_empty[simp]: "closedin U {}" by (simp add: closedin_def)
 | |
| 86 | lemma closedin_topspace[intro,simp]: | |
| 87 | "closedin U (topspace U)" by (simp add: closedin_def) | |
| 88 | lemma closedin_Un[intro]: "closedin U S \<Longrightarrow> closedin U T \<Longrightarrow> closedin U (S \<union> T)" | |
| 89 | by (auto simp add: Diff_Un closedin_def) | |
| 90 | ||
| 91 | lemma Diff_Inter[intro]: "A - \<Inter>S = \<Union> {A - s|s. s\<in>S}" by auto
 | |
| 92 | lemma closedin_Inter[intro]: assumes Ke: "K \<noteq> {}" and Kc: "\<forall>S \<in>K. closedin U S"
 | |
| 93 | shows "closedin U (\<Inter> K)" using Ke Kc unfolding closedin_def Diff_Inter by auto | |
| 94 | ||
| 95 | lemma closedin_Int[intro]: "closedin U S \<Longrightarrow> closedin U T \<Longrightarrow> closedin U (S \<inter> T)" | |
| 96 |   using closedin_Inter[of "{S,T}" U] by auto
 | |
| 97 | ||
| 98 | lemma Diff_Diff_Int: "A - (A - B) = A \<inter> B" by blast | |
| 99 | lemma openin_closedin_eq: "openin U S \<longleftrightarrow> S \<subseteq> topspace U \<and> closedin U (topspace U - S)" | |
| 100 | apply (auto simp add: closedin_def Diff_Diff_Int inf_absorb2) | |
| 101 | apply (metis openin_subset subset_eq) | |
| 102 | done | |
| 103 | ||
| 104 | lemma openin_closedin: "S \<subseteq> topspace U \<Longrightarrow> (openin U S \<longleftrightarrow> closedin U (topspace U - S))" | |
| 105 | by (simp add: openin_closedin_eq) | |
| 106 | ||
| 107 | lemma openin_diff[intro]: assumes oS: "openin U S" and cT: "closedin U T" shows "openin U (S - T)" | |
| 108 | proof- | |
| 109 | have "S - T = S \<inter> (topspace U - T)" using openin_subset[of U S] oS cT | |
| 110 | by (auto simp add: topspace_def openin_subset) | |
| 111 | then show ?thesis using oS cT by (auto simp add: closedin_def) | |
| 112 | qed | |
| 113 | ||
| 114 | lemma closedin_diff[intro]: assumes oS: "closedin U S" and cT: "openin U T" shows "closedin U (S - T)" | |
| 115 | proof- | |
| 116 | have "S - T = S \<inter> (topspace U - T)" using closedin_subset[of U S] oS cT | |
| 117 | by (auto simp add: topspace_def ) | |
| 118 | then show ?thesis using oS cT by (auto simp add: openin_closedin_eq) | |
| 119 | qed | |
| 120 | ||
| 121 | subsection{* Subspace topology. *}
 | |
| 122 | ||
| 123 | definition "subtopology U V = topology {S \<inter> V |S. openin U S}"
 | |
| 124 | ||
| 125 | lemma istopology_subtopology: "istopology {S \<inter> V |S. openin U S}" (is "istopology ?L")
 | |
| 126 | proof- | |
| 127 |   have "{} \<in> ?L" by blast
 | |
| 128 |   {fix A B assume A: "A \<in> ?L" and B: "B \<in> ?L"
 | |
| 129 | from A B obtain Sa and Sb where Sa: "openin U Sa" "A = Sa \<inter> V" and Sb: "openin U Sb" "B = Sb \<inter> V" by blast | |
| 130 | have "A\<inter>B = (Sa \<inter> Sb) \<inter> V" "openin U (Sa \<inter> Sb)" using Sa Sb by blast+ | |
| 131 | then have "A \<inter> B \<in> ?L" by blast} | |
| 132 | moreover | |
| 133 |   {fix K assume K: "K \<subseteq> ?L"
 | |
| 134 | have th0: "?L = (\<lambda>S. S \<inter> V) ` openin U " | |
| 135 | apply (rule set_ext) | |
| 136 | apply (simp add: Ball_def image_iff) | |
| 137 | by (metis mem_def) | |
| 138 | from K[unfolded th0 subset_image_iff] | |
| 139 | obtain Sk where Sk: "Sk \<subseteq> openin U" "K = (\<lambda>S. S \<inter> V) ` Sk" by blast | |
| 140 | have "\<Union>K = (\<Union>Sk) \<inter> V" using Sk by auto | |
| 141 | moreover have "openin U (\<Union> Sk)" using Sk by (auto simp add: subset_eq mem_def) | |
| 142 | ultimately have "\<Union>K \<in> ?L" by blast} | |
| 143 | ultimately show ?thesis unfolding istopology_def by blast | |
| 144 | qed | |
| 145 | ||
| 146 | lemma openin_subtopology: | |
| 147 | "openin (subtopology U V) S \<longleftrightarrow> (\<exists> T. (openin U T) \<and> (S = T \<inter> V))" | |
| 148 | unfolding subtopology_def topology_inverse'[OF istopology_subtopology] | |
| 149 | by (auto simp add: Collect_def) | |
| 150 | ||
| 151 | lemma topspace_subtopology: "topspace(subtopology U V) = topspace U \<inter> V" | |
| 152 | by (auto simp add: topspace_def openin_subtopology) | |
| 153 | ||
| 154 | lemma closedin_subtopology: | |
| 155 | "closedin (subtopology U V) S \<longleftrightarrow> (\<exists>T. closedin U T \<and> S = T \<inter> V)" | |
| 156 | unfolding closedin_def topspace_subtopology | |
| 157 | apply (simp add: openin_subtopology) | |
| 158 | apply (rule iffI) | |
| 159 | apply clarify | |
| 160 | apply (rule_tac x="topspace U - T" in exI) | |
| 161 | by auto | |
| 162 | ||
| 163 | lemma openin_subtopology_refl: "openin (subtopology U V) V \<longleftrightarrow> V \<subseteq> topspace U" | |
| 164 | unfolding openin_subtopology | |
| 165 | apply (rule iffI, clarify) | |
| 166 | apply (frule openin_subset[of U]) apply blast | |
| 167 | apply (rule exI[where x="topspace U"]) | |
| 168 | by auto | |
| 169 | ||
| 170 | lemma subtopology_superset: assumes UV: "topspace U \<subseteq> V" | |
| 171 | shows "subtopology U V = U" | |
| 172 | proof- | |
| 173 |   {fix S
 | |
| 174 |     {fix T assume T: "openin U T" "S = T \<inter> V"
 | |
| 175 | from T openin_subset[OF T(1)] UV have eq: "S = T" by blast | |
| 176 | have "openin U S" unfolding eq using T by blast} | |
| 177 | moreover | |
| 178 |     {assume S: "openin U S"
 | |
| 179 | hence "\<exists>T. openin U T \<and> S = T \<inter> V" | |
| 180 | using openin_subset[OF S] UV by auto} | |
| 181 | ultimately have "(\<exists>T. openin U T \<and> S = T \<inter> V) \<longleftrightarrow> openin U S" by blast} | |
| 182 | then show ?thesis unfolding topology_eq openin_subtopology by blast | |
| 183 | qed | |
| 184 | ||
| 185 | ||
| 186 | lemma subtopology_topspace[simp]: "subtopology U (topspace U) = U" | |
| 187 | by (simp add: subtopology_superset) | |
| 188 | ||
| 189 | lemma subtopology_UNIV[simp]: "subtopology U UNIV = U" | |
| 190 | by (simp add: subtopology_superset) | |
| 191 | ||
| 192 | subsection{* The universal Euclidean versions are what we use most of the time *}
 | |
| 193 | ||
| 194 | definition | |
| 195 | euclidean :: "'a::topological_space topology" where | |
| 196 | "euclidean = topology open" | |
| 197 | ||
| 198 | lemma open_openin: "open S \<longleftrightarrow> openin euclidean S" | |
| 199 | unfolding euclidean_def | |
| 200 | apply (rule cong[where x=S and y=S]) | |
| 201 | apply (rule topology_inverse[symmetric]) | |
| 202 | apply (auto simp add: istopology_def) | |
| 203 | by (auto simp add: mem_def subset_eq) | |
| 204 | ||
| 205 | lemma topspace_euclidean: "topspace euclidean = UNIV" | |
| 206 | apply (simp add: topspace_def) | |
| 207 | apply (rule set_ext) | |
| 208 | by (auto simp add: open_openin[symmetric]) | |
| 209 | ||
| 210 | lemma topspace_euclidean_subtopology[simp]: "topspace (subtopology euclidean S) = S" | |
| 211 | by (simp add: topspace_euclidean topspace_subtopology) | |
| 212 | ||
| 213 | lemma closed_closedin: "closed S \<longleftrightarrow> closedin euclidean S" | |
| 214 | by (simp add: closed_def closedin_def topspace_euclidean open_openin Compl_eq_Diff_UNIV) | |
| 215 | ||
| 216 | lemma open_subopen: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>T. open T \<and> x \<in> T \<and> T \<subseteq> S)" | |
| 217 | by (simp add: open_openin openin_subopen[symmetric]) | |
| 218 | ||
| 219 | subsection{* Open and closed balls. *}
 | |
| 220 | ||
| 221 | definition | |
| 222 | ball :: "'a::metric_space \<Rightarrow> real \<Rightarrow> 'a set" where | |
| 223 |   "ball x e = {y. dist x y < e}"
 | |
| 224 | ||
| 225 | definition | |
| 226 | cball :: "'a::metric_space \<Rightarrow> real \<Rightarrow> 'a set" where | |
| 227 |   "cball x e = {y. dist x y \<le> e}"
 | |
| 228 | ||
| 229 | lemma mem_ball[simp]: "y \<in> ball x e \<longleftrightarrow> dist x y < e" by (simp add: ball_def) | |
| 230 | lemma mem_cball[simp]: "y \<in> cball x e \<longleftrightarrow> dist x y \<le> e" by (simp add: cball_def) | |
| 231 | ||
| 232 | lemma mem_ball_0 [simp]: | |
| 233 | fixes x :: "'a::real_normed_vector" | |
| 234 | shows "x \<in> ball 0 e \<longleftrightarrow> norm x < e" | |
| 235 | by (simp add: dist_norm) | |
| 236 | ||
| 237 | lemma mem_cball_0 [simp]: | |
| 238 | fixes x :: "'a::real_normed_vector" | |
| 239 | shows "x \<in> cball 0 e \<longleftrightarrow> norm x \<le> e" | |
| 240 | by (simp add: dist_norm) | |
| 241 | ||
| 242 | lemma centre_in_cball[simp]: "x \<in> cball x e \<longleftrightarrow> 0\<le> e" by simp | |
| 243 | lemma ball_subset_cball[simp,intro]: "ball x e \<subseteq> cball x e" by (simp add: subset_eq) | |
| 244 | lemma subset_ball[intro]: "d <= e ==> ball x d \<subseteq> ball x e" by (simp add: subset_eq) | |
| 245 | lemma subset_cball[intro]: "d <= e ==> cball x d \<subseteq> cball x e" by (simp add: subset_eq) | |
| 246 | lemma ball_max_Un: "ball a (max r s) = ball a r \<union> ball a s" | |
| 247 | by (simp add: expand_set_eq) arith | |
| 248 | ||
| 249 | lemma ball_min_Int: "ball a (min r s) = ball a r \<inter> ball a s" | |
| 250 | by (simp add: expand_set_eq) | |
| 251 | ||
| 252 | subsection{* Topological properties of open balls *}
 | |
| 253 | ||
| 254 | lemma diff_less_iff: "(a::real) - b > 0 \<longleftrightarrow> a > b" | |
| 255 | "(a::real) - b < 0 \<longleftrightarrow> a < b" | |
| 256 | "a - b < c \<longleftrightarrow> a < c +b" "a - b > c \<longleftrightarrow> a > c +b" by arith+ | |
| 257 | lemma diff_le_iff: "(a::real) - b \<ge> 0 \<longleftrightarrow> a \<ge> b" "(a::real) - b \<le> 0 \<longleftrightarrow> a \<le> b" | |
| 258 | "a - b \<le> c \<longleftrightarrow> a \<le> c +b" "a - b \<ge> c \<longleftrightarrow> a \<ge> c +b" by arith+ | |
| 259 | ||
| 260 | lemma open_ball[intro, simp]: "open (ball x e)" | |
| 261 | unfolding open_dist ball_def Collect_def Ball_def mem_def | |
| 262 | unfolding dist_commute | |
| 263 | apply clarify | |
| 264 | apply (rule_tac x="e - dist xa x" in exI) | |
| 265 | using dist_triangle_alt[where z=x] | |
| 266 | apply (clarsimp simp add: diff_less_iff) | |
| 267 | apply atomize | |
| 268 | apply (erule_tac x="y" in allE) | |
| 269 | apply (erule_tac x="xa" in allE) | |
| 270 | by arith | |
| 271 | ||
| 272 | lemma centre_in_ball[simp]: "x \<in> ball x e \<longleftrightarrow> e > 0" by (metis mem_ball dist_self) | |
| 273 | lemma open_contains_ball: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. ball x e \<subseteq> S)" | |
| 274 | unfolding open_dist subset_eq mem_ball Ball_def dist_commute .. | |
| 275 | ||
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 276 | lemma openE[elim?]: | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 277 | assumes "open S" "x\<in>S" | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 278 | obtains e where "e>0" "ball x e \<subseteq> S" | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 279 | using assms unfolding open_contains_ball by auto | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 280 | |
| 33175 | 281 | lemma open_contains_ball_eq: "open S \<Longrightarrow> \<forall>x. x\<in>S \<longleftrightarrow> (\<exists>e>0. ball x e \<subseteq> S)" | 
| 282 | by (metis open_contains_ball subset_eq centre_in_ball) | |
| 283 | ||
| 284 | lemma ball_eq_empty[simp]: "ball x e = {} \<longleftrightarrow> e \<le> 0"
 | |
| 285 | unfolding mem_ball expand_set_eq | |
| 286 | apply (simp add: not_less) | |
| 287 | by (metis zero_le_dist order_trans dist_self) | |
| 288 | ||
| 289 | lemma ball_empty[intro]: "e \<le> 0 ==> ball x e = {}" by simp
 | |
| 290 | ||
| 291 | subsection{* Basic "localization" results are handy for connectedness. *}
 | |
| 292 | ||
| 293 | lemma openin_open: "openin (subtopology euclidean U) S \<longleftrightarrow> (\<exists>T. open T \<and> (S = U \<inter> T))" | |
| 294 | by (auto simp add: openin_subtopology open_openin[symmetric]) | |
| 295 | ||
| 296 | lemma openin_open_Int[intro]: "open S \<Longrightarrow> openin (subtopology euclidean U) (U \<inter> S)" | |
| 297 | by (auto simp add: openin_open) | |
| 298 | ||
| 299 | lemma open_openin_trans[trans]: | |
| 300 | "open S \<Longrightarrow> open T \<Longrightarrow> T \<subseteq> S \<Longrightarrow> openin (subtopology euclidean S) T" | |
| 301 | by (metis Int_absorb1 openin_open_Int) | |
| 302 | ||
| 303 | lemma open_subset: "S \<subseteq> T \<Longrightarrow> open S \<Longrightarrow> openin (subtopology euclidean T) S" | |
| 304 | by (auto simp add: openin_open) | |
| 305 | ||
| 306 | lemma closedin_closed: "closedin (subtopology euclidean U) S \<longleftrightarrow> (\<exists>T. closed T \<and> S = U \<inter> T)" | |
| 307 | by (simp add: closedin_subtopology closed_closedin Int_ac) | |
| 308 | ||
| 309 | lemma closedin_closed_Int: "closed S ==> closedin (subtopology euclidean U) (U \<inter> S)" | |
| 310 | by (metis closedin_closed) | |
| 311 | ||
| 312 | lemma closed_closedin_trans: "closed S \<Longrightarrow> closed T \<Longrightarrow> T \<subseteq> S \<Longrightarrow> closedin (subtopology euclidean S) T" | |
| 313 | apply (subgoal_tac "S \<inter> T = T" ) | |
| 314 | apply auto | |
| 315 | apply (frule closedin_closed_Int[of T S]) | |
| 316 | by simp | |
| 317 | ||
| 318 | lemma closed_subset: "S \<subseteq> T \<Longrightarrow> closed S \<Longrightarrow> closedin (subtopology euclidean T) S" | |
| 319 | by (auto simp add: closedin_closed) | |
| 320 | ||
| 321 | lemma openin_euclidean_subtopology_iff: | |
| 322 | fixes S U :: "'a::metric_space set" | |
| 323 | shows "openin (subtopology euclidean U) S | |
| 324 | \<longleftrightarrow> S \<subseteq> U \<and> (\<forall>x\<in>S. \<exists>e>0. \<forall>x'\<in>U. dist x' x < e \<longrightarrow> x'\<in> S)" (is "?lhs \<longleftrightarrow> ?rhs") | |
| 325 | proof- | |
| 326 |   {assume ?lhs hence ?rhs unfolding openin_subtopology open_openin[symmetric]
 | |
| 327 | by (simp add: open_dist) blast} | |
| 328 | moreover | |
| 329 |   {assume SU: "S \<subseteq> U" and H: "\<And>x. x \<in> S \<Longrightarrow> \<exists>e>0. \<forall>x'\<in>U. dist x' x < e \<longrightarrow> x' \<in> S"
 | |
| 330 | from H obtain d where d: "\<And>x . x\<in> S \<Longrightarrow> d x > 0 \<and> (\<forall>x' \<in> U. dist x' x < d x \<longrightarrow> x' \<in> S)" | |
| 331 | by metis | |
| 332 |     let ?T = "\<Union>{B. \<exists>x\<in>S. B = ball x (d x)}"
 | |
| 333 | have oT: "open ?T" by auto | |
| 334 |     { fix x assume "x\<in>S"
 | |
| 335 |       hence "x \<in> \<Union>{B. \<exists>x\<in>S. B = ball x (d x)}"
 | |
| 336 | apply simp apply(rule_tac x="ball x(d x)" in exI) apply auto | |
| 337 | by (rule d [THEN conjunct1]) | |
| 338 | hence "x\<in> ?T \<inter> U" using SU and `x\<in>S` by auto } | |
| 339 | moreover | |
| 340 |     { fix y assume "y\<in>?T"
 | |
| 341 |       then obtain B where "y\<in>B" "B\<in>{B. \<exists>x\<in>S. B = ball x (d x)}" by auto
 | |
| 342 | then obtain x where "x\<in>S" and x:"y \<in> ball x (d x)" by auto | |
| 343 | assume "y\<in>U" | |
| 344 | hence "y\<in>S" using d[OF `x\<in>S`] and x by(auto simp add: dist_commute) } | |
| 345 | ultimately have "S = ?T \<inter> U" by blast | |
| 346 | with oT have ?lhs unfolding openin_subtopology open_openin[symmetric] by blast} | |
| 347 | ultimately show ?thesis by blast | |
| 348 | qed | |
| 349 | ||
| 350 | text{* These "transitivity" results are handy too. *}
 | |
| 351 | ||
| 352 | lemma openin_trans[trans]: "openin (subtopology euclidean T) S \<Longrightarrow> openin (subtopology euclidean U) T | |
| 353 | \<Longrightarrow> openin (subtopology euclidean U) S" | |
| 354 | unfolding open_openin openin_open by blast | |
| 355 | ||
| 356 | lemma openin_open_trans: "openin (subtopology euclidean T) S \<Longrightarrow> open T \<Longrightarrow> open S" | |
| 357 | by (auto simp add: openin_open intro: openin_trans) | |
| 358 | ||
| 359 | lemma closedin_trans[trans]: | |
| 360 | "closedin (subtopology euclidean T) S \<Longrightarrow> | |
| 361 | closedin (subtopology euclidean U) T | |
| 362 | ==> closedin (subtopology euclidean U) S" | |
| 363 | by (auto simp add: closedin_closed closed_closedin closed_Inter Int_assoc) | |
| 364 | ||
| 365 | lemma closedin_closed_trans: "closedin (subtopology euclidean T) S \<Longrightarrow> closed T \<Longrightarrow> closed S" | |
| 366 | by (auto simp add: closedin_closed intro: closedin_trans) | |
| 367 | ||
| 368 | subsection{* Connectedness *}
 | |
| 369 | ||
| 370 | definition "connected S \<longleftrightarrow> | |
| 371 |   ~(\<exists>e1 e2. open e1 \<and> open e2 \<and> S \<subseteq> (e1 \<union> e2) \<and> (e1 \<inter> e2 \<inter> S = {})
 | |
| 372 |   \<and> ~(e1 \<inter> S = {}) \<and> ~(e2 \<inter> S = {}))"
 | |
| 373 | ||
| 374 | lemma connected_local: | |
| 375 | "connected S \<longleftrightarrow> ~(\<exists>e1 e2. | |
| 376 | openin (subtopology euclidean S) e1 \<and> | |
| 377 | openin (subtopology euclidean S) e2 \<and> | |
| 378 | S \<subseteq> e1 \<union> e2 \<and> | |
| 379 |                  e1 \<inter> e2 = {} \<and>
 | |
| 380 |                  ~(e1 = {}) \<and>
 | |
| 381 |                  ~(e2 = {}))"
 | |
| 382 | unfolding connected_def openin_open by (safe, blast+) | |
| 383 | ||
| 34105 | 384 | lemma exists_diff: | 
| 385 | fixes P :: "'a set \<Rightarrow> bool" | |
| 386 | shows "(\<exists>S. P(- S)) \<longleftrightarrow> (\<exists>S. P S)" (is "?lhs \<longleftrightarrow> ?rhs") | |
| 33175 | 387 | proof- | 
| 388 |   {assume "?lhs" hence ?rhs by blast }
 | |
| 389 | moreover | |
| 390 |   {fix S assume H: "P S"
 | |
| 34105 | 391 | have "S = - (- S)" by auto | 
| 392 | with H have "P (- (- S))" by metis } | |
| 33175 | 393 | ultimately show ?thesis by metis | 
| 394 | qed | |
| 395 | ||
| 396 | lemma connected_clopen: "connected S \<longleftrightarrow> | |
| 397 | (\<forall>T. openin (subtopology euclidean S) T \<and> | |
| 398 |             closedin (subtopology euclidean S) T \<longrightarrow> T = {} \<or> T = S)" (is "?lhs \<longleftrightarrow> ?rhs")
 | |
| 399 | proof- | |
| 34105 | 400 |   have " \<not> connected S \<longleftrightarrow> (\<exists>e1 e2. open e1 \<and> open (- e2) \<and> S \<subseteq> e1 \<union> (- e2) \<and> e1 \<inter> (- e2) \<inter> S = {} \<and> e1 \<inter> S \<noteq> {} \<and> (- e2) \<inter> S \<noteq> {})"
 | 
| 33175 | 401 | unfolding connected_def openin_open closedin_closed | 
| 402 | apply (subst exists_diff) by blast | |
| 34105 | 403 |   hence th0: "connected S \<longleftrightarrow> \<not> (\<exists>e2 e1. closed e2 \<and> open e1 \<and> S \<subseteq> e1 \<union> (- e2) \<and> e1 \<inter> (- e2) \<inter> S = {} \<and> e1 \<inter> S \<noteq> {} \<and> (- e2) \<inter> S \<noteq> {})"
 | 
| 404 | (is " _ \<longleftrightarrow> \<not> (\<exists>e2 e1. ?P e2 e1)") apply (simp add: closed_def) by metis | |
| 33175 | 405 | |
| 406 |   have th1: "?rhs \<longleftrightarrow> \<not> (\<exists>t' t. closed t'\<and>t = S\<inter>t' \<and> t\<noteq>{} \<and> t\<noteq>S \<and> (\<exists>t'. open t' \<and> t = S \<inter> t'))"
 | |
| 407 | (is "_ \<longleftrightarrow> \<not> (\<exists>t' t. ?Q t' t)") | |
| 408 | unfolding connected_def openin_open closedin_closed by auto | |
| 409 |   {fix e2
 | |
| 410 |     {fix e1 have "?P e2 e1 \<longleftrightarrow> (\<exists>t.  closed e2 \<and> t = S\<inter>e2 \<and> open e1 \<and> t = S\<inter>e1 \<and> t\<noteq>{} \<and> t\<noteq>S)"
 | |
| 411 | by auto} | |
| 412 | then have "(\<exists>e1. ?P e2 e1) \<longleftrightarrow> (\<exists>t. ?Q e2 t)" by metis} | |
| 413 | then have "\<forall>e2. (\<exists>e1. ?P e2 e1) \<longleftrightarrow> (\<exists>t. ?Q e2 t)" by blast | |
| 414 | then show ?thesis unfolding th0 th1 by simp | |
| 415 | qed | |
| 416 | ||
| 417 | lemma connected_empty[simp, intro]: "connected {}"
 | |
| 418 | by (simp add: connected_def) | |
| 419 | ||
| 420 | subsection{* Hausdorff and other separation properties *}
 | |
| 421 | ||
| 422 | class t0_space = | |
| 423 | assumes t0_space: "x \<noteq> y \<Longrightarrow> \<exists>U. open U \<and> \<not> (x \<in> U \<longleftrightarrow> y \<in> U)" | |
| 424 | ||
| 425 | class t1_space = | |
| 426 | assumes t1_space: "x \<noteq> y \<Longrightarrow> \<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<notin> U \<and> x \<notin> V \<and> y \<in> V" | |
| 427 | begin | |
| 428 | ||
| 429 | subclass t0_space | |
| 430 | proof | |
| 431 | qed (fast dest: t1_space) | |
| 432 | ||
| 433 | end | |
| 434 | ||
| 435 | text {* T2 spaces are also known as Hausdorff spaces. *}
 | |
| 436 | ||
| 437 | class t2_space = | |
| 438 |   assumes hausdorff: "x \<noteq> y \<Longrightarrow> \<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {}"
 | |
| 439 | begin | |
| 440 | ||
| 441 | subclass t1_space | |
| 442 | proof | |
| 443 | qed (fast dest: hausdorff) | |
| 444 | ||
| 445 | end | |
| 446 | ||
| 447 | instance metric_space \<subseteq> t2_space | |
| 448 | proof | |
| 449 | fix x y :: "'a::metric_space" | |
| 450 | assume xy: "x \<noteq> y" | |
| 451 | let ?U = "ball x (dist x y / 2)" | |
| 452 | let ?V = "ball y (dist x y / 2)" | |
| 453 | have th0: "\<And>d x y z. (d x z :: real) <= d x y + d y z \<Longrightarrow> d y z = d z y | |
| 454 | ==> ~(d x y * 2 < d x z \<and> d z y * 2 < d x z)" by arith | |
| 455 |   have "open ?U \<and> open ?V \<and> x \<in> ?U \<and> y \<in> ?V \<and> ?U \<inter> ?V = {}"
 | |
| 456 | using dist_pos_lt[OF xy] th0[of dist,OF dist_triangle dist_commute] | |
| 457 | by (auto simp add: expand_set_eq) | |
| 458 |   then show "\<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {}"
 | |
| 459 | by blast | |
| 460 | qed | |
| 461 | ||
| 462 | lemma separation_t2: | |
| 463 | fixes x y :: "'a::t2_space" | |
| 464 |   shows "x \<noteq> y \<longleftrightarrow> (\<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {})"
 | |
| 465 | using hausdorff[of x y] by blast | |
| 466 | ||
| 467 | lemma separation_t1: | |
| 468 | fixes x y :: "'a::t1_space" | |
| 469 | shows "x \<noteq> y \<longleftrightarrow> (\<exists>U V. open U \<and> open V \<and> x \<in>U \<and> y\<notin> U \<and> x\<notin>V \<and> y\<in>V)" | |
| 470 | using t1_space[of x y] by blast | |
| 471 | ||
| 472 | lemma separation_t0: | |
| 473 | fixes x y :: "'a::t0_space" | |
| 474 | shows "x \<noteq> y \<longleftrightarrow> (\<exists>U. open U \<and> ~(x\<in>U \<longleftrightarrow> y\<in>U))" | |
| 475 | using t0_space[of x y] by blast | |
| 476 | ||
| 477 | subsection{* Limit points *}
 | |
| 478 | ||
| 479 | definition | |
| 480 | islimpt:: "'a::topological_space \<Rightarrow> 'a set \<Rightarrow> bool" | |
| 481 | (infixr "islimpt" 60) where | |
| 482 | "x islimpt S \<longleftrightarrow> (\<forall>T. x\<in>T \<longrightarrow> open T \<longrightarrow> (\<exists>y\<in>S. y\<in>T \<and> y\<noteq>x))" | |
| 483 | ||
| 484 | lemma islimptI: | |
| 485 | assumes "\<And>T. x \<in> T \<Longrightarrow> open T \<Longrightarrow> \<exists>y\<in>S. y \<in> T \<and> y \<noteq> x" | |
| 486 | shows "x islimpt S" | |
| 487 | using assms unfolding islimpt_def by auto | |
| 488 | ||
| 489 | lemma islimptE: | |
| 490 | assumes "x islimpt S" and "x \<in> T" and "open T" | |
| 491 | obtains y where "y \<in> S" and "y \<in> T" and "y \<noteq> x" | |
| 492 | using assms unfolding islimpt_def by auto | |
| 493 | ||
| 494 | lemma islimpt_subset: "x islimpt S \<Longrightarrow> S \<subseteq> T ==> x islimpt T" by (auto simp add: islimpt_def) | |
| 495 | ||
| 496 | lemma islimpt_approachable: | |
| 497 | fixes x :: "'a::metric_space" | |
| 498 | shows "x islimpt S \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e)" | |
| 499 | unfolding islimpt_def | |
| 500 | apply auto | |
| 501 | apply(erule_tac x="ball x e" in allE) | |
| 502 | apply auto | |
| 503 | apply(rule_tac x=y in bexI) | |
| 504 | apply (auto simp add: dist_commute) | |
| 505 | apply (simp add: open_dist, drule (1) bspec) | |
| 506 | apply (clarify, drule spec, drule (1) mp, auto) | |
| 507 | done | |
| 508 | ||
| 509 | lemma islimpt_approachable_le: | |
| 510 | fixes x :: "'a::metric_space" | |
| 511 | shows "x islimpt S \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in> S. x' \<noteq> x \<and> dist x' x <= e)" | |
| 512 | unfolding islimpt_approachable | |
| 513 | using approachable_lt_le[where f="\<lambda>x'. dist x' x" and P="\<lambda>x'. \<not> (x'\<in>S \<and> x'\<noteq>x)"] | |
| 33324 | 514 | by metis | 
| 33175 | 515 | |
| 516 | class perfect_space = | |
| 517 | (* FIXME: perfect_space should inherit from topological_space *) | |
| 518 | assumes islimpt_UNIV [simp, intro]: "(x::'a::metric_space) islimpt UNIV" | |
| 519 | ||
| 520 | lemma perfect_choose_dist: | |
| 521 | fixes x :: "'a::perfect_space" | |
| 522 | shows "0 < r \<Longrightarrow> \<exists>a. a \<noteq> x \<and> dist a x < r" | |
| 523 | using islimpt_UNIV [of x] | |
| 524 | by (simp add: islimpt_approachable) | |
| 525 | ||
| 526 | instance real :: perfect_space | |
| 527 | apply default | |
| 528 | apply (rule islimpt_approachable [THEN iffD2]) | |
| 529 | apply (clarify, rule_tac x="x + e/2" in bexI) | |
| 530 | apply (auto simp add: dist_norm) | |
| 531 | done | |
| 532 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 533 | instance cart :: (perfect_space, finite) perfect_space | 
| 33175 | 534 | proof | 
| 535 | fix x :: "'a ^ 'b" | |
| 536 |   {
 | |
| 537 | fix e :: real assume "0 < e" | |
| 538 | def a \<equiv> "x $ undefined" | |
| 539 | have "a islimpt UNIV" by (rule islimpt_UNIV) | |
| 540 | with `0 < e` obtain b where "b \<noteq> a" and "dist b a < e" | |
| 541 | unfolding islimpt_approachable by auto | |
| 542 | def y \<equiv> "Cart_lambda ((Cart_nth x)(undefined := b))" | |
| 543 | from `b \<noteq> a` have "y \<noteq> x" | |
| 544 | unfolding a_def y_def by (simp add: Cart_eq) | |
| 545 | from `dist b a < e` have "dist y x < e" | |
| 546 | unfolding dist_vector_def a_def y_def | |
| 547 | apply simp | |
| 548 | apply (rule le_less_trans [OF setL2_le_setsum [OF zero_le_dist]]) | |
| 549 | apply (subst setsum_diff1' [where a=undefined], simp, simp, simp) | |
| 550 | done | |
| 551 | from `y \<noteq> x` and `dist y x < e` | |
| 552 | have "\<exists>y\<in>UNIV. y \<noteq> x \<and> dist y x < e" by auto | |
| 553 | } | |
| 554 | then show "x islimpt UNIV" unfolding islimpt_approachable by blast | |
| 555 | qed | |
| 556 | ||
| 557 | lemma closed_limpt: "closed S \<longleftrightarrow> (\<forall>x. x islimpt S \<longrightarrow> x \<in> S)" | |
| 558 | unfolding closed_def | |
| 559 | apply (subst open_subopen) | |
| 34105 | 560 | apply (simp add: islimpt_def subset_eq) | 
| 561 | by (metis ComplE ComplI insertCI insert_absorb mem_def) | |
| 33175 | 562 | |
| 563 | lemma islimpt_EMPTY[simp]: "\<not> x islimpt {}"
 | |
| 564 | unfolding islimpt_def by auto | |
| 565 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 566 | lemma closed_positive_orthant: "closed {x::real^'n. \<forall>i. 0 \<le>x$i}"
 | 
| 33175 | 567 | proof- | 
| 568 | let ?U = "UNIV :: 'n set" | |
| 569 |   let ?O = "{x::real^'n. \<forall>i. x$i\<ge>0}"
 | |
| 570 |   {fix x:: "real^'n" and i::'n assume H: "\<forall>e>0. \<exists>x'\<in>?O. x' \<noteq> x \<and> dist x' x < e"
 | |
| 571 | and xi: "x$i < 0" | |
| 572 | from xi have th0: "-x$i > 0" by arith | |
| 573 | from H[rule_format, OF th0] obtain x' where x': "x' \<in>?O" "x' \<noteq> x" "dist x' x < -x $ i" by blast | |
| 574 | have th:" \<And>b a (x::real). abs x <= b \<Longrightarrow> b <= a ==> ~(a + x < 0)" by arith | |
| 575 | have th': "\<And>x (y::real). x < 0 \<Longrightarrow> 0 <= y ==> abs x <= abs (y - x)" by arith | |
| 576 | have th1: "\<bar>x$i\<bar> \<le> \<bar>(x' - x)$i\<bar>" using x'(1) xi | |
| 577 | apply (simp only: vector_component) | |
| 578 | by (rule th') auto | |
| 579 | have th2: "\<bar>dist x x'\<bar> \<ge> \<bar>(x' - x)$i\<bar>" using component_le_norm[of "x'-x" i] | |
| 580 | apply (simp add: dist_norm) by norm | |
| 581 | from th[OF th1 th2] x'(3) have False by (simp add: dist_commute) } | |
| 582 | then show ?thesis unfolding closed_limpt islimpt_approachable | |
| 583 | unfolding not_le[symmetric] by blast | |
| 584 | qed | |
| 585 | ||
| 586 | lemma finite_set_avoid: | |
| 587 | fixes a :: "'a::metric_space" | |
| 588 | assumes fS: "finite S" shows "\<exists>d>0. \<forall>x\<in>S. x \<noteq> a \<longrightarrow> d <= dist a x" | |
| 589 | proof(induct rule: finite_induct[OF fS]) | |
| 590 | case 1 thus ?case apply auto by ferrack | |
| 591 | next | |
| 592 | case (2 x F) | |
| 593 | from 2 obtain d where d: "d >0" "\<forall>x\<in>F. x\<noteq>a \<longrightarrow> d \<le> dist a x" by blast | |
| 594 |   {assume "x = a" hence ?case using d by auto  }
 | |
| 595 | moreover | |
| 596 |   {assume xa: "x\<noteq>a"
 | |
| 597 | let ?d = "min d (dist a x)" | |
| 598 | have dp: "?d > 0" using xa d(1) using dist_nz by auto | |
| 599 | from d have d': "\<forall>x\<in>F. x\<noteq>a \<longrightarrow> ?d \<le> dist a x" by auto | |
| 600 | with dp xa have ?case by(auto intro!: exI[where x="?d"]) } | |
| 601 | ultimately show ?case by blast | |
| 602 | qed | |
| 603 | ||
| 604 | lemma islimpt_finite: | |
| 605 | fixes S :: "'a::metric_space set" | |
| 606 | assumes fS: "finite S" shows "\<not> a islimpt S" | |
| 607 | unfolding islimpt_approachable | |
| 608 | using finite_set_avoid[OF fS, of a] by (metis dist_commute not_le) | |
| 609 | ||
| 610 | lemma islimpt_Un: "x islimpt (S \<union> T) \<longleftrightarrow> x islimpt S \<or> x islimpt T" | |
| 611 | apply (rule iffI) | |
| 612 | defer | |
| 613 | apply (metis Un_upper1 Un_upper2 islimpt_subset) | |
| 614 | unfolding islimpt_def | |
| 615 | apply (rule ccontr, clarsimp, rename_tac A B) | |
| 616 | apply (drule_tac x="A \<inter> B" in spec) | |
| 617 | apply (auto simp add: open_Int) | |
| 618 | done | |
| 619 | ||
| 620 | lemma discrete_imp_closed: | |
| 621 | fixes S :: "'a::metric_space set" | |
| 622 | assumes e: "0 < e" and d: "\<forall>x \<in> S. \<forall>y \<in> S. dist y x < e \<longrightarrow> y = x" | |
| 623 | shows "closed S" | |
| 624 | proof- | |
| 625 |   {fix x assume C: "\<forall>e>0. \<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e"
 | |
| 626 | from e have e2: "e/2 > 0" by arith | |
| 627 | from C[rule_format, OF e2] obtain y where y: "y \<in> S" "y\<noteq>x" "dist y x < e/2" by blast | |
| 628 | let ?m = "min (e/2) (dist x y) " | |
| 629 | from e2 y(2) have mp: "?m > 0" by (simp add: dist_nz[THEN sym]) | |
| 630 | from C[rule_format, OF mp] obtain z where z: "z \<in> S" "z\<noteq>x" "dist z x < ?m" by blast | |
| 631 | have th: "dist z y < e" using z y | |
| 632 | by (intro dist_triangle_lt [where z=x], simp) | |
| 633 | from d[rule_format, OF y(1) z(1) th] y z | |
| 634 | have False by (auto simp add: dist_commute)} | |
| 635 | then show ?thesis by (metis islimpt_approachable closed_limpt [where 'a='a]) | |
| 636 | qed | |
| 637 | ||
| 638 | subsection{* Interior of a Set *}
 | |
| 639 | definition "interior S = {x. \<exists>T. open T \<and> x \<in> T \<and> T \<subseteq> S}"
 | |
| 640 | ||
| 641 | lemma interior_eq: "interior S = S \<longleftrightarrow> open S" | |
| 642 | apply (simp add: expand_set_eq interior_def) | |
| 643 | apply (subst (2) open_subopen) by (safe, blast+) | |
| 644 | ||
| 645 | lemma interior_open: "open S ==> (interior S = S)" by (metis interior_eq) | |
| 646 | ||
| 647 | lemma interior_empty[simp]: "interior {} = {}" by (simp add: interior_def)
 | |
| 648 | ||
| 649 | lemma open_interior[simp, intro]: "open(interior S)" | |
| 650 | apply (simp add: interior_def) | |
| 651 | apply (subst open_subopen) by blast | |
| 652 | ||
| 653 | lemma interior_interior[simp]: "interior(interior S) = interior S" by (metis interior_eq open_interior) | |
| 654 | lemma interior_subset: "interior S \<subseteq> S" by (auto simp add: interior_def) | |
| 655 | lemma subset_interior: "S \<subseteq> T ==> (interior S) \<subseteq> (interior T)" by (auto simp add: interior_def) | |
| 656 | lemma interior_maximal: "T \<subseteq> S \<Longrightarrow> open T ==> T \<subseteq> (interior S)" by (auto simp add: interior_def) | |
| 657 | lemma interior_unique: "T \<subseteq> S \<Longrightarrow> open T \<Longrightarrow> (\<forall>T'. T' \<subseteq> S \<and> open T' \<longrightarrow> T' \<subseteq> T) \<Longrightarrow> interior S = T" | |
| 658 | by (metis equalityI interior_maximal interior_subset open_interior) | |
| 659 | lemma mem_interior: "x \<in> interior S \<longleftrightarrow> (\<exists>e. 0 < e \<and> ball x e \<subseteq> S)" | |
| 660 | apply (simp add: interior_def) | |
| 661 | by (metis open_contains_ball centre_in_ball open_ball subset_trans) | |
| 662 | ||
| 663 | lemma open_subset_interior: "open S ==> S \<subseteq> interior T \<longleftrightarrow> S \<subseteq> T" | |
| 664 | by (metis interior_maximal interior_subset subset_trans) | |
| 665 | ||
| 666 | lemma interior_inter[simp]: "interior(S \<inter> T) = interior S \<inter> interior T" | |
| 667 | apply (rule equalityI, simp) | |
| 668 | apply (metis Int_lower1 Int_lower2 subset_interior) | |
| 669 | by (metis Int_mono interior_subset open_Int open_interior open_subset_interior) | |
| 670 | ||
| 671 | lemma interior_limit_point [intro]: | |
| 672 | fixes x :: "'a::perfect_space" | |
| 673 | assumes x: "x \<in> interior S" shows "x islimpt S" | |
| 674 | proof- | |
| 675 | from x obtain e where e: "e>0" "\<forall>x'. dist x x' < e \<longrightarrow> x' \<in> S" | |
| 676 | unfolding mem_interior subset_eq Ball_def mem_ball by blast | |
| 677 |   {
 | |
| 678 | fix d::real assume d: "d>0" | |
| 679 | let ?m = "min d e" | |
| 680 | have mde2: "0 < ?m" using e(1) d(1) by simp | |
| 681 | from perfect_choose_dist [OF mde2, of x] | |
| 682 | obtain y where "y \<noteq> x" and "dist y x < ?m" by blast | |
| 683 | then have "dist y x < e" "dist y x < d" by simp_all | |
| 684 | from `dist y x < e` e(2) have "y \<in> S" by (simp add: dist_commute) | |
| 685 | have "\<exists>x'\<in>S. x'\<noteq> x \<and> dist x' x < d" | |
| 686 | using `y \<in> S` `y \<noteq> x` `dist y x < d` by fast | |
| 687 | } | |
| 688 | then show ?thesis unfolding islimpt_approachable by blast | |
| 689 | qed | |
| 690 | ||
| 691 | lemma interior_closed_Un_empty_interior: | |
| 692 |   assumes cS: "closed S" and iT: "interior T = {}"
 | |
| 693 | shows "interior(S \<union> T) = interior S" | |
| 694 | proof | |
| 695 | show "interior S \<subseteq> interior (S\<union>T)" | |
| 696 | by (rule subset_interior, blast) | |
| 697 | next | |
| 698 | show "interior (S \<union> T) \<subseteq> interior S" | |
| 699 | proof | |
| 700 | fix x assume "x \<in> interior (S \<union> T)" | |
| 701 | then obtain R where "open R" "x \<in> R" "R \<subseteq> S \<union> T" | |
| 702 | unfolding interior_def by fast | |
| 703 | show "x \<in> interior S" | |
| 704 | proof (rule ccontr) | |
| 705 | assume "x \<notin> interior S" | |
| 706 | with `x \<in> R` `open R` obtain y where "y \<in> R - S" | |
| 707 | unfolding interior_def expand_set_eq by fast | |
| 708 | from `open R` `closed S` have "open (R - S)" by (rule open_Diff) | |
| 709 | from `R \<subseteq> S \<union> T` have "R - S \<subseteq> T" by fast | |
| 710 |       from `y \<in> R - S` `open (R - S)` `R - S \<subseteq> T` `interior T = {}`
 | |
| 711 | show "False" unfolding interior_def by fast | |
| 712 | qed | |
| 713 | qed | |
| 714 | qed | |
| 715 | ||
| 716 | ||
| 717 | subsection{* Closure of a Set *}
 | |
| 718 | ||
| 719 | definition "closure S = S \<union> {x | x. x islimpt S}"
 | |
| 720 | ||
| 34105 | 721 | lemma closure_interior: "closure S = - interior (- S)" | 
| 33175 | 722 | proof- | 
| 723 |   { fix x
 | |
| 34105 | 724 | have "x\<in>- interior (- S) \<longleftrightarrow> x \<in> closure S" (is "?lhs = ?rhs") | 
| 33175 | 725 | proof | 
| 34105 | 726 | let ?exT = "\<lambda> y. (\<exists>T. open T \<and> y \<in> T \<and> T \<subseteq> - S)" | 
| 33175 | 727 | assume "?lhs" | 
| 728 | hence *:"\<not> ?exT x" | |
| 729 | unfolding interior_def | |
| 730 | by simp | |
| 731 |       { assume "\<not> ?rhs"
 | |
| 732 | hence False using * | |
| 733 | unfolding closure_def islimpt_def | |
| 734 | by blast | |
| 735 | } | |
| 736 | thus "?rhs" | |
| 737 | by blast | |
| 738 | next | |
| 739 | assume "?rhs" thus "?lhs" | |
| 740 | unfolding closure_def interior_def islimpt_def | |
| 741 | by blast | |
| 742 | qed | |
| 743 | } | |
| 744 | thus ?thesis | |
| 745 | by blast | |
| 746 | qed | |
| 747 | ||
| 34105 | 748 | lemma interior_closure: "interior S = - (closure (- S))" | 
| 33175 | 749 | proof- | 
| 750 |   { fix x
 | |
| 34105 | 751 | have "x \<in> interior S \<longleftrightarrow> x \<in> - (closure (- S))" | 
| 33175 | 752 | unfolding interior_def closure_def islimpt_def | 
| 33324 | 753 | by auto | 
| 33175 | 754 | } | 
| 755 | thus ?thesis | |
| 756 | by blast | |
| 757 | qed | |
| 758 | ||
| 759 | lemma closed_closure[simp, intro]: "closed (closure S)" | |
| 760 | proof- | |
| 34105 | 761 | have "closed (- interior (-S))" by blast | 
| 33175 | 762 | thus ?thesis using closure_interior[of S] by simp | 
| 763 | qed | |
| 764 | ||
| 765 | lemma closure_hull: "closure S = closed hull S" | |
| 766 | proof- | |
| 767 | have "S \<subseteq> closure S" | |
| 768 | unfolding closure_def | |
| 769 | by blast | |
| 770 | moreover | |
| 771 | have "closed (closure S)" | |
| 772 | using closed_closure[of S] | |
| 773 | by assumption | |
| 774 | moreover | |
| 775 |   { fix t
 | |
| 776 | assume *:"S \<subseteq> t" "closed t" | |
| 777 |     { fix x
 | |
| 778 | assume "x islimpt S" | |
| 779 | hence "x islimpt t" using *(1) | |
| 780 | using islimpt_subset[of x, of S, of t] | |
| 781 | by blast | |
| 782 | } | |
| 783 | with * have "closure S \<subseteq> t" | |
| 784 | unfolding closure_def | |
| 785 | using closed_limpt[of t] | |
| 786 | by auto | |
| 787 | } | |
| 788 | ultimately show ?thesis | |
| 789 | using hull_unique[of S, of "closure S", of closed] | |
| 790 | unfolding mem_def | |
| 791 | by simp | |
| 792 | qed | |
| 793 | ||
| 794 | lemma closure_eq: "closure S = S \<longleftrightarrow> closed S" | |
| 795 | unfolding closure_hull | |
| 796 | using hull_eq[of closed, unfolded mem_def, OF closed_Inter, of S] | |
| 797 | by (metis mem_def subset_eq) | |
| 798 | ||
| 799 | lemma closure_closed[simp]: "closed S \<Longrightarrow> closure S = S" | |
| 800 | using closure_eq[of S] | |
| 801 | by simp | |
| 802 | ||
| 803 | lemma closure_closure[simp]: "closure (closure S) = closure S" | |
| 804 | unfolding closure_hull | |
| 805 | using hull_hull[of closed S] | |
| 806 | by assumption | |
| 807 | ||
| 808 | lemma closure_subset: "S \<subseteq> closure S" | |
| 809 | unfolding closure_hull | |
| 810 | using hull_subset[of S closed] | |
| 811 | by assumption | |
| 812 | ||
| 813 | lemma subset_closure: "S \<subseteq> T \<Longrightarrow> closure S \<subseteq> closure T" | |
| 814 | unfolding closure_hull | |
| 815 | using hull_mono[of S T closed] | |
| 816 | by assumption | |
| 817 | ||
| 818 | lemma closure_minimal: "S \<subseteq> T \<Longrightarrow> closed T \<Longrightarrow> closure S \<subseteq> T" | |
| 819 | using hull_minimal[of S T closed] | |
| 820 | unfolding closure_hull mem_def | |
| 821 | by simp | |
| 822 | ||
| 823 | lemma closure_unique: "S \<subseteq> T \<and> closed T \<and> (\<forall> T'. S \<subseteq> T' \<and> closed T' \<longrightarrow> T \<subseteq> T') \<Longrightarrow> closure S = T" | |
| 824 | using hull_unique[of S T closed] | |
| 825 | unfolding closure_hull mem_def | |
| 826 | by simp | |
| 827 | ||
| 828 | lemma closure_empty[simp]: "closure {} = {}"
 | |
| 829 |   using closed_empty closure_closed[of "{}"]
 | |
| 830 | by simp | |
| 831 | ||
| 832 | lemma closure_univ[simp]: "closure UNIV = UNIV" | |
| 833 | using closure_closed[of UNIV] | |
| 834 | by simp | |
| 835 | ||
| 836 | lemma closure_eq_empty: "closure S = {} \<longleftrightarrow> S = {}"
 | |
| 837 | using closure_empty closure_subset[of S] | |
| 838 | by blast | |
| 839 | ||
| 840 | lemma closure_subset_eq: "closure S \<subseteq> S \<longleftrightarrow> closed S" | |
| 841 | using closure_eq[of S] closure_subset[of S] | |
| 842 | by simp | |
| 843 | ||
| 844 | lemma open_inter_closure_eq_empty: | |
| 845 |   "open S \<Longrightarrow> (S \<inter> closure T) = {} \<longleftrightarrow> S \<inter> T = {}"
 | |
| 34105 | 846 | using open_subset_interior[of S "- T"] | 
| 847 | using interior_subset[of "- T"] | |
| 33175 | 848 | unfolding closure_interior | 
| 849 | by auto | |
| 850 | ||
| 851 | lemma open_inter_closure_subset: | |
| 852 | "open S \<Longrightarrow> (S \<inter> (closure T)) \<subseteq> closure(S \<inter> T)" | |
| 853 | proof | |
| 854 | fix x | |
| 855 | assume as: "open S" "x \<in> S \<inter> closure T" | |
| 856 |   { assume *:"x islimpt T"
 | |
| 857 | have "x islimpt (S \<inter> T)" | |
| 858 | proof (rule islimptI) | |
| 859 | fix A | |
| 860 | assume "x \<in> A" "open A" | |
| 861 | with as have "x \<in> A \<inter> S" "open (A \<inter> S)" | |
| 862 | by (simp_all add: open_Int) | |
| 863 | with * obtain y where "y \<in> T" "y \<in> A \<inter> S" "y \<noteq> x" | |
| 864 | by (rule islimptE) | |
| 865 | hence "y \<in> S \<inter> T" "y \<in> A \<and> y \<noteq> x" | |
| 866 | by simp_all | |
| 867 | thus "\<exists>y\<in>(S \<inter> T). y \<in> A \<and> y \<noteq> x" .. | |
| 868 | qed | |
| 869 | } | |
| 870 | then show "x \<in> closure (S \<inter> T)" using as | |
| 871 | unfolding closure_def | |
| 872 | by blast | |
| 873 | qed | |
| 874 | ||
| 34105 | 875 | lemma closure_complement: "closure(- S) = - interior(S)" | 
| 33175 | 876 | proof- | 
| 34105 | 877 | have "S = - (- S)" | 
| 33175 | 878 | by auto | 
| 879 | thus ?thesis | |
| 880 | unfolding closure_interior | |
| 881 | by auto | |
| 882 | qed | |
| 883 | ||
| 34105 | 884 | lemma interior_complement: "interior(- S) = - closure(S)" | 
| 33175 | 885 | unfolding closure_interior | 
| 886 | by blast | |
| 887 | ||
| 888 | subsection{* Frontier (aka boundary) *}
 | |
| 889 | ||
| 890 | definition "frontier S = closure S - interior S" | |
| 891 | ||
| 892 | lemma frontier_closed: "closed(frontier S)" | |
| 893 | by (simp add: frontier_def closed_Diff) | |
| 894 | ||
| 34105 | 895 | lemma frontier_closures: "frontier S = (closure S) \<inter> (closure(- S))" | 
| 33175 | 896 | by (auto simp add: frontier_def interior_closure) | 
| 897 | ||
| 898 | lemma frontier_straddle: | |
| 899 | fixes a :: "'a::metric_space" | |
| 900 | shows "a \<in> frontier S \<longleftrightarrow> (\<forall>e>0. (\<exists>x\<in>S. dist a x < e) \<and> (\<exists>x. x \<notin> S \<and> dist a x < e))" (is "?lhs \<longleftrightarrow> ?rhs") | |
| 901 | proof | |
| 902 | assume "?lhs" | |
| 903 |   { fix e::real
 | |
| 904 | assume "e > 0" | |
| 905 | let ?rhse = "(\<exists>x\<in>S. dist a x < e) \<and> (\<exists>x. x \<notin> S \<and> dist a x < e)" | |
| 906 |     { assume "a\<in>S"
 | |
| 907 | have "\<exists>x\<in>S. dist a x < e" using `e>0` `a\<in>S` by(rule_tac x=a in bexI) auto | |
| 908 | moreover have "\<exists>x. x \<notin> S \<and> dist a x < e" using `?lhs` `a\<in>S` | |
| 909 | unfolding frontier_closures closure_def islimpt_def using `e>0` | |
| 910 | by (auto, erule_tac x="ball a e" in allE, auto) | |
| 911 | ultimately have ?rhse by auto | |
| 912 | } | |
| 913 | moreover | |
| 914 |     { assume "a\<notin>S"
 | |
| 915 | hence ?rhse using `?lhs` | |
| 916 | unfolding frontier_closures closure_def islimpt_def | |
| 917 | using open_ball[of a e] `e > 0` | |
| 33324 | 918 | by simp (metis centre_in_ball mem_ball open_ball) | 
| 33175 | 919 | } | 
| 920 | ultimately have ?rhse by auto | |
| 921 | } | |
| 922 | thus ?rhs by auto | |
| 923 | next | |
| 924 | assume ?rhs | |
| 925 | moreover | |
| 926 |   { fix T assume "a\<notin>S" and
 | |
| 927 | as:"\<forall>e>0. (\<exists>x\<in>S. dist a x < e) \<and> (\<exists>x. x \<notin> S \<and> dist a x < e)" "a \<notin> S" "a \<in> T" "open T" | |
| 928 | from `open T` `a \<in> T` have "\<exists>e>0. ball a e \<subseteq> T" unfolding open_contains_ball[of T] by auto | |
| 929 | then obtain e where "e>0" "ball a e \<subseteq> T" by auto | |
| 930 | then obtain y where y:"y\<in>S" "dist a y < e" using as(1) by auto | |
| 931 | have "\<exists>y\<in>S. y \<in> T \<and> y \<noteq> a" | |
| 932 | using `dist a y < e` `ball a e \<subseteq> T` unfolding ball_def using `y\<in>S` `a\<notin>S` by auto | |
| 933 | } | |
| 934 | hence "a \<in> closure S" unfolding closure_def islimpt_def using `?rhs` by auto | |
| 935 | moreover | |
| 936 |   { fix T assume "a \<in> T"  "open T" "a\<in>S"
 | |
| 937 | then obtain e where "e>0" and balle: "ball a e \<subseteq> T" unfolding open_contains_ball using `?rhs` by auto | |
| 938 | obtain x where "x \<notin> S" "dist a x < e" using `?rhs` using `e>0` by auto | |
| 34105 | 939 | hence "\<exists>y\<in>- S. y \<in> T \<and> y \<noteq> a" using balle `a\<in>S` unfolding ball_def by (rule_tac x=x in bexI)auto | 
| 33175 | 940 | } | 
| 34105 | 941 | hence "a islimpt (- S) \<or> a\<notin>S" unfolding islimpt_def by auto | 
| 942 | ultimately show ?lhs unfolding frontier_closures using closure_def[of "- S"] by auto | |
| 33175 | 943 | qed | 
| 944 | ||
| 945 | lemma frontier_subset_closed: "closed S \<Longrightarrow> frontier S \<subseteq> S" | |
| 946 | by (metis frontier_def closure_closed Diff_subset) | |
| 947 | ||
| 34964 | 948 | lemma frontier_empty[simp]: "frontier {} = {}"
 | 
| 33175 | 949 | by (simp add: frontier_def closure_empty) | 
| 950 | ||
| 951 | lemma frontier_subset_eq: "frontier S \<subseteq> S \<longleftrightarrow> closed S" | |
| 952 | proof- | |
| 953 |   { assume "frontier S \<subseteq> S"
 | |
| 954 | hence "closure S \<subseteq> S" using interior_subset unfolding frontier_def by auto | |
| 955 | hence "closed S" using closure_subset_eq by auto | |
| 956 | } | |
| 957 | thus ?thesis using frontier_subset_closed[of S] by auto | |
| 958 | qed | |
| 959 | ||
| 34105 | 960 | lemma frontier_complement: "frontier(- S) = frontier S" | 
| 33175 | 961 | by (auto simp add: frontier_def closure_complement interior_complement) | 
| 962 | ||
| 963 | lemma frontier_disjoint_eq: "frontier S \<inter> S = {} \<longleftrightarrow> open S"
 | |
| 34105 | 964 | using frontier_complement frontier_subset_eq[of "- S"] | 
| 965 | unfolding open_closed by auto | |
| 33175 | 966 | |
| 967 | subsection{* Common nets and The "within" modifier for nets. *}
 | |
| 968 | ||
| 969 | definition | |
| 970 | at_infinity :: "'a::real_normed_vector net" where | |
| 971 |   "at_infinity = Abs_net (range (\<lambda>r. {x. r \<le> norm x}))"
 | |
| 972 | ||
| 973 | definition | |
| 974 | indirection :: "'a::real_normed_vector \<Rightarrow> 'a \<Rightarrow> 'a net" (infixr "indirection" 70) where | |
| 975 |   "a indirection v = (at a) within {b. \<exists>c\<ge>0. b - a = scaleR c v}"
 | |
| 976 | ||
| 977 | text{* Prove That They are all nets. *}
 | |
| 978 | ||
| 979 | lemma Rep_net_at_infinity: | |
| 980 |   "Rep_net at_infinity = range (\<lambda>r. {x. r \<le> norm x})"
 | |
| 981 | unfolding at_infinity_def | |
| 982 | apply (rule Abs_net_inverse') | |
| 983 | apply (rule image_nonempty, simp) | |
| 984 | apply (clarsimp, rename_tac r s) | |
| 985 | apply (rule_tac x="max r s" in exI, auto) | |
| 986 | done | |
| 987 | ||
| 988 | lemma within_UNIV: "net within UNIV = net" | |
| 989 | by (simp add: Rep_net_inject [symmetric] Rep_net_within) | |
| 990 | ||
| 991 | subsection{* Identify Trivial limits, where we can't approach arbitrarily closely. *}
 | |
| 992 | ||
| 993 | definition | |
| 994 | trivial_limit :: "'a net \<Rightarrow> bool" where | |
| 995 |   "trivial_limit net \<longleftrightarrow> {} \<in> Rep_net net"
 | |
| 996 | ||
| 997 | lemma trivial_limit_within: | |
| 998 | shows "trivial_limit (at a within S) \<longleftrightarrow> \<not> a islimpt S" | |
| 999 | proof | |
| 1000 | assume "trivial_limit (at a within S)" | |
| 1001 | thus "\<not> a islimpt S" | |
| 1002 | unfolding trivial_limit_def | |
| 1003 | unfolding Rep_net_within Rep_net_at | |
| 1004 | unfolding islimpt_def | |
| 1005 | apply (clarsimp simp add: expand_set_eq) | |
| 1006 | apply (rename_tac T, rule_tac x=T in exI) | |
| 1007 | apply (clarsimp, drule_tac x=y in spec, simp) | |
| 1008 | done | |
| 1009 | next | |
| 1010 | assume "\<not> a islimpt S" | |
| 1011 | thus "trivial_limit (at a within S)" | |
| 1012 | unfolding trivial_limit_def | |
| 1013 | unfolding Rep_net_within Rep_net_at | |
| 1014 | unfolding islimpt_def | |
| 1015 | apply (clarsimp simp add: image_image) | |
| 1016 | apply (rule_tac x=T in image_eqI) | |
| 1017 | apply (auto simp add: expand_set_eq) | |
| 1018 | done | |
| 1019 | qed | |
| 1020 | ||
| 1021 | lemma trivial_limit_at_iff: "trivial_limit (at a) \<longleftrightarrow> \<not> a islimpt UNIV" | |
| 1022 | using trivial_limit_within [of a UNIV] | |
| 1023 | by (simp add: within_UNIV) | |
| 1024 | ||
| 1025 | lemma trivial_limit_at: | |
| 1026 | fixes a :: "'a::perfect_space" | |
| 1027 | shows "\<not> trivial_limit (at a)" | |
| 1028 | by (simp add: trivial_limit_at_iff) | |
| 1029 | ||
| 1030 | lemma trivial_limit_at_infinity: | |
| 1031 |   "\<not> trivial_limit (at_infinity :: ('a::{real_normed_vector,zero_neq_one}) net)"
 | |
| 1032 | (* FIXME: find a more appropriate type class *) | |
| 1033 | unfolding trivial_limit_def Rep_net_at_infinity | |
| 1034 | apply (clarsimp simp add: expand_set_eq) | |
| 1035 | apply (drule_tac x="scaleR r (sgn 1)" in spec) | |
| 1036 | apply (simp add: norm_sgn) | |
| 1037 | done | |
| 1038 | ||
| 34964 | 1039 | lemma trivial_limit_sequentially[intro]: "\<not> trivial_limit sequentially" | 
| 33175 | 1040 | by (auto simp add: trivial_limit_def Rep_net_sequentially) | 
| 1041 | ||
| 1042 | subsection{* Some property holds "sufficiently close" to the limit point. *}
 | |
| 1043 | ||
| 1044 | lemma eventually_at: (* FIXME: this replaces Limits.eventually_at *) | |
| 1045 | "eventually P (at a) \<longleftrightarrow> (\<exists>d>0. \<forall>x. 0 < dist x a \<and> dist x a < d \<longrightarrow> P x)" | |
| 1046 | unfolding eventually_at dist_nz by auto | |
| 1047 | ||
| 1048 | lemma eventually_at_infinity: | |
| 1049 | "eventually P at_infinity \<longleftrightarrow> (\<exists>b. \<forall>x. norm x >= b \<longrightarrow> P x)" | |
| 1050 | unfolding eventually_def Rep_net_at_infinity by auto | |
| 1051 | ||
| 1052 | lemma eventually_within: "eventually P (at a within S) \<longleftrightarrow> | |
| 1053 | (\<exists>d>0. \<forall>x\<in>S. 0 < dist x a \<and> dist x a < d \<longrightarrow> P x)" | |
| 1054 | unfolding eventually_within eventually_at dist_nz by auto | |
| 1055 | ||
| 1056 | lemma eventually_within_le: "eventually P (at a within S) \<longleftrightarrow> | |
| 1057 | (\<exists>d>0. \<forall>x\<in>S. 0 < dist x a \<and> dist x a <= d \<longrightarrow> P x)" (is "?lhs = ?rhs") | |
| 1058 | unfolding eventually_within | |
| 33324 | 1059 | by auto (metis Rats_dense_in_nn_real order_le_less_trans order_refl) | 
| 33175 | 1060 | |
| 1061 | lemma eventually_happens: "eventually P net ==> trivial_limit net \<or> (\<exists>x. P x)" | |
| 1062 | unfolding eventually_def trivial_limit_def | |
| 1063 | using Rep_net_nonempty [of net] by auto | |
| 1064 | ||
| 1065 | lemma always_eventually: "(\<forall>x. P x) ==> eventually P net" | |
| 1066 | unfolding eventually_def trivial_limit_def | |
| 1067 | using Rep_net_nonempty [of net] by auto | |
| 1068 | ||
| 1069 | lemma trivial_limit_eventually: "trivial_limit net \<Longrightarrow> eventually P net" | |
| 1070 | unfolding trivial_limit_def eventually_def by auto | |
| 1071 | ||
| 1072 | lemma eventually_False: "eventually (\<lambda>x. False) net \<longleftrightarrow> trivial_limit net" | |
| 1073 | unfolding trivial_limit_def eventually_def by auto | |
| 1074 | ||
| 1075 | lemma trivial_limit_eq: "trivial_limit net \<longleftrightarrow> (\<forall>P. eventually P net)" | |
| 1076 | apply (safe elim!: trivial_limit_eventually) | |
| 1077 | apply (simp add: eventually_False [symmetric]) | |
| 1078 | done | |
| 1079 | ||
| 1080 | text{* Combining theorems for "eventually" *}
 | |
| 1081 | ||
| 1082 | lemma eventually_conjI: | |
| 1083 | "\<lbrakk>eventually (\<lambda>x. P x) net; eventually (\<lambda>x. Q x) net\<rbrakk> | |
| 1084 | \<Longrightarrow> eventually (\<lambda>x. P x \<and> Q x) net" | |
| 1085 | by (rule eventually_conj) | |
| 1086 | ||
| 1087 | lemma eventually_rev_mono: | |
| 1088 | "eventually P net \<Longrightarrow> (\<forall>x. P x \<longrightarrow> Q x) \<Longrightarrow> eventually Q net" | |
| 1089 | using eventually_mono [of P Q] by fast | |
| 1090 | ||
| 1091 | lemma eventually_and: " eventually (\<lambda>x. P x \<and> Q x) net \<longleftrightarrow> eventually P net \<and> eventually Q net" | |
| 1092 | by (auto intro!: eventually_conjI elim: eventually_rev_mono) | |
| 1093 | ||
| 1094 | lemma eventually_false: "eventually (\<lambda>x. False) net \<longleftrightarrow> trivial_limit net" | |
| 1095 | by (auto simp add: eventually_False) | |
| 1096 | ||
| 1097 | lemma not_eventually: "(\<forall>x. \<not> P x ) \<Longrightarrow> ~(trivial_limit net) ==> ~(eventually (\<lambda>x. P x) net)" | |
| 1098 | by (simp add: eventually_False) | |
| 1099 | ||
| 1100 | subsection{* Limits, defined as vacuously true when the limit is trivial. *}
 | |
| 1101 | ||
| 1102 |   text{* Notation Lim to avoid collition with lim defined in analysis *}
 | |
| 1103 | definition | |
| 1104 |   Lim :: "'a net \<Rightarrow> ('a \<Rightarrow> 'b::t2_space) \<Rightarrow> 'b" where
 | |
| 1105 | "Lim net f = (THE l. (f ---> l) net)" | |
| 1106 | ||
| 1107 | lemma Lim: | |
| 1108 | "(f ---> l) net \<longleftrightarrow> | |
| 1109 | trivial_limit net \<or> | |
| 1110 | (\<forall>e>0. eventually (\<lambda>x. dist (f x) l < e) net)" | |
| 1111 | unfolding tendsto_iff trivial_limit_eq by auto | |
| 1112 | ||
| 1113 | ||
| 1114 | text{* Show that they yield usual definitions in the various cases. *}
 | |
| 1115 | ||
| 1116 | lemma Lim_within_le: "(f ---> l)(at a within S) \<longleftrightarrow> | |
| 1117 | (\<forall>e>0. \<exists>d>0. \<forall>x\<in>S. 0 < dist x a \<and> dist x a <= d \<longrightarrow> dist (f x) l < e)" | |
| 1118 | by (auto simp add: tendsto_iff eventually_within_le) | |
| 1119 | ||
| 1120 | lemma Lim_within: "(f ---> l) (at a within S) \<longleftrightarrow> | |
| 1121 | (\<forall>e >0. \<exists>d>0. \<forall>x \<in> S. 0 < dist x a \<and> dist x a < d \<longrightarrow> dist (f x) l < e)" | |
| 1122 | by (auto simp add: tendsto_iff eventually_within) | |
| 1123 | ||
| 1124 | lemma Lim_at: "(f ---> l) (at a) \<longleftrightarrow> | |
| 1125 | (\<forall>e >0. \<exists>d>0. \<forall>x. 0 < dist x a \<and> dist x a < d \<longrightarrow> dist (f x) l < e)" | |
| 1126 | by (auto simp add: tendsto_iff eventually_at) | |
| 1127 | ||
| 1128 | lemma Lim_at_iff_LIM: "(f ---> l) (at a) \<longleftrightarrow> f -- a --> l" | |
| 1129 | unfolding Lim_at LIM_def by (simp only: zero_less_dist_iff) | |
| 1130 | ||
| 1131 | lemma Lim_at_infinity: | |
| 1132 | "(f ---> l) at_infinity \<longleftrightarrow> (\<forall>e>0. \<exists>b. \<forall>x. norm x >= b \<longrightarrow> dist (f x) l < e)" | |
| 1133 | by (auto simp add: tendsto_iff eventually_at_infinity) | |
| 1134 | ||
| 1135 | lemma Lim_sequentially: | |
| 1136 | "(S ---> l) sequentially \<longleftrightarrow> | |
| 1137 | (\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (S n) l < e)" | |
| 1138 | by (auto simp add: tendsto_iff eventually_sequentially) | |
| 1139 | ||
| 1140 | lemma Lim_sequentially_iff_LIMSEQ: "(S ---> l) sequentially \<longleftrightarrow> S ----> l" | |
| 1141 | unfolding Lim_sequentially LIMSEQ_def .. | |
| 1142 | ||
| 1143 | lemma Lim_eventually: "eventually (\<lambda>x. f x = l) net \<Longrightarrow> (f ---> l) net" | |
| 1144 | by (rule topological_tendstoI, auto elim: eventually_rev_mono) | |
| 1145 | ||
| 1146 | text{* The expected monotonicity property. *}
 | |
| 1147 | ||
| 1148 | lemma Lim_within_empty: "(f ---> l) (net within {})"
 | |
| 1149 | unfolding tendsto_def Limits.eventually_within by simp | |
| 1150 | ||
| 1151 | lemma Lim_within_subset: "(f ---> l) (net within S) \<Longrightarrow> T \<subseteq> S \<Longrightarrow> (f ---> l) (net within T)" | |
| 1152 | unfolding tendsto_def Limits.eventually_within | |
| 1153 | by (auto elim!: eventually_elim1) | |
| 1154 | ||
| 1155 | lemma Lim_Un: assumes "(f ---> l) (net within S)" "(f ---> l) (net within T)" | |
| 1156 | shows "(f ---> l) (net within (S \<union> T))" | |
| 1157 | using assms unfolding tendsto_def Limits.eventually_within | |
| 1158 | apply clarify | |
| 1159 | apply (drule spec, drule (1) mp, drule (1) mp) | |
| 1160 | apply (drule spec, drule (1) mp, drule (1) mp) | |
| 1161 | apply (auto elim: eventually_elim2) | |
| 1162 | done | |
| 1163 | ||
| 1164 | lemma Lim_Un_univ: | |
| 1165 | "(f ---> l) (net within S) \<Longrightarrow> (f ---> l) (net within T) \<Longrightarrow> S \<union> T = UNIV | |
| 1166 | ==> (f ---> l) net" | |
| 1167 | by (metis Lim_Un within_UNIV) | |
| 1168 | ||
| 1169 | text{* Interrelations between restricted and unrestricted limits. *}
 | |
| 1170 | ||
| 1171 | lemma Lim_at_within: "(f ---> l) net ==> (f ---> l)(net within S)" | |
| 1172 | (* FIXME: rename *) | |
| 1173 | unfolding tendsto_def Limits.eventually_within | |
| 1174 | apply (clarify, drule spec, drule (1) mp, drule (1) mp) | |
| 1175 | by (auto elim!: eventually_elim1) | |
| 1176 | ||
| 1177 | lemma Lim_within_open: | |
| 1178 | fixes f :: "'a::topological_space \<Rightarrow> 'b::topological_space" | |
| 1179 | assumes"a \<in> S" "open S" | |
| 1180 | shows "(f ---> l)(at a within S) \<longleftrightarrow> (f ---> l)(at a)" (is "?lhs \<longleftrightarrow> ?rhs") | |
| 1181 | proof | |
| 1182 | assume ?lhs | |
| 1183 |   { fix A assume "open A" "l \<in> A"
 | |
| 1184 | with `?lhs` have "eventually (\<lambda>x. f x \<in> A) (at a within S)" | |
| 1185 | by (rule topological_tendstoD) | |
| 1186 | hence "eventually (\<lambda>x. x \<in> S \<longrightarrow> f x \<in> A) (at a)" | |
| 1187 | unfolding Limits.eventually_within . | |
| 1188 | then obtain T where "open T" "a \<in> T" "\<forall>x\<in>T. x \<noteq> a \<longrightarrow> x \<in> S \<longrightarrow> f x \<in> A" | |
| 1189 | unfolding eventually_at_topological by fast | |
| 1190 | hence "open (T \<inter> S)" "a \<in> T \<inter> S" "\<forall>x\<in>(T \<inter> S). x \<noteq> a \<longrightarrow> f x \<in> A" | |
| 1191 | using assms by auto | |
| 1192 | hence "\<exists>T. open T \<and> a \<in> T \<and> (\<forall>x\<in>T. x \<noteq> a \<longrightarrow> f x \<in> A)" | |
| 1193 | by fast | |
| 1194 | hence "eventually (\<lambda>x. f x \<in> A) (at a)" | |
| 1195 | unfolding eventually_at_topological . | |
| 1196 | } | |
| 1197 | thus ?rhs by (rule topological_tendstoI) | |
| 1198 | next | |
| 1199 | assume ?rhs | |
| 1200 | thus ?lhs by (rule Lim_at_within) | |
| 1201 | qed | |
| 1202 | ||
| 1203 | text{* Another limit point characterization. *}
 | |
| 1204 | ||
| 1205 | lemma islimpt_sequential: | |
| 1206 | fixes x :: "'a::metric_space" (* FIXME: generalize to topological_space *) | |
| 1207 |   shows "x islimpt S \<longleftrightarrow> (\<exists>f. (\<forall>n::nat. f n \<in> S -{x}) \<and> (f ---> x) sequentially)"
 | |
| 1208 | (is "?lhs = ?rhs") | |
| 1209 | proof | |
| 1210 | assume ?lhs | |
| 1211 | then obtain f where f:"\<forall>y. y>0 \<longrightarrow> f y \<in> S \<and> f y \<noteq> x \<and> dist (f y) x < y" | |
| 1212 | unfolding islimpt_approachable using choice[of "\<lambda>e y. e>0 \<longrightarrow> y\<in>S \<and> y\<noteq>x \<and> dist y x < e"] by auto | |
| 1213 |   { fix n::nat
 | |
| 1214 |     have "f (inverse (real n + 1)) \<in> S - {x}" using f by auto
 | |
| 1215 | } | |
| 1216 | moreover | |
| 1217 |   { fix e::real assume "e>0"
 | |
| 1218 | hence "\<exists>N::nat. inverse (real (N + 1)) < e" using real_arch_inv[of e] apply (auto simp add: Suc_pred') apply(rule_tac x="n - 1" in exI) by auto | |
| 1219 | then obtain N::nat where "inverse (real (N + 1)) < e" by auto | |
| 1220 | hence "\<forall>n\<ge>N. inverse (real n + 1) < e" by (auto, metis Suc_le_mono le_SucE less_imp_inverse_less nat_le_real_less order_less_trans real_of_nat_Suc real_of_nat_Suc_gt_zero) | |
| 1221 | moreover have "\<forall>n\<ge>N. dist (f (inverse (real n + 1))) x < (inverse (real n + 1))" using f `e>0` by auto | |
| 1222 | ultimately have "\<exists>N::nat. \<forall>n\<ge>N. dist (f (inverse (real n + 1))) x < e" apply(rule_tac x=N in exI) apply auto apply(erule_tac x=n in allE)+ by auto | |
| 1223 | } | |
| 1224 | hence " ((\<lambda>n. f (inverse (real n + 1))) ---> x) sequentially" | |
| 1225 | unfolding Lim_sequentially using f by auto | |
| 1226 | ultimately show ?rhs apply (rule_tac x="(\<lambda>n::nat. f (inverse (real n + 1)))" in exI) by auto | |
| 1227 | next | |
| 1228 | assume ?rhs | |
| 1229 |   then obtain f::"nat\<Rightarrow>'a"  where f:"(\<forall>n. f n \<in> S - {x})" "(\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (f n) x < e)" unfolding Lim_sequentially by auto
 | |
| 1230 |   { fix e::real assume "e>0"
 | |
| 1231 | then obtain N where "dist (f N) x < e" using f(2) by auto | |
| 1232 | moreover have "f N\<in>S" "f N \<noteq> x" using f(1) by auto | |
| 1233 | ultimately have "\<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e" by auto | |
| 1234 | } | |
| 1235 | thus ?lhs unfolding islimpt_approachable by auto | |
| 1236 | qed | |
| 1237 | ||
| 1238 | text{* Basic arithmetical combining theorems for limits. *}
 | |
| 1239 | ||
| 1240 | lemma Lim_linear: | |
| 1241 | assumes "(f ---> l) net" "bounded_linear h" | |
| 1242 | shows "((\<lambda>x. h (f x)) ---> h l) net" | |
| 1243 | using `bounded_linear h` `(f ---> l) net` | |
| 1244 | by (rule bounded_linear.tendsto) | |
| 1245 | ||
| 1246 | lemma Lim_ident_at: "((\<lambda>x. x) ---> a) (at a)" | |
| 1247 | unfolding tendsto_def Limits.eventually_at_topological by fast | |
| 1248 | ||
| 34964 | 1249 | lemma Lim_const[intro]: "((\<lambda>x. a) ---> a) net" by (rule tendsto_const) | 
| 1250 | ||
| 1251 | lemma Lim_cmul[intro]: | |
| 33175 | 1252 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | 
| 1253 | shows "(f ---> l) net ==> ((\<lambda>x. c *\<^sub>R f x) ---> c *\<^sub>R l) net" | |
| 1254 | by (intro tendsto_intros) | |
| 1255 | ||
| 1256 | lemma Lim_neg: | |
| 1257 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1258 | shows "(f ---> l) net ==> ((\<lambda>x. -(f x)) ---> -l) net" | |
| 1259 | by (rule tendsto_minus) | |
| 1260 | ||
| 1261 | lemma Lim_add: fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" shows | |
| 1262 | "(f ---> l) net \<Longrightarrow> (g ---> m) net \<Longrightarrow> ((\<lambda>x. f(x) + g(x)) ---> l + m) net" | |
| 1263 | by (rule tendsto_add) | |
| 1264 | ||
| 1265 | lemma Lim_sub: | |
| 1266 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1267 | shows "(f ---> l) net \<Longrightarrow> (g ---> m) net \<Longrightarrow> ((\<lambda>x. f(x) - g(x)) ---> l - m) net" | |
| 1268 | by (rule tendsto_diff) | |
| 1269 | ||
| 1270 | lemma Lim_null: | |
| 1271 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1272 | shows "(f ---> l) net \<longleftrightarrow> ((\<lambda>x. f(x) - l) ---> 0) net" by (simp add: Lim dist_norm) | |
| 1273 | ||
| 1274 | lemma Lim_null_norm: | |
| 1275 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1276 | shows "(f ---> 0) net \<longleftrightarrow> ((\<lambda>x. norm(f x)) ---> 0) net" | |
| 1277 | by (simp add: Lim dist_norm) | |
| 1278 | ||
| 1279 | lemma Lim_null_comparison: | |
| 1280 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1281 | assumes "eventually (\<lambda>x. norm (f x) \<le> g x) net" "(g ---> 0) net" | |
| 1282 | shows "(f ---> 0) net" | |
| 1283 | proof(simp add: tendsto_iff, rule+) | |
| 1284 | fix e::real assume "0<e" | |
| 1285 |   { fix x
 | |
| 1286 | assume "norm (f x) \<le> g x" "dist (g x) 0 < e" | |
| 1287 | hence "dist (f x) 0 < e" by (simp add: dist_norm) | |
| 1288 | } | |
| 1289 | thus "eventually (\<lambda>x. dist (f x) 0 < e) net" | |
| 1290 | using eventually_and[of "\<lambda>x. norm(f x) <= g x" "\<lambda>x. dist (g x) 0 < e" net] | |
| 1291 | using eventually_mono[of "(\<lambda>x. norm (f x) \<le> g x \<and> dist (g x) 0 < e)" "(\<lambda>x. dist (f x) 0 < e)" net] | |
| 1292 | using assms `e>0` unfolding tendsto_iff by auto | |
| 1293 | qed | |
| 1294 | ||
| 1295 | lemma Lim_component: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 1296 | fixes f :: "'a \<Rightarrow> 'b::metric_space ^ 'n" | 
| 33175 | 1297 | shows "(f ---> l) net \<Longrightarrow> ((\<lambda>a. f a $i) ---> l$i) net" | 
| 1298 | unfolding tendsto_iff | |
| 1299 | apply (clarify) | |
| 1300 | apply (drule spec, drule (1) mp) | |
| 1301 | apply (erule eventually_elim1) | |
| 1302 | apply (erule le_less_trans [OF dist_nth_le]) | |
| 1303 | done | |
| 1304 | ||
| 1305 | lemma Lim_transform_bound: | |
| 1306 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1307 | fixes g :: "'a \<Rightarrow> 'c::real_normed_vector" | |
| 1308 | assumes "eventually (\<lambda>n. norm(f n) <= norm(g n)) net" "(g ---> 0) net" | |
| 1309 | shows "(f ---> 0) net" | |
| 1310 | proof (rule tendstoI) | |
| 1311 | fix e::real assume "e>0" | |
| 1312 |   { fix x
 | |
| 1313 | assume "norm (f x) \<le> norm (g x)" "dist (g x) 0 < e" | |
| 1314 | hence "dist (f x) 0 < e" by (simp add: dist_norm)} | |
| 1315 | thus "eventually (\<lambda>x. dist (f x) 0 < e) net" | |
| 1316 | using eventually_and[of "\<lambda>x. norm (f x) \<le> norm (g x)" "\<lambda>x. dist (g x) 0 < e" net] | |
| 1317 | using eventually_mono[of "\<lambda>x. norm (f x) \<le> norm (g x) \<and> dist (g x) 0 < e" "\<lambda>x. dist (f x) 0 < e" net] | |
| 1318 | using assms `e>0` unfolding tendsto_iff by blast | |
| 1319 | qed | |
| 1320 | ||
| 1321 | text{* Deducing things about the limit from the elements. *}
 | |
| 1322 | ||
| 1323 | lemma Lim_in_closed_set: | |
| 1324 | assumes "closed S" "eventually (\<lambda>x. f(x) \<in> S) net" "\<not>(trivial_limit net)" "(f ---> l) net" | |
| 1325 | shows "l \<in> S" | |
| 1326 | proof (rule ccontr) | |
| 1327 | assume "l \<notin> S" | |
| 1328 | with `closed S` have "open (- S)" "l \<in> - S" | |
| 1329 | by (simp_all add: open_Compl) | |
| 1330 | with assms(4) have "eventually (\<lambda>x. f x \<in> - S) net" | |
| 1331 | by (rule topological_tendstoD) | |
| 1332 | with assms(2) have "eventually (\<lambda>x. False) net" | |
| 1333 | by (rule eventually_elim2) simp | |
| 1334 | with assms(3) show "False" | |
| 1335 | by (simp add: eventually_False) | |
| 1336 | qed | |
| 1337 | ||
| 1338 | text{* Need to prove closed(cball(x,e)) before deducing this as a corollary. *}
 | |
| 1339 | ||
| 1340 | lemma Lim_dist_ubound: | |
| 1341 | assumes "\<not>(trivial_limit net)" "(f ---> l) net" "eventually (\<lambda>x. dist a (f x) <= e) net" | |
| 1342 | shows "dist a l <= e" | |
| 1343 | proof (rule ccontr) | |
| 1344 | assume "\<not> dist a l \<le> e" | |
| 1345 | then have "0 < dist a l - e" by simp | |
| 1346 | with assms(2) have "eventually (\<lambda>x. dist (f x) l < dist a l - e) net" | |
| 1347 | by (rule tendstoD) | |
| 1348 | with assms(3) have "eventually (\<lambda>x. dist a (f x) \<le> e \<and> dist (f x) l < dist a l - e) net" | |
| 1349 | by (rule eventually_conjI) | |
| 1350 | then obtain w where "dist a (f w) \<le> e" "dist (f w) l < dist a l - e" | |
| 1351 | using assms(1) eventually_happens by auto | |
| 1352 | hence "dist a (f w) + dist (f w) l < e + (dist a l - e)" | |
| 1353 | by (rule add_le_less_mono) | |
| 1354 | hence "dist a (f w) + dist (f w) l < dist a l" | |
| 1355 | by simp | |
| 1356 | also have "\<dots> \<le> dist a (f w) + dist (f w) l" | |
| 1357 | by (rule dist_triangle) | |
| 1358 | finally show False by simp | |
| 1359 | qed | |
| 1360 | ||
| 1361 | lemma Lim_norm_ubound: | |
| 1362 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1363 | assumes "\<not>(trivial_limit net)" "(f ---> l) net" "eventually (\<lambda>x. norm(f x) <= e) net" | |
| 1364 | shows "norm(l) <= e" | |
| 1365 | proof (rule ccontr) | |
| 1366 | assume "\<not> norm l \<le> e" | |
| 1367 | then have "0 < norm l - e" by simp | |
| 1368 | with assms(2) have "eventually (\<lambda>x. dist (f x) l < norm l - e) net" | |
| 1369 | by (rule tendstoD) | |
| 1370 | with assms(3) have "eventually (\<lambda>x. norm (f x) \<le> e \<and> dist (f x) l < norm l - e) net" | |
| 1371 | by (rule eventually_conjI) | |
| 1372 | then obtain w where "norm (f w) \<le> e" "dist (f w) l < norm l - e" | |
| 1373 | using assms(1) eventually_happens by auto | |
| 1374 | hence "norm (f w - l) < norm l - e" "norm (f w) \<le> e" by (simp_all add: dist_norm) | |
| 1375 | hence "norm (f w - l) + norm (f w) < norm l" by simp | |
| 1376 | hence "norm (f w - l - f w) < norm l" by (rule le_less_trans [OF norm_triangle_ineq4]) | |
| 1377 | thus False using `\<not> norm l \<le> e` by simp | |
| 1378 | qed | |
| 1379 | ||
| 1380 | lemma Lim_norm_lbound: | |
| 1381 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1382 | assumes "\<not> (trivial_limit net)" "(f ---> l) net" "eventually (\<lambda>x. e <= norm(f x)) net" | |
| 1383 | shows "e \<le> norm l" | |
| 1384 | proof (rule ccontr) | |
| 1385 | assume "\<not> e \<le> norm l" | |
| 1386 | then have "0 < e - norm l" by simp | |
| 1387 | with assms(2) have "eventually (\<lambda>x. dist (f x) l < e - norm l) net" | |
| 1388 | by (rule tendstoD) | |
| 1389 | with assms(3) have "eventually (\<lambda>x. e \<le> norm (f x) \<and> dist (f x) l < e - norm l) net" | |
| 1390 | by (rule eventually_conjI) | |
| 1391 | then obtain w where "e \<le> norm (f w)" "dist (f w) l < e - norm l" | |
| 1392 | using assms(1) eventually_happens by auto | |
| 1393 | hence "norm (f w - l) + norm l < e" "e \<le> norm (f w)" by (simp_all add: dist_norm) | |
| 1394 | hence "norm (f w - l) + norm l < norm (f w)" by (rule less_le_trans) | |
| 1395 | hence "norm (f w - l + l) < norm (f w)" by (rule le_less_trans [OF norm_triangle_ineq]) | |
| 1396 | thus False by simp | |
| 1397 | qed | |
| 1398 | ||
| 1399 | text{* Uniqueness of the limit, when nontrivial. *}
 | |
| 1400 | ||
| 1401 | lemma Lim_unique: | |
| 1402 | fixes f :: "'a \<Rightarrow> 'b::t2_space" | |
| 1403 | assumes "\<not> trivial_limit net" "(f ---> l) net" "(f ---> l') net" | |
| 1404 | shows "l = l'" | |
| 1405 | proof (rule ccontr) | |
| 1406 | assume "l \<noteq> l'" | |
| 1407 |   obtain U V where "open U" "open V" "l \<in> U" "l' \<in> V" "U \<inter> V = {}"
 | |
| 1408 | using hausdorff [OF `l \<noteq> l'`] by fast | |
| 1409 | have "eventually (\<lambda>x. f x \<in> U) net" | |
| 1410 | using `(f ---> l) net` `open U` `l \<in> U` by (rule topological_tendstoD) | |
| 1411 | moreover | |
| 1412 | have "eventually (\<lambda>x. f x \<in> V) net" | |
| 1413 | using `(f ---> l') net` `open V` `l' \<in> V` by (rule topological_tendstoD) | |
| 1414 | ultimately | |
| 1415 | have "eventually (\<lambda>x. False) net" | |
| 1416 | proof (rule eventually_elim2) | |
| 1417 | fix x | |
| 1418 | assume "f x \<in> U" "f x \<in> V" | |
| 1419 | hence "f x \<in> U \<inter> V" by simp | |
| 1420 |     with `U \<inter> V = {}` show "False" by simp
 | |
| 1421 | qed | |
| 1422 | with `\<not> trivial_limit net` show "False" | |
| 1423 | by (simp add: eventually_False) | |
| 1424 | qed | |
| 1425 | ||
| 1426 | lemma tendsto_Lim: | |
| 1427 | fixes f :: "'a \<Rightarrow> 'b::t2_space" | |
| 1428 | shows "~(trivial_limit net) \<Longrightarrow> (f ---> l) net ==> Lim net f = l" | |
| 1429 | unfolding Lim_def using Lim_unique[of net f] by auto | |
| 1430 | ||
| 1431 | text{* Limit under bilinear function *}
 | |
| 1432 | ||
| 1433 | lemma Lim_bilinear: | |
| 1434 | assumes "(f ---> l) net" and "(g ---> m) net" and "bounded_bilinear h" | |
| 1435 | shows "((\<lambda>x. h (f x) (g x)) ---> (h l m)) net" | |
| 1436 | using `bounded_bilinear h` `(f ---> l) net` `(g ---> m) net` | |
| 1437 | by (rule bounded_bilinear.tendsto) | |
| 1438 | ||
| 1439 | text{* These are special for limits out of the same vector space. *}
 | |
| 1440 | ||
| 1441 | lemma Lim_within_id: "(id ---> a) (at a within s)" | |
| 1442 | unfolding tendsto_def Limits.eventually_within eventually_at_topological | |
| 1443 | by auto | |
| 1444 | ||
| 1445 | lemma Lim_at_id: "(id ---> a) (at a)" | |
| 1446 | apply (subst within_UNIV[symmetric]) by (simp add: Lim_within_id) | |
| 1447 | ||
| 1448 | lemma Lim_at_zero: | |
| 1449 | fixes a :: "'a::real_normed_vector" | |
| 1450 | fixes l :: "'b::topological_space" | |
| 1451 | shows "(f ---> l) (at a) \<longleftrightarrow> ((\<lambda>x. f(a + x)) ---> l) (at 0)" (is "?lhs = ?rhs") | |
| 1452 | proof | |
| 1453 | assume "?lhs" | |
| 1454 |   { fix S assume "open S" "l \<in> S"
 | |
| 1455 | with `?lhs` have "eventually (\<lambda>x. f x \<in> S) (at a)" | |
| 1456 | by (rule topological_tendstoD) | |
| 1457 | then obtain d where d: "d>0" "\<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<in> S" | |
| 1458 | unfolding Limits.eventually_at by fast | |
| 1459 |     { fix x::"'a" assume "x \<noteq> 0 \<and> dist x 0 < d"
 | |
| 1460 | hence "f (a + x) \<in> S" using d | |
| 1461 | apply(erule_tac x="x+a" in allE) | |
| 1462 | by(auto simp add: comm_monoid_add.mult_commute dist_norm dist_commute) | |
| 1463 | } | |
| 1464 | hence "\<exists>d>0. \<forall>x. x \<noteq> 0 \<and> dist x 0 < d \<longrightarrow> f (a + x) \<in> S" | |
| 1465 | using d(1) by auto | |
| 1466 | hence "eventually (\<lambda>x. f (a + x) \<in> S) (at 0)" | |
| 1467 | unfolding Limits.eventually_at . | |
| 1468 | } | |
| 1469 | thus "?rhs" by (rule topological_tendstoI) | |
| 1470 | next | |
| 1471 | assume "?rhs" | |
| 1472 |   { fix S assume "open S" "l \<in> S"
 | |
| 1473 | with `?rhs` have "eventually (\<lambda>x. f (a + x) \<in> S) (at 0)" | |
| 1474 | by (rule topological_tendstoD) | |
| 1475 | then obtain d where d: "d>0" "\<forall>x. x \<noteq> 0 \<and> dist x 0 < d \<longrightarrow> f (a + x) \<in> S" | |
| 1476 | unfolding Limits.eventually_at by fast | |
| 1477 |     { fix x::"'a" assume "x \<noteq> a \<and> dist x a < d"
 | |
| 1478 | hence "f x \<in> S" using d apply(erule_tac x="x-a" in allE) | |
| 1479 | by(auto simp add: comm_monoid_add.mult_commute dist_norm dist_commute) | |
| 1480 | } | |
| 1481 | hence "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<in> S" using d(1) by auto | |
| 1482 | hence "eventually (\<lambda>x. f x \<in> S) (at a)" unfolding Limits.eventually_at . | |
| 1483 | } | |
| 1484 | thus "?lhs" by (rule topological_tendstoI) | |
| 1485 | qed | |
| 1486 | ||
| 1487 | text{* It's also sometimes useful to extract the limit point from the net.  *}
 | |
| 1488 | ||
| 1489 | definition | |
| 1490 | netlimit :: "'a::t2_space net \<Rightarrow> 'a" where | |
| 1491 | "netlimit net = (SOME a. ((\<lambda>x. x) ---> a) net)" | |
| 1492 | ||
| 1493 | lemma netlimit_within: | |
| 1494 | assumes "\<not> trivial_limit (at a within S)" | |
| 1495 | shows "netlimit (at a within S) = a" | |
| 1496 | unfolding netlimit_def | |
| 1497 | apply (rule some_equality) | |
| 1498 | apply (rule Lim_at_within) | |
| 1499 | apply (rule Lim_ident_at) | |
| 1500 | apply (erule Lim_unique [OF assms]) | |
| 1501 | apply (rule Lim_at_within) | |
| 1502 | apply (rule Lim_ident_at) | |
| 1503 | done | |
| 1504 | ||
| 1505 | lemma netlimit_at: | |
| 1506 | fixes a :: "'a::perfect_space" | |
| 1507 | shows "netlimit (at a) = a" | |
| 1508 | apply (subst within_UNIV[symmetric]) | |
| 1509 | using netlimit_within[of a UNIV] | |
| 1510 | by (simp add: trivial_limit_at within_UNIV) | |
| 1511 | ||
| 1512 | text{* Transformation of limit. *}
 | |
| 1513 | ||
| 1514 | lemma Lim_transform: | |
| 1515 | fixes f g :: "'a::type \<Rightarrow> 'b::real_normed_vector" | |
| 1516 | assumes "((\<lambda>x. f x - g x) ---> 0) net" "(f ---> l) net" | |
| 1517 | shows "(g ---> l) net" | |
| 1518 | proof- | |
| 1519 | from assms have "((\<lambda>x. f x - g x - f x) ---> 0 - l) net" using Lim_sub[of "\<lambda>x. f x - g x" 0 net f l] by auto | |
| 1520 | thus "?thesis" using Lim_neg [of "\<lambda> x. - g x" "-l" net] by auto | |
| 1521 | qed | |
| 1522 | ||
| 1523 | lemma Lim_transform_eventually: | |
| 1524 | "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f ---> l) net ==> (g ---> l) net" | |
| 1525 | apply (rule topological_tendstoI) | |
| 1526 | apply (drule (2) topological_tendstoD) | |
| 1527 | apply (erule (1) eventually_elim2, simp) | |
| 1528 | done | |
| 1529 | ||
| 1530 | lemma Lim_transform_within: | |
| 1531 | fixes l :: "'b::metric_space" (* TODO: generalize *) | |
| 1532 | assumes "0 < d" "(\<forall>x'\<in>S. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x')" | |
| 1533 | "(f ---> l) (at x within S)" | |
| 1534 | shows "(g ---> l) (at x within S)" | |
| 1535 | using assms(1,3) unfolding Lim_within | |
| 1536 | apply - | |
| 1537 | apply (clarify, rename_tac e) | |
| 1538 | apply (drule_tac x=e in spec, clarsimp, rename_tac r) | |
| 1539 | apply (rule_tac x="min d r" in exI, clarsimp, rename_tac y) | |
| 1540 | apply (drule_tac x=y in bspec, assumption, clarsimp) | |
| 1541 | apply (simp add: assms(2)) | |
| 1542 | done | |
| 1543 | ||
| 1544 | lemma Lim_transform_at: | |
| 1545 | fixes l :: "'b::metric_space" (* TODO: generalize *) | |
| 1546 | shows "0 < d \<Longrightarrow> (\<forall>x'. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x') \<Longrightarrow> | |
| 1547 | (f ---> l) (at x) ==> (g ---> l) (at x)" | |
| 1548 | apply (subst within_UNIV[symmetric]) | |
| 1549 | using Lim_transform_within[of d UNIV x f g l] | |
| 1550 | by (auto simp add: within_UNIV) | |
| 1551 | ||
| 1552 | text{* Common case assuming being away from some crucial point like 0. *}
 | |
| 1553 | ||
| 1554 | lemma Lim_transform_away_within: | |
| 1555 | fixes a b :: "'a::metric_space" | |
| 1556 | fixes l :: "'b::metric_space" (* TODO: generalize *) | |
| 1557 | assumes "a\<noteq>b" "\<forall>x\<in> S. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" | |
| 1558 | and "(f ---> l) (at a within S)" | |
| 1559 | shows "(g ---> l) (at a within S)" | |
| 1560 | proof- | |
| 1561 | have "\<forall>x'\<in>S. 0 < dist x' a \<and> dist x' a < dist a b \<longrightarrow> f x' = g x'" using assms(2) | |
| 1562 | apply auto apply(erule_tac x=x' in ballE) by (auto simp add: dist_commute) | |
| 1563 | thus ?thesis using Lim_transform_within[of "dist a b" S a f g l] using assms(1,3) unfolding dist_nz by auto | |
| 1564 | qed | |
| 1565 | ||
| 1566 | lemma Lim_transform_away_at: | |
| 1567 | fixes a b :: "'a::metric_space" | |
| 1568 | fixes l :: "'b::metric_space" (* TODO: generalize *) | |
| 1569 | assumes ab: "a\<noteq>b" and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" | |
| 1570 | and fl: "(f ---> l) (at a)" | |
| 1571 | shows "(g ---> l) (at a)" | |
| 1572 | using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl | |
| 1573 | by (auto simp add: within_UNIV) | |
| 1574 | ||
| 1575 | text{* Alternatively, within an open set. *}
 | |
| 1576 | ||
| 1577 | lemma Lim_transform_within_open: | |
| 1578 | fixes a :: "'a::metric_space" | |
| 1579 | fixes l :: "'b::metric_space" (* TODO: generalize *) | |
| 1580 | assumes "open S" "a \<in> S" "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> f x = g x" "(f ---> l) (at a)" | |
| 1581 | shows "(g ---> l) (at a)" | |
| 1582 | proof- | |
| 1583 | from assms(1,2) obtain e::real where "e>0" and e:"ball a e \<subseteq> S" unfolding open_contains_ball by auto | |
| 1584 | hence "\<forall>x'. 0 < dist x' a \<and> dist x' a < e \<longrightarrow> f x' = g x'" using assms(3) | |
| 1585 | unfolding ball_def subset_eq apply auto apply(erule_tac x=x' in allE) apply(erule_tac x=x' in ballE) by(auto simp add: dist_commute) | |
| 1586 | thus ?thesis using Lim_transform_at[of e a f g l] `e>0` assms(4) by auto | |
| 1587 | qed | |
| 1588 | ||
| 1589 | text{* A congruence rule allowing us to transform limits assuming not at point. *}
 | |
| 1590 | ||
| 1591 | (* FIXME: Only one congruence rule for tendsto can be used at a time! *) | |
| 1592 | ||
| 1593 | lemma Lim_cong_within[cong add]: | |
| 1594 | fixes a :: "'a::metric_space" | |
| 1595 | fixes l :: "'b::metric_space" (* TODO: generalize *) | |
| 1596 | shows "(\<And>x. x \<noteq> a \<Longrightarrow> f x = g x) ==> ((\<lambda>x. f x) ---> l) (at a within S) \<longleftrightarrow> ((g ---> l) (at a within S))" | |
| 1597 | by (simp add: Lim_within dist_nz[symmetric]) | |
| 1598 | ||
| 1599 | lemma Lim_cong_at[cong add]: | |
| 1600 | fixes a :: "'a::metric_space" | |
| 1601 | fixes l :: "'b::metric_space" (* TODO: generalize *) | |
| 1602 | shows "(\<And>x. x \<noteq> a ==> f x = g x) ==> (((\<lambda>x. f x) ---> l) (at a) \<longleftrightarrow> ((g ---> l) (at a)))" | |
| 1603 | by (simp add: Lim_at dist_nz[symmetric]) | |
| 1604 | ||
| 1605 | text{* Useful lemmas on closure and set of possible sequential limits.*}
 | |
| 1606 | ||
| 1607 | lemma closure_sequential: | |
| 1608 | fixes l :: "'a::metric_space" (* TODO: generalize *) | |
| 1609 | shows "l \<in> closure S \<longleftrightarrow> (\<exists>x. (\<forall>n. x n \<in> S) \<and> (x ---> l) sequentially)" (is "?lhs = ?rhs") | |
| 1610 | proof | |
| 1611 | assume "?lhs" moreover | |
| 1612 |   { assume "l \<in> S"
 | |
| 1613 | hence "?rhs" using Lim_const[of l sequentially] by auto | |
| 1614 | } moreover | |
| 1615 |   { assume "l islimpt S"
 | |
| 1616 | hence "?rhs" unfolding islimpt_sequential by auto | |
| 1617 | } ultimately | |
| 1618 | show "?rhs" unfolding closure_def by auto | |
| 1619 | next | |
| 1620 | assume "?rhs" | |
| 1621 | thus "?lhs" unfolding closure_def unfolding islimpt_sequential by auto | |
| 1622 | qed | |
| 1623 | ||
| 1624 | lemma closed_sequential_limits: | |
| 1625 | fixes S :: "'a::metric_space set" | |
| 1626 | shows "closed S \<longleftrightarrow> (\<forall>x l. (\<forall>n. x n \<in> S) \<and> (x ---> l) sequentially \<longrightarrow> l \<in> S)" | |
| 1627 | unfolding closed_limpt | |
| 1628 | using closure_sequential [where 'a='a] closure_closed [where 'a='a] closed_limpt [where 'a='a] islimpt_sequential [where 'a='a] mem_delete [where 'a='a] | |
| 1629 | by metis | |
| 1630 | ||
| 1631 | lemma closure_approachable: | |
| 1632 | fixes S :: "'a::metric_space set" | |
| 1633 | shows "x \<in> closure S \<longleftrightarrow> (\<forall>e>0. \<exists>y\<in>S. dist y x < e)" | |
| 1634 | apply (auto simp add: closure_def islimpt_approachable) | |
| 1635 | by (metis dist_self) | |
| 1636 | ||
| 1637 | lemma closed_approachable: | |
| 1638 | fixes S :: "'a::metric_space set" | |
| 1639 | shows "closed S ==> (\<forall>e>0. \<exists>y\<in>S. dist y x < e) \<longleftrightarrow> x \<in> S" | |
| 1640 | by (metis closure_closed closure_approachable) | |
| 1641 | ||
| 1642 | text{* Some other lemmas about sequences. *}
 | |
| 1643 | ||
| 1644 | lemma seq_offset: | |
| 1645 | fixes l :: "'a::metric_space" (* TODO: generalize *) | |
| 1646 | shows "(f ---> l) sequentially ==> ((\<lambda>i. f( i + k)) ---> l) sequentially" | |
| 1647 | apply (auto simp add: Lim_sequentially) | |
| 1648 | by (metis trans_le_add1 ) | |
| 1649 | ||
| 1650 | lemma seq_offset_neg: | |
| 1651 | "(f ---> l) sequentially ==> ((\<lambda>i. f(i - k)) ---> l) sequentially" | |
| 1652 | apply (rule topological_tendstoI) | |
| 1653 | apply (drule (2) topological_tendstoD) | |
| 1654 | apply (simp only: eventually_sequentially) | |
| 1655 | apply (subgoal_tac "\<And>N k (n::nat). N + k <= n ==> N <= n - k") | |
| 1656 | apply metis | |
| 1657 | by arith | |
| 1658 | ||
| 1659 | lemma seq_offset_rev: | |
| 1660 | "((\<lambda>i. f(i + k)) ---> l) sequentially ==> (f ---> l) sequentially" | |
| 1661 | apply (rule topological_tendstoI) | |
| 1662 | apply (drule (2) topological_tendstoD) | |
| 1663 | apply (simp only: eventually_sequentially) | |
| 1664 | apply (subgoal_tac "\<And>N k (n::nat). N + k <= n ==> N <= n - k \<and> (n - k) + k = n") | |
| 1665 | by metis arith | |
| 1666 | ||
| 1667 | lemma seq_harmonic: "((\<lambda>n. inverse (real n)) ---> 0) sequentially" | |
| 1668 | proof- | |
| 1669 |   { fix e::real assume "e>0"
 | |
| 1670 | hence "\<exists>N::nat. \<forall>n::nat\<ge>N. inverse (real n) < e" | |
| 1671 | using real_arch_inv[of e] apply auto apply(rule_tac x=n in exI) | |
| 1672 | by (metis not_le le_imp_inverse_le not_less real_of_nat_gt_zero_cancel_iff real_of_nat_less_iff xt1(7)) | |
| 1673 | } | |
| 1674 | thus ?thesis unfolding Lim_sequentially dist_norm by simp | |
| 1675 | qed | |
| 1676 | ||
| 1677 | text{* More properties of closed balls. *}
 | |
| 1678 | ||
| 1679 | lemma closed_cball: "closed (cball x e)" | |
| 1680 | unfolding cball_def closed_def | |
| 1681 | unfolding Collect_neg_eq [symmetric] not_le | |
| 1682 | apply (clarsimp simp add: open_dist, rename_tac y) | |
| 1683 | apply (rule_tac x="dist x y - e" in exI, clarsimp) | |
| 1684 | apply (rename_tac x') | |
| 1685 | apply (cut_tac x=x and y=x' and z=y in dist_triangle) | |
| 1686 | apply simp | |
| 1687 | done | |
| 1688 | ||
| 1689 | lemma open_contains_cball: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. cball x e \<subseteq> S)" | |
| 1690 | proof- | |
| 1691 |   { fix x and e::real assume "x\<in>S" "e>0" "ball x e \<subseteq> S"
 | |
| 1692 | hence "\<exists>d>0. cball x d \<subseteq> S" unfolding subset_eq by (rule_tac x="e/2" in exI, auto) | |
| 1693 | } moreover | |
| 1694 |   { fix x and e::real assume "x\<in>S" "e>0" "cball x e \<subseteq> S"
 | |
| 1695 | hence "\<exists>d>0. ball x d \<subseteq> S" unfolding subset_eq apply(rule_tac x="e/2" in exI) by auto | |
| 1696 | } ultimately | |
| 1697 | show ?thesis unfolding open_contains_ball by auto | |
| 1698 | qed | |
| 1699 | ||
| 1700 | lemma open_contains_cball_eq: "open S ==> (\<forall>x. x \<in> S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S))" | |
| 1701 | by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball mem_def) | |
| 1702 | ||
| 1703 | lemma mem_interior_cball: "x \<in> interior S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S)" | |
| 1704 | apply (simp add: interior_def, safe) | |
| 1705 | apply (force simp add: open_contains_cball) | |
| 1706 | apply (rule_tac x="ball x e" in exI) | |
| 1707 | apply (simp add: open_ball centre_in_ball subset_trans [OF ball_subset_cball]) | |
| 1708 | done | |
| 1709 | ||
| 1710 | lemma islimpt_ball: | |
| 1711 |   fixes x y :: "'a::{real_normed_vector,perfect_space}"
 | |
| 1712 | shows "y islimpt ball x e \<longleftrightarrow> 0 < e \<and> y \<in> cball x e" (is "?lhs = ?rhs") | |
| 1713 | proof | |
| 1714 | assume "?lhs" | |
| 1715 |   { assume "e \<le> 0"
 | |
| 1716 |     hence *:"ball x e = {}" using ball_eq_empty[of x e] by auto
 | |
| 1717 | have False using `?lhs` unfolding * using islimpt_EMPTY[of y] by auto | |
| 1718 | } | |
| 1719 | hence "e > 0" by (metis not_less) | |
| 1720 | moreover | |
| 1721 | have "y \<in> cball x e" using closed_cball[of x e] islimpt_subset[of y "ball x e" "cball x e"] ball_subset_cball[of x e] `?lhs` unfolding closed_limpt by auto | |
| 1722 | ultimately show "?rhs" by auto | |
| 1723 | next | |
| 1724 | assume "?rhs" hence "e>0" by auto | |
| 1725 |   { fix d::real assume "d>0"
 | |
| 1726 | have "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1727 | proof(cases "d \<le> dist x y") | |
| 1728 | case True thus "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1729 | proof(cases "x=y") | |
| 1730 | case True hence False using `d \<le> dist x y` `d>0` by auto | |
| 1731 | thus "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" by auto | |
| 1732 | next | |
| 1733 | case False | |
| 1734 | ||
| 1735 | have "dist x (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) | |
| 1736 | = norm (x - y + (d / (2 * norm (y - x))) *\<^sub>R (y - x))" | |
| 1737 | unfolding mem_cball mem_ball dist_norm diff_diff_eq2 diff_add_eq[THEN sym] by auto | |
| 1738 | also have "\<dots> = \<bar>- 1 + d / (2 * norm (x - y))\<bar> * norm (x - y)" | |
| 1739 | using scaleR_left_distrib[of "- 1" "d / (2 * norm (y - x))", THEN sym, of "y - x"] | |
| 1740 | unfolding scaleR_minus_left scaleR_one | |
| 1741 | by (auto simp add: norm_minus_commute) | |
| 1742 | also have "\<dots> = \<bar>- norm (x - y) + d / 2\<bar>" | |
| 1743 | unfolding abs_mult_pos[of "norm (x - y)", OF norm_ge_zero[of "x - y"]] | |
| 1744 | unfolding real_add_mult_distrib using `x\<noteq>y`[unfolded dist_nz, unfolded dist_norm] by auto | |
| 1745 | also have "\<dots> \<le> e - d/2" using `d \<le> dist x y` and `d>0` and `?rhs` by(auto simp add: dist_norm) | |
| 1746 | finally have "y - (d / (2 * dist y x)) *\<^sub>R (y - x) \<in> ball x e" using `d>0` by auto | |
| 1747 | ||
| 1748 | moreover | |
| 1749 | ||
| 1750 | have "(d / (2*dist y x)) *\<^sub>R (y - x) \<noteq> 0" | |
| 1751 | using `x\<noteq>y`[unfolded dist_nz] `d>0` unfolding scaleR_eq_0_iff by (auto simp add: dist_commute) | |
| 1752 | moreover | |
| 1753 | have "dist (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) y < d" unfolding dist_norm apply simp unfolding norm_minus_cancel | |
| 1754 | using `d>0` `x\<noteq>y`[unfolded dist_nz] dist_commute[of x y] | |
| 1755 | unfolding dist_norm by auto | |
| 1756 | ultimately show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" by (rule_tac x="y - (d / (2*dist y x)) *\<^sub>R (y - x)" in bexI) auto | |
| 1757 | qed | |
| 1758 | next | |
| 1759 | case False hence "d > dist x y" by auto | |
| 1760 | show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1761 | proof(cases "x=y") | |
| 1762 | case True | |
| 1763 | obtain z where **: "z \<noteq> y" "dist z y < min e d" | |
| 1764 | using perfect_choose_dist[of "min e d" y] | |
| 1765 | using `d > 0` `e>0` by auto | |
| 1766 | show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1767 | unfolding `x = y` | |
| 1768 | using `z \<noteq> y` ** | |
| 1769 | by (rule_tac x=z in bexI, auto simp add: dist_commute) | |
| 1770 | next | |
| 1771 | case False thus "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1772 | using `d>0` `d > dist x y` `?rhs` by(rule_tac x=x in bexI, auto) | |
| 1773 | qed | |
| 1774 | qed } | |
| 1775 | thus "?lhs" unfolding mem_cball islimpt_approachable mem_ball by auto | |
| 1776 | qed | |
| 1777 | ||
| 1778 | lemma closure_ball_lemma: | |
| 1779 | fixes x y :: "'a::real_normed_vector" | |
| 1780 | assumes "x \<noteq> y" shows "y islimpt ball x (dist x y)" | |
| 1781 | proof (rule islimptI) | |
| 1782 | fix T assume "y \<in> T" "open T" | |
| 1783 | then obtain r where "0 < r" "\<forall>z. dist z y < r \<longrightarrow> z \<in> T" | |
| 1784 | unfolding open_dist by fast | |
| 1785 | (* choose point between x and y, within distance r of y. *) | |
| 1786 | def k \<equiv> "min 1 (r / (2 * dist x y))" | |
| 1787 | def z \<equiv> "y + scaleR k (x - y)" | |
| 1788 | have z_def2: "z = x + scaleR (1 - k) (y - x)" | |
| 1789 | unfolding z_def by (simp add: algebra_simps) | |
| 1790 | have "dist z y < r" | |
| 1791 | unfolding z_def k_def using `0 < r` | |
| 1792 | by (simp add: dist_norm min_def) | |
| 1793 | hence "z \<in> T" using `\<forall>z. dist z y < r \<longrightarrow> z \<in> T` by simp | |
| 1794 | have "dist x z < dist x y" | |
| 1795 | unfolding z_def2 dist_norm | |
| 1796 | apply (simp add: norm_minus_commute) | |
| 1797 | apply (simp only: dist_norm [symmetric]) | |
| 1798 | apply (subgoal_tac "\<bar>1 - k\<bar> * dist x y < 1 * dist x y", simp) | |
| 1799 | apply (rule mult_strict_right_mono) | |
| 1800 | apply (simp add: k_def divide_pos_pos zero_less_dist_iff `0 < r` `x \<noteq> y`) | |
| 1801 | apply (simp add: zero_less_dist_iff `x \<noteq> y`) | |
| 1802 | done | |
| 1803 | hence "z \<in> ball x (dist x y)" by simp | |
| 1804 | have "z \<noteq> y" | |
| 1805 | unfolding z_def k_def using `x \<noteq> y` `0 < r` | |
| 1806 | by (simp add: min_def) | |
| 1807 | show "\<exists>z\<in>ball x (dist x y). z \<in> T \<and> z \<noteq> y" | |
| 1808 | using `z \<in> ball x (dist x y)` `z \<in> T` `z \<noteq> y` | |
| 1809 | by fast | |
| 1810 | qed | |
| 1811 | ||
| 1812 | lemma closure_ball: | |
| 1813 | fixes x :: "'a::real_normed_vector" | |
| 1814 | shows "0 < e \<Longrightarrow> closure (ball x e) = cball x e" | |
| 1815 | apply (rule equalityI) | |
| 1816 | apply (rule closure_minimal) | |
| 1817 | apply (rule ball_subset_cball) | |
| 1818 | apply (rule closed_cball) | |
| 1819 | apply (rule subsetI, rename_tac y) | |
| 1820 | apply (simp add: le_less [where 'a=real]) | |
| 1821 | apply (erule disjE) | |
| 1822 | apply (rule subsetD [OF closure_subset], simp) | |
| 1823 | apply (simp add: closure_def) | |
| 1824 | apply clarify | |
| 1825 | apply (rule closure_ball_lemma) | |
| 1826 | apply (simp add: zero_less_dist_iff) | |
| 1827 | done | |
| 1828 | ||
| 1829 | (* In a trivial vector space, this fails for e = 0. *) | |
| 1830 | lemma interior_cball: | |
| 1831 |   fixes x :: "'a::{real_normed_vector, perfect_space}"
 | |
| 1832 | shows "interior (cball x e) = ball x e" | |
| 1833 | proof(cases "e\<ge>0") | |
| 1834 | case False note cs = this | |
| 1835 |   from cs have "ball x e = {}" using ball_empty[of e x] by auto moreover
 | |
| 1836 |   { fix y assume "y \<in> cball x e"
 | |
| 1837 | hence False unfolding mem_cball using dist_nz[of x y] cs by auto } | |
| 1838 |   hence "cball x e = {}" by auto
 | |
| 1839 |   hence "interior (cball x e) = {}" using interior_empty by auto
 | |
| 1840 | ultimately show ?thesis by blast | |
| 1841 | next | |
| 1842 | case True note cs = this | |
| 1843 | have "ball x e \<subseteq> cball x e" using ball_subset_cball by auto moreover | |
| 1844 |   { fix S y assume as: "S \<subseteq> cball x e" "open S" "y\<in>S"
 | |
| 1845 | then obtain d where "d>0" and d:"\<forall>x'. dist x' y < d \<longrightarrow> x' \<in> S" unfolding open_dist by blast | |
| 1846 | ||
| 1847 | then obtain xa where xa_y: "xa \<noteq> y" and xa: "dist xa y < d" | |
| 1848 | using perfect_choose_dist [of d] by auto | |
| 1849 | have "xa\<in>S" using d[THEN spec[where x=xa]] using xa by(auto simp add: dist_commute) | |
| 1850 | hence xa_cball:"xa \<in> cball x e" using as(1) by auto | |
| 1851 | ||
| 1852 | hence "y \<in> ball x e" proof(cases "x = y") | |
| 1853 | case True | |
| 1854 | hence "e>0" using xa_y[unfolded dist_nz] xa_cball[unfolded mem_cball] by (auto simp add: dist_commute) | |
| 1855 | thus "y \<in> ball x e" using `x = y ` by simp | |
| 1856 | next | |
| 1857 | case False | |
| 1858 | have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) y < d" unfolding dist_norm | |
| 1859 | using `d>0` norm_ge_zero[of "y - x"] `x \<noteq> y` by auto | |
| 1860 | hence *:"y + (d / 2 / dist y x) *\<^sub>R (y - x) \<in> cball x e" using d as(1)[unfolded subset_eq] by blast | |
| 1861 | have "y - x \<noteq> 0" using `x \<noteq> y` by auto | |
| 1862 | hence **:"d / (2 * norm (y - x)) > 0" unfolding zero_less_norm_iff[THEN sym] | |
| 1863 | using `d>0` divide_pos_pos[of d "2*norm (y - x)"] by auto | |
| 1864 | ||
| 1865 | have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) x = norm (y + (d / (2 * norm (y - x))) *\<^sub>R y - (d / (2 * norm (y - x))) *\<^sub>R x - x)" | |
| 1866 | by (auto simp add: dist_norm algebra_simps) | |
| 1867 | also have "\<dots> = norm ((1 + d / (2 * norm (y - x))) *\<^sub>R (y - x))" | |
| 1868 | by (auto simp add: algebra_simps) | |
| 1869 | also have "\<dots> = \<bar>1 + d / (2 * norm (y - x))\<bar> * norm (y - x)" | |
| 1870 | using ** by auto | |
| 1871 | also have "\<dots> = (dist y x) + d/2"using ** by (auto simp add: left_distrib dist_norm) | |
| 1872 | finally have "e \<ge> dist x y +d/2" using *[unfolded mem_cball] by (auto simp add: dist_commute) | |
| 1873 | thus "y \<in> ball x e" unfolding mem_ball using `d>0` by auto | |
| 1874 | qed } | |
| 1875 | hence "\<forall>S \<subseteq> cball x e. open S \<longrightarrow> S \<subseteq> ball x e" by auto | |
| 1876 | ultimately show ?thesis using interior_unique[of "ball x e" "cball x e"] using open_ball[of x e] by auto | |
| 1877 | qed | |
| 1878 | ||
| 1879 | lemma frontier_ball: | |
| 1880 | fixes a :: "'a::real_normed_vector" | |
| 1881 |   shows "0 < e ==> frontier(ball a e) = {x. dist a x = e}"
 | |
| 1882 | apply (simp add: frontier_def closure_ball interior_open open_ball order_less_imp_le) | |
| 1883 | apply (simp add: expand_set_eq) | |
| 1884 | by arith | |
| 1885 | ||
| 1886 | lemma frontier_cball: | |
| 1887 |   fixes a :: "'a::{real_normed_vector, perfect_space}"
 | |
| 1888 |   shows "frontier(cball a e) = {x. dist a x = e}"
 | |
| 1889 | apply (simp add: frontier_def interior_cball closed_cball closure_closed order_less_imp_le) | |
| 1890 | apply (simp add: expand_set_eq) | |
| 1891 | by arith | |
| 1892 | ||
| 1893 | lemma cball_eq_empty: "(cball x e = {}) \<longleftrightarrow> e < 0"
 | |
| 1894 | apply (simp add: expand_set_eq not_le) | |
| 1895 | by (metis zero_le_dist dist_self order_less_le_trans) | |
| 1896 | lemma cball_empty: "e < 0 ==> cball x e = {}" by (simp add: cball_eq_empty)
 | |
| 1897 | ||
| 1898 | lemma cball_eq_sing: | |
| 1899 | fixes x :: "'a::perfect_space" | |
| 1900 |   shows "(cball x e = {x}) \<longleftrightarrow> e = 0"
 | |
| 1901 | proof (rule linorder_cases) | |
| 1902 | assume e: "0 < e" | |
| 1903 | obtain a where "a \<noteq> x" "dist a x < e" | |
| 1904 | using perfect_choose_dist [OF e] by auto | |
| 1905 | hence "a \<noteq> x" "dist x a \<le> e" by (auto simp add: dist_commute) | |
| 1906 | with e show ?thesis by (auto simp add: expand_set_eq) | |
| 1907 | qed auto | |
| 1908 | ||
| 1909 | lemma cball_sing: | |
| 1910 | fixes x :: "'a::metric_space" | |
| 1911 |   shows "e = 0 ==> cball x e = {x}"
 | |
| 1912 | by (auto simp add: expand_set_eq) | |
| 1913 | ||
| 1914 | text{* For points in the interior, localization of limits makes no difference.   *}
 | |
| 1915 | ||
| 1916 | lemma eventually_within_interior: | |
| 1917 | assumes "x \<in> interior S" | |
| 1918 | shows "eventually P (at x within S) \<longleftrightarrow> eventually P (at x)" (is "?lhs = ?rhs") | |
| 1919 | proof- | |
| 1920 | from assms obtain T where T: "open T" "x \<in> T" "T \<subseteq> S" | |
| 1921 | unfolding interior_def by fast | |
| 1922 |   { assume "?lhs"
 | |
| 1923 | then obtain A where "open A" "x \<in> A" "\<forall>y\<in>A. y \<noteq> x \<longrightarrow> y \<in> S \<longrightarrow> P y" | |
| 1924 | unfolding Limits.eventually_within Limits.eventually_at_topological | |
| 1925 | by auto | |
| 1926 | with T have "open (A \<inter> T)" "x \<in> A \<inter> T" "\<forall>y\<in>(A \<inter> T). y \<noteq> x \<longrightarrow> P y" | |
| 1927 | by auto | |
| 1928 | then have "?rhs" | |
| 1929 | unfolding Limits.eventually_at_topological by auto | |
| 1930 | } moreover | |
| 1931 |   { assume "?rhs" hence "?lhs"
 | |
| 1932 | unfolding Limits.eventually_within | |
| 1933 | by (auto elim: eventually_elim1) | |
| 1934 | } ultimately | |
| 1935 | show "?thesis" .. | |
| 1936 | qed | |
| 1937 | ||
| 1938 | lemma lim_within_interior: | |
| 1939 | "x \<in> interior S \<Longrightarrow> (f ---> l) (at x within S) \<longleftrightarrow> (f ---> l) (at x)" | |
| 1940 | unfolding tendsto_def by (simp add: eventually_within_interior) | |
| 1941 | ||
| 1942 | lemma netlimit_within_interior: | |
| 1943 |   fixes x :: "'a::{perfect_space, real_normed_vector}"
 | |
| 1944 | (* FIXME: generalize to perfect_space *) | |
| 1945 | assumes "x \<in> interior S" | |
| 1946 | shows "netlimit(at x within S) = x" (is "?lhs = ?rhs") | |
| 1947 | proof- | |
| 1948 | from assms obtain e::real where e:"e>0" "ball x e \<subseteq> S" using open_interior[of S] unfolding open_contains_ball using interior_subset[of S] by auto | |
| 1949 | hence "\<not> trivial_limit (at x within S)" using islimpt_subset[of x "ball x e" S] unfolding trivial_limit_within islimpt_ball centre_in_cball by auto | |
| 1950 | thus ?thesis using netlimit_within by auto | |
| 1951 | qed | |
| 1952 | ||
| 1953 | subsection{* Boundedness. *}
 | |
| 1954 | ||
| 1955 | (* FIXME: This has to be unified with BSEQ!! *) | |
| 1956 | definition | |
| 1957 | bounded :: "'a::metric_space set \<Rightarrow> bool" where | |
| 1958 | "bounded S \<longleftrightarrow> (\<exists>x e. \<forall>y\<in>S. dist x y \<le> e)" | |
| 1959 | ||
| 1960 | lemma bounded_any_center: "bounded S \<longleftrightarrow> (\<exists>e. \<forall>y\<in>S. dist a y \<le> e)" | |
| 1961 | unfolding bounded_def | |
| 1962 | apply safe | |
| 1963 | apply (rule_tac x="dist a x + e" in exI, clarify) | |
| 1964 | apply (drule (1) bspec) | |
| 1965 | apply (erule order_trans [OF dist_triangle add_left_mono]) | |
| 1966 | apply auto | |
| 1967 | done | |
| 1968 | ||
| 1969 | lemma bounded_iff: "bounded S \<longleftrightarrow> (\<exists>a. \<forall>x\<in>S. norm x \<le> a)" | |
| 1970 | unfolding bounded_any_center [where a=0] | |
| 1971 | by (simp add: dist_norm) | |
| 1972 | ||
| 1973 | lemma bounded_empty[simp]: "bounded {}" by (simp add: bounded_def)
 | |
| 1974 | lemma bounded_subset: "bounded T \<Longrightarrow> S \<subseteq> T ==> bounded S" | |
| 1975 | by (metis bounded_def subset_eq) | |
| 1976 | ||
| 1977 | lemma bounded_interior[intro]: "bounded S ==> bounded(interior S)" | |
| 1978 | by (metis bounded_subset interior_subset) | |
| 1979 | ||
| 1980 | lemma bounded_closure[intro]: assumes "bounded S" shows "bounded(closure S)" | |
| 1981 | proof- | |
| 1982 | from assms obtain x and a where a: "\<forall>y\<in>S. dist x y \<le> a" unfolding bounded_def by auto | |
| 1983 |   { fix y assume "y \<in> closure S"
 | |
| 1984 | then obtain f where f: "\<forall>n. f n \<in> S" "(f ---> y) sequentially" | |
| 1985 | unfolding closure_sequential by auto | |
| 1986 | have "\<forall>n. f n \<in> S \<longrightarrow> dist x (f n) \<le> a" using a by simp | |
| 1987 | hence "eventually (\<lambda>n. dist x (f n) \<le> a) sequentially" | |
| 1988 | by (rule eventually_mono, simp add: f(1)) | |
| 1989 | have "dist x y \<le> a" | |
| 1990 | apply (rule Lim_dist_ubound [of sequentially f]) | |
| 1991 | apply (rule trivial_limit_sequentially) | |
| 1992 | apply (rule f(2)) | |
| 1993 | apply fact | |
| 1994 | done | |
| 1995 | } | |
| 1996 | thus ?thesis unfolding bounded_def by auto | |
| 1997 | qed | |
| 1998 | ||
| 1999 | lemma bounded_cball[simp,intro]: "bounded (cball x e)" | |
| 2000 | apply (simp add: bounded_def) | |
| 2001 | apply (rule_tac x=x in exI) | |
| 2002 | apply (rule_tac x=e in exI) | |
| 2003 | apply auto | |
| 2004 | done | |
| 2005 | ||
| 2006 | lemma bounded_ball[simp,intro]: "bounded(ball x e)" | |
| 2007 | by (metis ball_subset_cball bounded_cball bounded_subset) | |
| 2008 | ||
| 2009 | lemma finite_imp_bounded[intro]: assumes "finite S" shows "bounded S" | |
| 2010 | proof- | |
| 2011 |   { fix a F assume as:"bounded F"
 | |
| 2012 | then obtain x e where "\<forall>y\<in>F. dist x y \<le> e" unfolding bounded_def by auto | |
| 2013 | hence "\<forall>y\<in>(insert a F). dist x y \<le> max e (dist x a)" by auto | |
| 2014 | hence "bounded (insert a F)" unfolding bounded_def by (intro exI) | |
| 2015 | } | |
| 2016 | thus ?thesis using finite_induct[of S bounded] using bounded_empty assms by auto | |
| 2017 | qed | |
| 2018 | ||
| 2019 | lemma bounded_Un[simp]: "bounded (S \<union> T) \<longleftrightarrow> bounded S \<and> bounded T" | |
| 2020 | apply (auto simp add: bounded_def) | |
| 2021 | apply (rename_tac x y r s) | |
| 2022 | apply (rule_tac x=x in exI) | |
| 2023 | apply (rule_tac x="max r (dist x y + s)" in exI) | |
| 2024 | apply (rule ballI, rename_tac z, safe) | |
| 2025 | apply (drule (1) bspec, simp) | |
| 2026 | apply (drule (1) bspec) | |
| 2027 | apply (rule min_max.le_supI2) | |
| 2028 | apply (erule order_trans [OF dist_triangle add_left_mono]) | |
| 2029 | done | |
| 2030 | ||
| 2031 | lemma bounded_Union[intro]: "finite F \<Longrightarrow> (\<forall>S\<in>F. bounded S) \<Longrightarrow> bounded(\<Union>F)" | |
| 2032 | by (induct rule: finite_induct[of F], auto) | |
| 2033 | ||
| 2034 | lemma bounded_pos: "bounded S \<longleftrightarrow> (\<exists>b>0. \<forall>x\<in> S. norm x <= b)" | |
| 2035 | apply (simp add: bounded_iff) | |
| 2036 | apply (subgoal_tac "\<And>x (y::real). 0 < 1 + abs y \<and> (x <= y \<longrightarrow> x <= 1 + abs y)") | |
| 2037 | by metis arith | |
| 2038 | ||
| 2039 | lemma bounded_Int[intro]: "bounded S \<or> bounded T \<Longrightarrow> bounded (S \<inter> T)" | |
| 2040 | by (metis Int_lower1 Int_lower2 bounded_subset) | |
| 2041 | ||
| 2042 | lemma bounded_diff[intro]: "bounded S ==> bounded (S - T)" | |
| 2043 | apply (metis Diff_subset bounded_subset) | |
| 2044 | done | |
| 2045 | ||
| 2046 | lemma bounded_insert[intro]:"bounded(insert x S) \<longleftrightarrow> bounded S" | |
| 2047 | by (metis Diff_cancel Un_empty_right Un_insert_right bounded_Un bounded_subset finite.emptyI finite_imp_bounded infinite_remove subset_insertI) | |
| 2048 | ||
| 2049 | lemma not_bounded_UNIV[simp, intro]: | |
| 2050 |   "\<not> bounded (UNIV :: 'a::{real_normed_vector, perfect_space} set)"
 | |
| 2051 | proof(auto simp add: bounded_pos not_le) | |
| 2052 | obtain x :: 'a where "x \<noteq> 0" | |
| 2053 | using perfect_choose_dist [OF zero_less_one] by fast | |
| 2054 | fix b::real assume b: "b >0" | |
| 2055 | have b1: "b +1 \<ge> 0" using b by simp | |
| 2056 | with `x \<noteq> 0` have "b < norm (scaleR (b + 1) (sgn x))" | |
| 2057 | by (simp add: norm_sgn) | |
| 2058 | then show "\<exists>x::'a. b < norm x" .. | |
| 2059 | qed | |
| 2060 | ||
| 2061 | lemma bounded_linear_image: | |
| 2062 | assumes "bounded S" "bounded_linear f" | |
| 2063 | shows "bounded(f ` S)" | |
| 2064 | proof- | |
| 2065 | from assms(1) obtain b where b:"b>0" "\<forall>x\<in>S. norm x \<le> b" unfolding bounded_pos by auto | |
| 2066 | from assms(2) obtain B where B:"B>0" "\<forall>x. norm (f x) \<le> B * norm x" using bounded_linear.pos_bounded by (auto simp add: mult_ac) | |
| 2067 |   { fix x assume "x\<in>S"
 | |
| 2068 | hence "norm x \<le> b" using b by auto | |
| 2069 | hence "norm (f x) \<le> B * b" using B(2) apply(erule_tac x=x in allE) | |
| 2070 | by (metis B(1) B(2) real_le_trans real_mult_le_cancel_iff2) | |
| 2071 | } | |
| 2072 | thus ?thesis unfolding bounded_pos apply(rule_tac x="b*B" in exI) | |
| 2073 | using b B real_mult_order[of b B] by (auto simp add: real_mult_commute) | |
| 2074 | qed | |
| 2075 | ||
| 2076 | lemma bounded_scaling: | |
| 2077 | fixes S :: "'a::real_normed_vector set" | |
| 2078 | shows "bounded S \<Longrightarrow> bounded ((\<lambda>x. c *\<^sub>R x) ` S)" | |
| 2079 | apply (rule bounded_linear_image, assumption) | |
| 2080 | apply (rule scaleR.bounded_linear_right) | |
| 2081 | done | |
| 2082 | ||
| 2083 | lemma bounded_translation: | |
| 2084 | fixes S :: "'a::real_normed_vector set" | |
| 2085 | assumes "bounded S" shows "bounded ((\<lambda>x. a + x) ` S)" | |
| 2086 | proof- | |
| 2087 | from assms obtain b where b:"b>0" "\<forall>x\<in>S. norm x \<le> b" unfolding bounded_pos by auto | |
| 2088 |   { fix x assume "x\<in>S"
 | |
| 2089 | hence "norm (a + x) \<le> b + norm a" using norm_triangle_ineq[of a x] b by auto | |
| 2090 | } | |
| 2091 | thus ?thesis unfolding bounded_pos using norm_ge_zero[of a] b(1) using add_strict_increasing[of b 0 "norm a"] | |
| 2092 | by (auto intro!: add exI[of _ "b + norm a"]) | |
| 2093 | qed | |
| 2094 | ||
| 2095 | ||
| 2096 | text{* Some theorems on sups and infs using the notion "bounded". *}
 | |
| 2097 | ||
| 2098 | lemma bounded_real: | |
| 2099 | fixes S :: "real set" | |
| 2100 | shows "bounded S \<longleftrightarrow> (\<exists>a. \<forall>x\<in>S. abs x <= a)" | |
| 2101 | by (simp add: bounded_iff) | |
| 2102 | ||
| 33270 | 2103 | lemma bounded_has_Sup: | 
| 2104 | fixes S :: "real set" | |
| 2105 |   assumes "bounded S" "S \<noteq> {}"
 | |
| 2106 | shows "\<forall>x\<in>S. x <= Sup S" and "\<forall>b. (\<forall>x\<in>S. x <= b) \<longrightarrow> Sup S <= b" | |
| 2107 | proof | |
| 2108 | fix x assume "x\<in>S" | |
| 2109 | thus "x \<le> Sup S" | |
| 2110 | by (metis SupInf.Sup_upper abs_le_D1 assms(1) bounded_real) | |
| 2111 | next | |
| 2112 | show "\<forall>b. (\<forall>x\<in>S. x \<le> b) \<longrightarrow> Sup S \<le> b" using assms | |
| 2113 | by (metis SupInf.Sup_least) | |
| 2114 | qed | |
| 2115 | ||
| 2116 | lemma Sup_insert: | |
| 2117 | fixes S :: "real set" | |
| 2118 |   shows "bounded S ==> Sup(insert x S) = (if S = {} then x else max x (Sup S))" 
 | |
| 2119 | by auto (metis Int_absorb Sup_insert_nonempty assms bounded_has_Sup(1) disjoint_iff_not_equal) | |
| 2120 | ||
| 2121 | lemma Sup_insert_finite: | |
| 2122 | fixes S :: "real set" | |
| 2123 |   shows "finite S \<Longrightarrow> Sup(insert x S) = (if S = {} then x else max x (Sup S))"
 | |
| 2124 | apply (rule Sup_insert) | |
| 2125 | apply (rule finite_imp_bounded) | |
| 2126 | by simp | |
| 2127 | ||
| 2128 | lemma bounded_has_Inf: | |
| 2129 | fixes S :: "real set" | |
| 2130 |   assumes "bounded S"  "S \<noteq> {}"
 | |
| 2131 | shows "\<forall>x\<in>S. x >= Inf S" and "\<forall>b. (\<forall>x\<in>S. x >= b) \<longrightarrow> Inf S >= b" | |
| 33175 | 2132 | proof | 
| 2133 | fix x assume "x\<in>S" | |
| 2134 | from assms(1) obtain a where a:"\<forall>x\<in>S. \<bar>x\<bar> \<le> a" unfolding bounded_real by auto | |
| 33270 | 2135 | thus "x \<ge> Inf S" using `x\<in>S` | 
| 2136 | by (metis Inf_lower_EX abs_le_D2 minus_le_iff) | |
| 33175 | 2137 | next | 
| 33270 | 2138 | show "\<forall>b. (\<forall>x\<in>S. x >= b) \<longrightarrow> Inf S \<ge> b" using assms | 
| 2139 | by (metis SupInf.Inf_greatest) | |
| 2140 | qed | |
| 2141 | ||
| 2142 | lemma Inf_insert: | |
| 2143 | fixes S :: "real set" | |
| 2144 |   shows "bounded S ==> Inf(insert x S) = (if S = {} then x else min x (Inf S))" 
 | |
| 2145 | by auto (metis Int_absorb Inf_insert_nonempty bounded_has_Inf(1) disjoint_iff_not_equal) | |
| 2146 | lemma Inf_insert_finite: | |
| 2147 | fixes S :: "real set" | |
| 2148 |   shows "finite S ==> Inf(insert x S) = (if S = {} then x else min x (Inf S))"
 | |
| 2149 | by (rule Inf_insert, rule finite_imp_bounded, simp) | |
| 2150 | ||
| 33175 | 2151 | |
| 2152 | (* TODO: Move this to RComplete.thy -- would need to include Glb into RComplete *) | |
| 2153 | lemma real_isGlb_unique: "[| isGlb R S x; isGlb R S y |] ==> x = (y::real)" | |
| 2154 | apply (frule isGlb_isLb) | |
| 2155 | apply (frule_tac x = y in isGlb_isLb) | |
| 2156 | apply (blast intro!: order_antisym dest!: isGlb_le_isLb) | |
| 2157 | done | |
| 2158 | ||
| 2159 | subsection{* Compactness (the definition is the one based on convegent subsequences). *}
 | |
| 2160 | ||
| 2161 | definition | |
| 2162 | compact :: "'a::metric_space set \<Rightarrow> bool" where (* TODO: generalize *) | |
| 2163 | "compact S \<longleftrightarrow> | |
| 2164 | (\<forall>f. (\<forall>n. f n \<in> S) \<longrightarrow> | |
| 2165 | (\<exists>l\<in>S. \<exists>r. subseq r \<and> ((f o r) ---> l) sequentially))" | |
| 2166 | ||
| 2167 | text {*
 | |
| 2168 | A metric space (or topological vector space) is said to have the | |
| 2169 | Heine-Borel property if every closed and bounded subset is compact. | |
| 2170 | *} | |
| 2171 | ||
| 2172 | class heine_borel = | |
| 2173 | assumes bounded_imp_convergent_subsequence: | |
| 2174 | "bounded s \<Longrightarrow> \<forall>n. f n \<in> s | |
| 2175 | \<Longrightarrow> \<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" | |
| 2176 | ||
| 2177 | lemma bounded_closed_imp_compact: | |
| 2178 | fixes s::"'a::heine_borel set" | |
| 2179 | assumes "bounded s" and "closed s" shows "compact s" | |
| 2180 | proof (unfold compact_def, clarify) | |
| 2181 | fix f :: "nat \<Rightarrow> 'a" assume f: "\<forall>n. f n \<in> s" | |
| 2182 | obtain l r where r: "subseq r" and l: "((f \<circ> r) ---> l) sequentially" | |
| 2183 | using bounded_imp_convergent_subsequence [OF `bounded s` `\<forall>n. f n \<in> s`] by auto | |
| 2184 | from f have fr: "\<forall>n. (f \<circ> r) n \<in> s" by simp | |
| 2185 | have "l \<in> s" using `closed s` fr l | |
| 2186 | unfolding closed_sequential_limits by blast | |
| 2187 | show "\<exists>l\<in>s. \<exists>r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" | |
| 2188 | using `l \<in> s` r l by blast | |
| 2189 | qed | |
| 2190 | ||
| 2191 | lemma subseq_bigger: assumes "subseq r" shows "n \<le> r n" | |
| 2192 | proof(induct n) | |
| 2193 | show "0 \<le> r 0" by auto | |
| 2194 | next | |
| 2195 | fix n assume "n \<le> r n" | |
| 2196 | moreover have "r n < r (Suc n)" | |
| 2197 | using assms [unfolded subseq_def] by auto | |
| 2198 | ultimately show "Suc n \<le> r (Suc n)" by auto | |
| 2199 | qed | |
| 2200 | ||
| 2201 | lemma eventually_subseq: | |
| 2202 | assumes r: "subseq r" | |
| 2203 | shows "eventually P sequentially \<Longrightarrow> eventually (\<lambda>n. P (r n)) sequentially" | |
| 2204 | unfolding eventually_sequentially | |
| 2205 | by (metis subseq_bigger [OF r] le_trans) | |
| 2206 | ||
| 2207 | lemma lim_subseq: | |
| 2208 | "subseq r \<Longrightarrow> (s ---> l) sequentially \<Longrightarrow> ((s o r) ---> l) sequentially" | |
| 2209 | unfolding tendsto_def eventually_sequentially o_def | |
| 2210 | by (metis subseq_bigger le_trans) | |
| 2211 | ||
| 2212 | lemma num_Axiom: "EX! g. g 0 = e \<and> (\<forall>n. g (Suc n) = f n (g n))" | |
| 2213 | unfolding Ex1_def | |
| 2214 | apply (rule_tac x="nat_rec e f" in exI) | |
| 2215 | apply (rule conjI)+ | |
| 2216 | apply (rule def_nat_rec_0, simp) | |
| 2217 | apply (rule allI, rule def_nat_rec_Suc, simp) | |
| 2218 | apply (rule allI, rule impI, rule ext) | |
| 2219 | apply (erule conjE) | |
| 2220 | apply (induct_tac x) | |
| 2221 | apply (simp add: nat_rec_0) | |
| 2222 | apply (erule_tac x="n" in allE) | |
| 2223 | apply (simp) | |
| 2224 | done | |
| 2225 | ||
| 2226 | lemma convergent_bounded_increasing: fixes s ::"nat\<Rightarrow>real" | |
| 2227 | assumes "incseq s" and "\<forall>n. abs(s n) \<le> b" | |
| 2228 | shows "\<exists> l. \<forall>e::real>0. \<exists> N. \<forall>n \<ge> N. abs(s n - l) < e" | |
| 2229 | proof- | |
| 2230 | have "isUb UNIV (range s) b" using assms(2) and abs_le_D1 unfolding isUb_def and setle_def by auto | |
| 2231 | then obtain t where t:"isLub UNIV (range s) t" using reals_complete[of "range s" ] by auto | |
| 2232 |   { fix e::real assume "e>0" and as:"\<forall>N. \<exists>n\<ge>N. \<not> \<bar>s n - t\<bar> < e"
 | |
| 2233 |     { fix n::nat
 | |
| 2234 | obtain N where "N\<ge>n" and n:"\<bar>s N - t\<bar> \<ge> e" using as[THEN spec[where x=n]] by auto | |
| 2235 | have "t \<ge> s N" using isLub_isUb[OF t, unfolded isUb_def setle_def] by auto | |
| 2236 | with n have "s N \<le> t - e" using `e>0` by auto | |
| 2237 | hence "s n \<le> t - e" using assms(1)[unfolded incseq_def, THEN spec[where x=n], THEN spec[where x=N]] using `n\<le>N` by auto } | |
| 2238 | hence "isUb UNIV (range s) (t - e)" unfolding isUb_def and setle_def by auto | |
| 2239 | hence False using isLub_le_isUb[OF t, of "t - e"] and `e>0` by auto } | |
| 2240 | thus ?thesis by blast | |
| 2241 | qed | |
| 2242 | ||
| 2243 | lemma convergent_bounded_monotone: fixes s::"nat \<Rightarrow> real" | |
| 2244 | assumes "\<forall>n. abs(s n) \<le> b" and "monoseq s" | |
| 2245 | shows "\<exists>l. \<forall>e::real>0. \<exists>N. \<forall>n\<ge>N. abs(s n - l) < e" | |
| 2246 | using convergent_bounded_increasing[of s b] assms using convergent_bounded_increasing[of "\<lambda>n. - s n" b] | |
| 2247 | unfolding monoseq_def incseq_def | |
| 2248 | apply auto unfolding minus_add_distrib[THEN sym, unfolded diff_minus[THEN sym]] | |
| 2249 | unfolding abs_minus_cancel by(rule_tac x="-l" in exI)auto | |
| 2250 | ||
| 2251 | lemma compact_real_lemma: | |
| 2252 | assumes "\<forall>n::nat. abs(s n) \<le> b" | |
| 2253 | shows "\<exists>(l::real) r. subseq r \<and> ((s \<circ> r) ---> l) sequentially" | |
| 2254 | proof- | |
| 2255 | obtain r where r:"subseq r" "monoseq (\<lambda>n. s (r n))" | |
| 2256 | using seq_monosub[of s] by auto | |
| 2257 | thus ?thesis using convergent_bounded_monotone[of "\<lambda>n. s (r n)" b] and assms | |
| 2258 | unfolding tendsto_iff dist_norm eventually_sequentially by auto | |
| 2259 | qed | |
| 2260 | ||
| 2261 | instance real :: heine_borel | |
| 2262 | proof | |
| 2263 | fix s :: "real set" and f :: "nat \<Rightarrow> real" | |
| 2264 | assume s: "bounded s" and f: "\<forall>n. f n \<in> s" | |
| 2265 | then obtain b where b: "\<forall>n. abs (f n) \<le> b" | |
| 2266 | unfolding bounded_iff by auto | |
| 2267 | obtain l :: real and r :: "nat \<Rightarrow> nat" where | |
| 2268 | r: "subseq r" and l: "((f \<circ> r) ---> l) sequentially" | |
| 2269 | using compact_real_lemma [OF b] by auto | |
| 2270 | thus "\<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" | |
| 2271 | by auto | |
| 2272 | qed | |
| 2273 | ||
| 2274 | lemma bounded_component: "bounded s \<Longrightarrow> bounded ((\<lambda>x. x $ i) ` s)" | |
| 2275 | unfolding bounded_def | |
| 2276 | apply clarify | |
| 2277 | apply (rule_tac x="x $ i" in exI) | |
| 2278 | apply (rule_tac x="e" in exI) | |
| 2279 | apply clarify | |
| 2280 | apply (rule order_trans [OF dist_nth_le], simp) | |
| 2281 | done | |
| 2282 | ||
| 2283 | lemma compact_lemma: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 2284 | fixes f :: "nat \<Rightarrow> 'a::heine_borel ^ 'n" | 
| 33175 | 2285 | assumes "bounded s" and "\<forall>n. f n \<in> s" | 
| 2286 | shows "\<forall>d. | |
| 2287 | \<exists>l r. subseq r \<and> | |
| 2288 | (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) $ i) (l $ i) < e) sequentially)" | |
| 2289 | proof | |
| 2290 | fix d::"'n set" have "finite d" by simp | |
| 2291 | thus "\<exists>l::'a ^ 'n. \<exists>r. subseq r \<and> | |
| 2292 | (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) $ i) (l $ i) < e) sequentially)" | |
| 2293 | proof(induct d) case empty thus ?case unfolding subseq_def by auto | |
| 2294 | next case (insert k d) | |
| 2295 | have s': "bounded ((\<lambda>x. x $ k) ` s)" using `bounded s` by (rule bounded_component) | |
| 2296 | obtain l1::"'a^'n" and r1 where r1:"subseq r1" and lr1:"\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r1 n) $ i) (l1 $ i) < e) sequentially" | |
| 2297 | using insert(3) by auto | |
| 2298 | have f': "\<forall>n. f (r1 n) $ k \<in> (\<lambda>x. x $ k) ` s" using `\<forall>n. f n \<in> s` by simp | |
| 2299 | obtain l2 r2 where r2:"subseq r2" and lr2:"((\<lambda>i. f (r1 (r2 i)) $ k) ---> l2) sequentially" | |
| 2300 | using bounded_imp_convergent_subsequence[OF s' f'] unfolding o_def by auto | |
| 2301 | def r \<equiv> "r1 \<circ> r2" have r:"subseq r" | |
| 2302 | using r1 and r2 unfolding r_def o_def subseq_def by auto | |
| 2303 | moreover | |
| 2304 | def l \<equiv> "(\<chi> i. if i = k then l2 else l1$i)::'a^'n" | |
| 2305 |     { fix e::real assume "e>0"
 | |
| 2306 | from lr1 `e>0` have N1:"eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r1 n) $ i) (l1 $ i) < e) sequentially" by blast | |
| 2307 | from lr2 `e>0` have N2:"eventually (\<lambda>n. dist (f (r1 (r2 n)) $ k) l2 < e) sequentially" by (rule tendstoD) | |
| 2308 | from r2 N1 have N1': "eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r1 (r2 n)) $ i) (l1 $ i) < e) sequentially" | |
| 2309 | by (rule eventually_subseq) | |
| 2310 | have "eventually (\<lambda>n. \<forall>i\<in>(insert k d). dist (f (r n) $ i) (l $ i) < e) sequentially" | |
| 2311 | using N1' N2 by (rule eventually_elim2, simp add: l_def r_def) | |
| 2312 | } | |
| 2313 | ultimately show ?case by auto | |
| 2314 | qed | |
| 2315 | qed | |
| 2316 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 2317 | instance cart :: (heine_borel, finite) heine_borel | 
| 33175 | 2318 | proof | 
| 2319 |   fix s :: "('a ^ 'b) set" and f :: "nat \<Rightarrow> 'a ^ 'b"
 | |
| 2320 | assume s: "bounded s" and f: "\<forall>n. f n \<in> s" | |
| 2321 | then obtain l r where r: "subseq r" | |
| 2322 | and l: "\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>UNIV. dist (f (r n) $ i) (l $ i) < e) sequentially" | |
| 2323 | using compact_lemma [OF s f] by blast | |
| 2324 | let ?d = "UNIV::'b set" | |
| 2325 |   { fix e::real assume "e>0"
 | |
| 2326 | hence "0 < e / (real_of_nat (card ?d))" | |
| 2327 | using zero_less_card_finite using divide_pos_pos[of e, of "real_of_nat (card ?d)"] by auto | |
| 2328 | with l have "eventually (\<lambda>n. \<forall>i. dist (f (r n) $ i) (l $ i) < e / (real_of_nat (card ?d))) sequentially" | |
| 2329 | by simp | |
| 2330 | moreover | |
| 2331 |     { fix n assume n: "\<forall>i. dist (f (r n) $ i) (l $ i) < e / (real_of_nat (card ?d))"
 | |
| 2332 | have "dist (f (r n)) l \<le> (\<Sum>i\<in>?d. dist (f (r n) $ i) (l $ i))" | |
| 2333 | unfolding dist_vector_def using zero_le_dist by (rule setL2_le_setsum) | |
| 2334 | also have "\<dots> < (\<Sum>i\<in>?d. e / (real_of_nat (card ?d)))" | |
| 2335 | by (rule setsum_strict_mono) (simp_all add: n) | |
| 2336 | finally have "dist (f (r n)) l < e" by simp | |
| 2337 | } | |
| 2338 | ultimately have "eventually (\<lambda>n. dist (f (r n)) l < e) sequentially" | |
| 2339 | by (rule eventually_elim1) | |
| 2340 | } | |
| 2341 | hence *:"((f \<circ> r) ---> l) sequentially" unfolding o_def tendsto_iff by simp | |
| 2342 | with r show "\<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" by auto | |
| 2343 | qed | |
| 2344 | ||
| 2345 | lemma bounded_fst: "bounded s \<Longrightarrow> bounded (fst ` s)" | |
| 2346 | unfolding bounded_def | |
| 2347 | apply clarify | |
| 2348 | apply (rule_tac x="a" in exI) | |
| 2349 | apply (rule_tac x="e" in exI) | |
| 2350 | apply clarsimp | |
| 2351 | apply (drule (1) bspec) | |
| 2352 | apply (simp add: dist_Pair_Pair) | |
| 2353 | apply (erule order_trans [OF real_sqrt_sum_squares_ge1]) | |
| 2354 | done | |
| 2355 | ||
| 2356 | lemma bounded_snd: "bounded s \<Longrightarrow> bounded (snd ` s)" | |
| 2357 | unfolding bounded_def | |
| 2358 | apply clarify | |
| 2359 | apply (rule_tac x="b" in exI) | |
| 2360 | apply (rule_tac x="e" in exI) | |
| 2361 | apply clarsimp | |
| 2362 | apply (drule (1) bspec) | |
| 2363 | apply (simp add: dist_Pair_Pair) | |
| 2364 | apply (erule order_trans [OF real_sqrt_sum_squares_ge2]) | |
| 2365 | done | |
| 2366 | ||
| 2367 | instance "*" :: (heine_borel, heine_borel) heine_borel | |
| 2368 | proof | |
| 2369 |   fix s :: "('a * 'b) set" and f :: "nat \<Rightarrow> 'a * 'b"
 | |
| 2370 | assume s: "bounded s" and f: "\<forall>n. f n \<in> s" | |
| 2371 | from s have s1: "bounded (fst ` s)" by (rule bounded_fst) | |
| 2372 | from f have f1: "\<forall>n. fst (f n) \<in> fst ` s" by simp | |
| 2373 | obtain l1 r1 where r1: "subseq r1" | |
| 2374 | and l1: "((\<lambda>n. fst (f (r1 n))) ---> l1) sequentially" | |
| 2375 | using bounded_imp_convergent_subsequence [OF s1 f1] | |
| 2376 | unfolding o_def by fast | |
| 2377 | from s have s2: "bounded (snd ` s)" by (rule bounded_snd) | |
| 2378 | from f have f2: "\<forall>n. snd (f (r1 n)) \<in> snd ` s" by simp | |
| 2379 | obtain l2 r2 where r2: "subseq r2" | |
| 2380 | and l2: "((\<lambda>n. snd (f (r1 (r2 n)))) ---> l2) sequentially" | |
| 2381 | using bounded_imp_convergent_subsequence [OF s2 f2] | |
| 2382 | unfolding o_def by fast | |
| 2383 | have l1': "((\<lambda>n. fst (f (r1 (r2 n)))) ---> l1) sequentially" | |
| 2384 | using lim_subseq [OF r2 l1] unfolding o_def . | |
| 2385 | have l: "((f \<circ> (r1 \<circ> r2)) ---> (l1, l2)) sequentially" | |
| 2386 | using tendsto_Pair [OF l1' l2] unfolding o_def by simp | |
| 2387 | have r: "subseq (r1 \<circ> r2)" | |
| 2388 | using r1 r2 unfolding subseq_def by simp | |
| 2389 | show "\<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" | |
| 2390 | using l r by fast | |
| 2391 | qed | |
| 2392 | ||
| 2393 | subsection{* Completeness. *}
 | |
| 2394 | ||
| 2395 | lemma cauchy_def: | |
| 2396 | "Cauchy s \<longleftrightarrow> (\<forall>e>0. \<exists>N. \<forall>m n. m \<ge> N \<and> n \<ge> N --> dist(s m)(s n) < e)" | |
| 2397 | unfolding Cauchy_def by blast | |
| 2398 | ||
| 2399 | definition | |
| 2400 | complete :: "'a::metric_space set \<Rightarrow> bool" where | |
| 2401 | "complete s \<longleftrightarrow> (\<forall>f. (\<forall>n. f n \<in> s) \<and> Cauchy f | |
| 2402 | --> (\<exists>l \<in> s. (f ---> l) sequentially))" | |
| 2403 | ||
| 2404 | lemma cauchy: "Cauchy s \<longleftrightarrow> (\<forall>e>0.\<exists> N::nat. \<forall>n\<ge>N. dist(s n)(s N) < e)" (is "?lhs = ?rhs") | |
| 2405 | proof- | |
| 2406 |   { assume ?rhs
 | |
| 2407 |     { fix e::real
 | |
| 2408 | assume "e>0" | |
| 2409 | with `?rhs` obtain N where N:"\<forall>n\<ge>N. dist (s n) (s N) < e/2" | |
| 2410 | by (erule_tac x="e/2" in allE) auto | |
| 2411 |       { fix n m
 | |
| 2412 | assume nm:"N \<le> m \<and> N \<le> n" | |
| 2413 | hence "dist (s m) (s n) < e" using N | |
| 2414 | using dist_triangle_half_l[of "s m" "s N" "e" "s n"] | |
| 2415 | by blast | |
| 2416 | } | |
| 2417 | hence "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (s m) (s n) < e" | |
| 2418 | by blast | |
| 2419 | } | |
| 2420 | hence ?lhs | |
| 2421 | unfolding cauchy_def | |
| 2422 | by blast | |
| 2423 | } | |
| 2424 | thus ?thesis | |
| 2425 | unfolding cauchy_def | |
| 2426 | using dist_triangle_half_l | |
| 2427 | by blast | |
| 2428 | qed | |
| 2429 | ||
| 2430 | lemma convergent_imp_cauchy: | |
| 2431 | "(s ---> l) sequentially ==> Cauchy s" | |
| 2432 | proof(simp only: cauchy_def, rule, rule) | |
| 2433 | fix e::real assume "e>0" "(s ---> l) sequentially" | |
| 2434 | then obtain N::nat where N:"\<forall>n\<ge>N. dist (s n) l < e/2" unfolding Lim_sequentially by(erule_tac x="e/2" in allE) auto | |
| 2435 | thus "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (s m) (s n) < e" using dist_triangle_half_l[of _ l e _] by (rule_tac x=N in exI) auto | |
| 2436 | qed | |
| 2437 | ||
| 34104 | 2438 | lemma cauchy_imp_bounded: assumes "Cauchy s" shows "bounded (range s)" | 
| 33175 | 2439 | proof- | 
| 2440 | from assms obtain N::nat where "\<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (s m) (s n) < 1" unfolding cauchy_def apply(erule_tac x= 1 in allE) by auto | |
| 2441 | hence N:"\<forall>n. N \<le> n \<longrightarrow> dist (s N) (s n) < 1" by auto | |
| 2442 | moreover | |
| 2443 |   have "bounded (s ` {0..N})" using finite_imp_bounded[of "s ` {1..N}"] by auto
 | |
| 2444 |   then obtain a where a:"\<forall>x\<in>s ` {0..N}. dist (s N) x \<le> a"
 | |
| 2445 | unfolding bounded_any_center [where a="s N"] by auto | |
| 2446 | ultimately show "?thesis" | |
| 2447 | unfolding bounded_any_center [where a="s N"] | |
| 2448 | apply(rule_tac x="max a 1" in exI) apply auto | |
| 34104 | 2449 | apply(erule_tac x=y in allE) apply(erule_tac x=y in ballE) by auto | 
| 33175 | 2450 | qed | 
| 2451 | ||
| 2452 | lemma compact_imp_complete: assumes "compact s" shows "complete s" | |
| 2453 | proof- | |
| 2454 |   { fix f assume as: "(\<forall>n::nat. f n \<in> s)" "Cauchy f"
 | |
| 2455 | from as(1) obtain l r where lr: "l\<in>s" "subseq r" "((f \<circ> r) ---> l) sequentially" using assms unfolding compact_def by blast | |
| 2456 | ||
| 2457 | note lr' = subseq_bigger [OF lr(2)] | |
| 2458 | ||
| 2459 |     { fix e::real assume "e>0"
 | |
| 2460 | from as(2) obtain N where N:"\<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (f m) (f n) < e/2" unfolding cauchy_def using `e>0` apply (erule_tac x="e/2" in allE) by auto | |
| 2461 | from lr(3)[unfolded Lim_sequentially, THEN spec[where x="e/2"]] obtain M where M:"\<forall>n\<ge>M. dist ((f \<circ> r) n) l < e/2" using `e>0` by auto | |
| 2462 |       { fix n::nat assume n:"n \<ge> max N M"
 | |
| 2463 | have "dist ((f \<circ> r) n) l < e/2" using n M by auto | |
| 2464 | moreover have "r n \<ge> N" using lr'[of n] n by auto | |
| 2465 | hence "dist (f n) ((f \<circ> r) n) < e / 2" using N using n by auto | |
| 2466 | ultimately have "dist (f n) l < e" using dist_triangle_half_r[of "f (r n)" "f n" e l] by (auto simp add: dist_commute) } | |
| 2467 | hence "\<exists>N. \<forall>n\<ge>N. dist (f n) l < e" by blast } | |
| 2468 | hence "\<exists>l\<in>s. (f ---> l) sequentially" using `l\<in>s` unfolding Lim_sequentially by auto } | |
| 2469 | thus ?thesis unfolding complete_def by auto | |
| 2470 | qed | |
| 2471 | ||
| 2472 | instance heine_borel < complete_space | |
| 2473 | proof | |
| 2474 | fix f :: "nat \<Rightarrow> 'a" assume "Cauchy f" | |
| 34104 | 2475 | hence "bounded (range f)" | 
| 2476 | by (rule cauchy_imp_bounded) | |
| 33175 | 2477 | hence "compact (closure (range f))" | 
| 2478 | using bounded_closed_imp_compact [of "closure (range f)"] by auto | |
| 2479 | hence "complete (closure (range f))" | |
| 34104 | 2480 | by (rule compact_imp_complete) | 
| 33175 | 2481 | moreover have "\<forall>n. f n \<in> closure (range f)" | 
| 2482 | using closure_subset [of "range f"] by auto | |
| 2483 | ultimately have "\<exists>l\<in>closure (range f). (f ---> l) sequentially" | |
| 2484 | using `Cauchy f` unfolding complete_def by auto | |
| 2485 | then show "convergent f" | |
| 2486 | unfolding convergent_def LIMSEQ_conv_tendsto [symmetric] by auto | |
| 2487 | qed | |
| 2488 | ||
| 2489 | lemma complete_univ: "complete (UNIV :: 'a::complete_space set)" | |
| 2490 | proof(simp add: complete_def, rule, rule) | |
| 2491 | fix f :: "nat \<Rightarrow> 'a" assume "Cauchy f" | |
| 2492 | hence "convergent f" by (rule Cauchy_convergent) | |
| 2493 | hence "\<exists>l. f ----> l" unfolding convergent_def . | |
| 2494 | thus "\<exists>l. (f ---> l) sequentially" unfolding LIMSEQ_conv_tendsto . | |
| 2495 | qed | |
| 2496 | ||
| 2497 | lemma complete_imp_closed: assumes "complete s" shows "closed s" | |
| 2498 | proof - | |
| 2499 |   { fix x assume "x islimpt s"
 | |
| 2500 |     then obtain f where f: "\<forall>n. f n \<in> s - {x}" "(f ---> x) sequentially"
 | |
| 2501 | unfolding islimpt_sequential by auto | |
| 2502 | then obtain l where l: "l\<in>s" "(f ---> l) sequentially" | |
| 2503 | using `complete s`[unfolded complete_def] using convergent_imp_cauchy[of f x] by auto | |
| 2504 | hence "x \<in> s" using Lim_unique[of sequentially f l x] trivial_limit_sequentially f(2) by auto | |
| 2505 | } | |
| 2506 | thus "closed s" unfolding closed_limpt by auto | |
| 2507 | qed | |
| 2508 | ||
| 2509 | lemma complete_eq_closed: | |
| 2510 | fixes s :: "'a::complete_space set" | |
| 2511 | shows "complete s \<longleftrightarrow> closed s" (is "?lhs = ?rhs") | |
| 2512 | proof | |
| 2513 | assume ?lhs thus ?rhs by (rule complete_imp_closed) | |
| 2514 | next | |
| 2515 | assume ?rhs | |
| 2516 |   { fix f assume as:"\<forall>n::nat. f n \<in> s" "Cauchy f"
 | |
| 2517 | then obtain l where "(f ---> l) sequentially" using complete_univ[unfolded complete_def, THEN spec[where x=f]] by auto | |
| 2518 | hence "\<exists>l\<in>s. (f ---> l) sequentially" using `?rhs`[unfolded closed_sequential_limits, THEN spec[where x=f], THEN spec[where x=l]] using as(1) by auto } | |
| 2519 | thus ?lhs unfolding complete_def by auto | |
| 2520 | qed | |
| 2521 | ||
| 2522 | lemma convergent_eq_cauchy: | |
| 2523 | fixes s :: "nat \<Rightarrow> 'a::complete_space" | |
| 2524 | shows "(\<exists>l. (s ---> l) sequentially) \<longleftrightarrow> Cauchy s" (is "?lhs = ?rhs") | |
| 2525 | proof | |
| 2526 | assume ?lhs then obtain l where "(s ---> l) sequentially" by auto | |
| 2527 | thus ?rhs using convergent_imp_cauchy by auto | |
| 2528 | next | |
| 2529 | assume ?rhs thus ?lhs using complete_univ[unfolded complete_def, THEN spec[where x=s]] by auto | |
| 2530 | qed | |
| 2531 | ||
| 2532 | lemma convergent_imp_bounded: | |
| 2533 | fixes s :: "nat \<Rightarrow> 'a::metric_space" | |
| 2534 | shows "(s ---> l) sequentially ==> bounded (s ` (UNIV::(nat set)))" | |
| 2535 | using convergent_imp_cauchy[of s] | |
| 2536 | using cauchy_imp_bounded[of s] | |
| 2537 | unfolding image_def | |
| 2538 | by auto | |
| 2539 | ||
| 2540 | subsection{* Total boundedness. *}
 | |
| 2541 | ||
| 2542 | fun helper_1::"('a::metric_space set) \<Rightarrow> real \<Rightarrow> nat \<Rightarrow> 'a" where
 | |
| 2543 | "helper_1 s e n = (SOME y::'a. y \<in> s \<and> (\<forall>m<n. \<not> (dist (helper_1 s e m) y < e)))" | |
| 2544 | declare helper_1.simps[simp del] | |
| 2545 | ||
| 2546 | lemma compact_imp_totally_bounded: | |
| 2547 | assumes "compact s" | |
| 2548 | shows "\<forall>e>0. \<exists>k. finite k \<and> k \<subseteq> s \<and> s \<subseteq> (\<Union>((\<lambda>x. ball x e) ` k))" | |
| 2549 | proof(rule, rule, rule ccontr) | |
| 2550 | fix e::real assume "e>0" and assm:"\<not> (\<exists>k. finite k \<and> k \<subseteq> s \<and> s \<subseteq> \<Union>(\<lambda>x. ball x e) ` k)" | |
| 2551 | def x \<equiv> "helper_1 s e" | |
| 2552 |   { fix n
 | |
| 2553 | have "x n \<in> s \<and> (\<forall>m<n. \<not> dist (x m) (x n) < e)" | |
| 2554 | proof(induct_tac rule:nat_less_induct) | |
| 2555 | fix n def Q \<equiv> "(\<lambda>y. y \<in> s \<and> (\<forall>m<n. \<not> dist (x m) y < e))" | |
| 2556 | assume as:"\<forall>m<n. x m \<in> s \<and> (\<forall>ma<m. \<not> dist (x ma) (x m) < e)" | |
| 2557 |       have "\<not> s \<subseteq> (\<Union>x\<in>x ` {0..<n}. ball x e)" using assm apply simp apply(erule_tac x="x ` {0 ..< n}" in allE) using as by auto
 | |
| 2558 |       then obtain z where z:"z\<in>s" "z \<notin> (\<Union>x\<in>x ` {0..<n}. ball x e)" unfolding subset_eq by auto
 | |
| 2559 | have "Q (x n)" unfolding x_def and helper_1.simps[of s e n] | |
| 2560 | apply(rule someI2[where a=z]) unfolding x_def[symmetric] and Q_def using z by auto | |
| 2561 | thus "x n \<in> s \<and> (\<forall>m<n. \<not> dist (x m) (x n) < e)" unfolding Q_def by auto | |
| 2562 | qed } | |
| 2563 | hence "\<forall>n::nat. x n \<in> s" and x:"\<forall>n. \<forall>m < n. \<not> (dist (x m) (x n) < e)" by blast+ | |
| 2564 | then obtain l r where "l\<in>s" and r:"subseq r" and "((x \<circ> r) ---> l) sequentially" using assms(1)[unfolded compact_def, THEN spec[where x=x]] by auto | |
| 2565 | from this(3) have "Cauchy (x \<circ> r)" using convergent_imp_cauchy by auto | |
| 2566 | then obtain N::nat where N:"\<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist ((x \<circ> r) m) ((x \<circ> r) n) < e" unfolding cauchy_def using `e>0` by auto | |
| 2567 | show False | |
| 2568 | using N[THEN spec[where x=N], THEN spec[where x="N+1"]] | |
| 2569 | using r[unfolded subseq_def, THEN spec[where x=N], THEN spec[where x="N+1"]] | |
| 2570 | using x[THEN spec[where x="r (N+1)"], THEN spec[where x="r (N)"]] by auto | |
| 2571 | qed | |
| 2572 | ||
| 2573 | subsection{* Heine-Borel theorem (following Burkill \& Burkill vol. 2) *}
 | |
| 2574 | ||
| 2575 | lemma heine_borel_lemma: fixes s::"'a::metric_space set" | |
| 2576 | assumes "compact s" "s \<subseteq> (\<Union> t)" "\<forall>b \<in> t. open b" | |
| 2577 | shows "\<exists>e>0. \<forall>x \<in> s. \<exists>b \<in> t. ball x e \<subseteq> b" | |
| 2578 | proof(rule ccontr) | |
| 2579 | assume "\<not> (\<exists>e>0. \<forall>x\<in>s. \<exists>b\<in>t. ball x e \<subseteq> b)" | |
| 2580 | hence cont:"\<forall>e>0. \<exists>x\<in>s. \<forall>xa\<in>t. \<not> (ball x e \<subseteq> xa)" by auto | |
| 2581 |   { fix n::nat
 | |
| 2582 | have "1 / real (n + 1) > 0" by auto | |
| 2583 | hence "\<exists>x. x\<in>s \<and> (\<forall>xa\<in>t. \<not> (ball x (inverse (real (n+1))) \<subseteq> xa))" using cont unfolding Bex_def by auto } | |
| 2584 | hence "\<forall>n::nat. \<exists>x. x \<in> s \<and> (\<forall>xa\<in>t. \<not> ball x (inverse (real (n + 1))) \<subseteq> xa)" by auto | |
| 2585 | then obtain f where f:"\<forall>n::nat. f n \<in> s \<and> (\<forall>xa\<in>t. \<not> ball (f n) (inverse (real (n + 1))) \<subseteq> xa)" | |
| 2586 | using choice[of "\<lambda>n::nat. \<lambda>x. x\<in>s \<and> (\<forall>xa\<in>t. \<not> ball x (inverse (real (n + 1))) \<subseteq> xa)"] by auto | |
| 2587 | ||
| 2588 | then obtain l r where l:"l\<in>s" and r:"subseq r" and lr:"((f \<circ> r) ---> l) sequentially" | |
| 2589 | using assms(1)[unfolded compact_def, THEN spec[where x=f]] by auto | |
| 2590 | ||
| 2591 | obtain b where "l\<in>b" "b\<in>t" using assms(2) and l by auto | |
| 2592 | then obtain e where "e>0" and e:"\<forall>z. dist z l < e \<longrightarrow> z\<in>b" | |
| 2593 | using assms(3)[THEN bspec[where x=b]] unfolding open_dist by auto | |
| 2594 | ||
| 2595 | then obtain N1 where N1:"\<forall>n\<ge>N1. dist ((f \<circ> r) n) l < e / 2" | |
| 2596 | using lr[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto | |
| 2597 | ||
| 2598 | obtain N2::nat where N2:"N2>0" "inverse (real N2) < e /2" using real_arch_inv[of "e/2"] and `e>0` by auto | |
| 2599 | have N2':"inverse (real (r (N1 + N2) +1 )) < e/2" | |
| 2600 | apply(rule order_less_trans) apply(rule less_imp_inverse_less) using N2 | |
| 2601 | using subseq_bigger[OF r, of "N1 + N2"] by auto | |
| 2602 | ||
| 2603 | def x \<equiv> "(f (r (N1 + N2)))" | |
| 2604 | have x:"\<not> ball x (inverse (real (r (N1 + N2) + 1))) \<subseteq> b" unfolding x_def | |
| 2605 | using f[THEN spec[where x="r (N1 + N2)"]] using `b\<in>t` by auto | |
| 2606 | have "\<exists>y\<in>ball x (inverse (real (r (N1 + N2) + 1))). y\<notin>b" apply(rule ccontr) using x by auto | |
| 2607 | then obtain y where y:"y \<in> ball x (inverse (real (r (N1 + N2) + 1)))" "y \<notin> b" by auto | |
| 2608 | ||
| 2609 | have "dist x l < e/2" using N1 unfolding x_def o_def by auto | |
| 2610 | hence "dist y l < e" using y N2' using dist_triangle[of y l x]by (auto simp add:dist_commute) | |
| 2611 | ||
| 2612 | thus False using e and `y\<notin>b` by auto | |
| 2613 | qed | |
| 2614 | ||
| 2615 | lemma compact_imp_heine_borel: "compact s ==> (\<forall>f. (\<forall>t \<in> f. open t) \<and> s \<subseteq> (\<Union> f) | |
| 2616 | \<longrightarrow> (\<exists>f'. f' \<subseteq> f \<and> finite f' \<and> s \<subseteq> (\<Union> f')))" | |
| 2617 | proof clarify | |
| 2618 | fix f assume "compact s" " \<forall>t\<in>f. open t" "s \<subseteq> \<Union>f" | |
| 2619 | then obtain e::real where "e>0" and "\<forall>x\<in>s. \<exists>b\<in>f. ball x e \<subseteq> b" using heine_borel_lemma[of s f] by auto | |
| 2620 | hence "\<forall>x\<in>s. \<exists>b. b\<in>f \<and> ball x e \<subseteq> b" by auto | |
| 2621 | hence "\<exists>bb. \<forall>x\<in>s. bb x \<in>f \<and> ball x e \<subseteq> bb x" using bchoice[of s "\<lambda>x b. b\<in>f \<and> ball x e \<subseteq> b"] by auto | |
| 2622 | then obtain bb where bb:"\<forall>x\<in>s. (bb x) \<in> f \<and> ball x e \<subseteq> (bb x)" by blast | |
| 2623 | ||
| 2624 | from `compact s` have "\<exists> k. finite k \<and> k \<subseteq> s \<and> s \<subseteq> \<Union>(\<lambda>x. ball x e) ` k" using compact_imp_totally_bounded[of s] `e>0` by auto | |
| 2625 | then obtain k where k:"finite k" "k \<subseteq> s" "s \<subseteq> \<Union>(\<lambda>x. ball x e) ` k" by auto | |
| 2626 | ||
| 2627 | have "finite (bb ` k)" using k(1) by auto | |
| 2628 | moreover | |
| 2629 |   { fix x assume "x\<in>s"
 | |
| 2630 | hence "x\<in>\<Union>(\<lambda>x. ball x e) ` k" using k(3) unfolding subset_eq by auto | |
| 2631 | hence "\<exists>X\<in>bb ` k. x \<in> X" using bb k(2) by blast | |
| 2632 | hence "x \<in> \<Union>(bb ` k)" using Union_iff[of x "bb ` k"] by auto | |
| 2633 | } | |
| 2634 | ultimately show "\<exists>f'\<subseteq>f. finite f' \<and> s \<subseteq> \<Union>f'" using bb k(2) by (rule_tac x="bb ` k" in exI) auto | |
| 2635 | qed | |
| 2636 | ||
| 2637 | subsection{* Bolzano-Weierstrass property. *}
 | |
| 2638 | ||
| 2639 | lemma heine_borel_imp_bolzano_weierstrass: | |
| 2640 | assumes "\<forall>f. (\<forall>t \<in> f. open t) \<and> s \<subseteq> (\<Union> f) --> (\<exists>f'. f' \<subseteq> f \<and> finite f' \<and> s \<subseteq> (\<Union> f'))" | |
| 2641 | "infinite t" "t \<subseteq> s" | |
| 2642 | shows "\<exists>x \<in> s. x islimpt t" | |
| 2643 | proof(rule ccontr) | |
| 2644 | assume "\<not> (\<exists>x \<in> s. x islimpt t)" | |
| 2645 | then obtain f where f:"\<forall>x\<in>s. x \<in> f x \<and> open (f x) \<and> (\<forall>y\<in>t. y \<in> f x \<longrightarrow> y = x)" unfolding islimpt_def | |
| 2646 | using bchoice[of s "\<lambda> x T. x \<in> T \<and> open T \<and> (\<forall>y\<in>t. y \<in> T \<longrightarrow> y = x)"] by auto | |
| 2647 |   obtain g where g:"g\<subseteq>{t. \<exists>x. x \<in> s \<and> t = f x}" "finite g" "s \<subseteq> \<Union>g"
 | |
| 2648 |     using assms(1)[THEN spec[where x="{t. \<exists>x. x\<in>s \<and> t = f x}"]] using f by auto
 | |
| 2649 | from g(1,3) have g':"\<forall>x\<in>g. \<exists>xa \<in> s. x = f xa" by auto | |
| 2650 |   { fix x y assume "x\<in>t" "y\<in>t" "f x = f y"
 | |
| 2651 | hence "x \<in> f x" "y \<in> f x \<longrightarrow> y = x" using f[THEN bspec[where x=x]] and `t\<subseteq>s` by auto | |
| 2652 | hence "x = y" using `f x = f y` and f[THEN bspec[where x=y]] and `y\<in>t` and `t\<subseteq>s` by auto } | |
| 2653 | hence "infinite (f ` t)" using assms(2) using finite_imageD[unfolded inj_on_def, of f t] by auto | |
| 2654 | moreover | |
| 2655 |   { fix x assume "x\<in>t" "f x \<notin> g"
 | |
| 2656 | from g(3) assms(3) `x\<in>t` obtain h where "h\<in>g" and "x\<in>h" by auto | |
| 2657 | then obtain y where "y\<in>s" "h = f y" using g'[THEN bspec[where x=h]] by auto | |
| 2658 | hence "y = x" using f[THEN bspec[where x=y]] and `x\<in>t` and `x\<in>h`[unfolded `h = f y`] by auto | |
| 2659 | hence False using `f x \<notin> g` `h\<in>g` unfolding `h = f y` by auto } | |
| 2660 | hence "f ` t \<subseteq> g" by auto | |
| 2661 | ultimately show False using g(2) using finite_subset by auto | |
| 2662 | qed | |
| 2663 | ||
| 2664 | subsection{* Complete the chain of compactness variants. *}
 | |
| 2665 | ||
| 2666 | primrec helper_2::"(real \<Rightarrow> 'a::metric_space) \<Rightarrow> nat \<Rightarrow> 'a" where | |
| 2667 | "helper_2 beyond 0 = beyond 0" | | |
| 2668 | "helper_2 beyond (Suc n) = beyond (dist undefined (helper_2 beyond n) + 1 )" | |
| 2669 | ||
| 2670 | lemma bolzano_weierstrass_imp_bounded: fixes s::"'a::metric_space set" | |
| 2671 | assumes "\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t)" | |
| 2672 | shows "bounded s" | |
| 2673 | proof(rule ccontr) | |
| 2674 | assume "\<not> bounded s" | |
| 2675 | then obtain beyond where "\<forall>a. beyond a \<in>s \<and> \<not> dist undefined (beyond a) \<le> a" | |
| 2676 | unfolding bounded_any_center [where a=undefined] | |
| 2677 | apply simp using choice[of "\<lambda>a x. x\<in>s \<and> \<not> dist undefined x \<le> a"] by auto | |
| 2678 | hence beyond:"\<And>a. beyond a \<in>s" "\<And>a. dist undefined (beyond a) > a" | |
| 2679 | unfolding linorder_not_le by auto | |
| 2680 | def x \<equiv> "helper_2 beyond" | |
| 2681 | ||
| 2682 |   { fix m n ::nat assume "m<n"
 | |
| 2683 | hence "dist undefined (x m) + 1 < dist undefined (x n)" | |
| 2684 | proof(induct n) | |
| 2685 | case 0 thus ?case by auto | |
| 2686 | next | |
| 2687 | case (Suc n) | |
| 2688 | have *:"dist undefined (x n) + 1 < dist undefined (x (Suc n))" | |
| 2689 | unfolding x_def and helper_2.simps | |
| 2690 | using beyond(2)[of "dist undefined (helper_2 beyond n) + 1"] by auto | |
| 2691 | thus ?case proof(cases "m < n") | |
| 2692 | case True thus ?thesis using Suc and * by auto | |
| 2693 | next | |
| 2694 | case False hence "m = n" using Suc(2) by auto | |
| 2695 | thus ?thesis using * by auto | |
| 2696 | qed | |
| 2697 | qed } note * = this | |
| 2698 |   { fix m n ::nat assume "m\<noteq>n"
 | |
| 2699 | have "1 < dist (x m) (x n)" | |
| 2700 | proof(cases "m<n") | |
| 2701 | case True | |
| 2702 | hence "1 < dist undefined (x n) - dist undefined (x m)" using *[of m n] by auto | |
| 2703 | thus ?thesis using dist_triangle [of undefined "x n" "x m"] by arith | |
| 2704 | next | |
| 2705 | case False hence "n<m" using `m\<noteq>n` by auto | |
| 2706 | hence "1 < dist undefined (x m) - dist undefined (x n)" using *[of n m] by auto | |
| 2707 | thus ?thesis using dist_triangle2 [of undefined "x m" "x n"] by arith | |
| 2708 | qed } note ** = this | |
| 2709 |   { fix a b assume "x a = x b" "a \<noteq> b"
 | |
| 2710 | hence False using **[of a b] by auto } | |
| 2711 | hence "inj x" unfolding inj_on_def by auto | |
| 2712 | moreover | |
| 2713 |   { fix n::nat
 | |
| 2714 | have "x n \<in> s" | |
| 2715 | proof(cases "n = 0") | |
| 2716 | case True thus ?thesis unfolding x_def using beyond by auto | |
| 2717 | next | |
| 2718 | case False then obtain z where "n = Suc z" using not0_implies_Suc by auto | |
| 2719 | thus ?thesis unfolding x_def using beyond by auto | |
| 2720 | qed } | |
| 2721 | ultimately have "infinite (range x) \<and> range x \<subseteq> s" unfolding x_def using range_inj_infinite[of "helper_2 beyond"] using beyond(1) by auto | |
| 2722 | ||
| 2723 | then obtain l where "l\<in>s" and l:"l islimpt range x" using assms[THEN spec[where x="range x"]] by auto | |
| 2724 | then obtain y where "x y \<noteq> l" and y:"dist (x y) l < 1/2" unfolding islimpt_approachable apply(erule_tac x="1/2" in allE) by auto | |
| 2725 | then obtain z where "x z \<noteq> l" and z:"dist (x z) l < dist (x y) l" using l[unfolded islimpt_approachable, THEN spec[where x="dist (x y) l"]] | |
| 2726 | unfolding dist_nz by auto | |
| 2727 | show False using y and z and dist_triangle_half_l[of "x y" l 1 "x z"] and **[of y z] by auto | |
| 2728 | qed | |
| 2729 | ||
| 2730 | lemma sequence_infinite_lemma: | |
| 2731 | fixes l :: "'a::metric_space" (* TODO: generalize *) | |
| 2732 | assumes "\<forall>n::nat. (f n \<noteq> l)" "(f ---> l) sequentially" | |
| 34104 | 2733 | shows "infinite (range f)" | 
| 2734 | proof | |
| 2735 | let ?A = "(\<lambda>x. dist x l) ` range f" | |
| 2736 | assume "finite (range f)" | |
| 33175 | 2737 |   hence **:"finite ?A" "?A \<noteq> {}" by auto
 | 
| 2738 | obtain k where k:"dist (f k) l = Min ?A" using Min_in[OF **] by auto | |
| 2739 | have "0 < Min ?A" using assms(1) unfolding dist_nz unfolding Min_gr_iff[OF **] by auto | |
| 2740 | then obtain N where "dist (f N) l < Min ?A" using assms(2)[unfolded Lim_sequentially, THEN spec[where x="Min ?A"]] by auto | |
| 2741 | moreover have "dist (f N) l \<in> ?A" by auto | |
| 2742 | ultimately show False using Min_le[OF **(1), of "dist (f N) l"] by auto | |
| 2743 | qed | |
| 2744 | ||
| 2745 | lemma sequence_unique_limpt: | |
| 2746 | fixes l :: "'a::metric_space" (* TODO: generalize *) | |
| 34104 | 2747 | assumes "\<forall>n::nat. (f n \<noteq> l)" "(f ---> l) sequentially" "l' islimpt (range f)" | 
| 33175 | 2748 | shows "l' = l" | 
| 2749 | proof(rule ccontr) | |
| 2750 | def e \<equiv> "dist l' l" | |
| 2751 | assume "l' \<noteq> l" hence "e>0" unfolding dist_nz e_def by auto | |
| 2752 | then obtain N::nat where N:"\<forall>n\<ge>N. dist (f n) l < e / 2" | |
| 2753 | using assms(2)[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto | |
| 2754 |   def d \<equiv> "Min (insert (e/2) ((\<lambda>n. if dist (f n) l' = 0 then e/2 else dist (f n) l') ` {0 .. N}))"
 | |
| 2755 | have "d>0" using `e>0` unfolding d_def e_def using zero_le_dist[of _ l', unfolded order_le_less] by auto | |
| 2756 | obtain k where k:"f k \<noteq> l'" "dist (f k) l' < d" using `d>0` and assms(3)[unfolded islimpt_approachable, THEN spec[where x="d"]] by auto | |
| 2757 | have "k\<ge>N" using k(1)[unfolded dist_nz] using k(2)[unfolded d_def] | |
| 2758 | by force | |
| 2759 | hence "dist l' l < e" using N[THEN spec[where x=k]] using k(2)[unfolded d_def] and dist_triangle_half_r[of "f k" l' e l] by auto | |
| 2760 | thus False unfolding e_def by auto | |
| 2761 | qed | |
| 2762 | ||
| 2763 | lemma bolzano_weierstrass_imp_closed: | |
| 2764 | fixes s :: "'a::metric_space set" (* TODO: can this be generalized? *) | |
| 2765 | assumes "\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t)" | |
| 2766 | shows "closed s" | |
| 2767 | proof- | |
| 2768 |   { fix x l assume as: "\<forall>n::nat. x n \<in> s" "(x ---> l) sequentially"
 | |
| 2769 | hence "l \<in> s" | |
| 2770 | proof(cases "\<forall>n. x n \<noteq> l") | |
| 2771 | case False thus "l\<in>s" using as(1) by auto | |
| 2772 | next | |
| 2773 | case True note cas = this | |
| 34104 | 2774 | with as(2) have "infinite (range x)" using sequence_infinite_lemma[of x l] by auto | 
| 2775 | then obtain l' where "l'\<in>s" "l' islimpt (range x)" using assms[THEN spec[where x="range x"]] as(1) by auto | |
| 33175 | 2776 | thus "l\<in>s" using sequence_unique_limpt[of x l l'] using as cas by auto | 
| 2777 | qed } | |
| 2778 | thus ?thesis unfolding closed_sequential_limits by fast | |
| 2779 | qed | |
| 2780 | ||
| 2781 | text{* Hence express everything as an equivalence.   *}
 | |
| 2782 | ||
| 2783 | lemma compact_eq_heine_borel: | |
| 2784 | fixes s :: "'a::heine_borel set" | |
| 2785 | shows "compact s \<longleftrightarrow> | |
| 2786 | (\<forall>f. (\<forall>t \<in> f. open t) \<and> s \<subseteq> (\<Union> f) | |
| 2787 | --> (\<exists>f'. f' \<subseteq> f \<and> finite f' \<and> s \<subseteq> (\<Union> f')))" (is "?lhs = ?rhs") | |
| 2788 | proof | |
| 2789 | assume ?lhs thus ?rhs using compact_imp_heine_borel[of s] by blast | |
| 2790 | next | |
| 2791 | assume ?rhs | |
| 2792 | hence "\<forall>t. infinite t \<and> t \<subseteq> s \<longrightarrow> (\<exists>x\<in>s. x islimpt t)" | |
| 2793 | by (blast intro: heine_borel_imp_bolzano_weierstrass[of s]) | |
| 2794 | thus ?lhs using bolzano_weierstrass_imp_bounded[of s] bolzano_weierstrass_imp_closed[of s] bounded_closed_imp_compact[of s] by blast | |
| 2795 | qed | |
| 2796 | ||
| 2797 | lemma compact_eq_bolzano_weierstrass: | |
| 2798 | fixes s :: "'a::heine_borel set" | |
| 2799 | shows "compact s \<longleftrightarrow> (\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t))" (is "?lhs = ?rhs") | |
| 2800 | proof | |
| 2801 | assume ?lhs thus ?rhs unfolding compact_eq_heine_borel using heine_borel_imp_bolzano_weierstrass[of s] by auto | |
| 2802 | next | |
| 2803 | assume ?rhs thus ?lhs using bolzano_weierstrass_imp_bounded bolzano_weierstrass_imp_closed bounded_closed_imp_compact by auto | |
| 2804 | qed | |
| 2805 | ||
| 2806 | lemma compact_eq_bounded_closed: | |
| 2807 | fixes s :: "'a::heine_borel set" | |
| 2808 | shows "compact s \<longleftrightarrow> bounded s \<and> closed s" (is "?lhs = ?rhs") | |
| 2809 | proof | |
| 2810 | assume ?lhs thus ?rhs unfolding compact_eq_bolzano_weierstrass using bolzano_weierstrass_imp_bounded bolzano_weierstrass_imp_closed by auto | |
| 2811 | next | |
| 2812 | assume ?rhs thus ?lhs using bounded_closed_imp_compact by auto | |
| 2813 | qed | |
| 2814 | ||
| 2815 | lemma compact_imp_bounded: | |
| 2816 | fixes s :: "'a::metric_space set" | |
| 2817 | shows "compact s ==> bounded s" | |
| 2818 | proof - | |
| 2819 | assume "compact s" | |
| 2820 | hence "\<forall>f. (\<forall>t\<in>f. open t) \<and> s \<subseteq> \<Union>f \<longrightarrow> (\<exists>f'\<subseteq>f. finite f' \<and> s \<subseteq> \<Union>f')" | |
| 2821 | by (rule compact_imp_heine_borel) | |
| 2822 | hence "\<forall>t. infinite t \<and> t \<subseteq> s \<longrightarrow> (\<exists>x \<in> s. x islimpt t)" | |
| 2823 | using heine_borel_imp_bolzano_weierstrass[of s] by auto | |
| 2824 | thus "bounded s" | |
| 2825 | by (rule bolzano_weierstrass_imp_bounded) | |
| 2826 | qed | |
| 2827 | ||
| 2828 | lemma compact_imp_closed: | |
| 2829 | fixes s :: "'a::metric_space set" | |
| 2830 | shows "compact s ==> closed s" | |
| 2831 | proof - | |
| 2832 | assume "compact s" | |
| 2833 | hence "\<forall>f. (\<forall>t\<in>f. open t) \<and> s \<subseteq> \<Union>f \<longrightarrow> (\<exists>f'\<subseteq>f. finite f' \<and> s \<subseteq> \<Union>f')" | |
| 2834 | by (rule compact_imp_heine_borel) | |
| 2835 | hence "\<forall>t. infinite t \<and> t \<subseteq> s \<longrightarrow> (\<exists>x \<in> s. x islimpt t)" | |
| 2836 | using heine_borel_imp_bolzano_weierstrass[of s] by auto | |
| 2837 | thus "closed s" | |
| 2838 | by (rule bolzano_weierstrass_imp_closed) | |
| 2839 | qed | |
| 2840 | ||
| 2841 | text{* In particular, some common special cases. *}
 | |
| 2842 | ||
| 2843 | lemma compact_empty[simp]: | |
| 2844 |  "compact {}"
 | |
| 2845 | unfolding compact_def | |
| 2846 | by simp | |
| 2847 | ||
| 2848 | (* TODO: can any of the next 3 lemmas be generalized to metric spaces? *) | |
| 2849 | ||
| 2850 | (* FIXME : Rename *) | |
| 2851 | lemma compact_union[intro]: | |
| 2852 | fixes s t :: "'a::heine_borel set" | |
| 2853 | shows "compact s \<Longrightarrow> compact t ==> compact (s \<union> t)" | |
| 2854 | unfolding compact_eq_bounded_closed | |
| 2855 | using bounded_Un[of s t] | |
| 2856 | using closed_Un[of s t] | |
| 2857 | by simp | |
| 2858 | ||
| 2859 | lemma compact_inter[intro]: | |
| 2860 | fixes s t :: "'a::heine_borel set" | |
| 2861 | shows "compact s \<Longrightarrow> compact t ==> compact (s \<inter> t)" | |
| 2862 | unfolding compact_eq_bounded_closed | |
| 2863 | using bounded_Int[of s t] | |
| 2864 | using closed_Int[of s t] | |
| 2865 | by simp | |
| 2866 | ||
| 2867 | lemma compact_inter_closed[intro]: | |
| 2868 | fixes s t :: "'a::heine_borel set" | |
| 2869 | shows "compact s \<Longrightarrow> closed t ==> compact (s \<inter> t)" | |
| 2870 | unfolding compact_eq_bounded_closed | |
| 2871 | using closed_Int[of s t] | |
| 2872 | using bounded_subset[of "s \<inter> t" s] | |
| 2873 | by blast | |
| 2874 | ||
| 2875 | lemma closed_inter_compact[intro]: | |
| 2876 | fixes s t :: "'a::heine_borel set" | |
| 2877 | shows "closed s \<Longrightarrow> compact t ==> compact (s \<inter> t)" | |
| 2878 | proof- | |
| 2879 | assume "closed s" "compact t" | |
| 2880 | moreover | |
| 2881 | have "s \<inter> t = t \<inter> s" by auto ultimately | |
| 2882 | show ?thesis | |
| 2883 | using compact_inter_closed[of t s] | |
| 2884 | by auto | |
| 2885 | qed | |
| 2886 | ||
| 2887 | lemma closed_sing [simp]: | |
| 2888 | fixes a :: "'a::metric_space" | |
| 2889 |   shows "closed {a}"
 | |
| 2890 | apply (clarsimp simp add: closed_def open_dist) | |
| 2891 | apply (rule ccontr) | |
| 2892 | apply (drule_tac x="dist x a" in spec) | |
| 2893 | apply (simp add: dist_nz dist_commute) | |
| 2894 | done | |
| 2895 | ||
| 2896 | lemma finite_imp_closed: | |
| 2897 | fixes s :: "'a::metric_space set" | |
| 2898 | shows "finite s ==> closed s" | |
| 2899 | proof (induct set: finite) | |
| 2900 |   case empty show "closed {}" by simp
 | |
| 2901 | next | |
| 2902 | case (insert x F) | |
| 2903 |   hence "closed ({x} \<union> F)" by (simp only: closed_Un closed_sing)
 | |
| 2904 | thus "closed (insert x F)" by simp | |
| 2905 | qed | |
| 2906 | ||
| 2907 | lemma finite_imp_compact: | |
| 2908 | fixes s :: "'a::heine_borel set" | |
| 2909 | shows "finite s ==> compact s" | |
| 2910 | unfolding compact_eq_bounded_closed | |
| 2911 | using finite_imp_closed finite_imp_bounded | |
| 2912 | by blast | |
| 2913 | ||
| 2914 | lemma compact_sing [simp]: "compact {a}"
 | |
| 2915 | unfolding compact_def o_def subseq_def | |
| 2916 | by (auto simp add: tendsto_const) | |
| 2917 | ||
| 2918 | lemma compact_cball[simp]: | |
| 2919 | fixes x :: "'a::heine_borel" | |
| 2920 | shows "compact(cball x e)" | |
| 2921 | using compact_eq_bounded_closed bounded_cball closed_cball | |
| 2922 | by blast | |
| 2923 | ||
| 2924 | lemma compact_frontier_bounded[intro]: | |
| 2925 | fixes s :: "'a::heine_borel set" | |
| 2926 | shows "bounded s ==> compact(frontier s)" | |
| 2927 | unfolding frontier_def | |
| 2928 | using compact_eq_bounded_closed | |
| 2929 | by blast | |
| 2930 | ||
| 2931 | lemma compact_frontier[intro]: | |
| 2932 | fixes s :: "'a::heine_borel set" | |
| 2933 | shows "compact s ==> compact (frontier s)" | |
| 2934 | using compact_eq_bounded_closed compact_frontier_bounded | |
| 2935 | by blast | |
| 2936 | ||
| 2937 | lemma frontier_subset_compact: | |
| 2938 | fixes s :: "'a::heine_borel set" | |
| 2939 | shows "compact s ==> frontier s \<subseteq> s" | |
| 2940 | using frontier_subset_closed compact_eq_bounded_closed | |
| 2941 | by blast | |
| 2942 | ||
| 2943 | lemma open_delete: | |
| 2944 | fixes s :: "'a::metric_space set" | |
| 2945 |   shows "open s ==> open(s - {x})"
 | |
| 2946 |   using open_Diff[of s "{x}"] closed_sing
 | |
| 2947 | by blast | |
| 2948 | ||
| 2949 | text{* Finite intersection property. I could make it an equivalence in fact. *}
 | |
| 2950 | ||
| 2951 | lemma compact_imp_fip: | |
| 2952 | fixes s :: "'a::heine_borel set" | |
| 2953 | assumes "compact s" "\<forall>t \<in> f. closed t" | |
| 2954 |         "\<forall>f'. finite f' \<and> f' \<subseteq> f --> (s \<inter> (\<Inter> f') \<noteq> {})"
 | |
| 2955 |   shows "s \<inter> (\<Inter> f) \<noteq> {}"
 | |
| 2956 | proof | |
| 2957 |   assume as:"s \<inter> (\<Inter> f) = {}"
 | |
| 34105 | 2958 | hence "s \<subseteq> \<Union> uminus ` f" by auto | 
| 2959 | moreover have "Ball (uminus ` f) open" using open_Diff closed_Diff using assms(2) by auto | |
| 2960 | ultimately obtain f' where f':"f' \<subseteq> uminus ` f" "finite f'" "s \<subseteq> \<Union>f'" using assms(1)[unfolded compact_eq_heine_borel, THEN spec[where x="(\<lambda>t. - t) ` f"]] by auto | |
| 2961 | hence "finite (uminus ` f') \<and> uminus ` f' \<subseteq> f" by(auto simp add: Diff_Diff_Int) | |
| 2962 |   hence "s \<inter> \<Inter>uminus ` f' \<noteq> {}" using assms(3)[THEN spec[where x="uminus ` f'"]] by auto
 | |
| 33175 | 2963 | thus False using f'(3) unfolding subset_eq and Union_iff by blast | 
| 2964 | qed | |
| 2965 | ||
| 2966 | subsection{* Bounded closed nest property (proof does not use Heine-Borel).            *}
 | |
| 2967 | ||
| 2968 | lemma bounded_closed_nest: | |
| 2969 |   assumes "\<forall>n. closed(s n)" "\<forall>n. (s n \<noteq> {})"
 | |
| 2970 | "(\<forall>m n. m \<le> n --> s n \<subseteq> s m)" "bounded(s 0)" | |
| 2971 | shows "\<exists>a::'a::heine_borel. \<forall>n::nat. a \<in> s(n)" | |
| 2972 | proof- | |
| 2973 | from assms(2) obtain x where x:"\<forall>n::nat. x n \<in> s n" using choice[of "\<lambda>n x. x\<in> s n"] by auto | |
| 2974 | from assms(4,1) have *:"compact (s 0)" using bounded_closed_imp_compact[of "s 0"] by auto | |
| 2975 | ||
| 2976 | then obtain l r where lr:"l\<in>s 0" "subseq r" "((x \<circ> r) ---> l) sequentially" | |
| 2977 | unfolding compact_def apply(erule_tac x=x in allE) using x using assms(3) by blast | |
| 2978 | ||
| 2979 |   { fix n::nat
 | |
| 2980 |     { fix e::real assume "e>0"
 | |
| 2981 | with lr(3) obtain N where N:"\<forall>m\<ge>N. dist ((x \<circ> r) m) l < e" unfolding Lim_sequentially by auto | |
| 2982 | hence "dist ((x \<circ> r) (max N n)) l < e" by auto | |
| 2983 | moreover | |
| 2984 | have "r (max N n) \<ge> n" using lr(2) using subseq_bigger[of r "max N n"] by auto | |
| 2985 | hence "(x \<circ> r) (max N n) \<in> s n" | |
| 2986 | using x apply(erule_tac x=n in allE) | |
| 2987 | using x apply(erule_tac x="r (max N n)" in allE) | |
| 2988 | using assms(3) apply(erule_tac x=n in allE)apply( erule_tac x="r (max N n)" in allE) by auto | |
| 2989 | ultimately have "\<exists>y\<in>s n. dist y l < e" by auto | |
| 2990 | } | |
| 2991 | hence "l \<in> s n" using closed_approachable[of "s n" l] assms(1) by blast | |
| 2992 | } | |
| 2993 | thus ?thesis by auto | |
| 2994 | qed | |
| 2995 | ||
| 2996 | text{* Decreasing case does not even need compactness, just completeness.        *}
 | |
| 2997 | ||
| 2998 | lemma decreasing_closed_nest: | |
| 2999 | assumes "\<forall>n. closed(s n)" | |
| 3000 |           "\<forall>n. (s n \<noteq> {})"
 | |
| 3001 | "\<forall>m n. m \<le> n --> s n \<subseteq> s m" | |
| 3002 | "\<forall>e>0. \<exists>n. \<forall>x \<in> (s n). \<forall> y \<in> (s n). dist x y < e" | |
| 3003 | shows "\<exists>a::'a::heine_borel. \<forall>n::nat. a \<in> s n" | |
| 3004 | proof- | |
| 3005 | have "\<forall>n. \<exists> x. x\<in>s n" using assms(2) by auto | |
| 3006 | hence "\<exists>t. \<forall>n. t n \<in> s n" using choice[of "\<lambda> n x. x \<in> s n"] by auto | |
| 3007 | then obtain t where t: "\<forall>n. t n \<in> s n" by auto | |
| 3008 |   { fix e::real assume "e>0"
 | |
| 3009 | then obtain N where N:"\<forall>x\<in>s N. \<forall>y\<in>s N. dist x y < e" using assms(4) by auto | |
| 3010 |     { fix m n ::nat assume "N \<le> m \<and> N \<le> n"
 | |
| 3011 | hence "t m \<in> s N" "t n \<in> s N" using assms(3) t unfolding subset_eq t by blast+ | |
| 3012 | hence "dist (t m) (t n) < e" using N by auto | |
| 3013 | } | |
| 3014 | hence "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (t m) (t n) < e" by auto | |
| 3015 | } | |
| 3016 | hence "Cauchy t" unfolding cauchy_def by auto | |
| 3017 | then obtain l where l:"(t ---> l) sequentially" using complete_univ unfolding complete_def by auto | |
| 3018 |   { fix n::nat
 | |
| 3019 |     { fix e::real assume "e>0"
 | |
| 3020 | then obtain N::nat where N:"\<forall>n\<ge>N. dist (t n) l < e" using l[unfolded Lim_sequentially] by auto | |
| 3021 | have "t (max n N) \<in> s n" using assms(3) unfolding subset_eq apply(erule_tac x=n in allE) apply (erule_tac x="max n N" in allE) using t by auto | |
| 3022 | hence "\<exists>y\<in>s n. dist y l < e" apply(rule_tac x="t (max n N)" in bexI) using N by auto | |
| 3023 | } | |
| 3024 | hence "l \<in> s n" using closed_approachable[of "s n" l] assms(1) by auto | |
| 3025 | } | |
| 3026 | then show ?thesis by auto | |
| 3027 | qed | |
| 3028 | ||
| 3029 | text{* Strengthen it to the intersection actually being a singleton.             *}
 | |
| 3030 | ||
| 3031 | lemma decreasing_closed_nest_sing: | |
| 34104 | 3032 | fixes s :: "nat \<Rightarrow> 'a::heine_borel set" | 
| 33175 | 3033 | assumes "\<forall>n. closed(s n)" | 
| 3034 |           "\<forall>n. s n \<noteq> {}"
 | |
| 3035 | "\<forall>m n. m \<le> n --> s n \<subseteq> s m" | |
| 3036 | "\<forall>e>0. \<exists>n. \<forall>x \<in> (s n). \<forall> y\<in>(s n). dist x y < e" | |
| 34104 | 3037 |   shows "\<exists>a. \<Inter>(range s) = {a}"
 | 
| 33175 | 3038 | proof- | 
| 3039 | obtain a where a:"\<forall>n. a \<in> s n" using decreasing_closed_nest[of s] using assms by auto | |
| 34104 | 3040 |   { fix b assume b:"b \<in> \<Inter>(range s)"
 | 
| 33175 | 3041 |     { fix e::real assume "e>0"
 | 
| 3042 | hence "dist a b < e" using assms(4 )using b using a by blast | |
| 3043 | } | |
| 3044 | hence "dist a b = 0" by (metis dist_eq_0_iff dist_nz real_less_def) | |
| 3045 | } | |
| 34104 | 3046 |   with a have "\<Inter>(range s) = {a}" unfolding image_def by auto
 | 
| 3047 | thus ?thesis .. | |
| 33175 | 3048 | qed | 
| 3049 | ||
| 3050 | text{* Cauchy-type criteria for uniform convergence. *}
 | |
| 3051 | ||
| 3052 | lemma uniformly_convergent_eq_cauchy: fixes s::"nat \<Rightarrow> 'b \<Rightarrow> 'a::heine_borel" shows | |
| 3053 | "(\<exists>l. \<forall>e>0. \<exists>N. \<forall>n x. N \<le> n \<and> P x --> dist(s n x)(l x) < e) \<longleftrightarrow> | |
| 3054 | (\<forall>e>0. \<exists>N. \<forall>m n x. N \<le> m \<and> N \<le> n \<and> P x --> dist (s m x) (s n x) < e)" (is "?lhs = ?rhs") | |
| 3055 | proof(rule) | |
| 3056 | assume ?lhs | |
| 3057 | then obtain l where l:"\<forall>e>0. \<exists>N. \<forall>n x. N \<le> n \<and> P x \<longrightarrow> dist (s n x) (l x) < e" by auto | |
| 3058 |   { fix e::real assume "e>0"
 | |
| 3059 | then obtain N::nat where N:"\<forall>n x. N \<le> n \<and> P x \<longrightarrow> dist (s n x) (l x) < e / 2" using l[THEN spec[where x="e/2"]] by auto | |
| 3060 |     { fix n m::nat and x::"'b" assume "N \<le> m \<and> N \<le> n \<and> P x"
 | |
| 3061 | hence "dist (s m x) (s n x) < e" | |
| 3062 | using N[THEN spec[where x=m], THEN spec[where x=x]] | |
| 3063 | using N[THEN spec[where x=n], THEN spec[where x=x]] | |
| 3064 | using dist_triangle_half_l[of "s m x" "l x" e "s n x"] by auto } | |
| 3065 | hence "\<exists>N. \<forall>m n x. N \<le> m \<and> N \<le> n \<and> P x --> dist (s m x) (s n x) < e" by auto } | |
| 3066 | thus ?rhs by auto | |
| 3067 | next | |
| 3068 | assume ?rhs | |
| 3069 | hence "\<forall>x. P x \<longrightarrow> Cauchy (\<lambda>n. s n x)" unfolding cauchy_def apply auto by (erule_tac x=e in allE)auto | |
| 3070 | then obtain l where l:"\<forall>x. P x \<longrightarrow> ((\<lambda>n. s n x) ---> l x) sequentially" unfolding convergent_eq_cauchy[THEN sym] | |
| 3071 | using choice[of "\<lambda>x l. P x \<longrightarrow> ((\<lambda>n. s n x) ---> l) sequentially"] by auto | |
| 3072 |   { fix e::real assume "e>0"
 | |
| 3073 | then obtain N where N:"\<forall>m n x. N \<le> m \<and> N \<le> n \<and> P x \<longrightarrow> dist (s m x) (s n x) < e/2" | |
| 3074 | using `?rhs`[THEN spec[where x="e/2"]] by auto | |
| 3075 |     { fix x assume "P x"
 | |
| 3076 | then obtain M where M:"\<forall>n\<ge>M. dist (s n x) (l x) < e/2" | |
| 3077 | using l[THEN spec[where x=x], unfolded Lim_sequentially] using `e>0` by(auto elim!: allE[where x="e/2"]) | |
| 3078 | fix n::nat assume "n\<ge>N" | |
| 3079 | hence "dist(s n x)(l x) < e" using `P x`and N[THEN spec[where x=n], THEN spec[where x="N+M"], THEN spec[where x=x]] | |
| 3080 | using M[THEN spec[where x="N+M"]] and dist_triangle_half_l[of "s n x" "s (N+M) x" e "l x"] by (auto simp add: dist_commute) } | |
| 3081 | hence "\<exists>N. \<forall>n x. N \<le> n \<and> P x \<longrightarrow> dist(s n x)(l x) < e" by auto } | |
| 3082 | thus ?lhs by auto | |
| 3083 | qed | |
| 3084 | ||
| 3085 | lemma uniformly_cauchy_imp_uniformly_convergent: | |
| 3086 | fixes s :: "nat \<Rightarrow> 'a \<Rightarrow> 'b::heine_borel" | |
| 3087 | assumes "\<forall>e>0.\<exists>N. \<forall>m (n::nat) x. N \<le> m \<and> N \<le> n \<and> P x --> dist(s m x)(s n x) < e" | |
| 3088 | "\<forall>x. P x --> (\<forall>e>0. \<exists>N. \<forall>n. N \<le> n --> dist(s n x)(l x) < e)" | |
| 3089 | shows "\<forall>e>0. \<exists>N. \<forall>n x. N \<le> n \<and> P x --> dist(s n x)(l x) < e" | |
| 3090 | proof- | |
| 3091 | obtain l' where l:"\<forall>e>0. \<exists>N. \<forall>n x. N \<le> n \<and> P x \<longrightarrow> dist (s n x) (l' x) < e" | |
| 3092 | using assms(1) unfolding uniformly_convergent_eq_cauchy[THEN sym] by auto | |
| 3093 | moreover | |
| 3094 |   { fix x assume "P x"
 | |
| 3095 | hence "l x = l' x" using Lim_unique[OF trivial_limit_sequentially, of "\<lambda>n. s n x" "l x" "l' x"] | |
| 3096 | using l and assms(2) unfolding Lim_sequentially by blast } | |
| 3097 | ultimately show ?thesis by auto | |
| 3098 | qed | |
| 3099 | ||
| 3100 | subsection{* Define continuity over a net to take in restrictions of the set. *}
 | |
| 3101 | ||
| 3102 | definition | |
| 3103 |   continuous :: "'a::t2_space net \<Rightarrow> ('a \<Rightarrow> 'b::topological_space) \<Rightarrow> bool" where
 | |
| 3104 | "continuous net f \<longleftrightarrow> (f ---> f(netlimit net)) net" | |
| 3105 | ||
| 3106 | lemma continuous_trivial_limit: | |
| 3107 | "trivial_limit net ==> continuous net f" | |
| 3108 | unfolding continuous_def tendsto_def trivial_limit_eq by auto | |
| 3109 | ||
| 3110 | lemma continuous_within: "continuous (at x within s) f \<longleftrightarrow> (f ---> f(x)) (at x within s)" | |
| 3111 | unfolding continuous_def | |
| 3112 | unfolding tendsto_def | |
| 3113 | using netlimit_within[of x s] | |
| 3114 | by (cases "trivial_limit (at x within s)") (auto simp add: trivial_limit_eventually) | |
| 3115 | ||
| 3116 | lemma continuous_at: "continuous (at x) f \<longleftrightarrow> (f ---> f(x)) (at x)" | |
| 3117 | using continuous_within [of x UNIV f] by (simp add: within_UNIV) | |
| 3118 | ||
| 3119 | lemma continuous_at_within: | |
| 3120 | assumes "continuous (at x) f" shows "continuous (at x within s) f" | |
| 3121 | using assms unfolding continuous_at continuous_within | |
| 3122 | by (rule Lim_at_within) | |
| 3123 | ||
| 3124 | text{* Derive the epsilon-delta forms, which we often use as "definitions" *}
 | |
| 3125 | ||
| 3126 | lemma continuous_within_eps_delta: | |
| 3127 | "continuous (at x within s) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. \<forall>x'\<in> s. dist x' x < d --> dist (f x') (f x) < e)" | |
| 3128 | unfolding continuous_within and Lim_within | |
| 3129 | apply auto unfolding dist_nz[THEN sym] apply(auto elim!:allE) apply(rule_tac x=d in exI) by auto | |
| 3130 | ||
| 3131 | lemma continuous_at_eps_delta: "continuous (at x) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. | |
| 3132 | \<forall>x'. dist x' x < d --> dist(f x')(f x) < e)" | |
| 3133 | using continuous_within_eps_delta[of x UNIV f] | |
| 3134 | unfolding within_UNIV by blast | |
| 3135 | ||
| 3136 | text{* Versions in terms of open balls. *}
 | |
| 3137 | ||
| 3138 | lemma continuous_within_ball: | |
| 3139 | "continuous (at x within s) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. | |
| 3140 | f ` (ball x d \<inter> s) \<subseteq> ball (f x) e)" (is "?lhs = ?rhs") | |
| 3141 | proof | |
| 3142 | assume ?lhs | |
| 3143 |   { fix e::real assume "e>0"
 | |
| 3144 | then obtain d where d: "d>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" | |
| 3145 | using `?lhs`[unfolded continuous_within Lim_within] by auto | |
| 3146 |     { fix y assume "y\<in>f ` (ball x d \<inter> s)"
 | |
| 3147 | hence "y \<in> ball (f x) e" using d(2) unfolding dist_nz[THEN sym] | |
| 3148 | apply (auto simp add: dist_commute mem_ball) apply(erule_tac x=xa in ballE) apply auto using `e>0` by auto | |
| 3149 | } | |
| 3150 | hence "\<exists>d>0. f ` (ball x d \<inter> s) \<subseteq> ball (f x) e" using `d>0` unfolding subset_eq ball_def by (auto simp add: dist_commute) } | |
| 3151 | thus ?rhs by auto | |
| 3152 | next | |
| 3153 | assume ?rhs thus ?lhs unfolding continuous_within Lim_within ball_def subset_eq | |
| 3154 | apply (auto simp add: dist_commute) apply(erule_tac x=e in allE) by auto | |
| 3155 | qed | |
| 3156 | ||
| 3157 | lemma continuous_at_ball: | |
| 3158 | "continuous (at x) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. f ` (ball x d) \<subseteq> ball (f x) e)" (is "?lhs = ?rhs") | |
| 3159 | proof | |
| 3160 | assume ?lhs thus ?rhs unfolding continuous_at Lim_at subset_eq Ball_def Bex_def image_iff mem_ball | |
| 3161 | apply auto apply(erule_tac x=e in allE) apply auto apply(rule_tac x=d in exI) apply auto apply(erule_tac x=xa in allE) apply (auto simp add: dist_commute dist_nz) | |
| 3162 | unfolding dist_nz[THEN sym] by auto | |
| 3163 | next | |
| 3164 | assume ?rhs thus ?lhs unfolding continuous_at Lim_at subset_eq Ball_def Bex_def image_iff mem_ball | |
| 3165 | apply auto apply(erule_tac x=e in allE) apply auto apply(rule_tac x=d in exI) apply auto apply(erule_tac x="f xa" in allE) by (auto simp add: dist_commute dist_nz) | |
| 3166 | qed | |
| 3167 | ||
| 3168 | text{* For setwise continuity, just start from the epsilon-delta definitions. *}
 | |
| 3169 | ||
| 3170 | definition | |
| 3171 |   continuous_on :: "'a::metric_space set \<Rightarrow> ('a \<Rightarrow> 'b::metric_space) \<Rightarrow> bool" where
 | |
| 3172 | "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. \<forall>e>0. \<exists>d::real>0. \<forall>x' \<in> s. dist x' x < d --> dist (f x') (f x) < e)" | |
| 3173 | ||
| 3174 | ||
| 3175 | definition | |
| 3176 | uniformly_continuous_on :: | |
| 3177 |     "'a::metric_space set \<Rightarrow> ('a \<Rightarrow> 'b::metric_space) \<Rightarrow> bool" where
 | |
| 3178 | "uniformly_continuous_on s f \<longleftrightarrow> | |
| 3179 | (\<forall>e>0. \<exists>d>0. \<forall>x\<in>s. \<forall> x'\<in>s. dist x' x < d | |
| 3180 | --> dist (f x') (f x) < e)" | |
| 3181 | ||
| 3182 | text{* Some simple consequential lemmas. *}
 | |
| 3183 | ||
| 3184 | lemma uniformly_continuous_imp_continuous: | |
| 3185 | " uniformly_continuous_on s f ==> continuous_on s f" | |
| 3186 | unfolding uniformly_continuous_on_def continuous_on_def by blast | |
| 3187 | ||
| 3188 | lemma continuous_at_imp_continuous_within: | |
| 3189 | "continuous (at x) f ==> continuous (at x within s) f" | |
| 3190 | unfolding continuous_within continuous_at using Lim_at_within by auto | |
| 3191 | ||
| 3192 | lemma continuous_at_imp_continuous_on: assumes "(\<forall>x \<in> s. continuous (at x) f)" | |
| 3193 | shows "continuous_on s f" | |
| 3194 | proof(simp add: continuous_at continuous_on_def, rule, rule, rule) | |
| 3195 | fix x and e::real assume "x\<in>s" "e>0" | |
| 3196 | hence "eventually (\<lambda>xa. dist (f xa) (f x) < e) (at x)" using assms unfolding continuous_at tendsto_iff by auto | |
| 3197 | then obtain d where d:"d>0" "\<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" unfolding eventually_at by auto | |
| 3198 |   { fix x' assume "\<not> 0 < dist x' x"
 | |
| 3199 | hence "x=x'" | |
| 3200 | using dist_nz[of x' x] by auto | |
| 3201 | hence "dist (f x') (f x) < e" using `e>0` by auto | |
| 3202 | } | |
| 3203 | thus "\<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using d by auto | |
| 3204 | qed | |
| 3205 | ||
| 3206 | lemma continuous_on_eq_continuous_within: | |
| 3207 | "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. continuous (at x within s) f)" (is "?lhs = ?rhs") | |
| 3208 | proof | |
| 3209 | assume ?rhs | |
| 3210 |   { fix x assume "x\<in>s"
 | |
| 3211 | fix e::real assume "e>0" | |
| 3212 | assume "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" | |
| 3213 | then obtain d where "d>0" and d:"\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" by auto | |
| 3214 |     { fix x' assume as:"x'\<in>s" "dist x' x < d"
 | |
| 3215 | hence "dist (f x') (f x) < e" using `e>0` d `x'\<in>s` dist_eq_0_iff[of x' x] zero_le_dist[of x' x] as(2) by (metis dist_eq_0_iff dist_nz) } | |
| 3216 | hence "\<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using `d>0` by auto | |
| 3217 | } | |
| 3218 | thus ?lhs using `?rhs` unfolding continuous_on_def continuous_within Lim_within by auto | |
| 3219 | next | |
| 3220 | assume ?lhs | |
| 3221 | thus ?rhs unfolding continuous_on_def continuous_within Lim_within by blast | |
| 3222 | qed | |
| 3223 | ||
| 3224 | lemma continuous_on: | |
| 3225 | "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. (f ---> f(x)) (at x within s))" | |
| 3226 | by (auto simp add: continuous_on_eq_continuous_within continuous_within) | |
| 3227 | ||
| 3228 | lemma continuous_on_eq_continuous_at: | |
| 3229 | "open s ==> (continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. continuous (at x) f))" | |
| 3230 | by (auto simp add: continuous_on continuous_at Lim_within_open) | |
| 3231 | ||
| 3232 | lemma continuous_within_subset: | |
| 3233 | "continuous (at x within s) f \<Longrightarrow> t \<subseteq> s | |
| 3234 | ==> continuous (at x within t) f" | |
| 3235 | unfolding continuous_within by(metis Lim_within_subset) | |
| 3236 | ||
| 3237 | lemma continuous_on_subset: | |
| 3238 | "continuous_on s f \<Longrightarrow> t \<subseteq> s ==> continuous_on t f" | |
| 3239 | unfolding continuous_on by (metis subset_eq Lim_within_subset) | |
| 3240 | ||
| 3241 | lemma continuous_on_interior: | |
| 3242 | "continuous_on s f \<Longrightarrow> x \<in> interior s ==> continuous (at x) f" | |
| 3243 | unfolding interior_def | |
| 3244 | apply simp | |
| 3245 | by (meson continuous_on_eq_continuous_at continuous_on_subset) | |
| 3246 | ||
| 3247 | lemma continuous_on_eq: | |
| 3248 | "(\<forall>x \<in> s. f x = g x) \<Longrightarrow> continuous_on s f | |
| 3249 | ==> continuous_on s g" | |
| 3250 | by (simp add: continuous_on_def) | |
| 3251 | ||
| 3252 | text{* Characterization of various kinds of continuity in terms of sequences.  *}
 | |
| 3253 | ||
| 3254 | (* \<longrightarrow> could be generalized, but \<longleftarrow> requires metric space *) | |
| 3255 | lemma continuous_within_sequentially: | |
| 3256 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" | |
| 3257 | shows "continuous (at a within s) f \<longleftrightarrow> | |
| 3258 | (\<forall>x. (\<forall>n::nat. x n \<in> s) \<and> (x ---> a) sequentially | |
| 3259 | --> ((f o x) ---> f a) sequentially)" (is "?lhs = ?rhs") | |
| 3260 | proof | |
| 3261 | assume ?lhs | |
| 3262 |   { fix x::"nat \<Rightarrow> 'a" assume x:"\<forall>n. x n \<in> s" "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (x n) a < e"
 | |
| 3263 | fix e::real assume "e>0" | |
| 3264 | from `?lhs` obtain d where "d>0" and d:"\<forall>x\<in>s. 0 < dist x a \<and> dist x a < d \<longrightarrow> dist (f x) (f a) < e" unfolding continuous_within Lim_within using `e>0` by auto | |
| 3265 | from x(2) `d>0` obtain N where N:"\<forall>n\<ge>N. dist (x n) a < d" by auto | |
| 3266 | hence "\<exists>N. \<forall>n\<ge>N. dist ((f \<circ> x) n) (f a) < e" | |
| 3267 | apply(rule_tac x=N in exI) using N d apply auto using x(1) | |
| 3268 | apply(erule_tac x=n in allE) apply(erule_tac x=n in allE) | |
| 3269 | apply(erule_tac x="x n" in ballE) apply auto unfolding dist_nz[THEN sym] apply auto using `e>0` by auto | |
| 3270 | } | |
| 3271 | thus ?rhs unfolding continuous_within unfolding Lim_sequentially by simp | |
| 3272 | next | |
| 3273 | assume ?rhs | |
| 3274 |   { fix e::real assume "e>0"
 | |
| 3275 | assume "\<not> (\<exists>d>0. \<forall>x\<in>s. 0 < dist x a \<and> dist x a < d \<longrightarrow> dist (f x) (f a) < e)" | |
| 3276 | hence "\<forall>d. \<exists>x. d>0 \<longrightarrow> x\<in>s \<and> (0 < dist x a \<and> dist x a < d \<and> \<not> dist (f x) (f a) < e)" by blast | |
| 3277 | then obtain x where x:"\<forall>d>0. x d \<in> s \<and> (0 < dist (x d) a \<and> dist (x d) a < d \<and> \<not> dist (f (x d)) (f a) < e)" | |
| 3278 | using choice[of "\<lambda>d x.0<d \<longrightarrow> x\<in>s \<and> (0 < dist x a \<and> dist x a < d \<and> \<not> dist (f x) (f a) < e)"] by auto | |
| 3279 |     { fix d::real assume "d>0"
 | |
| 3280 | hence "\<exists>N::nat. inverse (real (N + 1)) < d" using real_arch_inv[of d] by (auto, rule_tac x="n - 1" in exI)auto | |
| 3281 | then obtain N::nat where N:"inverse (real (N + 1)) < d" by auto | |
| 3282 |       { fix n::nat assume n:"n\<ge>N"
 | |
| 3283 | hence "dist (x (inverse (real (n + 1)))) a < inverse (real (n + 1))" using x[THEN spec[where x="inverse (real (n + 1))"]] by auto | |
| 3284 | moreover have "inverse (real (n + 1)) < d" using N n by (auto, metis Suc_le_mono le_SucE less_imp_inverse_less nat_le_real_less order_less_trans real_of_nat_Suc real_of_nat_Suc_gt_zero) | |
| 3285 | ultimately have "dist (x (inverse (real (n + 1)))) a < d" by auto | |
| 3286 | } | |
| 3287 | hence "\<exists>N::nat. \<forall>n\<ge>N. dist (x (inverse (real (n + 1)))) a < d" by auto | |
| 3288 | } | |
| 3289 | hence "(\<forall>n::nat. x (inverse (real (n + 1))) \<in> s) \<and> (\<forall>e>0. \<exists>N::nat. \<forall>n\<ge>N. dist (x (inverse (real (n + 1)))) a < e)" using x by auto | |
| 3290 | hence "\<forall>e>0. \<exists>N::nat. \<forall>n\<ge>N. dist (f (x (inverse (real (n + 1))))) (f a) < e" using `?rhs`[THEN spec[where x="\<lambda>n::nat. x (inverse (real (n+1)))"], unfolded Lim_sequentially] by auto | |
| 3291 | hence "False" apply(erule_tac x=e in allE) using `e>0` using x by auto | |
| 3292 | } | |
| 3293 | thus ?lhs unfolding continuous_within unfolding Lim_within unfolding Lim_sequentially by blast | |
| 3294 | qed | |
| 3295 | ||
| 3296 | lemma continuous_at_sequentially: | |
| 3297 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" | |
| 3298 | shows "continuous (at a) f \<longleftrightarrow> (\<forall>x. (x ---> a) sequentially | |
| 3299 | --> ((f o x) ---> f a) sequentially)" | |
| 3300 | using continuous_within_sequentially[of a UNIV f] unfolding within_UNIV by auto | |
| 3301 | ||
| 3302 | lemma continuous_on_sequentially: | |
| 3303 | "continuous_on s f \<longleftrightarrow> (\<forall>x. \<forall>a \<in> s. (\<forall>n. x(n) \<in> s) \<and> (x ---> a) sequentially | |
| 3304 | --> ((f o x) ---> f(a)) sequentially)" (is "?lhs = ?rhs") | |
| 3305 | proof | |
| 3306 | assume ?rhs thus ?lhs using continuous_within_sequentially[of _ s f] unfolding continuous_on_eq_continuous_within by auto | |
| 3307 | next | |
| 3308 | assume ?lhs thus ?rhs unfolding continuous_on_eq_continuous_within using continuous_within_sequentially[of _ s f] by auto | |
| 3309 | qed | |
| 3310 | ||
| 3311 | lemma uniformly_continuous_on_sequentially: | |
| 3312 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" | |
| 3313 | shows "uniformly_continuous_on s f \<longleftrightarrow> (\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> | |
| 3314 | ((\<lambda>n. x n - y n) ---> 0) sequentially | |
| 3315 | \<longrightarrow> ((\<lambda>n. f(x n) - f(y n)) ---> 0) sequentially)" (is "?lhs = ?rhs") | |
| 3316 | proof | |
| 3317 | assume ?lhs | |
| 3318 |   { fix x y assume x:"\<forall>n. x n \<in> s" and y:"\<forall>n. y n \<in> s" and xy:"((\<lambda>n. x n - y n) ---> 0) sequentially"
 | |
| 3319 |     { fix e::real assume "e>0"
 | |
| 3320 | then obtain d where "d>0" and d:"\<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" | |
| 3321 | using `?lhs`[unfolded uniformly_continuous_on_def, THEN spec[where x=e]] by auto | |
| 3322 | obtain N where N:"\<forall>n\<ge>N. norm (x n - y n - 0) < d" using xy[unfolded Lim_sequentially dist_norm] and `d>0` by auto | |
| 3323 |       { fix n assume "n\<ge>N"
 | |
| 3324 | hence "norm (f (x n) - f (y n) - 0) < e" | |
| 3325 | using N[THEN spec[where x=n]] using d[THEN bspec[where x="x n"], THEN bspec[where x="y n"]] using x and y | |
| 3326 | unfolding dist_commute and dist_norm by simp } | |
| 3327 | hence "\<exists>N. \<forall>n\<ge>N. norm (f (x n) - f (y n) - 0) < e" by auto } | |
| 3328 | hence "((\<lambda>n. f(x n) - f(y n)) ---> 0) sequentially" unfolding Lim_sequentially and dist_norm by auto } | |
| 3329 | thus ?rhs by auto | |
| 3330 | next | |
| 3331 | assume ?rhs | |
| 3332 |   { assume "\<not> ?lhs"
 | |
| 3333 | then obtain e where "e>0" "\<forall>d>0. \<exists>x\<in>s. \<exists>x'\<in>s. dist x' x < d \<and> \<not> dist (f x') (f x) < e" unfolding uniformly_continuous_on_def by auto | |
| 3334 | then obtain fa where fa:"\<forall>x. 0 < x \<longrightarrow> fst (fa x) \<in> s \<and> snd (fa x) \<in> s \<and> dist (fst (fa x)) (snd (fa x)) < x \<and> \<not> dist (f (fst (fa x))) (f (snd (fa x))) < e" | |
| 3335 | using choice[of "\<lambda>d x. d>0 \<longrightarrow> fst x \<in> s \<and> snd x \<in> s \<and> dist (snd x) (fst x) < d \<and> \<not> dist (f (snd x)) (f (fst x)) < e"] unfolding Bex_def | |
| 3336 | by (auto simp add: dist_commute) | |
| 3337 | def x \<equiv> "\<lambda>n::nat. fst (fa (inverse (real n + 1)))" | |
| 3338 | def y \<equiv> "\<lambda>n::nat. snd (fa (inverse (real n + 1)))" | |
| 3339 | have xyn:"\<forall>n. x n \<in> s \<and> y n \<in> s" and xy0:"\<forall>n. dist (x n) (y n) < inverse (real n + 1)" and fxy:"\<forall>n. \<not> dist (f (x n)) (f (y n)) < e" | |
| 3340 | unfolding x_def and y_def using fa by auto | |
| 3341 | have 1:"\<And>(x::'a) y. dist (x - y) 0 = dist x y" unfolding dist_norm by auto | |
| 3342 | have 2:"\<And>(x::'b) y. dist (x - y) 0 = dist x y" unfolding dist_norm by auto | |
| 3343 |     { fix e::real assume "e>0"
 | |
| 3344 | then obtain N::nat where "N \<noteq> 0" and N:"0 < inverse (real N) \<and> inverse (real N) < e" unfolding real_arch_inv[of e] by auto | |
| 3345 |       { fix n::nat assume "n\<ge>N"
 | |
| 3346 | hence "inverse (real n + 1) < inverse (real N)" using real_of_nat_ge_zero and `N\<noteq>0` by auto | |
| 3347 | also have "\<dots> < e" using N by auto | |
| 3348 | finally have "inverse (real n + 1) < e" by auto | |
| 3349 | hence "dist (x n - y n) 0 < e" unfolding 1 using xy0[THEN spec[where x=n]] by auto } | |
| 3350 | hence "\<exists>N. \<forall>n\<ge>N. dist (x n - y n) 0 < e" by auto } | |
| 3351 | hence "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (f (x n) - f (y n)) 0 < e" using `?rhs`[THEN spec[where x=x], THEN spec[where x=y]] and xyn unfolding Lim_sequentially by auto | |
| 3352 | hence False unfolding 2 using fxy and `e>0` by auto } | |
| 3353 | thus ?lhs unfolding uniformly_continuous_on_def by blast | |
| 3354 | qed | |
| 3355 | ||
| 3356 | text{* The usual transformation theorems. *}
 | |
| 3357 | ||
| 3358 | lemma continuous_transform_within: | |
| 3359 | fixes f g :: "'a::metric_space \<Rightarrow> 'b::metric_space" | |
| 3360 | assumes "0 < d" "x \<in> s" "\<forall>x' \<in> s. dist x' x < d --> f x' = g x'" | |
| 3361 | "continuous (at x within s) f" | |
| 3362 | shows "continuous (at x within s) g" | |
| 3363 | proof- | |
| 3364 |   { fix e::real assume "e>0"
 | |
| 3365 | then obtain d' where d':"d'>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d' \<longrightarrow> dist (f xa) (f x) < e" using assms(4) unfolding continuous_within Lim_within by auto | |
| 3366 |     { fix x' assume "x'\<in>s" "0 < dist x' x" "dist x' x < (min d d')"
 | |
| 3367 | hence "dist (f x') (g x) < e" using assms(2,3) apply(erule_tac x=x in ballE) using d' by auto } | |
| 3368 | hence "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < (min d d') \<longrightarrow> dist (f xa) (g x) < e" by blast | |
| 3369 | hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (g x) < e" using `d>0` `d'>0` by(rule_tac x="min d d'" in exI)auto } | |
| 3370 | hence "(f ---> g x) (at x within s)" unfolding Lim_within using assms(1) by auto | |
| 3371 | thus ?thesis unfolding continuous_within using Lim_transform_within[of d s x f g "g x"] using assms by blast | |
| 3372 | qed | |
| 3373 | ||
| 3374 | lemma continuous_transform_at: | |
| 3375 | fixes f g :: "'a::metric_space \<Rightarrow> 'b::metric_space" | |
| 3376 | assumes "0 < d" "\<forall>x'. dist x' x < d --> f x' = g x'" | |
| 3377 | "continuous (at x) f" | |
| 3378 | shows "continuous (at x) g" | |
| 3379 | proof- | |
| 3380 |   { fix e::real assume "e>0"
 | |
| 3381 | then obtain d' where d':"d'>0" "\<forall>xa. 0 < dist xa x \<and> dist xa x < d' \<longrightarrow> dist (f xa) (f x) < e" using assms(3) unfolding continuous_at Lim_at by auto | |
| 3382 |     { fix x' assume "0 < dist x' x" "dist x' x < (min d d')"
 | |
| 3383 | hence "dist (f x') (g x) < e" using assms(2) apply(erule_tac x=x in allE) using d' by auto | |
| 3384 | } | |
| 3385 | hence "\<forall>xa. 0 < dist xa x \<and> dist xa x < (min d d') \<longrightarrow> dist (f xa) (g x) < e" by blast | |
| 3386 | hence "\<exists>d>0. \<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (g x) < e" using `d>0` `d'>0` by(rule_tac x="min d d'" in exI)auto | |
| 3387 | } | |
| 3388 | hence "(f ---> g x) (at x)" unfolding Lim_at using assms(1) by auto | |
| 3389 | thus ?thesis unfolding continuous_at using Lim_transform_at[of d x f g "g x"] using assms by blast | |
| 3390 | qed | |
| 3391 | ||
| 3392 | text{* Combination results for pointwise continuity. *}
 | |
| 3393 | ||
| 3394 | lemma continuous_const: "continuous net (\<lambda>x. c)" | |
| 3395 | by (auto simp add: continuous_def Lim_const) | |
| 3396 | ||
| 3397 | lemma continuous_cmul: | |
| 3398 | fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" | |
| 3399 | shows "continuous net f ==> continuous net (\<lambda>x. c *\<^sub>R f x)" | |
| 3400 | by (auto simp add: continuous_def Lim_cmul) | |
| 3401 | ||
| 3402 | lemma continuous_neg: | |
| 3403 | fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" | |
| 3404 | shows "continuous net f ==> continuous net (\<lambda>x. -(f x))" | |
| 3405 | by (auto simp add: continuous_def Lim_neg) | |
| 3406 | ||
| 3407 | lemma continuous_add: | |
| 3408 | fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" | |
| 3409 | shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x + g x)" | |
| 3410 | by (auto simp add: continuous_def Lim_add) | |
| 3411 | ||
| 3412 | lemma continuous_sub: | |
| 3413 | fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" | |
| 3414 | shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x - g x)" | |
| 3415 | by (auto simp add: continuous_def Lim_sub) | |
| 3416 | ||
| 34964 | 3417 | |
| 33175 | 3418 | text{* Same thing for setwise continuity. *}
 | 
| 3419 | ||
| 3420 | lemma continuous_on_const: | |
| 3421 | "continuous_on s (\<lambda>x. c)" | |
| 3422 | unfolding continuous_on_eq_continuous_within using continuous_const by blast | |
| 3423 | ||
| 3424 | lemma continuous_on_cmul: | |
| 3425 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3426 | shows "continuous_on s f ==> continuous_on s (\<lambda>x. c *\<^sub>R (f x))" | |
| 3427 | unfolding continuous_on_eq_continuous_within using continuous_cmul by blast | |
| 3428 | ||
| 3429 | lemma continuous_on_neg: | |
| 3430 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3431 | shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. - f x)" | |
| 3432 | unfolding continuous_on_eq_continuous_within using continuous_neg by blast | |
| 3433 | ||
| 3434 | lemma continuous_on_add: | |
| 3435 | fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3436 | shows "continuous_on s f \<Longrightarrow> continuous_on s g | |
| 3437 | \<Longrightarrow> continuous_on s (\<lambda>x. f x + g x)" | |
| 3438 | unfolding continuous_on_eq_continuous_within using continuous_add by blast | |
| 3439 | ||
| 3440 | lemma continuous_on_sub: | |
| 3441 | fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3442 | shows "continuous_on s f \<Longrightarrow> continuous_on s g | |
| 3443 | \<Longrightarrow> continuous_on s (\<lambda>x. f x - g x)" | |
| 3444 | unfolding continuous_on_eq_continuous_within using continuous_sub by blast | |
| 3445 | ||
| 3446 | text{* Same thing for uniform continuity, using sequential formulations. *}
 | |
| 3447 | ||
| 3448 | lemma uniformly_continuous_on_const: | |
| 3449 | "uniformly_continuous_on s (\<lambda>x. c)" | |
| 3450 | unfolding uniformly_continuous_on_def by simp | |
| 3451 | ||
| 3452 | lemma uniformly_continuous_on_cmul: | |
| 3453 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" | |
| 3454 | (* FIXME: generalize 'a to metric_space *) | |
| 3455 | assumes "uniformly_continuous_on s f" | |
| 3456 | shows "uniformly_continuous_on s (\<lambda>x. c *\<^sub>R f(x))" | |
| 3457 | proof- | |
| 3458 |   { fix x y assume "((\<lambda>n. f (x n) - f (y n)) ---> 0) sequentially"
 | |
| 3459 | hence "((\<lambda>n. c *\<^sub>R f (x n) - c *\<^sub>R f (y n)) ---> 0) sequentially" | |
| 3460 | using Lim_cmul[of "(\<lambda>n. f (x n) - f (y n))" 0 sequentially c] | |
| 3461 | unfolding scaleR_zero_right scaleR_right_diff_distrib by auto | |
| 3462 | } | |
| 3463 | thus ?thesis using assms unfolding uniformly_continuous_on_sequentially by auto | |
| 3464 | qed | |
| 3465 | ||
| 3466 | lemma dist_minus: | |
| 3467 | fixes x y :: "'a::real_normed_vector" | |
| 3468 | shows "dist (- x) (- y) = dist x y" | |
| 3469 | unfolding dist_norm minus_diff_minus norm_minus_cancel .. | |
| 3470 | ||
| 3471 | lemma uniformly_continuous_on_neg: | |
| 3472 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3473 | shows "uniformly_continuous_on s f | |
| 3474 | ==> uniformly_continuous_on s (\<lambda>x. -(f x))" | |
| 3475 | unfolding uniformly_continuous_on_def dist_minus . | |
| 3476 | ||
| 3477 | lemma uniformly_continuous_on_add: | |
| 3478 | fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" (* FIXME: generalize 'a *) | |
| 3479 | assumes "uniformly_continuous_on s f" "uniformly_continuous_on s g" | |
| 3480 | shows "uniformly_continuous_on s (\<lambda>x. f x + g x)" | |
| 3481 | proof- | |
| 3482 |   {  fix x y assume "((\<lambda>n. f (x n) - f (y n)) ---> 0) sequentially"
 | |
| 3483 | "((\<lambda>n. g (x n) - g (y n)) ---> 0) sequentially" | |
| 3484 | hence "((\<lambda>xa. f (x xa) - f (y xa) + (g (x xa) - g (y xa))) ---> 0 + 0) sequentially" | |
| 3485 | using Lim_add[of "\<lambda> n. f (x n) - f (y n)" 0 sequentially "\<lambda> n. g (x n) - g (y n)" 0] by auto | |
| 3486 | hence "((\<lambda>n. f (x n) + g (x n) - (f (y n) + g (y n))) ---> 0) sequentially" unfolding Lim_sequentially and add_diff_add [symmetric] by auto } | |
| 3487 | thus ?thesis using assms unfolding uniformly_continuous_on_sequentially by auto | |
| 3488 | qed | |
| 3489 | ||
| 3490 | lemma uniformly_continuous_on_sub: | |
| 3491 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" (* FIXME: generalize 'a *) | |
| 3492 | shows "uniformly_continuous_on s f \<Longrightarrow> uniformly_continuous_on s g | |
| 3493 | ==> uniformly_continuous_on s (\<lambda>x. f x - g x)" | |
| 3494 | unfolding ab_diff_minus | |
| 3495 | using uniformly_continuous_on_add[of s f "\<lambda>x. - g x"] | |
| 3496 | using uniformly_continuous_on_neg[of s g] by auto | |
| 3497 | ||
| 3498 | text{* Identity function is continuous in every sense. *}
 | |
| 3499 | ||
| 3500 | lemma continuous_within_id: | |
| 3501 | "continuous (at a within s) (\<lambda>x. x)" | |
| 3502 | unfolding continuous_within by (rule Lim_at_within [OF Lim_ident_at]) | |
| 3503 | ||
| 3504 | lemma continuous_at_id: | |
| 3505 | "continuous (at a) (\<lambda>x. x)" | |
| 3506 | unfolding continuous_at by (rule Lim_ident_at) | |
| 3507 | ||
| 3508 | lemma continuous_on_id: | |
| 3509 | "continuous_on s (\<lambda>x. x)" | |
| 3510 | unfolding continuous_on Lim_within by auto | |
| 3511 | ||
| 3512 | lemma uniformly_continuous_on_id: | |
| 3513 | "uniformly_continuous_on s (\<lambda>x. x)" | |
| 3514 | unfolding uniformly_continuous_on_def by auto | |
| 3515 | ||
| 3516 | text{* Continuity of all kinds is preserved under composition. *}
 | |
| 3517 | ||
| 3518 | lemma continuous_within_compose: | |
| 3519 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3520 | fixes g :: "'b::metric_space \<Rightarrow> 'c::metric_space" | |
| 3521 | assumes "continuous (at x within s) f" "continuous (at (f x) within f ` s) g" | |
| 3522 | shows "continuous (at x within s) (g o f)" | |
| 3523 | proof- | |
| 3524 |   { fix e::real assume "e>0"
 | |
| 3525 | with assms(2)[unfolded continuous_within Lim_within] obtain d where "d>0" and d:"\<forall>xa\<in>f ` s. 0 < dist xa (f x) \<and> dist xa (f x) < d \<longrightarrow> dist (g xa) (g (f x)) < e" by auto | |
| 3526 | from assms(1)[unfolded continuous_within Lim_within] obtain d' where "d'>0" and d':"\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d' \<longrightarrow> dist (f xa) (f x) < d" using `d>0` by auto | |
| 3527 |     { fix y assume as:"y\<in>s"  "0 < dist y x"  "dist y x < d'"
 | |
| 3528 | hence "dist (f y) (f x) < d" using d'[THEN bspec[where x=y]] by (auto simp add:dist_commute) | |
| 3529 | hence "dist (g (f y)) (g (f x)) < e" using as(1) d[THEN bspec[where x="f y"]] unfolding dist_nz[THEN sym] using `e>0` by auto } | |
| 3530 | hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (g (f xa)) (g (f x)) < e" using `d'>0` by auto } | |
| 3531 | thus ?thesis unfolding continuous_within Lim_within by auto | |
| 3532 | qed | |
| 3533 | ||
| 3534 | lemma continuous_at_compose: | |
| 3535 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3536 | fixes g :: "'b::metric_space \<Rightarrow> 'c::metric_space" | |
| 3537 | assumes "continuous (at x) f" "continuous (at (f x)) g" | |
| 3538 | shows "continuous (at x) (g o f)" | |
| 3539 | proof- | |
| 3540 | have " continuous (at (f x) within range f) g" using assms(2) using continuous_within_subset[of "f x" UNIV g "range f", unfolded within_UNIV] by auto | |
| 3541 | thus ?thesis using assms(1) using continuous_within_compose[of x UNIV f g, unfolded within_UNIV] by auto | |
| 3542 | qed | |
| 3543 | ||
| 3544 | lemma continuous_on_compose: | |
| 3545 | "continuous_on s f \<Longrightarrow> continuous_on (f ` s) g \<Longrightarrow> continuous_on s (g o f)" | |
| 3546 | unfolding continuous_on_eq_continuous_within using continuous_within_compose[of _ s f g] by auto | |
| 3547 | ||
| 3548 | lemma uniformly_continuous_on_compose: | |
| 3549 | assumes "uniformly_continuous_on s f" "uniformly_continuous_on (f ` s) g" | |
| 3550 | shows "uniformly_continuous_on s (g o f)" | |
| 3551 | proof- | |
| 3552 |   { fix e::real assume "e>0"
 | |
| 3553 | then obtain d where "d>0" and d:"\<forall>x\<in>f ` s. \<forall>x'\<in>f ` s. dist x' x < d \<longrightarrow> dist (g x') (g x) < e" using assms(2) unfolding uniformly_continuous_on_def by auto | |
| 3554 | obtain d' where "d'>0" "\<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d' \<longrightarrow> dist (f x') (f x) < d" using `d>0` using assms(1) unfolding uniformly_continuous_on_def by auto | |
| 3555 | hence "\<exists>d>0. \<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist ((g \<circ> f) x') ((g \<circ> f) x) < e" using `d>0` using d by auto } | |
| 3556 | thus ?thesis using assms unfolding uniformly_continuous_on_def by auto | |
| 3557 | qed | |
| 3558 | ||
| 3559 | text{* Continuity in terms of open preimages. *}
 | |
| 3560 | ||
| 3561 | lemma continuous_at_open: | |
| 3562 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3563 | shows "continuous (at x) f \<longleftrightarrow> (\<forall>t. open t \<and> f x \<in> t --> (\<exists>s. open s \<and> x \<in> s \<and> (\<forall>x' \<in> s. (f x') \<in> t)))" (is "?lhs = ?rhs") | |
| 3564 | proof | |
| 3565 | assume ?lhs | |
| 3566 |   { fix t assume as: "open t" "f x \<in> t"
 | |
| 3567 | then obtain e where "e>0" and e:"ball (f x) e \<subseteq> t" unfolding open_contains_ball by auto | |
| 3568 | ||
| 3569 | obtain d where "d>0" and d:"\<forall>y. 0 < dist y x \<and> dist y x < d \<longrightarrow> dist (f y) (f x) < e" using `e>0` using `?lhs`[unfolded continuous_at Lim_at open_dist] by auto | |
| 3570 | ||
| 3571 | have "open (ball x d)" using open_ball by auto | |
| 3572 | moreover have "x \<in> ball x d" unfolding centre_in_ball using `d>0` by simp | |
| 3573 | moreover | |
| 3574 |     { fix x' assume "x'\<in>ball x d" hence "f x' \<in> t"
 | |
| 3575 | using e[unfolded subset_eq Ball_def mem_ball, THEN spec[where x="f x'"]] d[THEN spec[where x=x']] | |
| 3576 | unfolding mem_ball apply (auto simp add: dist_commute) | |
| 3577 | unfolding dist_nz[THEN sym] using as(2) by auto } | |
| 3578 | hence "\<forall>x'\<in>ball x d. f x' \<in> t" by auto | |
| 3579 | ultimately have "\<exists>s. open s \<and> x \<in> s \<and> (\<forall>x'\<in>s. f x' \<in> t)" | |
| 3580 | apply(rule_tac x="ball x d" in exI) by simp } | |
| 3581 | thus ?rhs by auto | |
| 3582 | next | |
| 3583 | assume ?rhs | |
| 3584 |   { fix e::real assume "e>0"
 | |
| 3585 | then obtain s where s: "open s" "x \<in> s" "\<forall>x'\<in>s. f x' \<in> ball (f x) e" using `?rhs`[unfolded continuous_at Lim_at, THEN spec[where x="ball (f x) e"]] | |
| 3586 | unfolding centre_in_ball[of "f x" e, THEN sym] by auto | |
| 3587 | then obtain d where "d>0" and d:"ball x d \<subseteq> s" unfolding open_contains_ball by auto | |
| 3588 |     { fix y assume "0 < dist y x \<and> dist y x < d"
 | |
| 3589 | hence "dist (f y) (f x) < e" using d[unfolded subset_eq Ball_def mem_ball, THEN spec[where x=y]] | |
| 3590 | using s(3)[THEN bspec[where x=y], unfolded mem_ball] by (auto simp add: dist_commute) } | |
| 3591 | hence "\<exists>d>0. \<forall>xa. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" using `d>0` by auto } | |
| 3592 | thus ?lhs unfolding continuous_at Lim_at by auto | |
| 3593 | qed | |
| 3594 | ||
| 3595 | lemma continuous_on_open: | |
| 3596 | "continuous_on s f \<longleftrightarrow> | |
| 3597 | (\<forall>t. openin (subtopology euclidean (f ` s)) t | |
| 3598 |             --> openin (subtopology euclidean s) {x \<in> s. f x \<in> t})" (is "?lhs = ?rhs")
 | |
| 3599 | proof | |
| 3600 | assume ?lhs | |
| 3601 |   { fix t assume as:"openin (subtopology euclidean (f ` s)) t"
 | |
| 3602 |     have "{x \<in> s. f x \<in> t} \<subseteq> s" using as[unfolded openin_euclidean_subtopology_iff] by auto
 | |
| 3603 | moreover | |
| 3604 |     { fix x assume as':"x\<in>{x \<in> s. f x \<in> t}"
 | |
| 3605 | then obtain e where e: "e>0" "\<forall>x'\<in>f ` s. dist x' (f x) < e \<longrightarrow> x' \<in> t" using as[unfolded openin_euclidean_subtopology_iff, THEN conjunct2, THEN bspec[where x="f x"]] by auto | |
| 3606 | from this(1) obtain d where d: "d>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" using `?lhs`[unfolded continuous_on Lim_within, THEN bspec[where x=x]] using as' by auto | |
| 3607 |       have "\<exists>e>0. \<forall>x'\<in>s. dist x' x < e \<longrightarrow> x' \<in> {x \<in> s. f x \<in> t}" using d e unfolding dist_nz[THEN sym] by (rule_tac x=d in exI, auto)  }
 | |
| 3608 |     ultimately have "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}" unfolding openin_euclidean_subtopology_iff by auto  }
 | |
| 3609 | thus ?rhs unfolding continuous_on Lim_within using openin by auto | |
| 3610 | next | |
| 3611 | assume ?rhs | |
| 3612 |   { fix e::real and x assume "x\<in>s" "e>0"
 | |
| 3613 |     { fix xa x' assume "dist (f xa) (f x) < e" "xa \<in> s" "x' \<in> s" "dist (f xa) (f x') < e - dist (f xa) (f x)"
 | |
| 3614 | hence "dist (f x') (f x) < e" using dist_triangle[of "f x'" "f x" "f xa"] | |
| 3615 | by (auto simp add: dist_commute) } | |
| 3616 | hence "ball (f x) e \<inter> f ` s \<subseteq> f ` s \<and> (\<forall>xa\<in>ball (f x) e \<inter> f ` s. \<exists>ea>0. \<forall>x'\<in>f ` s. dist x' xa < ea \<longrightarrow> x' \<in> ball (f x) e \<inter> f ` s)" apply auto | |
| 3617 | apply(rule_tac x="e - dist (f xa) (f x)" in exI) using `e>0` by (auto simp add: dist_commute) | |
| 3618 |     hence "\<forall>xa\<in>{xa \<in> s. f xa \<in> ball (f x) e \<inter> f ` s}. \<exists>ea>0. \<forall>x'\<in>s. dist x' xa < ea \<longrightarrow> x' \<in> {xa \<in> s. f xa \<in> ball (f x) e \<inter> f ` s}"
 | |
| 3619 | using `?rhs`[unfolded openin_euclidean_subtopology_iff, THEN spec[where x="ball (f x) e \<inter> f ` s"]] by auto | |
| 3620 | hence "\<exists>d>0. \<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e" apply(erule_tac x=x in ballE) apply auto using `e>0` `x\<in>s` by (auto simp add: dist_commute) } | |
| 3621 | thus ?lhs unfolding continuous_on Lim_within by auto | |
| 3622 | qed | |
| 3623 | ||
| 3624 | (* ------------------------------------------------------------------------- *) | |
| 3625 | (* Similarly in terms of closed sets. *) | |
| 3626 | (* ------------------------------------------------------------------------- *) | |
| 3627 | ||
| 3628 | lemma continuous_on_closed: | |
| 3629 |  "continuous_on s f \<longleftrightarrow>  (\<forall>t. closedin (subtopology euclidean (f ` s)) t  --> closedin (subtopology euclidean s) {x \<in> s. f x \<in> t})" (is "?lhs = ?rhs")
 | |
| 3630 | proof | |
| 3631 | assume ?lhs | |
| 3632 |   { fix t
 | |
| 3633 |     have *:"s - {x \<in> s. f x \<in> f ` s - t} = {x \<in> s. f x \<in> t}" by auto
 | |
| 3634 | have **:"f ` s - (f ` s - (f ` s - t)) = f ` s - t" by auto | |
| 3635 | assume as:"closedin (subtopology euclidean (f ` s)) t" | |
| 3636 | hence "closedin (subtopology euclidean (f ` s)) (f ` s - (f ` s - t))" unfolding closedin_def topspace_euclidean_subtopology unfolding ** by auto | |
| 3637 |     hence "closedin (subtopology euclidean s) {x \<in> s. f x \<in> t}" using `?lhs`[unfolded continuous_on_open, THEN spec[where x="(f ` s) - t"]]
 | |
| 3638 | unfolding openin_closedin_eq topspace_euclidean_subtopology unfolding * by auto } | |
| 3639 | thus ?rhs by auto | |
| 3640 | next | |
| 3641 | assume ?rhs | |
| 3642 |   { fix t
 | |
| 3643 |     have *:"s - {x \<in> s. f x \<in> f ` s - t} = {x \<in> s. f x \<in> t}" by auto
 | |
| 3644 | assume as:"openin (subtopology euclidean (f ` s)) t" | |
| 3645 |     hence "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}" using `?rhs`[THEN spec[where x="(f ` s) - t"]]
 | |
| 3646 | unfolding openin_closedin_eq topspace_euclidean_subtopology *[THEN sym] closedin_subtopology by auto } | |
| 3647 | thus ?lhs unfolding continuous_on_open by auto | |
| 3648 | qed | |
| 3649 | ||
| 3650 | text{* Half-global and completely global cases.                                  *}
 | |
| 3651 | ||
| 3652 | lemma continuous_open_in_preimage: | |
| 3653 | assumes "continuous_on s f" "open t" | |
| 3654 |   shows "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}"
 | |
| 3655 | proof- | |
| 3656 | have *:"\<forall>x. x \<in> s \<and> f x \<in> t \<longleftrightarrow> x \<in> s \<and> f x \<in> (t \<inter> f ` s)" by auto | |
| 3657 | have "openin (subtopology euclidean (f ` s)) (t \<inter> f ` s)" | |
| 3658 | using openin_open_Int[of t "f ` s", OF assms(2)] unfolding openin_open by auto | |
| 3659 | thus ?thesis using assms(1)[unfolded continuous_on_open, THEN spec[where x="t \<inter> f ` s"]] using * by auto | |
| 3660 | qed | |
| 3661 | ||
| 3662 | lemma continuous_closed_in_preimage: | |
| 3663 | assumes "continuous_on s f" "closed t" | |
| 3664 |   shows "closedin (subtopology euclidean s) {x \<in> s. f x \<in> t}"
 | |
| 3665 | proof- | |
| 3666 | have *:"\<forall>x. x \<in> s \<and> f x \<in> t \<longleftrightarrow> x \<in> s \<and> f x \<in> (t \<inter> f ` s)" by auto | |
| 3667 | have "closedin (subtopology euclidean (f ` s)) (t \<inter> f ` s)" | |
| 3668 | using closedin_closed_Int[of t "f ` s", OF assms(2)] unfolding Int_commute by auto | |
| 3669 | thus ?thesis | |
| 3670 | using assms(1)[unfolded continuous_on_closed, THEN spec[where x="t \<inter> f ` s"]] using * by auto | |
| 3671 | qed | |
| 3672 | ||
| 3673 | lemma continuous_open_preimage: | |
| 3674 | assumes "continuous_on s f" "open s" "open t" | |
| 3675 |   shows "open {x \<in> s. f x \<in> t}"
 | |
| 3676 | proof- | |
| 3677 |   obtain T where T: "open T" "{x \<in> s. f x \<in> t} = s \<inter> T"
 | |
| 3678 | using continuous_open_in_preimage[OF assms(1,3)] unfolding openin_open by auto | |
| 3679 | thus ?thesis using open_Int[of s T, OF assms(2)] by auto | |
| 3680 | qed | |
| 3681 | ||
| 3682 | lemma continuous_closed_preimage: | |
| 3683 | assumes "continuous_on s f" "closed s" "closed t" | |
| 3684 |   shows "closed {x \<in> s. f x \<in> t}"
 | |
| 3685 | proof- | |
| 3686 |   obtain T where T: "closed T" "{x \<in> s. f x \<in> t} = s \<inter> T"
 | |
| 3687 | using continuous_closed_in_preimage[OF assms(1,3)] unfolding closedin_closed by auto | |
| 3688 | thus ?thesis using closed_Int[of s T, OF assms(2)] by auto | |
| 3689 | qed | |
| 3690 | ||
| 3691 | lemma continuous_open_preimage_univ: | |
| 3692 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3693 |   shows "\<forall>x. continuous (at x) f \<Longrightarrow> open s \<Longrightarrow> open {x. f x \<in> s}"
 | |
| 3694 | using continuous_open_preimage[of UNIV f s] open_UNIV continuous_at_imp_continuous_on by auto | |
| 3695 | ||
| 3696 | lemma continuous_closed_preimage_univ: | |
| 3697 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3698 |   shows "(\<forall>x. continuous (at x) f) \<Longrightarrow> closed s ==> closed {x. f x \<in> s}"
 | |
| 3699 | using continuous_closed_preimage[of UNIV f s] closed_UNIV continuous_at_imp_continuous_on by auto | |
| 3700 | ||
| 3701 | lemma continuous_open_vimage: | |
| 3702 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3703 | shows "\<forall>x. continuous (at x) f \<Longrightarrow> open s \<Longrightarrow> open (f -` s)" | |
| 3704 | unfolding vimage_def by (rule continuous_open_preimage_univ) | |
| 3705 | ||
| 3706 | lemma continuous_closed_vimage: | |
| 3707 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3708 | shows "\<forall>x. continuous (at x) f \<Longrightarrow> closed s \<Longrightarrow> closed (f -` s)" | |
| 3709 | unfolding vimage_def by (rule continuous_closed_preimage_univ) | |
| 3710 | ||
| 3711 | text{* Equality of continuous functions on closure and related results.          *}
 | |
| 3712 | ||
| 3713 | lemma continuous_closed_in_preimage_constant: | |
| 3714 |  "continuous_on s f ==> closedin (subtopology euclidean s) {x \<in> s. f x = a}"
 | |
| 3715 |   using continuous_closed_in_preimage[of s f "{a}"] closed_sing by auto
 | |
| 3716 | ||
| 3717 | lemma continuous_closed_preimage_constant: | |
| 3718 |  "continuous_on s f \<Longrightarrow> closed s ==> closed {x \<in> s. f x = a}"
 | |
| 3719 |   using continuous_closed_preimage[of s f "{a}"] closed_sing by auto
 | |
| 3720 | ||
| 3721 | lemma continuous_constant_on_closure: | |
| 3722 | assumes "continuous_on (closure s) f" | |
| 3723 | "\<forall>x \<in> s. f x = a" | |
| 3724 | shows "\<forall>x \<in> (closure s). f x = a" | |
| 3725 | using continuous_closed_preimage_constant[of "closure s" f a] | |
| 3726 |     assms closure_minimal[of s "{x \<in> closure s. f x = a}"] closure_subset unfolding subset_eq by auto
 | |
| 3727 | ||
| 3728 | lemma image_closure_subset: | |
| 3729 | assumes "continuous_on (closure s) f" "closed t" "(f ` s) \<subseteq> t" | |
| 3730 | shows "f ` (closure s) \<subseteq> t" | |
| 3731 | proof- | |
| 3732 |   have "s \<subseteq> {x \<in> closure s. f x \<in> t}" using assms(3) closure_subset by auto
 | |
| 3733 |   moreover have "closed {x \<in> closure s. f x \<in> t}"
 | |
| 3734 | using continuous_closed_preimage[OF assms(1)] and assms(2) by auto | |
| 3735 |   ultimately have "closure s = {x \<in> closure s . f x \<in> t}"
 | |
| 3736 |     using closure_minimal[of s "{x \<in> closure s. f x \<in> t}"] by auto
 | |
| 3737 | thus ?thesis by auto | |
| 3738 | qed | |
| 3739 | ||
| 3740 | lemma continuous_on_closure_norm_le: | |
| 3741 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3742 | assumes "continuous_on (closure s) f" "\<forall>y \<in> s. norm(f y) \<le> b" "x \<in> (closure s)" | |
| 3743 | shows "norm(f x) \<le> b" | |
| 3744 | proof- | |
| 3745 | have *:"f ` s \<subseteq> cball 0 b" using assms(2)[unfolded mem_cball_0[THEN sym]] by auto | |
| 3746 | show ?thesis | |
| 3747 | using image_closure_subset[OF assms(1) closed_cball[of 0 b] *] assms(3) | |
| 3748 | unfolding subset_eq apply(erule_tac x="f x" in ballE) by (auto simp add: dist_norm) | |
| 3749 | qed | |
| 3750 | ||
| 3751 | text{* Making a continuous function avoid some value in a neighbourhood.         *}
 | |
| 3752 | ||
| 3753 | lemma continuous_within_avoid: | |
| 3754 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3755 | assumes "continuous (at x within s) f" "x \<in> s" "f x \<noteq> a" | |
| 3756 | shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e --> f y \<noteq> a" | |
| 3757 | proof- | |
| 3758 | obtain d where "d>0" and d:"\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < dist (f x) a" | |
| 3759 | using assms(1)[unfolded continuous_within Lim_within, THEN spec[where x="dist (f x) a"]] assms(3)[unfolded dist_nz] by auto | |
| 3760 |   { fix y assume " y\<in>s"  "dist x y < d"
 | |
| 3761 | hence "f y \<noteq> a" using d[THEN bspec[where x=y]] assms(3)[unfolded dist_nz] | |
| 3762 | apply auto unfolding dist_nz[THEN sym] by (auto simp add: dist_commute) } | |
| 3763 | thus ?thesis using `d>0` by auto | |
| 3764 | qed | |
| 3765 | ||
| 3766 | lemma continuous_at_avoid: | |
| 3767 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3768 | assumes "continuous (at x) f" "f x \<noteq> a" | |
| 3769 | shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" | |
| 3770 | using assms using continuous_within_avoid[of x UNIV f a, unfolded within_UNIV] by auto | |
| 3771 | ||
| 3772 | lemma continuous_on_avoid: | |
| 3773 | assumes "continuous_on s f" "x \<in> s" "f x \<noteq> a" | |
| 3774 | shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e \<longrightarrow> f y \<noteq> a" | |
| 3775 | using assms(1)[unfolded continuous_on_eq_continuous_within, THEN bspec[where x=x], OF assms(2)] continuous_within_avoid[of x s f a] assms(2,3) by auto | |
| 3776 | ||
| 3777 | lemma continuous_on_open_avoid: | |
| 3778 | assumes "continuous_on s f" "open s" "x \<in> s" "f x \<noteq> a" | |
| 3779 | shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" | |
| 3780 | using assms(1)[unfolded continuous_on_eq_continuous_at[OF assms(2)], THEN bspec[where x=x], OF assms(3)] continuous_at_avoid[of x f a] assms(3,4) by auto | |
| 3781 | ||
| 3782 | text{* Proving a function is constant by proving open-ness of level set.         *}
 | |
| 3783 | ||
| 3784 | lemma continuous_levelset_open_in_cases: | |
| 3785 | "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow> | |
| 3786 |         openin (subtopology euclidean s) {x \<in> s. f x = a}
 | |
| 3787 | ==> (\<forall>x \<in> s. f x \<noteq> a) \<or> (\<forall>x \<in> s. f x = a)" | |
| 3788 | unfolding connected_clopen using continuous_closed_in_preimage_constant by auto | |
| 3789 | ||
| 3790 | lemma continuous_levelset_open_in: | |
| 3791 | "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow> | |
| 3792 |         openin (subtopology euclidean s) {x \<in> s. f x = a} \<Longrightarrow>
 | |
| 3793 | (\<exists>x \<in> s. f x = a) ==> (\<forall>x \<in> s. f x = a)" | |
| 3794 | using continuous_levelset_open_in_cases[of s f ] | |
| 3795 | by meson | |
| 3796 | ||
| 3797 | lemma continuous_levelset_open: | |
| 3798 |   assumes "connected s"  "continuous_on s f"  "open {x \<in> s. f x = a}"  "\<exists>x \<in> s.  f x = a"
 | |
| 3799 | shows "\<forall>x \<in> s. f x = a" | |
| 3800 | using continuous_levelset_open_in[OF assms(1,2), of a, unfolded openin_open] using assms (3,4) by auto | |
| 3801 | ||
| 3802 | text{* Some arithmetical combinations (more to prove).                           *}
 | |
| 3803 | ||
| 3804 | lemma open_scaling[intro]: | |
| 3805 | fixes s :: "'a::real_normed_vector set" | |
| 3806 | assumes "c \<noteq> 0" "open s" | |
| 3807 | shows "open((\<lambda>x. c *\<^sub>R x) ` s)" | |
| 3808 | proof- | |
| 3809 |   { fix x assume "x \<in> s"
 | |
| 3810 | then obtain e where "e>0" and e:"\<forall>x'. dist x' x < e \<longrightarrow> x' \<in> s" using assms(2)[unfolded open_dist, THEN bspec[where x=x]] by auto | |
| 3811 | have "e * abs c > 0" using assms(1)[unfolded zero_less_abs_iff[THEN sym]] using real_mult_order[OF `e>0`] by auto | |
| 3812 | moreover | |
| 3813 |     { fix y assume "dist y (c *\<^sub>R x) < e * \<bar>c\<bar>"
 | |
| 3814 | hence "norm ((1 / c) *\<^sub>R y - x) < e" unfolding dist_norm | |
| 3815 | using norm_scaleR[of c "(1 / c) *\<^sub>R y - x", unfolded scaleR_right_diff_distrib, unfolded scaleR_scaleR] assms(1) | |
| 3816 | assms(1)[unfolded zero_less_abs_iff[THEN sym]] by (simp del:zero_less_abs_iff) | |
| 3817 | hence "y \<in> op *\<^sub>R c ` s" using rev_image_eqI[of "(1 / c) *\<^sub>R y" s y "op *\<^sub>R c"] e[THEN spec[where x="(1 / c) *\<^sub>R y"]] assms(1) unfolding dist_norm scaleR_scaleR by auto } | |
| 3818 | ultimately have "\<exists>e>0. \<forall>x'. dist x' (c *\<^sub>R x) < e \<longrightarrow> x' \<in> op *\<^sub>R c ` s" apply(rule_tac x="e * abs c" in exI) by auto } | |
| 3819 | thus ?thesis unfolding open_dist by auto | |
| 3820 | qed | |
| 3821 | ||
| 3822 | lemma minus_image_eq_vimage: | |
| 3823 | fixes A :: "'a::ab_group_add set" | |
| 3824 | shows "(\<lambda>x. - x) ` A = (\<lambda>x. - x) -` A" | |
| 3825 | by (auto intro!: image_eqI [where f="\<lambda>x. - x"]) | |
| 3826 | ||
| 3827 | lemma open_negations: | |
| 3828 | fixes s :: "'a::real_normed_vector set" | |
| 3829 | shows "open s ==> open ((\<lambda> x. -x) ` s)" | |
| 3830 | unfolding scaleR_minus1_left [symmetric] | |
| 3831 | by (rule open_scaling, auto) | |
| 3832 | ||
| 3833 | lemma open_translation: | |
| 3834 | fixes s :: "'a::real_normed_vector set" | |
| 3835 | assumes "open s" shows "open((\<lambda>x. a + x) ` s)" | |
| 3836 | proof- | |
| 3837 |   { fix x have "continuous (at x) (\<lambda>x. x - a)" using continuous_sub[of "at x" "\<lambda>x. x" "\<lambda>x. a"] continuous_at_id[of x] continuous_const[of "at x" a] by auto  }
 | |
| 3838 |   moreover have "{x. x - a \<in> s}  = op + a ` s" apply auto unfolding image_iff apply(rule_tac x="x - a" in bexI) by auto
 | |
| 3839 | ultimately show ?thesis using continuous_open_preimage_univ[of "\<lambda>x. x - a" s] using assms by auto | |
| 3840 | qed | |
| 3841 | ||
| 3842 | lemma open_affinity: | |
| 3843 | fixes s :: "'a::real_normed_vector set" | |
| 3844 | assumes "open s" "c \<noteq> 0" | |
| 3845 | shows "open ((\<lambda>x. a + c *\<^sub>R x) ` s)" | |
| 3846 | proof- | |
| 3847 | have *:"(\<lambda>x. a + c *\<^sub>R x) = (\<lambda>x. a + x) \<circ> (\<lambda>x. c *\<^sub>R x)" unfolding o_def .. | |
| 3848 | have "op + a ` op *\<^sub>R c ` s = (op + a \<circ> op *\<^sub>R c) ` s" by auto | |
| 3849 | thus ?thesis using assms open_translation[of "op *\<^sub>R c ` s" a] unfolding * by auto | |
| 3850 | qed | |
| 3851 | ||
| 3852 | lemma interior_translation: | |
| 3853 | fixes s :: "'a::real_normed_vector set" | |
| 3854 | shows "interior ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (interior s)" | |
| 3855 | proof (rule set_ext, rule) | |
| 3856 | fix x assume "x \<in> interior (op + a ` s)" | |
| 3857 | then obtain e where "e>0" and e:"ball x e \<subseteq> op + a ` s" unfolding mem_interior by auto | |
| 3858 | hence "ball (x - a) e \<subseteq> s" unfolding subset_eq Ball_def mem_ball dist_norm apply auto apply(erule_tac x="a + xa" in allE) unfolding ab_group_add_class.diff_diff_eq[THEN sym] by auto | |
| 3859 | thus "x \<in> op + a ` interior s" unfolding image_iff apply(rule_tac x="x - a" in bexI) unfolding mem_interior using `e > 0` by auto | |
| 3860 | next | |
| 3861 | fix x assume "x \<in> op + a ` interior s" | |
| 3862 | then obtain y e where "e>0" and e:"ball y e \<subseteq> s" and y:"x = a + y" unfolding image_iff Bex_def mem_interior by auto | |
| 3863 |   { fix z have *:"a + y - z = y + a - z" by auto
 | |
| 3864 | assume "z\<in>ball x e" | |
| 3865 | hence "z - a \<in> s" using e[unfolded subset_eq, THEN bspec[where x="z - a"]] unfolding mem_ball dist_norm y ab_group_add_class.diff_diff_eq2 * by auto | |
| 3866 | hence "z \<in> op + a ` s" unfolding image_iff by(auto intro!: bexI[where x="z - a"]) } | |
| 3867 | hence "ball x e \<subseteq> op + a ` s" unfolding subset_eq by auto | |
| 3868 | thus "x \<in> interior (op + a ` s)" unfolding mem_interior using `e>0` by auto | |
| 3869 | qed | |
| 3870 | ||
| 3871 | subsection {* Preservation of compactness and connectedness under continuous function.  *}
 | |
| 3872 | ||
| 3873 | lemma compact_continuous_image: | |
| 3874 | assumes "continuous_on s f" "compact s" | |
| 3875 | shows "compact(f ` s)" | |
| 3876 | proof- | |
| 3877 |   { fix x assume x:"\<forall>n::nat. x n \<in> f ` s"
 | |
| 3878 | then obtain y where y:"\<forall>n. y n \<in> s \<and> x n = f (y n)" unfolding image_iff Bex_def using choice[of "\<lambda>n xa. xa \<in> s \<and> x n = f xa"] by auto | |
| 3879 | then obtain l r where "l\<in>s" and r:"subseq r" and lr:"((y \<circ> r) ---> l) sequentially" using assms(2)[unfolded compact_def, THEN spec[where x=y]] by auto | |
| 3880 |     { fix e::real assume "e>0"
 | |
| 3881 | then obtain d where "d>0" and d:"\<forall>x'\<in>s. dist x' l < d \<longrightarrow> dist (f x') (f l) < e" using assms(1)[unfolded continuous_on_def, THEN bspec[where x=l], OF `l\<in>s`] by auto | |
| 3882 | then obtain N::nat where N:"\<forall>n\<ge>N. dist ((y \<circ> r) n) l < d" using lr[unfolded Lim_sequentially, THEN spec[where x=d]] by auto | |
| 3883 |       { fix n::nat assume "n\<ge>N" hence "dist ((x \<circ> r) n) (f l) < e" using N[THEN spec[where x=n]] d[THEN bspec[where x="y (r n)"]] y[THEN spec[where x="r n"]] by auto  }
 | |
| 3884 | hence "\<exists>N. \<forall>n\<ge>N. dist ((x \<circ> r) n) (f l) < e" by auto } | |
| 3885 | hence "\<exists>l\<in>f ` s. \<exists>r. subseq r \<and> ((x \<circ> r) ---> l) sequentially" unfolding Lim_sequentially using r lr `l\<in>s` by auto } | |
| 3886 | thus ?thesis unfolding compact_def by auto | |
| 3887 | qed | |
| 3888 | ||
| 3889 | lemma connected_continuous_image: | |
| 3890 | assumes "continuous_on s f" "connected s" | |
| 3891 | shows "connected(f ` s)" | |
| 3892 | proof- | |
| 3893 |   { fix T assume as: "T \<noteq> {}"  "T \<noteq> f ` s"  "openin (subtopology euclidean (f ` s)) T"  "closedin (subtopology euclidean (f ` s)) T"
 | |
| 3894 |     have "{x \<in> s. f x \<in> T} = {} \<or> {x \<in> s. f x \<in> T} = s"
 | |
| 3895 | using assms(1)[unfolded continuous_on_open, THEN spec[where x=T]] | |
| 3896 | using assms(1)[unfolded continuous_on_closed, THEN spec[where x=T]] | |
| 3897 |       using assms(2)[unfolded connected_clopen, THEN spec[where x="{x \<in> s. f x \<in> T}"]] as(3,4) by auto
 | |
| 3898 | hence False using as(1,2) | |
| 3899 | using as(4)[unfolded closedin_def topspace_euclidean_subtopology] by auto } | |
| 3900 | thus ?thesis unfolding connected_clopen by auto | |
| 3901 | qed | |
| 3902 | ||
| 3903 | text{* Continuity implies uniform continuity on a compact domain.                *}
 | |
| 3904 | ||
| 3905 | lemma compact_uniformly_continuous: | |
| 3906 | assumes "continuous_on s f" "compact s" | |
| 3907 | shows "uniformly_continuous_on s f" | |
| 3908 | proof- | |
| 3909 |     { fix x assume x:"x\<in>s"
 | |
| 3910 | hence "\<forall>xa. \<exists>y. 0 < xa \<longrightarrow> (y > 0 \<and> (\<forall>x'\<in>s. dist x' x < y \<longrightarrow> dist (f x') (f x) < xa))" using assms(1)[unfolded continuous_on_def, THEN bspec[where x=x]] by auto | |
| 3911 | hence "\<exists>fa. \<forall>xa>0. \<forall>x'\<in>s. fa xa > 0 \<and> (dist x' x < fa xa \<longrightarrow> dist (f x') (f x) < xa)" using choice[of "\<lambda>e d. e>0 \<longrightarrow> d>0 \<and>(\<forall>x'\<in>s. (dist x' x < d \<longrightarrow> dist (f x') (f x) < e))"] by auto } | |
| 3912 | then have "\<forall>x\<in>s. \<exists>y. \<forall>xa. 0 < xa \<longrightarrow> (\<forall>x'\<in>s. y xa > 0 \<and> (dist x' x < y xa \<longrightarrow> dist (f x') (f x) < xa))" by auto | |
| 3913 | then obtain d where d:"\<forall>e>0. \<forall>x\<in>s. \<forall>x'\<in>s. d x e > 0 \<and> (dist x' x < d x e \<longrightarrow> dist (f x') (f x) < e)" | |
| 3914 | using bchoice[of s "\<lambda>x fa. \<forall>xa>0. \<forall>x'\<in>s. fa xa > 0 \<and> (dist x' x < fa xa \<longrightarrow> dist (f x') (f x) < xa)"] by blast | |
| 3915 | ||
| 3916 |   { fix e::real assume "e>0"
 | |
| 3917 | ||
| 3918 |     { fix x assume "x\<in>s" hence "x \<in> ball x (d x (e / 2))" unfolding centre_in_ball using d[THEN spec[where x="e/2"]] using `e>0` by auto  }
 | |
| 3919 |     hence "s \<subseteq> \<Union>{ball x (d x (e / 2)) |x. x \<in> s}" unfolding subset_eq by auto
 | |
| 3920 | moreover | |
| 3921 |     { fix b assume "b\<in>{ball x (d x (e / 2)) |x. x \<in> s}" hence "open b" by auto  }
 | |
| 3922 |     ultimately obtain ea where "ea>0" and ea:"\<forall>x\<in>s. \<exists>b\<in>{ball x (d x (e / 2)) |x. x \<in> s}. ball x ea \<subseteq> b" using heine_borel_lemma[OF assms(2), of "{ball x (d x (e / 2)) | x. x\<in>s }"] by auto
 | |
| 3923 | ||
| 3924 |     { fix x y assume "x\<in>s" "y\<in>s" and as:"dist y x < ea"
 | |
| 3925 | obtain z where "z\<in>s" and z:"ball x ea \<subseteq> ball z (d z (e / 2))" using ea[THEN bspec[where x=x]] and `x\<in>s` by auto | |
| 3926 | hence "x\<in>ball z (d z (e / 2))" using `ea>0` unfolding subset_eq by auto | |
| 3927 | hence "dist (f z) (f x) < e / 2" using d[THEN spec[where x="e/2"]] and `e>0` and `x\<in>s` and `z\<in>s` | |
| 3928 | by (auto simp add: dist_commute) | |
| 3929 | moreover have "y\<in>ball z (d z (e / 2))" using as and `ea>0` and z[unfolded subset_eq] | |
| 3930 | by (auto simp add: dist_commute) | |
| 3931 | hence "dist (f z) (f y) < e / 2" using d[THEN spec[where x="e/2"]] and `e>0` and `y\<in>s` and `z\<in>s` | |
| 3932 | by (auto simp add: dist_commute) | |
| 3933 | ultimately have "dist (f y) (f x) < e" using dist_triangle_half_r[of "f z" "f x" e "f y"] | |
| 3934 | by (auto simp add: dist_commute) } | |
| 3935 | then have "\<exists>d>0. \<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e" using `ea>0` by auto } | |
| 3936 | thus ?thesis unfolding uniformly_continuous_on_def by auto | |
| 3937 | qed | |
| 3938 | ||
| 3939 | text{* Continuity of inverse function on compact domain. *}
 | |
| 3940 | ||
| 3941 | lemma continuous_on_inverse: | |
| 3942 | fixes f :: "'a::heine_borel \<Rightarrow> 'b::heine_borel" | |
| 3943 | (* TODO: can this be generalized more? *) | |
| 3944 | assumes "continuous_on s f" "compact s" "\<forall>x \<in> s. g (f x) = x" | |
| 3945 | shows "continuous_on (f ` s) g" | |
| 3946 | proof- | |
| 3947 | have *:"g ` f ` s = s" using assms(3) by (auto simp add: image_iff) | |
| 3948 |   { fix t assume t:"closedin (subtopology euclidean (g ` f ` s)) t"
 | |
| 3949 | then obtain T where T: "closed T" "t = s \<inter> T" unfolding closedin_closed unfolding * by auto | |
| 3950 | have "continuous_on (s \<inter> T) f" using continuous_on_subset[OF assms(1), of "s \<inter> t"] | |
| 3951 | unfolding T(2) and Int_left_absorb by auto | |
| 3952 | moreover have "compact (s \<inter> T)" | |
| 3953 | using assms(2) unfolding compact_eq_bounded_closed | |
| 3954 | using bounded_subset[of s "s \<inter> T"] and T(1) by auto | |
| 3955 | ultimately have "closed (f ` t)" using T(1) unfolding T(2) | |
| 3956 | using compact_continuous_image [of "s \<inter> T" f] unfolding compact_eq_bounded_closed by auto | |
| 3957 |     moreover have "{x \<in> f ` s. g x \<in> t} = f ` s \<inter> f ` t" using assms(3) unfolding T(2) by auto
 | |
| 3958 |     ultimately have "closedin (subtopology euclidean (f ` s)) {x \<in> f ` s. g x \<in> t}"
 | |
| 3959 | unfolding closedin_closed by auto } | |
| 3960 | thus ?thesis unfolding continuous_on_closed by auto | |
| 3961 | qed | |
| 3962 | ||
| 3963 | subsection{* A uniformly convergent limit of continuous functions is continuous.       *}
 | |
| 3964 | ||
| 3965 | lemma norm_triangle_lt: | |
| 3966 | fixes x y :: "'a::real_normed_vector" | |
| 3967 | shows "norm x + norm y < e \<Longrightarrow> norm (x + y) < e" | |
| 3968 | by (rule le_less_trans [OF norm_triangle_ineq]) | |
| 3969 | ||
| 3970 | lemma continuous_uniform_limit: | |
| 3971 | fixes f :: "'a \<Rightarrow> 'b::metric_space \<Rightarrow> 'c::real_normed_vector" | |
| 3972 | assumes "\<not> (trivial_limit net)" "eventually (\<lambda>n. continuous_on s (f n)) net" | |
| 3973 | "\<forall>e>0. eventually (\<lambda>n. \<forall>x \<in> s. norm(f n x - g x) < e) net" | |
| 3974 | shows "continuous_on s g" | |
| 3975 | proof- | |
| 3976 |   { fix x and e::real assume "x\<in>s" "e>0"
 | |
| 3977 | have "eventually (\<lambda>n. \<forall>x\<in>s. norm (f n x - g x) < e / 3) net" using `e>0` assms(3)[THEN spec[where x="e/3"]] by auto | |
| 3978 | then obtain n where n:"\<forall>xa\<in>s. norm (f n xa - g xa) < e / 3" "continuous_on s (f n)" | |
| 3979 | using eventually_and[of "(\<lambda>n. \<forall>x\<in>s. norm (f n x - g x) < e / 3)" "(\<lambda>n. continuous_on s (f n))" net] assms(1,2) eventually_happens by blast | |
| 3980 | have "e / 3 > 0" using `e>0` by auto | |
| 3981 | then obtain d where "d>0" and d:"\<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f n x') (f n x) < e / 3" | |
| 3982 | using n(2)[unfolded continuous_on_def, THEN bspec[where x=x], OF `x\<in>s`, THEN spec[where x="e/3"]] by blast | |
| 3983 |     { fix y assume "y\<in>s" "dist y x < d"
 | |
| 3984 | hence "dist (f n y) (f n x) < e / 3" using d[THEN bspec[where x=y]] by auto | |
| 3985 | hence "norm (f n y - g x) < 2 * e / 3" using norm_triangle_lt[of "f n y - f n x" "f n x - g x" "2*e/3"] | |
| 3986 | using n(1)[THEN bspec[where x=x], OF `x\<in>s`] unfolding dist_norm unfolding ab_group_add_class.ab_diff_minus by auto | |
| 3987 | hence "dist (g y) (g x) < e" unfolding dist_norm using n(1)[THEN bspec[where x=y], OF `y\<in>s`] | |
| 3988 | unfolding norm_minus_cancel[of "f n y - g y", THEN sym] using norm_triangle_lt[of "f n y - g x" "g y - f n y" e] by (auto simp add: uminus_add_conv_diff) } | |
| 3989 | hence "\<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (g x') (g x) < e" using `d>0` by auto } | |
| 3990 | thus ?thesis unfolding continuous_on_def by auto | |
| 3991 | qed | |
| 3992 | ||
| 3993 | subsection{* Topological properties of linear functions.                               *}
 | |
| 3994 | ||
| 3995 | lemma linear_lim_0: | |
| 3996 | assumes "bounded_linear f" shows "(f ---> 0) (at (0))" | |
| 3997 | proof- | |
| 3998 | interpret f: bounded_linear f by fact | |
| 3999 | have "(f ---> f 0) (at 0)" | |
| 4000 | using tendsto_ident_at by (rule f.tendsto) | |
| 4001 | thus ?thesis unfolding f.zero . | |
| 4002 | qed | |
| 4003 | ||
| 4004 | lemma linear_continuous_at: | |
| 4005 | assumes "bounded_linear f" shows "continuous (at a) f" | |
| 4006 | unfolding continuous_at using assms | |
| 4007 | apply (rule bounded_linear.tendsto) | |
| 4008 | apply (rule tendsto_ident_at) | |
| 4009 | done | |
| 4010 | ||
| 4011 | lemma linear_continuous_within: | |
| 4012 | shows "bounded_linear f ==> continuous (at x within s) f" | |
| 4013 | using continuous_at_imp_continuous_within[of x f s] using linear_continuous_at[of f] by auto | |
| 4014 | ||
| 4015 | lemma linear_continuous_on: | |
| 4016 | shows "bounded_linear f ==> continuous_on s f" | |
| 4017 | using continuous_at_imp_continuous_on[of s f] using linear_continuous_at[of f] by auto | |
| 4018 | ||
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4019 | lemma continuous_on_vec1:"continuous_on A (vec1::real\<Rightarrow>real^1)" | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4020 | by(rule linear_continuous_on[OF bounded_linear_vec1]) | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4021 | |
| 33175 | 4022 | text{* Also bilinear functions, in composition form.                             *}
 | 
| 4023 | ||
| 4024 | lemma bilinear_continuous_at_compose: | |
| 4025 | shows "continuous (at x) f \<Longrightarrow> continuous (at x) g \<Longrightarrow> bounded_bilinear h | |
| 4026 | ==> continuous (at x) (\<lambda>x. h (f x) (g x))" | |
| 4027 | unfolding continuous_at using Lim_bilinear[of f "f x" "(at x)" g "g x" h] by auto | |
| 4028 | ||
| 4029 | lemma bilinear_continuous_within_compose: | |
| 4030 | shows "continuous (at x within s) f \<Longrightarrow> continuous (at x within s) g \<Longrightarrow> bounded_bilinear h | |
| 4031 | ==> continuous (at x within s) (\<lambda>x. h (f x) (g x))" | |
| 4032 | unfolding continuous_within using Lim_bilinear[of f "f x"] by auto | |
| 4033 | ||
| 4034 | lemma bilinear_continuous_on_compose: | |
| 4035 | shows "continuous_on s f \<Longrightarrow> continuous_on s g \<Longrightarrow> bounded_bilinear h | |
| 4036 | ==> continuous_on s (\<lambda>x. h (f x) (g x))" | |
| 4037 | unfolding continuous_on_eq_continuous_within apply auto apply(erule_tac x=x in ballE) apply auto apply(erule_tac x=x in ballE) apply auto | |
| 4038 | using bilinear_continuous_within_compose[of _ s f g h] by auto | |
| 4039 | ||
| 4040 | subsection{* Topological stuff lifted from and dropped to R                            *}
 | |
| 4041 | ||
| 4042 | ||
| 4043 | lemma open_real: | |
| 4044 | fixes s :: "real set" shows | |
| 4045 | "open s \<longleftrightarrow> | |
| 4046 | (\<forall>x \<in> s. \<exists>e>0. \<forall>x'. abs(x' - x) < e --> x' \<in> s)" (is "?lhs = ?rhs") | |
| 4047 | unfolding open_dist dist_norm by simp | |
| 4048 | ||
| 4049 | lemma islimpt_approachable_real: | |
| 4050 | fixes s :: "real set" | |
| 4051 | shows "x islimpt s \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in> s. x' \<noteq> x \<and> abs(x' - x) < e)" | |
| 4052 | unfolding islimpt_approachable dist_norm by simp | |
| 4053 | ||
| 4054 | lemma closed_real: | |
| 4055 | fixes s :: "real set" | |
| 4056 | shows "closed s \<longleftrightarrow> | |
| 4057 | (\<forall>x. (\<forall>e>0. \<exists>x' \<in> s. x' \<noteq> x \<and> abs(x' - x) < e) | |
| 4058 | --> x \<in> s)" | |
| 4059 | unfolding closed_limpt islimpt_approachable dist_norm by simp | |
| 4060 | ||
| 4061 | lemma continuous_at_real_range: | |
| 4062 | fixes f :: "'a::real_normed_vector \<Rightarrow> real" | |
| 4063 | shows "continuous (at x) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. | |
| 4064 | \<forall>x'. norm(x' - x) < d --> abs(f x' - f x) < e)" | |
| 4065 | unfolding continuous_at unfolding Lim_at | |
| 4066 | unfolding dist_nz[THEN sym] unfolding dist_norm apply auto | |
| 4067 | apply(erule_tac x=e in allE) apply auto apply (rule_tac x=d in exI) apply auto apply (erule_tac x=x' in allE) apply auto | |
| 4068 | apply(erule_tac x=e in allE) by auto | |
| 4069 | ||
| 4070 | lemma continuous_on_real_range: | |
| 4071 | fixes f :: "'a::real_normed_vector \<Rightarrow> real" | |
| 4072 | shows "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. \<forall>e>0. \<exists>d>0. (\<forall>x' \<in> s. norm(x' - x) < d --> abs(f x' - f x) < e))" | |
| 4073 | unfolding continuous_on_def dist_norm by simp | |
| 4074 | ||
| 4075 | lemma continuous_at_norm: "continuous (at x) norm" | |
| 4076 | unfolding continuous_at by (intro tendsto_intros) | |
| 4077 | ||
| 4078 | lemma continuous_on_norm: "continuous_on s norm" | |
| 4079 | unfolding continuous_on by (intro ballI tendsto_intros) | |
| 4080 | ||
| 4081 | lemma continuous_at_component: "continuous (at a) (\<lambda>x. x $ i)" | |
| 4082 | unfolding continuous_at by (intro tendsto_intros) | |
| 4083 | ||
| 4084 | lemma continuous_on_component: "continuous_on s (\<lambda>x. x $ i)" | |
| 4085 | unfolding continuous_on by (intro ballI tendsto_intros) | |
| 4086 | ||
| 4087 | lemma continuous_at_infnorm: "continuous (at x) infnorm" | |
| 4088 | unfolding continuous_at Lim_at o_def unfolding dist_norm | |
| 4089 | apply auto apply (rule_tac x=e in exI) apply auto | |
| 4090 | using order_trans[OF real_abs_sub_infnorm infnorm_le_norm, of _ x] by (metis xt1(7)) | |
| 4091 | ||
| 4092 | text{* Hence some handy theorems on distance, diameter etc. of/from a set.       *}
 | |
| 4093 | ||
| 4094 | lemma compact_attains_sup: | |
| 4095 | fixes s :: "real set" | |
| 4096 |   assumes "compact s"  "s \<noteq> {}"
 | |
| 4097 | shows "\<exists>x \<in> s. \<forall>y \<in> s. y \<le> x" | |
| 4098 | proof- | |
| 4099 | from assms(1) have a:"bounded s" "closed s" unfolding compact_eq_bounded_closed by auto | |
| 33270 | 4100 |   { fix e::real assume as: "\<forall>x\<in>s. x \<le> Sup s" "Sup s \<notin> s"  "0 < e" "\<forall>x'\<in>s. x' = Sup s \<or> \<not> Sup s - x' < e"
 | 
| 4101 | have "isLub UNIV s (Sup s)" using Sup[OF assms(2)] unfolding setle_def using as(1) by auto | |
| 4102 | moreover have "isUb UNIV s (Sup s - e)" unfolding isUb_def unfolding setle_def using as(4,2) by auto | |
| 4103 | ultimately have False using isLub_le_isUb[of UNIV s "Sup s" "Sup s - e"] using `e>0` by auto } | |
| 4104 | thus ?thesis using bounded_has_Sup(1)[OF a(1) assms(2)] using a(2)[unfolded closed_real, THEN spec[where x="Sup s"]] | |
| 4105 | apply(rule_tac x="Sup s" in bexI) by auto | |
| 4106 | qed | |
| 4107 | ||
| 4108 | lemma Inf: | |
| 4109 | fixes S :: "real set" | |
| 4110 |   shows "S \<noteq> {} ==> (\<exists>b. b <=* S) ==> isGlb UNIV S (Inf S)"
 | |
| 4111 | by (auto simp add: isLb_def setle_def setge_def isGlb_def greatestP_def) | |
| 33175 | 4112 | |
| 4113 | lemma compact_attains_inf: | |
| 4114 | fixes s :: "real set" | |
| 4115 |   assumes "compact s" "s \<noteq> {}"  shows "\<exists>x \<in> s. \<forall>y \<in> s. x \<le> y"
 | |
| 4116 | proof- | |
| 4117 | from assms(1) have a:"bounded s" "closed s" unfolding compact_eq_bounded_closed by auto | |
| 33270 | 4118 |   { fix e::real assume as: "\<forall>x\<in>s. x \<ge> Inf s"  "Inf s \<notin> s"  "0 < e"
 | 
| 4119 | "\<forall>x'\<in>s. x' = Inf s \<or> \<not> abs (x' - Inf s) < e" | |
| 4120 | have "isGlb UNIV s (Inf s)" using Inf[OF assms(2)] unfolding setge_def using as(1) by auto | |
| 33175 | 4121 | moreover | 
| 4122 |     { fix x assume "x \<in> s"
 | |
| 33270 | 4123 | hence *:"abs (x - Inf s) = x - Inf s" using as(1)[THEN bspec[where x=x]] by auto | 
| 4124 | have "Inf s + e \<le> x" using as(4)[THEN bspec[where x=x]] using as(2) `x\<in>s` unfolding * by auto } | |
| 4125 | hence "isLb UNIV s (Inf s + e)" unfolding isLb_def and setge_def by auto | |
| 4126 | ultimately have False using isGlb_le_isLb[of UNIV s "Inf s" "Inf s + e"] using `e>0` by auto } | |
| 4127 | thus ?thesis using bounded_has_Inf(1)[OF a(1) assms(2)] using a(2)[unfolded closed_real, THEN spec[where x="Inf s"]] | |
| 4128 | apply(rule_tac x="Inf s" in bexI) by auto | |
| 33175 | 4129 | qed | 
| 4130 | ||
| 4131 | lemma continuous_attains_sup: | |
| 4132 | fixes f :: "'a::metric_space \<Rightarrow> real" | |
| 4133 |   shows "compact s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> continuous_on s f
 | |
| 4134 | ==> (\<exists>x \<in> s. \<forall>y \<in> s. f y \<le> f x)" | |
| 4135 | using compact_attains_sup[of "f ` s"] | |
| 4136 | using compact_continuous_image[of s f] by auto | |
| 4137 | ||
| 4138 | lemma continuous_attains_inf: | |
| 4139 | fixes f :: "'a::metric_space \<Rightarrow> real" | |
| 4140 |   shows "compact s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> continuous_on s f
 | |
| 4141 | \<Longrightarrow> (\<exists>x \<in> s. \<forall>y \<in> s. f x \<le> f y)" | |
| 4142 | using compact_attains_inf[of "f ` s"] | |
| 4143 | using compact_continuous_image[of s f] by auto | |
| 4144 | ||
| 4145 | lemma distance_attains_sup: | |
| 4146 |   assumes "compact s" "s \<noteq> {}"
 | |
| 4147 | shows "\<exists>x \<in> s. \<forall>y \<in> s. dist a y \<le> dist a x" | |
| 4148 | proof (rule continuous_attains_sup [OF assms]) | |
| 4149 |   { fix x assume "x\<in>s"
 | |
| 4150 | have "(dist a ---> dist a x) (at x within s)" | |
| 4151 | by (intro tendsto_dist tendsto_const Lim_at_within Lim_ident_at) | |
| 4152 | } | |
| 4153 | thus "continuous_on s (dist a)" | |
| 4154 | unfolding continuous_on .. | |
| 4155 | qed | |
| 4156 | ||
| 4157 | text{* For *minimal* distance, we only need closure, not compactness.            *}
 | |
| 4158 | ||
| 4159 | lemma distance_attains_inf: | |
| 4160 | fixes a :: "'a::heine_borel" | |
| 4161 |   assumes "closed s"  "s \<noteq> {}"
 | |
| 4162 | shows "\<exists>x \<in> s. \<forall>y \<in> s. dist a x \<le> dist a y" | |
| 4163 | proof- | |
| 4164 | from assms(2) obtain b where "b\<in>s" by auto | |
| 4165 | let ?B = "cball a (dist b a) \<inter> s" | |
| 4166 | have "b \<in> ?B" using `b\<in>s` by (simp add: dist_commute) | |
| 4167 |   hence "?B \<noteq> {}" by auto
 | |
| 4168 | moreover | |
| 4169 |   { fix x assume "x\<in>?B"
 | |
| 4170 | fix e::real assume "e>0" | |
| 4171 |     { fix x' assume "x'\<in>?B" and as:"dist x' x < e"
 | |
| 4172 | from as have "\<bar>dist a x' - dist a x\<bar> < e" | |
| 4173 | unfolding abs_less_iff minus_diff_eq | |
| 4174 | using dist_triangle2 [of a x' x] | |
| 4175 | using dist_triangle [of a x x'] | |
| 4176 | by arith | |
| 4177 | } | |
| 4178 | hence "\<exists>d>0. \<forall>x'\<in>?B. dist x' x < d \<longrightarrow> \<bar>dist a x' - dist a x\<bar> < e" | |
| 4179 | using `e>0` by auto | |
| 4180 | } | |
| 4181 | hence "continuous_on (cball a (dist b a) \<inter> s) (dist a)" | |
| 4182 | unfolding continuous_on Lim_within dist_norm real_norm_def | |
| 4183 | by fast | |
| 4184 | moreover have "compact ?B" | |
| 4185 | using compact_cball[of a "dist b a"] | |
| 4186 | unfolding compact_eq_bounded_closed | |
| 4187 | using bounded_Int and closed_Int and assms(1) by auto | |
| 4188 | ultimately obtain x where "x\<in>cball a (dist b a) \<inter> s" "\<forall>y\<in>cball a (dist b a) \<inter> s. dist a x \<le> dist a y" | |
| 4189 | using continuous_attains_inf[of ?B "dist a"] by fastsimp | |
| 4190 | thus ?thesis by fastsimp | |
| 4191 | qed | |
| 4192 | ||
| 4193 | subsection{* We can now extend limit compositions to consider the scalar multiplier.   *}
 | |
| 4194 | ||
| 4195 | lemma Lim_mul: | |
| 4196 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 4197 | assumes "(c ---> d) net" "(f ---> l) net" | |
| 4198 | shows "((\<lambda>x. c(x) *\<^sub>R f x) ---> (d *\<^sub>R l)) net" | |
| 4199 | using assms by (rule scaleR.tendsto) | |
| 4200 | ||
| 4201 | lemma Lim_vmul: | |
| 4202 | fixes c :: "'a \<Rightarrow> real" and v :: "'b::real_normed_vector" | |
| 4203 | shows "(c ---> d) net ==> ((\<lambda>x. c(x) *\<^sub>R v) ---> d *\<^sub>R v) net" | |
| 4204 | by (intro tendsto_intros) | |
| 4205 | ||
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4206 | lemmas Lim_intros = Lim_add Lim_const Lim_sub Lim_cmul Lim_vmul Lim_within_id | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4207 | |
| 33175 | 4208 | lemma continuous_vmul: | 
| 4209 | fixes c :: "'a::metric_space \<Rightarrow> real" and v :: "'b::real_normed_vector" | |
| 4210 | shows "continuous net c ==> continuous net (\<lambda>x. c(x) *\<^sub>R v)" | |
| 4211 | unfolding continuous_def using Lim_vmul[of c] by auto | |
| 4212 | ||
| 4213 | lemma continuous_mul: | |
| 4214 | fixes c :: "'a::metric_space \<Rightarrow> real" | |
| 4215 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 4216 | shows "continuous net c \<Longrightarrow> continuous net f | |
| 4217 | ==> continuous net (\<lambda>x. c(x) *\<^sub>R f x) " | |
| 4218 | unfolding continuous_def by (intro tendsto_intros) | |
| 4219 | ||
| 34964 | 4220 | lemmas continuous_intros = continuous_add continuous_vmul continuous_cmul continuous_const continuous_sub continuous_at_id continuous_within_id continuous_mul | 
| 4221 | ||
| 33175 | 4222 | lemma continuous_on_vmul: | 
| 4223 | fixes c :: "'a::metric_space \<Rightarrow> real" and v :: "'b::real_normed_vector" | |
| 4224 | shows "continuous_on s c ==> continuous_on s (\<lambda>x. c(x) *\<^sub>R v)" | |
| 4225 | unfolding continuous_on_eq_continuous_within using continuous_vmul[of _ c] by auto | |
| 4226 | ||
| 4227 | lemma continuous_on_mul: | |
| 4228 | fixes c :: "'a::metric_space \<Rightarrow> real" | |
| 4229 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 4230 | shows "continuous_on s c \<Longrightarrow> continuous_on s f | |
| 4231 | ==> continuous_on s (\<lambda>x. c(x) *\<^sub>R f x)" | |
| 4232 | unfolding continuous_on_eq_continuous_within using continuous_mul[of _ c] by auto | |
| 4233 | ||
| 34964 | 4234 | lemmas continuous_on_intros = continuous_on_add continuous_on_const continuous_on_id continuous_on_compose continuous_on_cmul continuous_on_neg continuous_on_sub | 
| 4235 | uniformly_continuous_on_add uniformly_continuous_on_const uniformly_continuous_on_id uniformly_continuous_on_compose uniformly_continuous_on_cmul uniformly_continuous_on_neg uniformly_continuous_on_sub | |
| 4236 | continuous_on_mul continuous_on_vmul | |
| 4237 | ||
| 33175 | 4238 | text{* And so we have continuity of inverse.                                     *}
 | 
| 4239 | ||
| 4240 | lemma Lim_inv: | |
| 4241 | fixes f :: "'a \<Rightarrow> real" | |
| 4242 | assumes "(f ---> l) (net::'a net)" "l \<noteq> 0" | |
| 4243 | shows "((inverse o f) ---> inverse l) net" | |
| 4244 | unfolding o_def using assms by (rule tendsto_inverse) | |
| 4245 | ||
| 4246 | lemma continuous_inv: | |
| 4247 | fixes f :: "'a::metric_space \<Rightarrow> real" | |
| 4248 | shows "continuous net f \<Longrightarrow> f(netlimit net) \<noteq> 0 | |
| 4249 | ==> continuous net (inverse o f)" | |
| 4250 | unfolding continuous_def using Lim_inv by auto | |
| 4251 | ||
| 4252 | lemma continuous_at_within_inv: | |
| 4253 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_field" | |
| 4254 | assumes "continuous (at a within s) f" "f a \<noteq> 0" | |
| 4255 | shows "continuous (at a within s) (inverse o f)" | |
| 4256 | using assms unfolding continuous_within o_def | |
| 4257 | by (intro tendsto_intros) | |
| 4258 | ||
| 4259 | lemma continuous_at_inv: | |
| 4260 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_field" | |
| 4261 | shows "continuous (at a) f \<Longrightarrow> f a \<noteq> 0 | |
| 4262 | ==> continuous (at a) (inverse o f) " | |
| 4263 | using within_UNIV[THEN sym, of "at a"] using continuous_at_within_inv[of a UNIV] by auto | |
| 4264 | ||
| 4265 | subsection{* Preservation properties for pasted sets.                                  *}
 | |
| 4266 | ||
| 4267 | lemma bounded_pastecart: | |
| 4268 |   fixes s :: "('a::real_normed_vector ^ _) set" (* FIXME: generalize to metric_space *)
 | |
| 4269 | assumes "bounded s" "bounded t" | |
| 4270 |   shows "bounded { pastecart x y | x y . (x \<in> s \<and> y \<in> t)}"
 | |
| 4271 | proof- | |
| 4272 | obtain a b where ab:"\<forall>x\<in>s. norm x \<le> a" "\<forall>x\<in>t. norm x \<le> b" using assms[unfolded bounded_iff] by auto | |
| 4273 |   { fix x y assume "x\<in>s" "y\<in>t"
 | |
| 4274 | hence "norm x \<le> a" "norm y \<le> b" using ab by auto | |
| 4275 | hence "norm (pastecart x y) \<le> a + b" using norm_pastecart[of x y] by auto } | |
| 4276 | thus ?thesis unfolding bounded_iff by auto | |
| 4277 | qed | |
| 4278 | ||
| 4279 | lemma bounded_Times: | |
| 4280 | assumes "bounded s" "bounded t" shows "bounded (s \<times> t)" | |
| 4281 | proof- | |
| 4282 | obtain x y a b where "\<forall>z\<in>s. dist x z \<le> a" "\<forall>z\<in>t. dist y z \<le> b" | |
| 4283 | using assms [unfolded bounded_def] by auto | |
| 4284 | then have "\<forall>z\<in>s \<times> t. dist (x, y) z \<le> sqrt (a\<twosuperior> + b\<twosuperior>)" | |
| 4285 | by (auto simp add: dist_Pair_Pair real_sqrt_le_mono add_mono power_mono) | |
| 4286 | thus ?thesis unfolding bounded_any_center [where a="(x, y)"] by auto | |
| 4287 | qed | |
| 4288 | ||
| 4289 | lemma closed_pastecart: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4290 | fixes s :: "(real ^ 'a) set" (* FIXME: generalize *) | 
| 33175 | 4291 | assumes "closed s" "closed t" | 
| 4292 |   shows "closed {pastecart x y | x y . x \<in> s \<and> y \<in> t}"
 | |
| 4293 | proof- | |
| 4294 |   { fix x l assume as:"\<forall>n::nat. x n \<in> {pastecart x y |x y. x \<in> s \<and> y \<in> t}"  "(x ---> l) sequentially"
 | |
| 4295 |     { fix n::nat have "fstcart (x n) \<in> s" "sndcart (x n) \<in> t" using as(1)[THEN spec[where x=n]] by auto } note * = this
 | |
| 4296 | moreover | |
| 4297 |     { fix e::real assume "e>0"
 | |
| 4298 | then obtain N::nat where N:"\<forall>n\<ge>N. dist (x n) l < e" using as(2)[unfolded Lim_sequentially, THEN spec[where x=e]] by auto | |
| 4299 |       { fix n::nat assume "n\<ge>N"
 | |
| 4300 | hence "dist (fstcart (x n)) (fstcart l) < e" "dist (sndcart (x n)) (sndcart l) < e" | |
| 4301 | using N[THEN spec[where x=n]] dist_fstcart[of "x n" l] dist_sndcart[of "x n" l] by auto } | |
| 4302 | hence "\<exists>N. \<forall>n\<ge>N. dist (fstcart (x n)) (fstcart l) < e" "\<exists>N. \<forall>n\<ge>N. dist (sndcart (x n)) (sndcart l) < e" by auto } | |
| 4303 | ultimately have "fstcart l \<in> s" "sndcart l \<in> t" | |
| 4304 | using assms(1)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. fstcart (x n)"], THEN spec[where x="fstcart l"]] | |
| 4305 | using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. sndcart (x n)"], THEN spec[where x="sndcart l"]] | |
| 4306 | unfolding Lim_sequentially by auto | |
| 34964 | 4307 |     hence "l \<in> {pastecart x y |x y. x \<in> s \<and> y \<in> t}" apply- unfolding mem_Collect_eq apply(rule_tac x="fstcart l" in exI,rule_tac x="sndcart l" in exI) by auto }
 | 
| 33175 | 4308 | thus ?thesis unfolding closed_sequential_limits by auto | 
| 4309 | qed | |
| 4310 | ||
| 4311 | lemma compact_pastecart: | |
| 4312 | fixes s t :: "(real ^ _) set" | |
| 4313 |   shows "compact s \<Longrightarrow> compact t ==> compact {pastecart x y | x y . x \<in> s \<and> y \<in> t}"
 | |
| 4314 | unfolding compact_eq_bounded_closed using bounded_pastecart[of s t] closed_pastecart[of s t] by auto | |
| 4315 | ||
| 4316 | lemma mem_Times_iff: "x \<in> A \<times> B \<longleftrightarrow> fst x \<in> A \<and> snd x \<in> B" | |
| 4317 | by (induct x) simp | |
| 4318 | ||
| 4319 | lemma compact_Times: "compact s \<Longrightarrow> compact t \<Longrightarrow> compact (s \<times> t)" | |
| 4320 | unfolding compact_def | |
| 4321 | apply clarify | |
| 4322 | apply (drule_tac x="fst \<circ> f" in spec) | |
| 4323 | apply (drule mp, simp add: mem_Times_iff) | |
| 4324 | apply (clarify, rename_tac l1 r1) | |
| 4325 | apply (drule_tac x="snd \<circ> f \<circ> r1" in spec) | |
| 4326 | apply (drule mp, simp add: mem_Times_iff) | |
| 4327 | apply (clarify, rename_tac l2 r2) | |
| 4328 | apply (rule_tac x="(l1, l2)" in rev_bexI, simp) | |
| 4329 | apply (rule_tac x="r1 \<circ> r2" in exI) | |
| 4330 | apply (rule conjI, simp add: subseq_def) | |
| 4331 | apply (drule_tac r=r2 in lim_subseq [COMP swap_prems_rl], assumption) | |
| 4332 | apply (drule (1) tendsto_Pair) back | |
| 4333 | apply (simp add: o_def) | |
| 4334 | done | |
| 4335 | ||
| 4336 | text{* Hence some useful properties follow quite easily.                         *}
 | |
| 4337 | ||
| 4338 | lemma compact_scaling: | |
| 4339 | fixes s :: "'a::real_normed_vector set" | |
| 4340 | assumes "compact s" shows "compact ((\<lambda>x. c *\<^sub>R x) ` s)" | |
| 4341 | proof- | |
| 4342 | let ?f = "\<lambda>x. scaleR c x" | |
| 4343 | have *:"bounded_linear ?f" by (rule scaleR.bounded_linear_right) | |
| 4344 | show ?thesis using compact_continuous_image[of s ?f] continuous_at_imp_continuous_on[of s ?f] | |
| 4345 | using linear_continuous_at[OF *] assms by auto | |
| 4346 | qed | |
| 4347 | ||
| 4348 | lemma compact_negations: | |
| 4349 | fixes s :: "'a::real_normed_vector set" | |
| 4350 | assumes "compact s" shows "compact ((\<lambda>x. -x) ` s)" | |
| 4351 | using compact_scaling [OF assms, of "- 1"] by auto | |
| 4352 | ||
| 4353 | lemma compact_sums: | |
| 4354 | fixes s t :: "'a::real_normed_vector set" | |
| 4355 |   assumes "compact s"  "compact t"  shows "compact {x + y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4356 | proof- | |
| 4357 |   have *:"{x + y | x y. x \<in> s \<and> y \<in> t} = (\<lambda>z. fst z + snd z) ` (s \<times> t)"
 | |
| 4358 | apply auto unfolding image_iff apply(rule_tac x="(xa, y)" in bexI) by auto | |
| 4359 | have "continuous_on (s \<times> t) (\<lambda>z. fst z + snd z)" | |
| 4360 | unfolding continuous_on by (rule ballI) (intro tendsto_intros) | |
| 4361 | thus ?thesis unfolding * using compact_continuous_image compact_Times [OF assms] by auto | |
| 4362 | qed | |
| 4363 | ||
| 4364 | lemma compact_differences: | |
| 4365 | fixes s t :: "'a::real_normed_vector set" | |
| 4366 |   assumes "compact s" "compact t"  shows "compact {x - y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4367 | proof- | |
| 4368 |   have "{x - y | x y. x\<in>s \<and> y \<in> t} =  {x + y | x y. x \<in> s \<and> y \<in> (uminus ` t)}"
 | |
| 4369 | apply auto apply(rule_tac x= xa in exI) apply auto apply(rule_tac x=xa in exI) by auto | |
| 4370 | thus ?thesis using compact_sums[OF assms(1) compact_negations[OF assms(2)]] by auto | |
| 4371 | qed | |
| 4372 | ||
| 4373 | lemma compact_translation: | |
| 4374 | fixes s :: "'a::real_normed_vector set" | |
| 4375 | assumes "compact s" shows "compact ((\<lambda>x. a + x) ` s)" | |
| 4376 | proof- | |
| 4377 |   have "{x + y |x y. x \<in> s \<and> y \<in> {a}} = (\<lambda>x. a + x) ` s" by auto
 | |
| 4378 | thus ?thesis using compact_sums[OF assms compact_sing[of a]] by auto | |
| 4379 | qed | |
| 4380 | ||
| 4381 | lemma compact_affinity: | |
| 4382 | fixes s :: "'a::real_normed_vector set" | |
| 4383 | assumes "compact s" shows "compact ((\<lambda>x. a + c *\<^sub>R x) ` s)" | |
| 4384 | proof- | |
| 4385 | have "op + a ` op *\<^sub>R c ` s = (\<lambda>x. a + c *\<^sub>R x) ` s" by auto | |
| 4386 | thus ?thesis using compact_translation[OF compact_scaling[OF assms], of a c] by auto | |
| 4387 | qed | |
| 4388 | ||
| 4389 | text{* Hence we get the following.                                               *}
 | |
| 4390 | ||
| 4391 | lemma compact_sup_maxdistance: | |
| 4392 | fixes s :: "'a::real_normed_vector set" | |
| 4393 |   assumes "compact s"  "s \<noteq> {}"
 | |
| 4394 | shows "\<exists>x\<in>s. \<exists>y\<in>s. \<forall>u\<in>s. \<forall>v\<in>s. norm(u - v) \<le> norm(x - y)" | |
| 4395 | proof- | |
| 4396 |   have "{x - y | x y . x\<in>s \<and> y\<in>s} \<noteq> {}" using `s \<noteq> {}` by auto
 | |
| 4397 |   then obtain x where x:"x\<in>{x - y |x y. x \<in> s \<and> y \<in> s}"  "\<forall>y\<in>{x - y |x y. x \<in> s \<and> y \<in> s}. norm y \<le> norm x"
 | |
| 4398 | using compact_differences[OF assms(1) assms(1)] | |
| 4399 |     using distance_attains_sup[where 'a="'a", unfolded dist_norm, of "{x - y | x y . x\<in>s \<and> y\<in>s}" 0] by(auto simp add: norm_minus_cancel)
 | |
| 4400 | from x(1) obtain a b where "a\<in>s" "b\<in>s" "x = a - b" by auto | |
| 4401 | thus ?thesis using x(2)[unfolded `x = a - b`] by blast | |
| 4402 | qed | |
| 4403 | ||
| 4404 | text{* We can state this in terms of diameter of a set.                          *}
 | |
| 4405 | ||
| 33270 | 4406 | definition "diameter s = (if s = {} then 0::real else Sup {norm(x - y) | x y. x \<in> s \<and> y \<in> s})"
 | 
| 33175 | 4407 | (* TODO: generalize to class metric_space *) | 
| 4408 | ||
| 4409 | lemma diameter_bounded: | |
| 4410 | assumes "bounded s" | |
| 4411 | shows "\<forall>x\<in>s. \<forall>y\<in>s. norm(x - y) \<le> diameter s" | |
| 4412 | "\<forall>d>0. d < diameter s --> (\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d)" | |
| 4413 | proof- | |
| 4414 |   let ?D = "{norm (x - y) |x y. x \<in> s \<and> y \<in> s}"
 | |
| 4415 | obtain a where a:"\<forall>x\<in>s. norm x \<le> a" using assms[unfolded bounded_iff] by auto | |
| 4416 |   { fix x y assume "x \<in> s" "y \<in> s"
 | |
| 4417 | hence "norm (x - y) \<le> 2 * a" using norm_triangle_ineq[of x "-y", unfolded norm_minus_cancel] a[THEN bspec[where x=x]] a[THEN bspec[where x=y]] by (auto simp add: ring_simps) } | |
| 4418 | note * = this | |
| 4419 |   { fix x y assume "x\<in>s" "y\<in>s"  hence "s \<noteq> {}" by auto
 | |
| 33324 | 4420 |     have "norm(x - y) \<le> diameter s" unfolding diameter_def using `s\<noteq>{}` *[OF `x\<in>s` `y\<in>s`] `x\<in>s` `y\<in>s`  
 | 
| 4421 | by simp (blast intro!: Sup_upper *) } | |
| 33175 | 4422 | moreover | 
| 4423 |   { fix d::real assume "d>0" "d < diameter s"
 | |
| 4424 |     hence "s\<noteq>{}" unfolding diameter_def by auto
 | |
| 4425 | have "\<exists>d' \<in> ?D. d' > d" | |
| 4426 | proof(rule ccontr) | |
| 4427 |       assume "\<not> (\<exists>d'\<in>{norm (x - y) |x y. x \<in> s \<and> y \<in> s}. d < d')"
 | |
| 33324 | 4428 | hence "\<forall>d'\<in>?D. d' \<le> d" by auto (metis not_leE) | 
| 4429 |       thus False using `d < diameter s` `s\<noteq>{}` 
 | |
| 4430 | apply (auto simp add: diameter_def) | |
| 4431 | apply (drule Sup_real_iff [THEN [2] rev_iffD2]) | |
| 4432 | apply (auto, force) | |
| 4433 | done | |
| 33175 | 4434 | qed | 
| 4435 | hence "\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d" by auto } | |
| 4436 | ultimately show "\<forall>x\<in>s. \<forall>y\<in>s. norm(x - y) \<le> diameter s" | |
| 4437 | "\<forall>d>0. d < diameter s --> (\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d)" by auto | |
| 4438 | qed | |
| 4439 | ||
| 4440 | lemma diameter_bounded_bound: | |
| 4441 | "bounded s \<Longrightarrow> x \<in> s \<Longrightarrow> y \<in> s ==> norm(x - y) \<le> diameter s" | |
| 4442 | using diameter_bounded by blast | |
| 4443 | ||
| 4444 | lemma diameter_compact_attained: | |
| 4445 | fixes s :: "'a::real_normed_vector set" | |
| 4446 |   assumes "compact s"  "s \<noteq> {}"
 | |
| 4447 | shows "\<exists>x\<in>s. \<exists>y\<in>s. (norm(x - y) = diameter s)" | |
| 4448 | proof- | |
| 4449 | have b:"bounded s" using assms(1) by (rule compact_imp_bounded) | |
| 4450 | then obtain x y where xys:"x\<in>s" "y\<in>s" and xy:"\<forall>u\<in>s. \<forall>v\<in>s. norm (u - v) \<le> norm (x - y)" using compact_sup_maxdistance[OF assms] by auto | |
| 33270 | 4451 | hence "diameter s \<le> norm (x - y)" | 
| 4452 | by (force simp add: diameter_def intro!: Sup_least) | |
| 33324 | 4453 | thus ?thesis | 
| 4454 | by (metis b diameter_bounded_bound order_antisym xys) | |
| 33175 | 4455 | qed | 
| 4456 | ||
| 4457 | text{* Related results with closure as the conclusion.                           *}
 | |
| 4458 | ||
| 4459 | lemma closed_scaling: | |
| 4460 | fixes s :: "'a::real_normed_vector set" | |
| 4461 | assumes "closed s" shows "closed ((\<lambda>x. c *\<^sub>R x) ` s)" | |
| 4462 | proof(cases "s={}")
 | |
| 4463 | case True thus ?thesis by auto | |
| 4464 | next | |
| 4465 | case False | |
| 4466 | show ?thesis | |
| 4467 | proof(cases "c=0") | |
| 4468 |     have *:"(\<lambda>x. 0) ` s = {0}" using `s\<noteq>{}` by auto
 | |
| 4469 | case True thus ?thesis apply auto unfolding * using closed_sing by auto | |
| 4470 | next | |
| 4471 | case False | |
| 4472 |     { fix x l assume as:"\<forall>n::nat. x n \<in> scaleR c ` s"  "(x ---> l) sequentially"
 | |
| 4473 |       { fix n::nat have "scaleR (1 / c) (x n) \<in> s"
 | |
| 4474 | using as(1)[THEN spec[where x=n]] | |
| 4475 | using `c\<noteq>0` by (auto simp add: vector_smult_assoc) | |
| 4476 | } | |
| 4477 | moreover | |
| 4478 |       { fix e::real assume "e>0"
 | |
| 4479 | hence "0 < e *\<bar>c\<bar>" using `c\<noteq>0` mult_pos_pos[of e "abs c"] by auto | |
| 4480 | then obtain N where "\<forall>n\<ge>N. dist (x n) l < e * \<bar>c\<bar>" | |
| 4481 | using as(2)[unfolded Lim_sequentially, THEN spec[where x="e * abs c"]] by auto | |
| 4482 | hence "\<exists>N. \<forall>n\<ge>N. dist (scaleR (1 / c) (x n)) (scaleR (1 / c) l) < e" | |
| 4483 | unfolding dist_norm unfolding scaleR_right_diff_distrib[THEN sym] | |
| 4484 | using mult_imp_div_pos_less[of "abs c" _ e] `c\<noteq>0` by auto } | |
| 4485 | hence "((\<lambda>n. scaleR (1 / c) (x n)) ---> scaleR (1 / c) l) sequentially" unfolding Lim_sequentially by auto | |
| 4486 | ultimately have "l \<in> scaleR c ` s" | |
| 4487 | using assms[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. scaleR (1/c) (x n)"], THEN spec[where x="scaleR (1/c) l"]] | |
| 4488 | unfolding image_iff using `c\<noteq>0` apply(rule_tac x="scaleR (1 / c) l" in bexI) by auto } | |
| 4489 | thus ?thesis unfolding closed_sequential_limits by fast | |
| 4490 | qed | |
| 4491 | qed | |
| 4492 | ||
| 4493 | lemma closed_negations: | |
| 4494 | fixes s :: "'a::real_normed_vector set" | |
| 4495 | assumes "closed s" shows "closed ((\<lambda>x. -x) ` s)" | |
| 4496 | using closed_scaling[OF assms, of "- 1"] by simp | |
| 4497 | ||
| 4498 | lemma compact_closed_sums: | |
| 4499 | fixes s :: "'a::real_normed_vector set" | |
| 4500 |   assumes "compact s"  "closed t"  shows "closed {x + y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4501 | proof- | |
| 4502 |   let ?S = "{x + y |x y. x \<in> s \<and> y \<in> t}"
 | |
| 4503 |   { fix x l assume as:"\<forall>n. x n \<in> ?S"  "(x ---> l) sequentially"
 | |
| 4504 | from as(1) obtain f where f:"\<forall>n. x n = fst (f n) + snd (f n)" "\<forall>n. fst (f n) \<in> s" "\<forall>n. snd (f n) \<in> t" | |
| 4505 | using choice[of "\<lambda>n y. x n = (fst y) + (snd y) \<and> fst y \<in> s \<and> snd y \<in> t"] by auto | |
| 4506 | obtain l' r where "l'\<in>s" and r:"subseq r" and lr:"(((\<lambda>n. fst (f n)) \<circ> r) ---> l') sequentially" | |
| 4507 | using assms(1)[unfolded compact_def, THEN spec[where x="\<lambda> n. fst (f n)"]] using f(2) by auto | |
| 4508 | have "((\<lambda>n. snd (f (r n))) ---> l - l') sequentially" | |
| 4509 | using Lim_sub[OF lim_subseq[OF r as(2)] lr] and f(1) unfolding o_def by auto | |
| 4510 | hence "l - l' \<in> t" | |
| 4511 | using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda> n. snd (f (r n))"], THEN spec[where x="l - l'"]] | |
| 4512 | using f(3) by auto | |
| 4513 | hence "l \<in> ?S" using `l' \<in> s` apply auto apply(rule_tac x=l' in exI) apply(rule_tac x="l - l'" in exI) by auto | |
| 4514 | } | |
| 4515 | thus ?thesis unfolding closed_sequential_limits by fast | |
| 4516 | qed | |
| 4517 | ||
| 4518 | lemma closed_compact_sums: | |
| 4519 | fixes s t :: "'a::real_normed_vector set" | |
| 4520 | assumes "closed s" "compact t" | |
| 4521 |   shows "closed {x + y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4522 | proof- | |
| 4523 |   have "{x + y |x y. x \<in> t \<and> y \<in> s} = {x + y |x y. x \<in> s \<and> y \<in> t}" apply auto
 | |
| 4524 | apply(rule_tac x=y in exI) apply auto apply(rule_tac x=y in exI) by auto | |
| 4525 | thus ?thesis using compact_closed_sums[OF assms(2,1)] by simp | |
| 4526 | qed | |
| 4527 | ||
| 4528 | lemma compact_closed_differences: | |
| 4529 | fixes s t :: "'a::real_normed_vector set" | |
| 4530 | assumes "compact s" "closed t" | |
| 4531 |   shows "closed {x - y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4532 | proof- | |
| 4533 |   have "{x + y |x y. x \<in> s \<and> y \<in> uminus ` t} =  {x - y |x y. x \<in> s \<and> y \<in> t}"
 | |
| 4534 | apply auto apply(rule_tac x=xa in exI) apply auto apply(rule_tac x=xa in exI) by auto | |
| 4535 | thus ?thesis using compact_closed_sums[OF assms(1) closed_negations[OF assms(2)]] by auto | |
| 4536 | qed | |
| 4537 | ||
| 4538 | lemma closed_compact_differences: | |
| 4539 | fixes s t :: "'a::real_normed_vector set" | |
| 4540 | assumes "closed s" "compact t" | |
| 4541 |   shows "closed {x - y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4542 | proof- | |
| 4543 |   have "{x + y |x y. x \<in> s \<and> y \<in> uminus ` t} = {x - y |x y. x \<in> s \<and> y \<in> t}"
 | |
| 4544 | apply auto apply(rule_tac x=xa in exI) apply auto apply(rule_tac x=xa in exI) by auto | |
| 4545 | thus ?thesis using closed_compact_sums[OF assms(1) compact_negations[OF assms(2)]] by simp | |
| 4546 | qed | |
| 4547 | ||
| 4548 | lemma closed_translation: | |
| 4549 | fixes a :: "'a::real_normed_vector" | |
| 4550 | assumes "closed s" shows "closed ((\<lambda>x. a + x) ` s)" | |
| 4551 | proof- | |
| 4552 |   have "{a + y |y. y \<in> s} = (op + a ` s)" by auto
 | |
| 4553 | thus ?thesis using compact_closed_sums[OF compact_sing[of a] assms] by auto | |
| 4554 | qed | |
| 4555 | ||
| 34105 | 4556 | lemma translation_Compl: | 
| 4557 | fixes a :: "'a::ab_group_add" | |
| 4558 | shows "(\<lambda>x. a + x) ` (- t) = - ((\<lambda>x. a + x) ` t)" | |
| 4559 | apply (auto simp add: image_iff) apply(rule_tac x="x - a" in bexI) by auto | |
| 4560 | ||
| 33175 | 4561 | lemma translation_UNIV: | 
| 4562 | fixes a :: "'a::ab_group_add" shows "range (\<lambda>x. a + x) = UNIV" | |
| 4563 | apply (auto simp add: image_iff) apply(rule_tac x="x - a" in exI) by auto | |
| 4564 | ||
| 4565 | lemma translation_diff: | |
| 4566 | fixes a :: "'a::ab_group_add" | |
| 4567 | shows "(\<lambda>x. a + x) ` (s - t) = ((\<lambda>x. a + x) ` s) - ((\<lambda>x. a + x) ` t)" | |
| 4568 | by auto | |
| 4569 | ||
| 4570 | lemma closure_translation: | |
| 4571 | fixes a :: "'a::real_normed_vector" | |
| 4572 | shows "closure ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (closure s)" | |
| 4573 | proof- | |
| 34105 | 4574 | have *:"op + a ` (- s) = - op + a ` s" | 
| 33175 | 4575 | apply auto unfolding image_iff apply(rule_tac x="x - a" in bexI) by auto | 
| 34105 | 4576 | show ?thesis unfolding closure_interior translation_Compl | 
| 4577 | using interior_translation[of a "- s"] unfolding * by auto | |
| 33175 | 4578 | qed | 
| 4579 | ||
| 4580 | lemma frontier_translation: | |
| 4581 | fixes a :: "'a::real_normed_vector" | |
| 4582 | shows "frontier((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (frontier s)" | |
| 4583 | unfolding frontier_def translation_diff interior_translation closure_translation by auto | |
| 4584 | ||
| 4585 | subsection{* Separation between points and sets.                                       *}
 | |
| 4586 | ||
| 4587 | lemma separate_point_closed: | |
| 4588 | fixes s :: "'a::heine_borel set" | |
| 4589 | shows "closed s \<Longrightarrow> a \<notin> s ==> (\<exists>d>0. \<forall>x\<in>s. d \<le> dist a x)" | |
| 4590 | proof(cases "s = {}")
 | |
| 4591 | case True | |
| 4592 | thus ?thesis by(auto intro!: exI[where x=1]) | |
| 4593 | next | |
| 4594 | case False | |
| 4595 | assume "closed s" "a \<notin> s" | |
| 4596 |   then obtain x where "x\<in>s" "\<forall>y\<in>s. dist a x \<le> dist a y" using `s \<noteq> {}` distance_attains_inf [of s a] by blast
 | |
| 4597 | with `x\<in>s` show ?thesis using dist_pos_lt[of a x] and`a \<notin> s` by blast | |
| 4598 | qed | |
| 4599 | ||
| 4600 | lemma separate_compact_closed: | |
| 4601 |   fixes s t :: "'a::{heine_borel, real_normed_vector} set"
 | |
| 4602 | (* TODO: does this generalize to heine_borel? *) | |
| 4603 |   assumes "compact s" and "closed t" and "s \<inter> t = {}"
 | |
| 4604 | shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" | |
| 4605 | proof- | |
| 4606 |   have "0 \<notin> {x - y |x y. x \<in> s \<and> y \<in> t}" using assms(3) by auto
 | |
| 4607 |   then obtain d where "d>0" and d:"\<forall>x\<in>{x - y |x y. x \<in> s \<and> y \<in> t}. d \<le> dist 0 x"
 | |
| 4608 | using separate_point_closed[OF compact_closed_differences[OF assms(1,2)], of 0] by auto | |
| 4609 |   { fix x y assume "x\<in>s" "y\<in>t"
 | |
| 4610 |     hence "x - y \<in> {x - y |x y. x \<in> s \<and> y \<in> t}" by auto
 | |
| 4611 | hence "d \<le> dist (x - y) 0" using d[THEN bspec[where x="x - y"]] using dist_commute | |
| 4612 | by (auto simp add: dist_commute) | |
| 4613 | hence "d \<le> dist x y" unfolding dist_norm by auto } | |
| 4614 | thus ?thesis using `d>0` by auto | |
| 4615 | qed | |
| 4616 | ||
| 4617 | lemma separate_closed_compact: | |
| 4618 |   fixes s t :: "'a::{heine_borel, real_normed_vector} set"
 | |
| 4619 |   assumes "closed s" and "compact t" and "s \<inter> t = {}"
 | |
| 4620 | shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" | |
| 4621 | proof- | |
| 4622 |   have *:"t \<inter> s = {}" using assms(3) by auto
 | |
| 4623 | show ?thesis using separate_compact_closed[OF assms(2,1) *] | |
| 4624 | apply auto apply(rule_tac x=d in exI) apply auto apply (erule_tac x=y in ballE) | |
| 4625 | by (auto simp add: dist_commute) | |
| 4626 | qed | |
| 4627 | ||
| 4628 | (* A cute way of denoting open and closed intervals using overloading. *) | |
| 4629 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4630 | lemma interval: fixes a :: "'a::ord^'n" shows | 
| 33175 | 4631 |   "{a <..< b} = {x::'a^'n. \<forall>i. a$i < x$i \<and> x$i < b$i}" and
 | 
| 4632 |   "{a .. b} = {x::'a^'n. \<forall>i. a$i \<le> x$i \<and> x$i \<le> b$i}"
 | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 4633 | by (auto simp add: expand_set_eq vector_less_def vector_le_def) | 
| 33175 | 4634 | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4635 | lemma mem_interval: fixes a :: "'a::ord^'n" shows | 
| 33175 | 4636 |   "x \<in> {a<..<b} \<longleftrightarrow> (\<forall>i. a$i < x$i \<and> x$i < b$i)"
 | 
| 4637 |   "x \<in> {a .. b} \<longleftrightarrow> (\<forall>i. a$i \<le> x$i \<and> x$i \<le> b$i)"
 | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 4638 | using interval[of a b] by(auto simp add: expand_set_eq vector_less_def vector_le_def) | 
| 33175 | 4639 | |
| 4640 | lemma mem_interval_1: fixes x :: "real^1" shows | |
| 4641 |  "(x \<in> {a .. b} \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 x \<and> dest_vec1 x \<le> dest_vec1 b)"
 | |
| 4642 |  "(x \<in> {a<..<b} \<longleftrightarrow> dest_vec1 a < dest_vec1 x \<and> dest_vec1 x < dest_vec1 b)"
 | |
| 34964 | 4643 | by(simp_all add: Cart_eq vector_less_def vector_le_def forall_1) | 
| 33175 | 4644 | |
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4645 | lemma vec1_interval:fixes a::"real" shows | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4646 |   "vec1 ` {a .. b} = {vec1 a .. vec1 b}"
 | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4647 |   "vec1 ` {a<..<b} = {vec1 a<..<vec1 b}"
 | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4648 | apply(rule_tac[!] set_ext) unfolding image_iff vector_less_def unfolding mem_interval | 
| 34964 | 4649 | unfolding forall_1 unfolding vec1_dest_vec1_simps | 
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4650 | apply rule defer apply(rule_tac x="dest_vec1 x" in bexI) prefer 3 apply rule defer | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4651 | apply(rule_tac x="dest_vec1 x" in bexI) by auto | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4652 | |
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4653 | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4654 | lemma interval_eq_empty: fixes a :: "real^'n" shows | 
| 33175 | 4655 |  "({a <..< b} = {} \<longleftrightarrow> (\<exists>i. b$i \<le> a$i))" (is ?th1) and
 | 
| 4656 |  "({a  ..  b} = {} \<longleftrightarrow> (\<exists>i. b$i < a$i))" (is ?th2)
 | |
| 4657 | proof- | |
| 4658 |   { fix i x assume as:"b$i \<le> a$i" and x:"x\<in>{a <..< b}"
 | |
| 4659 | hence "a $ i < x $ i \<and> x $ i < b $ i" unfolding mem_interval by auto | |
| 4660 | hence "a$i < b$i" by auto | |
| 4661 | hence False using as by auto } | |
| 4662 | moreover | |
| 4663 |   { assume as:"\<forall>i. \<not> (b$i \<le> a$i)"
 | |
| 4664 | let ?x = "(1/2) *\<^sub>R (a + b)" | |
| 4665 |     { fix i
 | |
| 4666 | have "a$i < b$i" using as[THEN spec[where x=i]] by auto | |
| 4667 | hence "a$i < ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i < b$i" | |
| 4668 | unfolding vector_smult_component and vector_add_component | |
| 4669 | by (auto simp add: less_divide_eq_number_of1) } | |
| 4670 |     hence "{a <..< b} \<noteq> {}" using mem_interval(1)[of "?x" a b] by auto  }
 | |
| 4671 | ultimately show ?th1 by blast | |
| 4672 | ||
| 4673 |   { fix i x assume as:"b$i < a$i" and x:"x\<in>{a .. b}"
 | |
| 4674 | hence "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" unfolding mem_interval by auto | |
| 4675 | hence "a$i \<le> b$i" by auto | |
| 4676 | hence False using as by auto } | |
| 4677 | moreover | |
| 4678 |   { assume as:"\<forall>i. \<not> (b$i < a$i)"
 | |
| 4679 | let ?x = "(1/2) *\<^sub>R (a + b)" | |
| 4680 |     { fix i
 | |
| 4681 | have "a$i \<le> b$i" using as[THEN spec[where x=i]] by auto | |
| 4682 | hence "a$i \<le> ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i \<le> b$i" | |
| 4683 | unfolding vector_smult_component and vector_add_component | |
| 4684 | by (auto simp add: less_divide_eq_number_of1) } | |
| 4685 |     hence "{a .. b} \<noteq> {}" using mem_interval(2)[of "?x" a b] by auto  }
 | |
| 4686 | ultimately show ?th2 by blast | |
| 4687 | qed | |
| 4688 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4689 | lemma interval_ne_empty: fixes a :: "real^'n" shows | 
| 33175 | 4690 |   "{a  ..  b} \<noteq> {} \<longleftrightarrow> (\<forall>i. a$i \<le> b$i)" and
 | 
| 4691 |   "{a <..< b} \<noteq> {} \<longleftrightarrow> (\<forall>i. a$i < b$i)"
 | |
| 4692 | unfolding interval_eq_empty[of a b] by (auto simp add: not_less not_le) (* BH: Why doesn't just "auto" work here? *) | |
| 4693 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4694 | lemma subset_interval_imp: fixes a :: "real^'n" shows | 
| 33175 | 4695 |  "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> {c .. d} \<subseteq> {a .. b}" and
 | 
| 4696 |  "(\<forall>i. a$i < c$i \<and> d$i < b$i) \<Longrightarrow> {c .. d} \<subseteq> {a<..<b}" and
 | |
| 4697 |  "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> {c<..<d} \<subseteq> {a .. b}" and
 | |
| 4698 |  "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> {c<..<d} \<subseteq> {a<..<b}"
 | |
| 4699 | unfolding subset_eq[unfolded Ball_def] unfolding mem_interval | |
| 4700 | by (auto intro: order_trans less_le_trans le_less_trans less_imp_le) (* BH: Why doesn't just "auto" work here? *) | |
| 4701 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4702 | lemma interval_sing: fixes a :: "'a::linorder^'n" shows | 
| 33175 | 4703 |  "{a .. a} = {a} \<and> {a<..<a} = {}"
 | 
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 4704 | apply(auto simp add: expand_set_eq vector_less_def vector_le_def Cart_eq) | 
| 33175 | 4705 | apply (simp add: order_eq_iff) | 
| 4706 | apply (auto simp add: not_less less_imp_le) | |
| 4707 | done | |
| 4708 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4709 | lemma interval_open_subset_closed: fixes a :: "'a::preorder^'n" shows | 
| 33175 | 4710 |  "{a<..<b} \<subseteq> {a .. b}"
 | 
| 4711 | proof(simp add: subset_eq, rule) | |
| 4712 | fix x | |
| 4713 |   assume x:"x \<in>{a<..<b}"
 | |
| 4714 |   { fix i
 | |
| 4715 | have "a $ i \<le> x $ i" | |
| 4716 | using x order_less_imp_le[of "a$i" "x$i"] | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 4717 | by(simp add: expand_set_eq vector_less_def vector_le_def Cart_eq) | 
| 33175 | 4718 | } | 
| 4719 | moreover | |
| 4720 |   { fix i
 | |
| 4721 | have "x $ i \<le> b $ i" | |
| 4722 | using x order_less_imp_le[of "x$i" "b$i"] | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 4723 | by(simp add: expand_set_eq vector_less_def vector_le_def Cart_eq) | 
| 33175 | 4724 | } | 
| 4725 | ultimately | |
| 4726 | show "a \<le> x \<and> x \<le> b" | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 4727 | by(simp add: expand_set_eq vector_less_def vector_le_def Cart_eq) | 
| 33175 | 4728 | qed | 
| 4729 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4730 | lemma subset_interval: fixes a :: "real^'n" shows | 
| 33175 | 4731 |  "{c .. d} \<subseteq> {a .. b} \<longleftrightarrow> (\<forall>i. c$i \<le> d$i) --> (\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i)" (is ?th1) and
 | 
| 4732 |  "{c .. d} \<subseteq> {a<..<b} \<longleftrightarrow> (\<forall>i. c$i \<le> d$i) --> (\<forall>i. a$i < c$i \<and> d$i < b$i)" (is ?th2) and
 | |
| 4733 |  "{c<..<d} \<subseteq> {a .. b} \<longleftrightarrow> (\<forall>i. c$i < d$i) --> (\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i)" (is ?th3) and
 | |
| 4734 |  "{c<..<d} \<subseteq> {a<..<b} \<longleftrightarrow> (\<forall>i. c$i < d$i) --> (\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i)" (is ?th4)
 | |
| 4735 | proof- | |
| 4736 | show ?th1 unfolding subset_eq and Ball_def and mem_interval by (auto intro: order_trans) | |
| 4737 | show ?th2 unfolding subset_eq and Ball_def and mem_interval by (auto intro: le_less_trans less_le_trans order_trans less_imp_le) | |
| 4738 |   { assume as: "{c<..<d} \<subseteq> {a .. b}" "\<forall>i. c$i < d$i"
 | |
| 4739 |     hence "{c<..<d} \<noteq> {}" unfolding interval_eq_empty by (auto, drule_tac x=i in spec, simp) (* BH: Why doesn't just "auto" work? *)
 | |
| 4740 | fix i | |
| 4741 | (** TODO combine the following two parts as done in the HOL_light version. **) | |
| 4742 |     { let ?x = "(\<chi> j. (if j=i then ((min (a$j) (d$j))+c$j)/2 else (c$j+d$j)/2))::real^'n"
 | |
| 4743 | assume as2: "a$i > c$i" | |
| 4744 |       { fix j
 | |
| 4745 | have "c $ j < ?x $ j \<and> ?x $ j < d $ j" unfolding Cart_lambda_beta | |
| 4746 | apply(cases "j=i") using as(2)[THEN spec[where x=j]] | |
| 4747 | by (auto simp add: less_divide_eq_number_of1 as2) } | |
| 4748 |       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
 | |
| 4749 | moreover | |
| 4750 |       have "?x\<notin>{a .. b}"
 | |
| 4751 | unfolding mem_interval apply auto apply(rule_tac x=i in exI) | |
| 4752 | using as(2)[THEN spec[where x=i]] and as2 | |
| 4753 | by (auto simp add: less_divide_eq_number_of1) | |
| 4754 | ultimately have False using as by auto } | |
| 4755 | hence "a$i \<le> c$i" by(rule ccontr)auto | |
| 4756 | moreover | |
| 4757 |     { let ?x = "(\<chi> j. (if j=i then ((max (b$j) (c$j))+d$j)/2 else (c$j+d$j)/2))::real^'n"
 | |
| 4758 | assume as2: "b$i < d$i" | |
| 4759 |       { fix j
 | |
| 4760 | have "d $ j > ?x $ j \<and> ?x $ j > c $ j" unfolding Cart_lambda_beta | |
| 4761 | apply(cases "j=i") using as(2)[THEN spec[where x=j]] | |
| 4762 | by (auto simp add: less_divide_eq_number_of1 as2) } | |
| 4763 |       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
 | |
| 4764 | moreover | |
| 4765 |       have "?x\<notin>{a .. b}"
 | |
| 4766 | unfolding mem_interval apply auto apply(rule_tac x=i in exI) | |
| 4767 | using as(2)[THEN spec[where x=i]] and as2 | |
| 4768 | by (auto simp add: less_divide_eq_number_of1) | |
| 4769 | ultimately have False using as by auto } | |
| 4770 | hence "b$i \<ge> d$i" by(rule ccontr)auto | |
| 4771 | ultimately | |
| 4772 | have "a$i \<le> c$i \<and> d$i \<le> b$i" by auto | |
| 4773 | } note part1 = this | |
| 4774 | thus ?th3 unfolding subset_eq and Ball_def and mem_interval apply auto apply (erule_tac x=ia in allE, simp)+ by (erule_tac x=i in allE, erule_tac x=i in allE, simp)+ | |
| 4775 |   { assume as:"{c<..<d} \<subseteq> {a<..<b}" "\<forall>i. c$i < d$i"
 | |
| 4776 | fix i | |
| 4777 |     from as(1) have "{c<..<d} \<subseteq> {a..b}" using interval_open_subset_closed[of a b] by auto
 | |
| 4778 | hence "a$i \<le> c$i \<and> d$i \<le> b$i" using part1 and as(2) by auto } note * = this | |
| 4779 | thus ?th4 unfolding subset_eq and Ball_def and mem_interval apply auto apply (erule_tac x=ia in allE, simp)+ by (erule_tac x=i in allE, erule_tac x=i in allE, simp)+ | |
| 4780 | qed | |
| 4781 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4782 | lemma disjoint_interval: fixes a::"real^'n" shows | 
| 33175 | 4783 |   "{a .. b} \<inter> {c .. d} = {} \<longleftrightarrow> (\<exists>i. (b$i < a$i \<or> d$i < c$i \<or> b$i < c$i \<or> d$i < a$i))" (is ?th1) and
 | 
| 4784 |   "{a .. b} \<inter> {c<..<d} = {} \<longleftrightarrow> (\<exists>i. (b$i < a$i \<or> d$i \<le> c$i \<or> b$i \<le> c$i \<or> d$i \<le> a$i))" (is ?th2) and
 | |
| 4785 |   "{a<..<b} \<inter> {c .. d} = {} \<longleftrightarrow> (\<exists>i. (b$i \<le> a$i \<or> d$i < c$i \<or> b$i \<le> c$i \<or> d$i \<le> a$i))" (is ?th3) and
 | |
| 4786 |   "{a<..<b} \<inter> {c<..<d} = {} \<longleftrightarrow> (\<exists>i. (b$i \<le> a$i \<or> d$i \<le> c$i \<or> b$i \<le> c$i \<or> d$i \<le> a$i))" (is ?th4)
 | |
| 4787 | proof- | |
| 4788 | let ?z = "(\<chi> i. ((max (a$i) (c$i)) + (min (b$i) (d$i))) / 2)::real^'n" | |
| 4789 | show ?th1 ?th2 ?th3 ?th4 | |
| 4790 | unfolding expand_set_eq and Int_iff and empty_iff and mem_interval and all_conj_distrib[THEN sym] and eq_False | |
| 4791 | apply (auto elim!: allE[where x="?z"]) | |
| 4792 | apply ((rule_tac x=x in exI, force) | (rule_tac x=i in exI, force))+ | |
| 4793 | done | |
| 4794 | qed | |
| 4795 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4796 | lemma inter_interval: fixes a :: "'a::linorder^'n" shows | 
| 33175 | 4797 |  "{a .. b} \<inter> {c .. d} =  {(\<chi> i. max (a$i) (c$i)) .. (\<chi> i. min (b$i) (d$i))}"
 | 
| 4798 | unfolding expand_set_eq and Int_iff and mem_interval | |
| 4799 | by (auto simp add: less_divide_eq_number_of1 intro!: bexI) | |
| 4800 | ||
| 4801 | (* Moved interval_open_subset_closed a bit upwards *) | |
| 4802 | ||
| 4803 | lemma open_interval_lemma: fixes x :: "real" shows | |
| 4804 | "a < x \<Longrightarrow> x < b ==> (\<exists>d>0. \<forall>x'. abs(x' - x) < d --> a < x' \<and> x' < b)" | |
| 4805 | by(rule_tac x="min (x - a) (b - x)" in exI, auto) | |
| 4806 | ||
| 34964 | 4807 | lemma open_interval[intro]: fixes a :: "real^'n" shows "open {a<..<b}"
 | 
| 33175 | 4808 | proof- | 
| 4809 |   { fix x assume x:"x\<in>{a<..<b}"
 | |
| 4810 |     { fix i
 | |
| 4811 | have "\<exists>d>0. \<forall>x'. abs (x' - (x$i)) < d \<longrightarrow> a$i < x' \<and> x' < b$i" | |
| 4812 | using x[unfolded mem_interval, THEN spec[where x=i]] | |
| 4813 | using open_interval_lemma[of "a$i" "x$i" "b$i"] by auto } | |
| 4814 | ||
| 4815 | hence "\<forall>i. \<exists>d>0. \<forall>x'. abs (x' - (x$i)) < d \<longrightarrow> a$i < x' \<and> x' < b$i" by auto | |
| 4816 | then obtain d where d:"\<forall>i. 0 < d i \<and> (\<forall>x'. \<bar>x' - x $ i\<bar> < d i \<longrightarrow> a $ i < x' \<and> x' < b $ i)" | |
| 4817 | using bchoice[of "UNIV" "\<lambda>i d. d>0 \<and> (\<forall>x'. \<bar>x' - x $ i\<bar> < d \<longrightarrow> a $ i < x' \<and> x' < b $ i)"] by auto | |
| 4818 | ||
| 4819 | let ?d = "Min (range d)" | |
| 4820 |     have **:"finite (range d)" "range d \<noteq> {}" by auto
 | |
| 4821 | have "?d>0" unfolding Min_gr_iff[OF **] using d by auto | |
| 4822 | moreover | |
| 4823 |     { fix x' assume as:"dist x' x < ?d"
 | |
| 4824 |       { fix i
 | |
| 4825 | have "\<bar>x'$i - x $ i\<bar> < d i" | |
| 4826 | using norm_bound_component_lt[OF as[unfolded dist_norm], of i] | |
| 4827 | unfolding vector_minus_component and Min_gr_iff[OF **] by auto | |
| 4828 | hence "a $ i < x' $ i" "x' $ i < b $ i" using d[THEN spec[where x=i]] by auto } | |
| 4829 | hence "a < x' \<and> x' < b" unfolding vector_less_def by auto } | |
| 4830 |     ultimately have "\<exists>e>0. \<forall>x'. dist x' x < e \<longrightarrow> x' \<in> {a<..<b}" by (auto, rule_tac x="?d" in exI, simp)
 | |
| 4831 | } | |
| 4832 | thus ?thesis unfolding open_dist using open_interval_lemma by auto | |
| 4833 | qed | |
| 4834 | ||
| 34964 | 4835 | lemma open_interval_real[intro]: fixes a :: "real" shows "open {a<..<b}"
 | 
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4836 | using open_interval[of "vec1 a" "vec1 b"] unfolding open_contains_ball | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4837 | apply-apply(rule,erule_tac x="vec1 x" in ballE) apply(erule exE,rule_tac x=e in exI) | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4838 | unfolding subset_eq mem_ball apply(rule) defer apply(rule,erule conjE,erule_tac x="vec1 xa" in ballE) | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4839 | by(auto simp add: vec1_dest_vec1_simps vector_less_def forall_1) | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4840 | |
| 34964 | 4841 | lemma closed_interval[intro]: fixes a :: "real^'n" shows "closed {a .. b}"
 | 
| 33175 | 4842 | proof- | 
| 4843 |   { fix x i assume as:"\<forall>e>0. \<exists>x'\<in>{a..b}. x' \<noteq> x \<and> dist x' x < e"(* and xab:"a$i > x$i \<or> b$i < x$i"*)
 | |
| 4844 |     { assume xa:"a$i > x$i"
 | |
| 4845 |       with as obtain y where y:"y\<in>{a..b}" "y \<noteq> x" "dist y x < a$i - x$i" by(erule_tac x="a$i - x$i" in allE)auto
 | |
| 4846 | hence False unfolding mem_interval and dist_norm | |
| 4847 | using component_le_norm[of "y-x" i, unfolded vector_minus_component] and xa by(auto elim!: allE[where x=i]) | |
| 4848 | } hence "a$i \<le> x$i" by(rule ccontr)auto | |
| 4849 | moreover | |
| 4850 |     { assume xb:"b$i < x$i"
 | |
| 4851 |       with as obtain y where y:"y\<in>{a..b}" "y \<noteq> x" "dist y x < x$i - b$i" by(erule_tac x="x$i - b$i" in allE)auto
 | |
| 4852 | hence False unfolding mem_interval and dist_norm | |
| 4853 | using component_le_norm[of "y-x" i, unfolded vector_minus_component] and xb by(auto elim!: allE[where x=i]) | |
| 4854 | } hence "x$i \<le> b$i" by(rule ccontr)auto | |
| 4855 | ultimately | |
| 4856 | have "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" by auto } | |
| 4857 | thus ?thesis unfolding closed_limpt islimpt_approachable mem_interval by auto | |
| 4858 | qed | |
| 4859 | ||
| 34964 | 4860 | lemma interior_closed_interval[intro]: fixes a :: "real^'n" shows | 
| 33175 | 4861 |  "interior {a .. b} = {a<..<b}" (is "?L = ?R")
 | 
| 4862 | proof(rule subset_antisym) | |
| 4863 | show "?R \<subseteq> ?L" using interior_maximal[OF interval_open_subset_closed open_interval] by auto | |
| 4864 | next | |
| 4865 |   { fix x assume "\<exists>T. open T \<and> x \<in> T \<and> T \<subseteq> {a..b}"
 | |
| 4866 |     then obtain s where s:"open s" "x \<in> s" "s \<subseteq> {a..b}" by auto
 | |
| 4867 |     then obtain e where "e>0" and e:"\<forall>x'. dist x' x < e \<longrightarrow> x' \<in> {a..b}" unfolding open_dist and subset_eq by auto
 | |
| 4868 |     { fix i
 | |
| 4869 | have "dist (x - (e / 2) *\<^sub>R basis i) x < e" | |
| 4870 | "dist (x + (e / 2) *\<^sub>R basis i) x < e" | |
| 4871 | unfolding dist_norm apply auto | |
| 4872 | unfolding norm_minus_cancel using norm_basis[of i] and `e>0` by auto | |
| 4873 | hence "a $ i \<le> (x - (e / 2) *\<^sub>R basis i) $ i" | |
| 4874 | "(x + (e / 2) *\<^sub>R basis i) $ i \<le> b $ i" | |
| 4875 | using e[THEN spec[where x="x - (e/2) *\<^sub>R basis i"]] | |
| 4876 | and e[THEN spec[where x="x + (e/2) *\<^sub>R basis i"]] | |
| 4877 | unfolding mem_interval by (auto elim!: allE[where x=i]) | |
| 4878 | hence "a $ i < x $ i" and "x $ i < b $ i" | |
| 4879 | unfolding vector_minus_component and vector_add_component | |
| 4880 | unfolding vector_smult_component and basis_component using `e>0` by auto } | |
| 4881 |     hence "x \<in> {a<..<b}" unfolding mem_interval by auto  }
 | |
| 4882 | thus "?L \<subseteq> ?R" unfolding interior_def and subset_eq by auto | |
| 4883 | qed | |
| 4884 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4885 | lemma bounded_closed_interval: fixes a :: "real^'n" shows | 
| 33175 | 4886 |  "bounded {a .. b}"
 | 
| 4887 | proof- | |
| 4888 | let ?b = "\<Sum>i\<in>UNIV. \<bar>a$i\<bar> + \<bar>b$i\<bar>" | |
| 4889 |   { fix x::"real^'n" assume x:"\<forall>i. a $ i \<le> x $ i \<and> x $ i \<le> b $ i"
 | |
| 4890 |     { fix i
 | |
| 4891 | have "\<bar>x$i\<bar> \<le> \<bar>a$i\<bar> + \<bar>b$i\<bar>" using x[THEN spec[where x=i]] by auto } | |
| 4892 | hence "(\<Sum>i\<in>UNIV. \<bar>x $ i\<bar>) \<le> ?b" by(rule setsum_mono) | |
| 4893 | hence "norm x \<le> ?b" using norm_le_l1[of x] by auto } | |
| 4894 | thus ?thesis unfolding interval and bounded_iff by auto | |
| 4895 | qed | |
| 4896 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4897 | lemma bounded_interval: fixes a :: "real^'n" shows | 
| 33175 | 4898 |  "bounded {a .. b} \<and> bounded {a<..<b}"
 | 
| 4899 | using bounded_closed_interval[of a b] | |
| 4900 | using interval_open_subset_closed[of a b] | |
| 4901 |   using bounded_subset[of "{a..b}" "{a<..<b}"]
 | |
| 4902 | by simp | |
| 4903 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4904 | lemma not_interval_univ: fixes a :: "real^'n" shows | 
| 33175 | 4905 |  "({a .. b} \<noteq> UNIV) \<and> ({a<..<b} \<noteq> UNIV)"
 | 
| 4906 | using bounded_interval[of a b] | |
| 4907 | by auto | |
| 4908 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4909 | lemma compact_interval: fixes a :: "real^'n" shows | 
| 33175 | 4910 |  "compact {a .. b}"
 | 
| 4911 | using bounded_closed_imp_compact using bounded_interval[of a b] using closed_interval[of a b] by auto | |
| 4912 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4913 | lemma open_interval_midpoint: fixes a :: "real^'n" | 
| 33175 | 4914 |   assumes "{a<..<b} \<noteq> {}" shows "((1/2) *\<^sub>R (a + b)) \<in> {a<..<b}"
 | 
| 4915 | proof- | |
| 4916 |   { fix i
 | |
| 4917 | have "a $ i < ((1 / 2) *\<^sub>R (a + b)) $ i \<and> ((1 / 2) *\<^sub>R (a + b)) $ i < b $ i" | |
| 4918 | using assms[unfolded interval_ne_empty, THEN spec[where x=i]] | |
| 4919 | unfolding vector_smult_component and vector_add_component | |
| 4920 | by(auto simp add: less_divide_eq_number_of1) } | |
| 4921 | thus ?thesis unfolding mem_interval by auto | |
| 4922 | qed | |
| 4923 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4924 | lemma open_closed_interval_convex: fixes x :: "real^'n" | 
| 33175 | 4925 |   assumes x:"x \<in> {a<..<b}" and y:"y \<in> {a .. b}" and e:"0 < e" "e \<le> 1"
 | 
| 4926 |   shows "(e *\<^sub>R x + (1 - e) *\<^sub>R y) \<in> {a<..<b}"
 | |
| 4927 | proof- | |
| 4928 |   { fix i
 | |
| 4929 | have "a $ i = e * a$i + (1 - e) * a$i" unfolding left_diff_distrib by simp | |
| 4930 | also have "\<dots> < e * x $ i + (1 - e) * y $ i" apply(rule add_less_le_mono) | |
| 4931 | using e unfolding mult_less_cancel_left and mult_le_cancel_left apply simp_all | |
| 4932 | using x unfolding mem_interval apply simp | |
| 4933 | using y unfolding mem_interval apply simp | |
| 4934 | done | |
| 4935 | finally have "a $ i < (e *\<^sub>R x + (1 - e) *\<^sub>R y) $ i" by auto | |
| 4936 |     moreover {
 | |
| 4937 | have "b $ i = e * b$i + (1 - e) * b$i" unfolding left_diff_distrib by simp | |
| 4938 | also have "\<dots> > e * x $ i + (1 - e) * y $ i" apply(rule add_less_le_mono) | |
| 4939 | using e unfolding mult_less_cancel_left and mult_le_cancel_left apply simp_all | |
| 4940 | using x unfolding mem_interval apply simp | |
| 4941 | using y unfolding mem_interval apply simp | |
| 4942 | done | |
| 4943 | finally have "(e *\<^sub>R x + (1 - e) *\<^sub>R y) $ i < b $ i" by auto | |
| 4944 | } ultimately have "a $ i < (e *\<^sub>R x + (1 - e) *\<^sub>R y) $ i \<and> (e *\<^sub>R x + (1 - e) *\<^sub>R y) $ i < b $ i" by auto } | |
| 4945 | thus ?thesis unfolding mem_interval by auto | |
| 4946 | qed | |
| 4947 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4948 | lemma closure_open_interval: fixes a :: "real^'n" | 
| 33175 | 4949 |   assumes "{a<..<b} \<noteq> {}"
 | 
| 4950 |   shows "closure {a<..<b} = {a .. b}"
 | |
| 4951 | proof- | |
| 4952 | have ab:"a < b" using assms[unfolded interval_ne_empty] unfolding vector_less_def by auto | |
| 4953 | let ?c = "(1 / 2) *\<^sub>R (a + b)" | |
| 4954 |   { fix x assume as:"x \<in> {a .. b}"
 | |
| 4955 | def f == "\<lambda>n::nat. x + (inverse (real n + 1)) *\<^sub>R (?c - x)" | |
| 4956 |     { fix n assume fn:"f n < b \<longrightarrow> a < f n \<longrightarrow> f n = x" and xc:"x \<noteq> ?c"
 | |
| 4957 | have *:"0 < inverse (real n + 1)" "inverse (real n + 1) \<le> 1" unfolding inverse_le_1_iff by auto | |
| 4958 | have "(inverse (real n + 1)) *\<^sub>R ((1 / 2) *\<^sub>R (a + b)) + (1 - inverse (real n + 1)) *\<^sub>R x = | |
| 4959 | x + (inverse (real n + 1)) *\<^sub>R (((1 / 2) *\<^sub>R (a + b)) - x)" | |
| 4960 | by (auto simp add: algebra_simps) | |
| 4961 | hence "f n < b" and "a < f n" using open_closed_interval_convex[OF open_interval_midpoint[OF assms] as *] unfolding f_def by auto | |
| 4962 | hence False using fn unfolding f_def using xc by(auto simp add: vector_mul_lcancel vector_ssub_ldistrib) } | |
| 4963 | moreover | |
| 4964 |     { assume "\<not> (f ---> x) sequentially"
 | |
| 4965 |       { fix e::real assume "e>0"
 | |
| 4966 | hence "\<exists>N::nat. inverse (real (N + 1)) < e" using real_arch_inv[of e] apply (auto simp add: Suc_pred') apply(rule_tac x="n - 1" in exI) by auto | |
| 4967 | then obtain N::nat where "inverse (real (N + 1)) < e" by auto | |
| 4968 | hence "\<forall>n\<ge>N. inverse (real n + 1) < e" by (auto, metis Suc_le_mono le_SucE less_imp_inverse_less nat_le_real_less order_less_trans real_of_nat_Suc real_of_nat_Suc_gt_zero) | |
| 4969 | hence "\<exists>N::nat. \<forall>n\<ge>N. inverse (real n + 1) < e" by auto } | |
| 4970 | hence "((\<lambda>n. inverse (real n + 1)) ---> 0) sequentially" | |
| 4971 | unfolding Lim_sequentially by(auto simp add: dist_norm) | |
| 4972 | hence "(f ---> x) sequentially" unfolding f_def | |
| 4973 | using Lim_add[OF Lim_const, of "\<lambda>n::nat. (inverse (real n + 1)) *\<^sub>R ((1 / 2) *\<^sub>R (a + b) - x)" 0 sequentially x] | |
| 4974 | using Lim_vmul[of "\<lambda>n::nat. inverse (real n + 1)" 0 sequentially "((1 / 2) *\<^sub>R (a + b) - x)"] by auto } | |
| 4975 |     ultimately have "x \<in> closure {a<..<b}"
 | |
| 4976 | using as and open_interval_midpoint[OF assms] unfolding closure_def unfolding islimpt_sequential by(cases "x=?c")auto } | |
| 4977 | thus ?thesis using closure_minimal[OF interval_open_subset_closed closed_interval, of a b] by blast | |
| 4978 | qed | |
| 4979 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4980 | lemma bounded_subset_open_interval_symmetric: fixes s::"(real^'n) set" | 
| 33175 | 4981 |   assumes "bounded s"  shows "\<exists>a. s \<subseteq> {-a<..<a}"
 | 
| 4982 | proof- | |
| 4983 | obtain b where "b>0" and b:"\<forall>x\<in>s. norm x \<le> b" using assms[unfolded bounded_pos] by auto | |
| 4984 | def a \<equiv> "(\<chi> i. b+1)::real^'n" | |
| 4985 |   { fix x assume "x\<in>s"
 | |
| 4986 | fix i | |
| 4987 | have "(-a)$i < x$i" and "x$i < a$i" using b[THEN bspec[where x=x], OF `x\<in>s`] and component_le_norm[of x i] | |
| 4988 | unfolding vector_uminus_component and a_def and Cart_lambda_beta by auto | |
| 4989 | } | |
| 4990 | thus ?thesis by(auto intro: exI[where x=a] simp add: vector_less_def) | |
| 4991 | qed | |
| 4992 | ||
| 4993 | lemma bounded_subset_open_interval: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4994 | fixes s :: "(real ^ 'n) set" | 
| 33175 | 4995 |   shows "bounded s ==> (\<exists>a b. s \<subseteq> {a<..<b})"
 | 
| 4996 | by (auto dest!: bounded_subset_open_interval_symmetric) | |
| 4997 | ||
| 4998 | lemma bounded_subset_closed_interval_symmetric: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4999 | fixes s :: "(real ^ 'n) set" | 
| 33175 | 5000 |   assumes "bounded s" shows "\<exists>a. s \<subseteq> {-a .. a}"
 | 
| 5001 | proof- | |
| 5002 |   obtain a where "s \<subseteq> {- a<..<a}" using bounded_subset_open_interval_symmetric[OF assms] by auto
 | |
| 5003 | thus ?thesis using interval_open_subset_closed[of "-a" a] by auto | |
| 5004 | qed | |
| 5005 | ||
| 5006 | lemma bounded_subset_closed_interval: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5007 | fixes s :: "(real ^ 'n) set" | 
| 33175 | 5008 |   shows "bounded s ==> (\<exists>a b. s \<subseteq> {a .. b})"
 | 
| 5009 | using bounded_subset_closed_interval_symmetric[of s] by auto | |
| 5010 | ||
| 5011 | lemma frontier_closed_interval: | |
| 5012 | fixes a b :: "real ^ _" | |
| 5013 |   shows "frontier {a .. b} = {a .. b} - {a<..<b}"
 | |
| 5014 | unfolding frontier_def unfolding interior_closed_interval and closure_closed[OF closed_interval] .. | |
| 5015 | ||
| 5016 | lemma frontier_open_interval: | |
| 5017 | fixes a b :: "real ^ _" | |
| 5018 |   shows "frontier {a<..<b} = (if {a<..<b} = {} then {} else {a .. b} - {a<..<b})"
 | |
| 5019 | proof(cases "{a<..<b} = {}")
 | |
| 5020 | case True thus ?thesis using frontier_empty by auto | |
| 5021 | next | |
| 5022 | case False thus ?thesis unfolding frontier_def and closure_open_interval[OF False] and interior_open[OF open_interval] by auto | |
| 5023 | qed | |
| 5024 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5025 | lemma inter_interval_mixed_eq_empty: fixes a :: "real^'n" | 
| 33175 | 5026 |   assumes "{c<..<d} \<noteq> {}"  shows "{a<..<b} \<inter> {c .. d} = {} \<longleftrightarrow> {a<..<b} \<inter> {c<..<d} = {}"
 | 
| 5027 | unfolding closure_open_interval[OF assms, THEN sym] unfolding open_inter_closure_eq_empty[OF open_interval] .. | |
| 5028 | ||
| 5029 | ||
| 5030 | (* Some special cases for intervals in R^1. *) | |
| 5031 | ||
| 5032 | lemma interval_cases_1: fixes x :: "real^1" shows | |
| 5033 |  "x \<in> {a .. b} ==> x \<in> {a<..<b} \<or> (x = a) \<or> (x = b)"
 | |
| 34964 | 5034 | unfolding Cart_eq vector_less_def vector_le_def mem_interval by(auto simp del:dest_vec1_eq) | 
| 33175 | 5035 | |
| 5036 | lemma in_interval_1: fixes x :: "real^1" shows | |
| 5037 |  "(x \<in> {a .. b} \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 x \<and> dest_vec1 x \<le> dest_vec1 b) \<and>
 | |
| 5038 |   (x \<in> {a<..<b} \<longleftrightarrow> dest_vec1 a < dest_vec1 x \<and> dest_vec1 x < dest_vec1 b)"
 | |
| 34964 | 5039 | unfolding Cart_eq vector_less_def vector_le_def mem_interval by(auto simp del:dest_vec1_eq) | 
| 33175 | 5040 | |
| 5041 | lemma interval_eq_empty_1: fixes a :: "real^1" shows | |
| 5042 |   "{a .. b} = {} \<longleftrightarrow> dest_vec1 b < dest_vec1 a"
 | |
| 5043 |   "{a<..<b} = {} \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a"
 | |
| 34964 | 5044 | unfolding interval_eq_empty and ex_1 by auto | 
| 33175 | 5045 | |
| 5046 | lemma subset_interval_1: fixes a :: "real^1" shows | |
| 5047 |  "({a .. b} \<subseteq> {c .. d} \<longleftrightarrow>  dest_vec1 b < dest_vec1 a \<or>
 | |
| 5048 | dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a \<le> dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)" | |
| 5049 |  "({a .. b} \<subseteq> {c<..<d} \<longleftrightarrow>  dest_vec1 b < dest_vec1 a \<or>
 | |
| 5050 | dest_vec1 c < dest_vec1 a \<and> dest_vec1 a \<le> dest_vec1 b \<and> dest_vec1 b < dest_vec1 d)" | |
| 5051 |  "({a<..<b} \<subseteq> {c .. d} \<longleftrightarrow>  dest_vec1 b \<le> dest_vec1 a \<or>
 | |
| 5052 | dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a < dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)" | |
| 5053 |  "({a<..<b} \<subseteq> {c<..<d} \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a \<or>
 | |
| 5054 | dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a < dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)" | |
| 34964 | 5055 | unfolding subset_interval[of a b c d] unfolding forall_1 by auto | 
| 33175 | 5056 | |
| 5057 | lemma eq_interval_1: fixes a :: "real^1" shows | |
| 5058 |  "{a .. b} = {c .. d} \<longleftrightarrow>
 | |
| 5059 | dest_vec1 b < dest_vec1 a \<and> dest_vec1 d < dest_vec1 c \<or> | |
| 5060 | dest_vec1 a = dest_vec1 c \<and> dest_vec1 b = dest_vec1 d" | |
| 34964 | 5061 | unfolding set_eq_subset[of "{a .. b}" "{c .. d}"]
 | 
| 5062 | unfolding subset_interval_1(1)[of a b c d] | |
| 5063 | unfolding subset_interval_1(1)[of c d a b] | |
| 5064 | by auto | |
| 33175 | 5065 | |
| 5066 | lemma disjoint_interval_1: fixes a :: "real^1" shows | |
| 5067 |   "{a .. b} \<inter> {c .. d} = {} \<longleftrightarrow> dest_vec1 b < dest_vec1 a \<or> dest_vec1 d < dest_vec1 c  \<or>  dest_vec1 b < dest_vec1 c \<or> dest_vec1 d < dest_vec1 a"
 | |
| 5068 |   "{a .. b} \<inter> {c<..<d} = {} \<longleftrightarrow> dest_vec1 b < dest_vec1 a \<or> dest_vec1 d \<le> dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
 | |
| 5069 |   "{a<..<b} \<inter> {c .. d} = {} \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a \<or> dest_vec1 d < dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
 | |
| 5070 |   "{a<..<b} \<inter> {c<..<d} = {} \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a \<or> dest_vec1 d \<le> dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
 | |
| 34964 | 5071 | unfolding disjoint_interval and ex_1 by auto | 
| 33175 | 5072 | |
| 5073 | lemma open_closed_interval_1: fixes a :: "real^1" shows | |
| 5074 |  "{a<..<b} = {a .. b} - {a, b}"
 | |
| 34964 | 5075 | unfolding expand_set_eq apply simp unfolding vector_less_def and vector_le_def and forall_1 and dest_vec1_eq[THEN sym] by(auto simp del:dest_vec1_eq) | 
| 33175 | 5076 | |
| 5077 | lemma closed_open_interval_1: "dest_vec1 (a::real^1) \<le> dest_vec1 b ==> {a .. b} = {a<..<b} \<union> {a,b}"
 | |
| 34964 | 5078 | unfolding expand_set_eq apply simp unfolding vector_less_def and vector_le_def and forall_1 and dest_vec1_eq[THEN sym] by(auto simp del:dest_vec1_eq) | 
| 33175 | 5079 | |
| 5080 | (* Some stuff for half-infinite intervals too; FIXME: notation? *) | |
| 5081 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5082 | lemma closed_interval_left: fixes b::"real^'n" | 
| 33175 | 5083 |   shows "closed {x::real^'n. \<forall>i. x$i \<le> b$i}"
 | 
| 5084 | proof- | |
| 5085 |   { fix i
 | |
| 5086 |     fix x::"real^'n" assume x:"\<forall>e>0. \<exists>x'\<in>{x. \<forall>i. x $ i \<le> b $ i}. x' \<noteq> x \<and> dist x' x < e"
 | |
| 5087 |     { assume "x$i > b$i"
 | |
| 5088 | then obtain y where "y $ i \<le> b $ i" "y \<noteq> x" "dist y x < x$i - b$i" using x[THEN spec[where x="x$i - b$i"]] by auto | |
| 5089 | hence False using component_le_norm[of "y - x" i] unfolding dist_norm and vector_minus_component by auto } | |
| 5090 | hence "x$i \<le> b$i" by(rule ccontr)auto } | |
| 5091 | thus ?thesis unfolding closed_limpt unfolding islimpt_approachable by blast | |
| 5092 | qed | |
| 5093 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5094 | lemma closed_interval_right: fixes a::"real^'n" | 
| 33175 | 5095 |   shows "closed {x::real^'n. \<forall>i. a$i \<le> x$i}"
 | 
| 5096 | proof- | |
| 5097 |   { fix i
 | |
| 5098 |     fix x::"real^'n" assume x:"\<forall>e>0. \<exists>x'\<in>{x. \<forall>i. a $ i \<le> x $ i}. x' \<noteq> x \<and> dist x' x < e"
 | |
| 5099 |     { assume "a$i > x$i"
 | |
| 5100 | then obtain y where "a $ i \<le> y $ i" "y \<noteq> x" "dist y x < a$i - x$i" using x[THEN spec[where x="a$i - x$i"]] by auto | |
| 5101 | hence False using component_le_norm[of "y - x" i] unfolding dist_norm and vector_minus_component by auto } | |
| 5102 | hence "a$i \<le> x$i" by(rule ccontr)auto } | |
| 5103 | thus ?thesis unfolding closed_limpt unfolding islimpt_approachable by blast | |
| 5104 | qed | |
| 5105 | ||
| 5106 | subsection{* Intervals in general, including infinite and mixtures of open and closed. *}
 | |
| 5107 | ||
| 5108 | definition "is_interval s \<longleftrightarrow> (\<forall>a\<in>s. \<forall>b\<in>s. \<forall>x. (\<forall>i. ((a$i \<le> x$i \<and> x$i \<le> b$i) \<or> (b$i \<le> x$i \<and> x$i \<le> a$i))) \<longrightarrow> x \<in> s)" | |
| 5109 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5110 | lemma is_interval_interval: "is_interval {a .. b::real^'n}" (is ?th1) "is_interval {a<..<b}" (is ?th2) proof - 
 | 
| 33175 | 5111 | have *:"\<And>x y z::real. x < y \<Longrightarrow> y < z \<Longrightarrow> x < z" by auto | 
| 5112 | show ?th1 ?th2 unfolding is_interval_def mem_interval Ball_def atLeastAtMost_iff | |
| 5113 | by(meson real_le_trans le_less_trans less_le_trans *)+ qed | |
| 5114 | ||
| 5115 | lemma is_interval_empty: | |
| 5116 |  "is_interval {}"
 | |
| 5117 | unfolding is_interval_def | |
| 5118 | by simp | |
| 5119 | ||
| 5120 | lemma is_interval_univ: | |
| 5121 | "is_interval UNIV" | |
| 5122 | unfolding is_interval_def | |
| 5123 | by simp | |
| 5124 | ||
| 5125 | subsection{* Closure of halfspaces and hyperplanes.                                    *}
 | |
| 5126 | ||
| 5127 | lemma Lim_inner: | |
| 5128 | assumes "(f ---> l) net" shows "((\<lambda>y. inner a (f y)) ---> inner a l) net" | |
| 5129 | by (intro tendsto_intros assms) | |
| 5130 | ||
| 5131 | lemma continuous_at_inner: "continuous (at x) (inner a)" | |
| 5132 | unfolding continuous_at by (intro tendsto_intros) | |
| 5133 | ||
| 5134 | lemma continuous_on_inner: | |
| 5135 | fixes s :: "'a::real_inner set" | |
| 5136 | shows "continuous_on s (inner a)" | |
| 5137 | unfolding continuous_on by (rule ballI) (intro tendsto_intros) | |
| 5138 | ||
| 5139 | lemma closed_halfspace_le: "closed {x. inner a x \<le> b}"
 | |
| 5140 | proof- | |
| 5141 | have "\<forall>x. continuous (at x) (inner a)" | |
| 5142 | unfolding continuous_at by (rule allI) (intro tendsto_intros) | |
| 5143 |   hence "closed (inner a -` {..b})"
 | |
| 5144 | using closed_real_atMost by (rule continuous_closed_vimage) | |
| 5145 |   moreover have "{x. inner a x \<le> b} = inner a -` {..b}" by auto
 | |
| 5146 | ultimately show ?thesis by simp | |
| 5147 | qed | |
| 5148 | ||
| 5149 | lemma closed_halfspace_ge: "closed {x. inner a x \<ge> b}"
 | |
| 5150 | using closed_halfspace_le[of "-a" "-b"] unfolding inner_minus_left by auto | |
| 5151 | ||
| 5152 | lemma closed_hyperplane: "closed {x. inner a x = b}"
 | |
| 5153 | proof- | |
| 5154 |   have "{x. inner a x = b} = {x. inner a x \<ge> b} \<inter> {x. inner a x \<le> b}" by auto
 | |
| 5155 | thus ?thesis using closed_halfspace_le[of a b] and closed_halfspace_ge[of b a] using closed_Int by auto | |
| 5156 | qed | |
| 5157 | ||
| 5158 | lemma closed_halfspace_component_le: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5159 |   shows "closed {x::real^'n. x$i \<le> a}"
 | 
| 33175 | 5160 | using closed_halfspace_le[of "(basis i)::real^'n" a] unfolding inner_basis[OF assms] by auto | 
| 5161 | ||
| 5162 | lemma closed_halfspace_component_ge: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5163 |   shows "closed {x::real^'n. x$i \<ge> a}"
 | 
| 33175 | 5164 | using closed_halfspace_ge[of a "(basis i)::real^'n"] unfolding inner_basis[OF assms] by auto | 
| 5165 | ||
| 5166 | text{* Openness of halfspaces.                                                   *}
 | |
| 5167 | ||
| 5168 | lemma open_halfspace_lt: "open {x. inner a x < b}"
 | |
| 5169 | proof- | |
| 34105 | 5170 |   have "- {x. b \<le> inner a x} = {x. inner a x < b}" by auto
 | 
| 5171 | thus ?thesis using closed_halfspace_ge[unfolded closed_def, of b a] by auto | |
| 33175 | 5172 | qed | 
| 5173 | ||
| 5174 | lemma open_halfspace_gt: "open {x. inner a x > b}"
 | |
| 5175 | proof- | |
| 34105 | 5176 |   have "- {x. b \<ge> inner a x} = {x. inner a x > b}" by auto
 | 
| 5177 | thus ?thesis using closed_halfspace_le[unfolded closed_def, of a b] by auto | |
| 33175 | 5178 | qed | 
| 5179 | ||
| 5180 | lemma open_halfspace_component_lt: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5181 |   shows "open {x::real^'n. x$i < a}"
 | 
| 33175 | 5182 | using open_halfspace_lt[of "(basis i)::real^'n" a] unfolding inner_basis[OF assms] by auto | 
| 5183 | ||
| 5184 | lemma open_halfspace_component_gt: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5185 |   shows "open {x::real^'n. x$i  > a}"
 | 
| 33175 | 5186 | using open_halfspace_gt[of a "(basis i)::real^'n"] unfolding inner_basis[OF assms] by auto | 
| 5187 | ||
| 5188 | text{* This gives a simple derivation of limit component bounds.                 *}
 | |
| 5189 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5190 | lemma Lim_component_le: fixes f :: "'a \<Rightarrow> real^'n" | 
| 33175 | 5191 | assumes "(f ---> l) net" "\<not> (trivial_limit net)" "eventually (\<lambda>x. f(x)$i \<le> b) net" | 
| 5192 | shows "l$i \<le> b" | |
| 5193 | proof- | |
| 5194 |   { fix x have "x \<in> {x::real^'n. inner (basis i) x \<le> b} \<longleftrightarrow> x$i \<le> b" unfolding inner_basis by auto } note * = this
 | |
| 5195 |   show ?thesis using Lim_in_closed_set[of "{x. inner (basis i) x \<le> b}" f net l] unfolding *
 | |
| 5196 | using closed_halfspace_le[of "(basis i)::real^'n" b] and assms(1,2,3) by auto | |
| 5197 | qed | |
| 5198 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5199 | lemma Lim_component_ge: fixes f :: "'a \<Rightarrow> real^'n" | 
| 33175 | 5200 | assumes "(f ---> l) net" "\<not> (trivial_limit net)" "eventually (\<lambda>x. b \<le> (f x)$i) net" | 
| 5201 | shows "b \<le> l$i" | |
| 5202 | proof- | |
| 5203 |   { fix x have "x \<in> {x::real^'n. inner (basis i) x \<ge> b} \<longleftrightarrow> x$i \<ge> b" unfolding inner_basis by auto } note * = this
 | |
| 5204 |   show ?thesis using Lim_in_closed_set[of "{x. inner (basis i) x \<ge> b}" f net l] unfolding *
 | |
| 5205 | using closed_halfspace_ge[of b "(basis i)::real^'n"] and assms(1,2,3) by auto | |
| 5206 | qed | |
| 5207 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5208 | lemma Lim_component_eq: fixes f :: "'a \<Rightarrow> real^'n" | 
| 33175 | 5209 | assumes net:"(f ---> l) net" "~(trivial_limit net)" and ev:"eventually (\<lambda>x. f(x)$i = b) net" | 
| 5210 | shows "l$i = b" | |
| 5211 | using ev[unfolded order_eq_iff eventually_and] using Lim_component_ge[OF net, of b i] and Lim_component_le[OF net, of i b] by auto | |
| 5212 | ||
| 5213 | lemma Lim_drop_le: fixes f :: "'a \<Rightarrow> real^1" shows | |
| 5214 | "(f ---> l) net \<Longrightarrow> ~(trivial_limit net) \<Longrightarrow> eventually (\<lambda>x. dest_vec1 (f x) \<le> b) net ==> dest_vec1 l \<le> b" | |
| 34964 | 5215 | using Lim_component_le[of f l net 1 b] by auto | 
| 33175 | 5216 | |
| 5217 | lemma Lim_drop_ge: fixes f :: "'a \<Rightarrow> real^1" shows | |
| 5218 | "(f ---> l) net \<Longrightarrow> ~(trivial_limit net) \<Longrightarrow> eventually (\<lambda>x. b \<le> dest_vec1 (f x)) net ==> b \<le> dest_vec1 l" | |
| 34964 | 5219 | using Lim_component_ge[of f l net b 1] by auto | 
| 33175 | 5220 | |
| 5221 | text{* Limits relative to a union.                                               *}
 | |
| 5222 | ||
| 5223 | lemma eventually_within_Un: | |
| 5224 | "eventually P (net within (s \<union> t)) \<longleftrightarrow> | |
| 5225 | eventually P (net within s) \<and> eventually P (net within t)" | |
| 5226 | unfolding Limits.eventually_within | |
| 5227 | by (auto elim!: eventually_rev_mp) | |
| 5228 | ||
| 5229 | lemma Lim_within_union: | |
| 5230 | "(f ---> l) (net within (s \<union> t)) \<longleftrightarrow> | |
| 5231 | (f ---> l) (net within s) \<and> (f ---> l) (net within t)" | |
| 5232 | unfolding tendsto_def | |
| 5233 | by (auto simp add: eventually_within_Un) | |
| 5234 | ||
| 5235 | lemma continuous_on_union: | |
| 5236 | assumes "closed s" "closed t" "continuous_on s f" "continuous_on t f" | |
| 5237 | shows "continuous_on (s \<union> t) f" | |
| 5238 | using assms unfolding continuous_on unfolding Lim_within_union | |
| 5239 | unfolding Lim unfolding trivial_limit_within unfolding closed_limpt by auto | |
| 5240 | ||
| 5241 | lemma continuous_on_cases: | |
| 5242 | assumes "closed s" "closed t" "continuous_on s f" "continuous_on t g" | |
| 5243 | "\<forall>x. (x\<in>s \<and> \<not> P x) \<or> (x \<in> t \<and> P x) \<longrightarrow> f x = g x" | |
| 5244 | shows "continuous_on (s \<union> t) (\<lambda>x. if P x then f x else g x)" | |
| 5245 | proof- | |
| 5246 | let ?h = "(\<lambda>x. if P x then f x else g x)" | |
| 5247 | have "\<forall>x\<in>s. f x = (if P x then f x else g x)" using assms(5) by auto | |
| 5248 | hence "continuous_on s ?h" using continuous_on_eq[of s f ?h] using assms(3) by auto | |
| 5249 | moreover | |
| 5250 | have "\<forall>x\<in>t. g x = (if P x then f x else g x)" using assms(5) by auto | |
| 5251 | hence "continuous_on t ?h" using continuous_on_eq[of t g ?h] using assms(4) by auto | |
| 5252 | ultimately show ?thesis using continuous_on_union[OF assms(1,2), of ?h] by auto | |
| 5253 | qed | |
| 5254 | ||
| 5255 | ||
| 5256 | text{* Some more convenient intermediate-value theorem formulations.             *}
 | |
| 5257 | ||
| 5258 | lemma connected_ivt_hyperplane: | |
| 5259 | assumes "connected s" "x \<in> s" "y \<in> s" "inner a x \<le> b" "b \<le> inner a y" | |
| 5260 | shows "\<exists>z \<in> s. inner a z = b" | |
| 5261 | proof(rule ccontr) | |
| 5262 | assume as:"\<not> (\<exists>z\<in>s. inner a z = b)" | |
| 5263 |   let ?A = "{x. inner a x < b}"
 | |
| 5264 |   let ?B = "{x. inner a x > b}"
 | |
| 5265 | have "open ?A" "open ?B" using open_halfspace_lt and open_halfspace_gt by auto | |
| 5266 |   moreover have "?A \<inter> ?B = {}" by auto
 | |
| 5267 | moreover have "s \<subseteq> ?A \<union> ?B" using as by auto | |
| 5268 | ultimately show False using assms(1)[unfolded connected_def not_ex, THEN spec[where x="?A"], THEN spec[where x="?B"]] and assms(2-5) by auto | |
| 5269 | qed | |
| 5270 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5271 | lemma connected_ivt_component: fixes x::"real^'n" shows | 
| 33175 | 5272 | "connected s \<Longrightarrow> x \<in> s \<Longrightarrow> y \<in> s \<Longrightarrow> x$k \<le> a \<Longrightarrow> a \<le> y$k \<Longrightarrow> (\<exists>z\<in>s. z$k = a)" | 
| 5273 | using connected_ivt_hyperplane[of s x y "(basis k)::real^'n" a] by (auto simp add: inner_basis) | |
| 5274 | ||
| 5275 | text{* Also more convenient formulations of monotone convergence.                *}
 | |
| 5276 | ||
| 5277 | lemma bounded_increasing_convergent: fixes s::"nat \<Rightarrow> real^1" | |
| 5278 |   assumes "bounded {s n| n::nat. True}"  "\<forall>n. dest_vec1(s n) \<le> dest_vec1(s(Suc n))"
 | |
| 5279 | shows "\<exists>l. (s ---> l) sequentially" | |
| 5280 | proof- | |
| 5281 | obtain a where a:"\<forall>n. \<bar>dest_vec1 (s n)\<bar> \<le> a" using assms(1)[unfolded bounded_iff abs_dest_vec1] by auto | |
| 5282 |   { fix m::nat
 | |
| 5283 | have "\<And> n. n\<ge>m \<longrightarrow> dest_vec1 (s m) \<le> dest_vec1 (s n)" | |
| 5284 | apply(induct_tac n) apply simp using assms(2) apply(erule_tac x="na" in allE) by(auto simp add: not_less_eq_eq) } | |
| 5285 | hence "\<forall>m n. m \<le> n \<longrightarrow> dest_vec1 (s m) \<le> dest_vec1 (s n)" by auto | |
| 5286 | then obtain l where "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<bar>dest_vec1 (s n) - l\<bar> < e" using convergent_bounded_monotone[OF a] unfolding monoseq_def by auto | |
| 5287 | thus ?thesis unfolding Lim_sequentially apply(rule_tac x="vec1 l" in exI) | |
| 34964 | 5288 | unfolding dist_norm unfolding abs_dest_vec1 by auto | 
| 33175 | 5289 | qed | 
| 5290 | ||
| 5291 | subsection{* Basic homeomorphism definitions.                                          *}
 | |
| 5292 | ||
| 5293 | definition "homeomorphism s t f g \<equiv> | |
| 5294 | (\<forall>x\<in>s. (g(f x) = x)) \<and> (f ` s = t) \<and> continuous_on s f \<and> | |
| 5295 | (\<forall>y\<in>t. (f(g y) = y)) \<and> (g ` t = s) \<and> continuous_on t g" | |
| 5296 | ||
| 5297 | definition | |
| 5298 | homeomorphic :: "'a::metric_space set \<Rightarrow> 'b::metric_space set \<Rightarrow> bool" | |
| 5299 | (infixr "homeomorphic" 60) where | |
| 5300 | homeomorphic_def: "s homeomorphic t \<equiv> (\<exists>f g. homeomorphism s t f g)" | |
| 5301 | ||
| 5302 | lemma homeomorphic_refl: "s homeomorphic s" | |
| 5303 | unfolding homeomorphic_def | |
| 5304 | unfolding homeomorphism_def | |
| 5305 | using continuous_on_id | |
| 5306 | apply(rule_tac x = "(\<lambda>x. x)" in exI) | |
| 5307 | apply(rule_tac x = "(\<lambda>x. x)" in exI) | |
| 5308 | by blast | |
| 5309 | ||
| 5310 | lemma homeomorphic_sym: | |
| 5311 | "s homeomorphic t \<longleftrightarrow> t homeomorphic s" | |
| 5312 | unfolding homeomorphic_def | |
| 5313 | unfolding homeomorphism_def | |
| 33324 | 5314 | by blast | 
| 33175 | 5315 | |
| 5316 | lemma homeomorphic_trans: | |
| 5317 | assumes "s homeomorphic t" "t homeomorphic u" shows "s homeomorphic u" | |
| 5318 | proof- | |
| 5319 | obtain f1 g1 where fg1:"\<forall>x\<in>s. g1 (f1 x) = x" "f1 ` s = t" "continuous_on s f1" "\<forall>y\<in>t. f1 (g1 y) = y" "g1 ` t = s" "continuous_on t g1" | |
| 5320 | using assms(1) unfolding homeomorphic_def homeomorphism_def by auto | |
| 5321 | obtain f2 g2 where fg2:"\<forall>x\<in>t. g2 (f2 x) = x" "f2 ` t = u" "continuous_on t f2" "\<forall>y\<in>u. f2 (g2 y) = y" "g2 ` u = t" "continuous_on u g2" | |
| 5322 | using assms(2) unfolding homeomorphic_def homeomorphism_def by auto | |
| 5323 | ||
| 5324 |   { fix x assume "x\<in>s" hence "(g1 \<circ> g2) ((f2 \<circ> f1) x) = x" using fg1(1)[THEN bspec[where x=x]] and fg2(1)[THEN bspec[where x="f1 x"]] and fg1(2) by auto }
 | |
| 5325 | moreover have "(f2 \<circ> f1) ` s = u" using fg1(2) fg2(2) by auto | |
| 5326 | moreover have "continuous_on s (f2 \<circ> f1)" using continuous_on_compose[OF fg1(3)] and fg2(3) unfolding fg1(2) by auto | |
| 5327 |   moreover { fix y assume "y\<in>u" hence "(f2 \<circ> f1) ((g1 \<circ> g2) y) = y" using fg2(4)[THEN bspec[where x=y]] and fg1(4)[THEN bspec[where x="g2 y"]] and fg2(5) by auto }
 | |
| 5328 | moreover have "(g1 \<circ> g2) ` u = s" using fg1(5) fg2(5) by auto | |
| 5329 | moreover have "continuous_on u (g1 \<circ> g2)" using continuous_on_compose[OF fg2(6)] and fg1(6) unfolding fg2(5) by auto | |
| 5330 | ultimately show ?thesis unfolding homeomorphic_def homeomorphism_def apply(rule_tac x="f2 \<circ> f1" in exI) apply(rule_tac x="g1 \<circ> g2" in exI) by auto | |
| 5331 | qed | |
| 5332 | ||
| 5333 | lemma homeomorphic_minimal: | |
| 5334 | "s homeomorphic t \<longleftrightarrow> | |
| 5335 | (\<exists>f g. (\<forall>x\<in>s. f(x) \<in> t \<and> (g(f(x)) = x)) \<and> | |
| 5336 | (\<forall>y\<in>t. g(y) \<in> s \<and> (f(g(y)) = y)) \<and> | |
| 5337 | continuous_on s f \<and> continuous_on t g)" | |
| 5338 | unfolding homeomorphic_def homeomorphism_def | |
| 5339 | apply auto apply (rule_tac x=f in exI) apply (rule_tac x=g in exI) | |
| 5340 | apply auto apply (rule_tac x=f in exI) apply (rule_tac x=g in exI) apply auto | |
| 5341 | unfolding image_iff | |
| 5342 | apply(erule_tac x="g x" in ballE) apply(erule_tac x="x" in ballE) | |
| 5343 | apply auto apply(rule_tac x="g x" in bexI) apply auto | |
| 5344 | apply(erule_tac x="f x" in ballE) apply(erule_tac x="x" in ballE) | |
| 5345 | apply auto apply(rule_tac x="f x" in bexI) by auto | |
| 5346 | ||
| 5347 | subsection{* Relatively weak hypotheses if a set is compact.                           *}
 | |
| 5348 | ||
| 5349 | definition "inv_on f s = (\<lambda>x. SOME y. y\<in>s \<and> f y = x)" | |
| 5350 | ||
| 5351 | lemma assumes "inj_on f s" "x\<in>s" | |
| 5352 | shows "inv_on f s (f x) = x" | |
| 5353 | using assms unfolding inj_on_def inv_on_def by auto | |
| 5354 | ||
| 5355 | lemma homeomorphism_compact: | |
| 5356 | fixes f :: "'a::heine_borel \<Rightarrow> 'b::heine_borel" | |
| 5357 | (* class constraint due to continuous_on_inverse *) | |
| 5358 | assumes "compact s" "continuous_on s f" "f ` s = t" "inj_on f s" | |
| 5359 | shows "\<exists>g. homeomorphism s t f g" | |
| 5360 | proof- | |
| 5361 | def g \<equiv> "\<lambda>x. SOME y. y\<in>s \<and> f y = x" | |
| 5362 | have g:"\<forall>x\<in>s. g (f x) = x" using assms(3) assms(4)[unfolded inj_on_def] unfolding g_def by auto | |
| 5363 |   { fix y assume "y\<in>t"
 | |
| 5364 | then obtain x where x:"f x = y" "x\<in>s" using assms(3) by auto | |
| 5365 | hence "g (f x) = x" using g by auto | |
| 5366 | hence "f (g y) = y" unfolding x(1)[THEN sym] by auto } | |
| 5367 | hence g':"\<forall>x\<in>t. f (g x) = x" by auto | |
| 5368 | moreover | |
| 5369 |   { fix x
 | |
| 5370 | have "x\<in>s \<Longrightarrow> x \<in> g ` t" using g[THEN bspec[where x=x]] unfolding image_iff using assms(3) by(auto intro!: bexI[where x="f x"]) | |
| 5371 | moreover | |
| 5372 |     { assume "x\<in>g ` t"
 | |
| 5373 | then obtain y where y:"y\<in>t" "g y = x" by auto | |
| 5374 | then obtain x' where x':"x'\<in>s" "f x' = y" using assms(3) by auto | |
| 5375 | hence "x \<in> s" unfolding g_def using someI2[of "\<lambda>b. b\<in>s \<and> f b = y" x' "\<lambda>x. x\<in>s"] unfolding y(2)[THEN sym] and g_def by auto } | |
| 5376 | ultimately have "x\<in>s \<longleftrightarrow> x \<in> g ` t" by auto } | |
| 5377 | hence "g ` t = s" by auto | |
| 5378 | ultimately | |
| 5379 | show ?thesis unfolding homeomorphism_def homeomorphic_def | |
| 5380 | apply(rule_tac x=g in exI) using g and assms(3) and continuous_on_inverse[OF assms(2,1), of g, unfolded assms(3)] and assms(2) by auto | |
| 5381 | qed | |
| 5382 | ||
| 5383 | lemma homeomorphic_compact: | |
| 5384 | fixes f :: "'a::heine_borel \<Rightarrow> 'b::heine_borel" | |
| 5385 | (* class constraint due to continuous_on_inverse *) | |
| 5386 | shows "compact s \<Longrightarrow> continuous_on s f \<Longrightarrow> (f ` s = t) \<Longrightarrow> inj_on f s | |
| 5387 | \<Longrightarrow> s homeomorphic t" | |
| 5388 | unfolding homeomorphic_def by(metis homeomorphism_compact) | |
| 5389 | ||
| 5390 | text{* Preservation of topological properties.                                   *}
 | |
| 5391 | ||
| 5392 | lemma homeomorphic_compactness: | |
| 5393 | "s homeomorphic t ==> (compact s \<longleftrightarrow> compact t)" | |
| 5394 | unfolding homeomorphic_def homeomorphism_def | |
| 5395 | by (metis compact_continuous_image) | |
| 5396 | ||
| 5397 | text{* Results on translation, scaling etc.                                      *}
 | |
| 5398 | ||
| 5399 | lemma homeomorphic_scaling: | |
| 5400 | fixes s :: "'a::real_normed_vector set" | |
| 5401 | assumes "c \<noteq> 0" shows "s homeomorphic ((\<lambda>x. c *\<^sub>R x) ` s)" | |
| 5402 | unfolding homeomorphic_minimal | |
| 5403 | apply(rule_tac x="\<lambda>x. c *\<^sub>R x" in exI) | |
| 5404 | apply(rule_tac x="\<lambda>x. (1 / c) *\<^sub>R x" in exI) | |
| 5405 | using assms apply auto | |
| 5406 | using continuous_on_cmul[OF continuous_on_id] by auto | |
| 5407 | ||
| 5408 | lemma homeomorphic_translation: | |
| 5409 | fixes s :: "'a::real_normed_vector set" | |
| 5410 | shows "s homeomorphic ((\<lambda>x. a + x) ` s)" | |
| 5411 | unfolding homeomorphic_minimal | |
| 5412 | apply(rule_tac x="\<lambda>x. a + x" in exI) | |
| 5413 | apply(rule_tac x="\<lambda>x. -a + x" in exI) | |
| 5414 | using continuous_on_add[OF continuous_on_const continuous_on_id] by auto | |
| 5415 | ||
| 5416 | lemma homeomorphic_affinity: | |
| 5417 | fixes s :: "'a::real_normed_vector set" | |
| 5418 | assumes "c \<noteq> 0" shows "s homeomorphic ((\<lambda>x. a + c *\<^sub>R x) ` s)" | |
| 5419 | proof- | |
| 5420 | have *:"op + a ` op *\<^sub>R c ` s = (\<lambda>x. a + c *\<^sub>R x) ` s" by auto | |
| 5421 | show ?thesis | |
| 5422 | using homeomorphic_trans | |
| 5423 | using homeomorphic_scaling[OF assms, of s] | |
| 5424 | using homeomorphic_translation[of "(\<lambda>x. c *\<^sub>R x) ` s" a] unfolding * by auto | |
| 5425 | qed | |
| 5426 | ||
| 5427 | lemma homeomorphic_balls: | |
| 5428 | fixes a b ::"'a::real_normed_vector" (* FIXME: generalize to metric_space *) | |
| 5429 | assumes "0 < d" "0 < e" | |
| 5430 | shows "(ball a d) homeomorphic (ball b e)" (is ?th) | |
| 5431 | "(cball a d) homeomorphic (cball b e)" (is ?cth) | |
| 5432 | proof- | |
| 5433 | have *:"\<bar>e / d\<bar> > 0" "\<bar>d / e\<bar> >0" using assms using divide_pos_pos by auto | |
| 5434 | show ?th unfolding homeomorphic_minimal | |
| 5435 | apply(rule_tac x="\<lambda>x. b + (e/d) *\<^sub>R (x - a)" in exI) | |
| 5436 | apply(rule_tac x="\<lambda>x. a + (d/e) *\<^sub>R (x - b)" in exI) | |
| 5437 | using assms apply (auto simp add: dist_commute) | |
| 5438 | unfolding dist_norm | |
| 5439 | apply (auto simp add: pos_divide_less_eq mult_strict_left_mono) | |
| 5440 | unfolding continuous_on | |
| 5441 | by (intro ballI tendsto_intros, simp, assumption)+ | |
| 5442 | next | |
| 5443 | have *:"\<bar>e / d\<bar> > 0" "\<bar>d / e\<bar> >0" using assms using divide_pos_pos by auto | |
| 5444 | show ?cth unfolding homeomorphic_minimal | |
| 5445 | apply(rule_tac x="\<lambda>x. b + (e/d) *\<^sub>R (x - a)" in exI) | |
| 5446 | apply(rule_tac x="\<lambda>x. a + (d/e) *\<^sub>R (x - b)" in exI) | |
| 5447 | using assms apply (auto simp add: dist_commute) | |
| 5448 | unfolding dist_norm | |
| 5449 | apply (auto simp add: pos_divide_le_eq) | |
| 5450 | unfolding continuous_on | |
| 5451 | by (intro ballI tendsto_intros, simp, assumption)+ | |
| 5452 | qed | |
| 5453 | ||
| 5454 | text{* "Isometry" (up to constant bounds) of injective linear map etc.           *}
 | |
| 5455 | ||
| 5456 | lemma cauchy_isometric: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5457 | fixes x :: "nat \<Rightarrow> real ^ 'n" | 
| 33175 | 5458 | assumes e:"0 < e" and s:"subspace s" and f:"bounded_linear f" and normf:"\<forall>x\<in>s. norm(f x) \<ge> e * norm(x)" and xs:"\<forall>n::nat. x n \<in> s" and cf:"Cauchy(f o x)" | 
| 5459 | shows "Cauchy x" | |
| 5460 | proof- | |
| 5461 | interpret f: bounded_linear f by fact | |
| 5462 |   { fix d::real assume "d>0"
 | |
| 5463 | then obtain N where N:"\<forall>n\<ge>N. norm (f (x n) - f (x N)) < e * d" | |
| 5464 | using cf[unfolded cauchy o_def dist_norm, THEN spec[where x="e*d"]] and e and mult_pos_pos[of e d] by auto | |
| 5465 |     { fix n assume "n\<ge>N"
 | |
| 5466 | hence "norm (f (x n - x N)) < e * d" using N[THEN spec[where x=n]] unfolding f.diff[THEN sym] by auto | |
| 5467 | moreover have "e * norm (x n - x N) \<le> norm (f (x n - x N))" | |
| 5468 | using subspace_sub[OF s, of "x n" "x N"] using xs[THEN spec[where x=N]] and xs[THEN spec[where x=n]] | |
| 5469 | using normf[THEN bspec[where x="x n - x N"]] by auto | |
| 5470 | ultimately have "norm (x n - x N) < d" using `e>0` | |
| 5471 | using mult_left_less_imp_less[of e "norm (x n - x N)" d] by auto } | |
| 5472 | hence "\<exists>N. \<forall>n\<ge>N. norm (x n - x N) < d" by auto } | |
| 5473 | thus ?thesis unfolding cauchy and dist_norm by auto | |
| 5474 | qed | |
| 5475 | ||
| 5476 | lemma complete_isometric_image: | |
| 5477 | fixes f :: "real ^ _ \<Rightarrow> real ^ _" | |
| 5478 | assumes "0 < e" and s:"subspace s" and f:"bounded_linear f" and normf:"\<forall>x\<in>s. norm(f x) \<ge> e * norm(x)" and cs:"complete s" | |
| 5479 | shows "complete(f ` s)" | |
| 5480 | proof- | |
| 5481 |   { fix g assume as:"\<forall>n::nat. g n \<in> f ` s" and cfg:"Cauchy g"
 | |
| 33324 | 5482 | then obtain x where "\<forall>n. x n \<in> s \<and> g n = f (x n)" | 
| 33175 | 5483 | using choice[of "\<lambda> n xa. xa \<in> s \<and> g n = f xa"] by auto | 
| 5484 | hence x:"\<forall>n. x n \<in> s" "\<forall>n. g n = f (x n)" by auto | |
| 5485 | hence "f \<circ> x = g" unfolding expand_fun_eq by auto | |
| 5486 | then obtain l where "l\<in>s" and l:"(x ---> l) sequentially" | |
| 5487 | using cs[unfolded complete_def, THEN spec[where x="x"]] | |
| 5488 | using cauchy_isometric[OF `0<e` s f normf] and cfg and x(1) by auto | |
| 5489 | hence "\<exists>l\<in>f ` s. (g ---> l) sequentially" | |
| 5490 | using linear_continuous_at[OF f, unfolded continuous_at_sequentially, THEN spec[where x=x], of l] | |
| 5491 | unfolding `f \<circ> x = g` by auto } | |
| 5492 | thus ?thesis unfolding complete_def by auto | |
| 5493 | qed | |
| 5494 | ||
| 5495 | lemma dist_0_norm: | |
| 5496 | fixes x :: "'a::real_normed_vector" | |
| 5497 | shows "dist 0 x = norm x" | |
| 5498 | unfolding dist_norm by simp | |
| 5499 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5500 | lemma injective_imp_isometric: fixes f::"real^'m \<Rightarrow> real^'n" | 
| 33175 | 5501 | assumes s:"closed s" "subspace s" and f:"bounded_linear f" "\<forall>x\<in>s. (f x = 0) \<longrightarrow> (x = 0)" | 
| 5502 | shows "\<exists>e>0. \<forall>x\<in>s. norm (f x) \<ge> e * norm(x)" | |
| 5503 | proof(cases "s \<subseteq> {0::real^'m}")
 | |
| 5504 | case True | |
| 5505 |   { fix x assume "x \<in> s"
 | |
| 5506 | hence "x = 0" using True by auto | |
| 5507 | hence "norm x \<le> norm (f x)" by auto } | |
| 5508 | thus ?thesis by(auto intro!: exI[where x=1]) | |
| 5509 | next | |
| 5510 | interpret f: bounded_linear f by fact | |
| 5511 | case False | |
| 5512 | then obtain a where a:"a\<noteq>0" "a\<in>s" by auto | |
| 5513 |   from False have "s \<noteq> {}" by auto
 | |
| 5514 |   let ?S = "{f x| x. (x \<in> s \<and> norm x = norm a)}"
 | |
| 5515 |   let ?S' = "{x::real^'m. x\<in>s \<and> norm x = norm a}"
 | |
| 5516 |   let ?S'' = "{x::real^'m. norm x = norm a}"
 | |
| 5517 | ||
| 5518 | have "?S'' = frontier(cball 0 (norm a))" unfolding frontier_cball and dist_norm by (auto simp add: norm_minus_cancel) | |
| 5519 | hence "compact ?S''" using compact_frontier[OF compact_cball, of 0 "norm a"] by auto | |
| 5520 | moreover have "?S' = s \<inter> ?S''" by auto | |
| 5521 | ultimately have "compact ?S'" using closed_inter_compact[of s ?S''] using s(1) by auto | |
| 5522 | moreover have *:"f ` ?S' = ?S" by auto | |
| 5523 | ultimately have "compact ?S" using compact_continuous_image[OF linear_continuous_on[OF f(1)], of ?S'] by auto | |
| 5524 | hence "closed ?S" using compact_imp_closed by auto | |
| 5525 |   moreover have "?S \<noteq> {}" using a by auto
 | |
| 5526 | ultimately obtain b' where "b'\<in>?S" "\<forall>y\<in>?S. norm b' \<le> norm y" using distance_attains_inf[of ?S 0] unfolding dist_0_norm by auto | |
| 5527 |   then obtain b where "b\<in>s" and ba:"norm b = norm a" and b:"\<forall>x\<in>{x \<in> s. norm x = norm a}. norm (f b) \<le> norm (f x)" unfolding *[THEN sym] unfolding image_iff by auto
 | |
| 5528 | ||
| 5529 | let ?e = "norm (f b) / norm b" | |
| 5530 | have "norm b > 0" using ba and a and norm_ge_zero by auto | |
| 5531 | moreover have "norm (f b) > 0" using f(2)[THEN bspec[where x=b], OF `b\<in>s`] using `norm b >0` unfolding zero_less_norm_iff by auto | |
| 5532 | ultimately have "0 < norm (f b) / norm b" by(simp only: divide_pos_pos) | |
| 5533 | moreover | |
| 5534 |   { fix x assume "x\<in>s"
 | |
| 5535 | hence "norm (f b) / norm b * norm x \<le> norm (f x)" | |
| 5536 | proof(cases "x=0") | |
| 5537 | case True thus "norm (f b) / norm b * norm x \<le> norm (f x)" by auto | |
| 5538 | next | |
| 5539 | case False | |
| 5540 | hence *:"0 < norm a / norm x" using `a\<noteq>0` unfolding zero_less_norm_iff[THEN sym] by(simp only: divide_pos_pos) | |
| 5541 | have "\<forall>c. \<forall>x\<in>s. c *\<^sub>R x \<in> s" using s[unfolded subspace_def smult_conv_scaleR] by auto | |
| 5542 |       hence "(norm a / norm x) *\<^sub>R x \<in> {x \<in> s. norm x = norm a}" using `x\<in>s` and `x\<noteq>0` by auto
 | |
| 5543 | thus "norm (f b) / norm b * norm x \<le> norm (f x)" using b[THEN bspec[where x="(norm a / norm x) *\<^sub>R x"]] | |
| 5544 | unfolding f.scaleR and ba using `x\<noteq>0` `a\<noteq>0` | |
| 5545 | by (auto simp add: real_mult_commute pos_le_divide_eq pos_divide_le_eq) | |
| 5546 | qed } | |
| 5547 | ultimately | |
| 5548 | show ?thesis by auto | |
| 5549 | qed | |
| 5550 | ||
| 5551 | lemma closed_injective_image_subspace: | |
| 5552 | fixes f :: "real ^ _ \<Rightarrow> real ^ _" | |
| 5553 | assumes "subspace s" "bounded_linear f" "\<forall>x\<in>s. f x = 0 --> x = 0" "closed s" | |
| 5554 | shows "closed(f ` s)" | |
| 5555 | proof- | |
| 5556 | obtain e where "e>0" and e:"\<forall>x\<in>s. e * norm x \<le> norm (f x)" using injective_imp_isometric[OF assms(4,1,2,3)] by auto | |
| 5557 | show ?thesis using complete_isometric_image[OF `e>0` assms(1,2) e] and assms(4) | |
| 5558 | unfolding complete_eq_closed[THEN sym] by auto | |
| 5559 | qed | |
| 5560 | ||
| 5561 | subsection{* Some properties of a canonical subspace.                                  *}
 | |
| 5562 | ||
| 5563 | lemma subspace_substandard: | |
| 34289 | 5564 |  "subspace {x::real^_. (\<forall>i. P i \<longrightarrow> x$i = 0)}"
 | 
| 33175 | 5565 | unfolding subspace_def by(auto simp add: vector_add_component vector_smult_component elim!: ballE) | 
| 5566 | ||
| 5567 | lemma closed_substandard: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5568 |  "closed {x::real^'n. \<forall>i. P i --> x$i = 0}" (is "closed ?A")
 | 
| 33175 | 5569 | proof- | 
| 5570 |   let ?D = "{i. P i}"
 | |
| 5571 |   let ?Bs = "{{x::real^'n. inner (basis i) x = 0}| i. i \<in> ?D}"
 | |
| 5572 |   { fix x
 | |
| 5573 |     { assume "x\<in>?A"
 | |
| 5574 | hence x:"\<forall>i\<in>?D. x $ i = 0" by auto | |
| 5575 | hence "x\<in> \<Inter> ?Bs" by(auto simp add: inner_basis x) } | |
| 5576 | moreover | |
| 5577 |     { assume x:"x\<in>\<Inter>?Bs"
 | |
| 5578 |       { fix i assume i:"i \<in> ?D"
 | |
| 5579 |         then obtain B where BB:"B \<in> ?Bs" and B:"B = {x::real^'n. inner (basis i) x = 0}" by auto
 | |
| 5580 | hence "x $ i = 0" unfolding B using x unfolding inner_basis by auto } | |
| 5581 | hence "x\<in>?A" by auto } | |
| 5582 | ultimately have "x\<in>?A \<longleftrightarrow> x\<in> \<Inter>?Bs" by auto } | |
| 5583 | hence "?A = \<Inter> ?Bs" by auto | |
| 5584 | thus ?thesis by(auto simp add: closed_Inter closed_hyperplane) | |
| 5585 | qed | |
| 5586 | ||
| 5587 | lemma dim_substandard: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5588 |   shows "dim {x::real^'n. \<forall>i. i \<notin> d \<longrightarrow> x$i = 0} = card d" (is "dim ?A = _")
 | 
| 33175 | 5589 | proof- | 
| 5590 | let ?D = "UNIV::'n set" | |
| 5591 | let ?B = "(basis::'n\<Rightarrow>real^'n) ` d" | |
| 5592 | ||
| 5593 | let ?bas = "basis::'n \<Rightarrow> real^'n" | |
| 5594 | ||
| 5595 | have "?B \<subseteq> ?A" by auto | |
| 5596 | ||
| 5597 | moreover | |
| 5598 |   { fix x::"real^'n" assume "x\<in>?A"
 | |
| 5599 | with finite[of d] | |
| 5600 | have "x\<in> span ?B" | |
| 5601 | proof(induct d arbitrary: x) | |
| 5602 | case empty hence "x=0" unfolding Cart_eq by auto | |
| 5603 |       thus ?case using subspace_0[OF subspace_span[of "{}"]] by auto
 | |
| 5604 | next | |
| 5605 | case (insert k F) | |
| 5606 | hence *:"\<forall>i. i \<notin> insert k F \<longrightarrow> x $ i = 0" by auto | |
| 5607 | have **:"F \<subseteq> insert k F" by auto | |
| 5608 | def y \<equiv> "x - x$k *\<^sub>R basis k" | |
| 5609 | have y:"x = y + (x$k) *\<^sub>R basis k" unfolding y_def by auto | |
| 5610 |       { fix i assume i':"i \<notin> F"
 | |
| 5611 | hence "y $ i = 0" unfolding y_def unfolding vector_minus_component | |
| 5612 | and vector_smult_component and basis_component | |
| 5613 | using *[THEN spec[where x=i]] by auto } | |
| 5614 | hence "y \<in> span (basis ` (insert k F))" using insert(3) | |
| 5615 | using span_mono[of "?bas ` F" "?bas ` (insert k F)"] | |
| 5616 | using image_mono[OF **, of basis] by auto | |
| 5617 | moreover | |
| 5618 | have "basis k \<in> span (?bas ` (insert k F))" by(rule span_superset, auto) | |
| 5619 | hence "x$k *\<^sub>R basis k \<in> span (?bas ` (insert k F))" | |
| 5620 | using span_mul [where 'a=real, unfolded smult_conv_scaleR] by auto | |
| 5621 | ultimately | |
| 5622 | have "y + x$k *\<^sub>R basis k \<in> span (?bas ` (insert k F))" | |
| 5623 | using span_add by auto | |
| 5624 | thus ?case using y by auto | |
| 5625 | qed | |
| 5626 | } | |
| 5627 | hence "?A \<subseteq> span ?B" by auto | |
| 5628 | ||
| 5629 | moreover | |
| 5630 |   { fix x assume "x \<in> ?B"
 | |
| 5631 |     hence "x\<in>{(basis i)::real^'n |i. i \<in> ?D}" using assms by auto  }
 | |
| 5632 | hence "independent ?B" using independent_mono[OF independent_stdbasis, of ?B] and assms by auto | |
| 5633 | ||
| 5634 | moreover | |
| 5635 | have "d \<subseteq> ?D" unfolding subset_eq using assms by auto | |
| 5636 | hence *:"inj_on (basis::'n\<Rightarrow>real^'n) d" using subset_inj_on[OF basis_inj, of "d"] by auto | |
| 33715 | 5637 | have "card ?B = card d" unfolding card_image[OF *] by auto | 
| 33175 | 5638 | |
| 5639 | ultimately show ?thesis using dim_unique[of "basis ` d" ?A] by auto | |
| 5640 | qed | |
| 5641 | ||
| 5642 | text{* Hence closure and completeness of all subspaces.                          *}
 | |
| 5643 | ||
| 5644 | lemma closed_subspace_lemma: "n \<le> card (UNIV::'n::finite set) \<Longrightarrow> \<exists>A::'n set. card A = n" | |
| 5645 | apply (induct n) | |
| 5646 | apply (rule_tac x="{}" in exI, simp)
 | |
| 5647 | apply clarsimp | |
| 5648 | apply (subgoal_tac "\<exists>x. x \<notin> A") | |
| 5649 | apply (erule exE) | |
| 5650 | apply (rule_tac x="insert x A" in exI, simp) | |
| 5651 | apply (subgoal_tac "A \<noteq> UNIV", auto) | |
| 5652 | done | |
| 5653 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5654 | lemma closed_subspace: fixes s::"(real^'n) set" | 
| 33175 | 5655 | assumes "subspace s" shows "closed s" | 
| 5656 | proof- | |
| 5657 | have "dim s \<le> card (UNIV :: 'n set)" using dim_subset_univ by auto | |
| 5658 | then obtain d::"'n set" where t: "card d = dim s" | |
| 5659 | using closed_subspace_lemma by auto | |
| 5660 |   let ?t = "{x::real^'n. \<forall>i. i \<notin> d \<longrightarrow> x$i = 0}"
 | |
| 5661 | obtain f where f:"bounded_linear f" "f ` ?t = s" "inj_on f ?t" | |
| 5662 | using subspace_isomorphism[unfolded linear_conv_bounded_linear, OF subspace_substandard[of "\<lambda>i. i \<notin> d"] assms] | |
| 5663 | using dim_substandard[of d] and t by auto | |
| 5664 | interpret f: bounded_linear f by fact | |
| 5665 | have "\<forall>x\<in>?t. f x = 0 \<longrightarrow> x = 0" using f.zero using f(3)[unfolded inj_on_def] | |
| 5666 | by(erule_tac x=0 in ballE) auto | |
| 5667 | moreover have "closed ?t" using closed_substandard . | |
| 5668 | moreover have "subspace ?t" using subspace_substandard . | |
| 5669 | ultimately show ?thesis using closed_injective_image_subspace[of ?t f] | |
| 5670 | unfolding f(2) using f(1) by auto | |
| 5671 | qed | |
| 5672 | ||
| 5673 | lemma complete_subspace: | |
| 5674 | fixes s :: "(real ^ _) set" shows "subspace s ==> complete s" | |
| 5675 | using complete_eq_closed closed_subspace | |
| 5676 | by auto | |
| 5677 | ||
| 5678 | lemma dim_closure: | |
| 5679 | fixes s :: "(real ^ _) set" | |
| 5680 | shows "dim(closure s) = dim s" (is "?dc = ?d") | |
| 5681 | proof- | |
| 5682 | have "?dc \<le> ?d" using closure_minimal[OF span_inc, of s] | |
| 5683 | using closed_subspace[OF subspace_span, of s] | |
| 5684 | using dim_subset[of "closure s" "span s"] unfolding dim_span by auto | |
| 5685 | thus ?thesis using dim_subset[OF closure_subset, of s] by auto | |
| 5686 | qed | |
| 5687 | ||
| 5688 | text{* Affine transformations of intervals.                                      *}
 | |
| 5689 | ||
| 5690 | lemma affinity_inverses: | |
| 5691 | assumes m0: "m \<noteq> (0::'a::field)" | |
| 5692 | shows "(\<lambda>x. m *s x + c) o (\<lambda>x. inverse(m) *s x + (-(inverse(m) *s c))) = id" | |
| 5693 | "(\<lambda>x. inverse(m) *s x + (-(inverse(m) *s c))) o (\<lambda>x. m *s x + c) = id" | |
| 5694 | using m0 | |
| 5695 | apply (auto simp add: expand_fun_eq vector_add_ldistrib vector_smult_assoc) | |
| 5696 | by (simp add: vector_smult_lneg[symmetric] vector_smult_assoc vector_sneg_minus1[symmetric]) | |
| 5697 | ||
| 5698 | lemma real_affinity_le: | |
| 5699 | "0 < (m::'a::ordered_field) ==> (m * x + c \<le> y \<longleftrightarrow> x \<le> inverse(m) * y + -(c / m))" | |
| 5700 | by (simp add: field_simps inverse_eq_divide) | |
| 5701 | ||
| 5702 | lemma real_le_affinity: | |
| 5703 | "0 < (m::'a::ordered_field) ==> (y \<le> m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) \<le> x)" | |
| 5704 | by (simp add: field_simps inverse_eq_divide) | |
| 5705 | ||
| 5706 | lemma real_affinity_lt: | |
| 5707 | "0 < (m::'a::ordered_field) ==> (m * x + c < y \<longleftrightarrow> x < inverse(m) * y + -(c / m))" | |
| 5708 | by (simp add: field_simps inverse_eq_divide) | |
| 5709 | ||
| 5710 | lemma real_lt_affinity: | |
| 5711 | "0 < (m::'a::ordered_field) ==> (y < m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) < x)" | |
| 5712 | by (simp add: field_simps inverse_eq_divide) | |
| 5713 | ||
| 5714 | lemma real_affinity_eq: | |
| 5715 | "(m::'a::ordered_field) \<noteq> 0 ==> (m * x + c = y \<longleftrightarrow> x = inverse(m) * y + -(c / m))" | |
| 5716 | by (simp add: field_simps inverse_eq_divide) | |
| 5717 | ||
| 5718 | lemma real_eq_affinity: | |
| 5719 | "(m::'a::ordered_field) \<noteq> 0 ==> (y = m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) = x)" | |
| 5720 | by (simp add: field_simps inverse_eq_divide) | |
| 5721 | ||
| 5722 | lemma vector_affinity_eq: | |
| 5723 | assumes m0: "(m::'a::field) \<noteq> 0" | |
| 5724 | shows "m *s x + c = y \<longleftrightarrow> x = inverse m *s y + -(inverse m *s c)" | |
| 5725 | proof | |
| 5726 | assume h: "m *s x + c = y" | |
| 5727 | hence "m *s x = y - c" by (simp add: ring_simps) | |
| 5728 | hence "inverse m *s (m *s x) = inverse m *s (y - c)" by simp | |
| 5729 | then show "x = inverse m *s y + - (inverse m *s c)" | |
| 5730 | using m0 by (simp add: vector_smult_assoc vector_ssub_ldistrib) | |
| 5731 | next | |
| 5732 | assume h: "x = inverse m *s y + - (inverse m *s c)" | |
| 5733 | show "m *s x + c = y" unfolding h diff_minus[symmetric] | |
| 5734 | using m0 by (simp add: vector_smult_assoc vector_ssub_ldistrib) | |
| 5735 | qed | |
| 5736 | ||
| 5737 | lemma vector_eq_affinity: | |
| 5738 | "(m::'a::field) \<noteq> 0 ==> (y = m *s x + c \<longleftrightarrow> inverse(m) *s y + -(inverse(m) *s c) = x)" | |
| 5739 | using vector_affinity_eq[where m=m and x=x and y=y and c=c] | |
| 5740 | by metis | |
| 5741 | ||
| 5742 | lemma image_affinity_interval: fixes m::real | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5743 | fixes a b c :: "real^'n" | 
| 33175 | 5744 |   shows "(\<lambda>x. m *\<^sub>R x + c) ` {a .. b} =
 | 
| 5745 |             (if {a .. b} = {} then {}
 | |
| 5746 |             else (if 0 \<le> m then {m *\<^sub>R a + c .. m *\<^sub>R b + c}
 | |
| 5747 |             else {m *\<^sub>R b + c .. m *\<^sub>R a + c}))"
 | |
| 5748 | proof(cases "m=0") | |
| 5749 |   { fix x assume "x \<le> c" "c \<le> x"
 | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 5750 | hence "x=c" unfolding vector_le_def and Cart_eq by (auto intro: order_antisym) } | 
| 33175 | 5751 | moreover case True | 
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 5752 |   moreover have "c \<in> {m *\<^sub>R a + c..m *\<^sub>R b + c}" unfolding True by(auto simp add: vector_le_def)
 | 
| 33175 | 5753 | ultimately show ?thesis by auto | 
| 5754 | next | |
| 5755 | case False | |
| 5756 |   { fix y assume "a \<le> y" "y \<le> b" "m > 0"
 | |
| 5757 | hence "m *\<^sub>R a + c \<le> m *\<^sub>R y + c" "m *\<^sub>R y + c \<le> m *\<^sub>R b + c" | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 5758 | unfolding vector_le_def by(auto simp add: vector_smult_component vector_add_component) | 
| 33175 | 5759 | } moreover | 
| 5760 |   { fix y assume "a \<le> y" "y \<le> b" "m < 0"
 | |
| 5761 | hence "m *\<^sub>R b + c \<le> m *\<^sub>R y + c" "m *\<^sub>R y + c \<le> m *\<^sub>R a + c" | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 5762 | unfolding vector_le_def by(auto simp add: vector_smult_component vector_add_component mult_left_mono_neg elim!:ballE) | 
| 33175 | 5763 | } moreover | 
| 5764 |   { fix y assume "m > 0"  "m *\<^sub>R a + c \<le> y"  "y \<le> m *\<^sub>R b + c"
 | |
| 5765 |     hence "y \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}"
 | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 5766 | unfolding image_iff Bex_def mem_interval vector_le_def | 
| 33175 | 5767 | apply(auto simp add: vector_smult_component vector_add_component vector_minus_component vector_smult_assoc pth_3[symmetric] | 
| 5768 | intro!: exI[where x="(1 / m) *\<^sub>R (y - c)"]) | |
| 5769 | by(auto simp add: pos_le_divide_eq pos_divide_le_eq real_mult_commute diff_le_iff) | |
| 5770 | } moreover | |
| 5771 |   { fix y assume "m *\<^sub>R b + c \<le> y" "y \<le> m *\<^sub>R a + c" "m < 0"
 | |
| 5772 |     hence "y \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}"
 | |
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 5773 | unfolding image_iff Bex_def mem_interval vector_le_def | 
| 33175 | 5774 | apply(auto simp add: vector_smult_component vector_add_component vector_minus_component vector_smult_assoc pth_3[symmetric] | 
| 5775 | intro!: exI[where x="(1 / m) *\<^sub>R (y - c)"]) | |
| 5776 | by(auto simp add: neg_le_divide_eq neg_divide_le_eq real_mult_commute diff_le_iff) | |
| 5777 | } | |
| 5778 | ultimately show ?thesis using False by auto | |
| 5779 | qed | |
| 5780 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5781 | lemma image_smult_interval:"(\<lambda>x. m *\<^sub>R (x::real^'n)) ` {a..b} =
 | 
| 33175 | 5782 |   (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a..m *\<^sub>R b} else {m *\<^sub>R b..m *\<^sub>R a})"
 | 
| 5783 | using image_affinity_interval[of m 0 a b] by auto | |
| 5784 | ||
| 5785 | subsection{* Banach fixed point theorem (not really topological...) *}
 | |
| 5786 | ||
| 5787 | lemma banach_fix: | |
| 5788 |   assumes s:"complete s" "s \<noteq> {}" and c:"0 \<le> c" "c < 1" and f:"(f ` s) \<subseteq> s" and
 | |
| 5789 | lipschitz:"\<forall>x\<in>s. \<forall>y\<in>s. dist (f x) (f y) \<le> c * dist x y" | |
| 5790 | shows "\<exists>! x\<in>s. (f x = x)" | |
| 5791 | proof- | |
| 5792 | have "1 - c > 0" using c by auto | |
| 5793 | ||
| 5794 | from s(2) obtain z0 where "z0 \<in> s" by auto | |
| 5795 | def z \<equiv> "\<lambda>n. (f ^^ n) z0" | |
| 5796 |   { fix n::nat
 | |
| 5797 | have "z n \<in> s" unfolding z_def | |
| 5798 | proof(induct n) case 0 thus ?case using `z0 \<in>s` by auto | |
| 5799 | next case Suc thus ?case using f by auto qed } | |
| 5800 | note z_in_s = this | |
| 5801 | ||
| 5802 | def d \<equiv> "dist (z 0) (z 1)" | |
| 5803 | ||
| 5804 | have fzn:"\<And>n. f (z n) = z (Suc n)" unfolding z_def by auto | |
| 5805 |   { fix n::nat
 | |
| 5806 | have "dist (z n) (z (Suc n)) \<le> (c ^ n) * d" | |
| 5807 | proof(induct n) | |
| 5808 | case 0 thus ?case unfolding d_def by auto | |
| 5809 | next | |
| 5810 | case (Suc m) | |
| 5811 | hence "c * dist (z m) (z (Suc m)) \<le> c ^ Suc m * d" | |
| 5812 | using `0 \<le> c` using mult_mono1_class.mult_mono1[of "dist (z m) (z (Suc m))" "c ^ m * d" c] by auto | |
| 5813 | thus ?case using lipschitz[THEN bspec[where x="z m"], OF z_in_s, THEN bspec[where x="z (Suc m)"], OF z_in_s] | |
| 5814 | unfolding fzn and mult_le_cancel_left by auto | |
| 5815 | qed | |
| 5816 | } note cf_z = this | |
| 5817 | ||
| 5818 |   { fix n m::nat
 | |
| 5819 | have "(1 - c) * dist (z m) (z (m+n)) \<le> (c ^ m) * d * (1 - c ^ n)" | |
| 5820 | proof(induct n) | |
| 5821 | case 0 show ?case by auto | |
| 5822 | next | |
| 5823 | case (Suc k) | |
| 5824 | have "(1 - c) * dist (z m) (z (m + Suc k)) \<le> (1 - c) * (dist (z m) (z (m + k)) + dist (z (m + k)) (z (Suc (m + k))))" | |
| 5825 | using dist_triangle and c by(auto simp add: dist_triangle) | |
| 5826 | also have "\<dots> \<le> (1 - c) * (dist (z m) (z (m + k)) + c ^ (m + k) * d)" | |
| 5827 | using cf_z[of "m + k"] and c by auto | |
| 5828 | also have "\<dots> \<le> c ^ m * d * (1 - c ^ k) + (1 - c) * c ^ (m + k) * d" | |
| 5829 | using Suc by (auto simp add: ring_simps) | |
| 5830 | also have "\<dots> = (c ^ m) * (d * (1 - c ^ k) + (1 - c) * c ^ k * d)" | |
| 5831 | unfolding power_add by (auto simp add: ring_simps) | |
| 5832 | also have "\<dots> \<le> (c ^ m) * d * (1 - c ^ Suc k)" | |
| 5833 | using c by (auto simp add: ring_simps) | |
| 5834 | finally show ?case by auto | |
| 5835 | qed | |
| 5836 | } note cf_z2 = this | |
| 5837 |   { fix e::real assume "e>0"
 | |
| 5838 | hence "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (z m) (z n) < e" | |
| 5839 | proof(cases "d = 0") | |
| 5840 | case True | |
| 5841 | hence "\<And>n. z n = z0" using cf_z2[of 0] and c unfolding z_def by (auto simp add: pos_prod_le[OF `1 - c > 0`]) | |
| 5842 | thus ?thesis using `e>0` by auto | |
| 5843 | next | |
| 5844 | case False hence "d>0" unfolding d_def using zero_le_dist[of "z 0" "z 1"] | |
| 5845 | by (metis False d_def real_less_def) | |
| 5846 | hence "0 < e * (1 - c) / d" using `e>0` and `1-c>0` | |
| 5847 | using divide_pos_pos[of "e * (1 - c)" d] and mult_pos_pos[of e "1 - c"] by auto | |
| 5848 | then obtain N where N:"c ^ N < e * (1 - c) / d" using real_arch_pow_inv[of "e * (1 - c) / d" c] and c by auto | |
| 5849 |       { fix m n::nat assume "m>n" and as:"m\<ge>N" "n\<ge>N"
 | |
| 5850 | have *:"c ^ n \<le> c ^ N" using `n\<ge>N` and c using power_decreasing[OF `n\<ge>N`, of c] by auto | |
| 5851 | have "1 - c ^ (m - n) > 0" using c and power_strict_mono[of c 1 "m - n"] using `m>n` by auto | |
| 5852 | hence **:"d * (1 - c ^ (m - n)) / (1 - c) > 0" | |
| 5853 | using real_mult_order[OF `d>0`, of "1 - c ^ (m - n)"] | |
| 5854 | using divide_pos_pos[of "d * (1 - c ^ (m - n))" "1 - c"] | |
| 5855 | using `0 < 1 - c` by auto | |
| 5856 | ||
| 5857 | have "dist (z m) (z n) \<le> c ^ n * d * (1 - c ^ (m - n)) / (1 - c)" | |
| 5858 | using cf_z2[of n "m - n"] and `m>n` unfolding pos_le_divide_eq[OF `1-c>0`] | |
| 5859 | by (auto simp add: real_mult_commute dist_commute) | |
| 5860 | also have "\<dots> \<le> c ^ N * d * (1 - c ^ (m - n)) / (1 - c)" | |
| 5861 | using mult_right_mono[OF * order_less_imp_le[OF **]] | |
| 5862 | unfolding real_mult_assoc by auto | |
| 5863 | also have "\<dots> < (e * (1 - c) / d) * d * (1 - c ^ (m - n)) / (1 - c)" | |
| 5864 | using mult_strict_right_mono[OF N **] unfolding real_mult_assoc by auto | |
| 5865 | also have "\<dots> = e * (1 - c ^ (m - n))" using c and `d>0` and `1 - c > 0` by auto | |
| 5866 | also have "\<dots> \<le> e" using c and `1 - c ^ (m - n) > 0` and `e>0` using mult_right_le_one_le[of e "1 - c ^ (m - n)"] by auto | |
| 5867 | finally have "dist (z m) (z n) < e" by auto | |
| 5868 | } note * = this | |
| 5869 |       { fix m n::nat assume as:"N\<le>m" "N\<le>n"
 | |
| 5870 | hence "dist (z n) (z m) < e" | |
| 5871 | proof(cases "n = m") | |
| 5872 | case True thus ?thesis using `e>0` by auto | |
| 5873 | next | |
| 5874 | case False thus ?thesis using as and *[of n m] *[of m n] unfolding nat_neq_iff by (auto simp add: dist_commute) | |
| 5875 | qed } | |
| 5876 | thus ?thesis by auto | |
| 5877 | qed | |
| 5878 | } | |
| 5879 | hence "Cauchy z" unfolding cauchy_def by auto | |
| 5880 | then obtain x where "x\<in>s" and x:"(z ---> x) sequentially" using s(1)[unfolded compact_def complete_def, THEN spec[where x=z]] and z_in_s by auto | |
| 5881 | ||
| 5882 | def e \<equiv> "dist (f x) x" | |
| 5883 | have "e = 0" proof(rule ccontr) | |
| 5884 | assume "e \<noteq> 0" hence "e>0" unfolding e_def using zero_le_dist[of "f x" x] | |
| 5885 | by (metis dist_eq_0_iff dist_nz e_def) | |
| 5886 | then obtain N where N:"\<forall>n\<ge>N. dist (z n) x < e / 2" | |
| 5887 | using x[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto | |
| 5888 | hence N':"dist (z N) x < e / 2" by auto | |
| 5889 | ||
| 5890 | have *:"c * dist (z N) x \<le> dist (z N) x" unfolding mult_le_cancel_right2 | |
| 5891 | using zero_le_dist[of "z N" x] and c | |
| 5892 | by (metis dist_eq_0_iff dist_nz order_less_asym real_less_def) | |
| 5893 | have "dist (f (z N)) (f x) \<le> c * dist (z N) x" using lipschitz[THEN bspec[where x="z N"], THEN bspec[where x=x]] | |
| 5894 | using z_in_s[of N] `x\<in>s` using c by auto | |
| 5895 | also have "\<dots> < e / 2" using N' and c using * by auto | |
| 5896 | finally show False unfolding fzn | |
| 5897 | using N[THEN spec[where x="Suc N"]] and dist_triangle_half_r[of "z (Suc N)" "f x" e x] | |
| 5898 | unfolding e_def by auto | |
| 5899 | qed | |
| 5900 | hence "f x = x" unfolding e_def by auto | |
| 5901 | moreover | |
| 5902 |   { fix y assume "f y = y" "y\<in>s"
 | |
| 5903 | hence "dist x y \<le> c * dist x y" using lipschitz[THEN bspec[where x=x], THEN bspec[where x=y]] | |
| 5904 | using `x\<in>s` and `f x = x` by auto | |
| 5905 | hence "dist x y = 0" unfolding mult_le_cancel_right1 | |
| 5906 | using c and zero_le_dist[of x y] by auto | |
| 5907 | hence "y = x" by auto | |
| 5908 | } | |
| 5909 | ultimately show ?thesis unfolding Bex1_def using `x\<in>s` by blast+ | |
| 5910 | qed | |
| 5911 | ||
| 5912 | subsection{* Edelstein fixed point theorem.                                            *}
 | |
| 5913 | ||
| 5914 | lemma edelstein_fix: | |
| 5915 | fixes s :: "'a::real_normed_vector set" | |
| 5916 |   assumes s:"compact s" "s \<noteq> {}" and gs:"(g ` s) \<subseteq> s"
 | |
| 5917 | and dist:"\<forall>x\<in>s. \<forall>y\<in>s. x \<noteq> y \<longrightarrow> dist (g x) (g y) < dist x y" | |
| 5918 | shows "\<exists>! x\<in>s. g x = x" | |
| 5919 | proof(cases "\<exists>x\<in>s. g x \<noteq> x") | |
| 5920 | obtain x where "x\<in>s" using s(2) by auto | |
| 5921 | case False hence g:"\<forall>x\<in>s. g x = x" by auto | |
| 5922 |   { fix y assume "y\<in>s"
 | |
| 5923 | hence "x = y" using `x\<in>s` and dist[THEN bspec[where x=x], THEN bspec[where x=y]] | |
| 5924 | unfolding g[THEN bspec[where x=x], OF `x\<in>s`] | |
| 5925 | unfolding g[THEN bspec[where x=y], OF `y\<in>s`] by auto } | |
| 5926 | thus ?thesis unfolding Bex1_def using `x\<in>s` and g by blast+ | |
| 5927 | next | |
| 5928 | case True | |
| 5929 | then obtain x where [simp]:"x\<in>s" and "g x \<noteq> x" by auto | |
| 5930 |   { fix x y assume "x \<in> s" "y \<in> s"
 | |
| 5931 | hence "dist (g x) (g y) \<le> dist x y" | |
| 5932 | using dist[THEN bspec[where x=x], THEN bspec[where x=y]] by auto } note dist' = this | |
| 5933 | def y \<equiv> "g x" | |
| 5934 | have [simp]:"y\<in>s" unfolding y_def using gs[unfolded image_subset_iff] and `x\<in>s` by blast | |
| 5935 | def f \<equiv> "\<lambda>n. g ^^ n" | |
| 5936 | have [simp]:"\<And>n z. g (f n z) = f (Suc n) z" unfolding f_def by auto | |
| 5937 | have [simp]:"\<And>z. f 0 z = z" unfolding f_def by auto | |
| 5938 |   { fix n::nat and z assume "z\<in>s"
 | |
| 5939 | have "f n z \<in> s" unfolding f_def | |
| 5940 | proof(induct n) | |
| 5941 | case 0 thus ?case using `z\<in>s` by simp | |
| 5942 | next | |
| 5943 | case (Suc n) thus ?case using gs[unfolded image_subset_iff] by auto | |
| 5944 | qed } note fs = this | |
| 5945 |   { fix m n ::nat assume "m\<le>n"
 | |
| 5946 | fix w z assume "w\<in>s" "z\<in>s" | |
| 5947 | have "dist (f n w) (f n z) \<le> dist (f m w) (f m z)" using `m\<le>n` | |
| 5948 | proof(induct n) | |
| 5949 | case 0 thus ?case by auto | |
| 5950 | next | |
| 5951 | case (Suc n) | |
| 5952 | thus ?case proof(cases "m\<le>n") | |
| 5953 | case True thus ?thesis using Suc(1) | |
| 5954 | using dist'[OF fs fs, OF `w\<in>s` `z\<in>s`, of n n] by auto | |
| 5955 | next | |
| 5956 | case False hence mn:"m = Suc n" using Suc(2) by simp | |
| 5957 | show ?thesis unfolding mn by auto | |
| 5958 | qed | |
| 5959 | qed } note distf = this | |
| 5960 | ||
| 5961 | def h \<equiv> "\<lambda>n. (f n x, f n y)" | |
| 5962 | let ?s2 = "s \<times> s" | |
| 5963 | obtain l r where "l\<in>?s2" and r:"subseq r" and lr:"((h \<circ> r) ---> l) sequentially" | |
| 5964 | using compact_Times [OF s(1) s(1), unfolded compact_def, THEN spec[where x=h]] unfolding h_def | |
| 5965 | using fs[OF `x\<in>s`] and fs[OF `y\<in>s`] by blast | |
| 5966 | def a \<equiv> "fst l" def b \<equiv> "snd l" | |
| 5967 | have lab:"l = (a, b)" unfolding a_def b_def by simp | |
| 5968 | have [simp]:"a\<in>s" "b\<in>s" unfolding a_def b_def using `l\<in>?s2` by auto | |
| 5969 | ||
| 5970 | have lima:"((fst \<circ> (h \<circ> r)) ---> a) sequentially" | |
| 5971 | and limb:"((snd \<circ> (h \<circ> r)) ---> b) sequentially" | |
| 5972 | using lr | |
| 5973 | unfolding o_def a_def b_def by (simp_all add: tendsto_intros) | |
| 5974 | ||
| 5975 |   { fix n::nat
 | |
| 5976 | have *:"\<And>fx fy (x::'a) y. dist fx fy \<le> dist x y \<Longrightarrow> \<not> (dist (fx - fy) (a - b) < dist a b - dist x y)" unfolding dist_norm by norm | |
| 5977 |     { fix x y :: 'a
 | |
| 5978 | have "dist (-x) (-y) = dist x y" unfolding dist_norm | |
| 5979 | using norm_minus_cancel[of "x - y"] by (auto simp add: uminus_add_conv_diff) } note ** = this | |
| 5980 | ||
| 5981 |     { assume as:"dist a b > dist (f n x) (f n y)"
 | |
| 5982 | then obtain Na Nb where "\<forall>m\<ge>Na. dist (f (r m) x) a < (dist a b - dist (f n x) (f n y)) / 2" | |
| 5983 | and "\<forall>m\<ge>Nb. dist (f (r m) y) b < (dist a b - dist (f n x) (f n y)) / 2" | |
| 5984 | using lima limb unfolding h_def Lim_sequentially by (fastsimp simp del: less_divide_eq_number_of1) | |
| 5985 | hence "dist (f (r (Na + Nb + n)) x - f (r (Na + Nb + n)) y) (a - b) < dist a b - dist (f n x) (f n y)" | |
| 5986 | apply(erule_tac x="Na+Nb+n" in allE) | |
| 5987 | apply(erule_tac x="Na+Nb+n" in allE) apply simp | |
| 5988 | using dist_triangle_add_half[of a "f (r (Na + Nb + n)) x" "dist a b - dist (f n x) (f n y)" | |
| 5989 | "-b" "- f (r (Na + Nb + n)) y"] | |
| 5990 | unfolding ** unfolding group_simps(12) by (auto simp add: dist_commute) | |
| 5991 | moreover | |
| 5992 | have "dist (f (r (Na + Nb + n)) x - f (r (Na + Nb + n)) y) (a - b) \<ge> dist a b - dist (f n x) (f n y)" | |
| 5993 | using distf[of n "r (Na+Nb+n)", OF _ `x\<in>s` `y\<in>s`] | |
| 5994 | using subseq_bigger[OF r, of "Na+Nb+n"] | |
| 5995 | using *[of "f (r (Na + Nb + n)) x" "f (r (Na + Nb + n)) y" "f n x" "f n y"] by auto | |
| 5996 | ultimately have False by simp | |
| 5997 | } | |
| 5998 | hence "dist a b \<le> dist (f n x) (f n y)" by(rule ccontr)auto } | |
| 5999 | note ab_fn = this | |
| 6000 | ||
| 6001 | have [simp]:"a = b" proof(rule ccontr) | |
| 6002 | def e \<equiv> "dist a b - dist (g a) (g b)" | |
| 6003 | assume "a\<noteq>b" hence "e > 0" unfolding e_def using dist by fastsimp | |
| 6004 | hence "\<exists>n. dist (f n x) a < e/2 \<and> dist (f n y) b < e/2" | |
| 6005 | using lima limb unfolding Lim_sequentially | |
| 6006 | apply (auto elim!: allE[where x="e/2"]) apply(rule_tac x="r (max N Na)" in exI) unfolding h_def by fastsimp | |
| 6007 | then obtain n where n:"dist (f n x) a < e/2 \<and> dist (f n y) b < e/2" by auto | |
| 6008 | have "dist (f (Suc n) x) (g a) \<le> dist (f n x) a" | |
| 6009 | using dist[THEN bspec[where x="f n x"], THEN bspec[where x="a"]] and fs by auto | |
| 6010 | moreover have "dist (f (Suc n) y) (g b) \<le> dist (f n y) b" | |
| 6011 | using dist[THEN bspec[where x="f n y"], THEN bspec[where x="b"]] and fs by auto | |
| 6012 | ultimately have "dist (f (Suc n) x) (g a) + dist (f (Suc n) y) (g b) < e" using n by auto | |
| 6013 | thus False unfolding e_def using ab_fn[of "Suc n"] by norm | |
| 6014 | qed | |
| 6015 | ||
| 6016 | have [simp]:"\<And>n. f (Suc n) x = f n y" unfolding f_def y_def by(induct_tac n)auto | |
| 6017 |   { fix x y assume "x\<in>s" "y\<in>s" moreover
 | |
| 6018 | fix e::real assume "e>0" ultimately | |
| 6019 | have "dist y x < e \<longrightarrow> dist (g y) (g x) < e" using dist by fastsimp } | |
| 6020 | hence "continuous_on s g" unfolding continuous_on_def by auto | |
| 6021 | ||
| 6022 | hence "((snd \<circ> h \<circ> r) ---> g a) sequentially" unfolding continuous_on_sequentially | |
| 6023 | apply (rule allE[where x="\<lambda>n. (fst \<circ> h \<circ> r) n"]) apply (erule ballE[where x=a]) | |
| 6024 | using lima unfolding h_def o_def using fs[OF `x\<in>s`] by (auto simp add: y_def) | |
| 6025 | hence "g a = a" using Lim_unique[OF trivial_limit_sequentially limb, of "g a"] | |
| 6026 | unfolding `a=b` and o_assoc by auto | |
| 6027 | moreover | |
| 6028 |   { fix x assume "x\<in>s" "g x = x" "x\<noteq>a"
 | |
| 6029 | hence "False" using dist[THEN bspec[where x=a], THEN bspec[where x=x]] | |
| 6030 | using `g a = a` and `a\<in>s` by auto } | |
| 6031 | ultimately show "\<exists>!x\<in>s. g x = x" unfolding Bex1_def using `a\<in>s` by blast | |
| 6032 | qed | |
| 6033 | ||
| 6034 | end |