merged
authorpaulson
Tue Mar 19 16:14:59 2019 +0000 (3 months ago)
changeset 69923cd8b6f32ed79
parent 69921 5f67c5e457e3
parent 69922 4a9167f377b0
child 69924 512ac874bb9d
merged
     1.1 --- a/src/HOL/Analysis/Abstract_Topology.thy	Mon Mar 18 21:50:51 2019 +0100
     1.2 +++ b/src/HOL/Analysis/Abstract_Topology.thy	Tue Mar 19 16:14:59 2019 +0000
     1.3 @@ -8,7 +8,6 @@
     1.4      Complex_Main
     1.5      "HOL-Library.Set_Idioms"
     1.6      "HOL-Library.FuncSet"
     1.7 -    (* Path_Connected *)
     1.8  begin
     1.9  
    1.10  subsection \<open>General notion of a topology as a value\<close>
    1.11 @@ -427,7 +426,7 @@
    1.12  lemma topspace_euclidean [simp]: "topspace euclidean = UNIV"
    1.13    by (force simp: topspace_def)
    1.14  
    1.15 -lemma topspace_euclidean_subtopology[simp]: "topspace (subtopology euclidean S) = S"
    1.16 +lemma topspace_euclidean_subtopology[simp]: "topspace (top_of_set S) = S"
    1.17    by (simp add: topspace_subtopology)
    1.18  
    1.19  lemma closed_closedin: "closed S \<longleftrightarrow> closedin euclidean S"
    1.20 @@ -435,7 +434,7 @@
    1.21  
    1.22  declare closed_closedin [symmetric, simp]
    1.23  
    1.24 -lemma openin_subtopology_self [simp]: "openin (subtopology euclidean S) S"
    1.25 +lemma openin_subtopology_self [simp]: "openin (top_of_set S) S"
    1.26    by (metis openin_topspace topspace_euclidean_subtopology)
    1.27  
    1.28  subsubsection\<open>The most basic facts about the usual topology and metric on R\<close>
    1.29 @@ -445,51 +444,51 @@
    1.30  
    1.31  subsection \<open>Basic "localization" results are handy for connectedness.\<close>
    1.32  
    1.33 -lemma openin_open: "openin (subtopology euclidean U) S \<longleftrightarrow> (\<exists>T. open T \<and> (S = U \<inter> T))"
    1.34 +lemma openin_open: "openin (top_of_set U) S \<longleftrightarrow> (\<exists>T. open T \<and> (S = U \<inter> T))"
    1.35    by (auto simp: openin_subtopology)
    1.36  
    1.37  lemma openin_Int_open:
    1.38 -   "\<lbrakk>openin (subtopology euclidean U) S; open T\<rbrakk>
    1.39 -        \<Longrightarrow> openin (subtopology euclidean U) (S \<inter> T)"
    1.40 +   "\<lbrakk>openin (top_of_set U) S; open T\<rbrakk>
    1.41 +        \<Longrightarrow> openin (top_of_set U) (S \<inter> T)"
    1.42  by (metis open_Int Int_assoc openin_open)
    1.43  
    1.44 -lemma openin_open_Int[intro]: "open S \<Longrightarrow> openin (subtopology euclidean U) (U \<inter> S)"
    1.45 +lemma openin_open_Int[intro]: "open S \<Longrightarrow> openin (top_of_set U) (U \<inter> S)"
    1.46    by (auto simp: openin_open)
    1.47  
    1.48  lemma open_openin_trans[trans]:
    1.49 -  "open S \<Longrightarrow> open T \<Longrightarrow> T \<subseteq> S \<Longrightarrow> openin (subtopology euclidean S) T"
    1.50 +  "open S \<Longrightarrow> open T \<Longrightarrow> T \<subseteq> S \<Longrightarrow> openin (top_of_set S) T"
    1.51    by (metis Int_absorb1  openin_open_Int)
    1.52  
    1.53 -lemma open_subset: "S \<subseteq> T \<Longrightarrow> open S \<Longrightarrow> openin (subtopology euclidean T) S"
    1.54 +lemma open_subset: "S \<subseteq> T \<Longrightarrow> open S \<Longrightarrow> openin (top_of_set T) S"
    1.55    by (auto simp: openin_open)
    1.56  
    1.57 -lemma closedin_closed: "closedin (subtopology euclidean U) S \<longleftrightarrow> (\<exists>T. closed T \<and> S = U \<inter> T)"
    1.58 +lemma closedin_closed: "closedin (top_of_set U) S \<longleftrightarrow> (\<exists>T. closed T \<and> S = U \<inter> T)"
    1.59    by (simp add: closedin_subtopology Int_ac)
    1.60  
    1.61 -lemma closedin_closed_Int: "closed S \<Longrightarrow> closedin (subtopology euclidean U) (U \<inter> S)"
    1.62 +lemma closedin_closed_Int: "closed S \<Longrightarrow> closedin (top_of_set U) (U \<inter> S)"
    1.63    by (metis closedin_closed)
    1.64  
    1.65 -lemma closed_subset: "S \<subseteq> T \<Longrightarrow> closed S \<Longrightarrow> closedin (subtopology euclidean T) S"
    1.66 +lemma closed_subset: "S \<subseteq> T \<Longrightarrow> closed S \<Longrightarrow> closedin (top_of_set T) S"
    1.67    by (auto simp: closedin_closed)
    1.68  
    1.69  lemma closedin_closed_subset:
    1.70 - "\<lbrakk>closedin (subtopology euclidean U) V; T \<subseteq> U; S = V \<inter> T\<rbrakk>
    1.71 -             \<Longrightarrow> closedin (subtopology euclidean T) S"
    1.72 + "\<lbrakk>closedin (top_of_set U) V; T \<subseteq> U; S = V \<inter> T\<rbrakk>
    1.73 +             \<Longrightarrow> closedin (top_of_set T) S"
    1.74    by (metis (no_types, lifting) Int_assoc Int_commute closedin_closed inf.orderE)
    1.75  
    1.76  lemma finite_imp_closedin:
    1.77    fixes S :: "'a::t1_space set"
    1.78 -  shows "\<lbrakk>finite S; S \<subseteq> T\<rbrakk> \<Longrightarrow> closedin (subtopology euclidean T) S"
    1.79 +  shows "\<lbrakk>finite S; S \<subseteq> T\<rbrakk> \<Longrightarrow> closedin (top_of_set T) S"
    1.80      by (simp add: finite_imp_closed closed_subset)
    1.81  
    1.82  lemma closedin_singleton [simp]:
    1.83    fixes a :: "'a::t1_space"
    1.84 -  shows "closedin (subtopology euclidean U) {a} \<longleftrightarrow> a \<in> U"
    1.85 +  shows "closedin (top_of_set U) {a} \<longleftrightarrow> a \<in> U"
    1.86  using closedin_subset  by (force intro: closed_subset)
    1.87  
    1.88  lemma openin_euclidean_subtopology_iff:
    1.89    fixes S U :: "'a::metric_space set"
    1.90 -  shows "openin (subtopology euclidean U) S \<longleftrightarrow>
    1.91 +  shows "openin (top_of_set U) S \<longleftrightarrow>
    1.92      S \<subseteq> U \<and> (\<forall>x\<in>S. \<exists>e>0. \<forall>x'\<in>U. dist x' x < e \<longrightarrow> x'\<in> S)"
    1.93    (is "?lhs \<longleftrightarrow> ?rhs")
    1.94  proof
    1.95 @@ -513,16 +512,16 @@
    1.96  
    1.97  lemma connected_openin:
    1.98        "connected S \<longleftrightarrow>
    1.99 -       \<not>(\<exists>E1 E2. openin (subtopology euclidean S) E1 \<and>
   1.100 -                 openin (subtopology euclidean S) E2 \<and>
   1.101 +       \<not>(\<exists>E1 E2. openin (top_of_set S) E1 \<and>
   1.102 +                 openin (top_of_set S) E2 \<and>
   1.103                   S \<subseteq> E1 \<union> E2 \<and> E1 \<inter> E2 = {} \<and> E1 \<noteq> {} \<and> E2 \<noteq> {})"
   1.104    apply (simp add: connected_def openin_open disjoint_iff_not_equal, safe)
   1.105    by (simp_all, blast+)  (* SLOW *)
   1.106  
   1.107  lemma connected_openin_eq:
   1.108        "connected S \<longleftrightarrow>
   1.109 -       \<not>(\<exists>E1 E2. openin (subtopology euclidean S) E1 \<and>
   1.110 -                 openin (subtopology euclidean S) E2 \<and>
   1.111 +       \<not>(\<exists>E1 E2. openin (top_of_set S) E1 \<and>
   1.112 +                 openin (top_of_set S) E2 \<and>
   1.113                   E1 \<union> E2 = S \<and> E1 \<inter> E2 = {} \<and>
   1.114                   E1 \<noteq> {} \<and> E2 \<noteq> {})"
   1.115    apply (simp add: connected_openin, safe, blast)
   1.116 @@ -531,8 +530,8 @@
   1.117  lemma connected_closedin:
   1.118        "connected S \<longleftrightarrow>
   1.119         (\<nexists>E1 E2.
   1.120 -        closedin (subtopology euclidean S) E1 \<and>
   1.121 -        closedin (subtopology euclidean S) E2 \<and>
   1.122 +        closedin (top_of_set S) E1 \<and>
   1.123 +        closedin (top_of_set S) E2 \<and>
   1.124          S \<subseteq> E1 \<union> E2 \<and> E1 \<inter> E2 = {} \<and> E1 \<noteq> {} \<and> E2 \<noteq> {})"
   1.125         (is "?lhs = ?rhs")
   1.126  proof
   1.127 @@ -561,8 +560,8 @@
   1.128  lemma connected_closedin_eq:
   1.129        "connected S \<longleftrightarrow>
   1.130             \<not>(\<exists>E1 E2.
   1.131 -                 closedin (subtopology euclidean S) E1 \<and>
   1.132 -                 closedin (subtopology euclidean S) E2 \<and>
   1.133 +                 closedin (top_of_set S) E1 \<and>
   1.134 +                 closedin (top_of_set S) E2 \<and>
   1.135                   E1 \<union> E2 = S \<and> E1 \<inter> E2 = {} \<and>
   1.136                   E1 \<noteq> {} \<and> E2 \<noteq> {})"
   1.137    apply (simp add: connected_closedin, safe, blast)
   1.138 @@ -571,26 +570,26 @@
   1.139  text \<open>These "transitivity" results are handy too\<close>
   1.140  
   1.141  lemma openin_trans[trans]:
   1.142 -  "openin (subtopology euclidean T) S \<Longrightarrow> openin (subtopology euclidean U) T \<Longrightarrow>
   1.143 -    openin (subtopology euclidean U) S"
   1.144 +  "openin (top_of_set T) S \<Longrightarrow> openin (top_of_set U) T \<Longrightarrow>
   1.145 +    openin (top_of_set U) S"
   1.146    by (metis openin_Int_open openin_open)
   1.147  
   1.148 -lemma openin_open_trans: "openin (subtopology euclidean T) S \<Longrightarrow> open T \<Longrightarrow> open S"
   1.149 +lemma openin_open_trans: "openin (top_of_set T) S \<Longrightarrow> open T \<Longrightarrow> open S"
   1.150    by (auto simp: openin_open intro: openin_trans)
   1.151  
   1.152  lemma closedin_trans[trans]:
   1.153 -  "closedin (subtopology euclidean T) S \<Longrightarrow> closedin (subtopology euclidean U) T \<Longrightarrow>
   1.154 -    closedin (subtopology euclidean U) S"
   1.155 +  "closedin (top_of_set T) S \<Longrightarrow> closedin (top_of_set U) T \<Longrightarrow>
   1.156 +    closedin (top_of_set U) S"
   1.157    by (auto simp: closedin_closed closed_Inter Int_assoc)
   1.158  
   1.159 -lemma closedin_closed_trans: "closedin (subtopology euclidean T) S \<Longrightarrow> closed T \<Longrightarrow> closed S"
   1.160 +lemma closedin_closed_trans: "closedin (top_of_set T) S \<Longrightarrow> closed T \<Longrightarrow> closed S"
   1.161    by (auto simp: closedin_closed intro: closedin_trans)
   1.162  
   1.163  lemma openin_subtopology_Int_subset:
   1.164 -   "\<lbrakk>openin (subtopology euclidean u) (u \<inter> S); v \<subseteq> u\<rbrakk> \<Longrightarrow> openin (subtopology euclidean v) (v \<inter> S)"
   1.165 +   "\<lbrakk>openin (top_of_set u) (u \<inter> S); v \<subseteq> u\<rbrakk> \<Longrightarrow> openin (top_of_set v) (v \<inter> S)"
   1.166    by (auto simp: openin_subtopology)
   1.167  
   1.168 -lemma openin_open_eq: "open s \<Longrightarrow> (openin (subtopology euclidean s) t \<longleftrightarrow> open t \<and> t \<subseteq> s)"
   1.169 +lemma openin_open_eq: "open s \<Longrightarrow> (openin (top_of_set s) t \<longleftrightarrow> open t \<and> t \<subseteq> s)"
   1.170    using open_subset openin_open_trans openin_subset by fastforce
   1.171  
   1.172  
   1.173 @@ -1684,11 +1683,11 @@
   1.174    "continuous_map (discrete_topology U) X f \<longleftrightarrow> f ` U \<subseteq> topspace X"
   1.175    by (auto simp: continuous_map_def)
   1.176  
   1.177 -lemma continuous_map_iff_continuous_real [simp]: "continuous_map (subtopology euclideanreal S) euclideanreal g = continuous_on S g"
   1.178 -  by (force simp: continuous_map openin_subtopology continuous_on_open_invariant)
   1.179 -
   1.180 -lemma continuous_map_iff_continuous_real2 [simp]: "continuous_map euclideanreal euclideanreal g = continuous_on UNIV g"
   1.181 -  by (metis continuous_map_iff_continuous_real subtopology_UNIV)
   1.182 +lemma continuous_map_iff_continuous [simp]: "continuous_map (subtopology euclidean S) euclidean g = continuous_on S g"
   1.183 +  by (fastforce simp add: continuous_map openin_subtopology continuous_on_open_invariant)
   1.184 +
   1.185 +lemma continuous_map_iff_continuous2 [simp]: "continuous_map euclidean euclidean g = continuous_on UNIV g"
   1.186 +  by (metis continuous_map_iff_continuous subtopology_UNIV)
   1.187  
   1.188  lemma continuous_map_openin_preimage_eq:
   1.189     "continuous_map X Y f \<longleftrightarrow>
   1.190 @@ -2844,9 +2843,8 @@
   1.191      done
   1.192  qed
   1.193  
   1.194 -lemma connectedin_iff_connected_real [simp]:
   1.195 -     "connectedin euclideanreal S \<longleftrightarrow> connected S"
   1.196 -    by (simp add: connected_def connectedin)
   1.197 +lemma connectedin_iff_connected [simp]: "connectedin euclidean S \<longleftrightarrow> connected S"
   1.198 +  by (simp add: connected_def connectedin)
   1.199  
   1.200  lemma connectedin_closedin:
   1.201     "connectedin X S \<longleftrightarrow>
   1.202 @@ -3190,7 +3188,7 @@
   1.203    unfolding compact_space_alt
   1.204    using openin_subset by fastforce
   1.205  
   1.206 -lemma compactin_euclideanreal_iff [simp]: "compactin euclideanreal S \<longleftrightarrow> compact S"
   1.207 +lemma compactin_euclidean_iff [simp]: "compactin euclidean S \<longleftrightarrow> compact S"
   1.208    by (simp add: compact_eq_Heine_Borel compactin_def) meson
   1.209  
   1.210  lemma compactin_absolute [simp]:
   1.211 @@ -3639,36 +3637,127 @@
   1.212    unfolding embedding_map_def
   1.213    using homeomorphic_space by blast
   1.214  
   1.215 +
   1.216 +subsection\<open>Retraction and section maps\<close>
   1.217 +
   1.218 +definition retraction_maps :: "'a topology \<Rightarrow> 'b topology \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> bool"
   1.219 +  where "retraction_maps X Y f g \<equiv>
   1.220 +           continuous_map X Y f \<and> continuous_map Y X g \<and> (\<forall>x \<in> topspace Y. f(g x) = x)"
   1.221 +
   1.222 +definition section_map :: "'a topology \<Rightarrow> 'b topology \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
   1.223 +  where "section_map X Y f \<equiv> \<exists>g. retraction_maps Y X g f"
   1.224 +
   1.225 +definition retraction_map :: "'a topology \<Rightarrow> 'b topology \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
   1.226 +  where "retraction_map X Y f \<equiv> \<exists>g. retraction_maps X Y f g"
   1.227 +
   1.228 +lemma retraction_maps_eq:
   1.229 +   "\<lbrakk>retraction_maps X Y f g; \<And>x. x \<in> topspace X \<Longrightarrow> f x = f' x; \<And>x. x \<in> topspace Y \<Longrightarrow> g x = g' x\<rbrakk>
   1.230 +        \<Longrightarrow> retraction_maps X Y f' g'"
   1.231 +  unfolding retraction_maps_def by (metis (no_types, lifting) continuous_map_def continuous_map_eq)
   1.232 +
   1.233 +lemma section_map_eq:
   1.234 +   "\<lbrakk>section_map X Y f; \<And>x. x \<in> topspace X \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> section_map X Y g"
   1.235 +  unfolding section_map_def using retraction_maps_eq by blast
   1.236 +
   1.237 +lemma retraction_map_eq:
   1.238 +   "\<lbrakk>retraction_map X Y f; \<And>x. x \<in> topspace X \<Longrightarrow> f x = g x\<rbrakk> \<Longrightarrow> retraction_map X Y g"
   1.239 +  unfolding retraction_map_def using retraction_maps_eq by blast
   1.240 +
   1.241 +lemma homeomorphic_imp_retraction_maps:
   1.242 +   "homeomorphic_maps X Y f g \<Longrightarrow> retraction_maps X Y f g"
   1.243 +  by (simp add: homeomorphic_maps_def retraction_maps_def)
   1.244 +
   1.245 +lemma section_and_retraction_eq_homeomorphic_map:
   1.246 +   "section_map X Y f \<and> retraction_map X Y f \<longleftrightarrow> homeomorphic_map X Y f"
   1.247 +  apply (auto simp: section_map_def retraction_map_def homeomorphic_map_maps retraction_maps_def homeomorphic_maps_def)
   1.248 +  by (metis (full_types) continuous_map_image_subset_topspace image_subset_iff)
   1.249 +
   1.250 +lemma section_imp_embedding_map:
   1.251 +   "section_map X Y f \<Longrightarrow> embedding_map X Y f"
   1.252 +  unfolding section_map_def embedding_map_def homeomorphic_map_maps retraction_maps_def homeomorphic_maps_def
   1.253 +  by (force simp: continuous_map_in_subtopology continuous_map_from_subtopology topspace_subtopology)
   1.254 +
   1.255 +lemma retraction_imp_quotient_map:
   1.256 +  assumes "retraction_map X Y f"
   1.257 +  shows "quotient_map X Y f"
   1.258 +  unfolding quotient_map_def
   1.259 +proof (intro conjI subsetI allI impI)
   1.260 +  show "f ` topspace X = topspace Y"
   1.261 +    using assms by (force simp: retraction_map_def retraction_maps_def continuous_map_def)
   1.262 +next
   1.263 +  fix U
   1.264 +  assume U: "U \<subseteq> topspace Y"
   1.265 +  have "openin Y U"
   1.266 +    if "\<forall>x\<in>topspace Y. g x \<in> topspace X" "\<forall>x\<in>topspace Y. f (g x) = x"
   1.267 +       "openin Y {x \<in> topspace Y. g x \<in> {x \<in> topspace X. f x \<in> U}}" for g
   1.268 +    using openin_subopen U that by fastforce
   1.269 +  then show "openin X {x \<in> topspace X. f x \<in> U} = openin Y U"
   1.270 +    using assms by (auto simp: retraction_map_def retraction_maps_def continuous_map_def)
   1.271 +qed
   1.272 +
   1.273 +lemma retraction_maps_compose:
   1.274 +   "\<lbrakk>retraction_maps X Y f f'; retraction_maps Y Z g g'\<rbrakk> \<Longrightarrow> retraction_maps X Z (g \<circ> f) (f' \<circ> g')"
   1.275 +  by (clarsimp simp: retraction_maps_def continuous_map_compose) (simp add: continuous_map_def)
   1.276 +
   1.277 +lemma retraction_map_compose:
   1.278 +   "\<lbrakk>retraction_map X Y f; retraction_map Y Z g\<rbrakk> \<Longrightarrow> retraction_map X Z (g \<circ> f)"
   1.279 +  by (meson retraction_map_def retraction_maps_compose)
   1.280 +
   1.281 +lemma section_map_compose:
   1.282 +   "\<lbrakk>section_map X Y f; section_map Y Z g\<rbrakk> \<Longrightarrow> section_map X Z (g \<circ> f)"
   1.283 +  by (meson retraction_maps_compose section_map_def)
   1.284 +
   1.285 +lemma surjective_section_eq_homeomorphic_map:
   1.286 +   "section_map X Y f \<and> f ` (topspace X) = topspace Y \<longleftrightarrow> homeomorphic_map X Y f"
   1.287 +  by (meson section_and_retraction_eq_homeomorphic_map section_imp_embedding_map surjective_embedding_map)
   1.288 +
   1.289 +lemma surjective_retraction_or_section_map:
   1.290 +   "f ` (topspace X) = topspace Y \<Longrightarrow> retraction_map X Y f \<or> section_map X Y f \<longleftrightarrow> retraction_map X Y f"
   1.291 +  using section_and_retraction_eq_homeomorphic_map surjective_section_eq_homeomorphic_map by fastforce
   1.292 +
   1.293 +lemma retraction_imp_surjective_map:
   1.294 +   "retraction_map X Y f \<Longrightarrow> f ` (topspace X) = topspace Y"
   1.295 +  by (simp add: retraction_imp_quotient_map quotient_imp_surjective_map)
   1.296 +
   1.297 +lemma section_imp_injective_map:
   1.298 +   "\<lbrakk>section_map X Y f; x \<in> topspace X; y \<in> topspace X\<rbrakk> \<Longrightarrow> f x = f y \<longleftrightarrow> x = y"
   1.299 +  by (metis (mono_tags, hide_lams) retraction_maps_def section_map_def)
   1.300 +
   1.301 +lemma retraction_maps_to_retract_maps:
   1.302 +   "retraction_maps X Y r s
   1.303 +        \<Longrightarrow> retraction_maps X (subtopology X (s ` (topspace Y))) (s \<circ> r) id"
   1.304 +  unfolding retraction_maps_def
   1.305 +  by (auto simp: continuous_map_compose continuous_map_into_subtopology continuous_map_from_subtopology)
   1.306  subsection \<open>Continuity\<close>
   1.307  
   1.308  lemma continuous_on_open:
   1.309    "continuous_on S f \<longleftrightarrow>
   1.310 -    (\<forall>T. openin (subtopology euclidean (f ` S)) T \<longrightarrow>
   1.311 -      openin (subtopology euclidean S) (S \<inter> f -` T))"
   1.312 +    (\<forall>T. openin (top_of_set (f ` S)) T \<longrightarrow>
   1.313 +      openin (top_of_set S) (S \<inter> f -` T))"
   1.314    unfolding continuous_on_open_invariant openin_open Int_def vimage_def Int_commute
   1.315    by (simp add: imp_ex imageI conj_commute eq_commute cong: conj_cong)
   1.316  
   1.317  lemma continuous_on_closed:
   1.318    "continuous_on S f \<longleftrightarrow>
   1.319 -    (\<forall>T. closedin (subtopology euclidean (f ` S)) T \<longrightarrow>
   1.320 -      closedin (subtopology euclidean S) (S \<inter> f -` T))"
   1.321 +    (\<forall>T. closedin (top_of_set (f ` S)) T \<longrightarrow>
   1.322 +      closedin (top_of_set S) (S \<inter> f -` T))"
   1.323    unfolding continuous_on_closed_invariant closedin_closed Int_def vimage_def Int_commute
   1.324    by (simp add: imp_ex imageI conj_commute eq_commute cong: conj_cong)
   1.325  
   1.326  lemma continuous_on_imp_closedin:
   1.327 -  assumes "continuous_on S f" "closedin (subtopology euclidean (f ` S)) T"
   1.328 -  shows "closedin (subtopology euclidean S) (S \<inter> f -` T)"
   1.329 +  assumes "continuous_on S f" "closedin (top_of_set (f ` S)) T"
   1.330 +  shows "closedin (top_of_set S) (S \<inter> f -` T)"
   1.331    using assms continuous_on_closed by blast
   1.332  
   1.333  subsection%unimportant \<open>Half-global and completely global cases\<close>
   1.334  
   1.335  lemma continuous_openin_preimage_gen:
   1.336    assumes "continuous_on S f"  "open T"
   1.337 -  shows "openin (subtopology euclidean S) (S \<inter> f -` T)"
   1.338 +  shows "openin (top_of_set S) (S \<inter> f -` T)"
   1.339  proof -
   1.340    have *: "(S \<inter> f -` T) = (S \<inter> f -` (T \<inter> f ` S))"
   1.341      by auto
   1.342 -  have "openin (subtopology euclidean (f ` S)) (T \<inter> f ` S)"
   1.343 +  have "openin (top_of_set (f ` S)) (T \<inter> f ` S)"
   1.344      using openin_open_Int[of T "f ` S", OF assms(2)] unfolding openin_open by auto
   1.345    then show ?thesis
   1.346      using assms(1)[unfolded continuous_on_open, THEN spec[where x="T \<inter> f ` S"]]
   1.347 @@ -3677,11 +3766,11 @@
   1.348  
   1.349  lemma continuous_closedin_preimage:
   1.350    assumes "continuous_on S f" and "closed T"
   1.351 -  shows "closedin (subtopology euclidean S) (S \<inter> f -` T)"
   1.352 +  shows "closedin (top_of_set S) (S \<inter> f -` T)"
   1.353  proof -
   1.354    have *: "(S \<inter> f -` T) = (S \<inter> f -` (T \<inter> f ` S))"
   1.355      by auto
   1.356 -  have "closedin (subtopology euclidean (f ` S)) (T \<inter> f ` S)"
   1.357 +  have "closedin (top_of_set (f ` S)) (T \<inter> f ` S)"
   1.358      using closedin_closed_Int[of T "f ` S", OF assms(2)]
   1.359      by (simp add: Int_commute)
   1.360    then show ?thesis
   1.361 @@ -3691,7 +3780,7 @@
   1.362  
   1.363  lemma continuous_openin_preimage_eq:
   1.364     "continuous_on S f \<longleftrightarrow>
   1.365 -    (\<forall>T. open T \<longrightarrow> openin (subtopology euclidean S) (S \<inter> f -` T))"
   1.366 +    (\<forall>T. open T \<longrightarrow> openin (top_of_set S) (S \<inter> f -` T))"
   1.367  apply safe
   1.368  apply (simp add: continuous_openin_preimage_gen)
   1.369  apply (fastforce simp add: continuous_on_open openin_open)
   1.370 @@ -3699,7 +3788,7 @@
   1.371  
   1.372  lemma continuous_closedin_preimage_eq:
   1.373     "continuous_on S f \<longleftrightarrow>
   1.374 -    (\<forall>T. closed T \<longrightarrow> closedin (subtopology euclidean S) (S \<inter> f -` T))"
   1.375 +    (\<forall>T. closed T \<longrightarrow> closedin (top_of_set S) (S \<inter> f -` T))"
   1.376  apply safe
   1.377  apply (simp add: continuous_closedin_preimage)
   1.378  apply (fastforce simp add: continuous_on_closed closedin_closed)
   1.379 @@ -3733,9 +3822,9 @@
   1.380    by (simp add: closed_vimage continuous_on_eq_continuous_within)
   1.381  
   1.382  lemma Times_in_interior_subtopology:
   1.383 -  assumes "(x, y) \<in> U" "openin (subtopology euclidean (S \<times> T)) U"
   1.384 -  obtains V W where "openin (subtopology euclidean S) V" "x \<in> V"
   1.385 -                    "openin (subtopology euclidean T) W" "y \<in> W" "(V \<times> W) \<subseteq> U"
   1.386 +  assumes "(x, y) \<in> U" "openin (top_of_set (S \<times> T)) U"
   1.387 +  obtains V W where "openin (top_of_set S) V" "x \<in> V"
   1.388 +                    "openin (top_of_set T) W" "y \<in> W" "(V \<times> W) \<subseteq> U"
   1.389  proof -
   1.390    from assms obtain E where "open E" "U = S \<times> T \<inter> E" "(x, y) \<in> E" "x \<in> S" "y \<in> T"
   1.391      by (auto simp: openin_open)
   1.392 @@ -3744,8 +3833,8 @@
   1.393      by blast
   1.394    show ?thesis
   1.395    proof
   1.396 -    show "openin (subtopology euclidean S) (E1 \<inter> S)"
   1.397 -      "openin (subtopology euclidean T) (E2 \<inter> T)"
   1.398 +    show "openin (top_of_set S) (E1 \<inter> S)"
   1.399 +      "openin (top_of_set T) (E2 \<inter> T)"
   1.400        using \<open>open E1\<close> \<open>open E2\<close>
   1.401        by (auto simp: openin_open)
   1.402      show "x \<in> E1 \<inter> S" "y \<in> E2 \<inter> T"
   1.403 @@ -3757,20 +3846,20 @@
   1.404  qed
   1.405  
   1.406  lemma closedin_Times:
   1.407 -  "closedin (subtopology euclidean S) S' \<Longrightarrow> closedin (subtopology euclidean T) T' \<Longrightarrow>
   1.408 -    closedin (subtopology euclidean (S \<times> T)) (S' \<times> T')"
   1.409 +  "closedin (top_of_set S) S' \<Longrightarrow> closedin (top_of_set T) T' \<Longrightarrow>
   1.410 +    closedin (top_of_set (S \<times> T)) (S' \<times> T')"
   1.411    unfolding closedin_closed using closed_Times by blast
   1.412  
   1.413  lemma openin_Times:
   1.414 -  "openin (subtopology euclidean S) S' \<Longrightarrow> openin (subtopology euclidean T) T' \<Longrightarrow>
   1.415 -    openin (subtopology euclidean (S \<times> T)) (S' \<times> T')"
   1.416 +  "openin (top_of_set S) S' \<Longrightarrow> openin (top_of_set T) T' \<Longrightarrow>
   1.417 +    openin (top_of_set (S \<times> T)) (S' \<times> T')"
   1.418    unfolding openin_open using open_Times by blast
   1.419  
   1.420  lemma openin_Times_eq:
   1.421    fixes S :: "'a::topological_space set" and T :: "'b::topological_space set"
   1.422    shows
   1.423 -    "openin (subtopology euclidean (S \<times> T)) (S' \<times> T') \<longleftrightarrow>
   1.424 -      S' = {} \<or> T' = {} \<or> openin (subtopology euclidean S) S' \<and> openin (subtopology euclidean T) T'"
   1.425 +    "openin (top_of_set (S \<times> T)) (S' \<times> T') \<longleftrightarrow>
   1.426 +      S' = {} \<or> T' = {} \<or> openin (top_of_set S) S' \<and> openin (top_of_set T) T'"
   1.427      (is "?lhs = ?rhs")
   1.428  proof (cases "S' = {} \<or> T' = {}")
   1.429    case True
   1.430 @@ -3782,13 +3871,13 @@
   1.431    show ?thesis
   1.432    proof
   1.433      assume ?lhs
   1.434 -    have "openin (subtopology euclidean S) S'"
   1.435 +    have "openin (top_of_set S) S'"
   1.436        apply (subst openin_subopen, clarify)
   1.437        apply (rule Times_in_interior_subtopology [OF _ \<open>?lhs\<close>])
   1.438        using \<open>y \<in> T'\<close>
   1.439         apply auto
   1.440        done
   1.441 -    moreover have "openin (subtopology euclidean T) T'"
   1.442 +    moreover have "openin (top_of_set T) T'"
   1.443        apply (subst openin_subopen, clarify)
   1.444        apply (rule Times_in_interior_subtopology [OF _ \<open>?lhs\<close>])
   1.445        using \<open>x \<in> S'\<close>
   1.446 @@ -3805,7 +3894,7 @@
   1.447  
   1.448  lemma Lim_transform_within_openin:
   1.449    assumes f: "(f \<longlongrightarrow> l) (at a within T)"
   1.450 -    and "openin (subtopology euclidean T) S" "a \<in> S"
   1.451 +    and "openin (top_of_set T) S" "a \<in> S"
   1.452      and eq: "\<And>x. \<lbrakk>x \<in> S; x \<noteq> a\<rbrakk> \<Longrightarrow> f x = g x"
   1.453    shows "(g \<longlongrightarrow> l) (at a within T)"
   1.454  proof -
   1.455 @@ -3827,8 +3916,8 @@
   1.456  lemma continuous_on_open_gen:
   1.457    assumes "f ` S \<subseteq> T"
   1.458      shows "continuous_on S f \<longleftrightarrow>
   1.459 -             (\<forall>U. openin (subtopology euclidean T) U
   1.460 -                  \<longrightarrow> openin (subtopology euclidean S) (S \<inter> f -` U))"
   1.461 +             (\<forall>U. openin (top_of_set T) U
   1.462 +                  \<longrightarrow> openin (top_of_set S) (S \<inter> f -` U))"
   1.463       (is "?lhs = ?rhs")
   1.464  proof
   1.465    assume ?lhs
   1.466 @@ -3841,23 +3930,23 @@
   1.467    proof (clarsimp simp add: continuous_openin_preimage_eq)
   1.468      fix U::"'a set"
   1.469      assume "open U"
   1.470 -    then have "openin (subtopology euclidean S) (S \<inter> f -` (U \<inter> T))"
   1.471 +    then have "openin (top_of_set S) (S \<inter> f -` (U \<inter> T))"
   1.472        by (metis R inf_commute openin_open)
   1.473 -    then show "openin (subtopology euclidean S) (S \<inter> f -` U)"
   1.474 +    then show "openin (top_of_set S) (S \<inter> f -` U)"
   1.475        by (metis Int_assoc Int_commute assms image_subset_iff_subset_vimage inf.absorb_iff2 vimage_Int)
   1.476    qed
   1.477  qed
   1.478  
   1.479  lemma continuous_openin_preimage:
   1.480 -  "\<lbrakk>continuous_on S f; f ` S \<subseteq> T; openin (subtopology euclidean T) U\<rbrakk>
   1.481 -        \<Longrightarrow> openin (subtopology euclidean S) (S \<inter> f -` U)"
   1.482 +  "\<lbrakk>continuous_on S f; f ` S \<subseteq> T; openin (top_of_set T) U\<rbrakk>
   1.483 +        \<Longrightarrow> openin (top_of_set S) (S \<inter> f -` U)"
   1.484    by (simp add: continuous_on_open_gen)
   1.485  
   1.486  lemma continuous_on_closed_gen:
   1.487    assumes "f ` S \<subseteq> T"
   1.488    shows "continuous_on S f \<longleftrightarrow>
   1.489 -             (\<forall>U. closedin (subtopology euclidean T) U
   1.490 -                  \<longrightarrow> closedin (subtopology euclidean S) (S \<inter> f -` U))"
   1.491 +             (\<forall>U. closedin (top_of_set T) U
   1.492 +                  \<longrightarrow> closedin (top_of_set S) (S \<inter> f -` U))"
   1.493      (is "?lhs = ?rhs")
   1.494  proof -
   1.495    have *: "U \<subseteq> T \<Longrightarrow> S \<inter> f -` (T - U) = S - (S \<inter> f -` U)" for U
   1.496 @@ -3868,8 +3957,8 @@
   1.497      show ?rhs
   1.498      proof clarify
   1.499        fix U
   1.500 -      assume "closedin (subtopology euclidean T) U"
   1.501 -      then show "closedin (subtopology euclidean S) (S \<inter> f -` U)"
   1.502 +      assume "closedin (top_of_set T) U"
   1.503 +      then show "closedin (top_of_set S) (S \<inter> f -` U)"
   1.504          using L unfolding continuous_on_open_gen [OF assms]
   1.505          by (metis * closedin_def inf_le1 topspace_euclidean_subtopology)
   1.506      qed
   1.507 @@ -3882,16 +3971,376 @@
   1.508  qed
   1.509  
   1.510  lemma continuous_closedin_preimage_gen:
   1.511 -  assumes "continuous_on S f" "f ` S \<subseteq> T" "closedin (subtopology euclidean T) U"
   1.512 -    shows "closedin (subtopology euclidean S) (S \<inter> f -` U)"
   1.513 +  assumes "continuous_on S f" "f ` S \<subseteq> T" "closedin (top_of_set T) U"
   1.514 +    shows "closedin (top_of_set S) (S \<inter> f -` U)"
   1.515  using assms continuous_on_closed_gen by blast
   1.516  
   1.517  lemma continuous_transform_within_openin:
   1.518    assumes "continuous (at a within T) f"
   1.519 -    and "openin (subtopology euclidean T) S" "a \<in> S"
   1.520 +    and "openin (top_of_set T) S" "a \<in> S"
   1.521      and eq: "\<And>x. x \<in> S \<Longrightarrow> f x = g x"
   1.522    shows "continuous (at a within T) g"
   1.523    using assms by (simp add: Lim_transform_within_openin continuous_within)
   1.524  
   1.525  
   1.526 +subsection%important \<open>The topology generated by some (open) subsets\<close>
   1.527 +
   1.528 +text \<open>In the definition below of a generated topology, the \<open>Empty\<close> case is not necessary,
   1.529 +as it follows from \<open>UN\<close> taking for \<open>K\<close> the empty set. However, it is convenient to have,
   1.530 +and is never a problem in proofs, so I prefer to write it down explicitly.
   1.531 +
   1.532 +We do not require \<open>UNIV\<close> to be an open set, as this will not be the case in applications. (We are
   1.533 +thinking of a topology on a subset of \<open>UNIV\<close>, the remaining part of \<open>UNIV\<close> being irrelevant.)\<close>
   1.534 +
   1.535 +inductive generate_topology_on for S where
   1.536 +  Empty: "generate_topology_on S {}"
   1.537 +| Int: "generate_topology_on S a \<Longrightarrow> generate_topology_on S b \<Longrightarrow> generate_topology_on S (a \<inter> b)"
   1.538 +| UN: "(\<And>k. k \<in> K \<Longrightarrow> generate_topology_on S k) \<Longrightarrow> generate_topology_on S (\<Union>K)"
   1.539 +| Basis: "s \<in> S \<Longrightarrow> generate_topology_on S s"
   1.540 +
   1.541 +lemma istopology_generate_topology_on:
   1.542 +  "istopology (generate_topology_on S)"
   1.543 +unfolding istopology_def by (auto intro: generate_topology_on.intros)
   1.544 +
   1.545 +text \<open>The basic property of the topology generated by a set \<open>S\<close> is that it is the
   1.546 +smallest topology containing all the elements of \<open>S\<close>:\<close>
   1.547 +
   1.548 +lemma generate_topology_on_coarsest:
   1.549 +  assumes "istopology T"
   1.550 +          "\<And>s. s \<in> S \<Longrightarrow> T s"
   1.551 +          "generate_topology_on S s0"
   1.552 +  shows "T s0"
   1.553 +using assms(3) apply (induct rule: generate_topology_on.induct)
   1.554 +using assms(1) assms(2) unfolding istopology_def by auto
   1.555 +
   1.556 +abbreviation%unimportant topology_generated_by::"('a set set) \<Rightarrow> ('a topology)"
   1.557 +  where "topology_generated_by S \<equiv> topology (generate_topology_on S)"
   1.558 +
   1.559 +lemma openin_topology_generated_by_iff:
   1.560 +  "openin (topology_generated_by S) s \<longleftrightarrow> generate_topology_on S s"
   1.561 +  using topology_inverse'[OF istopology_generate_topology_on[of S]] by simp
   1.562 +
   1.563 +lemma openin_topology_generated_by:
   1.564 +  "openin (topology_generated_by S) s \<Longrightarrow> generate_topology_on S s"
   1.565 +using openin_topology_generated_by_iff by auto
   1.566 +
   1.567 +lemma topology_generated_by_topspace:
   1.568 +  "topspace (topology_generated_by S) = (\<Union>S)"
   1.569 +proof
   1.570 +  {
   1.571 +    fix s assume "openin (topology_generated_by S) s"
   1.572 +    then have "generate_topology_on S s" by (rule openin_topology_generated_by)
   1.573 +    then have "s \<subseteq> (\<Union>S)" by (induct, auto)
   1.574 +  }
   1.575 +  then show "topspace (topology_generated_by S) \<subseteq> (\<Union>S)"
   1.576 +    unfolding topspace_def by auto
   1.577 +next
   1.578 +  have "generate_topology_on S (\<Union>S)"
   1.579 +    using generate_topology_on.UN[OF generate_topology_on.Basis, of S S] by simp
   1.580 +  then show "(\<Union>S) \<subseteq> topspace (topology_generated_by S)"
   1.581 +    unfolding topspace_def using openin_topology_generated_by_iff by auto
   1.582 +qed
   1.583 +
   1.584 +lemma topology_generated_by_Basis:
   1.585 +  "s \<in> S \<Longrightarrow> openin (topology_generated_by S) s"
   1.586 +  by (simp only: openin_topology_generated_by_iff, auto simp: generate_topology_on.Basis)
   1.587 +
   1.588 +lemma generate_topology_on_Inter:
   1.589 +  "\<lbrakk>finite \<F>; \<And>K. K \<in> \<F> \<Longrightarrow> generate_topology_on \<S> K; \<F> \<noteq> {}\<rbrakk> \<Longrightarrow> generate_topology_on \<S> (\<Inter>\<F>)"
   1.590 +  by (induction \<F> rule: finite_induct; force intro: generate_topology_on.intros)
   1.591 +
   1.592 +subsection\<open>Topology bases and sub-bases\<close>
   1.593 +
   1.594 +lemma istopology_base_alt:
   1.595 +   "istopology (arbitrary union_of P) \<longleftrightarrow>
   1.596 +    (\<forall>S T. (arbitrary union_of P) S \<and> (arbitrary union_of P) T
   1.597 +           \<longrightarrow> (arbitrary union_of P) (S \<inter> T))"
   1.598 +  by (simp add: istopology_def) (blast intro: arbitrary_union_of_Union)
   1.599 +
   1.600 +lemma istopology_base_eq:
   1.601 +   "istopology (arbitrary union_of P) \<longleftrightarrow>
   1.602 +    (\<forall>S T. P S \<and> P T \<longrightarrow> (arbitrary union_of P) (S \<inter> T))"
   1.603 +  by (simp add: istopology_base_alt arbitrary_union_of_Int_eq)
   1.604 +
   1.605 +lemma istopology_base:
   1.606 +   "(\<And>S T. \<lbrakk>P S; P T\<rbrakk> \<Longrightarrow> P(S \<inter> T)) \<Longrightarrow> istopology (arbitrary union_of P)"
   1.607 +  by (simp add: arbitrary_def istopology_base_eq union_of_inc)
   1.608 +
   1.609 +lemma openin_topology_base_unique:
   1.610 +   "openin X = arbitrary union_of P \<longleftrightarrow>
   1.611 +        (\<forall>V. P V \<longrightarrow> openin X V) \<and> (\<forall>U x. openin X U \<and> x \<in> U \<longrightarrow> (\<exists>V. P V \<and> x \<in> V \<and> V \<subseteq> U))"
   1.612 +   (is "?lhs = ?rhs")
   1.613 +proof
   1.614 +  assume ?lhs
   1.615 +  then show ?rhs
   1.616 +    by (auto simp: union_of_def arbitrary_def)
   1.617 +next
   1.618 +  assume R: ?rhs
   1.619 +  then have *: "\<exists>\<U>\<subseteq>Collect P. \<Union>\<U> = S" if "openin X S" for S
   1.620 +    using that by (rule_tac x="{V. P V \<and> V \<subseteq> S}" in exI) fastforce
   1.621 +  from R show ?lhs
   1.622 +    by (fastforce simp add: union_of_def arbitrary_def intro: *)
   1.623 +qed
   1.624 +
   1.625 +lemma topology_base_unique:
   1.626 +   "\<lbrakk>\<And>S. P S \<Longrightarrow> openin X S;
   1.627 +     \<And>U x. \<lbrakk>openin X U; x \<in> U\<rbrakk> \<Longrightarrow> \<exists>B. P B \<and> x \<in> B \<and> B \<subseteq> U\<rbrakk>
   1.628 +    \<Longrightarrow> topology(arbitrary union_of P) = X"
   1.629 +  by (metis openin_topology_base_unique openin_inverse [of X])
   1.630 +
   1.631 +lemma topology_bases_eq_aux:
   1.632 +   "\<lbrakk>(arbitrary union_of P) S;
   1.633 +     \<And>U x. \<lbrakk>P U; x \<in> U\<rbrakk> \<Longrightarrow> \<exists>V. Q V \<and> x \<in> V \<and> V \<subseteq> U\<rbrakk>
   1.634 +        \<Longrightarrow> (arbitrary union_of Q) S"
   1.635 +  by (metis arbitrary_union_of_alt arbitrary_union_of_idempot)
   1.636 +
   1.637 +lemma topology_bases_eq:
   1.638 +   "\<lbrakk>\<And>U x. \<lbrakk>P U; x \<in> U\<rbrakk> \<Longrightarrow> \<exists>V. Q V \<and> x \<in> V \<and> V \<subseteq> U;
   1.639 +    \<And>V x. \<lbrakk>Q V; x \<in> V\<rbrakk> \<Longrightarrow> \<exists>U. P U \<and> x \<in> U \<and> U \<subseteq> V\<rbrakk>
   1.640 +        \<Longrightarrow> topology (arbitrary union_of P) =
   1.641 +            topology (arbitrary union_of Q)"
   1.642 +  by (fastforce intro:  arg_cong [where f=topology]  elim: topology_bases_eq_aux)
   1.643 +
   1.644 +lemma istopology_subbase:
   1.645 +   "istopology (arbitrary union_of (finite intersection_of P relative_to S))"
   1.646 +  by (simp add: finite_intersection_of_Int istopology_base relative_to_Int)
   1.647 +
   1.648 +lemma openin_subbase:
   1.649 +  "openin (topology (arbitrary union_of (finite intersection_of B relative_to U))) S
   1.650 +   \<longleftrightarrow> (arbitrary union_of (finite intersection_of B relative_to U)) S"
   1.651 +  by (simp add: istopology_subbase topology_inverse')
   1.652 +
   1.653 +lemma topspace_subbase [simp]:
   1.654 +   "topspace(topology (arbitrary union_of (finite intersection_of B relative_to U))) = U" (is "?lhs = _")
   1.655 +proof
   1.656 +  show "?lhs \<subseteq> U"
   1.657 +    by (metis arbitrary_union_of_relative_to openin_subbase openin_topspace relative_to_imp_subset)
   1.658 +  show "U \<subseteq> ?lhs"
   1.659 +    by (metis arbitrary_union_of_inc finite_intersection_of_empty inf.orderE istopology_subbase 
   1.660 +              openin_subset relative_to_inc subset_UNIV topology_inverse')
   1.661 +qed
   1.662 +
   1.663 +lemma minimal_topology_subbase:
   1.664 +   "\<lbrakk>\<And>S. P S \<Longrightarrow> openin X S; openin X U;
   1.665 +     openin(topology(arbitrary union_of (finite intersection_of P relative_to U))) S\<rbrakk>
   1.666 +    \<Longrightarrow> openin X S"
   1.667 +  apply (simp add: istopology_subbase topology_inverse)
   1.668 +  apply (simp add: union_of_def intersection_of_def relative_to_def)
   1.669 +  apply (blast intro: openin_Int_Inter)
   1.670 +  done
   1.671 +
   1.672 +lemma istopology_subbase_UNIV:
   1.673 +   "istopology (arbitrary union_of (finite intersection_of P))"
   1.674 +  by (simp add: istopology_base finite_intersection_of_Int)
   1.675 +
   1.676 +
   1.677 +lemma generate_topology_on_eq:
   1.678 +  "generate_topology_on S = arbitrary union_of finite' intersection_of (\<lambda>x. x \<in> S)" (is "?lhs = ?rhs")
   1.679 +proof (intro ext iffI)
   1.680 +  fix A
   1.681 +  assume "?lhs A"
   1.682 +  then show "?rhs A"
   1.683 +  proof induction
   1.684 +    case (Int a b)
   1.685 +    then show ?case
   1.686 +      by (metis (mono_tags, lifting) istopology_base_alt finite'_intersection_of_Int istopology_base)
   1.687 +  next
   1.688 +    case (UN K)
   1.689 +    then show ?case
   1.690 +      by (simp add: arbitrary_union_of_Union)
   1.691 +  next
   1.692 +    case (Basis s)
   1.693 +    then show ?case
   1.694 +      by (simp add: Sup_upper arbitrary_union_of_inc finite'_intersection_of_inc relative_to_subset)
   1.695 +  qed auto
   1.696 +next
   1.697 +  fix A
   1.698 +  assume "?rhs A"
   1.699 +  then obtain \<U> where \<U>: "\<And>T. T \<in> \<U> \<Longrightarrow> \<exists>\<F>. finite' \<F> \<and> \<F> \<subseteq> S \<and> \<Inter>\<F> = T" and eq: "A = \<Union>\<U>"
   1.700 +    unfolding union_of_def intersection_of_def by auto
   1.701 +  show "?lhs A"
   1.702 +    unfolding eq
   1.703 +  proof (rule generate_topology_on.UN)
   1.704 +    fix T
   1.705 +    assume "T \<in> \<U>"
   1.706 +    with \<U> obtain \<F> where "finite' \<F>" "\<F> \<subseteq> S" "\<Inter>\<F> = T"
   1.707 +      by blast
   1.708 +    have "generate_topology_on S (\<Inter>\<F>)"
   1.709 +    proof (rule generate_topology_on_Inter)
   1.710 +      show "finite \<F>" "\<F> \<noteq> {}"
   1.711 +        by (auto simp: \<open>finite' \<F>\<close>)
   1.712 +      show "\<And>K. K \<in> \<F> \<Longrightarrow> generate_topology_on S K"
   1.713 +        by (metis \<open>\<F> \<subseteq> S\<close> generate_topology_on.simps subset_iff)
   1.714 +    qed
   1.715 +    then show "generate_topology_on S T"
   1.716 +      using \<open>\<Inter>\<F> = T\<close> by blast
   1.717 +  qed
   1.718 +qed
   1.719 +
   1.720 +subsubsection%important \<open>Continuity\<close>
   1.721 +
   1.722 +text \<open>We will need to deal with continuous maps in terms of topologies and not in terms
   1.723 +of type classes, as defined below.\<close>
   1.724 +
   1.725 +definition%important continuous_on_topo::"'a topology \<Rightarrow> 'b topology \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
   1.726 +  where "continuous_on_topo T1 T2 f = ((\<forall> U. openin T2 U \<longrightarrow> openin T1 (f-`U \<inter> topspace(T1)))
   1.727 +                                      \<and> (f`(topspace T1) \<subseteq> (topspace T2)))"
   1.728 +
   1.729 +lemma continuous_on_continuous_on_topo:
   1.730 +  "continuous_on s f \<longleftrightarrow> continuous_on_topo (top_of_set s) euclidean f"
   1.731 +  by (auto simp: continuous_on_topo_def Int_commute continuous_openin_preimage_eq)
   1.732 +
   1.733 +lemma continuous_on_topo_UNIV:
   1.734 +  "continuous_on UNIV f \<longleftrightarrow> continuous_on_topo euclidean euclidean f"
   1.735 +using continuous_on_continuous_on_topo[of UNIV f] subtopology_UNIV[of euclidean] by auto
   1.736 +
   1.737 +lemma continuous_on_topo_open [intro]:
   1.738 +  "continuous_on_topo T1 T2 f \<Longrightarrow> openin T2 U \<Longrightarrow> openin T1 (f-`U \<inter> topspace(T1))"
   1.739 +  unfolding continuous_on_topo_def by auto
   1.740 +
   1.741 +lemma continuous_on_topo_topspace [intro]:
   1.742 +  "continuous_on_topo T1 T2 f \<Longrightarrow> f`(topspace T1) \<subseteq> (topspace T2)"
   1.743 +unfolding continuous_on_topo_def by auto
   1.744 +
   1.745 +lemma continuous_on_generated_topo_iff:
   1.746 +  "continuous_on_topo T1 (topology_generated_by S) f \<longleftrightarrow>
   1.747 +      ((\<forall>U. U \<in> S \<longrightarrow> openin T1 (f-`U \<inter> topspace(T1))) \<and> (f`(topspace T1) \<subseteq> (\<Union> S)))"
   1.748 +unfolding continuous_on_topo_def topology_generated_by_topspace
   1.749 +proof (auto simp add: topology_generated_by_Basis)
   1.750 +  assume H: "\<forall>U. U \<in> S \<longrightarrow> openin T1 (f -` U \<inter> topspace T1)"
   1.751 +  fix U assume "openin (topology_generated_by S) U"
   1.752 +  then have "generate_topology_on S U" by (rule openin_topology_generated_by)
   1.753 +  then show "openin T1 (f -` U \<inter> topspace T1)"
   1.754 +  proof (induct)
   1.755 +    fix a b
   1.756 +    assume H: "openin T1 (f -` a \<inter> topspace T1)" "openin T1 (f -` b \<inter> topspace T1)"
   1.757 +    have "f -` (a \<inter> b) \<inter> topspace T1 = (f-`a \<inter> topspace T1) \<inter> (f-`b \<inter> topspace T1)"
   1.758 +      by auto
   1.759 +    then show "openin T1 (f -` (a \<inter> b) \<inter> topspace T1)" using H by auto
   1.760 +  next
   1.761 +    fix K
   1.762 +    assume H: "openin T1 (f -` k \<inter> topspace T1)" if "k\<in> K" for k
   1.763 +    define L where "L = {f -` k \<inter> topspace T1|k. k \<in> K}"
   1.764 +    have *: "openin T1 l" if "l \<in>L" for l using that H unfolding L_def by auto
   1.765 +    have "openin T1 (\<Union>L)" using openin_Union[OF *] by simp
   1.766 +    moreover have "(\<Union>L) = (f -` \<Union>K \<inter> topspace T1)" unfolding L_def by auto
   1.767 +    ultimately show "openin T1 (f -` \<Union>K \<inter> topspace T1)" by simp
   1.768 +  qed (auto simp add: H)
   1.769 +qed
   1.770 +
   1.771 +lemma continuous_on_generated_topo:
   1.772 +  assumes "\<And>U. U \<in>S \<Longrightarrow> openin T1 (f-`U \<inter> topspace(T1))"
   1.773 +          "f`(topspace T1) \<subseteq> (\<Union> S)"
   1.774 +  shows "continuous_on_topo T1 (topology_generated_by S) f"
   1.775 +  using assms continuous_on_generated_topo_iff by blast
   1.776 +
   1.777 +proposition continuous_on_topo_compose:
   1.778 +  assumes "continuous_on_topo T1 T2 f" "continuous_on_topo T2 T3 g"
   1.779 +  shows "continuous_on_topo T1 T3 (g o f)"
   1.780 +  using assms unfolding continuous_on_topo_def
   1.781 +proof (auto)
   1.782 +  fix U :: "'c set"
   1.783 +  assume H: "openin T3 U"
   1.784 +  have "openin T1 (f -` (g -` U \<inter> topspace T2) \<inter> topspace T1)"
   1.785 +    using H assms by blast
   1.786 +  moreover have "f -` (g -` U \<inter> topspace T2) \<inter> topspace T1 = (g \<circ> f) -` U \<inter> topspace T1"
   1.787 +    using H assms continuous_on_topo_topspace by fastforce
   1.788 +  ultimately show "openin T1 ((g \<circ> f) -` U \<inter> topspace T1)"
   1.789 +    by simp
   1.790 +qed (blast)
   1.791 +
   1.792 +lemma continuous_on_topo_preimage_topspace [intro]:
   1.793 +  assumes "continuous_on_topo T1 T2 f"
   1.794 +  shows "f-`(topspace T2) \<inter> topspace T1 = topspace T1"
   1.795 +using assms unfolding continuous_on_topo_def by auto
   1.796 +
   1.797 +
   1.798 +subsubsection%important \<open>Pullback topology\<close>
   1.799 +
   1.800 +text \<open>Pulling back a topology by map gives again a topology. \<open>subtopology\<close> is
   1.801 +a special case of this notion, pulling back by the identity. We introduce the general notion as
   1.802 +we will need it to define the strong operator topology on the space of continuous linear operators,
   1.803 +by pulling back the product topology on the space of all functions.\<close>
   1.804 +
   1.805 +text \<open>\<open>pullback_topology A f T\<close> is the pullback of the topology \<open>T\<close> by the map \<open>f\<close> on
   1.806 +the set \<open>A\<close>.\<close>
   1.807 +
   1.808 +definition%important pullback_topology::"('a set) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b topology) \<Rightarrow> ('a topology)"
   1.809 +  where "pullback_topology A f T = topology (\<lambda>S. \<exists>U. openin T U \<and> S = f-`U \<inter> A)"
   1.810 +
   1.811 +lemma istopology_pullback_topology:
   1.812 +  "istopology (\<lambda>S. \<exists>U. openin T U \<and> S = f-`U \<inter> A)"
   1.813 +  unfolding istopology_def proof (auto)
   1.814 +  fix K assume "\<forall>S\<in>K. \<exists>U. openin T U \<and> S = f -` U \<inter> A"
   1.815 +  then have "\<exists>U. \<forall>S\<in>K. openin T (U S) \<and> S = f-`(U S) \<inter> A"
   1.816 +    by (rule bchoice)
   1.817 +  then obtain U where U: "\<forall>S\<in>K. openin T (U S) \<and> S = f-`(U S) \<inter> A"
   1.818 +    by blast
   1.819 +  define V where "V = (\<Union>S\<in>K. U S)"
   1.820 +  have "openin T V" "\<Union>K = f -` V \<inter> A" unfolding V_def using U by auto
   1.821 +  then show "\<exists>V. openin T V \<and> \<Union>K = f -` V \<inter> A" by auto
   1.822 +qed
   1.823 +
   1.824 +lemma openin_pullback_topology:
   1.825 +  "openin (pullback_topology A f T) S \<longleftrightarrow> (\<exists>U. openin T U \<and> S = f-`U \<inter> A)"
   1.826 +unfolding pullback_topology_def topology_inverse'[OF istopology_pullback_topology] by auto
   1.827 +
   1.828 +lemma topspace_pullback_topology:
   1.829 +  "topspace (pullback_topology A f T) = f-`(topspace T) \<inter> A"
   1.830 +by (auto simp add: topspace_def openin_pullback_topology)
   1.831 +
   1.832 +proposition continuous_on_topo_pullback [intro]:
   1.833 +  assumes "continuous_on_topo T1 T2 g"
   1.834 +  shows "continuous_on_topo (pullback_topology A f T1) T2 (g o f)"
   1.835 +unfolding continuous_on_topo_def
   1.836 +proof (auto)
   1.837 +  fix U::"'b set" assume "openin T2 U"
   1.838 +  then have "openin T1 (g-`U \<inter> topspace T1)"
   1.839 +    using assms unfolding continuous_on_topo_def by auto
   1.840 +  have "(g o f)-`U \<inter> topspace (pullback_topology A f T1) = (g o f)-`U \<inter> A \<inter> f-`(topspace T1)"
   1.841 +    unfolding topspace_pullback_topology by auto
   1.842 +  also have "... = f-`(g-`U \<inter> topspace T1) \<inter> A "
   1.843 +    by auto
   1.844 +  also have "openin (pullback_topology A f T1) (...)"
   1.845 +    unfolding openin_pullback_topology using \<open>openin T1 (g-`U \<inter> topspace T1)\<close> by auto
   1.846 +  finally show "openin (pullback_topology A f T1) ((g \<circ> f) -` U \<inter> topspace (pullback_topology A f T1))"
   1.847 +    by auto
   1.848 +next
   1.849 +  fix x assume "x \<in> topspace (pullback_topology A f T1)"
   1.850 +  then have "f x \<in> topspace T1"
   1.851 +    unfolding topspace_pullback_topology by auto
   1.852 +  then show "g (f x) \<in> topspace T2"
   1.853 +    using assms unfolding continuous_on_topo_def by auto
   1.854 +qed
   1.855 +
   1.856 +proposition continuous_on_topo_pullback' [intro]:
   1.857 +  assumes "continuous_on_topo T1 T2 (f o g)" "topspace T1 \<subseteq> g-`A"
   1.858 +  shows "continuous_on_topo T1 (pullback_topology A f T2) g"
   1.859 +unfolding continuous_on_topo_def
   1.860 +proof (auto)
   1.861 +  fix U assume "openin (pullback_topology A f T2) U"
   1.862 +  then have "\<exists>V. openin T2 V \<and> U = f-`V \<inter> A"
   1.863 +    unfolding openin_pullback_topology by auto
   1.864 +  then obtain V where "openin T2 V" "U = f-`V \<inter> A"
   1.865 +    by blast
   1.866 +  then have "g -` U \<inter> topspace T1 = g-`(f-`V \<inter> A) \<inter> topspace T1"
   1.867 +    by blast
   1.868 +  also have "... = (f o g)-`V \<inter> (g-`A \<inter> topspace T1)"
   1.869 +    by auto
   1.870 +  also have "... = (f o g)-`V \<inter> topspace T1"
   1.871 +    using assms(2) by auto
   1.872 +  also have "openin T1 (...)"
   1.873 +    using assms(1) \<open>openin T2 V\<close> by auto
   1.874 +  finally show "openin T1 (g -` U \<inter> topspace T1)" by simp
   1.875 +next
   1.876 +  fix x assume "x \<in> topspace T1"
   1.877 +  have "(f o g) x \<in> topspace T2"
   1.878 +    using assms(1) \<open>x \<in> topspace T1\<close> unfolding continuous_on_topo_def by auto
   1.879 +  then have "g x \<in> f-`(topspace T2)"
   1.880 +    unfolding comp_def by blast
   1.881 +  moreover have "g x \<in> A" using assms(2) \<open>x \<in> topspace T1\<close> by blast
   1.882 +  ultimately show "g x \<in> topspace (pullback_topology A f T2)"
   1.883 +    unfolding topspace_pullback_topology by blast
   1.884 +qed
   1.885 +
   1.886  end
     2.1 --- a/src/HOL/Analysis/Abstract_Topology_2.thy	Mon Mar 18 21:50:51 2019 +0100
     2.2 +++ b/src/HOL/Analysis/Abstract_Topology_2.thy	Tue Mar 19 16:14:59 2019 +0000
     2.3 @@ -99,14 +99,14 @@
     2.4  qed
     2.5  
     2.6  lemma closedin_limpt:
     2.7 -  "closedin (subtopology euclidean T) S \<longleftrightarrow> S \<subseteq> T \<and> (\<forall>x. x islimpt S \<and> x \<in> T \<longrightarrow> x \<in> S)"
     2.8 +  "closedin (top_of_set T) S \<longleftrightarrow> S \<subseteq> T \<and> (\<forall>x. x islimpt S \<and> x \<in> T \<longrightarrow> x \<in> S)"
     2.9    apply (simp add: closedin_closed, safe)
    2.10     apply (simp add: closed_limpt islimpt_subset)
    2.11    apply (rule_tac x="closure S" in exI, simp)
    2.12    apply (force simp: closure_def)
    2.13    done
    2.14  
    2.15 -lemma closedin_closed_eq: "closed S \<Longrightarrow> closedin (subtopology euclidean S) T \<longleftrightarrow> closed T \<and> T \<subseteq> S"
    2.16 +lemma closedin_closed_eq: "closed S \<Longrightarrow> closedin (top_of_set S) T \<longleftrightarrow> closed T \<and> T \<subseteq> S"
    2.17    by (meson closedin_limpt closed_subset closedin_closed_trans)
    2.18  
    2.19  lemma connected_closed_set:
    2.20 @@ -123,32 +123,35 @@
    2.21  by (metis assms closed_Un connected_closed_set)
    2.22  
    2.23  lemma closedin_subset_trans:
    2.24 -  "closedin (subtopology euclidean U) S \<Longrightarrow> S \<subseteq> T \<Longrightarrow> T \<subseteq> U \<Longrightarrow>
    2.25 -    closedin (subtopology euclidean T) S"
    2.26 +  "closedin (top_of_set U) S \<Longrightarrow> S \<subseteq> T \<Longrightarrow> T \<subseteq> U \<Longrightarrow>
    2.27 +    closedin (top_of_set T) S"
    2.28    by (meson closedin_limpt subset_iff)
    2.29  
    2.30  lemma openin_subset_trans:
    2.31 -  "openin (subtopology euclidean U) S \<Longrightarrow> S \<subseteq> T \<Longrightarrow> T \<subseteq> U \<Longrightarrow>
    2.32 -    openin (subtopology euclidean T) S"
    2.33 +  "openin (top_of_set U) S \<Longrightarrow> S \<subseteq> T \<Longrightarrow> T \<subseteq> U \<Longrightarrow>
    2.34 +    openin (top_of_set T) S"
    2.35    by (auto simp: openin_open)
    2.36  
    2.37  lemma closedin_compact:
    2.38 -   "\<lbrakk>compact S; closedin (subtopology euclidean S) T\<rbrakk> \<Longrightarrow> compact T"
    2.39 +   "\<lbrakk>compact S; closedin (top_of_set S) T\<rbrakk> \<Longrightarrow> compact T"
    2.40  by (metis closedin_closed compact_Int_closed)
    2.41  
    2.42  lemma closedin_compact_eq:
    2.43    fixes S :: "'a::t2_space set"
    2.44    shows
    2.45     "compact S
    2.46 -         \<Longrightarrow> (closedin (subtopology euclidean S) T \<longleftrightarrow>
    2.47 +         \<Longrightarrow> (closedin (top_of_set S) T \<longleftrightarrow>
    2.48                compact T \<and> T \<subseteq> S)"
    2.49  by (metis closedin_imp_subset closedin_compact closed_subset compact_imp_closed)
    2.50  
    2.51  
    2.52  subsection \<open>Closure\<close>
    2.53  
    2.54 +lemma euclidean_closure_of [simp]: "euclidean closure_of S = closure S"
    2.55 +  by (auto simp: closure_of_def closure_def islimpt_def)
    2.56 +
    2.57  lemma closure_openin_Int_closure:
    2.58 -  assumes ope: "openin (subtopology euclidean U) S" and "T \<subseteq> U"
    2.59 +  assumes ope: "openin (top_of_set U) S" and "T \<subseteq> U"
    2.60    shows "closure(S \<inter> closure T) = closure(S \<inter> T)"
    2.61  proof
    2.62    obtain V where "open V" and S: "S = U \<inter> V"
    2.63 @@ -171,16 +174,16 @@
    2.64  
    2.65  corollary infinite_openin:
    2.66    fixes S :: "'a :: t1_space set"
    2.67 -  shows "\<lbrakk>openin (subtopology euclidean U) S; x \<in> S; x islimpt U\<rbrakk> \<Longrightarrow> infinite S"
    2.68 +  shows "\<lbrakk>openin (top_of_set U) S; x \<in> S; x islimpt U\<rbrakk> \<Longrightarrow> infinite S"
    2.69    by (clarsimp simp add: openin_open islimpt_eq_acc_point inf_commute)
    2.70  
    2.71  lemma closure_Int_ballI:
    2.72 -  assumes "\<And>U. \<lbrakk>openin (subtopology euclidean S) U; U \<noteq> {}\<rbrakk> \<Longrightarrow> T \<inter> U \<noteq> {}"
    2.73 +  assumes "\<And>U. \<lbrakk>openin (top_of_set S) U; U \<noteq> {}\<rbrakk> \<Longrightarrow> T \<inter> U \<noteq> {}"
    2.74    shows "S \<subseteq> closure T"
    2.75  proof (clarsimp simp: closure_iff_nhds_not_empty)
    2.76    fix x and A and V
    2.77    assume "x \<in> S" "V \<subseteq> A" "open V" "x \<in> V" "T \<inter> A = {}"
    2.78 -  then have "openin (subtopology euclidean S) (A \<inter> V \<inter> S)"
    2.79 +  then have "openin (top_of_set S) (A \<inter> V \<inter> S)"
    2.80      by (auto simp: openin_open intro!: exI[where x="V"])
    2.81    moreover have "A \<inter> V \<inter> S \<noteq> {}" using \<open>x \<in> V\<close> \<open>V \<subseteq> A\<close> \<open>x \<in> S\<close>
    2.82      by auto
    2.83 @@ -192,6 +195,12 @@
    2.84  
    2.85  subsection \<open>Frontier\<close>
    2.86  
    2.87 +lemma euclidean_interior_of [simp]: "euclidean interior_of S = interior S"
    2.88 +  by (auto simp: interior_of_def interior_def)
    2.89 +
    2.90 +lemma euclidean_frontier_of [simp]: "euclidean frontier_of S = frontier S"
    2.91 +  by (auto simp: frontier_of_def frontier_def)
    2.92 +
    2.93  lemma connected_Int_frontier:
    2.94       "\<lbrakk>connected s; s \<inter> t \<noteq> {}; s - t \<noteq> {}\<rbrakk> \<Longrightarrow> (s \<inter> frontier t \<noteq> {})"
    2.95    apply (simp add: frontier_interiors connected_openin, safe)
    2.96 @@ -204,17 +213,17 @@
    2.97  
    2.98  lemma openin_delete:
    2.99    fixes a :: "'a :: t1_space"
   2.100 -  shows "openin (subtopology euclidean u) s
   2.101 -         \<Longrightarrow> openin (subtopology euclidean u) (s - {a})"
   2.102 +  shows "openin (top_of_set u) s
   2.103 +         \<Longrightarrow> openin (top_of_set u) (s - {a})"
   2.104  by (metis Int_Diff open_delete openin_open)
   2.105  
   2.106  lemma compact_eq_openin_cover:
   2.107    "compact S \<longleftrightarrow>
   2.108 -    (\<forall>C. (\<forall>c\<in>C. openin (subtopology euclidean S) c) \<and> S \<subseteq> \<Union>C \<longrightarrow>
   2.109 +    (\<forall>C. (\<forall>c\<in>C. openin (top_of_set S) c) \<and> S \<subseteq> \<Union>C \<longrightarrow>
   2.110        (\<exists>D\<subseteq>C. finite D \<and> S \<subseteq> \<Union>D))"
   2.111  proof safe
   2.112    fix C
   2.113 -  assume "compact S" and "\<forall>c\<in>C. openin (subtopology euclidean S) c" and "S \<subseteq> \<Union>C"
   2.114 +  assume "compact S" and "\<forall>c\<in>C. openin (top_of_set S) c" and "S \<subseteq> \<Union>C"
   2.115    then have "\<forall>c\<in>{T. open T \<and> S \<inter> T \<in> C}. open c" and "S \<subseteq> \<Union>{T. open T \<and> S \<inter> T \<in> C}"
   2.116      unfolding openin_open by force+
   2.117    with \<open>compact S\<close> obtain D where "D \<subseteq> {T. open T \<and> S \<inter> T \<in> C}" and "finite D" and "S \<subseteq> \<Union>D"
   2.118 @@ -223,14 +232,14 @@
   2.119      by auto
   2.120    then show "\<exists>D\<subseteq>C. finite D \<and> S \<subseteq> \<Union>D" ..
   2.121  next
   2.122 -  assume 1: "\<forall>C. (\<forall>c\<in>C. openin (subtopology euclidean S) c) \<and> S \<subseteq> \<Union>C \<longrightarrow>
   2.123 +  assume 1: "\<forall>C. (\<forall>c\<in>C. openin (top_of_set S) c) \<and> S \<subseteq> \<Union>C \<longrightarrow>
   2.124          (\<exists>D\<subseteq>C. finite D \<and> S \<subseteq> \<Union>D)"
   2.125    show "compact S"
   2.126    proof (rule compactI)
   2.127      fix C
   2.128      let ?C = "image (\<lambda>T. S \<inter> T) C"
   2.129      assume "\<forall>t\<in>C. open t" and "S \<subseteq> \<Union>C"
   2.130 -    then have "(\<forall>c\<in>?C. openin (subtopology euclidean S) c) \<and> S \<subseteq> \<Union>?C"
   2.131 +    then have "(\<forall>c\<in>?C. openin (top_of_set S) c) \<and> S \<subseteq> \<Union>?C"
   2.132        unfolding openin_open by auto
   2.133      with 1 obtain D where "D \<subseteq> ?C" and "finite D" and "S \<subseteq> \<Union>D"
   2.134        by metis
   2.135 @@ -276,7 +285,7 @@
   2.136  
   2.137  lemma continuous_closedin_preimage_constant:
   2.138    fixes f :: "_ \<Rightarrow> 'b::t1_space"
   2.139 -  shows "continuous_on S f \<Longrightarrow> closedin (subtopology euclidean S) {x \<in> S. f x = a}"
   2.140 +  shows "continuous_on S f \<Longrightarrow> closedin (top_of_set S) {x \<in> S. f x = a}"
   2.141    using continuous_closedin_preimage[of S f "{a}"] by (simp add: vimage_def Collect_conj_eq)
   2.142  
   2.143  lemma continuous_closed_preimage_constant:
   2.144 @@ -335,14 +344,14 @@
   2.145  subsection%unimportant \<open>Continuity relative to a union.\<close>
   2.146  
   2.147  lemma continuous_on_Un_local:
   2.148 -    "\<lbrakk>closedin (subtopology euclidean (s \<union> t)) s; closedin (subtopology euclidean (s \<union> t)) t;
   2.149 +    "\<lbrakk>closedin (top_of_set (s \<union> t)) s; closedin (top_of_set (s \<union> t)) t;
   2.150        continuous_on s f; continuous_on t f\<rbrakk>
   2.151       \<Longrightarrow> continuous_on (s \<union> t) f"
   2.152    unfolding continuous_on closedin_limpt
   2.153    by (metis Lim_trivial_limit Lim_within_union Un_iff trivial_limit_within)
   2.154  
   2.155  lemma continuous_on_cases_local:
   2.156 -     "\<lbrakk>closedin (subtopology euclidean (s \<union> t)) s; closedin (subtopology euclidean (s \<union> t)) t;
   2.157 +     "\<lbrakk>closedin (top_of_set (s \<union> t)) s; closedin (top_of_set (s \<union> t)) t;
   2.158         continuous_on s f; continuous_on t g;
   2.159         \<And>x. \<lbrakk>x \<in> s \<and> \<not>P x \<or> x \<in> t \<and> P x\<rbrakk> \<Longrightarrow> f x = g x\<rbrakk>
   2.160        \<Longrightarrow> continuous_on (s \<union> t) (\<lambda>x. if P x then f x else g x)"
   2.161 @@ -358,9 +367,9 @@
   2.162  proof -
   2.163    have s: "s = (s \<inter> h -` atMost a) \<union> (s \<inter> h -` atLeast a)"
   2.164      by force
   2.165 -  have 1: "closedin (subtopology euclidean s) (s \<inter> h -` atMost a)"
   2.166 +  have 1: "closedin (top_of_set s) (s \<inter> h -` atMost a)"
   2.167      by (rule continuous_closedin_preimage [OF h closed_atMost])
   2.168 -  have 2: "closedin (subtopology euclidean s) (s \<inter> h -` atLeast a)"
   2.169 +  have 2: "closedin (top_of_set s) (s \<inter> h -` atLeast a)"
   2.170      by (rule continuous_closedin_preimage [OF h closed_atLeast])
   2.171    have eq: "s \<inter> h -` {..a} = {t \<in> s. h t \<le> a}" "s \<inter> h -` {a..} = {t \<in> s. a \<le> h t}"
   2.172      by auto
   2.173 @@ -388,7 +397,7 @@
   2.174    assumes contf: "continuous_on S f"
   2.175      and imf: "f ` S = T"
   2.176      and injf: "\<And>x. x \<in> S \<Longrightarrow> g (f x) = x"
   2.177 -    and oo: "\<And>U. openin (subtopology euclidean S) U \<Longrightarrow> openin (subtopology euclidean T) (f ` U)"
   2.178 +    and oo: "\<And>U. openin (top_of_set S) U \<Longrightarrow> openin (top_of_set T) (f ` U)"
   2.179    shows "continuous_on T g"
   2.180  proof -
   2.181    from imf injf have gTS: "g ` T = S"
   2.182 @@ -403,7 +412,7 @@
   2.183    assumes contf: "continuous_on S f"
   2.184      and imf: "f ` S = T"
   2.185      and injf: "\<And>x. x \<in> S \<Longrightarrow> g(f x) = x"
   2.186 -    and oo: "\<And>U. closedin (subtopology euclidean S) U \<Longrightarrow> closedin (subtopology euclidean T) (f ` U)"
   2.187 +    and oo: "\<And>U. closedin (top_of_set S) U \<Longrightarrow> closedin (top_of_set T) (f ` U)"
   2.188    shows "continuous_on T g"
   2.189  proof -
   2.190    from imf injf have gTS: "g ` T = S"
   2.191 @@ -418,7 +427,7 @@
   2.192    assumes contf: "continuous_on S f"
   2.193      and imf: "f ` S = T"
   2.194      and injf: "inj_on f S"
   2.195 -    and oo: "\<And>U. openin (subtopology euclidean S) U \<Longrightarrow> openin (subtopology euclidean T) (f ` U)"
   2.196 +    and oo: "\<And>U. openin (top_of_set S) U \<Longrightarrow> openin (top_of_set T) (f ` U)"
   2.197    obtains g where "homeomorphism S T f g"
   2.198  proof
   2.199    have "continuous_on T (inv_into S f)"
   2.200 @@ -431,7 +440,7 @@
   2.201    assumes contf: "continuous_on S f"
   2.202      and imf: "f ` S = T"
   2.203      and injf: "inj_on f S"
   2.204 -    and oo: "\<And>U. closedin (subtopology euclidean S) U \<Longrightarrow> closedin (subtopology euclidean T) (f ` U)"
   2.205 +    and oo: "\<And>U. closedin (top_of_set S) U \<Longrightarrow> closedin (top_of_set T) (f ` U)"
   2.206    obtains g where "homeomorphism S T f g"
   2.207  proof
   2.208    have "continuous_on T (inv_into S f)"
   2.209 @@ -442,8 +451,8 @@
   2.210  
   2.211  lemma homeomorphism_imp_open_map:
   2.212    assumes hom: "homeomorphism S T f g"
   2.213 -    and oo: "openin (subtopology euclidean S) U"
   2.214 -  shows "openin (subtopology euclidean T) (f ` U)"
   2.215 +    and oo: "openin (top_of_set S) U"
   2.216 +  shows "openin (top_of_set T) (f ` U)"
   2.217  proof -
   2.218    from hom oo have [simp]: "f ` U = T \<inter> g -` U"
   2.219      using openin_subset by (fastforce simp: homeomorphism_def rev_image_eqI)
   2.220 @@ -457,8 +466,8 @@
   2.221  
   2.222  lemma homeomorphism_imp_closed_map:
   2.223    assumes hom: "homeomorphism S T f g"
   2.224 -    and oo: "closedin (subtopology euclidean S) U"
   2.225 -  shows "closedin (subtopology euclidean T) (f ` U)"
   2.226 +    and oo: "closedin (top_of_set S) U"
   2.227 +  shows "closedin (top_of_set T) (f ` U)"
   2.228  proof -
   2.229    from hom oo have [simp]: "f ` U = T \<inter> g -` U"
   2.230      using closedin_subset by (fastforce simp: homeomorphism_def rev_image_eqI)
   2.231 @@ -476,13 +485,13 @@
   2.232    obtains \<B> :: "'a:: second_countable_topology set set"
   2.233      where "countable \<B>"
   2.234            "{} \<notin> \<B>"
   2.235 -          "\<And>C. C \<in> \<B> \<Longrightarrow> openin(subtopology euclidean S) C"
   2.236 -          "\<And>T. openin(subtopology euclidean S) T \<Longrightarrow> \<exists>\<U>. \<U> \<subseteq> \<B> \<and> T = \<Union>\<U>"
   2.237 +          "\<And>C. C \<in> \<B> \<Longrightarrow> openin(top_of_set S) C"
   2.238 +          "\<And>T. openin(top_of_set S) T \<Longrightarrow> \<exists>\<U>. \<U> \<subseteq> \<B> \<and> T = \<Union>\<U>"
   2.239  proof -
   2.240    obtain \<B> :: "'a set set"
   2.241      where "countable \<B>"
   2.242 -      and opeB: "\<And>C. C \<in> \<B> \<Longrightarrow> openin(subtopology euclidean S) C"
   2.243 -      and \<B>:    "\<And>T. openin(subtopology euclidean S) T \<Longrightarrow> \<exists>\<U>. \<U> \<subseteq> \<B> \<and> T = \<Union>\<U>"
   2.244 +      and opeB: "\<And>C. C \<in> \<B> \<Longrightarrow> openin(top_of_set S) C"
   2.245 +      and \<B>:    "\<And>T. openin(top_of_set S) T \<Longrightarrow> \<exists>\<U>. \<U> \<subseteq> \<B> \<and> T = \<Union>\<U>"
   2.246    proof -
   2.247      obtain \<C> :: "'a set set"
   2.248        where "countable \<C>" and ope: "\<And>C. C \<in> \<C> \<Longrightarrow> open C"
   2.249 @@ -492,9 +501,9 @@
   2.250      proof
   2.251        show "countable ((\<lambda>C. S \<inter> C) ` \<C>)"
   2.252          by (simp add: \<open>countable \<C>\<close>)
   2.253 -      show "\<And>C. C \<in> (\<inter>) S ` \<C> \<Longrightarrow> openin (subtopology euclidean S) C"
   2.254 +      show "\<And>C. C \<in> (\<inter>) S ` \<C> \<Longrightarrow> openin (top_of_set S) C"
   2.255          using ope by auto
   2.256 -      show "\<And>T. openin (subtopology euclidean S) T \<Longrightarrow> \<exists>\<U>\<subseteq>(\<inter>) S ` \<C>. T = \<Union>\<U>"
   2.257 +      show "\<And>T. openin (top_of_set S) T \<Longrightarrow> \<exists>\<U>\<subseteq>(\<inter>) S ` \<C>. T = \<Union>\<U>"
   2.258          by (metis \<C> image_mono inf_Sup openin_open)
   2.259      qed
   2.260    qed
   2.261 @@ -502,9 +511,9 @@
   2.262    proof
   2.263      show "countable (\<B> - {{}})"
   2.264        using \<open>countable \<B>\<close> by blast
   2.265 -    show "\<And>C. \<lbrakk>C \<in> \<B> - {{}}\<rbrakk> \<Longrightarrow> openin (subtopology euclidean S) C"
   2.266 -      by (simp add: \<open>\<And>C. C \<in> \<B> \<Longrightarrow> openin (subtopology euclidean S) C\<close>)
   2.267 -    show "\<exists>\<U>\<subseteq>\<B> - {{}}. T = \<Union>\<U>" if "openin (subtopology euclidean S) T" for T
   2.268 +    show "\<And>C. \<lbrakk>C \<in> \<B> - {{}}\<rbrakk> \<Longrightarrow> openin (top_of_set S) C"
   2.269 +      by (simp add: \<open>\<And>C. C \<in> \<B> \<Longrightarrow> openin (top_of_set S) C\<close>)
   2.270 +    show "\<exists>\<U>\<subseteq>\<B> - {{}}. T = \<Union>\<U>" if "openin (top_of_set S) T" for T
   2.271        using \<B> [OF that]
   2.272        apply clarify
   2.273        apply (rule_tac x="\<U> - {{}}" in exI, auto)
   2.274 @@ -514,7 +523,7 @@
   2.275  
   2.276  lemma Lindelof_openin:
   2.277    fixes \<F> :: "'a::second_countable_topology set set"
   2.278 -  assumes "\<And>S. S \<in> \<F> \<Longrightarrow> openin (subtopology euclidean U) S"
   2.279 +  assumes "\<And>S. S \<in> \<F> \<Longrightarrow> openin (top_of_set U) S"
   2.280    obtains \<F>' where "\<F>' \<subseteq> \<F>" "countable \<F>'" "\<Union>\<F>' = \<Union>\<F>"
   2.281  proof -
   2.282    have "\<And>S. S \<in> \<F> \<Longrightarrow> \<exists>T. open T \<and> S = U \<inter> T"
   2.283 @@ -535,16 +544,16 @@
   2.284  
   2.285  lemma continuous_imp_closed_map:
   2.286    fixes f :: "'a::t2_space \<Rightarrow> 'b::t2_space"
   2.287 -  assumes "closedin (subtopology euclidean S) U"
   2.288 +  assumes "closedin (top_of_set S) U"
   2.289            "continuous_on S f" "f ` S = T" "compact S"
   2.290 -    shows "closedin (subtopology euclidean T) (f ` U)"
   2.291 +    shows "closedin (top_of_set T) (f ` U)"
   2.292    by (metis assms closedin_compact_eq compact_continuous_image continuous_on_subset subset_image_iff)
   2.293  
   2.294  lemma closed_map_restrict:
   2.295 -  assumes cloU: "closedin (subtopology euclidean (S \<inter> f -` T')) U"
   2.296 -    and cc: "\<And>U. closedin (subtopology euclidean S) U \<Longrightarrow> closedin (subtopology euclidean T) (f ` U)"
   2.297 +  assumes cloU: "closedin (top_of_set (S \<inter> f -` T')) U"
   2.298 +    and cc: "\<And>U. closedin (top_of_set S) U \<Longrightarrow> closedin (top_of_set T) (f ` U)"
   2.299      and "T' \<subseteq> T"
   2.300 -  shows "closedin (subtopology euclidean T') (f ` U)"
   2.301 +  shows "closedin (top_of_set T') (f ` U)"
   2.302  proof -
   2.303    obtain V where "closed V" "U = S \<inter> f -` T' \<inter> V"
   2.304      using cloU by (auto simp: closedin_closed)
   2.305 @@ -555,10 +564,10 @@
   2.306  subsection%unimportant\<open>Open Maps\<close>
   2.307  
   2.308  lemma open_map_restrict:
   2.309 -  assumes opeU: "openin (subtopology euclidean (S \<inter> f -` T')) U"
   2.310 -    and oo: "\<And>U. openin (subtopology euclidean S) U \<Longrightarrow> openin (subtopology euclidean T) (f ` U)"
   2.311 +  assumes opeU: "openin (top_of_set (S \<inter> f -` T')) U"
   2.312 +    and oo: "\<And>U. openin (top_of_set S) U \<Longrightarrow> openin (top_of_set T) (f ` U)"
   2.313      and "T' \<subseteq> T"
   2.314 -  shows "openin (subtopology euclidean T') (f ` U)"
   2.315 +  shows "openin (top_of_set T') (f ` U)"
   2.316  proof -
   2.317    obtain V where "open V" "U = S \<inter> f -` T' \<inter> V"
   2.318      using opeU by (auto simp: openin_open)
   2.319 @@ -572,8 +581,8 @@
   2.320  lemma quotient_map_imp_continuous_open:
   2.321    assumes T: "f ` S \<subseteq> T"
   2.322        and ope: "\<And>U. U \<subseteq> T
   2.323 -              \<Longrightarrow> (openin (subtopology euclidean S) (S \<inter> f -` U) \<longleftrightarrow>
   2.324 -                   openin (subtopology euclidean T) U)"
   2.325 +              \<Longrightarrow> (openin (top_of_set S) (S \<inter> f -` U) \<longleftrightarrow>
   2.326 +                   openin (top_of_set T) U)"
   2.327      shows "continuous_on S f"
   2.328  proof -
   2.329    have [simp]: "S \<inter> f -` f ` S = S" by auto
   2.330 @@ -586,8 +595,8 @@
   2.331  lemma quotient_map_imp_continuous_closed:
   2.332    assumes T: "f ` S \<subseteq> T"
   2.333        and ope: "\<And>U. U \<subseteq> T
   2.334 -                  \<Longrightarrow> (closedin (subtopology euclidean S) (S \<inter> f -` U) \<longleftrightarrow>
   2.335 -                       closedin (subtopology euclidean T) U)"
   2.336 +                  \<Longrightarrow> (closedin (top_of_set S) (S \<inter> f -` U) \<longleftrightarrow>
   2.337 +                       closedin (top_of_set T) U)"
   2.338      shows "continuous_on S f"
   2.339  proof -
   2.340    have [simp]: "S \<inter> f -` f ` S = S" by auto
   2.341 @@ -600,10 +609,10 @@
   2.342  lemma open_map_imp_quotient_map:
   2.343    assumes contf: "continuous_on S f"
   2.344        and T: "T \<subseteq> f ` S"
   2.345 -      and ope: "\<And>T. openin (subtopology euclidean S) T
   2.346 -                   \<Longrightarrow> openin (subtopology euclidean (f ` S)) (f ` T)"
   2.347 -    shows "openin (subtopology euclidean S) (S \<inter> f -` T) =
   2.348 -           openin (subtopology euclidean (f ` S)) T"
   2.349 +      and ope: "\<And>T. openin (top_of_set S) T
   2.350 +                   \<Longrightarrow> openin (top_of_set (f ` S)) (f ` T)"
   2.351 +    shows "openin (top_of_set S) (S \<inter> f -` T) =
   2.352 +           openin (top_of_set (f ` S)) T"
   2.353  proof -
   2.354    have "T = f ` (S \<inter> f -` T)"
   2.355      using T by blast
   2.356 @@ -614,14 +623,14 @@
   2.357  lemma closed_map_imp_quotient_map:
   2.358    assumes contf: "continuous_on S f"
   2.359        and T: "T \<subseteq> f ` S"
   2.360 -      and ope: "\<And>T. closedin (subtopology euclidean S) T
   2.361 -              \<Longrightarrow> closedin (subtopology euclidean (f ` S)) (f ` T)"
   2.362 -    shows "openin (subtopology euclidean S) (S \<inter> f -` T) \<longleftrightarrow>
   2.363 -           openin (subtopology euclidean (f ` S)) T"
   2.364 +      and ope: "\<And>T. closedin (top_of_set S) T
   2.365 +              \<Longrightarrow> closedin (top_of_set (f ` S)) (f ` T)"
   2.366 +    shows "openin (top_of_set S) (S \<inter> f -` T) \<longleftrightarrow>
   2.367 +           openin (top_of_set (f ` S)) T"
   2.368            (is "?lhs = ?rhs")
   2.369  proof
   2.370    assume ?lhs
   2.371 -  then have *: "closedin (subtopology euclidean S) (S - (S \<inter> f -` T))"
   2.372 +  then have *: "closedin (top_of_set S) (S - (S \<inter> f -` T))"
   2.373      using closedin_diff by fastforce
   2.374    have [simp]: "(f ` S - f ` (S - (S \<inter> f -` T))) = T"
   2.375      using T by blast
   2.376 @@ -638,14 +647,14 @@
   2.377        and contg: "continuous_on T g" and img: "g ` T \<subseteq> S"
   2.378        and fg [simp]: "\<And>y. y \<in> T \<Longrightarrow> f(g y) = y"
   2.379        and U: "U \<subseteq> T"
   2.380 -    shows "openin (subtopology euclidean S) (S \<inter> f -` U) \<longleftrightarrow>
   2.381 -           openin (subtopology euclidean T) U"
   2.382 +    shows "openin (top_of_set S) (S \<inter> f -` U) \<longleftrightarrow>
   2.383 +           openin (top_of_set T) U"
   2.384            (is "?lhs = ?rhs")
   2.385  proof -
   2.386 -  have f: "\<And>Z. openin (subtopology euclidean (f ` S)) Z \<Longrightarrow>
   2.387 -                openin (subtopology euclidean S) (S \<inter> f -` Z)"
   2.388 -  and  g: "\<And>Z. openin (subtopology euclidean (g ` T)) Z \<Longrightarrow>
   2.389 -                openin (subtopology euclidean T) (T \<inter> g -` Z)"
   2.390 +  have f: "\<And>Z. openin (top_of_set (f ` S)) Z \<Longrightarrow>
   2.391 +                openin (top_of_set S) (S \<inter> f -` Z)"
   2.392 +  and  g: "\<And>Z. openin (top_of_set (g ` T)) Z \<Longrightarrow>
   2.393 +                openin (top_of_set T) (T \<inter> g -` Z)"
   2.394      using contf contg by (auto simp: continuous_on_open)
   2.395    show ?thesis
   2.396    proof
   2.397 @@ -655,7 +664,7 @@
   2.398        using U by auto
   2.399      finally have eq: "T \<inter> g -` (g ` T \<inter> (S \<inter> f -` U)) = U" .
   2.400      assume ?lhs
   2.401 -    then have *: "openin (subtopology euclidean (g ` T)) (g ` T \<inter> (S \<inter> f -` U))"
   2.402 +    then have *: "openin (top_of_set (g ` T)) (g ` T \<inter> (S \<inter> f -` U))"
   2.403        by (meson img openin_Int openin_subtopology_Int_subset openin_subtopology_self)
   2.404      show ?rhs
   2.405        using g [OF *] eq by auto
   2.406 @@ -671,8 +680,8 @@
   2.407        and "continuous_on (f ` S) g"
   2.408        and  "\<And>x. x \<in> S \<Longrightarrow> g(f x) = x"
   2.409        and "U \<subseteq> f ` S"
   2.410 -    shows "openin (subtopology euclidean S) (S \<inter> f -` U) \<longleftrightarrow>
   2.411 -           openin (subtopology euclidean (f ` S)) U"
   2.412 +    shows "openin (top_of_set S) (S \<inter> f -` U) \<longleftrightarrow>
   2.413 +           openin (top_of_set (f ` S)) U"
   2.414  apply (rule continuous_right_inverse_imp_quotient_map)
   2.415  using assms apply force+
   2.416  done
   2.417 @@ -680,101 +689,220 @@
   2.418  lemma continuous_imp_quotient_map:
   2.419    fixes f :: "'a::t2_space \<Rightarrow> 'b::t2_space"
   2.420    assumes "continuous_on S f" "f ` S = T" "compact S" "U \<subseteq> T"
   2.421 -    shows "openin (subtopology euclidean S) (S \<inter> f -` U) \<longleftrightarrow>
   2.422 -           openin (subtopology euclidean T) U"
   2.423 +    shows "openin (top_of_set S) (S \<inter> f -` U) \<longleftrightarrow>
   2.424 +           openin (top_of_set T) U"
   2.425    by (metis (no_types, lifting) assms closed_map_imp_quotient_map continuous_imp_closed_map)
   2.426  
   2.427 -subsection%unimportant\<open>Pasting functions together\<close>
   2.428 +subsection%unimportant\<open>Pasting lemmas for functions, for of casewise definitions\<close>
   2.429  
   2.430 -text\<open>on open sets\<close>
   2.431 +subsubsection\<open>on open sets\<close>
   2.432  
   2.433  lemma pasting_lemma:
   2.434 -  fixes f :: "'i \<Rightarrow> 'a::topological_space \<Rightarrow> 'b::topological_space"
   2.435 -  assumes clo: "\<And>i. i \<in> I \<Longrightarrow> openin (subtopology euclidean S) (T i)"
   2.436 -      and cont: "\<And>i. i \<in> I \<Longrightarrow> continuous_on (T i) (f i)"
   2.437 -      and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> S \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.438 -      and g: "\<And>x. x \<in> S \<Longrightarrow> \<exists>j. j \<in> I \<and> x \<in> T j \<and> g x = f j x"
   2.439 -    shows "continuous_on S g"
   2.440 -proof (clarsimp simp: continuous_openin_preimage_eq)
   2.441 -  fix U :: "'b set"
   2.442 -  assume "open U"
   2.443 -  have S: "\<And>i. i \<in> I \<Longrightarrow> (T i) \<subseteq> S"
   2.444 -    using clo openin_imp_subset by blast
   2.445 -  have *: "(S \<inter> g -` U) = (\<Union>i \<in> I. T i \<inter> f i -` U)"
   2.446 -    using S f g by fastforce
   2.447 -  show "openin (subtopology euclidean S) (S \<inter> g -` U)"
   2.448 -    apply (subst *)
   2.449 -    apply (rule openin_Union, clarify)
   2.450 -    using \<open>open U\<close> clo cont continuous_openin_preimage_gen openin_trans by blast
   2.451 +  assumes ope: "\<And>i. i \<in> I \<Longrightarrow> openin X (T i)"
   2.452 +      and cont: "\<And>i. i \<in> I \<Longrightarrow> continuous_map(subtopology X (T i)) Y (f i)"
   2.453 +      and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> topspace X \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.454 +      and g: "\<And>x. x \<in> topspace X \<Longrightarrow> \<exists>j. j \<in> I \<and> x \<in> T j \<and> g x = f j x"
   2.455 +    shows "continuous_map X Y g"
   2.456 +  unfolding continuous_map_openin_preimage_eq
   2.457 +proof (intro conjI allI impI)
   2.458 +  show "g ` topspace X \<subseteq> topspace Y"
   2.459 +    using g cont continuous_map_image_subset_topspace topspace_subtopology by fastforce
   2.460 +next
   2.461 +  fix U
   2.462 +  assume Y: "openin Y U"
   2.463 +  have T: "T i \<subseteq> topspace X" if "i \<in> I" for i
   2.464 +    using ope by (simp add: openin_subset that)
   2.465 +  have *: "topspace X \<inter> g -` U = (\<Union>i \<in> I. T i \<inter> f i -` U)"
   2.466 +    using f g T by fastforce
   2.467 +  have "\<And>i. i \<in> I \<Longrightarrow> openin X (T i \<inter> f i -` U)"
   2.468 +    using cont unfolding continuous_map_openin_preimage_eq
   2.469 +    by (metis Y T inf.commute inf_absorb1 ope topspace_subtopology openin_trans_full)
   2.470 +  then show "openin X (topspace X \<inter> g -` U)"
   2.471 +    by (auto simp: *)
   2.472  qed
   2.473  
   2.474  lemma pasting_lemma_exists:
   2.475 -  fixes f :: "'i \<Rightarrow> 'a::topological_space \<Rightarrow> 'b::topological_space"
   2.476 -  assumes S: "S \<subseteq> (\<Union>i \<in> I. T i)"
   2.477 -      and clo: "\<And>i. i \<in> I \<Longrightarrow> openin (subtopology euclidean S) (T i)"
   2.478 -      and cont: "\<And>i. i \<in> I \<Longrightarrow> continuous_on (T i) (f i)"
   2.479 -      and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> S \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.480 -    obtains g where "continuous_on S g" "\<And>x i. \<lbrakk>i \<in> I; x \<in> S \<inter> T i\<rbrakk> \<Longrightarrow> g x = f i x"
   2.481 +  assumes X: "topspace X \<subseteq> (\<Union>i \<in> I. T i)"
   2.482 +      and ope: "\<And>i. i \<in> I \<Longrightarrow> openin X (T i)"
   2.483 +      and cont: "\<And>i. i \<in> I \<Longrightarrow> continuous_map (subtopology X (T i)) Y (f i)"
   2.484 +      and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> topspace X \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.485 +    obtains g where "continuous_map X Y g" "\<And>x i. \<lbrakk>i \<in> I; x \<in> topspace X \<inter> T i\<rbrakk> \<Longrightarrow> g x = f i x"
   2.486  proof
   2.487 -  show "continuous_on S (\<lambda>x. f (SOME i. i \<in> I \<and> x \<in> T i) x)"
   2.488 -    apply (rule pasting_lemma [OF clo cont])
   2.489 +  let ?h = "\<lambda>x. f (SOME i. i \<in> I \<and> x \<in> T i) x"
   2.490 +  show "continuous_map X Y ?h"
   2.491 +    apply (rule pasting_lemma [OF ope cont])
   2.492       apply (blast intro: f)+
   2.493 -    apply (metis (mono_tags, lifting) S UN_iff subsetCE someI)
   2.494 +    by (metis (no_types, lifting) UN_E X subsetD someI_ex)
   2.495 +  show "f (SOME i. i \<in> I \<and> x \<in> T i) x = f i x" if "i \<in> I" "x \<in> topspace X \<inter> T i" for i x
   2.496 +    by (metis (no_types, lifting) IntD2 IntI f someI_ex that)
   2.497 +qed
   2.498 +
   2.499 +lemma pasting_lemma_locally_finite:
   2.500 +  assumes fin: "\<And>x. x \<in> topspace X \<Longrightarrow> \<exists>V. openin X V \<and> x \<in> V \<and> finite {i \<in> I. T i \<inter> V \<noteq> {}}"
   2.501 +    and clo: "\<And>i. i \<in> I \<Longrightarrow> closedin X (T i)"
   2.502 +    and cont:  "\<And>i. i \<in> I \<Longrightarrow> continuous_map(subtopology X (T i)) Y (f i)"
   2.503 +    and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> topspace X \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.504 +    and g: "\<And>x. x \<in> topspace X \<Longrightarrow> \<exists>j. j \<in> I \<and> x \<in> T j \<and> g x = f j x"
   2.505 +  shows "continuous_map X Y g"
   2.506 +  unfolding continuous_map_closedin_preimage_eq
   2.507 +proof (intro conjI allI impI)
   2.508 +  show "g ` topspace X \<subseteq> topspace Y"
   2.509 +    using g cont continuous_map_image_subset_topspace topspace_subtopology by fastforce
   2.510 +next
   2.511 +  fix U
   2.512 +  assume Y: "closedin Y U"
   2.513 +  have T: "T i \<subseteq> topspace X" if "i \<in> I" for i
   2.514 +    using clo by (simp add: closedin_subset that)
   2.515 +  have *: "topspace X \<inter> g -` U = (\<Union>i \<in> I. T i \<inter> f i -` U)"
   2.516 +    using f g T by fastforce
   2.517 +  have cTf: "\<And>i. i \<in> I \<Longrightarrow> closedin X (T i \<inter> f i -` U)"
   2.518 +    using cont unfolding continuous_map_closedin_preimage_eq topspace_subtopology
   2.519 +    by (simp add: Int_absorb1 T Y clo closedin_closed_subtopology)
   2.520 +  have sub: "{Z \<in> (\<lambda>i. T i \<inter> f i -` U) ` I. Z \<inter> V \<noteq> {}}
   2.521 +           \<subseteq> (\<lambda>i. T i \<inter> f i -` U) ` {i \<in> I. T i \<inter> V \<noteq> {}}" for V
   2.522 +    by auto
   2.523 +  have 1: "(\<Union>i\<in>I. T i \<inter> f i -` U) \<subseteq> topspace X"
   2.524 +    using T by blast
   2.525 +  then have lf: "locally_finite_in X ((\<lambda>i. T i \<inter> f i -` U) ` I)"
   2.526 +    unfolding locally_finite_in_def
   2.527 +    using finite_subset [OF sub] fin by force
   2.528 +  show "closedin X (topspace X \<inter> g -` U)"
   2.529 +    apply (subst *)
   2.530 +    apply (rule closedin_locally_finite_Union)
   2.531 +     apply (auto intro: cTf lf)
   2.532      done
   2.533 +qed
   2.534 +
   2.535 +subsubsection\<open>Likewise on closed sets, with a finiteness assumption\<close>
   2.536 +
   2.537 +lemma pasting_lemma_closed:
   2.538 +  assumes fin: "finite I"
   2.539 +    and clo: "\<And>i. i \<in> I \<Longrightarrow> closedin X (T i)"
   2.540 +    and cont:  "\<And>i. i \<in> I \<Longrightarrow> continuous_map(subtopology X (T i)) Y (f i)"
   2.541 +    and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> topspace X \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.542 +    and g: "\<And>x. x \<in> topspace X \<Longrightarrow> \<exists>j. j \<in> I \<and> x \<in> T j \<and> g x = f j x"
   2.543 +  shows "continuous_map X Y g"
   2.544 +  using pasting_lemma_locally_finite [OF _ clo cont f g] fin by auto
   2.545 +
   2.546 +lemma pasting_lemma_exists_locally_finite:
   2.547 +  assumes fin: "\<And>x. x \<in> topspace X \<Longrightarrow> \<exists>V. openin X V \<and> x \<in> V \<and> finite {i \<in> I. T i \<inter> V \<noteq> {}}"
   2.548 +    and X: "topspace X \<subseteq> \<Union>(T ` I)"
   2.549 +    and clo: "\<And>i. i \<in> I \<Longrightarrow> closedin X (T i)"
   2.550 +    and cont:  "\<And>i. i \<in> I \<Longrightarrow> continuous_map(subtopology X (T i)) Y (f i)"
   2.551 +    and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> topspace X \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.552 +    and g: "\<And>x. x \<in> topspace X \<Longrightarrow> \<exists>j. j \<in> I \<and> x \<in> T j \<and> g x = f j x"
   2.553 +  obtains g where "continuous_map X Y g" "\<And>x i. \<lbrakk>i \<in> I; x \<in> topspace X \<inter> T i\<rbrakk> \<Longrightarrow> g x = f i x"
   2.554 +proof
   2.555 +  show "continuous_map X Y (\<lambda>x. f(@i. i \<in> I \<and> x \<in> T i) x)"
   2.556 +    apply (rule pasting_lemma_locally_finite [OF fin])
   2.557 +        apply (blast intro: assms)+
   2.558 +    by (metis (no_types, lifting) UN_E X set_rev_mp someI_ex)
   2.559  next
   2.560    fix x i
   2.561 -  assume "i \<in> I" "x \<in> S \<inter> T i"
   2.562 +  assume "i \<in> I" and "x \<in> topspace X \<inter> T i"
   2.563 +  show "f (SOME i. i \<in> I \<and> x \<in> T i) x = f i x"
   2.564 +    apply (rule someI2_ex)
   2.565 +    using \<open>i \<in> I\<close> \<open>x \<in> topspace X \<inter> T i\<close> apply blast
   2.566 +    by (meson Int_iff \<open>i \<in> I\<close> \<open>x \<in> topspace X \<inter> T i\<close> f)
   2.567 +qed
   2.568 +
   2.569 +lemma pasting_lemma_exists_closed:
   2.570 +  assumes fin: "finite I"
   2.571 +    and X: "topspace X \<subseteq> \<Union>(T ` I)"
   2.572 +    and clo: "\<And>i. i \<in> I \<Longrightarrow> closedin X (T i)"
   2.573 +    and cont:  "\<And>i. i \<in> I \<Longrightarrow> continuous_map(subtopology X (T i)) Y (f i)"
   2.574 +    and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> topspace X \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.575 +  obtains g where "continuous_map X Y g" "\<And>x i. \<lbrakk>i \<in> I; x \<in> topspace X \<inter> T i\<rbrakk> \<Longrightarrow> g x = f i x"
   2.576 +proof
   2.577 +  show "continuous_map X Y (\<lambda>x. f (SOME i. i \<in> I \<and> x \<in> T i) x)"
   2.578 +    apply (rule pasting_lemma_closed [OF \<open>finite I\<close> clo cont])
   2.579 +     apply (blast intro: f)+
   2.580 +    by (metis (mono_tags, lifting) UN_iff X someI_ex subset_iff)
   2.581 +next
   2.582 +  fix x i
   2.583 +  assume "i \<in> I" "x \<in> topspace X \<inter> T i"
   2.584    then show "f (SOME i. i \<in> I \<and> x \<in> T i) x = f i x"
   2.585      by (metis (no_types, lifting) IntD2 IntI f someI_ex)
   2.586  qed
   2.587  
   2.588 -text\<open>Likewise on closed sets, with a finiteness assumption\<close>
   2.589 +lemma continuous_map_cases:
   2.590 +  assumes f: "continuous_map (subtopology X (X closure_of {x. P x})) Y f"
   2.591 +      and g: "continuous_map (subtopology X (X closure_of {x. \<not> P x})) Y g"
   2.592 +      and fg: "\<And>x. x \<in> X frontier_of {x. P x} \<Longrightarrow> f x = g x"
   2.593 +  shows "continuous_map X Y (\<lambda>x. if P x then f x else g x)"
   2.594 +proof (rule pasting_lemma_closed)
   2.595 +  let ?f = "\<lambda>b. if b then f else g"
   2.596 +  let ?g = "\<lambda>x. if P x then f x else g x"
   2.597 +  let ?T = "\<lambda>b. if b then X closure_of {x. P x} else X closure_of {x. ~P x}"
   2.598 +  show "finite {True,False}" by auto
   2.599 +  have eq: "topspace X - Collect P = topspace X \<inter> {x. \<not> P x}"
   2.600 +    by blast
   2.601 +  show "?f i x = ?f j x"
   2.602 +    if "i \<in> {True,False}" "j \<in> {True,False}" and x: "x \<in> topspace X \<inter> ?T i \<inter> ?T j" for i j x
   2.603 +  proof -
   2.604 +    have "f x = g x"
   2.605 +      if "i" "\<not> j"
   2.606 +      apply (rule fg)
   2.607 +      unfolding frontier_of_closures eq
   2.608 +      using x that closure_of_restrict by fastforce
   2.609 +    moreover
   2.610 +    have "g x = f x"
   2.611 +      if "x \<in> X closure_of {x. \<not> P x}" "x \<in> X closure_of Collect P" "\<not> i" "j" for x
   2.612 +        apply (rule fg [symmetric])
   2.613 +        unfolding frontier_of_closures eq
   2.614 +        using x that closure_of_restrict by fastforce
   2.615 +    ultimately show ?thesis
   2.616 +      using that by (auto simp flip: closure_of_restrict)
   2.617 +  qed
   2.618 +  show "\<exists>j. j \<in> {True,False} \<and> x \<in> ?T j \<and> (if P x then f x else g x) = ?f j x"
   2.619 +    if "x \<in> topspace X" for x
   2.620 +    apply simp
   2.621 +    apply safe
   2.622 +    apply (metis Int_iff closure_of inf_sup_absorb mem_Collect_eq that)
   2.623 +    by (metis DiffI eq closure_of_subset_Int contra_subsetD mem_Collect_eq that)
   2.624 +qed (auto simp: f g)
   2.625  
   2.626 -lemma pasting_lemma_closed:
   2.627 -  fixes f :: "'i \<Rightarrow> 'a::topological_space \<Rightarrow> 'b::topological_space"
   2.628 -  assumes "finite I"
   2.629 -      and clo: "\<And>i. i \<in> I \<Longrightarrow> closedin (subtopology euclidean S) (T i)"
   2.630 -      and cont: "\<And>i. i \<in> I \<Longrightarrow> continuous_on (T i) (f i)"
   2.631 -      and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> S \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.632 -      and g: "\<And>x. x \<in> S \<Longrightarrow> \<exists>j. j \<in> I \<and> x \<in> T j \<and> g x = f j x"
   2.633 -    shows "continuous_on S g"
   2.634 -proof (clarsimp simp: continuous_closedin_preimage_eq)
   2.635 -  fix U :: "'b set"
   2.636 -  assume "closed U"
   2.637 -  have S: "\<And>i. i \<in> I \<Longrightarrow> (T i) \<subseteq> S"
   2.638 -    using clo closedin_imp_subset by blast
   2.639 -  have *: "(S \<inter> g -` U) = (\<Union>i \<in> I. T i \<inter> f i -` U)"
   2.640 -    using S f g by fastforce
   2.641 -  show "closedin (subtopology euclidean S) (S \<inter> g -` U)"
   2.642 -    apply (subst *)
   2.643 -    apply (rule closedin_Union)
   2.644 -    using \<open>finite I\<close> apply simp
   2.645 -    apply (blast intro: \<open>closed U\<close> continuous_closedin_preimage cont clo closedin_trans)
   2.646 -    done
   2.647 +lemma continuous_map_cases_alt:
   2.648 +  assumes f: "continuous_map (subtopology X (X closure_of {x \<in> topspace X. P x})) Y f"
   2.649 +      and g: "continuous_map (subtopology X (X closure_of {x \<in> topspace X. ~P x})) Y g"
   2.650 +      and fg: "\<And>x. x \<in> X frontier_of {x \<in> topspace X. P x} \<Longrightarrow> f x = g x"
   2.651 +    shows "continuous_map X Y (\<lambda>x. if P x then f x else g x)"
   2.652 +  apply (rule continuous_map_cases)
   2.653 +  using assms
   2.654 +    apply (simp_all add: Collect_conj_eq closure_of_restrict [symmetric] frontier_of_restrict [symmetric])
   2.655 +  done
   2.656 +
   2.657 +lemma continuous_map_cases_function:
   2.658 +  assumes contp: "continuous_map X Z p"
   2.659 +    and contf: "continuous_map (subtopology X {x \<in> topspace X. p x \<in> Z closure_of U}) Y f"
   2.660 +    and contg: "continuous_map (subtopology X {x \<in> topspace X. p x \<in> Z closure_of (topspace Z - U)}) Y g"
   2.661 +    and fg: "\<And>x. \<lbrakk>x \<in> topspace X; p x \<in> Z frontier_of U\<rbrakk> \<Longrightarrow> f x = g x"
   2.662 +  shows "continuous_map X Y (\<lambda>x. if p x \<in> U then f x else g x)"
   2.663 +proof (rule continuous_map_cases_alt)
   2.664 +  show "continuous_map (subtopology X (X closure_of {x \<in> topspace X. p x \<in> U})) Y f"
   2.665 +  proof (rule continuous_map_from_subtopology_mono)
   2.666 +    let ?T = "{x \<in> topspace X. p x \<in> Z closure_of U}"
   2.667 +    show "continuous_map (subtopology X ?T) Y f"
   2.668 +      by (simp add: contf)
   2.669 +    show "X closure_of {x \<in> topspace X. p x \<in> U} \<subseteq> ?T"
   2.670 +      by (rule continuous_map_closure_preimage_subset [OF contp])
   2.671 +  qed
   2.672 +  show "continuous_map (subtopology X (X closure_of {x \<in> topspace X. p x \<notin> U})) Y g"
   2.673 +  proof (rule continuous_map_from_subtopology_mono)
   2.674 +    let ?T = "{x \<in> topspace X. p x \<in> Z closure_of (topspace Z - U)}"
   2.675 +    show "continuous_map (subtopology X ?T) Y g"
   2.676 +      by (simp add: contg)
   2.677 +    have "X closure_of {x \<in> topspace X. p x \<notin> U} \<subseteq> X closure_of {x \<in> topspace X. p x \<in> topspace Z - U}"
   2.678 +      apply (rule closure_of_mono)
   2.679 +      using continuous_map_closedin contp by fastforce
   2.680 +    then show "X closure_of {x \<in> topspace X. p x \<notin> U} \<subseteq> ?T"
   2.681 +      by (rule order_trans [OF _ continuous_map_closure_preimage_subset [OF contp]])
   2.682 +  qed
   2.683 +next
   2.684 +  show "f x = g x" if "x \<in> X frontier_of {x \<in> topspace X. p x \<in> U}" for x
   2.685 +    using that continuous_map_frontier_frontier_preimage_subset [OF contp, of U] fg by blast
   2.686  qed
   2.687  
   2.688 -lemma pasting_lemma_exists_closed:
   2.689 -  fixes f :: "'i \<Rightarrow> 'a::topological_space \<Rightarrow> 'b::topological_space"
   2.690 -  assumes "finite I"
   2.691 -      and S: "S \<subseteq> (\<Union>i \<in> I. T i)"
   2.692 -      and clo: "\<And>i. i \<in> I \<Longrightarrow> closedin (subtopology euclidean S) (T i)"
   2.693 -      and cont: "\<And>i. i \<in> I \<Longrightarrow> continuous_on (T i) (f i)"
   2.694 -      and f: "\<And>i j x. \<lbrakk>i \<in> I; j \<in> I; x \<in> S \<inter> T i \<inter> T j\<rbrakk> \<Longrightarrow> f i x = f j x"
   2.695 -    obtains g where "continuous_on S g" "\<And>x i. \<lbrakk>i \<in> I; x \<in> S \<inter> T i\<rbrakk> \<Longrightarrow> g x = f i x"
   2.696 -proof
   2.697 -  show "continuous_on S (\<lambda>x. f (SOME i. i \<in> I \<and> x \<in> T i) x)"
   2.698 -    apply (rule pasting_lemma_closed [OF \<open>finite I\<close> clo cont])
   2.699 -     apply (blast intro: f)+
   2.700 -    apply (metis (mono_tags, lifting) S UN_iff subsetCE someI)
   2.701 -    done
   2.702 -next
   2.703 -  fix x i
   2.704 -  assume "i \<in> I" "x \<in> S \<inter> T i"
   2.705 -  then show "f (SOME i. i \<in> I \<and> x \<in> T i) x = f i x"
   2.706 -    by (metis (no_types, lifting) IntD2 IntI f someI_ex)
   2.707 -qed
   2.708 -
   2.709 -
   2.710  subsection \<open>Retractions\<close>
   2.711  
   2.712  definition%important retraction :: "('a::topological_space) set \<Rightarrow> 'a set \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> bool"
   2.713 @@ -948,7 +1076,7 @@
   2.714  lemma closedin_retract:
   2.715    fixes S :: "'a :: t2_space set"
   2.716    assumes "S retract_of T"
   2.717 -    shows "closedin (subtopology euclidean T) S"
   2.718 +    shows "closedin (top_of_set T) S"
   2.719  proof -
   2.720    obtain r where r: "S \<subseteq> T" "continuous_on T r" "r ` T \<subseteq> S" "\<And>x. x \<in> S \<Longrightarrow> r x = x"
   2.721      using assms by (auto simp: retract_of_def retraction_def)
   2.722 @@ -963,7 +1091,7 @@
   2.723    finally show ?thesis .
   2.724  qed
   2.725  
   2.726 -lemma closedin_self [simp]: "closedin (subtopology euclidean S) S"
   2.727 +lemma closedin_self [simp]: "closedin (top_of_set S) S"
   2.728    by simp
   2.729  
   2.730  lemma retract_of_closed:
   2.731 @@ -980,7 +1108,7 @@
   2.732    by (metis Topological_Spaces.connected_continuous_image retract_of_def retraction)
   2.733  
   2.734  lemma retraction_imp_quotient_map:
   2.735 -  "openin (subtopology euclidean S) (S \<inter> r -` U) \<longleftrightarrow> openin (subtopology euclidean T) U"
   2.736 +  "openin (top_of_set S) (S \<inter> r -` U) \<longleftrightarrow> openin (top_of_set T) U"
   2.737    if retraction: "retraction S T r" and "U \<subseteq> T"
   2.738    using retraction apply (rule retractionE)
   2.739    apply (rule continuous_right_inverse_imp_quotient_map [where g=r])
   2.740 @@ -995,4 +1123,472 @@
   2.741  apply (rule conjI continuous_intros | erule continuous_on_subset | force)+
   2.742  done
   2.743  
   2.744 +subsection\<open>Retractions on a topological space\<close>
   2.745 +
   2.746 +definition retract_of_space :: "'a set \<Rightarrow> 'a topology \<Rightarrow> bool" (infix "retract'_of'_space" 50)
   2.747 +  where "S retract_of_space X
   2.748 +         \<equiv> S \<subseteq> topspace X \<and> (\<exists>r. continuous_map X (subtopology X S) r \<and> (\<forall>x \<in> S. r x = x))"
   2.749 +
   2.750 +lemma retract_of_space_retraction_maps:
   2.751 +   "S retract_of_space X \<longleftrightarrow> S \<subseteq> topspace X \<and> (\<exists>r. retraction_maps X (subtopology X S) r id)"
   2.752 +  by (auto simp: retract_of_space_def retraction_maps_def)
   2.753 +
   2.754 +lemma retract_of_space_section_map:
   2.755 +   "S retract_of_space X \<longleftrightarrow> S \<subseteq> topspace X \<and> section_map (subtopology X S) X id"
   2.756 +  unfolding retract_of_space_def retraction_maps_def section_map_def
   2.757 +  by (auto simp: continuous_map_from_subtopology)
   2.758 +
   2.759 +lemma retract_of_space_imp_subset:
   2.760 +   "S retract_of_space X \<Longrightarrow> S \<subseteq> topspace X"
   2.761 +  by (simp add: retract_of_space_def)
   2.762 +
   2.763 +lemma retract_of_space_topspace:
   2.764 +   "topspace X retract_of_space X"
   2.765 +  using retract_of_space_def by force
   2.766 +
   2.767 +lemma retract_of_space_empty [simp]:
   2.768 +   "{} retract_of_space X \<longleftrightarrow> topspace X = {}"
   2.769 +  by (auto simp: continuous_map_def retract_of_space_def)
   2.770 +
   2.771 +lemma retract_of_space_singleton [simp]:
   2.772 +  "{a} retract_of_space X \<longleftrightarrow> a \<in> topspace X"
   2.773 +proof -
   2.774 +  have "continuous_map X (subtopology X {a}) (\<lambda>x. a) \<and> (\<lambda>x. a) a = a" if "a \<in> topspace X"
   2.775 +    using that by simp
   2.776 +  then show ?thesis
   2.777 +    by (force simp: retract_of_space_def)
   2.778 +qed
   2.779 +
   2.780 +lemma retract_of_space_clopen:
   2.781 +  assumes "openin X S" "closedin X S" "S = {} \<Longrightarrow> topspace X = {}"
   2.782 +  shows "S retract_of_space X"
   2.783 +proof (cases "S = {}")
   2.784 +  case False
   2.785 +  then obtain a where "a \<in> S"
   2.786 +    by blast
   2.787 +  show ?thesis
   2.788 +    unfolding retract_of_space_def
   2.789 +  proof (intro exI conjI)
   2.790 +    show "S \<subseteq> topspace X"
   2.791 +      by (simp add: assms closedin_subset)
   2.792 +    have "continuous_map X X (\<lambda>x. if x \<in> S then x else a)"
   2.793 +    proof (rule continuous_map_cases)
   2.794 +      show "continuous_map (subtopology X (X closure_of {x. x \<in> S})) X (\<lambda>x. x)"
   2.795 +        by (simp add: continuous_map_from_subtopology)
   2.796 +      show "continuous_map (subtopology X (X closure_of {x. x \<notin> S})) X (\<lambda>x. a)"
   2.797 +        using \<open>S \<subseteq> topspace X\<close> \<open>a \<in> S\<close> by force
   2.798 +      show "x = a" if "x \<in> X frontier_of {x. x \<in> S}" for x
   2.799 +        using assms that clopenin_eq_frontier_of by fastforce
   2.800 +    qed
   2.801 +    then show "continuous_map X (subtopology X S) (\<lambda>x. if x \<in> S then x else a)"
   2.802 +      using \<open>S \<subseteq> topspace X\<close> \<open>a \<in> S\<close>  by (auto simp: continuous_map_in_subtopology)
   2.803 +  qed auto
   2.804 +qed (use assms in auto)
   2.805 +
   2.806 +lemma retract_of_space_disjoint_union:
   2.807 +  assumes "openin X S" "openin X T" and ST: "disjnt S T" "S \<union> T = topspace X" and "S = {} \<Longrightarrow> topspace X = {}"
   2.808 +  shows "S retract_of_space X"
   2.809 +proof (rule retract_of_space_clopen)
   2.810 +  have "S \<inter> T = {}"
   2.811 +    by (meson ST disjnt_def)
   2.812 +  then have "S = topspace X - T"
   2.813 +    using ST by auto
   2.814 +  then show "closedin X S"
   2.815 +    using \<open>openin X T\<close> by blast
   2.816 +qed (auto simp: assms)
   2.817 +
   2.818 +lemma retraction_maps_section_image1:
   2.819 +  assumes "retraction_maps X Y r s"
   2.820 +  shows "s ` (topspace Y) retract_of_space X"
   2.821 +  unfolding retract_of_space_section_map
   2.822 +proof
   2.823 +  show "s ` topspace Y \<subseteq> topspace X"
   2.824 +    using assms continuous_map_image_subset_topspace retraction_maps_def by blast
   2.825 +  show "section_map (subtopology X (s ` topspace Y)) X id"
   2.826 +    unfolding section_map_def
   2.827 +    using assms retraction_maps_to_retract_maps by blast
   2.828 +qed
   2.829 +
   2.830 +lemma retraction_maps_section_image2:
   2.831 +   "retraction_maps X Y r s
   2.832 +        \<Longrightarrow> subtopology X (s ` (topspace Y)) homeomorphic_space Y"
   2.833 +  using embedding_map_imp_homeomorphic_space homeomorphic_space_sym section_imp_embedding_map
   2.834 +        section_map_def by blast
   2.835 +
   2.836 +subsection\<open>Paths and path-connectedness\<close>
   2.837 +
   2.838 +definition pathin :: "'a topology \<Rightarrow> (real \<Rightarrow> 'a) \<Rightarrow> bool" where
   2.839 +   "pathin X g \<equiv> continuous_map (subtopology euclideanreal {0..1}) X g"
   2.840 +
   2.841 +lemma pathin_compose:
   2.842 +     "\<lbrakk>pathin X g; continuous_map X Y f\<rbrakk> \<Longrightarrow> pathin Y (f \<circ> g)"
   2.843 +   by (simp add: continuous_map_compose pathin_def)
   2.844 +
   2.845 +lemma pathin_subtopology:
   2.846 +     "pathin (subtopology X S) g \<longleftrightarrow> pathin X g \<and> (\<forall>x \<in> {0..1}. g x \<in> S)"
   2.847 +  by (auto simp: pathin_def continuous_map_in_subtopology)
   2.848 +
   2.849 +lemma pathin_const:
   2.850 +   "pathin X (\<lambda>x. a) \<longleftrightarrow> a \<in> topspace X"
   2.851 +  by (simp add: pathin_def)
   2.852 +
   2.853 +definition path_connected_space :: "'a topology \<Rightarrow> bool"
   2.854 +  where "path_connected_space X \<equiv> \<forall>x \<in> topspace X. \<forall> y \<in> topspace X. \<exists>g. pathin X g \<and> g 0 = x \<and> g 1 = y"
   2.855 +
   2.856 +definition path_connectedin :: "'a topology \<Rightarrow> 'a set \<Rightarrow> bool"
   2.857 +  where "path_connectedin X S \<equiv> S \<subseteq> topspace X \<and> path_connected_space(subtopology X S)"
   2.858 +
   2.859 +lemma path_connectedin_absolute [simp]:
   2.860 +     "path_connectedin (subtopology X S) S \<longleftrightarrow> path_connectedin X S"
   2.861 +  by (simp add: path_connectedin_def subtopology_subtopology topspace_subtopology)
   2.862 +
   2.863 +lemma path_connectedin_subset_topspace:
   2.864 +     "path_connectedin X S \<Longrightarrow> S \<subseteq> topspace X"
   2.865 +  by (simp add: path_connectedin_def)
   2.866 +
   2.867 +lemma path_connectedin_subtopology:
   2.868 +     "path_connectedin (subtopology X S) T \<longleftrightarrow> path_connectedin X T \<and> T \<subseteq> S"
   2.869 +  by (auto simp: path_connectedin_def subtopology_subtopology topspace_subtopology inf.absorb2)
   2.870 +
   2.871 +lemma path_connectedin:
   2.872 +     "path_connectedin X S \<longleftrightarrow>
   2.873 +        S \<subseteq> topspace X \<and>
   2.874 +        (\<forall>x \<in> S. \<forall>y \<in> S. \<exists>g. pathin X g \<and> g ` {0..1} \<subseteq> S \<and> g 0 = x \<and> g 1 = y)"
   2.875 +  unfolding path_connectedin_def path_connected_space_def pathin_def continuous_map_in_subtopology
   2.876 +  by (intro conj_cong refl ball_cong) (simp_all add: inf.absorb_iff2 topspace_subtopology)
   2.877 +
   2.878 +lemma path_connectedin_topspace:
   2.879 +     "path_connectedin X (topspace X) \<longleftrightarrow> path_connected_space X"
   2.880 +  by (simp add: path_connectedin_def)
   2.881 +
   2.882 +lemma path_connected_imp_connected_space:
   2.883 +  assumes "path_connected_space X"
   2.884 +  shows "connected_space X"
   2.885 +proof -
   2.886 +  have *: "\<exists>S. connectedin X S \<and> g 0 \<in> S \<and> g 1 \<in> S" if "pathin X g" for g
   2.887 +  proof (intro exI conjI)
   2.888 +    have "continuous_map (subtopology euclideanreal {0..1}) X g"
   2.889 +      using connectedin_absolute that by (simp add: pathin_def)
   2.890 +    then show "connectedin X (g ` {0..1})"
   2.891 +      by (rule connectedin_continuous_map_image) auto
   2.892 +  qed auto
   2.893 +  show ?thesis
   2.894 +    using assms
   2.895 +    by (auto intro: * simp add: path_connected_space_def connected_space_subconnected Ball_def)
   2.896 +qed
   2.897 +
   2.898 +lemma path_connectedin_imp_connectedin:
   2.899 +     "path_connectedin X S \<Longrightarrow> connectedin X S"
   2.900 +  by (simp add: connectedin_def path_connected_imp_connected_space path_connectedin_def)
   2.901 +
   2.902 +lemma path_connected_space_topspace_empty:
   2.903 +     "topspace X = {} \<Longrightarrow> path_connected_space X"
   2.904 +  by (simp add: path_connected_space_def)
   2.905 +
   2.906 +lemma path_connectedin_empty [simp]: "path_connectedin X {}"
   2.907 +  by (simp add: path_connectedin)
   2.908 +
   2.909 +lemma path_connectedin_singleton [simp]: "path_connectedin X {a} \<longleftrightarrow> a \<in> topspace X"
   2.910 +proof
   2.911 +  show "path_connectedin X {a} \<Longrightarrow> a \<in> topspace X"
   2.912 +    by (simp add: path_connectedin)
   2.913 +  show "a \<in> topspace X \<Longrightarrow> path_connectedin X {a}"
   2.914 +    unfolding path_connectedin
   2.915 +    using pathin_const by fastforce
   2.916 +qed
   2.917 +
   2.918 +lemma path_connectedin_continuous_map_image:
   2.919 +  assumes f: "continuous_map X Y f" and S: "path_connectedin X S"
   2.920 +  shows "path_connectedin Y (f ` S)"
   2.921 +proof -
   2.922 +  have fX: "f ` (topspace X) \<subseteq> topspace Y"
   2.923 +    by (metis f continuous_map_image_subset_topspace)
   2.924 +  show ?thesis
   2.925 +    unfolding path_connectedin
   2.926 +  proof (intro conjI ballI; clarify?)
   2.927 +    fix x
   2.928 +    assume "x \<in> S"
   2.929 +    show "f x \<in> topspace Y"
   2.930 +      by (meson S fX \<open>x \<in> S\<close> image_subset_iff path_connectedin_subset_topspace set_mp)
   2.931 +  next
   2.932 +    fix x y
   2.933 +    assume "x \<in> S" and "y \<in> S"
   2.934 +    then obtain g where g: "pathin X g" "g ` {0..1} \<subseteq> S" "g 0 = x" "g 1 = y"
   2.935 +      using S  by (force simp: path_connectedin)
   2.936 +    show "\<exists>g. pathin Y g \<and> g ` {0..1} \<subseteq> f ` S \<and> g 0 = f x \<and> g 1 = f y"
   2.937 +    proof (intro exI conjI)
   2.938 +      show "pathin Y (f \<circ> g)"
   2.939 +        using \<open>pathin X g\<close> f pathin_compose by auto
   2.940 +    qed (use g in auto)
   2.941 +  qed
   2.942 +qed
   2.943 +
   2.944 +lemma homeomorphic_path_connected_space_imp:
   2.945 +     "\<lbrakk>path_connected_space X; X homeomorphic_space Y\<rbrakk> \<Longrightarrow> path_connected_space Y"
   2.946 +  unfolding homeomorphic_space_def homeomorphic_maps_def
   2.947 +  by (metis (no_types, hide_lams) continuous_map_closedin continuous_map_image_subset_topspace imageI order_class.order.antisym path_connectedin_continuous_map_image path_connectedin_topspace subsetI)
   2.948 +
   2.949 +lemma homeomorphic_path_connected_space:
   2.950 +   "X homeomorphic_space Y \<Longrightarrow> path_connected_space X \<longleftrightarrow> path_connected_space Y"
   2.951 +  by (meson homeomorphic_path_connected_space_imp homeomorphic_space_sym)
   2.952 +
   2.953 +lemma homeomorphic_map_path_connectedness:
   2.954 +  assumes "homeomorphic_map X Y f" "U \<subseteq> topspace X"
   2.955 +  shows "path_connectedin Y (f ` U) \<longleftrightarrow> path_connectedin X U"
   2.956 +  unfolding path_connectedin_def
   2.957 +proof (intro conj_cong homeomorphic_path_connected_space)
   2.958 +  show "(f ` U \<subseteq> topspace Y) = (U \<subseteq> topspace X)"
   2.959 +    using assms homeomorphic_imp_surjective_map by blast
   2.960 +next
   2.961 +  assume "U \<subseteq> topspace X"
   2.962 +  show "subtopology Y (f ` U) homeomorphic_space subtopology X U"
   2.963 +    using assms unfolding homeomorphic_eq_everything_map
   2.964 +    by (metis (no_types, hide_lams) assms homeomorphic_map_subtopologies homeomorphic_space homeomorphic_space_sym image_mono inf.absorb_iff2)
   2.965 +qed
   2.966 +
   2.967 +lemma homeomorphic_map_path_connectedness_eq:
   2.968 +   "homeomorphic_map X Y f \<Longrightarrow> path_connectedin X U \<longleftrightarrow> U \<subseteq> topspace X \<and> path_connectedin Y (f ` U)"
   2.969 +  by (meson homeomorphic_map_path_connectedness path_connectedin_def)
   2.970 +
   2.971 +subsection\<open>Connected components\<close>
   2.972 +
   2.973 +definition connected_component_of :: "'a topology \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"
   2.974 +  where "connected_component_of X x y \<equiv>
   2.975 +        \<exists>T. connectedin X T \<and> x \<in> T \<and> y \<in> T"
   2.976 +
   2.977 +abbreviation connected_component_of_set
   2.978 +  where "connected_component_of_set X x \<equiv> Collect (connected_component_of X x)"
   2.979 +
   2.980 +definition connected_components_of :: "'a topology \<Rightarrow> ('a set) set"
   2.981 +  where "connected_components_of X \<equiv> connected_component_of_set X ` topspace X"
   2.982 +
   2.983 +lemma connected_component_in_topspace:
   2.984 +   "connected_component_of X x y \<Longrightarrow> x \<in> topspace X \<and> y \<in> topspace X"
   2.985 +  by (meson connected_component_of_def connectedin_subset_topspace in_mono)
   2.986 +
   2.987 +lemma connected_component_of_refl:
   2.988 +   "connected_component_of X x x \<longleftrightarrow> x \<in> topspace X"
   2.989 +  by (meson connected_component_in_topspace connected_component_of_def connectedin_sing insertI1)
   2.990 +
   2.991 +lemma connected_component_of_sym:
   2.992 +   "connected_component_of X x y \<longleftrightarrow> connected_component_of X y x"
   2.993 +  by (meson connected_component_of_def)
   2.994 +
   2.995 +lemma connected_component_of_trans:
   2.996 +   "\<lbrakk>connected_component_of X x y; connected_component_of X y z\<rbrakk>
   2.997 +        \<Longrightarrow> connected_component_of X x z"
   2.998 +  unfolding connected_component_of_def
   2.999 +  using connectedin_Un by fastforce
  2.1000 +
  2.1001 +lemma connected_component_of_mono:
  2.1002 +   "\<lbrakk>connected_component_of (subtopology X S) x y; S \<subseteq> T\<rbrakk>
  2.1003 +        \<Longrightarrow> connected_component_of (subtopology X T) x y"
  2.1004 +  by (metis connected_component_of_def connectedin_subtopology inf.absorb_iff2 subtopology_subtopology)
  2.1005 +
  2.1006 +lemma connected_component_of_set:
  2.1007 +   "connected_component_of_set X x = {y. \<exists>T. connectedin X T \<and> x \<in> T \<and> y \<in> T}"
  2.1008 +  by (meson connected_component_of_def)
  2.1009 +
  2.1010 +lemma connected_component_of_subset_topspace:
  2.1011 +   "connected_component_of_set X x \<subseteq> topspace X"
  2.1012 +  using connected_component_in_topspace by force
  2.1013 +
  2.1014 +lemma connected_component_of_eq_empty:
  2.1015 +   "connected_component_of_set X x = {} \<longleftrightarrow> (x \<notin> topspace X)"
  2.1016 +  using connected_component_in_topspace connected_component_of_refl by fastforce
  2.1017 +
  2.1018 +lemma connected_space_iff_connected_component:
  2.1019 +   "connected_space X \<longleftrightarrow> (\<forall>x \<in> topspace X. \<forall>y \<in> topspace X. connected_component_of X x y)"
  2.1020 +  by (simp add: connected_component_of_def connected_space_subconnected)
  2.1021 +
  2.1022 +lemma connected_space_imp_connected_component_of:
  2.1023 +   "\<lbrakk>connected_space X; a \<in> topspace X; b \<in> topspace X\<rbrakk>
  2.1024 +    \<Longrightarrow> connected_component_of X a b"
  2.1025 +  by (simp add: connected_space_iff_connected_component)
  2.1026 +
  2.1027 +lemma connected_space_connected_component_set:
  2.1028 +   "connected_space X \<longleftrightarrow> (\<forall>x \<in> topspace X. connected_component_of_set X x = topspace X)"
  2.1029 +  using connected_component_of_subset_topspace connected_space_iff_connected_component by fastforce
  2.1030 +
  2.1031 +lemma connected_component_of_maximal:
  2.1032 +   "\<lbrakk>connectedin X S; x \<in> S\<rbrakk> \<Longrightarrow> S \<subseteq> connected_component_of_set X x"
  2.1033 +  by (meson Ball_Collect connected_component_of_def)
  2.1034 +
  2.1035 +lemma connected_component_of_equiv:
  2.1036 +   "connected_component_of X x y \<longleftrightarrow>
  2.1037 +    x \<in> topspace X \<and> y \<in> topspace X \<and> connected_component_of X x = connected_component_of X y"
  2.1038 +  apply (simp add: connected_component_in_topspace fun_eq_iff)
  2.1039 +  by (meson connected_component_of_refl connected_component_of_sym connected_component_of_trans)
  2.1040 +
  2.1041 +lemma connected_component_of_disjoint:
  2.1042 +   "disjnt (connected_component_of_set X x) (connected_component_of_set X y)
  2.1043 +    \<longleftrightarrow> ~(connected_component_of X x y)"
  2.1044 +  using connected_component_of_equiv unfolding disjnt_iff by force
  2.1045 +
  2.1046 +lemma connected_component_of_eq:
  2.1047 +   "connected_component_of X x = connected_component_of X y \<longleftrightarrow>
  2.1048 +        (x \<notin> topspace X) \<and> (y \<notin> topspace X) \<or>
  2.1049 +        x \<in> topspace X \<and> y \<in> topspace X \<and>
  2.1050 +        connected_component_of X x y"
  2.1051 +  by (metis Collect_empty_eq_bot connected_component_of_eq_empty connected_component_of_equiv)
  2.1052 +
  2.1053 +lemma connectedin_connected_component_of:
  2.1054 +   "connectedin X (connected_component_of_set X x)"
  2.1055 +proof -
  2.1056 +  have "connected_component_of_set X x = \<Union> {T. connectedin X T \<and> x \<in> T}"
  2.1057 +    by (auto simp: connected_component_of_def)
  2.1058 +  then show ?thesis
  2.1059 +    apply (rule ssubst)
  2.1060 +    by (blast intro: connectedin_Union)
  2.1061 +qed
  2.1062 +
  2.1063 +
  2.1064 +lemma Union_connected_components_of:
  2.1065 +   "\<Union>(connected_components_of X) = topspace X"
  2.1066 +  unfolding connected_components_of_def
  2.1067 +  apply (rule equalityI)
  2.1068 +  apply (simp add: SUP_least connected_component_of_subset_topspace)
  2.1069 +  using connected_component_of_refl by fastforce
  2.1070 +
  2.1071 +lemma connected_components_of_maximal:
  2.1072 +   "\<lbrakk>C \<in> connected_components_of X; connectedin X S; ~disjnt C S\<rbrakk> \<Longrightarrow> S \<subseteq> C"
  2.1073 +  unfolding connected_components_of_def disjnt_def
  2.1074 +  apply clarify
  2.1075 +  by (metis Int_emptyI connected_component_of_def connected_component_of_trans mem_Collect_eq)
  2.1076 +
  2.1077 +lemma pairwise_disjoint_connected_components_of:
  2.1078 +   "pairwise disjnt (connected_components_of X)"
  2.1079 +  unfolding connected_components_of_def pairwise_def
  2.1080 +  apply clarify
  2.1081 +  by (metis connected_component_of_disjoint connected_component_of_equiv)
  2.1082 +
  2.1083 +lemma complement_connected_components_of_Union:
  2.1084 +   "C \<in> connected_components_of X
  2.1085 +      \<Longrightarrow> topspace X - C = \<Union> (connected_components_of X - {C})"
  2.1086 +  apply (rule equalityI)
  2.1087 +  using Union_connected_components_of apply fastforce
  2.1088 +  by (metis Diff_cancel Diff_subset Union_connected_components_of cSup_singleton diff_Union_pairwise_disjoint equalityE insert_subsetI pairwise_disjoint_connected_components_of)
  2.1089 +
  2.1090 +lemma nonempty_connected_components_of:
  2.1091 +   "C \<in> connected_components_of X \<Longrightarrow> C \<noteq> {}"
  2.1092 +  unfolding connected_components_of_def
  2.1093 +  by (metis (no_types, lifting) connected_component_of_eq_empty imageE)
  2.1094 +
  2.1095 +lemma connected_components_of_subset:
  2.1096 +   "C \<in> connected_components_of X \<Longrightarrow> C \<subseteq> topspace X"
  2.1097 +  using Union_connected_components_of by fastforce
  2.1098 +
  2.1099 +lemma connectedin_connected_components_of:
  2.1100 +  assumes "C \<in> connected_components_of X"
  2.1101 +  shows "connectedin X C"
  2.1102 +proof -
  2.1103 +  have "C \<in> connected_component_of_set X ` topspace X"
  2.1104 +    using assms connected_components_of_def by blast
  2.1105 +then show ?thesis
  2.1106 +  using connectedin_connected_component_of by fastforce
  2.1107 +qed
  2.1108 +
  2.1109 +lemma connected_component_in_connected_components_of:
  2.1110 +   "connected_component_of_set X a \<in> connected_components_of X \<longleftrightarrow> a \<in> topspace X"
  2.1111 +  apply (rule iffI)
  2.1112 +  using connected_component_of_eq_empty nonempty_connected_components_of apply fastforce
  2.1113 +  by (simp add: connected_components_of_def)
  2.1114 +
  2.1115 +lemma connected_space_iff_components_eq:
  2.1116 +   "connected_space X \<longleftrightarrow> (\<forall>C \<in> connected_components_of X. \<forall>C' \<in> connected_components_of X. C = C')"
  2.1117 +  apply (rule iffI)
  2.1118 +  apply (force simp: connected_components_of_def connected_space_connected_component_set image_iff)
  2.1119 +  by (metis connected_component_in_connected_components_of connected_component_of_refl connected_space_iff_connected_component mem_Collect_eq)
  2.1120 +
  2.1121 +lemma connected_components_of_eq_empty:
  2.1122 +   "connected_components_of X = {} \<longleftrightarrow> topspace X = {}"
  2.1123 +  by (simp add: connected_components_of_def)
  2.1124 +
  2.1125 +lemma connected_components_of_empty_space:
  2.1126 +   "topspace X = {} \<Longrightarrow> connected_components_of X = {}"
  2.1127 +  by (simp add: connected_components_of_eq_empty)
  2.1128 +
  2.1129 +lemma connected_components_of_subset_sing:
  2.1130 +   "connected_components_of X \<subseteq> {S} \<longleftrightarrow> connected_space X \<and> (topspace X = {} \<or> topspace X = S)"
  2.1131 +proof (cases "topspace X = {}")
  2.1132 +  case True
  2.1133 +  then show ?thesis
  2.1134 +    by (simp add: connected_components_of_empty_space connected_space_topspace_empty)
  2.1135 +next
  2.1136 +  case False
  2.1137 +  then show ?thesis
  2.1138 +    by (metis (no_types, hide_lams) Union_connected_components_of ccpo_Sup_singleton
  2.1139 +        connected_components_of_eq_empty connected_space_iff_components_eq insertI1 singletonD
  2.1140 +        subsetI subset_singleton_iff)
  2.1141 +qed
  2.1142 +
  2.1143 +lemma connected_space_iff_components_subset_singleton:
  2.1144 +   "connected_space X \<longleftrightarrow> (\<exists>a. connected_components_of X \<subseteq> {a})"
  2.1145 +  by (simp add: connected_components_of_subset_sing)
  2.1146 +
  2.1147 +lemma connected_components_of_eq_singleton:
  2.1148 +   "connected_components_of X = {S}
  2.1149 +\<longleftrightarrow> connected_space X \<and> topspace X \<noteq> {} \<and> S = topspace X"
  2.1150 +  by (metis ccpo_Sup_singleton connected_components_of_subset_sing insert_not_empty subset_singleton_iff)
  2.1151 +
  2.1152 +lemma connected_components_of_connected_space:
  2.1153 +   "connected_space X \<Longrightarrow> connected_components_of X = (if topspace X = {} then {} else {topspace X})"
  2.1154 +  by (simp add: connected_components_of_eq_empty connected_components_of_eq_singleton)
  2.1155 +
  2.1156 +lemma exists_connected_component_of_superset:
  2.1157 +  assumes "connectedin X S" and ne: "topspace X \<noteq> {}"
  2.1158 +  shows "\<exists>C. C \<in> connected_components_of X \<and> S \<subseteq> C"
  2.1159 +proof (cases "S = {}")
  2.1160 +  case True
  2.1161 +  then show ?thesis
  2.1162 +    using ne connected_components_of_def by blast
  2.1163 +next
  2.1164 +  case False
  2.1165 +  then show ?thesis
  2.1166 +    by (meson all_not_in_conv assms(1) connected_component_in_connected_components_of connected_component_of_maximal connectedin_subset_topspace in_mono)
  2.1167 +qed
  2.1168 +
  2.1169 +lemma closedin_connected_components_of:
  2.1170 +  assumes "C \<in> connected_components_of X"
  2.1171 +  shows   "closedin X C"
  2.1172 +proof -
  2.1173 +  obtain x where "x \<in> topspace X" and x: "C = connected_component_of_set X x"
  2.1174 +    using assms by (auto simp: connected_components_of_def)
  2.1175 +  have "connected_component_of_set X x \<subseteq> topspace X"
  2.1176 +    by (simp add: connected_component_of_subset_topspace)
  2.1177 +  moreover have "X closure_of connected_component_of_set X x \<subseteq> connected_component_of_set X x"
  2.1178 +  proof (rule connected_component_of_maximal)
  2.1179 +    show "connectedin X (X closure_of connected_component_of_set X x)"
  2.1180 +      by (simp add: connectedin_closure_of connectedin_connected_component_of)
  2.1181 +    show "x \<in> X closure_of connected_component_of_set X x"
  2.1182 +      by (simp add: \<open>x \<in> topspace X\<close> closure_of connected_component_of_refl)
  2.1183 +  qed
  2.1184 +  ultimately
  2.1185 +  show ?thesis
  2.1186 +    using closure_of_subset_eq x by auto
  2.1187 +qed
  2.1188 +
  2.1189 +lemma closedin_connected_component_of:
  2.1190 +   "closedin X (connected_component_of_set X x)"
  2.1191 +  by (metis closedin_connected_components_of closedin_empty connected_component_in_connected_components_of connected_component_of_eq_empty)
  2.1192 +
  2.1193 +lemma connected_component_of_eq_overlap:
  2.1194 +   "connected_component_of_set X x = connected_component_of_set X y \<longleftrightarrow>
  2.1195 +      (x \<notin> topspace X) \<and> (y \<notin> topspace X) \<or>
  2.1196 +      ~(connected_component_of_set X x \<inter> connected_component_of_set X y = {})"
  2.1197 +  using connected_component_of_equiv by fastforce
  2.1198 +
  2.1199 +lemma connected_component_of_nonoverlap:
  2.1200 +   "connected_component_of_set X x \<inter> connected_component_of_set X y = {} \<longleftrightarrow>
  2.1201 +     (x \<notin> topspace X) \<or> (y \<notin> topspace X) \<or>
  2.1202 +     ~(connected_component_of_set X x = connected_component_of_set X y)"
  2.1203 +  by (metis connected_component_of_eq_empty connected_component_of_eq_overlap inf.idem)
  2.1204 +
  2.1205 +lemma connected_component_of_overlap:
  2.1206 +   "~(connected_component_of_set X x \<inter> connected_component_of_set X y = {}) \<longleftrightarrow>
  2.1207 +    x \<in> topspace X \<and> y \<in> topspace X \<and>
  2.1208 +    connected_component_of_set X x = connected_component_of_set X y"
  2.1209 +  by (meson connected_component_of_nonoverlap)
  2.1210 +
  2.1211 +
  2.1212  end
  2.1213 \ No newline at end of file
     3.1 --- a/src/HOL/Analysis/Analysis.thy	Mon Mar 18 21:50:51 2019 +0100
     3.2 +++ b/src/HOL/Analysis/Analysis.thy	Tue Mar 19 16:14:59 2019 +0000
     3.3 @@ -27,7 +27,7 @@
     3.4    Homeomorphism
     3.5    Bounded_Continuous_Function
     3.6    Abstract_Topology
     3.7 -  Function_Topology
     3.8 +  Product_Topology
     3.9    T1_Spaces
    3.10    Infinite_Products
    3.11    Infinite_Set_Sum
     4.1 --- a/src/HOL/Analysis/Arcwise_Connected.thy	Mon Mar 18 21:50:51 2019 +0100
     4.2 +++ b/src/HOL/Analysis/Arcwise_Connected.thy	Tue Mar 19 16:14:59 2019 +0000
     4.3 @@ -2005,7 +2005,7 @@
     4.4  
     4.5  lemma dense_accessible_frontier_points:
     4.6    fixes S :: "'a::{complete_space,real_normed_vector} set"
     4.7 -  assumes "open S" and opeSV: "openin (subtopology euclidean (frontier S)) V" and "V \<noteq> {}"
     4.8 +  assumes "open S" and opeSV: "openin (top_of_set (frontier S)) V" and "V \<noteq> {}"
     4.9    obtains g where "arc g" "g ` {0..<1} \<subseteq> S" "pathstart g \<in> S" "pathfinish g \<in> V"
    4.10  proof -
    4.11    obtain z where "z \<in> V"
    4.12 @@ -2101,7 +2101,7 @@
    4.13  lemma dense_accessible_frontier_points_connected:
    4.14    fixes S :: "'a::{complete_space,real_normed_vector} set"
    4.15    assumes "open S" "connected S" "x \<in> S" "V \<noteq> {}"
    4.16 -      and ope: "openin (subtopology euclidean (frontier S)) V"
    4.17 +      and ope: "openin (top_of_set (frontier S)) V"
    4.18    obtains g where "arc g" "g ` {0..<1} \<subseteq> S" "pathstart g = x" "pathfinish g \<in> V"
    4.19  proof -
    4.20    have "V \<subseteq> frontier S"
    4.21 @@ -2136,8 +2136,8 @@
    4.22  lemma dense_access_fp_aux:
    4.23    fixes S :: "'a::{complete_space,real_normed_vector} set"
    4.24    assumes S: "open S" "connected S"
    4.25 -      and opeSU: "openin (subtopology euclidean (frontier S)) U"
    4.26 -      and opeSV: "openin (subtopology euclidean (frontier S)) V"
    4.27 +      and opeSU: "openin (top_of_set (frontier S)) U"
    4.28 +      and opeSV: "openin (top_of_set (frontier S)) V"
    4.29        and "V \<noteq> {}" "\<not> U \<subseteq> V"
    4.30    obtains g where "arc g" "pathstart g \<in> U" "pathfinish g \<in> V" "g ` {0<..<1} \<subseteq> S"
    4.31  proof -
    4.32 @@ -2150,7 +2150,7 @@
    4.33    proof (rule dense_accessible_frontier_points_connected [OF S \<open>x \<in> S\<close>])
    4.34      show "U - {pathfinish g} \<noteq> {}"
    4.35        using \<open>pathfinish g \<in> V\<close> \<open>\<not> U \<subseteq> V\<close> by blast
    4.36 -    show "openin (subtopology euclidean (frontier S)) (U - {pathfinish g})"
    4.37 +    show "openin (top_of_set (frontier S)) (U - {pathfinish g})"
    4.38        by (simp add: opeSU openin_delete)
    4.39    qed auto
    4.40    obtain \<gamma> where "arc \<gamma>"
    4.41 @@ -2183,8 +2183,8 @@
    4.42  lemma dense_accessible_frontier_point_pairs:
    4.43    fixes S :: "'a::{complete_space,real_normed_vector} set"
    4.44    assumes S: "open S" "connected S"
    4.45 -      and opeSU: "openin (subtopology euclidean (frontier S)) U"
    4.46 -      and opeSV: "openin (subtopology euclidean (frontier S)) V"
    4.47 +      and opeSU: "openin (top_of_set (frontier S)) U"
    4.48 +      and opeSV: "openin (top_of_set (frontier S)) V"
    4.49        and "U \<noteq> {}" "V \<noteq> {}" "U \<noteq> V"
    4.50      obtains g where "arc g" "pathstart g \<in> U" "pathfinish g \<in> V" "g ` {0<..<1} \<subseteq> S"
    4.51  proof -
     5.1 --- a/src/HOL/Analysis/Brouwer_Fixpoint.thy	Mon Mar 18 21:50:51 2019 +0100
     5.2 +++ b/src/HOL/Analysis/Brouwer_Fixpoint.thy	Tue Mar 19 16:14:59 2019 +0000
     5.3 @@ -85,7 +85,7 @@
     5.4  qed
     5.5  
     5.6  lemma retraction_imp_quotient_map:
     5.7 -  "openin (subtopology euclidean S) (S \<inter> r -` U) \<longleftrightarrow> openin (subtopology euclidean T) U"
     5.8 +  "openin (top_of_set S) (S \<inter> r -` U) \<longleftrightarrow> openin (top_of_set T) U"
     5.9    if retraction: "retraction S T r" and "U \<subseteq> T"
    5.10    using retraction apply (rule retractionE)
    5.11    apply (rule continuous_right_inverse_imp_quotient_map [where g=r])
    5.12 @@ -233,12 +233,12 @@
    5.13  
    5.14  definition%important AR :: "'a::topological_space set \<Rightarrow> bool" where
    5.15  "AR S \<equiv> \<forall>U. \<forall>S'::('a * real) set.
    5.16 -  S homeomorphic S' \<and> closedin (subtopology euclidean U) S' \<longrightarrow> S' retract_of U"
    5.17 +  S homeomorphic S' \<and> closedin (top_of_set U) S' \<longrightarrow> S' retract_of U"
    5.18  
    5.19  definition%important ANR :: "'a::topological_space set \<Rightarrow> bool" where
    5.20  "ANR S \<equiv> \<forall>U. \<forall>S'::('a * real) set.
    5.21 -  S homeomorphic S' \<and> closedin (subtopology euclidean U) S'
    5.22 -  \<longrightarrow> (\<exists>T. openin (subtopology euclidean U) T \<and> S' retract_of T)"
    5.23 +  S homeomorphic S' \<and> closedin (top_of_set U) S'
    5.24 +  \<longrightarrow> (\<exists>T. openin (top_of_set U) T \<and> S' retract_of T)"
    5.25  
    5.26  definition%important ENR :: "'a::topological_space set \<Rightarrow> bool" where
    5.27  "ENR S \<equiv> \<exists>U. open U \<and> S retract_of U"
    5.28 @@ -248,14 +248,14 @@
    5.29  lemma AR_imp_absolute_extensor:
    5.30    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
    5.31    assumes "AR S" and contf: "continuous_on T f" and "f ` T \<subseteq> S"
    5.32 -      and cloUT: "closedin (subtopology euclidean U) T"
    5.33 +      and cloUT: "closedin (top_of_set U) T"
    5.34    obtains g where "continuous_on U g" "g ` U \<subseteq> S" "\<And>x. x \<in> T \<Longrightarrow> g x = f x"
    5.35  proof -
    5.36    have "aff_dim S < int (DIM('b \<times> real))"
    5.37      using aff_dim_le_DIM [of S] by simp
    5.38    then obtain C and S' :: "('b * real) set"
    5.39            where C: "convex C" "C \<noteq> {}"
    5.40 -            and cloCS: "closedin (subtopology euclidean C) S'"
    5.41 +            and cloCS: "closedin (top_of_set C) S'"
    5.42              and hom: "S homeomorphic S'"
    5.43      by (metis that homeomorphic_closedin_convex)
    5.44    then have "S' retract_of C"
    5.45 @@ -296,7 +296,7 @@
    5.46  lemma AR_imp_absolute_retract:
    5.47    fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set"
    5.48    assumes "AR S" "S homeomorphic S'"
    5.49 -      and clo: "closedin (subtopology euclidean U) S'"
    5.50 +      and clo: "closedin (top_of_set U) S'"
    5.51      shows "S' retract_of U"
    5.52  proof -
    5.53    obtain g h where hom: "homeomorphism S S' g h"
    5.54 @@ -334,12 +334,12 @@
    5.55    fixes S :: "'a::euclidean_space set"
    5.56    assumes "\<And>f :: 'a * real \<Rightarrow> 'a.
    5.57             \<And>U T. \<lbrakk>continuous_on T f;  f ` T \<subseteq> S;
    5.58 -                  closedin (subtopology euclidean U) T\<rbrakk>
    5.59 +                  closedin (top_of_set U) T\<rbrakk>
    5.60                   \<Longrightarrow> \<exists>g. continuous_on U g \<and> g ` U \<subseteq> S \<and> (\<forall>x \<in> T. g x = f x)"
    5.61    shows "AR S"
    5.62  proof (clarsimp simp: AR_def)
    5.63    fix U and T :: "('a * real) set"
    5.64 -  assume "S homeomorphic T" and clo: "closedin (subtopology euclidean U) T"
    5.65 +  assume "S homeomorphic T" and clo: "closedin (top_of_set U) T"
    5.66    then obtain g h where hom: "homeomorphism S T g h"
    5.67      by (force simp: homeomorphic_def)
    5.68    have h: "continuous_on T h" " h ` T \<subseteq> S"
    5.69 @@ -369,7 +369,7 @@
    5.70    shows "AR S \<longleftrightarrow>
    5.71         (\<forall>f :: 'a * real \<Rightarrow> 'a.
    5.72          \<forall>U T. continuous_on T f \<longrightarrow> f ` T \<subseteq> S \<longrightarrow>
    5.73 -               closedin (subtopology euclidean U) T \<longrightarrow>
    5.74 +               closedin (top_of_set U) T \<longrightarrow>
    5.75                  (\<exists>g. continuous_on U g \<and> g ` U \<subseteq> S \<and> (\<forall>x \<in> T. g x = f x)))"
    5.76  apply (rule iffI)
    5.77   apply (metis AR_imp_absolute_extensor)
    5.78 @@ -378,7 +378,7 @@
    5.79  
    5.80  lemma AR_imp_retract:
    5.81    fixes S :: "'a::euclidean_space set"
    5.82 -  assumes "AR S \<and> closedin (subtopology euclidean U) S"
    5.83 +  assumes "AR S \<and> closedin (top_of_set U) S"
    5.84      shows "S retract_of U"
    5.85  using AR_imp_absolute_retract assms homeomorphic_refl by blast
    5.86  
    5.87 @@ -398,8 +398,8 @@
    5.88  lemma ANR_imp_absolute_neighbourhood_extensor:
    5.89    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
    5.90    assumes "ANR S" and contf: "continuous_on T f" and "f ` T \<subseteq> S"
    5.91 -      and cloUT: "closedin (subtopology euclidean U) T"
    5.92 -  obtains V g where "T \<subseteq> V" "openin (subtopology euclidean U) V"
    5.93 +      and cloUT: "closedin (top_of_set U) T"
    5.94 +  obtains V g where "T \<subseteq> V" "openin (top_of_set U) V"
    5.95                      "continuous_on V g"
    5.96                      "g ` V \<subseteq> S" "\<And>x. x \<in> T \<Longrightarrow> g x = f x"
    5.97  proof -
    5.98 @@ -407,10 +407,10 @@
    5.99      using aff_dim_le_DIM [of S] by simp
   5.100    then obtain C and S' :: "('b * real) set"
   5.101            where C: "convex C" "C \<noteq> {}"
   5.102 -            and cloCS: "closedin (subtopology euclidean C) S'"
   5.103 +            and cloCS: "closedin (top_of_set C) S'"
   5.104              and hom: "S homeomorphic S'"
   5.105      by (metis that homeomorphic_closedin_convex)
   5.106 -  then obtain D where opD: "openin (subtopology euclidean C) D" and "S' retract_of D"
   5.107 +  then obtain D where opD: "openin (top_of_set C) D" and "S' retract_of D"
   5.108      using \<open>ANR S\<close> by (auto simp: ANR_def)
   5.109    then obtain r where "S' \<subseteq> D" and contr: "continuous_on D r"
   5.110                    and "r ` D \<subseteq> S'" and rid: "\<And>x. x \<in> S' \<Longrightarrow> r x = x"
   5.111 @@ -437,7 +437,7 @@
   5.112      show "T \<subseteq> U \<inter> f' -` D"
   5.113        using cloUT closedin_imp_subset \<open>S' \<subseteq> D\<close> \<open>f ` T \<subseteq> S\<close> eq homeomorphism_image1 homgh
   5.114        by fastforce
   5.115 -    show ope: "openin (subtopology euclidean U) (U \<inter> f' -` D)"
   5.116 +    show ope: "openin (top_of_set U) (U \<inter> f' -` D)"
   5.117        using  \<open>f' ` U \<subseteq> C\<close> by (auto simp: opD contf' continuous_openin_preimage)
   5.118      have conth: "continuous_on (r ` f' ` (U \<inter> f' -` D)) h"
   5.119        apply (rule continuous_on_subset [of S'])
   5.120 @@ -460,8 +460,8 @@
   5.121  corollary ANR_imp_absolute_neighbourhood_retract:
   5.122    fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set"
   5.123    assumes "ANR S" "S homeomorphic S'"
   5.124 -      and clo: "closedin (subtopology euclidean U) S'"
   5.125 -  obtains V where "openin (subtopology euclidean U) V" "S' retract_of V"
   5.126 +      and clo: "closedin (top_of_set U) S'"
   5.127 +  obtains V where "openin (top_of_set U) V" "S' retract_of V"
   5.128  proof -
   5.129    obtain g h where hom: "homeomorphism S S' g h"
   5.130      using assms by (force simp: homeomorphic_def)
   5.131 @@ -470,7 +470,7 @@
   5.132      apply (metis hom equalityE homeomorphism_def)
   5.133      done
   5.134      from ANR_imp_absolute_neighbourhood_extensor [OF \<open>ANR S\<close> h clo]
   5.135 -  obtain V h' where "S' \<subseteq> V" and opUV: "openin (subtopology euclidean U) V"
   5.136 +  obtain V h' where "S' \<subseteq> V" and opUV: "openin (top_of_set U) V"
   5.137                  and h': "continuous_on V h'" "h' ` V \<subseteq> S"
   5.138                  and h'h:"\<And>x. x \<in> S' \<Longrightarrow> h' x = h x"
   5.139      by (blast intro: ANR_imp_absolute_neighbourhood_extensor [OF \<open>ANR S\<close> h clo])
   5.140 @@ -508,20 +508,20 @@
   5.141    fixes S :: "'a::euclidean_space set"
   5.142    assumes "\<And>f :: 'a * real \<Rightarrow> 'a.
   5.143             \<And>U T. \<lbrakk>continuous_on T f;  f ` T \<subseteq> S;
   5.144 -                  closedin (subtopology euclidean U) T\<rbrakk>
   5.145 -                 \<Longrightarrow> \<exists>V g. T \<subseteq> V \<and> openin (subtopology euclidean U) V \<and>
   5.146 +                  closedin (top_of_set U) T\<rbrakk>
   5.147 +                 \<Longrightarrow> \<exists>V g. T \<subseteq> V \<and> openin (top_of_set U) V \<and>
   5.148                         continuous_on V g \<and> g ` V \<subseteq> S \<and> (\<forall>x \<in> T. g x = f x)"
   5.149    shows "ANR S"
   5.150  proof (clarsimp simp: ANR_def)
   5.151    fix U and T :: "('a * real) set"
   5.152 -  assume "S homeomorphic T" and clo: "closedin (subtopology euclidean U) T"
   5.153 +  assume "S homeomorphic T" and clo: "closedin (top_of_set U) T"
   5.154    then obtain g h where hom: "homeomorphism S T g h"
   5.155      by (force simp: homeomorphic_def)
   5.156    have h: "continuous_on T h" " h ` T \<subseteq> S"
   5.157      using hom homeomorphism_def apply blast
   5.158      apply (metis hom equalityE homeomorphism_def)
   5.159      done
   5.160 -  obtain V h' where "T \<subseteq> V" and opV: "openin (subtopology euclidean U) V"
   5.161 +  obtain V h' where "T \<subseteq> V" and opV: "openin (top_of_set U) V"
   5.162                  and h': "continuous_on V h'" "h' ` V \<subseteq> S"
   5.163                and h'h: "\<forall>x\<in>T. h' x = h x"
   5.164      using assms [OF h clo] by blast
   5.165 @@ -538,7 +538,7 @@
   5.166      show "\<forall>x\<in>T. (g \<circ> h') x = x"
   5.167        by clarsimp (metis h'h hom homeomorphism_def)
   5.168    qed
   5.169 -  then show "\<exists>V. openin (subtopology euclidean U) V \<and> T retract_of V"
   5.170 +  then show "\<exists>V. openin (top_of_set U) V \<and> T retract_of V"
   5.171      using opV by blast
   5.172  qed
   5.173  
   5.174 @@ -547,8 +547,8 @@
   5.175    shows "ANR S \<longleftrightarrow>
   5.176           (\<forall>f :: 'a * real \<Rightarrow> 'a.
   5.177            \<forall>U T. continuous_on T f \<longrightarrow> f ` T \<subseteq> S \<longrightarrow>
   5.178 -                closedin (subtopology euclidean U) T \<longrightarrow>
   5.179 -               (\<exists>V g. T \<subseteq> V \<and> openin (subtopology euclidean U) V \<and>
   5.180 +                closedin (top_of_set U) T \<longrightarrow>
   5.181 +               (\<exists>V g. T \<subseteq> V \<and> openin (top_of_set U) V \<and>
   5.182                         continuous_on V g \<and> g ` V \<subseteq> S \<and> (\<forall>x \<in> T. g x = f x)))"
   5.183  apply (rule iffI)
   5.184   apply (metis ANR_imp_absolute_neighbourhood_extensor)
   5.185 @@ -557,27 +557,27 @@
   5.186  
   5.187  lemma ANR_imp_neighbourhood_retract:
   5.188    fixes S :: "'a::euclidean_space set"
   5.189 -  assumes "ANR S" "closedin (subtopology euclidean U) S"
   5.190 -  obtains V where "openin (subtopology euclidean U) V" "S retract_of V"
   5.191 +  assumes "ANR S" "closedin (top_of_set U) S"
   5.192 +  obtains V where "openin (top_of_set U) V" "S retract_of V"
   5.193  using ANR_imp_absolute_neighbourhood_retract assms homeomorphic_refl by blast
   5.194  
   5.195  lemma ANR_imp_absolute_closed_neighbourhood_retract:
   5.196    fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set"
   5.197 -  assumes "ANR S" "S homeomorphic S'" and US': "closedin (subtopology euclidean U) S'"
   5.198 +  assumes "ANR S" "S homeomorphic S'" and US': "closedin (top_of_set U) S'"
   5.199    obtains V W
   5.200 -    where "openin (subtopology euclidean U) V"
   5.201 -          "closedin (subtopology euclidean U) W"
   5.202 +    where "openin (top_of_set U) V"
   5.203 +          "closedin (top_of_set U) W"
   5.204            "S' \<subseteq> V" "V \<subseteq> W" "S' retract_of W"
   5.205  proof -
   5.206 -  obtain Z where "openin (subtopology euclidean U) Z" and S'Z: "S' retract_of Z"
   5.207 +  obtain Z where "openin (top_of_set U) Z" and S'Z: "S' retract_of Z"
   5.208      by (blast intro: assms ANR_imp_absolute_neighbourhood_retract)
   5.209 -  then have UUZ: "closedin (subtopology euclidean U) (U - Z)"
   5.210 +  then have UUZ: "closedin (top_of_set U) (U - Z)"
   5.211      by auto
   5.212    have "S' \<inter> (U - Z) = {}"
   5.213      using \<open>S' retract_of Z\<close> closedin_retract closedin_subtopology by fastforce
   5.214    then obtain V W
   5.215 -      where "openin (subtopology euclidean U) V"
   5.216 -        and "openin (subtopology euclidean U) W"
   5.217 +      where "openin (top_of_set U) V"
   5.218 +        and "openin (top_of_set U) W"
   5.219          and "S' \<subseteq> V" "U - Z \<subseteq> W" "V \<inter> W = {}"
   5.220        using separation_normal_local [OF US' UUZ]  by auto
   5.221    moreover have "S' retract_of U - W"
   5.222 @@ -592,9 +592,9 @@
   5.223  
   5.224  lemma ANR_imp_closed_neighbourhood_retract:
   5.225    fixes S :: "'a::euclidean_space set"
   5.226 -  assumes "ANR S" "closedin (subtopology euclidean U) S"
   5.227 -  obtains V W where "openin (subtopology euclidean U) V"
   5.228 -                    "closedin (subtopology euclidean U) W"
   5.229 +  assumes "ANR S" "closedin (top_of_set U) S"
   5.230 +  obtains V W where "openin (top_of_set U) V"
   5.231 +                    "closedin (top_of_set U) W"
   5.232                      "S \<subseteq> V" "V \<subseteq> W" "S retract_of W"
   5.233  by (meson ANR_imp_absolute_closed_neighbourhood_retract assms homeomorphic_refl)
   5.234  
   5.235 @@ -616,7 +616,7 @@
   5.236    fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set"
   5.237    assumes "ENR S" and hom: "S homeomorphic S'"
   5.238        and "S' \<subseteq> U"
   5.239 -  obtains V where "openin (subtopology euclidean U) V" "S' retract_of V"
   5.240 +  obtains V where "openin (top_of_set U) V" "S' retract_of V"
   5.241  proof -
   5.242    obtain X where "open X" "S retract_of X"
   5.243      using \<open>ENR S\<close> by (auto simp: ENR_def)
   5.244 @@ -625,8 +625,8 @@
   5.245    have "locally compact S'"
   5.246      using retract_of_locally_compact open_imp_locally_compact
   5.247            homeomorphic_local_compactness \<open>S retract_of X\<close> \<open>open X\<close> hom by blast
   5.248 -  then obtain W where UW: "openin (subtopology euclidean U) W"
   5.249 -                  and WS': "closedin (subtopology euclidean W) S'"
   5.250 +  then obtain W where UW: "openin (top_of_set U) W"
   5.251 +                  and WS': "closedin (top_of_set W) S'"
   5.252      apply (rule locally_compact_closedin_open)
   5.253      apply (rename_tac W)
   5.254      apply (rule_tac W = "U \<inter> W" in that, blast)
   5.255 @@ -752,7 +752,7 @@
   5.256  proof
   5.257    assume ?lhs
   5.258    obtain C and S' :: "('a * real) set"
   5.259 -    where "convex C" "C \<noteq> {}" "closedin (subtopology euclidean C) S'" "S homeomorphic S'"
   5.260 +    where "convex C" "C \<noteq> {}" "closedin (top_of_set C) S'" "S homeomorphic S'"
   5.261        apply (rule homeomorphic_closedin_convex [of S, where 'n = "'a * real"])
   5.262        using aff_dim_le_DIM [of S] by auto
   5.263    with \<open>AR S\<close> have "contractible S"
   5.264 @@ -777,27 +777,27 @@
   5.265      by (metis all_not_in_conv atLeastAtMost_iff image_subset_iff mem_Sigma_iff order_refl zero_le_one)
   5.266    have "\<exists>g. continuous_on W g \<and> g ` W \<subseteq> S \<and> (\<forall>x\<in>T. g x = f x)"
   5.267           if      f: "continuous_on T f" "f ` T \<subseteq> S"
   5.268 -            and WT: "closedin (subtopology euclidean W) T"
   5.269 +            and WT: "closedin (top_of_set W) T"
   5.270           for W T and f :: "'a \<times> real \<Rightarrow> 'a"
   5.271    proof -
   5.272      obtain U g
   5.273 -      where "T \<subseteq> U" and WU: "openin (subtopology euclidean W) U"
   5.274 +      where "T \<subseteq> U" and WU: "openin (top_of_set W) U"
   5.275          and contg: "continuous_on U g"
   5.276          and "g ` U \<subseteq> S" and gf: "\<And>x. x \<in> T \<Longrightarrow> g x = f x"
   5.277        using iffD1 [OF ANR_eq_absolute_neighbourhood_extensor \<open>ANR S\<close>, rule_format, OF f WT]
   5.278        by auto
   5.279 -    have WWU: "closedin (subtopology euclidean W) (W - U)"
   5.280 +    have WWU: "closedin (top_of_set W) (W - U)"
   5.281        using WU closedin_diff by fastforce
   5.282      moreover have "(W - U) \<inter> T = {}"
   5.283        using \<open>T \<subseteq> U\<close> by auto
   5.284      ultimately obtain V V'
   5.285 -      where WV': "openin (subtopology euclidean W) V'"
   5.286 -        and WV: "openin (subtopology euclidean W) V"
   5.287 +      where WV': "openin (top_of_set W) V'"
   5.288 +        and WV: "openin (top_of_set W) V"
   5.289          and "W - U \<subseteq> V'" "T \<subseteq> V" "V' \<inter> V = {}"
   5.290        using separation_normal_local [of W "W-U" T] WT by blast
   5.291      then have WVT: "T \<inter> (W - V) = {}"
   5.292        by auto
   5.293 -    have WWV: "closedin (subtopology euclidean W) (W - V)"
   5.294 +    have WWV: "closedin (top_of_set W) (W - V)"
   5.295        using WV closedin_diff by fastforce
   5.296      obtain j :: " 'a \<times> real \<Rightarrow> real"
   5.297        where contj: "continuous_on W j"
   5.298 @@ -931,8 +931,8 @@
   5.299  
   5.300  lemma AR_closed_Un_local_aux:
   5.301    fixes U :: "'a::euclidean_space set"
   5.302 -  assumes "closedin (subtopology euclidean U) S"
   5.303 -          "closedin (subtopology euclidean U) T"
   5.304 +  assumes "closedin (top_of_set U) S"
   5.305 +          "closedin (top_of_set U) T"
   5.306            "AR S" "AR T" "AR(S \<inter> T)"
   5.307    shows "(S \<union> T) retract_of U"
   5.308  proof -
   5.309 @@ -943,10 +943,10 @@
   5.310    define S' where "S' \<equiv> {x \<in> U. setdist {x} S \<le> setdist {x} T}"
   5.311    define T' where "T' \<equiv> {x \<in> U. setdist {x} T \<le> setdist {x} S}"
   5.312    define W  where "W \<equiv> {x \<in> U. setdist {x} S = setdist {x} T}"
   5.313 -  have US': "closedin (subtopology euclidean U) S'"
   5.314 +  have US': "closedin (top_of_set U) S'"
   5.315      using continuous_closedin_preimage [of U "\<lambda>x. setdist {x} S - setdist {x} T" "{..0}"]
   5.316      by (simp add: S'_def vimage_def Collect_conj_eq continuous_on_diff continuous_on_setdist)
   5.317 -  have UT': "closedin (subtopology euclidean U) T'"
   5.318 +  have UT': "closedin (top_of_set U) T'"
   5.319      using continuous_closedin_preimage [of U "\<lambda>x. setdist {x} T - setdist {x} S" "{..0}"]
   5.320      by (simp add: T'_def vimage_def Collect_conj_eq continuous_on_diff continuous_on_setdist)
   5.321    have "S \<subseteq> S'"
   5.322 @@ -971,7 +971,7 @@
   5.323      by (force simp: W_def setdist_sing_in_set)
   5.324    have "S' \<inter> T' = W"
   5.325      by (auto simp: S'_def T'_def W_def)
   5.326 -  then have cloUW: "closedin (subtopology euclidean U) W"
   5.327 +  then have cloUW: "closedin (top_of_set U) W"
   5.328      using closedin_Int US' UT' by blast
   5.329    define r where "r \<equiv> \<lambda>x. if x \<in> W then r0 x else x"
   5.330    have "r ` (W \<union> S) \<subseteq> S" "r ` (W \<union> T) \<subseteq> T"
   5.331 @@ -979,14 +979,14 @@
   5.332    have contr: "continuous_on (W \<union> (S \<union> T)) r"
   5.333    unfolding r_def
   5.334    proof (rule continuous_on_cases_local [OF _ _ contr0 continuous_on_id])
   5.335 -    show "closedin (subtopology euclidean (W \<union> (S \<union> T))) W"
   5.336 -      using \<open>S \<subseteq> U\<close> \<open>T \<subseteq> U\<close> \<open>W \<subseteq> U\<close> \<open>closedin (subtopology euclidean U) W\<close> closedin_subset_trans by fastforce
   5.337 -    show "closedin (subtopology euclidean (W \<union> (S \<union> T))) (S \<union> T)"
   5.338 +    show "closedin (top_of_set (W \<union> (S \<union> T))) W"
   5.339 +      using \<open>S \<subseteq> U\<close> \<open>T \<subseteq> U\<close> \<open>W \<subseteq> U\<close> \<open>closedin (top_of_set U) W\<close> closedin_subset_trans by fastforce
   5.340 +    show "closedin (top_of_set (W \<union> (S \<union> T))) (S \<union> T)"
   5.341        by (meson \<open>S \<subseteq> U\<close> \<open>T \<subseteq> U\<close> \<open>W \<subseteq> U\<close> assms closedin_Un closedin_subset_trans sup.bounded_iff sup.cobounded2)
   5.342      show "\<And>x. x \<in> W \<and> x \<notin> W \<or> x \<in> S \<union> T \<and> x \<in> W \<Longrightarrow> r0 x = x"
   5.343        by (auto simp: ST)
   5.344    qed
   5.345 -  have cloUWS: "closedin (subtopology euclidean U) (W \<union> S)"
   5.346 +  have cloUWS: "closedin (top_of_set U) (W \<union> S)"
   5.347      by (simp add: cloUW assms closedin_Un)
   5.348    obtain g where contg: "continuous_on U g"
   5.349               and "g ` U \<subseteq> S" and geqr: "\<And>x. x \<in> W \<union> S \<Longrightarrow> g x = r x"
   5.350 @@ -994,7 +994,7 @@
   5.351        apply (rule continuous_on_subset [OF contr])
   5.352        using \<open>r ` (W \<union> S) \<subseteq> S\<close> apply auto
   5.353      done
   5.354 -  have cloUWT: "closedin (subtopology euclidean U) (W \<union> T)"
   5.355 +  have cloUWT: "closedin (top_of_set U) (W \<union> T)"
   5.356      by (simp add: cloUW assms closedin_Un)
   5.357    obtain h where conth: "continuous_on U h"
   5.358               and "h ` U \<subseteq> T" and heqr: "\<And>x. x \<in> W \<union> T \<Longrightarrow> h x = r x"
   5.359 @@ -1022,24 +1022,24 @@
   5.360  
   5.361  lemma AR_closed_Un_local:
   5.362    fixes S :: "'a::euclidean_space set"
   5.363 -  assumes STS: "closedin (subtopology euclidean (S \<union> T)) S"
   5.364 -      and STT: "closedin (subtopology euclidean (S \<union> T)) T"
   5.365 +  assumes STS: "closedin (top_of_set (S \<union> T)) S"
   5.366 +      and STT: "closedin (top_of_set (S \<union> T)) T"
   5.367        and "AR S" "AR T" "AR(S \<inter> T)"
   5.368      shows "AR(S \<union> T)"
   5.369  proof -
   5.370    have "C retract_of U"
   5.371 -       if hom: "S \<union> T homeomorphic C" and UC: "closedin (subtopology euclidean U) C"
   5.372 +       if hom: "S \<union> T homeomorphic C" and UC: "closedin (top_of_set U) C"
   5.373         for U and C :: "('a * real) set"
   5.374    proof -
   5.375      obtain f g where hom: "homeomorphism (S \<union> T) C f g"
   5.376        using hom by (force simp: homeomorphic_def)
   5.377 -    have US: "closedin (subtopology euclidean U) (C \<inter> g -` S)"
   5.378 +    have US: "closedin (top_of_set U) (C \<inter> g -` S)"
   5.379        apply (rule closedin_trans [OF _ UC])
   5.380        apply (rule continuous_closedin_preimage_gen [OF _ _ STS])
   5.381        using hom homeomorphism_def apply blast
   5.382        apply (metis hom homeomorphism_def set_eq_subset)
   5.383        done
   5.384 -    have UT: "closedin (subtopology euclidean U) (C \<inter> g -` T)"
   5.385 +    have UT: "closedin (top_of_set U) (C \<inter> g -` T)"
   5.386        apply (rule closedin_trans [OF _ UC])
   5.387        apply (rule continuous_closedin_preimage_gen [OF _ _ STT])
   5.388        using hom homeomorphism_def apply blast
   5.389 @@ -1088,10 +1088,10 @@
   5.390  
   5.391  lemma ANR_closed_Un_local_aux:
   5.392    fixes U :: "'a::euclidean_space set"
   5.393 -  assumes US: "closedin (subtopology euclidean U) S"
   5.394 -      and UT: "closedin (subtopology euclidean U) T"
   5.395 +  assumes US: "closedin (top_of_set U) S"
   5.396 +      and UT: "closedin (top_of_set U) T"
   5.397        and "ANR S" "ANR T" "ANR(S \<inter> T)"
   5.398 -  obtains V where "openin (subtopology euclidean U) V" "(S \<union> T) retract_of V"
   5.399 +  obtains V where "openin (top_of_set U) V" "(S \<union> T) retract_of V"
   5.400  proof (cases "S = {} \<or> T = {}")
   5.401    case True with assms that show ?thesis
   5.402      by (metis ANR_imp_neighbourhood_retract Un_commute inf_bot_right sup_inf_absorb)
   5.403 @@ -1103,10 +1103,10 @@
   5.404    define S' where "S' \<equiv> {x \<in> U. setdist {x} S \<le> setdist {x} T}"
   5.405    define T' where "T' \<equiv> {x \<in> U. setdist {x} T \<le> setdist {x} S}"
   5.406    define W  where "W \<equiv> {x \<in> U. setdist {x} S = setdist {x} T}"
   5.407 -  have cloUS': "closedin (subtopology euclidean U) S'"
   5.408 +  have cloUS': "closedin (top_of_set U) S'"
   5.409      using continuous_closedin_preimage [of U "\<lambda>x. setdist {x} S - setdist {x} T" "{..0}"]
   5.410      by (simp add: S'_def vimage_def Collect_conj_eq continuous_on_diff continuous_on_setdist)
   5.411 -  have cloUT': "closedin (subtopology euclidean U) T'"
   5.412 +  have cloUT': "closedin (top_of_set U) T'"
   5.413      using continuous_closedin_preimage [of U "\<lambda>x. setdist {x} T - setdist {x} S" "{..0}"]
   5.414      by (simp add: T'_def vimage_def Collect_conj_eq continuous_on_diff continuous_on_setdist)
   5.415    have "S \<subseteq> S'"
   5.416 @@ -1123,17 +1123,17 @@
   5.417      using \<open>S \<subseteq> U\<close> by (force simp: W_def setdist_sing_in_set)+
   5.418    have "S' \<inter> T' = W"
   5.419      by (auto simp: S'_def T'_def W_def)
   5.420 -  then have cloUW: "closedin (subtopology euclidean U) W"
   5.421 +  then have cloUW: "closedin (top_of_set U) W"
   5.422      using closedin_Int cloUS' cloUT' by blast
   5.423 -  obtain W' W0 where "openin (subtopology euclidean W) W'"
   5.424 -                 and cloWW0: "closedin (subtopology euclidean W) W0"
   5.425 +  obtain W' W0 where "openin (top_of_set W) W'"
   5.426 +                 and cloWW0: "closedin (top_of_set W) W0"
   5.427                   and "S \<inter> T \<subseteq> W'" "W' \<subseteq> W0"
   5.428                   and ret: "(S \<inter> T) retract_of W0"
   5.429      apply (rule ANR_imp_closed_neighbourhood_retract [OF \<open>ANR(S \<inter> T)\<close>])
   5.430      apply (rule closedin_subset_trans [of U, OF _ ST_W \<open>W \<subseteq> U\<close>])
   5.431      apply (blast intro: assms)+
   5.432      done
   5.433 -  then obtain U0 where opeUU0: "openin (subtopology euclidean U) U0"
   5.434 +  then obtain U0 where opeUU0: "openin (top_of_set U) U0"
   5.435                     and U0: "S \<inter> T \<subseteq> U0" "U0 \<inter> W \<subseteq> W0"
   5.436      unfolding openin_open  using \<open>W \<subseteq> U\<close> by blast
   5.437    have "W0 \<subseteq> U"
   5.438 @@ -1150,29 +1150,29 @@
   5.439    have contr: "continuous_on (W0 \<union> (S \<union> T)) r"
   5.440    unfolding r_def
   5.441    proof (rule continuous_on_cases_local [OF _ _ contr0 continuous_on_id])
   5.442 -    show "closedin (subtopology euclidean (W0 \<union> (S \<union> T))) W0"
   5.443 +    show "closedin (top_of_set (W0 \<union> (S \<union> T))) W0"
   5.444        apply (rule closedin_subset_trans [of U])
   5.445        using cloWW0 cloUW closedin_trans \<open>W0 \<subseteq> U\<close> \<open>S \<subseteq> U\<close> \<open>T \<subseteq> U\<close> apply blast+
   5.446        done
   5.447 -    show "closedin (subtopology euclidean (W0 \<union> (S \<union> T))) (S \<union> T)"
   5.448 +    show "closedin (top_of_set (W0 \<union> (S \<union> T))) (S \<union> T)"
   5.449        by (meson \<open>S \<subseteq> U\<close> \<open>T \<subseteq> U\<close> \<open>W0 \<subseteq> U\<close> assms closedin_Un closedin_subset_trans sup.bounded_iff sup.cobounded2)
   5.450      show "\<And>x. x \<in> W0 \<and> x \<notin> W0 \<or> x \<in> S \<union> T \<and> x \<in> W0 \<Longrightarrow> r0 x = x"
   5.451        using ST cloWW0 closedin_subset by fastforce
   5.452    qed
   5.453 -  have cloS'WS: "closedin (subtopology euclidean S') (W0 \<union> S)"
   5.454 +  have cloS'WS: "closedin (top_of_set S') (W0 \<union> S)"
   5.455      by (meson closedin_subset_trans US cloUS' \<open>S \<subseteq> S'\<close> \<open>W \<subseteq> S'\<close> cloUW cloWW0 
   5.456                closedin_Un closedin_imp_subset closedin_trans)
   5.457    obtain W1 g where "W0 \<union> S \<subseteq> W1" and contg: "continuous_on W1 g"
   5.458 -                and opeSW1: "openin (subtopology euclidean S') W1"
   5.459 +                and opeSW1: "openin (top_of_set S') W1"
   5.460                  and "g ` W1 \<subseteq> S" and geqr: "\<And>x. x \<in> W0 \<union> S \<Longrightarrow> g x = r x"
   5.461      apply (rule ANR_imp_absolute_neighbourhood_extensor [OF \<open>ANR S\<close> _ \<open>r ` (W0 \<union> S) \<subseteq> S\<close> cloS'WS])
   5.462       apply (rule continuous_on_subset [OF contr], blast+)
   5.463      done
   5.464 -  have cloT'WT: "closedin (subtopology euclidean T') (W0 \<union> T)"
   5.465 +  have cloT'WT: "closedin (top_of_set T') (W0 \<union> T)"
   5.466      by (meson closedin_subset_trans UT cloUT' \<open>T \<subseteq> T'\<close> \<open>W \<subseteq> T'\<close> cloUW cloWW0 
   5.467                closedin_Un closedin_imp_subset closedin_trans)
   5.468    obtain W2 h where "W0 \<union> T \<subseteq> W2" and conth: "continuous_on W2 h"
   5.469 -                and opeSW2: "openin (subtopology euclidean T') W2"
   5.470 +                and opeSW2: "openin (top_of_set T') W2"
   5.471                  and "h ` W2 \<subseteq> T" and heqr: "\<And>x. x \<in> W0 \<union> T \<Longrightarrow> h x = r x"
   5.472      apply (rule ANR_imp_absolute_neighbourhood_extensor [OF \<open>ANR T\<close> _ \<open>r ` (W0 \<union> T) \<subseteq> T\<close> cloT'WT])
   5.473       apply (rule continuous_on_subset [OF contr], blast+)
   5.474 @@ -1187,17 +1187,17 @@
   5.475           ((U - T') \<inter> O1 \<union> (U - S') \<inter> O2 \<union> U \<inter> O1 \<inter> O2) - (W - U0)"
   5.476       using \<open>U0 \<inter> W \<subseteq> W0\<close> \<open>W0 \<union> S \<subseteq> W1\<close> \<open>W0 \<union> T \<subseteq> W2\<close>
   5.477        by (auto simp: \<open>S' \<union> T' = U\<close> [symmetric] \<open>S' \<inter> T' = W\<close> [symmetric] \<open>W1 = S' \<inter> O1\<close> \<open>W2 = T' \<inter> O2\<close>)
   5.478 -    show "openin (subtopology euclidean U) (W1 - (W - U0) \<union> (W2 - (W - U0)))"
   5.479 +    show "openin (top_of_set U) (W1 - (W - U0) \<union> (W2 - (W - U0)))"
   5.480        apply (subst eq)
   5.481        apply (intro openin_Un openin_Int_open openin_diff closedin_diff cloUW opeUU0 cloUS' cloUT' \<open>open O1\<close> \<open>open O2\<close>, simp_all)
   5.482        done
   5.483 -    have cloW1: "closedin (subtopology euclidean (W1 - (W - U0) \<union> (W2 - (W - U0)))) (W1 - (W - U0))"
   5.484 +    have cloW1: "closedin (top_of_set (W1 - (W - U0) \<union> (W2 - (W - U0)))) (W1 - (W - U0))"
   5.485        using cloUS' apply (simp add: closedin_closed)
   5.486        apply (erule ex_forward)
   5.487        using U0 \<open>W0 \<union> S \<subseteq> W1\<close>
   5.488        apply (auto simp: \<open>W1 = S' \<inter> O1\<close> \<open>W2 = T' \<inter> O2\<close> \<open>S' \<union> T' = U\<close> [symmetric]\<open>S' \<inter> T' = W\<close> [symmetric])
   5.489        done
   5.490 -    have cloW2: "closedin (subtopology euclidean (W1 - (W - U0) \<union> (W2 - (W - U0)))) (W2 - (W - U0))"
   5.491 +    have cloW2: "closedin (top_of_set (W1 - (W - U0) \<union> (W2 - (W - U0)))) (W2 - (W - U0))"
   5.492        using cloUT' apply (simp add: closedin_closed)
   5.493        apply (erule ex_forward)
   5.494        using U0 \<open>W0 \<union> T \<subseteq> W2\<close>
   5.495 @@ -1227,24 +1227,24 @@
   5.496  
   5.497  lemma ANR_closed_Un_local:
   5.498    fixes S :: "'a::euclidean_space set"
   5.499 -  assumes STS: "closedin (subtopology euclidean (S \<union> T)) S"
   5.500 -      and STT: "closedin (subtopology euclidean (S \<union> T)) T"
   5.501 +  assumes STS: "closedin (top_of_set (S \<union> T)) S"
   5.502 +      and STT: "closedin (top_of_set (S \<union> T)) T"
   5.503        and "ANR S" "ANR T" "ANR(S \<inter> T)" 
   5.504      shows "ANR(S \<union> T)"
   5.505  proof -
   5.506 -  have "\<exists>T. openin (subtopology euclidean U) T \<and> C retract_of T"
   5.507 -       if hom: "S \<union> T homeomorphic C" and UC: "closedin (subtopology euclidean U) C"
   5.508 +  have "\<exists>T. openin (top_of_set U) T \<and> C retract_of T"
   5.509 +       if hom: "S \<union> T homeomorphic C" and UC: "closedin (top_of_set U) C"
   5.510         for U and C :: "('a * real) set"
   5.511    proof -
   5.512      obtain f g where hom: "homeomorphism (S \<union> T) C f g"
   5.513        using hom by (force simp: homeomorphic_def)
   5.514 -    have US: "closedin (subtopology euclidean U) (C \<inter> g -` S)"
   5.515 +    have US: "closedin (top_of_set U) (C \<inter> g -` S)"
   5.516        apply (rule closedin_trans [OF _ UC])
   5.517        apply (rule continuous_closedin_preimage_gen [OF _ _ STS])
   5.518        using hom [unfolded homeomorphism_def] apply blast
   5.519        apply (metis hom homeomorphism_def set_eq_subset)
   5.520        done
   5.521 -    have UT: "closedin (subtopology euclidean U) (C \<inter> g -` T)"
   5.522 +    have UT: "closedin (top_of_set U) (C \<inter> g -` T)"
   5.523        apply (rule closedin_trans [OF _ UC])
   5.524        apply (rule continuous_closedin_preimage_gen [OF _ _ STT])
   5.525        using hom [unfolded homeomorphism_def] apply blast
   5.526 @@ -1291,26 +1291,26 @@
   5.527  
   5.528  lemma ANR_openin:
   5.529    fixes S :: "'a::euclidean_space set"
   5.530 -  assumes "ANR T" and opeTS: "openin (subtopology euclidean T) S"
   5.531 +  assumes "ANR T" and opeTS: "openin (top_of_set T) S"
   5.532    shows "ANR S"
   5.533  proof (clarsimp simp only: ANR_eq_absolute_neighbourhood_extensor)
   5.534    fix f :: "'a \<times> real \<Rightarrow> 'a" and U C
   5.535    assume contf: "continuous_on C f" and fim: "f ` C \<subseteq> S"
   5.536 -     and cloUC: "closedin (subtopology euclidean U) C"
   5.537 +     and cloUC: "closedin (top_of_set U) C"
   5.538    have "f ` C \<subseteq> T"
   5.539      using fim opeTS openin_imp_subset by blast
   5.540    obtain W g where "C \<subseteq> W"
   5.541 -               and UW: "openin (subtopology euclidean U) W"
   5.542 +               and UW: "openin (top_of_set U) W"
   5.543                 and contg: "continuous_on W g"
   5.544                 and gim: "g ` W \<subseteq> T"
   5.545                 and geq: "\<And>x. x \<in> C \<Longrightarrow> g x = f x"
   5.546      apply (rule ANR_imp_absolute_neighbourhood_extensor [OF \<open>ANR T\<close> contf \<open>f ` C \<subseteq> T\<close> cloUC])
   5.547      using fim by auto
   5.548 -  show "\<exists>V g. C \<subseteq> V \<and> openin (subtopology euclidean U) V \<and> continuous_on V g \<and> g ` V \<subseteq> S \<and> (\<forall>x\<in>C. g x = f x)"
   5.549 +  show "\<exists>V g. C \<subseteq> V \<and> openin (top_of_set U) V \<and> continuous_on V g \<and> g ` V \<subseteq> S \<and> (\<forall>x\<in>C. g x = f x)"
   5.550    proof (intro exI conjI)
   5.551      show "C \<subseteq> W \<inter> g -` S"
   5.552        using \<open>C \<subseteq> W\<close> fim geq by blast
   5.553 -    show "openin (subtopology euclidean U) (W \<inter> g -` S)"
   5.554 +    show "openin (top_of_set U) (W \<inter> g -` S)"
   5.555        by (metis (mono_tags, lifting) UW contg continuous_openin_preimage gim opeTS openin_trans)
   5.556      show "continuous_on (W \<inter> g -` S) g"
   5.557        by (blast intro: continuous_on_subset [OF contg])
   5.558 @@ -1323,20 +1323,20 @@
   5.559  
   5.560  lemma ENR_openin:
   5.561      fixes S :: "'a::euclidean_space set"
   5.562 -    assumes "ENR T" and opeTS: "openin (subtopology euclidean T) S"
   5.563 +    assumes "ENR T" and opeTS: "openin (top_of_set T) S"
   5.564      shows "ENR S"
   5.565    using assms apply (simp add: ENR_ANR)
   5.566    using ANR_openin locally_open_subset by blast
   5.567  
   5.568  lemma ANR_neighborhood_retract:
   5.569      fixes S :: "'a::euclidean_space set"
   5.570 -    assumes "ANR U" "S retract_of T" "openin (subtopology euclidean U) T"
   5.571 +    assumes "ANR U" "S retract_of T" "openin (top_of_set U) T"
   5.572      shows "ANR S"
   5.573    using ANR_openin ANR_retract_of_ANR assms by blast
   5.574  
   5.575  lemma ENR_neighborhood_retract:
   5.576      fixes S :: "'a::euclidean_space set"
   5.577 -    assumes "ENR U" "S retract_of T" "openin (subtopology euclidean U) T"
   5.578 +    assumes "ENR U" "S retract_of T" "openin (top_of_set U) T"
   5.579      shows "ENR S"
   5.580    using ENR_openin ENR_retract_of_ENR assms by blast
   5.581  
   5.582 @@ -1438,7 +1438,7 @@
   5.583  proof -
   5.584    obtain U and T :: "('a \<times> real) set"
   5.585       where "convex U" "U \<noteq> {}"
   5.586 -       and UT: "closedin (subtopology euclidean U) T"
   5.587 +       and UT: "closedin (top_of_set U) T"
   5.588         and "S homeomorphic T"
   5.589      apply (rule homeomorphic_closedin_convex [of S])
   5.590      using aff_dim_le_DIM [of S] apply auto
   5.591 @@ -1447,7 +1447,7 @@
   5.592      by (meson ANR_imp_absolute_neighbourhood_retract
   5.593          assms convex_imp_locally_path_connected locally_open_subset retract_of_locally_path_connected)
   5.594    then have S: "locally path_connected S"
   5.595 -      if "openin (subtopology euclidean U) V" "T retract_of V" "U \<noteq> {}" for V
   5.596 +      if "openin (top_of_set U) V" "T retract_of V" "U \<noteq> {}" for V
   5.597      using \<open>S homeomorphic T\<close> homeomorphic_locally homeomorphic_path_connectedness by blast
   5.598    show ?thesis
   5.599      using assms
   5.600 @@ -1494,11 +1494,11 @@
   5.601  proof (clarsimp simp only: ANR_eq_absolute_neighbourhood_extensor)
   5.602    fix f :: " ('a \<times> 'b) \<times> real \<Rightarrow> 'a \<times> 'b" and U C
   5.603    assume "continuous_on C f" and fim: "f ` C \<subseteq> S \<times> T"
   5.604 -     and cloUC: "closedin (subtopology euclidean U) C"
   5.605 +     and cloUC: "closedin (top_of_set U) C"
   5.606    have contf1: "continuous_on C (fst \<circ> f)"
   5.607      by (simp add: \<open>continuous_on C f\<close> continuous_on_fst)
   5.608    obtain W1 g where "C \<subseteq> W1"
   5.609 -               and UW1: "openin (subtopology euclidean U) W1"
   5.610 +               and UW1: "openin (top_of_set U) W1"
   5.611                 and contg: "continuous_on W1 g"
   5.612                 and gim: "g ` W1 \<subseteq> S"
   5.613                 and geq: "\<And>x. x \<in> C \<Longrightarrow> g x = (fst \<circ> f) x"
   5.614 @@ -1508,7 +1508,7 @@
   5.615    have contf2: "continuous_on C (snd \<circ> f)"
   5.616      by (simp add: \<open>continuous_on C f\<close> continuous_on_snd)
   5.617    obtain W2 h where "C \<subseteq> W2"
   5.618 -               and UW2: "openin (subtopology euclidean U) W2"
   5.619 +               and UW2: "openin (top_of_set U) W2"
   5.620                 and conth: "continuous_on W2 h"
   5.621                 and him: "h ` W2 \<subseteq> T"
   5.622                 and heq: "\<And>x. x \<in> C \<Longrightarrow> h x = (snd \<circ> f) x"
   5.623 @@ -1516,12 +1516,12 @@
   5.624      using fim apply auto
   5.625      done
   5.626    show "\<exists>V g. C \<subseteq> V \<and>
   5.627 -               openin (subtopology euclidean U) V \<and>
   5.628 +               openin (top_of_set U) V \<and>
   5.629                 continuous_on V g \<and> g ` V \<subseteq> S \<times> T \<and> (\<forall>x\<in>C. g x = f x)"
   5.630    proof (intro exI conjI)
   5.631      show "C \<subseteq> W1 \<inter> W2"
   5.632        by (simp add: \<open>C \<subseteq> W1\<close> \<open>C \<subseteq> W2\<close>)
   5.633 -    show "openin (subtopology euclidean U) (W1 \<inter> W2)"
   5.634 +    show "openin (top_of_set U) (W1 \<inter> W2)"
   5.635        by (simp add: UW1 UW2 openin_Int)
   5.636      show  "continuous_on (W1 \<inter> W2) (\<lambda>x. (g x, h x))"
   5.637        by (metis (no_types) contg conth continuous_on_Pair continuous_on_subset inf_commute inf_le1)
   5.638 @@ -3706,7 +3706,7 @@
   5.639      apply (auto simp: False closest_point_self affine_imp_convex closest_point_in_set continuous_on_closest_point)
   5.640      done
   5.641    finally have "rel_frontier S retract_of {x. closest_point (affine hull S) x \<noteq> a}" .
   5.642 -  moreover have "openin (subtopology euclidean UNIV) (UNIV \<inter> closest_point (affine hull S) -` (- {a}))"
   5.643 +  moreover have "openin (top_of_set UNIV) (UNIV \<inter> closest_point (affine hull S) -` (- {a}))"
   5.644      apply (rule continuous_openin_preimage_gen)
   5.645      apply (auto simp: False affine_imp_convex continuous_on_closest_point)
   5.646      done
   5.647 @@ -3726,7 +3726,7 @@
   5.648  lemma ENR_closedin_Un_local:
   5.649    fixes S :: "'a::euclidean_space set"
   5.650    shows "\<lbrakk>ENR S; ENR T; ENR(S \<inter> T);
   5.651 -          closedin (subtopology euclidean (S \<union> T)) S; closedin (subtopology euclidean (S \<union> T)) T\<rbrakk>
   5.652 +          closedin (top_of_set (S \<union> T)) S; closedin (top_of_set (S \<union> T)) T\<rbrakk>
   5.653          \<Longrightarrow> ENR(S \<union> T)"
   5.654  by (simp add: ENR_ANR ANR_closed_Un_local locally_compact_closedin_Un)
   5.655  
   5.656 @@ -3743,8 +3743,8 @@
   5.657  
   5.658  lemma retract_from_Un_Int:
   5.659    fixes S :: "'a::euclidean_space set"
   5.660 -  assumes clS: "closedin (subtopology euclidean (S \<union> T)) S"
   5.661 -      and clT: "closedin (subtopology euclidean (S \<union> T)) T"
   5.662 +  assumes clS: "closedin (top_of_set (S \<union> T)) S"
   5.663 +      and clT: "closedin (top_of_set (S \<union> T)) T"
   5.664        and Un: "(S \<union> T) retract_of U" and Int: "(S \<inter> T) retract_of T"
   5.665      shows "S retract_of U"
   5.666  proof -
   5.667 @@ -3764,8 +3764,8 @@
   5.668  
   5.669  lemma AR_from_Un_Int_local:
   5.670    fixes S :: "'a::euclidean_space set"
   5.671 -  assumes clS: "closedin (subtopology euclidean (S \<union> T)) S"
   5.672 -      and clT: "closedin (subtopology euclidean (S \<union> T)) T"
   5.673 +  assumes clS: "closedin (top_of_set (S \<union> T)) S"
   5.674 +      and clT: "closedin (top_of_set (S \<union> T)) T"
   5.675        and Un: "AR(S \<union> T)" and Int: "AR(S \<inter> T)"
   5.676      shows "AR S"
   5.677    apply (rule AR_retract_of_AR [OF Un])
   5.678 @@ -3773,8 +3773,8 @@
   5.679  
   5.680  lemma AR_from_Un_Int_local':
   5.681    fixes S :: "'a::euclidean_space set"
   5.682 -  assumes "closedin (subtopology euclidean (S \<union> T)) S"
   5.683 -      and "closedin (subtopology euclidean (S \<union> T)) T"
   5.684 +  assumes "closedin (top_of_set (S \<union> T)) S"
   5.685 +      and "closedin (top_of_set (S \<union> T)) T"
   5.686        and "AR(S \<union> T)" "AR(S \<inter> T)"
   5.687      shows "AR T"
   5.688    using AR_from_Un_Int_local [of T S] assms by (simp add: Un_commute Int_commute)
   5.689 @@ -3787,13 +3787,13 @@
   5.690  
   5.691  lemma ANR_from_Un_Int_local:
   5.692    fixes S :: "'a::euclidean_space set"
   5.693 -  assumes clS: "closedin (subtopology euclidean (S \<union> T)) S"
   5.694 -      and clT: "closedin (subtopology euclidean (S \<union> T)) T"
   5.695 +  assumes clS: "closedin (top_of_set (S \<union> T)) S"
   5.696 +      and clT: "closedin (top_of_set (S \<union> T)) T"
   5.697        and Un: "ANR(S \<union> T)" and Int: "ANR(S \<inter> T)"
   5.698      shows "ANR S"
   5.699  proof -
   5.700 -  obtain V where clo: "closedin (subtopology euclidean (S \<union> T)) (S \<inter> T)"
   5.701 -             and ope: "openin (subtopology euclidean (S \<union> T)) V"
   5.702 +  obtain V where clo: "closedin (top_of_set (S \<union> T)) (S \<inter> T)"
   5.703 +             and ope: "openin (top_of_set (S \<union> T)) V"
   5.704               and ret: "S \<inter> T retract_of V"
   5.705      using ANR_imp_neighbourhood_retract [OF Int] by (metis clS clT closedin_Int)
   5.706    then obtain r where r: "continuous_on V r" and rim: "r ` V \<subseteq> S \<inter> T" and req: "\<forall>x\<in>S \<inter> T. r x = x"
   5.707 @@ -3808,9 +3808,9 @@
   5.708      using Vsub by blast
   5.709    have "continuous_on (S \<union> V \<inter> T) (\<lambda>x. if x \<in> S then x else r x)"
   5.710    proof (rule continuous_on_cases_local)
   5.711 -    show "closedin (subtopology euclidean (S \<union> V \<inter> T)) S"
   5.712 +    show "closedin (top_of_set (S \<union> V \<inter> T)) S"
   5.713        using clS closedin_subset_trans inf.boundedE by blast
   5.714 -    show "closedin (subtopology euclidean (S \<union> V \<inter> T)) (V \<inter> T)"
   5.715 +    show "closedin (top_of_set (S \<union> V \<inter> T)) (V \<inter> T)"
   5.716        using clT Vsup by (auto simp: closedin_closed)
   5.717      show "continuous_on (V \<inter> T) r"
   5.718        by (meson Int_lower1 continuous_on_subset r)
   5.719 @@ -3938,7 +3938,7 @@
   5.720  
   5.721  lemma absolute_retract_imp_AR_gen:
   5.722    fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set"
   5.723 -  assumes "S retract_of T" "convex T" "T \<noteq> {}" "S homeomorphic S'" "closedin (subtopology euclidean U) S'"
   5.724 +  assumes "S retract_of T" "convex T" "T \<noteq> {}" "S homeomorphic S'" "closedin (top_of_set U) S'"
   5.725    shows "S' retract_of U"
   5.726  proof -
   5.727    have "AR T"
   5.728 @@ -3972,7 +3972,7 @@
   5.729  
   5.730  lemma ENR_from_Un_Int_gen:
   5.731    fixes S :: "'a::euclidean_space set"
   5.732 -  assumes "closedin (subtopology euclidean (S \<union> T)) S" "closedin (subtopology euclidean (S \<union> T)) T" "ENR(S \<union> T)" "ENR(S \<inter> T)"
   5.733 +  assumes "closedin (top_of_set (S \<union> T)) S" "closedin (top_of_set (S \<union> T)) T" "ENR(S \<union> T)" "ENR(S \<inter> T)"
   5.734    shows "ENR S"
   5.735    apply (simp add: ENR_ANR)
   5.736    using ANR_from_Un_Int_local ENR_ANR assms locally_compact_closedin by blast
   5.737 @@ -4124,7 +4124,7 @@
   5.738  
   5.739  theorem Borsuk_homotopy_extension_homotopic:
   5.740    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
   5.741 -  assumes cloTS: "closedin (subtopology euclidean T) S"
   5.742 +  assumes cloTS: "closedin (top_of_set T) S"
   5.743        and anr: "(ANR S \<and> ANR T) \<or> ANR U"
   5.744        and contf: "continuous_on T f"
   5.745        and "f ` T \<subseteq> U"
   5.746 @@ -4140,15 +4140,15 @@
   5.747         using assms by (auto simp: homotopic_with_def)
   5.748    define h' where "h' \<equiv>  \<lambda>z. if snd z \<in> S then h z else (f \<circ> snd) z"
   5.749    define B where "B \<equiv> {0::real} \<times> T \<union> {0..1} \<times> S"
   5.750 -  have clo0T: "closedin (subtopology euclidean ({0..1} \<times> T)) ({0::real} \<times> T)"
   5.751 +  have clo0T: "closedin (top_of_set ({0..1} \<times> T)) ({0::real} \<times> T)"
   5.752      by (simp add: closedin_subtopology_refl closedin_Times)
   5.753 -  moreover have cloT1S: "closedin (subtopology euclidean ({0..1} \<times> T)) ({0..1} \<times> S)"
   5.754 +  moreover have cloT1S: "closedin (top_of_set ({0..1} \<times> T)) ({0..1} \<times> S)"
   5.755      by (simp add: closedin_subtopology_refl closedin_Times assms)
   5.756 -  ultimately have clo0TB:"closedin (subtopology euclidean ({0..1} \<times> T)) B"
   5.757 +  ultimately have clo0TB:"closedin (top_of_set ({0..1} \<times> T)) B"
   5.758      by (auto simp: B_def)
   5.759 -  have cloBS: "closedin (subtopology euclidean B) ({0..1} \<times> S)"
   5.760 +  have cloBS: "closedin (top_of_set B) ({0..1} \<times> S)"
   5.761      by (metis (no_types) Un_subset_iff B_def closedin_subset_trans [OF cloT1S] clo0TB closedin_imp_subset closedin_self)
   5.762 -  moreover have cloBT: "closedin (subtopology euclidean B) ({0} \<times> T)"
   5.763 +  moreover have cloBT: "closedin (top_of_set B) ({0} \<times> T)"
   5.764      using \<open>S \<subseteq> T\<close> closedin_subset_trans [OF clo0T]
   5.765      by (metis B_def Un_upper1 clo0TB closedin_closed inf_le1)
   5.766    moreover have "continuous_on ({0} \<times> T) (f \<circ> snd)"
   5.767 @@ -4161,7 +4161,7 @@
   5.768      done
   5.769    have "image h' B \<subseteq> U"
   5.770      using \<open>f ` T \<subseteq> U\<close> him by (auto simp: h'_def B_def)
   5.771 -  obtain V k where "B \<subseteq> V" and opeTV: "openin (subtopology euclidean ({0..1} \<times> T)) V"
   5.772 +  obtain V k where "B \<subseteq> V" and opeTV: "openin (top_of_set ({0..1} \<times> T)) V"
   5.773                 and contk: "continuous_on V k" and kim: "k ` V \<subseteq> U"
   5.774                 and keq: "\<And>x. x \<in> B \<Longrightarrow> k x = h' x"
   5.775    using anr
   5.776 @@ -4177,7 +4177,7 @@
   5.777          apply (simp_all add: ANR_Times convex_imp_ANR ANR_singleton ST eq)
   5.778        done
   5.779      note Vk = that
   5.780 -    have *: thesis if "openin (subtopology euclidean ({0..1::real} \<times> T)) V"
   5.781 +    have *: thesis if "openin (top_of_set ({0..1::real} \<times> T)) V"
   5.782                        "retraction V B r" for V r
   5.783        using that
   5.784        apply (clarsimp simp add: retraction_def)
   5.785 @@ -4195,14 +4195,14 @@
   5.786      show ?thesis by blast
   5.787    qed
   5.788    define S' where "S' \<equiv> {x. \<exists>u::real. u \<in> {0..1} \<and> (u, x::'a) \<in> {0..1} \<times> T - V}"
   5.789 -  have "closedin (subtopology euclidean T) S'"
   5.790 +  have "closedin (top_of_set T) S'"
   5.791      unfolding S'_def
   5.792      apply (rule closedin_compact_projection, blast)
   5.793      using closedin_self opeTV by blast
   5.794    have S'_def: "S' = {x. \<exists>u::real.  (u, x::'a) \<in> {0..1} \<times> T - V}"
   5.795      by (auto simp: S'_def)
   5.796 -  have cloTS': "closedin (subtopology euclidean T) S'"
   5.797 -    using S'_def \<open>closedin (subtopology euclidean T) S'\<close> by blast
   5.798 +  have cloTS': "closedin (top_of_set T) S'"
   5.799 +    using S'_def \<open>closedin (top_of_set T) S'\<close> by blast
   5.800    have "S \<inter> S' = {}"
   5.801      using S'_def B_def \<open>B \<subseteq> V\<close> by force
   5.802    obtain a :: "'a \<Rightarrow> real" where conta: "continuous_on T a"
   5.803 @@ -4269,7 +4269,7 @@
   5.804    assume ?lhs
   5.805    then obtain c where c: "homotopic_with (\<lambda>x. True) S T (\<lambda>x. c) f"
   5.806      by (blast intro: homotopic_with_symD)
   5.807 -  have "closedin (subtopology euclidean UNIV) S"
   5.808 +  have "closedin (top_of_set UNIV) S"
   5.809      using \<open>closed S\<close> closed_closedin by fastforce
   5.810    then obtain g where "continuous_on UNIV g" "range g \<subseteq> T"
   5.811                        "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
   5.812 @@ -4412,7 +4412,7 @@
   5.813                            "g ` (S \<union> connected_component_set (- S) a) \<subseteq> sphere 0 1"
   5.814                            "\<And>x. x \<in> S \<Longrightarrow> g x = (x - a) /\<^sub>R norm (x - a)"
   5.815    proof (rule Borsuk_homotopy_extension_homotopic)
   5.816 -    show "closedin (subtopology euclidean ?T) S"
   5.817 +    show "closedin (top_of_set ?T) S"
   5.818        by (simp add: \<open>compact S\<close> closed_subset compact_imp_closed)
   5.819      show "continuous_on ?T (\<lambda>x. (x - b) /\<^sub>R norm (x - b))"
   5.820        by (simp add: \<open>b \<notin> S\<close> notcc continuous_on_Borsuk_map)
   5.821 @@ -4467,8 +4467,8 @@
   5.822  subsubsection\<open>More extension theorems\<close>
   5.823  
   5.824  lemma extension_from_clopen:
   5.825 -  assumes ope: "openin (subtopology euclidean S) T"
   5.826 -      and clo: "closedin (subtopology euclidean S) T"
   5.827 +  assumes ope: "openin (top_of_set S) T"
   5.828 +      and clo: "closedin (top_of_set S) T"
   5.829        and contf: "continuous_on T f" and fim: "f ` T \<subseteq> U" and null: "U = {} \<Longrightarrow> S = {}"
   5.830   obtains g where "continuous_on S g" "g ` S \<subseteq> U" "\<And>x. x \<in> T \<Longrightarrow> g x = f x"
   5.831  proof (cases "U = {}")
   5.832 @@ -4503,8 +4503,8 @@
   5.833       and C: "C \<in> components S" and contf: "continuous_on C f" and fim: "f ` C \<subseteq> U"
   5.834   obtains g where "continuous_on S g" "g ` S \<subseteq> U" "\<And>x. x \<in> C \<Longrightarrow> g x = f x"
   5.835  proof -
   5.836 -  obtain T g where ope: "openin (subtopology euclidean S) T"
   5.837 -               and clo: "closedin (subtopology euclidean S) T"
   5.838 +  obtain T g where ope: "openin (top_of_set S) T"
   5.839 +               and clo: "closedin (top_of_set S) T"
   5.840                 and "C \<subseteq> T" and contg: "continuous_on T g" and gim: "g ` T \<subseteq> U"
   5.841                 and gf: "\<And>x. x \<in> C \<Longrightarrow> g x = f x"
   5.842      using S
   5.843 @@ -4514,7 +4514,7 @@
   5.844        by (metis C \<open>locally connected S\<close> openin_components_locally_connected closedin_component contf fim order_refl that)
   5.845    next
   5.846      assume "compact S"
   5.847 -    then obtain W g where "C \<subseteq> W" and opeW: "openin (subtopology euclidean S) W"
   5.848 +    then obtain W g where "C \<subseteq> W" and opeW: "openin (top_of_set S) W"
   5.849                   and contg: "continuous_on W g"
   5.850                   and gim: "g ` W \<subseteq> U" and gf: "\<And>x. x \<in> C \<Longrightarrow> g x = f x"
   5.851        using ANR_imp_absolute_neighbourhood_extensor [of U C f S] C \<open>ANR U\<close> closedin_component contf fim by blast
   5.852 @@ -4522,11 +4522,11 @@
   5.853        by (auto simp: openin_open)
   5.854      moreover have "locally compact S"
   5.855        by (simp add: \<open>compact S\<close> closed_imp_locally_compact compact_imp_closed)
   5.856 -    ultimately obtain K where opeK: "openin (subtopology euclidean S) K" and "compact K" "C \<subseteq> K" "K \<subseteq> V"
   5.857 +    ultimately obtain K where opeK: "openin (top_of_set S) K" and "compact K" "C \<subseteq> K" "K \<subseteq> V"
   5.858        by (metis C Int_subset_iff \<open>C \<subseteq> W\<close> \<open>compact S\<close> compact_components Sura_Bura_clopen_subset)
   5.859      show ?thesis
   5.860      proof
   5.861 -      show "closedin (subtopology euclidean S) K"
   5.862 +      show "closedin (top_of_set S) K"
   5.863          by (meson \<open>compact K\<close> \<open>compact S\<close> closedin_compact_eq opeK openin_imp_subset)
   5.864        show "continuous_on K g"
   5.865          by (metis Int_subset_iff V \<open>K \<subseteq> V\<close> contg continuous_on_subset opeK openin_subtopology subset_eq)
   5.866 @@ -4545,13 +4545,13 @@
   5.867  lemma tube_lemma:
   5.868    fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set"
   5.869    assumes "compact S" and S: "S \<noteq> {}" "(\<lambda>x. (x,a)) ` S \<subseteq> U" 
   5.870 -      and ope: "openin (subtopology euclidean (S \<times> T)) U"
   5.871 -  obtains V where "openin (subtopology euclidean T) V" "a \<in> V" "S \<times> V \<subseteq> U"
   5.872 +      and ope: "openin (top_of_set (S \<times> T)) U"
   5.873 +  obtains V where "openin (top_of_set T) V" "a \<in> V" "S \<times> V \<subseteq> U"
   5.874  proof -
   5.875    let ?W = "{y. \<exists>x. x \<in> S \<and> (x, y) \<in> (S \<times> T - U)}"
   5.876 -  have "U \<subseteq> S \<times> T" "closedin (subtopology euclidean (S \<times> T)) (S \<times> T - U)"
   5.877 +  have "U \<subseteq> S \<times> T" "closedin (top_of_set (S \<times> T)) (S \<times> T - U)"
   5.878      using ope by (auto simp: openin_closedin_eq)
   5.879 -  then have "closedin (subtopology euclidean T) ?W"
   5.880 +  then have "closedin (top_of_set T) ?W"
   5.881      using \<open>compact S\<close> closedin_compact_projection by blast
   5.882    moreover have "a \<in> T - ?W"
   5.883      using \<open>U \<subseteq> S \<times> T\<close> S by auto
   5.884 @@ -4564,16 +4564,16 @@
   5.885  lemma tube_lemma_gen:
   5.886    fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set"
   5.887    assumes "compact S" "S \<noteq> {}" "T \<subseteq> T'" "S \<times> T \<subseteq> U"
   5.888 -      and ope: "openin (subtopology euclidean (S \<times> T')) U"
   5.889 -  obtains V where "openin (subtopology euclidean T') V" "T \<subseteq> V" "S \<times> V \<subseteq> U"
   5.890 +      and ope: "openin (top_of_set (S \<times> T')) U"
   5.891 +  obtains V where "openin (top_of_set T') V" "T \<subseteq> V" "S \<times> V \<subseteq> U"
   5.892  proof -
   5.893 -  have "\<And>x. x \<in> T \<Longrightarrow> \<exists>V. openin (subtopology euclidean T') V \<and> x \<in> V \<and> S \<times> V \<subseteq> U"
   5.894 +  have "\<And>x. x \<in> T \<Longrightarrow> \<exists>V. openin (top_of_set T') V \<and> x \<in> V \<and> S \<times> V \<subseteq> U"
   5.895      using assms by (auto intro:  tube_lemma [OF \<open>compact S\<close>])
   5.896 -  then obtain F where F: "\<And>x. x \<in> T \<Longrightarrow> openin (subtopology euclidean T') (F x) \<and> x \<in> F x \<and> S \<times> F x \<subseteq> U"
   5.897 +  then obtain F where F: "\<And>x. x \<in> T \<Longrightarrow> openin (top_of_set T') (F x) \<and> x \<in> F x \<and> S \<times> F x \<subseteq> U"
   5.898      by metis
   5.899    show ?thesis
   5.900    proof
   5.901 -    show "openin (subtopology euclidean T') (\<Union>(F ` T))"
   5.902 +    show "openin (top_of_set T') (\<Union>(F ` T))"
   5.903        using F by blast
   5.904      show "T \<subseteq> \<Union>(F ` T)"
   5.905        using F by blast
   5.906 @@ -4586,9 +4586,9 @@
   5.907    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
   5.908    assumes contf: "continuous_on S f" and fim: "f ` S \<subseteq> U"
   5.909        and contg: "continuous_on S g" and gim: "g ` S \<subseteq> U"
   5.910 -      and clo: "closedin (subtopology euclidean S) T"
   5.911 +      and clo: "closedin (top_of_set S) T"
   5.912        and "ANR U" and hom: "homotopic_with (\<lambda>x. True) T U f g"
   5.913 -    obtains V where "T \<subseteq> V" "openin (subtopology euclidean S) V"
   5.914 +    obtains V where "T \<subseteq> V" "openin (top_of_set S) V"
   5.915                      "homotopic_with (\<lambda>x. True) V U f g"
   5.916  proof -
   5.917    have "T \<subseteq> S"
   5.918 @@ -4604,11 +4604,11 @@
   5.919    have "continuous_on(?S0 \<union> (?S1 \<union> {0..1} \<times> T)) h'"
   5.920      unfolding h'_def
   5.921    proof (intro continuous_on_cases_local)
   5.922 -    show "closedin (subtopology euclidean (?S0 \<union> (?S1 \<union> {0..1} \<times> T))) ?S0"
   5.923 -         "closedin (subtopology euclidean (?S1 \<union> {0..1} \<times> T)) ?S1"
   5.924 +    show "closedin (top_of_set (?S0 \<union> (?S1 \<union> {0..1} \<times> T))) ?S0"
   5.925 +         "closedin (top_of_set (?S1 \<union> {0..1} \<times> T)) ?S1"
   5.926        using \<open>T \<subseteq> S\<close> by (force intro: closedin_Times closedin_subset_trans [of "{0..1} \<times> S"])+
   5.927 -    show "closedin (subtopology euclidean (?S0 \<union> (?S1 \<union> {0..1} \<times> T))) (?S1 \<union> {0..1} \<times> T)"
   5.928 -         "closedin (subtopology euclidean (?S1 \<union> {0..1} \<times> T)) ({0..1} \<times> T)"
   5.929 +    show "closedin (top_of_set (?S0 \<union> (?S1 \<union> {0..1} \<times> T))) (?S1 \<union> {0..1} \<times> T)"
   5.930 +         "closedin (top_of_set (?S1 \<union> {0..1} \<times> T)) ({0..1} \<times> T)"
   5.931        using \<open>T \<subseteq> S\<close> by (force intro: clo closedin_Times closedin_subset_trans [of "{0..1} \<times> S"])+
   5.932      show "continuous_on (?S0) (\<lambda>x. f (snd x))"
   5.933        by (intro continuous_intros continuous_on_compose2 [OF contf]) auto
   5.934 @@ -4619,16 +4619,16 @@
   5.935      by (metis Sigma_Un_distrib1 Un_assoc insert_is_Un) 
   5.936    moreover have "h' ` ({0,1} \<times> S \<union> {0..1} \<times> T) \<subseteq> U"
   5.937      using fim gim him \<open>T \<subseteq> S\<close> unfolding h'_def by force
   5.938 -  moreover have "closedin (subtopology euclidean ({0..1::real} \<times> S)) ({0,1} \<times> S \<union> {0..1::real} \<times> T)"
   5.939 +  moreover have "closedin (top_of_set ({0..1::real} \<times> S)) ({0,1} \<times> S \<union> {0..1::real} \<times> T)"
   5.940      by (intro closedin_Times closedin_Un clo) (simp_all add: closed_subset)
   5.941    ultimately
   5.942    obtain W k where W: "({0,1} \<times> S) \<union> ({0..1} \<times> T) \<subseteq> W"
   5.943 -               and opeW: "openin (subtopology euclidean ({0..1} \<times> S)) W"
   5.944 +               and opeW: "openin (top_of_set ({0..1} \<times> S)) W"
   5.945                 and contk: "continuous_on W k"
   5.946                 and kim: "k ` W \<subseteq> U"
   5.947                 and kh': "\<And>x. x \<in> ({0,1} \<times> S) \<union> ({0..1} \<times> T) \<Longrightarrow> k x = h' x"
   5.948      by (metis ANR_imp_absolute_neighbourhood_extensor [OF \<open>ANR U\<close>, of "({0,1} \<times> S) \<union> ({0..1} \<times> T)" h' "{0..1} \<times> S"])
   5.949 -  obtain T' where opeT': "openin (subtopology euclidean S) T'" 
   5.950 +  obtain T' where opeT': "openin (top_of_set S) T'" 
   5.951                and "T \<subseteq> T'" and TW: "{0..1} \<times> T' \<subseteq> W"
   5.952      using tube_lemma_gen [of "{0..1::real}" T S W] W \<open>T \<subseteq> S\<close> opeW by auto
   5.953    moreover have "homotopic_with (\<lambda>x. True) T' U f g"
   5.954 @@ -4649,8 +4649,8 @@
   5.955  text\<open> Homotopy on a union of closed-open sets.\<close>
   5.956  proposition%unimportant homotopic_on_clopen_Union:
   5.957    fixes \<F> :: "'a::euclidean_space set set"
   5.958 -  assumes "\<And>S. S \<in> \<F> \<Longrightarrow> closedin (subtopology euclidean (\<Union>\<F>)) S"
   5.959 -      and "\<And>S. S \<in> \<F> \<Longrightarrow> openin (subtopology euclidean (\<Union>\<F>)) S"
   5.960 +  assumes "\<And>S. S \<in> \<F> \<Longrightarrow> closedin (top_of_set (\<Union>\<F>)) S"
   5.961 +      and "\<And>S. S \<in> \<F> \<Longrightarrow> openin (top_of_set (\<Union>\<F>)) S"
   5.962        and "\<And>S. S \<in> \<F> \<Longrightarrow> homotopic_with (\<lambda>x. True) S T f g"
   5.963    shows "homotopic_with (\<lambda>x. True) (\<Union>\<F>) T f g"
   5.964  proof -
   5.965 @@ -4665,8 +4665,8 @@
   5.966      case False
   5.967      then obtain V :: "nat \<Rightarrow> 'a set" where V: "range V = \<V>"
   5.968        using range_from_nat_into \<open>countable \<V>\<close> by metis
   5.969 -    with \<open>\<V> \<subseteq> \<F>\<close> have clo: "\<And>n. closedin (subtopology euclidean (\<Union>\<F>)) (V n)"
   5.970 -                  and ope: "\<And>n. openin (subtopology euclidean (\<Union>\<F>)) (V n)"
   5.971 +    with \<open>\<V> \<subseteq> \<F>\<close> have clo: "\<And>n. closedin (top_of_set (\<Union>\<F>)) (V n)"
   5.972 +                  and ope: "\<And>n. openin (top_of_set (\<Union>\<F>)) (V n)"
   5.973                    and hom: "\<And>n. homotopic_with (\<lambda>x. True) (V n) T f g"
   5.974        using assms by auto 
   5.975      then obtain h where conth: "\<And>n. continuous_on ({0..1::real} \<times> V n) (h n)"
   5.976 @@ -4680,20 +4680,20 @@
   5.977                and eq: "\<And>x i. \<lbrakk>x \<in> {0..1} \<times> \<Union>(V ` UNIV) \<inter>
   5.978                                     {0..1} \<times> (V i - (\<Union>m<i. V m))\<rbrakk> \<Longrightarrow> \<zeta> x = h i x"
   5.979      proof (rule pasting_lemma_exists)
   5.980 -      show "{0..1} \<times> \<Union>(V ` UNIV) \<subseteq> (\<Union>i. {0..1::real} \<times> (V i - (\<Union>m<i. V m)))"
   5.981 +      let ?X = "top_of_set ({0..1::real} \<times> \<Union>(range V))"
   5.982 +      show "topspace ?X \<subseteq> (\<Union>i. {0..1::real} \<times> (V i - (\<Union>m<i. V m)))"
   5.983          by (force simp: Ball_def dest: wop)
   5.984 -      show "openin (subtopology euclidean ({0..1} \<times> \<Union>(V ` UNIV))) 
   5.985 +      show "openin (top_of_set ({0..1} \<times> \<Union>(V ` UNIV))) 
   5.986                     ({0..1::real} \<times> (V i - (\<Union>m<i. V m)))" for i
   5.987        proof (intro openin_Times openin_subtopology_self openin_diff)
   5.988 -        show "openin (subtopology euclidean (\<Union>(V ` UNIV))) (V i)"
   5.989 +        show "openin (top_of_set (\<Union>(V ` UNIV))) (V i)"
   5.990            using ope V eqU by auto
   5.991 -        show "closedin (subtopology euclidean (\<Union>(V ` UNIV))) (\<Union>m<i. V m)"
   5.992 +        show "closedin (top_of_set (\<Union>(V ` UNIV))) (\<Union>m<i. V m)"
   5.993            using V clo eqU by (force intro: closedin_Union)
   5.994        qed
   5.995 -      show "continuous_on ({0..1} \<times> (V i - (\<Union>m<i. V m))) (h i)" for i
   5.996 -        by (rule continuous_on_subset [OF conth]) auto
   5.997 -      show "\<And>i j x. x \<in> {0..1} \<times> \<Union>(V ` UNIV) \<inter>
   5.998 -                    {0..1} \<times> (V i - (\<Union>m<i. V m)) \<inter> {0..1} \<times> (V j - (\<Union>m<j. V m))
   5.999 +      show "continuous_map (subtopology ?X ({0..1} \<times> (V i - \<Union> (V ` {..<i})))) euclidean (h i)"  for i
  5.1000 +        by (auto simp add: subtopology_subtopology intro!: continuous_on_subset [OF conth])
  5.1001 +      show "\<And>i j x. x \<in> topspace ?X \<inter> {0..1} \<times> (V i - (\<Union>m<i. V m)) \<inter> {0..1} \<times> (V j - (\<Union>m<j. V m))
  5.1002                      \<Longrightarrow> h i x = h j x"
  5.1003          by clarsimp (metis lessThan_iff linorder_neqE_nat)
  5.1004      qed auto
  5.1005 @@ -4738,8 +4738,8 @@
  5.1006        by (simp add: homotopic_with_subset_left in_components_subset)
  5.1007    next
  5.1008      assume R: ?rhs
  5.1009 -    have "\<exists>U. C \<subseteq> U \<and> closedin (subtopology euclidean S) U \<and>
  5.1010 -              openin (subtopology euclidean S) U \<and>
  5.1011 +    have "\<exists>U. C \<subseteq> U \<and> closedin (top_of_set S) U \<and>
  5.1012 +              openin (top_of_set S) U \<and>
  5.1013                homotopic_with (\<lambda>x. True) U T f g" if C: "C \<in> components S" for C
  5.1014      proof -
  5.1015        have "C \<subseteq> S"
  5.1016 @@ -4750,9 +4750,9 @@
  5.1017          assume "locally connected S"
  5.1018          show ?thesis
  5.1019          proof (intro exI conjI)
  5.1020 -          show "closedin (subtopology euclidean S) C"
  5.1021 +          show "closedin (top_of_set S) C"
  5.1022              by (simp add: closedin_component that)
  5.1023 -          show "openin (subtopology euclidean S) C"
  5.1024 +          show "openin (top_of_set S) C"
  5.1025              by (simp add: \<open>locally connected S\<close> openin_components_locally_connected that)
  5.1026            show "homotopic_with (\<lambda>x. True) C T f g"
  5.1027              by (simp add: R that)
  5.1028 @@ -4761,7 +4761,7 @@
  5.1029          assume "compact S"
  5.1030          have hom: "homotopic_with (\<lambda>x. True) C T f g"
  5.1031            using R that by blast
  5.1032 -        obtain U where "C \<subseteq> U" and opeU: "openin (subtopology euclidean S) U"
  5.1033 +        obtain U where "C \<subseteq> U" and opeU: "openin (top_of_set S) U"
  5.1034                    and hom: "homotopic_with (\<lambda>x. True) U T f g"
  5.1035            using homotopic_neighbourhood_extension [OF contf fim contg gim _ \<open>ANR T\<close> hom]
  5.1036              \<open>C \<in> components S\<close> closedin_component by blast
  5.1037 @@ -4769,11 +4769,11 @@
  5.1038            by (auto simp: openin_open)
  5.1039          moreover have "locally compact S"
  5.1040            by (simp add: \<open>compact S\<close> closed_imp_locally_compact compact_imp_closed)
  5.1041 -        ultimately obtain K where opeK: "openin (subtopology euclidean S) K" and "compact K" "C \<subseteq> K" "K \<subseteq> V"
  5.1042 +        ultimately obtain K where opeK: "openin (top_of_set S) K" and "compact K" "C \<subseteq> K" "K \<subseteq> V"
  5.1043            by (metis C Int_subset_iff Sura_Bura_clopen_subset \<open>C \<subseteq> U\<close> \<open>compact S\<close> compact_components)
  5.1044          show ?thesis
  5.1045          proof (intro exI conjI)
  5.1046 -          show "closedin (subtopology euclidean S) K"
  5.1047 +          show "closedin (top_of_set S) K"
  5.1048              by (meson \<open>compact K\<close> \<open>compact S\<close> closedin_compact_eq opeK openin_imp_subset)
  5.1049            show "homotopic_with (\<lambda>x. True) K T f g"
  5.1050              using V \<open>K \<subseteq> V\<close> hom homotopic_with_subset_left opeK openin_imp_subset by fastforce
  5.1051 @@ -4781,8 +4781,8 @@
  5.1052        qed
  5.1053      qed
  5.1054      then obtain \<phi> where \<phi>: "\<And>C. C \<in> components S \<Longrightarrow> C \<subseteq> \<phi> C"
  5.1055 -                  and clo\<phi>: "\<And>C. C \<in> components S \<Longrightarrow> closedin (subtopology euclidean S) (\<phi> C)"
  5.1056 -                  and ope\<phi>: "\<And>C. C \<in> components S \<Longrightarrow> openin (subtopology euclidean S) (\<phi> C)"
  5.1057 +                  and clo\<phi>: "\<And>C. C \<in> components S \<Longrightarrow> closedin (top_of_set S) (\<phi> C)"
  5.1058 +                  and ope\<phi>: "\<And>C. C \<in> components S \<Longrightarrow> openin (top_of_set S) (\<phi> C)"
  5.1059                    and hom\<phi>: "\<And>C. C \<in> components S \<Longrightarrow> homotopic_with (\<lambda>x. True) (\<phi> C) T f g"
  5.1060        by metis
  5.1061      have Seq: "S = \<Union> (\<phi> ` components S)"
     6.1 --- a/src/HOL/Analysis/Cauchy_Integral_Theorem.thy	Mon Mar 18 21:50:51 2019 +0100
     6.2 +++ b/src/HOL/Analysis/Cauchy_Integral_Theorem.thy	Tue Mar 19 16:14:59 2019 +0000
     6.3 @@ -7001,13 +7001,13 @@
     6.4        by (metis funpow_add o_apply)
     6.5      with that show ?thesis by auto
     6.6    qed
     6.7 -  have 1: "openin (subtopology euclidean S) (\<Inter>n. {w \<in> S. (deriv ^^ n) f w = 0})"
     6.8 +  have 1: "openin (top_of_set S) (\<Inter>n. {w \<in> S. (deriv ^^ n) f w = 0})"
     6.9      apply (rule open_subset, force)
    6.10      using \<open>open S\<close>
    6.11      apply (simp add: open_contains_ball Ball_def)
    6.12      apply (erule all_forward)
    6.13      using "*" by auto blast+
    6.14 -  have 2: "closedin (subtopology euclidean S) (\<Inter>n. {w \<in> S. (deriv ^^ n) f w = 0})"
    6.15 +  have 2: "closedin (top_of_set S) (\<Inter>n. {w \<in> S. (deriv ^^ n) f w = 0})"
    6.16      using assms
    6.17      by (auto intro: continuous_closedin_preimage_constant holomorphic_on_imp_continuous_on holomorphic_higher_deriv)
    6.18    obtain e where "e>0" and e: "ball w e \<subseteq> S" using openE [OF \<open>open S\<close> \<open>w \<in> S\<close>] .
     7.1 --- a/src/HOL/Analysis/Change_Of_Vars.thy	Mon Mar 18 21:50:51 2019 +0100
     7.2 +++ b/src/HOL/Analysis/Change_Of_Vars.thy	Tue Mar 19 16:14:59 2019 +0000
     7.3 @@ -1567,24 +1567,24 @@
     7.4          show "countable {A. \<forall>i j. A $ i $ j \<in> \<rat>}"
     7.5            using countable_vector [OF countable_vector, of "\<lambda>i j. \<rat>"] by (simp add: countable_rat)
     7.6        qed blast
     7.7 -      have *: "\<lbrakk>U \<noteq> {} \<Longrightarrow> closedin (subtopology euclidean S) (S \<inter> \<Inter> U)\<rbrakk>
     7.8 -               \<Longrightarrow> closedin (subtopology euclidean S) (S \<inter> \<Inter> U)" for U
     7.9 +      have *: "\<lbrakk>U \<noteq> {} \<Longrightarrow> closedin (top_of_set S) (S \<inter> \<Inter> U)\<rbrakk>
    7.10 +               \<Longrightarrow> closedin (top_of_set S) (S \<inter> \<Inter> U)" for U
    7.11          by fastforce
    7.12        have eq: "{x::(real,'m)vec. P x \<and> (Q x \<longrightarrow> R x)} = {x. P x \<and> \<not> Q x} \<union> {x. P x \<and> R x}" for P Q R
    7.13          by auto
    7.14        have sets: "S \<inter> (\<Inter>y\<in>S. {x \<in> S. norm (y - x) < d \<longrightarrow> norm (f y - f x - A *v (y - x)) \<le> e * norm (y - x)})
    7.15                    \<in> sets lebesgue" for e A d
    7.16        proof -
    7.17 -        have clo: "closedin (subtopology euclidean S)
    7.18 +        have clo: "closedin (top_of_set S)
    7.19                       {x \<in> S. norm (y - x) < d \<longrightarrow> norm (f y - f x - A *v (y - x)) \<le> e * norm (y - x)}"
    7.20            for y
    7.21          proof -
    7.22            have cont1: "continuous_on S (\<lambda>x. norm (y - x))"
    7.23            and  cont2: "continuous_on S (\<lambda>x. e * norm (y - x) - norm (f y - f x - (A *v y - A *v x)))"
    7.24              by (force intro: contf continuous_intros)+
    7.25 -          have clo1: "closedin (subtopology euclidean S) {x \<in> S. d \<le> norm (y - x)}"
    7.26 +          have clo1: "closedin (top_of_set S) {x \<in> S. d \<le> norm (y - x)}"
    7.27              using continuous_closedin_preimage [OF cont1, of "{d..}"] by (simp add: vimage_def Int_def)
    7.28 -          have clo2: "closedin (subtopology euclidean S)
    7.29 +          have clo2: "closedin (top_of_set S)
    7.30                         {x \<in> S. norm (f y - f x - (A *v y - A *v x)) \<le> e * norm (y - x)}"
    7.31              using continuous_closedin_preimage [OF cont2, of "{0..}"] by (simp add: vimage_def Int_def)
    7.32            show ?thesis
     8.1 --- a/src/HOL/Analysis/Connected.thy	Mon Mar 18 21:50:51 2019 +0100
     8.2 +++ b/src/HOL/Analysis/Connected.thy	Tue Mar 19 16:14:59 2019 +0000
     8.3 @@ -14,8 +14,8 @@
     8.4  lemma connected_local:
     8.5   "connected S \<longleftrightarrow>
     8.6    \<not> (\<exists>e1 e2.
     8.7 -      openin (subtopology euclidean S) e1 \<and>
     8.8 -      openin (subtopology euclidean S) e2 \<and>
     8.9 +      openin (top_of_set S) e1 \<and>
    8.10 +      openin (top_of_set S) e2 \<and>
    8.11        S \<subseteq> e1 \<union> e2 \<and>
    8.12        e1 \<inter> e2 = {} \<and>
    8.13        e1 \<noteq> {} \<and>
    8.14 @@ -39,8 +39,8 @@
    8.15  qed
    8.16  
    8.17  lemma connected_clopen: "connected S \<longleftrightarrow>
    8.18 -  (\<forall>T. openin (subtopology euclidean S) T \<and>
    8.19 -     closedin (subtopology euclidean S) T \<longrightarrow> T = {} \<or> T = S)" (is "?lhs \<longleftrightarrow> ?rhs")
    8.20 +  (\<forall>T. openin (top_of_set S) T \<and>
    8.21 +     closedin (top_of_set S) T \<longrightarrow> T = {} \<or> T = S)" (is "?lhs \<longleftrightarrow> ?rhs")
    8.22  proof -
    8.23    have "\<not> connected S \<longleftrightarrow>
    8.24      (\<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> {})"
    8.25 @@ -402,7 +402,7 @@
    8.26      by blast
    8.27  qed
    8.28  
    8.29 -lemma closedin_connected_component: "closedin (subtopology euclidean s) (connected_component_set s x)"
    8.30 +lemma closedin_connected_component: "closedin (top_of_set s) (connected_component_set s x)"
    8.31  proof (cases "connected_component_set s x = {}")
    8.32    case True
    8.33    then show ?thesis
    8.34 @@ -423,7 +423,7 @@
    8.35  qed
    8.36  
    8.37  lemma closedin_component:
    8.38 -   "C \<in> components s \<Longrightarrow> closedin (subtopology euclidean s) C"
    8.39 +   "C \<in> components s \<Longrightarrow> closedin (top_of_set s) C"
    8.40    using closedin_connected_component componentsE by blast
    8.41  
    8.42  
    8.43 @@ -433,7 +433,7 @@
    8.44  lemma continuous_levelset_openin_cases:
    8.45    fixes f :: "_ \<Rightarrow> 'b::t1_space"
    8.46    shows "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow>
    8.47 -        openin (subtopology euclidean s) {x \<in> s. f x = a}
    8.48 +        openin (top_of_set s) {x \<in> s. f x = a}
    8.49          \<Longrightarrow> (\<forall>x \<in> s. f x \<noteq> a) \<or> (\<forall>x \<in> s. f x = a)"
    8.50    unfolding connected_clopen
    8.51    using continuous_closedin_preimage_constant by auto
    8.52 @@ -441,7 +441,7 @@
    8.53  lemma continuous_levelset_openin:
    8.54    fixes f :: "_ \<Rightarrow> 'b::t1_space"
    8.55    shows "connected s \<Longrightarrow> continuous_on s f \<Longrightarrow>
    8.56 -        openin (subtopology euclidean s) {x \<in> s. f x = a} \<Longrightarrow>
    8.57 +        openin (top_of_set s) {x \<in> s. f x = a} \<Longrightarrow>
    8.58          (\<exists>x \<in> s. f x = a)  \<Longrightarrow> (\<forall>x \<in> s. f x = a)"
    8.59    using continuous_levelset_openin_cases[of s f ]
    8.60    by meson
    8.61 @@ -469,8 +469,8 @@
    8.62    assumes "connected T"
    8.63        and contf: "continuous_on S f" and fim: "f ` S = T"
    8.64        and opT: "\<And>U. U \<subseteq> T
    8.65 -                 \<Longrightarrow> openin (subtopology euclidean S) (S \<inter> f -` U) \<longleftrightarrow>
    8.66 -                     openin (subtopology euclidean T) U"
    8.67 +                 \<Longrightarrow> openin (top_of_set S) (S \<inter> f -` U) \<longleftrightarrow>
    8.68 +                     openin (top_of_set T) U"
    8.69        and connT: "\<And>y. y \<in> T \<Longrightarrow> connected (S \<inter> f -` {y})"
    8.70      shows "connected S"
    8.71  proof (rule connectedI)
    8.72 @@ -492,9 +492,9 @@
    8.73    qed
    8.74    ultimately have UU: "(S \<inter> f -` f ` (S \<inter> U)) = S \<inter> U" and VV: "(S \<inter> f -` f ` (S \<inter> V)) = S \<inter> V"
    8.75      by auto
    8.76 -  have opeU: "openin (subtopology euclidean T) (f ` (S \<inter> U))"
    8.77 +  have opeU: "openin (top_of_set T) (f ` (S \<inter> U))"
    8.78      by (metis UU \<open>open U\<close> fim image_Int_subset le_inf_iff opT openin_open_Int)
    8.79 -  have opeV: "openin (subtopology euclidean T) (f ` (S \<inter> V))"
    8.80 +  have opeV: "openin (top_of_set T) (f ` (S \<inter> V))"
    8.81      by (metis opT fim VV \<open>open V\<close> openin_open_Int image_Int_subset inf.bounded_iff)
    8.82    have "T \<subseteq> f ` (S \<inter> U) \<union> f ` (S \<inter> V)"
    8.83      using \<open>S \<subseteq> U \<union> V\<close> fim by auto
    8.84 @@ -505,7 +505,7 @@
    8.85  
    8.86  lemma connected_open_monotone_preimage:
    8.87    assumes contf: "continuous_on S f" and fim: "f ` S = T"
    8.88 -    and ST: "\<And>C. openin (subtopology euclidean S) C \<Longrightarrow> openin (subtopology euclidean T) (f ` C)"
    8.89 +    and ST: "\<And>C. openin (top_of_set S) C \<Longrightarrow> openin (top_of_set T) (f ` C)"
    8.90      and connT: "\<And>y. y \<in> T \<Longrightarrow> connected (S \<inter> f -` {y})"
    8.91      and "connected C" "C \<subseteq> T"
    8.92    shows "connected (S \<inter> f -` C)"
    8.93 @@ -525,12 +525,12 @@
    8.94        ultimately show ?thesis
    8.95          by metis
    8.96      qed
    8.97 -    have "\<And>U. openin (subtopology euclidean (S \<inter> f -` C)) U
    8.98 -               \<Longrightarrow> openin (subtopology euclidean C) (f ` U)"
    8.99 +    have "\<And>U. openin (top_of_set (S \<inter> f -` C)) U
   8.100 +               \<Longrightarrow> openin (top_of_set C) (f ` U)"
   8.101        using open_map_restrict [OF _ ST \<open>C \<subseteq> T\<close>] by metis
   8.102      then show "\<And>D. D \<subseteq> C
   8.103 -          \<Longrightarrow> openin (subtopology euclidean (S \<inter> f -` C)) (S \<inter> f -` C \<inter> f -` D) =
   8.104 -              openin (subtopology euclidean C) D"
   8.105 +          \<Longrightarrow> openin (top_of_set (S \<inter> f -` C)) (S \<inter> f -` C \<inter> f -` D) =
   8.106 +              openin (top_of_set C) D"
   8.107        using open_map_imp_quotient_map [of "(S \<inter> f -` C)" f] contf' by (simp add: eqC)
   8.108    qed
   8.109  qed
   8.110 @@ -538,7 +538,7 @@
   8.111  
   8.112  lemma connected_closed_monotone_preimage:
   8.113    assumes contf: "continuous_on S f" and fim: "f ` S = T"
   8.114 -    and ST: "\<And>C. closedin (subtopology euclidean S) C \<Longrightarrow> closedin (subtopology euclidean T) (f ` C)"
   8.115 +    and ST: "\<And>C. closedin (top_of_set S) C \<Longrightarrow> closedin (top_of_set T) (f ` C)"
   8.116      and connT: "\<And>y. y \<in> T \<Longrightarrow> connected (S \<inter> f -` {y})"
   8.117      and "connected C" "C \<subseteq> T"
   8.118    shows "connected (S \<inter> f -` C)"
   8.119 @@ -558,12 +558,12 @@
   8.120        ultimately show ?thesis
   8.121          by metis
   8.122      qed
   8.123 -    have "\<And>U. closedin (subtopology euclidean (S \<inter> f -` C)) U
   8.124 -               \<Longrightarrow> closedin (subtopology euclidean C) (f ` U)"
   8.125 +    have "\<And>U. closedin (top_of_set (S \<inter> f -` C)) U
   8.126 +               \<Longrightarrow> closedin (top_of_set C) (f ` U)"
   8.127        using closed_map_restrict [OF _ ST \<open>C \<subseteq> T\<close>] by metis
   8.128      then show "\<And>D. D \<subseteq> C
   8.129 -          \<Longrightarrow> openin (subtopology euclidean (S \<inter> f -` C)) (S \<inter> f -` C \<inter> f -` D) =
   8.130 -              openin (subtopology euclidean C) D"
   8.131 +          \<Longrightarrow> openin (top_of_set (S \<inter> f -` C)) (S \<inter> f -` C \<inter> f -` D) =
   8.132 +              openin (top_of_set C) D"
   8.133        using closed_map_imp_quotient_map [of "(S \<inter> f -` C)" f] contf' by (simp add: eqC)
   8.134    qed
   8.135  qed
   8.136 @@ -576,8 +576,8 @@
   8.137  lemma connected_Un_clopen_in_complement:
   8.138    fixes S U :: "'a::metric_space set"
   8.139    assumes "connected S" "connected U" "S \<subseteq> U" 
   8.140 -      and opeT: "openin (subtopology euclidean (U - S)) T" 
   8.141 -      and cloT: "closedin (subtopology euclidean (U - S)) T"
   8.142 +      and opeT: "openin (top_of_set (U - S)) T" 
   8.143 +      and cloT: "closedin (top_of_set (U - S)) T"
   8.144      shows "connected (S \<union> T)"
   8.145  proof -
   8.146    have *: "\<lbrakk>\<And>x y. P x y \<longleftrightarrow> P y x; \<And>x y. P x y \<Longrightarrow> S \<subseteq> x \<or> S \<subseteq> y;
   8.147 @@ -587,11 +587,11 @@
   8.148      unfolding connected_closedin_eq
   8.149    proof (rule *)
   8.150      fix H1 H2
   8.151 -    assume H: "closedin (subtopology euclidean (S \<union> T)) H1 \<and> 
   8.152 -               closedin (subtopology euclidean (S \<union> T)) H2 \<and>
   8.153 +    assume H: "closedin (top_of_set (S \<union> T)) H1 \<and> 
   8.154 +               closedin (top_of_set (S \<union> T)) H2 \<and>
   8.155                 H1 \<union> H2 = S \<union> T \<and> H1 \<inter> H2 = {} \<and> H1 \<noteq> {} \<and> H2 \<noteq> {}"
   8.156 -    then have clo: "closedin (subtopology euclidean S) (S \<inter> H1)"
   8.157 -                   "closedin (subtopology euclidean S) (S \<inter> H2)"
   8.158 +    then have clo: "closedin (top_of_set S) (S \<inter> H1)"
   8.159 +                   "closedin (top_of_set S) (S \<inter> H2)"
   8.160        by (metis Un_upper1 closedin_closed_subset inf_commute)+
   8.161      have Seq: "S \<inter> (H1 \<union> H2) = S"
   8.162        by (simp add: H)
   8.163 @@ -606,8 +606,8 @@
   8.164        using H \<open>connected S\<close> unfolding connected_closedin by blast
   8.165    next
   8.166      fix H1 H2
   8.167 -    assume H: "closedin (subtopology euclidean (S \<union> T)) H1 \<and>
   8.168 -               closedin (subtopology euclidean (S \<union> T)) H2 \<and>
   8.169 +    assume H: "closedin (top_of_set (S \<union> T)) H1 \<and>
   8.170 +               closedin (top_of_set (S \<union> T)) H2 \<and>
   8.171                 H1 \<union> H2 = S \<union> T \<and> H1 \<inter> H2 = {} \<and> H1 \<noteq> {} \<and> H2 \<noteq> {}" 
   8.172         and "S \<subseteq> H1"
   8.173      then have H2T: "H2 \<subseteq> T"
   8.174 @@ -616,17 +616,17 @@
   8.175        using Diff_iff opeT openin_imp_subset by auto
   8.176      with \<open>S \<subseteq> U\<close> have Ueq: "U = (U - S) \<union> (S \<union> T)" 
   8.177        by auto
   8.178 -    have "openin (subtopology euclidean ((U - S) \<union> (S \<union> T))) H2"
   8.179 +    have "openin (top_of_set ((U - S) \<union> (S \<union> T))) H2"
   8.180      proof (rule openin_subtopology_Un)
   8.181 -      show "openin (subtopology euclidean (S \<union> T)) H2"
   8.182 +      show "openin (top_of_set (S \<union> T)) H2"
   8.183          using \<open>H2 \<subseteq> T\<close> apply (auto simp: openin_closedin_eq)
   8.184          by (metis Diff_Diff_Int Diff_disjoint Diff_partition Diff_subset H Int_absorb1 Un_Diff)
   8.185 -      then show "openin (subtopology euclidean (U - S)) H2"
   8.186 +      then show "openin (top_of_set (U - S)) H2"
   8.187          by (meson H2T Un_upper2 opeT openin_subset_trans openin_trans)
   8.188      qed
   8.189 -    moreover have "closedin (subtopology euclidean ((U - S) \<union> (S \<union> T))) H2"
   8.190 +    moreover have "closedin (top_of_set ((U - S) \<union> (S \<union> T))) H2"
   8.191      proof (rule closedin_subtopology_Un)
   8.192 -      show "closedin (subtopology euclidean (U - S)) H2"
   8.193 +      show "closedin (top_of_set (U - S)) H2"
   8.194          using H H2T cloT closedin_subset_trans 
   8.195          by (blast intro: closedin_subtopology_Un closedin_trans)
   8.196      qed (simp add: H)
   8.197 @@ -650,33 +650,33 @@
   8.198    using \<open>connected S\<close> unfolding connected_closedin_eq not_ex de_Morgan_conj
   8.199  proof clarify
   8.200    fix H3 H4 
   8.201 -  assume clo3: "closedin (subtopology euclidean (U - C)) H3" 
   8.202 -    and clo4: "closedin (subtopology euclidean (U - C)) H4" 
   8.203 +  assume clo3: "closedin (top_of_set (U - C)) H3" 
   8.204 +    and clo4: "closedin (top_of_set (U - C)) H4" 
   8.205      and "H3 \<union> H4 = U - C" and "H3 \<inter> H4 = {}" and "H3 \<noteq> {}" and "H4 \<noteq> {}"
   8.206      and * [rule_format]:
   8.207 -    "\<forall>H1 H2. \<not> closedin (subtopology euclidean S) H1 \<or>
   8.208 -                      \<not> closedin (subtopology euclidean S) H2 \<or>
   8.209 +    "\<forall>H1 H2. \<not> closedin (top_of_set S) H1 \<or>
   8.210 +                      \<not> closedin (top_of_set S) H2 \<or>
   8.211                        H1 \<union> H2 \<noteq> S \<or> H1 \<inter> H2 \<noteq> {} \<or> \<not> H1 \<noteq> {} \<or> \<not> H2 \<noteq> {}"
   8.212 -  then have "H3 \<subseteq> U-C" and ope3: "openin (subtopology euclidean (U - C)) (U - C - H3)"
   8.213 -    and "H4 \<subseteq> U-C" and ope4: "openin (subtopology euclidean (U - C)) (U - C - H4)"
   8.214 +  then have "H3 \<subseteq> U-C" and ope3: "openin (top_of_set (U - C)) (U - C - H3)"
   8.215 +    and "H4 \<subseteq> U-C" and ope4: "openin (top_of_set (U - C)) (U - C - H4)"
   8.216      by (auto simp: closedin_def)
   8.217    have "C \<noteq> {}" "C \<subseteq> U-S" "connected C"
   8.218      using C in_components_nonempty in_components_subset in_components_maximal by blast+
   8.219    have cCH3: "connected (C \<union> H3)"
   8.220    proof (rule connected_Un_clopen_in_complement [OF \<open>connected C\<close> \<open>connected U\<close> _ _ clo3])
   8.221 -    show "openin (subtopology euclidean (U - C)) H3"
   8.222 +    show "openin (top_of_set (U - C)) H3"
   8.223        apply (simp add: openin_closedin_eq \<open>H3 \<subseteq> U - C\<close>)
   8.224        apply (simp add: closedin_subtopology)
   8.225        by (metis Diff_cancel Diff_triv Un_Diff clo4 \<open>H3 \<inter> H4 = {}\<close> \<open>H3 \<union> H4 = U - C\<close> closedin_closed inf_commute sup_bot.left_neutral)
   8.226    qed (use clo3 \<open>C \<subseteq> U - S\<close> in auto)
   8.227    have cCH4: "connected (C \<union> H4)"
   8.228    proof (rule connected_Un_clopen_in_complement [OF \<open>connected C\<close> \<open>connected U\<close> _ _ clo4])
   8.229 -    show "openin (subtopology euclidean (U - C)) H4"
   8.230 +    show "openin (top_of_set (U - C)) H4"
   8.231        apply (simp add: openin_closedin_eq \<open>H4 \<subseteq> U - C\<close>)
   8.232        apply (simp add: closedin_subtopology)
   8.233        by (metis Diff_cancel Int_commute Un_Diff Un_Diff_Int \<open>H3 \<inter> H4 = {}\<close> \<open>H3 \<union> H4 = U - C\<close> clo3 closedin_closed)
   8.234    qed (use clo4 \<open>C \<subseteq> U - S\<close> in auto)
   8.235 -  have "closedin (subtopology euclidean S) (S \<inter> H3)" "closedin (subtopology euclidean S) (S \<inter> H4)"
   8.236 +  have "closedin (top_of_set S) (S \<inter> H3)" "closedin (top_of_set S) (S \<inter> H4)"
   8.237      using clo3 clo4 \<open>S \<subseteq> U\<close> \<open>C \<subseteq> U - S\<close> by (auto simp: closedin_closed)
   8.238    moreover have "S \<inter> H3 \<noteq> {}"      
   8.239      using components_maximal [OF C cCH3] \<open>C \<noteq> {}\<close> \<open>C \<subseteq> U - S\<close> \<open>H3 \<noteq> {}\<close> \<open>H3 \<subseteq> U - C\<close> by auto
   8.240 @@ -719,8 +719,8 @@
   8.241      shows "connected S"
   8.242  proof -
   8.243    { fix t u
   8.244 -    assume clt: "closedin (subtopology euclidean S) t"
   8.245 -       and clu: "closedin (subtopology euclidean S) u"
   8.246 +    assume clt: "closedin (top_of_set S) t"
   8.247 +       and clu: "closedin (top_of_set S) u"
   8.248         and tue: "t \<inter> u = {}" and tus: "t \<union> u = S"
   8.249      have conif: "continuous_on S (\<lambda>x. if x \<in> t then 0 else 1)"
   8.250        apply (subst tus [symmetric])
     9.1 --- a/src/HOL/Analysis/Continuous_Extension.thy	Mon Mar 18 21:50:51 2019 +0100
     9.2 +++ b/src/HOL/Analysis/Continuous_Extension.thy	Tue Mar 19 16:14:59 2019 +0000
     9.3 @@ -33,7 +33,7 @@
     9.4        by (simp add: supp_sum_def sum_nonneg)
     9.5      have sd_pos: "0 < setdist {x} (S - V)" if "V \<in> \<C>" "x \<in> S" "x \<in> V" for V x
     9.6      proof -
     9.7 -      have "closedin (subtopology euclidean S) (S - V)"
     9.8 +      have "closedin (top_of_set S) (S - V)"
     9.9          by (simp add: Diff_Diff_Int closedin_def opC openin_open_Int \<open>V \<in> \<C>\<close>)
    9.10        with that False  setdist_pos_le [of "{x}" "S - V"]
    9.11        show ?thesis
    9.12 @@ -67,7 +67,7 @@
    9.13            fix x assume "x \<in> S"
    9.14            then obtain X where "open X" and x: "x \<in> S \<inter> X" and finX: "finite {U \<in> \<C>. U \<inter> X \<noteq> {}}"
    9.15              using assms by blast
    9.16 -          then have OSX: "openin (subtopology euclidean S) (S \<inter> X)" by blast
    9.17 +          then have OSX: "openin (top_of_set S) (S \<inter> X)" by blast
    9.18            have sumeq: "\<And>x. x \<in> S \<inter> X \<Longrightarrow>
    9.19                       (\<Sum>V | V \<in> \<C> \<and> V \<inter> X \<noteq> {}. setdist {x} (S - V))
    9.20                       = supp_sum (\<lambda>V. setdist {x} (S - V)) \<C>"
    9.21 @@ -114,8 +114,8 @@
    9.22  text \<open>For Euclidean spaces the proof is easy using distances.\<close>
    9.23  
    9.24  lemma Urysohn_both_ne:
    9.25 -  assumes US: "closedin (subtopology euclidean U) S"
    9.26 -      and UT: "closedin (subtopology euclidean U) T"
    9.27 +  assumes US: "closedin (top_of_set U) S"
    9.28 +      and UT: "closedin (top_of_set U) T"
    9.29        and "S \<inter> T = {}" "S \<noteq> {}" "T \<noteq> {}" "a \<noteq> b"
    9.30    obtains f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
    9.31      where "continuous_on U f"
    9.32 @@ -167,8 +167,8 @@
    9.33  qed
    9.34  
    9.35  proposition Urysohn_local_strong:
    9.36 -  assumes US: "closedin (subtopology euclidean U) S"
    9.37 -      and UT: "closedin (subtopology euclidean U) T"
    9.38 +  assumes US: "closedin (top_of_set U) S"
    9.39 +      and UT: "closedin (top_of_set U) T"
    9.40        and "S \<inter> T = {}" "a \<noteq> b"
    9.41    obtains f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
    9.42      where "continuous_on U f"
    9.43 @@ -250,8 +250,8 @@
    9.44  qed
    9.45  
    9.46  lemma Urysohn_local:
    9.47 -  assumes US: "closedin (subtopology euclidean U) S"
    9.48 -      and UT: "closedin (subtopology euclidean U) T"
    9.49 +  assumes US: "closedin (top_of_set U) S"
    9.50 +      and UT: "closedin (top_of_set U) T"
    9.51        and "S \<inter> T = {}"
    9.52    obtains f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
    9.53      where "continuous_on U f"
    9.54 @@ -301,7 +301,7 @@
    9.55  theorem Dugundji:
    9.56    fixes f :: "'a::{metric_space,second_countable_topology} \<Rightarrow> 'b::real_inner"
    9.57    assumes "convex C" "C \<noteq> {}"
    9.58 -      and cloin: "closedin (subtopology euclidean U) S"
    9.59 +      and cloin: "closedin (top_of_set U) S"
    9.60        and contf: "continuous_on S f" and "f ` S \<subseteq> C"
    9.61    obtains g where "continuous_on U g" "g ` U \<subseteq> C"
    9.62                    "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
    9.63 @@ -427,7 +427,7 @@
    9.64          obtain N where N: "open N" "a \<in> N"
    9.65                     and finN: "finite {U \<in> \<C>. \<exists>a\<in>N. H U a \<noteq> 0}"
    9.66            using Hfin False \<open>a \<in> U\<close> by auto
    9.67 -        have oUS: "openin (subtopology euclidean U) (U - S)"
    9.68 +        have oUS: "openin (top_of_set U) (U - S)"
    9.69            using cloin by (simp add: openin_diff)
    9.70          have HcontU: "continuous (at a within U) (H T)" if "T \<in> \<C>" for T
    9.71            using Hcont [OF \<open>T \<in> \<C>\<close>] False  \<open>a \<in> U\<close> \<open>T \<in> \<C>\<close>
    9.72 @@ -444,7 +444,7 @@
    9.73                      (\<lambda>x. \<Sum>T\<in>{U \<in> \<C>. \<exists>x\<in>N. H U x \<noteq> 0}. H T x *\<^sub>R f (\<A> T))"
    9.74                by (force intro: continuous_intros HcontU)+
    9.75            next
    9.76 -            show "openin (subtopology euclidean U) ((U - S) \<inter> N)"
    9.77 +            show "openin (top_of_set U) ((U - S) \<inter> N)"
    9.78                using N oUS openin_trans by blast
    9.79            next
    9.80              show "a \<in> (U - S) \<inter> N" using False \<open>a \<in> U\<close> N by blast
    9.81 @@ -475,7 +475,7 @@
    9.82  corollary Tietze:
    9.83    fixes f :: "'a::{metric_space,second_countable_topology} \<Rightarrow> 'b::real_inner"
    9.84    assumes "continuous_on S f"
    9.85 -    and "closedin (subtopology euclidean U) S"
    9.86 +    and "closedin (top_of_set U) S"
    9.87      and "0 \<le> B"
    9.88      and "\<And>x. x \<in> S \<Longrightarrow> norm(f x) \<le> B"
    9.89    obtains g where "continuous_on U g" "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
    9.90 @@ -485,7 +485,7 @@
    9.91  corollary%unimportant Tietze_closed_interval:
    9.92    fixes f :: "'a::{metric_space,second_countable_topology} \<Rightarrow> 'b::euclidean_space"
    9.93    assumes "continuous_on S f"
    9.94 -    and "closedin (subtopology euclidean U) S"
    9.95 +    and "closedin (top_of_set U) S"
    9.96      and "cbox a b \<noteq> {}"
    9.97      and "\<And>x. x \<in> S \<Longrightarrow> f x \<in> cbox a b"
    9.98    obtains g where "continuous_on U g" "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
    9.99 @@ -496,7 +496,7 @@
   9.100  corollary%unimportant Tietze_closed_interval_1:
   9.101    fixes f :: "'a::{metric_space,second_countable_topology} \<Rightarrow> real"
   9.102    assumes "continuous_on S f"
   9.103 -    and "closedin (subtopology euclidean U) S"
   9.104 +    and "closedin (top_of_set U) S"
   9.105      and "a \<le> b"
   9.106      and "\<And>x. x \<in> S \<Longrightarrow> f x \<in> cbox a b"
   9.107    obtains g where "continuous_on U g" "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
   9.108 @@ -507,7 +507,7 @@
   9.109  corollary%unimportant Tietze_open_interval:
   9.110    fixes f :: "'a::{metric_space,second_countable_topology} \<Rightarrow> 'b::euclidean_space"
   9.111    assumes "continuous_on S f"
   9.112 -    and "closedin (subtopology euclidean U) S"
   9.113 +    and "closedin (top_of_set U) S"
   9.114      and "box a b \<noteq> {}"
   9.115      and "\<And>x. x \<in> S \<Longrightarrow> f x \<in> box a b"
   9.116    obtains g where "continuous_on U g" "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
   9.117 @@ -518,7 +518,7 @@
   9.118  corollary%unimportant Tietze_open_interval_1:
   9.119    fixes f :: "'a::{metric_space,second_countable_topology} \<Rightarrow> real"
   9.120    assumes "continuous_on S f"
   9.121 -    and "closedin (subtopology euclidean U) S"
   9.122 +    and "closedin (top_of_set U) S"
   9.123      and "a < b"
   9.124      and no: "\<And>x. x \<in> S \<Longrightarrow> f x \<in> box a b"
   9.125    obtains g where "continuous_on U g" "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
   9.126 @@ -529,7 +529,7 @@
   9.127  corollary%unimportant Tietze_unbounded:
   9.128    fixes f :: "'a::{metric_space,second_countable_topology} \<Rightarrow> 'b::real_inner"
   9.129    assumes "continuous_on S f"
   9.130 -    and "closedin (subtopology euclidean U) S"
   9.131 +    and "closedin (top_of_set U) S"
   9.132    obtains g where "continuous_on U g" "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
   9.133    apply (rule Dugundji [of UNIV U S f])
   9.134    using assms by auto
    10.1 --- a/src/HOL/Analysis/Convex_Euclidean_Space.thy	Mon Mar 18 21:50:51 2019 +0100
    10.2 +++ b/src/HOL/Analysis/Convex_Euclidean_Space.thy	Tue Mar 19 16:14:59 2019 +0000
    10.3 @@ -62,7 +62,7 @@
    10.4      using g unfolding o_def id_def image_def by auto metis+
    10.5    show ?thesis
    10.6    proof (rule closedin_closed_trans [of "range f"])
    10.7 -    show "closedin (subtopology euclidean (range f)) (f ` S)"
    10.8 +    show "closedin (top_of_set (range f)) (f ` S)"
    10.9        using continuous_closedin_preimage [OF confg cgf] by simp
   10.10      show "closed (range f)"
   10.11        apply (rule closed_injective_image_subspace)
   10.12 @@ -319,7 +319,7 @@
   10.13  subsection \<open>Relative interior of a set\<close>
   10.14  
   10.15  definition%important "rel_interior S =
   10.16 -  {x. \<exists>T. openin (subtopology euclidean (affine hull S)) T \<and> x \<in> T \<and> T \<subseteq> S}"
   10.17 +  {x. \<exists>T. openin (top_of_set (affine hull S)) T \<and> x \<in> T \<and> T \<subseteq> S}"
   10.18  
   10.19  lemma rel_interior_mono:
   10.20     "\<lbrakk>S \<subseteq> T; affine hull S = affine hull T\<rbrakk>
   10.21 @@ -327,7 +327,7 @@
   10.22    by (auto simp: rel_interior_def)
   10.23  
   10.24  lemma rel_interior_maximal:
   10.25 -   "\<lbrakk>T \<subseteq> S; openin(subtopology euclidean (affine hull S)) T\<rbrakk> \<Longrightarrow> T \<subseteq> (rel_interior S)"
   10.26 +   "\<lbrakk>T \<subseteq> S; openin(top_of_set (affine hull S)) T\<rbrakk> \<Longrightarrow> T \<subseteq> (rel_interior S)"
   10.27    by (auto simp: rel_interior_def)
   10.28  
   10.29  lemma rel_interior:
   10.30 @@ -651,20 +651,20 @@
   10.31  
   10.32  definition%important "rel_open S \<longleftrightarrow> rel_interior S = S"
   10.33  
   10.34 -lemma rel_open: "rel_open S \<longleftrightarrow> openin (subtopology euclidean (affine hull S)) S"
   10.35 +lemma rel_open: "rel_open S \<longleftrightarrow> openin (top_of_set (affine hull S)) S"
   10.36    unfolding rel_open_def rel_interior_def
   10.37    apply auto
   10.38 -  using openin_subopen[of "subtopology euclidean (affine hull S)" S]
   10.39 +  using openin_subopen[of "top_of_set (affine hull S)" S]
   10.40    apply auto
   10.41    done
   10.42  
   10.43 -lemma openin_rel_interior: "openin (subtopology euclidean (affine hull S)) (rel_interior S)"
   10.44 +lemma openin_rel_interior: "openin (top_of_set (affine hull S)) (rel_interior S)"
   10.45    apply (simp add: rel_interior_def)
   10.46    apply (subst openin_subopen, blast)
   10.47    done
   10.48  
   10.49  lemma openin_set_rel_interior:
   10.50 -   "openin (subtopology euclidean S) (rel_interior S)"
   10.51 +   "openin (top_of_set S) (rel_interior S)"
   10.52  by (rule openin_subset_trans [OF openin_rel_interior rel_interior_subset hull_subset])
   10.53  
   10.54  lemma affine_rel_open:
   10.55 @@ -806,11 +806,11 @@
   10.56  qed
   10.57  
   10.58  lemma rel_interior_eq:
   10.59 -   "rel_interior s = s \<longleftrightarrow> openin(subtopology euclidean (affine hull s)) s"
   10.60 +   "rel_interior s = s \<longleftrightarrow> openin(top_of_set (affine hull s)) s"
   10.61  using rel_open rel_open_def by blast
   10.62  
   10.63  lemma rel_interior_openin:
   10.64 -   "openin(subtopology euclidean (affine hull s)) s \<Longrightarrow> rel_interior s = s"
   10.65 +   "openin(top_of_set (affine hull s)) s \<Longrightarrow> rel_interior s = s"
   10.66  by (simp add: rel_interior_eq)
   10.67  
   10.68  lemma rel_interior_affine:
   10.69 @@ -1992,9 +1992,9 @@
   10.70    proof -
   10.71      obtain e where "e > 0" and e: "cball a e \<subseteq> T"
   10.72        using \<open>open T\<close> \<open>a \<in> T\<close> by (auto simp: open_contains_cball)
   10.73 -    have "openin (subtopology euclidean S) {a}"
   10.74 +    have "openin (top_of_set S) {a}"
   10.75        unfolding openin_open using that \<open>a \<in> S\<close> by blast
   10.76 -    moreover have "closedin (subtopology euclidean S) {a}"
   10.77 +    moreover have "closedin (top_of_set S) {a}"
   10.78        by (simp add: assms)
   10.79      ultimately show "False"
   10.80        using \<open>connected S\<close> connected_clopen S by blast
    11.1 --- a/src/HOL/Analysis/Elementary_Metric_Spaces.thy	Mon Mar 18 21:50:51 2019 +0100
    11.2 +++ b/src/HOL/Analysis/Elementary_Metric_Spaces.thy	Tue Mar 19 16:14:59 2019 +0000
    11.3 @@ -2718,7 +2718,7 @@
    11.4  subsection \<open>With Abstract Topology (TODO: move and remove dependency?)\<close>
    11.5  
    11.6  lemma openin_contains_ball:
    11.7 -    "openin (subtopology euclidean t) s \<longleftrightarrow>
    11.8 +    "openin (top_of_set t) s \<longleftrightarrow>
    11.9       s \<subseteq> t \<and> (\<forall>x \<in> s. \<exists>e. 0 < e \<and> ball x e \<inter> t \<subseteq> s)"
   11.10      (is "?lhs = ?rhs")
   11.11  proof
   11.12 @@ -2735,7 +2735,7 @@
   11.13  qed
   11.14  
   11.15  lemma openin_contains_cball:
   11.16 -   "openin (subtopology euclidean t) s \<longleftrightarrow>
   11.17 +   "openin (top_of_set t) s \<longleftrightarrow>
   11.18          s \<subseteq> t \<and>
   11.19          (\<forall>x \<in> s. \<exists>e. 0 < e \<and> cball x e \<inter> t \<subseteq> s)"
   11.20    apply (simp add: openin_contains_ball)
    12.1 --- a/src/HOL/Analysis/Elementary_Normed_Spaces.thy	Mon Mar 18 21:50:51 2019 +0100
    12.2 +++ b/src/HOL/Analysis/Elementary_Normed_Spaces.thy	Tue Mar 19 16:14:59 2019 +0000
    12.3 @@ -915,7 +915,7 @@
    12.4  theorem Baire:
    12.5    fixes S::"'a::{real_normed_vector,heine_borel} set"
    12.6    assumes "closed S" "countable \<G>"
    12.7 -      and ope: "\<And>T. T \<in> \<G> \<Longrightarrow> openin (subtopology euclidean S) T \<and> S \<subseteq> closure T"
    12.8 +      and ope: "\<And>T. T \<in> \<G> \<Longrightarrow> openin (top_of_set S) T \<and> S \<subseteq> closure T"
    12.9   shows "S \<subseteq> closure(\<Inter>\<G>)"
   12.10  proof (cases "\<G> = {}")
   12.11    case True
   12.12 @@ -930,31 +930,31 @@
   12.13    proof (clarsimp simp: closure_approachable)
   12.14      fix x and e::real
   12.15      assume "x \<in> S" "0 < e"
   12.16 -    obtain TF where opeF: "\<And>n. openin (subtopology euclidean S) (TF n)"
   12.17 +    obtain TF where opeF: "\<And>n. openin (top_of_set S) (TF n)"
   12.18                 and ne: "\<And>n. TF n \<noteq> {}"
   12.19                 and subg: "\<And>n. S \<inter> closure(TF n) \<subseteq> ?g n"
   12.20                 and subball: "\<And>n. closure(TF n) \<subseteq> ball x e"
   12.21                 and decr: "\<And>n. TF(Suc n) \<subseteq> TF n"
   12.22      proof -
   12.23 -      have *: "\<exists>Y. (openin (subtopology euclidean S) Y \<and> Y \<noteq> {} \<and>
   12.24 +      have *: "\<exists>Y. (openin (top_of_set S) Y \<and> Y \<noteq> {} \<and>
   12.25                     S \<inter> closure Y \<subseteq> ?g n \<and> closure Y \<subseteq> ball x e) \<and> Y \<subseteq> U"
   12.26 -        if opeU: "openin (subtopology euclidean S) U" and "U \<noteq> {}" and cloU: "closure U \<subseteq> ball x e" for U n
   12.27 +        if opeU: "openin (top_of_set S) U" and "U \<noteq> {}" and cloU: "closure U \<subseteq> ball x e" for U n
   12.28        proof -
   12.29          obtain T where T: "open T" "U = T \<inter> S"
   12.30 -          using \<open>openin (subtopology euclidean S) U\<close> by (auto simp: openin_subtopology)
   12.31 +          using \<open>openin (top_of_set S) U\<close> by (auto simp: openin_subtopology)
   12.32          with \<open>U \<noteq> {}\<close> have "T \<inter> closure (?g n) \<noteq> {}"
   12.33            using gin ope by fastforce
   12.34          then have "T \<inter> ?g n \<noteq> {}"
   12.35            using \<open>open T\<close> open_Int_closure_eq_empty by blast
   12.36          then obtain y where "y \<in> U" "y \<in> ?g n"
   12.37            using T ope [of "?g n", OF gin] by (blast dest:  openin_imp_subset)
   12.38 -        moreover have "openin (subtopology euclidean S) (U \<inter> ?g n)"
   12.39 +        moreover have "openin (top_of_set S) (U \<inter> ?g n)"
   12.40            using gin ope opeU by blast
   12.41          ultimately obtain d where U: "U \<inter> ?g n \<subseteq> S" and "d > 0" and d: "ball y d \<inter> S \<subseteq> U \<inter> ?g n"
   12.42            by (force simp: openin_contains_ball)
   12.43          show ?thesis
   12.44          proof (intro exI conjI)
   12.45 -          show "openin (subtopology euclidean S) (S \<inter> ball y (d/2))"
   12.46 +          show "openin (top_of_set S) (S \<inter> ball y (d/2))"
   12.47              by (simp add: openin_open_Int)
   12.48            show "S \<inter> ball y (d/2) \<noteq> {}"
   12.49              using \<open>0 < d\<close> \<open>y \<in> U\<close> opeU openin_imp_subset by fastforce
   12.50 @@ -979,14 +979,14 @@
   12.51              using ball_divide_subset_numeral d by blast
   12.52          qed
   12.53        qed
   12.54 -      let ?\<Phi> = "\<lambda>n X. openin (subtopology euclidean S) X \<and> X \<noteq> {} \<and>
   12.55 +      let ?\<Phi> = "\<lambda>n X. openin (top_of_set S) X \<and> X \<noteq> {} \<and>
   12.56                        S \<inter> closure X \<subseteq> ?g n \<and> closure X \<subseteq> ball x e"
   12.57        have "closure (S \<inter> ball x (e / 2)) \<subseteq> closure(ball x (e/2))"
   12.58          by (simp add: closure_mono)
   12.59        also have "...  \<subseteq> ball x e"
   12.60          using \<open>e > 0\<close> by auto
   12.61        finally have "closure (S \<inter> ball x (e / 2)) \<subseteq> ball x e" .
   12.62 -      moreover have"openin (subtopology euclidean S) (S \<inter> ball x (e / 2))" "S \<inter> ball x (e / 2) \<noteq> {}"
   12.63 +      moreover have"openin (top_of_set S) (S \<inter> ball x (e / 2))" "S \<inter> ball x (e / 2) \<noteq> {}"
   12.64          using \<open>0 < e\<close> \<open>x \<in> S\<close> by auto
   12.65        ultimately obtain Y where Y: "?\<Phi> 0 Y \<and> Y \<subseteq> S \<inter> ball x (e / 2)"
   12.66              using * [of "S \<inter> ball x (e/2)" 0] by metis
    13.1 --- a/src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy	Mon Mar 18 21:50:51 2019 +0100
    13.2 +++ b/src/HOL/Analysis/Equivalence_Lebesgue_Henstock_Integration.thy	Tue Mar 19 16:14:59 2019 +0000
    13.3 @@ -2032,7 +2032,7 @@
    13.4  subsection\<open>Negligibility is a local property\<close>
    13.5  
    13.6  lemma locally_negligible_alt:
    13.7 -    "negligible S \<longleftrightarrow> (\<forall>x \<in> S. \<exists>U. openin (subtopology euclidean S) U \<and> x \<in> U \<and> negligible U)"
    13.8 +    "negligible S \<longleftrightarrow> (\<forall>x \<in> S. \<exists>U. openin (top_of_set S) U \<and> x \<in> U \<and> negligible U)"
    13.9       (is "_ = ?rhs")
   13.10  proof
   13.11    assume "negligible S"
   13.12 @@ -2040,7 +2040,7 @@
   13.13      using openin_subtopology_self by blast
   13.14  next
   13.15    assume ?rhs
   13.16 -  then obtain U where ope: "\<And>x. x \<in> S \<Longrightarrow> openin (subtopology euclidean S) (U x)"
   13.17 +  then obtain U where ope: "\<And>x. x \<in> S \<Longrightarrow> openin (top_of_set S) (U x)"
   13.18      and cov: "\<And>x. x \<in> S \<Longrightarrow> x \<in> U x"
   13.19      and neg: "\<And>x. x \<in> S \<Longrightarrow> negligible (U x)"
   13.20      by metis
   13.21 @@ -4493,7 +4493,7 @@
   13.22      fix a
   13.23      assume a: "a \<in> U n" and fa: "f a \<in> T"
   13.24      define V where "V \<equiv> {x. x \<in> U n \<and> f x \<in> T} \<inter> ball a (1 / n / 2)"
   13.25 -    show "\<exists>V. openin (subtopology euclidean {x \<in> U n. f x \<in> T}) V \<and> a \<in> V \<and> negligible V"
   13.26 +    show "\<exists>V. openin (top_of_set {x \<in> U n. f x \<in> T}) V \<and> a \<in> V \<and> negligible V"
   13.27      proof (intro exI conjI)
   13.28        have noxy: "norm(x - y) \<le> n * norm(f x - f y)" if "x \<in> V" "y \<in> V" for x y
   13.29          using that unfolding U_def V_def mem_Collect_eq Int_iff mem_ball dist_norm
    14.1 --- a/src/HOL/Analysis/Function_Topology.thy	Mon Mar 18 21:50:51 2019 +0100
    14.2 +++ b/src/HOL/Analysis/Function_Topology.thy	Tue Mar 19 16:14:59 2019 +0000
    14.3 @@ -7,9 +7,9 @@
    14.4  begin
    14.5  
    14.6  
    14.7 -section \<open>Product Topology\<close> (* FIX  see comments by the author *)
    14.8 +section \<open>Function Topology\<close> 
    14.9  
   14.10 -text \<open>We want to define the product topology.
   14.11 +text \<open>We want to define the general product topology.
   14.12  
   14.13  The product topology on a product of topological spaces is generated by
   14.14  the sets which are products of open sets along finitely many coordinates, and the whole
   14.15 @@ -48,7 +48,7 @@
   14.16  be the natural continuity definition of a map from the topology \<open>T1\<close> to the topology \<open>T2\<close>. Then
   14.17  the current \<open>continuous_on\<close> (with type classes) can be redefined as
   14.18  @{text [display] \<open>continuous_on s f =
   14.19 -    continuous_on_topo (subtopology euclidean s) (topology euclidean) f\<close>}
   14.20 +    continuous_on_topo (top_of_set s) (topology euclidean) f\<close>}
   14.21  
   14.22  In fact, I need \<open>continuous_on_topo\<close> to express the continuity of the projection on subfactors
   14.23  for the product topology, in Lemma~\<open>continuous_on_restrict_product_topology\<close>, and I show
   14.24 @@ -61,369 +61,6 @@
   14.25  I realized afterwards that this theory has a lot in common with \<^file>\<open>~~/src/HOL/Library/Finite_Map.thy\<close>.
   14.26  \<close>
   14.27  
   14.28 -subsection \<open>Topology without type classes\<close>
   14.29 -
   14.30 -subsubsection%important \<open>The topology generated by some (open) subsets\<close>
   14.31 -
   14.32 -text \<open>In the definition below of a generated topology, the \<open>Empty\<close> case is not necessary,
   14.33 -as it follows from \<open>UN\<close> taking for \<open>K\<close> the empty set. However, it is convenient to have,
   14.34 -and is never a problem in proofs, so I prefer to write it down explicitly.
   14.35 -
   14.36 -We do not require \<open>UNIV\<close> to be an open set, as this will not be the case in applications. (We are
   14.37 -thinking of a topology on a subset of \<open>UNIV\<close>, the remaining part of \<open>UNIV\<close> being irrelevant.)\<close>
   14.38 -
   14.39 -inductive generate_topology_on for S where
   14.40 -  Empty: "generate_topology_on S {}"
   14.41 -| Int: "generate_topology_on S a \<Longrightarrow> generate_topology_on S b \<Longrightarrow> generate_topology_on S (a \<inter> b)"
   14.42 -| UN: "(\<And>k. k \<in> K \<Longrightarrow> generate_topology_on S k) \<Longrightarrow> generate_topology_on S (\<Union>K)"
   14.43 -| Basis: "s \<in> S \<Longrightarrow> generate_topology_on S s"
   14.44 -
   14.45 -lemma istopology_generate_topology_on:
   14.46 -  "istopology (generate_topology_on S)"
   14.47 -unfolding istopology_def by (auto intro: generate_topology_on.intros)
   14.48 -
   14.49 -text \<open>The basic property of the topology generated by a set \<open>S\<close> is that it is the
   14.50 -smallest topology containing all the elements of \<open>S\<close>:\<close>
   14.51 -
   14.52 -lemma generate_topology_on_coarsest:
   14.53 -  assumes "istopology T"
   14.54 -          "\<And>s. s \<in> S \<Longrightarrow> T s"
   14.55 -          "generate_topology_on S s0"
   14.56 -  shows "T s0"
   14.57 -using assms(3) apply (induct rule: generate_topology_on.induct)
   14.58 -using assms(1) assms(2) unfolding istopology_def by auto
   14.59 -
   14.60 -abbreviation%unimportant topology_generated_by::"('a set set) \<Rightarrow> ('a topology)"
   14.61 -  where "topology_generated_by S \<equiv> topology (generate_topology_on S)"
   14.62 -
   14.63 -lemma openin_topology_generated_by_iff:
   14.64 -  "openin (topology_generated_by S) s \<longleftrightarrow> generate_topology_on S s"
   14.65 -  using topology_inverse'[OF istopology_generate_topology_on[of S]] by simp
   14.66 -
   14.67 -lemma openin_topology_generated_by:
   14.68 -  "openin (topology_generated_by S) s \<Longrightarrow> generate_topology_on S s"
   14.69 -using openin_topology_generated_by_iff by auto
   14.70 -
   14.71 -lemma topology_generated_by_topspace:
   14.72 -  "topspace (topology_generated_by S) = (\<Union>S)"
   14.73 -proof
   14.74 -  {
   14.75 -    fix s assume "openin (topology_generated_by S) s"
   14.76 -    then have "generate_topology_on S s" by (rule openin_topology_generated_by)
   14.77 -    then have "s \<subseteq> (\<Union>S)" by (induct, auto)
   14.78 -  }
   14.79 -  then show "topspace (topology_generated_by S) \<subseteq> (\<Union>S)"
   14.80 -    unfolding topspace_def by auto
   14.81 -next
   14.82 -  have "generate_topology_on S (\<Union>S)"
   14.83 -    using generate_topology_on.UN[OF generate_topology_on.Basis, of S S] by simp
   14.84 -  then show "(\<Union>S) \<subseteq> topspace (topology_generated_by S)"
   14.85 -    unfolding topspace_def using openin_topology_generated_by_iff by auto
   14.86 -qed
   14.87 -
   14.88 -lemma topology_generated_by_Basis:
   14.89 -  "s \<in> S \<Longrightarrow> openin (topology_generated_by S) s"
   14.90 -  by (simp only: openin_topology_generated_by_iff, auto simp: generate_topology_on.Basis)
   14.91 -
   14.92 -lemma generate_topology_on_Inter:
   14.93 -  "\<lbrakk>finite \<F>; \<And>K. K \<in> \<F> \<Longrightarrow> generate_topology_on \<S> K; \<F> \<noteq> {}\<rbrakk> \<Longrightarrow> generate_topology_on \<S> (\<Inter>\<F>)"
   14.94 -  by (induction \<F> rule: finite_induct; force intro: generate_topology_on.intros)
   14.95 -
   14.96 -subsection\<open>Topology bases and sub-bases\<close>
   14.97 -
   14.98 -lemma istopology_base_alt:
   14.99 -   "istopology (arbitrary union_of P) \<longleftrightarrow>
  14.100 -    (\<forall>S T. (arbitrary union_of P) S \<and> (arbitrary union_of P) T
  14.101 -           \<longrightarrow> (arbitrary union_of P) (S \<inter> T))"
  14.102 -  by (simp add: istopology_def) (blast intro: arbitrary_union_of_Union)
  14.103 -
  14.104 -lemma istopology_base_eq:
  14.105 -   "istopology (arbitrary union_of P) \<longleftrightarrow>
  14.106 -    (\<forall>S T. P S \<and> P T \<longrightarrow> (arbitrary union_of P) (S \<inter> T))"
  14.107 -  by (simp add: istopology_base_alt arbitrary_union_of_Int_eq)
  14.108 -
  14.109 -lemma istopology_base:
  14.110 -   "(\<And>S T. \<lbrakk>P S; P T\<rbrakk> \<Longrightarrow> P(S \<inter> T)) \<Longrightarrow> istopology (arbitrary union_of P)"
  14.111 -  by (simp add: arbitrary_def istopology_base_eq union_of_inc)
  14.112 -
  14.113 -lemma openin_topology_base_unique:
  14.114 -   "openin X = arbitrary union_of P \<longleftrightarrow>
  14.115 -        (\<forall>V. P V \<longrightarrow> openin X V) \<and> (\<forall>U x. openin X U \<and> x \<in> U \<longrightarrow> (\<exists>V. P V \<and> x \<in> V \<and> V \<subseteq> U))"
  14.116 -   (is "?lhs = ?rhs")
  14.117 -proof
  14.118 -  assume ?lhs
  14.119 -  then show ?rhs
  14.120 -    by (auto simp: union_of_def arbitrary_def)
  14.121 -next
  14.122 -  assume R: ?rhs
  14.123 -  then have *: "\<exists>\<U>\<subseteq>Collect P. \<Union>\<U> = S" if "openin X S" for S
  14.124 -    using that by (rule_tac x="{V. P V \<and> V \<subseteq> S}" in exI) fastforce
  14.125 -  from R show ?lhs
  14.126 -    by (fastforce simp add: union_of_def arbitrary_def intro: *)
  14.127 -qed
  14.128 -
  14.129 -lemma topology_base_unique:
  14.130 -   "\<lbrakk>\<And>S. P S \<Longrightarrow> openin X S;
  14.131 -     \<And>U x. \<lbrakk>openin X U; x \<in> U\<rbrakk> \<Longrightarrow> \<exists>B. P B \<and> x \<in> B \<and> B \<subseteq> U\<rbrakk>
  14.132 -    \<Longrightarrow> topology(arbitrary union_of P) = X"
  14.133 -  by (metis openin_topology_base_unique openin_inverse [of X])
  14.134 -
  14.135 -lemma topology_bases_eq_aux:
  14.136 -   "\<lbrakk>(arbitrary union_of P) S;
  14.137 -     \<And>U x. \<lbrakk>P U; x \<in> U\<rbrakk> \<Longrightarrow> \<exists>V. Q V \<and> x \<in> V \<and> V \<subseteq> U\<rbrakk>
  14.138 -        \<Longrightarrow> (arbitrary union_of Q) S"
  14.139 -  by (metis arbitrary_union_of_alt arbitrary_union_of_idempot)
  14.140 -
  14.141 -lemma topology_bases_eq:
  14.142 -   "\<lbrakk>\<And>U x. \<lbrakk>P U; x \<in> U\<rbrakk> \<Longrightarrow> \<exists>V. Q V \<and> x \<in> V \<and> V \<subseteq> U;
  14.143 -    \<And>V x. \<lbrakk>Q V; x \<in> V\<rbrakk> \<Longrightarrow> \<exists>U. P U \<and> x \<in> U \<and> U \<subseteq> V\<rbrakk>
  14.144 -        \<Longrightarrow> topology (arbitrary union_of P) =
  14.145 -            topology (arbitrary union_of Q)"
  14.146 -  by (fastforce intro:  arg_cong [where f=topology]  elim: topology_bases_eq_aux)
  14.147 -
  14.148 -lemma istopology_subbase:
  14.149 -   "istopology (arbitrary union_of (finite intersection_of P relative_to S))"
  14.150 -  by (simp add: finite_intersection_of_Int istopology_base relative_to_Int)
  14.151 -
  14.152 -lemma openin_subbase:
  14.153 -  "openin (topology (arbitrary union_of (finite intersection_of B relative_to U))) S
  14.154 -   \<longleftrightarrow> (arbitrary union_of (finite intersection_of B relative_to U)) S"
  14.155 -  by (simp add: istopology_subbase topology_inverse')
  14.156 -
  14.157 -lemma topspace_subbase [simp]:
  14.158 -   "topspace(topology (arbitrary union_of (finite intersection_of B relative_to U))) = U" (is "?lhs = _")
  14.159 -proof
  14.160 -  show "?lhs \<subseteq> U"
  14.161 -    by (metis arbitrary_union_of_relative_to openin_subbase openin_topspace relative_to_imp_subset)
  14.162 -  show "U \<subseteq> ?lhs"
  14.163 -    by (metis arbitrary_union_of_inc finite_intersection_of_empty inf.orderE istopology_subbase 
  14.164 -              openin_subset relative_to_inc subset_UNIV topology_inverse')
  14.165 -qed
  14.166 -
  14.167 -lemma minimal_topology_subbase:
  14.168 -   "\<lbrakk>\<And>S. P S \<Longrightarrow> openin X S; openin X U;
  14.169 -     openin(topology(arbitrary union_of (finite intersection_of P relative_to U))) S\<rbrakk>
  14.170 -    \<Longrightarrow> openin X S"
  14.171 -  apply (simp add: istopology_subbase topology_inverse)
  14.172 -  apply (simp add: union_of_def intersection_of_def relative_to_def)
  14.173 -  apply (blast intro: openin_Int_Inter)
  14.174 -  done
  14.175 -
  14.176 -lemma istopology_subbase_UNIV:
  14.177 -   "istopology (arbitrary union_of (finite intersection_of P))"
  14.178 -  by (simp add: istopology_base finite_intersection_of_Int)
  14.179 -
  14.180 -
  14.181 -lemma generate_topology_on_eq:
  14.182 -  "generate_topology_on S = arbitrary union_of finite' intersection_of (\<lambda>x. x \<in> S)" (is "?lhs = ?rhs")
  14.183 -proof (intro ext iffI)
  14.184 -  fix A
  14.185 -  assume "?lhs A"
  14.186 -  then show "?rhs A"
  14.187 -  proof induction
  14.188 -    case (Int a b)
  14.189 -    then show ?case
  14.190 -      by (metis (mono_tags, lifting) istopology_base_alt finite'_intersection_of_Int istopology_base)
  14.191 -  next
  14.192 -    case (UN K)
  14.193 -    then show ?case
  14.194 -      by (simp add: arbitrary_union_of_Union)
  14.195 -  next
  14.196 -    case (Basis s)
  14.197 -    then show ?case
  14.198 -      by (simp add: Sup_upper arbitrary_union_of_inc finite'_intersection_of_inc relative_to_subset)
  14.199 -  qed auto
  14.200 -next
  14.201 -  fix A
  14.202 -  assume "?rhs A"
  14.203 -  then obtain \<U> where \<U>: "\<And>T. T \<in> \<U> \<Longrightarrow> \<exists>\<F>. finite' \<F> \<and> \<F> \<subseteq> S \<and> \<Inter>\<F> = T" and eq: "A = \<Union>\<U>"
  14.204 -    unfolding union_of_def intersection_of_def by auto
  14.205 -  show "?lhs A"
  14.206 -    unfolding eq
  14.207 -  proof (rule generate_topology_on.UN)
  14.208 -    fix T
  14.209 -    assume "T \<in> \<U>"
  14.210 -    with \<U> obtain \<F> where "finite' \<F>" "\<F> \<subseteq> S" "\<Inter>\<F> = T"
  14.211 -      by blast
  14.212 -    have "generate_topology_on S (\<Inter>\<F>)"
  14.213 -    proof (rule generate_topology_on_Inter)
  14.214 -      show "finite \<F>" "\<F> \<noteq> {}"
  14.215 -        by (auto simp: \<open>finite' \<F>\<close>)
  14.216 -      show "\<And>K. K \<in> \<F> \<Longrightarrow> generate_topology_on S K"
  14.217 -        by (metis \<open>\<F> \<subseteq> S\<close> generate_topology_on.simps subset_iff)
  14.218 -    qed
  14.219 -    then show "generate_topology_on S T"
  14.220 -      using \<open>\<Inter>\<F> = T\<close> by blast
  14.221 -  qed
  14.222 -qed
  14.223 -
  14.224 -subsubsection%important \<open>Continuity\<close>
  14.225 -
  14.226 -text \<open>We will need to deal with continuous maps in terms of topologies and not in terms
  14.227 -of type classes, as defined below.\<close>
  14.228 -
  14.229 -definition%important continuous_on_topo::"'a topology \<Rightarrow> 'b topology \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
  14.230 -  where "continuous_on_topo T1 T2 f = ((\<forall> U. openin T2 U \<longrightarrow> openin T1 (f-`U \<inter> topspace(T1)))
  14.231 -                                      \<and> (f`(topspace T1) \<subseteq> (topspace T2)))"
  14.232 -
  14.233 -lemma continuous_on_continuous_on_topo:
  14.234 -  "continuous_on s f \<longleftrightarrow> continuous_on_topo (subtopology euclidean s) euclidean f"
  14.235 -  by (auto simp: continuous_on_topo_def Int_commute continuous_openin_preimage_eq)
  14.236 -
  14.237 -lemma continuous_on_topo_UNIV:
  14.238 -  "continuous_on UNIV f \<longleftrightarrow> continuous_on_topo euclidean euclidean f"
  14.239 -using continuous_on_continuous_on_topo[of UNIV f] subtopology_UNIV[of euclidean] by auto
  14.240 -
  14.241 -lemma continuous_on_topo_open [intro]:
  14.242 -  "continuous_on_topo T1 T2 f \<Longrightarrow> openin T2 U \<Longrightarrow> openin T1 (f-`U \<inter> topspace(T1))"
  14.243 -  unfolding continuous_on_topo_def by auto
  14.244 -
  14.245 -lemma continuous_on_topo_topspace [intro]:
  14.246 -  "continuous_on_topo T1 T2 f \<Longrightarrow> f`(topspace T1) \<subseteq> (topspace T2)"
  14.247 -unfolding continuous_on_topo_def by auto
  14.248 -
  14.249 -lemma continuous_on_generated_topo_iff:
  14.250 -  "continuous_on_topo T1 (topology_generated_by S) f \<longleftrightarrow>
  14.251 -      ((\<forall>U. U \<in> S \<longrightarrow> openin T1 (f-`U \<inter> topspace(T1))) \<and> (f`(topspace T1) \<subseteq> (\<Union> S)))"
  14.252 -unfolding continuous_on_topo_def topology_generated_by_topspace
  14.253 -proof (auto simp add: topology_generated_by_Basis)
  14.254 -  assume H: "\<forall>U. U \<in> S \<longrightarrow> openin T1 (f -` U \<inter> topspace T1)"
  14.255 -  fix U assume "openin (topology_generated_by S) U"
  14.256 -  then have "generate_topology_on S U" by (rule openin_topology_generated_by)
  14.257 -  then show "openin T1 (f -` U \<inter> topspace T1)"
  14.258 -  proof (induct)
  14.259 -    fix a b
  14.260 -    assume H: "openin T1 (f -` a \<inter> topspace T1)" "openin T1 (f -` b \<inter> topspace T1)"
  14.261 -    have "f -` (a \<inter> b) \<inter> topspace T1 = (f-`a \<inter> topspace T1) \<inter> (f-`b \<inter> topspace T1)"
  14.262 -      by auto
  14.263 -    then show "openin T1 (f -` (a \<inter> b) \<inter> topspace T1)" using H by auto
  14.264 -  next
  14.265 -    fix K
  14.266 -    assume H: "openin T1 (f -` k \<inter> topspace T1)" if "k\<in> K" for k
  14.267 -    define L where "L = {f -` k \<inter> topspace T1|k. k \<in> K}"
  14.268 -    have *: "openin T1 l" if "l \<in>L" for l using that H unfolding L_def by auto
  14.269 -    have "openin T1 (\<Union>L)" using openin_Union[OF *] by simp
  14.270 -    moreover have "(\<Union>L) = (f -` \<Union>K \<inter> topspace T1)" unfolding L_def by auto
  14.271 -    ultimately show "openin T1 (f -` \<Union>K \<inter> topspace T1)" by simp
  14.272 -  qed (auto simp add: H)
  14.273 -qed
  14.274 -
  14.275 -lemma continuous_on_generated_topo:
  14.276 -  assumes "\<And>U. U \<in>S \<Longrightarrow> openin T1 (f-`U \<inter> topspace(T1))"
  14.277 -          "f`(topspace T1) \<subseteq> (\<Union> S)"
  14.278 -  shows "continuous_on_topo T1 (topology_generated_by S) f"
  14.279 -  using assms continuous_on_generated_topo_iff by blast
  14.280 -
  14.281 -proposition continuous_on_topo_compose:
  14.282 -  assumes "continuous_on_topo T1 T2 f" "continuous_on_topo T2 T3 g"
  14.283 -  shows "continuous_on_topo T1 T3 (g o f)"
  14.284 -  using assms unfolding continuous_on_topo_def
  14.285 -proof (auto)
  14.286 -  fix U :: "'c set"
  14.287 -  assume H: "openin T3 U"
  14.288 -  have "openin T1 (f -` (g -` U \<inter> topspace T2) \<inter> topspace T1)"
  14.289 -    using H assms by blast
  14.290 -  moreover have "f -` (g -` U \<inter> topspace T2) \<inter> topspace T1 = (g \<circ> f) -` U \<inter> topspace T1"
  14.291 -    using H assms continuous_on_topo_topspace by fastforce
  14.292 -  ultimately show "openin T1 ((g \<circ> f) -` U \<inter> topspace T1)"
  14.293 -    by simp
  14.294 -qed (blast)
  14.295 -
  14.296 -lemma continuous_on_topo_preimage_topspace [intro]:
  14.297 -  assumes "continuous_on_topo T1 T2 f"
  14.298 -  shows "f-`(topspace T2) \<inter> topspace T1 = topspace T1"
  14.299 -using assms unfolding continuous_on_topo_def by auto
  14.300 -
  14.301 -
  14.302 -subsubsection%important \<open>Pullback topology\<close>
  14.303 -
  14.304 -text \<open>Pulling back a topology by map gives again a topology. \<open>subtopology\<close> is
  14.305 -a special case of this notion, pulling back by the identity. We introduce the general notion as
  14.306 -we will need it to define the strong operator topology on the space of continuous linear operators,
  14.307 -by pulling back the product topology on the space of all functions.\<close>
  14.308 -
  14.309 -text \<open>\<open>pullback_topology A f T\<close> is the pullback of the topology \<open>T\<close> by the map \<open>f\<close> on
  14.310 -the set \<open>A\<close>.\<close>
  14.311 -
  14.312 -definition%important pullback_topology::"('a set) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b topology) \<Rightarrow> ('a topology)"
  14.313 -  where "pullback_topology A f T = topology (\<lambda>S. \<exists>U. openin T U \<and> S = f-`U \<inter> A)"
  14.314 -
  14.315 -lemma istopology_pullback_topology:
  14.316 -  "istopology (\<lambda>S. \<exists>U. openin T U \<and> S = f-`U \<inter> A)"
  14.317 -  unfolding istopology_def proof (auto)
  14.318 -  fix K assume "\<forall>S\<in>K. \<exists>U. openin T U \<and> S = f -` U \<inter> A"
  14.319 -  then have "\<exists>U. \<forall>S\<in>K. openin T (U S) \<and> S = f-`(U S) \<inter> A"
  14.320 -    by (rule bchoice)
  14.321 -  then obtain U where U: "\<forall>S\<in>K. openin T (U S) \<and> S = f-`(U S) \<inter> A"
  14.322 -    by blast
  14.323 -  define V where "V = (\<Union>S\<in>K. U S)"
  14.324 -  have "openin T V" "\<Union>K = f -` V \<inter> A" unfolding V_def using U by auto
  14.325 -  then show "\<exists>V. openin T V \<and> \<Union>K = f -` V \<inter> A" by auto
  14.326 -qed
  14.327 -
  14.328 -lemma openin_pullback_topology:
  14.329 -  "openin (pullback_topology A f T) S \<longleftrightarrow> (\<exists>U. openin T U \<and> S = f-`U \<inter> A)"
  14.330 -unfolding pullback_topology_def topology_inverse'[OF istopology_pullback_topology] by auto
  14.331 -
  14.332 -lemma topspace_pullback_topology:
  14.333 -  "topspace (pullback_topology A f T) = f-`(topspace T) \<inter> A"
  14.334 -by (auto simp add: topspace_def openin_pullback_topology)
  14.335 -
  14.336 -proposition continuous_on_topo_pullback [intro]:
  14.337 -  assumes "continuous_on_topo T1 T2 g"
  14.338 -  shows "continuous_on_topo (pullback_topology A f T1) T2 (g o f)"
  14.339 -unfolding continuous_on_topo_def
  14.340 -proof (auto)
  14.341 -  fix U::"'b set" assume "openin T2 U"
  14.342 -  then have "openin T1 (g-`U \<inter> topspace T1)"
  14.343 -    using assms unfolding continuous_on_topo_def by auto
  14.344 -  have "(g o f)-`U \<inter> topspace (pullback_topology A f T1) = (g o f)-`U \<inter> A \<inter> f-`(topspace T1)"
  14.345 -    unfolding topspace_pullback_topology by auto
  14.346 -  also have "... = f-`(g-`U \<inter> topspace T1) \<inter> A "
  14.347 -    by auto
  14.348 -  also have "openin (pullback_topology A f T1) (...)"
  14.349 -    unfolding openin_pullback_topology using \<open>openin T1 (g-`U \<inter> topspace T1)\<close> by auto
  14.350 -  finally show "openin (pullback_topology A f T1) ((g \<circ> f) -` U \<inter> topspace (pullback_topology A f T1))"
  14.351 -    by auto
  14.352 -next
  14.353 -  fix x assume "x \<in> topspace (pullback_topology A f T1)"
  14.354 -  then have "f x \<in> topspace T1"
  14.355 -    unfolding topspace_pullback_topology by auto
  14.356 -  then show "g (f x) \<in> topspace T2"
  14.357 -    using assms unfolding continuous_on_topo_def by auto
  14.358 -qed
  14.359 -
  14.360 -proposition continuous_on_topo_pullback' [intro]:
  14.361 -  assumes "continuous_on_topo T1 T2 (f o g)" "topspace T1 \<subseteq> g-`A"
  14.362 -  shows "continuous_on_topo T1 (pullback_topology A f T2) g"
  14.363 -unfolding continuous_on_topo_def
  14.364 -proof (auto)
  14.365 -  fix U assume "openin (pullback_topology A f T2) U"
  14.366 -  then have "\<exists>V. openin T2 V \<and> U = f-`V \<inter> A"
  14.367 -    unfolding openin_pullback_topology by auto
  14.368 -  then obtain V where "openin T2 V" "U = f-`V \<inter> A"
  14.369 -    by blast
  14.370 -  then have "g -` U \<inter> topspace T1 = g-`(f-`V \<inter> A) \<inter> topspace T1"
  14.371 -    by blast
  14.372 -  also have "... = (f o g)-`V \<inter> (g-`A \<inter> topspace T1)"
  14.373 -    by auto
  14.374 -  also have "... = (f o g)-`V \<inter> topspace T1"
  14.375 -    using assms(2) by auto
  14.376 -  also have "openin T1 (...)"
  14.377 -    using assms(1) \<open>openin T2 V\<close> by auto
  14.378 -  finally show "openin T1 (g -` U \<inter> topspace T1)" by simp
  14.379 -next
  14.380 -  fix x assume "x \<in> topspace T1"
  14.381 -  have "(f o g) x \<in> topspace T2"
  14.382 -    using assms(1) \<open>x \<in> topspace T1\<close> unfolding continuous_on_topo_def by auto
  14.383 -  then have "g x \<in> f-`(topspace T2)"
  14.384 -    unfolding comp_def by blast
  14.385 -  moreover have "g x \<in> A" using assms(2) \<open>x \<in> topspace T1\<close> by blast
  14.386 -  ultimately show "g x \<in> topspace (pullback_topology A f T2)"
  14.387 -    unfolding topspace_pullback_topology by blast
  14.388 -qed
  14.389 -
  14.390 -
  14.391  subsection \<open>The product topology\<close>
  14.392  
  14.393  text \<open>We can now define the product topology, as generated by
  14.394 @@ -605,6 +242,9 @@
  14.395    then show ?thesis using \<open>x \<in> U\<close> by auto
  14.396  qed
  14.397  
  14.398 +lemma product_topology_empty_discrete:
  14.399 +   "product_topology T {} = discrete_topology {(\<lambda>x. undefined)}"
  14.400 +  by (simp add: subtopology_eq_discrete_topology_sing)
  14.401  
  14.402  lemma openin_product_topology:
  14.403     "openin (product_topology X I) =
  14.404 @@ -793,6 +433,15 @@
  14.405    using PiE_singleton closedin_product_topology [of X I]
  14.406    by (metis (no_types, lifting) all_not_in_conv insertI1)
  14.407  
  14.408 +lemma product_topology_empty:
  14.409 +   "product_topology X {} = topology (\<lambda>S. S \<in> {{},{\<lambda>k. undefined}})"
  14.410 +  unfolding product_topology union_of_def intersection_of_def arbitrary_def relative_to_def
  14.411 +  by (auto intro: arg_cong [where f=topology])
  14.412 +
  14.413 +lemma openin_product_topology_empty: "openin (product_topology X {}) S \<longleftrightarrow> S \<in> {{},{\<lambda>k. undefined}}"
  14.414 +  unfolding union_of_def intersection_of_def arbitrary_def relative_to_def openin_product_topology
  14.415 +  by auto
  14.416 +
  14.417  
  14.418  subsubsection \<open>The basic property of the product topology is the continuity of projections:\<close>
  14.419  
  14.420 @@ -949,10 +598,10 @@
  14.421    by (rule continuous_on_topo_product_coordinates, simp)
  14.422  
  14.423  lemma continuous_on_coordinatewise_then_product [intro, continuous_intros]:
  14.424 -  fixes f :: "('a \<Rightarrow> real) \<Rightarrow> 'b \<Rightarrow> real"
  14.425 +  fixes f :: "'a::topological_space \<Rightarrow> 'b \<Rightarrow> 'c::topological_space"
  14.426    assumes "\<And>i. continuous_on S (\<lambda>x. f x i)"
  14.427    shows "continuous_on S f"
  14.428 -  using continuous_on_topo_coordinatewise_then_product [of UNIV, where T = "\<lambda>i. euclideanreal"]
  14.429 +  using continuous_on_topo_coordinatewise_then_product [of UNIV, where T = "\<lambda>i. euclidean"]
  14.430    by (metis UNIV_I assms continuous_on_continuous_on_topo euclidean_product_topology)
  14.431  
  14.432  lemma continuous_on_product_then_coordinatewise_UNIV:
  14.433 @@ -1583,4 +1232,354 @@
  14.434  instance "fun" :: (countable, polish_space) polish_space
  14.435  by standard
  14.436  
  14.437 +
  14.438 +subsection\<open>The Alexander subbase theorem\<close>
  14.439 +
  14.440 +theorem Alexander_subbase:
  14.441 +  assumes X: "topology (arbitrary union_of (finite intersection_of (\<lambda>x. x \<in> \<B>) relative_to \<Union>\<B>)) = X"
  14.442 +    and fin: "\<And>C. \<lbrakk>C \<subseteq> \<B>; \<Union>C = topspace X\<rbrakk> \<Longrightarrow> \<exists>C'. finite C' \<and> C' \<subseteq> C \<and> \<Union>C' = topspace X"
  14.443 +  shows "compact_space X"
  14.444 +proof -
  14.445 +  have U\<B>: "\<Union>\<B> = topspace X"
  14.446 +    by (simp flip: X)
  14.447 +  have False if \<U>: "\<forall>U\<in>\<U>. openin X U" and sub: "topspace X \<subseteq> \<Union>\<U>"
  14.448 +    and neg: "\<And>\<F>. \<lbrakk>\<F> \<subseteq> \<U>; finite \<F>\<rbrakk> \<Longrightarrow> \<not> topspace X \<subseteq> \<Union>\<F>" for \<U>
  14.449 +  proof -
  14.450 +    define \<A> where "\<A> \<equiv> {\<C>. (\<forall>U \<in> \<C>. openin X U) \<and> topspace X \<subseteq> \<Union>\<C> \<and> (\<forall>\<F>. finite \<F> \<longrightarrow> \<F> \<subseteq> \<C> \<longrightarrow> ~(topspace X \<subseteq> \<Union>\<F>))}"
  14.451 +    have 1: "\<A> \<noteq> {}"
  14.452 +      unfolding \<A>_def using sub \<U> neg by force
  14.453 +    have 2: "\<Union>\<C> \<in> \<A>" if "\<C>\<noteq>{}" and \<C>: "subset.chain \<A> \<C>" for \<C>
  14.454 +      unfolding \<A>_def
  14.455 +    proof (intro CollectI conjI ballI allI impI notI)
  14.456 +      show "openin X U" if U: "U \<in> \<Union>\<C>" for U
  14.457 +        using U \<C> unfolding \<A>_def subset_chain_def by force
  14.458 +      have "\<C> \<subseteq> \<A>"
  14.459 +        using subset_chain_def \<C> by blast
  14.460 +      with that \<A>_def show UUC: "topspace X \<subseteq> \<Union>(\<Union>\<C>)"
  14.461 +        by blast
  14.462 +      show "False" if "finite \<F>" and "\<F> \<subseteq> \<Union>\<C>" and "topspace X \<subseteq> \<Union>\<F>" for \<F>
  14.463 +      proof -
  14.464 +        obtain \<B> where "\<B> \<in> \<C>" "\<F> \<subseteq> \<B>"
  14.465 +          by (metis Sup_empty \<C> \<open>\<F> \<subseteq> \<Union>\<C>\<close> \<open>finite \<F>\<close> UUC empty_subsetI finite.emptyI finite_subset_Union_chain neg)
  14.466 +        then show False
  14.467 +          using \<A>_def \<open>\<C> \<subseteq> \<A>\<close> \<open>finite \<F>\<close> \<open>topspace X \<subseteq> \<Union>\<F>\<close> by blast
  14.468 +      qed
  14.469 +    qed
  14.470 +    obtain \<K> where "\<K> \<in> \<A>" and "\<And>X. \<lbrakk>X\<in>\<A>; \<K> \<subseteq> X\<rbrakk> \<Longrightarrow> X = \<K>"
  14.471 +      using subset_Zorn_nonempty [OF 1 2] by metis
  14.472 +    then have *: "\<And>\<W>. \<lbrakk>\<And>W. W\<in>\<W> \<Longrightarrow> openin X W; topspace X \<subseteq> \<Union>\<W>; \<K> \<subseteq> \<W>;
  14.473 +                        \<And>\<F>. \<lbrakk>finite \<F>; \<F> \<subseteq> \<W>; topspace X \<subseteq> \<Union>\<F>\<rbrakk> \<Longrightarrow> False\<rbrakk>
  14.474 +           \<Longrightarrow> \<W> = \<K>"
  14.475 +      and ope: "\<forall>U\<in>\<K>. openin X U" and top: "topspace X \<subseteq> \<Union>\<K>"
  14.476 +      and non: "\<And>\<F>. \<lbrakk>finite \<F>; \<F> \<subseteq> \<K>; topspace X \<subseteq> \<Union>\<F>\<rbrakk> \<Longrightarrow> False"
  14.477 +      unfolding \<A>_def by simp_all metis+
  14.478 +    then obtain x where "x \<in> topspace X" "x \<notin> \<Union>(\<B> \<inter> \<K>)"
  14.479 +    proof -
  14.480 +      have "\<Union>(\<B> \<inter> \<K>) \<noteq> \<Union>\<B>"
  14.481 +        by (metis \<open>\<Union>\<B> = topspace X\<close> fin inf.bounded_iff non order_refl)
  14.482 +      then have "\<exists>a. a \<notin> \<Union>(\<B> \<inter> \<K>) \<and> a \<in> \<Union>\<B>"
  14.483 +        by blast
  14.484 +      then show ?thesis
  14.485 +        using that by (metis U\<B>)
  14.486 +    qed
  14.487 +    obtain C where C: "openin X C" "C \<in> \<K>" "x \<in> C"
  14.488 +      using \<open>x \<in> topspace X\<close> ope top by auto
  14.489 +    then have "C \<subseteq> topspace X"
  14.490 +      by (metis openin_subset)
  14.491 +    then have "(arbitrary union_of (finite intersection_of (\<lambda>x. x \<in> \<B>) relative_to \<Union>\<B>)) C"
  14.492 +      using openin_subbase C unfolding X [symmetric] by blast
  14.493 +    moreover have "C \<noteq> topspace X"
  14.494 +      using \<open>\<K> \<in> \<A>\<close> \<open>C \<in> \<K>\<close> unfolding \<A>_def by blast
  14.495 +    ultimately obtain \<V> W where W: "(finite intersection_of (\<lambda>x. x \<in> \<B>) relative_to topspace X) W"
  14.496 +      and "x \<in> W" "W \<in> \<V>" "\<Union>\<V> \<noteq> topspace X" "C = \<Union>\<V>"
  14.497 +      using C  by (auto simp: union_of_def U\<B>)
  14.498 +    then have "\<Union>\<V> \<subseteq> topspace X"
  14.499 +      by (metis \<open>C \<subseteq> topspace X\<close>)
  14.500 +    then have "topspace X \<notin> \<V>"
  14.501 +      using \<open>\<Union>\<V> \<noteq> topspace X\<close> by blast
  14.502 +    then obtain \<B>' where \<B>': "finite \<B>'" "\<B>' \<subseteq> \<B>" "x \<in> \<Inter>\<B>'" "W = topspace X \<inter> \<Inter>\<B>'"
  14.503 +      using W \<open>x \<in> W\<close> unfolding relative_to_def intersection_of_def by auto
  14.504 +    then have "\<Inter>\<B>' \<subseteq> \<Union>\<B>"
  14.505 +      using \<open>W \<in> \<V>\<close> \<open>\<Union>\<V> \<noteq> topspace X\<close> \<open>\<Union>\<V> \<subseteq> topspace X\<close> by blast
  14.506 +    then have "\<Inter>\<B>' \<subseteq> C"
  14.507 +      using U\<B> \<open>C = \<Union>\<V>\<close> \<open>W = topspace X \<inter> \<Inter>\<B>'\<close> \<open>W \<in> \<V>\<close> by auto
  14.508 +    have "\<forall>b \<in> \<B>'. \<exists>C'. finite C' \<and> C' \<subseteq> \<K> \<and> topspace X \<subseteq> \<Union>(insert b C')"
  14.509 +    proof
  14.510 +      fix b
  14.511 +      assume "b \<in> \<B>'"
  14.512 +      have "insert b \<K> = \<K>" if neg: "\<not> (\<exists>C'. finite C' \<and> C' \<subseteq> \<K> \<and> topspace X \<subseteq> \<Union>(insert b C'))"
  14.513 +      proof (rule *)
  14.514 +        show "openin X W" if "W \<in> insert b \<K>" for W
  14.515 +          using that
  14.516 +        proof
  14.517 +          have "b \<in> \<B>"
  14.518 +            using \<open>b \<in> \<B>'\<close> \<open>\<B>' \<subseteq> \<B>\<close> by blast
  14.519 +          then have "\<exists>\<U>. finite \<U> \<and> \<U> \<subseteq> \<B> \<and> \<Inter>\<U> = b"
  14.520 +            by (rule_tac x="{b}" in exI) auto
  14.521 +          moreover have "\<Union>\<B> \<inter> b = b"
  14.522 +            using \<B>'(2) \<open>b \<in> \<B>'\<close> by auto
  14.523 +          ultimately show "openin X W" if "W = b"
  14.524 +            using  that \<open>b \<in> \<B>'\<close>
  14.525 +            apply (simp add: openin_subbase flip: X)
  14.526 +            apply (auto simp: arbitrary_def intersection_of_def relative_to_def intro!: union_of_inc)
  14.527 +            done
  14.528 +          show "openin X W" if "W \<in> \<K>"
  14.529 +            by (simp add: \<open>W \<in> \<K>\<close> ope)
  14.530 +        qed
  14.531 +      next
  14.532 +        show "topspace X \<subseteq> \<Union> (insert b \<K>)"
  14.533 +          using top by auto
  14.534 +      next
  14.535 +        show False if "finite \<F>" and "\<F> \<subseteq> insert b \<K>" "topspace X \<subseteq> \<Union>\<F>" for \<F>
  14.536 +        proof -
  14.537 +          have "insert b (\<F> \<inter> \<K>) = \<F>"
  14.538 +            using non that by blast
  14.539 +          then show False
  14.540 +            by (metis Int_lower2 finite_insert neg that(1) that(3))
  14.541 +        qed
  14.542 +      qed auto
  14.543 +      then show "\<exists>C'. finite C' \<and> C' \<subseteq> \<K> \<and> topspace X \<subseteq> \<Union>(insert b C')"
  14.544 +        using \<open>b \<in> \<B>'\<close> \<open>x \<notin> \<Union>(\<B> \<inter> \<K>)\<close> \<B>'
  14.545 +        by (metis IntI InterE Union_iff subsetD insertI1)
  14.546 +    qed
  14.547 +    then obtain F where F: "\<forall>b \<in> \<B>'. finite (F b) \<and> F b \<subseteq> \<K> \<and> topspace X \<subseteq> \<Union>(insert b (F b))"
  14.548 +      by metis
  14.549 +    let ?\<D> = "insert C (\<Union>(F ` \<B>'))"
  14.550 +    show False
  14.551 +    proof (rule non)
  14.552 +      have "topspace X \<subseteq> (\<Inter>b \<in> \<B>'. \<Union>(insert b (F b)))"
  14.553 +        using F by (simp add: INT_greatest)
  14.554 +      also have "\<dots> \<subseteq> \<Union>?\<D>"
  14.555 +        using \<open>\<Inter>\<B>' \<subseteq> C\<close> by force
  14.556 +      finally show "topspace X \<subseteq> \<Union>?\<D>" .
  14.557 +      show "?\<D> \<subseteq> \<K>"
  14.558 +        using \<open>C \<in> \<K>\<close> F by auto
  14.559 +      show "finite ?\<D>"
  14.560 +        using \<open>finite \<B>'\<close> F by auto
  14.561 +    qed
  14.562 +  qed
  14.563 +  then show ?thesis
  14.564 +    by (force simp: compact_space_def compactin_def)
  14.565 +qed
  14.566 +
  14.567 +
  14.568 +corollary Alexander_subbase_alt:
  14.569 +  assumes "U \<subseteq> \<Union>\<B>"
  14.570 +  and fin: "\<And>C. \<lbrakk>C \<subseteq> \<B>; U \<subseteq> \<Union>C\<rbrakk> \<Longrightarrow> \<exists>C'. finite C' \<and> C' \<subseteq> C \<and> U \<subseteq> \<Union>C'"
  14.571 +   and X: "topology
  14.572 +              (arbitrary union_of
  14.573 +                   (finite intersection_of (\<lambda>x. x \<in> \<B>) relative_to U)) = X"
  14.574 + shows "compact_space X"
  14.575 +proof -
  14.576 +  have "topspace X = U"
  14.577 +    using X topspace_subbase by fastforce
  14.578 +  have eq: "\<Union> (Collect ((\<lambda>x. x \<in> \<B>) relative_to U)) = U"
  14.579 +    unfolding relative_to_def
  14.580 +    using \<open>U \<subseteq> \<Union>\<B>\<close> by blast
  14.581 +  have *: "\<exists>\<F>. finite \<F> \<and> \<F> \<subseteq> \<C> \<and> \<Union>\<F> = topspace X"
  14.582 +    if  "\<C> \<subseteq> Collect ((\<lambda>x. x \<in> \<B>) relative_to topspace X)" and UC: "\<Union>\<C> = topspace X" for \<C>
  14.583 +  proof -
  14.584 +    have "\<C> \<subseteq> (\<lambda>U. topspace X \<inter> U) ` \<B>"
  14.585 +      using that by (auto simp: relative_to_def)
  14.586 +    then obtain \<B>' where "\<B>' \<subseteq> \<B>" and \<B>': "\<C> = (\<inter>) (topspace X) ` \<B>'"
  14.587 +      by (auto simp: subset_image_iff)
  14.588 +    moreover have "U \<subseteq> \<Union>\<B>'"
  14.589 +      using \<B>' \<open>topspace X = U\<close> UC by auto
  14.590 +    ultimately obtain \<C>' where "finite \<C>'" "\<C>' \<subseteq> \<B>'" "U \<subseteq> \<Union>\<C>'"
  14.591 +      using fin [of \<B>'] \<open>topspace X = U\<close> \<open>U \<subseteq> \<Union>\<B>\<close> by blast
  14.592 +    then show ?thesis
  14.593 +      unfolding \<B>' exists_finite_subset_image \<open>topspace X = U\<close> by auto
  14.594 +  qed
  14.595 +  show ?thesis
  14.596 +    apply (rule Alexander_subbase [where \<B> = "Collect ((\<lambda>x. x \<in> \<B>) relative_to (topspace X))"])
  14.597 +     apply (simp flip: X)
  14.598 +     apply (metis finite_intersection_of_relative_to eq)
  14.599 +    apply (blast intro: *)
  14.600 +    done
  14.601 +qed
  14.602 +
  14.603 +proposition continuous_map_componentwise:
  14.604 +   "continuous_map X (product_topology Y I) f \<longleftrightarrow>
  14.605 +    f ` (topspace X) \<subseteq> extensional I \<and> (\<forall>k \<in> I. continuous_map X (Y k) (\<lambda>x. f x k))"
  14.606 +    (is "?lhs \<longleftrightarrow> _ \<and> ?rhs")
  14.607 +proof (cases "\<forall>x \<in> topspace X. f x \<in> extensional I")
  14.608 +  case True
  14.609 +  then have "f ` (topspace X) \<subseteq> extensional I"
  14.610 +    by force
  14.611 +  moreover have ?rhs if L: ?lhs
  14.612 +  proof -
  14.613 +    have "openin X {x \<in> topspace X. f x k \<in> U}" if "k \<in> I" and "openin (Y k) U" for k U
  14.614 +    proof -
  14.615 +      have "openin (product_topology Y I) ({Y. Y k \<in> U} \<inter> (\<Pi>\<^sub>E i\<in>I. topspace (Y i)))"
  14.616 +        apply (simp add: openin_product_topology flip: arbitrary_union_of_relative_to)
  14.617 +        apply (simp add: relative_to_def)
  14.618 +        using that apply (blast intro: arbitrary_union_of_inc finite_intersection_of_inc)
  14.619 +        done
  14.620 +      with that have "openin X {x \<in> topspace X. f x \<in> ({Y. Y k \<in> U} \<inter> (\<Pi>\<^sub>E i\<in>I. topspace (Y i)))}"
  14.621 +        using L unfolding continuous_map_def by blast
  14.622 +      moreover have "{x \<in> topspace X. f x \<in> ({Y. Y k \<in> U} \<inter> (\<Pi>\<^sub>E i\<in>I. topspace (Y i)))} = {x \<in> topspace X. f x k \<in> U}"
  14.623 +        using L by (auto simp: continuous_map_def)
  14.624 +      ultimately show ?thesis
  14.625 +        by metis
  14.626 +    qed
  14.627 +    with that
  14.628 +    show ?thesis
  14.629 +      by (auto simp: continuous_map_def)
  14.630 +  qed
  14.631 +  moreover have ?lhs if ?rhs
  14.632 +  proof -
  14.633 +    have 1: "\<And>x. x \<in> topspace X \<Longrightarrow> f x \<in> (\<Pi>\<^sub>E i\<in>I. topspace (Y i))"
  14.634 +      using that True by (auto simp: continuous_map_def PiE_iff)
  14.635 +    have 2: "{x \<in> S. \<exists>T\<in>\<T>. f x \<in> T} = (\<Union>T\<in>\<T>. {x \<in> S. f x \<in> T})" for S \<T>
  14.636 +      by blast
  14.637 +    have 3: "{x \<in> S. \<forall>U\<in>\<U>. f x \<in> U} = (\<Inter> (insert S ((\<lambda>U. {x \<in> S. f x \<in> U}) ` \<U>)))" for S \<U>
  14.638 +      by blast
  14.639 +    show ?thesis
  14.640 +      unfolding continuous_map_def openin_product_topology arbitrary_def
  14.641 +    proof (clarsimp simp: all_union_of 1 2)
  14.642 +      fix \<T>
  14.643 +      assume \<T>: "\<T> \<subseteq> Collect (finite intersection_of (\<lambda>F. \<exists>i U. F = {f. f i \<in> U} \<and> i \<in> I \<and> openin (Y i) U)
  14.644 +                  relative_to (\<Pi>\<^sub>E i\<in>I. topspace (Y i)))"
  14.645 +      show "openin X (\<Union>T\<in>\<T>. {x \<in> topspace X. f x \<in> T})"
  14.646 +      proof (rule openin_Union; clarify)
  14.647 +        fix S T
  14.648 +        assume "T \<in> \<T>"
  14.649 +        obtain \<U> where "T = (\<Pi>\<^sub>E i\<in>I. topspace (Y i)) \<inter> \<Inter>\<U>" and "finite \<U>"
  14.650 +          "\<U> \<subseteq> {{f. f i \<in> U} |i U. i \<in> I \<and> openin (Y i) U}"
  14.651 +          using subsetD [OF \<T> \<open>T \<in> \<T>\<close>] by (auto simp: intersection_of_def relative_to_def)
  14.652 +        with that show "openin X {x \<in> topspace X. f x \<in> T}"
  14.653 +          apply (simp add: continuous_map_def 1 cong: conj_cong)
  14.654 +          unfolding 3
  14.655 +          apply (rule openin_Inter; auto)
  14.656 +          done
  14.657 +      qed
  14.658 +    qed
  14.659 +  qed
  14.660 +  ultimately show ?thesis
  14.661 +    by metis
  14.662 +next
  14.663 +  case False
  14.664 +  then show ?thesis
  14.665 +    by (auto simp: continuous_map_def PiE_def)
  14.666 +qed
  14.667 +
  14.668 +
  14.669 +lemma continuous_map_componentwise_UNIV:
  14.670 +   "continuous_map X (product_topology Y UNIV) f \<longleftrightarrow> (\<forall>k. continuous_map X (Y k) (\<lambda>x. f x k))"
  14.671 +  by (simp add: continuous_map_componentwise)
  14.672 +
  14.673 +lemma continuous_map_product_projection [continuous_intros]:
  14.674 +   "k \<in> I \<Longrightarrow> continuous_map (product_topology X I) (X k) (\<lambda>x. x k)"
  14.675 +  using continuous_map_componentwise [of "product_topology X I" X I id] by simp
  14.676 +
  14.677 +proposition open_map_product_projection:
  14.678 +  assumes "i \<in> I"
  14.679 +  shows "open_map (product_topology Y I) (Y i) (\<lambda>f. f i)"
  14.680 +  unfolding openin_product_topology all_union_of arbitrary_def open_map_def image_Union
  14.681 +proof clarify
  14.682 +  fix \<V>
  14.683 +  assume \<V>: "\<V> \<subseteq> Collect
  14.684 +               (finite intersection_of
  14.685 +                (\<lambda>F. \<exists>i U. F = {f. f i \<in> U} \<and> i \<in> I \<and> openin (Y i) U) relative_to
  14.686 +                           topspace (product_topology Y I))"
  14.687 +  show "openin (Y i) (\<Union>x\<in>\<V>. (\<lambda>f. f i) ` x)"
  14.688 +  proof (rule openin_Union, clarify)
  14.689 +    fix S V
  14.690 +    assume "V \<in> \<V>"
  14.691 +    obtain \<F> where "finite \<F>"
  14.692 +      and V: "V = (\<Pi>\<^sub>E i\<in>I. topspace (Y i)) \<inter> \<Inter>\<F>"
  14.693 +      and \<F>: "\<F> \<subseteq> {{f. f i \<in> U} |i U. i \<in> I \<and> openin (Y i) U}"
  14.694 +      using subsetD [OF \<V> \<open>V \<in> \<V>\<close>]
  14.695 +      by (auto simp: intersection_of_def relative_to_def)
  14.696 +    show "openin (Y i) ((\<lambda>f. f i) ` V)"
  14.697 +    proof (subst openin_subopen; clarify)
  14.698 +      fix x f
  14.699 +      assume "f \<in> V"
  14.700 +      let ?T = "{a \<in> topspace(Y i).
  14.701 +                   (\<lambda>j. if j = i then a
  14.702 +                        else if j \<in> I then f j else undefined) \<in> (\<Pi>\<^sub>E i\<in>I. topspace (Y i)) \<inter> \<Inter>\<F>}"
  14.703 +      show "\<exists>T. openin (Y i) T \<and> f i \<in> T \<and> T \<subseteq> (\<lambda>f. f i) ` V"
  14.704 +      proof (intro exI conjI)
  14.705 +        show "openin (Y i) ?T"
  14.706 +        proof (rule openin_continuous_map_preimage)
  14.707 +          have "continuous_map (Y i) (Y k) (\<lambda>x. if k = i then x else f k)" if "k \<in> I" for k
  14.708 +          proof (cases "k=i")
  14.709 +            case True
  14.710 +            then show ?thesis
  14.711 +              by (metis (mono_tags) continuous_map_id eq_id_iff)
  14.712 +          next
  14.713 +            case False
  14.714 +            then show ?thesis
  14.715 +              by simp (metis IntD1 PiE_iff V \<open>f \<in> V\<close> that)
  14.716 +          qed
  14.717 +          then show "continuous_map (Y i) (product_topology Y I)
  14.718 +                  (\<lambda>x j. if j = i then x else if j \<in> I then f j else undefined)"
  14.719 +            by (auto simp: continuous_map_componentwise assms extensional_def)
  14.720 +        next
  14.721 +          have "openin (product_topology Y I) (\<Pi>\<^sub>E i\<in>I. topspace (Y i))"
  14.722 +            by (metis openin_topspace topspace_product_topology)
  14.723 +          moreover have "openin (product_topology Y I) (\<Inter>B\<in>\<F>. (\<Pi>\<^sub>E i\<in>I. topspace (Y i)) \<inter> B)"
  14.724 +                         if "\<F> \<noteq> {}"
  14.725 +          proof -
  14.726 +            show ?thesis
  14.727 +            proof (rule openin_Inter)
  14.728 +              show "\<And>X. X \<in> (\<inter>) (\<Pi>\<^sub>E i\<in>I. topspace (Y i)) ` \<F> \<Longrightarrow> openin (product_topology Y I) X"
  14.729 +                unfolding openin_product_topology relative_to_def
  14.730 +                apply (clarify intro!: arbitrary_union_of_inc)
  14.731 +                apply (rename_tac F)
  14.732 +                apply (rule_tac x=F in exI)
  14.733 +                using subsetD [OF \<F>]
  14.734 +                apply (force intro: finite_intersection_of_inc)
  14.735 +                done
  14.736 +            qed (use \<open>finite \<F>\<close> \<open>\<F> \<noteq> {}\<close> in auto)
  14.737 +          qed
  14.738 +          ultimately show "openin (product_topology Y I) ((\<Pi>\<^sub>E i\<in>I. topspace (Y i)) \<inter> \<Inter>\<F>)"
  14.739 +            by (auto simp only: Int_Inter_eq split: if_split)
  14.740 +        qed
  14.741 +      next
  14.742 +        have eqf: "(\<lambda>j. if j = i then f i else if j \<in> I then f j else undefined) = f"
  14.743 +          using PiE_arb V \<open>f \<in> V\<close> by force
  14.744 +        show "f i \<in> ?T"
  14.745 +          using V assms \<open>f \<in> V\<close> by (auto simp: PiE_iff eqf)
  14.746 +      next
  14.747 +        show "?T \<subseteq> (\<lambda>f. f i) ` V"
  14.748 +          unfolding V by (auto simp: intro!: rev_image_eqI)
  14.749 +      qed
  14.750 +    qed
  14.751 +  qed
  14.752 +qed
  14.753 +
  14.754 +lemma retraction_map_product_projection:
  14.755 +  assumes "i \<in> I"
  14.756 +  shows "(retraction_map (product_topology X I) (X i) (\<lambda>x. x i) \<longleftrightarrow>
  14.757 +         (topspace (product_topology X I) = {}) \<longrightarrow> topspace (X i) = {})"
  14.758 +  (is "?lhs = ?rhs")
  14.759 +proof
  14.760 +  assume ?lhs
  14.761 +  then show ?rhs
  14.762 +    using retraction_imp_surjective_map by force
  14.763 +next
  14.764 +  assume R: ?rhs
  14.765 +  show ?lhs
  14.766 +  proof (cases "topspace (product_topology X I) = {}")
  14.767 +    case True
  14.768 +    then show ?thesis
  14.769 +      using R by (auto simp: retraction_map_def retraction_maps_def continuous_map_on_empty)
  14.770 +  next
  14.771 +    case False
  14.772 +    have *: "\<exists>g. continuous_map (X i) (product_topology X I) g \<and> (\<forall>x\<in>topspace (X i). g x i = x)"
  14.773 +      if z: "z \<in> (\<Pi>\<^sub>E i\<in>I. topspace (X i))" for z
  14.774 +    proof -
  14.775 +      have cm: "continuous_map (X i) (X j) (\<lambda>x. if j = i then x else z j)" if "j \<in> I" for j
  14.776 +        using \<open>j \<in> I\<close> z  by (case_tac "j = i") auto
  14.777 +      show ?thesis
  14.778 +        using \<open>i \<in> I\<close> that
  14.779 +        by (rule_tac x="\<lambda>x j. if j = i then x else z j" in exI) (auto simp: continuous_map_componentwise PiE_iff extensional_def cm)
  14.780 +    qed
  14.781 +    show ?thesis
  14.782 +      using \<open>i \<in> I\<close> False
  14.783 +      by (auto simp: retraction_map_def retraction_maps_def assms continuous_map_product_projection *)
  14.784 +  qed
  14.785 +qed
  14.786 +
  14.787  end
    15.1 --- a/src/HOL/Analysis/Further_Topology.thy	Mon Mar 18 21:50:51 2019 +0100
    15.2 +++ b/src/HOL/Analysis/Further_Topology.thy	Tue Mar 19 16:14:59 2019 +0000
    15.3 @@ -1149,7 +1149,7 @@
    15.4    assumes "finite K" "affine U" and contf: "continuous_on (U - K) f"
    15.5        and fim: "f ` (U - K) \<subseteq> T"
    15.6        and comps: "\<And>C. \<lbrakk>C \<in> components(U - S); C \<inter> K \<noteq> {}\<rbrakk> \<Longrightarrow> C \<inter> L \<noteq> {}"
    15.7 -      and clo: "closedin (subtopology euclidean U) S" and K: "disjnt K S" "K \<subseteq> U"
    15.8 +      and clo: "closedin (top_of_set U) S" and K: "disjnt K S" "K \<subseteq> U"
    15.9    obtains g where "continuous_on (U - L) g" "g ` (U - L) \<subseteq> T" "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
   15.10  proof (cases "K = {}")
   15.11    case True
   15.12 @@ -1176,11 +1176,11 @@
   15.13      have "C \<subseteq> U-S" "C \<inter> L \<noteq> {}"
   15.14        by (simp_all add: in_components_subset comps that)
   15.15      then obtain a where a: "a \<in> C" "a \<in> L" by auto
   15.16 -    have opeUC: "openin (subtopology euclidean U) C"
   15.17 +    have opeUC: "openin (top_of_set U) C"
   15.18      proof (rule openin_trans)
   15.19 -      show "openin (subtopology euclidean (U-S)) C"
   15.20 +      show "openin (top_of_set (U-S)) C"
   15.21          by (simp add: \<open>locally connected U\<close> clo locally_diff_closed openin_components_locally_connected [OF _ C])
   15.22 -      show "openin (subtopology euclidean U) (U - S)"
   15.23 +      show "openin (top_of_set U) (U - S)"
   15.24          by (simp add: clo openin_diff)
   15.25      qed
   15.26      then obtain d where "C \<subseteq> U" "0 < d" and d: "cball a d \<inter> U \<subseteq> C"
   15.27 @@ -1192,10 +1192,10 @@
   15.28                   and bou: "bounded {x. (\<not> (h x = x \<and> k x = x))}"
   15.29                   and hin: "\<And>x. x \<in> C \<inter> K \<Longrightarrow> h x \<in> ball a d \<inter> U"
   15.30      proof (rule homeomorphism_grouping_points_exists_gen [of C "ball a d \<inter> U" "C \<inter> K" "S \<union> C"])
   15.31 -      show "openin (subtopology euclidean C) (ball a d \<inter> U)"
   15.32 +      show "openin (top_of_set C) (ball a d \<inter> U)"
   15.33          by (metis open_ball \<open>C \<subseteq> U\<close> \<open>ball a d \<inter> U \<subseteq> C\<close> inf.absorb_iff2 inf.orderE inf_assoc open_openin openin_subtopology)
   15.34 -      show "openin (subtopology euclidean (affine hull C)) C"
   15.35 -        by (metis \<open>a \<in> C\<close> \<open>openin (subtopology euclidean U) C\<close> affine_hull_eq affine_hull_openin all_not_in_conv \<open>affine U\<close>)
   15.36 +      show "openin (top_of_set (affine hull C)) C"
   15.37 +        by (metis \<open>a \<in> C\<close> \<open>openin (top_of_set U) C\<close> affine_hull_eq affine_hull_openin all_not_in_conv \<open>affine U\<close>)
   15.38        show "ball a d \<inter> U \<noteq> {}"
   15.39          using \<open>0 < d\<close> \<open>C \<subseteq> U\<close> \<open>a \<in> C\<close> by force
   15.40        show "finite (C \<inter> K)"
   15.41 @@ -1323,13 +1323,14 @@
   15.42    obtain g where contg: "continuous_on (S \<union> UF) g"
   15.43               and gh: "\<And>x i. \<lbrakk>i \<in> F; x \<in> (S \<union> UF) \<inter> (S \<union> (i - {a i}))\<rbrakk>
   15.44                              \<Longrightarrow> g x = h i x"
   15.45 -  proof (rule pasting_lemma_exists_closed [OF \<open>finite F\<close>, of "S \<union> UF" "\<lambda>C. S \<union> (C - {a C})" h])
   15.46 -    show "S \<union> UF \<subseteq> (\<Union>C\<in>F. S \<union> (C - {a C}))"
   15.47 +  proof (rule pasting_lemma_exists_closed [OF \<open>finite F\<close>])
   15.48 +    let ?X = "top_of_set (S \<union> UF)"
   15.49 +    show "topspace ?X \<subseteq> (\<Union>C\<in>F. S \<union> (C - {a C}))"
   15.50        using \<open>C0 \<in> F\<close> by (force simp: UF_def)
   15.51 -    show "closedin (subtopology euclidean (S \<union> UF)) (S \<union> (C - {a C}))"
   15.52 +    show "closedin (top_of_set (S \<union> UF)) (S \<union> (C - {a C}))"
   15.53           if "C \<in> F" for C
   15.54      proof (rule closedin_closed_subset [of U "S \<union> C"])
   15.55 -      show "closedin (subtopology euclidean U) (S \<union> C)"
   15.56 +      show "closedin (top_of_set U) (S \<union> C)"
   15.57          apply (rule closedin_Un_complement_component [OF \<open>locally connected U\<close> clo])
   15.58          using F_def that by blast
   15.59      next
   15.60 @@ -1346,22 +1347,26 @@
   15.61        show "S \<union> (C - {a C}) = (S \<union> C) \<inter> (S \<union> UF)"
   15.62          using F_def UF_def components_nonoverlap that by auto
   15.63      qed
   15.64 -  next
   15.65 -    show "continuous_on (S \<union> (C' - {a C'})) (h C')" if "C' \<in> F" for C'
   15.66 -      using ah F_def that by blast
   15.67 +    show "continuous_map (subtopology ?X (S \<union> (C' - {a C'}))) euclidean (h C')" if "C' \<in> F" for C'
   15.68 +    proof -
   15.69 +      have C': "C' \<in> components (U - S)" "C' \<inter> K \<noteq> {}"
   15.70 +        using F_def that by blast+
   15.71 +      show ?thesis
   15.72 +        using ah [OF C'] by (auto simp: F_def subtopology_subtopology intro: continuous_on_subset)
   15.73 +    qed
   15.74      show "\<And>i j x. \<lbrakk>i \<in> F; j \<in> F;
   15.75 -                   x \<in> (S \<union> UF) \<inter> (S \<union> (i - {a i})) \<inter> (S \<union> (j - {a j}))\<rbrakk>
   15.76 +                   x \<in> topspace ?X \<inter> (S \<union> (i - {a i})) \<inter> (S \<union> (j - {a j}))\<rbrakk>
   15.77                    \<Longrightarrow> h i x = h j x"
   15.78        using components_eq by (fastforce simp: components_eq F_def ah)
   15.79 -  qed blast
   15.80 +  qed auto
   15.81    have SU': "S \<union> \<Union>G \<union> (S \<union> UF) \<subseteq> U"
   15.82      using \<open>S \<subseteq> U\<close> in_components_subset by (auto simp: F_def G_def UF_def)
   15.83 -  have clo1: "closedin (subtopology euclidean (S \<union> \<Union>G \<union> (S \<union> UF))) (S \<union> \<Union>G)"
   15.84 +  have clo1: "closedin (top_of_set (S \<union> \<Union>G \<union> (S \<union> UF))) (S \<union> \<Union>G)"
   15.85    proof (rule closedin_closed_subset [OF _ SU'])
   15.86 -    have *: "\<And>C. C \<in> F \<Longrightarrow> openin (subtopology euclidean U) C"
   15.87 +    have *: "\<And>C. C \<in> F \<Longrightarrow> openin (top_of_set U) C"
   15.88        unfolding F_def
   15.89        by clarify (metis (no_types, lifting) \<open>locally connected U\<close> clo closedin_def locally_diff_closed openin_components_locally_connected openin_trans topspace_euclidean_subtopology)
   15.90 -    show "closedin (subtopology euclidean U) (U - UF)"
   15.91 +    show "closedin (top_of_set U) (U - UF)"
   15.92        unfolding UF_def
   15.93        by (force intro: openin_delete *)
   15.94      show "S \<union> \<Union>G = (U - UF) \<inter> (S \<union> \<Union>G \<union> (S \<union> UF))"
   15.95 @@ -1370,9 +1375,9 @@
   15.96         apply (metis DiffD1 UnionI Union_components)
   15.97        by (metis (no_types, lifting) IntI components_nonoverlap empty_iff)
   15.98    qed
   15.99 -  have clo2: "closedin (subtopology euclidean (S \<union> \<Union>G \<union> (S \<union> UF))) (S \<union> UF)"
  15.100 +  have clo2: "closedin (top_of_set (S \<union> \<Union>G \<union> (S \<union> UF))) (S \<union> UF)"
  15.101    proof (rule closedin_closed_subset [OF _ SU'])
  15.102 -    show "closedin (subtopology euclidean U) (\<Union>C\<in>F. S \<union> C)"
  15.103 +    show "closedin (top_of_set U) (\<Union>C\<in>F. S \<union> C)"
  15.104        apply (rule closedin_Union)
  15.105         apply (simp add: \<open>finite F\<close>)
  15.106        using F_def \<open>locally connected U\<close> clo closedin_Un_complement_component by blast
  15.107 @@ -1467,7 +1472,7 @@
  15.108               and him: "h ` (T - \<xi> ` K) \<subseteq> rel_frontier U"
  15.109               and hg: "\<And>x. x \<in> S \<Longrightarrow> h x = g x"
  15.110    proof (rule extend_map_affine_to_sphere1 [OF \<open>finite K\<close> \<open>affine T\<close> contg gim, of S "\<xi> ` K"])
  15.111 -    show cloTS: "closedin (subtopology euclidean T) S"
  15.112 +    show cloTS: "closedin (top_of_set T) S"
  15.113        by (simp add: \<open>compact S\<close> \<open>S \<subseteq> T\<close> closed_subset compact_imp_closed)
  15.114      show "\<And>C. \<lbrakk>C \<in> components (T - S); C \<inter> K \<noteq> {}\<rbrakk> \<Longrightarrow> C \<inter> \<xi> ` K \<noteq> {}"
  15.115        using \<xi> components_eq by blast
  15.116 @@ -2008,8 +2013,8 @@
  15.117    fixes f :: "'a \<Rightarrow> 'a::euclidean_space"
  15.118    assumes contf: "continuous_on U f" and injf: "inj_on f U" and fim: "f ` U \<subseteq> S"
  15.119        and "subspace S" and dimS: "dim S = DIM('b::euclidean_space)"
  15.120 -      and ope: "openin (subtopology euclidean S) U"
  15.121 -    shows "openin (subtopology euclidean S) (f ` U)"
  15.122 +      and ope: "openin (top_of_set S) U"
  15.123 +    shows "openin (top_of_set S) (f ` U)"
  15.124  proof -
  15.125    have "U \<subseteq> S"
  15.126      using ope openin_imp_subset by blast
  15.127 @@ -2033,7 +2038,7 @@
  15.128          apply (rule continuous_on_subset [OF homeomorphism_cont2 [OF homhk]])
  15.129          using fim homhk homeomorphism_apply2 ope openin_subset by fastforce
  15.130      qed
  15.131 -    have ope_iff: "\<And>T. open T \<longleftrightarrow> openin (subtopology euclidean (k ` S)) T"
  15.132 +    have ope_iff: "\<And>T. open T \<longleftrightarrow> openin (top_of_set (k ` S)) T"
  15.133        using homhk homeomorphism_image2 open_openin by fastforce
  15.134      show "open (k ` U)"
  15.135        by (simp add: ope_iff homeomorphism_imp_open_map [OF homkh ope])
  15.136 @@ -2053,14 +2058,14 @@
  15.137    fixes f :: "'a \<Rightarrow> 'a::euclidean_space"
  15.138    assumes contf: "continuous_on U f" and injf: "inj_on f U" and fim: "f ` U \<subseteq> S"
  15.139        and "subspace S"
  15.140 -      and ope: "openin (subtopology euclidean S) U"
  15.141 -    shows "openin (subtopology euclidean S) (f ` U)"
  15.142 +      and ope: "openin (top_of_set S) U"
  15.143 +    shows "openin (top_of_set S) (f ` U)"
  15.144  proof -
  15.145    define S' where "S' \<equiv> {y. \<forall>x \<in> S. orthogonal x y}"
  15.146    have "subspace S'"
  15.147      by (simp add: S'_def subspace_orthogonal_to_vectors)
  15.148    define g where "g \<equiv> \<lambda>z::'a*'a. ((f \<circ> fst)z, snd z)"
  15.149 -  have "openin (subtopology euclidean (S \<times> S')) (g ` (U \<times> S'))"
  15.150 +  have "openin (top_of_set (S \<times> S')) (g ` (U \<times> S'))"
  15.151    proof (rule inv_of_domain_ss0)
  15.152      show "continuous_on (U \<times> S') g"
  15.153        apply (simp add: g_def)
  15.154 @@ -2072,7 +2077,7 @@
  15.155        using injf by (auto simp: g_def inj_on_def)
  15.156      show "subspace (S \<times> S')"
  15.157        by (simp add: \<open>subspace S'\<close> \<open>subspace S\<close> subspace_Times)
  15.158 -    show "openin (subtopology euclidean (S \<times> S')) (U \<times> S')"
  15.159 +    show "openin (top_of_set (S \<times> S')) (U \<times> S')"
  15.160        by (simp add: openin_Times [OF ope])
  15.161      have "dim (S \<times> S') = dim S + dim S'"
  15.162        by (simp add: \<open>subspace S'\<close> \<open>subspace S\<close> dim_Times)
  15.163 @@ -2092,11 +2097,11 @@
  15.164  
  15.165  corollary invariance_of_domain_subspaces:
  15.166    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  15.167 -  assumes ope: "openin (subtopology euclidean U) S"
  15.168 +  assumes ope: "openin (top_of_set U) S"
  15.169        and "subspace U" "subspace V" and VU: "dim V \<le> dim U"
  15.170        and contf: "continuous_on S f" and fim: "f ` S \<subseteq> V"
  15.171        and injf: "inj_on f S"
  15.172 -    shows "openin (subtopology euclidean V) (f ` S)"
  15.173 +    shows "openin (top_of_set V) (f ` S)"
  15.174  proof -
  15.175    obtain V' where "subspace V'" "V' \<subseteq> U" "dim V' = dim V"
  15.176      using choose_subspace_of_subspace [OF VU]
  15.177 @@ -2119,7 +2124,7 @@
  15.178        by (simp add: homeomorphism_symD homhk)
  15.179      have hfV': "(h \<circ> f) ` S \<subseteq> V'"
  15.180        using fim homeomorphism_image1 homhk by fastforce
  15.181 -    moreover have "openin (subtopology euclidean U) ((h \<circ> f) ` S)"
  15.182 +    moreover have "openin (top_of_set U) ((h \<circ> f) ` S)"
  15.183      proof (rule inv_of_domain_ss1)
  15.184        show "continuous_on S (h \<circ> f)"
  15.185          by (meson contf continuous_on_compose continuous_on_subset fim homeomorphism_cont1 homhk)
  15.186 @@ -2129,14 +2134,14 @@
  15.187        show "(h \<circ> f) ` S \<subseteq> U"
  15.188          using \<open>V' \<subseteq> U\<close> hfV' by auto
  15.189        qed (auto simp: assms)
  15.190 -    ultimately show "openin (subtopology euclidean V') ((h \<circ> f) ` S)"
  15.191 +    ultimately show "openin (top_of_set V') ((h \<circ> f) ` S)"
  15.192        using openin_subset_trans \<open>V' \<subseteq> U\<close> by force
  15.193    qed
  15.194  qed
  15.195  
  15.196  corollary invariance_of_dimension_subspaces:
  15.197    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  15.198 -  assumes ope: "openin (subtopology euclidean U) S"
  15.199 +  assumes ope: "openin (top_of_set U) S"
  15.200        and "subspace U" "subspace V"
  15.201        and contf: "continuous_on S f" and fim: "f ` S \<subseteq> V"
  15.202        and injf: "inj_on f S" and "S \<noteq> {}"
  15.203 @@ -2158,7 +2163,7 @@
  15.204      moreover have "inj_on (h \<circ> f) S"
  15.205        apply (clarsimp simp: inj_on_def)
  15.206        by (metis fim homeomorphism_apply1 homhk image_subset_iff inj_onD injf)
  15.207 -    ultimately have ope_hf: "openin (subtopology euclidean U) ((h \<circ> f) ` S)"
  15.208 +    ultimately have ope_hf: "openin (top_of_set U) ((h \<circ> f) ` S)"
  15.209        using invariance_of_domain_subspaces [OF ope \<open>subspace U\<close> \<open>subspace U\<close>] by blast
  15.210      have "(h \<circ> f) ` S \<subseteq> T"
  15.211        using fim homeomorphism_image1 homhk by fastforce
  15.212 @@ -2176,11 +2181,11 @@
  15.213  
  15.214  corollary invariance_of_domain_affine_sets:
  15.215    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  15.216 -  assumes ope: "openin (subtopology euclidean U) S"
  15.217 +  assumes ope: "openin (top_of_set U) S"
  15.218        and aff: "affine U" "affine V" "aff_dim V \<le> aff_dim U"
  15.219        and contf: "continuous_on S f" and fim: "f ` S \<subseteq> V"
  15.220        and injf: "inj_on f S"
  15.221 -    shows "openin (subtopology euclidean V) (f ` S)"
  15.222 +    shows "openin (top_of_set V) (f ` S)"
  15.223  proof (cases "S = {}")
  15.224    case True
  15.225    then show ?thesis by auto
  15.226 @@ -2188,9 +2193,9 @@
  15.227    case False
  15.228    obtain a b where "a \<in> S" "a \<in> U" "b \<in> V"
  15.229      using False fim ope openin_contains_cball by fastforce
  15.230 -  have "openin (subtopology euclidean ((+) (- b) ` V)) (((+) (- b) \<circ> f \<circ> (+) a) ` (+) (- a) ` S)"
  15.231 +  have "openin (top_of_set ((+) (- b) ` V)) (((+) (- b) \<circ> f \<circ> (+) a) ` (+) (- a) ` S)"
  15.232    proof (rule invariance_of_domain_subspaces)
  15.233 -    show "openin (subtopology euclidean ((+) (- a) ` U)) ((+) (- a) ` S)"
  15.234 +    show "openin (top_of_set ((+) (- a) ` U)) ((+) (- a) ` S)"
  15.235        by (metis ope homeomorphism_imp_open_map homeomorphism_translation translation_galois)
  15.236      show "subspace ((+) (- a) ` U)"
  15.237        by (simp add: \<open>a \<in> U\<close> affine_diffs_subspace_subtract \<open>affine U\<close> cong: image_cong_simp)
  15.238 @@ -2211,7 +2216,7 @@
  15.239  
  15.240  corollary invariance_of_dimension_affine_sets:
  15.241    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  15.242 -  assumes ope: "openin (subtopology euclidean U) S"
  15.243 +  assumes ope: "openin (top_of_set U) S"
  15.244        and aff: "affine U" "affine V"
  15.245        and contf: "continuous_on S f" and fim: "f ` S \<subseteq> V"
  15.246        and injf: "inj_on f S" and "S \<noteq> {}"
  15.247 @@ -2221,7 +2226,7 @@
  15.248      using \<open>S \<noteq> {}\<close> fim ope openin_contains_cball by fastforce
  15.249    have "dim ((+) (- a) ` U) \<le> dim ((+) (- b) ` V)"
  15.250    proof (rule invariance_of_dimension_subspaces)
  15.251 -    show "openin (subtopology euclidean ((+) (- a) ` U)) ((+) (- a) ` S)"
  15.252 +    show "openin (top_of_set ((+) (- a) ` U)) ((+) (- a) ` S)"
  15.253        by (metis ope homeomorphism_imp_open_map homeomorphism_translation translation_galois)
  15.254      show "subspace ((+) (- a) ` U)"
  15.255        by (simp add: \<open>a \<in> U\<close> affine_diffs_subspace_subtract \<open>affine U\<close> cong: image_cong_simp)
  15.256 @@ -2269,7 +2274,7 @@
  15.257    case False
  15.258    have "aff_dim (affine hull S) \<le> aff_dim (affine hull T)"
  15.259    proof (rule invariance_of_dimension_affine_sets)
  15.260 -    show "openin (subtopology euclidean (affine hull S)) (rel_interior S)"
  15.261 +    show "openin (top_of_set (affine hull S)) (rel_interior S)"
  15.262        by (simp add: openin_rel_interior)
  15.263      show "continuous_on (rel_interior S) f"
  15.264        using contf continuous_on_subset rel_interior_subset by blast
  15.265 @@ -2335,7 +2340,7 @@
  15.266    assume "open T"
  15.267    have eq: "f ` S \<inter> g -` T = f ` (S \<inter> T)"
  15.268      by (auto simp: gf)
  15.269 -  show "openin (subtopology euclidean (f ` S)) (f ` S \<inter> g -` T)"
  15.270 +  show "openin (top_of_set (f ` S)) (f ` S \<inter> g -` T)"
  15.271      apply (subst eq)
  15.272      apply (rule open_openin_trans)
  15.273        apply (rule invariance_of_domain_gen)
  15.274 @@ -2530,9 +2535,9 @@
  15.275  proof (rule rel_interior_maximal)
  15.276    show "f ` rel_interior S \<subseteq> f ` S"
  15.277      by(simp add: image_mono rel_interior_subset)
  15.278 -  show "openin (subtopology euclidean (affine hull f ` S)) (f ` rel_interior S)"
  15.279 +  show "openin (top_of_set (affine hull f ` S)) (f ` rel_interior S)"
  15.280    proof (rule invariance_of_domain_affine_sets)
  15.281 -    show "openin (subtopology euclidean (affine hull S)) (rel_interior S)"
  15.282 +    show "openin (top_of_set (affine hull S)) (rel_interior S)"
  15.283        by (simp add: openin_rel_interior)
  15.284      show "aff_dim (affine hull f ` S) \<le> aff_dim (affine hull S)"
  15.285        by (metis aff_dim_affine_hull aff_dim_subset fim TS order_trans)
  15.286 @@ -2826,8 +2831,8 @@
  15.287    assumes contf: "continuous_on S f" and injf: "inj_on f S" and fim: "f ` S \<subseteq> T"
  15.288        and U: "bounded U" "convex U"
  15.289        and "affine T" and affTU: "aff_dim T < aff_dim U"
  15.290 -      and ope: "openin (subtopology euclidean (rel_frontier U)) S"
  15.291 -   shows "openin (subtopology euclidean T) (f ` S)"
  15.292 +      and ope: "openin (top_of_set (rel_frontier U)) S"
  15.293 +   shows "openin (top_of_set T) (f ` S)"
  15.294  proof (cases "rel_frontier U = {}")
  15.295    case True
  15.296    then show ?thesis
  15.297 @@ -2857,9 +2862,9 @@
  15.298      by (simp_all add: homeomorphism_def subset_eq)
  15.299    have [simp]: "aff_dim T \<le> aff_dim V"
  15.300      by (simp add: affTU affV)
  15.301 -  have "openin (subtopology euclidean T) ((f \<circ> h) ` g ` (S - {b}))"
  15.302 +  have "openin (top_of_set T) ((f \<circ> h) ` g ` (S - {b}))"
  15.303    proof (rule invariance_of_domain_affine_sets [OF _ \<open>affine V\<close>])
  15.304 -    show "openin (subtopology euclidean V) (g ` (S - {b}))"
  15.305 +    show "openin (top_of_set V) (g ` (S - {b}))"
  15.306        apply (rule homeomorphism_imp_open_map [OF gh])
  15.307        by (meson Diff_mono Diff_subset SU ope openin_delete openin_subset_trans order_refl)
  15.308      show "continuous_on (g ` (S - {b})) (f \<circ> h)"
  15.309 @@ -2874,9 +2879,9 @@
  15.310        by (metis fim image_comp image_mono hgsub subset_trans)
  15.311    qed (auto simp: assms)
  15.312    moreover
  15.313 -  have "openin (subtopology euclidean T) ((f \<circ> k) ` j ` (S - {c}))"
  15.314 +  have "openin (top_of_set T) ((f \<circ> k) ` j ` (S - {c}))"
  15.315    proof (rule invariance_of_domain_affine_sets [OF _ \<open>affine V\<close>])
  15.316 -    show "openin (subtopology euclidean V) (j ` (S - {c}))"
  15.317 +    show "openin (top_of_set V) (j ` (S - {c}))"
  15.318        apply (rule homeomorphism_imp_open_map [OF jk])
  15.319        by (meson Diff_mono Diff_subset SU ope openin_delete openin_subset_trans order_refl)
  15.320      show "continuous_on (j ` (S - {c})) (f \<circ> k)"
  15.321 @@ -2890,7 +2895,7 @@
  15.322      show "(f \<circ> k) ` j ` (S - {c}) \<subseteq> T"
  15.323        by (metis fim image_comp image_mono kjsub subset_trans)
  15.324    qed (auto simp: assms)
  15.325 -  ultimately have "openin (subtopology euclidean T) ((f \<circ> h) ` g ` (S - {b}) \<union> ((f \<circ> k) ` j ` (S - {c})))"
  15.326 +  ultimately have "openin (top_of_set T) ((f \<circ> h) ` g ` (S - {b}) \<union> ((f \<circ> k) ` j ` (S - {c})))"
  15.327      by (rule openin_Un)
  15.328    moreover have "(f \<circ> h) ` g ` (S - {b}) = f ` (S - {b})"
  15.329    proof -
  15.330 @@ -2931,8 +2936,8 @@
  15.331    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  15.332    assumes contf: "continuous_on S f" and injf: "inj_on f S" and fim: "f ` S \<subseteq> T"
  15.333        and "r \<noteq> 0" "affine T" and affTU: "aff_dim T < DIM('a)"
  15.334 -      and ope: "openin (subtopology euclidean (sphere a r)) S"
  15.335 -   shows "openin (subtopology euclidean T) (f ` S)"
  15.336 +      and ope: "openin (top_of_set (sphere a r)) S"
  15.337 +   shows "openin (top_of_set T) (f ` S)"
  15.338  proof (cases "sphere a r = {}")
  15.339    case True
  15.340    then show ?thesis
  15.341 @@ -2943,7 +2948,7 @@
  15.342    proof (rule invariance_of_domain_sphere_affine_set_gen [OF contf injf fim bounded_cball convex_cball \<open>affine T\<close>])
  15.343      show "aff_dim T < aff_dim (cball a r)"
  15.344        by (metis False affTU aff_dim_cball assms(4) linorder_cases sphere_empty)
  15.345 -    show "openin (subtopology euclidean (rel_frontier (cball a r))) S"
  15.346 +    show "openin (top_of_set (rel_frontier (cball a r))) S"
  15.347        by (simp add: \<open>r \<noteq> 0\<close> ope)
  15.348    qed
  15.349  qed
  15.350 @@ -3379,7 +3384,7 @@
  15.351      by (rule continuous_on_exp [OF continuous_on_id])
  15.352    show "range exp = - {0::complex}"
  15.353      by auto (metis exp_Ln range_eqI)
  15.354 -  show "\<exists>T. z \<in> T \<and> openin (subtopology euclidean (- {0})) T \<and>
  15.355 +  show "\<exists>T. z \<in> T \<and> openin (top_of_set (- {0})) T \<and>
  15.356               (\<exists>v. \<Union>v = exp -` T \<and> (\<forall>u\<in>v. open u) \<and> disjoint v \<and>
  15.357                    (\<forall>u\<in>v. \<exists>q. homeomorphism u T exp q))"
  15.358          if "z \<in> - {0::complex}" for z
  15.359 @@ -3399,7 +3404,7 @@
  15.360        moreover have "inj_on exp (ball (Ln z) 1)"
  15.361          apply (rule inj_on_subset [OF inj_on_exp_pi [of "Ln z"]])
  15.362          using pi_ge_two by (simp add: ball_subset_ball_iff)
  15.363 -      ultimately show "openin (subtopology euclidean (- {0})) (exp ` ball (Ln z) 1)"
  15.364 +      ultimately show "openin (top_of_set (- {0})) (exp ` ball (Ln z) 1)"
  15.365          by (auto simp: openin_open_eq invariance_of_domain continuous_on_exp [OF continuous_on_id])
  15.366        show "\<Union>\<V> = exp -` exp ` ball (Ln z) 1"
  15.367          by (force simp: \<V>_def Complex_Transcendental.exp_eq image_iff)
  15.368 @@ -3647,150 +3652,150 @@
  15.369  text\<open>Many similar proofs below.\<close>
  15.370  lemma upper_hemicontinuous:
  15.371    assumes "\<And>x. x \<in> S \<Longrightarrow> f x \<subseteq> T"
  15.372 -    shows "((\<forall>U. openin (subtopology euclidean T) U
  15.373 -                 \<longrightarrow> openin (subtopology euclidean S) {x \<in> S. f x \<subseteq> U}) \<longleftrightarrow>
  15.374 -            (\<forall>U. closedin (subtopology euclidean T) U
  15.375 -                 \<longrightarrow> closedin (subtopology euclidean S) {x \<in> S. f x \<inter> U \<noteq> {}}))"
  15.376 +    shows "((\<forall>U. openin (top_of_set T) U
  15.377 +                 \<longrightarrow> openin (top_of_set S) {x \<in> S. f x \<subseteq> U}) \<longleftrightarrow>
  15.378 +            (\<forall>U. closedin (top_of_set T) U
  15.379 +                 \<longrightarrow> closedin (top_of_set S) {x \<in> S. f x \<inter> U \<noteq> {}}))"
  15.380            (is "?lhs = ?rhs")
  15.381  proof (intro iffI allI impI)
  15.382    fix U
  15.383 -  assume * [rule_format]: ?lhs and "closedin (subtopology euclidean T) U"
  15.384 -  then have "openin (subtopology euclidean T) (T - U)"
  15.385 +  assume * [rule_format]: ?lhs and "closedin (top_of_set T) U"
  15.386 +  then have "openin (top_of_set T) (T - U)"
  15.387      by (simp add: openin_diff)
  15.388 -  then have "openin (subtopology euclidean S) {x \<in> S. f x \<subseteq> T - U}"
  15.389 +  then have "openin (top_of_set S) {x \<in> S. f x \<subseteq> T - U}"
  15.390      using * [of "T-U"] by blast
  15.391    moreover have "S - {x \<in> S. f x \<subseteq> T - U} = {x \<in> S. f x \<inter> U \<noteq> {}}"
  15.392      using assms by blast
  15.393 -  ultimately show "closedin (subtopology euclidean S) {x \<in> S. f x \<inter> U \<noteq> {}}"
  15.394 +  ultimately show "closedin (top_of_set S) {x \<in> S. f x \<inter> U \<noteq> {}}"
  15.395      by (simp add: openin_closedin_eq)
  15.396  next
  15.397    fix U
  15.398 -  assume * [rule_format]: ?rhs and "openin (subtopology euclidean T) U"
  15.399 -  then have "closedin (subtopology euclidean T) (T - U)"
  15.400 +  assume * [rule_format]: ?rhs and "openin (top_of_set T) U"
  15.401 +  then have "closedin (top_of_set T) (T - U)"
  15.402      by (simp add: closedin_diff)
  15.403 -  then have "closedin (subtopology euclidean S) {x \<in> S. f x \<inter> (T - U) \<noteq> {}}"
  15.404 +  then have "closedin (top_of_set S) {x \<in> S. f x \<inter> (T - U) \<noteq> {}}"
  15.405      using * [of "T-U"] by blast
  15.406    moreover have "{x \<in> S. f x \<inter> (T - U) \<noteq> {}} = S - {x \<in> S. f x \<subseteq> U}"
  15.407      using assms by auto
  15.408 -  ultimately show "openin (subtopology euclidean S) {x \<in> S. f x \<subseteq> U}"
  15.409 +  ultimately show "openin (top_of_set S) {x \<in> S. f x \<subseteq> U}"
  15.410      by (simp add: openin_closedin_eq)
  15.411  qed
  15.412  
  15.413  lemma lower_hemicontinuous:
  15.414    assumes "\<And>x. x \<in> S \<Longrightarrow> f x \<subseteq> T"
  15.415 -    shows "((\<forall>U. closedin (subtopology euclidean T) U
  15.416 -                 \<longrightarrow> closedin (subtopology euclidean S) {x \<in> S. f x \<subseteq> U}) \<longleftrightarrow>
  15.417 -            (\<forall>U. openin (subtopology euclidean T) U
  15.418 -                 \<longrightarrow> openin (subtopology euclidean S) {x \<in> S. f x \<inter> U \<noteq> {}}))"
  15.419 +    shows "((\<forall>U. closedin (top_of_set T) U
  15.420 +                 \<longrightarrow> closedin (top_of_set S) {x \<in> S. f x \<subseteq> U}) \<longleftrightarrow>
  15.421 +            (\<forall>U. openin (top_of_set T) U
  15.422 +                 \<longrightarrow> openin (top_of_set S) {x \<in> S. f x \<inter> U \<noteq> {}}))"
  15.423            (is "?lhs = ?rhs")
  15.424  proof (intro iffI allI impI)
  15.425    fix U
  15.426 -  assume * [rule_format]: ?lhs and "openin (subtopology euclidean T) U"
  15.427 -  then have "closedin (subtopology euclidean T) (T - U)"
  15.428 +  assume * [rule_format]: ?lhs and "openin (top_of_set T) U"
  15.429 +  then have "closedin (top_of_set T) (T - U)"
  15.430      by (simp add: closedin_diff)
  15.431 -  then have "closedin (subtopology euclidean S) {x \<in> S. f x \<subseteq> T-U}"
  15.432 +  then have "closedin (top_of_set S) {x \<in> S. f x \<subseteq> T-U}"
  15.433      using * [of "T-U"] by blast
  15.434    moreover have "{x \<in> S. f x \<subseteq> T-U} = S - {x \<in> S. f x \<inter> U \<noteq> {}}"
  15.435      using assms by auto
  15.436 -  ultimately show "openin (subtopology euclidean S) {x \<in> S. f x \<inter> U \<noteq> {}}"
  15.437 +  ultimately show "openin (top_of_set S) {x \<in> S. f x \<inter> U \<noteq> {}}"
  15.438      by (simp add: openin_closedin_eq)
  15.439  next
  15.440    fix U
  15.441 -  assume * [rule_format]: ?rhs and "closedin (subtopology euclidean T) U"
  15.442 -  then have "openin (subtopology euclidean T) (T - U)"
  15.443 +  assume * [rule_format]: ?rhs and "closedin (top_of_set T) U"
  15.444 +  then have "openin (top_of_set T) (T - U)"
  15.445      by (simp add: openin_diff)
  15.446 -  then have "openin (subtopology euclidean S) {x \<in> S. f x \<inter> (T - U) \<noteq> {}}"
  15.447 +  then have "openin (top_of_set S) {x \<in> S. f x \<inter> (T - U) \<noteq> {}}"
  15.448      using * [of "T-U"] by blast
  15.449    moreover have "S - {x \<in> S. f x \<inter> (T - U) \<noteq> {}} = {x \<in> S. f x \<subseteq> U}"
  15.450      using assms by blast
  15.451 -  ultimately show "closedin (subtopology euclidean S) {x \<in> S. f x \<subseteq> U}"
  15.452 +  ultimately show "closedin (top_of_set S) {x \<in> S. f x \<subseteq> U}"
  15.453      by (simp add: openin_closedin_eq)
  15.454  qed
  15.455  
  15.456  lemma open_map_iff_lower_hemicontinuous_preimage:
  15.457    assumes "f ` S \<subseteq> T"
  15.458 -    shows "((\<forall>U. openin (subtopology euclidean S) U
  15.459 -                 \<longrightarrow> openin (subtopology euclidean T) (f ` U)) \<longleftrightarrow>
  15.460 -            (\<forall>U. closedin (subtopology euclidean S) U
  15.461 -                 \<longrightarrow> closedin (subtopology euclidean T) {y \<in> T. {x. x \<in> S \<and> f x = y} \<subseteq> U}))"
  15.462 +    shows "((\<forall>U. openin (top_of_set S) U
  15.463 +                 \<longrightarrow> openin (top_of_set T) (f ` U)) \<longleftrightarrow>
  15.464 +            (\<forall>U. closedin (top_of_set S) U
  15.465 +                 \<longrightarrow> closedin (top_of_set T) {y \<in> T. {x. x \<in> S \<and> f x = y} \<subseteq> U}))"
  15.466            (is "?lhs = ?rhs")
  15.467  proof (intro iffI allI impI)
  15.468    fix U
  15.469 -  assume * [rule_format]: ?lhs and "closedin (subtopology euclidean S) U"
  15.470 -  then have "openin (subtopology euclidean S) (S - U)"
  15.471 +  assume * [rule_format]: ?lhs and "closedin (top_of_set S) U"
  15.472 +  then have "openin (top_of_set S) (S - U)"
  15.473      by (simp add: openin_diff)
  15.474 -  then have "openin (subtopology euclidean T) (f ` (S - U))"
  15.475 +  then have "openin (top_of_set T) (f ` (S - U))"
  15.476      using * [of "S-U"] by blast
  15.477    moreover have "T - (f ` (S - U)) = {y \<in> T. {x \<in> S. f x = y} \<subseteq> U}"
  15.478      using assms by blast
  15.479 -  ultimately show "closedin (subtopology euclidean T) {y \<in> T. {x \<in> S. f x = y} \<subseteq> U}"
  15.480 +  ultimately show "closedin (top_of_set T) {y \<in> T. {x \<in> S. f x = y} \<subseteq> U}"
  15.481      by (simp add: openin_closedin_eq)
  15.482  next
  15.483    fix U
  15.484 -  assume * [rule_format]: ?rhs and opeSU: "openin (subtopology euclidean S) U"
  15.485 -  then have "closedin (subtopology euclidean S) (S - U)"
  15.486 +  assume * [rule_format]: ?rhs and opeSU: "openin (top_of_set S) U"
  15.487 +  then have "closedin (top_of_set S) (S - U)"
  15.488      by (simp add: closedin_diff)
  15.489 -  then have "closedin (subtopology euclidean T) {y \<in> T. {x \<in> S. f x = y} \<subseteq> S - U}"
  15.490 +  then have "closedin (top_of_set T) {y \<in> T. {x \<in> S. f x = y} \<subseteq> S - U}"
  15.491      using * [of "S-U"] by blast
  15.492    moreover have "{y \<in> T. {x \<in> S. f x = y} \<subseteq> S - U} = T - (f ` U)"
  15.493      using assms openin_imp_subset [OF opeSU] by auto
  15.494 -  ultimately show "openin (subtopology euclidean T) (f ` U)"
  15.495 +  ultimately show "openin (top_of_set T) (f ` U)"
  15.496      using assms openin_imp_subset [OF opeSU] by (force simp: openin_closedin_eq)
  15.497  qed
  15.498  
  15.499  lemma closed_map_iff_upper_hemicontinuous_preimage:
  15.500    assumes "f ` S \<subseteq> T"
  15.501 -    shows "((\<forall>U. closedin (subtopology euclidean S) U
  15.502 -                 \<longrightarrow> closedin (subtopology euclidean T) (f ` U)) \<longleftrightarrow>
  15.503 -            (\<forall>U. openin (subtopology euclidean S) U
  15.504 -                 \<longrightarrow> openin (subtopology euclidean T) {y \<in> T. {x. x \<in> S \<and> f x = y} \<subseteq> U}))"
  15.505 +    shows "((\<forall>U. closedin (top_of_set S) U
  15.506 +                 \<longrightarrow> closedin (top_of_set T) (f ` U)) \<longleftrightarrow>
  15.507 +            (\<forall>U. openin (top_of_set S) U
  15.508 +                 \<longrightarrow> openin (top_of_set T) {y \<in> T. {x. x \<in> S \<and> f x = y} \<subseteq> U}))"
  15.509            (is "?lhs = ?rhs")
  15.510  proof (intro iffI allI impI)
  15.511    fix U
  15.512 -  assume * [rule_format]: ?lhs and opeSU: "openin (subtopology euclidean S) U"
  15.513 -  then have "closedin (subtopology euclidean S) (S - U)"
  15.514 +  assume * [rule_format]: ?lhs and opeSU: "openin (top_of_set S) U"
  15.515 +  then have "closedin (top_of_set S) (S - U)"
  15.516      by (simp add: closedin_diff)
  15.517 -  then have "closedin (subtopology euclidean T) (f ` (S - U))"
  15.518 +  then have "closedin (top_of_set T) (f ` (S - U))"
  15.519      using * [of "S-U"] by blast
  15.520    moreover have "f ` (S - U) = T -  {y \<in> T. {x. x \<in> S \<and> f x = y} \<subseteq> U}"
  15.521      using assms openin_imp_subset [OF opeSU] by auto
  15.522 -  ultimately show "openin (subtopology euclidean T)  {y \<in> T. {x. x \<in> S \<and> f x = y} \<subseteq> U}"
  15.523 +  ultimately show "openin (top_of_set T)  {y \<in> T. {x. x \<in> S \<and> f x = y} \<subseteq> U}"
  15.524      using assms openin_imp_subset [OF opeSU] by (force simp: openin_closedin_eq)
  15.525  next
  15.526    fix U
  15.527 -  assume * [rule_format]: ?rhs and cloSU: "closedin (subtopology euclidean S) U"
  15.528 -  then have "openin (subtopology euclidean S) (S - U)"
  15.529 +  assume * [rule_format]: ?rhs and cloSU: "closedin (top_of_set S) U"
  15.530 +  then have "openin (top_of_set S) (S - U)"
  15.531      by (simp add: openin_diff)
  15.532 -  then have "openin (subtopology euclidean T) {y \<in> T. {x \<in> S. f x = y} \<subseteq> S - U}"
  15.533 +  then have "openin (top_of_set T) {y \<in> T. {x \<in> S. f x = y} \<subseteq> S - U}"
  15.534      using * [of "S-U"] by blast
  15.535    moreover have "(f ` U) = T - {y \<in> T. {x \<in> S. f x = y} \<subseteq> S - U}"
  15.536      using assms closedin_imp_subset [OF cloSU]  by auto
  15.537 -  ultimately show "closedin (subtopology euclidean T) (f ` U)"
  15.538 +  ultimately show "closedin (top_of_set T) (f ` U)"
  15.539      by (simp add: openin_closedin_eq)
  15.540  qed
  15.541  
  15.542  proposition upper_lower_hemicontinuous_explicit:
  15.543    fixes T :: "('b::{real_normed_vector,heine_borel}) set"
  15.544    assumes fST: "\<And>x. x \<in> S \<Longrightarrow> f x \<subseteq> T"
  15.545 -      and ope: "\<And>U. openin (subtopology euclidean T) U
  15.546 -                     \<Longrightarrow> openin (subtopology euclidean S) {x \<in> S. f x \<subseteq> U}"
  15.547 -      and clo: "\<And>U. closedin (subtopology euclidean T) U
  15.548 -                     \<Longrightarrow> closedin (subtopology euclidean S) {x \<in> S. f x \<subseteq> U}"
  15.549 +      and ope: "\<And>U. openin (top_of_set T) U
  15.550 +                     \<Longrightarrow> openin (top_of_set S) {x \<in> S. f x \<subseteq> U}"
  15.551 +      and clo: "\<And>U. closedin (top_of_set T) U
  15.552 +                     \<Longrightarrow> closedin (top_of_set S) {x \<in> S. f x \<subseteq> U}"
  15.553        and "x \<in> S" "0 < e" and bofx: "bounded(f x)" and fx_ne: "f x \<noteq> {}"
  15.554    obtains d where "0 < d"
  15.555               "\<And>x'. \<lbrakk>x' \<in> S; dist x x' < d\<rbrakk>
  15.556                             \<Longrightarrow> (\<forall>y \<in> f x. \<exists>y'. y' \<in> f x' \<and> dist y y' < e) \<and>
  15.557                                 (\<forall>y' \<in> f x'. \<exists>y. y \<in> f x \<and> dist y' y < e)"
  15.558  proof -
  15.559 -  have "openin (subtopology euclidean T) (T \<inter> (\<Union>a\<in>f x. \<Union>b\<in>ball 0 e. {a + b}))"
  15.560 +  have "openin (top_of_set T) (T \<inter> (\<Union>a\<in>f x. \<Union>b\<in>ball 0 e. {a + b}))"
  15.561      by (auto simp: open_sums openin_open_Int)
  15.562 -  with ope have "openin (subtopology euclidean S)
  15.563 +  with ope have "openin (top_of_set S)
  15.564                      {u \<in> S. f u \<subseteq> T \<inter> (\<Union>a\<in>f x. \<Union>b\<in>ball 0 e. {a + b})}" by blast
  15.565    with \<open>0 < e\<close> \<open>x \<in> S\<close> obtain d1 where "d1 > 0" and
  15.566           d1: "\<And>x'. \<lbrakk>x' \<in> S; dist x' x < d1\<rbrakk> \<Longrightarrow> f x' \<subseteq> T \<and> f x' \<subseteq> (\<Union>a \<in> f x. \<Union>b \<in> ball 0 e. {a + b})"
  15.567      by (force simp: openin_euclidean_subtopology_iff dest: fST)
  15.568 -  have oo: "\<And>U. openin (subtopology euclidean T) U \<Longrightarrow>
  15.569 -                 openin (subtopology euclidean S) {x \<in> S. f x \<inter> U \<noteq> {}}"
  15.570 +  have oo: "\<And>U. openin (top_of_set T) U \<Longrightarrow>
  15.571 +                 openin (top_of_set S) {x \<in> S. f x \<inter> U \<noteq> {}}"
  15.572      apply (rule lower_hemicontinuous [THEN iffD1, rule_format])
  15.573      using fST clo by auto
  15.574    have "compact (closure(f x))"
  15.575 @@ -3806,9 +3811,9 @@
  15.576      by blast
  15.577    have xin: "x \<in> (\<Inter>a \<in> C. {x \<in> S. f x \<inter> T \<inter> ball a (e/2) \<noteq> {}})"
  15.578      using \<open>x \<in> S\<close> \<open>0 < e\<close> fST \<open>C \<subseteq> f x\<close> by force
  15.579 -  have "openin (subtopology euclidean S) {x \<in> S. f x \<inter> (T \<inter> ball a (e/2)) \<noteq> {}}" for a
  15.580 +  have "openin (top_of_set S) {x \<in> S. f x \<inter> (T \<inter> ball a (e/2)) \<noteq> {}}" for a
  15.581      by (simp add: openin_open_Int oo)
  15.582 -  then have "openin (subtopology euclidean S) (\<Inter>a \<in> C. {x \<in> S. f x \<inter> T \<inter> ball a (e/2) \<noteq> {}})"
  15.583 +  then have "openin (top_of_set S) (\<Inter>a \<in> C. {x \<in> S. f x \<inter> T \<inter> ball a (e/2) \<noteq> {}})"
  15.584      by (simp add: Int_assoc openin_INT2 [OF \<open>finite C\<close> \<open>C \<noteq> {}\<close>])
  15.585    with xin obtain d2 where "d2>0"
  15.586                and d2: "\<And>u v. \<lbrakk>u \<in> S; dist u x < d2; v \<in> C\<rbrakk> \<Longrightarrow> f u \<inter> T \<inter> ball v (e/2) \<noteq> {}"
  15.587 @@ -4375,8 +4380,8 @@
  15.588  
  15.589  proposition Borsukian_open_Un:
  15.590    fixes S :: "'a::real_normed_vector set"
  15.591 -  assumes opeS: "openin (subtopology euclidean (S \<union> T)) S"
  15.592 -      and opeT: "openin (subtopology euclidean (S \<union> T)) T"
  15.593 +  assumes opeS: "openin (top_of_set (S \<union> T)) S"
  15.594 +      and opeT: "openin (top_of_set (S \<union> T)) T"
  15.595        and BS: "Borsukian S" and BT: "Borsukian T" and ST: "connected(S \<inter> T)"
  15.596      shows "Borsukian(S \<union> T)"
  15.597  proof (clarsimp simp add: Borsukian_continuous_logarithm)
  15.598 @@ -4445,8 +4450,8 @@
  15.599  text\<open>The proof is a duplicate of that of \<open>Borsukian_open_Un\<close>.\<close>
  15.600  lemma Borsukian_closed_Un:
  15.601    fixes S :: "'a::real_normed_vector set"
  15.602 -  assumes cloS: "closedin (subtopology euclidean (S \<union> T)) S"
  15.603 -      and cloT: "closedin (subtopology euclidean (S \<union> T)) T"
  15.604 +  assumes cloS: "closedin (top_of_set (S \<union> T)) S"
  15.605 +      and cloT: "closedin (top_of_set (S \<union> T)) T"
  15.606        and BS: "Borsukian S" and BT: "Borsukian T" and ST: "connected(S \<inter> T)"
  15.607      shows "Borsukian(S \<union> T)"
  15.608  proof (clarsimp simp add: Borsukian_continuous_logarithm)
  15.609 @@ -4586,8 +4591,8 @@
  15.610  lemma Borsukian_open_map_image_compact:
  15.611    fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
  15.612    assumes "Borsukian S" and contf: "continuous_on S f" and fim: "f ` S = T" and "compact S"
  15.613 -      and ope: "\<And>U. openin (subtopology euclidean S) U
  15.614 -                     \<Longrightarrow> openin (subtopology euclidean T) (f ` U)"
  15.615 +      and ope: "\<And>U. openin (top_of_set S) U
  15.616 +                     \<Longrightarrow> openin (top_of_set T) (f ` U)"
  15.617      shows "Borsukian T"
  15.618  proof (clarsimp simp add: Borsukian_continuous_logarithm_circle_real)
  15.619    fix g :: "'b \<Rightarrow> complex"
  15.620 @@ -4636,12 +4641,12 @@
  15.621                 \<Longrightarrow> (\<forall>v \<in> {z \<in> S. f z = y}. \<exists>v'. v' \<in> {z \<in> S. f z = x'} \<and> dist v v' < d) \<and>
  15.622                     (\<forall>v' \<in> {z \<in> S. f z = x'}. \<exists>v. v \<in> {z \<in> S. f z = y} \<and> dist v' v < d)"
  15.623      proof (rule upper_lower_hemicontinuous_explicit [of T "\<lambda>y. {z \<in> S. f z = y}" S])
  15.624 -      show "\<And>U. openin (subtopology euclidean S) U
  15.625 -                 \<Longrightarrow> openin (subtopology euclidean T) {x \<in> T. {z \<in> S. f z = x} \<subseteq> U}"
  15.626 +      show "\<And>U. openin (top_of_set S) U
  15.627 +                 \<Longrightarrow> openin (top_of_set T) {x \<in> T. {z \<in> S. f z = x} \<subseteq> U}"
  15.628          using continuous_imp_closed_map closed_map_iff_upper_hemicontinuous_preimage [OF fim [THEN equalityD1]]
  15.629          by (simp add: continuous_imp_closed_map \<open>compact S\<close> contf fim)
  15.630 -      show "\<And>U. closedin (subtopology euclidean S) U \<Longrightarrow>
  15.631 -                 closedin (subtopology euclidean T) {x \<in> T. {z \<in> S. f z = x} \<subseteq> U}"
  15.632 +      show "\<And>U. closedin (top_of_set S) U \<Longrightarrow>
  15.633 +                 closedin (top_of_set T) {x \<in> T. {z \<in> S. f z = x} \<subseteq> U}"
  15.634          using  ope open_map_iff_lower_hemicontinuous_preimage [OF fim [THEN equalityD1]]
  15.635          by meson
  15.636        show "bounded {z \<in> S. f z = y}"
  15.637 @@ -4812,17 +4817,17 @@
  15.638  definition%important unicoherent where
  15.639    "unicoherent U \<equiv>
  15.640    \<forall>S T. connected S \<and> connected T \<and> S \<union> T = U \<and>
  15.641 -        closedin (subtopology euclidean U) S \<and> closedin (subtopology euclidean U) T
  15.642 +        closedin (top_of_set U) S \<and> closedin (top_of_set U) T
  15.643          \<longrightarrow> connected (S \<inter> T)"
  15.644  
  15.645  lemma unicoherentI [intro?]:
  15.646 -  assumes "\<And>S T. \<lbrakk>connected S; connected T; U = S \<union> T; closedin (subtopology euclidean U) S; closedin (subtopology euclidean U) T\<rbrakk>
  15.647 +  assumes "\<And>S T. \<lbrakk>connected S; connected T; U = S \<union> T; closedin (top_of_set U) S; closedin (top_of_set U) T\<rbrakk>
  15.648            \<Longrightarrow> connected (S \<inter> T)"
  15.649    shows "unicoherent U"
  15.650    using assms unfolding unicoherent_def by blast
  15.651  
  15.652  lemma unicoherentD:
  15.653 -  assumes "unicoherent U" "connected S" "connected T" "U = S \<union> T" "closedin (subtopology euclidean U) S" "closedin (subtopology euclidean U) T"
  15.654 +  assumes "unicoherent U" "connected S" "connected T" "U = S \<union> T" "closedin (top_of_set U) S" "closedin (top_of_set U) T"
  15.655    shows "connected (S \<inter> T)"
  15.656    using assms unfolding unicoherent_def by blast
  15.657  
  15.658 @@ -4837,8 +4842,8 @@
  15.659    proof
  15.660      fix U V
  15.661      assume "connected U" "connected V" and T: "T = U \<union> V"
  15.662 -      and cloU: "closedin (subtopology euclidean T) U"
  15.663 -      and cloV: "closedin (subtopology euclidean T) V"
  15.664 +      and cloU: "closedin (top_of_set T) U"
  15.665 +      and cloV: "closedin (top_of_set T) V"
  15.666      have "f ` (g ` U \<inter> g ` V) \<subseteq> U" "f ` (g ` U \<inter> g ` V) \<subseteq> V"
  15.667        using gf fim T by auto (metis UnCI image_iff)+
  15.668      moreover have "U \<inter> V \<subseteq> f ` (g ` U \<inter> g ` V)"
  15.669 @@ -4858,10 +4863,10 @@
  15.670            using T fim gfim by auto
  15.671          have hom: "homeomorphism T S g f"
  15.672            by (simp add: contf contg fim gf gfim homeomorphism_def)
  15.673 -        have "closedin (subtopology euclidean T) U" "closedin (subtopology euclidean T) V"
  15.674 +        have "closedin (top_of_set T) U" "closedin (top_of_set T) V"
  15.675            by (simp_all add: cloU cloV)
  15.676 -        then show "closedin (subtopology euclidean S) (g ` U)"
  15.677 -                  "closedin (subtopology euclidean S) (g ` V)"
  15.678 +        then show "closedin (top_of_set S) (g ` U)"
  15.679 +                  "closedin (top_of_set S) (g ` V)"
  15.680            by (blast intro: homeomorphism_imp_closed_map [OF hom])+
  15.681        qed
  15.682      qed
  15.683 @@ -4894,16 +4899,16 @@
  15.684  proof clarify
  15.685    fix S T
  15.686    assume "connected S" "connected T" "U = S \<union> T"
  15.687 -     and cloS: "closedin (subtopology euclidean (S \<union> T)) S"
  15.688 -     and cloT: "closedin (subtopology euclidean (S \<union> T)) T"
  15.689 +     and cloS: "closedin (top_of_set (S \<union> T)) S"
  15.690 +     and cloT: "closedin (top_of_set (S \<union> T)) T"
  15.691    show "connected (S \<inter> T)"
  15.692      unfolding connected_closedin_eq
  15.693    proof clarify
  15.694      fix V W
  15.695 -    assume "closedin (subtopology euclidean (S \<inter> T)) V"
  15.696 -       and "closedin (subtopology euclidean (S \<inter> T)) W"
  15.697 +    assume "closedin (top_of_set (S \<inter> T)) V"
  15.698 +       and "closedin (top_of_set (S \<inter> T)) W"
  15.699         and VW: "V \<union> W = S \<inter> T" "V \<inter> W = {}" and "V \<noteq> {}" "W \<noteq> {}"
  15.700 -    then have cloV: "closedin (subtopology euclidean U) V" and cloW: "closedin (subtopology euclidean U) W"
  15.701 +    then have cloV: "closedin (top_of_set U) V" and cloW: "closedin (top_of_set U) W"
  15.702        using \<open>U = S \<union> T\<close> cloS cloT closedin_trans by blast+
  15.703      obtain q where contq: "continuous_on U q"
  15.704           and q01: "\<And>x. x \<in> U \<Longrightarrow> q x \<in> {0..1::real}"
  15.705 @@ -5020,8 +5025,8 @@
  15.706  proof
  15.707    fix U V
  15.708    assume UV: "connected U" "connected V" "T = U \<union> V"
  15.709 -     and cloU: "closedin (subtopology euclidean T) U"
  15.710 -     and cloV: "closedin (subtopology euclidean T) V"
  15.711 +     and cloU: "closedin (top_of_set T) U"
  15.712 +     and cloV: "closedin (top_of_set T) V"
  15.713    moreover have "compact T"
  15.714      using \<open>compact S\<close> compact_continuous_image contf fim by blast
  15.715    ultimately have "closed U" "closed V"
  15.716 @@ -5035,14 +5040,14 @@
  15.717        by (meson contf continuous_on_subset inf_le1)
  15.718      show "connected ?SUV"
  15.719      proof (rule unicoherentD [OF \<open>unicoherent S\<close>, of "S \<inter> f -` U" "S \<inter> f -` V"])
  15.720 -      have "\<And>C. closedin (subtopology euclidean S) C \<Longrightarrow> closedin (subtopology euclidean T) (f ` C)"
  15.721 +      have "\<And>C. closedin (top_of_set S) C \<Longrightarrow> closedin (top_of_set T) (f ` C)"
  15.722          by (metis \<open>compact S\<close> closed_subset closedin_compact closedin_imp_subset compact_continuous_image compact_imp_closed contf continuous_on_subset fim image_mono)
  15.723        then show "connected (S \<inter> f -` U)" "connected (S \<inter> f -` V)"
  15.724          using UV by (auto simp: conn intro: connected_closed_monotone_preimage [OF contf fim])
  15.725        show "S = (S \<inter> f -` U) \<union> (S \<inter> f -` V)"
  15.726          using UV fim by blast
  15.727 -      show "closedin (subtopology euclidean S) (S \<inter> f -` U)"
  15.728 -            "closedin (subtopology euclidean S) (S \<inter> f -` V)"
  15.729 +      show "closedin (top_of_set S) (S \<inter> f -` U)"
  15.730 +            "closedin (top_of_set S) (S \<inter> f -` V)"
  15.731          by (auto simp: continuous_on_imp_closedin cloU cloV contf fim)
  15.732      qed
  15.733    qed
  15.734 @@ -5348,7 +5353,7 @@
  15.735      obtain g where contg: "continuous_on UNIV g" and gim: "g ` UNIV \<subseteq> -{0}"
  15.736                     and gf: "\<And>x. x \<in> S \<Longrightarrow> g x = f x"
  15.737      proof (rule Borsuk_homotopy_extension_homotopic [OF _ _ continuous_on_const _ homotopic_with_symD [OF a]])
  15.738 -      show "closedin (subtopology euclidean UNIV) S"
  15.739 +      show "closedin (top_of_set UNIV) S"
  15.740          using assms by auto
  15.741        show "range (\<lambda>t. a) \<subseteq> - {0}"
  15.742          using a homotopic_with_imp_subset2 False by blast
  15.743 @@ -5396,8 +5401,8 @@
  15.744  lemma inessential_on_clopen_Union:
  15.745    fixes \<F> :: "'a::euclidean_space set set"
  15.746    assumes T: "path_connected T"
  15.747 -      and "\<And>S. S \<in> \<F> \<Longrightarrow> closedin (subtopology euclidean (\<Union>\<F>)) S"
  15.748 -      and "\<And>S. S \<in> \<F> \<Longrightarrow> openin (subtopology euclidean (\<Union>\<F>)) S"
  15.749 +      and "\<And>S. S \<in> \<F> \<Longrightarrow> closedin (top_of_set (\<Union>\<F>)) S"
  15.750 +      and "\<And>S. S \<in> \<F> \<Longrightarrow> openin (top_of_set (\<Union>\<F>)) S"
  15.751        and hom: "\<And>S. S \<in> \<F> \<Longrightarrow> \<exists>a. homotopic_with (\<lambda>x. True) S T f (\<lambda>x. a)"
  15.752    obtains a where "homotopic_with (\<lambda>x. True) (\<Union>\<F>) T f (\<lambda>x. a)"
  15.753  proof (cases "\<Union>\<F> = {}")
  15.754 @@ -5408,16 +5413,16 @@
  15.755    case False
  15.756    then obtain C where "C \<in> \<F>" "C \<noteq> {}"
  15.757      by blast
  15.758 -  then obtain a where clo: "closedin (subtopology euclidean (\<Union>\<F>)) C"
  15.759 -    and ope: "openin (subtopology euclidean (\<Union>\<F>)) C"
  15.760 +  then obtain a where clo: "closedin (top_of_set (\<Union>\<F>)) C"
  15.761 +    and ope: "openin (top_of_set (\<Union>\<F>)) C"
  15.762      and "homotopic_with (\<lambda>x. True) C T f (\<lambda>x. a)"
  15.763      using assms by blast
  15.764    with \<open>C \<noteq> {}\<close> have "f ` C \<subseteq> T" "a \<in> T"
  15.765      using homotopic_with_imp_subset1 homotopic_with_imp_subset2 by blast+
  15.766    have "homotopic_with (\<lambda>x. True) (\<Union>\<F>) T f (\<lambda>x. a)"
  15.767    proof (rule homotopic_on_clopen_Union)
  15.768 -    show "\<And>S. S \<in> \<F> \<Longrightarrow> closedin (subtopology euclidean (\<Union>\<F>)) S"
  15.769 -         "\<And>S. S \<in> \<F> \<Longrightarrow> openin (subtopology euclidean (\<Union>\<F>)) S"
  15.770 +    show "\<And>S. S \<in> \<F> \<Longrightarrow> closedin (top_of_set (\<Union>\<F>)) S"
  15.771 +         "\<And>S. S \<in> \<F> \<Longrightarrow> openin (top_of_set (\<Union>\<F>)) S"
  15.772        by (simp_all add: assms)
  15.773      show "homotopic_with (\<lambda>x. True) S T f (\<lambda>x. a)" if "S \<in> \<F>" for S
  15.774      proof (cases "S = {}")
    16.1 --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy	Mon Mar 18 21:50:51 2019 +0100
    16.2 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy	Tue Mar 19 16:14:59 2019 +0000
    16.3 @@ -4415,9 +4415,9 @@
    16.4      then show "\<exists>e>0. ball x e \<subseteq> (S \<inter> f -` {f x})"
    16.5        using \<open>0 < e\<close> by blast
    16.6    qed
    16.7 -  then have "openin (subtopology euclidean S) (S \<inter> f -` {y})"
    16.8 +  then have "openin (top_of_set S) (S \<inter> f -` {y})"
    16.9      by (auto intro!: open_openin_trans[OF \<open>open S\<close>] simp: open_contains_ball)
   16.10 -  moreover have "closedin (subtopology euclidean S) (S \<inter> f -` {y})"
   16.11 +  moreover have "closedin (top_of_set S) (S \<inter> f -` {y})"
   16.12      by (force intro!: continuous_closedin_preimage [OF contf])
   16.13    ultimately have "(S \<inter> f -` {y}) = {} \<or> (S \<inter> f -` {y}) = S"
   16.14      using \<open>connected S\<close> by (simp add: connected_clopen)
    17.1 --- a/src/HOL/Analysis/Homeomorphism.thy	Mon Mar 18 21:50:51 2019 +0100
    17.2 +++ b/src/HOL/Analysis/Homeomorphism.thy	Tue Mar 19 16:14:59 2019 +0000
    17.3 @@ -916,7 +916,7 @@
    17.4    fixes S :: "'m::euclidean_space set"
    17.5    assumes "aff_dim S < DIM('n)"
    17.6    obtains U and T :: "'n::euclidean_space set"
    17.7 -     where "convex U" "U \<noteq> {}" "closedin (subtopology euclidean U) T"
    17.8 +     where "convex U" "U \<noteq> {}" "closedin (top_of_set U) T"
    17.9             "S homeomorphic T"
   17.10  proof (cases "S = {}")
   17.11    case True then show ?thesis
   17.12 @@ -1051,7 +1051,7 @@
   17.13  lemma locally_compact_closedin_open:
   17.14      fixes S :: "'a :: metric_space set"
   17.15      assumes "locally compact S"
   17.16 -    obtains T where "open T" "closedin (subtopology euclidean T) S"
   17.17 +    obtains T where "open T" "closedin (top_of_set T) S"
   17.18    by (metis locally_compact_open_Int_closure [OF assms] closed_closure closedin_closed_Int)
   17.19  
   17.20  
   17.21 @@ -1079,7 +1079,7 @@
   17.22        by (simp add: Ucomp setdist_eq_0_sing_1)
   17.23      then have homU: "homeomorphism U (f`U) f fst"
   17.24        by (auto simp: f_def homeomorphism_def image_iff continuous_intros)
   17.25 -    have cloS: "closedin (subtopology euclidean U) S"
   17.26 +    have cloS: "closedin (top_of_set U) S"
   17.27        by (metis US closed_closure closedin_closed_Int)
   17.28      have cont: "isCont ((\<lambda>x. setdist {x} (- U)) o fst) z" for z :: "'a \<times> 'b"
   17.29        by (rule continuous_at_compose continuous_intros continuous_at_setdist)+
   17.30 @@ -1275,9 +1275,9 @@
   17.31    where
   17.32    "covering_space c p S \<equiv>
   17.33         continuous_on c p \<and> p ` c = S \<and>
   17.34 -       (\<forall>x \<in> S. \<exists>T. x \<in> T \<and> openin (subtopology euclidean S) T \<and>
   17.35 +       (\<forall>x \<in> S. \<exists>T. x \<in> T \<and> openin (top_of_set S) T \<and>
   17.36                      (\<exists>v. \<Union>v = c \<inter> p -` T \<and>
   17.37 -                        (\<forall>u \<in> v. openin (subtopology euclidean c) u) \<and>
   17.38 +                        (\<forall>u \<in> v. openin (top_of_set c) u) \<and>
   17.39                          pairwise disjnt v \<and>
   17.40                          (\<forall>u \<in> v. \<exists>q. homeomorphism u T p q)))"
   17.41  
   17.42 @@ -1295,8 +1295,8 @@
   17.43  
   17.44  lemma covering_space_local_homeomorphism:
   17.45    assumes "covering_space c p S" "x \<in> c"
   17.46 -  obtains T u q where "x \<in> T" "openin (subtopology euclidean c) T"
   17.47 -                      "p x \<in> u" "openin (subtopology euclidean S) u"
   17.48 +  obtains T u q where "x \<in> T" "openin (top_of_set c) T"
   17.49 +                      "p x \<in> u" "openin (top_of_set S) u"
   17.50                        "homeomorphism T u p q"
   17.51  using assms
   17.52  apply (simp add: covering_space_def, clarify)
   17.53 @@ -1307,8 +1307,8 @@
   17.54  lemma covering_space_local_homeomorphism_alt:
   17.55    assumes p: "covering_space c p S" and "y \<in> S"
   17.56    obtains x T U q where "p x = y"
   17.57 -                        "x \<in> T" "openin (subtopology euclidean c) T"
   17.58 -                        "y \<in> U" "openin (subtopology euclidean S) U"
   17.59 +                        "x \<in> T" "openin (top_of_set c) T"
   17.60 +                        "y \<in> U" "openin (top_of_set S) U"
   17.61                            "homeomorphism T U p q"
   17.62  proof -
   17.63    obtain x where "p x = y" "x \<in> c"
   17.64 @@ -1320,26 +1320,26 @@
   17.65  
   17.66  proposition covering_space_open_map:
   17.67    fixes S :: "'a :: metric_space set" and T :: "'b :: metric_space set"
   17.68 -  assumes p: "covering_space c p S" and T: "openin (subtopology euclidean c) T"
   17.69 -    shows "openin (subtopology euclidean S) (p ` T)"
   17.70 +  assumes p: "covering_space c p S" and T: "openin (top_of_set c) T"
   17.71 +    shows "openin (top_of_set S) (p ` T)"
   17.72  proof -
   17.73    have pce: "p ` c = S"
   17.74     and covs:
   17.75         "\<And>x. x \<in> S \<Longrightarrow>
   17.76 -            \<exists>X VS. x \<in> X \<and> openin (subtopology euclidean S) X \<and>
   17.77 +            \<exists>X VS. x \<in> X \<and> openin (top_of_set S) X \<and>
   17.78                    \<Union>VS = c \<inter> p -` X \<and>
   17.79 -                  (\<forall>u \<in> VS. openin (subtopology euclidean c) u) \<and>
   17.80 +                  (\<forall>u \<in> VS. openin (top_of_set c) u) \<and>
   17.81                    pairwise disjnt VS \<and>
   17.82                    (\<forall>u \<in> VS. \<exists>q. homeomorphism u X p q)"
   17.83      using p by (auto simp: covering_space_def)
   17.84    have "T \<subseteq> c"  by (metis openin_euclidean_subtopology_iff T)
   17.85 -  have "\<exists>X. openin (subtopology euclidean S) X \<and> y \<in> X \<and> X \<subseteq> p ` T"
   17.86 +  have "\<exists>X. openin (top_of_set S) X \<and> y \<in> X \<and> X \<subseteq> p ` T"
   17.87            if "y \<in> p ` T" for y
   17.88    proof -
   17.89      have "y \<in> S" using \<open>T \<subseteq> c\<close> pce that by blast
   17.90 -    obtain U VS where "y \<in> U" and U: "openin (subtopology euclidean S) U"
   17.91 +    obtain U VS where "y \<in> U" and U: "openin (top_of_set S) U"
   17.92                    and VS: "\<Union>VS = c \<inter> p -` U"
   17.93 -                  and openVS: "\<forall>V \<in> VS. openin (subtopology euclidean c) V"
   17.94 +                  and openVS: "\<forall>V \<in> VS. openin (top_of_set c) V"
   17.95                    and homVS: "\<And>V. V \<in> VS \<Longrightarrow> \<exists>q. homeomorphism V U p q"
   17.96        using covs [OF \<open>y \<in> S\<close>] by auto
   17.97      obtain x where "x \<in> c" "p x \<in> U" "x \<in> T" "p x = y"
   17.98 @@ -1349,14 +1349,14 @@
   17.99      then obtain q where q: "homeomorphism V U p q" using homVS by blast
  17.100      then have ptV: "p ` (T \<inter> V) = U \<inter> q -` (T \<inter> V)"
  17.101        using VS \<open>V \<in> VS\<close> by (auto simp: homeomorphism_def)
  17.102 -    have ocv: "openin (subtopology euclidean c) V"
  17.103 +    have ocv: "openin (top_of_set c) V"
  17.104        by (simp add: \<open>V \<in> VS\<close> openVS)
  17.105 -    have "openin (subtopology euclidean U) (U \<inter> q -` (T \<inter> V))"
  17.106 +    have "openin (top_of_set U) (U \<inter> q -` (T \<inter> V))"
  17.107        apply (rule continuous_on_open [THEN iffD1, rule_format])
  17.108         using homeomorphism_def q apply blast
  17.109        using openin_subtopology_Int_subset [of c] q T unfolding homeomorphism_def
  17.110        by (metis inf.absorb_iff2 Int_commute ocv openin_euclidean_subtopology_iff)
  17.111 -    then have os: "openin (subtopology euclidean S) (U \<inter> q -` (T \<inter> V))"
  17.112 +    then have os: "openin (top_of_set S) (U \<inter> q -` (T \<inter> V))"
  17.113        using openin_trans [of U] by (simp add: Collect_conj_eq U)
  17.114      show ?thesis
  17.115        apply (rule_tac x = "p ` (T \<inter> V)" in exI)
  17.116 @@ -1386,13 +1386,13 @@
  17.117    have "connected U" by (rule in_components_connected [OF u_compt])
  17.118    have contu: "continuous_on U g1" "continuous_on U g2"
  17.119         using \<open>U \<subseteq> T\<close> continuous_on_subset g1 g2 by blast+
  17.120 -  have o12: "openin (subtopology euclidean U) G12"
  17.121 +  have o12: "openin (top_of_set U) G12"
  17.122    unfolding G12_def
  17.123    proof (subst openin_subopen, clarify)
  17.124      fix z
  17.125      assume z: "z \<in> U" "g1 z - g2 z = 0"
  17.126 -    obtain v w q where "g1 z \<in> v" and ocv: "openin (subtopology euclidean c) v"
  17.127 -                   and "p (g1 z) \<in> w" and osw: "openin (subtopology euclidean S) w"
  17.128 +    obtain v w q where "g1 z \<in> v" and ocv: "openin (top_of_set c) v"
  17.129 +                   and "p (g1 z) \<in> w" and osw: "openin (top_of_set S) w"
  17.130                     and hom: "homeomorphism v w p q"
  17.131        apply (rule_tac x = "g1 z" in covering_space_local_homeomorphism [OF cov])
  17.132         using \<open>U \<subseteq> T\<close> \<open>z \<in> U\<close> g1(2) apply blast+
  17.133 @@ -1400,15 +1400,15 @@
  17.134      have "g2 z \<in> v" using \<open>g1 z \<in> v\<close> z by auto
  17.135      have gg: "U \<inter> g -` v = U \<inter> g -` (v \<inter> g ` U)" for g
  17.136        by auto
  17.137 -    have "openin (subtopology euclidean (g1 ` U)) (v \<inter> g1 ` U)"
  17.138 +    have "openin (top_of_set (g1 ` U)) (v \<inter> g1 ` U)"
  17.139        using ocv \<open>U \<subseteq> T\<close> g1 by (fastforce simp add: openin_open)
  17.140 -    then have 1: "openin (subtopology euclidean U) (U \<inter> g1 -` v)"
  17.141 +    then have 1: "openin (top_of_set U) (U \<inter> g1 -` v)"
  17.142        unfolding gg by (blast intro: contu continuous_on_open [THEN iffD1, rule_format])
  17.143 -    have "openin (subtopology euclidean (g2 ` U)) (v \<inter> g2 ` U)"
  17.144 +    have "openin (top_of_set (g2 ` U)) (v \<inter> g2 ` U)"
  17.145        using ocv \<open>U \<subseteq> T\<close> g2 by (fastforce simp add: openin_open)
  17.146 -    then have 2: "openin (subtopology euclidean U) (U \<inter> g2 -` v)"
  17.147 +    then have 2: "openin (top_of_set U) (U \<inter> g2 -` v)"
  17.148        unfolding gg by (blast intro: contu continuous_on_open [THEN iffD1, rule_format])
  17.149 -    show "\<exists>T. openin (subtopology euclidean U) T \<and> z \<in> T \<and> T \<subseteq> {z \<in> U. g1 z - g2 z = 0}"
  17.150 +    show "\<exists>T. openin (top_of_set U) T \<and> z \<in> T \<and> T \<subseteq> {z \<in> U. g1 z - g2 z = 0}"
  17.151        using z
  17.152        apply (rule_tac x = "(U \<inter> g1 -` v) \<inter> (U \<inter> g2 -` v)" in exI)
  17.153        apply (intro conjI)
  17.154 @@ -1417,7 +1417,7 @@
  17.155        apply (metis \<open>U \<subseteq> T\<close> subsetD eq_iff_diff_eq_0 fg1 fg2 hom homeomorphism_def)
  17.156        done
  17.157    qed
  17.158 -  have c12: "closedin (subtopology euclidean U) G12"
  17.159 +  have c12: "closedin (top_of_set U) G12"
  17.160      unfolding G12_def
  17.161      by (intro continuous_intros continuous_closedin_preimage_constant contu)
  17.162    have "G12 = {} \<or> G12 = U"
  17.163 @@ -1468,37 +1468,37 @@
  17.164    show ?rhs
  17.165    proof (rule locallyI)
  17.166      fix V x
  17.167 -    assume V: "openin (subtopology euclidean C) V" and "x \<in> V"
  17.168 +    assume V: "openin (top_of_set C) V" and "x \<in> V"
  17.169      have "p x \<in> p ` C"
  17.170        by (metis IntE V \<open>x \<in> V\<close> imageI openin_open)
  17.171      then obtain T \<V> where "p x \<in> T"
  17.172 -                      and opeT: "openin (subtopology euclidean S) T"
  17.173 +                      and opeT: "openin (top_of_set S) T"
  17.174                        and veq: "\<Union>\<V> = C \<inter> p -` T"
  17.175 -                      and ope: "\<forall>U\<in>\<V>. openin (subtopology euclidean C) U"
  17.176 +                      and ope: "\<forall>U\<in>\<V>. openin (top_of_set C) U"
  17.177                        and hom: "\<forall>U\<in>\<V>. \<exists>q. homeomorphism U T p q"
  17.178        using cov unfolding covering_space_def by (blast intro: that)
  17.179      have "x \<in> \<Union>\<V>"
  17.180        using V veq \<open>p x \<in> T\<close> \<open>x \<in> V\<close> openin_imp_subset by fastforce
  17.181      then obtain U where "x \<in> U" "U \<in> \<V>"
  17.182        by blast
  17.183 -    then obtain q where opeU: "openin (subtopology euclidean C) U" and q: "homeomorphism U T p q"
  17.184 +    then obtain q where opeU: "openin (top_of_set C) U" and q: "homeomorphism U T p q"
  17.185        using ope hom by blast
  17.186 -    with V have "openin (subtopology euclidean C) (U \<inter> V)"
  17.187 +    with V have "openin (top_of_set C) (U \<inter> V)"
  17.188        by blast
  17.189 -    then have UV: "openin (subtopology euclidean S) (p ` (U \<inter> V))"
  17.190 +    then have UV: "openin (top_of_set S) (p ` (U \<inter> V))"
  17.191        using cov covering_space_open_map by blast
  17.192 -    obtain W W' where opeW: "openin (subtopology euclidean S) W" and "\<psi> W'" "p x \<in> W" "W \<subseteq> W'" and W'sub: "W' \<subseteq> p ` (U \<inter> V)"
  17.193 +    obtain W W' where opeW: "openin (top_of_set S) W" and "\<psi> W'" "p x \<in> W" "W \<subseteq> W'" and W'sub: "W' \<subseteq> p ` (U \<inter> V)"
  17.194        using locallyE [OF L UV] \<open>x \<in> U\<close> \<open>x \<in> V\<close> by blast
  17.195      then have "W \<subseteq> T"
  17.196        by (metis Int_lower1 q homeomorphism_image1 image_Int_subset order_trans)
  17.197 -    show "\<exists>U Z. openin (subtopology euclidean C) U \<and>
  17.198 +    show "\<exists>U Z. openin (top_of_set C) U \<and>
  17.199                   \<phi> Z \<and> x \<in> U \<and> U \<subseteq> Z \<and> Z \<subseteq> V"
  17.200      proof (intro exI conjI)
  17.201 -      have "openin (subtopology euclidean T) W"
  17.202 +      have "openin (top_of_set T) W"
  17.203          by (meson opeW opeT openin_imp_subset openin_subset_trans \<open>W \<subseteq> T\<close>)
  17.204 -      then have "openin (subtopology euclidean U) (q ` W)"
  17.205 +      then have "openin (top_of_set U) (q ` W)"
  17.206          by (meson homeomorphism_imp_open_map homeomorphism_symD q)
  17.207 -      then show "openin (subtopology euclidean C) (q ` W)"
  17.208 +      then show "openin (top_of_set C) (q ` W)"
  17.209          using opeU openin_trans by blast
  17.210        show "\<phi> (q ` W')"
  17.211          by (metis (mono_tags, lifting) Int_subset_iff UV W'sub \<open>\<psi> W'\<close> continuous_on_subset dual_order.trans homeomorphism_def image_Int_subset openin_imp_subset q qim)
  17.212 @@ -1575,18 +1575,18 @@
  17.213                      "\<And>y. y \<in> U \<Longrightarrow> k(0, y) = f y"
  17.214                      "\<And>z. z \<in> {0..1} \<times> U \<Longrightarrow> h z = p(k z)"
  17.215  proof -
  17.216 -  have "\<exists>V k. openin (subtopology euclidean U) V \<and> y \<in> V \<and>
  17.217 +  have "\<exists>V k. openin (top_of_set U) V \<and> y \<in> V \<and>
  17.218                continuous_on ({0..1} \<times> V) k \<and> k ` ({0..1} \<times> V) \<subseteq> C \<and>
  17.219                (\<forall>z \<in> V. k(0, z) = f z) \<and> (\<forall>z \<in> {0..1} \<times> V. h z = p(k z))"
  17.220          if "y \<in> U" for y
  17.221    proof -
  17.222 -    obtain UU where UU: "\<And>s. s \<in> S \<Longrightarrow> s \<in> (UU s) \<and> openin (subtopology euclidean S) (UU s) \<and>
  17.223 +    obtain UU where UU: "\<And>s. s \<in> S \<Longrightarrow> s \<in> (UU s) \<and> openin (top_of_set S) (UU s) \<and>
  17.224                                          (\<exists>\<V>. \<Union>\<V> = C \<inter> p -` UU s \<and>
  17.225 -                                            (\<forall>U \<in> \<V>. openin (subtopology euclidean C) U) \<and>
  17.226 +                                            (\<forall>U \<in> \<V>. openin (top_of_set C) U) \<and>
  17.227                                              pairwise disjnt \<V> \<and>
  17.228                                              (\<forall>U \<in> \<V>. \<exists>q. homeomorphism U (UU s) p q))"
  17.229        using cov unfolding covering_space_def by (metis (mono_tags))
  17.230 -    then have ope: "\<And>s. s \<in> S \<Longrightarrow> s \<in> (UU s) \<and> openin (subtopology euclidean S) (UU s)"
  17.231 +    then have ope: "\<And>s. s \<in> S \<Longrightarrow> s \<in> (UU s) \<and> openin (top_of_set S) (UU s)"
  17.232        by blast
  17.233      have "\<exists>k n i. open k \<and> open n \<and>
  17.234                    t \<in> k \<and> y \<in> n \<and> i \<in> S \<and> h ` (({0..1} \<inter> k) \<times> (U \<inter> n)) \<subseteq> UU i" if "t \<in> {0..1}" for t
  17.235 @@ -1595,7 +1595,7 @@
  17.236          using \<open>y \<in> U\<close> him that by blast
  17.237        then have "(t,y) \<in> ({0..1} \<times> U) \<inter> h -` UU(h(t, y))"
  17.238          using \<open>y \<in> U\<close> \<open>t \<in> {0..1}\<close>  by (auto simp: ope)
  17.239 -      moreover have ope_01U: "openin (subtopology euclidean ({0..1} \<times> U)) (({0..1} \<times> U) \<inter> h -` UU(h(t, y)))"
  17.240 +      moreover have ope_01U: "openin (top_of_set ({0..1} \<times> U)) (({0..1} \<times> U) \<inter> h -` UU(h(t, y)))"
  17.241          using hinS ope continuous_on_open_gen [OF him] conth by blast
  17.242        ultimately obtain V W where opeV: "open V" and "t \<in> {0..1} \<inter> V" "t \<in> {0..1} \<inter> V"
  17.243                                and opeW: "open W" and "y \<in> U" "y \<in> W"
  17.244 @@ -1641,7 +1641,7 @@
  17.245        using reals_Archimedean2 by blast
  17.246      then have "N > 0"
  17.247        using \<open>0 < \<delta>\<close> order.asym by force
  17.248 -    have *: "\<exists>V k. openin (subtopology euclidean U) V \<and> y \<in> V \<and>
  17.249 +    have *: "\<exists>V k. openin (top_of_set U) V \<and> y \<in> V \<and>
  17.250                     continuous_on ({0..of_nat n / N} \<times> V) k \<and>
  17.251                     k ` ({0..of_nat n / N} \<times> V) \<subseteq> C \<and>
  17.252                     (\<forall>z\<in>V. k (0, z) = f z) \<and>
  17.253 @@ -1657,7 +1657,7 @@
  17.254          done
  17.255      next
  17.256        case (Suc n)
  17.257 -      then obtain V k where opeUV: "openin (subtopology euclidean U) V"
  17.258 +      then obtain V k where opeUV: "openin (top_of_set U) V"
  17.259                          and "y \<in> V"
  17.260                          and contk: "continuous_on ({0..real n / real N} \<times> V) k"
  17.261                          and kim: "k ` ({0..real n / real N} \<times> V) \<subseteq> C"
  17.262 @@ -1676,7 +1676,7 @@
  17.263        have t01: "t \<in> {0..1}"
  17.264          using \<open>t \<in> tk\<close> \<open>tk \<subseteq> {0..1}\<close> by blast
  17.265        obtain \<V> where \<V>: "\<Union>\<V> = C \<inter> p -` UU (X t)"
  17.266 -                 and opeC: "\<And>U. U \<in> \<V> \<Longrightarrow> openin (subtopology euclidean C) U"
  17.267 +                 and opeC: "\<And>U. U \<in> \<V> \<Longrightarrow> openin (top_of_set C) U"
  17.268                   and "pairwise disjnt \<V>"
  17.269                   and homuu: "\<And>U. U \<in> \<V> \<Longrightarrow> \<exists>q. homeomorphism U (UU (X t)) p q"
  17.270          using inUS [OF t01] UU by meson
  17.271 @@ -1703,24 +1703,24 @@
  17.272          by blast
  17.273        then obtain W where W: "k (real n / real N, y) \<in> W" and "W \<in> \<V>"
  17.274          by blast
  17.275 -      then obtain p' where opeC': "openin (subtopology euclidean C) W"
  17.276 +      then obtain p' where opeC': "openin (top_of_set C) W"
  17.277                         and hom': "homeomorphism W (UU (X t)) p p'"
  17.278          using homuu opeC by blast
  17.279        then have "W \<subseteq> C"
  17.280          using openin_imp_subset by blast
  17.281        define W' where "W' = UU(X t)"
  17.282 -      have opeVW: "openin (subtopology euclidean V) (V \<inter> (k \<circ> Pair (n / N)) -` W)"
  17.283 +      have opeVW: "openin (top_of_set V) (V \<inter> (k \<circ> Pair (n / N)) -` W)"
  17.284          apply (rule continuous_openin_preimage [OF _ _ opeC'])
  17.285           apply (intro continuous_intros continuous_on_subset [OF contk])
  17.286          using kim apply (auto simp: \<open>y \<in> V\<close> W)
  17.287          done
  17.288 -      obtain N' where opeUN': "openin (subtopology euclidean U) N'"
  17.289 +      obtain N' where opeUN': "openin (top_of_set U) N'"
  17.290                    and "y \<in> N'" and kimw: "k ` ({(real n / real N)} \<times> N') \<subseteq> W"
  17.291          apply (rule_tac N' = "(V \<inter> (k \<circ> Pair (n / N)) -` W)" in that)
  17.292          apply (fastforce simp:  \<open>y \<in> V\<close> W intro!: openin_trans [OF opeVW opeUV])+
  17.293          done
  17.294 -      obtain Q Q' where opeUQ: "openin (subtopology euclidean U) Q"
  17.295 -                    and cloUQ': "closedin (subtopology euclidean U) Q'"
  17.296 +      obtain Q Q' where opeUQ: "openin (top_of_set U) Q"
  17.297 +                    and cloUQ': "closedin (top_of_set U) Q'"
  17.298                      and "y \<in> Q" "Q \<subseteq> Q'"
  17.299                      and Q': "Q' \<subseteq> (U \<inter> NN(t)) \<inter> N' \<inter> V"
  17.300        proof -
  17.301 @@ -1732,9 +1732,9 @@
  17.302            by (metis Int_iff \<open>N' = U \<inter> VX\<close> \<open>V = U \<inter> VO\<close> \<open>y \<in> N'\<close> \<open>y \<in> V\<close> inUS open_contains_cball t01)
  17.303          show ?thesis
  17.304          proof
  17.305 -          show "openin (subtopology euclidean U) (U \<inter> ball y e)"
  17.306 +          show "openin (top_of_set U) (U \<inter> ball y e)"
  17.307              by blast
  17.308 -          show "closedin (subtopology euclidean U) (U \<inter> cball y e)"
  17.309 +          show "closedin (top_of_set U) (U \<inter> cball y e)"
  17.310              using e by (auto simp: closedin_closed)
  17.311          qed (use \<open>y \<in> U\<close> \<open>e > 0\<close> VO VX e in auto)
  17.312        qed
  17.313 @@ -1749,13 +1749,13 @@
  17.314          (\<lambda>x. if x \<in> {0..real n / real N} \<times> Q' then k x else (p' \<circ> h) x)"
  17.315          unfolding neqQ' [symmetric]
  17.316        proof (rule continuous_on_cases_local, simp_all add: neqQ' del: comp_apply)
  17.317 -        show "closedin (subtopology euclidean ({0..(1 + real n) / real N} \<times> Q'))
  17.318 +        show "closedin (top_of_set ({0..(1 + real n) / real N} \<times> Q'))
  17.319                         ({0..real n / real N} \<times> Q')"
  17.320            apply (simp add: closedin_closed)
  17.321            apply (rule_tac x="{0 .. real n / real N} \<times> UNIV" in exI)
  17.322            using n_div_N_in apply (auto simp: closed_Times)
  17.323            done
  17.324 -        show "closedin (subtopology euclidean ({0..(1 + real n) / real N} \<times> Q'))
  17.325 +        show "closedin (top_of_set ({0..(1 + real n) / real N} \<times> Q'))
  17.326                         ({real n / real N..(1 + real n) / real N} \<times> Q')"
  17.327            apply (simp add: closedin_closed)
  17.328            apply (rule_tac x="{real n / real N .. (1 + real n) / real N} \<times> UNIV" in exI)
  17.329 @@ -1845,7 +1845,7 @@
  17.330      show ?thesis
  17.331        using*[OF order_refl] N \<open>0 < \<delta>\<close> by (simp add: split: if_split_asm)
  17.332    qed
  17.333 -  then obtain V fs where opeV: "\<And>y. y \<in> U \<Longrightarrow> openin (subtopology euclidean U) (V y)"
  17.334 +  then obtain V fs where opeV: "\<And>y. y \<in> U \<Longrightarrow> openin (top_of_set U) (V y)"
  17.335            and V: "\<And>y. y \<in> U \<Longrightarrow> y \<in> V y"
  17.336            and contfs: "\<And>y. y \<in> U \<Longrightarrow> continuous_on ({0..1} \<times> V y) (fs y)"
  17.337            and *: "\<And>y. y \<in> U \<Longrightarrow> (fs y) ` ({0..1} \<times> V y) \<subseteq> C \<and>
  17.338 @@ -1857,14 +1857,17 @@
  17.339    obtain k where contk: "continuous_on ({0..1} \<times> U) k"
  17.340               and k: "\<And>x i. \<lbrakk>i \<in> U; x \<in> {0..1} \<times> U \<inter> {0..1} \<times> V i\<rbrakk> \<Longrightarrow> k x = fs i x"
  17.341    proof (rule pasting_lemma_exists)
  17.342 -    show "{0..1} \<times> U \<subseteq> (\<Union>i\<in>U. {0..1} \<times> V i)"
  17.343 -      apply auto
  17.344 -      using V by blast
  17.345 -    show "\<And>i. i \<in> U \<Longrightarrow> openin (subtopology euclidean ({0..1} \<times> U)) ({0..1} \<times> V i)"
  17.346 +    let ?X = "top_of_set ({0..1::real} \<times> U)"
  17.347 +    show "topspace ?X \<subseteq> (\<Union>i\<in>U. {0..1} \<times> V i)"
  17.348 +      using V by force
  17.349 +    show "\<And>i. i \<in> U \<Longrightarrow> openin (top_of_set ({0..1} \<times> U)) ({0..1} \<times> V i)"
  17.350        by (simp add: opeV openin_Times)
  17.351 -    show "\<And>i. i \<in> U \<Longrightarrow> continuous_on ({0..1} \<times> V i) (fs i)"
  17.352 -      using contfs by blast
  17.353 -    show "fs i x = fs j x"  if "i \<in> U" "j \<in> U" and x: "x \<in> {0..1} \<times> U \<inter> {0..1} \<times> V i \<inter> {0..1} \<times> V j"
  17.354 +    show "\<And>i. i \<in> U \<Longrightarrow> continuous_map
  17.355 +              (subtopology (top_of_set ({0..1} \<times> U)) ({0..1} \<times> V i)) euclidean (fs i)"
  17.356 +      using contfs
  17.357 +      apply simp
  17.358 +      by (metis continuous_map_iff_continuous continuous_on_subset openin_imp_subset openin_subtopology_self subtopology_subtopology)
  17.359 +    show "fs i x = fs j x"  if "i \<in> U" "j \<in> U" and x: "x \<in> topspace ?X \<inter> {0..1} \<times> V i \<inter> {0..1} \<times> V j"
  17.360           for i j x
  17.361      proof -
  17.362        obtain u y where "x = (u, y)" "y \<in> V i" "y \<in> V j" "0 \<le> u" "u \<le> 1"
  17.363 @@ -1900,7 +1903,7 @@
  17.364            using \<open>x = (u, y)\<close> x by blast
  17.365        qed
  17.366      qed
  17.367 -  qed blast
  17.368 +  qed force
  17.369    show ?thesis
  17.370    proof
  17.371      show "k ` ({0..1} \<times> U) \<subseteq> C"
  17.372 @@ -2282,17 +2285,17 @@
  17.373        using l [of "linepath z z" z "linepath a a"] by (auto simp: assms)
  17.374      show LC: "l ` U \<subseteq> C"
  17.375        by (clarify dest!: *) (metis (full_types) l pathfinish_in_path_image subsetCE)
  17.376 -    have "\<exists>T. openin (subtopology euclidean U) T \<and> y \<in> T \<and> T \<subseteq> U \<inter> l -` X"
  17.377 -         if X: "openin (subtopology euclidean C) X" and "y \<in> U" "l y \<in> X" for X y
  17.378 +    have "\<exists>T. openin (top_of_set U) T \<and> y \<in> T \<and> T \<subseteq> U \<inter> l -` X"
  17.379 +         if X: "openin (top_of_set C) X" and "y \<in> U" "l y \<in> X" for X y
  17.380      proof -
  17.381        have "X \<subseteq> C"
  17.382          using X openin_euclidean_subtopology_iff by blast
  17.383        have "f y \<in> S"
  17.384          using fim \<open>y \<in> U\<close> by blast
  17.385        then obtain W \<V>
  17.386 -              where WV: "f y \<in> W \<and> openin (subtopology euclidean S) W \<and>
  17.387 +              where WV: "f y \<in> W \<and> openin (top_of_set S) W \<and>
  17.388                           (\<Union>\<V> = C \<inter> p -` W \<and>
  17.389 -                          (\<forall>U \<in> \<V>. openin (subtopology euclidean C) U) \<and>
  17.390 +                          (\<forall>U \<in> \<V>. openin (top_of_set C) U) \<and>
  17.391                            pairwise disjnt \<V> \<and>
  17.392                            (\<forall>U \<in> \<V>. \<exists>q. homeomorphism U W p q))"
  17.393          using cov by (force simp: covering_space_def)
  17.394 @@ -2300,15 +2303,15 @@
  17.395          using \<open>X \<subseteq> C\<close> pleq that by auto
  17.396        then obtain W' where "l y \<in> W'" and "W' \<in> \<V>"
  17.397          by blast
  17.398 -      with WV obtain p' where opeCW': "openin (subtopology euclidean C) W'"
  17.399 +      with WV obtain p' where opeCW': "openin (top_of_set C) W'"
  17.400                            and homUW': "homeomorphism W' W p p'"
  17.401          by blast
  17.402        then have contp': "continuous_on W p'" and p'im: "p' ` W \<subseteq> W'"
  17.403          using homUW' homeomorphism_image2 homeomorphism_cont2 by fastforce+
  17.404        obtain V where "y \<in> V" "y \<in> U" and fimW: "f ` V \<subseteq> W" "V \<subseteq> U"
  17.405 -                 and "path_connected V" and opeUV: "openin (subtopology euclidean U) V"
  17.406 +                 and "path_connected V" and opeUV: "openin (top_of_set U) V"
  17.407        proof -
  17.408 -        have "openin (subtopology euclidean U) (U \<inter> f -` W)"
  17.409 +        have "openin (top_of_set U) (U \<inter> f -` W)"
  17.410            using WV contf continuous_on_open_gen fim by auto
  17.411          then show ?thesis
  17.412            using U WV
  17.413 @@ -2324,16 +2327,16 @@
  17.414          using homUW' homeomorphism_image2 by fastforce
  17.415        show ?thesis
  17.416        proof (intro exI conjI)
  17.417 -        have "openin (subtopology euclidean S) (W \<inter> p' -` (W' \<inter> X))"
  17.418 +        have "openin (top_of_set S) (W \<inter> p' -` (W' \<inter> X))"
  17.419          proof (rule openin_trans)
  17.420 -          show "openin (subtopology euclidean W) (W \<inter> p' -` (W' \<inter> X))"
  17.421 +          show "openin (top_of_set W) (W \<inter> p' -` (W' \<inter> X))"
  17.422              apply (rule continuous_openin_preimage [OF contp' p'im])
  17.423              using X \<open>W' \<subseteq> C\<close> apply (auto simp: openin_open)
  17.424              done
  17.425 -          show "openin (subtopology euclidean S) W"
  17.426 +          show "openin (top_of_set S) W"
  17.427              using WV by blast
  17.428          qed
  17.429 -        then show "openin (subtopology euclidean U) (V \<inter> (U \<inter> (f -` (W \<inter> (p' -` (W' \<inter> X))))))"
  17.430 +        then show "openin (top_of_set U) (V \<inter> (U \<inter> (f -` (W \<inter> (p' -` (W' \<inter> X))))))"
  17.431            by (blast intro: opeUV openin_subtopology_self continuous_openin_preimage [OF contf fim])
  17.432           have "p' (f y) \<in> X"
  17.433            using \<open>l y \<in> W'\<close> homeomorphism_apply1 [OF homUW'] pleq \<open>y \<in> U\<close> \<open>l y \<in> X\<close> by fastforce
    18.1 --- a/src/HOL/Analysis/Homotopy.thy	Mon Mar 18 21:50:51 2019 +0100
    18.2 +++ b/src/HOL/Analysis/Homotopy.thy	Tue Mar 19 16:14:59 2019 +0000
    18.3 @@ -258,12 +258,12 @@
    18.4      assumes "homotopic_with P X Y f g" and "homotopic_with P X Y g h"
    18.5        shows "homotopic_with P X Y f h"
    18.6  proof -
    18.7 -  have clo1: "closedin (subtopology euclidean ({0..1/2} \<times> X \<union> {1/2..1} \<times> X)) ({0..1/2::real} \<times> X)"
    18.8 +  have clo1: "closedin (top_of_set ({0..1/2} \<times> X \<union> {1/2..1} \<times> X)) ({0..1/2::real} \<times> X)"
    18.9      apply (simp add: closedin_closed split_01_prod [symmetric])
   18.10      apply (rule_tac x="{0..1/2} \<times> UNIV" in exI)
   18.11      apply (force simp: closed_Times)
   18.12      done
   18.13 -  have clo2: "closedin (subtopology euclidean ({0..1/2} \<times> X \<union> {1/2..1} \<times> X)) ({1/2..1::real} \<times> X)"
   18.14 +  have clo2: "closedin (top_of_set ({0..1/2} \<times> X \<union> {1/2..1} \<times> X)) ({1/2..1::real} \<times> X)"
   18.15      apply (simp add: closedin_closed split_01_prod [symmetric])
   18.16      apply (rule_tac x="{1/2..1} \<times> UNIV" in exI)
   18.17      apply (force simp: closed_Times)
   18.18 @@ -1472,20 +1472,20 @@
   18.19  definition%important locally :: "('a::topological_space set \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> bool"
   18.20  where
   18.21   "locally P S \<equiv>
   18.22 -        \<forall>w x. openin (subtopology euclidean S) w \<and> x \<in> w
   18.23 -              \<longrightarrow> (\<exists>u v. openin (subtopology euclidean S) u \<and> P v \<and>
   18.24 +        \<forall>w x. openin (top_of_set S) w \<and> x \<in> w
   18.25 +              \<longrightarrow> (\<exists>u v. openin (top_of_set S) u \<and> P v \<and>
   18.26                          x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> w)"
   18.27  
   18.28  lemma locallyI:
   18.29 -  assumes "\<And>w x. \<lbrakk>openin (subtopology euclidean S) w; x \<in> w\<rbrakk>
   18.30 -                  \<Longrightarrow> \<exists>u v. openin (subtopology euclidean S) u \<and> P v \<and>
   18.31 +  assumes "\<And>w x. \<lbrakk>openin (top_of_set S) w; x \<in> w\<rbrakk>
   18.32 +                  \<Longrightarrow> \<exists>u v. openin (top_of_set S) u \<and> P v \<and>
   18.33                          x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> w"
   18.34      shows "locally P S"
   18.35  using assms by (force simp: locally_def)
   18.36  
   18.37  lemma locallyE:
   18.38 -  assumes "locally P S" "openin (subtopology euclidean S) w" "x \<in> w"
   18.39 -  obtains u v where "openin (subtopology euclidean S) u"
   18.40 +  assumes "locally P S" "openin (top_of_set S) w" "x \<in> w"
   18.41 +  obtains u v where "openin (top_of_set S) u"
   18.42                      "P v" "x \<in> u" "u \<subseteq> v" "v \<subseteq> w"
   18.43    using assms unfolding locally_def by meson
   18.44  
   18.45 @@ -1495,7 +1495,7 @@
   18.46  by (metis assms locally_def)
   18.47  
   18.48  lemma locally_open_subset:
   18.49 -  assumes "locally P S" "openin (subtopology euclidean S) t"
   18.50 +  assumes "locally P S" "openin (top_of_set S) t"
   18.51      shows "locally P t"
   18.52  using assms
   18.53  apply (simp add: locally_def)
   18.54 @@ -1507,7 +1507,7 @@
   18.55  by (metis (no_types, hide_lams) Int_absorb1 Int_lower1 Int_subset_iff openin_open openin_subtopology_Int_subset)
   18.56  
   18.57  lemma locally_diff_closed:
   18.58 -    "\<lbrakk>locally P S; closedin (subtopology euclidean S) t\<rbrakk> \<Longrightarrow> locally P (S - t)"
   18.59 +    "\<lbrakk>locally P S; closedin (top_of_set S) t\<rbrakk> \<Longrightarrow> locally P (S - t)"
   18.60    using locally_open_subset closedin_def by fastforce
   18.61  
   18.62  lemma locally_empty [iff]: "locally P {}"
   18.63 @@ -1550,15 +1550,15 @@
   18.64      unfolding locally_def
   18.65  proof (clarify)
   18.66    fix W x y
   18.67 -  assume W: "openin (subtopology euclidean (S \<times> T)) W" and xy: "(x, y) \<in> W"
   18.68 -  then obtain U V where "openin (subtopology euclidean S) U" "x \<in> U"
   18.69 -                        "openin (subtopology euclidean T) V" "y \<in> V" "U \<times> V \<subseteq> W"
   18.70 +  assume W: "openin (top_of_set (S \<times> T)) W" and xy: "(x, y) \<in> W"
   18.71 +  then obtain U V where "openin (top_of_set S) U" "x \<in> U"
   18.72 +                        "openin (top_of_set T) V" "y \<in> V" "U \<times> V \<subseteq> W"
   18.73      using Times_in_interior_subtopology by metis
   18.74    then obtain U1 U2 V1 V2
   18.75 -         where opeS: "openin (subtopology euclidean S) U1 \<and> P U2 \<and> x \<in> U1 \<and> U1 \<subseteq> U2 \<and> U2 \<subseteq> U"
   18.76 -           and opeT: "openin (subtopology euclidean T) V1 \<and> Q V2 \<and> y \<in> V1 \<and> V1 \<subseteq> V2 \<and> V2 \<subseteq> V"
   18.77 +         where opeS: "openin (top_of_set S) U1 \<and> P U2 \<and> x \<in> U1 \<and> U1 \<subseteq> U2 \<and> U2 \<subseteq> U"
   18.78 +           and opeT: "openin (top_of_set T) V1 \<and> Q V2 \<and> y \<in> V1 \<and> V1 \<subseteq> V2 \<and> V2 \<subseteq> V"
   18.79      by (meson PS QT locallyE)
   18.80 -  with \<open>U \<times> V \<subseteq> W\<close> show "\<exists>u v. openin (subtopology euclidean (S \<times> T)) u \<and> R v \<and> (x,y) \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> W"
   18.81 +  with \<open>U \<times> V \<subseteq> W\<close> show "\<exists>u v. openin (top_of_set (S \<times> T)) u \<and> R v \<and> (x,y) \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> W"
   18.82      apply (rule_tac x="U1 \<times> V1" in exI)
   18.83      apply (rule_tac x="U2 \<times> V2" in exI)
   18.84      apply (auto simp: openin_Times R)
   18.85 @@ -1573,7 +1573,7 @@
   18.86      shows "locally Q t"
   18.87  proof (clarsimp simp: locally_def)
   18.88    fix W y
   18.89 -  assume "y \<in> W" and "openin (subtopology euclidean t) W"
   18.90 +  assume "y \<in> W" and "openin (top_of_set t) W"
   18.91    then obtain T where T: "open T" "W = t \<inter> T"
   18.92      by (force simp: openin_open)
   18.93    then have "W \<subseteq> t" by auto
   18.94 @@ -1586,15 +1586,15 @@
   18.95      using \<open>g ` t = S\<close> \<open>W \<subseteq> t\<close> apply blast
   18.96      using g \<open>W \<subseteq> t\<close> apply auto[1]
   18.97      by (simp add: f rev_image_eqI)
   18.98 -  have \<circ>: "openin (subtopology euclidean S) (g ` W)"
   18.99 +  have \<circ>: "openin (top_of_set S) (g ` W)"
  18.100    proof -
  18.101      have "continuous_on S f"
  18.102        using f(3) by blast
  18.103 -    then show "openin (subtopology euclidean S) (g ` W)"
  18.104 -      by (simp add: gw Collect_conj_eq \<open>openin (subtopology euclidean t) W\<close> continuous_on_open f(2))
  18.105 +    then show "openin (top_of_set S) (g ` W)"
  18.106 +      by (simp add: gw Collect_conj_eq \<open>openin (top_of_set t) W\<close> continuous_on_open f(2))
  18.107    qed
  18.108    then obtain u v
  18.109 -    where osu: "openin (subtopology euclidean S) u" and uv: "P v" "g y \<in> u" "u \<subseteq> v" "v \<subseteq> g ` W"
  18.110 +    where osu: "openin (top_of_set S) u" and uv: "P v" "g y \<in> u" "u \<subseteq> v" "v \<subseteq> g ` W"
  18.111      using S [unfolded locally_def, rule_format, of "g ` W" "g y"] \<open>y \<in> W\<close> by force
  18.112    have "v \<subseteq> S" using uv by (simp add: gw)
  18.113    have fv: "f ` v = t \<inter> {x. g x \<in> v}"
  18.114 @@ -1609,7 +1609,7 @@
  18.115      using \<open>v \<subseteq> S\<close> \<open>W \<subseteq> t\<close> f
  18.116      apply (simp add: homeomorphism_def contvf contvg, auto)
  18.117      by (metis f(1) rev_image_eqI rev_subsetD)
  18.118 -  have 1: "openin (subtopology euclidean t) (t \<inter> g -` u)"
  18.119 +  have 1: "openin (top_of_set t) (t \<inter> g -` u)"
  18.120      apply (rule continuous_on_open [THEN iffD1, rule_format])
  18.121      apply (rule \<open>continuous_on t g\<close>)
  18.122      using \<open>g ` t = S\<close> apply (simp add: osu)
  18.123 @@ -1619,7 +1619,7 @@
  18.124      apply (intro conjI Q [OF \<open>P v\<close> homv])
  18.125      using \<open>W \<subseteq> t\<close> \<open>y \<in> W\<close>  \<open>f ` v \<subseteq> W\<close>  uv  apply (auto simp: fv)
  18.126      done
  18.127 -  show "\<exists>U. openin (subtopology euclidean t) U \<and> (\<exists>v. Q v \<and> y \<in> U \<and> U \<subseteq> v \<and> v \<subseteq> W)"
  18.128 +  show "\<exists>U. openin (top_of_set t) U \<and> (\<exists>v. Q v \<and> y \<in> U \<and> U \<subseteq> v \<and> v \<subseteq> W)"
  18.129      by (meson 1 2)
  18.130  qed
  18.131  
  18.132 @@ -1674,23 +1674,23 @@
  18.133    fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
  18.134    assumes P: "locally P S"
  18.135        and f: "continuous_on S f"
  18.136 -      and oo: "\<And>t. openin (subtopology euclidean S) t
  18.137 -                   \<Longrightarrow> openin (subtopology euclidean (f ` S)) (f ` t)"
  18.138 +      and oo: "\<And>t. openin (top_of_set S) t
  18.139 +                   \<Longrightarrow> openin (top_of_set (f ` S)) (f ` t)"
  18.140        and Q: "\<And>t. \<lbrakk>t \<subseteq> S; P t\<rbrakk> \<Longrightarrow> Q(f ` t)"
  18.141      shows "locally Q (f ` S)"
  18.142  proof (clarsimp simp add: locally_def)
  18.143    fix W y
  18.144 -  assume oiw: "openin (subtopology euclidean (f ` S)) W" and "y \<in> W"
  18.145 +  assume oiw: "openin (top_of_set (f ` S)) W" and "y \<in> W"
  18.146    then have "W \<subseteq> f ` S" by (simp add: openin_euclidean_subtopology_iff)
  18.147 -  have oivf: "openin (subtopology euclidean S) (S \<inter> f -` W)"
  18.148 +  have oivf: "openin (top_of_set S) (S \<inter> f -` W)"
  18.149      by (rule continuous_on_open [THEN iffD1, rule_format, OF f oiw])
  18.150    then obtain x where "x \<in> S" "f x = y"
  18.151      using \<open>W \<subseteq> f ` S\<close> \<open>y \<in> W\<close> by blast
  18.152    then obtain U V
  18.153 -    where "openin (subtopology euclidean S) U" "P V" "x \<in> U" "U \<subseteq> V" "V \<subseteq> S \<inter> f -` W"
  18.154 +    where "openin (top_of_set S) U" "P V" "x \<in> U" "U \<subseteq> V" "V \<subseteq> S \<inter> f -` W"
  18.155      using P [unfolded locally_def, rule_format, of "(S \<inter> f -` W)" x] oivf \<open>y \<in> W\<close>
  18.156      by auto
  18.157 -  then show "\<exists>X. openin (subtopology euclidean (f ` S)) X \<and> (\<exists>Y. Q Y \<and> y \<in> X \<and> X \<subseteq> Y \<and> Y \<subseteq> W)"
  18.158 +  then show "\<exists>X. openin (top_of_set (f ` S)) X \<and> (\<exists>Y. Q Y \<and> y \<in> X \<and> X \<subseteq> Y \<and> Y \<subseteq> W)"
  18.159      apply (rule_tac x="f ` U" in exI)
  18.160      apply (rule conjI, blast intro!: oo)
  18.161      apply (rule_tac x="f ` V" in exI)
  18.162 @@ -1703,21 +1703,21 @@
  18.163  
  18.164  proposition connected_induction:
  18.165    assumes "connected S"
  18.166 -      and opD: "\<And>T a. \<lbrakk>openin (subtopology euclidean S) T; a \<in> T\<rbrakk> \<Longrightarrow> \<exists>z. z \<in> T \<and> P z"
  18.167 +      and opD: "\<And>T a. \<lbrakk>openin (top_of_set S) T; a \<in> T\<rbrakk> \<Longrightarrow> \<exists>z. z \<in> T \<and> P z"
  18.168        and opI: "\<And>a. a \<in> S
  18.169 -             \<Longrightarrow> \<exists>T. openin (subtopology euclidean S) T \<and> a \<in> T \<and>
  18.170 +             \<Longrightarrow> \<exists>T. openin (top_of_set S) T \<and> a \<in> T \<and>
  18.171                       (\<forall>x \<in> T. \<forall>y \<in> T. P x \<and> P y \<and> Q x \<longrightarrow> Q y)"
  18.172        and etc: "a \<in> S" "b \<in> S" "P a" "P b" "Q a"
  18.173      shows "Q b"
  18.174  proof -
  18.175 -  have 1: "openin (subtopology euclidean S)
  18.176 -             {b. \<exists>T. openin (subtopology euclidean S) T \<and>
  18.177 +  have 1: "openin (top_of_set S)
  18.178 +             {b. \<exists>T. openin (top_of_set S) T \<and>
  18.179                       b \<in> T \<and> (\<forall>x\<in>T. P x \<longrightarrow> Q x)}"
  18.180      apply (subst openin_subopen, clarify)
  18.181      apply (rule_tac x=T in exI, auto)
  18.182      done
  18.183 -  have 2: "openin (subtopology euclidean S)
  18.184 -             {b. \<exists>T. openin (subtopology euclidean S) T \<and>
  18.185 +  have 2: "openin (top_of_set S)
  18.186 +             {b. \<exists>T. openin (top_of_set S) T \<and>
  18.187                       b \<in> T \<and> (\<forall>x\<in>T. P x \<longrightarrow> \<not> Q x)}"
  18.188      apply (subst openin_subopen, clarify)
  18.189      apply (rule_tac x=T in exI, auto)
  18.190 @@ -1738,9 +1738,9 @@
  18.191    assumes "connected S"
  18.192        and etc: "a \<in> S" "b \<in> S" "P a" "P b"
  18.193        and trans: "\<And>x y z. \<lbrakk>R x y; R y z\<rbrakk> \<Longrightarrow> R x z"
  18.194 -      and opD: "\<And>T a. \<lbrakk>openin (subtopology euclidean S) T; a \<in> T\<rbrakk> \<Longrightarrow> \<exists>z. z \<in> T \<and> P z"
  18.195 +      and opD: "\<And>T a. \<lbrakk>openin (top_of_set S) T; a \<in> T\<rbrakk> \<Longrightarrow> \<exists>z. z \<in> T \<and> P z"
  18.196        and opI: "\<And>a. a \<in> S
  18.197 -             \<Longrightarrow> \<exists>T. openin (subtopology euclidean S) T \<and> a \<in> T \<and>
  18.198 +             \<Longrightarrow> \<exists>T. openin (top_of_set S) T \<and> a \<in> T \<and>
  18.199                       (\<forall>x \<in> T. \<forall>y \<in> T. P x \<and> P y \<longrightarrow> R x y)"
  18.200      shows "R a b"
  18.201  proof -
  18.202 @@ -1754,7 +1754,7 @@
  18.203    assumes "connected S"
  18.204        and etc: "a \<in> S" "b \<in> S" "P a"
  18.205        and opI: "\<And>a. a \<in> S
  18.206 -             \<Longrightarrow> \<exists>T. openin (subtopology euclidean S) T \<and> a \<in> T \<and>
  18.207 +             \<Longrightarrow> \<exists>T. openin (top_of_set S) T \<and> a \<in> T \<and>
  18.208                       (\<forall>x \<in> T. \<forall>y \<in> T. P x \<longrightarrow> P y)"
  18.209      shows "P b"
  18.210  apply (rule connected_induction [OF \<open>connected S\<close> _, where P = "\<lambda>x. True"], blast)
  18.211 @@ -1767,7 +1767,7 @@
  18.212        and etc: "a \<in> S" "b \<in> S"
  18.213        and sym: "\<And>x y. \<lbrakk>R x y; x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> R y x"
  18.214        and trans: "\<And>x y z. \<lbrakk>R x y; R y z; x \<in> S; y \<in> S; z \<in> S\<rbrakk> \<Longrightarrow> R x z"
  18.215 -      and opI: "\<And>a. a \<in> S \<Longrightarrow> \<exists>T. openin (subtopology euclidean S) T \<and> a \<in> T \<and> (\<forall>x \<in> T. R a x)"
  18.216 +      and opI: "\<And>a. a \<in> S \<Longrightarrow> \<exists>T. openin (top_of_set S) T \<and> a \<in> T \<and> (\<forall>x \<in> T. R a x)"
  18.217      shows "R a b"
  18.218  proof -
  18.219    have "\<And>a b c. \<lbrakk>a \<in> S; b \<in> S; c \<in> S; R a b\<rbrakk> \<Longrightarrow> R a c"
  18.220 @@ -1779,7 +1779,7 @@
  18.221  lemma locally_constant_imp_constant:
  18.222    assumes "connected S"
  18.223        and opI: "\<And>a. a \<in> S
  18.224 -             \<Longrightarrow> \<exists>T. openin (subtopology euclidean S) T \<and> a \<in> T \<and> (\<forall>x \<in> T. f x = f a)"
  18.225 +             \<Longrightarrow> \<exists>T. openin (top_of_set S) T \<and> a \<in> T \<and> (\<forall>x \<in> T. f x = f a)"
  18.226      shows "f constant_on S"
  18.227  proof -
  18.228    have "\<And>x y. x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> f x = f y"
  18.229 @@ -1805,7 +1805,7 @@
  18.230    shows
  18.231      "locally compact s \<longleftrightarrow>
  18.232       (\<forall>x \<in> s. \<exists>u v. x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> s \<and>
  18.233 -                    openin (subtopology euclidean s) u \<and> compact v)"
  18.234 +                    openin (top_of_set s) u \<and> compact v)"
  18.235       (is "?lhs = ?rhs")
  18.236  proof
  18.237    assume ?lhs
  18.238 @@ -1816,11 +1816,11 @@
  18.239  next
  18.240    assume r [rule_format]: ?rhs
  18.241    have *: "\<exists>u v.
  18.242 -              openin (subtopology euclidean s) u \<and>
  18.243 +              openin (top_of_set s) u \<and>
  18.244                compact v \<and> x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> s \<inter> T"
  18.245            if "open T" "x \<in> s" "x \<in> T" for x T
  18.246    proof -
  18.247 -    obtain u v where uv: "x \<in> u" "u \<subseteq> v" "v \<subseteq> s" "compact v" "openin (subtopology euclidean s) u"
  18.248 +    obtain u v where uv: "x \<in> u" "u \<subseteq> v" "v \<subseteq> s" "compact v" "openin (top_of_set s) u"
  18.249        using r [OF \<open>x \<in> s\<close>] by auto
  18.250      obtain e where "e>0" and e: "cball x e \<subseteq> T"
  18.251        using open_contains_cball \<open>open T\<close> \<open>x \<in> T\<close> by blast
  18.252 @@ -1842,7 +1842,7 @@
  18.253    fixes s :: "'a :: metric_space set"
  18.254    assumes "locally compact s"
  18.255    obtains u v where "\<And>x. x \<in> s \<Longrightarrow> x \<in> u x \<and> u x \<subseteq> v x \<and> v x \<subseteq> s \<and>
  18.256 -                             openin (subtopology euclidean s) (u x) \<and> compact (v x)"
  18.257 +                             openin (top_of_set s) (u x) \<and> compact (v x)"
  18.258  using assms
  18.259  unfolding locally_compact by metis
  18.260  
  18.261 @@ -1850,7 +1850,7 @@
  18.262    fixes s :: "'a :: heine_borel set"
  18.263    shows "locally compact s \<longleftrightarrow>
  18.264           (\<forall>x \<in> s. \<exists>u. x \<in> u \<and>
  18.265 -                    openin (subtopology euclidean s) u \<and> compact(closure u) \<and> closure u \<subseteq> s)"
  18.266 +                    openin (top_of_set s) u \<and> compact(closure u) \<and> closure u \<subseteq> s)"
  18.267  apply (simp add: locally_compact)
  18.268  apply (intro ball_cong ex_cong refl iffI)
  18.269  apply (metis bounded_subset closure_eq closure_mono compact_eq_bounded_closed dual_order.trans)
  18.270 @@ -1884,21 +1884,21 @@
  18.271    shows "locally compact s \<longleftrightarrow>
  18.272           (\<forall>k. k \<subseteq> s \<and> compact k
  18.273                \<longrightarrow> (\<exists>u v. k \<subseteq> u \<and> u \<subseteq> v \<and> v \<subseteq> s \<and>
  18.274 -                         openin (subtopology euclidean s) u \<and> compact v))"
  18.275 +                         openin (top_of_set s) u \<and> compact v))"
  18.276          (is "?lhs = ?rhs")
  18.277  proof
  18.278    assume ?lhs
  18.279    then obtain u v where
  18.280      uv: "\<And>x. x \<in> s \<Longrightarrow> x \<in> u x \<and> u x \<subseteq> v x \<and> v x \<subseteq> s \<and>
  18.281 -                             openin (subtopology euclidean s) (u x) \<and> compact (v x)"
  18.282 +                             openin (top_of_set s) (u x) \<and> compact (v x)"
  18.283      by (metis locally_compactE)
  18.284 -  have *: "\<exists>u v. k \<subseteq> u \<and> u \<subseteq> v \<and> v \<subseteq> s \<and> openin (subtopology euclidean s) u \<and> compact v"
  18.285 +  have *: "\<exists>u v. k \<subseteq> u \<and> u \<subseteq> v \<and> v \<subseteq> s \<and> openin (top_of_set s) u \<and> compact v"
  18.286            if "k \<subseteq> s" "compact k" for k
  18.287    proof -
  18.288 -    have "\<And>C. (\<forall>c\<in>C. openin (subtopology euclidean k) c) \<and> k \<subseteq> \<Union>C \<Longrightarrow>
  18.289 +    have "\<And>C. (\<forall>c\<in>C. openin (top_of_set k) c) \<and> k \<subseteq> \<Union>C \<Longrightarrow>
  18.290                      \<exists>D\<subseteq>C. finite D \<and> k \<subseteq> \<Union>D"
  18.291        using that by (simp add: compact_eq_openin_cover)
  18.292 -    moreover have "\<forall>c \<in> (\<lambda>x. k \<inter> u x) ` k. openin (subtopology euclidean k) c"
  18.293 +    moreover have "\<forall>c \<in> (\<lambda>x. k \<inter> u x) ` k. openin (top_of_set k) c"
  18.294        using that by clarify (metis subsetD inf.absorb_iff2 openin_subset openin_subtopology_Int_subset topspace_euclidean_subtopology uv)
  18.295      moreover have "k \<subseteq> \<Union>((\<lambda>x. k \<inter> u x) ` k)"
  18.296        using that by clarsimp (meson subsetCE uv)
  18.297 @@ -1931,12 +1931,12 @@
  18.298    assumes "open s"
  18.299      shows "locally compact s"
  18.300  proof -
  18.301 -  have *: "\<exists>u v. x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> s \<and> openin (subtopology euclidean s) u \<and> compact v"
  18.302 +  have *: "\<exists>u v. x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> s \<and> openin (top_of_set s) u \<and> compact v"
  18.303            if "x \<in> s" for x
  18.304    proof -
  18.305      obtain e where "e>0" and e: "cball x e \<subseteq> s"
  18.306        using open_contains_cball assms \<open>x \<in> s\<close> by blast
  18.307 -    have ope: "openin (subtopology euclidean s) (ball x e)"
  18.308 +    have ope: "openin (top_of_set s) (ball x e)"
  18.309        by (meson e open_ball ball_subset_cball dual_order.trans open_subset)
  18.310      show ?thesis
  18.311        apply (rule_tac x="ball x e" in exI)
  18.312 @@ -1955,7 +1955,7 @@
  18.313      shows "locally compact s"
  18.314  proof -
  18.315    have *: "\<exists>u v. x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> s \<and>
  18.316 -                 openin (subtopology euclidean s) u \<and> compact v"
  18.317 +                 openin (top_of_set s) u \<and> compact v"
  18.318            if "x \<in> s" for x
  18.319    proof -
  18.320      show ?thesis
  18.321 @@ -1979,7 +1979,7 @@
  18.322  
  18.323  lemma locally_compact_closedin:
  18.324    fixes s :: "'a :: heine_borel set"
  18.325 -  shows "\<lbrakk>closedin (subtopology euclidean s) t; locally compact s\<rbrakk>
  18.326 +  shows "\<lbrakk>closedin (top_of_set s) t; locally compact s\<rbrakk>
  18.327          \<Longrightarrow> locally compact t"
  18.328  unfolding closedin_closed
  18.329  using closed_imp_locally_compact locally_compact_Int by blast
  18.330 @@ -2010,8 +2010,8 @@
  18.331  lemma locally_compact_openin_Un:
  18.332    fixes S :: "'a::euclidean_space set"
  18.333    assumes LCS: "locally compact S" and LCT:"locally compact T"
  18.334 -      and opS: "openin (subtopology euclidean (S \<union> T)) S"
  18.335 -      and opT: "openin (subtopology euclidean (S \<union> T)) T"
  18.336 +      and opS: "openin (top_of_set (S \<union> T)) S"
  18.337 +      and opT: "openin (top_of_set (S \<union> T)) T"
  18.338      shows "locally compact (S \<union> T)"
  18.339  proof -
  18.340    have "\<exists>e>0. closed (cball x e \<inter> (S \<union> T))" if "x \<in> S" for x
  18.341 @@ -2047,8 +2047,8 @@
  18.342  lemma locally_compact_closedin_Un:
  18.343    fixes S :: "'a::euclidean_space set"
  18.344    assumes LCS: "locally compact S" and LCT:"locally compact T"
  18.345 -      and clS: "closedin (subtopology euclidean (S \<union> T)) S"
  18.346 -      and clT: "closedin (subtopology euclidean (S \<union> T)) T"
  18.347 +      and clS: "closedin (top_of_set (S \<union> T)) S"
  18.348 +      and clT: "closedin (top_of_set (S \<union> T)) T"
  18.349      shows "locally compact (S \<union> T)"
  18.350  proof -
  18.351    have "\<exists>e>0. closed (cball x e \<inter> (S \<union> T))" if "x \<in> S" "x \<in> T" for x
  18.352 @@ -2113,7 +2113,7 @@
  18.353     "locally compact S \<longleftrightarrow>
  18.354      (\<forall>K T. K \<subseteq> S \<and> compact K \<and> open T \<and> K \<subseteq> T
  18.355            \<longrightarrow> (\<exists>U V. K \<subseteq> U \<and> U \<subseteq> V \<and> U \<subseteq> T \<and> V \<subseteq> S \<and>
  18.356 -                     openin (subtopology euclidean S) U \<and> compact V))"
  18.357 +                     openin (top_of_set S) U \<and> compact V))"
  18.358     (is "?lhs = ?rhs")
  18.359  proof
  18.360    assume L: ?lhs
  18.361 @@ -2122,10 +2122,10 @@
  18.362      fix K :: "'a set" and T :: "'a set"
  18.363      assume "K \<subseteq> S" and "compact K" and "open T" and "K \<subseteq> T"
  18.364      obtain U V where "K \<subseteq> U" "U \<subseteq> V" "V \<subseteq> S" "compact V"
  18.365 -                 and ope: "openin (subtopology euclidean S) U"
  18.366 +                 and ope: "openin (top_of_set S) U"
  18.367        using L unfolding locally_compact_compact by (meson \<open>K \<subseteq> S\<close> \<open>compact K\<close>)
  18.368      show "\<exists>U V. K \<subseteq> U \<and> U \<subseteq> V \<and> U \<subseteq> T \<and> V \<subseteq> S \<and>
  18.369 -                openin (subtopology euclidean S) U \<and> compact V"
  18.370 +                openin (top_of_set S) U \<and> compact V"
  18.371      proof (intro exI conjI)
  18.372        show "K \<subseteq> U \<inter> T"
  18.373          by (simp add: \<open>K \<subseteq> T\<close> \<open>K \<subseteq> U\<close>)
  18.374 @@ -2133,7 +2133,7 @@
  18.375          by (rule closure_subset)
  18.376        show "closure (U \<inter> T) \<subseteq> S"
  18.377          by (metis \<open>U \<subseteq> V\<close> \<open>V \<subseteq> S\<close> \<open>compact V\<close> closure_closed closure_mono compact_imp_closed inf.cobounded1 subset_trans)
  18.378 -      show "openin (subtopology euclidean S) (U \<inter> T)"
  18.379 +      show "openin (top_of_set S) (U \<inter> T)"
  18.380          by (simp add: \<open>open T\<close> ope openin_Int_open)
  18.381        show "compact (closure (U \<inter> T))"
  18.382          by (meson Int_lower1 \<open>U \<subseteq> V\<close> \<open>compact V\<close> bounded_subset compact_closure compact_eq_bounded_closed)
  18.383 @@ -2151,8 +2151,8 @@
  18.384  proposition Sura_Bura_compact:
  18.385    fixes S :: "'a::euclidean_space set"
  18.386    assumes "compact S" and C: "C \<in> components S"
  18.387 -  shows "C = \<Inter>{T. C \<subseteq> T \<and> openin (subtopology euclidean S) T \<and>
  18.388 -                           closedin (subtopology euclidean S) T}"
  18.389 +  shows "C = \<Inter>{T. C \<subseteq> T \<and> openin (top_of_set S) T \<and>
  18.390 +                           closedin (top_of_set S) T}"
  18.391           (is "C = \<Inter>?\<T>")
  18.392  proof
  18.393    obtain x where x: "C = connected_component_set S x" and "x \<in> S"
  18.394 @@ -2168,8 +2168,8 @@
  18.395      have clo: "closed (\<Inter>?\<T>)"
  18.396        by (simp add: \<open>compact S\<close> closed_Inter closedin_compact_eq compact_imp_closed)
  18.397      have False
  18.398 -      if K1: "closedin (subtopology euclidean (\<Inter>?\<T>)) K1" and
  18.399 -         K2: "closedin (subtopology euclidean (\<Inter>?\<T>)) K2" and
  18.400 +      if K1: "closedin (top_of_set (\<Inter>?\<T>)) K1" and
  18.401 +         K2: "closedin (top_of_set (\<Inter>?\<T>)) K2" and
  18.402           K12_Int: "K1 \<inter> K2 = {}" and K12_Un: "K1 \<union> K2 = \<Inter>?\<T>" and "K1 \<noteq> {}" "K2 \<noteq> {}"
  18.403         for K1 K2
  18.404      proof -
  18.405 @@ -2187,8 +2187,8 @@
  18.406          show "(S - (V1 \<union> V2)) \<inter> \<Inter>\<F> \<noteq> {}" if "finite \<F>" and \<F>: "\<F> \<subseteq> ?\<T>" for \<F>
  18.407          proof
  18.408            assume djo: "(S - (V1 \<union> V2)) \<inter> \<Inter>\<F> = {}"
  18.409 -          obtain D where opeD: "openin (subtopology euclidean S) D"
  18.410 -                   and cloD: "closedin (subtopology euclidean S) D"
  18.411 +          obtain D where opeD: "openin (top_of_set S) D"
  18.412 +                   and cloD: "closedin (top_of_set S) D"
  18.413                     and "C \<subseteq> D" and DV12: "D \<subseteq> V1 \<union> V2"
  18.414            proof (cases "\<F> = {}")
  18.415              case True
  18.416 @@ -2197,9 +2197,9 @@
  18.417            next
  18.418              case False show ?thesis
  18.419              proof
  18.420 -              show ope: "openin (subtopology euclidean S) (\<Inter>\<F>)"
  18.421 +              show ope: "openin (top_of_set S) (\<Inter>\<F>)"
  18.422                  using openin_Inter \<open>finite \<F>\<close> False \<F> by blast
  18.423 -              then show "closedin (subtopology euclidean S) (\<Inter>\<F>)"
  18.424 +              then show "closedin (top_of_set S) (\<Inter>\<F>)"
  18.425                  by (meson clo\<T> \<F> closed_Inter closed_subset openin_imp_subset subset_eq)
  18.426                show "C \<subseteq> \<Inter>\<F>"
  18.427                  using \<F> by auto
  18.428 @@ -2211,16 +2211,16 @@
  18.429              by (simp add: x)
  18.430            have "closed D"
  18.431              using \<open>compact S\<close> cloD closedin_closed_trans compact_imp_closed by blast
  18.432 -          have cloV1: "closedin (subtopology euclidean D) (D \<inter> closure V1)"
  18.433 -            and cloV2: "closedin (subtopology euclidean D) (D \<inter> closure V2)"
  18.434 +          have cloV1: "closedin (top_of_set D) (D \<inter> closure V1)"
  18.435 +            and cloV2: "closedin (top_of_set D) (D \<inter> closure V2)"
  18.436              by (simp_all add: closedin_closed_Int)
  18.437            moreover have "D \<inter> closure V1 = D \<inter> V1" "D \<inter> closure V2 = D \<inter> V2"
  18.438              apply safe
  18.439              using \<open>D \<subseteq> V1 \<union> V2\<close> \<open>open V1\<close> \<open>open V2\<close> V12
  18.440                 apply (simp_all add: closure_subset [THEN subsetD] closure_iff_nhds_not_empty, blast+)
  18.441              done
  18.442 -          ultimately have cloDV1: "closedin (subtopology euclidean D) (D \<inter> V1)"
  18.443 -                      and cloDV2:  "closedin (subtopology euclidean D) (D \<inter> V2)"
  18.444 +          ultimately have cloDV1: "closedin (top_of_set D) (D \<inter> V1)"
  18.445 +                      and cloDV2:  "closedin (top_of_set D) (D \<inter> V2)"
  18.446              by metis+
  18.447            then obtain U1 U2 where "closed U1" "closed U2"
  18.448                 and D1: "D \<inter> V1 = D \<inter> U1" and D2: "D \<inter> V2 = D \<inter> U2"
  18.449 @@ -2274,21 +2274,21 @@
  18.450    fixes S :: "'a::euclidean_space set"
  18.451    assumes S: "locally compact S" and C: "C \<in> components S" and "compact C"
  18.452        and U: "open U" "C \<subseteq> U"
  18.453 -  obtains K where "openin (subtopology euclidean S) K" "compact K" "C \<subseteq> K" "K \<subseteq> U"
  18.454 +  obtains K where "openin (top_of_set S) K" "compact K" "C \<subseteq> K" "K \<subseteq> U"
  18.455  proof (rule ccontr)
  18.456    assume "\<not> thesis"
  18.457 -  with that have neg: "\<nexists>K. openin (subtopology euclidean S) K \<and> compact K \<and> C \<subseteq> K \<and> K \<subseteq> U"
  18.458 +  with that have neg: "\<nexists>K. openin (top_of_set S) K \<and> compact K \<and> C \<subseteq> K \<and> K \<subseteq> U"
  18.459      by metis
  18.460    obtain V K where "C \<subseteq> V" "V \<subseteq> U" "V \<subseteq> K" "K \<subseteq> S" "compact K"
  18.461 -               and opeSV: "openin (subtopology euclidean S) V"
  18.462 +               and opeSV: "openin (top_of_set S) V"
  18.463      using S U \<open>compact C\<close>
  18.464      apply (simp add: locally_compact_compact_subopen)
  18.465      by (meson C in_components_subset)
  18.466 -  let ?\<T> = "{T. C \<subseteq> T \<and> openin (subtopology euclidean K) T \<and> compact T \<and> T \<subseteq> K}"
  18.467 +  let ?\<T> = "{T. C \<subseteq> T \<and> openin (top_of_set K) T \<and> compact T \<and> T \<subseteq> K}"
  18.468    have CK: "C \<in> components K"
  18.469      by (meson C \<open>C \<subseteq> V\<close> \<open>K \<subseteq> S\<close> \<open>V \<subseteq> K\<close> components_intermediate_subset subset_trans)
  18.470    with \<open>compact K\<close>
  18.471 -  have "C = \<Inter>{T. C \<subseteq> T \<and> openin (subtopology euclidean K) T \<and> closedin (subtopology euclidean K) T}"
  18.472 +  have "C = \<Inter>{T. C \<subseteq> T \<and> openin (top_of_set K) T \<and> closedin (top_of_set K) T}"
  18.473      by (simp add: Sura_Bura_compact)
  18.474    then have Ceq: "C = \<Inter>?\<T>"
  18.475      by (simp add: closedin_compact_eq \<open>compact K\<close>)
  18.476 @@ -2322,11 +2322,11 @@
  18.477            by (metis (no_types, lifting) compact_Inter False mem_Collect_eq subsetCE \<F>)
  18.478          moreover have "\<Inter>\<F> \<subseteq> K"
  18.479            using False that(2) by fastforce
  18.480 -        moreover have opeKF: "openin (subtopology euclidean K) (\<Inter>\<F>)"
  18.481 +        moreover have opeKF: "openin (top_of_set K) (\<Inter>\<F>)"
  18.482            using False \<F> \<open>finite \<F>\<close> by blast
  18.483 -        then have opeVF: "openin (subtopology euclidean V) (\<Inter>\<F>)"
  18.484 +        then have opeVF: "openin (top_of_set V) (\<Inter>\<F>)"
  18.485            using W \<open>K \<subseteq> S\<close> \<open>V \<subseteq> K\<close> opeKF \<open>\<Inter>\<F> \<subseteq> K\<close> FUW openin_subset_trans by fastforce
  18.486 -        then have "openin (subtopology euclidean S) (\<Inter>\<F>)"
  18.487 +        then have "openin (top_of_set S) (\<Inter>\<F>)"
  18.488            by (metis opeSV openin_trans)
  18.489          moreover have "\<Inter>\<F> \<subseteq> U"
  18.490            by (meson \<open>V \<subseteq> U\<close> opeVF dual_order.trans openin_imp_subset)
  18.491 @@ -2343,8 +2343,8 @@
  18.492  corollary Sura_Bura_clopen_subset_alt:
  18.493    fixes S :: "'a::euclidean_space set"
  18.494    assumes S: "locally compact S" and C: "C \<in> components S" and "compact C"
  18.495 -      and opeSU: "openin (subtopology euclidean S) U" and "C \<subseteq> U"
  18.496 -  obtains K where "openin (subtopology euclidean S) K" "compact K" "C \<subseteq> K" "K \<subseteq> U"
  18.497 +      and opeSU: "openin (top_of_set S) U" and "C \<subseteq> U"
  18.498 +  obtains K where "openin (top_of_set S) K" "compact K" "C \<subseteq> K" "K \<subseteq> U"
  18.499  proof -
  18.500    obtain V where "open V" "U = S \<inter> V"
  18.501      using opeSU by (auto simp: openin_open)
  18.502 @@ -2358,13 +2358,13 @@
  18.503  corollary Sura_Bura:
  18.504    fixes S :: "'a::euclidean_space set"
  18.505    assumes "locally compact S" "C \<in> components S" "compact C"
  18.506 -  shows "C = \<Inter> {K. C \<subseteq> K \<and> compact K \<and> openin (subtopology euclidean S) K}"
  18.507 +  shows "C = \<Inter> {K. C \<subseteq> K \<and> compact K \<and> openin (top_of_set S) K}"
  18.508           (is "C = ?rhs")
  18.509  proof
  18.510    show "?rhs \<subseteq> C"
  18.511    proof (clarsimp, rule ccontr)
  18.512      fix x
  18.513 -    assume *: "\<forall>X. C \<subseteq> X \<and> compact X \<and> openin (subtopology euclidean S) X \<longrightarrow> x \<in> X"
  18.514 +    assume *: "\<forall>X. C \<subseteq> X \<and> compact X \<and> openin (top_of_set S) X \<longrightarrow> x \<in> X"
  18.515        and "x \<notin> C"
  18.516      obtain U V where "open U" "open V" "{x} \<subseteq> U" "C \<subseteq> V" "U \<inter> V = {}"
  18.517        using separation_normal [of "{x}" C]
  18.518 @@ -2381,8 +2381,8 @@
  18.519  
  18.520  lemma locally_connected_1:
  18.521    assumes
  18.522 -    "\<And>v x. \<lbrakk>openin (subtopology euclidean S) v; x \<in> v\<rbrakk>
  18.523 -              \<Longrightarrow> \<exists>u. openin (subtopology euclidean S) u \<and>
  18.524 +    "\<And>v x. \<lbrakk>openin (top_of_set S) v; x \<in> v\<rbrakk>
  18.525 +              \<Longrightarrow> \<exists>u. openin (top_of_set S) u \<and>
  18.526                        connected u \<and> x \<in> u \<and> u \<subseteq> v"
  18.527     shows "locally connected S"
  18.528  apply (clarsimp simp add: locally_def)
  18.529 @@ -2391,12 +2391,12 @@
  18.530  
  18.531  lemma locally_connected_2:
  18.532    assumes "locally connected S"
  18.533 -          "openin (subtopology euclidean S) t"
  18.534 +          "openin (top_of_set S) t"
  18.535            "x \<in> t"
  18.536 -   shows "openin (subtopology euclidean S) (connected_component_set t x)"
  18.537 +   shows "openin (top_of_set S) (connected_component_set t x)"
  18.538  proof -
  18.539    { fix y :: 'a
  18.540 -    let ?SS = "subtopology euclidean S"
  18.541 +    let ?SS = "top_of_set S"
  18.542      assume 1: "openin ?SS t"
  18.543                "\<forall>w x. openin ?SS w \<and> x \<in> w \<longrightarrow> (\<exists>u. openin ?SS u \<and> (\<exists>v. connected v \<and> x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> w))"
  18.544      and "connected_component t x y"
  18.545 @@ -2420,29 +2420,29 @@
  18.546  qed
  18.547  
  18.548  lemma locally_connected_3:
  18.549 -  assumes "\<And>t x. \<lbrakk>openin (subtopology euclidean S) t; x \<in> t\<rbrakk>
  18.550 -              \<Longrightarrow> openin (subtopology euclidean S)
  18.551 +  assumes "\<And>t x. \<lbrakk>openin (top_of_set S) t; x \<in> t\<rbrakk>
  18.552 +              \<Longrightarrow> openin (top_of_set S)
  18.553                            (connected_component_set t x)"
  18.554 -          "openin (subtopology euclidean S) v" "x \<in> v"
  18.555 -   shows  "\<exists>u. openin (subtopology euclidean S) u \<and> connected u \<and> x \<in> u \<and> u \<subseteq> v"
  18.556 +          "openin (top_of_set S) v" "x \<in> v"
  18.557 +   shows  "\<exists>u. openin (top_of_set S) u \<and> connected u \<and> x \<in> u \<and> u \<subseteq> v"
  18.558  using assms connected_component_subset by fastforce
  18.559  
  18.560  lemma locally_connected:
  18.561    "locally connected S \<longleftrightarrow>
  18.562 -   (\<forall>v x. openin (subtopology euclidean S) v \<and> x \<in> v
  18.563 -          \<longrightarrow> (\<exists>u. openin (subtopology euclidean S) u \<and> connected u \<and> x \<in> u \<and> u \<subseteq> v))"
  18.564 +   (\<forall>v x. openin (top_of_set S) v \<and> x \<in> v
  18.565 +          \<longrightarrow> (\<exists>u. openin (top_of_set S) u \<and> connected u \<and> x \<in> u \<and> u \<subseteq> v))"
  18.566  by (metis locally_connected_1 locally_connected_2 locally_connected_3)
  18.567  
  18.568  lemma locally_connected_open_connected_component:
  18.569    "locally connected S \<longleftrightarrow>
  18.570 -   (\<forall>t x. openin (subtopology euclidean S) t \<and> x \<in> t
  18.571 -          \<longrightarrow> openin (subtopology euclidean S) (connected_component_set t x))"
  18.572 +   (\<forall>t x. openin (top_of_set S) t \<and> x \<in> t
  18.573 +          \<longrightarrow> openin (top_of_set S) (connected_component_set t x))"
  18.574  by (metis locally_connected_1 locally_connected_2 locally_connected_3)
  18.575  
  18.576  lemma locally_path_connected_1:
  18.577    assumes
  18.578 -    "\<And>v x. \<lbrakk>openin (subtopology euclidean S) v; x \<in> v\<rbrakk>
  18.579 -              \<Longrightarrow> \<exists>u. openin (subtopology euclidean S) u \<and> path_connected u \<and> x \<in> u \<and> u \<subseteq> v"
  18.580 +    "\<And>v x. \<lbrakk>openin (top_of_set S) v; x \<in> v\<rbrakk>
  18.581 +              \<Longrightarrow> \<exists>u. openin (top_of_set S) u \<and> path_connected u \<and> x \<in> u \<and> u \<subseteq> v"
  18.582     shows "locally path_connected S"
  18.583  apply (clarsimp simp add: locally_def)
  18.584  apply (drule assms; blast)
  18.585 @@ -2450,12 +2450,12 @@
  18.586  
  18.587  lemma locally_path_connected_2:
  18.588    assumes "locally path_connected S"
  18.589 -          "openin (subtopology euclidean S) t"
  18.590 +          "openin (top_of_set S) t"
  18.591            "x \<in> t"
  18.592 -   shows "openin (subtopology euclidean S) (path_component_set t x)"
  18.593 +   shows "openin (top_of_set S) (path_component_set t x)"
  18.594  proof -
  18.595    { fix y :: 'a
  18.596 -    let ?SS = "subtopology euclidean S"
  18.597 +    let ?SS = "top_of_set S"
  18.598      assume 1: "openin ?SS t"
  18.599                "\<forall>w x. openin ?SS w \<and> x \<in> w \<longrightarrow> (\<exists>u. openin ?SS u \<and> (\<exists>v. path_connected v \<and> x \<in> u \<and> u \<subseteq> v \<and> v \<subseteq> w))"
  18.600      and "path_component t x y"
  18.601 @@ -2479,10 +2479,10 @@
  18.602  qed
  18.603  
  18.604  lemma locally_path_connected_3:
  18.605 -  assumes "\<And>t x. \<lbrakk>openin (subtopology euclidean S) t; x \<in> t\<rbrakk>
  18.606 -              \<Longrightarrow> openin (subtopology euclidean S) (path_component_set t x)"
  18.607 -          "openin (subtopology euclidean S) v" "x \<in> v"
  18.608 -   shows  "\<exists>u. openin (subtopology euclidean S) u \<and> path_connected u \<and> x \<in> u \<and> u \<subseteq> v"
  18.609 +  assumes "\<And>t x. \<lbrakk>openin (top_of_set S) t; x \<in> t\<rbrakk>
  18.610 +              \<Longrightarrow> openin (top_of_set S) (path_component_set t x)"
  18.611 +          "openin (top_of_set S) v" "x \<in> v"
  18.612 +   shows  "\<exists>u. openin (top_of_set S) u \<and> path_connected u \<and> x \<in> u \<and> u \<subseteq> v"
  18.613  proof -
  18.614    have "path_component v x x"
  18.615      by (meson assms(3) path_component_refl)
  18.616 @@ -2492,26 +2492,26 @@
  18.617  
  18.618  proposition locally_path_connected:
  18.619    "locally path_connected S \<longleftrightarrow>
  18.620 -   (\<forall>v x. openin (subtopology euclidean S) v \<and> x \<in> v
  18.621 -          \<longrightarrow> (\<exists>u. openin (subtopology euclidean S) u \<and> path_connected u \<and> x \<in> u \<and> u \<subseteq> v))"
  18.622 +   (\<forall>v x. openin (top_of_set S) v \<and> x \<in> v
  18.623 +          \<longrightarrow> (\<exists>u. openin (top_of_set S) u \<and> path_connected u \<and> x \<in> u \<and> u \<subseteq> v))"
  18.624    by (metis locally_path_connected_1 locally_path_connected_2 locally_path_connected_3)
  18.625  
  18.626  proposition locally_path_connected_open_path_component:
  18.627    "locally path_connected S \<longleftrightarrow>
  18.628 -   (\<forall>t x. openin (subtopology euclidean S) t \<and> x \<in> t
  18.629 -          \<longrightarrow> openin (subtopology euclidean S) (path_component_set t x))"
  18.630 +   (\<forall>t x. openin (top_of_set S) t \<and> x \<in> t
  18.631 +          \<longrightarrow> openin (top_of_set S) (path_component_set t x))"
  18.632    by (metis locally_path_connected_1 locally_path_connected_2 locally_path_connected_3)
  18.633  
  18.634  lemma locally_connected_open_component:
  18.635    "locally connected S \<longleftrightarrow>
  18.636 -   (\<forall>t c. openin (subtopology euclidean S) t \<and> c \<in> components t
  18.637 -          \<longrightarrow> openin (subtopology euclidean S) c)"
  18.638 +   (\<forall>t c. openin (top_of_set S) t \<and> c \<in> components t
  18.639 +          \<longrightarrow> openin (top_of_set S) c)"
  18.640  by (metis components_iff locally_connected_open_connected_component)
  18.641  
  18.642  proposition locally_connected_im_kleinen:
  18.643    "locally connected S \<longleftrightarrow>
  18.644 -   (\<forall>v x. openin (subtopology euclidean S) v \<and> x \<in> v
  18.645 -       \<longrightarrow> (\<exists>u. openin (subtopology euclidean S) u \<and>
  18.646 +   (\<forall>v x. openin (top_of_set S) v \<and> x \<in> v
  18.647 +       \<longrightarrow> (\<exists>u. openin (top_of_set S) u \<and>
  18.648                  x \<in> u \<and> u \<subseteq> v \<and>
  18.649                  (\<forall>y. y \<in> u \<longrightarrow> (\<exists>c. connected c \<and> c \<subseteq> v \<and> x \<in> c \<and> y \<in> c))))"
  18.650     (is "?lhs = ?rhs")
  18.651 @@ -2521,12 +2521,12 @@
  18.652      by (fastforce simp add: locally_connected)
  18.653  next
  18.654    assume ?rhs
  18.655 -  have *: "\<exists>T. openin (subtopology euclidean S) T \<and> x \<in> T \<and> T \<subseteq> c"
  18.656 -       if "openin (subtopology euclidean S) t" and c: "c \<in> components t" and "x \<in> c" for t c x
  18.657 +  have *: "\<exists>T. openin (top_of_set S) T \<and> x \<in> T \<and> T \<subseteq> c"
  18.658 +       if "openin (top_of_set S) t" and c: "c \<in> components t" and "x \<in> c" for t c x
  18.659    proof -
  18.660      from that \<open>?rhs\<close> [rule_format, of t x]
  18.661      obtain u where u:
  18.662 -      "openin (subtopology euclidean S) u \<and> x \<in> u \<and> u \<subseteq> t \<and>
  18.663 +      "openin (top_of_set S) u \<and> x \<in> u \<and> u \<subseteq> t \<and>
  18.664         (\<forall>y. y \<in> u \<longrightarrow> (\<exists>c. connected c \<and> c \<subseteq> t \<and> x \<in> c \<and> y \<in> c))"
  18.665        using in_components_subset by auto
  18.666      obtain F :: "'a set \<Rightarrow> 'a set \<Rightarrow> 'a" where
  18.667 @@ -2551,8 +2551,8 @@
  18.668  
  18.669  proposition locally_path_connected_im_kleinen:
  18.670    "locally path_connected S \<longleftrightarrow>
  18.671 -   (\<forall>v x. openin (subtopology euclidean S) v \<and> x \<in> v
  18.672 -       \<longrightarrow> (\<exists>u. openin (subtopology euclidean S) u \<and>
  18.673 +   (\<forall>v x. openin (top_of_set S) v \<and> x \<in> v
  18.674 +       \<longrightarrow> (\<exists>u. openin (top_of_set S) u \<and>
  18.675                  x \<in> u \<and> u \<subseteq> v \<and>
  18.676                  (\<forall>y. y \<in> u \<longrightarrow> (\<exists>p. path p \<and> path_image p \<subseteq> v \<and>
  18.677                                  pathstart p = x \<and> pathfinish p = y))))"
  18.678 @@ -2565,15 +2565,15 @@
  18.679      by (meson dual_order.trans)
  18.680  next
  18.681    assume ?rhs
  18.682 -  have *: "\<exists>T. openin (subtopology euclidean S) T \<and>
  18.683 +  have *: "\<exists>T. openin (top_of_set S) T \<and>
  18.684                 x \<in> T \<and> T \<subseteq> path_component_set u z"
  18.685 -       if "openin (subtopology euclidean S) u" and "z \<in> u" and c: "path_component u z x" for u z x
  18.686 +       if "openin (top_of_set S) u" and "z \<in> u" and c: "path_component u z x" for u z x
  18.687    proof -
  18.688      have "x \<in> u"
  18.689        by (meson c path_component_mem(2))
  18.690      with that \<open>?rhs\<close> [rule_format, of u x]
  18.691      obtain U where U:
  18.692 -      "openin (subtopology euclidean S) U \<and> x \<in> U \<and> U \<subseteq> u \<and>
  18.693 +      "openin (top_of_set S) U \<and> x \<in> U \<and> U \<subseteq> u \<and>
  18.694         (\<forall>y. y \<in> U \<longrightarrow> (\<exists>p. path p \<and> path_image p \<subseteq> u \<and> pathstart p = x \<and> pathfinish p = y))"
  18.695         by blast
  18.696      show ?thesis
  18.697 @@ -2626,22 +2626,22 @@
  18.698  
  18.699  lemma openin_connected_component_locally_connected:
  18.700      "locally connected S
  18.701 -     \<Longrightarrow> openin (subtopology euclidean S) (connected_component_set S x)"
  18.702 +     \<Longrightarrow> openin (top_of_set S) (connected_component_set S x)"
  18.703  apply (simp add: locally_connected_open_connected_component)
  18.704  by (metis connected_component_eq_empty connected_component_subset open_empty open_subset openin_subtopology_self)
  18.705  
  18.706  lemma openin_components_locally_connected:
  18.707 -    "\<lbrakk>locally connected S; c \<in> components S\<rbrakk> \<Longrightarrow> openin (subtopology euclidean S) c"
  18.708 +    "\<lbrakk>locally connected S; c \<in> components S\<rbrakk> \<Longrightarrow> openin (top_of_set S) c"
  18.709    using locally_connected_open_component openin_subtopology_self by blast
  18.710  
  18.711  lemma openin_path_component_locally_path_connected:
  18.712    "locally path_connected S
  18.713 -        \<Longrightarrow> openin (subtopology euclidean S) (path_component_set S x)"
  18.714 +        \<Longrightarrow> openin (top_of_set S) (path_component_set S x)"
  18.715  by (metis (no_types) empty_iff locally_path_connected_2 openin_subopen openin_subtopology_self path_component_eq_empty)
  18.716  
  18.717  lemma closedin_path_component_locally_path_connected:
  18.718      "locally path_connected S
  18.719 -        \<Longrightarrow> closedin (subtopology euclidean S) (path_component_set S x)"
  18.720 +        \<Longrightarrow> closedin (top_of_set S) (path_component_set S x)"
  18.721  apply  (simp add: closedin_def path_component_subset complement_path_component_Union)
  18.722  apply (rule openin_Union)
  18.723  using openin_path_component_locally_path_connected by auto
  18.724 @@ -2670,12 +2670,12 @@
  18.725      shows "(path_component S x = connected_component S x)"
  18.726  proof (cases "x \<in> S")
  18.727    case True
  18.728 -  have "openin (subtopology euclidean (connected_component_set S x)) (path_component_set S x)"
  18.729 +  have "openin (top_of_set (connected_component_set S x)) (path_component_set S x)"
  18.730      apply (rule openin_subset_trans [of S])
  18.731      apply (intro conjI openin_path_component_locally_path_connected [OF assms])
  18.732      using path_component_subset_connected_component   apply (auto simp: connected_component_subset)
  18.733      done
  18.734 -  moreover have "closedin (subtopology euclidean (connected_component_set S x)) (path_component_set S x)"
  18.735 +  moreover have "closedin (top_of_set (connected_component_set S x)) (path_component_set S x)"
  18.736      apply (rule closedin_subset_trans [of S])
  18.737      apply (intro conjI closedin_path_component_locally_path_connected [OF assms])
  18.738      using path_component_subset_connected_component   apply (auto simp: connected_component_subset)
  18.739 @@ -2710,26 +2710,26 @@
  18.740  proposition locally_connected_quotient_image:
  18.741    assumes lcS: "locally connected S"
  18.742        and oo: "\<And>T. T \<subseteq> f ` S
  18.743 -                \<Longrightarrow> openin (subtopology euclidean S) (S \<inter> f -` T) \<longleftrightarrow>
  18.744 -                    openin (subtopology euclidean (f ` S)) T"
  18.745 +                \<Longrightarrow> openin (top_of_set S) (S \<inter> f -` T) \<longleftrightarrow>
  18.746 +                    openin (top_of_set (f ` S)) T"
  18.747      shows "locally connected (f ` S)"
  18.748  proof (clarsimp simp: locally_connected_open_component)
  18.749    fix U C
  18.750 -  assume opefSU: "openin (subtopology euclidean (f ` S)) U" and "C \<in> components U"
  18.751 +  assume opefSU: "openin (top_of_set (f ` S)) U" and "C \<in> components U"
  18.752    then have "C \<subseteq> U" "U \<subseteq> f ` S"
  18.753      by (meson in_components_subset openin_imp_subset)+
  18.754 -  then have "openin (subtopology euclidean (f ` S)) C \<longleftrightarrow>
  18.755 -             openin (subtopology euclidean S) (S \<inter> f -` C)"
  18.756 +  then have "openin (top_of_set (f ` S)) C \<longleftrightarrow>
  18.757 +             openin (top_of_set S) (S \<inter> f -` C)"
  18.758      by (auto simp: oo)
  18.759 -  moreover have "openin (subtopology euclidean S) (S \<inter> f -` C)"
  18.760 +  moreover have "openin (top_of_set S) (S \<inter> f -` C)"
  18.761    proof (subst openin_subopen, clarify)
  18.762      fix x
  18.763      assume "x \<in> S" "f x \<in> C"
  18.764 -    show "\<exists>T. openin (subtopology euclidean S) T \<and> x \<in> T \<and> T \<subseteq> (S \<inter> f -` C)"
  18.765 +    show "\<exists>T. openin (top_of_set S) T \<and> x \<in> T \<and> T \<subseteq> (S \<inter> f -` C)"
  18.766      proof (intro conjI exI)
  18.767 -      show "openin (subtopology euclidean S) (connected_component_set (S \<inter> f -` U) x)"
  18.768 +      show "openin (top_of_set S) (connected_component_set (S \<inter> f -` U) x)"
  18.769        proof (rule ccontr)
  18.770 -        assume **: "\<not> openin (subtopology euclidean S) (connected_component_set (S \<inter> f -` U) x)"
  18.771 +        assume **: "\<not> openin (top_of_set S) (connected_component_set (S \<inter> f -` U) x)"
  18.772          then have "x \<notin> (S \<inter> f -` U)"
  18.773            using \<open>U \<subseteq> f ` S\<close> opefSU lcS locally_connected_2 oo by blast
  18.774          with ** show False
  18.775 @@ -2768,7 +2768,7 @@
  18.776        finally show "connected_component_set (S \<inter> f -` U) x \<subseteq> (S \<inter> f -` C)" .
  18.777      qed
  18.778    qed
  18.779 -  ultimately show "openin (subtopology euclidean (f ` S)) C"
  18.780 +  ultimately show "openin (top_of_set (f ` S)) C"
  18.781      by metis
  18.782  qed
  18.783  
  18.784 @@ -2776,32 +2776,32 @@
  18.785  proposition locally_path_connected_quotient_image:
  18.786    assumes lcS: "locally path_connected S"
  18.787        and oo: "\<And>T. T \<subseteq> f ` S
  18.788 -                \<Longrightarrow> openin (subtopology euclidean S) (S \<inter> f -` T) \<longleftrightarrow> openin (subtopology euclidean (f ` S)) T"
  18.789 +                \<Longrightarrow> openin (top_of_set S) (S \<inter> f -` T) \<longleftrightarrow> openin (top_of_set (f ` S)) T"
  18.790      shows "locally path_connected (f ` S)"
  18.791  proof (clarsimp simp: locally_path_connected_open_path_component)
  18.792    fix U y
  18.793 -  assume opefSU: "openin (subtopology euclidean (f ` S)) U" and "y \<in> U"
  18.794 +  assume opefSU: "openin (top_of_set (f ` S)) U" and "y \<in> U"
  18.795    then have "path_component_set U y \<subseteq> U" "U \<subseteq> f ` S"
  18.796      by (meson path_component_subset openin_imp_subset)+
  18.797 -  then have "openin (subtopology euclidean (f ` S)) (path_component_set U y) \<longleftrightarrow>
  18.798 -             openin (subtopology euclidean S) (S \<inter> f -` path_component_set U y)"
  18.799 +  then have "openin (top_of_set (f ` S)) (path_component_set U y) \<longleftrightarrow>
  18.800 +             openin (top_of_set S) (S \<inter> f -` path_component_set U y)"
  18.801    proof -
  18.802      have "path_component_set U y \<subseteq> f ` S"
  18.803        using \<open>U \<subseteq> f ` S\<close> \<open>path_component_set U y \<subseteq> U\<close> by blast
  18.804      then show ?thesis
  18.805        using oo by blast
  18.806    qed
  18.807 -  moreover have "openin (subtopology euclidean S) (S \<inter> f -` path_component_set U y)"
  18.808 +  moreover have "openin (top_of_set S) (S \<inter> f -` path_component_set U y)"
  18.809    proof (subst openin_subopen, clarify)
  18.810      fix x
  18.811      assume "x \<in> S" and Uyfx: "path_component U y (f x)"
  18.812      then have "f x \<in> U"
  18.813        using path_component_mem by blast
  18.814 -    show "\<exists>T. openin (subtopology euclidean S) T \<and> x \<in> T \<and> T \<subseteq> (S \<inter> f -` path_component_set U y)"
  18.815 +    show "\<exists>T. openin (top_of_set S) T \<and> x \<in> T \<and> T \<subseteq> (S \<inter> f -` path_component_set U y)"
  18.816      proof (intro conjI exI)
  18.817 -      show "openin (subtopology euclidean S) (path_component_set (S \<inter> f -` U) x)"
  18.818 +      show "openin (top_of_set S) (path_component_set (S \<inter> f -` U) x)"
  18.819        proof (rule ccontr)
  18.820 -        assume **: "\<not> openin (subtopology euclidean S) (path_component_set (S \<inter> f -` U) x)"
  18.821 +        assume **: "\<not> openin (top_of_set S) (path_component_set (S \<inter> f -` U) x)"
  18.822          then have "x \<notin> (S \<inter> f -` U)"
  18.823            by (metis (no_types, lifting) \<open>U \<subseteq> f ` S\<close> opefSU lcS oo locally_path_connected_open_path_component)
  18.824          then show False
  18.825 @@ -2842,7 +2842,7 @@
  18.826        finally show "path_component_set (S \<inter> f -` U) x \<subseteq> (S \<inter> f -` path_component_set U y)" .
  18.827      qed
  18.828    qed
  18.829 -  ultimately show "openin (subtopology euclidean (f ` S)) (path_component_set U y)"
  18.830 +  ultimately show "openin (top_of_set (f ` S)) (path_component_set U y)"
  18.831      by metis
  18.832  qed
  18.833  
  18.834 @@ -2851,14 +2851,14 @@
  18.835  lemma continuous_on_components_gen:
  18.836   fixes f :: "'a::topological_space \<Rightarrow> 'b::topological_space"
  18.837    assumes "\<And>c. c \<in> components S \<Longrightarrow>
  18.838 -              openin (subtopology euclidean S) c \<and> continuous_on c f"
  18.839 +              openin (top_of_set S) c \<and> continuous_on c f"
  18.840      shows "continuous_on S f"
  18.841  proof (clarsimp simp: continuous_openin_preimage_eq)
  18.842    fix t :: "'b set"
  18.843    assume "open t"
  18.844    have *: "S \<inter> f -` t = (\<Union>c \<in> components S. c \<inter> f -` t)"
  18.845      by auto
  18.846 -  show "openin (subtopology euclidean S) (S \<inter> f -` t)"
  18.847 +  show "openin (top_of_set S) (S \<inter> f -` t)"
  18.848      unfolding * using \<open>open t\<close> assms continuous_openin_preimage_gen openin_trans openin_Union by blast
  18.849  qed
  18.850  
  18.851 @@ -2891,9 +2891,9 @@
  18.852  
  18.853  lemma closedin_union_complement_components:
  18.854    assumes u: "locally connected u"
  18.855 -      and S: "closedin (subtopology euclidean u) S"
  18.856 +      and S: "closedin (top_of_set u) S"
  18.857        and cuS: "c \<subseteq> components(u - S)"
  18.858 -    shows "closedin (subtopology euclidean u) (S \<union> \<Union>c)"
  18.859 +    shows "closedin (top_of_set u) (S \<union> \<Union>c)"
  18.860  proof -
  18.861    have di: "(\<And>S t. S \<in> c \<and> t \<in> c' \<Longrightarrow> disjnt S t) \<Longrightarrow> disjnt (\<Union> c) (\<Union> c')" for c'
  18.862      by (simp add: disjnt_def) blast
  18.863 @@ -2906,13 +2906,13 @@
  18.864      by (metis DiffD1 DiffD2 assms(3) components_nonoverlap disjnt_def subsetCE)
  18.865    ultimately have eq: "S \<union> \<Union>c = u - (\<Union>(components(u - S) - c))"
  18.866      by (auto simp: disjnt_def)
  18.867 -  have *: "openin (subtopology euclidean u) (\<Union>(components (u - S) - c))"
  18.868 +  have *: "openin (top_of_set u) (\<Union>(components (u - S) - c))"
  18.869      apply (rule openin_Union)
  18.870      apply (rule openin_trans [of "u - S"])
  18.871      apply (simp add: u S locally_diff_closed openin_components_locally_connected)
  18.872      apply (simp add: openin_diff S)
  18.873      done
  18.874 -  have "openin (subtopology euclidean u) (u - (u - \<Union>(components (u - S) - c)))"
  18.875 +  have "openin (top_of_set u) (u - (u - \<Union>(components (u - S) - c)))"
  18.876      apply (rule openin_diff, simp)
  18.877      apply (metis closedin_diff closedin_topspace topspace_euclidean_subtopology *)
  18.878      done
  18.879 @@ -2925,7 +2925,7 @@
  18.880    assumes S: "closed S" and c: "c \<subseteq> components(- S)"
  18.881      shows "closed(S \<union> \<Union> c)"
  18.882  proof -
  18.883 -  have "closedin (subtopology euclidean UNIV) (S \<union> \<Union>c)"
  18.884 +  have "closedin (top_of_set UNIV) (S \<union> \<Union>c)"
  18.885      apply (rule closedin_union_complement_components [OF locally_connected_UNIV])
  18.886      using S c apply (simp_all add: Compl_eq_Diff_UNIV)
  18.887      done
  18.888 @@ -2935,11 +2935,11 @@
  18.889  lemma closedin_Un_complement_component:
  18.890    fixes S :: "'a::real_normed_vector set"
  18.891    assumes u: "locally connected u"
  18.892 -      and S: "closedin (subtopology euclidean u) S"
  18.893 +      and S: "closedin (top_of_set u) S"
  18.894        and c: " c \<in> components(u - S)"
  18.895 -    shows "closedin (subtopology euclidean u) (S \<union> c)"
  18.896 +    shows "closedin (top_of_set u) (S \<union> c)"
  18.897  proof -
  18.898 -  have "closedin (subtopology euclidean u) (S \<union> \<Union>{c})"
  18.899 +  have "closedin (top_of_set u) (S \<union> \<Union>{c})"
  18.900      using c by (blast intro: closedin_union_complement_components [OF u S])
  18.901    then show ?thesis
  18.902      by simp
  18.903 @@ -3987,7 +3987,7 @@
  18.904  
  18.905  proposition path_connected_openin_diff_countable:
  18.906    fixes S :: "'a::euclidean_space set"
  18.907 -  assumes "connected S" and ope: "openin (subtopology euclidean (affine hull S)) S"
  18.908 +  assumes "connected S" and ope: "openin (top_of_set (affine hull S)) S"
  18.909        and "\<not> collinear S" "countable T"
  18.910      shows "path_connected(S - T)"
  18.911  proof (clarsimp simp add: path_connected_component)
  18.912 @@ -3995,9 +3995,9 @@
  18.913    assume xy: "x \<in> S" "x \<notin> T" "y \<in> S" "y \<notin> T"
  18.914    show "path_component (S - T) x y"
  18.915    proof (rule connected_equivalence_relation_gen [OF \<open>connected S\<close>, where P = "\<lambda>x. x \<notin> T"])
  18.916 -    show "\<exists>z. z \<in> U \<and> z \<notin> T" if opeU: "openin (subtopology euclidean S) U" and "x \<in> U" for U x
  18.917 +    show "\<exists>z. z \<in> U \<and> z \<notin> T" if opeU: "openin (top_of_set S) U" and "x \<in> U" for U x
  18.918      proof -
  18.919 -      have "openin (subtopology euclidean (affine hull S)) U"
  18.920 +      have "openin (top_of_set (affine hull S)) U"
  18.921          using opeU ope openin_trans by blast
  18.922        with \<open>x \<in> U\<close> obtain r where Usub: "U \<subseteq> affine hull S" and "r > 0"
  18.923                                and subU: "ball x r \<inter> affine hull S \<subseteq> U"
  18.924 @@ -4024,7 +4024,7 @@
  18.925          using \<open>countable T\<close> countable_subset by blast
  18.926        then show ?thesis by blast
  18.927      qed
  18.928 -    show "\<exists>U. openin (subtopology euclidean S) U \<and> x \<in> U \<and>
  18.929 +    show "\<exists>U. openin (top_of_set S) U \<and> x \<in> U \<and>
  18.930                (\<forall>x\<in>U. \<forall>y\<in>U. x \<notin> T \<and> y \<notin> T \<longrightarrow> path_component (S - T) x y)"
  18.931            if "x \<in> S" for x
  18.932      proof -
  18.933 @@ -4046,9 +4046,9 @@
  18.934        proof (intro exI conjI)
  18.935          show "x \<in> ball x r \<inter> affine hull S"
  18.936            using \<open>x \<in> S\<close> \<open>r > 0\<close> by (simp add: hull_inc)
  18.937 -        have "openin (subtopology euclidean (affine hull S)) (ball x r \<inter> affine hull S)"
  18.938 +        have "openin (top_of_set (affine hull S)) (ball x r \<inter> affine hull S)"
  18.939            by (subst inf.commute) (simp add: openin_Int_open)
  18.940 -        then show "openin (subtopology euclidean S) (ball x r \<inter> affine hull S)"
  18.941 +        then show "openin (top_of_set S) (ball x r \<inter> affine hull S)"
  18.942            by (rule openin_subset_trans [OF _ subS Ssub])
  18.943        qed (use * path_component_trans in \<open>auto simp: path_connected_component path_component_of_subset [OF ST]\<close>)
  18.944      qed
  18.945 @@ -4057,7 +4057,7 @@
  18.946  
  18.947  corollary connected_openin_diff_countable:
  18.948    fixes S :: "'a::euclidean_space set"
  18.949 -  assumes "connected S" and ope: "openin (subtopology euclidean (affine hull S)) S"
  18.950 +  assumes "connected S" and ope: "openin (top_of_set (affine hull S)) S"
  18.951        and "\<not> collinear S" "countable T"
  18.952      shows "connected(S - T)"
  18.953    by (metis path_connected_imp_connected path_connected_openin_diff_countable [OF assms])
  18.954 @@ -4074,7 +4074,7 @@
  18.955    case False
  18.956    show ?thesis
  18.957    proof (rule path_connected_openin_diff_countable)
  18.958 -    show "openin (subtopology euclidean (affine hull S)) S"
  18.959 +    show "openin (top_of_set (affine hull S)) S"
  18.960        by (simp add: assms hull_subset open_subset)
  18.961      show "\<not> collinear S"
  18.962        using assms False by (simp add: collinear_aff_dim aff_dim_open)
  18.963 @@ -4329,7 +4329,7 @@
  18.964  
  18.965  proposition%unimportant homeomorphism_moving_point:
  18.966    fixes a :: "'a::euclidean_space"
  18.967 -  assumes ope: "openin (subtopology euclidean (affine hull S)) S"
  18.968 +  assumes ope: "openin (top_of_set (affine hull S)) S"
  18.969        and "S \<subseteq> T"
  18.970        and TS: "T \<subseteq> affine hull S"
  18.971        and S: "connected S" "a \<in> S" "b \<in> S"
  18.972 @@ -4371,7 +4371,7 @@
  18.973      then show "bounded {x. \<not> ((f2 \<circ> f1) x = x \<and> (g1 \<circ> g2) x = x)}"
  18.974        by (rule bounded_subset) auto
  18.975    qed
  18.976 -  have 3: "\<exists>U. openin (subtopology euclidean S) U \<and>
  18.977 +  have 3: "\<exists>U. openin (top_of_set S) U \<and>
  18.978                d \<in> U \<and>
  18.979                (\<forall>x\<in>U.
  18.980                    \<exists>f g. homeomorphism T T f g \<and> f d = x \<and>
  18.981 @@ -4410,7 +4410,7 @@
  18.982    assumes K: "finite K" "\<And>i. i \<in> K \<Longrightarrow> x i \<in> S \<and> y i \<in> S"
  18.983               "pairwise (\<lambda>i j. (x i \<noteq> x j) \<and> (y i \<noteq> y j)) K"
  18.984        and "2 \<le> aff_dim S"
  18.985 -      and ope: "openin (subtopology euclidean (affine hull S)) S"
  18.986 +      and ope: "openin (top_of_set (affine hull S)) S"
  18.987        and "S \<subseteq> T" "T \<subseteq> affine hull S" "connected S"
  18.988    shows "\<exists>f g. homeomorphism T T f g \<and> (\<forall>i \<in> K. f(x i) = y i) \<and>
  18.989                 {x. \<not> (f x = x \<and> g x = x)} \<subseteq> S \<and> bounded {x. \<not> (f x = x \<and> g x = x)}"
  18.990 @@ -4449,7 +4449,7 @@
  18.991                 and hk_sub: "{x. \<not> (h x = x \<and> k x = x)} \<subseteq> S - y ` K"
  18.992                 and bo_hk:  "bounded {x. \<not> (h x = x \<and> k x = x)}"
  18.993    proof (rule homeomorphism_moving_point [of "S - y`K" T "f(x i)" "y i"])
  18.994 -    show "openin (subtopology euclidean (affine hull (S - y ` K))) (S - y ` K)"
  18.995 +    show &