src/HOL/Analysis/Abstract_Topology.thy
changeset 77234 61fba09a3456
parent 75455 91c16c5ad3e9
child 77934 01c88cf514fc
equal deleted inserted replaced
77230:2d26af072990 77234:61fba09a3456
   164 
   164 
   165 lemma openin_diff[intro]:
   165 lemma openin_diff[intro]:
   166   assumes oS: "openin U S"
   166   assumes oS: "openin U S"
   167     and cT: "closedin U T"
   167     and cT: "closedin U T"
   168   shows "openin U (S - T)"
   168   shows "openin U (S - T)"
   169 proof -
   169   by (metis Int_Diff cT closedin_def inf.orderE oS openin_Int openin_subset)
   170   have "S - T = S \<inter> (topspace U - T)" using openin_subset[of U S]  oS cT
       
   171     by (auto simp: topspace_def openin_subset)
       
   172   then show ?thesis using oS cT
       
   173     by (auto simp: closedin_def)
       
   174 qed
       
   175 
   170 
   176 lemma closedin_diff[intro]:
   171 lemma closedin_diff[intro]:
   177   assumes oS: "closedin U S"
   172   assumes oS: "closedin U S"
   178     and cT: "openin U T"
   173     and cT: "openin U T"
   179   shows "closedin U (S - T)"
   174   shows "closedin U (S - T)"
   180 proof -
   175   by (metis Int_Diff cT closedin_Int closedin_subset inf.orderE oS openin_closedin_eq)
   181   have "S - T = S \<inter> (topspace U - T)"
       
   182     using closedin_subset[of U S] oS cT by (auto simp: topspace_def)
       
   183   then show ?thesis
       
   184     using oS cT by (auto simp: openin_closedin_eq)
       
   185 qed
       
   186 
   176 
   187 
   177 
   188 subsection\<open>The discrete topology\<close>
   178 subsection\<open>The discrete topology\<close>
   189 
   179 
   190 definition discrete_topology where "discrete_topology U \<equiv> topology (\<lambda>S. S \<subseteq> U)"
   180 definition discrete_topology where "discrete_topology U \<equiv> topology (\<lambda>S. S \<subseteq> U)"
   207    "discrete_topology U = X \<longleftrightarrow> topspace X = U \<and> (\<forall>x \<in> U. openin X {x})" (is "?lhs = ?rhs")
   197    "discrete_topology U = X \<longleftrightarrow> topspace X = U \<and> (\<forall>x \<in> U. openin X {x})" (is "?lhs = ?rhs")
   208 proof
   198 proof
   209   assume R: ?rhs
   199   assume R: ?rhs
   210   then have "openin X S" if "S \<subseteq> U" for S
   200   then have "openin X S" if "S \<subseteq> U" for S
   211     using openin_subopen subsetD that by fastforce
   201     using openin_subopen subsetD that by fastforce
   212   moreover have "x \<in> topspace X" if "openin X S" and "x \<in> S" for x S
   202   then show ?lhs
   213     using openin_subset that by blast
   203     by (metis R openin_discrete_topology openin_subset topology_eq)
   214   ultimately
       
   215   show ?lhs
       
   216     using R by (auto simp: topology_eq)
       
   217 qed auto
   204 qed auto
   218 
   205 
   219 lemma discrete_topology_unique_alt:
   206 lemma discrete_topology_unique_alt:
   220   "discrete_topology U = X \<longleftrightarrow> topspace X \<subseteq> U \<and> (\<forall>x \<in> U. openin X {x})"
   207   "discrete_topology U = X \<longleftrightarrow> topspace X \<subseteq> U \<and> (\<forall>x \<in> U. openin X {x})"
   221   using openin_subset
   208   using openin_subset
   230   by (metis discrete_topology_unique openin_topspace singletonD)
   217   by (metis discrete_topology_unique openin_topspace singletonD)
   231 
   218 
   232 
   219 
   233 subsection \<open>Subspace topology\<close>
   220 subsection \<open>Subspace topology\<close>
   234 
   221 
   235 definition\<^marker>\<open>tag important\<close> subtopology :: "'a topology \<Rightarrow> 'a set \<Rightarrow> 'a topology" where
   222 definition\<^marker>\<open>tag important\<close> subtopology :: "'a topology \<Rightarrow> 'a set \<Rightarrow> 'a topology" 
   236 "subtopology U V = topology (\<lambda>T. \<exists>S. T = S \<inter> V \<and> openin U S)"
   223   where "subtopology U V = topology (\<lambda>T. \<exists>S. T = S \<inter> V \<and> openin U S)"
   237 
   224 
   238 lemma istopology_subtopology: "istopology (\<lambda>T. \<exists>S. T = S \<inter> V \<and> openin U S)"
   225 lemma istopology_subtopology: "istopology (\<lambda>T. \<exists>S. T = S \<inter> V \<and> openin U S)"
   239   (is "istopology ?L")
   226   (is "istopology ?L")
   240 proof -
   227 proof -
   241   have "?L {}" by blast
   228   have "?L {}" by blast
   324 
   311 
   325 lemma subtopology_superset:
   312 lemma subtopology_superset:
   326   assumes UV: "topspace U \<subseteq> V"
   313   assumes UV: "topspace U \<subseteq> V"
   327   shows "subtopology U V = U"
   314   shows "subtopology U V = U"
   328 proof -
   315 proof -
   329   {
   316   { fix S
   330     fix S
   317     have "openin U S" if "openin U T" "S = T \<inter> V" for T
   331     {
   318       by (metis Int_subset_iff assms inf.orderE openin_subset that)
   332       fix T
   319     then have "(\<exists>T. openin U T \<and> S = T \<inter> V) \<longleftrightarrow> openin U S"
   333       assume T: "openin U T" "S = T \<inter> V"
   320       by (metis assms inf.orderE inf_assoc openin_subset)
   334       from T openin_subset[OF T(1)] UV have eq: "S = T"
       
   335         by blast
       
   336       have "openin U S"
       
   337         unfolding eq using T by blast
       
   338     }
       
   339     moreover
       
   340     {
       
   341       assume S: "openin U S"
       
   342       then have "\<exists>T. openin U T \<and> S = T \<inter> V"
       
   343         using openin_subset[OF S] UV by auto
       
   344     }
       
   345     ultimately have "(\<exists>T. openin U T \<and> S = T \<inter> V) \<longleftrightarrow> openin U S"
       
   346       by blast
       
   347   }
   321   }
   348   then show ?thesis
   322   then show ?thesis
   349     unfolding topology_eq openin_subtopology by blast
   323     unfolding topology_eq openin_subtopology by blast
   350 qed
   324 qed
   351 
   325 
   358 lemma subtopology_restrict:
   332 lemma subtopology_restrict:
   359    "subtopology X (topspace X \<inter> S) = subtopology X S"
   333    "subtopology X (topspace X \<inter> S) = subtopology X S"
   360   by (metis subtopology_subtopology subtopology_topspace)
   334   by (metis subtopology_subtopology subtopology_topspace)
   361 
   335 
   362 lemma openin_subtopology_empty:
   336 lemma openin_subtopology_empty:
   363    "openin (subtopology U {}) S \<longleftrightarrow> S = {}"
   337   "openin (subtopology U {}) S \<longleftrightarrow> S = {}"
   364 by (metis Int_empty_right openin_empty openin_subtopology)
   338   by (metis Int_empty_right openin_empty openin_subtopology)
   365 
   339 
   366 lemma closedin_subtopology_empty:
   340 lemma closedin_subtopology_empty:
   367    "closedin (subtopology U {}) S \<longleftrightarrow> S = {}"
   341   "closedin (subtopology U {}) S \<longleftrightarrow> S = {}"
   368 by (metis Int_empty_right closedin_empty closedin_subtopology)
   342   by (metis Int_empty_right closedin_empty closedin_subtopology)
   369 
   343 
   370 lemma closedin_subtopology_refl [simp]:
   344 lemma closedin_subtopology_refl [simp]:
   371    "closedin (subtopology U X) X \<longleftrightarrow> X \<subseteq> topspace U"
   345   "closedin (subtopology U X) X \<longleftrightarrow> X \<subseteq> topspace U"
   372 by (metis closedin_def closedin_topspace inf.absorb_iff2 le_inf_iff topspace_subtopology)
   346   by (metis closedin_def closedin_topspace inf.absorb_iff2 le_inf_iff topspace_subtopology)
   373 
   347 
   374 lemma closedin_topspace_empty: "topspace T = {} \<Longrightarrow> (closedin T S \<longleftrightarrow> S = {})"
   348 lemma closedin_topspace_empty: "topspace T = {} \<Longrightarrow> (closedin T S \<longleftrightarrow> S = {})"
   375   by (simp add: closedin_def)
   349   by (simp add: closedin_def)
   376 
   350 
   377 lemma open_in_topspace_empty:
   351 lemma open_in_topspace_empty:
   378    "topspace X = {} \<Longrightarrow> openin X S \<longleftrightarrow> S = {}"
   352    "topspace X = {} \<Longrightarrow> openin X S \<longleftrightarrow> S = {}"
   379   by (simp add: openin_closedin_eq)
   353   by (simp add: openin_closedin_eq)
   380 
   354 
   381 lemma openin_imp_subset:
   355 lemma openin_imp_subset:
   382    "openin (subtopology U S) T \<Longrightarrow> T \<subseteq> S"
   356   "openin (subtopology U S) T \<Longrightarrow> T \<subseteq> S"
   383 by (metis Int_iff openin_subtopology subsetI)
   357   by (metis Int_iff openin_subtopology subsetI)
   384 
   358 
   385 lemma closedin_imp_subset:
   359 lemma closedin_imp_subset:
   386    "closedin (subtopology U S) T \<Longrightarrow> T \<subseteq> S"
   360   "closedin (subtopology U S) T \<Longrightarrow> T \<subseteq> S"
   387 by (simp add: closedin_def)
   361   by (simp add: closedin_def)
   388 
   362 
   389 lemma openin_open_subtopology:
   363 lemma openin_open_subtopology:
   390      "openin X S \<Longrightarrow> openin (subtopology X S) T \<longleftrightarrow> openin X T \<and> T \<subseteq> S"
   364      "openin X S \<Longrightarrow> openin (subtopology X S) T \<longleftrightarrow> openin X T \<and> T \<subseteq> S"
   391   by (metis inf.orderE openin_Int openin_imp_subset openin_subtopology)
   365   by (metis inf.orderE openin_Int openin_imp_subset openin_subtopology)
   392 
   366 
   416 
   390 
   417 abbreviation top_of_set :: "'a::topological_space set \<Rightarrow> 'a topology"
   391 abbreviation top_of_set :: "'a::topological_space set \<Rightarrow> 'a topology"
   418   where "top_of_set \<equiv> subtopology (topology open)"
   392   where "top_of_set \<equiv> subtopology (topology open)"
   419 
   393 
   420 lemma open_openin: "open S \<longleftrightarrow> openin euclidean S"
   394 lemma open_openin: "open S \<longleftrightarrow> openin euclidean S"
   421   by (simp add: istopology_open topology_inverse')
   395   by simp
   422 
   396 
   423 declare open_openin [symmetric, simp]
   397 declare open_openin [symmetric, simp]
   424 
   398 
   425 lemma topspace_euclidean [simp]: "topspace euclidean = UNIV"
   399 lemma topspace_euclidean [simp]: "topspace euclidean = UNIV"
   426   by (force simp: topspace_def)
   400   by (force simp: topspace_def)
   541   proof (clarsimp simp add: connected_closed closedin_closed)
   515   proof (clarsimp simp add: connected_closed closedin_closed)
   542     fix A B 
   516     fix A B 
   543     assume s_sub: "S \<subseteq> A \<union> B" "B \<inter> S \<noteq> {}"
   517     assume s_sub: "S \<subseteq> A \<union> B" "B \<inter> S \<noteq> {}"
   544       and disj: "A \<inter> B \<inter> S = {}"
   518       and disj: "A \<inter> B \<inter> S = {}"
   545       and cl: "closed A" "closed B"
   519       and cl: "closed A" "closed B"
   546     have "S \<inter> (A \<union> B) = S"
       
   547       using s_sub(1) by auto
       
   548     have "S - A = B \<inter> S"
   520     have "S - A = B \<inter> S"
   549       using Diff_subset_conv Un_Diff_Int disj s_sub(1) by auto
   521       using Diff_subset_conv Un_Diff_Int disj s_sub(1) by auto
   550     then have "S \<inter> A = {}"
       
   551       by (metis Diff_Diff_Int Diff_disjoint Un_Diff_Int R cl closedin_closed_Int inf_commute order_refl s_sub(2))
       
   552     then show "A \<inter> S = {}"
   522     then show "A \<inter> S = {}"
   553       by blast
   523       by (metis Int_Diff_Un Int_Diff_disjoint R cl closedin_closed_Int dual_order.refl inf_commute s_sub(2))
   554   qed
   524   qed
   555 qed
   525 qed
   556 
   526 
   557 lemma connected_closedin_eq:
   527 lemma connected_closedin_eq:
   558       "connected S \<longleftrightarrow>
   528       "connected S \<longleftrightarrow>
   663    "S \<subseteq> topspace X \<and> S \<inter> X derived_set_of S = {}
   633    "S \<subseteq> topspace X \<and> S \<inter> X derived_set_of S = {}
   664         \<Longrightarrow> subtopology X S = discrete_topology S"
   634         \<Longrightarrow> subtopology X S = discrete_topology S"
   665   by (simp add: subtopology_eq_discrete_topology_eq)
   635   by (simp add: subtopology_eq_discrete_topology_eq)
   666 
   636 
   667 lemma subtopology_eq_discrete_topology_gen:
   637 lemma subtopology_eq_discrete_topology_gen:
   668    "S \<inter> X derived_set_of S = {} \<Longrightarrow> subtopology X S = discrete_topology(topspace X \<inter> S)"
   638   assumes "S \<inter> X derived_set_of S = {}"
   669   by (metis Int_lower1 derived_set_of_restrict inf_assoc inf_bot_right subtopology_eq_discrete_topology_eq subtopology_subtopology subtopology_topspace)
   639   shows "subtopology X S = discrete_topology(topspace X \<inter> S)"
       
   640 proof -
       
   641   have "subtopology X S = subtopology X (topspace X \<inter> S)"
       
   642     by (simp add: subtopology_restrict)
       
   643   then show ?thesis
       
   644     using assms by (simp add: inf.assoc subtopology_eq_discrete_topology_eq)
       
   645 qed
   670 
   646 
   671 lemma subtopology_discrete_topology [simp]: 
   647 lemma subtopology_discrete_topology [simp]: 
   672   "subtopology (discrete_topology U) S = discrete_topology(U \<inter> S)"
   648   "subtopology (discrete_topology U) S = discrete_topology(U \<inter> S)"
   673 proof -
   649 proof -
   674   have "(\<lambda>T. \<exists>Sa. T = Sa \<inter> S \<and> Sa \<subseteq> U) = (\<lambda>Sa. Sa \<subseteq> U \<and> Sa \<subseteq> S)"
   650   have "(\<lambda>T. \<exists>Sa. T = Sa \<inter> S \<and> Sa \<subseteq> U) = (\<lambda>Sa. Sa \<subseteq> U \<and> Sa \<subseteq> S)"
   675     by force
   651     by force
   676   then show ?thesis
   652   then show ?thesis
   677     by (simp add: subtopology_def) (simp add: discrete_topology_def)
   653     by (simp add: subtopology_def) (simp add: discrete_topology_def)
   678 qed
   654 qed
       
   655 
   679 lemma openin_Int_derived_set_of_subset:
   656 lemma openin_Int_derived_set_of_subset:
   680    "openin X S \<Longrightarrow> S \<inter> X derived_set_of T \<subseteq> X derived_set_of (S \<inter> T)"
   657    "openin X S \<Longrightarrow> S \<inter> X derived_set_of T \<subseteq> X derived_set_of (S \<inter> T)"
   681   by (auto simp: derived_set_of_def)
   658   by (auto simp: derived_set_of_def)
   682 
   659 
   683 lemma openin_Int_derived_set_of_eq:
   660 lemma openin_Int_derived_set_of_eq:
   772   then show ?thesis
   749   then show ?thesis
   773     by (auto simp: closedin_def closure_of_def disjoint_iff_not_equal)
   750     by (auto simp: closedin_def closure_of_def disjoint_iff_not_equal)
   774 qed
   751 qed
   775 
   752 
   776 lemma closure_of_eq: "X closure_of S = S \<longleftrightarrow> closedin X S"
   753 lemma closure_of_eq: "X closure_of S = S \<longleftrightarrow> closedin X S"
   777 proof (cases "S \<subseteq> topspace X")
   754   by (metis closure_of_subset closure_of_subset_eq closure_of_subset_topspace subset_antisym)
   778   case True
       
   779   then show ?thesis
       
   780     by (metis closure_of_subset closure_of_subset_eq set_eq_subset)
       
   781 next
       
   782   case False
       
   783   then show ?thesis
       
   784     using closure_of closure_of_subset_eq by fastforce
       
   785 qed
       
   786 
   755 
   787 lemma closedin_contains_derived_set:
   756 lemma closedin_contains_derived_set:
   788    "closedin X S \<longleftrightarrow> X derived_set_of S \<subseteq> S \<and> S \<subseteq> topspace X"
   757    "closedin X S \<longleftrightarrow> X derived_set_of S \<subseteq> S \<and> S \<subseteq> topspace X"
   789 proof (intro iffI conjI)
   758 proof (intro iffI conjI)
   790   show "closedin X S \<Longrightarrow> X derived_set_of S \<subseteq> S"
   759   show "closedin X S \<Longrightarrow> X derived_set_of S \<subseteq> S"
   795     by (metis closure_of closure_of_eq inf.absorb_iff2 sup.orderE)
   764     by (metis closure_of closure_of_eq inf.absorb_iff2 sup.orderE)
   796 qed
   765 qed
   797 
   766 
   798 lemma derived_set_subset_gen:
   767 lemma derived_set_subset_gen:
   799    "X derived_set_of S \<subseteq> S \<longleftrightarrow> closedin X (topspace X \<inter> S)"
   768    "X derived_set_of S \<subseteq> S \<longleftrightarrow> closedin X (topspace X \<inter> S)"
   800   by (simp add: closedin_contains_derived_set derived_set_of_restrict derived_set_of_subset_topspace)
   769   by (simp add: closedin_contains_derived_set derived_set_of_subset_topspace)
   801 
   770 
   802 lemma derived_set_subset: "S \<subseteq> topspace X \<Longrightarrow> (X derived_set_of S \<subseteq> S \<longleftrightarrow> closedin X S)"
   771 lemma derived_set_subset: "S \<subseteq> topspace X \<Longrightarrow> (X derived_set_of S \<subseteq> S \<longleftrightarrow> closedin X S)"
   803   by (simp add: closedin_contains_derived_set)
   772   by (simp add: closedin_contains_derived_set)
   804 
   773 
   805 lemma closedin_derived_set:
   774 lemma closedin_derived_set:
   823 lemma closure_of_closure_of [simp]: "X closure_of (X closure_of S) = X closure_of S"
   792 lemma closure_of_closure_of [simp]: "X closure_of (X closure_of S) = X closure_of S"
   824   by (simp add: closure_of_eq)
   793   by (simp add: closure_of_eq)
   825 
   794 
   826 lemma closure_of_hull:
   795 lemma closure_of_hull:
   827   assumes "S \<subseteq> topspace X" shows "X closure_of S = (closedin X) hull S"
   796   assumes "S \<subseteq> topspace X" shows "X closure_of S = (closedin X) hull S"
   828 proof (rule hull_unique [THEN sym])
   797   by (metis assms closedin_closure_of closure_of_eq closure_of_mono closure_of_subset hull_unique)
   829   show "S \<subseteq> X closure_of S"
       
   830     by (simp add: closure_of_subset assms)
       
   831 next
       
   832   show "closedin X (X closure_of S)"
       
   833     by simp
       
   834   show "\<And>T. \<lbrakk>S \<subseteq> T; closedin X T\<rbrakk> \<Longrightarrow> X closure_of S \<subseteq> T"
       
   835     by (metis closure_of_eq closure_of_mono)
       
   836 qed
       
   837 
   798 
   838 lemma closure_of_minimal:
   799 lemma closure_of_minimal:
   839    "\<lbrakk>S \<subseteq> T; closedin X T\<rbrakk> \<Longrightarrow> (X closure_of S) \<subseteq> T"
   800    "\<lbrakk>S \<subseteq> T; closedin X T\<rbrakk> \<Longrightarrow> (X closure_of S) \<subseteq> T"
   840   by (metis closure_of_eq closure_of_mono)
   801   by (metis closure_of_eq closure_of_mono)
   841 
   802 
   874 proof
   835 proof
   875   show "X closure_of (S \<inter> X closure_of T) \<subseteq> X closure_of (S \<inter> T)"
   836   show "X closure_of (S \<inter> X closure_of T) \<subseteq> X closure_of (S \<inter> T)"
   876     by (simp add: assms closure_of_minimal openin_Int_closure_of_subset)
   837     by (simp add: assms closure_of_minimal openin_Int_closure_of_subset)
   877 next
   838 next
   878   show "X closure_of (S \<inter> T) \<subseteq> X closure_of (S \<inter> X closure_of T)"
   839   show "X closure_of (S \<inter> T) \<subseteq> X closure_of (S \<inter> X closure_of T)"
   879     by (metis Int_lower1 Int_subset_iff assms closedin_closure_of closure_of_minimal_eq closure_of_mono inf_le2 le_infI1 openin_subset)
   840     by (metis Int_subset_iff assms closure_of_alt closure_of_mono inf_mono openin_subset subset_refl sup.coboundedI1)
   880 qed
   841 qed
   881 
   842 
   882 lemma openin_Int_closure_of_eq:
   843 lemma openin_Int_closure_of_eq:
   883   assumes "openin X S" shows "S \<inter> X closure_of T = S \<inter> X closure_of (S \<inter> T)"  (is "?lhs = ?rhs")
   844   assumes "openin X S" shows "S \<inter> X closure_of T = S \<inter> X closure_of (S \<inter> T)"  (is "?lhs = ?rhs")
   884 proof
   845 proof
   907   assumes S: "openin (subtopology X U) S" and "T \<subseteq> U"
   868   assumes S: "openin (subtopology X U) S" and "T \<subseteq> U"
   908   shows "X closure_of (S \<inter> X closure_of T) = X closure_of (S \<inter> T)" (is "?lhs = ?rhs")
   869   shows "X closure_of (S \<inter> X closure_of T) = X closure_of (S \<inter> T)" (is "?lhs = ?rhs")
   909 proof
   870 proof
   910   obtain S0 where S0: "openin X S0" "S = S0 \<inter> U"
   871   obtain S0 where S0: "openin X S0" "S = S0 \<inter> U"
   911     using assms by (auto simp: openin_subtopology)
   872     using assms by (auto simp: openin_subtopology)
   912   show "?lhs \<subseteq> ?rhs"
   873   then show "?lhs \<subseteq> ?rhs"
   913   proof -
   874   proof -
   914     have "S0 \<inter> X closure_of T = S0 \<inter> X closure_of (S0 \<inter> T)"
   875     have "S0 \<inter> X closure_of T = S0 \<inter> X closure_of (S0 \<inter> T)"
   915       by (meson S0(1) openin_Int_closure_of_eq)
   876       by (meson S0(1) openin_Int_closure_of_eq)
   916     moreover have "S0 \<inter> T = S0 \<inter> U \<inter> T"
   877     moreover have "S0 \<inter> T = S0 \<inter> U \<inter> T"
   917       using \<open>T \<subseteq> U\<close> by fastforce
   878       using \<open>T \<subseteq> U\<close> by fastforce
   924   show "?rhs \<subseteq> ?lhs"
   885   show "?rhs \<subseteq> ?lhs"
   925   proof -
   886   proof -
   926     have "T \<inter> S \<subseteq> T \<union> X derived_set_of T"
   887     have "T \<inter> S \<subseteq> T \<union> X derived_set_of T"
   927       by force
   888       by force
   928     then show ?thesis
   889     then show ?thesis
   929       by (metis Int_subset_iff S closure_of closure_of_mono inf.cobounded2 inf.coboundedI2 inf_commute openin_closedin_eq topspace_subtopology)
   890       by (smt (verit, del_insts) Int_iff in_closure_of inf.orderE openin_subset subsetI)
   930   qed
   891   qed
   931 qed
   892 qed
   932 
   893 
   933 lemma closure_of_subtopology_open:
   894 lemma closure_of_subtopology_open:
   934      "openin X U \<or> S \<subseteq> U \<Longrightarrow> (subtopology X U) closure_of S = U \<inter> X closure_of S"
   895      "openin X U \<or> S \<subseteq> U \<Longrightarrow> (subtopology X U) closure_of S = U \<inter> X closure_of S"
  1060    "\<lbrakk>S \<subseteq> T; T \<subseteq> U\<rbrakk> \<Longrightarrow> (subtopology X U) interior_of S \<subseteq> (subtopology X T) interior_of S"
  1021    "\<lbrakk>S \<subseteq> T; T \<subseteq> U\<rbrakk> \<Longrightarrow> (subtopology X U) interior_of S \<subseteq> (subtopology X T) interior_of S"
  1061   by (metis dual_order.trans inf.orderE inf_commute interior_of_subset interior_of_subtopology_subsets)
  1022   by (metis dual_order.trans inf.orderE inf_commute interior_of_subset interior_of_subtopology_subsets)
  1062 
  1023 
  1063 lemma interior_of_subtopology_open:
  1024 lemma interior_of_subtopology_open:
  1064   assumes "openin X U"
  1025   assumes "openin X U"
  1065   shows "(subtopology X U) interior_of S = U \<inter> X interior_of S"
  1026   shows "(subtopology X U) interior_of S = U \<inter> X interior_of S" (is "?lhs = ?rhs")
  1066 proof -
  1027 proof
  1067   have "\<forall>A. U \<inter> X closure_of (U \<inter> A) = U \<inter> X closure_of A"
  1028   show "?lhs \<subseteq> ?rhs"
  1068     using assms openin_Int_closure_of_eq by blast
  1029     by (meson assms interior_of_maximal interior_of_subset le_infI openin_interior_of openin_open_subtopology)
  1069   then have "topspace X \<inter> U - U \<inter> X closure_of (topspace X \<inter> U - S) = U \<inter> (topspace X - X closure_of (topspace X - S))"
  1030   show "?rhs \<subseteq> ?lhs"
  1070     by (metis (no_types) Diff_Int_distrib Int_Diff inf_commute)
  1031     by (simp add: interior_of_subtopology_subset)
  1071   then show ?thesis
       
  1072     unfolding interior_of_closure_of closure_of_subtopology_open topspace_subtopology
       
  1073     using openin_Int_closure_of_eq [OF assms]
       
  1074     by (metis assms closure_of_subtopology_open)
       
  1075 qed
  1032 qed
  1076 
  1033 
  1077 lemma dense_intersects_open:
  1034 lemma dense_intersects_open:
  1078    "X closure_of S = topspace X \<longleftrightarrow> (\<forall>T. openin X T \<and> T \<noteq> {} \<longrightarrow> S \<inter> T \<noteq> {})"
  1035    "X closure_of S = topspace X \<longleftrightarrow> (\<forall>T. openin X T \<and> T \<noteq> {} \<longrightarrow> S \<inter> T \<noteq> {})"
  1079 proof -
  1036 proof -
  1397 next
  1354 next
  1398   fix x
  1355   fix x
  1399   assume "x \<in> topspace X" and "\<Union>\<A> \<subseteq> topspace X"
  1356   assume "x \<in> topspace X" and "\<Union>\<A> \<subseteq> topspace X"
  1400   then obtain V where V: "openin X V" "x \<in> V" and fin: "finite {U \<in> \<A>. U \<inter> V \<noteq> {}}"
  1357   then obtain V where V: "openin X V" "x \<in> V" and fin: "finite {U \<in> \<A>. U \<inter> V \<noteq> {}}"
  1401     using \<A> unfolding locally_finite_in_def by blast
  1358     using \<A> unfolding locally_finite_in_def by blast
  1402   have eq: "{y \<in> f ` \<A>. Q y} = f ` {x. x \<in> \<A> \<and> Q(f x)}" for f Q
  1359   have eq: "{y \<in> f ` \<A>. Q y} = f ` {x. x \<in> \<A> \<and> Q(f x)}" for f and Q :: "'a set \<Rightarrow> bool"
  1403     by blast
  1360     by blast
  1404   have eq2: "{A \<in> \<A>. X closure_of A \<inter> V \<noteq> {}} = {A \<in> \<A>. A \<inter> V \<noteq> {}}"
  1361   have eq2: "{A \<in> \<A>. X closure_of A \<inter> V \<noteq> {}} = {A \<in> \<A>. A \<inter> V \<noteq> {}}"
  1405     using openin_Int_closure_of_eq_empty V  by blast
  1362     using openin_Int_closure_of_eq_empty V  by blast
  1406   have "finite {U \<in> (closure_of) X ` \<A>. U \<inter> V \<noteq> {}}"
  1363   have "finite {U \<in> (closure_of) X ` \<A>. U \<inter> V \<noteq> {}}"
  1407     by (simp add: eq eq2 fin)
  1364     by (simp add: eq eq2 fin)
  1464       using that by blast
  1421       using that by blast
  1465     show ?thesis
  1422     show ?thesis
  1466     proof (intro iffI allI impI)
  1423     proof (intro iffI allI impI)
  1467       fix C
  1424       fix C
  1468       assume "\<forall>U. openin Y U \<longrightarrow> openin X {x \<in> topspace X. f x \<in> U}" and "closedin Y C"
  1425       assume "\<forall>U. openin Y U \<longrightarrow> openin X {x \<in> topspace X. f x \<in> U}" and "closedin Y C"
  1469       then have "openin X {x \<in> topspace X. f x \<in> topspace Y - C}" by blast
       
  1470       then show "closedin X {x \<in> topspace X. f x \<in> C}"
  1426       then show "closedin X {x \<in> topspace X. f x \<in> C}"
  1471         by (auto simp add: closedin_def eq)
  1427         by (auto simp add: closedin_def eq)
  1472     next
  1428     next
  1473       fix U
  1429       fix U
  1474       assume "\<forall>C. closedin Y C \<longrightarrow> closedin X {x \<in> topspace X. f x \<in> C}" and "openin Y U"
  1430       assume "\<forall>C. closedin Y C \<longrightarrow> closedin X {x \<in> topspace X. f x \<in> C}" and "openin Y U"
  1475       then have "closedin X {x \<in> topspace X. f x \<in> topspace Y - U}" by blast
       
  1476       then show "openin X {x \<in> topspace X. f x \<in> U}"
  1431       then show "openin X {x \<in> topspace X. f x \<in> U}"
  1477         by (auto simp add: openin_closedin_eq eq)
  1432         by (auto simp add: openin_closedin_eq eq)
  1478     qed
  1433     qed
  1479   qed
  1434   qed
  1480   then show ?thesis
  1435   then show ?thesis
  1515   assumes "continuous_map X Y f"
  1470   assumes "continuous_map X Y f"
  1516   shows "f ` (X closure_of S) \<subseteq> Y closure_of f ` S"
  1471   shows "f ` (X closure_of S) \<subseteq> Y closure_of f ` S"
  1517 proof -
  1472 proof -
  1518   have *: "f ` (topspace X) \<subseteq> topspace Y"
  1473   have *: "f ` (topspace X) \<subseteq> topspace Y"
  1519     by (meson assms continuous_map)
  1474     by (meson assms continuous_map)
  1520   have "X closure_of T \<subseteq> {x \<in> X closure_of T. f x \<in> Y closure_of (f ` T)}" if "T \<subseteq> topspace X" for T
  1475   have "X closure_of T \<subseteq> {x \<in> X closure_of T. f x \<in> Y closure_of (f ` T)}"
       
  1476     if "T \<subseteq> topspace X" for T
  1521   proof (rule closure_of_minimal)
  1477   proof (rule closure_of_minimal)
  1522     show "T \<subseteq> {x \<in> X closure_of T. f x \<in> Y closure_of f ` T}"
  1478     show "T \<subseteq> {x \<in> X closure_of T. f x \<in> Y closure_of f ` T}"
  1523       using closure_of_subset * that  by (fastforce simp: in_closure_of)
  1479       using closure_of_subset * that  by (fastforce simp: in_closure_of)
  1524   next
  1480   next
  1525     show "closedin X {x \<in> X closure_of T. f x \<in> Y closure_of f ` T}"
  1481     show "closedin X {x \<in> X closure_of T. f x \<in> Y closure_of f ` T}"
  1526       using assms closedin_continuous_map_preimage_gen by fastforce
  1482       using assms closedin_continuous_map_preimage_gen by fastforce
  1527   qed
  1483   qed
  1528   then have "f ` (X closure_of (topspace X \<inter> S)) \<subseteq> Y closure_of (f ` (topspace X \<inter> S))"
       
  1529     by blast
       
  1530   also have "\<dots> \<subseteq> Y closure_of (topspace Y \<inter> f ` S)"
       
  1531     using * by (blast intro!: closure_of_mono)
       
  1532   finally have "f ` (X closure_of (topspace X \<inter> S)) \<subseteq> Y closure_of (topspace Y \<inter> f ` S)" .
       
  1533   then show ?thesis
  1484   then show ?thesis
  1534     by (metis closure_of_restrict)
  1485     by (smt (verit, ccfv_threshold) assms continuous_map image_eqI image_subset_iff in_closure_of mem_Collect_eq)
  1535 qed
  1486 qed
  1536 
  1487 
  1537 lemma continuous_map_subset_aux1: "continuous_map X Y f \<Longrightarrow>
  1488 lemma continuous_map_subset_aux1: "continuous_map X Y f \<Longrightarrow>
  1538        (\<forall>S. f ` (X closure_of S) \<subseteq> Y closure_of f ` S)"
  1489        (\<forall>S. f ` (X closure_of S) \<subseteq> Y closure_of f ` S)"
  1539   using continuous_map_image_closure_subset by blast
  1490   using continuous_map_image_closure_subset by blast
  1559       by (meson x in_closure_of)
  1510       by (meson x in_closure_of)
  1560     have "{a \<in> topspace X. f a \<in> C} \<subseteq> topspace X"
  1511     have "{a \<in> topspace X. f a \<in> C} \<subseteq> topspace X"
  1561       by simp
  1512       by simp
  1562     moreover have "Y closure_of f ` {a \<in> topspace X. f a \<in> C} \<subseteq> C"
  1513     moreover have "Y closure_of f ` {a \<in> topspace X. f a \<in> C} \<subseteq> C"
  1563       by (simp add: \<open>closedin Y C\<close> closure_of_minimal image_subset_iff)
  1514       by (simp add: \<open>closedin Y C\<close> closure_of_minimal image_subset_iff)
  1564     ultimately have "f ` (X closure_of {a \<in> topspace X. f a \<in> C}) \<subseteq> C"
  1515     ultimately show "f x \<in> C"
  1565       using assms by blast
  1516       using x assms by blast
  1566     then show "f x \<in> C"
       
  1567       using x by auto
       
  1568   qed
  1517   qed
  1569 qed
  1518 qed
  1570 
  1519 
  1571 lemma continuous_map_eq_image_closure_subset:
  1520 lemma continuous_map_eq_image_closure_subset:
  1572      "continuous_map X Y f \<longleftrightarrow> (\<forall>S. f ` (X closure_of S) \<subseteq> Y closure_of f ` S)"
  1521      "continuous_map X Y f \<longleftrightarrow> (\<forall>S. f ` (X closure_of S) \<subseteq> Y closure_of f ` S)"
  1654     using assms unfolding continuous_map_def
  1603     using assms unfolding continuous_map_def
  1655     using \<open>openin X'' U\<close> by blast
  1604     using \<open>openin X'' U\<close> by blast
  1656 qed
  1605 qed
  1657 
  1606 
  1658 lemma continuous_map_eq:
  1607 lemma continuous_map_eq:
  1659   assumes "continuous_map X X' f" and "\<And>x. x \<in> topspace X \<Longrightarrow> f x = g x" shows "continuous_map X X' g"
  1608   assumes "continuous_map X X' f" and "\<And>x. x \<in> topspace X \<Longrightarrow> f x = g x" 
       
  1609   shows "continuous_map X X' g"
  1660 proof -
  1610 proof -
  1661   have eq: "{x \<in> topspace X. f x \<in> U} = {x \<in> topspace X. g x \<in> U}" for U
  1611   have eq: "{x \<in> topspace X. f x \<in> U} = {x \<in> topspace X. g x \<in> U}" for U
  1662     using assms by auto
  1612     using assms by auto
  1663   show ?thesis
  1613   show ?thesis
  1664     using assms by (simp add: continuous_map_def eq)
  1614     using assms by (simp add: continuous_map_def eq)
  1676   show ?rhs
  1626   show ?rhs
  1677   proof -
  1627   proof -
  1678     have "\<And>A. f ` (X closure_of A) \<subseteq> subtopology X' S closure_of f ` A"
  1628     have "\<And>A. f ` (X closure_of A) \<subseteq> subtopology X' S closure_of f ` A"
  1679       by (meson L continuous_map_image_closure_subset)
  1629       by (meson L continuous_map_image_closure_subset)
  1680     then show ?thesis
  1630     then show ?thesis
  1681       by (metis (no_types) closure_of_subset_subtopology closure_of_subtopology_subset closure_of_topspace continuous_map_eq_image_closure_subset dual_order.trans)
  1631       by (metis (no_types) closure_of_subset_subtopology closure_of_subtopology_subset closure_of_topspace continuous_map_eq_image_closure_subset order.trans)
  1682   qed
  1632   qed
  1683 next
  1633 next
  1684   assume R: ?rhs
  1634   assume R: ?rhs
  1685   then have eq: "{x \<in> topspace X. f x \<in> U} = {x \<in> topspace X. f x \<in> U \<and> f x \<in> S}" for U
  1635   then have eq: "{x \<in> topspace X. f x \<in> U} = {x \<in> topspace X. f x \<in> U \<and> f x \<in> S}" for U
  1686     by auto
  1636     by auto
  1782    "topspace X = {} \<Longrightarrow> closed_map X Y f"
  1732    "topspace X = {} \<Longrightarrow> closed_map X Y f"
  1783   by (simp add: closed_map_def closedin_topspace_empty)
  1733   by (simp add: closed_map_def closedin_topspace_empty)
  1784 
  1734 
  1785 lemma closed_map_const:
  1735 lemma closed_map_const:
  1786    "closed_map X Y (\<lambda>x. c) \<longleftrightarrow> topspace X = {} \<or> closedin Y {c}"
  1736    "closed_map X Y (\<lambda>x. c) \<longleftrightarrow> topspace X = {} \<or> closedin Y {c}"
  1787 proof (cases "topspace X = {}")
  1737   by (metis closed_map_def closed_map_on_empty closedin_empty closedin_topspace image_constant_conv)
  1788   case True
       
  1789   then show ?thesis
       
  1790     by (simp add: closed_map_on_empty)
       
  1791 next
       
  1792   case False
       
  1793   then show ?thesis
       
  1794     by (auto simp: closed_map_def image_constant_conv)
       
  1795 qed
       
  1796 
  1738 
  1797 lemma open_map_imp_subset:
  1739 lemma open_map_imp_subset:
  1798     "\<lbrakk>open_map X1 X2 f; S \<subseteq> topspace X1\<rbrakk> \<Longrightarrow> f ` S \<subseteq> topspace X2"
  1740     "\<lbrakk>open_map X1 X2 f; S \<subseteq> topspace X1\<rbrakk> \<Longrightarrow> f ` S \<subseteq> topspace X2"
  1799   by (meson order_trans open_map_imp_subset_topspace subset_image_iff)
  1741   by (meson order_trans open_map_imp_subset_topspace subset_image_iff)
  1800 
  1742 
  1810   unfolding open_map_def
  1752   unfolding open_map_def
  1811   by (metis image_cong openin_subset subset_iff)
  1753   by (metis image_cong openin_subset subset_iff)
  1812 
  1754 
  1813 lemma open_map_inclusion_eq:
  1755 lemma open_map_inclusion_eq:
  1814   "open_map (subtopology X S) X id \<longleftrightarrow> openin X (topspace X \<inter> S)"
  1756   "open_map (subtopology X S) X id \<longleftrightarrow> openin X (topspace X \<inter> S)"
  1815 proof -
  1757   by (metis openin_topspace openin_trans_full subtopology_restrict topology_finer_open_id topspace_subtopology)
  1816   have *: "openin X (T \<inter> S)" if "openin X (S \<inter> topspace X)" "openin X T" for T
       
  1817   proof -
       
  1818     have "T \<subseteq> topspace X"
       
  1819       using that by (simp add: openin_subset)
       
  1820     with that show "openin X (T \<inter> S)"
       
  1821       by (metis inf.absorb1 inf.left_commute inf_commute openin_Int)
       
  1822   qed
       
  1823   show ?thesis
       
  1824     by (fastforce simp add: open_map_def Int_commute openin_subtopology_alt intro: *)
       
  1825 qed
       
  1826 
  1758 
  1827 lemma open_map_inclusion:
  1759 lemma open_map_inclusion:
  1828      "openin X S \<Longrightarrow> open_map (subtopology X S) X id"
  1760      "openin X S \<Longrightarrow> open_map (subtopology X S) X id"
  1829   by (simp add: open_map_inclusion_eq openin_Int)
  1761   by (simp add: open_map_inclusion_eq openin_Int)
  1830 
  1762 
  1859 lemma closed_map_inclusion_eq:
  1791 lemma closed_map_inclusion_eq:
  1860    "closed_map (subtopology X S) X id \<longleftrightarrow>
  1792    "closed_map (subtopology X S) X id \<longleftrightarrow>
  1861         closedin X (topspace X \<inter> S)"
  1793         closedin X (topspace X \<inter> S)"
  1862 proof -
  1794 proof -
  1863   have *: "closedin X (T \<inter> S)" if "closedin X (S \<inter> topspace X)" "closedin X T" for T
  1795   have *: "closedin X (T \<inter> S)" if "closedin X (S \<inter> topspace X)" "closedin X T" for T
  1864   proof -
  1796     by (smt (verit, best) closedin_Int closure_of_subset_eq inf_sup_aci le_iff_inf that)
  1865     have "T \<subseteq> topspace X"
  1797   then show ?thesis
  1866       using that by (simp add: closedin_subset)
       
  1867     with that show "closedin X (T \<inter> S)"
       
  1868       by (metis inf.absorb1 inf.left_commute inf_commute closedin_Int)
       
  1869   qed
       
  1870   show ?thesis
       
  1871     by (fastforce simp add: closed_map_def Int_commute closedin_subtopology_alt intro: *)
  1798     by (fastforce simp add: closed_map_def Int_commute closedin_subtopology_alt intro: *)
  1872 qed
  1799 qed
  1873 
  1800 
  1874 lemma closed_map_inclusion: "closedin X S \<Longrightarrow> closed_map (subtopology X S) X id"
  1801 lemma closed_map_inclusion: "closedin X S \<Longrightarrow> closed_map (subtopology X S) X id"
  1875   by (simp add: closed_map_inclusion_eq closedin_Int)
  1802   by (simp add: closed_map_inclusion_eq closedin_Int)
  1948         (\<forall>U. U \<subseteq> topspace X' \<longrightarrow> (openin X {x. x \<in> topspace X \<and> f x \<in> U} \<longleftrightarrow> openin X' U))"
  1875         (\<forall>U. U \<subseteq> topspace X' \<longrightarrow> (openin X {x. x \<in> topspace X \<and> f x \<in> U} \<longleftrightarrow> openin X' U))"
  1949 
  1876 
  1950 lemma quotient_map_eq:
  1877 lemma quotient_map_eq:
  1951   assumes "quotient_map X X' f" "\<And>x. x \<in> topspace X \<Longrightarrow> f x = g x"
  1878   assumes "quotient_map X X' f" "\<And>x. x \<in> topspace X \<Longrightarrow> f x = g x"
  1952   shows "quotient_map X X' g"
  1879   shows "quotient_map X X' g"
  1953 proof -
  1880   by (smt (verit) Collect_cong assms image_cong quotient_map_def)
  1954   have eq: "{x \<in> topspace X. f x \<in> U} = {x \<in> topspace X. g x \<in> U}" for U
       
  1955     using assms by auto
       
  1956   show ?thesis
       
  1957   using assms
       
  1958   unfolding quotient_map_def
       
  1959   by (metis (mono_tags, lifting) eq image_cong)
       
  1960 qed
       
  1961 
  1881 
  1962 lemma quotient_map_compose:
  1882 lemma quotient_map_compose:
  1963   assumes f: "quotient_map X X' f" and g: "quotient_map X' X'' g"
  1883   assumes f: "quotient_map X X' f" and g: "quotient_map X' X'' g"
  1964   shows "quotient_map X X'' (g \<circ> f)"
  1884   shows "quotient_map X X'' (g \<circ> f)"
  1965   unfolding quotient_map_def
  1885   unfolding quotient_map_def
  1966 proof (intro conjI allI impI)
  1886 proof (intro conjI allI impI)
  1967   show "(g \<circ> f) ` topspace X = topspace X''"
  1887   show "(g \<circ> f) ` topspace X = topspace X''"
  1968     using assms by (simp only: image_comp [symmetric]) (simp add: quotient_map_def)
  1888     using assms by (simp only: image_comp [symmetric]) (simp add: quotient_map_def)
  1969 next
  1889 next
  1970   fix U''
  1890   fix U''
  1971   assume "U'' \<subseteq> topspace X''"
  1891   assume U'': "U'' \<subseteq> topspace X''"
  1972   define U' where "U' \<equiv> {y \<in> topspace X'. g y \<in> U''}"
  1892   define U' where "U' \<equiv> {y \<in> topspace X'. g y \<in> U''}"
  1973   have "U' \<subseteq> topspace X'"
  1893   have "U' \<subseteq> topspace X'"
  1974     by (auto simp add: U'_def)
  1894     by (auto simp add: U'_def)
  1975   then have U': "openin X {x \<in> topspace X. f x \<in> U'} = openin X' U'"
  1895   then have U': "openin X {x \<in> topspace X. f x \<in> U'} = openin X' U'"
  1976     using assms unfolding quotient_map_def by simp
  1896     using assms unfolding quotient_map_def by simp
  1977   have eq: "{x \<in> topspace X. f x \<in> topspace X' \<and> g (f x) \<in> U''} = {x \<in> topspace X. (g \<circ> f) x \<in> U''}"
  1897   have "{x \<in> topspace X. f x \<in> topspace X' \<and> g (f x) \<in> U''} = {x \<in> topspace X. (g \<circ> f) x \<in> U''}"
  1978     using f quotient_map_def by fastforce
  1898     using f quotient_map_def by fastforce
  1979   have "openin X {x \<in> topspace X. (g \<circ> f) x \<in> U''} = openin X {x \<in> topspace X. f x \<in> U'}"
  1899   then show "openin X {x \<in> topspace X. (g \<circ> f) x \<in> U''} = openin X'' U''"
  1980     using assms  by (simp add: quotient_map_def U'_def eq)
  1900     by (smt (verit, best) Collect_cong U' U'_def U'' g mem_Collect_eq quotient_map_def)
  1981   also have "\<dots> = openin X'' U''"
       
  1982     using U'_def \<open>U'' \<subseteq> topspace X''\<close> U' g quotient_map_def by fastforce
       
  1983   finally show "openin X {x \<in> topspace X. (g \<circ> f) x \<in> U''} = openin X'' U''" .
       
  1984 qed
  1901 qed
  1985 
  1902 
  1986 lemma quotient_map_from_composition:
  1903 lemma quotient_map_from_composition:
  1987   assumes f: "continuous_map X X' f" and g: "continuous_map X' X'' g" and gf: "quotient_map X X'' (g \<circ> f)"
  1904   assumes f: "continuous_map X X' f" and g: "continuous_map X' X'' g" and gf: "quotient_map X X'' (g \<circ> f)"
  1988   shows  "quotient_map X' X'' g"
  1905   shows  "quotient_map X' X'' g"
  2076   shows "quotient_map X X' f \<longleftrightarrow>
  1993   shows "quotient_map X X' f \<longleftrightarrow>
  2077          continuous_map X X' f \<and> open_map X X' f \<and> closed_map X X' f \<and> f ` (topspace X) = topspace X'"
  1994          continuous_map X X' f \<and> open_map X X' f \<and> closed_map X X' f \<and> f ` (topspace X) = topspace X'"
  2078          (is "?lhs = ?rhs")
  1995          (is "?lhs = ?rhs")
  2079 proof
  1996 proof
  2080   assume L: ?lhs
  1997   assume L: ?lhs
  2081   have "open_map X X' f"
  1998   have om: "open_map X X' f"
  2082   proof (clarsimp simp add: open_map_def)
  1999   proof (clarsimp simp add: open_map_def)
  2083     fix U
  2000     fix U
  2084     assume "openin X U"
  2001     assume "openin X U"
  2085     then have "U \<subseteq> topspace X"
  2002     then have "U \<subseteq> topspace X"
  2086       by (simp add: openin_subset)
  2003       by (simp add: openin_subset)
  2088       using \<open>U \<subseteq> topspace X\<close> assms inj_onD by fastforce
  2005       using \<open>U \<subseteq> topspace X\<close> assms inj_onD by fastforce
  2089     ultimately show "openin X' (f ` U)"
  2006     ultimately show "openin X' (f ` U)"
  2090       using L unfolding quotient_map_def
  2007       using L unfolding quotient_map_def
  2091       by (metis (no_types, lifting) Collect_cong \<open>openin X U\<close> image_mono)
  2008       by (metis (no_types, lifting) Collect_cong \<open>openin X U\<close> image_mono)
  2092   qed
  2009   qed
  2093   moreover have "closed_map X X' f"
  2010   then have "closed_map X X' f"
  2094   proof (clarsimp simp add: closed_map_def)
  2011     by (simp add: L assms bijective_open_imp_closed_map quotient_imp_surjective_map)
  2095     fix U
  2012   then show ?rhs
  2096     assume "closedin X U"
  2013     using L om by (simp add: quotient_imp_continuous_map quotient_imp_surjective_map)
  2097     then have "U \<subseteq> topspace X"
       
  2098       by (simp add: closedin_subset)
       
  2099     moreover have "{x \<in> topspace X. f x \<in> f ` U} = U"
       
  2100       using \<open>U \<subseteq> topspace X\<close> assms inj_onD by fastforce
       
  2101     ultimately show "closedin X' (f ` U)"
       
  2102       using L unfolding quotient_map_closedin
       
  2103       by (metis (no_types, lifting) Collect_cong \<open>closedin X U\<close> image_mono)
       
  2104   qed
       
  2105   ultimately show ?rhs
       
  2106     using L by (simp add: quotient_imp_continuous_map quotient_imp_surjective_map)
       
  2107 next
  2014 next
  2108   assume ?rhs
  2015   assume ?rhs
  2109   then show ?lhs
  2016   then show ?lhs
  2110     by (simp add: continuous_closed_imp_quotient_map)
  2017     by (simp add: continuous_closed_imp_quotient_map)
  2111 qed
  2018 qed
  2256      "separatedin X {} S \<longleftrightarrow> S \<subseteq> topspace X"
  2163      "separatedin X {} S \<longleftrightarrow> S \<subseteq> topspace X"
  2257   by (simp_all add: separatedin_def)
  2164   by (simp_all add: separatedin_def)
  2258 
  2165 
  2259 lemma separatedin_refl [simp]:
  2166 lemma separatedin_refl [simp]:
  2260      "separatedin X S S \<longleftrightarrow> S = {}"
  2167      "separatedin X S S \<longleftrightarrow> S = {}"
  2261 proof -
  2168   by (metis closure_of_subset empty_subsetI inf.orderE separatedin_def)
  2262   have "\<And>x. \<lbrakk>separatedin X S S; x \<in> S\<rbrakk> \<Longrightarrow> False"
       
  2263     by (metis all_not_in_conv closure_of_subset inf.orderE separatedin_def)
       
  2264   then show ?thesis
       
  2265     by auto
       
  2266 qed
       
  2267 
  2169 
  2268 lemma separatedin_sym:
  2170 lemma separatedin_sym:
  2269      "separatedin X S T \<longleftrightarrow> separatedin X T S"
  2171      "separatedin X S T \<longleftrightarrow> separatedin X T S"
  2270   by (auto simp: separatedin_def)
  2172   by (auto simp: separatedin_def)
  2271 
  2173 
  2287      "\<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> separatedin X S T \<longleftrightarrow> disjnt S T"
  2189      "\<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> separatedin X S T \<longleftrightarrow> disjnt S T"
  2288   unfolding closure_of_eq disjnt_def separatedin_def
  2190   unfolding closure_of_eq disjnt_def separatedin_def
  2289   by (metis closedin_def closure_of_eq inf_commute)
  2191   by (metis closedin_def closure_of_eq inf_commute)
  2290 
  2192 
  2291 lemma separatedin_subtopology:
  2193 lemma separatedin_subtopology:
  2292      "separatedin (subtopology X U) S T \<longleftrightarrow> S \<subseteq> U \<and> T \<subseteq> U \<and> separatedin X S T" (is "?lhs = ?rhs")
  2194      "separatedin (subtopology X U) S T \<longleftrightarrow> S \<subseteq> U \<and> T \<subseteq> U \<and> separatedin X S T"
  2293   by (auto simp: separatedin_def closure_of_subtopology Int_ac disjoint_iff elim!: inf.orderE)
  2195   by (auto simp: separatedin_def closure_of_subtopology Int_ac disjoint_iff elim!: inf.orderE)
  2294 
  2196 
  2295 lemma separatedin_discrete_topology:
  2197 lemma separatedin_discrete_topology:
  2296      "separatedin (discrete_topology U) S T \<longleftrightarrow> S \<subseteq> U \<and> T \<subseteq> U \<and> disjnt S T"
  2198      "separatedin (discrete_topology U) S T \<longleftrightarrow> S \<subseteq> U \<and> T \<subseteq> U \<and> disjnt S T"
  2297   by (metis openin_discrete_topology separatedin_def separatedin_open_sets topspace_discrete_topology)
  2199   by (metis openin_discrete_topology separatedin_def separatedin_open_sets topspace_discrete_topology)
  2607     "homeomorphic_map X Y f \<Longrightarrow> closedin X U \<longleftrightarrow> U \<subseteq> topspace X \<and> closedin Y (f ` U)"
  2509     "homeomorphic_map X Y f \<Longrightarrow> closedin X U \<longleftrightarrow> U \<subseteq> topspace X \<and> closedin Y (f ` U)"
  2608   by (meson closedin_subset homeomorphic_map_closedness)
  2510   by (meson closedin_subset homeomorphic_map_closedness)
  2609 
  2511 
  2610 lemma all_openin_homeomorphic_image:
  2512 lemma all_openin_homeomorphic_image:
  2611   assumes "homeomorphic_map X Y f"
  2513   assumes "homeomorphic_map X Y f"
  2612   shows "(\<forall>V. openin Y V \<longrightarrow> P V) \<longleftrightarrow> (\<forall>U. openin X U \<longrightarrow> P(f ` U))"  (is "?lhs = ?rhs")
  2514   shows "(\<forall>V. openin Y V \<longrightarrow> P V) \<longleftrightarrow> (\<forall>U. openin X U \<longrightarrow> P(f ` U))" 
  2613 proof
  2515   by (metis (no_types, lifting) assms homeomorphic_imp_surjective_map homeomorphic_map_openness openin_subset subset_image_iff)
  2614   assume ?lhs
       
  2615   then show ?rhs
       
  2616     by (meson assms homeomorphic_map_openness_eq)
       
  2617 next
       
  2618   assume ?rhs
       
  2619   then show ?lhs
       
  2620     by (metis (no_types, lifting) assms homeomorphic_imp_surjective_map homeomorphic_map_openness openin_subset subset_image_iff)
       
  2621 qed
       
  2622 
  2516 
  2623 lemma all_closedin_homeomorphic_image:
  2517 lemma all_closedin_homeomorphic_image:
  2624   assumes "homeomorphic_map X Y f"
  2518   assumes "homeomorphic_map X Y f"
  2625   shows "(\<forall>V. closedin Y V \<longrightarrow> P V) \<longleftrightarrow> (\<forall>U. closedin X U \<longrightarrow> P(f ` U))"  (is "?lhs = ?rhs")
  2519   shows "(\<forall>V. closedin Y V \<longrightarrow> P V) \<longleftrightarrow> (\<forall>U. closedin X U \<longrightarrow> P(f ` U))"  (is "?lhs = ?rhs")
  2626 proof
  2520   by (metis (no_types, lifting) assms homeomorphic_imp_surjective_map homeomorphic_map_closedness closedin_subset subset_image_iff)
  2627   assume ?lhs
       
  2628   then show ?rhs
       
  2629     by (meson assms homeomorphic_map_closedness_eq)
       
  2630 next
       
  2631   assume ?rhs
       
  2632   then show ?lhs
       
  2633     by (metis (no_types, lifting) assms homeomorphic_imp_surjective_map homeomorphic_map_closedness closedin_subset subset_image_iff)
       
  2634 qed
       
  2635 
  2521 
  2636 
  2522 
  2637 lemma homeomorphic_map_derived_set_of:
  2523 lemma homeomorphic_map_derived_set_of:
  2638   assumes hom: "homeomorphic_map X Y f" and S: "S \<subseteq> topspace X"
  2524   assumes hom: "homeomorphic_map X Y f" and S: "S \<subseteq> topspace X"
  2639   shows "Y derived_set_of (f ` S) = f ` (X derived_set_of S)"
  2525   shows "Y derived_set_of (f ` S) = f ` (X derived_set_of S)"
  2646   proof -
  2532   proof -
  2647     have \<section>: "(x \<in> T \<and> openin X T) = (T \<subseteq> topspace X \<and> f x \<in> f ` T \<and> openin Y (f ` T))" for T
  2533     have \<section>: "(x \<in> T \<and> openin X T) = (T \<subseteq> topspace X \<and> f x \<in> f ` T \<and> openin Y (f ` T))" for T
  2648       by (meson hom homeomorphic_map_openness_eq inj inj_on_image_mem_iff that)
  2534       by (meson hom homeomorphic_map_openness_eq inj inj_on_image_mem_iff that)
  2649     moreover have "(\<exists>y. y \<noteq> x \<and> y \<in> S \<and> y \<in> T) = (\<exists>y. y \<noteq> f x \<and> y \<in> f ` S \<and> y \<in> f ` T)"  (is "?lhs = ?rhs")
  2535     moreover have "(\<exists>y. y \<noteq> x \<and> y \<in> S \<and> y \<in> T) = (\<exists>y. y \<noteq> f x \<and> y \<in> f ` S \<and> y \<in> f ` T)"  (is "?lhs = ?rhs")
  2650       if "T \<subseteq> topspace X \<and> f x \<in> f ` T \<and> openin Y (f ` T)" for T
  2536       if "T \<subseteq> topspace X \<and> f x \<in> f ` T \<and> openin Y (f ` T)" for T
  2651     proof
  2537       by (smt (verit, del_insts) S \<open>x \<in> topspace X\<close> image_iff inj inj_on_def subsetD that)
  2652       show "?lhs \<Longrightarrow> ?rhs"
       
  2653         by (meson \<section> imageI inj inj_on_eq_iff inj_on_subset that)
       
  2654       show "?rhs \<Longrightarrow> ?lhs"
       
  2655         using S inj inj_onD that by fastforce
       
  2656     qed
       
  2657     ultimately show ?thesis
  2538     ultimately show ?thesis
  2658       by (auto simp flip: fim simp: all_subset_image)
  2539       by (auto simp flip: fim simp: all_subset_image)
  2659   qed
  2540   qed
  2660   have *: "\<lbrakk>T = f ` S; \<And>x. x \<in> S \<Longrightarrow> P x \<longleftrightarrow> Q(f x)\<rbrakk> \<Longrightarrow> {y. y \<in> T \<and> Q y} = f ` {x \<in> S. P x}" for T S P Q
  2541   have *: "\<lbrakk>T = f ` S; \<And>x. x \<in> S \<Longrightarrow> P x \<longleftrightarrow> Q(f x)\<rbrakk> \<Longrightarrow> {y. y \<in> T \<and> Q y} = f ` {x \<in> S. P x}" for T S P Q
  2661     by auto
  2542     by auto
  2715 next
  2596 next
  2716   fix x
  2597   fix x
  2717   assume "x \<in> f ` (X closure_of S - X interior_of S)"
  2598   assume "x \<in> f ` (X closure_of S - X interior_of S)"
  2718   then obtain y where y: "x = f y" "y \<in> X closure_of S" "y \<notin> X interior_of S"
  2599   then obtain y where y: "x = f y" "y \<in> X closure_of S" "y \<notin> X interior_of S"
  2719     by blast
  2600     by blast
  2720   then have "y \<in> topspace X"
       
  2721     by (simp add: in_closure_of)
       
  2722   then have "f y \<notin> f ` (X interior_of S)"
       
  2723     by (meson hom homeomorphic_map_def inj_on_image_mem_iff interior_of_subset_topspace y(3))
       
  2724   then show "x \<notin> Y interior_of f ` S"
  2601   then show "x \<notin> Y interior_of f ` S"
  2725     using S hom homeomorphic_map_interior_of y(1) by blast
  2602     using S hom homeomorphic_map_interior_of y(1)
       
  2603     unfolding homeomorphic_map_def
       
  2604     by (smt (verit, ccfv_SIG) in_closure_of inj_on_image_mem_iff interior_of_subset_topspace) 
  2726 qed
  2605 qed
  2727 
  2606 
  2728 lemma homeomorphic_maps_subtopologies:
  2607 lemma homeomorphic_maps_subtopologies:
  2729    "\<lbrakk>homeomorphic_maps X Y f g;  f ` (topspace X \<inter> S) = topspace Y \<inter> T\<rbrakk>
  2608    "\<lbrakk>homeomorphic_maps X Y f g;  f ` (topspace X \<inter> S) = topspace Y \<inter> T\<rbrakk>
  2730         \<Longrightarrow> homeomorphic_maps (subtopology X S) (subtopology Y T) f g"
  2609         \<Longrightarrow> homeomorphic_maps (subtopology X S) (subtopology Y T) f g"
  2746   assumes hom: "homeomorphic_map X Y f" 
  2625   assumes hom: "homeomorphic_map X Y f" 
  2747       and S: "\<And>x. \<lbrakk>x \<in> topspace X; f x \<in> topspace Y\<rbrakk> \<Longrightarrow> f x \<in> T \<longleftrightarrow> x \<in> S"
  2626       and S: "\<And>x. \<lbrakk>x \<in> topspace X; f x \<in> topspace Y\<rbrakk> \<Longrightarrow> f x \<in> T \<longleftrightarrow> x \<in> S"
  2748     shows "homeomorphic_map (subtopology X S) (subtopology Y T) f"
  2627     shows "homeomorphic_map (subtopology X S) (subtopology Y T) f"
  2749 proof -
  2628 proof -
  2750   have "homeomorphic_maps (subtopology X S) (subtopology Y T) f g" 
  2629   have "homeomorphic_maps (subtopology X S) (subtopology Y T) f g" 
  2751       if "homeomorphic_maps X Y f g" for g
  2630     if "homeomorphic_maps X Y f g" for g
  2752   proof (rule homeomorphic_maps_subtopologies [OF that])
  2631   proof (rule homeomorphic_maps_subtopologies [OF that])
  2753     show "f ` (topspace X \<inter> S) = topspace Y \<inter> T"
  2632     have "f ` (topspace X \<inter> S) \<subseteq> topspace Y \<inter> T"
  2754       using that S 
  2633       using S hom homeomorphic_imp_surjective_map by fastforce
  2755       apply (auto simp: homeomorphic_maps_def continuous_map_def)
  2634     then show "f ` (topspace X \<inter> S) = topspace Y \<inter> T"
  2756       by (metis IntI image_iff)
  2635       using that unfolding homeomorphic_maps_def continuous_map_def
       
  2636       by (smt (verit, del_insts) Int_iff S image_iff subsetI subset_antisym)
  2757   qed
  2637   qed
  2758   then show ?thesis
  2638   then show ?thesis
  2759     using hom by (meson homeomorphic_map_maps)
  2639     using hom by (meson homeomorphic_map_maps)
  2760 qed
  2640 qed
  2761 
  2641 
  2793      "X homeomorphic_space Y \<Longrightarrow> topspace X = {} \<longleftrightarrow> topspace Y = {}"
  2673      "X homeomorphic_space Y \<Longrightarrow> topspace X = {} \<longleftrightarrow> topspace Y = {}"
  2794   by (metis homeomorphic_imp_surjective_map homeomorphic_space image_is_empty)
  2674   by (metis homeomorphic_imp_surjective_map homeomorphic_space image_is_empty)
  2795 
  2675 
  2796 lemma homeomorphic_empty_space_eq:
  2676 lemma homeomorphic_empty_space_eq:
  2797   assumes "topspace X = {}"
  2677   assumes "topspace X = {}"
  2798     shows "X homeomorphic_space Y \<longleftrightarrow> topspace Y = {}"
  2678   shows "X homeomorphic_space Y \<longleftrightarrow> topspace Y = {}"
  2799 proof -
  2679   unfolding homeomorphic_maps_def homeomorphic_space_def
  2800   have "\<forall>f t. continuous_map X (t::'b topology) f"
  2680   by (metis assms continuous_map_on_empty continuous_map_closedin ex_in_conv)
  2801     using assms continuous_map_on_empty by blast
       
  2802   then show ?thesis
       
  2803     by (metis (no_types) assms continuous_map_on_empty empty_iff homeomorphic_empty_space homeomorphic_maps_def homeomorphic_space_def)
       
  2804 qed
       
  2805 
  2681 
  2806 subsection\<open>Connected topological spaces\<close>
  2682 subsection\<open>Connected topological spaces\<close>
  2807 
  2683 
  2808 definition connected_space :: "'a topology \<Rightarrow> bool" where
  2684 definition connected_space :: "'a topology \<Rightarrow> bool" where
  2809   "connected_space X \<equiv>
  2685   "connected_space X \<equiv>
  2843      "connected_space X \<longleftrightarrow>
  2719      "connected_space X \<longleftrightarrow>
  2844       (\<nexists>E1 E2. closedin X E1 \<and> closedin X E2 \<and> topspace X \<subseteq> E1 \<union> E2 \<and>
  2720       (\<nexists>E1 E2. closedin X E1 \<and> closedin X E2 \<and> topspace X \<subseteq> E1 \<union> E2 \<and>
  2845                E1 \<inter> E2 = {} \<and> E1 \<noteq> {} \<and> E2 \<noteq> {})" (is "?lhs = ?rhs")
  2721                E1 \<inter> E2 = {} \<and> E1 \<noteq> {} \<and> E2 \<noteq> {})" (is "?lhs = ?rhs")
  2846 proof
  2722 proof
  2847   assume ?lhs
  2723   assume ?lhs
  2848   then have L: "\<And>E1 E2. \<lbrakk>openin X E1; E1 \<inter> E2 = {}; topspace X \<subseteq> E1 \<union> E2; openin X E2\<rbrakk> \<Longrightarrow> E1 = {} \<or> E2 = {}"
  2724   then have "\<And>E1 E2. \<lbrakk>openin X E1; E1 \<inter> E2 = {}; topspace X \<subseteq> E1 \<union> E2; openin X E2\<rbrakk> \<Longrightarrow> E1 = {} \<or> E2 = {}"
  2849     by (simp add: connected_space_def)
  2725     by (simp add: connected_space_def)
  2850   show ?rhs
  2726   then show ?rhs
  2851     unfolding connected_space_def
  2727     unfolding connected_space_def
  2852   proof clarify
  2728     by (metis disjnt_def separatedin_closed_sets separation_openin_Un_gen subtopology_superset)
  2853     fix E1 E2
       
  2854     assume "closedin X E1" and "closedin X E2" and "topspace X \<subseteq> E1 \<union> E2" and "E1 \<inter> E2 = {}"
       
  2855       and "E1 \<noteq> {}" and "E2 \<noteq> {}"
       
  2856     have "E1 \<union> E2 = topspace X"
       
  2857       by (meson Un_subset_iff \<open>closedin X E1\<close> \<open>closedin X E2\<close> \<open>topspace X \<subseteq> E1 \<union> E2\<close> closedin_def subset_antisym)
       
  2858     then have "topspace X - E2 = E1"
       
  2859       using \<open>E1 \<inter> E2 = {}\<close> by fastforce
       
  2860     then have "topspace X = E1"
       
  2861       using \<open>E1 \<noteq> {}\<close> L \<open>closedin X E1\<close> \<open>closedin X E2\<close> by blast
       
  2862     then show "False"
       
  2863       using \<open>E1 \<inter> E2 = {}\<close> \<open>E1 \<union> E2 = topspace X\<close> \<open>E2 \<noteq> {}\<close> by blast
       
  2864   qed
       
  2865 next
  2729 next
  2866   assume R: ?rhs
  2730   assume R: ?rhs
  2867   show ?lhs
  2731   then show ?lhs
  2868     unfolding connected_space_def
  2732     unfolding connected_space_def
  2869   proof clarify
  2733     by (metis Diff_triv Int_commute separatedin_openin_diff separation_closedin_Un_gen subtopology_superset)
  2870     fix E1 E2
       
  2871     assume "openin X E1" and "openin X E2" and "topspace X \<subseteq> E1 \<union> E2" and "E1 \<inter> E2 = {}"
       
  2872       and "E1 \<noteq> {}" and "E2 \<noteq> {}"
       
  2873     have "E1 \<union> E2 = topspace X"
       
  2874       by (meson Un_subset_iff \<open>openin X E1\<close> \<open>openin X E2\<close> \<open>topspace X \<subseteq> E1 \<union> E2\<close> openin_closedin_eq subset_antisym)
       
  2875     then have "topspace X - E2 = E1"
       
  2876       using \<open>E1 \<inter> E2 = {}\<close> by fastforce
       
  2877     then have "topspace X = E1"
       
  2878       using \<open>E1 \<noteq> {}\<close> R \<open>openin X E1\<close> \<open>openin X E2\<close> by blast
       
  2879     then show "False"
       
  2880       using \<open>E1 \<inter> E2 = {}\<close> \<open>E1 \<union> E2 = topspace X\<close> \<open>E2 \<noteq> {}\<close> by blast
       
  2881   qed
       
  2882 qed
  2734 qed
  2883 
  2735 
  2884 lemma connected_space_closedin_eq:
  2736 lemma connected_space_closedin_eq:
  2885      "connected_space X \<longleftrightarrow>
  2737      "connected_space X \<longleftrightarrow>
  2886        (\<nexists>E1 E2. closedin X E1 \<and> closedin X E2 \<and>
  2738        (\<nexists>E1 E2. closedin X E1 \<and> closedin X E2 \<and>
  3040   by (meson closure_of_subset connectedin_def connectedin_intermediate_closure_of subset_refl)
  2892   by (meson closure_of_subset connectedin_def connectedin_intermediate_closure_of subset_refl)
  3041 
  2893 
  3042 lemma connectedin_separation:
  2894 lemma connectedin_separation:
  3043   "connectedin X S \<longleftrightarrow>
  2895   "connectedin X S \<longleftrightarrow>
  3044         S \<subseteq> topspace X \<and>
  2896         S \<subseteq> topspace X \<and>
  3045         (\<nexists>C1 C2. C1 \<union> C2 = S \<and> C1 \<noteq> {} \<and> C2 \<noteq> {} \<and> C1 \<inter> X closure_of C2 = {} \<and> C2 \<inter> X closure_of C1 = {})" (is "?lhs = ?rhs")
  2897         (\<nexists>C1 C2. C1 \<union> C2 = S \<and> C1 \<noteq> {} \<and> C2 \<noteq> {} \<and> C1 \<inter> X closure_of C2 = {} \<and> C2 \<inter> X closure_of C1 = {})" 
  3046   unfolding connectedin_def connected_space_closedin_eq closedin_Int_closure_of topspace_subtopology
  2898   unfolding connectedin_def connected_space_closedin_eq closedin_Int_closure_of topspace_subtopology
  3047   apply (intro conj_cong refl arg_cong [where f=Not])
  2899   apply (intro conj_cong refl arg_cong [where f=Not])
  3048   apply (intro ex_cong1 iffI, blast)
  2900   apply (intro ex_cong1 iffI, blast)
  3049   using closure_of_subset_Int by force
  2901   using closure_of_subset_Int by force
  3050 
  2902 
  3093     using assms
  2945     using assms
  3094     unfolding connectedin_eq_not_separated_subset
  2946     unfolding connectedin_eq_not_separated_subset
  3095     by (metis (no_types, lifting) assms connectedin_subset_separated_union inf.orderE separatedin_empty(1) separatedin_mono separatedin_sym)
  2947     by (metis (no_types, lifting) assms connectedin_subset_separated_union inf.orderE separatedin_empty(1) separatedin_mono separatedin_sym)
  3096   then show ?thesis
  2948   then show ?thesis
  3097     unfolding connectedin_eq_not_separated_subset
  2949     unfolding connectedin_eq_not_separated_subset
  3098     by (simp add: assms(1) assms(2) connectedin_subset_topspace Int_Un_distrib2)
  2950     by (simp add: assms connectedin_subset_topspace Int_Un_distrib2)
  3099 qed
  2951 qed
  3100 
  2952 
  3101 lemma connected_space_closures:
  2953 lemma connected_space_closures:
  3102      "connected_space X \<longleftrightarrow>
  2954      "connected_space X \<longleftrightarrow>
  3103         (\<nexists>e1 e2. e1 \<union> e2 = topspace X \<and> X closure_of e1 \<inter> X closure_of e2 = {} \<and> e1 \<noteq> {} \<and> e2 \<noteq> {})"
  2955         (\<nexists>e1 e2. e1 \<union> e2 = topspace X \<and> X closure_of e1 \<inter> X closure_of e2 = {} \<and> e1 \<noteq> {} \<and> e2 \<noteq> {})"
  3124   moreover
  2976   moreover
  3125   have "S - (topspace X \<inter> T) \<noteq> {}"
  2977   have "S - (topspace X \<inter> T) \<noteq> {}"
  3126     using assms(3) by blast
  2978     using assms(3) by blast
  3127   moreover
  2979   moreover
  3128   have "S \<inter> topspace X \<inter> T \<noteq> {}"
  2980   have "S \<inter> topspace X \<inter> T \<noteq> {}"
  3129     using assms(1) assms(2) connectedin by fastforce
  2981     using assms connectedin by fastforce
  3130   moreover
  2982   moreover
  3131   have False if "S \<inter> T \<noteq> {}" "S - T \<noteq> {}" "T \<subseteq> topspace X" "S \<inter> X frontier_of T = {}" for T
  2983   have False if "S \<inter> T \<noteq> {}" "S - T \<noteq> {}" "T \<subseteq> topspace X" "S \<inter> X frontier_of T = {}" for T
  3132   proof -
  2984   proof -
  3133     have null: "S \<inter> (X closure_of T - X interior_of T) = {}"
  2985     have null: "S \<inter> (X closure_of T - X interior_of T) = {}"
  3134       using that unfolding frontier_of_def by blast
  2986       using that unfolding frontier_of_def by blast
  3192     have "f ` U \<subseteq> topspace Y"
  3044     have "f ` U \<subseteq> topspace Y"
  3193       by (simp add: U 1)
  3045       by (simp add: U 1)
  3194     then have "topspace Y \<inter> f ` U = f ` U"
  3046     then have "topspace Y \<inter> f ` U = f ` U"
  3195       by (simp add: subset_antisym)
  3047       by (simp add: subset_antisym)
  3196     then show "subtopology Y (f ` U) homeomorphic_space subtopology X U"
  3048     then show "subtopology Y (f ` U) homeomorphic_space subtopology X U"
  3197       by (metis (no_types) Int_subset_iff U f homeomorphic_map_imp_homeomorphic_space homeomorphic_map_subtopologies homeomorphic_space_sym subset_antisym subset_refl)
  3049       by (metis U f homeomorphic_map_imp_homeomorphic_space homeomorphic_map_subtopologies homeomorphic_space_sym inf.absorb_iff2)
  3198   qed
  3050   qed
  3199   ultimately show ?thesis
  3051   ultimately show ?thesis
  3200     by (auto simp: connectedin_def)
  3052     by (auto simp: connectedin_def)
  3201 qed
  3053 qed
  3202 
  3054 
  3433     (\<forall>\<U>. (\<forall>C\<in>\<U>. closedin X C) \<and> (\<forall>\<F>. finite \<F> \<and> \<F> \<subseteq> \<U> \<longrightarrow> \<Inter>\<F> \<noteq> {}) \<longrightarrow> \<Inter>\<U> \<noteq> {})"
  3285     (\<forall>\<U>. (\<forall>C\<in>\<U>. closedin X C) \<and> (\<forall>\<F>. finite \<F> \<and> \<F> \<subseteq> \<U> \<longrightarrow> \<Inter>\<F> \<noteq> {}) \<longrightarrow> \<Inter>\<U> \<noteq> {})"
  3434    (is "_ = ?rhs")
  3286    (is "_ = ?rhs")
  3435 proof (cases "topspace X = {}")
  3287 proof (cases "topspace X = {}")
  3436   case True
  3288   case True
  3437   then show ?thesis
  3289   then show ?thesis
  3438 unfolding compact_space_def
  3290     unfolding compact_space_def
  3439   by (metis Sup_bot_conv(1) closedin_topspace_empty compactin_empty finite.emptyI finite_UnionD order_refl)
  3291     by (metis Sup_bot_conv(1) closedin_topspace_empty compactin_empty finite.emptyI finite_UnionD order_refl)
  3440 next
  3292 next
  3441   case False
  3293   case False
  3442   show ?thesis
  3294   show ?thesis
  3443   proof safe
  3295   proof safe
  3444     fix \<U> :: "'a set set"
  3296     fix \<U> :: "'a set set"
  3661   shows "embedding_map X X'' (g \<circ> f)"
  3513   shows "embedding_map X X'' (g \<circ> f)"
  3662 proof -
  3514 proof -
  3663   have hm: "homeomorphic_map X (subtopology X' (f ` topspace X)) f" "homeomorphic_map X' (subtopology X'' (g ` topspace X')) g"
  3515   have hm: "homeomorphic_map X (subtopology X' (f ` topspace X)) f" "homeomorphic_map X' (subtopology X'' (g ` topspace X')) g"
  3664     using assms by (auto simp: embedding_map_def)
  3516     using assms by (auto simp: embedding_map_def)
  3665   then obtain C where "g ` topspace X' \<inter> C = (g \<circ> f) ` topspace X"
  3517   then obtain C where "g ` topspace X' \<inter> C = (g \<circ> f) ` topspace X"
  3666     by (metis (no_types) Int_absorb1 continuous_map_image_subset_topspace continuous_map_in_subtopology homeomorphic_eq_everything_map image_comp image_mono)
  3518     by (metis homeomorphic_imp_surjective_map image_comp image_mono inf.absorb_iff2 topspace_subtopology)
  3667   then have "homeomorphic_map (subtopology X' (f ` topspace X)) (subtopology X'' ((g \<circ> f) ` topspace X)) g"
  3519   then have "homeomorphic_map (subtopology X' (f ` topspace X)) (subtopology X'' ((g \<circ> f) ` topspace X)) g"
  3668     by (metis hm homeomorphic_imp_surjective_map homeomorphic_map_subtopologies image_comp subtopology_subtopology topspace_subtopology)
  3520     by (metis hm homeomorphic_imp_surjective_map homeomorphic_map_subtopologies image_comp subtopology_subtopology topspace_subtopology)
  3669   then show ?thesis
  3521   then show ?thesis
  3670   unfolding embedding_map_def
  3522   unfolding embedding_map_def
  3671   using hm(1) homeomorphic_map_compose by blast
  3523   using hm(1) homeomorphic_map_compose by blast
  3736 
  3588 
  3737 lemma section_and_retraction_eq_homeomorphic_map:
  3589 lemma section_and_retraction_eq_homeomorphic_map:
  3738    "section_map X Y f \<and> retraction_map X Y f \<longleftrightarrow> homeomorphic_map X Y f"  (is "?lhs = ?rhs")
  3590    "section_map X Y f \<and> retraction_map X Y f \<longleftrightarrow> homeomorphic_map X Y f"  (is "?lhs = ?rhs")
  3739 proof
  3591 proof
  3740   assume ?lhs
  3592   assume ?lhs
  3741   then obtain g g' where f: "continuous_map X Y f" 
  3593   then obtain g where "homeomorphic_maps X Y f g"
  3742     and g: "continuous_map Y X g" "\<forall>x\<in>topspace X. g (f x) = x"
  3594     unfolding homeomorphic_maps_def retraction_map_def section_map_def
  3743     and g': "continuous_map Y X g'" "\<forall>x\<in>topspace Y. f (g' x) = x"
  3595     by (smt (verit, best) continuous_map_def retraction_maps_def)
  3744     by (auto simp: retraction_map_def retraction_maps_def section_map_def)
       
  3745   then have "homeomorphic_maps X Y f g"
       
  3746     by (force simp add: homeomorphic_maps_def continuous_map_def)
       
  3747   then show ?rhs
  3596   then show ?rhs
  3748     using homeomorphic_map_maps by blast
  3597     using homeomorphic_map_maps by blast
  3749 next
  3598 next
  3750   assume ?rhs
  3599   assume ?rhs
  3751   then show ?lhs
  3600   then show ?lhs
  3914   from open_prod_elim[OF \<open>open E\<close> \<open>(x, y) \<in> E\<close>]
  3763   from open_prod_elim[OF \<open>open E\<close> \<open>(x, y) \<in> E\<close>]
  3915   obtain E1 E2 where "open E1" "open E2" "(x, y) \<in> E1 \<times> E2" "E1 \<times> E2 \<subseteq> E"
  3764   obtain E1 E2 where "open E1" "open E2" "(x, y) \<in> E1 \<times> E2" "E1 \<times> E2 \<subseteq> E"
  3916     by blast
  3765     by blast
  3917   show ?thesis
  3766   show ?thesis
  3918   proof
  3767   proof
  3919     show "openin (top_of_set S) (E1 \<inter> S)"
  3768     show "openin (top_of_set S) (E1 \<inter> S)" "openin (top_of_set T) (E2 \<inter> T)"
  3920       "openin (top_of_set T) (E2 \<inter> T)"
  3769       using \<open>open E1\<close> \<open>open E2\<close> by (auto simp: openin_open)
  3921       using \<open>open E1\<close> \<open>open E2\<close>
       
  3922       by (auto simp: openin_open)
       
  3923     show "x \<in> E1 \<inter> S" "y \<in> E2 \<inter> T"
  3770     show "x \<in> E1 \<inter> S" "y \<in> E2 \<inter> T"
  3924       using \<open>(x, y) \<in> E1 \<times> E2\<close> \<open>x \<in> S\<close> \<open>y \<in> T\<close> by auto
  3771       using \<open>(x, y) \<in> E1 \<times> E2\<close> \<open>x \<in> S\<close> \<open>y \<in> T\<close> by auto
  3925     show "(E1 \<inter> S) \<times> (E2 \<inter> T) \<subseteq> U"
  3772     show "(E1 \<inter> S) \<times> (E2 \<inter> T) \<subseteq> U"
  3926       using \<open>E1 \<times> E2 \<subseteq> E\<close> \<open>U = _\<close>
  3773       using \<open>E1 \<times> E2 \<subseteq> E\<close> \<open>U = _\<close> by auto
  3927       by auto
       
  3928   qed
  3774   qed
  3929 qed
  3775 qed
  3930 
  3776 
  3931 lemma closedin_Times:
  3777 lemma closedin_Times:
  3932   "closedin (top_of_set S) S' \<Longrightarrow> closedin (top_of_set T) T' \<Longrightarrow>
  3778   "closedin (top_of_set S) S' \<Longrightarrow> closedin (top_of_set T) T' \<Longrightarrow>
  4028 lemma continuous_on_closed_gen:
  3874 lemma continuous_on_closed_gen:
  4029   assumes "f ` S \<subseteq> T"
  3875   assumes "f ` S \<subseteq> T"
  4030   shows "continuous_on S f \<longleftrightarrow>
  3876   shows "continuous_on S f \<longleftrightarrow>
  4031              (\<forall>U. closedin (top_of_set T) U
  3877              (\<forall>U. closedin (top_of_set T) U
  4032                   \<longrightarrow> closedin (top_of_set S) (S \<inter> f -` U))"
  3878                   \<longrightarrow> closedin (top_of_set S) (S \<inter> f -` U))"
  4033     (is "?lhs = ?rhs")
       
  4034 proof -
  3879 proof -
  4035   have *: "U \<subseteq> T \<Longrightarrow> S \<inter> f -` (T - U) = S - (S \<inter> f -` U)" for U
  3880   have *: "U \<subseteq> T \<Longrightarrow> S \<inter> f -` (T - U) = S - (S \<inter> f -` U)" for U
  4036     using assms by blast
  3881     using assms by blast
  4037   show ?thesis
  3882   then show ?thesis
  4038   proof
       
  4039     assume L: ?lhs
       
  4040     show ?rhs
       
  4041     proof clarify
       
  4042       fix U
       
  4043       assume "closedin (top_of_set T) U"
       
  4044       then show "closedin (top_of_set S) (S \<inter> f -` U)"
       
  4045         using L unfolding continuous_on_open_gen [OF assms]
       
  4046         by (metis * closedin_def inf_le1 topspace_euclidean_subtopology)
       
  4047     qed
       
  4048   next
       
  4049     assume R [rule_format]: ?rhs
       
  4050     show ?lhs
       
  4051       unfolding continuous_on_open_gen [OF assms]
  3883       unfolding continuous_on_open_gen [OF assms]
  4052       by (metis * R inf_le1 openin_closedin_eq topspace_euclidean_subtopology)
  3884       by (metis closedin_def inf.cobounded1 openin_closedin_eq topspace_euclidean_subtopology)
  4053   qed
       
  4054 qed
  3885 qed
  4055 
  3886 
  4056 lemma continuous_closedin_preimage_gen:
  3887 lemma continuous_closedin_preimage_gen:
  4057   assumes "continuous_on S f" "f ` S \<subseteq> T" "closedin (top_of_set T) U"
  3888   assumes "continuous_on S f" "f ` S \<subseteq> T" "closedin (top_of_set T) U"
  4058     shows "closedin (top_of_set S) (S \<inter> f -` U)"
  3889     shows "closedin (top_of_set S) (S \<inter> f -` U)"
  4123     unfolding topspace_def using openin_topology_generated_by_iff by auto
  3954     unfolding topspace_def using openin_topology_generated_by_iff by auto
  4124 qed
  3955 qed
  4125 
  3956 
  4126 lemma topology_generated_by_Basis:
  3957 lemma topology_generated_by_Basis:
  4127   "s \<in> S \<Longrightarrow> openin (topology_generated_by S) s"
  3958   "s \<in> S \<Longrightarrow> openin (topology_generated_by S) s"
  4128   by (simp only: openin_topology_generated_by_iff, auto simp: generate_topology_on.Basis)
  3959   by (simp add: Basis openin_topology_generated_by_iff)
  4129 
  3960 
  4130 lemma generate_topology_on_Inter:
  3961 lemma generate_topology_on_Inter:
  4131   "\<lbrakk>finite \<F>; \<And>K. K \<in> \<F> \<Longrightarrow> generate_topology_on \<S> K; \<F> \<noteq> {}\<rbrakk> \<Longrightarrow> generate_topology_on \<S> (\<Inter>\<F>)"
  3962   "\<lbrakk>finite \<F>; \<And>K. K \<in> \<F> \<Longrightarrow> generate_topology_on \<S> K; \<F> \<noteq> {}\<rbrakk> \<Longrightarrow> generate_topology_on \<S> (\<Inter>\<F>)"
  4132   by (induction \<F> rule: finite_induct; force intro: generate_topology_on.intros)
  3963   by (induction \<F> rule: finite_induct; force intro: generate_topology_on.intros)
  4133 
  3964 
  4407   shows "proper_map X Y f"
  4238   shows "proper_map X Y f"
  4408   unfolding proper_map_def
  4239   unfolding proper_map_def
  4409 proof (clarsimp simp: f)
  4240 proof (clarsimp simp: f)
  4410   show "compactin X {x \<in> topspace X. f x = y}"
  4241   show "compactin X {x \<in> topspace X. f x = y}"
  4411     if "y \<in> topspace Y" for y
  4242     if "y \<in> topspace Y" for y
       
  4243 using inj_on_eq_iff [OF inj] that
  4412   proof -
  4244   proof -
  4413     have "{x \<in> topspace X. f x = y} = {} \<or> (\<exists>a \<in> topspace X. {x \<in> topspace X. f x = y} = {a})"
  4245     have "{x \<in> topspace X. f x = y} = {} \<or> (\<exists>a \<in> topspace X. {x \<in> topspace X. f x = y} = {a})"
  4414       using inj_on_eq_iff [OF inj] by auto
  4246       using inj_on_eq_iff [OF inj] by auto
  4415     then show ?thesis
  4247     then show ?thesis
  4416       using that by (metis (no_types, lifting) compactin_empty compactin_sing)
  4248       using that by (metis (no_types, lifting) compactin_empty compactin_sing)
  4556   then show ?thesis
  4388   then show ?thesis
  4557     by (simp add: compact_space_topspace_empty proper_map_on_empty)
  4389     by (simp add: compact_space_topspace_empty proper_map_on_empty)
  4558 next
  4390 next
  4559   case False
  4391   case False
  4560   have *: "compactin X {x \<in> topspace X. c = y}" if "compact_space X" for y
  4392   have *: "compactin X {x \<in> topspace X. c = y}" if "compact_space X" for y
  4561   proof (cases "c = y")
  4393     using that unfolding compact_space_def
  4562     case True
  4394     by (metis (mono_tags, lifting) compactin_empty empty_subsetI mem_Collect_eq subsetI subset_antisym)
  4563     then show ?thesis
       
  4564       using compact_space_def \<open>compact_space X\<close> by auto
       
  4565   qed auto
       
  4566   then show ?thesis
  4395   then show ?thesis
  4567     using closed_compactin closedin_subset
  4396     using closed_compactin closedin_subset
  4568     by (force simp: False proper_map_def closed_map_const compact_space_def)
  4397     by (force simp: False proper_map_def closed_map_const compact_space_def)
  4569 qed
  4398 qed
  4570 
  4399 
  4571 lemma proper_map_inclusion:
  4400 lemma proper_map_inclusion:
  4572    "s \<subseteq> topspace X
  4401    "S \<subseteq> topspace X \<Longrightarrow> proper_map (subtopology X S) X id \<longleftrightarrow> closedin X S \<and> (\<forall>k. compactin X k \<longrightarrow> compactin X (S \<inter> k))"
  4573         \<Longrightarrow> proper_map (subtopology X s) X id \<longleftrightarrow> closedin X s \<and> (\<forall>k. compactin X k \<longrightarrow> compactin X (s \<inter> k))"
  4402   by (metis closed_Int_compactin closed_map_inclusion_eq inf.absorb_iff2 inj_on_id injective_imp_proper_eq_closed_map)
  4574   by (auto simp: proper_map_alt closed_map_inclusion_eq inf.absorb_iff2 Collect_conj_eq compactin_subtopology intro: closed_Int_compactin)
       
  4575 
  4403 
  4576 
  4404 
  4577 subsection\<open>Perfect maps (proper, continuous and surjective)\<close>
  4405 subsection\<open>Perfect maps (proper, continuous and surjective)\<close>
  4578 
  4406 
  4579 definition perfect_map 
  4407 definition perfect_map