| author | haftmann | 
| Sat, 19 Jun 2010 09:14:06 +0200 | |
| changeset 37469 | 1436d6f28f17 | 
| parent 37452 | 8f515d6aded5 | 
| child 37486 | b993fac7985b | 
| child 37489 | 44e42d392c6e | 
| 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 | |
| 36623 | 9 | imports SEQ Euclidean_Space Glbs | 
| 33175 | 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 | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 51 | unfolding subset_eq Ball_def mem_def by auto | 
| 33175 | 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)" | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 58 | using openin_clauses by simp | 
| 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 59 | |
| 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 60 | lemma openin_Union[intro]: "(\<forall>S \<in>K. openin U S) \<Longrightarrow> openin U (\<Union> K)" | 
| 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 61 | using openin_clauses by simp | 
| 33175 | 62 | |
| 63 | lemma openin_Un[intro]: "openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S \<union> T)" | |
| 64 |   using openin_Union[of "{S,T}" U] by auto
 | |
| 65 | ||
| 66 | lemma openin_topspace[intro, simp]: "openin U (topspace U)" by (simp add: openin_Union topspace_def) | |
| 67 | ||
| 68 | 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") | |
| 36584 | 69 | proof | 
| 70 | assume ?lhs then show ?rhs by auto | |
| 71 | next | |
| 72 | assume H: ?rhs | |
| 73 |   let ?t = "\<Union>{T. openin U T \<and> T \<subseteq> S}"
 | |
| 74 | have "openin U ?t" by (simp add: openin_Union) | |
| 75 | also have "?t = S" using H by auto | |
| 76 | finally show "openin U S" . | |
| 33175 | 77 | qed | 
| 78 | ||
| 79 | subsection{* Closed sets *}
 | |
| 80 | ||
| 81 | definition "closedin U S \<longleftrightarrow> S \<subseteq> topspace U \<and> openin U (topspace U - S)" | |
| 82 | ||
| 83 | lemma closedin_subset: "closedin U S \<Longrightarrow> S \<subseteq> topspace U" by (metis closedin_def) | |
| 84 | lemma closedin_empty[simp]: "closedin U {}" by (simp add: closedin_def)
 | |
| 85 | lemma closedin_topspace[intro,simp]: | |
| 86 | "closedin U (topspace U)" by (simp add: closedin_def) | |
| 87 | lemma closedin_Un[intro]: "closedin U S \<Longrightarrow> closedin U T \<Longrightarrow> closedin U (S \<union> T)" | |
| 88 | by (auto simp add: Diff_Un closedin_def) | |
| 89 | ||
| 90 | lemma Diff_Inter[intro]: "A - \<Inter>S = \<Union> {A - s|s. s\<in>S}" by auto
 | |
| 91 | lemma closedin_Inter[intro]: assumes Ke: "K \<noteq> {}" and Kc: "\<forall>S \<in>K. closedin U S"
 | |
| 92 | shows "closedin U (\<Inter> K)" using Ke Kc unfolding closedin_def Diff_Inter by auto | |
| 93 | ||
| 94 | lemma closedin_Int[intro]: "closedin U S \<Longrightarrow> closedin U T \<Longrightarrow> closedin U (S \<inter> T)" | |
| 95 |   using closedin_Inter[of "{S,T}" U] by auto
 | |
| 96 | ||
| 97 | lemma Diff_Diff_Int: "A - (A - B) = A \<inter> B" by blast | |
| 98 | lemma openin_closedin_eq: "openin U S \<longleftrightarrow> S \<subseteq> topspace U \<and> closedin U (topspace U - S)" | |
| 99 | apply (auto simp add: closedin_def Diff_Diff_Int inf_absorb2) | |
| 100 | apply (metis openin_subset subset_eq) | |
| 101 | done | |
| 102 | ||
| 103 | lemma openin_closedin: "S \<subseteq> topspace U \<Longrightarrow> (openin U S \<longleftrightarrow> closedin U (topspace U - S))" | |
| 104 | by (simp add: openin_closedin_eq) | |
| 105 | ||
| 106 | lemma openin_diff[intro]: assumes oS: "openin U S" and cT: "closedin U T" shows "openin U (S - T)" | |
| 107 | proof- | |
| 108 | have "S - T = S \<inter> (topspace U - T)" using openin_subset[of U S] oS cT | |
| 109 | by (auto simp add: topspace_def openin_subset) | |
| 110 | then show ?thesis using oS cT by (auto simp add: closedin_def) | |
| 111 | qed | |
| 112 | ||
| 113 | lemma closedin_diff[intro]: assumes oS: "closedin U S" and cT: "openin U T" shows "closedin U (S - T)" | |
| 114 | proof- | |
| 115 | have "S - T = S \<inter> (topspace U - T)" using closedin_subset[of U S] oS cT | |
| 116 | by (auto simp add: topspace_def ) | |
| 117 | then show ?thesis using oS cT by (auto simp add: openin_closedin_eq) | |
| 118 | qed | |
| 119 | ||
| 120 | subsection{* Subspace topology. *}
 | |
| 121 | ||
| 122 | definition "subtopology U V = topology {S \<inter> V |S. openin U S}"
 | |
| 123 | ||
| 124 | lemma istopology_subtopology: "istopology {S \<inter> V |S. openin U S}" (is "istopology ?L")
 | |
| 125 | proof- | |
| 126 |   have "{} \<in> ?L" by blast
 | |
| 127 |   {fix A B assume A: "A \<in> ?L" and B: "B \<in> ?L"
 | |
| 128 | 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 | |
| 129 | have "A\<inter>B = (Sa \<inter> Sb) \<inter> V" "openin U (Sa \<inter> Sb)" using Sa Sb by blast+ | |
| 130 | then have "A \<inter> B \<in> ?L" by blast} | |
| 131 | moreover | |
| 132 |   {fix K assume K: "K \<subseteq> ?L"
 | |
| 133 | have th0: "?L = (\<lambda>S. S \<inter> V) ` openin U " | |
| 134 | apply (rule set_ext) | |
| 135 | apply (simp add: Ball_def image_iff) | |
| 136 | by (metis mem_def) | |
| 137 | from K[unfolded th0 subset_image_iff] | |
| 138 | obtain Sk where Sk: "Sk \<subseteq> openin U" "K = (\<lambda>S. S \<inter> V) ` Sk" by blast | |
| 139 | have "\<Union>K = (\<Union>Sk) \<inter> V" using Sk by auto | |
| 140 | moreover have "openin U (\<Union> Sk)" using Sk by (auto simp add: subset_eq mem_def) | |
| 141 | ultimately have "\<Union>K \<in> ?L" by blast} | |
| 142 | ultimately show ?thesis unfolding istopology_def by blast | |
| 143 | qed | |
| 144 | ||
| 145 | lemma openin_subtopology: | |
| 146 | "openin (subtopology U V) S \<longleftrightarrow> (\<exists> T. (openin U T) \<and> (S = T \<inter> V))" | |
| 147 | unfolding subtopology_def topology_inverse'[OF istopology_subtopology] | |
| 148 | by (auto simp add: Collect_def) | |
| 149 | ||
| 150 | lemma topspace_subtopology: "topspace(subtopology U V) = topspace U \<inter> V" | |
| 151 | by (auto simp add: topspace_def openin_subtopology) | |
| 152 | ||
| 153 | lemma closedin_subtopology: | |
| 154 | "closedin (subtopology U V) S \<longleftrightarrow> (\<exists>T. closedin U T \<and> S = T \<inter> V)" | |
| 155 | unfolding closedin_def topspace_subtopology | |
| 156 | apply (simp add: openin_subtopology) | |
| 157 | apply (rule iffI) | |
| 158 | apply clarify | |
| 159 | apply (rule_tac x="topspace U - T" in exI) | |
| 160 | by auto | |
| 161 | ||
| 162 | lemma openin_subtopology_refl: "openin (subtopology U V) V \<longleftrightarrow> V \<subseteq> topspace U" | |
| 163 | unfolding openin_subtopology | |
| 164 | apply (rule iffI, clarify) | |
| 165 | apply (frule openin_subset[of U]) apply blast | |
| 166 | apply (rule exI[where x="topspace U"]) | |
| 167 | by auto | |
| 168 | ||
| 169 | lemma subtopology_superset: assumes UV: "topspace U \<subseteq> V" | |
| 170 | shows "subtopology U V = U" | |
| 171 | proof- | |
| 172 |   {fix S
 | |
| 173 |     {fix T assume T: "openin U T" "S = T \<inter> V"
 | |
| 174 | from T openin_subset[OF T(1)] UV have eq: "S = T" by blast | |
| 175 | have "openin U S" unfolding eq using T by blast} | |
| 176 | moreover | |
| 177 |     {assume S: "openin U S"
 | |
| 178 | hence "\<exists>T. openin U T \<and> S = T \<inter> V" | |
| 179 | using openin_subset[OF S] UV by auto} | |
| 180 | ultimately have "(\<exists>T. openin U T \<and> S = T \<inter> V) \<longleftrightarrow> openin U S" by blast} | |
| 181 | then show ?thesis unfolding topology_eq openin_subtopology by blast | |
| 182 | qed | |
| 183 | ||
| 184 | ||
| 185 | lemma subtopology_topspace[simp]: "subtopology U (topspace U) = U" | |
| 186 | by (simp add: subtopology_superset) | |
| 187 | ||
| 188 | lemma subtopology_UNIV[simp]: "subtopology U UNIV = U" | |
| 189 | by (simp add: subtopology_superset) | |
| 190 | ||
| 191 | subsection{* The universal Euclidean versions are what we use most of the time *}
 | |
| 192 | ||
| 193 | definition | |
| 194 | euclidean :: "'a::topological_space topology" where | |
| 195 | "euclidean = topology open" | |
| 196 | ||
| 197 | lemma open_openin: "open S \<longleftrightarrow> openin euclidean S" | |
| 198 | unfolding euclidean_def | |
| 199 | apply (rule cong[where x=S and y=S]) | |
| 200 | apply (rule topology_inverse[symmetric]) | |
| 201 | apply (auto simp add: istopology_def) | |
| 202 | by (auto simp add: mem_def subset_eq) | |
| 203 | ||
| 204 | lemma topspace_euclidean: "topspace euclidean = UNIV" | |
| 205 | apply (simp add: topspace_def) | |
| 206 | apply (rule set_ext) | |
| 207 | by (auto simp add: open_openin[symmetric]) | |
| 208 | ||
| 209 | lemma topspace_euclidean_subtopology[simp]: "topspace (subtopology euclidean S) = S" | |
| 210 | by (simp add: topspace_euclidean topspace_subtopology) | |
| 211 | ||
| 212 | lemma closed_closedin: "closed S \<longleftrightarrow> closedin euclidean S" | |
| 213 | by (simp add: closed_def closedin_def topspace_euclidean open_openin Compl_eq_Diff_UNIV) | |
| 214 | ||
| 215 | lemma open_subopen: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>T. open T \<and> x \<in> T \<and> T \<subseteq> S)" | |
| 216 | by (simp add: open_openin openin_subopen[symmetric]) | |
| 217 | ||
| 218 | subsection{* Open and closed balls. *}
 | |
| 219 | ||
| 220 | definition | |
| 221 | ball :: "'a::metric_space \<Rightarrow> real \<Rightarrow> 'a set" where | |
| 222 |   "ball x e = {y. dist x y < e}"
 | |
| 223 | ||
| 224 | definition | |
| 225 | cball :: "'a::metric_space \<Rightarrow> real \<Rightarrow> 'a set" where | |
| 226 |   "cball x e = {y. dist x y \<le> e}"
 | |
| 227 | ||
| 228 | lemma mem_ball[simp]: "y \<in> ball x e \<longleftrightarrow> dist x y < e" by (simp add: ball_def) | |
| 229 | lemma mem_cball[simp]: "y \<in> cball x e \<longleftrightarrow> dist x y \<le> e" by (simp add: cball_def) | |
| 230 | ||
| 231 | lemma mem_ball_0 [simp]: | |
| 232 | fixes x :: "'a::real_normed_vector" | |
| 233 | shows "x \<in> ball 0 e \<longleftrightarrow> norm x < e" | |
| 234 | by (simp add: dist_norm) | |
| 235 | ||
| 236 | lemma mem_cball_0 [simp]: | |
| 237 | fixes x :: "'a::real_normed_vector" | |
| 238 | shows "x \<in> cball 0 e \<longleftrightarrow> norm x \<le> e" | |
| 239 | by (simp add: dist_norm) | |
| 240 | ||
| 241 | lemma centre_in_cball[simp]: "x \<in> cball x e \<longleftrightarrow> 0\<le> e" by simp | |
| 242 | lemma ball_subset_cball[simp,intro]: "ball x e \<subseteq> cball x e" by (simp add: subset_eq) | |
| 243 | lemma subset_ball[intro]: "d <= e ==> ball x d \<subseteq> ball x e" by (simp add: subset_eq) | |
| 244 | lemma subset_cball[intro]: "d <= e ==> cball x d \<subseteq> cball x e" by (simp add: subset_eq) | |
| 245 | lemma ball_max_Un: "ball a (max r s) = ball a r \<union> ball a s" | |
| 246 | by (simp add: expand_set_eq) arith | |
| 247 | ||
| 248 | lemma ball_min_Int: "ball a (min r s) = ball a r \<inter> ball a s" | |
| 249 | by (simp add: expand_set_eq) | |
| 250 | ||
| 251 | lemma diff_less_iff: "(a::real) - b > 0 \<longleftrightarrow> a > b" | |
| 252 | "(a::real) - b < 0 \<longleftrightarrow> a < b" | |
| 253 | "a - b < c \<longleftrightarrow> a < c +b" "a - b > c \<longleftrightarrow> a > c +b" by arith+ | |
| 254 | lemma diff_le_iff: "(a::real) - b \<ge> 0 \<longleftrightarrow> a \<ge> b" "(a::real) - b \<le> 0 \<longleftrightarrow> a \<le> b" | |
| 255 | "a - b \<le> c \<longleftrightarrow> a \<le> c +b" "a - b \<ge> c \<longleftrightarrow> a \<ge> c +b" by arith+ | |
| 256 | ||
| 257 | lemma open_ball[intro, simp]: "open (ball x e)" | |
| 258 | unfolding open_dist ball_def Collect_def Ball_def mem_def | |
| 259 | unfolding dist_commute | |
| 260 | apply clarify | |
| 261 | apply (rule_tac x="e - dist xa x" in exI) | |
| 262 | using dist_triangle_alt[where z=x] | |
| 263 | apply (clarsimp simp add: diff_less_iff) | |
| 264 | apply atomize | |
| 265 | apply (erule_tac x="y" in allE) | |
| 266 | apply (erule_tac x="xa" in allE) | |
| 267 | by arith | |
| 268 | ||
| 269 | lemma centre_in_ball[simp]: "x \<in> ball x e \<longleftrightarrow> e > 0" by (metis mem_ball dist_self) | |
| 270 | lemma open_contains_ball: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. ball x e \<subseteq> S)" | |
| 271 | unfolding open_dist subset_eq mem_ball Ball_def dist_commute .. | |
| 272 | ||
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 273 | lemma openE[elim?]: | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 274 | assumes "open S" "x\<in>S" | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 275 | obtains e where "e>0" "ball x e \<subseteq> S" | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 276 | using assms unfolding open_contains_ball by auto | 
| 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 277 | |
| 33175 | 278 | lemma open_contains_ball_eq: "open S \<Longrightarrow> \<forall>x. x\<in>S \<longleftrightarrow> (\<exists>e>0. ball x e \<subseteq> S)" | 
| 279 | by (metis open_contains_ball subset_eq centre_in_ball) | |
| 280 | ||
| 281 | lemma ball_eq_empty[simp]: "ball x e = {} \<longleftrightarrow> e \<le> 0"
 | |
| 282 | unfolding mem_ball expand_set_eq | |
| 283 | apply (simp add: not_less) | |
| 284 | by (metis zero_le_dist order_trans dist_self) | |
| 285 | ||
| 286 | lemma ball_empty[intro]: "e \<le> 0 ==> ball x e = {}" by simp
 | |
| 287 | ||
| 288 | subsection{* Basic "localization" results are handy for connectedness. *}
 | |
| 289 | ||
| 290 | lemma openin_open: "openin (subtopology euclidean U) S \<longleftrightarrow> (\<exists>T. open T \<and> (S = U \<inter> T))" | |
| 291 | by (auto simp add: openin_subtopology open_openin[symmetric]) | |
| 292 | ||
| 293 | lemma openin_open_Int[intro]: "open S \<Longrightarrow> openin (subtopology euclidean U) (U \<inter> S)" | |
| 294 | by (auto simp add: openin_open) | |
| 295 | ||
| 296 | lemma open_openin_trans[trans]: | |
| 297 | "open S \<Longrightarrow> open T \<Longrightarrow> T \<subseteq> S \<Longrightarrow> openin (subtopology euclidean S) T" | |
| 298 | by (metis Int_absorb1 openin_open_Int) | |
| 299 | ||
| 300 | lemma open_subset: "S \<subseteq> T \<Longrightarrow> open S \<Longrightarrow> openin (subtopology euclidean T) S" | |
| 301 | by (auto simp add: openin_open) | |
| 302 | ||
| 303 | lemma closedin_closed: "closedin (subtopology euclidean U) S \<longleftrightarrow> (\<exists>T. closed T \<and> S = U \<inter> T)" | |
| 304 | by (simp add: closedin_subtopology closed_closedin Int_ac) | |
| 305 | ||
| 306 | lemma closedin_closed_Int: "closed S ==> closedin (subtopology euclidean U) (U \<inter> S)" | |
| 307 | by (metis closedin_closed) | |
| 308 | ||
| 309 | lemma closed_closedin_trans: "closed S \<Longrightarrow> closed T \<Longrightarrow> T \<subseteq> S \<Longrightarrow> closedin (subtopology euclidean S) T" | |
| 310 | apply (subgoal_tac "S \<inter> T = T" ) | |
| 311 | apply auto | |
| 312 | apply (frule closedin_closed_Int[of T S]) | |
| 313 | by simp | |
| 314 | ||
| 315 | lemma closed_subset: "S \<subseteq> T \<Longrightarrow> closed S \<Longrightarrow> closedin (subtopology euclidean T) S" | |
| 316 | by (auto simp add: closedin_closed) | |
| 317 | ||
| 318 | lemma openin_euclidean_subtopology_iff: | |
| 319 | fixes S U :: "'a::metric_space set" | |
| 320 | shows "openin (subtopology euclidean U) S | |
| 321 | \<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") | |
| 322 | proof- | |
| 323 |   {assume ?lhs hence ?rhs unfolding openin_subtopology open_openin[symmetric]
 | |
| 324 | by (simp add: open_dist) blast} | |
| 325 | moreover | |
| 326 |   {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"
 | |
| 327 | 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)" | |
| 328 | by metis | |
| 329 |     let ?T = "\<Union>{B. \<exists>x\<in>S. B = ball x (d x)}"
 | |
| 330 | have oT: "open ?T" by auto | |
| 331 |     { fix x assume "x\<in>S"
 | |
| 332 |       hence "x \<in> \<Union>{B. \<exists>x\<in>S. B = ball x (d x)}"
 | |
| 333 | apply simp apply(rule_tac x="ball x(d x)" in exI) apply auto | |
| 334 | by (rule d [THEN conjunct1]) | |
| 335 | hence "x\<in> ?T \<inter> U" using SU and `x\<in>S` by auto } | |
| 336 | moreover | |
| 337 |     { fix y assume "y\<in>?T"
 | |
| 338 |       then obtain B where "y\<in>B" "B\<in>{B. \<exists>x\<in>S. B = ball x (d x)}" by auto
 | |
| 339 | then obtain x where "x\<in>S" and x:"y \<in> ball x (d x)" by auto | |
| 340 | assume "y\<in>U" | |
| 341 | hence "y\<in>S" using d[OF `x\<in>S`] and x by(auto simp add: dist_commute) } | |
| 342 | ultimately have "S = ?T \<inter> U" by blast | |
| 343 | with oT have ?lhs unfolding openin_subtopology open_openin[symmetric] by blast} | |
| 344 | ultimately show ?thesis by blast | |
| 345 | qed | |
| 346 | ||
| 347 | text{* These "transitivity" results are handy too. *}
 | |
| 348 | ||
| 349 | lemma openin_trans[trans]: "openin (subtopology euclidean T) S \<Longrightarrow> openin (subtopology euclidean U) T | |
| 350 | \<Longrightarrow> openin (subtopology euclidean U) S" | |
| 351 | unfolding open_openin openin_open by blast | |
| 352 | ||
| 353 | lemma openin_open_trans: "openin (subtopology euclidean T) S \<Longrightarrow> open T \<Longrightarrow> open S" | |
| 354 | by (auto simp add: openin_open intro: openin_trans) | |
| 355 | ||
| 356 | lemma closedin_trans[trans]: | |
| 357 | "closedin (subtopology euclidean T) S \<Longrightarrow> | |
| 358 | closedin (subtopology euclidean U) T | |
| 359 | ==> closedin (subtopology euclidean U) S" | |
| 360 | by (auto simp add: closedin_closed closed_closedin closed_Inter Int_assoc) | |
| 361 | ||
| 362 | lemma closedin_closed_trans: "closedin (subtopology euclidean T) S \<Longrightarrow> closed T \<Longrightarrow> closed S" | |
| 363 | by (auto simp add: closedin_closed intro: closedin_trans) | |
| 364 | ||
| 365 | subsection{* Connectedness *}
 | |
| 366 | ||
| 367 | definition "connected S \<longleftrightarrow> | |
| 368 |   ~(\<exists>e1 e2. open e1 \<and> open e2 \<and> S \<subseteq> (e1 \<union> e2) \<and> (e1 \<inter> e2 \<inter> S = {})
 | |
| 369 |   \<and> ~(e1 \<inter> S = {}) \<and> ~(e2 \<inter> S = {}))"
 | |
| 370 | ||
| 371 | lemma connected_local: | |
| 372 | "connected S \<longleftrightarrow> ~(\<exists>e1 e2. | |
| 373 | openin (subtopology euclidean S) e1 \<and> | |
| 374 | openin (subtopology euclidean S) e2 \<and> | |
| 375 | S \<subseteq> e1 \<union> e2 \<and> | |
| 376 |                  e1 \<inter> e2 = {} \<and>
 | |
| 377 |                  ~(e1 = {}) \<and>
 | |
| 378 |                  ~(e2 = {}))"
 | |
| 379 | unfolding connected_def openin_open by (safe, blast+) | |
| 380 | ||
| 34105 | 381 | lemma exists_diff: | 
| 382 | fixes P :: "'a set \<Rightarrow> bool" | |
| 383 | shows "(\<exists>S. P(- S)) \<longleftrightarrow> (\<exists>S. P S)" (is "?lhs \<longleftrightarrow> ?rhs") | |
| 33175 | 384 | proof- | 
| 385 |   {assume "?lhs" hence ?rhs by blast }
 | |
| 386 | moreover | |
| 387 |   {fix S assume H: "P S"
 | |
| 34105 | 388 | have "S = - (- S)" by auto | 
| 389 | with H have "P (- (- S))" by metis } | |
| 33175 | 390 | ultimately show ?thesis by metis | 
| 391 | qed | |
| 392 | ||
| 393 | lemma connected_clopen: "connected S \<longleftrightarrow> | |
| 394 | (\<forall>T. openin (subtopology euclidean S) T \<and> | |
| 395 |             closedin (subtopology euclidean S) T \<longrightarrow> T = {} \<or> T = S)" (is "?lhs \<longleftrightarrow> ?rhs")
 | |
| 396 | proof- | |
| 34105 | 397 |   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 | 398 | unfolding connected_def openin_open closedin_closed | 
| 399 | apply (subst exists_diff) by blast | |
| 34105 | 400 |   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> {})"
 | 
| 401 | (is " _ \<longleftrightarrow> \<not> (\<exists>e2 e1. ?P e2 e1)") apply (simp add: closed_def) by metis | |
| 33175 | 402 | |
| 403 |   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'))"
 | |
| 404 | (is "_ \<longleftrightarrow> \<not> (\<exists>t' t. ?Q t' t)") | |
| 405 | unfolding connected_def openin_open closedin_closed by auto | |
| 406 |   {fix e2
 | |
| 407 |     {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)"
 | |
| 408 | by auto} | |
| 409 | then have "(\<exists>e1. ?P e2 e1) \<longleftrightarrow> (\<exists>t. ?Q e2 t)" by metis} | |
| 410 | then have "\<forall>e2. (\<exists>e1. ?P e2 e1) \<longleftrightarrow> (\<exists>t. ?Q e2 t)" by blast | |
| 411 | then show ?thesis unfolding th0 th1 by simp | |
| 412 | qed | |
| 413 | ||
| 414 | lemma connected_empty[simp, intro]: "connected {}"
 | |
| 415 | by (simp add: connected_def) | |
| 416 | ||
| 417 | subsection{* Hausdorff and other separation properties *}
 | |
| 418 | ||
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 419 | class t0_space = topological_space + | 
| 33175 | 420 | assumes t0_space: "x \<noteq> y \<Longrightarrow> \<exists>U. open U \<and> \<not> (x \<in> U \<longleftrightarrow> y \<in> U)" | 
| 421 | ||
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 422 | class t1_space = topological_space + | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 423 | assumes t1_space: "x \<noteq> y \<Longrightarrow> \<exists>U. open U \<and> x \<in> U \<and> y \<notin> U" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 424 | |
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 425 | instance t1_space \<subseteq> t0_space | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 426 | proof qed (fast dest: t1_space) | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 427 | |
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 428 | lemma separation_t1: | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 429 | fixes x y :: "'a::t1_space" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 430 | shows "x \<noteq> y \<longleftrightarrow> (\<exists>U. open U \<and> x \<in> U \<and> y \<notin> U)" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 431 | using t1_space[of x y] by blast | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 432 | |
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 433 | lemma closed_sing: | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 434 | fixes a :: "'a::t1_space" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 435 |   shows "closed {a}"
 | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 436 | proof - | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 437 |   let ?T = "\<Union>{S. open S \<and> a \<notin> S}"
 | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 438 | have "open ?T" by (simp add: open_Union) | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 439 |   also have "?T = - {a}"
 | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 440 | by (simp add: expand_set_eq separation_t1, auto) | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 441 |   finally show "closed {a}" unfolding closed_def .
 | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 442 | qed | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 443 | |
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 444 | lemma closed_insert [simp]: | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 445 | fixes a :: "'a::t1_space" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 446 | assumes "closed S" shows "closed (insert a S)" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 447 | proof - | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 448 | from closed_sing assms | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 449 |   have "closed ({a} \<union> S)" by (rule closed_Un)
 | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 450 | thus "closed (insert a S)" by simp | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 451 | qed | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 452 | |
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 453 | lemma finite_imp_closed: | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 454 | fixes S :: "'a::t1_space set" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 455 | shows "finite S \<Longrightarrow> closed S" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 456 | by (induct set: finite, simp_all) | 
| 33175 | 457 | |
| 458 | text {* T2 spaces are also known as Hausdorff spaces. *}
 | |
| 459 | ||
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 460 | class t2_space = topological_space + | 
| 33175 | 461 |   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 = {}"
 | 
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 462 | |
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 463 | instance t2_space \<subseteq> t1_space | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 464 | proof qed (fast dest: hausdorff) | 
| 33175 | 465 | |
| 466 | instance metric_space \<subseteq> t2_space | |
| 467 | proof | |
| 468 | fix x y :: "'a::metric_space" | |
| 469 | assume xy: "x \<noteq> y" | |
| 470 | let ?U = "ball x (dist x y / 2)" | |
| 471 | let ?V = "ball y (dist x y / 2)" | |
| 472 | have th0: "\<And>d x y z. (d x z :: real) <= d x y + d y z \<Longrightarrow> d y z = d z y | |
| 473 | ==> ~(d x y * 2 < d x z \<and> d z y * 2 < d x z)" by arith | |
| 474 |   have "open ?U \<and> open ?V \<and> x \<in> ?U \<and> y \<in> ?V \<and> ?U \<inter> ?V = {}"
 | |
| 475 | using dist_pos_lt[OF xy] th0[of dist,OF dist_triangle dist_commute] | |
| 476 | by (auto simp add: expand_set_eq) | |
| 477 |   then show "\<exists>U V. open U \<and> open V \<and> x \<in> U \<and> y \<in> V \<and> U \<inter> V = {}"
 | |
| 478 | by blast | |
| 479 | qed | |
| 480 | ||
| 481 | lemma separation_t2: | |
| 482 | fixes x y :: "'a::t2_space" | |
| 483 |   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 = {})"
 | |
| 484 | using hausdorff[of x y] by blast | |
| 485 | ||
| 486 | lemma separation_t0: | |
| 487 | fixes x y :: "'a::t0_space" | |
| 488 | shows "x \<noteq> y \<longleftrightarrow> (\<exists>U. open U \<and> ~(x\<in>U \<longleftrightarrow> y\<in>U))" | |
| 489 | using t0_space[of x y] by blast | |
| 490 | ||
| 491 | subsection{* Limit points *}
 | |
| 492 | ||
| 493 | definition | |
| 494 | islimpt:: "'a::topological_space \<Rightarrow> 'a set \<Rightarrow> bool" | |
| 495 | (infixr "islimpt" 60) where | |
| 496 | "x islimpt S \<longleftrightarrow> (\<forall>T. x\<in>T \<longrightarrow> open T \<longrightarrow> (\<exists>y\<in>S. y\<in>T \<and> y\<noteq>x))" | |
| 497 | ||
| 498 | lemma islimptI: | |
| 499 | assumes "\<And>T. x \<in> T \<Longrightarrow> open T \<Longrightarrow> \<exists>y\<in>S. y \<in> T \<and> y \<noteq> x" | |
| 500 | shows "x islimpt S" | |
| 501 | using assms unfolding islimpt_def by auto | |
| 502 | ||
| 503 | lemma islimptE: | |
| 504 | assumes "x islimpt S" and "x \<in> T" and "open T" | |
| 505 | obtains y where "y \<in> S" and "y \<in> T" and "y \<noteq> x" | |
| 506 | using assms unfolding islimpt_def by auto | |
| 507 | ||
| 508 | lemma islimpt_subset: "x islimpt S \<Longrightarrow> S \<subseteq> T ==> x islimpt T" by (auto simp add: islimpt_def) | |
| 509 | ||
| 510 | lemma islimpt_approachable: | |
| 511 | fixes x :: "'a::metric_space" | |
| 512 | shows "x islimpt S \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e)" | |
| 513 | unfolding islimpt_def | |
| 514 | apply auto | |
| 515 | apply(erule_tac x="ball x e" in allE) | |
| 516 | apply auto | |
| 517 | apply(rule_tac x=y in bexI) | |
| 518 | apply (auto simp add: dist_commute) | |
| 519 | apply (simp add: open_dist, drule (1) bspec) | |
| 520 | apply (clarify, drule spec, drule (1) mp, auto) | |
| 521 | done | |
| 522 | ||
| 523 | lemma islimpt_approachable_le: | |
| 524 | fixes x :: "'a::metric_space" | |
| 525 | shows "x islimpt S \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in> S. x' \<noteq> x \<and> dist x' x <= e)" | |
| 526 | unfolding islimpt_approachable | |
| 527 | using approachable_lt_le[where f="\<lambda>x'. dist x' x" and P="\<lambda>x'. \<not> (x'\<in>S \<and> x'\<noteq>x)"] | |
| 33324 | 528 | by metis | 
| 33175 | 529 | |
| 530 | class perfect_space = | |
| 531 | (* FIXME: perfect_space should inherit from topological_space *) | |
| 532 | assumes islimpt_UNIV [simp, intro]: "(x::'a::metric_space) islimpt UNIV" | |
| 533 | ||
| 534 | lemma perfect_choose_dist: | |
| 535 | fixes x :: "'a::perfect_space" | |
| 536 | shows "0 < r \<Longrightarrow> \<exists>a. a \<noteq> x \<and> dist a x < r" | |
| 537 | using islimpt_UNIV [of x] | |
| 538 | by (simp add: islimpt_approachable) | |
| 539 | ||
| 540 | instance real :: perfect_space | |
| 541 | apply default | |
| 542 | apply (rule islimpt_approachable [THEN iffD2]) | |
| 543 | apply (clarify, rule_tac x="x + e/2" in bexI) | |
| 544 | apply (auto simp add: dist_norm) | |
| 545 | done | |
| 546 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 547 | instance cart :: (perfect_space, finite) perfect_space | 
| 33175 | 548 | proof | 
| 549 | fix x :: "'a ^ 'b" | |
| 550 |   {
 | |
| 551 | fix e :: real assume "0 < e" | |
| 552 | def a \<equiv> "x $ undefined" | |
| 553 | have "a islimpt UNIV" by (rule islimpt_UNIV) | |
| 554 | with `0 < e` obtain b where "b \<noteq> a" and "dist b a < e" | |
| 555 | unfolding islimpt_approachable by auto | |
| 556 | def y \<equiv> "Cart_lambda ((Cart_nth x)(undefined := b))" | |
| 557 | from `b \<noteq> a` have "y \<noteq> x" | |
| 558 | unfolding a_def y_def by (simp add: Cart_eq) | |
| 559 | from `dist b a < e` have "dist y x < e" | |
| 560 | unfolding dist_vector_def a_def y_def | |
| 561 | apply simp | |
| 562 | apply (rule le_less_trans [OF setL2_le_setsum [OF zero_le_dist]]) | |
| 563 | apply (subst setsum_diff1' [where a=undefined], simp, simp, simp) | |
| 564 | done | |
| 565 | from `y \<noteq> x` and `dist y x < e` | |
| 566 | have "\<exists>y\<in>UNIV. y \<noteq> x \<and> dist y x < e" by auto | |
| 567 | } | |
| 568 | then show "x islimpt UNIV" unfolding islimpt_approachable by blast | |
| 569 | qed | |
| 570 | ||
| 571 | lemma closed_limpt: "closed S \<longleftrightarrow> (\<forall>x. x islimpt S \<longrightarrow> x \<in> S)" | |
| 572 | unfolding closed_def | |
| 573 | apply (subst open_subopen) | |
| 34105 | 574 | apply (simp add: islimpt_def subset_eq) | 
| 575 | by (metis ComplE ComplI insertCI insert_absorb mem_def) | |
| 33175 | 576 | |
| 577 | lemma islimpt_EMPTY[simp]: "\<not> x islimpt {}"
 | |
| 578 | unfolding islimpt_def by auto | |
| 579 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 580 | lemma closed_positive_orthant: "closed {x::real^'n. \<forall>i. 0 \<le>x$i}"
 | 
| 33175 | 581 | proof- | 
| 582 | let ?U = "UNIV :: 'n set" | |
| 583 |   let ?O = "{x::real^'n. \<forall>i. x$i\<ge>0}"
 | |
| 584 |   {fix x:: "real^'n" and i::'n assume H: "\<forall>e>0. \<exists>x'\<in>?O. x' \<noteq> x \<and> dist x' x < e"
 | |
| 585 | and xi: "x$i < 0" | |
| 586 | from xi have th0: "-x$i > 0" by arith | |
| 587 | from H[rule_format, OF th0] obtain x' where x': "x' \<in>?O" "x' \<noteq> x" "dist x' x < -x $ i" by blast | |
| 588 | have th:" \<And>b a (x::real). abs x <= b \<Longrightarrow> b <= a ==> ~(a + x < 0)" by arith | |
| 589 | have th': "\<And>x (y::real). x < 0 \<Longrightarrow> 0 <= y ==> abs x <= abs (y - x)" by arith | |
| 590 | have th1: "\<bar>x$i\<bar> \<le> \<bar>(x' - x)$i\<bar>" using x'(1) xi | |
| 591 | apply (simp only: vector_component) | |
| 592 | by (rule th') auto | |
| 593 | have th2: "\<bar>dist x x'\<bar> \<ge> \<bar>(x' - x)$i\<bar>" using component_le_norm[of "x'-x" i] | |
| 594 | apply (simp add: dist_norm) by norm | |
| 595 | from th[OF th1 th2] x'(3) have False by (simp add: dist_commute) } | |
| 596 | then show ?thesis unfolding closed_limpt islimpt_approachable | |
| 597 | unfolding not_le[symmetric] by blast | |
| 598 | qed | |
| 599 | ||
| 600 | lemma finite_set_avoid: | |
| 601 | fixes a :: "'a::metric_space" | |
| 602 | assumes fS: "finite S" shows "\<exists>d>0. \<forall>x\<in>S. x \<noteq> a \<longrightarrow> d <= dist a x" | |
| 603 | proof(induct rule: finite_induct[OF fS]) | |
| 604 | case 1 thus ?case apply auto by ferrack | |
| 605 | next | |
| 606 | case (2 x F) | |
| 607 | from 2 obtain d where d: "d >0" "\<forall>x\<in>F. x\<noteq>a \<longrightarrow> d \<le> dist a x" by blast | |
| 608 |   {assume "x = a" hence ?case using d by auto  }
 | |
| 609 | moreover | |
| 610 |   {assume xa: "x\<noteq>a"
 | |
| 611 | let ?d = "min d (dist a x)" | |
| 612 | have dp: "?d > 0" using xa d(1) using dist_nz by auto | |
| 613 | from d have d': "\<forall>x\<in>F. x\<noteq>a \<longrightarrow> ?d \<le> dist a x" by auto | |
| 614 | with dp xa have ?case by(auto intro!: exI[where x="?d"]) } | |
| 615 | ultimately show ?case by blast | |
| 616 | qed | |
| 617 | ||
| 618 | lemma islimpt_finite: | |
| 619 | fixes S :: "'a::metric_space set" | |
| 620 | assumes fS: "finite S" shows "\<not> a islimpt S" | |
| 621 | unfolding islimpt_approachable | |
| 622 | using finite_set_avoid[OF fS, of a] by (metis dist_commute not_le) | |
| 623 | ||
| 624 | lemma islimpt_Un: "x islimpt (S \<union> T) \<longleftrightarrow> x islimpt S \<or> x islimpt T" | |
| 625 | apply (rule iffI) | |
| 626 | defer | |
| 627 | apply (metis Un_upper1 Un_upper2 islimpt_subset) | |
| 628 | unfolding islimpt_def | |
| 629 | apply (rule ccontr, clarsimp, rename_tac A B) | |
| 630 | apply (drule_tac x="A \<inter> B" in spec) | |
| 631 | apply (auto simp add: open_Int) | |
| 632 | done | |
| 633 | ||
| 634 | lemma discrete_imp_closed: | |
| 635 | fixes S :: "'a::metric_space set" | |
| 636 | assumes e: "0 < e" and d: "\<forall>x \<in> S. \<forall>y \<in> S. dist y x < e \<longrightarrow> y = x" | |
| 637 | shows "closed S" | |
| 638 | proof- | |
| 639 |   {fix x assume C: "\<forall>e>0. \<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e"
 | |
| 640 | from e have e2: "e/2 > 0" by arith | |
| 641 | from C[rule_format, OF e2] obtain y where y: "y \<in> S" "y\<noteq>x" "dist y x < e/2" by blast | |
| 642 | let ?m = "min (e/2) (dist x y) " | |
| 643 | from e2 y(2) have mp: "?m > 0" by (simp add: dist_nz[THEN sym]) | |
| 644 | from C[rule_format, OF mp] obtain z where z: "z \<in> S" "z\<noteq>x" "dist z x < ?m" by blast | |
| 645 | have th: "dist z y < e" using z y | |
| 646 | by (intro dist_triangle_lt [where z=x], simp) | |
| 647 | from d[rule_format, OF y(1) z(1) th] y z | |
| 648 | have False by (auto simp add: dist_commute)} | |
| 649 | then show ?thesis by (metis islimpt_approachable closed_limpt [where 'a='a]) | |
| 650 | qed | |
| 651 | ||
| 652 | subsection{* Interior of a Set *}
 | |
| 653 | definition "interior S = {x. \<exists>T. open T \<and> x \<in> T \<and> T \<subseteq> S}"
 | |
| 654 | ||
| 655 | lemma interior_eq: "interior S = S \<longleftrightarrow> open S" | |
| 656 | apply (simp add: expand_set_eq interior_def) | |
| 657 | apply (subst (2) open_subopen) by (safe, blast+) | |
| 658 | ||
| 659 | lemma interior_open: "open S ==> (interior S = S)" by (metis interior_eq) | |
| 660 | ||
| 661 | lemma interior_empty[simp]: "interior {} = {}" by (simp add: interior_def)
 | |
| 662 | ||
| 663 | lemma open_interior[simp, intro]: "open(interior S)" | |
| 664 | apply (simp add: interior_def) | |
| 665 | apply (subst open_subopen) by blast | |
| 666 | ||
| 667 | lemma interior_interior[simp]: "interior(interior S) = interior S" by (metis interior_eq open_interior) | |
| 668 | lemma interior_subset: "interior S \<subseteq> S" by (auto simp add: interior_def) | |
| 669 | lemma subset_interior: "S \<subseteq> T ==> (interior S) \<subseteq> (interior T)" by (auto simp add: interior_def) | |
| 670 | lemma interior_maximal: "T \<subseteq> S \<Longrightarrow> open T ==> T \<subseteq> (interior S)" by (auto simp add: interior_def) | |
| 671 | 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" | |
| 672 | by (metis equalityI interior_maximal interior_subset open_interior) | |
| 673 | lemma mem_interior: "x \<in> interior S \<longleftrightarrow> (\<exists>e. 0 < e \<and> ball x e \<subseteq> S)" | |
| 674 | apply (simp add: interior_def) | |
| 675 | by (metis open_contains_ball centre_in_ball open_ball subset_trans) | |
| 676 | ||
| 677 | lemma open_subset_interior: "open S ==> S \<subseteq> interior T \<longleftrightarrow> S \<subseteq> T" | |
| 678 | by (metis interior_maximal interior_subset subset_trans) | |
| 679 | ||
| 680 | lemma interior_inter[simp]: "interior(S \<inter> T) = interior S \<inter> interior T" | |
| 681 | apply (rule equalityI, simp) | |
| 682 | apply (metis Int_lower1 Int_lower2 subset_interior) | |
| 683 | by (metis Int_mono interior_subset open_Int open_interior open_subset_interior) | |
| 684 | ||
| 685 | lemma interior_limit_point [intro]: | |
| 686 | fixes x :: "'a::perfect_space" | |
| 687 | assumes x: "x \<in> interior S" shows "x islimpt S" | |
| 688 | proof- | |
| 689 | from x obtain e where e: "e>0" "\<forall>x'. dist x x' < e \<longrightarrow> x' \<in> S" | |
| 690 | unfolding mem_interior subset_eq Ball_def mem_ball by blast | |
| 691 |   {
 | |
| 692 | fix d::real assume d: "d>0" | |
| 693 | let ?m = "min d e" | |
| 694 | have mde2: "0 < ?m" using e(1) d(1) by simp | |
| 695 | from perfect_choose_dist [OF mde2, of x] | |
| 696 | obtain y where "y \<noteq> x" and "dist y x < ?m" by blast | |
| 697 | then have "dist y x < e" "dist y x < d" by simp_all | |
| 698 | from `dist y x < e` e(2) have "y \<in> S" by (simp add: dist_commute) | |
| 699 | have "\<exists>x'\<in>S. x'\<noteq> x \<and> dist x' x < d" | |
| 700 | using `y \<in> S` `y \<noteq> x` `dist y x < d` by fast | |
| 701 | } | |
| 702 | then show ?thesis unfolding islimpt_approachable by blast | |
| 703 | qed | |
| 704 | ||
| 705 | lemma interior_closed_Un_empty_interior: | |
| 706 |   assumes cS: "closed S" and iT: "interior T = {}"
 | |
| 707 | shows "interior(S \<union> T) = interior S" | |
| 708 | proof | |
| 709 | show "interior S \<subseteq> interior (S\<union>T)" | |
| 710 | by (rule subset_interior, blast) | |
| 711 | next | |
| 712 | show "interior (S \<union> T) \<subseteq> interior S" | |
| 713 | proof | |
| 714 | fix x assume "x \<in> interior (S \<union> T)" | |
| 715 | then obtain R where "open R" "x \<in> R" "R \<subseteq> S \<union> T" | |
| 716 | unfolding interior_def by fast | |
| 717 | show "x \<in> interior S" | |
| 718 | proof (rule ccontr) | |
| 719 | assume "x \<notin> interior S" | |
| 720 | with `x \<in> R` `open R` obtain y where "y \<in> R - S" | |
| 721 | unfolding interior_def expand_set_eq by fast | |
| 722 | from `open R` `closed S` have "open (R - S)" by (rule open_Diff) | |
| 723 | from `R \<subseteq> S \<union> T` have "R - S \<subseteq> T" by fast | |
| 724 |       from `y \<in> R - S` `open (R - S)` `R - S \<subseteq> T` `interior T = {}`
 | |
| 725 | show "False" unfolding interior_def by fast | |
| 726 | qed | |
| 727 | qed | |
| 728 | qed | |
| 729 | ||
| 730 | ||
| 731 | subsection{* Closure of a Set *}
 | |
| 732 | ||
| 733 | definition "closure S = S \<union> {x | x. x islimpt S}"
 | |
| 734 | ||
| 34105 | 735 | lemma closure_interior: "closure S = - interior (- S)" | 
| 33175 | 736 | proof- | 
| 737 |   { fix x
 | |
| 34105 | 738 | have "x\<in>- interior (- S) \<longleftrightarrow> x \<in> closure S" (is "?lhs = ?rhs") | 
| 33175 | 739 | proof | 
| 34105 | 740 | let ?exT = "\<lambda> y. (\<exists>T. open T \<and> y \<in> T \<and> T \<subseteq> - S)" | 
| 33175 | 741 | assume "?lhs" | 
| 742 | hence *:"\<not> ?exT x" | |
| 743 | unfolding interior_def | |
| 744 | by simp | |
| 745 |       { assume "\<not> ?rhs"
 | |
| 746 | hence False using * | |
| 747 | unfolding closure_def islimpt_def | |
| 748 | by blast | |
| 749 | } | |
| 750 | thus "?rhs" | |
| 751 | by blast | |
| 752 | next | |
| 753 | assume "?rhs" thus "?lhs" | |
| 754 | unfolding closure_def interior_def islimpt_def | |
| 755 | by blast | |
| 756 | qed | |
| 757 | } | |
| 758 | thus ?thesis | |
| 759 | by blast | |
| 760 | qed | |
| 761 | ||
| 34105 | 762 | lemma interior_closure: "interior S = - (closure (- S))" | 
| 33175 | 763 | proof- | 
| 764 |   { fix x
 | |
| 34105 | 765 | have "x \<in> interior S \<longleftrightarrow> x \<in> - (closure (- S))" | 
| 33175 | 766 | unfolding interior_def closure_def islimpt_def | 
| 33324 | 767 | by auto | 
| 33175 | 768 | } | 
| 769 | thus ?thesis | |
| 770 | by blast | |
| 771 | qed | |
| 772 | ||
| 773 | lemma closed_closure[simp, intro]: "closed (closure S)" | |
| 774 | proof- | |
| 34105 | 775 | have "closed (- interior (-S))" by blast | 
| 33175 | 776 | thus ?thesis using closure_interior[of S] by simp | 
| 777 | qed | |
| 778 | ||
| 779 | lemma closure_hull: "closure S = closed hull S" | |
| 780 | proof- | |
| 781 | have "S \<subseteq> closure S" | |
| 782 | unfolding closure_def | |
| 783 | by blast | |
| 784 | moreover | |
| 785 | have "closed (closure S)" | |
| 786 | using closed_closure[of S] | |
| 787 | by assumption | |
| 788 | moreover | |
| 789 |   { fix t
 | |
| 790 | assume *:"S \<subseteq> t" "closed t" | |
| 791 |     { fix x
 | |
| 792 | assume "x islimpt S" | |
| 793 | hence "x islimpt t" using *(1) | |
| 794 | using islimpt_subset[of x, of S, of t] | |
| 795 | by blast | |
| 796 | } | |
| 797 | with * have "closure S \<subseteq> t" | |
| 798 | unfolding closure_def | |
| 799 | using closed_limpt[of t] | |
| 800 | by auto | |
| 801 | } | |
| 802 | ultimately show ?thesis | |
| 803 | using hull_unique[of S, of "closure S", of closed] | |
| 804 | unfolding mem_def | |
| 805 | by simp | |
| 806 | qed | |
| 807 | ||
| 808 | lemma closure_eq: "closure S = S \<longleftrightarrow> closed S" | |
| 809 | unfolding closure_hull | |
| 810 | using hull_eq[of closed, unfolded mem_def, OF closed_Inter, of S] | |
| 811 | by (metis mem_def subset_eq) | |
| 812 | ||
| 813 | lemma closure_closed[simp]: "closed S \<Longrightarrow> closure S = S" | |
| 814 | using closure_eq[of S] | |
| 815 | by simp | |
| 816 | ||
| 817 | lemma closure_closure[simp]: "closure (closure S) = closure S" | |
| 818 | unfolding closure_hull | |
| 819 | using hull_hull[of closed S] | |
| 820 | by assumption | |
| 821 | ||
| 822 | lemma closure_subset: "S \<subseteq> closure S" | |
| 823 | unfolding closure_hull | |
| 824 | using hull_subset[of S closed] | |
| 825 | by assumption | |
| 826 | ||
| 827 | lemma subset_closure: "S \<subseteq> T \<Longrightarrow> closure S \<subseteq> closure T" | |
| 828 | unfolding closure_hull | |
| 829 | using hull_mono[of S T closed] | |
| 830 | by assumption | |
| 831 | ||
| 832 | lemma closure_minimal: "S \<subseteq> T \<Longrightarrow> closed T \<Longrightarrow> closure S \<subseteq> T" | |
| 833 | using hull_minimal[of S T closed] | |
| 834 | unfolding closure_hull mem_def | |
| 835 | by simp | |
| 836 | ||
| 837 | 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" | |
| 838 | using hull_unique[of S T closed] | |
| 839 | unfolding closure_hull mem_def | |
| 840 | by simp | |
| 841 | ||
| 842 | lemma closure_empty[simp]: "closure {} = {}"
 | |
| 843 |   using closed_empty closure_closed[of "{}"]
 | |
| 844 | by simp | |
| 845 | ||
| 846 | lemma closure_univ[simp]: "closure UNIV = UNIV" | |
| 847 | using closure_closed[of UNIV] | |
| 848 | by simp | |
| 849 | ||
| 850 | lemma closure_eq_empty: "closure S = {} \<longleftrightarrow> S = {}"
 | |
| 851 | using closure_empty closure_subset[of S] | |
| 852 | by blast | |
| 853 | ||
| 854 | lemma closure_subset_eq: "closure S \<subseteq> S \<longleftrightarrow> closed S" | |
| 855 | using closure_eq[of S] closure_subset[of S] | |
| 856 | by simp | |
| 857 | ||
| 858 | lemma open_inter_closure_eq_empty: | |
| 859 |   "open S \<Longrightarrow> (S \<inter> closure T) = {} \<longleftrightarrow> S \<inter> T = {}"
 | |
| 34105 | 860 | using open_subset_interior[of S "- T"] | 
| 861 | using interior_subset[of "- T"] | |
| 33175 | 862 | unfolding closure_interior | 
| 863 | by auto | |
| 864 | ||
| 865 | lemma open_inter_closure_subset: | |
| 866 | "open S \<Longrightarrow> (S \<inter> (closure T)) \<subseteq> closure(S \<inter> T)" | |
| 867 | proof | |
| 868 | fix x | |
| 869 | assume as: "open S" "x \<in> S \<inter> closure T" | |
| 870 |   { assume *:"x islimpt T"
 | |
| 871 | have "x islimpt (S \<inter> T)" | |
| 872 | proof (rule islimptI) | |
| 873 | fix A | |
| 874 | assume "x \<in> A" "open A" | |
| 875 | with as have "x \<in> A \<inter> S" "open (A \<inter> S)" | |
| 876 | by (simp_all add: open_Int) | |
| 877 | with * obtain y where "y \<in> T" "y \<in> A \<inter> S" "y \<noteq> x" | |
| 878 | by (rule islimptE) | |
| 879 | hence "y \<in> S \<inter> T" "y \<in> A \<and> y \<noteq> x" | |
| 880 | by simp_all | |
| 881 | thus "\<exists>y\<in>(S \<inter> T). y \<in> A \<and> y \<noteq> x" .. | |
| 882 | qed | |
| 883 | } | |
| 884 | then show "x \<in> closure (S \<inter> T)" using as | |
| 885 | unfolding closure_def | |
| 886 | by blast | |
| 887 | qed | |
| 888 | ||
| 34105 | 889 | lemma closure_complement: "closure(- S) = - interior(S)" | 
| 33175 | 890 | proof- | 
| 34105 | 891 | have "S = - (- S)" | 
| 33175 | 892 | by auto | 
| 893 | thus ?thesis | |
| 894 | unfolding closure_interior | |
| 895 | by auto | |
| 896 | qed | |
| 897 | ||
| 34105 | 898 | lemma interior_complement: "interior(- S) = - closure(S)" | 
| 33175 | 899 | unfolding closure_interior | 
| 900 | by blast | |
| 901 | ||
| 902 | subsection{* Frontier (aka boundary) *}
 | |
| 903 | ||
| 904 | definition "frontier S = closure S - interior S" | |
| 905 | ||
| 906 | lemma frontier_closed: "closed(frontier S)" | |
| 907 | by (simp add: frontier_def closed_Diff) | |
| 908 | ||
| 34105 | 909 | lemma frontier_closures: "frontier S = (closure S) \<inter> (closure(- S))" | 
| 33175 | 910 | by (auto simp add: frontier_def interior_closure) | 
| 911 | ||
| 912 | lemma frontier_straddle: | |
| 913 | fixes a :: "'a::metric_space" | |
| 914 | 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") | |
| 915 | proof | |
| 916 | assume "?lhs" | |
| 917 |   { fix e::real
 | |
| 918 | assume "e > 0" | |
| 919 | let ?rhse = "(\<exists>x\<in>S. dist a x < e) \<and> (\<exists>x. x \<notin> S \<and> dist a x < e)" | |
| 920 |     { assume "a\<in>S"
 | |
| 921 | have "\<exists>x\<in>S. dist a x < e" using `e>0` `a\<in>S` by(rule_tac x=a in bexI) auto | |
| 922 | moreover have "\<exists>x. x \<notin> S \<and> dist a x < e" using `?lhs` `a\<in>S` | |
| 923 | unfolding frontier_closures closure_def islimpt_def using `e>0` | |
| 924 | by (auto, erule_tac x="ball a e" in allE, auto) | |
| 925 | ultimately have ?rhse by auto | |
| 926 | } | |
| 927 | moreover | |
| 928 |     { assume "a\<notin>S"
 | |
| 929 | hence ?rhse using `?lhs` | |
| 930 | unfolding frontier_closures closure_def islimpt_def | |
| 931 | using open_ball[of a e] `e > 0` | |
| 33324 | 932 | by simp (metis centre_in_ball mem_ball open_ball) | 
| 33175 | 933 | } | 
| 934 | ultimately have ?rhse by auto | |
| 935 | } | |
| 936 | thus ?rhs by auto | |
| 937 | next | |
| 938 | assume ?rhs | |
| 939 | moreover | |
| 940 |   { fix T assume "a\<notin>S" and
 | |
| 941 | 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" | |
| 942 | from `open T` `a \<in> T` have "\<exists>e>0. ball a e \<subseteq> T" unfolding open_contains_ball[of T] by auto | |
| 943 | then obtain e where "e>0" "ball a e \<subseteq> T" by auto | |
| 944 | then obtain y where y:"y\<in>S" "dist a y < e" using as(1) by auto | |
| 945 | have "\<exists>y\<in>S. y \<in> T \<and> y \<noteq> a" | |
| 946 | using `dist a y < e` `ball a e \<subseteq> T` unfolding ball_def using `y\<in>S` `a\<notin>S` by auto | |
| 947 | } | |
| 948 | hence "a \<in> closure S" unfolding closure_def islimpt_def using `?rhs` by auto | |
| 949 | moreover | |
| 950 |   { fix T assume "a \<in> T"  "open T" "a\<in>S"
 | |
| 951 | then obtain e where "e>0" and balle: "ball a e \<subseteq> T" unfolding open_contains_ball using `?rhs` by auto | |
| 952 | obtain x where "x \<notin> S" "dist a x < e" using `?rhs` using `e>0` by auto | |
| 34105 | 953 | 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 | 954 | } | 
| 34105 | 955 | hence "a islimpt (- S) \<or> a\<notin>S" unfolding islimpt_def by auto | 
| 956 | ultimately show ?lhs unfolding frontier_closures using closure_def[of "- S"] by auto | |
| 33175 | 957 | qed | 
| 958 | ||
| 959 | lemma frontier_subset_closed: "closed S \<Longrightarrow> frontier S \<subseteq> S" | |
| 960 | by (metis frontier_def closure_closed Diff_subset) | |
| 961 | ||
| 34964 | 962 | lemma frontier_empty[simp]: "frontier {} = {}"
 | 
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 963 | by (simp add: frontier_def) | 
| 33175 | 964 | |
| 965 | lemma frontier_subset_eq: "frontier S \<subseteq> S \<longleftrightarrow> closed S" | |
| 966 | proof- | |
| 967 |   { assume "frontier S \<subseteq> S"
 | |
| 968 | hence "closure S \<subseteq> S" using interior_subset unfolding frontier_def by auto | |
| 969 | hence "closed S" using closure_subset_eq by auto | |
| 970 | } | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 971 | thus ?thesis using frontier_subset_closed[of S] .. | 
| 33175 | 972 | qed | 
| 973 | ||
| 34105 | 974 | lemma frontier_complement: "frontier(- S) = frontier S" | 
| 33175 | 975 | by (auto simp add: frontier_def closure_complement interior_complement) | 
| 976 | ||
| 977 | lemma frontier_disjoint_eq: "frontier S \<inter> S = {} \<longleftrightarrow> open S"
 | |
| 34105 | 978 | using frontier_complement frontier_subset_eq[of "- S"] | 
| 979 | unfolding open_closed by auto | |
| 33175 | 980 | |
| 36437 | 981 | subsection {* Nets and the ``eventually true'' quantifier *}
 | 
| 982 | ||
| 983 | text {* Common nets and The "within" modifier for nets. *}
 | |
| 33175 | 984 | |
| 985 | definition | |
| 986 | at_infinity :: "'a::real_normed_vector net" where | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 987 | "at_infinity = Abs_net (\<lambda>P. \<exists>r. \<forall>x. r \<le> norm x \<longrightarrow> P x)" | 
| 33175 | 988 | |
| 989 | definition | |
| 990 | indirection :: "'a::real_normed_vector \<Rightarrow> 'a \<Rightarrow> 'a net" (infixr "indirection" 70) where | |
| 991 |   "a indirection v = (at a) within {b. \<exists>c\<ge>0. b - a = scaleR c v}"
 | |
| 992 | ||
| 993 | text{* Prove That They are all nets. *}
 | |
| 994 | ||
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 995 | lemma eventually_at_infinity: | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 996 | "eventually P at_infinity \<longleftrightarrow> (\<exists>b. \<forall>x. norm x >= b \<longrightarrow> P x)" | 
| 33175 | 997 | unfolding at_infinity_def | 
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 998 | proof (rule eventually_Abs_net, rule is_filter.intro) | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 999 | fix P Q :: "'a \<Rightarrow> bool" | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1000 | assume "\<exists>r. \<forall>x. r \<le> norm x \<longrightarrow> P x" and "\<exists>s. \<forall>x. s \<le> norm x \<longrightarrow> Q x" | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1001 | then obtain r s where | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1002 | "\<forall>x. r \<le> norm x \<longrightarrow> P x" and "\<forall>x. s \<le> norm x \<longrightarrow> Q x" by auto | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1003 | then have "\<forall>x. max r s \<le> norm x \<longrightarrow> P x \<and> Q x" by simp | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1004 | then show "\<exists>r. \<forall>x. r \<le> norm x \<longrightarrow> P x \<and> Q x" .. | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1005 | qed auto | 
| 33175 | 1006 | |
| 36437 | 1007 | text {* Identify Trivial limits, where we can't approach arbitrarily closely. *}
 | 
| 33175 | 1008 | |
| 1009 | definition | |
| 1010 | trivial_limit :: "'a net \<Rightarrow> bool" where | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1011 | "trivial_limit net \<longleftrightarrow> eventually (\<lambda>x. False) net" | 
| 33175 | 1012 | |
| 1013 | lemma trivial_limit_within: | |
| 1014 | shows "trivial_limit (at a within S) \<longleftrightarrow> \<not> a islimpt S" | |
| 1015 | proof | |
| 1016 | assume "trivial_limit (at a within S)" | |
| 1017 | thus "\<not> a islimpt S" | |
| 1018 | unfolding trivial_limit_def | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1019 | unfolding eventually_within eventually_at_topological | 
| 33175 | 1020 | unfolding islimpt_def | 
| 1021 | apply (clarsimp simp add: expand_set_eq) | |
| 1022 | apply (rename_tac T, rule_tac x=T in exI) | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1023 | apply (clarsimp, drule_tac x=y in bspec, simp_all) | 
| 33175 | 1024 | done | 
| 1025 | next | |
| 1026 | assume "\<not> a islimpt S" | |
| 1027 | thus "trivial_limit (at a within S)" | |
| 1028 | unfolding trivial_limit_def | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1029 | unfolding eventually_within eventually_at_topological | 
| 33175 | 1030 | unfolding islimpt_def | 
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1031 | apply clarsimp | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1032 | apply (rule_tac x=T in exI) | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1033 | apply auto | 
| 33175 | 1034 | done | 
| 1035 | qed | |
| 1036 | ||
| 1037 | lemma trivial_limit_at_iff: "trivial_limit (at a) \<longleftrightarrow> \<not> a islimpt UNIV" | |
| 1038 | using trivial_limit_within [of a UNIV] | |
| 1039 | by (simp add: within_UNIV) | |
| 1040 | ||
| 1041 | lemma trivial_limit_at: | |
| 1042 | fixes a :: "'a::perfect_space" | |
| 1043 | shows "\<not> trivial_limit (at a)" | |
| 1044 | by (simp add: trivial_limit_at_iff) | |
| 1045 | ||
| 1046 | lemma trivial_limit_at_infinity: | |
| 1047 |   "\<not> trivial_limit (at_infinity :: ('a::{real_normed_vector,zero_neq_one}) net)"
 | |
| 1048 | (* FIXME: find a more appropriate type class *) | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1049 | unfolding trivial_limit_def eventually_at_infinity | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1050 | apply clarsimp | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1051 | apply (rule_tac x="scaleR b (sgn 1)" in exI) | 
| 33175 | 1052 | apply (simp add: norm_sgn) | 
| 1053 | done | |
| 1054 | ||
| 34964 | 1055 | lemma trivial_limit_sequentially[intro]: "\<not> trivial_limit sequentially" | 
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1056 | by (auto simp add: trivial_limit_def eventually_sequentially) | 
| 33175 | 1057 | |
| 36437 | 1058 | text {* Some property holds "sufficiently close" to the limit point. *}
 | 
| 33175 | 1059 | |
| 1060 | lemma eventually_at: (* FIXME: this replaces Limits.eventually_at *) | |
| 1061 | "eventually P (at a) \<longleftrightarrow> (\<exists>d>0. \<forall>x. 0 < dist x a \<and> dist x a < d \<longrightarrow> P x)" | |
| 1062 | unfolding eventually_at dist_nz by auto | |
| 1063 | ||
| 1064 | lemma eventually_within: "eventually P (at a within S) \<longleftrightarrow> | |
| 1065 | (\<exists>d>0. \<forall>x\<in>S. 0 < dist x a \<and> dist x a < d \<longrightarrow> P x)" | |
| 1066 | unfolding eventually_within eventually_at dist_nz by auto | |
| 1067 | ||
| 1068 | lemma eventually_within_le: "eventually P (at a within S) \<longleftrightarrow> | |
| 1069 | (\<exists>d>0. \<forall>x\<in>S. 0 < dist x a \<and> dist x a <= d \<longrightarrow> P x)" (is "?lhs = ?rhs") | |
| 1070 | unfolding eventually_within | |
| 33324 | 1071 | by auto (metis Rats_dense_in_nn_real order_le_less_trans order_refl) | 
| 33175 | 1072 | |
| 1073 | lemma eventually_happens: "eventually P net ==> trivial_limit net \<or> (\<exists>x. P x)" | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1074 | unfolding trivial_limit_def | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1075 | by (auto elim: eventually_rev_mp) | 
| 33175 | 1076 | |
| 1077 | lemma always_eventually: "(\<forall>x. P x) ==> eventually P net" | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1078 | proof - | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1079 | assume "\<forall>x. P x" hence "P = (\<lambda>x. True)" by (simp add: ext) | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1080 | thus "eventually P net" by simp | 
| 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1081 | qed | 
| 33175 | 1082 | |
| 1083 | lemma trivial_limit_eventually: "trivial_limit net \<Longrightarrow> eventually P net" | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1084 | unfolding trivial_limit_def by (auto elim: eventually_rev_mp) | 
| 33175 | 1085 | |
| 1086 | lemma eventually_False: "eventually (\<lambda>x. False) net \<longleftrightarrow> trivial_limit net" | |
| 36358 
246493d61204
define nets directly as filters, instead of as filter bases
 huffman parents: 
36336diff
changeset | 1087 | unfolding trivial_limit_def .. | 
| 33175 | 1088 | |
| 1089 | lemma trivial_limit_eq: "trivial_limit net \<longleftrightarrow> (\<forall>P. eventually P net)" | |
| 1090 | apply (safe elim!: trivial_limit_eventually) | |
| 1091 | apply (simp add: eventually_False [symmetric]) | |
| 1092 | done | |
| 1093 | ||
| 1094 | text{* Combining theorems for "eventually" *}
 | |
| 1095 | ||
| 1096 | lemma eventually_conjI: | |
| 1097 | "\<lbrakk>eventually (\<lambda>x. P x) net; eventually (\<lambda>x. Q x) net\<rbrakk> | |
| 1098 | \<Longrightarrow> eventually (\<lambda>x. P x \<and> Q x) net" | |
| 1099 | by (rule eventually_conj) | |
| 1100 | ||
| 1101 | lemma eventually_rev_mono: | |
| 1102 | "eventually P net \<Longrightarrow> (\<forall>x. P x \<longrightarrow> Q x) \<Longrightarrow> eventually Q net" | |
| 1103 | using eventually_mono [of P Q] by fast | |
| 1104 | ||
| 1105 | lemma eventually_and: " eventually (\<lambda>x. P x \<and> Q x) net \<longleftrightarrow> eventually P net \<and> eventually Q net" | |
| 1106 | by (auto intro!: eventually_conjI elim: eventually_rev_mono) | |
| 1107 | ||
| 1108 | lemma eventually_false: "eventually (\<lambda>x. False) net \<longleftrightarrow> trivial_limit net" | |
| 1109 | by (auto simp add: eventually_False) | |
| 1110 | ||
| 1111 | lemma not_eventually: "(\<forall>x. \<not> P x ) \<Longrightarrow> ~(trivial_limit net) ==> ~(eventually (\<lambda>x. P x) net)" | |
| 1112 | by (simp add: eventually_False) | |
| 1113 | ||
| 36437 | 1114 | subsection {* Limits *}
 | 
| 33175 | 1115 | |
| 1116 |   text{* Notation Lim to avoid collition with lim defined in analysis *}
 | |
| 1117 | definition | |
| 1118 |   Lim :: "'a net \<Rightarrow> ('a \<Rightarrow> 'b::t2_space) \<Rightarrow> 'b" where
 | |
| 1119 | "Lim net f = (THE l. (f ---> l) net)" | |
| 1120 | ||
| 1121 | lemma Lim: | |
| 1122 | "(f ---> l) net \<longleftrightarrow> | |
| 1123 | trivial_limit net \<or> | |
| 1124 | (\<forall>e>0. eventually (\<lambda>x. dist (f x) l < e) net)" | |
| 1125 | unfolding tendsto_iff trivial_limit_eq by auto | |
| 1126 | ||
| 1127 | ||
| 1128 | text{* Show that they yield usual definitions in the various cases. *}
 | |
| 1129 | ||
| 1130 | lemma Lim_within_le: "(f ---> l)(at a within S) \<longleftrightarrow> | |
| 1131 | (\<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)" | |
| 1132 | by (auto simp add: tendsto_iff eventually_within_le) | |
| 1133 | ||
| 1134 | lemma Lim_within: "(f ---> l) (at a within S) \<longleftrightarrow> | |
| 1135 | (\<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)" | |
| 1136 | by (auto simp add: tendsto_iff eventually_within) | |
| 1137 | ||
| 1138 | lemma Lim_at: "(f ---> l) (at a) \<longleftrightarrow> | |
| 1139 | (\<forall>e >0. \<exists>d>0. \<forall>x. 0 < dist x a \<and> dist x a < d \<longrightarrow> dist (f x) l < e)" | |
| 1140 | by (auto simp add: tendsto_iff eventually_at) | |
| 1141 | ||
| 1142 | lemma Lim_at_iff_LIM: "(f ---> l) (at a) \<longleftrightarrow> f -- a --> l" | |
| 1143 | unfolding Lim_at LIM_def by (simp only: zero_less_dist_iff) | |
| 1144 | ||
| 1145 | lemma Lim_at_infinity: | |
| 1146 | "(f ---> l) at_infinity \<longleftrightarrow> (\<forall>e>0. \<exists>b. \<forall>x. norm x >= b \<longrightarrow> dist (f x) l < e)" | |
| 1147 | by (auto simp add: tendsto_iff eventually_at_infinity) | |
| 1148 | ||
| 1149 | lemma Lim_sequentially: | |
| 1150 | "(S ---> l) sequentially \<longleftrightarrow> | |
| 1151 | (\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (S n) l < e)" | |
| 1152 | by (auto simp add: tendsto_iff eventually_sequentially) | |
| 1153 | ||
| 1154 | lemma Lim_sequentially_iff_LIMSEQ: "(S ---> l) sequentially \<longleftrightarrow> S ----> l" | |
| 1155 | unfolding Lim_sequentially LIMSEQ_def .. | |
| 1156 | ||
| 1157 | lemma Lim_eventually: "eventually (\<lambda>x. f x = l) net \<Longrightarrow> (f ---> l) net" | |
| 1158 | by (rule topological_tendstoI, auto elim: eventually_rev_mono) | |
| 1159 | ||
| 1160 | text{* The expected monotonicity property. *}
 | |
| 1161 | ||
| 1162 | lemma Lim_within_empty: "(f ---> l) (net within {})"
 | |
| 1163 | unfolding tendsto_def Limits.eventually_within by simp | |
| 1164 | ||
| 1165 | lemma Lim_within_subset: "(f ---> l) (net within S) \<Longrightarrow> T \<subseteq> S \<Longrightarrow> (f ---> l) (net within T)" | |
| 1166 | unfolding tendsto_def Limits.eventually_within | |
| 1167 | by (auto elim!: eventually_elim1) | |
| 1168 | ||
| 1169 | lemma Lim_Un: assumes "(f ---> l) (net within S)" "(f ---> l) (net within T)" | |
| 1170 | shows "(f ---> l) (net within (S \<union> T))" | |
| 1171 | using assms unfolding tendsto_def Limits.eventually_within | |
| 1172 | apply clarify | |
| 1173 | apply (drule spec, drule (1) mp, drule (1) mp) | |
| 1174 | apply (drule spec, drule (1) mp, drule (1) mp) | |
| 1175 | apply (auto elim: eventually_elim2) | |
| 1176 | done | |
| 1177 | ||
| 1178 | lemma Lim_Un_univ: | |
| 1179 | "(f ---> l) (net within S) \<Longrightarrow> (f ---> l) (net within T) \<Longrightarrow> S \<union> T = UNIV | |
| 1180 | ==> (f ---> l) net" | |
| 1181 | by (metis Lim_Un within_UNIV) | |
| 1182 | ||
| 1183 | text{* Interrelations between restricted and unrestricted limits. *}
 | |
| 1184 | ||
| 1185 | lemma Lim_at_within: "(f ---> l) net ==> (f ---> l)(net within S)" | |
| 1186 | (* FIXME: rename *) | |
| 1187 | unfolding tendsto_def Limits.eventually_within | |
| 1188 | apply (clarify, drule spec, drule (1) mp, drule (1) mp) | |
| 1189 | by (auto elim!: eventually_elim1) | |
| 1190 | ||
| 1191 | lemma Lim_within_open: | |
| 1192 | fixes f :: "'a::topological_space \<Rightarrow> 'b::topological_space" | |
| 1193 | assumes"a \<in> S" "open S" | |
| 1194 | shows "(f ---> l)(at a within S) \<longleftrightarrow> (f ---> l)(at a)" (is "?lhs \<longleftrightarrow> ?rhs") | |
| 1195 | proof | |
| 1196 | assume ?lhs | |
| 1197 |   { fix A assume "open A" "l \<in> A"
 | |
| 1198 | with `?lhs` have "eventually (\<lambda>x. f x \<in> A) (at a within S)" | |
| 1199 | by (rule topological_tendstoD) | |
| 1200 | hence "eventually (\<lambda>x. x \<in> S \<longrightarrow> f x \<in> A) (at a)" | |
| 1201 | unfolding Limits.eventually_within . | |
| 1202 | 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" | |
| 1203 | unfolding eventually_at_topological by fast | |
| 1204 | hence "open (T \<inter> S)" "a \<in> T \<inter> S" "\<forall>x\<in>(T \<inter> S). x \<noteq> a \<longrightarrow> f x \<in> A" | |
| 1205 | using assms by auto | |
| 1206 | hence "\<exists>T. open T \<and> a \<in> T \<and> (\<forall>x\<in>T. x \<noteq> a \<longrightarrow> f x \<in> A)" | |
| 1207 | by fast | |
| 1208 | hence "eventually (\<lambda>x. f x \<in> A) (at a)" | |
| 1209 | unfolding eventually_at_topological . | |
| 1210 | } | |
| 1211 | thus ?rhs by (rule topological_tendstoI) | |
| 1212 | next | |
| 1213 | assume ?rhs | |
| 1214 | thus ?lhs by (rule Lim_at_within) | |
| 1215 | qed | |
| 1216 | ||
| 1217 | text{* Another limit point characterization. *}
 | |
| 1218 | ||
| 1219 | lemma islimpt_sequential: | |
| 36667 | 1220 | fixes x :: "'a::metric_space" | 
| 33175 | 1221 |   shows "x islimpt S \<longleftrightarrow> (\<exists>f. (\<forall>n::nat. f n \<in> S -{x}) \<and> (f ---> x) sequentially)"
 | 
| 1222 | (is "?lhs = ?rhs") | |
| 1223 | proof | |
| 1224 | assume ?lhs | |
| 1225 | 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" | |
| 1226 | 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 | |
| 1227 |   { fix n::nat
 | |
| 1228 |     have "f (inverse (real n + 1)) \<in> S - {x}" using f by auto
 | |
| 1229 | } | |
| 1230 | moreover | |
| 1231 |   { fix e::real assume "e>0"
 | |
| 1232 | 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 | |
| 1233 | then obtain N::nat where "inverse (real (N + 1)) < e" by auto | |
| 1234 | 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) | |
| 1235 | moreover have "\<forall>n\<ge>N. dist (f (inverse (real n + 1))) x < (inverse (real n + 1))" using f `e>0` by auto | |
| 1236 | 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 | |
| 1237 | } | |
| 1238 | hence " ((\<lambda>n. f (inverse (real n + 1))) ---> x) sequentially" | |
| 1239 | unfolding Lim_sequentially using f by auto | |
| 1240 | ultimately show ?rhs apply (rule_tac x="(\<lambda>n::nat. f (inverse (real n + 1)))" in exI) by auto | |
| 1241 | next | |
| 1242 | assume ?rhs | |
| 1243 |   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
 | |
| 1244 |   { fix e::real assume "e>0"
 | |
| 1245 | then obtain N where "dist (f N) x < e" using f(2) by auto | |
| 1246 | moreover have "f N\<in>S" "f N \<noteq> x" using f(1) by auto | |
| 1247 | ultimately have "\<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e" by auto | |
| 1248 | } | |
| 1249 | thus ?lhs unfolding islimpt_approachable by auto | |
| 1250 | qed | |
| 1251 | ||
| 1252 | text{* Basic arithmetical combining theorems for limits. *}
 | |
| 1253 | ||
| 1254 | lemma Lim_linear: | |
| 1255 | assumes "(f ---> l) net" "bounded_linear h" | |
| 1256 | shows "((\<lambda>x. h (f x)) ---> h l) net" | |
| 1257 | using `bounded_linear h` `(f ---> l) net` | |
| 1258 | by (rule bounded_linear.tendsto) | |
| 1259 | ||
| 1260 | lemma Lim_ident_at: "((\<lambda>x. x) ---> a) (at a)" | |
| 1261 | unfolding tendsto_def Limits.eventually_at_topological by fast | |
| 1262 | ||
| 34964 | 1263 | lemma Lim_const[intro]: "((\<lambda>x. a) ---> a) net" by (rule tendsto_const) | 
| 1264 | ||
| 1265 | lemma Lim_cmul[intro]: | |
| 33175 | 1266 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | 
| 1267 | shows "(f ---> l) net ==> ((\<lambda>x. c *\<^sub>R f x) ---> c *\<^sub>R l) net" | |
| 1268 | by (intro tendsto_intros) | |
| 1269 | ||
| 1270 | lemma Lim_neg: | |
| 1271 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1272 | shows "(f ---> l) net ==> ((\<lambda>x. -(f x)) ---> -l) net" | |
| 1273 | by (rule tendsto_minus) | |
| 1274 | ||
| 1275 | lemma Lim_add: fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" shows | |
| 1276 | "(f ---> l) net \<Longrightarrow> (g ---> m) net \<Longrightarrow> ((\<lambda>x. f(x) + g(x)) ---> l + m) net" | |
| 1277 | by (rule tendsto_add) | |
| 1278 | ||
| 1279 | lemma Lim_sub: | |
| 1280 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1281 | shows "(f ---> l) net \<Longrightarrow> (g ---> m) net \<Longrightarrow> ((\<lambda>x. f(x) - g(x)) ---> l - m) net" | |
| 1282 | by (rule tendsto_diff) | |
| 1283 | ||
| 36437 | 1284 | lemma Lim_mul: | 
| 1285 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1286 | assumes "(c ---> d) net" "(f ---> l) net" | |
| 1287 | shows "((\<lambda>x. c(x) *\<^sub>R f x) ---> (d *\<^sub>R l)) net" | |
| 1288 | using assms by (rule scaleR.tendsto) | |
| 1289 | ||
| 1290 | lemma Lim_inv: | |
| 1291 | fixes f :: "'a \<Rightarrow> real" | |
| 1292 | assumes "(f ---> l) (net::'a net)" "l \<noteq> 0" | |
| 1293 | shows "((inverse o f) ---> inverse l) net" | |
| 1294 | unfolding o_def using assms by (rule tendsto_inverse) | |
| 1295 | ||
| 1296 | lemma Lim_vmul: | |
| 1297 | fixes c :: "'a \<Rightarrow> real" and v :: "'b::real_normed_vector" | |
| 1298 | shows "(c ---> d) net ==> ((\<lambda>x. c(x) *\<^sub>R v) ---> d *\<^sub>R v) net" | |
| 1299 | by (intro tendsto_intros) | |
| 1300 | ||
| 33175 | 1301 | lemma Lim_null: | 
| 1302 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1303 | shows "(f ---> l) net \<longleftrightarrow> ((\<lambda>x. f(x) - l) ---> 0) net" by (simp add: Lim dist_norm) | |
| 1304 | ||
| 1305 | lemma Lim_null_norm: | |
| 1306 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1307 | shows "(f ---> 0) net \<longleftrightarrow> ((\<lambda>x. norm(f x)) ---> 0) net" | |
| 1308 | by (simp add: Lim dist_norm) | |
| 1309 | ||
| 1310 | lemma Lim_null_comparison: | |
| 1311 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1312 | assumes "eventually (\<lambda>x. norm (f x) \<le> g x) net" "(g ---> 0) net" | |
| 1313 | shows "(f ---> 0) net" | |
| 1314 | proof(simp add: tendsto_iff, rule+) | |
| 1315 | fix e::real assume "0<e" | |
| 1316 |   { fix x
 | |
| 1317 | assume "norm (f x) \<le> g x" "dist (g x) 0 < e" | |
| 1318 | hence "dist (f x) 0 < e" by (simp add: dist_norm) | |
| 1319 | } | |
| 1320 | thus "eventually (\<lambda>x. dist (f x) 0 < e) net" | |
| 1321 | using eventually_and[of "\<lambda>x. norm(f x) <= g x" "\<lambda>x. dist (g x) 0 < e" net] | |
| 1322 | 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] | |
| 1323 | using assms `e>0` unfolding tendsto_iff by auto | |
| 1324 | qed | |
| 1325 | ||
| 1326 | lemma Lim_component: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 1327 | fixes f :: "'a \<Rightarrow> 'b::metric_space ^ 'n" | 
| 33175 | 1328 | shows "(f ---> l) net \<Longrightarrow> ((\<lambda>a. f a $i) ---> l$i) net" | 
| 1329 | unfolding tendsto_iff | |
| 1330 | apply (clarify) | |
| 1331 | apply (drule spec, drule (1) mp) | |
| 1332 | apply (erule eventually_elim1) | |
| 1333 | apply (erule le_less_trans [OF dist_nth_le]) | |
| 1334 | done | |
| 1335 | ||
| 1336 | lemma Lim_transform_bound: | |
| 1337 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1338 | fixes g :: "'a \<Rightarrow> 'c::real_normed_vector" | |
| 1339 | assumes "eventually (\<lambda>n. norm(f n) <= norm(g n)) net" "(g ---> 0) net" | |
| 1340 | shows "(f ---> 0) net" | |
| 1341 | proof (rule tendstoI) | |
| 1342 | fix e::real assume "e>0" | |
| 1343 |   { fix x
 | |
| 1344 | assume "norm (f x) \<le> norm (g x)" "dist (g x) 0 < e" | |
| 1345 | hence "dist (f x) 0 < e" by (simp add: dist_norm)} | |
| 1346 | thus "eventually (\<lambda>x. dist (f x) 0 < e) net" | |
| 1347 | using eventually_and[of "\<lambda>x. norm (f x) \<le> norm (g x)" "\<lambda>x. dist (g x) 0 < e" net] | |
| 1348 | 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] | |
| 1349 | using assms `e>0` unfolding tendsto_iff by blast | |
| 1350 | qed | |
| 1351 | ||
| 1352 | text{* Deducing things about the limit from the elements. *}
 | |
| 1353 | ||
| 1354 | lemma Lim_in_closed_set: | |
| 1355 | assumes "closed S" "eventually (\<lambda>x. f(x) \<in> S) net" "\<not>(trivial_limit net)" "(f ---> l) net" | |
| 1356 | shows "l \<in> S" | |
| 1357 | proof (rule ccontr) | |
| 1358 | assume "l \<notin> S" | |
| 1359 | with `closed S` have "open (- S)" "l \<in> - S" | |
| 1360 | by (simp_all add: open_Compl) | |
| 1361 | with assms(4) have "eventually (\<lambda>x. f x \<in> - S) net" | |
| 1362 | by (rule topological_tendstoD) | |
| 1363 | with assms(2) have "eventually (\<lambda>x. False) net" | |
| 1364 | by (rule eventually_elim2) simp | |
| 1365 | with assms(3) show "False" | |
| 1366 | by (simp add: eventually_False) | |
| 1367 | qed | |
| 1368 | ||
| 1369 | text{* Need to prove closed(cball(x,e)) before deducing this as a corollary. *}
 | |
| 1370 | ||
| 1371 | lemma Lim_dist_ubound: | |
| 1372 | assumes "\<not>(trivial_limit net)" "(f ---> l) net" "eventually (\<lambda>x. dist a (f x) <= e) net" | |
| 1373 | shows "dist a l <= e" | |
| 1374 | proof (rule ccontr) | |
| 1375 | assume "\<not> dist a l \<le> e" | |
| 1376 | then have "0 < dist a l - e" by simp | |
| 1377 | with assms(2) have "eventually (\<lambda>x. dist (f x) l < dist a l - e) net" | |
| 1378 | by (rule tendstoD) | |
| 1379 | with assms(3) have "eventually (\<lambda>x. dist a (f x) \<le> e \<and> dist (f x) l < dist a l - e) net" | |
| 1380 | by (rule eventually_conjI) | |
| 1381 | then obtain w where "dist a (f w) \<le> e" "dist (f w) l < dist a l - e" | |
| 1382 | using assms(1) eventually_happens by auto | |
| 1383 | hence "dist a (f w) + dist (f w) l < e + (dist a l - e)" | |
| 1384 | by (rule add_le_less_mono) | |
| 1385 | hence "dist a (f w) + dist (f w) l < dist a l" | |
| 1386 | by simp | |
| 1387 | also have "\<dots> \<le> dist a (f w) + dist (f w) l" | |
| 1388 | by (rule dist_triangle) | |
| 1389 | finally show False by simp | |
| 1390 | qed | |
| 1391 | ||
| 1392 | lemma Lim_norm_ubound: | |
| 1393 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1394 | assumes "\<not>(trivial_limit net)" "(f ---> l) net" "eventually (\<lambda>x. norm(f x) <= e) net" | |
| 1395 | shows "norm(l) <= e" | |
| 1396 | proof (rule ccontr) | |
| 1397 | assume "\<not> norm l \<le> e" | |
| 1398 | then have "0 < norm l - e" by simp | |
| 1399 | with assms(2) have "eventually (\<lambda>x. dist (f x) l < norm l - e) net" | |
| 1400 | by (rule tendstoD) | |
| 1401 | with assms(3) have "eventually (\<lambda>x. norm (f x) \<le> e \<and> dist (f x) l < norm l - e) net" | |
| 1402 | by (rule eventually_conjI) | |
| 1403 | then obtain w where "norm (f w) \<le> e" "dist (f w) l < norm l - e" | |
| 1404 | using assms(1) eventually_happens by auto | |
| 1405 | hence "norm (f w - l) < norm l - e" "norm (f w) \<le> e" by (simp_all add: dist_norm) | |
| 1406 | hence "norm (f w - l) + norm (f w) < norm l" by simp | |
| 1407 | hence "norm (f w - l - f w) < norm l" by (rule le_less_trans [OF norm_triangle_ineq4]) | |
| 1408 | thus False using `\<not> norm l \<le> e` by simp | |
| 1409 | qed | |
| 1410 | ||
| 1411 | lemma Lim_norm_lbound: | |
| 1412 | fixes f :: "'a \<Rightarrow> 'b::real_normed_vector" | |
| 1413 | assumes "\<not> (trivial_limit net)" "(f ---> l) net" "eventually (\<lambda>x. e <= norm(f x)) net" | |
| 1414 | shows "e \<le> norm l" | |
| 1415 | proof (rule ccontr) | |
| 1416 | assume "\<not> e \<le> norm l" | |
| 1417 | then have "0 < e - norm l" by simp | |
| 1418 | with assms(2) have "eventually (\<lambda>x. dist (f x) l < e - norm l) net" | |
| 1419 | by (rule tendstoD) | |
| 1420 | with assms(3) have "eventually (\<lambda>x. e \<le> norm (f x) \<and> dist (f x) l < e - norm l) net" | |
| 1421 | by (rule eventually_conjI) | |
| 1422 | then obtain w where "e \<le> norm (f w)" "dist (f w) l < e - norm l" | |
| 1423 | using assms(1) eventually_happens by auto | |
| 1424 | hence "norm (f w - l) + norm l < e" "e \<le> norm (f w)" by (simp_all add: dist_norm) | |
| 1425 | hence "norm (f w - l) + norm l < norm (f w)" by (rule less_le_trans) | |
| 1426 | hence "norm (f w - l + l) < norm (f w)" by (rule le_less_trans [OF norm_triangle_ineq]) | |
| 1427 | thus False by simp | |
| 1428 | qed | |
| 1429 | ||
| 1430 | text{* Uniqueness of the limit, when nontrivial. *}
 | |
| 1431 | ||
| 1432 | lemma Lim_unique: | |
| 1433 | fixes f :: "'a \<Rightarrow> 'b::t2_space" | |
| 1434 | assumes "\<not> trivial_limit net" "(f ---> l) net" "(f ---> l') net" | |
| 1435 | shows "l = l'" | |
| 1436 | proof (rule ccontr) | |
| 1437 | assume "l \<noteq> l'" | |
| 1438 |   obtain U V where "open U" "open V" "l \<in> U" "l' \<in> V" "U \<inter> V = {}"
 | |
| 1439 | using hausdorff [OF `l \<noteq> l'`] by fast | |
| 1440 | have "eventually (\<lambda>x. f x \<in> U) net" | |
| 1441 | using `(f ---> l) net` `open U` `l \<in> U` by (rule topological_tendstoD) | |
| 1442 | moreover | |
| 1443 | have "eventually (\<lambda>x. f x \<in> V) net" | |
| 1444 | using `(f ---> l') net` `open V` `l' \<in> V` by (rule topological_tendstoD) | |
| 1445 | ultimately | |
| 1446 | have "eventually (\<lambda>x. False) net" | |
| 1447 | proof (rule eventually_elim2) | |
| 1448 | fix x | |
| 1449 | assume "f x \<in> U" "f x \<in> V" | |
| 1450 | hence "f x \<in> U \<inter> V" by simp | |
| 1451 |     with `U \<inter> V = {}` show "False" by simp
 | |
| 1452 | qed | |
| 1453 | with `\<not> trivial_limit net` show "False" | |
| 1454 | by (simp add: eventually_False) | |
| 1455 | qed | |
| 1456 | ||
| 1457 | lemma tendsto_Lim: | |
| 1458 | fixes f :: "'a \<Rightarrow> 'b::t2_space" | |
| 1459 | shows "~(trivial_limit net) \<Longrightarrow> (f ---> l) net ==> Lim net f = l" | |
| 1460 | unfolding Lim_def using Lim_unique[of net f] by auto | |
| 1461 | ||
| 1462 | text{* Limit under bilinear function *}
 | |
| 1463 | ||
| 1464 | lemma Lim_bilinear: | |
| 1465 | assumes "(f ---> l) net" and "(g ---> m) net" and "bounded_bilinear h" | |
| 1466 | shows "((\<lambda>x. h (f x) (g x)) ---> (h l m)) net" | |
| 1467 | using `bounded_bilinear h` `(f ---> l) net` `(g ---> m) net` | |
| 1468 | by (rule bounded_bilinear.tendsto) | |
| 1469 | ||
| 1470 | text{* These are special for limits out of the same vector space. *}
 | |
| 1471 | ||
| 1472 | lemma Lim_within_id: "(id ---> a) (at a within s)" | |
| 1473 | unfolding tendsto_def Limits.eventually_within eventually_at_topological | |
| 1474 | by auto | |
| 1475 | ||
| 36437 | 1476 | lemmas Lim_intros = Lim_add Lim_const Lim_sub Lim_cmul Lim_vmul Lim_within_id | 
| 1477 | ||
| 33175 | 1478 | lemma Lim_at_id: "(id ---> a) (at a)" | 
| 1479 | apply (subst within_UNIV[symmetric]) by (simp add: Lim_within_id) | |
| 1480 | ||
| 1481 | lemma Lim_at_zero: | |
| 1482 | fixes a :: "'a::real_normed_vector" | |
| 1483 | fixes l :: "'b::topological_space" | |
| 1484 | shows "(f ---> l) (at a) \<longleftrightarrow> ((\<lambda>x. f(a + x)) ---> l) (at 0)" (is "?lhs = ?rhs") | |
| 1485 | proof | |
| 1486 | assume "?lhs" | |
| 1487 |   { fix S assume "open S" "l \<in> S"
 | |
| 1488 | with `?lhs` have "eventually (\<lambda>x. f x \<in> S) (at a)" | |
| 1489 | by (rule topological_tendstoD) | |
| 1490 | then obtain d where d: "d>0" "\<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<in> S" | |
| 1491 | unfolding Limits.eventually_at by fast | |
| 1492 |     { fix x::"'a" assume "x \<noteq> 0 \<and> dist x 0 < d"
 | |
| 1493 | hence "f (a + x) \<in> S" using d | |
| 1494 | apply(erule_tac x="x+a" in allE) | |
| 35820 
b57c3afd1484
dropped odd interpretation of comm_monoid_mult into comm_monoid_add; consider Min.insert_idem as default simp rule
 haftmann parents: 
35172diff
changeset | 1495 | by (auto simp add: add_commute dist_norm dist_commute) | 
| 33175 | 1496 | } | 
| 1497 | hence "\<exists>d>0. \<forall>x. x \<noteq> 0 \<and> dist x 0 < d \<longrightarrow> f (a + x) \<in> S" | |
| 1498 | using d(1) by auto | |
| 1499 | hence "eventually (\<lambda>x. f (a + x) \<in> S) (at 0)" | |
| 1500 | unfolding Limits.eventually_at . | |
| 1501 | } | |
| 1502 | thus "?rhs" by (rule topological_tendstoI) | |
| 1503 | next | |
| 1504 | assume "?rhs" | |
| 1505 |   { fix S assume "open S" "l \<in> S"
 | |
| 1506 | with `?rhs` have "eventually (\<lambda>x. f (a + x) \<in> S) (at 0)" | |
| 1507 | by (rule topological_tendstoD) | |
| 1508 | then obtain d where d: "d>0" "\<forall>x. x \<noteq> 0 \<and> dist x 0 < d \<longrightarrow> f (a + x) \<in> S" | |
| 1509 | unfolding Limits.eventually_at by fast | |
| 1510 |     { fix x::"'a" assume "x \<noteq> a \<and> dist x a < d"
 | |
| 1511 | hence "f x \<in> S" using d apply(erule_tac x="x-a" in allE) | |
| 35820 
b57c3afd1484
dropped odd interpretation of comm_monoid_mult into comm_monoid_add; consider Min.insert_idem as default simp rule
 haftmann parents: 
35172diff
changeset | 1512 | by(auto simp add: add_commute dist_norm dist_commute) | 
| 33175 | 1513 | } | 
| 1514 | hence "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<in> S" using d(1) by auto | |
| 1515 | hence "eventually (\<lambda>x. f x \<in> S) (at a)" unfolding Limits.eventually_at . | |
| 1516 | } | |
| 1517 | thus "?lhs" by (rule topological_tendstoI) | |
| 1518 | qed | |
| 1519 | ||
| 1520 | text{* It's also sometimes useful to extract the limit point from the net.  *}
 | |
| 1521 | ||
| 1522 | definition | |
| 1523 | netlimit :: "'a::t2_space net \<Rightarrow> 'a" where | |
| 1524 | "netlimit net = (SOME a. ((\<lambda>x. x) ---> a) net)" | |
| 1525 | ||
| 1526 | lemma netlimit_within: | |
| 1527 | assumes "\<not> trivial_limit (at a within S)" | |
| 1528 | shows "netlimit (at a within S) = a" | |
| 1529 | unfolding netlimit_def | |
| 1530 | apply (rule some_equality) | |
| 1531 | apply (rule Lim_at_within) | |
| 1532 | apply (rule Lim_ident_at) | |
| 1533 | apply (erule Lim_unique [OF assms]) | |
| 1534 | apply (rule Lim_at_within) | |
| 1535 | apply (rule Lim_ident_at) | |
| 1536 | done | |
| 1537 | ||
| 1538 | lemma netlimit_at: | |
| 1539 | fixes a :: "'a::perfect_space" | |
| 1540 | shows "netlimit (at a) = a" | |
| 1541 | apply (subst within_UNIV[symmetric]) | |
| 1542 | using netlimit_within[of a UNIV] | |
| 1543 | by (simp add: trivial_limit_at within_UNIV) | |
| 1544 | ||
| 1545 | text{* Transformation of limit. *}
 | |
| 1546 | ||
| 1547 | lemma Lim_transform: | |
| 1548 | fixes f g :: "'a::type \<Rightarrow> 'b::real_normed_vector" | |
| 1549 | assumes "((\<lambda>x. f x - g x) ---> 0) net" "(f ---> l) net" | |
| 1550 | shows "(g ---> l) net" | |
| 1551 | proof- | |
| 1552 | 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 | |
| 1553 | thus "?thesis" using Lim_neg [of "\<lambda> x. - g x" "-l" net] by auto | |
| 1554 | qed | |
| 1555 | ||
| 1556 | lemma Lim_transform_eventually: | |
| 36667 | 1557 | "eventually (\<lambda>x. f x = g x) net \<Longrightarrow> (f ---> l) net \<Longrightarrow> (g ---> l) net" | 
| 33175 | 1558 | apply (rule topological_tendstoI) | 
| 1559 | apply (drule (2) topological_tendstoD) | |
| 1560 | apply (erule (1) eventually_elim2, simp) | |
| 1561 | done | |
| 1562 | ||
| 1563 | lemma Lim_transform_within: | |
| 36667 | 1564 | assumes "0 < d" and "\<forall>x'\<in>S. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x'" | 
| 1565 | and "(f ---> l) (at x within S)" | |
| 1566 | shows "(g ---> l) (at x within S)" | |
| 1567 | proof (rule Lim_transform_eventually) | |
| 1568 | show "eventually (\<lambda>x. f x = g x) (at x within S)" | |
| 1569 | unfolding eventually_within | |
| 1570 | using assms(1,2) by auto | |
| 1571 | show "(f ---> l) (at x within S)" by fact | |
| 1572 | qed | |
| 33175 | 1573 | |
| 1574 | lemma Lim_transform_at: | |
| 36667 | 1575 | assumes "0 < d" and "\<forall>x'. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x'" | 
| 1576 | and "(f ---> l) (at x)" | |
| 1577 | shows "(g ---> l) (at x)" | |
| 1578 | proof (rule Lim_transform_eventually) | |
| 1579 | show "eventually (\<lambda>x. f x = g x) (at x)" | |
| 1580 | unfolding eventually_at | |
| 1581 | using assms(1,2) by auto | |
| 1582 | show "(f ---> l) (at x)" by fact | |
| 1583 | qed | |
| 33175 | 1584 | |
| 1585 | text{* Common case assuming being away from some crucial point like 0. *}
 | |
| 1586 | ||
| 1587 | lemma Lim_transform_away_within: | |
| 36669 | 1588 | fixes a b :: "'a::t1_space" | 
| 36667 | 1589 | assumes "a \<noteq> b" and "\<forall>x\<in>S. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" | 
| 33175 | 1590 | and "(f ---> l) (at a within S)" | 
| 1591 | shows "(g ---> l) (at a within S)" | |
| 36669 | 1592 | proof (rule Lim_transform_eventually) | 
| 1593 | show "(f ---> l) (at a within S)" by fact | |
| 1594 | show "eventually (\<lambda>x. f x = g x) (at a within S)" | |
| 1595 | unfolding Limits.eventually_within eventually_at_topological | |
| 1596 |     by (rule exI [where x="- {b}"], simp add: open_Compl assms)
 | |
| 33175 | 1597 | qed | 
| 1598 | ||
| 1599 | lemma Lim_transform_away_at: | |
| 36669 | 1600 | fixes a b :: "'a::t1_space" | 
| 33175 | 1601 | assumes ab: "a\<noteq>b" and fg: "\<forall>x. x \<noteq> a \<and> x \<noteq> b \<longrightarrow> f x = g x" | 
| 1602 | and fl: "(f ---> l) (at a)" | |
| 1603 | shows "(g ---> l) (at a)" | |
| 1604 | using Lim_transform_away_within[OF ab, of UNIV f g l] fg fl | |
| 1605 | by (auto simp add: within_UNIV) | |
| 1606 | ||
| 1607 | text{* Alternatively, within an open set. *}
 | |
| 1608 | ||
| 1609 | lemma Lim_transform_within_open: | |
| 36667 | 1610 | assumes "open S" and "a \<in> S" and "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> f x = g x" | 
| 1611 | and "(f ---> l) (at a)" | |
| 33175 | 1612 | shows "(g ---> l) (at a)" | 
| 36667 | 1613 | proof (rule Lim_transform_eventually) | 
| 1614 | show "eventually (\<lambda>x. f x = g x) (at a)" | |
| 1615 | unfolding eventually_at_topological | |
| 1616 | using assms(1,2,3) by auto | |
| 1617 | show "(f ---> l) (at a)" by fact | |
| 33175 | 1618 | qed | 
| 1619 | ||
| 1620 | text{* A congruence rule allowing us to transform limits assuming not at point. *}
 | |
| 1621 | ||
| 1622 | (* FIXME: Only one congruence rule for tendsto can be used at a time! *) | |
| 1623 | ||
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 1624 | lemma Lim_cong_within(*[cong add]*): | 
| 36667 | 1625 | assumes "\<And>x. x \<noteq> a \<Longrightarrow> f x = g x" | 
| 1626 | shows "((\<lambda>x. f x) ---> l) (at a within S) \<longleftrightarrow> ((g ---> l) (at a within S))" | |
| 1627 | unfolding tendsto_def Limits.eventually_within eventually_at_topological | |
| 1628 | using assms by simp | |
| 1629 | ||
| 1630 | lemma Lim_cong_at(*[cong add]*): | |
| 1631 | assumes "\<And>x. x \<noteq> a \<Longrightarrow> f x = g x" | |
| 1632 | shows "((\<lambda>x. f x) ---> l) (at a) \<longleftrightarrow> ((g ---> l) (at a))" | |
| 1633 | unfolding tendsto_def eventually_at_topological | |
| 1634 | using assms by simp | |
| 33175 | 1635 | |
| 1636 | text{* Useful lemmas on closure and set of possible sequential limits.*}
 | |
| 1637 | ||
| 1638 | lemma closure_sequential: | |
| 36667 | 1639 | fixes l :: "'a::metric_space" | 
| 33175 | 1640 | shows "l \<in> closure S \<longleftrightarrow> (\<exists>x. (\<forall>n. x n \<in> S) \<and> (x ---> l) sequentially)" (is "?lhs = ?rhs") | 
| 1641 | proof | |
| 1642 | assume "?lhs" moreover | |
| 1643 |   { assume "l \<in> S"
 | |
| 1644 | hence "?rhs" using Lim_const[of l sequentially] by auto | |
| 1645 | } moreover | |
| 1646 |   { assume "l islimpt S"
 | |
| 1647 | hence "?rhs" unfolding islimpt_sequential by auto | |
| 1648 | } ultimately | |
| 1649 | show "?rhs" unfolding closure_def by auto | |
| 1650 | next | |
| 1651 | assume "?rhs" | |
| 1652 | thus "?lhs" unfolding closure_def unfolding islimpt_sequential by auto | |
| 1653 | qed | |
| 1654 | ||
| 1655 | lemma closed_sequential_limits: | |
| 1656 | fixes S :: "'a::metric_space set" | |
| 1657 | shows "closed S \<longleftrightarrow> (\<forall>x l. (\<forall>n. x n \<in> S) \<and> (x ---> l) sequentially \<longrightarrow> l \<in> S)" | |
| 1658 | unfolding closed_limpt | |
| 1659 | 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] | |
| 1660 | by metis | |
| 1661 | ||
| 1662 | lemma closure_approachable: | |
| 1663 | fixes S :: "'a::metric_space set" | |
| 1664 | shows "x \<in> closure S \<longleftrightarrow> (\<forall>e>0. \<exists>y\<in>S. dist y x < e)" | |
| 1665 | apply (auto simp add: closure_def islimpt_approachable) | |
| 1666 | by (metis dist_self) | |
| 1667 | ||
| 1668 | lemma closed_approachable: | |
| 1669 | fixes S :: "'a::metric_space set" | |
| 1670 | shows "closed S ==> (\<forall>e>0. \<exists>y\<in>S. dist y x < e) \<longleftrightarrow> x \<in> S" | |
| 1671 | by (metis closure_closed closure_approachable) | |
| 1672 | ||
| 1673 | text{* Some other lemmas about sequences. *}
 | |
| 1674 | ||
| 36441 | 1675 | lemma sequentially_offset: | 
| 1676 | assumes "eventually (\<lambda>i. P i) sequentially" | |
| 1677 | shows "eventually (\<lambda>i. P (i + k)) sequentially" | |
| 1678 | using assms unfolding eventually_sequentially by (metis trans_le_add1) | |
| 1679 | ||
| 33175 | 1680 | lemma seq_offset: | 
| 36441 | 1681 | assumes "(f ---> l) sequentially" | 
| 1682 | shows "((\<lambda>i. f (i + k)) ---> l) sequentially" | |
| 1683 | using assms unfolding tendsto_def | |
| 1684 | by clarify (rule sequentially_offset, simp) | |
| 33175 | 1685 | |
| 1686 | lemma seq_offset_neg: | |
| 1687 | "(f ---> l) sequentially ==> ((\<lambda>i. f(i - k)) ---> l) sequentially" | |
| 1688 | apply (rule topological_tendstoI) | |
| 1689 | apply (drule (2) topological_tendstoD) | |
| 1690 | apply (simp only: eventually_sequentially) | |
| 1691 | apply (subgoal_tac "\<And>N k (n::nat). N + k <= n ==> N <= n - k") | |
| 1692 | apply metis | |
| 1693 | by arith | |
| 1694 | ||
| 1695 | lemma seq_offset_rev: | |
| 1696 | "((\<lambda>i. f(i + k)) ---> l) sequentially ==> (f ---> l) sequentially" | |
| 1697 | apply (rule topological_tendstoI) | |
| 1698 | apply (drule (2) topological_tendstoD) | |
| 1699 | apply (simp only: eventually_sequentially) | |
| 1700 | apply (subgoal_tac "\<And>N k (n::nat). N + k <= n ==> N <= n - k \<and> (n - k) + k = n") | |
| 1701 | by metis arith | |
| 1702 | ||
| 1703 | lemma seq_harmonic: "((\<lambda>n. inverse (real n)) ---> 0) sequentially" | |
| 1704 | proof- | |
| 1705 |   { fix e::real assume "e>0"
 | |
| 1706 | hence "\<exists>N::nat. \<forall>n::nat\<ge>N. inverse (real n) < e" | |
| 1707 | using real_arch_inv[of e] apply auto apply(rule_tac x=n in exI) | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 1708 | by (metis le_imp_inverse_le not_less real_of_nat_gt_zero_cancel_iff real_of_nat_less_iff xt1(7)) | 
| 33175 | 1709 | } | 
| 1710 | thus ?thesis unfolding Lim_sequentially dist_norm by simp | |
| 1711 | qed | |
| 1712 | ||
| 36437 | 1713 | subsection {* More properties of closed balls. *}
 | 
| 33175 | 1714 | |
| 1715 | lemma closed_cball: "closed (cball x e)" | |
| 1716 | unfolding cball_def closed_def | |
| 1717 | unfolding Collect_neg_eq [symmetric] not_le | |
| 1718 | apply (clarsimp simp add: open_dist, rename_tac y) | |
| 1719 | apply (rule_tac x="dist x y - e" in exI, clarsimp) | |
| 1720 | apply (rename_tac x') | |
| 1721 | apply (cut_tac x=x and y=x' and z=y in dist_triangle) | |
| 1722 | apply simp | |
| 1723 | done | |
| 1724 | ||
| 1725 | lemma open_contains_cball: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. cball x e \<subseteq> S)" | |
| 1726 | proof- | |
| 1727 |   { fix x and e::real assume "x\<in>S" "e>0" "ball x e \<subseteq> S"
 | |
| 1728 | hence "\<exists>d>0. cball x d \<subseteq> S" unfolding subset_eq by (rule_tac x="e/2" in exI, auto) | |
| 1729 | } moreover | |
| 1730 |   { fix x and e::real assume "x\<in>S" "e>0" "cball x e \<subseteq> S"
 | |
| 1731 | hence "\<exists>d>0. ball x d \<subseteq> S" unfolding subset_eq apply(rule_tac x="e/2" in exI) by auto | |
| 1732 | } ultimately | |
| 1733 | show ?thesis unfolding open_contains_ball by auto | |
| 1734 | qed | |
| 1735 | ||
| 1736 | lemma open_contains_cball_eq: "open S ==> (\<forall>x. x \<in> S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S))" | |
| 1737 | by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball mem_def) | |
| 1738 | ||
| 1739 | lemma mem_interior_cball: "x \<in> interior S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S)" | |
| 1740 | apply (simp add: interior_def, safe) | |
| 1741 | apply (force simp add: open_contains_cball) | |
| 1742 | apply (rule_tac x="ball x e" in exI) | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 1743 | apply (simp add: subset_trans [OF ball_subset_cball]) | 
| 33175 | 1744 | done | 
| 1745 | ||
| 1746 | lemma islimpt_ball: | |
| 1747 |   fixes x y :: "'a::{real_normed_vector,perfect_space}"
 | |
| 1748 | shows "y islimpt ball x e \<longleftrightarrow> 0 < e \<and> y \<in> cball x e" (is "?lhs = ?rhs") | |
| 1749 | proof | |
| 1750 | assume "?lhs" | |
| 1751 |   { assume "e \<le> 0"
 | |
| 1752 |     hence *:"ball x e = {}" using ball_eq_empty[of x e] by auto
 | |
| 1753 | have False using `?lhs` unfolding * using islimpt_EMPTY[of y] by auto | |
| 1754 | } | |
| 1755 | hence "e > 0" by (metis not_less) | |
| 1756 | moreover | |
| 1757 | 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 | |
| 1758 | ultimately show "?rhs" by auto | |
| 1759 | next | |
| 1760 | assume "?rhs" hence "e>0" by auto | |
| 1761 |   { fix d::real assume "d>0"
 | |
| 1762 | have "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1763 | proof(cases "d \<le> dist x y") | |
| 1764 | case True thus "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1765 | proof(cases "x=y") | |
| 1766 | case True hence False using `d \<le> dist x y` `d>0` by auto | |
| 1767 | thus "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" by auto | |
| 1768 | next | |
| 1769 | case False | |
| 1770 | ||
| 1771 | have "dist x (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) | |
| 1772 | = norm (x - y + (d / (2 * norm (y - x))) *\<^sub>R (y - x))" | |
| 1773 | unfolding mem_cball mem_ball dist_norm diff_diff_eq2 diff_add_eq[THEN sym] by auto | |
| 1774 | also have "\<dots> = \<bar>- 1 + d / (2 * norm (x - y))\<bar> * norm (x - y)" | |
| 1775 | using scaleR_left_distrib[of "- 1" "d / (2 * norm (y - x))", THEN sym, of "y - x"] | |
| 1776 | unfolding scaleR_minus_left scaleR_one | |
| 1777 | by (auto simp add: norm_minus_commute) | |
| 1778 | also have "\<dots> = \<bar>- norm (x - y) + d / 2\<bar>" | |
| 1779 | unfolding abs_mult_pos[of "norm (x - y)", OF norm_ge_zero[of "x - y"]] | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 1780 | unfolding left_distrib using `x\<noteq>y`[unfolded dist_nz, unfolded dist_norm] by auto | 
| 33175 | 1781 | also have "\<dots> \<le> e - d/2" using `d \<le> dist x y` and `d>0` and `?rhs` by(auto simp add: dist_norm) | 
| 1782 | finally have "y - (d / (2 * dist y x)) *\<^sub>R (y - x) \<in> ball x e" using `d>0` by auto | |
| 1783 | ||
| 1784 | moreover | |
| 1785 | ||
| 1786 | have "(d / (2*dist y x)) *\<^sub>R (y - x) \<noteq> 0" | |
| 1787 | using `x\<noteq>y`[unfolded dist_nz] `d>0` unfolding scaleR_eq_0_iff by (auto simp add: dist_commute) | |
| 1788 | moreover | |
| 1789 | have "dist (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) y < d" unfolding dist_norm apply simp unfolding norm_minus_cancel | |
| 1790 | using `d>0` `x\<noteq>y`[unfolded dist_nz] dist_commute[of x y] | |
| 1791 | unfolding dist_norm by auto | |
| 1792 | 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 | |
| 1793 | qed | |
| 1794 | next | |
| 1795 | case False hence "d > dist x y" by auto | |
| 1796 | show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1797 | proof(cases "x=y") | |
| 1798 | case True | |
| 1799 | obtain z where **: "z \<noteq> y" "dist z y < min e d" | |
| 1800 | using perfect_choose_dist[of "min e d" y] | |
| 1801 | using `d > 0` `e>0` by auto | |
| 1802 | show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1803 | unfolding `x = y` | |
| 1804 | using `z \<noteq> y` ** | |
| 1805 | by (rule_tac x=z in bexI, auto simp add: dist_commute) | |
| 1806 | next | |
| 1807 | case False thus "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d" | |
| 1808 | using `d>0` `d > dist x y` `?rhs` by(rule_tac x=x in bexI, auto) | |
| 1809 | qed | |
| 1810 | qed } | |
| 1811 | thus "?lhs" unfolding mem_cball islimpt_approachable mem_ball by auto | |
| 1812 | qed | |
| 1813 | ||
| 1814 | lemma closure_ball_lemma: | |
| 1815 | fixes x y :: "'a::real_normed_vector" | |
| 1816 | assumes "x \<noteq> y" shows "y islimpt ball x (dist x y)" | |
| 1817 | proof (rule islimptI) | |
| 1818 | fix T assume "y \<in> T" "open T" | |
| 1819 | then obtain r where "0 < r" "\<forall>z. dist z y < r \<longrightarrow> z \<in> T" | |
| 1820 | unfolding open_dist by fast | |
| 1821 | (* choose point between x and y, within distance r of y. *) | |
| 1822 | def k \<equiv> "min 1 (r / (2 * dist x y))" | |
| 1823 | def z \<equiv> "y + scaleR k (x - y)" | |
| 1824 | have z_def2: "z = x + scaleR (1 - k) (y - x)" | |
| 1825 | unfolding z_def by (simp add: algebra_simps) | |
| 1826 | have "dist z y < r" | |
| 1827 | unfolding z_def k_def using `0 < r` | |
| 1828 | by (simp add: dist_norm min_def) | |
| 1829 | hence "z \<in> T" using `\<forall>z. dist z y < r \<longrightarrow> z \<in> T` by simp | |
| 1830 | have "dist x z < dist x y" | |
| 1831 | unfolding z_def2 dist_norm | |
| 1832 | apply (simp add: norm_minus_commute) | |
| 1833 | apply (simp only: dist_norm [symmetric]) | |
| 1834 | apply (subgoal_tac "\<bar>1 - k\<bar> * dist x y < 1 * dist x y", simp) | |
| 1835 | apply (rule mult_strict_right_mono) | |
| 1836 | apply (simp add: k_def divide_pos_pos zero_less_dist_iff `0 < r` `x \<noteq> y`) | |
| 1837 | apply (simp add: zero_less_dist_iff `x \<noteq> y`) | |
| 1838 | done | |
| 1839 | hence "z \<in> ball x (dist x y)" by simp | |
| 1840 | have "z \<noteq> y" | |
| 1841 | unfolding z_def k_def using `x \<noteq> y` `0 < r` | |
| 1842 | by (simp add: min_def) | |
| 1843 | show "\<exists>z\<in>ball x (dist x y). z \<in> T \<and> z \<noteq> y" | |
| 1844 | using `z \<in> ball x (dist x y)` `z \<in> T` `z \<noteq> y` | |
| 1845 | by fast | |
| 1846 | qed | |
| 1847 | ||
| 1848 | lemma closure_ball: | |
| 1849 | fixes x :: "'a::real_normed_vector" | |
| 1850 | shows "0 < e \<Longrightarrow> closure (ball x e) = cball x e" | |
| 1851 | apply (rule equalityI) | |
| 1852 | apply (rule closure_minimal) | |
| 1853 | apply (rule ball_subset_cball) | |
| 1854 | apply (rule closed_cball) | |
| 1855 | apply (rule subsetI, rename_tac y) | |
| 1856 | apply (simp add: le_less [where 'a=real]) | |
| 1857 | apply (erule disjE) | |
| 1858 | apply (rule subsetD [OF closure_subset], simp) | |
| 1859 | apply (simp add: closure_def) | |
| 1860 | apply clarify | |
| 1861 | apply (rule closure_ball_lemma) | |
| 1862 | apply (simp add: zero_less_dist_iff) | |
| 1863 | done | |
| 1864 | ||
| 1865 | (* In a trivial vector space, this fails for e = 0. *) | |
| 1866 | lemma interior_cball: | |
| 1867 |   fixes x :: "'a::{real_normed_vector, perfect_space}"
 | |
| 1868 | shows "interior (cball x e) = ball x e" | |
| 1869 | proof(cases "e\<ge>0") | |
| 1870 | case False note cs = this | |
| 1871 |   from cs have "ball x e = {}" using ball_empty[of e x] by auto moreover
 | |
| 1872 |   { fix y assume "y \<in> cball x e"
 | |
| 1873 | hence False unfolding mem_cball using dist_nz[of x y] cs by auto } | |
| 1874 |   hence "cball x e = {}" by auto
 | |
| 1875 |   hence "interior (cball x e) = {}" using interior_empty by auto
 | |
| 1876 | ultimately show ?thesis by blast | |
| 1877 | next | |
| 1878 | case True note cs = this | |
| 1879 | have "ball x e \<subseteq> cball x e" using ball_subset_cball by auto moreover | |
| 1880 |   { fix S y assume as: "S \<subseteq> cball x e" "open S" "y\<in>S"
 | |
| 1881 | then obtain d where "d>0" and d:"\<forall>x'. dist x' y < d \<longrightarrow> x' \<in> S" unfolding open_dist by blast | |
| 1882 | ||
| 1883 | then obtain xa where xa_y: "xa \<noteq> y" and xa: "dist xa y < d" | |
| 1884 | using perfect_choose_dist [of d] by auto | |
| 1885 | have "xa\<in>S" using d[THEN spec[where x=xa]] using xa by(auto simp add: dist_commute) | |
| 1886 | hence xa_cball:"xa \<in> cball x e" using as(1) by auto | |
| 1887 | ||
| 1888 | hence "y \<in> ball x e" proof(cases "x = y") | |
| 1889 | case True | |
| 1890 | hence "e>0" using xa_y[unfolded dist_nz] xa_cball[unfolded mem_cball] by (auto simp add: dist_commute) | |
| 1891 | thus "y \<in> ball x e" using `x = y ` by simp | |
| 1892 | next | |
| 1893 | case False | |
| 1894 | have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) y < d" unfolding dist_norm | |
| 1895 | using `d>0` norm_ge_zero[of "y - x"] `x \<noteq> y` by auto | |
| 1896 | hence *:"y + (d / 2 / dist y x) *\<^sub>R (y - x) \<in> cball x e" using d as(1)[unfolded subset_eq] by blast | |
| 1897 | have "y - x \<noteq> 0" using `x \<noteq> y` by auto | |
| 1898 | hence **:"d / (2 * norm (y - x)) > 0" unfolding zero_less_norm_iff[THEN sym] | |
| 1899 | using `d>0` divide_pos_pos[of d "2*norm (y - x)"] by auto | |
| 1900 | ||
| 1901 | 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)" | |
| 1902 | by (auto simp add: dist_norm algebra_simps) | |
| 1903 | also have "\<dots> = norm ((1 + d / (2 * norm (y - x))) *\<^sub>R (y - x))" | |
| 1904 | by (auto simp add: algebra_simps) | |
| 1905 | also have "\<dots> = \<bar>1 + d / (2 * norm (y - x))\<bar> * norm (y - x)" | |
| 1906 | using ** by auto | |
| 1907 | also have "\<dots> = (dist y x) + d/2"using ** by (auto simp add: left_distrib dist_norm) | |
| 1908 | finally have "e \<ge> dist x y +d/2" using *[unfolded mem_cball] by (auto simp add: dist_commute) | |
| 1909 | thus "y \<in> ball x e" unfolding mem_ball using `d>0` by auto | |
| 1910 | qed } | |
| 1911 | hence "\<forall>S \<subseteq> cball x e. open S \<longrightarrow> S \<subseteq> ball x e" by auto | |
| 1912 | ultimately show ?thesis using interior_unique[of "ball x e" "cball x e"] using open_ball[of x e] by auto | |
| 1913 | qed | |
| 1914 | ||
| 1915 | lemma frontier_ball: | |
| 1916 | fixes a :: "'a::real_normed_vector" | |
| 1917 |   shows "0 < e ==> frontier(ball a e) = {x. dist a x = e}"
 | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 1918 | apply (simp add: frontier_def closure_ball interior_open order_less_imp_le) | 
| 33175 | 1919 | apply (simp add: expand_set_eq) | 
| 1920 | by arith | |
| 1921 | ||
| 1922 | lemma frontier_cball: | |
| 1923 |   fixes a :: "'a::{real_normed_vector, perfect_space}"
 | |
| 1924 |   shows "frontier(cball a e) = {x. dist a x = e}"
 | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 1925 | apply (simp add: frontier_def interior_cball closed_cball order_less_imp_le) | 
| 33175 | 1926 | apply (simp add: expand_set_eq) | 
| 1927 | by arith | |
| 1928 | ||
| 1929 | lemma cball_eq_empty: "(cball x e = {}) \<longleftrightarrow> e < 0"
 | |
| 1930 | apply (simp add: expand_set_eq not_le) | |
| 1931 | by (metis zero_le_dist dist_self order_less_le_trans) | |
| 1932 | lemma cball_empty: "e < 0 ==> cball x e = {}" by (simp add: cball_eq_empty)
 | |
| 1933 | ||
| 1934 | lemma cball_eq_sing: | |
| 1935 | fixes x :: "'a::perfect_space" | |
| 1936 |   shows "(cball x e = {x}) \<longleftrightarrow> e = 0"
 | |
| 1937 | proof (rule linorder_cases) | |
| 1938 | assume e: "0 < e" | |
| 1939 | obtain a where "a \<noteq> x" "dist a x < e" | |
| 1940 | using perfect_choose_dist [OF e] by auto | |
| 1941 | hence "a \<noteq> x" "dist x a \<le> e" by (auto simp add: dist_commute) | |
| 1942 | with e show ?thesis by (auto simp add: expand_set_eq) | |
| 1943 | qed auto | |
| 1944 | ||
| 1945 | lemma cball_sing: | |
| 1946 | fixes x :: "'a::metric_space" | |
| 1947 |   shows "e = 0 ==> cball x e = {x}"
 | |
| 1948 | by (auto simp add: expand_set_eq) | |
| 1949 | ||
| 1950 | text{* For points in the interior, localization of limits makes no difference.   *}
 | |
| 1951 | ||
| 1952 | lemma eventually_within_interior: | |
| 1953 | assumes "x \<in> interior S" | |
| 1954 | shows "eventually P (at x within S) \<longleftrightarrow> eventually P (at x)" (is "?lhs = ?rhs") | |
| 1955 | proof- | |
| 1956 | from assms obtain T where T: "open T" "x \<in> T" "T \<subseteq> S" | |
| 1957 | unfolding interior_def by fast | |
| 1958 |   { assume "?lhs"
 | |
| 1959 | then obtain A where "open A" "x \<in> A" "\<forall>y\<in>A. y \<noteq> x \<longrightarrow> y \<in> S \<longrightarrow> P y" | |
| 1960 | unfolding Limits.eventually_within Limits.eventually_at_topological | |
| 1961 | by auto | |
| 1962 | with T have "open (A \<inter> T)" "x \<in> A \<inter> T" "\<forall>y\<in>(A \<inter> T). y \<noteq> x \<longrightarrow> P y" | |
| 1963 | by auto | |
| 1964 | then have "?rhs" | |
| 1965 | unfolding Limits.eventually_at_topological by auto | |
| 1966 | } moreover | |
| 1967 |   { assume "?rhs" hence "?lhs"
 | |
| 1968 | unfolding Limits.eventually_within | |
| 1969 | by (auto elim: eventually_elim1) | |
| 1970 | } ultimately | |
| 1971 | show "?thesis" .. | |
| 1972 | qed | |
| 1973 | ||
| 1974 | lemma lim_within_interior: | |
| 1975 | "x \<in> interior S \<Longrightarrow> (f ---> l) (at x within S) \<longleftrightarrow> (f ---> l) (at x)" | |
| 1976 | unfolding tendsto_def by (simp add: eventually_within_interior) | |
| 1977 | ||
| 1978 | lemma netlimit_within_interior: | |
| 1979 |   fixes x :: "'a::{perfect_space, real_normed_vector}"
 | |
| 1980 | (* FIXME: generalize to perfect_space *) | |
| 1981 | assumes "x \<in> interior S" | |
| 1982 | shows "netlimit(at x within S) = x" (is "?lhs = ?rhs") | |
| 1983 | proof- | |
| 1984 | 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 | |
| 1985 | 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 | |
| 1986 | thus ?thesis using netlimit_within by auto | |
| 1987 | qed | |
| 1988 | ||
| 1989 | subsection{* Boundedness. *}
 | |
| 1990 | ||
| 1991 | (* FIXME: This has to be unified with BSEQ!! *) | |
| 1992 | definition | |
| 1993 | bounded :: "'a::metric_space set \<Rightarrow> bool" where | |
| 1994 | "bounded S \<longleftrightarrow> (\<exists>x e. \<forall>y\<in>S. dist x y \<le> e)" | |
| 1995 | ||
| 1996 | lemma bounded_any_center: "bounded S \<longleftrightarrow> (\<exists>e. \<forall>y\<in>S. dist a y \<le> e)" | |
| 1997 | unfolding bounded_def | |
| 1998 | apply safe | |
| 1999 | apply (rule_tac x="dist a x + e" in exI, clarify) | |
| 2000 | apply (drule (1) bspec) | |
| 2001 | apply (erule order_trans [OF dist_triangle add_left_mono]) | |
| 2002 | apply auto | |
| 2003 | done | |
| 2004 | ||
| 2005 | lemma bounded_iff: "bounded S \<longleftrightarrow> (\<exists>a. \<forall>x\<in>S. norm x \<le> a)" | |
| 2006 | unfolding bounded_any_center [where a=0] | |
| 2007 | by (simp add: dist_norm) | |
| 2008 | ||
| 2009 | lemma bounded_empty[simp]: "bounded {}" by (simp add: bounded_def)
 | |
| 2010 | lemma bounded_subset: "bounded T \<Longrightarrow> S \<subseteq> T ==> bounded S" | |
| 2011 | by (metis bounded_def subset_eq) | |
| 2012 | ||
| 2013 | lemma bounded_interior[intro]: "bounded S ==> bounded(interior S)" | |
| 2014 | by (metis bounded_subset interior_subset) | |
| 2015 | ||
| 2016 | lemma bounded_closure[intro]: assumes "bounded S" shows "bounded(closure S)" | |
| 2017 | proof- | |
| 2018 | from assms obtain x and a where a: "\<forall>y\<in>S. dist x y \<le> a" unfolding bounded_def by auto | |
| 2019 |   { fix y assume "y \<in> closure S"
 | |
| 2020 | then obtain f where f: "\<forall>n. f n \<in> S" "(f ---> y) sequentially" | |
| 2021 | unfolding closure_sequential by auto | |
| 2022 | have "\<forall>n. f n \<in> S \<longrightarrow> dist x (f n) \<le> a" using a by simp | |
| 2023 | hence "eventually (\<lambda>n. dist x (f n) \<le> a) sequentially" | |
| 2024 | by (rule eventually_mono, simp add: f(1)) | |
| 2025 | have "dist x y \<le> a" | |
| 2026 | apply (rule Lim_dist_ubound [of sequentially f]) | |
| 2027 | apply (rule trivial_limit_sequentially) | |
| 2028 | apply (rule f(2)) | |
| 2029 | apply fact | |
| 2030 | done | |
| 2031 | } | |
| 2032 | thus ?thesis unfolding bounded_def by auto | |
| 2033 | qed | |
| 2034 | ||
| 2035 | lemma bounded_cball[simp,intro]: "bounded (cball x e)" | |
| 2036 | apply (simp add: bounded_def) | |
| 2037 | apply (rule_tac x=x in exI) | |
| 2038 | apply (rule_tac x=e in exI) | |
| 2039 | apply auto | |
| 2040 | done | |
| 2041 | ||
| 2042 | lemma bounded_ball[simp,intro]: "bounded(ball x e)" | |
| 2043 | by (metis ball_subset_cball bounded_cball bounded_subset) | |
| 2044 | ||
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 2045 | lemma finite_imp_bounded[intro]: | 
| 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 2046 | fixes S :: "'a::metric_space set" assumes "finite S" shows "bounded S" | 
| 33175 | 2047 | proof- | 
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 2048 |   { fix a and F :: "'a set" assume as:"bounded F"
 | 
| 33175 | 2049 | then obtain x e where "\<forall>y\<in>F. dist x y \<le> e" unfolding bounded_def by auto | 
| 2050 | hence "\<forall>y\<in>(insert a F). dist x y \<le> max e (dist x a)" by auto | |
| 2051 | hence "bounded (insert a F)" unfolding bounded_def by (intro exI) | |
| 2052 | } | |
| 2053 | thus ?thesis using finite_induct[of S bounded] using bounded_empty assms by auto | |
| 2054 | qed | |
| 2055 | ||
| 2056 | lemma bounded_Un[simp]: "bounded (S \<union> T) \<longleftrightarrow> bounded S \<and> bounded T" | |
| 2057 | apply (auto simp add: bounded_def) | |
| 2058 | apply (rename_tac x y r s) | |
| 2059 | apply (rule_tac x=x in exI) | |
| 2060 | apply (rule_tac x="max r (dist x y + s)" in exI) | |
| 2061 | apply (rule ballI, rename_tac z, safe) | |
| 2062 | apply (drule (1) bspec, simp) | |
| 2063 | apply (drule (1) bspec) | |
| 2064 | apply (rule min_max.le_supI2) | |
| 2065 | apply (erule order_trans [OF dist_triangle add_left_mono]) | |
| 2066 | done | |
| 2067 | ||
| 2068 | lemma bounded_Union[intro]: "finite F \<Longrightarrow> (\<forall>S\<in>F. bounded S) \<Longrightarrow> bounded(\<Union>F)" | |
| 2069 | by (induct rule: finite_induct[of F], auto) | |
| 2070 | ||
| 2071 | lemma bounded_pos: "bounded S \<longleftrightarrow> (\<exists>b>0. \<forall>x\<in> S. norm x <= b)" | |
| 2072 | apply (simp add: bounded_iff) | |
| 2073 | apply (subgoal_tac "\<And>x (y::real). 0 < 1 + abs y \<and> (x <= y \<longrightarrow> x <= 1 + abs y)") | |
| 2074 | by metis arith | |
| 2075 | ||
| 2076 | lemma bounded_Int[intro]: "bounded S \<or> bounded T \<Longrightarrow> bounded (S \<inter> T)" | |
| 2077 | by (metis Int_lower1 Int_lower2 bounded_subset) | |
| 2078 | ||
| 2079 | lemma bounded_diff[intro]: "bounded S ==> bounded (S - T)" | |
| 2080 | apply (metis Diff_subset bounded_subset) | |
| 2081 | done | |
| 2082 | ||
| 2083 | lemma bounded_insert[intro]:"bounded(insert x S) \<longleftrightarrow> bounded S" | |
| 2084 | by (metis Diff_cancel Un_empty_right Un_insert_right bounded_Un bounded_subset finite.emptyI finite_imp_bounded infinite_remove subset_insertI) | |
| 2085 | ||
| 2086 | lemma not_bounded_UNIV[simp, intro]: | |
| 2087 |   "\<not> bounded (UNIV :: 'a::{real_normed_vector, perfect_space} set)"
 | |
| 2088 | proof(auto simp add: bounded_pos not_le) | |
| 2089 | obtain x :: 'a where "x \<noteq> 0" | |
| 2090 | using perfect_choose_dist [OF zero_less_one] by fast | |
| 2091 | fix b::real assume b: "b >0" | |
| 2092 | have b1: "b +1 \<ge> 0" using b by simp | |
| 2093 | with `x \<noteq> 0` have "b < norm (scaleR (b + 1) (sgn x))" | |
| 2094 | by (simp add: norm_sgn) | |
| 2095 | then show "\<exists>x::'a. b < norm x" .. | |
| 2096 | qed | |
| 2097 | ||
| 2098 | lemma bounded_linear_image: | |
| 2099 | assumes "bounded S" "bounded_linear f" | |
| 2100 | shows "bounded(f ` S)" | |
| 2101 | proof- | |
| 2102 | from assms(1) obtain b where b:"b>0" "\<forall>x\<in>S. norm x \<le> b" unfolding bounded_pos by auto | |
| 2103 | 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) | |
| 2104 |   { fix x assume "x\<in>S"
 | |
| 2105 | hence "norm x \<le> b" using b by auto | |
| 2106 | hence "norm (f x) \<le> B * b" using B(2) apply(erule_tac x=x in allE) | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 2107 | by (metis B(1) B(2) order_trans mult_le_cancel_left_pos) | 
| 33175 | 2108 | } | 
| 2109 | thus ?thesis unfolding bounded_pos apply(rule_tac x="b*B" in exI) | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 2110 | using b B mult_pos_pos [of b B] by (auto simp add: mult_commute) | 
| 33175 | 2111 | qed | 
| 2112 | ||
| 2113 | lemma bounded_scaling: | |
| 2114 | fixes S :: "'a::real_normed_vector set" | |
| 2115 | shows "bounded S \<Longrightarrow> bounded ((\<lambda>x. c *\<^sub>R x) ` S)" | |
| 2116 | apply (rule bounded_linear_image, assumption) | |
| 2117 | apply (rule scaleR.bounded_linear_right) | |
| 2118 | done | |
| 2119 | ||
| 2120 | lemma bounded_translation: | |
| 2121 | fixes S :: "'a::real_normed_vector set" | |
| 2122 | assumes "bounded S" shows "bounded ((\<lambda>x. a + x) ` S)" | |
| 2123 | proof- | |
| 2124 | from assms obtain b where b:"b>0" "\<forall>x\<in>S. norm x \<le> b" unfolding bounded_pos by auto | |
| 2125 |   { fix x assume "x\<in>S"
 | |
| 2126 | hence "norm (a + x) \<le> b + norm a" using norm_triangle_ineq[of a x] b by auto | |
| 2127 | } | |
| 2128 | thus ?thesis unfolding bounded_pos using norm_ge_zero[of a] b(1) using add_strict_increasing[of b 0 "norm a"] | |
| 2129 | by (auto intro!: add exI[of _ "b + norm a"]) | |
| 2130 | qed | |
| 2131 | ||
| 2132 | ||
| 2133 | text{* Some theorems on sups and infs using the notion "bounded". *}
 | |
| 2134 | ||
| 2135 | lemma bounded_real: | |
| 2136 | fixes S :: "real set" | |
| 2137 | shows "bounded S \<longleftrightarrow> (\<exists>a. \<forall>x\<in>S. abs x <= a)" | |
| 2138 | by (simp add: bounded_iff) | |
| 2139 | ||
| 33270 | 2140 | lemma bounded_has_Sup: | 
| 2141 | fixes S :: "real set" | |
| 2142 |   assumes "bounded S" "S \<noteq> {}"
 | |
| 2143 | shows "\<forall>x\<in>S. x <= Sup S" and "\<forall>b. (\<forall>x\<in>S. x <= b) \<longrightarrow> Sup S <= b" | |
| 2144 | proof | |
| 2145 | fix x assume "x\<in>S" | |
| 2146 | thus "x \<le> Sup S" | |
| 2147 | by (metis SupInf.Sup_upper abs_le_D1 assms(1) bounded_real) | |
| 2148 | next | |
| 2149 | show "\<forall>b. (\<forall>x\<in>S. x \<le> b) \<longrightarrow> Sup S \<le> b" using assms | |
| 2150 | by (metis SupInf.Sup_least) | |
| 2151 | qed | |
| 2152 | ||
| 2153 | lemma Sup_insert: | |
| 2154 | fixes S :: "real set" | |
| 2155 |   shows "bounded S ==> Sup(insert x S) = (if S = {} then x else max x (Sup S))" 
 | |
| 2156 | by auto (metis Int_absorb Sup_insert_nonempty assms bounded_has_Sup(1) disjoint_iff_not_equal) | |
| 2157 | ||
| 2158 | lemma Sup_insert_finite: | |
| 2159 | fixes S :: "real set" | |
| 2160 |   shows "finite S \<Longrightarrow> Sup(insert x S) = (if S = {} then x else max x (Sup S))"
 | |
| 2161 | apply (rule Sup_insert) | |
| 2162 | apply (rule finite_imp_bounded) | |
| 2163 | by simp | |
| 2164 | ||
| 2165 | lemma bounded_has_Inf: | |
| 2166 | fixes S :: "real set" | |
| 2167 |   assumes "bounded S"  "S \<noteq> {}"
 | |
| 2168 | shows "\<forall>x\<in>S. x >= Inf S" and "\<forall>b. (\<forall>x\<in>S. x >= b) \<longrightarrow> Inf S >= b" | |
| 33175 | 2169 | proof | 
| 2170 | fix x assume "x\<in>S" | |
| 2171 | from assms(1) obtain a where a:"\<forall>x\<in>S. \<bar>x\<bar> \<le> a" unfolding bounded_real by auto | |
| 33270 | 2172 | thus "x \<ge> Inf S" using `x\<in>S` | 
| 2173 | by (metis Inf_lower_EX abs_le_D2 minus_le_iff) | |
| 33175 | 2174 | next | 
| 33270 | 2175 | show "\<forall>b. (\<forall>x\<in>S. x >= b) \<longrightarrow> Inf S \<ge> b" using assms | 
| 2176 | by (metis SupInf.Inf_greatest) | |
| 2177 | qed | |
| 2178 | ||
| 2179 | lemma Inf_insert: | |
| 2180 | fixes S :: "real set" | |
| 2181 |   shows "bounded S ==> Inf(insert x S) = (if S = {} then x else min x (Inf S))" 
 | |
| 2182 | by auto (metis Int_absorb Inf_insert_nonempty bounded_has_Inf(1) disjoint_iff_not_equal) | |
| 2183 | lemma Inf_insert_finite: | |
| 2184 | fixes S :: "real set" | |
| 2185 |   shows "finite S ==> Inf(insert x S) = (if S = {} then x else min x (Inf S))"
 | |
| 2186 | by (rule Inf_insert, rule finite_imp_bounded, simp) | |
| 2187 | ||
| 33175 | 2188 | |
| 2189 | (* TODO: Move this to RComplete.thy -- would need to include Glb into RComplete *) | |
| 2190 | lemma real_isGlb_unique: "[| isGlb R S x; isGlb R S y |] ==> x = (y::real)" | |
| 2191 | apply (frule isGlb_isLb) | |
| 2192 | apply (frule_tac x = y in isGlb_isLb) | |
| 2193 | apply (blast intro!: order_antisym dest!: isGlb_le_isLb) | |
| 2194 | done | |
| 2195 | ||
| 36437 | 2196 | subsection {* Equivalent versions of compactness *}
 | 
| 2197 | ||
| 2198 | subsubsection{* Sequential compactness *}
 | |
| 33175 | 2199 | |
| 2200 | definition | |
| 2201 | compact :: "'a::metric_space set \<Rightarrow> bool" where (* TODO: generalize *) | |
| 2202 | "compact S \<longleftrightarrow> | |
| 2203 | (\<forall>f. (\<forall>n. f n \<in> S) \<longrightarrow> | |
| 2204 | (\<exists>l\<in>S. \<exists>r. subseq r \<and> ((f o r) ---> l) sequentially))" | |
| 2205 | ||
| 2206 | text {*
 | |
| 2207 | A metric space (or topological vector space) is said to have the | |
| 2208 | Heine-Borel property if every closed and bounded subset is compact. | |
| 2209 | *} | |
| 2210 | ||
| 2211 | class heine_borel = | |
| 2212 | assumes bounded_imp_convergent_subsequence: | |
| 2213 | "bounded s \<Longrightarrow> \<forall>n. f n \<in> s | |
| 2214 | \<Longrightarrow> \<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" | |
| 2215 | ||
| 2216 | lemma bounded_closed_imp_compact: | |
| 2217 | fixes s::"'a::heine_borel set" | |
| 2218 | assumes "bounded s" and "closed s" shows "compact s" | |
| 2219 | proof (unfold compact_def, clarify) | |
| 2220 | fix f :: "nat \<Rightarrow> 'a" assume f: "\<forall>n. f n \<in> s" | |
| 2221 | obtain l r where r: "subseq r" and l: "((f \<circ> r) ---> l) sequentially" | |
| 2222 | using bounded_imp_convergent_subsequence [OF `bounded s` `\<forall>n. f n \<in> s`] by auto | |
| 2223 | from f have fr: "\<forall>n. (f \<circ> r) n \<in> s" by simp | |
| 2224 | have "l \<in> s" using `closed s` fr l | |
| 2225 | unfolding closed_sequential_limits by blast | |
| 2226 | show "\<exists>l\<in>s. \<exists>r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" | |
| 2227 | using `l \<in> s` r l by blast | |
| 2228 | qed | |
| 2229 | ||
| 2230 | lemma subseq_bigger: assumes "subseq r" shows "n \<le> r n" | |
| 2231 | proof(induct n) | |
| 2232 | show "0 \<le> r 0" by auto | |
| 2233 | next | |
| 2234 | fix n assume "n \<le> r n" | |
| 2235 | moreover have "r n < r (Suc n)" | |
| 2236 | using assms [unfolded subseq_def] by auto | |
| 2237 | ultimately show "Suc n \<le> r (Suc n)" by auto | |
| 2238 | qed | |
| 2239 | ||
| 2240 | lemma eventually_subseq: | |
| 2241 | assumes r: "subseq r" | |
| 2242 | shows "eventually P sequentially \<Longrightarrow> eventually (\<lambda>n. P (r n)) sequentially" | |
| 2243 | unfolding eventually_sequentially | |
| 2244 | by (metis subseq_bigger [OF r] le_trans) | |
| 2245 | ||
| 2246 | lemma lim_subseq: | |
| 2247 | "subseq r \<Longrightarrow> (s ---> l) sequentially \<Longrightarrow> ((s o r) ---> l) sequentially" | |
| 2248 | unfolding tendsto_def eventually_sequentially o_def | |
| 2249 | by (metis subseq_bigger le_trans) | |
| 2250 | ||
| 2251 | lemma num_Axiom: "EX! g. g 0 = e \<and> (\<forall>n. g (Suc n) = f n (g n))" | |
| 2252 | unfolding Ex1_def | |
| 2253 | apply (rule_tac x="nat_rec e f" in exI) | |
| 2254 | apply (rule conjI)+ | |
| 2255 | apply (rule def_nat_rec_0, simp) | |
| 2256 | apply (rule allI, rule def_nat_rec_Suc, simp) | |
| 2257 | apply (rule allI, rule impI, rule ext) | |
| 2258 | apply (erule conjE) | |
| 2259 | apply (induct_tac x) | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 2260 | apply simp | 
| 33175 | 2261 | apply (erule_tac x="n" in allE) | 
| 2262 | apply (simp) | |
| 2263 | done | |
| 2264 | ||
| 2265 | lemma convergent_bounded_increasing: fixes s ::"nat\<Rightarrow>real" | |
| 2266 | assumes "incseq s" and "\<forall>n. abs(s n) \<le> b" | |
| 2267 | shows "\<exists> l. \<forall>e::real>0. \<exists> N. \<forall>n \<ge> N. abs(s n - l) < e" | |
| 2268 | proof- | |
| 2269 | have "isUb UNIV (range s) b" using assms(2) and abs_le_D1 unfolding isUb_def and setle_def by auto | |
| 2270 | then obtain t where t:"isLub UNIV (range s) t" using reals_complete[of "range s" ] by auto | |
| 2271 |   { fix e::real assume "e>0" and as:"\<forall>N. \<exists>n\<ge>N. \<not> \<bar>s n - t\<bar> < e"
 | |
| 2272 |     { fix n::nat
 | |
| 2273 | obtain N where "N\<ge>n" and n:"\<bar>s N - t\<bar> \<ge> e" using as[THEN spec[where x=n]] by auto | |
| 2274 | have "t \<ge> s N" using isLub_isUb[OF t, unfolded isUb_def setle_def] by auto | |
| 2275 | with n have "s N \<le> t - e" using `e>0` by auto | |
| 2276 | 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 } | |
| 2277 | hence "isUb UNIV (range s) (t - e)" unfolding isUb_def and setle_def by auto | |
| 2278 | hence False using isLub_le_isUb[OF t, of "t - e"] and `e>0` by auto } | |
| 2279 | thus ?thesis by blast | |
| 2280 | qed | |
| 2281 | ||
| 2282 | lemma convergent_bounded_monotone: fixes s::"nat \<Rightarrow> real" | |
| 2283 | assumes "\<forall>n. abs(s n) \<le> b" and "monoseq s" | |
| 2284 | shows "\<exists>l. \<forall>e::real>0. \<exists>N. \<forall>n\<ge>N. abs(s n - l) < e" | |
| 2285 | using convergent_bounded_increasing[of s b] assms using convergent_bounded_increasing[of "\<lambda>n. - s n" b] | |
| 2286 | unfolding monoseq_def incseq_def | |
| 2287 | apply auto unfolding minus_add_distrib[THEN sym, unfolded diff_minus[THEN sym]] | |
| 2288 | unfolding abs_minus_cancel by(rule_tac x="-l" in exI)auto | |
| 2289 | ||
| 2290 | lemma compact_real_lemma: | |
| 2291 | assumes "\<forall>n::nat. abs(s n) \<le> b" | |
| 2292 | shows "\<exists>(l::real) r. subseq r \<and> ((s \<circ> r) ---> l) sequentially" | |
| 2293 | proof- | |
| 2294 | obtain r where r:"subseq r" "monoseq (\<lambda>n. s (r n))" | |
| 2295 | using seq_monosub[of s] by auto | |
| 2296 | thus ?thesis using convergent_bounded_monotone[of "\<lambda>n. s (r n)" b] and assms | |
| 2297 | unfolding tendsto_iff dist_norm eventually_sequentially by auto | |
| 2298 | qed | |
| 2299 | ||
| 2300 | instance real :: heine_borel | |
| 2301 | proof | |
| 2302 | fix s :: "real set" and f :: "nat \<Rightarrow> real" | |
| 2303 | assume s: "bounded s" and f: "\<forall>n. f n \<in> s" | |
| 2304 | then obtain b where b: "\<forall>n. abs (f n) \<le> b" | |
| 2305 | unfolding bounded_iff by auto | |
| 2306 | obtain l :: real and r :: "nat \<Rightarrow> nat" where | |
| 2307 | r: "subseq r" and l: "((f \<circ> r) ---> l) sequentially" | |
| 2308 | using compact_real_lemma [OF b] by auto | |
| 2309 | thus "\<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" | |
| 2310 | by auto | |
| 2311 | qed | |
| 2312 | ||
| 2313 | lemma bounded_component: "bounded s \<Longrightarrow> bounded ((\<lambda>x. x $ i) ` s)" | |
| 2314 | unfolding bounded_def | |
| 2315 | apply clarify | |
| 2316 | apply (rule_tac x="x $ i" in exI) | |
| 2317 | apply (rule_tac x="e" in exI) | |
| 2318 | apply clarify | |
| 2319 | apply (rule order_trans [OF dist_nth_le], simp) | |
| 2320 | done | |
| 2321 | ||
| 2322 | lemma compact_lemma: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 2323 | fixes f :: "nat \<Rightarrow> 'a::heine_borel ^ 'n" | 
| 33175 | 2324 | assumes "bounded s" and "\<forall>n. f n \<in> s" | 
| 2325 | shows "\<forall>d. | |
| 2326 | \<exists>l r. subseq r \<and> | |
| 2327 | (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) $ i) (l $ i) < e) sequentially)" | |
| 2328 | proof | |
| 2329 | fix d::"'n set" have "finite d" by simp | |
| 2330 | thus "\<exists>l::'a ^ 'n. \<exists>r. subseq r \<and> | |
| 2331 | (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) $ i) (l $ i) < e) sequentially)" | |
| 2332 | proof(induct d) case empty thus ?case unfolding subseq_def by auto | |
| 2333 | next case (insert k d) | |
| 2334 | have s': "bounded ((\<lambda>x. x $ k) ` s)" using `bounded s` by (rule bounded_component) | |
| 2335 | 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" | |
| 2336 | using insert(3) by auto | |
| 2337 | have f': "\<forall>n. f (r1 n) $ k \<in> (\<lambda>x. x $ k) ` s" using `\<forall>n. f n \<in> s` by simp | |
| 2338 | obtain l2 r2 where r2:"subseq r2" and lr2:"((\<lambda>i. f (r1 (r2 i)) $ k) ---> l2) sequentially" | |
| 2339 | using bounded_imp_convergent_subsequence[OF s' f'] unfolding o_def by auto | |
| 2340 | def r \<equiv> "r1 \<circ> r2" have r:"subseq r" | |
| 2341 | using r1 and r2 unfolding r_def o_def subseq_def by auto | |
| 2342 | moreover | |
| 2343 | def l \<equiv> "(\<chi> i. if i = k then l2 else l1$i)::'a^'n" | |
| 2344 |     { fix e::real assume "e>0"
 | |
| 2345 | from lr1 `e>0` have N1:"eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r1 n) $ i) (l1 $ i) < e) sequentially" by blast | |
| 2346 | from lr2 `e>0` have N2:"eventually (\<lambda>n. dist (f (r1 (r2 n)) $ k) l2 < e) sequentially" by (rule tendstoD) | |
| 2347 | from r2 N1 have N1': "eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r1 (r2 n)) $ i) (l1 $ i) < e) sequentially" | |
| 2348 | by (rule eventually_subseq) | |
| 2349 | have "eventually (\<lambda>n. \<forall>i\<in>(insert k d). dist (f (r n) $ i) (l $ i) < e) sequentially" | |
| 2350 | using N1' N2 by (rule eventually_elim2, simp add: l_def r_def) | |
| 2351 | } | |
| 2352 | ultimately show ?case by auto | |
| 2353 | qed | |
| 2354 | qed | |
| 2355 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 2356 | instance cart :: (heine_borel, finite) heine_borel | 
| 33175 | 2357 | proof | 
| 2358 |   fix s :: "('a ^ 'b) set" and f :: "nat \<Rightarrow> 'a ^ 'b"
 | |
| 2359 | assume s: "bounded s" and f: "\<forall>n. f n \<in> s" | |
| 2360 | then obtain l r where r: "subseq r" | |
| 2361 | and l: "\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>UNIV. dist (f (r n) $ i) (l $ i) < e) sequentially" | |
| 2362 | using compact_lemma [OF s f] by blast | |
| 2363 | let ?d = "UNIV::'b set" | |
| 2364 |   { fix e::real assume "e>0"
 | |
| 2365 | hence "0 < e / (real_of_nat (card ?d))" | |
| 2366 | using zero_less_card_finite using divide_pos_pos[of e, of "real_of_nat (card ?d)"] by auto | |
| 2367 | with l have "eventually (\<lambda>n. \<forall>i. dist (f (r n) $ i) (l $ i) < e / (real_of_nat (card ?d))) sequentially" | |
| 2368 | by simp | |
| 2369 | moreover | |
| 2370 |     { fix n assume n: "\<forall>i. dist (f (r n) $ i) (l $ i) < e / (real_of_nat (card ?d))"
 | |
| 2371 | have "dist (f (r n)) l \<le> (\<Sum>i\<in>?d. dist (f (r n) $ i) (l $ i))" | |
| 2372 | unfolding dist_vector_def using zero_le_dist by (rule setL2_le_setsum) | |
| 2373 | also have "\<dots> < (\<Sum>i\<in>?d. e / (real_of_nat (card ?d)))" | |
| 2374 | by (rule setsum_strict_mono) (simp_all add: n) | |
| 2375 | finally have "dist (f (r n)) l < e" by simp | |
| 2376 | } | |
| 2377 | ultimately have "eventually (\<lambda>n. dist (f (r n)) l < e) sequentially" | |
| 2378 | by (rule eventually_elim1) | |
| 2379 | } | |
| 2380 | hence *:"((f \<circ> r) ---> l) sequentially" unfolding o_def tendsto_iff by simp | |
| 2381 | with r show "\<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" by auto | |
| 2382 | qed | |
| 2383 | ||
| 2384 | lemma bounded_fst: "bounded s \<Longrightarrow> bounded (fst ` s)" | |
| 2385 | unfolding bounded_def | |
| 2386 | apply clarify | |
| 2387 | apply (rule_tac x="a" in exI) | |
| 2388 | apply (rule_tac x="e" in exI) | |
| 2389 | apply clarsimp | |
| 2390 | apply (drule (1) bspec) | |
| 2391 | apply (simp add: dist_Pair_Pair) | |
| 2392 | apply (erule order_trans [OF real_sqrt_sum_squares_ge1]) | |
| 2393 | done | |
| 2394 | ||
| 2395 | lemma bounded_snd: "bounded s \<Longrightarrow> bounded (snd ` s)" | |
| 2396 | unfolding bounded_def | |
| 2397 | apply clarify | |
| 2398 | apply (rule_tac x="b" in exI) | |
| 2399 | apply (rule_tac x="e" in exI) | |
| 2400 | apply clarsimp | |
| 2401 | apply (drule (1) bspec) | |
| 2402 | apply (simp add: dist_Pair_Pair) | |
| 2403 | apply (erule order_trans [OF real_sqrt_sum_squares_ge2]) | |
| 2404 | done | |
| 2405 | ||
| 2406 | instance "*" :: (heine_borel, heine_borel) heine_borel | |
| 2407 | proof | |
| 2408 |   fix s :: "('a * 'b) set" and f :: "nat \<Rightarrow> 'a * 'b"
 | |
| 2409 | assume s: "bounded s" and f: "\<forall>n. f n \<in> s" | |
| 2410 | from s have s1: "bounded (fst ` s)" by (rule bounded_fst) | |
| 2411 | from f have f1: "\<forall>n. fst (f n) \<in> fst ` s" by simp | |
| 2412 | obtain l1 r1 where r1: "subseq r1" | |
| 2413 | and l1: "((\<lambda>n. fst (f (r1 n))) ---> l1) sequentially" | |
| 2414 | using bounded_imp_convergent_subsequence [OF s1 f1] | |
| 2415 | unfolding o_def by fast | |
| 2416 | from s have s2: "bounded (snd ` s)" by (rule bounded_snd) | |
| 2417 | from f have f2: "\<forall>n. snd (f (r1 n)) \<in> snd ` s" by simp | |
| 2418 | obtain l2 r2 where r2: "subseq r2" | |
| 2419 | and l2: "((\<lambda>n. snd (f (r1 (r2 n)))) ---> l2) sequentially" | |
| 2420 | using bounded_imp_convergent_subsequence [OF s2 f2] | |
| 2421 | unfolding o_def by fast | |
| 2422 | have l1': "((\<lambda>n. fst (f (r1 (r2 n)))) ---> l1) sequentially" | |
| 2423 | using lim_subseq [OF r2 l1] unfolding o_def . | |
| 2424 | have l: "((f \<circ> (r1 \<circ> r2)) ---> (l1, l2)) sequentially" | |
| 2425 | using tendsto_Pair [OF l1' l2] unfolding o_def by simp | |
| 2426 | have r: "subseq (r1 \<circ> r2)" | |
| 2427 | using r1 r2 unfolding subseq_def by simp | |
| 2428 | show "\<exists>l r. subseq r \<and> ((f \<circ> r) ---> l) sequentially" | |
| 2429 | using l r by fast | |
| 2430 | qed | |
| 2431 | ||
| 36437 | 2432 | subsubsection{* Completeness *}
 | 
| 33175 | 2433 | |
| 2434 | lemma cauchy_def: | |
| 2435 | "Cauchy s \<longleftrightarrow> (\<forall>e>0. \<exists>N. \<forall>m n. m \<ge> N \<and> n \<ge> N --> dist(s m)(s n) < e)" | |
| 2436 | unfolding Cauchy_def by blast | |
| 2437 | ||
| 2438 | definition | |
| 2439 | complete :: "'a::metric_space set \<Rightarrow> bool" where | |
| 2440 | "complete s \<longleftrightarrow> (\<forall>f. (\<forall>n. f n \<in> s) \<and> Cauchy f | |
| 2441 | --> (\<exists>l \<in> s. (f ---> l) sequentially))" | |
| 2442 | ||
| 2443 | lemma cauchy: "Cauchy s \<longleftrightarrow> (\<forall>e>0.\<exists> N::nat. \<forall>n\<ge>N. dist(s n)(s N) < e)" (is "?lhs = ?rhs") | |
| 2444 | proof- | |
| 2445 |   { assume ?rhs
 | |
| 2446 |     { fix e::real
 | |
| 2447 | assume "e>0" | |
| 2448 | with `?rhs` obtain N where N:"\<forall>n\<ge>N. dist (s n) (s N) < e/2" | |
| 2449 | by (erule_tac x="e/2" in allE) auto | |
| 2450 |       { fix n m
 | |
| 2451 | assume nm:"N \<le> m \<and> N \<le> n" | |
| 2452 | hence "dist (s m) (s n) < e" using N | |
| 2453 | using dist_triangle_half_l[of "s m" "s N" "e" "s n"] | |
| 2454 | by blast | |
| 2455 | } | |
| 2456 | hence "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (s m) (s n) < e" | |
| 2457 | by blast | |
| 2458 | } | |
| 2459 | hence ?lhs | |
| 2460 | unfolding cauchy_def | |
| 2461 | by blast | |
| 2462 | } | |
| 2463 | thus ?thesis | |
| 2464 | unfolding cauchy_def | |
| 2465 | using dist_triangle_half_l | |
| 2466 | by blast | |
| 2467 | qed | |
| 2468 | ||
| 2469 | lemma convergent_imp_cauchy: | |
| 2470 | "(s ---> l) sequentially ==> Cauchy s" | |
| 2471 | proof(simp only: cauchy_def, rule, rule) | |
| 2472 | fix e::real assume "e>0" "(s ---> l) sequentially" | |
| 2473 | 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 | |
| 2474 | 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 | |
| 2475 | qed | |
| 2476 | ||
| 34104 | 2477 | lemma cauchy_imp_bounded: assumes "Cauchy s" shows "bounded (range s)" | 
| 33175 | 2478 | proof- | 
| 2479 | 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 | |
| 2480 | hence N:"\<forall>n. N \<le> n \<longrightarrow> dist (s N) (s n) < 1" by auto | |
| 2481 | moreover | |
| 2482 |   have "bounded (s ` {0..N})" using finite_imp_bounded[of "s ` {1..N}"] by auto
 | |
| 2483 |   then obtain a where a:"\<forall>x\<in>s ` {0..N}. dist (s N) x \<le> a"
 | |
| 2484 | unfolding bounded_any_center [where a="s N"] by auto | |
| 2485 | ultimately show "?thesis" | |
| 2486 | unfolding bounded_any_center [where a="s N"] | |
| 2487 | apply(rule_tac x="max a 1" in exI) apply auto | |
| 34104 | 2488 | apply(erule_tac x=y in allE) apply(erule_tac x=y in ballE) by auto | 
| 33175 | 2489 | qed | 
| 2490 | ||
| 2491 | lemma compact_imp_complete: assumes "compact s" shows "complete s" | |
| 2492 | proof- | |
| 2493 |   { fix f assume as: "(\<forall>n::nat. f n \<in> s)" "Cauchy f"
 | |
| 2494 | 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 | |
| 2495 | ||
| 2496 | note lr' = subseq_bigger [OF lr(2)] | |
| 2497 | ||
| 2498 |     { fix e::real assume "e>0"
 | |
| 2499 | 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 | |
| 2500 | 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 | |
| 2501 |       { fix n::nat assume n:"n \<ge> max N M"
 | |
| 2502 | have "dist ((f \<circ> r) n) l < e/2" using n M by auto | |
| 2503 | moreover have "r n \<ge> N" using lr'[of n] n by auto | |
| 2504 | hence "dist (f n) ((f \<circ> r) n) < e / 2" using N using n by auto | |
| 2505 | 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) } | |
| 2506 | hence "\<exists>N. \<forall>n\<ge>N. dist (f n) l < e" by blast } | |
| 2507 | hence "\<exists>l\<in>s. (f ---> l) sequentially" using `l\<in>s` unfolding Lim_sequentially by auto } | |
| 2508 | thus ?thesis unfolding complete_def by auto | |
| 2509 | qed | |
| 2510 | ||
| 2511 | instance heine_borel < complete_space | |
| 2512 | proof | |
| 2513 | fix f :: "nat \<Rightarrow> 'a" assume "Cauchy f" | |
| 34104 | 2514 | hence "bounded (range f)" | 
| 2515 | by (rule cauchy_imp_bounded) | |
| 33175 | 2516 | hence "compact (closure (range f))" | 
| 2517 | using bounded_closed_imp_compact [of "closure (range f)"] by auto | |
| 2518 | hence "complete (closure (range f))" | |
| 34104 | 2519 | by (rule compact_imp_complete) | 
| 33175 | 2520 | moreover have "\<forall>n. f n \<in> closure (range f)" | 
| 2521 | using closure_subset [of "range f"] by auto | |
| 2522 | ultimately have "\<exists>l\<in>closure (range f). (f ---> l) sequentially" | |
| 2523 | using `Cauchy f` unfolding complete_def by auto | |
| 2524 | then show "convergent f" | |
| 36660 
1cc4ab4b7ff7
make (X ----> L) an abbreviation for (X ---> L) sequentially
 huffman parents: 
36659diff
changeset | 2525 | unfolding convergent_def by auto | 
| 33175 | 2526 | qed | 
| 2527 | ||
| 2528 | lemma complete_univ: "complete (UNIV :: 'a::complete_space set)" | |
| 2529 | proof(simp add: complete_def, rule, rule) | |
| 2530 | fix f :: "nat \<Rightarrow> 'a" assume "Cauchy f" | |
| 2531 | hence "convergent f" by (rule Cauchy_convergent) | |
| 36660 
1cc4ab4b7ff7
make (X ----> L) an abbreviation for (X ---> L) sequentially
 huffman parents: 
36659diff
changeset | 2532 | thus "\<exists>l. f ----> l" unfolding convergent_def . | 
| 33175 | 2533 | qed | 
| 2534 | ||
| 2535 | lemma complete_imp_closed: assumes "complete s" shows "closed s" | |
| 2536 | proof - | |
| 2537 |   { fix x assume "x islimpt s"
 | |
| 2538 |     then obtain f where f: "\<forall>n. f n \<in> s - {x}" "(f ---> x) sequentially"
 | |
| 2539 | unfolding islimpt_sequential by auto | |
| 2540 | then obtain l where l: "l\<in>s" "(f ---> l) sequentially" | |
| 2541 | using `complete s`[unfolded complete_def] using convergent_imp_cauchy[of f x] by auto | |
| 2542 | hence "x \<in> s" using Lim_unique[of sequentially f l x] trivial_limit_sequentially f(2) by auto | |
| 2543 | } | |
| 2544 | thus "closed s" unfolding closed_limpt by auto | |
| 2545 | qed | |
| 2546 | ||
| 2547 | lemma complete_eq_closed: | |
| 2548 | fixes s :: "'a::complete_space set" | |
| 2549 | shows "complete s \<longleftrightarrow> closed s" (is "?lhs = ?rhs") | |
| 2550 | proof | |
| 2551 | assume ?lhs thus ?rhs by (rule complete_imp_closed) | |
| 2552 | next | |
| 2553 | assume ?rhs | |
| 2554 |   { fix f assume as:"\<forall>n::nat. f n \<in> s" "Cauchy f"
 | |
| 2555 | then obtain l where "(f ---> l) sequentially" using complete_univ[unfolded complete_def, THEN spec[where x=f]] by auto | |
| 2556 | 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 } | |
| 2557 | thus ?lhs unfolding complete_def by auto | |
| 2558 | qed | |
| 2559 | ||
| 2560 | lemma convergent_eq_cauchy: | |
| 2561 | fixes s :: "nat \<Rightarrow> 'a::complete_space" | |
| 2562 | shows "(\<exists>l. (s ---> l) sequentially) \<longleftrightarrow> Cauchy s" (is "?lhs = ?rhs") | |
| 2563 | proof | |
| 2564 | assume ?lhs then obtain l where "(s ---> l) sequentially" by auto | |
| 2565 | thus ?rhs using convergent_imp_cauchy by auto | |
| 2566 | next | |
| 2567 | assume ?rhs thus ?lhs using complete_univ[unfolded complete_def, THEN spec[where x=s]] by auto | |
| 2568 | qed | |
| 2569 | ||
| 2570 | lemma convergent_imp_bounded: | |
| 2571 | fixes s :: "nat \<Rightarrow> 'a::metric_space" | |
| 2572 | shows "(s ---> l) sequentially ==> bounded (s ` (UNIV::(nat set)))" | |
| 2573 | using convergent_imp_cauchy[of s] | |
| 2574 | using cauchy_imp_bounded[of s] | |
| 2575 | unfolding image_def | |
| 2576 | by auto | |
| 2577 | ||
| 36437 | 2578 | subsubsection{* Total boundedness *}
 | 
| 33175 | 2579 | |
| 2580 | fun helper_1::"('a::metric_space set) \<Rightarrow> real \<Rightarrow> nat \<Rightarrow> 'a" where
 | |
| 2581 | "helper_1 s e n = (SOME y::'a. y \<in> s \<and> (\<forall>m<n. \<not> (dist (helper_1 s e m) y < e)))" | |
| 2582 | declare helper_1.simps[simp del] | |
| 2583 | ||
| 2584 | lemma compact_imp_totally_bounded: | |
| 2585 | assumes "compact s" | |
| 2586 | shows "\<forall>e>0. \<exists>k. finite k \<and> k \<subseteq> s \<and> s \<subseteq> (\<Union>((\<lambda>x. ball x e) ` k))" | |
| 2587 | proof(rule, rule, rule ccontr) | |
| 2588 | 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)" | |
| 2589 | def x \<equiv> "helper_1 s e" | |
| 2590 |   { fix n
 | |
| 2591 | have "x n \<in> s \<and> (\<forall>m<n. \<not> dist (x m) (x n) < e)" | |
| 2592 | proof(induct_tac rule:nat_less_induct) | |
| 2593 | fix n def Q \<equiv> "(\<lambda>y. y \<in> s \<and> (\<forall>m<n. \<not> dist (x m) y < e))" | |
| 2594 | assume as:"\<forall>m<n. x m \<in> s \<and> (\<forall>ma<m. \<not> dist (x ma) (x m) < e)" | |
| 2595 |       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
 | |
| 2596 |       then obtain z where z:"z\<in>s" "z \<notin> (\<Union>x\<in>x ` {0..<n}. ball x e)" unfolding subset_eq by auto
 | |
| 2597 | have "Q (x n)" unfolding x_def and helper_1.simps[of s e n] | |
| 2598 | apply(rule someI2[where a=z]) unfolding x_def[symmetric] and Q_def using z by auto | |
| 2599 | thus "x n \<in> s \<and> (\<forall>m<n. \<not> dist (x m) (x n) < e)" unfolding Q_def by auto | |
| 2600 | qed } | |
| 2601 | hence "\<forall>n::nat. x n \<in> s" and x:"\<forall>n. \<forall>m < n. \<not> (dist (x m) (x n) < e)" by blast+ | |
| 2602 | 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 | |
| 2603 | from this(3) have "Cauchy (x \<circ> r)" using convergent_imp_cauchy by auto | |
| 2604 | 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 | |
| 2605 | show False | |
| 2606 | using N[THEN spec[where x=N], THEN spec[where x="N+1"]] | |
| 2607 | using r[unfolded subseq_def, THEN spec[where x=N], THEN spec[where x="N+1"]] | |
| 2608 | using x[THEN spec[where x="r (N+1)"], THEN spec[where x="r (N)"]] by auto | |
| 2609 | qed | |
| 2610 | ||
| 36437 | 2611 | subsubsection{* Heine-Borel theorem *}
 | 
| 2612 | ||
| 2613 | text {* Following Burkill \& Burkill vol. 2. *}
 | |
| 33175 | 2614 | |
| 2615 | lemma heine_borel_lemma: fixes s::"'a::metric_space set" | |
| 2616 | assumes "compact s" "s \<subseteq> (\<Union> t)" "\<forall>b \<in> t. open b" | |
| 2617 | shows "\<exists>e>0. \<forall>x \<in> s. \<exists>b \<in> t. ball x e \<subseteq> b" | |
| 2618 | proof(rule ccontr) | |
| 2619 | assume "\<not> (\<exists>e>0. \<forall>x\<in>s. \<exists>b\<in>t. ball x e \<subseteq> b)" | |
| 2620 | hence cont:"\<forall>e>0. \<exists>x\<in>s. \<forall>xa\<in>t. \<not> (ball x e \<subseteq> xa)" by auto | |
| 2621 |   { fix n::nat
 | |
| 2622 | have "1 / real (n + 1) > 0" by auto | |
| 2623 | 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 } | |
| 2624 | 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 | |
| 2625 | 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)" | |
| 2626 | 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 | |
| 2627 | ||
| 2628 | then obtain l r where l:"l\<in>s" and r:"subseq r" and lr:"((f \<circ> r) ---> l) sequentially" | |
| 2629 | using assms(1)[unfolded compact_def, THEN spec[where x=f]] by auto | |
| 2630 | ||
| 2631 | obtain b where "l\<in>b" "b\<in>t" using assms(2) and l by auto | |
| 2632 | then obtain e where "e>0" and e:"\<forall>z. dist z l < e \<longrightarrow> z\<in>b" | |
| 2633 | using assms(3)[THEN bspec[where x=b]] unfolding open_dist by auto | |
| 2634 | ||
| 2635 | then obtain N1 where N1:"\<forall>n\<ge>N1. dist ((f \<circ> r) n) l < e / 2" | |
| 2636 | using lr[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto | |
| 2637 | ||
| 2638 | obtain N2::nat where N2:"N2>0" "inverse (real N2) < e /2" using real_arch_inv[of "e/2"] and `e>0` by auto | |
| 2639 | have N2':"inverse (real (r (N1 + N2) +1 )) < e/2" | |
| 2640 | apply(rule order_less_trans) apply(rule less_imp_inverse_less) using N2 | |
| 2641 | using subseq_bigger[OF r, of "N1 + N2"] by auto | |
| 2642 | ||
| 2643 | def x \<equiv> "(f (r (N1 + N2)))" | |
| 2644 | have x:"\<not> ball x (inverse (real (r (N1 + N2) + 1))) \<subseteq> b" unfolding x_def | |
| 2645 | using f[THEN spec[where x="r (N1 + N2)"]] using `b\<in>t` by auto | |
| 2646 | have "\<exists>y\<in>ball x (inverse (real (r (N1 + N2) + 1))). y\<notin>b" apply(rule ccontr) using x by auto | |
| 2647 | then obtain y where y:"y \<in> ball x (inverse (real (r (N1 + N2) + 1)))" "y \<notin> b" by auto | |
| 2648 | ||
| 2649 | have "dist x l < e/2" using N1 unfolding x_def o_def by auto | |
| 2650 | hence "dist y l < e" using y N2' using dist_triangle[of y l x]by (auto simp add:dist_commute) | |
| 2651 | ||
| 2652 | thus False using e and `y\<notin>b` by auto | |
| 2653 | qed | |
| 2654 | ||
| 2655 | lemma compact_imp_heine_borel: "compact s ==> (\<forall>f. (\<forall>t \<in> f. open t) \<and> s \<subseteq> (\<Union> f) | |
| 2656 | \<longrightarrow> (\<exists>f'. f' \<subseteq> f \<and> finite f' \<and> s \<subseteq> (\<Union> f')))" | |
| 2657 | proof clarify | |
| 2658 | fix f assume "compact s" " \<forall>t\<in>f. open t" "s \<subseteq> \<Union>f" | |
| 2659 | 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 | |
| 2660 | hence "\<forall>x\<in>s. \<exists>b. b\<in>f \<and> ball x e \<subseteq> b" by auto | |
| 2661 | 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 | |
| 2662 | then obtain bb where bb:"\<forall>x\<in>s. (bb x) \<in> f \<and> ball x e \<subseteq> (bb x)" by blast | |
| 2663 | ||
| 2664 | 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 | |
| 2665 | then obtain k where k:"finite k" "k \<subseteq> s" "s \<subseteq> \<Union>(\<lambda>x. ball x e) ` k" by auto | |
| 2666 | ||
| 2667 | have "finite (bb ` k)" using k(1) by auto | |
| 2668 | moreover | |
| 2669 |   { fix x assume "x\<in>s"
 | |
| 2670 | hence "x\<in>\<Union>(\<lambda>x. ball x e) ` k" using k(3) unfolding subset_eq by auto | |
| 2671 | hence "\<exists>X\<in>bb ` k. x \<in> X" using bb k(2) by blast | |
| 2672 | hence "x \<in> \<Union>(bb ` k)" using Union_iff[of x "bb ` k"] by auto | |
| 2673 | } | |
| 2674 | 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 | |
| 2675 | qed | |
| 2676 | ||
| 36437 | 2677 | subsubsection {* Bolzano-Weierstrass property *}
 | 
| 33175 | 2678 | |
| 2679 | lemma heine_borel_imp_bolzano_weierstrass: | |
| 2680 | 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'))" | |
| 2681 | "infinite t" "t \<subseteq> s" | |
| 2682 | shows "\<exists>x \<in> s. x islimpt t" | |
| 2683 | proof(rule ccontr) | |
| 2684 | assume "\<not> (\<exists>x \<in> s. x islimpt t)" | |
| 2685 | 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 | |
| 2686 | 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 | |
| 2687 |   obtain g where g:"g\<subseteq>{t. \<exists>x. x \<in> s \<and> t = f x}" "finite g" "s \<subseteq> \<Union>g"
 | |
| 2688 |     using assms(1)[THEN spec[where x="{t. \<exists>x. x\<in>s \<and> t = f x}"]] using f by auto
 | |
| 2689 | from g(1,3) have g':"\<forall>x\<in>g. \<exists>xa \<in> s. x = f xa" by auto | |
| 2690 |   { fix x y assume "x\<in>t" "y\<in>t" "f x = f y"
 | |
| 2691 | 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 | |
| 2692 | 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 } | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 2693 | hence "inj_on f t" unfolding inj_on_def by simp | 
| 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 2694 | hence "infinite (f ` t)" using assms(2) using finite_imageD by auto | 
| 33175 | 2695 | moreover | 
| 2696 |   { fix x assume "x\<in>t" "f x \<notin> g"
 | |
| 2697 | from g(3) assms(3) `x\<in>t` obtain h where "h\<in>g" and "x\<in>h" by auto | |
| 2698 | then obtain y where "y\<in>s" "h = f y" using g'[THEN bspec[where x=h]] by auto | |
| 2699 | hence "y = x" using f[THEN bspec[where x=y]] and `x\<in>t` and `x\<in>h`[unfolded `h = f y`] by auto | |
| 2700 | hence False using `f x \<notin> g` `h\<in>g` unfolding `h = f y` by auto } | |
| 2701 | hence "f ` t \<subseteq> g" by auto | |
| 2702 | ultimately show False using g(2) using finite_subset by auto | |
| 2703 | qed | |
| 2704 | ||
| 36437 | 2705 | subsubsection {* Complete the chain of compactness variants *}
 | 
| 33175 | 2706 | |
| 2707 | primrec helper_2::"(real \<Rightarrow> 'a::metric_space) \<Rightarrow> nat \<Rightarrow> 'a" where | |
| 2708 | "helper_2 beyond 0 = beyond 0" | | |
| 2709 | "helper_2 beyond (Suc n) = beyond (dist undefined (helper_2 beyond n) + 1 )" | |
| 2710 | ||
| 2711 | lemma bolzano_weierstrass_imp_bounded: fixes s::"'a::metric_space set" | |
| 2712 | assumes "\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t)" | |
| 2713 | shows "bounded s" | |
| 2714 | proof(rule ccontr) | |
| 2715 | assume "\<not> bounded s" | |
| 2716 | then obtain beyond where "\<forall>a. beyond a \<in>s \<and> \<not> dist undefined (beyond a) \<le> a" | |
| 2717 | unfolding bounded_any_center [where a=undefined] | |
| 2718 | apply simp using choice[of "\<lambda>a x. x\<in>s \<and> \<not> dist undefined x \<le> a"] by auto | |
| 2719 | hence beyond:"\<And>a. beyond a \<in>s" "\<And>a. dist undefined (beyond a) > a" | |
| 2720 | unfolding linorder_not_le by auto | |
| 2721 | def x \<equiv> "helper_2 beyond" | |
| 2722 | ||
| 2723 |   { fix m n ::nat assume "m<n"
 | |
| 2724 | hence "dist undefined (x m) + 1 < dist undefined (x n)" | |
| 2725 | proof(induct n) | |
| 2726 | case 0 thus ?case by auto | |
| 2727 | next | |
| 2728 | case (Suc n) | |
| 2729 | have *:"dist undefined (x n) + 1 < dist undefined (x (Suc n))" | |
| 2730 | unfolding x_def and helper_2.simps | |
| 2731 | using beyond(2)[of "dist undefined (helper_2 beyond n) + 1"] by auto | |
| 2732 | thus ?case proof(cases "m < n") | |
| 2733 | case True thus ?thesis using Suc and * by auto | |
| 2734 | next | |
| 2735 | case False hence "m = n" using Suc(2) by auto | |
| 2736 | thus ?thesis using * by auto | |
| 2737 | qed | |
| 2738 | qed } note * = this | |
| 2739 |   { fix m n ::nat assume "m\<noteq>n"
 | |
| 2740 | have "1 < dist (x m) (x n)" | |
| 2741 | proof(cases "m<n") | |
| 2742 | case True | |
| 2743 | hence "1 < dist undefined (x n) - dist undefined (x m)" using *[of m n] by auto | |
| 2744 | thus ?thesis using dist_triangle [of undefined "x n" "x m"] by arith | |
| 2745 | next | |
| 2746 | case False hence "n<m" using `m\<noteq>n` by auto | |
| 2747 | hence "1 < dist undefined (x m) - dist undefined (x n)" using *[of n m] by auto | |
| 2748 | thus ?thesis using dist_triangle2 [of undefined "x m" "x n"] by arith | |
| 2749 | qed } note ** = this | |
| 2750 |   { fix a b assume "x a = x b" "a \<noteq> b"
 | |
| 2751 | hence False using **[of a b] by auto } | |
| 2752 | hence "inj x" unfolding inj_on_def by auto | |
| 2753 | moreover | |
| 2754 |   { fix n::nat
 | |
| 2755 | have "x n \<in> s" | |
| 2756 | proof(cases "n = 0") | |
| 2757 | case True thus ?thesis unfolding x_def using beyond by auto | |
| 2758 | next | |
| 2759 | case False then obtain z where "n = Suc z" using not0_implies_Suc by auto | |
| 2760 | thus ?thesis unfolding x_def using beyond by auto | |
| 2761 | qed } | |
| 2762 | 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 | |
| 2763 | ||
| 2764 | then obtain l where "l\<in>s" and l:"l islimpt range x" using assms[THEN spec[where x="range x"]] by auto | |
| 2765 | 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 | |
| 2766 | 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"]] | |
| 2767 | unfolding dist_nz by auto | |
| 2768 | show False using y and z and dist_triangle_half_l[of "x y" l 1 "x z"] and **[of y z] by auto | |
| 2769 | qed | |
| 2770 | ||
| 2771 | lemma sequence_infinite_lemma: | |
| 2772 | fixes l :: "'a::metric_space" (* TODO: generalize *) | |
| 2773 | assumes "\<forall>n::nat. (f n \<noteq> l)" "(f ---> l) sequentially" | |
| 34104 | 2774 | shows "infinite (range f)" | 
| 2775 | proof | |
| 2776 | let ?A = "(\<lambda>x. dist x l) ` range f" | |
| 2777 | assume "finite (range f)" | |
| 33175 | 2778 |   hence **:"finite ?A" "?A \<noteq> {}" by auto
 | 
| 2779 | obtain k where k:"dist (f k) l = Min ?A" using Min_in[OF **] by auto | |
| 2780 | have "0 < Min ?A" using assms(1) unfolding dist_nz unfolding Min_gr_iff[OF **] by auto | |
| 2781 | then obtain N where "dist (f N) l < Min ?A" using assms(2)[unfolded Lim_sequentially, THEN spec[where x="Min ?A"]] by auto | |
| 2782 | moreover have "dist (f N) l \<in> ?A" by auto | |
| 2783 | ultimately show False using Min_le[OF **(1), of "dist (f N) l"] by auto | |
| 2784 | qed | |
| 2785 | ||
| 2786 | lemma sequence_unique_limpt: | |
| 2787 | fixes l :: "'a::metric_space" (* TODO: generalize *) | |
| 34104 | 2788 | assumes "\<forall>n::nat. (f n \<noteq> l)" "(f ---> l) sequentially" "l' islimpt (range f)" | 
| 33175 | 2789 | shows "l' = l" | 
| 2790 | proof(rule ccontr) | |
| 2791 | def e \<equiv> "dist l' l" | |
| 2792 | assume "l' \<noteq> l" hence "e>0" unfolding dist_nz e_def by auto | |
| 2793 | then obtain N::nat where N:"\<forall>n\<ge>N. dist (f n) l < e / 2" | |
| 2794 | using assms(2)[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto | |
| 2795 |   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}))"
 | |
| 2796 | have "d>0" using `e>0` unfolding d_def e_def using zero_le_dist[of _ l', unfolded order_le_less] by auto | |
| 2797 | 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 | |
| 2798 | have "k\<ge>N" using k(1)[unfolded dist_nz] using k(2)[unfolded d_def] | |
| 35820 
b57c3afd1484
dropped odd interpretation of comm_monoid_mult into comm_monoid_add; consider Min.insert_idem as default simp rule
 haftmann parents: 
35172diff
changeset | 2799 | by (force simp del: Min.insert_idem) | 
| 
b57c3afd1484
dropped odd interpretation of comm_monoid_mult into comm_monoid_add; consider Min.insert_idem as default simp rule
 haftmann parents: 
35172diff
changeset | 2800 | 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 simp del: Min.insert_idem) | 
| 33175 | 2801 | thus False unfolding e_def by auto | 
| 2802 | qed | |
| 2803 | ||
| 2804 | lemma bolzano_weierstrass_imp_closed: | |
| 2805 | fixes s :: "'a::metric_space set" (* TODO: can this be generalized? *) | |
| 2806 | assumes "\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t)" | |
| 2807 | shows "closed s" | |
| 2808 | proof- | |
| 2809 |   { fix x l assume as: "\<forall>n::nat. x n \<in> s" "(x ---> l) sequentially"
 | |
| 2810 | hence "l \<in> s" | |
| 2811 | proof(cases "\<forall>n. x n \<noteq> l") | |
| 2812 | case False thus "l\<in>s" using as(1) by auto | |
| 2813 | next | |
| 2814 | case True note cas = this | |
| 34104 | 2815 | with as(2) have "infinite (range x)" using sequence_infinite_lemma[of x l] by auto | 
| 2816 | then obtain l' where "l'\<in>s" "l' islimpt (range x)" using assms[THEN spec[where x="range x"]] as(1) by auto | |
| 33175 | 2817 | thus "l\<in>s" using sequence_unique_limpt[of x l l'] using as cas by auto | 
| 2818 | qed } | |
| 2819 | thus ?thesis unfolding closed_sequential_limits by fast | |
| 2820 | qed | |
| 2821 | ||
| 2822 | text{* Hence express everything as an equivalence.   *}
 | |
| 2823 | ||
| 2824 | lemma compact_eq_heine_borel: | |
| 2825 | fixes s :: "'a::heine_borel set" | |
| 2826 | shows "compact s \<longleftrightarrow> | |
| 2827 | (\<forall>f. (\<forall>t \<in> f. open t) \<and> s \<subseteq> (\<Union> f) | |
| 2828 | --> (\<exists>f'. f' \<subseteq> f \<and> finite f' \<and> s \<subseteq> (\<Union> f')))" (is "?lhs = ?rhs") | |
| 2829 | proof | |
| 2830 | assume ?lhs thus ?rhs using compact_imp_heine_borel[of s] by blast | |
| 2831 | next | |
| 2832 | assume ?rhs | |
| 2833 | hence "\<forall>t. infinite t \<and> t \<subseteq> s \<longrightarrow> (\<exists>x\<in>s. x islimpt t)" | |
| 2834 | by (blast intro: heine_borel_imp_bolzano_weierstrass[of s]) | |
| 2835 | thus ?lhs using bolzano_weierstrass_imp_bounded[of s] bolzano_weierstrass_imp_closed[of s] bounded_closed_imp_compact[of s] by blast | |
| 2836 | qed | |
| 2837 | ||
| 2838 | lemma compact_eq_bolzano_weierstrass: | |
| 2839 | fixes s :: "'a::heine_borel set" | |
| 2840 | shows "compact s \<longleftrightarrow> (\<forall>t. infinite t \<and> t \<subseteq> s --> (\<exists>x \<in> s. x islimpt t))" (is "?lhs = ?rhs") | |
| 2841 | proof | |
| 2842 | assume ?lhs thus ?rhs unfolding compact_eq_heine_borel using heine_borel_imp_bolzano_weierstrass[of s] by auto | |
| 2843 | next | |
| 2844 | assume ?rhs thus ?lhs using bolzano_weierstrass_imp_bounded bolzano_weierstrass_imp_closed bounded_closed_imp_compact by auto | |
| 2845 | qed | |
| 2846 | ||
| 2847 | lemma compact_eq_bounded_closed: | |
| 2848 | fixes s :: "'a::heine_borel set" | |
| 2849 | shows "compact s \<longleftrightarrow> bounded s \<and> closed s" (is "?lhs = ?rhs") | |
| 2850 | proof | |
| 2851 | assume ?lhs thus ?rhs unfolding compact_eq_bolzano_weierstrass using bolzano_weierstrass_imp_bounded bolzano_weierstrass_imp_closed by auto | |
| 2852 | next | |
| 2853 | assume ?rhs thus ?lhs using bounded_closed_imp_compact by auto | |
| 2854 | qed | |
| 2855 | ||
| 2856 | lemma compact_imp_bounded: | |
| 2857 | fixes s :: "'a::metric_space set" | |
| 2858 | shows "compact s ==> bounded s" | |
| 2859 | proof - | |
| 2860 | assume "compact s" | |
| 2861 | 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')" | |
| 2862 | by (rule compact_imp_heine_borel) | |
| 2863 | hence "\<forall>t. infinite t \<and> t \<subseteq> s \<longrightarrow> (\<exists>x \<in> s. x islimpt t)" | |
| 2864 | using heine_borel_imp_bolzano_weierstrass[of s] by auto | |
| 2865 | thus "bounded s" | |
| 2866 | by (rule bolzano_weierstrass_imp_bounded) | |
| 2867 | qed | |
| 2868 | ||
| 2869 | lemma compact_imp_closed: | |
| 2870 | fixes s :: "'a::metric_space set" | |
| 2871 | shows "compact s ==> closed s" | |
| 2872 | proof - | |
| 2873 | assume "compact s" | |
| 2874 | 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')" | |
| 2875 | by (rule compact_imp_heine_borel) | |
| 2876 | hence "\<forall>t. infinite t \<and> t \<subseteq> s \<longrightarrow> (\<exists>x \<in> s. x islimpt t)" | |
| 2877 | using heine_borel_imp_bolzano_weierstrass[of s] by auto | |
| 2878 | thus "closed s" | |
| 2879 | by (rule bolzano_weierstrass_imp_closed) | |
| 2880 | qed | |
| 2881 | ||
| 2882 | text{* In particular, some common special cases. *}
 | |
| 2883 | ||
| 2884 | lemma compact_empty[simp]: | |
| 2885 |  "compact {}"
 | |
| 2886 | unfolding compact_def | |
| 2887 | by simp | |
| 2888 | ||
| 2889 | (* TODO: can any of the next 3 lemmas be generalized to metric spaces? *) | |
| 2890 | ||
| 2891 | (* FIXME : Rename *) | |
| 2892 | lemma compact_union[intro]: | |
| 2893 | fixes s t :: "'a::heine_borel set" | |
| 2894 | shows "compact s \<Longrightarrow> compact t ==> compact (s \<union> t)" | |
| 2895 | unfolding compact_eq_bounded_closed | |
| 2896 | using bounded_Un[of s t] | |
| 2897 | using closed_Un[of s t] | |
| 2898 | by simp | |
| 2899 | ||
| 2900 | lemma compact_inter[intro]: | |
| 2901 | fixes s t :: "'a::heine_borel set" | |
| 2902 | shows "compact s \<Longrightarrow> compact t ==> compact (s \<inter> t)" | |
| 2903 | unfolding compact_eq_bounded_closed | |
| 2904 | using bounded_Int[of s t] | |
| 2905 | using closed_Int[of s t] | |
| 2906 | by simp | |
| 2907 | ||
| 2908 | lemma compact_inter_closed[intro]: | |
| 2909 | fixes s t :: "'a::heine_borel set" | |
| 2910 | shows "compact s \<Longrightarrow> closed t ==> compact (s \<inter> t)" | |
| 2911 | unfolding compact_eq_bounded_closed | |
| 2912 | using closed_Int[of s t] | |
| 2913 | using bounded_subset[of "s \<inter> t" s] | |
| 2914 | by blast | |
| 2915 | ||
| 2916 | lemma closed_inter_compact[intro]: | |
| 2917 | fixes s t :: "'a::heine_borel set" | |
| 2918 | shows "closed s \<Longrightarrow> compact t ==> compact (s \<inter> t)" | |
| 2919 | proof- | |
| 2920 | assume "closed s" "compact t" | |
| 2921 | moreover | |
| 2922 | have "s \<inter> t = t \<inter> s" by auto ultimately | |
| 2923 | show ?thesis | |
| 2924 | using compact_inter_closed[of t s] | |
| 2925 | by auto | |
| 2926 | qed | |
| 2927 | ||
| 2928 | lemma finite_imp_compact: | |
| 2929 | fixes s :: "'a::heine_borel set" | |
| 2930 | shows "finite s ==> compact s" | |
| 2931 | unfolding compact_eq_bounded_closed | |
| 2932 | using finite_imp_closed finite_imp_bounded | |
| 2933 | by blast | |
| 2934 | ||
| 2935 | lemma compact_sing [simp]: "compact {a}"
 | |
| 2936 | unfolding compact_def o_def subseq_def | |
| 2937 | by (auto simp add: tendsto_const) | |
| 2938 | ||
| 2939 | lemma compact_cball[simp]: | |
| 2940 | fixes x :: "'a::heine_borel" | |
| 2941 | shows "compact(cball x e)" | |
| 2942 | using compact_eq_bounded_closed bounded_cball closed_cball | |
| 2943 | by blast | |
| 2944 | ||
| 2945 | lemma compact_frontier_bounded[intro]: | |
| 2946 | fixes s :: "'a::heine_borel set" | |
| 2947 | shows "bounded s ==> compact(frontier s)" | |
| 2948 | unfolding frontier_def | |
| 2949 | using compact_eq_bounded_closed | |
| 2950 | by blast | |
| 2951 | ||
| 2952 | lemma compact_frontier[intro]: | |
| 2953 | fixes s :: "'a::heine_borel set" | |
| 2954 | shows "compact s ==> compact (frontier s)" | |
| 2955 | using compact_eq_bounded_closed compact_frontier_bounded | |
| 2956 | by blast | |
| 2957 | ||
| 2958 | lemma frontier_subset_compact: | |
| 2959 | fixes s :: "'a::heine_borel set" | |
| 2960 | shows "compact s ==> frontier s \<subseteq> s" | |
| 2961 | using frontier_subset_closed compact_eq_bounded_closed | |
| 2962 | by blast | |
| 2963 | ||
| 2964 | lemma open_delete: | |
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 2965 | fixes s :: "'a::t1_space set" | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 2966 |   shows "open s \<Longrightarrow> open (s - {x})"
 | 
| 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 2967 | by (simp add: open_Diff) | 
| 33175 | 2968 | |
| 2969 | text{* Finite intersection property. I could make it an equivalence in fact. *}
 | |
| 2970 | ||
| 2971 | lemma compact_imp_fip: | |
| 2972 | fixes s :: "'a::heine_borel set" | |
| 2973 | assumes "compact s" "\<forall>t \<in> f. closed t" | |
| 2974 |         "\<forall>f'. finite f' \<and> f' \<subseteq> f --> (s \<inter> (\<Inter> f') \<noteq> {})"
 | |
| 2975 |   shows "s \<inter> (\<Inter> f) \<noteq> {}"
 | |
| 2976 | proof | |
| 2977 |   assume as:"s \<inter> (\<Inter> f) = {}"
 | |
| 34105 | 2978 | hence "s \<subseteq> \<Union> uminus ` f" by auto | 
| 2979 | moreover have "Ball (uminus ` f) open" using open_Diff closed_Diff using assms(2) by auto | |
| 2980 | 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 | |
| 2981 | hence "finite (uminus ` f') \<and> uminus ` f' \<subseteq> f" by(auto simp add: Diff_Diff_Int) | |
| 2982 |   hence "s \<inter> \<Inter>uminus ` f' \<noteq> {}" using assms(3)[THEN spec[where x="uminus ` f'"]] by auto
 | |
| 33175 | 2983 | thus False using f'(3) unfolding subset_eq and Union_iff by blast | 
| 2984 | qed | |
| 2985 | ||
| 2986 | subsection{* Bounded closed nest property (proof does not use Heine-Borel).            *}
 | |
| 2987 | ||
| 2988 | lemma bounded_closed_nest: | |
| 2989 |   assumes "\<forall>n. closed(s n)" "\<forall>n. (s n \<noteq> {})"
 | |
| 2990 | "(\<forall>m n. m \<le> n --> s n \<subseteq> s m)" "bounded(s 0)" | |
| 2991 | shows "\<exists>a::'a::heine_borel. \<forall>n::nat. a \<in> s(n)" | |
| 2992 | proof- | |
| 2993 | 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 | |
| 2994 | from assms(4,1) have *:"compact (s 0)" using bounded_closed_imp_compact[of "s 0"] by auto | |
| 2995 | ||
| 2996 | then obtain l r where lr:"l\<in>s 0" "subseq r" "((x \<circ> r) ---> l) sequentially" | |
| 2997 | unfolding compact_def apply(erule_tac x=x in allE) using x using assms(3) by blast | |
| 2998 | ||
| 2999 |   { fix n::nat
 | |
| 3000 |     { fix e::real assume "e>0"
 | |
| 3001 | with lr(3) obtain N where N:"\<forall>m\<ge>N. dist ((x \<circ> r) m) l < e" unfolding Lim_sequentially by auto | |
| 3002 | hence "dist ((x \<circ> r) (max N n)) l < e" by auto | |
| 3003 | moreover | |
| 3004 | have "r (max N n) \<ge> n" using lr(2) using subseq_bigger[of r "max N n"] by auto | |
| 3005 | hence "(x \<circ> r) (max N n) \<in> s n" | |
| 3006 | using x apply(erule_tac x=n in allE) | |
| 3007 | using x apply(erule_tac x="r (max N n)" in allE) | |
| 3008 | using assms(3) apply(erule_tac x=n in allE)apply( erule_tac x="r (max N n)" in allE) by auto | |
| 3009 | ultimately have "\<exists>y\<in>s n. dist y l < e" by auto | |
| 3010 | } | |
| 3011 | hence "l \<in> s n" using closed_approachable[of "s n" l] assms(1) by blast | |
| 3012 | } | |
| 3013 | thus ?thesis by auto | |
| 3014 | qed | |
| 3015 | ||
| 3016 | text{* Decreasing case does not even need compactness, just completeness.        *}
 | |
| 3017 | ||
| 3018 | lemma decreasing_closed_nest: | |
| 3019 | assumes "\<forall>n. closed(s n)" | |
| 3020 |           "\<forall>n. (s n \<noteq> {})"
 | |
| 3021 | "\<forall>m n. m \<le> n --> s n \<subseteq> s m" | |
| 3022 | "\<forall>e>0. \<exists>n. \<forall>x \<in> (s n). \<forall> y \<in> (s n). dist x y < e" | |
| 3023 | shows "\<exists>a::'a::heine_borel. \<forall>n::nat. a \<in> s n" | |
| 3024 | proof- | |
| 3025 | have "\<forall>n. \<exists> x. x\<in>s n" using assms(2) by auto | |
| 3026 | hence "\<exists>t. \<forall>n. t n \<in> s n" using choice[of "\<lambda> n x. x \<in> s n"] by auto | |
| 3027 | then obtain t where t: "\<forall>n. t n \<in> s n" by auto | |
| 3028 |   { fix e::real assume "e>0"
 | |
| 3029 | then obtain N where N:"\<forall>x\<in>s N. \<forall>y\<in>s N. dist x y < e" using assms(4) by auto | |
| 3030 |     { fix m n ::nat assume "N \<le> m \<and> N \<le> n"
 | |
| 3031 | hence "t m \<in> s N" "t n \<in> s N" using assms(3) t unfolding subset_eq t by blast+ | |
| 3032 | hence "dist (t m) (t n) < e" using N by auto | |
| 3033 | } | |
| 3034 | hence "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (t m) (t n) < e" by auto | |
| 3035 | } | |
| 3036 | hence "Cauchy t" unfolding cauchy_def by auto | |
| 3037 | then obtain l where l:"(t ---> l) sequentially" using complete_univ unfolding complete_def by auto | |
| 3038 |   { fix n::nat
 | |
| 3039 |     { fix e::real assume "e>0"
 | |
| 3040 | then obtain N::nat where N:"\<forall>n\<ge>N. dist (t n) l < e" using l[unfolded Lim_sequentially] by auto | |
| 3041 | 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 | |
| 3042 | hence "\<exists>y\<in>s n. dist y l < e" apply(rule_tac x="t (max n N)" in bexI) using N by auto | |
| 3043 | } | |
| 3044 | hence "l \<in> s n" using closed_approachable[of "s n" l] assms(1) by auto | |
| 3045 | } | |
| 3046 | then show ?thesis by auto | |
| 3047 | qed | |
| 3048 | ||
| 3049 | text{* Strengthen it to the intersection actually being a singleton.             *}
 | |
| 3050 | ||
| 3051 | lemma decreasing_closed_nest_sing: | |
| 34104 | 3052 | fixes s :: "nat \<Rightarrow> 'a::heine_borel set" | 
| 33175 | 3053 | assumes "\<forall>n. closed(s n)" | 
| 3054 |           "\<forall>n. s n \<noteq> {}"
 | |
| 3055 | "\<forall>m n. m \<le> n --> s n \<subseteq> s m" | |
| 3056 | "\<forall>e>0. \<exists>n. \<forall>x \<in> (s n). \<forall> y\<in>(s n). dist x y < e" | |
| 34104 | 3057 |   shows "\<exists>a. \<Inter>(range s) = {a}"
 | 
| 33175 | 3058 | proof- | 
| 3059 | obtain a where a:"\<forall>n. a \<in> s n" using decreasing_closed_nest[of s] using assms by auto | |
| 34104 | 3060 |   { fix b assume b:"b \<in> \<Inter>(range s)"
 | 
| 33175 | 3061 |     { fix e::real assume "e>0"
 | 
| 3062 | hence "dist a b < e" using assms(4 )using b using a by blast | |
| 3063 | } | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 3064 | hence "dist a b = 0" by (metis dist_eq_0_iff dist_nz less_le) | 
| 33175 | 3065 | } | 
| 34104 | 3066 |   with a have "\<Inter>(range s) = {a}" unfolding image_def by auto
 | 
| 3067 | thus ?thesis .. | |
| 33175 | 3068 | qed | 
| 3069 | ||
| 3070 | text{* Cauchy-type criteria for uniform convergence. *}
 | |
| 3071 | ||
| 3072 | lemma uniformly_convergent_eq_cauchy: fixes s::"nat \<Rightarrow> 'b \<Rightarrow> 'a::heine_borel" shows | |
| 3073 | "(\<exists>l. \<forall>e>0. \<exists>N. \<forall>n x. N \<le> n \<and> P x --> dist(s n x)(l x) < e) \<longleftrightarrow> | |
| 3074 | (\<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") | |
| 3075 | proof(rule) | |
| 3076 | assume ?lhs | |
| 3077 | 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 | |
| 3078 |   { fix e::real assume "e>0"
 | |
| 3079 | 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 | |
| 3080 |     { fix n m::nat and x::"'b" assume "N \<le> m \<and> N \<le> n \<and> P x"
 | |
| 3081 | hence "dist (s m x) (s n x) < e" | |
| 3082 | using N[THEN spec[where x=m], THEN spec[where x=x]] | |
| 3083 | using N[THEN spec[where x=n], THEN spec[where x=x]] | |
| 3084 | using dist_triangle_half_l[of "s m x" "l x" e "s n x"] by auto } | |
| 3085 | 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 } | |
| 3086 | thus ?rhs by auto | |
| 3087 | next | |
| 3088 | assume ?rhs | |
| 3089 | 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 | |
| 3090 | then obtain l where l:"\<forall>x. P x \<longrightarrow> ((\<lambda>n. s n x) ---> l x) sequentially" unfolding convergent_eq_cauchy[THEN sym] | |
| 3091 | using choice[of "\<lambda>x l. P x \<longrightarrow> ((\<lambda>n. s n x) ---> l) sequentially"] by auto | |
| 3092 |   { fix e::real assume "e>0"
 | |
| 3093 | 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" | |
| 3094 | using `?rhs`[THEN spec[where x="e/2"]] by auto | |
| 3095 |     { fix x assume "P x"
 | |
| 3096 | then obtain M where M:"\<forall>n\<ge>M. dist (s n x) (l x) < e/2" | |
| 3097 | using l[THEN spec[where x=x], unfolded Lim_sequentially] using `e>0` by(auto elim!: allE[where x="e/2"]) | |
| 3098 | fix n::nat assume "n\<ge>N" | |
| 3099 | 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]] | |
| 3100 | 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) } | |
| 3101 | hence "\<exists>N. \<forall>n x. N \<le> n \<and> P x \<longrightarrow> dist(s n x)(l x) < e" by auto } | |
| 3102 | thus ?lhs by auto | |
| 3103 | qed | |
| 3104 | ||
| 3105 | lemma uniformly_cauchy_imp_uniformly_convergent: | |
| 3106 | fixes s :: "nat \<Rightarrow> 'a \<Rightarrow> 'b::heine_borel" | |
| 3107 | 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" | |
| 3108 | "\<forall>x. P x --> (\<forall>e>0. \<exists>N. \<forall>n. N \<le> n --> dist(s n x)(l x) < e)" | |
| 3109 | shows "\<forall>e>0. \<exists>N. \<forall>n x. N \<le> n \<and> P x --> dist(s n x)(l x) < e" | |
| 3110 | proof- | |
| 3111 | 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" | |
| 3112 | using assms(1) unfolding uniformly_convergent_eq_cauchy[THEN sym] by auto | |
| 3113 | moreover | |
| 3114 |   { fix x assume "P x"
 | |
| 3115 | hence "l x = l' x" using Lim_unique[OF trivial_limit_sequentially, of "\<lambda>n. s n x" "l x" "l' x"] | |
| 3116 | using l and assms(2) unfolding Lim_sequentially by blast } | |
| 3117 | ultimately show ?thesis by auto | |
| 3118 | qed | |
| 3119 | ||
| 36437 | 3120 | subsection {* Continuity *}
 | 
| 3121 | ||
| 3122 | text {* Define continuity over a net to take in restrictions of the set. *}
 | |
| 33175 | 3123 | |
| 3124 | definition | |
| 3125 |   continuous :: "'a::t2_space net \<Rightarrow> ('a \<Rightarrow> 'b::topological_space) \<Rightarrow> bool" where
 | |
| 3126 | "continuous net f \<longleftrightarrow> (f ---> f(netlimit net)) net" | |
| 3127 | ||
| 3128 | lemma continuous_trivial_limit: | |
| 3129 | "trivial_limit net ==> continuous net f" | |
| 3130 | unfolding continuous_def tendsto_def trivial_limit_eq by auto | |
| 3131 | ||
| 3132 | lemma continuous_within: "continuous (at x within s) f \<longleftrightarrow> (f ---> f(x)) (at x within s)" | |
| 3133 | unfolding continuous_def | |
| 3134 | unfolding tendsto_def | |
| 3135 | using netlimit_within[of x s] | |
| 3136 | by (cases "trivial_limit (at x within s)") (auto simp add: trivial_limit_eventually) | |
| 3137 | ||
| 3138 | lemma continuous_at: "continuous (at x) f \<longleftrightarrow> (f ---> f(x)) (at x)" | |
| 3139 | using continuous_within [of x UNIV f] by (simp add: within_UNIV) | |
| 3140 | ||
| 3141 | lemma continuous_at_within: | |
| 3142 | assumes "continuous (at x) f" shows "continuous (at x within s) f" | |
| 3143 | using assms unfolding continuous_at continuous_within | |
| 3144 | by (rule Lim_at_within) | |
| 3145 | ||
| 3146 | text{* Derive the epsilon-delta forms, which we often use as "definitions" *}
 | |
| 3147 | ||
| 3148 | lemma continuous_within_eps_delta: | |
| 3149 | "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)" | |
| 3150 | unfolding continuous_within and Lim_within | |
| 3151 | apply auto unfolding dist_nz[THEN sym] apply(auto elim!:allE) apply(rule_tac x=d in exI) by auto | |
| 3152 | ||
| 3153 | lemma continuous_at_eps_delta: "continuous (at x) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. | |
| 3154 | \<forall>x'. dist x' x < d --> dist(f x')(f x) < e)" | |
| 3155 | using continuous_within_eps_delta[of x UNIV f] | |
| 3156 | unfolding within_UNIV by blast | |
| 3157 | ||
| 3158 | text{* Versions in terms of open balls. *}
 | |
| 3159 | ||
| 3160 | lemma continuous_within_ball: | |
| 3161 | "continuous (at x within s) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. | |
| 3162 | f ` (ball x d \<inter> s) \<subseteq> ball (f x) e)" (is "?lhs = ?rhs") | |
| 3163 | proof | |
| 3164 | assume ?lhs | |
| 3165 |   { fix e::real assume "e>0"
 | |
| 3166 | 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" | |
| 3167 | using `?lhs`[unfolded continuous_within Lim_within] by auto | |
| 3168 |     { fix y assume "y\<in>f ` (ball x d \<inter> s)"
 | |
| 3169 | hence "y \<in> ball (f x) e" using d(2) unfolding dist_nz[THEN sym] | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 3170 | apply (auto simp add: dist_commute) apply(erule_tac x=xa in ballE) apply auto using `e>0` by auto | 
| 33175 | 3171 | } | 
| 3172 | 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) } | |
| 3173 | thus ?rhs by auto | |
| 3174 | next | |
| 3175 | assume ?rhs thus ?lhs unfolding continuous_within Lim_within ball_def subset_eq | |
| 3176 | apply (auto simp add: dist_commute) apply(erule_tac x=e in allE) by auto | |
| 3177 | qed | |
| 3178 | ||
| 3179 | lemma continuous_at_ball: | |
| 3180 | "continuous (at x) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. f ` (ball x d) \<subseteq> ball (f x) e)" (is "?lhs = ?rhs") | |
| 3181 | proof | |
| 3182 | assume ?lhs thus ?rhs unfolding continuous_at Lim_at subset_eq Ball_def Bex_def image_iff mem_ball | |
| 3183 | 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) | |
| 3184 | unfolding dist_nz[THEN sym] by auto | |
| 3185 | next | |
| 3186 | assume ?rhs thus ?lhs unfolding continuous_at Lim_at subset_eq Ball_def Bex_def image_iff mem_ball | |
| 3187 | 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) | |
| 3188 | qed | |
| 3189 | ||
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3190 | text{* Define setwise continuity in terms of limits within the set. *}
 | 
| 33175 | 3191 | |
| 3192 | definition | |
| 36359 | 3193 | continuous_on :: | 
| 3194 |     "'a set \<Rightarrow> ('a::topological_space \<Rightarrow> 'b::topological_space) \<Rightarrow> bool"
 | |
| 3195 | where | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3196 | "continuous_on s f \<longleftrightarrow> (\<forall>x\<in>s. (f ---> f x) (at x within s))" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3197 | |
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3198 | lemma continuous_on_topological: | 
| 36359 | 3199 | "continuous_on s f \<longleftrightarrow> | 
| 3200 | (\<forall>x\<in>s. \<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3201 | (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3202 | unfolding continuous_on_def tendsto_def | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3203 | unfolding Limits.eventually_within eventually_at_topological | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3204 | by (intro ball_cong [OF refl] all_cong imp_cong ex_cong conj_cong refl) auto | 
| 36359 | 3205 | |
| 3206 | lemma continuous_on_iff: | |
| 3207 | "continuous_on s f \<longleftrightarrow> | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3208 | (\<forall>x\<in>s. \<forall>e>0. \<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e)" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3209 | unfolding continuous_on_def Lim_within | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3210 | apply (intro ball_cong [OF refl] all_cong ex_cong) | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3211 | apply (rename_tac y, case_tac "y = x", simp) | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3212 | apply (simp add: dist_nz) | 
| 36359 | 3213 | done | 
| 33175 | 3214 | |
| 3215 | definition | |
| 3216 | uniformly_continuous_on :: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3217 |     "'a set \<Rightarrow> ('a::metric_space \<Rightarrow> 'b::metric_space) \<Rightarrow> bool"
 | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3218 | where | 
| 33175 | 3219 | "uniformly_continuous_on s f \<longleftrightarrow> | 
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3220 | (\<forall>e>0. \<exists>d>0. \<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e)" | 
| 35172 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3221 | |
| 33175 | 3222 | text{* Some simple consequential lemmas. *}
 | 
| 3223 | ||
| 3224 | lemma uniformly_continuous_imp_continuous: | |
| 3225 | " uniformly_continuous_on s f ==> continuous_on s f" | |
| 36359 | 3226 | unfolding uniformly_continuous_on_def continuous_on_iff by blast | 
| 33175 | 3227 | |
| 3228 | lemma continuous_at_imp_continuous_within: | |
| 3229 | "continuous (at x) f ==> continuous (at x within s) f" | |
| 3230 | unfolding continuous_within continuous_at using Lim_at_within by auto | |
| 3231 | ||
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3232 | lemma Lim_trivial_limit: "trivial_limit net \<Longrightarrow> (f ---> l) net" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3233 | unfolding tendsto_def by (simp add: trivial_limit_eq) | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3234 | |
| 36359 | 3235 | lemma continuous_at_imp_continuous_on: | 
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3236 | assumes "\<forall>x\<in>s. continuous (at x) f" | 
| 33175 | 3237 | shows "continuous_on s f" | 
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3238 | unfolding continuous_on_def | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3239 | proof | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3240 | fix x assume "x \<in> s" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3241 | with assms have *: "(f ---> f (netlimit (at x))) (at x)" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3242 | unfolding continuous_def by simp | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3243 | have "(f ---> f x) (at x)" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3244 | proof (cases "trivial_limit (at x)") | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3245 | case True thus ?thesis | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3246 | by (rule Lim_trivial_limit) | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3247 | next | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3248 | case False | 
| 36667 | 3249 | hence 1: "netlimit (at x) = x" | 
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3250 | using netlimit_within [of x UNIV] | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3251 | by (simp add: within_UNIV) | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3252 | with * show ?thesis by simp | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3253 | qed | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3254 | thus "(f ---> f x) (at x within s)" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3255 | by (rule Lim_at_within) | 
| 33175 | 3256 | qed | 
| 3257 | ||
| 3258 | lemma continuous_on_eq_continuous_within: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3259 | "continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. continuous (at x within s) f)" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3260 | unfolding continuous_on_def continuous_def | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3261 | apply (rule ball_cong [OF refl]) | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3262 | apply (case_tac "trivial_limit (at x within s)") | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3263 | apply (simp add: Lim_trivial_limit) | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3264 | apply (simp add: netlimit_within) | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3265 | done | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3266 | |
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3267 | lemmas continuous_on = continuous_on_def -- "legacy theorem name" | 
| 33175 | 3268 | |
| 3269 | lemma continuous_on_eq_continuous_at: | |
| 36359 | 3270 | shows "open s ==> (continuous_on s f \<longleftrightarrow> (\<forall>x \<in> s. continuous (at x) f))" | 
| 33175 | 3271 | by (auto simp add: continuous_on continuous_at Lim_within_open) | 
| 3272 | ||
| 3273 | lemma continuous_within_subset: | |
| 3274 | "continuous (at x within s) f \<Longrightarrow> t \<subseteq> s | |
| 3275 | ==> continuous (at x within t) f" | |
| 3276 | unfolding continuous_within by(metis Lim_within_subset) | |
| 3277 | ||
| 3278 | lemma continuous_on_subset: | |
| 36359 | 3279 | shows "continuous_on s f \<Longrightarrow> t \<subseteq> s ==> continuous_on t f" | 
| 33175 | 3280 | unfolding continuous_on by (metis subset_eq Lim_within_subset) | 
| 3281 | ||
| 3282 | lemma continuous_on_interior: | |
| 36359 | 3283 | shows "continuous_on s f \<Longrightarrow> x \<in> interior s ==> continuous (at x) f" | 
| 33175 | 3284 | unfolding interior_def | 
| 3285 | apply simp | |
| 3286 | by (meson continuous_on_eq_continuous_at continuous_on_subset) | |
| 3287 | ||
| 3288 | lemma continuous_on_eq: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3289 | "(\<forall>x \<in> s. f x = g x) \<Longrightarrow> continuous_on s f \<Longrightarrow> continuous_on s g" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3290 | unfolding continuous_on_def tendsto_def Limits.eventually_within | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3291 | by simp | 
| 33175 | 3292 | |
| 3293 | text{* Characterization of various kinds of continuity in terms of sequences.  *}
 | |
| 3294 | ||
| 3295 | (* \<longrightarrow> could be generalized, but \<longleftarrow> requires metric space *) | |
| 3296 | lemma continuous_within_sequentially: | |
| 3297 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" | |
| 3298 | shows "continuous (at a within s) f \<longleftrightarrow> | |
| 3299 | (\<forall>x. (\<forall>n::nat. x n \<in> s) \<and> (x ---> a) sequentially | |
| 3300 | --> ((f o x) ---> f a) sequentially)" (is "?lhs = ?rhs") | |
| 3301 | proof | |
| 3302 | assume ?lhs | |
| 3303 |   { 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"
 | |
| 3304 | fix e::real assume "e>0" | |
| 3305 | 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 | |
| 3306 | from x(2) `d>0` obtain N where N:"\<forall>n\<ge>N. dist (x n) a < d" by auto | |
| 3307 | hence "\<exists>N. \<forall>n\<ge>N. dist ((f \<circ> x) n) (f a) < e" | |
| 3308 | apply(rule_tac x=N in exI) using N d apply auto using x(1) | |
| 3309 | apply(erule_tac x=n in allE) apply(erule_tac x=n in allE) | |
| 3310 | apply(erule_tac x="x n" in ballE) apply auto unfolding dist_nz[THEN sym] apply auto using `e>0` by auto | |
| 3311 | } | |
| 3312 | thus ?rhs unfolding continuous_within unfolding Lim_sequentially by simp | |
| 3313 | next | |
| 3314 | assume ?rhs | |
| 3315 |   { fix e::real assume "e>0"
 | |
| 3316 | 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)" | |
| 3317 | 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 | |
| 3318 | 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)" | |
| 3319 | 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 | |
| 3320 |     { fix d::real assume "d>0"
 | |
| 3321 | 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 | |
| 3322 | then obtain N::nat where N:"inverse (real (N + 1)) < d" by auto | |
| 3323 |       { fix n::nat assume n:"n\<ge>N"
 | |
| 3324 | hence "dist (x (inverse (real (n + 1)))) a < inverse (real (n + 1))" using x[THEN spec[where x="inverse (real (n + 1))"]] by auto | |
| 3325 | 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) | |
| 3326 | ultimately have "dist (x (inverse (real (n + 1)))) a < d" by auto | |
| 3327 | } | |
| 3328 | hence "\<exists>N::nat. \<forall>n\<ge>N. dist (x (inverse (real (n + 1)))) a < d" by auto | |
| 3329 | } | |
| 3330 | 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 | |
| 3331 | 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 | |
| 3332 | hence "False" apply(erule_tac x=e in allE) using `e>0` using x by auto | |
| 3333 | } | |
| 3334 | thus ?lhs unfolding continuous_within unfolding Lim_within unfolding Lim_sequentially by blast | |
| 3335 | qed | |
| 3336 | ||
| 3337 | lemma continuous_at_sequentially: | |
| 3338 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" | |
| 3339 | shows "continuous (at a) f \<longleftrightarrow> (\<forall>x. (x ---> a) sequentially | |
| 3340 | --> ((f o x) ---> f a) sequentially)" | |
| 3341 | using continuous_within_sequentially[of a UNIV f] unfolding within_UNIV by auto | |
| 3342 | ||
| 3343 | lemma continuous_on_sequentially: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3344 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" | 
| 36359 | 3345 | shows "continuous_on s f \<longleftrightarrow> | 
| 3346 | (\<forall>x. \<forall>a \<in> s. (\<forall>n. x(n) \<in> s) \<and> (x ---> a) sequentially | |
| 33175 | 3347 | --> ((f o x) ---> f(a)) sequentially)" (is "?lhs = ?rhs") | 
| 3348 | proof | |
| 3349 | assume ?rhs thus ?lhs using continuous_within_sequentially[of _ s f] unfolding continuous_on_eq_continuous_within by auto | |
| 3350 | next | |
| 3351 | assume ?lhs thus ?rhs unfolding continuous_on_eq_continuous_within using continuous_within_sequentially[of _ s f] by auto | |
| 3352 | qed | |
| 3353 | ||
| 36441 | 3354 | lemma uniformly_continuous_on_sequentially': | 
| 3355 | "uniformly_continuous_on s f \<longleftrightarrow> (\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> | |
| 3356 | ((\<lambda>n. dist (x n) (y n)) ---> 0) sequentially | |
| 3357 | \<longrightarrow> ((\<lambda>n. dist (f(x n)) (f(y n))) ---> 0) sequentially)" (is "?lhs = ?rhs") | |
| 33175 | 3358 | proof | 
| 3359 | assume ?lhs | |
| 36441 | 3360 |   { fix x y assume x:"\<forall>n. x n \<in> s" and y:"\<forall>n. y n \<in> s" and xy:"((\<lambda>n. dist (x n) (y n)) ---> 0) sequentially"
 | 
| 33175 | 3361 |     { fix e::real assume "e>0"
 | 
| 3362 | 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" | |
| 3363 | using `?lhs`[unfolded uniformly_continuous_on_def, THEN spec[where x=e]] by auto | |
| 36441 | 3364 | obtain N where N:"\<forall>n\<ge>N. dist (x n) (y n) < d" using xy[unfolded Lim_sequentially dist_norm] and `d>0` by auto | 
| 33175 | 3365 |       { fix n assume "n\<ge>N"
 | 
| 36441 | 3366 | hence "dist (f (x n)) (f (y n)) < e" | 
| 33175 | 3367 | 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 | 
| 36441 | 3368 | unfolding dist_commute by simp } | 
| 3369 | hence "\<exists>N. \<forall>n\<ge>N. dist (f (x n)) (f (y n)) < e" by auto } | |
| 3370 | hence "((\<lambda>n. dist (f(x n)) (f(y n))) ---> 0) sequentially" unfolding Lim_sequentially and dist_real_def by auto } | |
| 33175 | 3371 | thus ?rhs by auto | 
| 3372 | next | |
| 3373 | assume ?rhs | |
| 3374 |   { assume "\<not> ?lhs"
 | |
| 3375 | 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 | |
| 3376 | 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" | |
| 3377 | 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 | |
| 3378 | by (auto simp add: dist_commute) | |
| 3379 | def x \<equiv> "\<lambda>n::nat. fst (fa (inverse (real n + 1)))" | |
| 3380 | def y \<equiv> "\<lambda>n::nat. snd (fa (inverse (real n + 1)))" | |
| 3381 | 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" | |
| 3382 | unfolding x_def and y_def using fa by auto | |
| 3383 |     { fix e::real assume "e>0"
 | |
| 3384 | 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 | |
| 3385 |       { fix n::nat assume "n\<ge>N"
 | |
| 3386 | hence "inverse (real n + 1) < inverse (real N)" using real_of_nat_ge_zero and `N\<noteq>0` by auto | |
| 3387 | also have "\<dots> < e" using N by auto | |
| 3388 | finally have "inverse (real n + 1) < e" by auto | |
| 36441 | 3389 | hence "dist (x n) (y n) < e" using xy0[THEN spec[where x=n]] by auto } | 
| 3390 | hence "\<exists>N. \<forall>n\<ge>N. dist (x n) (y n) < e" by auto } | |
| 3391 | hence "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (f (x n)) (f (y n)) < e" using `?rhs`[THEN spec[where x=x], THEN spec[where x=y]] and xyn unfolding Lim_sequentially dist_real_def by auto | |
| 3392 | hence False using fxy and `e>0` by auto } | |
| 33175 | 3393 | thus ?lhs unfolding uniformly_continuous_on_def by blast | 
| 3394 | qed | |
| 3395 | ||
| 36441 | 3396 | lemma uniformly_continuous_on_sequentially: | 
| 3397 | fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" | |
| 3398 | shows "uniformly_continuous_on s f \<longleftrightarrow> (\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and> | |
| 3399 | ((\<lambda>n. x n - y n) ---> 0) sequentially | |
| 3400 | \<longrightarrow> ((\<lambda>n. f(x n) - f(y n)) ---> 0) sequentially)" (is "?lhs = ?rhs") | |
| 3401 | (* BH: maybe the previous lemma should replace this one? *) | |
| 3402 | unfolding uniformly_continuous_on_sequentially' | |
| 3403 | unfolding dist_norm Lim_null_norm [symmetric] .. | |
| 3404 | ||
| 33175 | 3405 | text{* The usual transformation theorems. *}
 | 
| 3406 | ||
| 3407 | lemma continuous_transform_within: | |
| 36667 | 3408 | fixes f g :: "'a::metric_space \<Rightarrow> 'b::topological_space" | 
| 33175 | 3409 | assumes "0 < d" "x \<in> s" "\<forall>x' \<in> s. dist x' x < d --> f x' = g x'" | 
| 3410 | "continuous (at x within s) f" | |
| 3411 | shows "continuous (at x within s) g" | |
| 36667 | 3412 | unfolding continuous_within | 
| 3413 | proof (rule Lim_transform_within) | |
| 3414 | show "0 < d" by fact | |
| 3415 | show "\<forall>x'\<in>s. 0 < dist x' x \<and> dist x' x < d \<longrightarrow> f x' = g x'" | |
| 3416 | using assms(3) by auto | |
| 3417 | have "f x = g x" | |
| 3418 | using assms(1,2,3) by auto | |
| 3419 | thus "(f ---> g x) (at x within s)" | |
| 3420 | using assms(4) unfolding continuous_within by simp | |
| 33175 | 3421 | qed | 
| 3422 | ||
| 3423 | lemma continuous_transform_at: | |
| 36667 | 3424 | fixes f g :: "'a::metric_space \<Rightarrow> 'b::topological_space" | 
| 33175 | 3425 | assumes "0 < d" "\<forall>x'. dist x' x < d --> f x' = g x'" | 
| 3426 | "continuous (at x) f" | |
| 3427 | shows "continuous (at x) g" | |
| 36667 | 3428 | using continuous_transform_within [of d x UNIV f g] assms | 
| 3429 | by (simp add: within_UNIV) | |
| 33175 | 3430 | |
| 3431 | text{* Combination results for pointwise continuity. *}
 | |
| 3432 | ||
| 3433 | lemma continuous_const: "continuous net (\<lambda>x. c)" | |
| 3434 | by (auto simp add: continuous_def Lim_const) | |
| 3435 | ||
| 3436 | lemma continuous_cmul: | |
| 3437 | fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" | |
| 3438 | shows "continuous net f ==> continuous net (\<lambda>x. c *\<^sub>R f x)" | |
| 3439 | by (auto simp add: continuous_def Lim_cmul) | |
| 3440 | ||
| 3441 | lemma continuous_neg: | |
| 3442 | fixes f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" | |
| 3443 | shows "continuous net f ==> continuous net (\<lambda>x. -(f x))" | |
| 3444 | by (auto simp add: continuous_def Lim_neg) | |
| 3445 | ||
| 3446 | lemma continuous_add: | |
| 3447 | fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" | |
| 3448 | shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x + g x)" | |
| 3449 | by (auto simp add: continuous_def Lim_add) | |
| 3450 | ||
| 3451 | lemma continuous_sub: | |
| 3452 | fixes f g :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector" | |
| 3453 | shows "continuous net f \<Longrightarrow> continuous net g \<Longrightarrow> continuous net (\<lambda>x. f x - g x)" | |
| 3454 | by (auto simp add: continuous_def Lim_sub) | |
| 3455 | ||
| 34964 | 3456 | |
| 33175 | 3457 | text{* Same thing for setwise continuity. *}
 | 
| 3458 | ||
| 3459 | lemma continuous_on_const: | |
| 3460 | "continuous_on s (\<lambda>x. c)" | |
| 36359 | 3461 | unfolding continuous_on_def by auto | 
| 33175 | 3462 | |
| 3463 | lemma continuous_on_cmul: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3464 | fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3465 | shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. c *\<^sub>R (f x))" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3466 | unfolding continuous_on_def by (auto intro: tendsto_intros) | 
| 33175 | 3467 | |
| 3468 | lemma continuous_on_neg: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3469 | fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector" | 
| 33175 | 3470 | shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. - f x)" | 
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3471 | unfolding continuous_on_def by (auto intro: tendsto_intros) | 
| 33175 | 3472 | |
| 3473 | lemma continuous_on_add: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3474 | fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector" | 
| 33175 | 3475 | shows "continuous_on s f \<Longrightarrow> continuous_on s g | 
| 3476 | \<Longrightarrow> continuous_on s (\<lambda>x. f x + g x)" | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3477 | unfolding continuous_on_def by (auto intro: tendsto_intros) | 
| 33175 | 3478 | |
| 3479 | lemma continuous_on_sub: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3480 | fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector" | 
| 33175 | 3481 | shows "continuous_on s f \<Longrightarrow> continuous_on s g | 
| 3482 | \<Longrightarrow> continuous_on s (\<lambda>x. f x - g x)" | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3483 | unfolding continuous_on_def by (auto intro: tendsto_intros) | 
| 33175 | 3484 | |
| 3485 | text{* Same thing for uniform continuity, using sequential formulations. *}
 | |
| 3486 | ||
| 3487 | lemma uniformly_continuous_on_const: | |
| 3488 | "uniformly_continuous_on s (\<lambda>x. c)" | |
| 3489 | unfolding uniformly_continuous_on_def by simp | |
| 3490 | ||
| 3491 | lemma uniformly_continuous_on_cmul: | |
| 36441 | 3492 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | 
| 33175 | 3493 | assumes "uniformly_continuous_on s f" | 
| 3494 | shows "uniformly_continuous_on s (\<lambda>x. c *\<^sub>R f(x))" | |
| 3495 | proof- | |
| 3496 |   { fix x y assume "((\<lambda>n. f (x n) - f (y n)) ---> 0) sequentially"
 | |
| 3497 | hence "((\<lambda>n. c *\<^sub>R f (x n) - c *\<^sub>R f (y n)) ---> 0) sequentially" | |
| 3498 | using Lim_cmul[of "(\<lambda>n. f (x n) - f (y n))" 0 sequentially c] | |
| 3499 | unfolding scaleR_zero_right scaleR_right_diff_distrib by auto | |
| 3500 | } | |
| 36441 | 3501 | thus ?thesis using assms unfolding uniformly_continuous_on_sequentially' | 
| 3502 | unfolding dist_norm Lim_null_norm [symmetric] by auto | |
| 33175 | 3503 | qed | 
| 3504 | ||
| 3505 | lemma dist_minus: | |
| 3506 | fixes x y :: "'a::real_normed_vector" | |
| 3507 | shows "dist (- x) (- y) = dist x y" | |
| 3508 | unfolding dist_norm minus_diff_minus norm_minus_cancel .. | |
| 3509 | ||
| 3510 | lemma uniformly_continuous_on_neg: | |
| 3511 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3512 | shows "uniformly_continuous_on s f | |
| 3513 | ==> uniformly_continuous_on s (\<lambda>x. -(f x))" | |
| 3514 | unfolding uniformly_continuous_on_def dist_minus . | |
| 3515 | ||
| 3516 | lemma uniformly_continuous_on_add: | |
| 36441 | 3517 | fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | 
| 33175 | 3518 | assumes "uniformly_continuous_on s f" "uniformly_continuous_on s g" | 
| 3519 | shows "uniformly_continuous_on s (\<lambda>x. f x + g x)" | |
| 3520 | proof- | |
| 3521 |   {  fix x y assume "((\<lambda>n. f (x n) - f (y n)) ---> 0) sequentially"
 | |
| 3522 | "((\<lambda>n. g (x n) - g (y n)) ---> 0) sequentially" | |
| 3523 | hence "((\<lambda>xa. f (x xa) - f (y xa) + (g (x xa) - g (y xa))) ---> 0 + 0) sequentially" | |
| 3524 | 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 | |
| 3525 | 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 } | |
| 36441 | 3526 | thus ?thesis using assms unfolding uniformly_continuous_on_sequentially' | 
| 3527 | unfolding dist_norm Lim_null_norm [symmetric] by auto | |
| 33175 | 3528 | qed | 
| 3529 | ||
| 3530 | lemma uniformly_continuous_on_sub: | |
| 36441 | 3531 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | 
| 33175 | 3532 | shows "uniformly_continuous_on s f \<Longrightarrow> uniformly_continuous_on s g | 
| 3533 | ==> uniformly_continuous_on s (\<lambda>x. f x - g x)" | |
| 3534 | unfolding ab_diff_minus | |
| 3535 | using uniformly_continuous_on_add[of s f "\<lambda>x. - g x"] | |
| 3536 | using uniformly_continuous_on_neg[of s g] by auto | |
| 3537 | ||
| 3538 | text{* Identity function is continuous in every sense. *}
 | |
| 3539 | ||
| 3540 | lemma continuous_within_id: | |
| 3541 | "continuous (at a within s) (\<lambda>x. x)" | |
| 3542 | unfolding continuous_within by (rule Lim_at_within [OF Lim_ident_at]) | |
| 3543 | ||
| 3544 | lemma continuous_at_id: | |
| 3545 | "continuous (at a) (\<lambda>x. x)" | |
| 3546 | unfolding continuous_at by (rule Lim_ident_at) | |
| 3547 | ||
| 3548 | lemma continuous_on_id: | |
| 3549 | "continuous_on s (\<lambda>x. x)" | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3550 | unfolding continuous_on_def by (auto intro: tendsto_ident_at_within) | 
| 33175 | 3551 | |
| 3552 | lemma uniformly_continuous_on_id: | |
| 3553 | "uniformly_continuous_on s (\<lambda>x. x)" | |
| 3554 | unfolding uniformly_continuous_on_def by auto | |
| 3555 | ||
| 3556 | text{* Continuity of all kinds is preserved under composition. *}
 | |
| 3557 | ||
| 36441 | 3558 | lemma continuous_within_topological: | 
| 3559 | "continuous (at x within s) f \<longleftrightarrow> | |
| 3560 | (\<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> | |
| 3561 | (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))" | |
| 3562 | unfolding continuous_within | |
| 3563 | unfolding tendsto_def Limits.eventually_within eventually_at_topological | |
| 3564 | by (intro ball_cong [OF refl] all_cong imp_cong ex_cong conj_cong refl) auto | |
| 3565 | ||
| 33175 | 3566 | lemma continuous_within_compose: | 
| 36441 | 3567 | assumes "continuous (at x within s) f" | 
| 3568 | assumes "continuous (at (f x) within f ` s) g" | |
| 33175 | 3569 | shows "continuous (at x within s) (g o f)" | 
| 36441 | 3570 | using assms unfolding continuous_within_topological by simp metis | 
| 33175 | 3571 | |
| 3572 | lemma continuous_at_compose: | |
| 3573 | assumes "continuous (at x) f" "continuous (at (f x)) g" | |
| 3574 | shows "continuous (at x) (g o f)" | |
| 3575 | proof- | |
| 3576 | 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 | |
| 3577 | thus ?thesis using assms(1) using continuous_within_compose[of x UNIV f g, unfolded within_UNIV] by auto | |
| 3578 | qed | |
| 3579 | ||
| 3580 | lemma continuous_on_compose: | |
| 36440 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3581 | "continuous_on s f \<Longrightarrow> continuous_on (f ` s) g \<Longrightarrow> continuous_on s (g o f)" | 
| 
89a70297564d
simplify definition of continuous_on; generalize some lemmas
 huffman parents: 
36439diff
changeset | 3582 | unfolding continuous_on_topological by simp metis | 
| 33175 | 3583 | |
| 3584 | lemma uniformly_continuous_on_compose: | |
| 3585 | assumes "uniformly_continuous_on s f" "uniformly_continuous_on (f ` s) g" | |
| 3586 | shows "uniformly_continuous_on s (g o f)" | |
| 3587 | proof- | |
| 3588 |   { fix e::real assume "e>0"
 | |
| 3589 | 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 | |
| 3590 | 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 | |
| 3591 | 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 } | |
| 3592 | thus ?thesis using assms unfolding uniformly_continuous_on_def by auto | |
| 3593 | qed | |
| 3594 | ||
| 3595 | text{* Continuity in terms of open preimages. *}
 | |
| 3596 | ||
| 3597 | lemma continuous_at_open: | |
| 36441 | 3598 | 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)))" | 
| 3599 | unfolding continuous_within_topological [of x UNIV f, unfolded within_UNIV] | |
| 3600 | unfolding imp_conjL by (intro all_cong imp_cong ex_cong conj_cong refl) auto | |
| 33175 | 3601 | |
| 3602 | lemma continuous_on_open: | |
| 36441 | 3603 | shows "continuous_on s f \<longleftrightarrow> | 
| 33175 | 3604 | (\<forall>t. openin (subtopology euclidean (f ` s)) t | 
| 3605 |             --> openin (subtopology euclidean s) {x \<in> s. f x \<in> t})" (is "?lhs = ?rhs")
 | |
| 36441 | 3606 | proof (safe) | 
| 3607 | fix t :: "'b set" | |
| 3608 | assume 1: "continuous_on s f" | |
| 3609 | assume 2: "openin (subtopology euclidean (f ` s)) t" | |
| 3610 | from 2 obtain B where B: "open B" and t: "t = f ` s \<inter> B" | |
| 3611 | unfolding openin_open by auto | |
| 3612 |   def U == "\<Union>{A. open A \<and> (\<forall>x\<in>s. x \<in> A \<longrightarrow> f x \<in> B)}"
 | |
| 3613 | have "open U" unfolding U_def by (simp add: open_Union) | |
| 3614 | moreover have "\<forall>x\<in>s. x \<in> U \<longleftrightarrow> f x \<in> t" | |
| 3615 | proof (intro ballI iffI) | |
| 3616 | fix x assume "x \<in> s" and "x \<in> U" thus "f x \<in> t" | |
| 3617 | unfolding U_def t by auto | |
| 3618 | next | |
| 3619 | fix x assume "x \<in> s" and "f x \<in> t" | |
| 3620 | hence "x \<in> s" and "f x \<in> B" | |
| 3621 | unfolding t by auto | |
| 3622 | with 1 B obtain A where "open A" "x \<in> A" "\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B" | |
| 3623 | unfolding t continuous_on_topological by metis | |
| 3624 | then show "x \<in> U" | |
| 3625 | unfolding U_def by auto | |
| 3626 | qed | |
| 3627 |   ultimately have "open U \<and> {x \<in> s. f x \<in> t} = s \<inter> U" by auto
 | |
| 3628 |   then show "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}"
 | |
| 3629 | unfolding openin_open by fast | |
| 33175 | 3630 | next | 
| 36441 | 3631 | assume "?rhs" show "continuous_on s f" | 
| 3632 | unfolding continuous_on_topological | |
| 3633 | proof (clarify) | |
| 3634 | fix x and B assume "x \<in> s" and "open B" and "f x \<in> B" | |
| 3635 | have "openin (subtopology euclidean (f ` s)) (f ` s \<inter> B)" | |
| 3636 | unfolding openin_open using `open B` by auto | |
| 3637 |     then have "openin (subtopology euclidean s) {x \<in> s. f x \<in> f ` s \<inter> B}"
 | |
| 3638 | using `?rhs` by fast | |
| 3639 | then show "\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)" | |
| 3640 | unfolding openin_open using `x \<in> s` and `f x \<in> B` by auto | |
| 3641 | qed | |
| 3642 | qed | |
| 3643 | ||
| 3644 | text {* Similarly in terms of closed sets. *}
 | |
| 33175 | 3645 | |
| 3646 | lemma continuous_on_closed: | |
| 36359 | 3647 |   shows "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")
 | 
| 33175 | 3648 | proof | 
| 3649 | assume ?lhs | |
| 3650 |   { fix t
 | |
| 3651 |     have *:"s - {x \<in> s. f x \<in> f ` s - t} = {x \<in> s. f x \<in> t}" by auto
 | |
| 3652 | have **:"f ` s - (f ` s - (f ` s - t)) = f ` s - t" by auto | |
| 3653 | assume as:"closedin (subtopology euclidean (f ` s)) t" | |
| 3654 | hence "closedin (subtopology euclidean (f ` s)) (f ` s - (f ` s - t))" unfolding closedin_def topspace_euclidean_subtopology unfolding ** by auto | |
| 3655 |     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"]]
 | |
| 3656 | unfolding openin_closedin_eq topspace_euclidean_subtopology unfolding * by auto } | |
| 3657 | thus ?rhs by auto | |
| 3658 | next | |
| 3659 | assume ?rhs | |
| 3660 |   { fix t
 | |
| 3661 |     have *:"s - {x \<in> s. f x \<in> f ` s - t} = {x \<in> s. f x \<in> t}" by auto
 | |
| 3662 | assume as:"openin (subtopology euclidean (f ` s)) t" | |
| 3663 |     hence "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}" using `?rhs`[THEN spec[where x="(f ` s) - t"]]
 | |
| 3664 | unfolding openin_closedin_eq topspace_euclidean_subtopology *[THEN sym] closedin_subtopology by auto } | |
| 3665 | thus ?lhs unfolding continuous_on_open by auto | |
| 3666 | qed | |
| 3667 | ||
| 3668 | text{* Half-global and completely global cases.                                  *}
 | |
| 3669 | ||
| 3670 | lemma continuous_open_in_preimage: | |
| 3671 | assumes "continuous_on s f" "open t" | |
| 3672 |   shows "openin (subtopology euclidean s) {x \<in> s. f x \<in> t}"
 | |
| 3673 | proof- | |
| 3674 | 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 | |
| 3675 | have "openin (subtopology euclidean (f ` s)) (t \<inter> f ` s)" | |
| 3676 | using openin_open_Int[of t "f ` s", OF assms(2)] unfolding openin_open by auto | |
| 3677 | thus ?thesis using assms(1)[unfolded continuous_on_open, THEN spec[where x="t \<inter> f ` s"]] using * by auto | |
| 3678 | qed | |
| 3679 | ||
| 3680 | lemma continuous_closed_in_preimage: | |
| 3681 | assumes "continuous_on s f" "closed t" | |
| 3682 |   shows "closedin (subtopology euclidean s) {x \<in> s. f x \<in> t}"
 | |
| 3683 | proof- | |
| 3684 | 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 | |
| 3685 | have "closedin (subtopology euclidean (f ` s)) (t \<inter> f ` s)" | |
| 3686 | using closedin_closed_Int[of t "f ` s", OF assms(2)] unfolding Int_commute by auto | |
| 3687 | thus ?thesis | |
| 3688 | using assms(1)[unfolded continuous_on_closed, THEN spec[where x="t \<inter> f ` s"]] using * by auto | |
| 3689 | qed | |
| 3690 | ||
| 3691 | lemma continuous_open_preimage: | |
| 3692 | assumes "continuous_on s f" "open s" "open t" | |
| 3693 |   shows "open {x \<in> s. f x \<in> t}"
 | |
| 3694 | proof- | |
| 3695 |   obtain T where T: "open T" "{x \<in> s. f x \<in> t} = s \<inter> T"
 | |
| 3696 | using continuous_open_in_preimage[OF assms(1,3)] unfolding openin_open by auto | |
| 3697 | thus ?thesis using open_Int[of s T, OF assms(2)] by auto | |
| 3698 | qed | |
| 3699 | ||
| 3700 | lemma continuous_closed_preimage: | |
| 3701 | assumes "continuous_on s f" "closed s" "closed t" | |
| 3702 |   shows "closed {x \<in> s. f x \<in> t}"
 | |
| 3703 | proof- | |
| 3704 |   obtain T where T: "closed T" "{x \<in> s. f x \<in> t} = s \<inter> T"
 | |
| 3705 | using continuous_closed_in_preimage[OF assms(1,3)] unfolding closedin_closed by auto | |
| 3706 | thus ?thesis using closed_Int[of s T, OF assms(2)] by auto | |
| 3707 | qed | |
| 3708 | ||
| 3709 | lemma continuous_open_preimage_univ: | |
| 3710 |   shows "\<forall>x. continuous (at x) f \<Longrightarrow> open s \<Longrightarrow> open {x. f x \<in> s}"
 | |
| 3711 | using continuous_open_preimage[of UNIV f s] open_UNIV continuous_at_imp_continuous_on by auto | |
| 3712 | ||
| 3713 | lemma continuous_closed_preimage_univ: | |
| 3714 |   shows "(\<forall>x. continuous (at x) f) \<Longrightarrow> closed s ==> closed {x. f x \<in> s}"
 | |
| 3715 | using continuous_closed_preimage[of UNIV f s] closed_UNIV continuous_at_imp_continuous_on by auto | |
| 3716 | ||
| 3717 | lemma continuous_open_vimage: | |
| 3718 | shows "\<forall>x. continuous (at x) f \<Longrightarrow> open s \<Longrightarrow> open (f -` s)" | |
| 3719 | unfolding vimage_def by (rule continuous_open_preimage_univ) | |
| 3720 | ||
| 3721 | lemma continuous_closed_vimage: | |
| 3722 | shows "\<forall>x. continuous (at x) f \<Longrightarrow> closed s \<Longrightarrow> closed (f -` s)" | |
| 3723 | unfolding vimage_def by (rule continuous_closed_preimage_univ) | |
| 3724 | ||
| 36441 | 3725 | lemma interior_image_subset: | 
| 35172 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3726 | assumes "\<forall>x. continuous (at x) f" "inj f" | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3727 | shows "interior (f ` s) \<subseteq> f ` (interior s)" | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3728 | apply rule unfolding interior_def mem_Collect_eq image_iff apply safe | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3729 | proof- fix x T assume as:"open T" "x \<in> T" "T \<subseteq> f ` s" | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3730 | hence "x \<in> f ` s" by auto then guess y unfolding image_iff .. note y=this | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3731 |   thus "\<exists>xa\<in>{x. \<exists>T. open T \<and> x \<in> T \<and> T \<subseteq> s}. x = f xa" apply(rule_tac x=y in bexI) using assms as
 | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3732 |     apply safe apply(rule_tac x="{x. f x \<in> T}" in exI) apply(safe,rule continuous_open_preimage_univ)
 | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3733 | proof- fix x assume "f x \<in> T" hence "f x \<in> f ` s" using as by auto | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3734 | thus "x \<in> s" unfolding inj_image_mem_iff[OF assms(2)] . qed auto qed | 
| 
579dd5570f96
Added integration to Multivariate-Analysis (upto FTC)
 himmelma parents: 
35028diff
changeset | 3735 | |
| 33175 | 3736 | text{* Equality of continuous functions on closure and related results.          *}
 | 
| 3737 | ||
| 3738 | lemma continuous_closed_in_preimage_constant: | |
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 3739 | fixes f :: "_ \<Rightarrow> 'b::t1_space" | 
| 36359 | 3740 |   shows "continuous_on s f ==> closedin (subtopology euclidean s) {x \<in> s. f x = a}"
 | 
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 3741 |   using continuous_closed_in_preimage[of s f "{a}"] by auto
 | 
| 33175 | 3742 | |
| 3743 | lemma continuous_closed_preimage_constant: | |
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 3744 | fixes f :: "_ \<Rightarrow> 'b::t1_space" | 
| 36359 | 3745 |   shows "continuous_on s f \<Longrightarrow> closed s ==> closed {x \<in> s. f x = a}"
 | 
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 3746 |   using continuous_closed_preimage[of s f "{a}"] by auto
 | 
| 33175 | 3747 | |
| 3748 | lemma continuous_constant_on_closure: | |
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 3749 | fixes f :: "_ \<Rightarrow> 'b::t1_space" | 
| 33175 | 3750 | assumes "continuous_on (closure s) f" | 
| 3751 | "\<forall>x \<in> s. f x = a" | |
| 3752 | shows "\<forall>x \<in> (closure s). f x = a" | |
| 3753 | using continuous_closed_preimage_constant[of "closure s" f a] | |
| 3754 |     assms closure_minimal[of s "{x \<in> closure s. f x = a}"] closure_subset unfolding subset_eq by auto
 | |
| 3755 | ||
| 3756 | lemma image_closure_subset: | |
| 3757 | assumes "continuous_on (closure s) f" "closed t" "(f ` s) \<subseteq> t" | |
| 3758 | shows "f ` (closure s) \<subseteq> t" | |
| 3759 | proof- | |
| 3760 |   have "s \<subseteq> {x \<in> closure s. f x \<in> t}" using assms(3) closure_subset by auto
 | |
| 3761 |   moreover have "closed {x \<in> closure s. f x \<in> t}"
 | |
| 3762 | using continuous_closed_preimage[OF assms(1)] and assms(2) by auto | |
| 3763 |   ultimately have "closure s = {x \<in> closure s . f x \<in> t}"
 | |
| 3764 |     using closure_minimal[of s "{x \<in> closure s. f x \<in> t}"] by auto
 | |
| 3765 | thus ?thesis by auto | |
| 3766 | qed | |
| 3767 | ||
| 3768 | lemma continuous_on_closure_norm_le: | |
| 3769 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3770 | assumes "continuous_on (closure s) f" "\<forall>y \<in> s. norm(f y) \<le> b" "x \<in> (closure s)" | |
| 3771 | shows "norm(f x) \<le> b" | |
| 3772 | proof- | |
| 3773 | have *:"f ` s \<subseteq> cball 0 b" using assms(2)[unfolded mem_cball_0[THEN sym]] by auto | |
| 3774 | show ?thesis | |
| 3775 | using image_closure_subset[OF assms(1) closed_cball[of 0 b] *] assms(3) | |
| 3776 | unfolding subset_eq apply(erule_tac x="f x" in ballE) by (auto simp add: dist_norm) | |
| 3777 | qed | |
| 3778 | ||
| 3779 | text{* Making a continuous function avoid some value in a neighbourhood.         *}
 | |
| 3780 | ||
| 3781 | lemma continuous_within_avoid: | |
| 3782 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3783 | assumes "continuous (at x within s) f" "x \<in> s" "f x \<noteq> a" | |
| 3784 | shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e --> f y \<noteq> a" | |
| 3785 | proof- | |
| 3786 | 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" | |
| 3787 | using assms(1)[unfolded continuous_within Lim_within, THEN spec[where x="dist (f x) a"]] assms(3)[unfolded dist_nz] by auto | |
| 3788 |   { fix y assume " y\<in>s"  "dist x y < d"
 | |
| 3789 | hence "f y \<noteq> a" using d[THEN bspec[where x=y]] assms(3)[unfolded dist_nz] | |
| 3790 | apply auto unfolding dist_nz[THEN sym] by (auto simp add: dist_commute) } | |
| 3791 | thus ?thesis using `d>0` by auto | |
| 3792 | qed | |
| 3793 | ||
| 3794 | lemma continuous_at_avoid: | |
| 3795 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* FIXME: generalize *) | |
| 3796 | assumes "continuous (at x) f" "f x \<noteq> a" | |
| 3797 | shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" | |
| 3798 | using assms using continuous_within_avoid[of x UNIV f a, unfolded within_UNIV] by auto | |
| 3799 | ||
| 3800 | lemma continuous_on_avoid: | |
| 36359 | 3801 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* TODO: generalize *) | 
| 33175 | 3802 | assumes "continuous_on s f" "x \<in> s" "f x \<noteq> a" | 
| 3803 | shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e \<longrightarrow> f y \<noteq> a" | |
| 3804 | 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 | |
| 3805 | ||
| 3806 | lemma continuous_on_open_avoid: | |
| 36359 | 3807 | fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* TODO: generalize *) | 
| 33175 | 3808 | assumes "continuous_on s f" "open s" "x \<in> s" "f x \<noteq> a" | 
| 3809 | shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a" | |
| 3810 | 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 | |
| 3811 | ||
| 3812 | text{* Proving a function is constant by proving open-ness of level set.         *}
 | |
| 3813 | ||
| 3814 | lemma continuous_levelset_open_in_cases: | |
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 3815 | fixes f :: "_ \<Rightarrow> 'b::t1_space" | 
| 36359 | 3816 | shows "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow> | 
| 33175 | 3817 |         openin (subtopology euclidean s) {x \<in> s. f x = a}
 | 
| 3818 | ==> (\<forall>x \<in> s. f x \<noteq> a) \<or> (\<forall>x \<in> s. f x = a)" | |
| 3819 | unfolding connected_clopen using continuous_closed_in_preimage_constant by auto | |
| 3820 | ||
| 3821 | lemma continuous_levelset_open_in: | |
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 3822 | fixes f :: "_ \<Rightarrow> 'b::t1_space" | 
| 36359 | 3823 | shows "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow> | 
| 33175 | 3824 |         openin (subtopology euclidean s) {x \<in> s. f x = a} \<Longrightarrow>
 | 
| 3825 | (\<exists>x \<in> s. f x = a) ==> (\<forall>x \<in> s. f x = a)" | |
| 3826 | using continuous_levelset_open_in_cases[of s f ] | |
| 3827 | by meson | |
| 3828 | ||
| 3829 | lemma continuous_levelset_open: | |
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 3830 | fixes f :: "_ \<Rightarrow> 'b::t1_space" | 
| 33175 | 3831 |   assumes "connected s"  "continuous_on s f"  "open {x \<in> s. f x = a}"  "\<exists>x \<in> s.  f x = a"
 | 
| 3832 | shows "\<forall>x \<in> s. f x = a" | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 3833 | using continuous_levelset_open_in[OF assms(1,2), of a, unfolded openin_open] using assms (3,4) by fast | 
| 33175 | 3834 | |
| 3835 | text{* Some arithmetical combinations (more to prove).                           *}
 | |
| 3836 | ||
| 3837 | lemma open_scaling[intro]: | |
| 3838 | fixes s :: "'a::real_normed_vector set" | |
| 3839 | assumes "c \<noteq> 0" "open s" | |
| 3840 | shows "open((\<lambda>x. c *\<^sub>R x) ` s)" | |
| 3841 | proof- | |
| 3842 |   { fix x assume "x \<in> s"
 | |
| 3843 | 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 | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 3844 | have "e * abs c > 0" using assms(1)[unfolded zero_less_abs_iff[THEN sym]] using mult_pos_pos[OF `e>0`] by auto | 
| 33175 | 3845 | moreover | 
| 3846 |     { fix y assume "dist y (c *\<^sub>R x) < e * \<bar>c\<bar>"
 | |
| 3847 | hence "norm ((1 / c) *\<^sub>R y - x) < e" unfolding dist_norm | |
| 3848 | using norm_scaleR[of c "(1 / c) *\<^sub>R y - x", unfolded scaleR_right_diff_distrib, unfolded scaleR_scaleR] assms(1) | |
| 3849 | assms(1)[unfolded zero_less_abs_iff[THEN sym]] by (simp del:zero_less_abs_iff) | |
| 3850 | 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 } | |
| 3851 | 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 } | |
| 3852 | thus ?thesis unfolding open_dist by auto | |
| 3853 | qed | |
| 3854 | ||
| 3855 | lemma minus_image_eq_vimage: | |
| 3856 | fixes A :: "'a::ab_group_add set" | |
| 3857 | shows "(\<lambda>x. - x) ` A = (\<lambda>x. - x) -` A" | |
| 3858 | by (auto intro!: image_eqI [where f="\<lambda>x. - x"]) | |
| 3859 | ||
| 3860 | lemma open_negations: | |
| 3861 | fixes s :: "'a::real_normed_vector set" | |
| 3862 | shows "open s ==> open ((\<lambda> x. -x) ` s)" | |
| 3863 | unfolding scaleR_minus1_left [symmetric] | |
| 3864 | by (rule open_scaling, auto) | |
| 3865 | ||
| 3866 | lemma open_translation: | |
| 3867 | fixes s :: "'a::real_normed_vector set" | |
| 3868 | assumes "open s" shows "open((\<lambda>x. a + x) ` s)" | |
| 3869 | proof- | |
| 3870 |   { 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  }
 | |
| 3871 |   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
 | |
| 3872 | ultimately show ?thesis using continuous_open_preimage_univ[of "\<lambda>x. x - a" s] using assms by auto | |
| 3873 | qed | |
| 3874 | ||
| 3875 | lemma open_affinity: | |
| 3876 | fixes s :: "'a::real_normed_vector set" | |
| 3877 | assumes "open s" "c \<noteq> 0" | |
| 3878 | shows "open ((\<lambda>x. a + c *\<^sub>R x) ` s)" | |
| 3879 | proof- | |
| 3880 | have *:"(\<lambda>x. a + c *\<^sub>R x) = (\<lambda>x. a + x) \<circ> (\<lambda>x. c *\<^sub>R x)" unfolding o_def .. | |
| 3881 | have "op + a ` op *\<^sub>R c ` s = (op + a \<circ> op *\<^sub>R c) ` s" by auto | |
| 3882 | thus ?thesis using assms open_translation[of "op *\<^sub>R c ` s" a] unfolding * by auto | |
| 3883 | qed | |
| 3884 | ||
| 3885 | lemma interior_translation: | |
| 3886 | fixes s :: "'a::real_normed_vector set" | |
| 3887 | shows "interior ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (interior s)" | |
| 3888 | proof (rule set_ext, rule) | |
| 3889 | fix x assume "x \<in> interior (op + a ` s)" | |
| 3890 | then obtain e where "e>0" and e:"ball x e \<subseteq> op + a ` s" unfolding mem_interior by auto | |
| 3891 | 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 | |
| 3892 | 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 | |
| 3893 | next | |
| 3894 | fix x assume "x \<in> op + a ` interior s" | |
| 3895 | 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 | |
| 3896 |   { fix z have *:"a + y - z = y + a - z" by auto
 | |
| 3897 | assume "z\<in>ball x e" | |
| 3898 | 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 | |
| 3899 | hence "z \<in> op + a ` s" unfolding image_iff by(auto intro!: bexI[where x="z - a"]) } | |
| 3900 | hence "ball x e \<subseteq> op + a ` s" unfolding subset_eq by auto | |
| 3901 | thus "x \<in> interior (op + a ` s)" unfolding mem_interior using `e>0` by auto | |
| 3902 | qed | |
| 3903 | ||
| 36437 | 3904 | text {* We can now extend limit compositions to consider the scalar multiplier.   *}
 | 
| 3905 | ||
| 3906 | lemma continuous_vmul: | |
| 3907 | fixes c :: "'a::metric_space \<Rightarrow> real" and v :: "'b::real_normed_vector" | |
| 3908 | shows "continuous net c ==> continuous net (\<lambda>x. c(x) *\<^sub>R v)" | |
| 3909 | unfolding continuous_def using Lim_vmul[of c] by auto | |
| 3910 | ||
| 3911 | lemma continuous_mul: | |
| 3912 | fixes c :: "'a::metric_space \<Rightarrow> real" | |
| 3913 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3914 | shows "continuous net c \<Longrightarrow> continuous net f | |
| 3915 | ==> continuous net (\<lambda>x. c(x) *\<^sub>R f x) " | |
| 3916 | unfolding continuous_def by (intro tendsto_intros) | |
| 3917 | ||
| 3918 | lemmas continuous_intros = continuous_add continuous_vmul continuous_cmul continuous_const continuous_sub continuous_at_id continuous_within_id continuous_mul | |
| 3919 | ||
| 3920 | lemma continuous_on_vmul: | |
| 3921 | fixes c :: "'a::metric_space \<Rightarrow> real" and v :: "'b::real_normed_vector" | |
| 3922 | shows "continuous_on s c ==> continuous_on s (\<lambda>x. c(x) *\<^sub>R v)" | |
| 3923 | unfolding continuous_on_eq_continuous_within using continuous_vmul[of _ c] by auto | |
| 3924 | ||
| 3925 | lemma continuous_on_mul: | |
| 3926 | fixes c :: "'a::metric_space \<Rightarrow> real" | |
| 3927 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector" | |
| 3928 | shows "continuous_on s c \<Longrightarrow> continuous_on s f | |
| 3929 | ==> continuous_on s (\<lambda>x. c(x) *\<^sub>R f x)" | |
| 3930 | unfolding continuous_on_eq_continuous_within using continuous_mul[of _ c] by auto | |
| 3931 | ||
| 3932 | 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 | |
| 3933 | 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 | |
| 3934 | continuous_on_mul continuous_on_vmul | |
| 3935 | ||
| 3936 | text{* And so we have continuity of inverse.                                     *}
 | |
| 3937 | ||
| 3938 | lemma continuous_inv: | |
| 3939 | fixes f :: "'a::metric_space \<Rightarrow> real" | |
| 3940 | shows "continuous net f \<Longrightarrow> f(netlimit net) \<noteq> 0 | |
| 3941 | ==> continuous net (inverse o f)" | |
| 3942 | unfolding continuous_def using Lim_inv by auto | |
| 3943 | ||
| 3944 | lemma continuous_at_within_inv: | |
| 3945 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_field" | |
| 3946 | assumes "continuous (at a within s) f" "f a \<noteq> 0" | |
| 3947 | shows "continuous (at a within s) (inverse o f)" | |
| 3948 | using assms unfolding continuous_within o_def | |
| 3949 | by (intro tendsto_intros) | |
| 3950 | ||
| 3951 | lemma continuous_at_inv: | |
| 3952 | fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_field" | |
| 3953 | shows "continuous (at a) f \<Longrightarrow> f a \<noteq> 0 | |
| 3954 | ==> continuous (at a) (inverse o f) " | |
| 3955 | using within_UNIV[THEN sym, of "at a"] using continuous_at_within_inv[of a UNIV] by auto | |
| 3956 | ||
| 3957 | text {* Topological properties of linear functions. *}
 | |
| 3958 | ||
| 3959 | lemma linear_lim_0: | |
| 3960 | assumes "bounded_linear f" shows "(f ---> 0) (at (0))" | |
| 3961 | proof- | |
| 3962 | interpret f: bounded_linear f by fact | |
| 3963 | have "(f ---> f 0) (at 0)" | |
| 3964 | using tendsto_ident_at by (rule f.tendsto) | |
| 3965 | thus ?thesis unfolding f.zero . | |
| 3966 | qed | |
| 3967 | ||
| 3968 | lemma linear_continuous_at: | |
| 3969 | assumes "bounded_linear f" shows "continuous (at a) f" | |
| 3970 | unfolding continuous_at using assms | |
| 3971 | apply (rule bounded_linear.tendsto) | |
| 3972 | apply (rule tendsto_ident_at) | |
| 3973 | done | |
| 3974 | ||
| 3975 | lemma linear_continuous_within: | |
| 3976 | shows "bounded_linear f ==> continuous (at x within s) f" | |
| 3977 | using continuous_at_imp_continuous_within[of x f s] using linear_continuous_at[of f] by auto | |
| 3978 | ||
| 3979 | lemma linear_continuous_on: | |
| 3980 | shows "bounded_linear f ==> continuous_on s f" | |
| 3981 | using continuous_at_imp_continuous_on[of s f] using linear_continuous_at[of f] by auto | |
| 3982 | ||
| 3983 | text{* Also bilinear functions, in composition form.                             *}
 | |
| 3984 | ||
| 3985 | lemma bilinear_continuous_at_compose: | |
| 3986 | shows "continuous (at x) f \<Longrightarrow> continuous (at x) g \<Longrightarrow> bounded_bilinear h | |
| 3987 | ==> continuous (at x) (\<lambda>x. h (f x) (g x))" | |
| 3988 | unfolding continuous_at using Lim_bilinear[of f "f x" "(at x)" g "g x" h] by auto | |
| 3989 | ||
| 3990 | lemma bilinear_continuous_within_compose: | |
| 3991 | shows "continuous (at x within s) f \<Longrightarrow> continuous (at x within s) g \<Longrightarrow> bounded_bilinear h | |
| 3992 | ==> continuous (at x within s) (\<lambda>x. h (f x) (g x))" | |
| 3993 | unfolding continuous_within using Lim_bilinear[of f "f x"] by auto | |
| 3994 | ||
| 3995 | lemma bilinear_continuous_on_compose: | |
| 3996 | shows "continuous_on s f \<Longrightarrow> continuous_on s g \<Longrightarrow> bounded_bilinear h | |
| 3997 | ==> continuous_on s (\<lambda>x. h (f x) (g x))" | |
| 36441 | 3998 | unfolding continuous_on_def | 
| 3999 | by (fast elim: bounded_bilinear.tendsto) | |
| 36437 | 4000 | |
| 4001 | text {* Preservation of compactness and connectedness under continuous function.  *}
 | |
| 33175 | 4002 | |
| 4003 | lemma compact_continuous_image: | |
| 4004 | assumes "continuous_on s f" "compact s" | |
| 4005 | shows "compact(f ` s)" | |
| 4006 | proof- | |
| 4007 |   { fix x assume x:"\<forall>n::nat. x n \<in> f ` s"
 | |
| 4008 | 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 | |
| 4009 | 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 | |
| 4010 |     { fix e::real assume "e>0"
 | |
| 36359 | 4011 | 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_iff, THEN bspec[where x=l], OF `l\<in>s`] by auto | 
| 33175 | 4012 | 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 | 
| 4013 |       { 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  }
 | |
| 4014 | hence "\<exists>N. \<forall>n\<ge>N. dist ((x \<circ> r) n) (f l) < e" by auto } | |
| 4015 | 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 } | |
| 4016 | thus ?thesis unfolding compact_def by auto | |
| 4017 | qed | |
| 4018 | ||
| 4019 | lemma connected_continuous_image: | |
| 4020 | assumes "continuous_on s f" "connected s" | |
| 4021 | shows "connected(f ` s)" | |
| 4022 | proof- | |
| 4023 |   { fix T assume as: "T \<noteq> {}"  "T \<noteq> f ` s"  "openin (subtopology euclidean (f ` s)) T"  "closedin (subtopology euclidean (f ` s)) T"
 | |
| 4024 |     have "{x \<in> s. f x \<in> T} = {} \<or> {x \<in> s. f x \<in> T} = s"
 | |
| 4025 | using assms(1)[unfolded continuous_on_open, THEN spec[where x=T]] | |
| 4026 | using assms(1)[unfolded continuous_on_closed, THEN spec[where x=T]] | |
| 4027 |       using assms(2)[unfolded connected_clopen, THEN spec[where x="{x \<in> s. f x \<in> T}"]] as(3,4) by auto
 | |
| 4028 | hence False using as(1,2) | |
| 4029 | using as(4)[unfolded closedin_def topspace_euclidean_subtopology] by auto } | |
| 4030 | thus ?thesis unfolding connected_clopen by auto | |
| 4031 | qed | |
| 4032 | ||
| 4033 | text{* Continuity implies uniform continuity on a compact domain.                *}
 | |
| 4034 | ||
| 4035 | lemma compact_uniformly_continuous: | |
| 4036 | assumes "continuous_on s f" "compact s" | |
| 4037 | shows "uniformly_continuous_on s f" | |
| 4038 | proof- | |
| 4039 |     { fix x assume x:"x\<in>s"
 | |
| 36359 | 4040 | 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_iff, THEN bspec[where x=x]] by auto | 
| 33175 | 4041 | 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 } | 
| 4042 | 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 | |
| 4043 | 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)" | |
| 4044 | 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 | |
| 4045 | ||
| 4046 |   { fix e::real assume "e>0"
 | |
| 4047 | ||
| 4048 |     { 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  }
 | |
| 4049 |     hence "s \<subseteq> \<Union>{ball x (d x (e / 2)) |x. x \<in> s}" unfolding subset_eq by auto
 | |
| 4050 | moreover | |
| 4051 |     { fix b assume "b\<in>{ball x (d x (e / 2)) |x. x \<in> s}" hence "open b" by auto  }
 | |
| 4052 |     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
 | |
| 4053 | ||
| 4054 |     { fix x y assume "x\<in>s" "y\<in>s" and as:"dist y x < ea"
 | |
| 4055 | 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 | |
| 4056 | hence "x\<in>ball z (d z (e / 2))" using `ea>0` unfolding subset_eq by auto | |
| 4057 | 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` | |
| 4058 | by (auto simp add: dist_commute) | |
| 4059 | moreover have "y\<in>ball z (d z (e / 2))" using as and `ea>0` and z[unfolded subset_eq] | |
| 4060 | by (auto simp add: dist_commute) | |
| 4061 | 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` | |
| 4062 | by (auto simp add: dist_commute) | |
| 4063 | ultimately have "dist (f y) (f x) < e" using dist_triangle_half_r[of "f z" "f x" e "f y"] | |
| 4064 | by (auto simp add: dist_commute) } | |
| 4065 | 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 } | |
| 4066 | thus ?thesis unfolding uniformly_continuous_on_def by auto | |
| 4067 | qed | |
| 4068 | ||
| 4069 | text{* Continuity of inverse function on compact domain. *}
 | |
| 4070 | ||
| 4071 | lemma continuous_on_inverse: | |
| 4072 | fixes f :: "'a::heine_borel \<Rightarrow> 'b::heine_borel" | |
| 4073 | (* TODO: can this be generalized more? *) | |
| 4074 | assumes "continuous_on s f" "compact s" "\<forall>x \<in> s. g (f x) = x" | |
| 4075 | shows "continuous_on (f ` s) g" | |
| 4076 | proof- | |
| 4077 | have *:"g ` f ` s = s" using assms(3) by (auto simp add: image_iff) | |
| 4078 |   { fix t assume t:"closedin (subtopology euclidean (g ` f ` s)) t"
 | |
| 4079 | then obtain T where T: "closed T" "t = s \<inter> T" unfolding closedin_closed unfolding * by auto | |
| 4080 | have "continuous_on (s \<inter> T) f" using continuous_on_subset[OF assms(1), of "s \<inter> t"] | |
| 4081 | unfolding T(2) and Int_left_absorb by auto | |
| 4082 | moreover have "compact (s \<inter> T)" | |
| 4083 | using assms(2) unfolding compact_eq_bounded_closed | |
| 4084 | using bounded_subset[of s "s \<inter> T"] and T(1) by auto | |
| 4085 | ultimately have "closed (f ` t)" using T(1) unfolding T(2) | |
| 4086 | using compact_continuous_image [of "s \<inter> T" f] unfolding compact_eq_bounded_closed by auto | |
| 4087 |     moreover have "{x \<in> f ` s. g x \<in> t} = f ` s \<inter> f ` t" using assms(3) unfolding T(2) by auto
 | |
| 4088 |     ultimately have "closedin (subtopology euclidean (f ` s)) {x \<in> f ` s. g x \<in> t}"
 | |
| 4089 | unfolding closedin_closed by auto } | |
| 4090 | thus ?thesis unfolding continuous_on_closed by auto | |
| 4091 | qed | |
| 4092 | ||
| 36437 | 4093 | text {* A uniformly convergent limit of continuous functions is continuous. *}
 | 
| 33175 | 4094 | |
| 4095 | lemma norm_triangle_lt: | |
| 4096 | fixes x y :: "'a::real_normed_vector" | |
| 4097 | shows "norm x + norm y < e \<Longrightarrow> norm (x + y) < e" | |
| 4098 | by (rule le_less_trans [OF norm_triangle_ineq]) | |
| 4099 | ||
| 4100 | lemma continuous_uniform_limit: | |
| 4101 | fixes f :: "'a \<Rightarrow> 'b::metric_space \<Rightarrow> 'c::real_normed_vector" | |
| 4102 | assumes "\<not> (trivial_limit net)" "eventually (\<lambda>n. continuous_on s (f n)) net" | |
| 4103 | "\<forall>e>0. eventually (\<lambda>n. \<forall>x \<in> s. norm(f n x - g x) < e) net" | |
| 4104 | shows "continuous_on s g" | |
| 4105 | proof- | |
| 4106 |   { fix x and e::real assume "x\<in>s" "e>0"
 | |
| 4107 | 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 | |
| 4108 | then obtain n where n:"\<forall>xa\<in>s. norm (f n xa - g xa) < e / 3" "continuous_on s (f n)" | |
| 4109 | 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 | |
| 4110 | have "e / 3 > 0" using `e>0` by auto | |
| 4111 | 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" | |
| 36359 | 4112 | using n(2)[unfolded continuous_on_iff, THEN bspec[where x=x], OF `x\<in>s`, THEN spec[where x="e/3"]] by blast | 
| 33175 | 4113 |     { fix y assume "y\<in>s" "dist y x < d"
 | 
| 4114 | hence "dist (f n y) (f n x) < e / 3" using d[THEN bspec[where x=y]] by auto | |
| 4115 | 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"] | |
| 4116 | 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 | |
| 4117 | hence "dist (g y) (g x) < e" unfolding dist_norm using n(1)[THEN bspec[where x=y], OF `y\<in>s`] | |
| 4118 | 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) } | |
| 4119 | hence "\<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (g x') (g x) < e" using `d>0` by auto } | |
| 36359 | 4120 | thus ?thesis unfolding continuous_on_iff by auto | 
| 33175 | 4121 | qed | 
| 4122 | ||
| 4123 | subsection{* Topological stuff lifted from and dropped to R                            *}
 | |
| 4124 | ||
| 4125 | ||
| 4126 | lemma open_real: | |
| 4127 | fixes s :: "real set" shows | |
| 4128 | "open s \<longleftrightarrow> | |
| 4129 | (\<forall>x \<in> s. \<exists>e>0. \<forall>x'. abs(x' - x) < e --> x' \<in> s)" (is "?lhs = ?rhs") | |
| 4130 | unfolding open_dist dist_norm by simp | |
| 4131 | ||
| 4132 | lemma islimpt_approachable_real: | |
| 4133 | fixes s :: "real set" | |
| 4134 | shows "x islimpt s \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in> s. x' \<noteq> x \<and> abs(x' - x) < e)" | |
| 4135 | unfolding islimpt_approachable dist_norm by simp | |
| 4136 | ||
| 4137 | lemma closed_real: | |
| 4138 | fixes s :: "real set" | |
| 4139 | shows "closed s \<longleftrightarrow> | |
| 4140 | (\<forall>x. (\<forall>e>0. \<exists>x' \<in> s. x' \<noteq> x \<and> abs(x' - x) < e) | |
| 4141 | --> x \<in> s)" | |
| 4142 | unfolding closed_limpt islimpt_approachable dist_norm by simp | |
| 4143 | ||
| 4144 | lemma continuous_at_real_range: | |
| 4145 | fixes f :: "'a::real_normed_vector \<Rightarrow> real" | |
| 4146 | shows "continuous (at x) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. | |
| 4147 | \<forall>x'. norm(x' - x) < d --> abs(f x' - f x) < e)" | |
| 4148 | unfolding continuous_at unfolding Lim_at | |
| 4149 | unfolding dist_nz[THEN sym] unfolding dist_norm apply auto | |
| 4150 | 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 | |
| 4151 | apply(erule_tac x=e in allE) by auto | |
| 4152 | ||
| 4153 | lemma continuous_on_real_range: | |
| 4154 | fixes f :: "'a::real_normed_vector \<Rightarrow> real" | |
| 4155 | 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))" | |
| 36359 | 4156 | unfolding continuous_on_iff dist_norm by simp | 
| 33175 | 4157 | |
| 4158 | lemma continuous_at_norm: "continuous (at x) norm" | |
| 4159 | unfolding continuous_at by (intro tendsto_intros) | |
| 4160 | ||
| 4161 | lemma continuous_on_norm: "continuous_on s norm" | |
| 4162 | unfolding continuous_on by (intro ballI tendsto_intros) | |
| 4163 | ||
| 4164 | lemma continuous_at_component: "continuous (at a) (\<lambda>x. x $ i)" | |
| 4165 | unfolding continuous_at by (intro tendsto_intros) | |
| 4166 | ||
| 36441 | 4167 | lemma continuous_on_component: "continuous_on s (\<lambda>x. x $ i)" | 
| 4168 | unfolding continuous_on_def by (intro ballI tendsto_intros) | |
| 33175 | 4169 | |
| 4170 | lemma continuous_at_infnorm: "continuous (at x) infnorm" | |
| 4171 | unfolding continuous_at Lim_at o_def unfolding dist_norm | |
| 4172 | apply auto apply (rule_tac x=e in exI) apply auto | |
| 4173 | using order_trans[OF real_abs_sub_infnorm infnorm_le_norm, of _ x] by (metis xt1(7)) | |
| 4174 | ||
| 4175 | text{* Hence some handy theorems on distance, diameter etc. of/from a set.       *}
 | |
| 4176 | ||
| 4177 | lemma compact_attains_sup: | |
| 4178 | fixes s :: "real set" | |
| 4179 |   assumes "compact s"  "s \<noteq> {}"
 | |
| 4180 | shows "\<exists>x \<in> s. \<forall>y \<in> s. y \<le> x" | |
| 4181 | proof- | |
| 4182 | from assms(1) have a:"bounded s" "closed s" unfolding compact_eq_bounded_closed by auto | |
| 33270 | 4183 |   { 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"
 | 
| 4184 | have "isLub UNIV s (Sup s)" using Sup[OF assms(2)] unfolding setle_def using as(1) by auto | |
| 4185 | moreover have "isUb UNIV s (Sup s - e)" unfolding isUb_def unfolding setle_def using as(4,2) by auto | |
| 4186 | ultimately have False using isLub_le_isUb[of UNIV s "Sup s" "Sup s - e"] using `e>0` by auto } | |
| 4187 | thus ?thesis using bounded_has_Sup(1)[OF a(1) assms(2)] using a(2)[unfolded closed_real, THEN spec[where x="Sup s"]] | |
| 4188 | apply(rule_tac x="Sup s" in bexI) by auto | |
| 4189 | qed | |
| 4190 | ||
| 4191 | lemma Inf: | |
| 4192 | fixes S :: "real set" | |
| 4193 |   shows "S \<noteq> {} ==> (\<exists>b. b <=* S) ==> isGlb UNIV S (Inf S)"
 | |
| 4194 | by (auto simp add: isLb_def setle_def setge_def isGlb_def greatestP_def) | |
| 33175 | 4195 | |
| 4196 | lemma compact_attains_inf: | |
| 4197 | fixes s :: "real set" | |
| 4198 |   assumes "compact s" "s \<noteq> {}"  shows "\<exists>x \<in> s. \<forall>y \<in> s. x \<le> y"
 | |
| 4199 | proof- | |
| 4200 | from assms(1) have a:"bounded s" "closed s" unfolding compact_eq_bounded_closed by auto | |
| 33270 | 4201 |   { fix e::real assume as: "\<forall>x\<in>s. x \<ge> Inf s"  "Inf s \<notin> s"  "0 < e"
 | 
| 4202 | "\<forall>x'\<in>s. x' = Inf s \<or> \<not> abs (x' - Inf s) < e" | |
| 4203 | have "isGlb UNIV s (Inf s)" using Inf[OF assms(2)] unfolding setge_def using as(1) by auto | |
| 33175 | 4204 | moreover | 
| 4205 |     { fix x assume "x \<in> s"
 | |
| 33270 | 4206 | hence *:"abs (x - Inf s) = x - Inf s" using as(1)[THEN bspec[where x=x]] by auto | 
| 4207 | have "Inf s + e \<le> x" using as(4)[THEN bspec[where x=x]] using as(2) `x\<in>s` unfolding * by auto } | |
| 4208 | hence "isLb UNIV s (Inf s + e)" unfolding isLb_def and setge_def by auto | |
| 4209 | ultimately have False using isGlb_le_isLb[of UNIV s "Inf s" "Inf s + e"] using `e>0` by auto } | |
| 4210 | thus ?thesis using bounded_has_Inf(1)[OF a(1) assms(2)] using a(2)[unfolded closed_real, THEN spec[where x="Inf s"]] | |
| 4211 | apply(rule_tac x="Inf s" in bexI) by auto | |
| 33175 | 4212 | qed | 
| 4213 | ||
| 4214 | lemma continuous_attains_sup: | |
| 4215 | fixes f :: "'a::metric_space \<Rightarrow> real" | |
| 4216 |   shows "compact s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> continuous_on s f
 | |
| 4217 | ==> (\<exists>x \<in> s. \<forall>y \<in> s. f y \<le> f x)" | |
| 4218 | using compact_attains_sup[of "f ` s"] | |
| 4219 | using compact_continuous_image[of s f] by auto | |
| 4220 | ||
| 4221 | lemma continuous_attains_inf: | |
| 4222 | fixes f :: "'a::metric_space \<Rightarrow> real" | |
| 4223 |   shows "compact s \<Longrightarrow> s \<noteq> {} \<Longrightarrow> continuous_on s f
 | |
| 4224 | \<Longrightarrow> (\<exists>x \<in> s. \<forall>y \<in> s. f x \<le> f y)" | |
| 4225 | using compact_attains_inf[of "f ` s"] | |
| 4226 | using compact_continuous_image[of s f] by auto | |
| 4227 | ||
| 4228 | lemma distance_attains_sup: | |
| 4229 |   assumes "compact s" "s \<noteq> {}"
 | |
| 4230 | shows "\<exists>x \<in> s. \<forall>y \<in> s. dist a y \<le> dist a x" | |
| 4231 | proof (rule continuous_attains_sup [OF assms]) | |
| 4232 |   { fix x assume "x\<in>s"
 | |
| 4233 | have "(dist a ---> dist a x) (at x within s)" | |
| 4234 | by (intro tendsto_dist tendsto_const Lim_at_within Lim_ident_at) | |
| 4235 | } | |
| 4236 | thus "continuous_on s (dist a)" | |
| 4237 | unfolding continuous_on .. | |
| 4238 | qed | |
| 4239 | ||
| 4240 | text{* For *minimal* distance, we only need closure, not compactness.            *}
 | |
| 4241 | ||
| 4242 | lemma distance_attains_inf: | |
| 4243 | fixes a :: "'a::heine_borel" | |
| 4244 |   assumes "closed s"  "s \<noteq> {}"
 | |
| 4245 | shows "\<exists>x \<in> s. \<forall>y \<in> s. dist a x \<le> dist a y" | |
| 4246 | proof- | |
| 4247 | from assms(2) obtain b where "b\<in>s" by auto | |
| 4248 | let ?B = "cball a (dist b a) \<inter> s" | |
| 4249 | have "b \<in> ?B" using `b\<in>s` by (simp add: dist_commute) | |
| 4250 |   hence "?B \<noteq> {}" by auto
 | |
| 4251 | moreover | |
| 4252 |   { fix x assume "x\<in>?B"
 | |
| 4253 | fix e::real assume "e>0" | |
| 4254 |     { fix x' assume "x'\<in>?B" and as:"dist x' x < e"
 | |
| 4255 | from as have "\<bar>dist a x' - dist a x\<bar> < e" | |
| 4256 | unfolding abs_less_iff minus_diff_eq | |
| 4257 | using dist_triangle2 [of a x' x] | |
| 4258 | using dist_triangle [of a x x'] | |
| 4259 | by arith | |
| 4260 | } | |
| 4261 | hence "\<exists>d>0. \<forall>x'\<in>?B. dist x' x < d \<longrightarrow> \<bar>dist a x' - dist a x\<bar> < e" | |
| 4262 | using `e>0` by auto | |
| 4263 | } | |
| 4264 | hence "continuous_on (cball a (dist b a) \<inter> s) (dist a)" | |
| 4265 | unfolding continuous_on Lim_within dist_norm real_norm_def | |
| 4266 | by fast | |
| 4267 | moreover have "compact ?B" | |
| 4268 | using compact_cball[of a "dist b a"] | |
| 4269 | unfolding compact_eq_bounded_closed | |
| 4270 | using bounded_Int and closed_Int and assms(1) by auto | |
| 4271 | 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" | |
| 4272 | using continuous_attains_inf[of ?B "dist a"] by fastsimp | |
| 4273 | thus ?thesis by fastsimp | |
| 4274 | qed | |
| 4275 | ||
| 36437 | 4276 | subsection {* Pasted sets *}
 | 
| 33175 | 4277 | |
| 4278 | lemma bounded_Times: | |
| 4279 | assumes "bounded s" "bounded t" shows "bounded (s \<times> t)" | |
| 4280 | proof- | |
| 4281 | obtain x y a b where "\<forall>z\<in>s. dist x z \<le> a" "\<forall>z\<in>t. dist y z \<le> b" | |
| 4282 | using assms [unfolded bounded_def] by auto | |
| 4283 | then have "\<forall>z\<in>s \<times> t. dist (x, y) z \<le> sqrt (a\<twosuperior> + b\<twosuperior>)" | |
| 4284 | by (auto simp add: dist_Pair_Pair real_sqrt_le_mono add_mono power_mono) | |
| 4285 | thus ?thesis unfolding bounded_any_center [where a="(x, y)"] by auto | |
| 4286 | qed | |
| 4287 | ||
| 4288 | lemma mem_Times_iff: "x \<in> A \<times> B \<longleftrightarrow> fst x \<in> A \<and> snd x \<in> B" | |
| 4289 | by (induct x) simp | |
| 4290 | ||
| 4291 | lemma compact_Times: "compact s \<Longrightarrow> compact t \<Longrightarrow> compact (s \<times> t)" | |
| 4292 | unfolding compact_def | |
| 4293 | apply clarify | |
| 4294 | apply (drule_tac x="fst \<circ> f" in spec) | |
| 4295 | apply (drule mp, simp add: mem_Times_iff) | |
| 4296 | apply (clarify, rename_tac l1 r1) | |
| 4297 | apply (drule_tac x="snd \<circ> f \<circ> r1" in spec) | |
| 4298 | apply (drule mp, simp add: mem_Times_iff) | |
| 4299 | apply (clarify, rename_tac l2 r2) | |
| 4300 | apply (rule_tac x="(l1, l2)" in rev_bexI, simp) | |
| 4301 | apply (rule_tac x="r1 \<circ> r2" in exI) | |
| 4302 | apply (rule conjI, simp add: subseq_def) | |
| 4303 | apply (drule_tac r=r2 in lim_subseq [COMP swap_prems_rl], assumption) | |
| 4304 | apply (drule (1) tendsto_Pair) back | |
| 4305 | apply (simp add: o_def) | |
| 4306 | done | |
| 4307 | ||
| 4308 | text{* Hence some useful properties follow quite easily.                         *}
 | |
| 4309 | ||
| 4310 | lemma compact_scaling: | |
| 4311 | fixes s :: "'a::real_normed_vector set" | |
| 4312 | assumes "compact s" shows "compact ((\<lambda>x. c *\<^sub>R x) ` s)" | |
| 4313 | proof- | |
| 4314 | let ?f = "\<lambda>x. scaleR c x" | |
| 4315 | have *:"bounded_linear ?f" by (rule scaleR.bounded_linear_right) | |
| 4316 | show ?thesis using compact_continuous_image[of s ?f] continuous_at_imp_continuous_on[of s ?f] | |
| 4317 | using linear_continuous_at[OF *] assms by auto | |
| 4318 | qed | |
| 4319 | ||
| 4320 | lemma compact_negations: | |
| 4321 | fixes s :: "'a::real_normed_vector set" | |
| 4322 | assumes "compact s" shows "compact ((\<lambda>x. -x) ` s)" | |
| 4323 | using compact_scaling [OF assms, of "- 1"] by auto | |
| 4324 | ||
| 4325 | lemma compact_sums: | |
| 4326 | fixes s t :: "'a::real_normed_vector set" | |
| 4327 |   assumes "compact s"  "compact t"  shows "compact {x + y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4328 | proof- | |
| 4329 |   have *:"{x + y | x y. x \<in> s \<and> y \<in> t} = (\<lambda>z. fst z + snd z) ` (s \<times> t)"
 | |
| 4330 | apply auto unfolding image_iff apply(rule_tac x="(xa, y)" in bexI) by auto | |
| 4331 | have "continuous_on (s \<times> t) (\<lambda>z. fst z + snd z)" | |
| 4332 | unfolding continuous_on by (rule ballI) (intro tendsto_intros) | |
| 4333 | thus ?thesis unfolding * using compact_continuous_image compact_Times [OF assms] by auto | |
| 4334 | qed | |
| 4335 | ||
| 4336 | lemma compact_differences: | |
| 4337 | fixes s t :: "'a::real_normed_vector set" | |
| 4338 |   assumes "compact s" "compact t"  shows "compact {x - y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4339 | proof- | |
| 4340 |   have "{x - y | x y. x\<in>s \<and> y \<in> t} =  {x + y | x y. x \<in> s \<and> y \<in> (uminus ` t)}"
 | |
| 4341 | apply auto apply(rule_tac x= xa in exI) apply auto apply(rule_tac x=xa in exI) by auto | |
| 4342 | thus ?thesis using compact_sums[OF assms(1) compact_negations[OF assms(2)]] by auto | |
| 4343 | qed | |
| 4344 | ||
| 4345 | lemma compact_translation: | |
| 4346 | fixes s :: "'a::real_normed_vector set" | |
| 4347 | assumes "compact s" shows "compact ((\<lambda>x. a + x) ` s)" | |
| 4348 | proof- | |
| 4349 |   have "{x + y |x y. x \<in> s \<and> y \<in> {a}} = (\<lambda>x. a + x) ` s" by auto
 | |
| 4350 | thus ?thesis using compact_sums[OF assms compact_sing[of a]] by auto | |
| 4351 | qed | |
| 4352 | ||
| 4353 | lemma compact_affinity: | |
| 4354 | fixes s :: "'a::real_normed_vector set" | |
| 4355 | assumes "compact s" shows "compact ((\<lambda>x. a + c *\<^sub>R x) ` s)" | |
| 4356 | proof- | |
| 4357 | have "op + a ` op *\<^sub>R c ` s = (\<lambda>x. a + c *\<^sub>R x) ` s" by auto | |
| 4358 | thus ?thesis using compact_translation[OF compact_scaling[OF assms], of a c] by auto | |
| 4359 | qed | |
| 4360 | ||
| 4361 | text{* Hence we get the following.                                               *}
 | |
| 4362 | ||
| 4363 | lemma compact_sup_maxdistance: | |
| 4364 | fixes s :: "'a::real_normed_vector set" | |
| 4365 |   assumes "compact s"  "s \<noteq> {}"
 | |
| 4366 | shows "\<exists>x\<in>s. \<exists>y\<in>s. \<forall>u\<in>s. \<forall>v\<in>s. norm(u - v) \<le> norm(x - y)" | |
| 4367 | proof- | |
| 4368 |   have "{x - y | x y . x\<in>s \<and> y\<in>s} \<noteq> {}" using `s \<noteq> {}` by auto
 | |
| 4369 |   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"
 | |
| 4370 | using compact_differences[OF assms(1) assms(1)] | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4371 |     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
 | 
| 33175 | 4372 | from x(1) obtain a b where "a\<in>s" "b\<in>s" "x = a - b" by auto | 
| 4373 | thus ?thesis using x(2)[unfolded `x = a - b`] by blast | |
| 4374 | qed | |
| 4375 | ||
| 4376 | text{* We can state this in terms of diameter of a set.                          *}
 | |
| 4377 | ||
| 33270 | 4378 | definition "diameter s = (if s = {} then 0::real else Sup {norm(x - y) | x y. x \<in> s \<and> y \<in> s})"
 | 
| 33175 | 4379 | (* TODO: generalize to class metric_space *) | 
| 4380 | ||
| 4381 | lemma diameter_bounded: | |
| 4382 | assumes "bounded s" | |
| 4383 | shows "\<forall>x\<in>s. \<forall>y\<in>s. norm(x - y) \<le> diameter s" | |
| 4384 | "\<forall>d>0. d < diameter s --> (\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d)" | |
| 4385 | proof- | |
| 4386 |   let ?D = "{norm (x - y) |x y. x \<in> s \<and> y \<in> s}"
 | |
| 4387 | obtain a where a:"\<forall>x\<in>s. norm x \<le> a" using assms[unfolded bounded_iff] by auto | |
| 4388 |   { fix x y assume "x \<in> s" "y \<in> s"
 | |
| 36350 | 4389 | 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: field_simps) } | 
| 33175 | 4390 | note * = this | 
| 4391 |   { fix x y assume "x\<in>s" "y\<in>s"  hence "s \<noteq> {}" by auto
 | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4392 |     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`
 | 
| 33324 | 4393 | by simp (blast intro!: Sup_upper *) } | 
| 33175 | 4394 | moreover | 
| 4395 |   { fix d::real assume "d>0" "d < diameter s"
 | |
| 4396 |     hence "s\<noteq>{}" unfolding diameter_def by auto
 | |
| 4397 | have "\<exists>d' \<in> ?D. d' > d" | |
| 4398 | proof(rule ccontr) | |
| 4399 |       assume "\<not> (\<exists>d'\<in>{norm (x - y) |x y. x \<in> s \<and> y \<in> s}. d < d')"
 | |
| 33324 | 4400 | hence "\<forall>d'\<in>?D. d' \<le> d" by auto (metis not_leE) | 
| 4401 |       thus False using `d < diameter s` `s\<noteq>{}` 
 | |
| 4402 | apply (auto simp add: diameter_def) | |
| 4403 | apply (drule Sup_real_iff [THEN [2] rev_iffD2]) | |
| 4404 | apply (auto, force) | |
| 4405 | done | |
| 33175 | 4406 | qed | 
| 4407 | hence "\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d" by auto } | |
| 4408 | ultimately show "\<forall>x\<in>s. \<forall>y\<in>s. norm(x - y) \<le> diameter s" | |
| 4409 | "\<forall>d>0. d < diameter s --> (\<exists>x\<in>s. \<exists>y\<in>s. norm(x - y) > d)" by auto | |
| 4410 | qed | |
| 4411 | ||
| 4412 | lemma diameter_bounded_bound: | |
| 4413 | "bounded s \<Longrightarrow> x \<in> s \<Longrightarrow> y \<in> s ==> norm(x - y) \<le> diameter s" | |
| 4414 | using diameter_bounded by blast | |
| 4415 | ||
| 4416 | lemma diameter_compact_attained: | |
| 4417 | fixes s :: "'a::real_normed_vector set" | |
| 4418 |   assumes "compact s"  "s \<noteq> {}"
 | |
| 4419 | shows "\<exists>x\<in>s. \<exists>y\<in>s. (norm(x - y) = diameter s)" | |
| 4420 | proof- | |
| 4421 | have b:"bounded s" using assms(1) by (rule compact_imp_bounded) | |
| 4422 | 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 | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4423 | hence "diameter s \<le> norm (x - y)" | 
| 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4424 | unfolding diameter_def by clarsimp (rule Sup_least, fast+) | 
| 33324 | 4425 | thus ?thesis | 
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4426 | by (metis b diameter_bounded_bound order_antisym xys) | 
| 33175 | 4427 | qed | 
| 4428 | ||
| 4429 | text{* Related results with closure as the conclusion.                           *}
 | |
| 4430 | ||
| 4431 | lemma closed_scaling: | |
| 4432 | fixes s :: "'a::real_normed_vector set" | |
| 4433 | assumes "closed s" shows "closed ((\<lambda>x. c *\<^sub>R x) ` s)" | |
| 4434 | proof(cases "s={}")
 | |
| 4435 | case True thus ?thesis by auto | |
| 4436 | next | |
| 4437 | case False | |
| 4438 | show ?thesis | |
| 4439 | proof(cases "c=0") | |
| 4440 |     have *:"(\<lambda>x. 0) ` s = {0}" using `s\<noteq>{}` by auto
 | |
| 36668 
941ba2da372e
simplify definition of t1_space; generalize lemma closed_sing and related lemmas
 huffman parents: 
36667diff
changeset | 4441 | case True thus ?thesis apply auto unfolding * by auto | 
| 33175 | 4442 | next | 
| 4443 | case False | |
| 4444 |     { fix x l assume as:"\<forall>n::nat. x n \<in> scaleR c ` s"  "(x ---> l) sequentially"
 | |
| 4445 |       { fix n::nat have "scaleR (1 / c) (x n) \<in> s"
 | |
| 4446 | using as(1)[THEN spec[where x=n]] | |
| 4447 | using `c\<noteq>0` by (auto simp add: vector_smult_assoc) | |
| 4448 | } | |
| 4449 | moreover | |
| 4450 |       { fix e::real assume "e>0"
 | |
| 4451 | hence "0 < e *\<bar>c\<bar>" using `c\<noteq>0` mult_pos_pos[of e "abs c"] by auto | |
| 4452 | then obtain N where "\<forall>n\<ge>N. dist (x n) l < e * \<bar>c\<bar>" | |
| 4453 | using as(2)[unfolded Lim_sequentially, THEN spec[where x="e * abs c"]] by auto | |
| 4454 | hence "\<exists>N. \<forall>n\<ge>N. dist (scaleR (1 / c) (x n)) (scaleR (1 / c) l) < e" | |
| 4455 | unfolding dist_norm unfolding scaleR_right_diff_distrib[THEN sym] | |
| 4456 | using mult_imp_div_pos_less[of "abs c" _ e] `c\<noteq>0` by auto } | |
| 4457 | hence "((\<lambda>n. scaleR (1 / c) (x n)) ---> scaleR (1 / c) l) sequentially" unfolding Lim_sequentially by auto | |
| 4458 | ultimately have "l \<in> scaleR c ` s" | |
| 4459 | 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"]] | |
| 4460 | unfolding image_iff using `c\<noteq>0` apply(rule_tac x="scaleR (1 / c) l" in bexI) by auto } | |
| 4461 | thus ?thesis unfolding closed_sequential_limits by fast | |
| 4462 | qed | |
| 4463 | qed | |
| 4464 | ||
| 4465 | lemma closed_negations: | |
| 4466 | fixes s :: "'a::real_normed_vector set" | |
| 4467 | assumes "closed s" shows "closed ((\<lambda>x. -x) ` s)" | |
| 4468 | using closed_scaling[OF assms, of "- 1"] by simp | |
| 4469 | ||
| 4470 | lemma compact_closed_sums: | |
| 4471 | fixes s :: "'a::real_normed_vector set" | |
| 4472 |   assumes "compact s"  "closed t"  shows "closed {x + y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4473 | proof- | |
| 4474 |   let ?S = "{x + y |x y. x \<in> s \<and> y \<in> t}"
 | |
| 4475 |   { fix x l assume as:"\<forall>n. x n \<in> ?S"  "(x ---> l) sequentially"
 | |
| 4476 | 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" | |
| 4477 | using choice[of "\<lambda>n y. x n = (fst y) + (snd y) \<and> fst y \<in> s \<and> snd y \<in> t"] by auto | |
| 4478 | obtain l' r where "l'\<in>s" and r:"subseq r" and lr:"(((\<lambda>n. fst (f n)) \<circ> r) ---> l') sequentially" | |
| 4479 | using assms(1)[unfolded compact_def, THEN spec[where x="\<lambda> n. fst (f n)"]] using f(2) by auto | |
| 4480 | have "((\<lambda>n. snd (f (r n))) ---> l - l') sequentially" | |
| 4481 | using Lim_sub[OF lim_subseq[OF r as(2)] lr] and f(1) unfolding o_def by auto | |
| 4482 | hence "l - l' \<in> t" | |
| 4483 | using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda> n. snd (f (r n))"], THEN spec[where x="l - l'"]] | |
| 4484 | using f(3) by auto | |
| 4485 | 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 | |
| 4486 | } | |
| 4487 | thus ?thesis unfolding closed_sequential_limits by fast | |
| 4488 | qed | |
| 4489 | ||
| 4490 | lemma closed_compact_sums: | |
| 4491 | fixes s t :: "'a::real_normed_vector set" | |
| 4492 | assumes "closed s" "compact t" | |
| 4493 |   shows "closed {x + y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4494 | proof- | |
| 4495 |   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
 | |
| 4496 | apply(rule_tac x=y in exI) apply auto apply(rule_tac x=y in exI) by auto | |
| 4497 | thus ?thesis using compact_closed_sums[OF assms(2,1)] by simp | |
| 4498 | qed | |
| 4499 | ||
| 4500 | lemma compact_closed_differences: | |
| 4501 | fixes s t :: "'a::real_normed_vector set" | |
| 4502 | assumes "compact s" "closed t" | |
| 4503 |   shows "closed {x - y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4504 | proof- | |
| 4505 |   have "{x + y |x y. x \<in> s \<and> y \<in> uminus ` t} =  {x - y |x y. x \<in> s \<and> y \<in> t}"
 | |
| 4506 | apply auto apply(rule_tac x=xa in exI) apply auto apply(rule_tac x=xa in exI) by auto | |
| 4507 | thus ?thesis using compact_closed_sums[OF assms(1) closed_negations[OF assms(2)]] by auto | |
| 4508 | qed | |
| 4509 | ||
| 4510 | lemma closed_compact_differences: | |
| 4511 | fixes s t :: "'a::real_normed_vector set" | |
| 4512 | assumes "closed s" "compact t" | |
| 4513 |   shows "closed {x - y | x y. x \<in> s \<and> y \<in> t}"
 | |
| 4514 | proof- | |
| 4515 |   have "{x + y |x y. x \<in> s \<and> y \<in> uminus ` t} = {x - y |x y. x \<in> s \<and> y \<in> t}"
 | |
| 4516 | apply auto apply(rule_tac x=xa in exI) apply auto apply(rule_tac x=xa in exI) by auto | |
| 4517 | thus ?thesis using closed_compact_sums[OF assms(1) compact_negations[OF assms(2)]] by simp | |
| 4518 | qed | |
| 4519 | ||
| 4520 | lemma closed_translation: | |
| 4521 | fixes a :: "'a::real_normed_vector" | |
| 4522 | assumes "closed s" shows "closed ((\<lambda>x. a + x) ` s)" | |
| 4523 | proof- | |
| 4524 |   have "{a + y |y. y \<in> s} = (op + a ` s)" by auto
 | |
| 4525 | thus ?thesis using compact_closed_sums[OF compact_sing[of a] assms] by auto | |
| 4526 | qed | |
| 4527 | ||
| 34105 | 4528 | lemma translation_Compl: | 
| 4529 | fixes a :: "'a::ab_group_add" | |
| 4530 | shows "(\<lambda>x. a + x) ` (- t) = - ((\<lambda>x. a + x) ` t)" | |
| 4531 | apply (auto simp add: image_iff) apply(rule_tac x="x - a" in bexI) by auto | |
| 4532 | ||
| 33175 | 4533 | lemma translation_UNIV: | 
| 4534 | fixes a :: "'a::ab_group_add" shows "range (\<lambda>x. a + x) = UNIV" | |
| 4535 | apply (auto simp add: image_iff) apply(rule_tac x="x - a" in exI) by auto | |
| 4536 | ||
| 4537 | lemma translation_diff: | |
| 4538 | fixes a :: "'a::ab_group_add" | |
| 4539 | shows "(\<lambda>x. a + x) ` (s - t) = ((\<lambda>x. a + x) ` s) - ((\<lambda>x. a + x) ` t)" | |
| 4540 | by auto | |
| 4541 | ||
| 4542 | lemma closure_translation: | |
| 4543 | fixes a :: "'a::real_normed_vector" | |
| 4544 | shows "closure ((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (closure s)" | |
| 4545 | proof- | |
| 34105 | 4546 | have *:"op + a ` (- s) = - op + a ` s" | 
| 33175 | 4547 | apply auto unfolding image_iff apply(rule_tac x="x - a" in bexI) by auto | 
| 34105 | 4548 | show ?thesis unfolding closure_interior translation_Compl | 
| 4549 | using interior_translation[of a "- s"] unfolding * by auto | |
| 33175 | 4550 | qed | 
| 4551 | ||
| 4552 | lemma frontier_translation: | |
| 4553 | fixes a :: "'a::real_normed_vector" | |
| 4554 | shows "frontier((\<lambda>x. a + x) ` s) = (\<lambda>x. a + x) ` (frontier s)" | |
| 4555 | unfolding frontier_def translation_diff interior_translation closure_translation by auto | |
| 4556 | ||
| 4557 | subsection{* Separation between points and sets.                                       *}
 | |
| 4558 | ||
| 4559 | lemma separate_point_closed: | |
| 4560 | fixes s :: "'a::heine_borel set" | |
| 4561 | shows "closed s \<Longrightarrow> a \<notin> s ==> (\<exists>d>0. \<forall>x\<in>s. d \<le> dist a x)" | |
| 4562 | proof(cases "s = {}")
 | |
| 4563 | case True | |
| 4564 | thus ?thesis by(auto intro!: exI[where x=1]) | |
| 4565 | next | |
| 4566 | case False | |
| 4567 | assume "closed s" "a \<notin> s" | |
| 4568 |   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
 | |
| 4569 | with `x\<in>s` show ?thesis using dist_pos_lt[of a x] and`a \<notin> s` by blast | |
| 4570 | qed | |
| 4571 | ||
| 4572 | lemma separate_compact_closed: | |
| 4573 |   fixes s t :: "'a::{heine_borel, real_normed_vector} set"
 | |
| 4574 | (* TODO: does this generalize to heine_borel? *) | |
| 4575 |   assumes "compact s" and "closed t" and "s \<inter> t = {}"
 | |
| 4576 | shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" | |
| 4577 | proof- | |
| 4578 |   have "0 \<notin> {x - y |x y. x \<in> s \<and> y \<in> t}" using assms(3) by auto
 | |
| 4579 |   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"
 | |
| 4580 | using separate_point_closed[OF compact_closed_differences[OF assms(1,2)], of 0] by auto | |
| 4581 |   { fix x y assume "x\<in>s" "y\<in>t"
 | |
| 4582 |     hence "x - y \<in> {x - y |x y. x \<in> s \<and> y \<in> t}" by auto
 | |
| 4583 | hence "d \<le> dist (x - y) 0" using d[THEN bspec[where x="x - y"]] using dist_commute | |
| 4584 | by (auto simp add: dist_commute) | |
| 4585 | hence "d \<le> dist x y" unfolding dist_norm by auto } | |
| 4586 | thus ?thesis using `d>0` by auto | |
| 4587 | qed | |
| 4588 | ||
| 4589 | lemma separate_closed_compact: | |
| 4590 |   fixes s t :: "'a::{heine_borel, real_normed_vector} set"
 | |
| 4591 |   assumes "closed s" and "compact t" and "s \<inter> t = {}"
 | |
| 4592 | shows "\<exists>d>0. \<forall>x\<in>s. \<forall>y\<in>t. d \<le> dist x y" | |
| 4593 | proof- | |
| 4594 |   have *:"t \<inter> s = {}" using assms(3) by auto
 | |
| 4595 | show ?thesis using separate_compact_closed[OF assms(2,1) *] | |
| 4596 | apply auto apply(rule_tac x=d in exI) apply auto apply (erule_tac x=y in ballE) | |
| 4597 | by (auto simp add: dist_commute) | |
| 4598 | qed | |
| 4599 | ||
| 36439 | 4600 | subsection {* Intervals *}
 | 
| 33175 | 4601 | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4602 | lemma interval: fixes a :: "'a::ord^'n" shows | 
| 33175 | 4603 |   "{a <..< b} = {x::'a^'n. \<forall>i. a$i < x$i \<and> x$i < b$i}" and
 | 
| 4604 |   "{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 | 4605 | by (auto simp add: expand_set_eq vector_less_def vector_le_def) | 
| 33175 | 4606 | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4607 | lemma mem_interval: fixes a :: "'a::ord^'n" shows | 
| 33175 | 4608 |   "x \<in> {a<..<b} \<longleftrightarrow> (\<forall>i. a$i < x$i \<and> x$i < b$i)"
 | 
| 4609 |   "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 | 4610 | using interval[of a b] by(auto simp add: expand_set_eq vector_less_def vector_le_def) | 
| 33175 | 4611 | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4612 | lemma interval_eq_empty: fixes a :: "real^'n" shows | 
| 33175 | 4613 |  "({a <..< b} = {} \<longleftrightarrow> (\<exists>i. b$i \<le> a$i))" (is ?th1) and
 | 
| 4614 |  "({a  ..  b} = {} \<longleftrightarrow> (\<exists>i. b$i < a$i))" (is ?th2)
 | |
| 4615 | proof- | |
| 4616 |   { fix i x assume as:"b$i \<le> a$i" and x:"x\<in>{a <..< b}"
 | |
| 4617 | hence "a $ i < x $ i \<and> x $ i < b $ i" unfolding mem_interval by auto | |
| 4618 | hence "a$i < b$i" by auto | |
| 4619 | hence False using as by auto } | |
| 4620 | moreover | |
| 4621 |   { assume as:"\<forall>i. \<not> (b$i \<le> a$i)"
 | |
| 4622 | let ?x = "(1/2) *\<^sub>R (a + b)" | |
| 4623 |     { fix i
 | |
| 4624 | have "a$i < b$i" using as[THEN spec[where x=i]] by auto | |
| 4625 | hence "a$i < ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i < b$i" | |
| 4626 | unfolding vector_smult_component and vector_add_component | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4627 | by auto } | 
| 33175 | 4628 |     hence "{a <..< b} \<noteq> {}" using mem_interval(1)[of "?x" a b] by auto  }
 | 
| 4629 | ultimately show ?th1 by blast | |
| 4630 | ||
| 4631 |   { fix i x assume as:"b$i < a$i" and x:"x\<in>{a .. b}"
 | |
| 4632 | hence "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" unfolding mem_interval by auto | |
| 4633 | hence "a$i \<le> b$i" by auto | |
| 4634 | hence False using as by auto } | |
| 4635 | moreover | |
| 4636 |   { assume as:"\<forall>i. \<not> (b$i < a$i)"
 | |
| 4637 | let ?x = "(1/2) *\<^sub>R (a + b)" | |
| 4638 |     { fix i
 | |
| 4639 | have "a$i \<le> b$i" using as[THEN spec[where x=i]] by auto | |
| 4640 | hence "a$i \<le> ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i \<le> b$i" | |
| 4641 | unfolding vector_smult_component and vector_add_component | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4642 | by auto } | 
| 33175 | 4643 |     hence "{a .. b} \<noteq> {}" using mem_interval(2)[of "?x" a b] by auto  }
 | 
| 4644 | ultimately show ?th2 by blast | |
| 4645 | qed | |
| 4646 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4647 | lemma interval_ne_empty: fixes a :: "real^'n" shows | 
| 33175 | 4648 |   "{a  ..  b} \<noteq> {} \<longleftrightarrow> (\<forall>i. a$i \<le> b$i)" and
 | 
| 4649 |   "{a <..< b} \<noteq> {} \<longleftrightarrow> (\<forall>i. a$i < b$i)"
 | |
| 4650 | unfolding interval_eq_empty[of a b] by (auto simp add: not_less not_le) (* BH: Why doesn't just "auto" work here? *) | |
| 4651 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4652 | lemma subset_interval_imp: fixes a :: "real^'n" shows | 
| 33175 | 4653 |  "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> {c .. d} \<subseteq> {a .. b}" and
 | 
| 4654 |  "(\<forall>i. a$i < c$i \<and> d$i < b$i) \<Longrightarrow> {c .. d} \<subseteq> {a<..<b}" and
 | |
| 4655 |  "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> {c<..<d} \<subseteq> {a .. b}" and
 | |
| 4656 |  "(\<forall>i. a$i \<le> c$i \<and> d$i \<le> b$i) \<Longrightarrow> {c<..<d} \<subseteq> {a<..<b}"
 | |
| 4657 | unfolding subset_eq[unfolded Ball_def] unfolding mem_interval | |
| 4658 | by (auto intro: order_trans less_le_trans le_less_trans less_imp_le) (* BH: Why doesn't just "auto" work here? *) | |
| 4659 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4660 | lemma interval_sing: fixes a :: "'a::linorder^'n" shows | 
| 33175 | 4661 |  "{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 | 4662 | apply(auto simp add: expand_set_eq vector_less_def vector_le_def Cart_eq) | 
| 33175 | 4663 | apply (simp add: order_eq_iff) | 
| 4664 | apply (auto simp add: not_less less_imp_le) | |
| 4665 | done | |
| 4666 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4667 | lemma interval_open_subset_closed: fixes a :: "'a::preorder^'n" shows | 
| 33175 | 4668 |  "{a<..<b} \<subseteq> {a .. b}"
 | 
| 4669 | proof(simp add: subset_eq, rule) | |
| 4670 | fix x | |
| 4671 |   assume x:"x \<in>{a<..<b}"
 | |
| 4672 |   { fix i
 | |
| 4673 | have "a $ i \<le> x $ i" | |
| 4674 | 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 | 4675 | by(simp add: expand_set_eq vector_less_def vector_le_def Cart_eq) | 
| 33175 | 4676 | } | 
| 4677 | moreover | |
| 4678 |   { fix i
 | |
| 4679 | have "x $ i \<le> b $ i" | |
| 4680 | 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 | 4681 | by(simp add: expand_set_eq vector_less_def vector_le_def Cart_eq) | 
| 33175 | 4682 | } | 
| 4683 | ultimately | |
| 4684 | 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 | 4685 | by(simp add: expand_set_eq vector_less_def vector_le_def Cart_eq) | 
| 33175 | 4686 | qed | 
| 4687 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4688 | lemma subset_interval: fixes a :: "real^'n" shows | 
| 33175 | 4689 |  "{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
 | 
| 4690 |  "{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
 | |
| 4691 |  "{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
 | |
| 4692 |  "{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)
 | |
| 4693 | proof- | |
| 4694 | show ?th1 unfolding subset_eq and Ball_def and mem_interval by (auto intro: order_trans) | |
| 4695 | 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) | |
| 4696 |   { assume as: "{c<..<d} \<subseteq> {a .. b}" "\<forall>i. c$i < d$i"
 | |
| 4697 |     hence "{c<..<d} \<noteq> {}" unfolding interval_eq_empty by (auto, drule_tac x=i in spec, simp) (* BH: Why doesn't just "auto" work? *)
 | |
| 4698 | fix i | |
| 4699 | (** TODO combine the following two parts as done in the HOL_light version. **) | |
| 4700 |     { let ?x = "(\<chi> j. (if j=i then ((min (a$j) (d$j))+c$j)/2 else (c$j+d$j)/2))::real^'n"
 | |
| 4701 | assume as2: "a$i > c$i" | |
| 4702 |       { fix j
 | |
| 4703 | have "c $ j < ?x $ j \<and> ?x $ j < d $ j" unfolding Cart_lambda_beta | |
| 4704 | apply(cases "j=i") using as(2)[THEN spec[where x=j]] | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4705 | by (auto simp add: as2) } | 
| 33175 | 4706 |       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
 | 
| 4707 | moreover | |
| 4708 |       have "?x\<notin>{a .. b}"
 | |
| 4709 | unfolding mem_interval apply auto apply(rule_tac x=i in exI) | |
| 4710 | using as(2)[THEN spec[where x=i]] and as2 | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4711 | by auto | 
| 33175 | 4712 | ultimately have False using as by auto } | 
| 4713 | hence "a$i \<le> c$i" by(rule ccontr)auto | |
| 4714 | moreover | |
| 4715 |     { let ?x = "(\<chi> j. (if j=i then ((max (b$j) (c$j))+d$j)/2 else (c$j+d$j)/2))::real^'n"
 | |
| 4716 | assume as2: "b$i < d$i" | |
| 4717 |       { fix j
 | |
| 4718 | have "d $ j > ?x $ j \<and> ?x $ j > c $ j" unfolding Cart_lambda_beta | |
| 4719 | apply(cases "j=i") using as(2)[THEN spec[where x=j]] | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4720 | by (auto simp add: as2) } | 
| 33175 | 4721 |       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
 | 
| 4722 | moreover | |
| 4723 |       have "?x\<notin>{a .. b}"
 | |
| 4724 | unfolding mem_interval apply auto apply(rule_tac x=i in exI) | |
| 4725 | using as(2)[THEN spec[where x=i]] and as2 | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4726 | by auto | 
| 33175 | 4727 | ultimately have False using as by auto } | 
| 4728 | hence "b$i \<ge> d$i" by(rule ccontr)auto | |
| 4729 | ultimately | |
| 4730 | have "a$i \<le> c$i \<and> d$i \<le> b$i" by auto | |
| 4731 | } note part1 = this | |
| 4732 | 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)+ | |
| 4733 |   { assume as:"{c<..<d} \<subseteq> {a<..<b}" "\<forall>i. c$i < d$i"
 | |
| 4734 | fix i | |
| 4735 |     from as(1) have "{c<..<d} \<subseteq> {a..b}" using interval_open_subset_closed[of a b] by auto
 | |
| 4736 | hence "a$i \<le> c$i \<and> d$i \<le> b$i" using part1 and as(2) by auto } note * = this | |
| 4737 | 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)+ | |
| 4738 | qed | |
| 4739 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4740 | lemma disjoint_interval: fixes a::"real^'n" shows | 
| 33175 | 4741 |   "{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
 | 
| 4742 |   "{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
 | |
| 4743 |   "{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
 | |
| 4744 |   "{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)
 | |
| 4745 | proof- | |
| 4746 | let ?z = "(\<chi> i. ((max (a$i) (c$i)) + (min (b$i) (d$i))) / 2)::real^'n" | |
| 4747 | show ?th1 ?th2 ?th3 ?th4 | |
| 4748 | unfolding expand_set_eq and Int_iff and empty_iff and mem_interval and all_conj_distrib[THEN sym] and eq_False | |
| 4749 | apply (auto elim!: allE[where x="?z"]) | |
| 4750 | apply ((rule_tac x=x in exI, force) | (rule_tac x=i in exI, force))+ | |
| 4751 | done | |
| 4752 | qed | |
| 4753 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4754 | lemma inter_interval: fixes a :: "'a::linorder^'n" shows | 
| 33175 | 4755 |  "{a .. b} \<inter> {c .. d} =  {(\<chi> i. max (a$i) (c$i)) .. (\<chi> i. min (b$i) (d$i))}"
 | 
| 4756 | unfolding expand_set_eq and Int_iff and mem_interval | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4757 | by auto | 
| 33175 | 4758 | |
| 4759 | (* Moved interval_open_subset_closed a bit upwards *) | |
| 4760 | ||
| 4761 | lemma open_interval_lemma: fixes x :: "real" shows | |
| 4762 | "a < x \<Longrightarrow> x < b ==> (\<exists>d>0. \<forall>x'. abs(x' - x) < d --> a < x' \<and> x' < b)" | |
| 4763 | by(rule_tac x="min (x - a) (b - x)" in exI, auto) | |
| 4764 | ||
| 34964 | 4765 | lemma open_interval[intro]: fixes a :: "real^'n" shows "open {a<..<b}"
 | 
| 33175 | 4766 | proof- | 
| 4767 |   { fix x assume x:"x\<in>{a<..<b}"
 | |
| 4768 |     { fix i
 | |
| 4769 | have "\<exists>d>0. \<forall>x'. abs (x' - (x$i)) < d \<longrightarrow> a$i < x' \<and> x' < b$i" | |
| 4770 | using x[unfolded mem_interval, THEN spec[where x=i]] | |
| 4771 | using open_interval_lemma[of "a$i" "x$i" "b$i"] by auto } | |
| 4772 | ||
| 4773 | hence "\<forall>i. \<exists>d>0. \<forall>x'. abs (x' - (x$i)) < d \<longrightarrow> a$i < x' \<and> x' < b$i" by auto | |
| 4774 | 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)" | |
| 4775 | 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 | |
| 4776 | ||
| 4777 | let ?d = "Min (range d)" | |
| 4778 |     have **:"finite (range d)" "range d \<noteq> {}" by auto
 | |
| 4779 | have "?d>0" unfolding Min_gr_iff[OF **] using d by auto | |
| 4780 | moreover | |
| 4781 |     { fix x' assume as:"dist x' x < ?d"
 | |
| 4782 |       { fix i
 | |
| 4783 | have "\<bar>x'$i - x $ i\<bar> < d i" | |
| 4784 | using norm_bound_component_lt[OF as[unfolded dist_norm], of i] | |
| 4785 | unfolding vector_minus_component and Min_gr_iff[OF **] by auto | |
| 4786 | hence "a $ i < x' $ i" "x' $ i < b $ i" using d[THEN spec[where x=i]] by auto } | |
| 4787 | hence "a < x' \<and> x' < b" unfolding vector_less_def by auto } | |
| 4788 |     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)
 | |
| 4789 | } | |
| 4790 | thus ?thesis unfolding open_dist using open_interval_lemma by auto | |
| 4791 | qed | |
| 4792 | ||
| 34964 | 4793 | lemma open_interval_real[intro]: fixes a :: "real" shows "open {a<..<b}"
 | 
| 36431 
340755027840
move definitions and theorems for type real^1 to separate theory file
 huffman parents: 
36365diff
changeset | 4794 | by (rule open_real_greaterThanLessThan) | 
| 33714 
eb2574ac4173
Added new lemmas to Euclidean Space by Robert Himmelmann
 hoelzl parents: 
33324diff
changeset | 4795 | |
| 34964 | 4796 | lemma closed_interval[intro]: fixes a :: "real^'n" shows "closed {a .. b}"
 | 
| 33175 | 4797 | proof- | 
| 4798 |   { 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"*)
 | |
| 4799 |     { assume xa:"a$i > x$i"
 | |
| 4800 |       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
 | |
| 4801 | hence False unfolding mem_interval and dist_norm | |
| 4802 | using component_le_norm[of "y-x" i, unfolded vector_minus_component] and xa by(auto elim!: allE[where x=i]) | |
| 4803 | } hence "a$i \<le> x$i" by(rule ccontr)auto | |
| 4804 | moreover | |
| 4805 |     { assume xb:"b$i < x$i"
 | |
| 4806 |       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
 | |
| 4807 | hence False unfolding mem_interval and dist_norm | |
| 4808 | using component_le_norm[of "y-x" i, unfolded vector_minus_component] and xb by(auto elim!: allE[where x=i]) | |
| 4809 | } hence "x$i \<le> b$i" by(rule ccontr)auto | |
| 4810 | ultimately | |
| 4811 | have "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" by auto } | |
| 4812 | thus ?thesis unfolding closed_limpt islimpt_approachable mem_interval by auto | |
| 4813 | qed | |
| 4814 | ||
| 34964 | 4815 | lemma interior_closed_interval[intro]: fixes a :: "real^'n" shows | 
| 33175 | 4816 |  "interior {a .. b} = {a<..<b}" (is "?L = ?R")
 | 
| 4817 | proof(rule subset_antisym) | |
| 4818 | show "?R \<subseteq> ?L" using interior_maximal[OF interval_open_subset_closed open_interval] by auto | |
| 4819 | next | |
| 4820 |   { fix x assume "\<exists>T. open T \<and> x \<in> T \<and> T \<subseteq> {a..b}"
 | |
| 4821 |     then obtain s where s:"open s" "x \<in> s" "s \<subseteq> {a..b}" by auto
 | |
| 4822 |     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
 | |
| 4823 |     { fix i
 | |
| 4824 | have "dist (x - (e / 2) *\<^sub>R basis i) x < e" | |
| 4825 | "dist (x + (e / 2) *\<^sub>R basis i) x < e" | |
| 4826 | unfolding dist_norm apply auto | |
| 4827 | unfolding norm_minus_cancel using norm_basis[of i] and `e>0` by auto | |
| 4828 | hence "a $ i \<le> (x - (e / 2) *\<^sub>R basis i) $ i" | |
| 4829 | "(x + (e / 2) *\<^sub>R basis i) $ i \<le> b $ i" | |
| 4830 | using e[THEN spec[where x="x - (e/2) *\<^sub>R basis i"]] | |
| 4831 | and e[THEN spec[where x="x + (e/2) *\<^sub>R basis i"]] | |
| 4832 | unfolding mem_interval by (auto elim!: allE[where x=i]) | |
| 4833 | hence "a $ i < x $ i" and "x $ i < b $ i" | |
| 4834 | unfolding vector_minus_component and vector_add_component | |
| 4835 | unfolding vector_smult_component and basis_component using `e>0` by auto } | |
| 4836 |     hence "x \<in> {a<..<b}" unfolding mem_interval by auto  }
 | |
| 4837 | thus "?L \<subseteq> ?R" unfolding interior_def and subset_eq by auto | |
| 4838 | qed | |
| 4839 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4840 | lemma bounded_closed_interval: fixes a :: "real^'n" shows | 
| 33175 | 4841 |  "bounded {a .. b}"
 | 
| 4842 | proof- | |
| 4843 | let ?b = "\<Sum>i\<in>UNIV. \<bar>a$i\<bar> + \<bar>b$i\<bar>" | |
| 4844 |   { fix x::"real^'n" assume x:"\<forall>i. a $ i \<le> x $ i \<and> x $ i \<le> b $ i"
 | |
| 4845 |     { fix i
 | |
| 4846 | have "\<bar>x$i\<bar> \<le> \<bar>a$i\<bar> + \<bar>b$i\<bar>" using x[THEN spec[where x=i]] by auto } | |
| 4847 | hence "(\<Sum>i\<in>UNIV. \<bar>x $ i\<bar>) \<le> ?b" by(rule setsum_mono) | |
| 4848 | hence "norm x \<le> ?b" using norm_le_l1[of x] by auto } | |
| 4849 | thus ?thesis unfolding interval and bounded_iff by auto | |
| 4850 | qed | |
| 4851 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4852 | lemma bounded_interval: fixes a :: "real^'n" shows | 
| 33175 | 4853 |  "bounded {a .. b} \<and> bounded {a<..<b}"
 | 
| 4854 | using bounded_closed_interval[of a b] | |
| 4855 | using interval_open_subset_closed[of a b] | |
| 4856 |   using bounded_subset[of "{a..b}" "{a<..<b}"]
 | |
| 4857 | by simp | |
| 4858 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4859 | lemma not_interval_univ: fixes a :: "real^'n" shows | 
| 33175 | 4860 |  "({a .. b} \<noteq> UNIV) \<and> ({a<..<b} \<noteq> UNIV)"
 | 
| 4861 | using bounded_interval[of a b] | |
| 4862 | by auto | |
| 4863 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4864 | lemma compact_interval: fixes a :: "real^'n" shows | 
| 33175 | 4865 |  "compact {a .. b}"
 | 
| 4866 | using bounded_closed_imp_compact using bounded_interval[of a b] using closed_interval[of a b] by auto | |
| 4867 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4868 | lemma open_interval_midpoint: fixes a :: "real^'n" | 
| 33175 | 4869 |   assumes "{a<..<b} \<noteq> {}" shows "((1/2) *\<^sub>R (a + b)) \<in> {a<..<b}"
 | 
| 4870 | proof- | |
| 4871 |   { fix i
 | |
| 4872 | have "a $ i < ((1 / 2) *\<^sub>R (a + b)) $ i \<and> ((1 / 2) *\<^sub>R (a + b)) $ i < b $ i" | |
| 4873 | using assms[unfolded interval_ne_empty, THEN spec[where x=i]] | |
| 4874 | unfolding vector_smult_component and vector_add_component | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4875 | by auto } | 
| 33175 | 4876 | thus ?thesis unfolding mem_interval by auto | 
| 4877 | qed | |
| 4878 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4879 | lemma open_closed_interval_convex: fixes x :: "real^'n" | 
| 33175 | 4880 |   assumes x:"x \<in> {a<..<b}" and y:"y \<in> {a .. b}" and e:"0 < e" "e \<le> 1"
 | 
| 4881 |   shows "(e *\<^sub>R x + (1 - e) *\<^sub>R y) \<in> {a<..<b}"
 | |
| 4882 | proof- | |
| 4883 |   { fix i
 | |
| 4884 | have "a $ i = e * a$i + (1 - e) * a$i" unfolding left_diff_distrib by simp | |
| 4885 | also have "\<dots> < e * x $ i + (1 - e) * y $ i" apply(rule add_less_le_mono) | |
| 4886 | using e unfolding mult_less_cancel_left and mult_le_cancel_left apply simp_all | |
| 4887 | using x unfolding mem_interval apply simp | |
| 4888 | using y unfolding mem_interval apply simp | |
| 4889 | done | |
| 4890 | finally have "a $ i < (e *\<^sub>R x + (1 - e) *\<^sub>R y) $ i" by auto | |
| 4891 |     moreover {
 | |
| 4892 | have "b $ i = e * b$i + (1 - e) * b$i" unfolding left_diff_distrib by simp | |
| 4893 | also have "\<dots> > e * x $ i + (1 - e) * y $ i" apply(rule add_less_le_mono) | |
| 4894 | using e unfolding mult_less_cancel_left and mult_le_cancel_left apply simp_all | |
| 4895 | using x unfolding mem_interval apply simp | |
| 4896 | using y unfolding mem_interval apply simp | |
| 4897 | done | |
| 4898 | finally have "(e *\<^sub>R x + (1 - e) *\<^sub>R y) $ i < b $ i" by auto | |
| 4899 | } 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 } | |
| 4900 | thus ?thesis unfolding mem_interval by auto | |
| 4901 | qed | |
| 4902 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4903 | lemma closure_open_interval: fixes a :: "real^'n" | 
| 33175 | 4904 |   assumes "{a<..<b} \<noteq> {}"
 | 
| 4905 |   shows "closure {a<..<b} = {a .. b}"
 | |
| 4906 | proof- | |
| 4907 | have ab:"a < b" using assms[unfolded interval_ne_empty] unfolding vector_less_def by auto | |
| 4908 | let ?c = "(1 / 2) *\<^sub>R (a + b)" | |
| 4909 |   { fix x assume as:"x \<in> {a .. b}"
 | |
| 4910 | def f == "\<lambda>n::nat. x + (inverse (real n + 1)) *\<^sub>R (?c - x)" | |
| 4911 |     { fix n assume fn:"f n < b \<longrightarrow> a < f n \<longrightarrow> f n = x" and xc:"x \<noteq> ?c"
 | |
| 4912 | have *:"0 < inverse (real n + 1)" "inverse (real n + 1) \<le> 1" unfolding inverse_le_1_iff by auto | |
| 4913 | have "(inverse (real n + 1)) *\<^sub>R ((1 / 2) *\<^sub>R (a + b)) + (1 - inverse (real n + 1)) *\<^sub>R x = | |
| 4914 | x + (inverse (real n + 1)) *\<^sub>R (((1 / 2) *\<^sub>R (a + b)) - x)" | |
| 4915 | by (auto simp add: algebra_simps) | |
| 4916 | 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 | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 4917 | hence False using fn unfolding f_def using xc by(auto simp add: vector_ssub_ldistrib) } | 
| 33175 | 4918 | moreover | 
| 4919 |     { assume "\<not> (f ---> x) sequentially"
 | |
| 4920 |       { fix e::real assume "e>0"
 | |
| 4921 | 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 | |
| 4922 | then obtain N::nat where "inverse (real (N + 1)) < e" by auto | |
| 4923 | 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) | |
| 4924 | hence "\<exists>N::nat. \<forall>n\<ge>N. inverse (real n + 1) < e" by auto } | |
| 4925 | hence "((\<lambda>n. inverse (real n + 1)) ---> 0) sequentially" | |
| 4926 | unfolding Lim_sequentially by(auto simp add: dist_norm) | |
| 4927 | hence "(f ---> x) sequentially" unfolding f_def | |
| 4928 | 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] | |
| 4929 | using Lim_vmul[of "\<lambda>n::nat. inverse (real n + 1)" 0 sequentially "((1 / 2) *\<^sub>R (a + b) - x)"] by auto } | |
| 4930 |     ultimately have "x \<in> closure {a<..<b}"
 | |
| 4931 | using as and open_interval_midpoint[OF assms] unfolding closure_def unfolding islimpt_sequential by(cases "x=?c")auto } | |
| 4932 | thus ?thesis using closure_minimal[OF interval_open_subset_closed closed_interval, of a b] by blast | |
| 4933 | qed | |
| 4934 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4935 | lemma bounded_subset_open_interval_symmetric: fixes s::"(real^'n) set" | 
| 33175 | 4936 |   assumes "bounded s"  shows "\<exists>a. s \<subseteq> {-a<..<a}"
 | 
| 4937 | proof- | |
| 4938 | obtain b where "b>0" and b:"\<forall>x\<in>s. norm x \<le> b" using assms[unfolded bounded_pos] by auto | |
| 4939 | def a \<equiv> "(\<chi> i. b+1)::real^'n" | |
| 4940 |   { fix x assume "x\<in>s"
 | |
| 4941 | fix i | |
| 4942 | 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] | |
| 4943 | unfolding vector_uminus_component and a_def and Cart_lambda_beta by auto | |
| 4944 | } | |
| 4945 | thus ?thesis by(auto intro: exI[where x=a] simp add: vector_less_def) | |
| 4946 | qed | |
| 4947 | ||
| 4948 | lemma bounded_subset_open_interval: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4949 | fixes s :: "(real ^ 'n) set" | 
| 33175 | 4950 |   shows "bounded s ==> (\<exists>a b. s \<subseteq> {a<..<b})"
 | 
| 4951 | by (auto dest!: bounded_subset_open_interval_symmetric) | |
| 4952 | ||
| 4953 | lemma bounded_subset_closed_interval_symmetric: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4954 | fixes s :: "(real ^ 'n) set" | 
| 33175 | 4955 |   assumes "bounded s" shows "\<exists>a. s \<subseteq> {-a .. a}"
 | 
| 4956 | proof- | |
| 4957 |   obtain a where "s \<subseteq> {- a<..<a}" using bounded_subset_open_interval_symmetric[OF assms] by auto
 | |
| 4958 | thus ?thesis using interval_open_subset_closed[of "-a" a] by auto | |
| 4959 | qed | |
| 4960 | ||
| 4961 | lemma bounded_subset_closed_interval: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4962 | fixes s :: "(real ^ 'n) set" | 
| 33175 | 4963 |   shows "bounded s ==> (\<exists>a b. s \<subseteq> {a .. b})"
 | 
| 4964 | using bounded_subset_closed_interval_symmetric[of s] by auto | |
| 4965 | ||
| 4966 | lemma frontier_closed_interval: | |
| 4967 | fixes a b :: "real ^ _" | |
| 4968 |   shows "frontier {a .. b} = {a .. b} - {a<..<b}"
 | |
| 4969 | unfolding frontier_def unfolding interior_closed_interval and closure_closed[OF closed_interval] .. | |
| 4970 | ||
| 4971 | lemma frontier_open_interval: | |
| 4972 | fixes a b :: "real ^ _" | |
| 4973 |   shows "frontier {a<..<b} = (if {a<..<b} = {} then {} else {a .. b} - {a<..<b})"
 | |
| 4974 | proof(cases "{a<..<b} = {}")
 | |
| 4975 | case True thus ?thesis using frontier_empty by auto | |
| 4976 | next | |
| 4977 | case False thus ?thesis unfolding frontier_def and closure_open_interval[OF False] and interior_open[OF open_interval] by auto | |
| 4978 | qed | |
| 4979 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4980 | lemma inter_interval_mixed_eq_empty: fixes a :: "real^'n" | 
| 33175 | 4981 |   assumes "{c<..<d} \<noteq> {}"  shows "{a<..<b} \<inter> {c .. d} = {} \<longleftrightarrow> {a<..<b} \<inter> {c<..<d} = {}"
 | 
| 4982 | unfolding closure_open_interval[OF assms, THEN sym] unfolding open_inter_closure_eq_empty[OF open_interval] .. | |
| 4983 | ||
| 4984 | ||
| 4985 | (* Some stuff for half-infinite intervals too; FIXME: notation? *) | |
| 4986 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4987 | lemma closed_interval_left: fixes b::"real^'n" | 
| 33175 | 4988 |   shows "closed {x::real^'n. \<forall>i. x$i \<le> b$i}"
 | 
| 4989 | proof- | |
| 4990 |   { fix i
 | |
| 4991 |     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"
 | |
| 4992 |     { assume "x$i > b$i"
 | |
| 4993 | 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 | |
| 4994 | hence False using component_le_norm[of "y - x" i] unfolding dist_norm and vector_minus_component by auto } | |
| 4995 | hence "x$i \<le> b$i" by(rule ccontr)auto } | |
| 4996 | thus ?thesis unfolding closed_limpt unfolding islimpt_approachable by blast | |
| 4997 | qed | |
| 4998 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 4999 | lemma closed_interval_right: fixes a::"real^'n" | 
| 33175 | 5000 |   shows "closed {x::real^'n. \<forall>i. a$i \<le> x$i}"
 | 
| 5001 | proof- | |
| 5002 |   { fix i
 | |
| 5003 |     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"
 | |
| 5004 |     { assume "a$i > x$i"
 | |
| 5005 | 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 | |
| 5006 | hence False using component_le_norm[of "y - x" i] unfolding dist_norm and vector_minus_component by auto } | |
| 5007 | hence "a$i \<le> x$i" by(rule ccontr)auto } | |
| 5008 | thus ?thesis unfolding closed_limpt unfolding islimpt_approachable by blast | |
| 5009 | qed | |
| 5010 | ||
| 36439 | 5011 | text {* Intervals in general, including infinite and mixtures of open and closed. *}
 | 
| 33175 | 5012 | |
| 5013 | 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)" | |
| 5014 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5015 | lemma is_interval_interval: "is_interval {a .. b::real^'n}" (is ?th1) "is_interval {a<..<b}" (is ?th2) proof - 
 | 
| 33175 | 5016 | have *:"\<And>x y z::real. x < y \<Longrightarrow> y < z \<Longrightarrow> x < z" by auto | 
| 5017 | show ?th1 ?th2 unfolding is_interval_def mem_interval Ball_def atLeastAtMost_iff | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5018 | by(meson order_trans le_less_trans less_le_trans *)+ qed | 
| 33175 | 5019 | |
| 5020 | lemma is_interval_empty: | |
| 5021 |  "is_interval {}"
 | |
| 5022 | unfolding is_interval_def | |
| 5023 | by simp | |
| 5024 | ||
| 5025 | lemma is_interval_univ: | |
| 5026 | "is_interval UNIV" | |
| 5027 | unfolding is_interval_def | |
| 5028 | by simp | |
| 5029 | ||
| 5030 | subsection{* Closure of halfspaces and hyperplanes.                                    *}
 | |
| 5031 | ||
| 5032 | lemma Lim_inner: | |
| 5033 | assumes "(f ---> l) net" shows "((\<lambda>y. inner a (f y)) ---> inner a l) net" | |
| 5034 | by (intro tendsto_intros assms) | |
| 5035 | ||
| 5036 | lemma continuous_at_inner: "continuous (at x) (inner a)" | |
| 5037 | unfolding continuous_at by (intro tendsto_intros) | |
| 5038 | ||
| 5039 | lemma continuous_on_inner: | |
| 5040 | fixes s :: "'a::real_inner set" | |
| 5041 | shows "continuous_on s (inner a)" | |
| 5042 | unfolding continuous_on by (rule ballI) (intro tendsto_intros) | |
| 5043 | ||
| 5044 | lemma closed_halfspace_le: "closed {x. inner a x \<le> b}"
 | |
| 5045 | proof- | |
| 5046 | have "\<forall>x. continuous (at x) (inner a)" | |
| 5047 | unfolding continuous_at by (rule allI) (intro tendsto_intros) | |
| 5048 |   hence "closed (inner a -` {..b})"
 | |
| 5049 | using closed_real_atMost by (rule continuous_closed_vimage) | |
| 5050 |   moreover have "{x. inner a x \<le> b} = inner a -` {..b}" by auto
 | |
| 5051 | ultimately show ?thesis by simp | |
| 5052 | qed | |
| 5053 | ||
| 5054 | lemma closed_halfspace_ge: "closed {x. inner a x \<ge> b}"
 | |
| 5055 | using closed_halfspace_le[of "-a" "-b"] unfolding inner_minus_left by auto | |
| 5056 | ||
| 5057 | lemma closed_hyperplane: "closed {x. inner a x = b}"
 | |
| 5058 | proof- | |
| 5059 |   have "{x. inner a x = b} = {x. inner a x \<ge> b} \<inter> {x. inner a x \<le> b}" by auto
 | |
| 5060 | thus ?thesis using closed_halfspace_le[of a b] and closed_halfspace_ge[of b a] using closed_Int by auto | |
| 5061 | qed | |
| 5062 | ||
| 5063 | lemma closed_halfspace_component_le: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5064 |   shows "closed {x::real^'n. x$i \<le> a}"
 | 
| 33175 | 5065 | using closed_halfspace_le[of "(basis i)::real^'n" a] unfolding inner_basis[OF assms] by auto | 
| 5066 | ||
| 5067 | lemma closed_halfspace_component_ge: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5068 |   shows "closed {x::real^'n. x$i \<ge> a}"
 | 
| 33175 | 5069 | using closed_halfspace_ge[of a "(basis i)::real^'n"] unfolding inner_basis[OF assms] by auto | 
| 5070 | ||
| 5071 | text{* Openness of halfspaces.                                                   *}
 | |
| 5072 | ||
| 5073 | lemma open_halfspace_lt: "open {x. inner a x < b}"
 | |
| 5074 | proof- | |
| 34105 | 5075 |   have "- {x. b \<le> inner a x} = {x. inner a x < b}" by auto
 | 
| 5076 | thus ?thesis using closed_halfspace_ge[unfolded closed_def, of b a] by auto | |
| 33175 | 5077 | qed | 
| 5078 | ||
| 5079 | lemma open_halfspace_gt: "open {x. inner a x > b}"
 | |
| 5080 | proof- | |
| 34105 | 5081 |   have "- {x. b \<ge> inner a x} = {x. inner a x > b}" by auto
 | 
| 5082 | thus ?thesis using closed_halfspace_le[unfolded closed_def, of a b] by auto | |
| 33175 | 5083 | qed | 
| 5084 | ||
| 5085 | lemma open_halfspace_component_lt: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5086 |   shows "open {x::real^'n. x$i < a}"
 | 
| 33175 | 5087 | using open_halfspace_lt[of "(basis i)::real^'n" a] unfolding inner_basis[OF assms] by auto | 
| 5088 | ||
| 5089 | lemma open_halfspace_component_gt: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5090 |   shows "open {x::real^'n. x$i  > a}"
 | 
| 33175 | 5091 | using open_halfspace_gt[of a "(basis i)::real^'n"] unfolding inner_basis[OF assms] by auto | 
| 5092 | ||
| 5093 | text{* This gives a simple derivation of limit component bounds.                 *}
 | |
| 5094 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5095 | lemma Lim_component_le: fixes f :: "'a \<Rightarrow> real^'n" | 
| 33175 | 5096 | assumes "(f ---> l) net" "\<not> (trivial_limit net)" "eventually (\<lambda>x. f(x)$i \<le> b) net" | 
| 5097 | shows "l$i \<le> b" | |
| 5098 | proof- | |
| 5099 |   { 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
 | |
| 5100 |   show ?thesis using Lim_in_closed_set[of "{x. inner (basis i) x \<le> b}" f net l] unfolding *
 | |
| 5101 | using closed_halfspace_le[of "(basis i)::real^'n" b] and assms(1,2,3) by auto | |
| 5102 | qed | |
| 5103 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5104 | lemma Lim_component_ge: fixes f :: "'a \<Rightarrow> real^'n" | 
| 33175 | 5105 | assumes "(f ---> l) net" "\<not> (trivial_limit net)" "eventually (\<lambda>x. b \<le> (f x)$i) net" | 
| 5106 | shows "b \<le> l$i" | |
| 5107 | proof- | |
| 5108 |   { 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
 | |
| 5109 |   show ?thesis using Lim_in_closed_set[of "{x. inner (basis i) x \<ge> b}" f net l] unfolding *
 | |
| 5110 | using closed_halfspace_ge[of b "(basis i)::real^'n"] and assms(1,2,3) by auto | |
| 5111 | qed | |
| 5112 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5113 | lemma Lim_component_eq: fixes f :: "'a \<Rightarrow> real^'n" | 
| 33175 | 5114 | assumes net:"(f ---> l) net" "~(trivial_limit net)" and ev:"eventually (\<lambda>x. f(x)$i = b) net" | 
| 5115 | shows "l$i = b" | |
| 5116 | 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 | |
| 5117 | ||
| 5118 | text{* Limits relative to a union.                                               *}
 | |
| 5119 | ||
| 5120 | lemma eventually_within_Un: | |
| 5121 | "eventually P (net within (s \<union> t)) \<longleftrightarrow> | |
| 5122 | eventually P (net within s) \<and> eventually P (net within t)" | |
| 5123 | unfolding Limits.eventually_within | |
| 5124 | by (auto elim!: eventually_rev_mp) | |
| 5125 | ||
| 5126 | lemma Lim_within_union: | |
| 5127 | "(f ---> l) (net within (s \<union> t)) \<longleftrightarrow> | |
| 5128 | (f ---> l) (net within s) \<and> (f ---> l) (net within t)" | |
| 5129 | unfolding tendsto_def | |
| 5130 | by (auto simp add: eventually_within_Un) | |
| 5131 | ||
| 36442 | 5132 | lemma Lim_topological: | 
| 5133 | "(f ---> l) net \<longleftrightarrow> | |
| 5134 | trivial_limit net \<or> | |
| 5135 | (\<forall>S. open S \<longrightarrow> l \<in> S \<longrightarrow> eventually (\<lambda>x. f x \<in> S) net)" | |
| 5136 | unfolding tendsto_def trivial_limit_eq by auto | |
| 5137 | ||
| 33175 | 5138 | lemma continuous_on_union: | 
| 5139 | assumes "closed s" "closed t" "continuous_on s f" "continuous_on t f" | |
| 5140 | shows "continuous_on (s \<union> t) f" | |
| 36442 | 5141 | using assms unfolding continuous_on Lim_within_union | 
| 5142 | unfolding Lim_topological trivial_limit_within closed_limpt by auto | |
| 33175 | 5143 | |
| 5144 | lemma continuous_on_cases: | |
| 5145 | assumes "closed s" "closed t" "continuous_on s f" "continuous_on t g" | |
| 5146 | "\<forall>x. (x\<in>s \<and> \<not> P x) \<or> (x \<in> t \<and> P x) \<longrightarrow> f x = g x" | |
| 5147 | shows "continuous_on (s \<union> t) (\<lambda>x. if P x then f x else g x)" | |
| 5148 | proof- | |
| 5149 | let ?h = "(\<lambda>x. if P x then f x else g x)" | |
| 5150 | have "\<forall>x\<in>s. f x = (if P x then f x else g x)" using assms(5) by auto | |
| 5151 | hence "continuous_on s ?h" using continuous_on_eq[of s f ?h] using assms(3) by auto | |
| 5152 | moreover | |
| 5153 | have "\<forall>x\<in>t. g x = (if P x then f x else g x)" using assms(5) by auto | |
| 5154 | hence "continuous_on t ?h" using continuous_on_eq[of t g ?h] using assms(4) by auto | |
| 5155 | ultimately show ?thesis using continuous_on_union[OF assms(1,2), of ?h] by auto | |
| 5156 | qed | |
| 5157 | ||
| 5158 | ||
| 5159 | text{* Some more convenient intermediate-value theorem formulations.             *}
 | |
| 5160 | ||
| 5161 | lemma connected_ivt_hyperplane: | |
| 5162 | assumes "connected s" "x \<in> s" "y \<in> s" "inner a x \<le> b" "b \<le> inner a y" | |
| 5163 | shows "\<exists>z \<in> s. inner a z = b" | |
| 5164 | proof(rule ccontr) | |
| 5165 | assume as:"\<not> (\<exists>z\<in>s. inner a z = b)" | |
| 5166 |   let ?A = "{x. inner a x < b}"
 | |
| 5167 |   let ?B = "{x. inner a x > b}"
 | |
| 5168 | have "open ?A" "open ?B" using open_halfspace_lt and open_halfspace_gt by auto | |
| 5169 |   moreover have "?A \<inter> ?B = {}" by auto
 | |
| 5170 | moreover have "s \<subseteq> ?A \<union> ?B" using as by auto | |
| 5171 | 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 | |
| 5172 | qed | |
| 5173 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5174 | lemma connected_ivt_component: fixes x::"real^'n" shows | 
| 33175 | 5175 | "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)" | 
| 5176 | using connected_ivt_hyperplane[of s x y "(basis k)::real^'n" a] by (auto simp add: inner_basis) | |
| 5177 | ||
| 36437 | 5178 | subsection {* Homeomorphisms *}
 | 
| 33175 | 5179 | |
| 5180 | definition "homeomorphism s t f g \<equiv> | |
| 5181 | (\<forall>x\<in>s. (g(f x) = x)) \<and> (f ` s = t) \<and> continuous_on s f \<and> | |
| 5182 | (\<forall>y\<in>t. (f(g y) = y)) \<and> (g ` t = s) \<and> continuous_on t g" | |
| 5183 | ||
| 5184 | definition | |
| 5185 | homeomorphic :: "'a::metric_space set \<Rightarrow> 'b::metric_space set \<Rightarrow> bool" | |
| 5186 | (infixr "homeomorphic" 60) where | |
| 5187 | homeomorphic_def: "s homeomorphic t \<equiv> (\<exists>f g. homeomorphism s t f g)" | |
| 5188 | ||
| 5189 | lemma homeomorphic_refl: "s homeomorphic s" | |
| 5190 | unfolding homeomorphic_def | |
| 5191 | unfolding homeomorphism_def | |
| 5192 | using continuous_on_id | |
| 5193 | apply(rule_tac x = "(\<lambda>x. x)" in exI) | |
| 5194 | apply(rule_tac x = "(\<lambda>x. x)" in exI) | |
| 5195 | by blast | |
| 5196 | ||
| 5197 | lemma homeomorphic_sym: | |
| 5198 | "s homeomorphic t \<longleftrightarrow> t homeomorphic s" | |
| 5199 | unfolding homeomorphic_def | |
| 5200 | unfolding homeomorphism_def | |
| 33324 | 5201 | by blast | 
| 33175 | 5202 | |
| 5203 | lemma homeomorphic_trans: | |
| 5204 | assumes "s homeomorphic t" "t homeomorphic u" shows "s homeomorphic u" | |
| 5205 | proof- | |
| 5206 | 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" | |
| 5207 | using assms(1) unfolding homeomorphic_def homeomorphism_def by auto | |
| 5208 | 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" | |
| 5209 | using assms(2) unfolding homeomorphic_def homeomorphism_def by auto | |
| 5210 | ||
| 5211 |   { 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 }
 | |
| 5212 | moreover have "(f2 \<circ> f1) ` s = u" using fg1(2) fg2(2) by auto | |
| 5213 | moreover have "continuous_on s (f2 \<circ> f1)" using continuous_on_compose[OF fg1(3)] and fg2(3) unfolding fg1(2) by auto | |
| 5214 |   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 }
 | |
| 5215 | moreover have "(g1 \<circ> g2) ` u = s" using fg1(5) fg2(5) by auto | |
| 5216 | moreover have "continuous_on u (g1 \<circ> g2)" using continuous_on_compose[OF fg2(6)] and fg1(6) unfolding fg2(5) by auto | |
| 5217 | 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 | |
| 5218 | qed | |
| 5219 | ||
| 5220 | lemma homeomorphic_minimal: | |
| 5221 | "s homeomorphic t \<longleftrightarrow> | |
| 5222 | (\<exists>f g. (\<forall>x\<in>s. f(x) \<in> t \<and> (g(f(x)) = x)) \<and> | |
| 5223 | (\<forall>y\<in>t. g(y) \<in> s \<and> (f(g(y)) = y)) \<and> | |
| 5224 | continuous_on s f \<and> continuous_on t g)" | |
| 5225 | unfolding homeomorphic_def homeomorphism_def | |
| 5226 | apply auto apply (rule_tac x=f in exI) apply (rule_tac x=g in exI) | |
| 5227 | apply auto apply (rule_tac x=f in exI) apply (rule_tac x=g in exI) apply auto | |
| 5228 | unfolding image_iff | |
| 5229 | apply(erule_tac x="g x" in ballE) apply(erule_tac x="x" in ballE) | |
| 5230 | apply auto apply(rule_tac x="g x" in bexI) apply auto | |
| 5231 | apply(erule_tac x="f x" in ballE) apply(erule_tac x="x" in ballE) | |
| 5232 | apply auto apply(rule_tac x="f x" in bexI) by auto | |
| 5233 | ||
| 36437 | 5234 | text {* Relatively weak hypotheses if a set is compact. *}
 | 
| 33175 | 5235 | |
| 5236 | lemma homeomorphism_compact: | |
| 5237 | fixes f :: "'a::heine_borel \<Rightarrow> 'b::heine_borel" | |
| 5238 | (* class constraint due to continuous_on_inverse *) | |
| 5239 | assumes "compact s" "continuous_on s f" "f ` s = t" "inj_on f s" | |
| 5240 | shows "\<exists>g. homeomorphism s t f g" | |
| 5241 | proof- | |
| 5242 | def g \<equiv> "\<lambda>x. SOME y. y\<in>s \<and> f y = x" | |
| 5243 | have g:"\<forall>x\<in>s. g (f x) = x" using assms(3) assms(4)[unfolded inj_on_def] unfolding g_def by auto | |
| 5244 |   { fix y assume "y\<in>t"
 | |
| 5245 | then obtain x where x:"f x = y" "x\<in>s" using assms(3) by auto | |
| 5246 | hence "g (f x) = x" using g by auto | |
| 5247 | hence "f (g y) = y" unfolding x(1)[THEN sym] by auto } | |
| 5248 | hence g':"\<forall>x\<in>t. f (g x) = x" by auto | |
| 5249 | moreover | |
| 5250 |   { fix x
 | |
| 5251 | 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"]) | |
| 5252 | moreover | |
| 5253 |     { assume "x\<in>g ` t"
 | |
| 5254 | then obtain y where y:"y\<in>t" "g y = x" by auto | |
| 5255 | then obtain x' where x':"x'\<in>s" "f x' = y" using assms(3) by auto | |
| 5256 | 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 } | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 5257 | ultimately have "x\<in>s \<longleftrightarrow> x \<in> g ` t" .. } | 
| 33175 | 5258 | hence "g ` t = s" by auto | 
| 5259 | ultimately | |
| 5260 | show ?thesis unfolding homeomorphism_def homeomorphic_def | |
| 5261 | 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 | |
| 5262 | qed | |
| 5263 | ||
| 5264 | lemma homeomorphic_compact: | |
| 5265 | fixes f :: "'a::heine_borel \<Rightarrow> 'b::heine_borel" | |
| 5266 | (* class constraint due to continuous_on_inverse *) | |
| 5267 | shows "compact s \<Longrightarrow> continuous_on s f \<Longrightarrow> (f ` s = t) \<Longrightarrow> inj_on f s | |
| 5268 | \<Longrightarrow> s homeomorphic t" | |
| 37452 | 5269 | unfolding homeomorphic_def by (auto intro: homeomorphism_compact) | 
| 33175 | 5270 | |
| 5271 | text{* Preservation of topological properties.                                   *}
 | |
| 5272 | ||
| 5273 | lemma homeomorphic_compactness: | |
| 5274 | "s homeomorphic t ==> (compact s \<longleftrightarrow> compact t)" | |
| 5275 | unfolding homeomorphic_def homeomorphism_def | |
| 5276 | by (metis compact_continuous_image) | |
| 5277 | ||
| 5278 | text{* Results on translation, scaling etc.                                      *}
 | |
| 5279 | ||
| 5280 | lemma homeomorphic_scaling: | |
| 5281 | fixes s :: "'a::real_normed_vector set" | |
| 5282 | assumes "c \<noteq> 0" shows "s homeomorphic ((\<lambda>x. c *\<^sub>R x) ` s)" | |
| 5283 | unfolding homeomorphic_minimal | |
| 5284 | apply(rule_tac x="\<lambda>x. c *\<^sub>R x" in exI) | |
| 5285 | apply(rule_tac x="\<lambda>x. (1 / c) *\<^sub>R x" in exI) | |
| 5286 | using assms apply auto | |
| 5287 | using continuous_on_cmul[OF continuous_on_id] by auto | |
| 5288 | ||
| 5289 | lemma homeomorphic_translation: | |
| 5290 | fixes s :: "'a::real_normed_vector set" | |
| 5291 | shows "s homeomorphic ((\<lambda>x. a + x) ` s)" | |
| 5292 | unfolding homeomorphic_minimal | |
| 5293 | apply(rule_tac x="\<lambda>x. a + x" in exI) | |
| 5294 | apply(rule_tac x="\<lambda>x. -a + x" in exI) | |
| 5295 | using continuous_on_add[OF continuous_on_const continuous_on_id] by auto | |
| 5296 | ||
| 5297 | lemma homeomorphic_affinity: | |
| 5298 | fixes s :: "'a::real_normed_vector set" | |
| 5299 | assumes "c \<noteq> 0" shows "s homeomorphic ((\<lambda>x. a + c *\<^sub>R x) ` s)" | |
| 5300 | proof- | |
| 5301 | have *:"op + a ` op *\<^sub>R c ` s = (\<lambda>x. a + c *\<^sub>R x) ` s" by auto | |
| 5302 | show ?thesis | |
| 5303 | using homeomorphic_trans | |
| 5304 | using homeomorphic_scaling[OF assms, of s] | |
| 5305 | using homeomorphic_translation[of "(\<lambda>x. c *\<^sub>R x) ` s" a] unfolding * by auto | |
| 5306 | qed | |
| 5307 | ||
| 5308 | lemma homeomorphic_balls: | |
| 5309 | fixes a b ::"'a::real_normed_vector" (* FIXME: generalize to metric_space *) | |
| 5310 | assumes "0 < d" "0 < e" | |
| 5311 | shows "(ball a d) homeomorphic (ball b e)" (is ?th) | |
| 5312 | "(cball a d) homeomorphic (cball b e)" (is ?cth) | |
| 5313 | proof- | |
| 5314 | have *:"\<bar>e / d\<bar> > 0" "\<bar>d / e\<bar> >0" using assms using divide_pos_pos by auto | |
| 5315 | show ?th unfolding homeomorphic_minimal | |
| 5316 | apply(rule_tac x="\<lambda>x. b + (e/d) *\<^sub>R (x - a)" in exI) | |
| 5317 | apply(rule_tac x="\<lambda>x. a + (d/e) *\<^sub>R (x - b)" in exI) | |
| 5318 | using assms apply (auto simp add: dist_commute) | |
| 5319 | unfolding dist_norm | |
| 5320 | apply (auto simp add: pos_divide_less_eq mult_strict_left_mono) | |
| 5321 | unfolding continuous_on | |
| 36659 
f794e92784aa
adapt to removed premise on tendsto lemma (cf. 88f0125c3bd2)
 huffman parents: 
36623diff
changeset | 5322 | by (intro ballI tendsto_intros, simp)+ | 
| 33175 | 5323 | next | 
| 5324 | have *:"\<bar>e / d\<bar> > 0" "\<bar>d / e\<bar> >0" using assms using divide_pos_pos by auto | |
| 5325 | show ?cth unfolding homeomorphic_minimal | |
| 5326 | apply(rule_tac x="\<lambda>x. b + (e/d) *\<^sub>R (x - a)" in exI) | |
| 5327 | apply(rule_tac x="\<lambda>x. a + (d/e) *\<^sub>R (x - b)" in exI) | |
| 5328 | using assms apply (auto simp add: dist_commute) | |
| 5329 | unfolding dist_norm | |
| 5330 | apply (auto simp add: pos_divide_le_eq) | |
| 5331 | unfolding continuous_on | |
| 36659 
f794e92784aa
adapt to removed premise on tendsto lemma (cf. 88f0125c3bd2)
 huffman parents: 
36623diff
changeset | 5332 | by (intro ballI tendsto_intros, simp)+ | 
| 33175 | 5333 | qed | 
| 5334 | ||
| 5335 | text{* "Isometry" (up to constant bounds) of injective linear map etc.           *}
 | |
| 5336 | ||
| 5337 | lemma cauchy_isometric: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5338 | fixes x :: "nat \<Rightarrow> real ^ 'n" | 
| 33175 | 5339 | 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)" | 
| 5340 | shows "Cauchy x" | |
| 5341 | proof- | |
| 5342 | interpret f: bounded_linear f by fact | |
| 5343 |   { fix d::real assume "d>0"
 | |
| 5344 | then obtain N where N:"\<forall>n\<ge>N. norm (f (x n) - f (x N)) < e * d" | |
| 5345 | 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 | |
| 5346 |     { fix n assume "n\<ge>N"
 | |
| 5347 | hence "norm (f (x n - x N)) < e * d" using N[THEN spec[where x=n]] unfolding f.diff[THEN sym] by auto | |
| 5348 | moreover have "e * norm (x n - x N) \<le> norm (f (x n - x N))" | |
| 5349 | using subspace_sub[OF s, of "x n" "x N"] using xs[THEN spec[where x=N]] and xs[THEN spec[where x=n]] | |
| 5350 | using normf[THEN bspec[where x="x n - x N"]] by auto | |
| 5351 | ultimately have "norm (x n - x N) < d" using `e>0` | |
| 5352 | using mult_left_less_imp_less[of e "norm (x n - x N)" d] by auto } | |
| 5353 | hence "\<exists>N. \<forall>n\<ge>N. norm (x n - x N) < d" by auto } | |
| 5354 | thus ?thesis unfolding cauchy and dist_norm by auto | |
| 5355 | qed | |
| 5356 | ||
| 5357 | lemma complete_isometric_image: | |
| 5358 | fixes f :: "real ^ _ \<Rightarrow> real ^ _" | |
| 5359 | 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" | |
| 5360 | shows "complete(f ` s)" | |
| 5361 | proof- | |
| 5362 |   { fix g assume as:"\<forall>n::nat. g n \<in> f ` s" and cfg:"Cauchy g"
 | |
| 33324 | 5363 | then obtain x where "\<forall>n. x n \<in> s \<and> g n = f (x n)" | 
| 33175 | 5364 | using choice[of "\<lambda> n xa. xa \<in> s \<and> g n = f xa"] by auto | 
| 5365 | hence x:"\<forall>n. x n \<in> s" "\<forall>n. g n = f (x n)" by auto | |
| 5366 | hence "f \<circ> x = g" unfolding expand_fun_eq by auto | |
| 5367 | then obtain l where "l\<in>s" and l:"(x ---> l) sequentially" | |
| 5368 | using cs[unfolded complete_def, THEN spec[where x="x"]] | |
| 5369 | using cauchy_isometric[OF `0<e` s f normf] and cfg and x(1) by auto | |
| 5370 | hence "\<exists>l\<in>f ` s. (g ---> l) sequentially" | |
| 5371 | using linear_continuous_at[OF f, unfolded continuous_at_sequentially, THEN spec[where x=x], of l] | |
| 5372 | unfolding `f \<circ> x = g` by auto } | |
| 5373 | thus ?thesis unfolding complete_def by auto | |
| 5374 | qed | |
| 5375 | ||
| 5376 | lemma dist_0_norm: | |
| 5377 | fixes x :: "'a::real_normed_vector" | |
| 5378 | shows "dist 0 x = norm x" | |
| 5379 | unfolding dist_norm by simp | |
| 5380 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5381 | lemma injective_imp_isometric: fixes f::"real^'m \<Rightarrow> real^'n" | 
| 33175 | 5382 | assumes s:"closed s" "subspace s" and f:"bounded_linear f" "\<forall>x\<in>s. (f x = 0) \<longrightarrow> (x = 0)" | 
| 5383 | shows "\<exists>e>0. \<forall>x\<in>s. norm (f x) \<ge> e * norm(x)" | |
| 5384 | proof(cases "s \<subseteq> {0::real^'m}")
 | |
| 5385 | case True | |
| 5386 |   { fix x assume "x \<in> s"
 | |
| 5387 | hence "x = 0" using True by auto | |
| 5388 | hence "norm x \<le> norm (f x)" by auto } | |
| 5389 | thus ?thesis by(auto intro!: exI[where x=1]) | |
| 5390 | next | |
| 5391 | interpret f: bounded_linear f by fact | |
| 5392 | case False | |
| 5393 | then obtain a where a:"a\<noteq>0" "a\<in>s" by auto | |
| 5394 |   from False have "s \<noteq> {}" by auto
 | |
| 5395 |   let ?S = "{f x| x. (x \<in> s \<and> norm x = norm a)}"
 | |
| 5396 |   let ?S' = "{x::real^'m. x\<in>s \<and> norm x = norm a}"
 | |
| 5397 |   let ?S'' = "{x::real^'m. norm x = norm a}"
 | |
| 5398 | ||
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 5399 | have "?S'' = frontier(cball 0 (norm a))" unfolding frontier_cball and dist_norm by auto | 
| 33175 | 5400 | hence "compact ?S''" using compact_frontier[OF compact_cball, of 0 "norm a"] by auto | 
| 5401 | moreover have "?S' = s \<inter> ?S''" by auto | |
| 5402 | ultimately have "compact ?S'" using closed_inter_compact[of s ?S''] using s(1) by auto | |
| 5403 | moreover have *:"f ` ?S' = ?S" by auto | |
| 5404 | ultimately have "compact ?S" using compact_continuous_image[OF linear_continuous_on[OF f(1)], of ?S'] by auto | |
| 5405 | hence "closed ?S" using compact_imp_closed by auto | |
| 5406 |   moreover have "?S \<noteq> {}" using a by auto
 | |
| 5407 | 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 | |
| 5408 |   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
 | |
| 5409 | ||
| 5410 | let ?e = "norm (f b) / norm b" | |
| 5411 | have "norm b > 0" using ba and a and norm_ge_zero by auto | |
| 5412 | 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 | |
| 5413 | ultimately have "0 < norm (f b) / norm b" by(simp only: divide_pos_pos) | |
| 5414 | moreover | |
| 5415 |   { fix x assume "x\<in>s"
 | |
| 5416 | hence "norm (f b) / norm b * norm x \<le> norm (f x)" | |
| 5417 | proof(cases "x=0") | |
| 5418 | case True thus "norm (f b) / norm b * norm x \<le> norm (f x)" by auto | |
| 5419 | next | |
| 5420 | case False | |
| 5421 | hence *:"0 < norm a / norm x" using `a\<noteq>0` unfolding zero_less_norm_iff[THEN sym] by(simp only: divide_pos_pos) | |
| 5422 | have "\<forall>c. \<forall>x\<in>s. c *\<^sub>R x \<in> s" using s[unfolded subspace_def smult_conv_scaleR] by auto | |
| 5423 |       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
 | |
| 5424 | 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"]] | |
| 5425 | unfolding f.scaleR and ba using `x\<noteq>0` `a\<noteq>0` | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5426 | by (auto simp add: mult_commute pos_le_divide_eq pos_divide_le_eq) | 
| 33175 | 5427 | qed } | 
| 5428 | ultimately | |
| 5429 | show ?thesis by auto | |
| 5430 | qed | |
| 5431 | ||
| 5432 | lemma closed_injective_image_subspace: | |
| 5433 | fixes f :: "real ^ _ \<Rightarrow> real ^ _" | |
| 5434 | assumes "subspace s" "bounded_linear f" "\<forall>x\<in>s. f x = 0 --> x = 0" "closed s" | |
| 5435 | shows "closed(f ` s)" | |
| 5436 | proof- | |
| 5437 | 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 | |
| 5438 | show ?thesis using complete_isometric_image[OF `e>0` assms(1,2) e] and assms(4) | |
| 5439 | unfolding complete_eq_closed[THEN sym] by auto | |
| 5440 | qed | |
| 5441 | ||
| 5442 | subsection{* Some properties of a canonical subspace.                                  *}
 | |
| 5443 | ||
| 5444 | lemma subspace_substandard: | |
| 34289 | 5445 |  "subspace {x::real^_. (\<forall>i. P i \<longrightarrow> x$i = 0)}"
 | 
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 5446 | unfolding subspace_def by auto | 
| 33175 | 5447 | |
| 5448 | lemma closed_substandard: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5449 |  "closed {x::real^'n. \<forall>i. P i --> x$i = 0}" (is "closed ?A")
 | 
| 33175 | 5450 | proof- | 
| 5451 |   let ?D = "{i. P i}"
 | |
| 5452 |   let ?Bs = "{{x::real^'n. inner (basis i) x = 0}| i. i \<in> ?D}"
 | |
| 5453 |   { fix x
 | |
| 5454 |     { assume "x\<in>?A"
 | |
| 5455 | hence x:"\<forall>i\<in>?D. x $ i = 0" by auto | |
| 5456 | hence "x\<in> \<Inter> ?Bs" by(auto simp add: inner_basis x) } | |
| 5457 | moreover | |
| 5458 |     { assume x:"x\<in>\<Inter>?Bs"
 | |
| 5459 |       { fix i assume i:"i \<in> ?D"
 | |
| 5460 |         then obtain B where BB:"B \<in> ?Bs" and B:"B = {x::real^'n. inner (basis i) x = 0}" by auto
 | |
| 5461 | hence "x $ i = 0" unfolding B using x unfolding inner_basis by auto } | |
| 5462 | hence "x\<in>?A" by auto } | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 5463 | ultimately have "x\<in>?A \<longleftrightarrow> x\<in> \<Inter>?Bs" .. } | 
| 33175 | 5464 | hence "?A = \<Inter> ?Bs" by auto | 
| 5465 | thus ?thesis by(auto simp add: closed_Inter closed_hyperplane) | |
| 5466 | qed | |
| 5467 | ||
| 5468 | lemma dim_substandard: | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5469 |   shows "dim {x::real^'n. \<forall>i. i \<notin> d \<longrightarrow> x$i = 0} = card d" (is "dim ?A = _")
 | 
| 33175 | 5470 | proof- | 
| 5471 | let ?D = "UNIV::'n set" | |
| 5472 | let ?B = "(basis::'n\<Rightarrow>real^'n) ` d" | |
| 5473 | ||
| 5474 | let ?bas = "basis::'n \<Rightarrow> real^'n" | |
| 5475 | ||
| 5476 | have "?B \<subseteq> ?A" by auto | |
| 5477 | ||
| 5478 | moreover | |
| 5479 |   { fix x::"real^'n" assume "x\<in>?A"
 | |
| 5480 | with finite[of d] | |
| 5481 | have "x\<in> span ?B" | |
| 5482 | proof(induct d arbitrary: x) | |
| 5483 | case empty hence "x=0" unfolding Cart_eq by auto | |
| 5484 |       thus ?case using subspace_0[OF subspace_span[of "{}"]] by auto
 | |
| 5485 | next | |
| 5486 | case (insert k F) | |
| 5487 | hence *:"\<forall>i. i \<notin> insert k F \<longrightarrow> x $ i = 0" by auto | |
| 5488 | have **:"F \<subseteq> insert k F" by auto | |
| 5489 | def y \<equiv> "x - x$k *\<^sub>R basis k" | |
| 5490 | have y:"x = y + (x$k) *\<^sub>R basis k" unfolding y_def by auto | |
| 5491 |       { fix i assume i':"i \<notin> F"
 | |
| 5492 | hence "y $ i = 0" unfolding y_def unfolding vector_minus_component | |
| 5493 | and vector_smult_component and basis_component | |
| 5494 | using *[THEN spec[where x=i]] by auto } | |
| 5495 | hence "y \<in> span (basis ` (insert k F))" using insert(3) | |
| 5496 | using span_mono[of "?bas ` F" "?bas ` (insert k F)"] | |
| 5497 | using image_mono[OF **, of basis] by auto | |
| 5498 | moreover | |
| 5499 | have "basis k \<in> span (?bas ` (insert k F))" by(rule span_superset, auto) | |
| 5500 | hence "x$k *\<^sub>R basis k \<in> span (?bas ` (insert k F))" | |
| 36593 
fb69c8cd27bd
define linear algebra concepts using scaleR instead of (op *s); generalized many lemmas, though a few theorems that used to work on type int^'n are a bit less general
 huffman parents: 
36590diff
changeset | 5501 | using span_mul by auto | 
| 33175 | 5502 | ultimately | 
| 5503 | have "y + x$k *\<^sub>R basis k \<in> span (?bas ` (insert k F))" | |
| 5504 | using span_add by auto | |
| 5505 | thus ?case using y by auto | |
| 5506 | qed | |
| 5507 | } | |
| 5508 | hence "?A \<subseteq> span ?B" by auto | |
| 5509 | ||
| 5510 | moreover | |
| 5511 |   { fix x assume "x \<in> ?B"
 | |
| 5512 |     hence "x\<in>{(basis i)::real^'n |i. i \<in> ?D}" using assms by auto  }
 | |
| 5513 | hence "independent ?B" using independent_mono[OF independent_stdbasis, of ?B] and assms by auto | |
| 5514 | ||
| 5515 | moreover | |
| 5516 | have "d \<subseteq> ?D" unfolding subset_eq using assms by auto | |
| 5517 | hence *:"inj_on (basis::'n\<Rightarrow>real^'n) d" using subset_inj_on[OF basis_inj, of "d"] by auto | |
| 33715 | 5518 | have "card ?B = card d" unfolding card_image[OF *] by auto | 
| 33175 | 5519 | |
| 5520 | ultimately show ?thesis using dim_unique[of "basis ` d" ?A] by auto | |
| 5521 | qed | |
| 5522 | ||
| 5523 | text{* Hence closure and completeness of all subspaces.                          *}
 | |
| 5524 | ||
| 5525 | lemma closed_subspace_lemma: "n \<le> card (UNIV::'n::finite set) \<Longrightarrow> \<exists>A::'n set. card A = n" | |
| 5526 | apply (induct n) | |
| 5527 | apply (rule_tac x="{}" in exI, simp)
 | |
| 5528 | apply clarsimp | |
| 5529 | apply (subgoal_tac "\<exists>x. x \<notin> A") | |
| 5530 | apply (erule exE) | |
| 5531 | apply (rule_tac x="insert x A" in exI, simp) | |
| 5532 | apply (subgoal_tac "A \<noteq> UNIV", auto) | |
| 5533 | done | |
| 5534 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5535 | lemma closed_subspace: fixes s::"(real^'n) set" | 
| 33175 | 5536 | assumes "subspace s" shows "closed s" | 
| 5537 | proof- | |
| 5538 | have "dim s \<le> card (UNIV :: 'n set)" using dim_subset_univ by auto | |
| 5539 | then obtain d::"'n set" where t: "card d = dim s" | |
| 5540 | using closed_subspace_lemma by auto | |
| 5541 |   let ?t = "{x::real^'n. \<forall>i. i \<notin> d \<longrightarrow> x$i = 0}"
 | |
| 5542 | obtain f where f:"bounded_linear f" "f ` ?t = s" "inj_on f ?t" | |
| 5543 | using subspace_isomorphism[unfolded linear_conv_bounded_linear, OF subspace_substandard[of "\<lambda>i. i \<notin> d"] assms] | |
| 5544 | using dim_substandard[of d] and t by auto | |
| 5545 | interpret f: bounded_linear f by fact | |
| 5546 | have "\<forall>x\<in>?t. f x = 0 \<longrightarrow> x = 0" using f.zero using f(3)[unfolded inj_on_def] | |
| 5547 | by(erule_tac x=0 in ballE) auto | |
| 5548 | moreover have "closed ?t" using closed_substandard . | |
| 5549 | moreover have "subspace ?t" using subspace_substandard . | |
| 5550 | ultimately show ?thesis using closed_injective_image_subspace[of ?t f] | |
| 5551 | unfolding f(2) using f(1) by auto | |
| 5552 | qed | |
| 5553 | ||
| 5554 | lemma complete_subspace: | |
| 5555 | fixes s :: "(real ^ _) set" shows "subspace s ==> complete s" | |
| 5556 | using complete_eq_closed closed_subspace | |
| 5557 | by auto | |
| 5558 | ||
| 5559 | lemma dim_closure: | |
| 5560 | fixes s :: "(real ^ _) set" | |
| 5561 | shows "dim(closure s) = dim s" (is "?dc = ?d") | |
| 5562 | proof- | |
| 5563 | have "?dc \<le> ?d" using closure_minimal[OF span_inc, of s] | |
| 5564 | using closed_subspace[OF subspace_span, of s] | |
| 5565 | using dim_subset[of "closure s" "span s"] unfolding dim_span by auto | |
| 5566 | thus ?thesis using dim_subset[OF closure_subset, of s] by auto | |
| 5567 | qed | |
| 5568 | ||
| 36437 | 5569 | subsection {* Affine transformations of intervals *}
 | 
| 33175 | 5570 | |
| 5571 | lemma affinity_inverses: | |
| 5572 | assumes m0: "m \<noteq> (0::'a::field)" | |
| 5573 | shows "(\<lambda>x. m *s x + c) o (\<lambda>x. inverse(m) *s x + (-(inverse(m) *s c))) = id" | |
| 5574 | "(\<lambda>x. inverse(m) *s x + (-(inverse(m) *s c))) o (\<lambda>x. m *s x + c) = id" | |
| 5575 | using m0 | |
| 5576 | apply (auto simp add: expand_fun_eq vector_add_ldistrib vector_smult_assoc) | |
| 5577 | by (simp add: vector_smult_lneg[symmetric] vector_smult_assoc vector_sneg_minus1[symmetric]) | |
| 5578 | ||
| 5579 | lemma real_affinity_le: | |
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
34999diff
changeset | 5580 | "0 < (m::'a::linordered_field) ==> (m * x + c \<le> y \<longleftrightarrow> x \<le> inverse(m) * y + -(c / m))" | 
| 33175 | 5581 | by (simp add: field_simps inverse_eq_divide) | 
| 5582 | ||
| 5583 | lemma real_le_affinity: | |
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
34999diff
changeset | 5584 | "0 < (m::'a::linordered_field) ==> (y \<le> m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) \<le> x)" | 
| 33175 | 5585 | by (simp add: field_simps inverse_eq_divide) | 
| 5586 | ||
| 5587 | lemma real_affinity_lt: | |
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
34999diff
changeset | 5588 | "0 < (m::'a::linordered_field) ==> (m * x + c < y \<longleftrightarrow> x < inverse(m) * y + -(c / m))" | 
| 33175 | 5589 | by (simp add: field_simps inverse_eq_divide) | 
| 5590 | ||
| 5591 | lemma real_lt_affinity: | |
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
34999diff
changeset | 5592 | "0 < (m::'a::linordered_field) ==> (y < m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) < x)" | 
| 33175 | 5593 | by (simp add: field_simps inverse_eq_divide) | 
| 5594 | ||
| 5595 | lemma real_affinity_eq: | |
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
34999diff
changeset | 5596 | "(m::'a::linordered_field) \<noteq> 0 ==> (m * x + c = y \<longleftrightarrow> x = inverse(m) * y + -(c / m))" | 
| 33175 | 5597 | by (simp add: field_simps inverse_eq_divide) | 
| 5598 | ||
| 5599 | lemma real_eq_affinity: | |
| 35028 
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
 haftmann parents: 
34999diff
changeset | 5600 | "(m::'a::linordered_field) \<noteq> 0 ==> (y = m * x + c \<longleftrightarrow> inverse(m) * y + -(c / m) = x)" | 
| 33175 | 5601 | by (simp add: field_simps inverse_eq_divide) | 
| 5602 | ||
| 5603 | lemma vector_affinity_eq: | |
| 5604 | assumes m0: "(m::'a::field) \<noteq> 0" | |
| 5605 | shows "m *s x + c = y \<longleftrightarrow> x = inverse m *s y + -(inverse m *s c)" | |
| 5606 | proof | |
| 5607 | assume h: "m *s x + c = y" | |
| 36350 | 5608 | hence "m *s x = y - c" by (simp add: field_simps) | 
| 33175 | 5609 | hence "inverse m *s (m *s x) = inverse m *s (y - c)" by simp | 
| 5610 | then show "x = inverse m *s y + - (inverse m *s c)" | |
| 5611 | using m0 by (simp add: vector_smult_assoc vector_ssub_ldistrib) | |
| 5612 | next | |
| 5613 | assume h: "x = inverse m *s y + - (inverse m *s c)" | |
| 5614 | show "m *s x + c = y" unfolding h diff_minus[symmetric] | |
| 5615 | using m0 by (simp add: vector_smult_assoc vector_ssub_ldistrib) | |
| 5616 | qed | |
| 5617 | ||
| 5618 | lemma vector_eq_affinity: | |
| 5619 | "(m::'a::field) \<noteq> 0 ==> (y = m *s x + c \<longleftrightarrow> inverse(m) *s y + -(inverse(m) *s c) = x)" | |
| 5620 | using vector_affinity_eq[where m=m and x=x and y=y and c=c] | |
| 5621 | by metis | |
| 5622 | ||
| 5623 | lemma image_affinity_interval: fixes m::real | |
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5624 | fixes a b c :: "real^'n" | 
| 33175 | 5625 |   shows "(\<lambda>x. m *\<^sub>R x + c) ` {a .. b} =
 | 
| 5626 |             (if {a .. b} = {} then {}
 | |
| 5627 |             else (if 0 \<le> m then {m *\<^sub>R a + c .. m *\<^sub>R b + c}
 | |
| 5628 |             else {m *\<^sub>R b + c .. m *\<^sub>R a + c}))"
 | |
| 5629 | proof(cases "m=0") | |
| 5630 |   { 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 | 5631 | hence "x=c" unfolding vector_le_def and Cart_eq by (auto intro: order_antisym) } | 
| 33175 | 5632 | moreover case True | 
| 33758 
53078b0d21f5
Renamed vector_less_eq_def to the more usual name vector_le_def.
 hoelzl parents: 
33715diff
changeset | 5633 |   moreover have "c \<in> {m *\<^sub>R a + c..m *\<^sub>R b + c}" unfolding True by(auto simp add: vector_le_def)
 | 
| 33175 | 5634 | ultimately show ?thesis by auto | 
| 5635 | next | |
| 5636 | case False | |
| 5637 |   { fix y assume "a \<le> y" "y \<le> b" "m > 0"
 | |
| 5638 | hence "m *\<^sub>R a + c \<le> m *\<^sub>R y + c" "m *\<^sub>R y + c \<le> m *\<^sub>R b + c" | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 5639 | unfolding vector_le_def by auto | 
| 33175 | 5640 | } moreover | 
| 5641 |   { fix y assume "a \<le> y" "y \<le> b" "m < 0"
 | |
| 5642 | hence "m *\<^sub>R b + c \<le> m *\<^sub>R y + c" "m *\<^sub>R y + c \<le> m *\<^sub>R a + c" | |
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 5643 | unfolding vector_le_def by(auto simp add: mult_left_mono_neg) | 
| 33175 | 5644 | } moreover | 
| 5645 |   { fix y assume "m > 0"  "m *\<^sub>R a + c \<le> y"  "y \<le> m *\<^sub>R b + c"
 | |
| 5646 |     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 | 5647 | unfolding image_iff Bex_def mem_interval vector_le_def | 
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 5648 | apply(auto simp add: vector_smult_assoc pth_3[symmetric] | 
| 33175 | 5649 | intro!: exI[where x="(1 / m) *\<^sub>R (y - c)"]) | 
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5650 | by(auto simp add: pos_le_divide_eq pos_divide_le_eq mult_commute diff_le_iff) | 
| 33175 | 5651 | } moreover | 
| 5652 |   { fix y assume "m *\<^sub>R b + c \<le> y" "y \<le> m *\<^sub>R a + c" "m < 0"
 | |
| 5653 |     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 | 5654 | unfolding image_iff Bex_def mem_interval vector_le_def | 
| 36362 
06475a1547cb
fix lots of looping simp calls and other warnings
 huffman parents: 
36360diff
changeset | 5655 | apply(auto simp add: vector_smult_assoc pth_3[symmetric] | 
| 33175 | 5656 | intro!: exI[where x="(1 / m) *\<^sub>R (y - c)"]) | 
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5657 | by(auto simp add: neg_le_divide_eq neg_divide_le_eq mult_commute diff_le_iff) | 
| 33175 | 5658 | } | 
| 5659 | ultimately show ?thesis using False by auto | |
| 5660 | qed | |
| 5661 | ||
| 34291 
4e896680897e
finite annotation on cartesian product is now implicit.
 hoelzl parents: 
34289diff
changeset | 5662 | lemma image_smult_interval:"(\<lambda>x. m *\<^sub>R (x::real^'n)) ` {a..b} =
 | 
| 33175 | 5663 |   (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})"
 | 
| 5664 | using image_affinity_interval[of m 0 a b] by auto | |
| 5665 | ||
| 5666 | subsection{* Banach fixed point theorem (not really topological...) *}
 | |
| 5667 | ||
| 5668 | lemma banach_fix: | |
| 5669 |   assumes s:"complete s" "s \<noteq> {}" and c:"0 \<le> c" "c < 1" and f:"(f ` s) \<subseteq> s" and
 | |
| 5670 | lipschitz:"\<forall>x\<in>s. \<forall>y\<in>s. dist (f x) (f y) \<le> c * dist x y" | |
| 5671 | shows "\<exists>! x\<in>s. (f x = x)" | |
| 5672 | proof- | |
| 5673 | have "1 - c > 0" using c by auto | |
| 5674 | ||
| 5675 | from s(2) obtain z0 where "z0 \<in> s" by auto | |
| 5676 | def z \<equiv> "\<lambda>n. (f ^^ n) z0" | |
| 5677 |   { fix n::nat
 | |
| 5678 | have "z n \<in> s" unfolding z_def | |
| 5679 | proof(induct n) case 0 thus ?case using `z0 \<in>s` by auto | |
| 5680 | next case Suc thus ?case using f by auto qed } | |
| 5681 | note z_in_s = this | |
| 5682 | ||
| 5683 | def d \<equiv> "dist (z 0) (z 1)" | |
| 5684 | ||
| 5685 | have fzn:"\<And>n. f (z n) = z (Suc n)" unfolding z_def by auto | |
| 5686 |   { fix n::nat
 | |
| 5687 | have "dist (z n) (z (Suc n)) \<le> (c ^ n) * d" | |
| 5688 | proof(induct n) | |
| 5689 | case 0 thus ?case unfolding d_def by auto | |
| 5690 | next | |
| 5691 | case (Suc m) | |
| 5692 | hence "c * dist (z m) (z (Suc m)) \<le> c ^ Suc m * d" | |
| 5693 | using `0 \<le> c` using mult_mono1_class.mult_mono1[of "dist (z m) (z (Suc m))" "c ^ m * d" c] by auto | |
| 5694 | 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] | |
| 5695 | unfolding fzn and mult_le_cancel_left by auto | |
| 5696 | qed | |
| 5697 | } note cf_z = this | |
| 5698 | ||
| 5699 |   { fix n m::nat
 | |
| 5700 | have "(1 - c) * dist (z m) (z (m+n)) \<le> (c ^ m) * d * (1 - c ^ n)" | |
| 5701 | proof(induct n) | |
| 5702 | case 0 show ?case by auto | |
| 5703 | next | |
| 5704 | case (Suc k) | |
| 5705 | 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))))" | |
| 5706 | using dist_triangle and c by(auto simp add: dist_triangle) | |
| 5707 | also have "\<dots> \<le> (1 - c) * (dist (z m) (z (m + k)) + c ^ (m + k) * d)" | |
| 5708 | using cf_z[of "m + k"] and c by auto | |
| 5709 | also have "\<dots> \<le> c ^ m * d * (1 - c ^ k) + (1 - c) * c ^ (m + k) * d" | |
| 36350 | 5710 | using Suc by (auto simp add: field_simps) | 
| 33175 | 5711 | also have "\<dots> = (c ^ m) * (d * (1 - c ^ k) + (1 - c) * c ^ k * d)" | 
| 36350 | 5712 | unfolding power_add by (auto simp add: field_simps) | 
| 33175 | 5713 | also have "\<dots> \<le> (c ^ m) * d * (1 - c ^ Suc k)" | 
| 36350 | 5714 | using c by (auto simp add: field_simps) | 
| 33175 | 5715 | finally show ?case by auto | 
| 5716 | qed | |
| 5717 | } note cf_z2 = this | |
| 5718 |   { fix e::real assume "e>0"
 | |
| 5719 | hence "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (z m) (z n) < e" | |
| 5720 | proof(cases "d = 0") | |
| 5721 | case True | |
| 5722 | 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`]) | |
| 5723 | thus ?thesis using `e>0` by auto | |
| 5724 | next | |
| 5725 | case False hence "d>0" unfolding d_def using zero_le_dist[of "z 0" "z 1"] | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5726 | by (metis False d_def less_le) | 
| 33175 | 5727 | hence "0 < e * (1 - c) / d" using `e>0` and `1-c>0` | 
| 5728 | using divide_pos_pos[of "e * (1 - c)" d] and mult_pos_pos[of e "1 - c"] by auto | |
| 5729 | 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 | |
| 5730 |       { fix m n::nat assume "m>n" and as:"m\<ge>N" "n\<ge>N"
 | |
| 5731 | have *:"c ^ n \<le> c ^ N" using `n\<ge>N` and c using power_decreasing[OF `n\<ge>N`, of c] by auto | |
| 5732 | have "1 - c ^ (m - n) > 0" using c and power_strict_mono[of c 1 "m - n"] using `m>n` by auto | |
| 5733 | hence **:"d * (1 - c ^ (m - n)) / (1 - c) > 0" | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5734 | using mult_pos_pos[OF `d>0`, of "1 - c ^ (m - n)"] | 
| 33175 | 5735 | using divide_pos_pos[of "d * (1 - c ^ (m - n))" "1 - c"] | 
| 5736 | using `0 < 1 - c` by auto | |
| 5737 | ||
| 5738 | have "dist (z m) (z n) \<le> c ^ n * d * (1 - c ^ (m - n)) / (1 - c)" | |
| 5739 | using cf_z2[of n "m - n"] and `m>n` unfolding pos_le_divide_eq[OF `1-c>0`] | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5740 | by (auto simp add: mult_commute dist_commute) | 
| 33175 | 5741 | also have "\<dots> \<le> c ^ N * d * (1 - c ^ (m - n)) / (1 - c)" | 
| 5742 | using mult_right_mono[OF * order_less_imp_le[OF **]] | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5743 | unfolding mult_assoc by auto | 
| 33175 | 5744 | also have "\<dots> < (e * (1 - c) / d) * d * (1 - c ^ (m - n)) / (1 - c)" | 
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5745 | using mult_strict_right_mono[OF N **] unfolding mult_assoc by auto | 
| 33175 | 5746 | also have "\<dots> = e * (1 - c ^ (m - n))" using c and `d>0` and `1 - c > 0` by auto | 
| 5747 | 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 | |
| 5748 | finally have "dist (z m) (z n) < e" by auto | |
| 5749 | } note * = this | |
| 5750 |       { fix m n::nat assume as:"N\<le>m" "N\<le>n"
 | |
| 5751 | hence "dist (z n) (z m) < e" | |
| 5752 | proof(cases "n = m") | |
| 5753 | case True thus ?thesis using `e>0` by auto | |
| 5754 | next | |
| 5755 | case False thus ?thesis using as and *[of n m] *[of m n] unfolding nat_neq_iff by (auto simp add: dist_commute) | |
| 5756 | qed } | |
| 5757 | thus ?thesis by auto | |
| 5758 | qed | |
| 5759 | } | |
| 5760 | hence "Cauchy z" unfolding cauchy_def by auto | |
| 5761 | 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 | |
| 5762 | ||
| 5763 | def e \<equiv> "dist (f x) x" | |
| 5764 | have "e = 0" proof(rule ccontr) | |
| 5765 | assume "e \<noteq> 0" hence "e>0" unfolding e_def using zero_le_dist[of "f x" x] | |
| 5766 | by (metis dist_eq_0_iff dist_nz e_def) | |
| 5767 | then obtain N where N:"\<forall>n\<ge>N. dist (z n) x < e / 2" | |
| 5768 | using x[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto | |
| 5769 | hence N':"dist (z N) x < e / 2" by auto | |
| 5770 | ||
| 5771 | have *:"c * dist (z N) x \<le> dist (z N) x" unfolding mult_le_cancel_right2 | |
| 5772 | using zero_le_dist[of "z N" x] and c | |
| 36778 
739a9379e29b
avoid using real-specific versions of generic lemmas
 huffman parents: 
36669diff
changeset | 5773 | by (metis dist_eq_0_iff dist_nz order_less_asym less_le) | 
| 33175 | 5774 | 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]] | 
| 5775 | using z_in_s[of N] `x\<in>s` using c by auto | |
| 5776 | also have "\<dots> < e / 2" using N' and c using * by auto | |
| 5777 | finally show False unfolding fzn | |
| 5778 | using N[THEN spec[where x="Suc N"]] and dist_triangle_half_r[of "z (Suc N)" "f x" e x] | |
| 5779 | unfolding e_def by auto | |
| 5780 | qed | |
| 5781 | hence "f x = x" unfolding e_def by auto | |
| 5782 | moreover | |
| 5783 |   { fix y assume "f y = y" "y\<in>s"
 | |
| 5784 | hence "dist x y \<le> c * dist x y" using lipschitz[THEN bspec[where x=x], THEN bspec[where x=y]] | |
| 5785 | using `x\<in>s` and `f x = x` by auto | |
| 5786 | hence "dist x y = 0" unfolding mult_le_cancel_right1 | |
| 5787 | using c and zero_le_dist[of x y] by auto | |
| 5788 | hence "y = x" by auto | |
| 5789 | } | |
| 34999 
5312d2ffee3b
Changed 'bounded unique existential quantifiers' from a constant to syntax translation.
 hoelzl parents: 
34964diff
changeset | 5790 | ultimately show ?thesis using `x\<in>s` by blast+ | 
| 33175 | 5791 | qed | 
| 5792 | ||
| 5793 | subsection{* Edelstein fixed point theorem.                                            *}
 | |
| 5794 | ||
| 5795 | lemma edelstein_fix: | |
| 5796 | fixes s :: "'a::real_normed_vector set" | |
| 5797 |   assumes s:"compact s" "s \<noteq> {}" and gs:"(g ` s) \<subseteq> s"
 | |
| 5798 | and dist:"\<forall>x\<in>s. \<forall>y\<in>s. x \<noteq> y \<longrightarrow> dist (g x) (g y) < dist x y" | |
| 5799 | shows "\<exists>! x\<in>s. g x = x" | |
| 5800 | proof(cases "\<exists>x\<in>s. g x \<noteq> x") | |
| 5801 | obtain x where "x\<in>s" using s(2) by auto | |
| 5802 | case False hence g:"\<forall>x\<in>s. g x = x" by auto | |
| 5803 |   { fix y assume "y\<in>s"
 | |
| 5804 | hence "x = y" using `x\<in>s` and dist[THEN bspec[where x=x], THEN bspec[where x=y]] | |
| 5805 | unfolding g[THEN bspec[where x=x], OF `x\<in>s`] | |
| 5806 | unfolding g[THEN bspec[where x=y], OF `y\<in>s`] by auto } | |
| 34999 
5312d2ffee3b
Changed 'bounded unique existential quantifiers' from a constant to syntax translation.
 hoelzl parents: 
34964diff
changeset | 5807 | thus ?thesis using `x\<in>s` and g by blast+ | 
| 33175 | 5808 | next | 
| 5809 | case True | |
| 5810 | then obtain x where [simp]:"x\<in>s" and "g x \<noteq> x" by auto | |
| 5811 |   { fix x y assume "x \<in> s" "y \<in> s"
 | |
| 5812 | hence "dist (g x) (g y) \<le> dist x y" | |
| 5813 | using dist[THEN bspec[where x=x], THEN bspec[where x=y]] by auto } note dist' = this | |
| 5814 | def y \<equiv> "g x" | |
| 5815 | have [simp]:"y\<in>s" unfolding y_def using gs[unfolded image_subset_iff] and `x\<in>s` by blast | |
| 5816 | def f \<equiv> "\<lambda>n. g ^^ n" | |
| 5817 | have [simp]:"\<And>n z. g (f n z) = f (Suc n) z" unfolding f_def by auto | |
| 5818 | have [simp]:"\<And>z. f 0 z = z" unfolding f_def by auto | |
| 5819 |   { fix n::nat and z assume "z\<in>s"
 | |
| 5820 | have "f n z \<in> s" unfolding f_def | |
| 5821 | proof(induct n) | |
| 5822 | case 0 thus ?case using `z\<in>s` by simp | |
| 5823 | next | |
| 5824 | case (Suc n) thus ?case using gs[unfolded image_subset_iff] by auto | |
| 5825 | qed } note fs = this | |
| 5826 |   { fix m n ::nat assume "m\<le>n"
 | |
| 5827 | fix w z assume "w\<in>s" "z\<in>s" | |
| 5828 | have "dist (f n w) (f n z) \<le> dist (f m w) (f m z)" using `m\<le>n` | |
| 5829 | proof(induct n) | |
| 5830 | case 0 thus ?case by auto | |
| 5831 | next | |
| 5832 | case (Suc n) | |
| 5833 | thus ?case proof(cases "m\<le>n") | |
| 5834 | case True thus ?thesis using Suc(1) | |
| 5835 | using dist'[OF fs fs, OF `w\<in>s` `z\<in>s`, of n n] by auto | |
| 5836 | next | |
| 5837 | case False hence mn:"m = Suc n" using Suc(2) by simp | |
| 5838 | show ?thesis unfolding mn by auto | |
| 5839 | qed | |
| 5840 | qed } note distf = this | |
| 5841 | ||
| 5842 | def h \<equiv> "\<lambda>n. (f n x, f n y)" | |
| 5843 | let ?s2 = "s \<times> s" | |
| 5844 | obtain l r where "l\<in>?s2" and r:"subseq r" and lr:"((h \<circ> r) ---> l) sequentially" | |
| 5845 | using compact_Times [OF s(1) s(1), unfolded compact_def, THEN spec[where x=h]] unfolding h_def | |
| 5846 | using fs[OF `x\<in>s`] and fs[OF `y\<in>s`] by blast | |
| 5847 | def a \<equiv> "fst l" def b \<equiv> "snd l" | |
| 5848 | have lab:"l = (a, b)" unfolding a_def b_def by simp | |
| 5849 | have [simp]:"a\<in>s" "b\<in>s" unfolding a_def b_def using `l\<in>?s2` by auto | |
| 5850 | ||
| 5851 | have lima:"((fst \<circ> (h \<circ> r)) ---> a) sequentially" | |
| 5852 | and limb:"((snd \<circ> (h \<circ> r)) ---> b) sequentially" | |
| 5853 | using lr | |
| 5854 | unfolding o_def a_def b_def by (simp_all add: tendsto_intros) | |
| 5855 | ||
| 5856 |   { fix n::nat
 | |
| 5857 | 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 | |
| 5858 |     { fix x y :: 'a
 | |
| 5859 | have "dist (-x) (-y) = dist x y" unfolding dist_norm | |
| 5860 | using norm_minus_cancel[of "x - y"] by (auto simp add: uminus_add_conv_diff) } note ** = this | |
| 5861 | ||
| 5862 |     { assume as:"dist a b > dist (f n x) (f n y)"
 | |
| 5863 | 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" | |
| 5864 | and "\<forall>m\<ge>Nb. dist (f (r m) y) b < (dist a b - dist (f n x) (f n y)) / 2" | |
| 5865 | using lima limb unfolding h_def Lim_sequentially by (fastsimp simp del: less_divide_eq_number_of1) | |
| 5866 | 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)" | |
| 5867 | apply(erule_tac x="Na+Nb+n" in allE) | |
| 5868 | apply(erule_tac x="Na+Nb+n" in allE) apply simp | |
| 5869 | using dist_triangle_add_half[of a "f (r (Na + Nb + n)) x" "dist a b - dist (f n x) (f n y)" | |
| 5870 | "-b" "- f (r (Na + Nb + n)) y"] | |
| 36350 | 5871 | unfolding ** by (auto simp add: algebra_simps dist_commute) | 
| 33175 | 5872 | moreover | 
| 5873 | 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)" | |
| 5874 | using distf[of n "r (Na+Nb+n)", OF _ `x\<in>s` `y\<in>s`] | |
| 5875 | using subseq_bigger[OF r, of "Na+Nb+n"] | |
| 5876 | using *[of "f (r (Na + Nb + n)) x" "f (r (Na + Nb + n)) y" "f n x" "f n y"] by auto | |
| 5877 | ultimately have False by simp | |
| 5878 | } | |
| 5879 | hence "dist a b \<le> dist (f n x) (f n y)" by(rule ccontr)auto } | |
| 5880 | note ab_fn = this | |
| 5881 | ||
| 5882 | have [simp]:"a = b" proof(rule ccontr) | |
| 5883 | def e \<equiv> "dist a b - dist (g a) (g b)" | |
| 5884 | assume "a\<noteq>b" hence "e > 0" unfolding e_def using dist by fastsimp | |
| 5885 | hence "\<exists>n. dist (f n x) a < e/2 \<and> dist (f n y) b < e/2" | |
| 5886 | using lima limb unfolding Lim_sequentially | |
| 5887 | apply (auto elim!: allE[where x="e/2"]) apply(rule_tac x="r (max N Na)" in exI) unfolding h_def by fastsimp | |
| 5888 | then obtain n where n:"dist (f n x) a < e/2 \<and> dist (f n y) b < e/2" by auto | |
| 5889 | have "dist (f (Suc n) x) (g a) \<le> dist (f n x) a" | |
| 5890 | using dist[THEN bspec[where x="f n x"], THEN bspec[where x="a"]] and fs by auto | |
| 5891 | moreover have "dist (f (Suc n) y) (g b) \<le> dist (f n y) b" | |
| 5892 | using dist[THEN bspec[where x="f n y"], THEN bspec[where x="b"]] and fs by auto | |
| 5893 | ultimately have "dist (f (Suc n) x) (g a) + dist (f (Suc n) y) (g b) < e" using n by auto | |
| 5894 | thus False unfolding e_def using ab_fn[of "Suc n"] by norm | |
| 5895 | qed | |
| 5896 | ||
| 5897 | have [simp]:"\<And>n. f (Suc n) x = f n y" unfolding f_def y_def by(induct_tac n)auto | |
| 5898 |   { fix x y assume "x\<in>s" "y\<in>s" moreover
 | |
| 5899 | fix e::real assume "e>0" ultimately | |
| 5900 | have "dist y x < e \<longrightarrow> dist (g y) (g x) < e" using dist by fastsimp } | |
| 36359 | 5901 | hence "continuous_on s g" unfolding continuous_on_iff by auto | 
| 33175 | 5902 | |
| 5903 | hence "((snd \<circ> h \<circ> r) ---> g a) sequentially" unfolding continuous_on_sequentially | |
| 5904 | apply (rule allE[where x="\<lambda>n. (fst \<circ> h \<circ> r) n"]) apply (erule ballE[where x=a]) | |
| 5905 | using lima unfolding h_def o_def using fs[OF `x\<in>s`] by (auto simp add: y_def) | |
| 5906 | hence "g a = a" using Lim_unique[OF trivial_limit_sequentially limb, of "g a"] | |
| 5907 | unfolding `a=b` and o_assoc by auto | |
| 5908 | moreover | |
| 5909 |   { fix x assume "x\<in>s" "g x = x" "x\<noteq>a"
 | |
| 5910 | hence "False" using dist[THEN bspec[where x=a], THEN bspec[where x=x]] | |
| 5911 | using `g a = a` and `a\<in>s` by auto } | |
| 34999 
5312d2ffee3b
Changed 'bounded unique existential quantifiers' from a constant to syntax translation.
 hoelzl parents: 
34964diff
changeset | 5912 | ultimately show "\<exists>!x\<in>s. g x = x" using `a\<in>s` by blast | 
| 33175 | 5913 | qed | 
| 5914 | ||
| 5915 | end |