src/HOL/Analysis/Abstract_Topology.thy
changeset 72608 ad45ae49be85
parent 71857 d73955442df5
child 73932 fd21b4a93043
equal deleted inserted replaced
72569:d56e4eeae967 72608:ad45ae49be85
    54     "openin U {}"
    54     "openin U {}"
    55     "\<And>S T. openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S\<inter>T)"
    55     "\<And>S T. openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S\<inter>T)"
    56     "\<And>K. (\<forall>S \<in> K. openin U S) \<Longrightarrow> openin U (\<Union>K)"
    56     "\<And>K. (\<forall>S \<in> K. openin U S) \<Longrightarrow> openin U (\<Union>K)"
    57   using openin[of U] unfolding istopology_def by auto
    57   using openin[of U] unfolding istopology_def by auto
    58 
    58 
    59 lemma openin_subset[intro]: "openin U S \<Longrightarrow> S \<subseteq> topspace U"
    59 lemma openin_subset: "openin U S \<Longrightarrow> S \<subseteq> topspace U"
    60   unfolding topspace_def by blast
    60   unfolding topspace_def by blast
    61 
    61 
    62 lemma openin_empty[simp]: "openin U {}"
    62 lemma openin_empty[simp]: "openin U {}"
    63   by (rule openin_clauses)
    63   by (rule openin_clauses)
    64 
    64 
   145   using Ke Kc unfolding closedin_def Diff_Inter by auto
   145   using Ke Kc unfolding closedin_def Diff_Inter by auto
   146 
   146 
   147 lemma closedin_INT[intro]:
   147 lemma closedin_INT[intro]:
   148   assumes "A \<noteq> {}" "\<And>x. x \<in> A \<Longrightarrow> closedin U (B x)"
   148   assumes "A \<noteq> {}" "\<And>x. x \<in> A \<Longrightarrow> closedin U (B x)"
   149   shows "closedin U (\<Inter>x\<in>A. B x)"
   149   shows "closedin U (\<Inter>x\<in>A. B x)"
   150   apply (rule closedin_Inter)
   150   using assms by blast
   151   using assms
       
   152   apply auto
       
   153   done
       
   154 
   151 
   155 lemma closedin_Int[intro]: "closedin U S \<Longrightarrow> closedin U T \<Longrightarrow> closedin U (S \<inter> T)"
   152 lemma closedin_Int[intro]: "closedin U S \<Longrightarrow> closedin U T \<Longrightarrow> closedin U (S \<inter> T)"
   156   using closedin_Inter[of "{S,T}" U] by auto
   153   using closedin_Inter[of "{S,T}" U] by auto
   157 
   154 
   158 lemma openin_closedin_eq: "openin U S \<longleftrightarrow> S \<subseteq> topspace U \<and> closedin U (topspace U - S)"
   155 lemma openin_closedin_eq: "openin U S \<longleftrightarrow> S \<subseteq> topspace U \<and> closedin U (topspace U - S)"
   159   apply (auto simp: closedin_def Diff_Diff_Int inf_absorb2)
   156   by (metis Diff_subset closedin_def double_diff equalityD1 openin_subset)
   160   apply (metis openin_subset subset_eq)
       
   161   done
       
   162 
   157 
   163 lemma topology_finer_closedin:
   158 lemma topology_finer_closedin:
   164   "topspace X = topspace Y \<Longrightarrow> (\<forall>S. openin Y S \<longrightarrow> openin X S) \<longleftrightarrow> (\<forall>S. closedin Y S \<longrightarrow> closedin X S)"
   159   "topspace X = topspace Y \<Longrightarrow> (\<forall>S. openin Y S \<longrightarrow> openin X S) \<longleftrightarrow> (\<forall>S. closedin Y S \<longrightarrow> closedin X S)"
   165   apply safe
   160   by (metis closedin_def openin_closedin_eq)
   166    apply (simp add: closedin_def)
       
   167   by (simp add: openin_closedin_eq)
       
   168 
   161 
   169 lemma openin_closedin: "S \<subseteq> topspace U \<Longrightarrow> (openin U S \<longleftrightarrow> closedin U (topspace U - S))"
   162 lemma openin_closedin: "S \<subseteq> topspace U \<Longrightarrow> (openin U S \<longleftrightarrow> closedin U (topspace U - S))"
   170   by (simp add: openin_closedin_eq)
   163   by (simp add: openin_closedin_eq)
   171 
   164 
   172 lemma openin_diff[intro]:
   165 lemma openin_diff[intro]:
   423 
   416 
   424 abbreviation top_of_set :: "'a::topological_space set \<Rightarrow> 'a topology"
   417 abbreviation top_of_set :: "'a::topological_space set \<Rightarrow> 'a topology"
   425   where "top_of_set \<equiv> subtopology (topology open)"
   418   where "top_of_set \<equiv> subtopology (topology open)"
   426 
   419 
   427 lemma open_openin: "open S \<longleftrightarrow> openin euclidean S"
   420 lemma open_openin: "open S \<longleftrightarrow> openin euclidean S"
   428   apply (rule cong[where x=S and y=S])
   421   by (simp add: istopology_open topology_inverse')
   429   apply (rule topology_inverse[symmetric])
       
   430   apply (auto simp: istopology_def)
       
   431   done
       
   432 
   422 
   433 declare open_openin [symmetric, simp]
   423 declare open_openin [symmetric, simp]
   434 
   424 
   435 lemma topspace_euclidean [simp]: "topspace euclidean = UNIV"
   425 lemma topspace_euclidean [simp]: "topspace euclidean = UNIV"
   436   by (force simp: topspace_def)
   426   by (force simp: topspace_def)
   508   define T where "T = {x. \<exists>a\<in>S. \<exists>d>0. (\<forall>y\<in>U. dist y a < d \<longrightarrow> y \<in> S) \<and> dist x a < d}"
   498   define T where "T = {x. \<exists>a\<in>S. \<exists>d>0. (\<forall>y\<in>U. dist y a < d \<longrightarrow> y \<in> S) \<and> dist x a < d}"
   509   have 1: "\<forall>x\<in>T. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> T"
   499   have 1: "\<forall>x\<in>T. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> T"
   510     unfolding T_def
   500     unfolding T_def
   511     apply clarsimp
   501     apply clarsimp
   512     apply (rule_tac x="d - dist x a" in exI)
   502     apply (rule_tac x="d - dist x a" in exI)
   513     apply (clarsimp simp add: less_diff_eq)
   503     by (metis add_0_left dist_commute dist_triangle_lt less_diff_eq)
   514     by (metis dist_commute dist_triangle_lt)
       
   515   assume ?rhs then have 2: "S = U \<inter> T"
   504   assume ?rhs then have 2: "S = U \<inter> T"
   516     unfolding T_def
   505     unfolding T_def
   517     by auto (metis dist_self)
   506     by auto (metis dist_self)
   518   from 1 2 show ?lhs
   507   from 1 2 show ?lhs
   519     unfolding openin_open open_dist by fast
   508     unfolding openin_open open_dist by fast
   530       "connected S \<longleftrightarrow>
   519       "connected S \<longleftrightarrow>
   531        \<not>(\<exists>E1 E2. openin (top_of_set S) E1 \<and>
   520        \<not>(\<exists>E1 E2. openin (top_of_set S) E1 \<and>
   532                  openin (top_of_set S) E2 \<and>
   521                  openin (top_of_set S) E2 \<and>
   533                  E1 \<union> E2 = S \<and> E1 \<inter> E2 = {} \<and>
   522                  E1 \<union> E2 = S \<and> E1 \<inter> E2 = {} \<and>
   534                  E1 \<noteq> {} \<and> E2 \<noteq> {})"
   523                  E1 \<noteq> {} \<and> E2 \<noteq> {})"
   535   apply (simp add: connected_openin, safe, blast)
   524   unfolding connected_openin
   536   by (metis Int_lower1 Un_subset_iff openin_open subset_antisym)
   525   by (metis (no_types, lifting) Un_subset_iff openin_imp_subset subset_antisym)
   537 
   526 
   538 lemma connected_closedin:
   527 lemma connected_closedin:
   539       "connected S \<longleftrightarrow>
   528       "connected S \<longleftrightarrow>
   540        (\<nexists>E1 E2.
   529        (\<nexists>E1 E2.
   541         closedin (top_of_set S) E1 \<and>
   530         closedin (top_of_set S) E1 \<and>
   570            \<not>(\<exists>E1 E2.
   559            \<not>(\<exists>E1 E2.
   571                  closedin (top_of_set S) E1 \<and>
   560                  closedin (top_of_set S) E1 \<and>
   572                  closedin (top_of_set S) E2 \<and>
   561                  closedin (top_of_set S) E2 \<and>
   573                  E1 \<union> E2 = S \<and> E1 \<inter> E2 = {} \<and>
   562                  E1 \<union> E2 = S \<and> E1 \<inter> E2 = {} \<and>
   574                  E1 \<noteq> {} \<and> E2 \<noteq> {})"
   563                  E1 \<noteq> {} \<and> E2 \<noteq> {})"
   575   apply (simp add: connected_closedin, safe, blast)
   564   unfolding connected_closedin
   576   by (metis Int_lower1 Un_subset_iff closedin_closed subset_antisym)
   565   by (metis Un_subset_iff closedin_imp_subset subset_antisym)
   577 
   566 
   578 text \<open>These "transitivity" results are handy too\<close>
   567 text \<open>These "transitivity" results are handy too\<close>
   579 
   568 
   580 lemma openin_trans[trans]:
   569 lemma openin_trans[trans]:
   581   "openin (top_of_set T) S \<Longrightarrow> openin (top_of_set U) T \<Longrightarrow>
   570   "openin (top_of_set T) S \<Longrightarrow> openin (top_of_set U) T \<Longrightarrow>
   637 
   626 
   638 lemma derived_set_of_Un:
   627 lemma derived_set_of_Un:
   639    "X derived_set_of (S \<union> T) = X derived_set_of S \<union> X derived_set_of T" (is "?lhs = ?rhs")
   628    "X derived_set_of (S \<union> T) = X derived_set_of S \<union> X derived_set_of T" (is "?lhs = ?rhs")
   640 proof
   629 proof
   641   show "?lhs \<subseteq> ?rhs"
   630   show "?lhs \<subseteq> ?rhs"
   642     apply (clarsimp simp: in_derived_set_of)
   631     by (clarsimp simp: in_derived_set_of) (metis IntE IntI openin_Int)
   643     by (metis IntE IntI openin_Int)
       
   644   show "?rhs \<subseteq> ?lhs"
   632   show "?rhs \<subseteq> ?lhs"
   645     by (simp add: derived_set_of_mono)
   633     by (simp add: derived_set_of_mono)
   646 qed
   634 qed
   647 
   635 
   648 lemma derived_set_of_Union:
   636 lemma derived_set_of_Union:
   652   then show ?case
   640   then show ?case
   653     by (simp add: derived_set_of_Un)
   641     by (simp add: derived_set_of_Un)
   654 qed auto
   642 qed auto
   655 
   643 
   656 lemma derived_set_of_topspace:
   644 lemma derived_set_of_topspace:
   657   "X derived_set_of (topspace X) = {x \<in> topspace X. \<not> openin X {x}}"
   645   "X derived_set_of (topspace X) = {x \<in> topspace X. \<not> openin X {x}}" (is "?lhs = ?rhs")
   658   apply (auto simp: in_derived_set_of)
   646 proof
   659   by (metis Set.set_insert all_not_in_conv insertCI openin_subset subsetCE)
   647   show "?lhs \<subseteq> ?rhs"
       
   648     by (auto simp: in_derived_set_of)
       
   649   show "?rhs \<subseteq> ?lhs"
       
   650     by (clarsimp simp: in_derived_set_of) (metis openin_closedin_eq openin_subopen singletonD subset_eq)
       
   651 qed
   660 
   652 
   661 lemma discrete_topology_unique_derived_set:
   653 lemma discrete_topology_unique_derived_set:
   662      "discrete_topology U = X \<longleftrightarrow> topspace X = U \<and> X derived_set_of U = {}"
   654      "discrete_topology U = X \<longleftrightarrow> topspace X = U \<and> X derived_set_of U = {}"
   663   by (auto simp: discrete_topology_unique derived_set_of_topspace)
   655   by (auto simp: discrete_topology_unique derived_set_of_topspace)
   664 
   656 
   674 
   666 
   675 lemma subtopology_eq_discrete_topology_gen:
   667 lemma subtopology_eq_discrete_topology_gen:
   676    "S \<inter> X derived_set_of S = {} \<Longrightarrow> subtopology X S = discrete_topology(topspace X \<inter> S)"
   668    "S \<inter> X derived_set_of S = {} \<Longrightarrow> subtopology X S = discrete_topology(topspace X \<inter> S)"
   677   by (metis Int_lower1 derived_set_of_restrict inf_assoc inf_bot_right subtopology_eq_discrete_topology_eq subtopology_subtopology subtopology_topspace)
   669   by (metis Int_lower1 derived_set_of_restrict inf_assoc inf_bot_right subtopology_eq_discrete_topology_eq subtopology_subtopology subtopology_topspace)
   678 
   670 
   679 lemma subtopology_discrete_topology [simp]: "subtopology (discrete_topology U) S = discrete_topology(U \<inter> S)"
   671 lemma subtopology_discrete_topology [simp]: 
       
   672   "subtopology (discrete_topology U) S = discrete_topology(U \<inter> S)"
   680 proof -
   673 proof -
   681   have "(\<lambda>T. \<exists>Sa. T = Sa \<inter> S \<and> Sa \<subseteq> U) = (\<lambda>Sa. Sa \<subseteq> U \<and> Sa \<subseteq> S)"
   674   have "(\<lambda>T. \<exists>Sa. T = Sa \<inter> S \<and> Sa \<subseteq> U) = (\<lambda>Sa. Sa \<subseteq> U \<and> Sa \<subseteq> S)"
   682     by force
   675     by force
   683   then show ?thesis
   676   then show ?thesis
   684     by (simp add: subtopology_def) (simp add: discrete_topology_def)
   677     by (simp add: subtopology_def) (simp add: discrete_topology_def)
   686 lemma openin_Int_derived_set_of_subset:
   679 lemma openin_Int_derived_set_of_subset:
   687    "openin X S \<Longrightarrow> S \<inter> X derived_set_of T \<subseteq> X derived_set_of (S \<inter> T)"
   680    "openin X S \<Longrightarrow> S \<inter> X derived_set_of T \<subseteq> X derived_set_of (S \<inter> T)"
   688   by (auto simp: derived_set_of_def)
   681   by (auto simp: derived_set_of_def)
   689 
   682 
   690 lemma openin_Int_derived_set_of_eq:
   683 lemma openin_Int_derived_set_of_eq:
   691   "openin X S \<Longrightarrow> S \<inter> X derived_set_of T = S \<inter> X derived_set_of (S \<inter> T)"
   684   assumes "openin X S"
   692   apply auto
   685   shows "S \<inter> X derived_set_of T = S \<inter> X derived_set_of (S \<inter> T)" (is "?lhs = ?rhs")
   693    apply (meson IntI openin_Int_derived_set_of_subset subsetCE)
   686 proof
   694   by (meson derived_set_of_mono inf_sup_ord(2) subset_eq)
   687   show "?lhs \<subseteq> ?rhs"
       
   688     by (simp add: assms openin_Int_derived_set_of_subset)
       
   689   show "?rhs \<subseteq> ?lhs"
       
   690     by (metis derived_set_of_mono inf_commute inf_le1 inf_mono order_refl)
       
   691 qed
   695 
   692 
   696 
   693 
   697 subsection\<open> Closure with respect to a topological space\<close>
   694 subsection\<open> Closure with respect to a topological space\<close>
   698 
   695 
   699 definition closure_of :: "'a topology \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixr "closure'_of" 80)
   696 definition closure_of :: "'a topology \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixr "closure'_of" 80)
   700   where "X closure_of S \<equiv> {x \<in> topspace X. \<forall>T. x \<in> T \<and> openin X T \<longrightarrow> (\<exists>y \<in> S. y \<in> T)}"
   697   where "X closure_of S \<equiv> {x \<in> topspace X. \<forall>T. x \<in> T \<and> openin X T \<longrightarrow> (\<exists>y \<in> S. y \<in> T)}"
   701 
   698 
   702 lemma closure_of_restrict: "X closure_of S = X closure_of (topspace X \<inter> S)"
   699 lemma closure_of_restrict: "X closure_of S = X closure_of (topspace X \<inter> S)"
   703   unfolding closure_of_def
   700   unfolding closure_of_def
   704   apply safe
   701   using openin_subset by blast
   705   apply (meson IntI openin_subset subset_iff)
       
   706   by auto
       
   707 
   702 
   708 lemma in_closure_of:
   703 lemma in_closure_of:
   709    "x \<in> X closure_of S \<longleftrightarrow>
   704    "x \<in> X closure_of S \<longleftrightarrow>
   710     x \<in> topspace X \<and> (\<forall>T. x \<in> T \<and> openin X T \<longrightarrow> (\<exists>y. y \<in> S \<and> y \<in> T))"
   705     x \<in> topspace X \<and> (\<forall>T. x \<in> T \<and> openin X T \<longrightarrow> (\<exists>y. y \<in> S \<and> y \<in> T))"
   711   by (auto simp: closure_of_def)
   706   by (auto simp: closure_of_def)
   767 
   762 
   768 lemma closure_of_subset_Int: "topspace X \<inter> S \<subseteq> X closure_of S"
   763 lemma closure_of_subset_Int: "topspace X \<inter> S \<subseteq> X closure_of S"
   769   by (auto simp: closure_of_def)
   764   by (auto simp: closure_of_def)
   770 
   765 
   771 lemma closure_of_subset_eq: "S \<subseteq> topspace X \<and> X closure_of S \<subseteq> S \<longleftrightarrow> closedin X S"
   766 lemma closure_of_subset_eq: "S \<subseteq> topspace X \<and> X closure_of S \<subseteq> S \<longleftrightarrow> closedin X S"
   772 proof (cases "S \<subseteq> topspace X")
   767 proof -
   773   case True
   768   have "openin X (topspace X - S)"
   774   then have "\<forall>x. x \<in> topspace X \<and> (\<forall>T. x \<in> T \<and> openin X T \<longrightarrow> (\<exists>y\<in>S. y \<in> T)) \<longrightarrow> x \<in> S
   769     if "\<And>x. \<lbrakk>x \<in> topspace X; \<forall>T. x \<in> T \<and> openin X T \<longrightarrow> S \<inter> T \<noteq> {}\<rbrakk> \<Longrightarrow> x \<in> S"
   775              \<Longrightarrow> openin X (topspace X - S)"
   770     apply (subst openin_subopen)
   776     apply (subst openin_subopen, safe)
   771     by (metis Diff_iff Diff_mono Diff_triv inf.commute openin_subset order_refl that)
   777     by (metis DiffI subset_eq openin_subset [of X])
       
   778   then show ?thesis
   772   then show ?thesis
   779     by (auto simp: closedin_def closure_of_def)
   773     by (auto simp: closedin_def closure_of_def disjoint_iff_not_equal)
   780 next
       
   781   case False
       
   782   then show ?thesis
       
   783     by (simp add: closedin_def)
       
   784 qed
   774 qed
   785 
   775 
   786 lemma closure_of_eq: "X closure_of S = S \<longleftrightarrow> closedin X S"
   776 lemma closure_of_eq: "X closure_of S = S \<longleftrightarrow> closedin X S"
   787 proof (cases "S \<subseteq> topspace X")
   777 proof (cases "S \<subseteq> topspace X")
   788   case True
   778   case True
   888   show "X closure_of (S \<inter> T) \<subseteq> X closure_of (S \<inter> X closure_of T)"
   878   show "X closure_of (S \<inter> T) \<subseteq> X closure_of (S \<inter> X closure_of T)"
   889     by (metis Int_lower1 Int_subset_iff assms closedin_closure_of closure_of_minimal_eq closure_of_mono inf_le2 le_infI1 openin_subset)
   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)
   890 qed
   880 qed
   891 
   881 
   892 lemma openin_Int_closure_of_eq:
   882 lemma openin_Int_closure_of_eq:
   893   "openin X S \<Longrightarrow> S \<inter> X closure_of T = S \<inter> X closure_of (S \<inter> T)"
   883   assumes "openin X S" shows "S \<inter> X closure_of T = S \<inter> X closure_of (S \<inter> T)"  (is "?lhs = ?rhs")
   894   apply (rule equalityI)
   884 proof
   895    apply (simp add: openin_Int_closure_of_subset)
   885   show "?lhs \<subseteq> ?rhs"
   896   by (meson closure_of_mono inf.cobounded2 inf_mono subset_refl)
   886     by (simp add: assms openin_Int_closure_of_subset)
       
   887   show "?rhs \<subseteq> ?lhs"
       
   888     by (metis closure_of_mono inf_commute inf_le1 inf_mono order_refl)
       
   889 qed
   897 
   890 
   898 lemma openin_Int_closure_of_eq_empty:
   891 lemma openin_Int_closure_of_eq_empty:
   899    "openin X S \<Longrightarrow> S \<inter> X closure_of T = {} \<longleftrightarrow> S \<inter> T = {}"
   892   assumes "openin X S" shows "S \<inter> X closure_of T = {} \<longleftrightarrow> S \<inter> T = {}"  (is "?lhs = ?rhs")
   900   apply (subst openin_Int_closure_of_eq, auto)
   893 proof
   901   by (meson IntI closure_of_subset_Int disjoint_iff_not_equal openin_subset subset_eq)
   894   show "?lhs \<Longrightarrow> ?rhs"
       
   895     unfolding disjoint_iff
       
   896     by (meson assms in_closure_of in_mono openin_subset)
       
   897   show "?rhs \<Longrightarrow> ?lhs"
       
   898     by (simp add: assms openin_Int_closure_of_eq)
       
   899 qed
   902 
   900 
   903 lemma closure_of_openin_Int_superset:
   901 lemma closure_of_openin_Int_superset:
   904    "openin X S \<and> S \<subseteq> X closure_of T
   902    "openin X S \<and> S \<subseteq> X closure_of T
   905         \<Longrightarrow> X closure_of (S \<inter> T) = X closure_of S"
   903         \<Longrightarrow> X closure_of (S \<inter> T) = X closure_of S"
   906   by (metis closure_of_openin_Int_closure_of inf.orderE)
   904   by (metis closure_of_openin_Int_closure_of inf.orderE)
   996   by (simp add: openin_subset)
   994   by (simp add: openin_subset)
   997 
   995 
   998 lemma interior_of_subset_subtopology: "(subtopology X S) interior_of T \<subseteq> S"
   996 lemma interior_of_subset_subtopology: "(subtopology X S) interior_of T \<subseteq> S"
   999   by (meson openin_imp_subset openin_interior_of)
   997   by (meson openin_imp_subset openin_interior_of)
  1000 
   998 
  1001 lemma interior_of_Int: "X interior_of (S \<inter> T) = X interior_of S \<inter> X interior_of T"
   999 lemma interior_of_Int: "X interior_of (S \<inter> T) = X interior_of S \<inter> X interior_of T"  (is "?lhs = ?rhs")
  1002   apply (rule equalityI)
  1000 proof
  1003    apply (simp add: interior_of_mono)
  1001   show "?lhs \<subseteq> ?rhs"
  1004   apply (auto simp: interior_of_maximal_eq openin_Int interior_of_subset le_infI1 le_infI2)
  1002     by (simp add: interior_of_mono)
  1005   done
  1003   show "?rhs \<subseteq> ?lhs"
       
  1004     by (meson inf_mono interior_of_maximal interior_of_subset openin_Int openin_interior_of)
       
  1005 qed
  1006 
  1006 
  1007 lemma interior_of_Inter_subset: "X interior_of (\<Inter>\<F>) \<subseteq> (\<Inter>S \<in> \<F>. X interior_of S)"
  1007 lemma interior_of_Inter_subset: "X interior_of (\<Inter>\<F>) \<subseteq> (\<Inter>S \<in> \<F>. X interior_of S)"
  1008   by (simp add: INT_greatest Inf_lower interior_of_mono)
  1008   by (simp add: INT_greatest Inf_lower interior_of_mono)
  1009 
  1009 
  1010 lemma union_interior_of_subset:
  1010 lemma union_interior_of_subset:
  1250 
  1250 
  1251 lemma frontier_of_Int_subset: "X frontier_of (S \<inter> T) \<subseteq> X frontier_of S \<union> X frontier_of T"
  1251 lemma frontier_of_Int_subset: "X frontier_of (S \<inter> T) \<subseteq> X frontier_of S \<union> X frontier_of T"
  1252   by (simp add: frontier_of_Int)
  1252   by (simp add: frontier_of_Int)
  1253 
  1253 
  1254 lemma frontier_of_Int_closedin:
  1254 lemma frontier_of_Int_closedin:
  1255   "\<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> X frontier_of(S \<inter> T) = X frontier_of S \<inter> T \<union> S \<inter> X frontier_of T"
  1255   assumes "closedin X S" "closedin X T" 
  1256   apply (simp add: frontier_of_Int closedin_Int closure_of_closedin)
  1256   shows "X frontier_of(S \<inter> T) = X frontier_of S \<inter> T \<union> S \<inter> X frontier_of T"  (is "?lhs = ?rhs")
  1257   using frontier_of_subset_closedin by blast
  1257 proof
       
  1258   show "?lhs \<subseteq> ?rhs"
       
  1259     using assms by (force simp add: frontier_of_Int closedin_Int closure_of_closedin)
       
  1260   show "?rhs \<subseteq> ?lhs"
       
  1261     using assms frontier_of_subset_closedin
       
  1262     by (auto simp add: frontier_of_Int closedin_Int closure_of_closedin)
       
  1263 qed
  1258 
  1264 
  1259 lemma frontier_of_Un_subset: "X frontier_of(S \<union> T) \<subseteq> X frontier_of S \<union> X frontier_of T"
  1265 lemma frontier_of_Un_subset: "X frontier_of(S \<union> T) \<subseteq> X frontier_of S \<union> X frontier_of T"
  1260   by (metis Diff_Un frontier_of_Int_subset frontier_of_complement)
  1266   by (metis Diff_Un frontier_of_Int_subset frontier_of_complement)
  1261 
  1267 
  1262 lemma frontier_of_Union_subset:
  1268 lemma frontier_of_Union_subset:
  1294 
  1300 
  1295 lemma locally_finite_in_subset:
  1301 lemma locally_finite_in_subset:
  1296   assumes "locally_finite_in X \<A>" "\<B> \<subseteq> \<A>"
  1302   assumes "locally_finite_in X \<A>" "\<B> \<subseteq> \<A>"
  1297   shows "locally_finite_in X \<B>"
  1303   shows "locally_finite_in X \<B>"
  1298 proof -
  1304 proof -
  1299   have "finite {U \<in> \<A>. U \<inter> V \<noteq> {}} \<Longrightarrow> finite {U \<in> \<B>. U \<inter> V \<noteq> {}}" for V
  1305   have "finite (\<A> \<inter> {U. U \<inter> V \<noteq> {}}) \<Longrightarrow> finite (\<B> \<inter> {U. U \<inter> V \<noteq> {}})" for V
  1300     apply (erule rev_finite_subset) using \<open>\<B> \<subseteq> \<A>\<close> by blast
  1306     by (meson \<open>\<B> \<subseteq> \<A>\<close> finite_subset inf_le1 inf_le2 le_inf_iff subset_trans)
  1301   then show ?thesis
  1307   then show ?thesis
  1302   using assms unfolding locally_finite_in_def by (fastforce simp add:)
  1308     using assms unfolding locally_finite_in_def Int_def by fastforce
  1303 qed
  1309 qed
  1304 
  1310 
  1305 lemma locally_finite_in_refinement:
  1311 lemma locally_finite_in_refinement:
  1306   assumes \<A>: "locally_finite_in X \<A>" and f: "\<And>S. S \<in> \<A> \<Longrightarrow> f S \<subseteq> S"
  1312   assumes \<A>: "locally_finite_in X \<A>" and f: "\<And>S. S \<in> \<A> \<Longrightarrow> f S \<subseteq> S"
  1307   shows "locally_finite_in X (f ` \<A>)"
  1313   shows "locally_finite_in X (f ` \<A>)"
  1409 
  1415 
  1410 lemma closure_of_Union_subset: "\<Union>((\<lambda>S. X closure_of S) ` \<A>) \<subseteq> X closure_of (\<Union>\<A>)"
  1416 lemma closure_of_Union_subset: "\<Union>((\<lambda>S. X closure_of S) ` \<A>) \<subseteq> X closure_of (\<Union>\<A>)"
  1411   by clarify (meson Union_upper closure_of_mono subsetD)
  1417   by clarify (meson Union_upper closure_of_mono subsetD)
  1412 
  1418 
  1413 lemma closure_of_locally_finite_Union:
  1419 lemma closure_of_locally_finite_Union:
  1414    "locally_finite_in X \<A> \<Longrightarrow> X closure_of (\<Union>\<A>) = \<Union>((\<lambda>S. X closure_of S) ` \<A>)"
  1420   assumes "locally_finite_in X \<A>" 
  1415   apply (rule closure_of_unique)
  1421   shows "X closure_of (\<Union>\<A>) = \<Union>((\<lambda>S. X closure_of S) ` \<A>)"  
  1416   apply (simp add: SUP_upper2 Sup_le_iff closure_of_subset locally_finite_in_def)
  1422 proof (rule closure_of_unique)
  1417   apply (simp add: closedin_Union_locally_finite_closure)
  1423   show "\<Union> \<A> \<subseteq> \<Union> ((closure_of) X ` \<A>)"
  1418   by (simp add: Sup_le_iff closure_of_minimal)
  1424     using assms by (simp add: SUP_upper2 Sup_le_iff closure_of_subset locally_finite_in_def)
       
  1425   show "closedin X (\<Union> ((closure_of) X ` \<A>))"
       
  1426     using assms by (simp add: closedin_Union_locally_finite_closure)
       
  1427   show "\<And>T'. \<lbrakk>\<Union> \<A> \<subseteq> T'; closedin X T'\<rbrakk> \<Longrightarrow> \<Union> ((closure_of) X ` \<A>) \<subseteq> T'"
       
  1428     by (simp add: Sup_le_iff closure_of_minimal)
       
  1429 qed
  1419 
  1430 
  1420 
  1431 
  1421 subsection\<^marker>\<open>tag important\<close> \<open>Continuous maps\<close>
  1432 subsection\<^marker>\<open>tag important\<close> \<open>Continuous maps\<close>
  1422 
  1433 
  1423 text \<open>We will need to deal with continuous maps in terms of topologies and not in terms
  1434 text \<open>We will need to deal with continuous maps in terms of topologies and not in terms
  1593   ultimately show ?thesis
  1604   ultimately show ?thesis
  1594     by (auto simp: frontier_of_closures)
  1605     by (auto simp: frontier_of_closures)
  1595 qed
  1606 qed
  1596 
  1607 
  1597 lemma topology_finer_continuous_id:
  1608 lemma topology_finer_continuous_id:
  1598   "topspace X = topspace Y \<Longrightarrow> ((\<forall>S. openin X S \<longrightarrow> openin Y S) \<longleftrightarrow> continuous_map Y X id)"
  1609   assumes "topspace X = topspace Y" 
  1599   unfolding continuous_map_def
  1610   shows "(\<forall>S. openin X S \<longrightarrow> openin Y S) \<longleftrightarrow> continuous_map Y X id"  (is "?lhs = ?rhs")
  1600   apply auto
  1611 proof
  1601   using openin_subopen openin_subset apply fastforce
  1612   show "?lhs \<Longrightarrow> ?rhs"
  1602   using openin_subopen topspace_def by fastforce
  1613     unfolding continuous_map_def
       
  1614     using assms openin_subopen openin_subset by fastforce
       
  1615   show "?rhs \<Longrightarrow> ?lhs"
       
  1616     unfolding continuous_map_def
       
  1617     using assms openin_subopen topspace_def by fastforce
       
  1618 qed
  1603 
  1619 
  1604 lemma continuous_map_const [simp]:
  1620 lemma continuous_map_const [simp]:
  1605    "continuous_map X Y (\<lambda>x. C) \<longleftrightarrow> topspace X = {} \<or> C \<in> topspace Y"
  1621    "continuous_map X Y (\<lambda>x. C) \<longleftrightarrow> topspace X = {} \<or> C \<in> topspace Y"
  1606 proof (cases "topspace X = {}")
  1622 proof (cases "topspace X = {}")
  1607   case False
  1623   case False
  1893 lemma closed_map_from_subtopology:
  1909 lemma closed_map_from_subtopology:
  1894      "\<lbrakk>closed_map X X' f; closedin X U\<rbrakk> \<Longrightarrow> closed_map (subtopology X U) X' f"
  1910      "\<lbrakk>closed_map X X' f; closedin X U\<rbrakk> \<Longrightarrow> closed_map (subtopology X U) X' f"
  1895   unfolding closed_map_def closedin_subtopology_alt by blast
  1911   unfolding closed_map_def closedin_subtopology_alt by blast
  1896 
  1912 
  1897 lemma open_map_restriction:
  1913 lemma open_map_restriction:
  1898      "\<lbrakk>open_map X X' f; {x. x \<in> topspace X \<and> f x \<in> V} = U\<rbrakk>
  1914   assumes f: "open_map X X' f" and U: "{x \<in> topspace X. f x \<in> V} = U"
  1899       \<Longrightarrow> open_map (subtopology X U) (subtopology X' V) f"
  1915   shows "open_map (subtopology X U) (subtopology X' V) f"
  1900   unfolding open_map_def openin_subtopology_alt
  1916   unfolding open_map_def
  1901   apply clarify
  1917 proof clarsimp
  1902   apply (rename_tac T)
  1918   fix W
  1903   apply (rule_tac x="f ` T" in image_eqI)
  1919   assume "openin (subtopology X U) W"
  1904   using openin_closedin_eq by fastforce+
  1920   then obtain T where "openin X T" "W = T \<inter> U"
       
  1921     by (meson openin_subtopology)
       
  1922   with f U have "f ` W = (f ` T) \<inter> V"
       
  1923     unfolding open_map_def openin_closedin_eq by auto
       
  1924   then show "openin (subtopology X' V) (f ` W)"
       
  1925     by (metis \<open>openin X T\<close> f open_map_def openin_subtopology_Int)
       
  1926 qed
  1905 
  1927 
  1906 lemma closed_map_restriction:
  1928 lemma closed_map_restriction:
  1907      "\<lbrakk>closed_map X X' f; {x. x \<in> topspace X \<and> f x \<in> V} = U\<rbrakk>
  1929   assumes f: "closed_map X X' f" and U: "{x \<in> topspace X. f x \<in> V} = U"
  1908       \<Longrightarrow> closed_map (subtopology X U) (subtopology X' V) f"
  1930   shows "closed_map (subtopology X U) (subtopology X' V) f"
  1909   unfolding closed_map_def closedin_subtopology_alt
  1931   unfolding closed_map_def
  1910   apply clarify
  1932 proof clarsimp
  1911   apply (rename_tac T)
  1933   fix W
  1912   apply (rule_tac x="f ` T" in image_eqI)
  1934   assume "closedin (subtopology X U) W"
  1913   using closedin_def by fastforce+
  1935   then obtain T where "closedin X T" "W = T \<inter> U"
       
  1936     by (meson closedin_subtopology)
       
  1937   with f U have "f ` W = (f ` T) \<inter> V"
       
  1938     unfolding closed_map_def closedin_def by auto
       
  1939   then show "closedin (subtopology X' V) (f ` W)"
       
  1940     by (metis \<open>closedin X T\<close> closed_map_def closedin_subtopology f)
       
  1941 qed
  1914 
  1942 
  1915 subsection\<open>Quotient maps\<close>
  1943 subsection\<open>Quotient maps\<close>
  1916                                       
  1944                                       
  1917 definition quotient_map where
  1945 definition quotient_map where
  1918  "quotient_map X X' f \<longleftrightarrow>
  1946  "quotient_map X X' f \<longleftrightarrow>
  2110    "quotient_map X X' f \<Longrightarrow> continuous_map X X'' (g \<circ> f) \<longleftrightarrow> continuous_map X' X'' g"
  2138    "quotient_map X X' f \<Longrightarrow> continuous_map X X'' (g \<circ> f) \<longleftrightarrow> continuous_map X' X'' g"
  2111   using continuous_compose_quotient_map continuous_map_compose quotient_imp_continuous_map by blast
  2139   using continuous_compose_quotient_map continuous_map_compose quotient_imp_continuous_map by blast
  2112 
  2140 
  2113 lemma quotient_map_compose_eq:
  2141 lemma quotient_map_compose_eq:
  2114    "quotient_map X X' f \<Longrightarrow> quotient_map X X'' (g \<circ> f) \<longleftrightarrow> quotient_map X' X'' g"
  2142    "quotient_map X X' f \<Longrightarrow> quotient_map X X'' (g \<circ> f) \<longleftrightarrow> quotient_map X' X'' g"
  2115   apply safe
  2143   by (meson continuous_compose_quotient_map_eq quotient_imp_continuous_map quotient_map_compose quotient_map_from_composition)
  2116   apply (meson continuous_compose_quotient_map_eq quotient_imp_continuous_map quotient_map_from_composition)
       
  2117   by (simp add: quotient_map_compose)
       
  2118 
  2144 
  2119 lemma quotient_map_restriction:
  2145 lemma quotient_map_restriction:
  2120   assumes quo: "quotient_map X Y f" and U: "{x \<in> topspace X. f x \<in> V} = U" and disj: "openin Y V \<or> closedin Y V"
  2146   assumes quo: "quotient_map X Y f" and U: "{x \<in> topspace X. f x \<in> V} = U" and disj: "openin Y V \<or> closedin Y V"
  2121  shows "quotient_map (subtopology X U) (subtopology Y V) f"
  2147  shows "quotient_map (subtopology X U) (subtopology Y V) f"
  2122   using disj
  2148   using disj
  2261      "\<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> separatedin X S T \<longleftrightarrow> disjnt S T"
  2287      "\<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> separatedin X S T \<longleftrightarrow> disjnt S T"
  2262   unfolding closure_of_eq disjnt_def separatedin_def
  2288   unfolding closure_of_eq disjnt_def separatedin_def
  2263   by (metis closedin_def closure_of_eq inf_commute)
  2289   by (metis closedin_def closure_of_eq inf_commute)
  2264 
  2290 
  2265 lemma separatedin_subtopology:
  2291 lemma separatedin_subtopology:
  2266      "separatedin (subtopology X U) S T \<longleftrightarrow> S \<subseteq> U \<and> T \<subseteq> U \<and> separatedin X S T"
  2292      "separatedin (subtopology X U) S T \<longleftrightarrow> S \<subseteq> U \<and> T \<subseteq> U \<and> separatedin X S T" (is "?lhs = ?rhs")
  2267   apply (simp add: separatedin_def closure_of_subtopology)
  2293   by (auto simp: separatedin_def closure_of_subtopology Int_ac disjoint_iff elim!: inf.orderE)
  2268   apply (safe; metis Int_absorb1 inf.assoc inf.orderE insert_disjoint(2) mk_disjoint_insert)
       
  2269   done
       
  2270 
  2294 
  2271 lemma separatedin_discrete_topology:
  2295 lemma separatedin_discrete_topology:
  2272      "separatedin (discrete_topology U) S T \<longleftrightarrow> S \<subseteq> U \<and> T \<subseteq> U \<and> disjnt S T"
  2296      "separatedin (discrete_topology U) S T \<longleftrightarrow> S \<subseteq> U \<and> T \<subseteq> U \<and> disjnt S T"
  2273   by (metis openin_discrete_topology separatedin_def separatedin_open_sets topspace_discrete_topology)
  2297   by (metis openin_discrete_topology separatedin_def separatedin_open_sets topspace_discrete_topology)
  2274 
  2298 
  2290   by (auto simp: separatedin_def closure_of_Union)
  2314   by (auto simp: separatedin_def closure_of_Union)
  2291 
  2315 
  2292 lemma separatedin_openin_diff:
  2316 lemma separatedin_openin_diff:
  2293    "\<lbrakk>openin X S; openin X T\<rbrakk> \<Longrightarrow> separatedin X (S - T) (T - S)"
  2317    "\<lbrakk>openin X S; openin X T\<rbrakk> \<Longrightarrow> separatedin X (S - T) (T - S)"
  2294   unfolding separatedin_def
  2318   unfolding separatedin_def
  2295   apply (intro conjI)
  2319   by (metis Diff_Int_distrib2 Diff_disjoint Diff_empty Diff_mono empty_Diff empty_subsetI openin_Int_closure_of_eq_empty openin_subset)
  2296   apply (meson Diff_subset openin_subset subset_trans)+
       
  2297   using openin_Int_closure_of_eq_empty by fastforce+
       
  2298 
  2320 
  2299 lemma separatedin_closedin_diff:
  2321 lemma separatedin_closedin_diff:
  2300      "\<lbrakk>closedin X S; closedin X T\<rbrakk> \<Longrightarrow> separatedin X (S - T) (T - S)"
  2322   assumes "closedin X S" "closedin X T"
  2301   apply (simp add: separatedin_def Diff_Int_distrib2 closure_of_minimal inf_absorb2)
  2323   shows "separatedin X (S - T) (T - S)"
  2302   apply (meson Diff_subset closedin_subset subset_trans)
  2324 proof -
  2303   done
  2325   have "S - T \<subseteq> topspace X" "T - S \<subseteq> topspace X"
       
  2326     using assms closedin_subset by auto
       
  2327   with assms show ?thesis
       
  2328     by (simp add: separatedin_def Diff_Int_distrib2 closure_of_minimal inf_absorb2)
       
  2329 qed
  2304 
  2330 
  2305 lemma separation_closedin_Un_gen:
  2331 lemma separation_closedin_Un_gen:
  2306      "separatedin X S T \<longleftrightarrow>
  2332      "separatedin X S T \<longleftrightarrow>
  2307         S \<subseteq> topspace X \<and> T \<subseteq> topspace X \<and> disjnt S T \<and>
  2333         S \<subseteq> topspace X \<and> T \<subseteq> topspace X \<and> disjnt S T \<and>
  2308         closedin (subtopology X (S \<union> T)) S \<and>
  2334         closedin (subtopology X (S \<union> T)) S \<and>
  2309         closedin (subtopology X (S \<union> T)) T"
  2335         closedin (subtopology X (S \<union> T)) T"
  2310   apply (simp add: separatedin_def closedin_Int_closure_of disjnt_iff)
  2336   by (auto simp add: separatedin_def closedin_Int_closure_of disjnt_iff dest: closure_of_subset)
  2311   using closure_of_subset apply blast
       
  2312   done
       
  2313 
  2337 
  2314 lemma separation_openin_Un_gen:
  2338 lemma separation_openin_Un_gen:
  2315      "separatedin X S T \<longleftrightarrow>
  2339      "separatedin X S T \<longleftrightarrow>
  2316         S \<subseteq> topspace X \<and> T \<subseteq> topspace X \<and> disjnt S T \<and>
  2340         S \<subseteq> topspace X \<and> T \<subseteq> topspace X \<and> disjnt S T \<and>
  2317         openin (subtopology X (S \<union> T)) S \<and>
  2341         openin (subtopology X (S \<union> T)) S \<and>
  2340 
  2364 
  2341 lemma homeomorphic_maps_eq:
  2365 lemma homeomorphic_maps_eq:
  2342      "\<lbrakk>homeomorphic_maps X Y f g;
  2366      "\<lbrakk>homeomorphic_maps X Y f g;
  2343        \<And>x. x \<in> topspace X \<Longrightarrow> f x = f' x; \<And>y. y \<in> topspace Y \<Longrightarrow> g y = g' y\<rbrakk>
  2367        \<And>x. x \<in> topspace X \<Longrightarrow> f x = f' x; \<And>y. y \<in> topspace Y \<Longrightarrow> g y = g' y\<rbrakk>
  2344       \<Longrightarrow> homeomorphic_maps X Y f' g'"
  2368       \<Longrightarrow> homeomorphic_maps X Y f' g'"
  2345   apply (simp add: homeomorphic_maps_def)
  2369   unfolding homeomorphic_maps_def
  2346   by (metis continuous_map_eq continuous_map_eq_image_closure_subset_gen image_subset_iff)
  2370   by (metis continuous_map_eq continuous_map_eq_image_closure_subset_gen image_subset_iff)
  2347 
  2371 
  2348 lemma homeomorphic_maps_sym:
  2372 lemma homeomorphic_maps_sym:
  2349      "homeomorphic_maps X Y f g \<longleftrightarrow> homeomorphic_maps Y X g f"
  2373      "homeomorphic_maps X Y f g \<longleftrightarrow> homeomorphic_maps Y X g f"
  2350   by (auto simp: homeomorphic_maps_def)
  2374   by (auto simp: homeomorphic_maps_def)
  2351 
  2375 
  2352 lemma homeomorphic_maps_id:
  2376 lemma homeomorphic_maps_id:
  2353      "homeomorphic_maps X Y id id \<longleftrightarrow> Y = X"
  2377      "homeomorphic_maps X Y id id \<longleftrightarrow> Y = X"  (is "?lhs = ?rhs")
  2354   (is "?lhs = ?rhs")
       
  2355 proof
  2378 proof
  2356   assume L: ?lhs
  2379   assume L: ?lhs
  2357   then have "topspace X = topspace Y"
  2380   then have "topspace X = topspace Y"
  2358     by (auto simp: homeomorphic_maps_def continuous_map_def)
  2381     by (auto simp: homeomorphic_maps_def continuous_map_def)
  2359   with L show ?rhs
  2382   with L show ?rhs
  2619     using hom by (auto simp: homeomorphic_eq_everything_map)
  2642     using hom by (auto simp: homeomorphic_eq_everything_map)
  2620   have iff: "(\<forall>T. x \<in> T \<and> openin X T \<longrightarrow> (\<exists>y. y \<noteq> x \<and> y \<in> S \<and> y \<in> T)) =
  2643   have iff: "(\<forall>T. x \<in> T \<and> openin X T \<longrightarrow> (\<exists>y. y \<noteq> x \<and> y \<in> S \<and> y \<in> T)) =
  2621             (\<forall>T. T \<subseteq> topspace Y \<longrightarrow> f x \<in> T \<longrightarrow> openin Y T \<longrightarrow> (\<exists>y. y \<noteq> f x \<and> y \<in> f ` S \<and> y \<in> T))"
  2644             (\<forall>T. T \<subseteq> topspace Y \<longrightarrow> f x \<in> T \<longrightarrow> openin Y T \<longrightarrow> (\<exists>y. y \<noteq> f x \<and> y \<in> f ` S \<and> y \<in> T))"
  2622     if "x \<in> topspace X" for x
  2645     if "x \<in> topspace X" for x
  2623   proof -
  2646   proof -
  2624     have 1: "(x \<in> T \<and> openin X T) = (T \<subseteq> topspace X \<and> f x \<in> f ` T \<and> openin Y (f ` T))" for T
  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
  2625       by (meson hom homeomorphic_map_openness_eq inj inj_on_image_mem_iff that)
  2648       by (meson hom homeomorphic_map_openness_eq inj inj_on_image_mem_iff that)
  2626     have 2: "(\<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")
  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")
  2627       if "T \<subseteq> topspace X \<and> f x \<in> f ` T \<and> openin Y (f ` T)" for T
  2650       if "T \<subseteq> topspace X \<and> f x \<in> f ` T \<and> openin Y (f ` T)" for T
  2628     proof
  2651     proof
  2629       show "?lhs \<Longrightarrow> ?rhs"
  2652       show "?lhs \<Longrightarrow> ?rhs"
  2630         by (meson "1" imageI inj inj_on_eq_iff inj_on_subset that)
  2653         by (meson \<section> imageI inj inj_on_eq_iff inj_on_subset that)
  2631       show "?rhs \<Longrightarrow> ?lhs"
  2654       show "?rhs \<Longrightarrow> ?lhs"
  2632         using S inj inj_onD that by fastforce
  2655         using S inj inj_onD that by fastforce
  2633     qed
  2656     qed
  2634     show ?thesis
  2657     ultimately show ?thesis
  2635       apply (simp flip: fim add: all_subset_image)
  2658       by (auto simp flip: fim simp: all_subset_image)
  2636       apply (simp flip: imp_conjL)
       
  2637       by (intro all_cong1 imp_cong 1 2)
       
  2638   qed
  2659   qed
  2639   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
  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
  2640     by auto
  2661     by auto
  2641   show ?thesis
  2662   show ?thesis
  2642     unfolding derived_set_of_def
  2663     unfolding derived_set_of_def
  2643     apply (rule *)
  2664     by (rule *) (use fim iff openin_subset in force)+
  2644     using fim apply blast
       
  2645     using iff openin_subset by force
       
  2646 qed
  2665 qed
  2647 
  2666 
  2648 
  2667 
  2649 lemma homeomorphic_map_closure_of:
  2668 lemma homeomorphic_map_closure_of:
  2650   assumes hom: "homeomorphic_map X Y f" and S: "S \<subseteq> topspace X"
  2669   assumes hom: "homeomorphic_map X Y f" and S: "S \<subseteq> topspace X"
  2722    "\<lbrakk>homeomorphic_map X Y f; f ` (topspace X \<inter> S) = topspace Y \<inter> T\<rbrakk>
  2741    "\<lbrakk>homeomorphic_map X Y f; f ` (topspace X \<inter> S) = topspace Y \<inter> T\<rbrakk>
  2723         \<Longrightarrow> homeomorphic_map (subtopology X S) (subtopology Y T) f"
  2742         \<Longrightarrow> homeomorphic_map (subtopology X S) (subtopology Y T) f"
  2724   by (meson homeomorphic_map_maps homeomorphic_maps_subtopologies)
  2743   by (meson homeomorphic_map_maps homeomorphic_maps_subtopologies)
  2725 
  2744 
  2726 lemma homeomorphic_map_subtopologies_alt:
  2745 lemma homeomorphic_map_subtopologies_alt:
  2727    "\<lbrakk>homeomorphic_map X Y f;
  2746   assumes hom: "homeomorphic_map X Y f" 
  2728      \<And>x. \<lbrakk>x \<in> topspace X; f x \<in> topspace Y\<rbrakk> \<Longrightarrow> f x \<in> T \<longleftrightarrow> x \<in> S\<rbrakk>
  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"
  2729     \<Longrightarrow> homeomorphic_map (subtopology X S) (subtopology Y T) f"
  2748     shows "homeomorphic_map (subtopology X S) (subtopology Y T) f"
  2730   unfolding homeomorphic_map_maps
  2749 proof -
  2731   apply (erule ex_forward)
  2750   have "homeomorphic_maps (subtopology X S) (subtopology Y T) f g" 
  2732   apply (rule homeomorphic_maps_subtopologies)
  2751       if "homeomorphic_maps X Y f g" for g
  2733   apply (auto simp: homeomorphic_maps_def continuous_map_def)
  2752   proof (rule homeomorphic_maps_subtopologies [OF that])
  2734   by (metis IntI image_iff)
  2753     show "f ` (topspace X \<inter> S) = topspace Y \<inter> T"
       
  2754       using that S 
       
  2755       apply (auto simp: homeomorphic_maps_def continuous_map_def)
       
  2756       by (metis IntI image_iff)
       
  2757   qed
       
  2758   then show ?thesis
       
  2759     using hom by (meson homeomorphic_map_maps)
       
  2760 qed
  2735 
  2761 
  2736 
  2762 
  2737 subsection\<open>Relation of homeomorphism between topological spaces\<close>
  2763 subsection\<open>Relation of homeomorphism between topological spaces\<close>
  2738 
  2764 
  2739 definition homeomorphic_space (infixr "homeomorphic'_space" 50)
  2765 definition homeomorphic_space (infixr "homeomorphic'_space" 50)
  2857 
  2883 
  2858 lemma connected_space_closedin_eq:
  2884 lemma connected_space_closedin_eq:
  2859      "connected_space X \<longleftrightarrow>
  2885      "connected_space X \<longleftrightarrow>
  2860        (\<nexists>E1 E2. closedin X E1 \<and> closedin X E2 \<and>
  2886        (\<nexists>E1 E2. closedin X E1 \<and> closedin X E2 \<and>
  2861                 E1 \<union> E2 = topspace X \<and> E1 \<inter> E2 = {} \<and> E1 \<noteq> {} \<and> E2 \<noteq> {})"
  2887                 E1 \<union> E2 = topspace X \<and> E1 \<inter> E2 = {} \<and> E1 \<noteq> {} \<and> E2 \<noteq> {})"
  2862   apply (simp add: connected_space_closedin)
  2888   by (metis closedin_Un closedin_def connected_space_closedin subset_antisym)
  2863   apply (intro all_cong)
       
  2864   using closedin_subset apply blast
       
  2865   done
       
  2866 
  2889 
  2867 lemma connected_space_clopen_in:
  2890 lemma connected_space_clopen_in:
  2868      "connected_space X \<longleftrightarrow>
  2891      "connected_space X \<longleftrightarrow>
  2869         (\<forall>T. openin X T \<and> closedin X T \<longrightarrow> T = {} \<or> T = topspace X)"
  2892         (\<forall>T. openin X T \<and> closedin X T \<longrightarrow> T = {} \<or> T = topspace X)"
  2870 proof -
  2893 proof -
  2879 lemma connectedin:
  2902 lemma connectedin:
  2880      "connectedin X S \<longleftrightarrow>
  2903      "connectedin X S \<longleftrightarrow>
  2881         S \<subseteq> topspace X \<and>
  2904         S \<subseteq> topspace X \<and>
  2882          (\<nexists>E1 E2.
  2905          (\<nexists>E1 E2.
  2883              openin X E1 \<and> openin X E2 \<and>
  2906              openin X E1 \<and> openin X E2 \<and>
  2884              S \<subseteq> E1 \<union> E2 \<and> E1 \<inter> E2 \<inter> S = {} \<and> E1 \<inter> S \<noteq> {} \<and> E2 \<inter> S \<noteq> {})"
  2907              S \<subseteq> E1 \<union> E2 \<and> E1 \<inter> E2 \<inter> S = {} \<and> E1 \<inter> S \<noteq> {} \<and> E2 \<inter> S \<noteq> {})"  (is "?lhs = ?rhs")
  2885 proof -
  2908 proof -
  2886   have *: "(\<exists>E1:: 'a set. \<exists>E2:: 'a set. (\<exists>T1:: 'a set. P1 T1 \<and> E1 = f1 T1) \<and> (\<exists>T2:: 'a set. P2 T2 \<and> E2 = f2 T2) \<and>
  2909   have *: "(\<exists>E1:: 'a set. \<exists>E2:: 'a set. (\<exists>T1:: 'a set. P1 T1 \<and> E1 = f1 T1) \<and> (\<exists>T2:: 'a set. P2 T2 \<and> E2 = f2 T2) \<and>
  2887              R E1 E2) \<longleftrightarrow> (\<exists>T1 T2. P1 T1 \<and> P2 T2 \<and> R(f1 T1) (f2 T2))" for P1 f1 P2 f2 R
  2910              R E1 E2) \<longleftrightarrow> (\<exists>T1 T2. P1 T1 \<and> P2 T2 \<and> R(f1 T1) (f2 T2))" for P1 f1 P2 f2 R
  2888     by auto
  2911     by auto
  2889   show ?thesis
  2912   show ?thesis 
  2890     unfolding connectedin_def connected_space_def openin_subtopology topspace_subtopology Not_eq_iff *
  2913     unfolding connectedin_def connected_space_def openin_subtopology topspace_subtopology *
  2891     apply (intro conj_cong arg_cong [where f=Not] ex_cong1 refl)
  2914     by (intro conj_cong arg_cong [where f=Not] ex_cong1; blast dest!: openin_subset)
  2892     apply (blast elim: dest!: openin_subset)+
       
  2893     done
       
  2894 qed
  2915 qed
  2895 
  2916 
  2896 lemma connectedin_iff_connected [simp]: "connectedin euclidean S \<longleftrightarrow> connected S"
  2917 lemma connectedin_iff_connected [simp]: "connectedin euclidean S \<longleftrightarrow> connected S"
  2897   by (simp add: connected_def connectedin)
  2918   by (simp add: connected_def connectedin)
  2898 
  2919 
  2906 proof -
  2927 proof -
  2907   have *: "(\<exists>E1:: 'a set. \<exists>E2:: 'a set. (\<exists>T1:: 'a set. P1 T1 \<and> E1 = f1 T1) \<and> (\<exists>T2:: 'a set. P2 T2 \<and> E2 = f2 T2) \<and>
  2928   have *: "(\<exists>E1:: 'a set. \<exists>E2:: 'a set. (\<exists>T1:: 'a set. P1 T1 \<and> E1 = f1 T1) \<and> (\<exists>T2:: 'a set. P2 T2 \<and> E2 = f2 T2) \<and>
  2908              R E1 E2) \<longleftrightarrow> (\<exists>T1 T2. P1 T1 \<and> P2 T2 \<and> R(f1 T1) (f2 T2))" for P1 f1 P2 f2 R
  2929              R E1 E2) \<longleftrightarrow> (\<exists>T1 T2. P1 T1 \<and> P2 T2 \<and> R(f1 T1) (f2 T2))" for P1 f1 P2 f2 R
  2909     by auto
  2930     by auto
  2910   show ?thesis
  2931   show ?thesis
  2911     unfolding connectedin_def connected_space_closedin closedin_subtopology topspace_subtopology Not_eq_iff *
  2932     unfolding connectedin_def connected_space_closedin closedin_subtopology topspace_subtopology *
  2912     apply (intro conj_cong arg_cong [where f=Not] ex_cong1 refl)
  2933     by (intro conj_cong arg_cong [where f=Not] ex_cong1; blast dest!: openin_subset)
  2913     apply (blast elim: dest!: openin_subset)+
       
  2914     done
       
  2915 qed
  2934 qed
  2916 
  2935 
  2917 lemma connectedin_empty [simp]: "connectedin X {}"
  2936 lemma connectedin_empty [simp]: "connectedin X {}"
  2918   by (simp add: connectedin)
  2937   by (simp add: connectedin)
  2919 
  2938 
  2924 lemma connectedin_sing [simp]: "connectedin X {a} \<longleftrightarrow> a \<in> topspace X"
  2943 lemma connectedin_sing [simp]: "connectedin X {a} \<longleftrightarrow> a \<in> topspace X"
  2925   by (simp add: connectedin)
  2944   by (simp add: connectedin)
  2926 
  2945 
  2927 lemma connectedin_absolute [simp]:
  2946 lemma connectedin_absolute [simp]:
  2928   "connectedin (subtopology X S) S \<longleftrightarrow> connectedin X S"
  2947   "connectedin (subtopology X S) S \<longleftrightarrow> connectedin X S"
  2929   apply (simp only: connectedin_def topspace_subtopology subtopology_subtopology)
  2948   by (simp add: connectedin_subtopology)
  2930   apply (intro conj_cong imp_cong arg_cong [where f=Not] all_cong1 ex_cong1 refl)
       
  2931   by auto
       
  2932 
  2949 
  2933 lemma connectedin_Union:
  2950 lemma connectedin_Union:
  2934   assumes \<U>: "\<And>S. S \<in> \<U> \<Longrightarrow> connectedin X S" and ne: "\<Inter>\<U> \<noteq> {}"
  2951   assumes \<U>: "\<And>S. S \<in> \<U> \<Longrightarrow> connectedin X S" and ne: "\<Inter>\<U> \<noteq> {}"
  2935   shows "connectedin X (\<Union>\<U>)"
  2952   shows "connectedin X (\<Union>\<U>)"
  2936 proof -
  2953 proof -
  3006 
  3023 
  3007 lemma connectedin_intermediate_closure_of:
  3024 lemma connectedin_intermediate_closure_of:
  3008   assumes "connectedin X S" "S \<subseteq> T" "T \<subseteq> X closure_of S"
  3025   assumes "connectedin X S" "S \<subseteq> T" "T \<subseteq> X closure_of S"
  3009   shows "connectedin X T"
  3026   shows "connectedin X T"
  3010 proof -
  3027 proof -
  3011   have S: "S \<subseteq> topspace X"and T: "T \<subseteq> topspace X"
  3028   have S: "S \<subseteq> topspace X" and T: "T \<subseteq> topspace X"
  3012     using assms by (meson closure_of_subset_topspace dual_order.trans)+
  3029     using assms by (meson closure_of_subset_topspace dual_order.trans)+
  3013   show ?thesis
  3030   have \<section>: "\<And>E1 E2. \<lbrakk>openin X E1; openin X E2; E1 \<inter> S = {} \<or> E2 \<inter> S = {}\<rbrakk> \<Longrightarrow> E1 \<inter> T = {} \<or> E2 \<inter> T = {}"
  3014   using assms
  3031     using assms unfolding disjoint_iff by (meson in_closure_of subsetD)
  3015   apply (simp add: connectedin closure_of_subset_topspace S T)
  3032   then show ?thesis
  3016   apply (elim all_forward imp_forward2 asm_rl)
  3033     using assms
  3017   apply (blast dest: openin_Int_closure_of_eq_empty [of X _ S])+
  3034     unfolding connectedin closure_of_subset_topspace S T
  3018   done
  3035     by (metis Int_empty_right T dual_order.trans inf.orderE inf_left_commute)
  3019 qed
  3036 qed
  3020 
  3037 
  3021 lemma connectedin_closure_of:
  3038 lemma connectedin_closure_of:
  3022      "connectedin X S \<Longrightarrow> connectedin X (X closure_of S)"
  3039      "connectedin X S \<Longrightarrow> connectedin X (X closure_of S)"
  3023   by (meson closure_of_subset connectedin_def connectedin_intermediate_closure_of subset_refl)
  3040   by (meson closure_of_subset connectedin_def connectedin_intermediate_closure_of subset_refl)
  3033 
  3050 
  3034 lemma connectedin_eq_not_separated:
  3051 lemma connectedin_eq_not_separated:
  3035    "connectedin X S \<longleftrightarrow>
  3052    "connectedin X S \<longleftrightarrow>
  3036          S \<subseteq> topspace X \<and>
  3053          S \<subseteq> topspace X \<and>
  3037          (\<nexists>C1 C2. C1 \<union> C2 = S \<and> C1 \<noteq> {} \<and> C2 \<noteq> {} \<and> separatedin X C1 C2)"
  3054          (\<nexists>C1 C2. C1 \<union> C2 = S \<and> C1 \<noteq> {} \<and> C2 \<noteq> {} \<and> separatedin X C1 C2)"
  3038   apply (simp add: separatedin_def connectedin_separation)
  3055   unfolding separatedin_def by (metis connectedin_separation sup.boundedE)
  3039   apply (intro conj_cong all_cong1 refl, blast)
       
  3040   done
       
  3041 
  3056 
  3042 lemma connectedin_eq_not_separated_subset:
  3057 lemma connectedin_eq_not_separated_subset:
  3043   "connectedin X S \<longleftrightarrow>
  3058   "connectedin X S \<longleftrightarrow>
  3044       S \<subseteq> topspace X \<and> (\<nexists>C1 C2. S \<subseteq> C1 \<union> C2 \<and> S \<inter> C1 \<noteq> {} \<and> S \<inter> C2 \<noteq> {} \<and> separatedin X C1 C2)"
  3059       S \<subseteq> topspace X \<and> (\<nexists>C1 C2. S \<subseteq> C1 \<union> C2 \<and> S \<inter> C1 \<noteq> {} \<and> S \<inter> C2 \<noteq> {} \<and> separatedin X C1 C2)"
  3045 proof -
  3060 proof -
  3046   have *: "\<forall>C1 C2. S \<subseteq> C1 \<union> C2 \<longrightarrow> S \<inter> C1 = {} \<or> S \<inter> C2 = {} \<or> \<not> separatedin X C1 C2"
  3061   have "\<forall>C1 C2. S \<subseteq> C1 \<union> C2 \<longrightarrow> S \<inter> C1 = {} \<or> S \<inter> C2 = {} \<or> \<not> separatedin X C1 C2"
  3047     if "\<And>C1 C2. C1 \<union> C2 = S \<longrightarrow> C1 = {} \<or> C2 = {} \<or> \<not> separatedin X C1 C2"
  3062     if "\<And>C1 C2. C1 \<union> C2 = S \<longrightarrow> C1 = {} \<or> C2 = {} \<or> \<not> separatedin X C1 C2"
  3048   proof (intro allI)
  3063   proof (intro allI)
  3049     fix C1 C2
  3064     fix C1 C2
  3050     show "S \<subseteq> C1 \<union> C2 \<longrightarrow> S \<inter> C1 = {} \<or> S \<inter> C2 = {} \<or> \<not> separatedin X C1 C2"
  3065     show "S \<subseteq> C1 \<union> C2 \<longrightarrow> S \<inter> C1 = {} \<or> S \<inter> C2 = {} \<or> \<not> separatedin X C1 C2"
  3051       using that [of "S \<inter> C1" "S \<inter> C2"]
  3066       using that [of "S \<inter> C1" "S \<inter> C2"]
  3052       by (auto simp: separatedin_mono)
  3067       by (auto simp: separatedin_mono)
  3053   qed
  3068   qed
  3054   show ?thesis
  3069   then show ?thesis
  3055     apply (simp add: connectedin_eq_not_separated)
  3070     by (metis Un_Int_eq(1) Un_Int_eq(2) connectedin_eq_not_separated order_refl)
  3056     apply (intro conj_cong refl iffI *)
       
  3057     apply (blast elim!: all_forward)+
       
  3058     done
       
  3059 qed
  3071 qed
  3060 
  3072 
  3061 lemma connected_space_eq_not_separated:
  3073 lemma connected_space_eq_not_separated:
  3062      "connected_space X \<longleftrightarrow>
  3074      "connected_space X \<longleftrightarrow>
  3063       (\<nexists>C1 C2. C1 \<union> C2 = topspace X \<and> C1 \<noteq> {} \<and> C2 \<noteq> {} \<and> separatedin X C1 C2)"
  3075       (\<nexists>C1 C2. C1 \<union> C2 = topspace X \<and> C1 \<noteq> {} \<and> C2 \<noteq> {} \<and> separatedin X C1 C2)"
  3064   by (simp add: connectedin_eq_not_separated flip: connectedin_topspace)
  3076   by (simp add: connectedin_eq_not_separated flip: connectedin_topspace)
  3065 
  3077 
  3066 lemma connected_space_eq_not_separated_subset:
  3078 lemma connected_space_eq_not_separated_subset:
  3067   "connected_space X \<longleftrightarrow>
  3079   "connected_space X \<longleftrightarrow>
  3068     (\<nexists>C1 C2. topspace X \<subseteq> C1 \<union> C2 \<and> C1 \<noteq> {} \<and> C2 \<noteq> {} \<and> separatedin X C1 C2)"
  3080     (\<nexists>C1 C2. topspace X \<subseteq> C1 \<union> C2 \<and> C1 \<noteq> {} \<and> C2 \<noteq> {} \<and> separatedin X C1 C2)"
  3069   apply (simp add: connected_space_eq_not_separated)
  3081   by (metis connected_space_eq_not_separated le_sup_iff separatedin_def subset_antisym)
  3070   apply (intro all_cong1)
       
  3071   by (metis Un_absorb dual_order.antisym separatedin_def subset_refl sup_mono)
       
  3072 
  3082 
  3073 lemma connectedin_subset_separated_union:
  3083 lemma connectedin_subset_separated_union:
  3074      "\<lbrakk>connectedin X C; separatedin X S T; C \<subseteq> S \<union> T\<rbrakk> \<Longrightarrow> C \<subseteq> S \<or> C \<subseteq> T"
  3084      "\<lbrakk>connectedin X C; separatedin X S T; C \<subseteq> S \<union> T\<rbrakk> \<Longrightarrow> C \<subseteq> S \<or> C \<subseteq> T"
  3075   unfolding connectedin_eq_not_separated_subset  by blast
  3085   unfolding connectedin_eq_not_separated_subset  by blast
  3076 
  3086 
  3077 lemma connectedin_nonseparated_union:
  3087 lemma connectedin_nonseparated_union:
  3078    "\<lbrakk>connectedin X S; connectedin X T; \<not>separatedin X S T\<rbrakk> \<Longrightarrow> connectedin X (S \<union> T)"
  3088   assumes "connectedin X S" "connectedin X T" "\<not>separatedin X S T"
  3079   apply (simp add: connectedin_eq_not_separated_subset, auto)
  3089   shows "connectedin X (S \<union> T)"
  3080     apply (metis (no_types, hide_lams) Diff_subset_conv Diff_triv disjoint_iff_not_equal separatedin_mono sup_commute)
  3090 proof -
  3081   apply (metis (no_types, hide_lams) Diff_subset_conv Diff_triv disjoint_iff_not_equal separatedin_mono separatedin_sym sup_commute)
  3091   have "\<And>C1 C2. \<lbrakk>T \<subseteq> C1 \<union> C2; S \<subseteq> C1 \<union> C2\<rbrakk> \<Longrightarrow>
  3082   by (meson disjoint_iff_not_equal)
  3092            S \<inter> C1 = {} \<and> T \<inter> C1 = {} \<or> S \<inter> C2 = {} \<and> T \<inter> C2 = {} \<or> \<not> separatedin X C1 C2"
       
  3093     using assms
       
  3094     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)
       
  3096   then show ?thesis
       
  3097     unfolding connectedin_eq_not_separated_subset
       
  3098     by (simp add: assms(1) assms(2) connectedin_subset_topspace Int_Un_distrib2)
       
  3099 qed
  3083 
  3100 
  3084 lemma connected_space_closures:
  3101 lemma connected_space_closures:
  3085      "connected_space X \<longleftrightarrow>
  3102      "connected_space X \<longleftrightarrow>
  3086         (\<nexists>e1 e2. e1 \<union> e2 = topspace X \<and> X closure_of e1 \<inter> X closure_of e2 = {} \<and> e1 \<noteq> {} \<and> e2 \<noteq> {})"
  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> {})"
  3087      (is "?lhs = ?rhs")
  3104      (is "?lhs = ?rhs")
  3102   shows "S \<inter> X frontier_of T \<noteq> {}"
  3119   shows "S \<inter> X frontier_of T \<noteq> {}"
  3103 proof -
  3120 proof -
  3104   have "S \<subseteq> topspace X" and *:
  3121   have "S \<subseteq> topspace X" and *:
  3105     "\<And>E1 E2. openin X E1 \<longrightarrow> openin X E2 \<longrightarrow> E1 \<inter> E2 \<inter> S = {} \<longrightarrow> S \<subseteq> E1 \<union> E2 \<longrightarrow> E1 \<inter> S = {} \<or> E2 \<inter> S = {}"
  3122     "\<And>E1 E2. openin X E1 \<longrightarrow> openin X E2 \<longrightarrow> E1 \<inter> E2 \<inter> S = {} \<longrightarrow> S \<subseteq> E1 \<union> E2 \<longrightarrow> E1 \<inter> S = {} \<or> E2 \<inter> S = {}"
  3106     using \<open>connectedin X S\<close> by (auto simp: connectedin)
  3123     using \<open>connectedin X S\<close> by (auto simp: connectedin)
       
  3124   moreover
  3107   have "S - (topspace X \<inter> T) \<noteq> {}"
  3125   have "S - (topspace X \<inter> T) \<noteq> {}"
  3108     using assms(3) by blast
  3126     using assms(3) by blast
  3109   moreover
  3127   moreover
  3110   have "S \<inter> topspace X \<inter> T \<noteq> {}"
  3128   have "S \<inter> topspace X \<inter> T \<noteq> {}"
  3111     using assms(1) assms(2) connectedin by fastforce
  3129     using assms(1) assms(2) connectedin by fastforce
  3112   moreover
  3130   moreover
  3113   have False if "S \<inter> T \<noteq> {}" "S - T \<noteq> {}" "T \<subseteq> topspace X" "S \<inter> X frontier_of T = {}" for T
  3131   have False if "S \<inter> T \<noteq> {}" "S - T \<noteq> {}" "T \<subseteq> topspace X" "S \<inter> X frontier_of T = {}" for T
  3114   proof -
  3132   proof -
  3115     have null: "S \<inter> (X closure_of T - X interior_of T) = {}"
  3133     have null: "S \<inter> (X closure_of T - X interior_of T) = {}"
  3116       using that unfolding frontier_of_def by blast
  3134       using that unfolding frontier_of_def by blast
  3117     have 1: "X interior_of T \<inter> (topspace X - X closure_of T) \<inter> S = {}"
  3135     have "X interior_of T \<inter> (topspace X - X closure_of T) \<inter> S = {}"
  3118       by (metis Diff_disjoint inf_bot_left interior_of_Int interior_of_complement interior_of_empty)
  3136       by (metis Diff_disjoint inf_bot_left interior_of_Int interior_of_complement interior_of_empty)
  3119     have 2: "S \<subseteq> X interior_of T \<union> (topspace X - X closure_of T)"
  3137     moreover have "S \<subseteq> X interior_of T \<union> (topspace X - X closure_of T)"
  3120       using that \<open>S \<subseteq> topspace X\<close> null by auto
  3138       using that \<open>S \<subseteq> topspace X\<close> null by auto
  3121     have 3: "S \<inter> X interior_of T \<noteq> {}"
  3139     moreover have "S \<inter> X interior_of T \<noteq> {}"
  3122       using closure_of_subset that(1) that(3) null by fastforce
  3140       using closure_of_subset that(1) that(3) null by fastforce
  3123     show ?thesis
  3141     ultimately have "S \<inter> X interior_of (topspace X - T) = {}"
  3124       using null \<open>S \<subseteq> topspace X\<close> that * [of "X interior_of T" "topspace X - X closure_of T"]
  3142       by (metis "*" inf_commute interior_of_complement openin_interior_of)
  3125       apply (clarsimp simp add: openin_diff 1 2)
  3143     then have "topspace (subtopology X S) \<inter> X interior_of T = S"
  3126       apply (simp add: Int_commute Diff_Int_distrib 3)
  3144       using \<open>S \<subseteq> topspace X\<close> interior_of_complement null by fastforce
  3127       by (metis Int_absorb2 contra_subsetD interior_of_subset)
  3145     then show ?thesis
       
  3146       using that by (metis Diff_eq_empty_iff inf_le2 interior_of_subset subset_trans)
  3128   qed
  3147   qed
  3129   ultimately show ?thesis
  3148   ultimately show ?thesis
  3130     by (metis Int_lower1 frontier_of_restrict inf_assoc)
  3149     by (metis Int_lower1 frontier_of_restrict inf_assoc)
  3131 qed
  3150 qed
  3132 
  3151 
  3150     then have 1: "?U \<inter> ?V \<inter> S = {}"
  3169     then have 1: "?U \<inter> ?V \<inter> S = {}"
  3151       by auto
  3170       by auto
  3152     have 2: "openin X ?U" "openin X ?V"
  3171     have 2: "openin X ?U" "openin X ?V"
  3153       using \<open>openin Y U\<close> \<open>openin Y V\<close> continuous_map f by fastforce+
  3172       using \<open>openin Y U\<close> \<open>openin Y V\<close> continuous_map f by fastforce+
  3154     show "False"
  3173     show "False"
  3155       using  * [of ?U ?V] UV \<open>S \<subseteq> topspace X\<close>
  3174       using * [of ?U ?V] UV \<open>S \<subseteq> topspace X\<close>
  3156       by (auto simp: 1 2)
  3175       by (auto simp: 1 2)
  3157   qed
  3176   qed
  3158 qed
  3177 qed
  3159 
  3178 
  3160 lemma homeomorphic_connected_space:
  3179 lemma homeomorphic_connected_space:
  3161      "X homeomorphic_space Y \<Longrightarrow> connected_space X \<longleftrightarrow> connected_space Y"
  3180      "X homeomorphic_space Y \<Longrightarrow> connected_space X \<longleftrightarrow> connected_space Y"
  3162   unfolding homeomorphic_space_def homeomorphic_maps_def
  3181   unfolding homeomorphic_space_def homeomorphic_maps_def
  3163   apply safe
  3182   by (metis connected_space_subconnected connectedin_continuous_map_image connectedin_topspace continuous_map_image_subset_topspace image_eqI image_subset_iff)
  3164   apply (metis connectedin_continuous_map_image connected_space_subconnected continuous_map_image_subset_topspace image_eqI image_subset_iff)
       
  3165   by (metis (no_types, hide_lams) connectedin_continuous_map_image connectedin_topspace continuous_map_def continuous_map_image_subset_topspace imageI set_eq_subset subsetI)
       
  3166 
  3183 
  3167 lemma homeomorphic_map_connectedness:
  3184 lemma homeomorphic_map_connectedness:
  3168   assumes f: "homeomorphic_map X Y f" and U: "U \<subseteq> topspace X"
  3185   assumes f: "homeomorphic_map X Y f" and U: "U \<subseteq> topspace X"
  3169   shows "connectedin Y (f ` U) \<longleftrightarrow> connectedin X U"
  3186   shows "connectedin Y (f ` U) \<longleftrightarrow> connectedin X U"
  3170 proof -
  3187 proof -
  3195   case True
  3212   case True
  3196   show ?thesis
  3213   show ?thesis
  3197   proof (cases "S = {}")
  3214   proof (cases "S = {}")
  3198     case False
  3215     case False
  3199     moreover have "connectedin (discrete_topology U) S \<longleftrightarrow> (\<exists>a. S = {a})"
  3216     moreover have "connectedin (discrete_topology U) S \<longleftrightarrow> (\<exists>a. S = {a})"
  3200       apply safe
  3217     proof
  3201       using False connectedin_inter_frontier_of insert_Diff apply fastforce
  3218       show "connectedin (discrete_topology U) S \<Longrightarrow> \<exists>a. S = {a}"
  3202       using True by auto
  3219         using False connectedin_inter_frontier_of insert_Diff by fastforce
       
  3220     qed (use True in auto)
  3203     ultimately show ?thesis
  3221     ultimately show ?thesis
  3204       by auto
  3222       by auto
  3205   qed simp
  3223   qed simp
  3206 next
  3224 next
  3207   case False
  3225   case False
  3260 
  3278 
  3261 lemma compact_space_subtopology: "compactin X S \<Longrightarrow> compact_space (subtopology X S)"
  3279 lemma compact_space_subtopology: "compactin X S \<Longrightarrow> compact_space (subtopology X S)"
  3262   by (simp add: compactin_subspace)
  3280   by (simp add: compactin_subspace)
  3263 
  3281 
  3264 lemma compactin_subtopology: "compactin (subtopology X S) T \<longleftrightarrow> compactin X T \<and> T \<subseteq> S"
  3282 lemma compactin_subtopology: "compactin (subtopology X S) T \<longleftrightarrow> compactin X T \<and> T \<subseteq> S"
  3265 apply (simp add: compactin_subspace)
  3283   by (metis compactin_subspace inf.absorb_iff2 le_inf_iff subtopology_subtopology topspace_subtopology)
  3266   by (metis inf.orderE inf_commute subtopology_subtopology)
       
  3267 
       
  3268 
  3284 
  3269 lemma compactin_subset_topspace: "compactin X S \<Longrightarrow> S \<subseteq> topspace X"
  3285 lemma compactin_subset_topspace: "compactin X S \<Longrightarrow> S \<subseteq> topspace X"
  3270   by (simp add: compactin_subspace)
  3286   by (simp add: compactin_subspace)
  3271 
  3287 
  3272 lemma compactin_contractive:
  3288 lemma compactin_contractive:
  3417     (\<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> {})"
  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> {})"
  3418    (is "_ = ?rhs")
  3434    (is "_ = ?rhs")
  3419 proof (cases "topspace X = {}")
  3435 proof (cases "topspace X = {}")
  3420   case True
  3436   case True
  3421   then show ?thesis
  3437   then show ?thesis
  3422     apply (clarsimp simp add: compact_space_def closedin_topspace_empty)
  3438 unfolding compact_space_def
  3423     by (metis finite.emptyI finite_insert infinite_super insertI1 subsetI)
  3439   by (metis Sup_bot_conv(1) closedin_topspace_empty compactin_empty finite.emptyI finite_UnionD order_refl)
  3424 next
  3440 next
  3425   case False
  3441   case False
  3426   show ?thesis
  3442   show ?thesis
  3427   proof safe
  3443   proof safe
  3428     fix \<U> :: "'a set set"
  3444     fix \<U> :: "'a set set"
  3480     proof -
  3496     proof -
  3481       have eq: "((\<forall>\<F>. finite \<F> \<and> \<F> \<subseteq> \<U> \<longrightarrow> \<Inter> ((\<inter>) S ` \<F>) \<noteq> {}) \<longrightarrow> \<Inter> ((\<inter>) S ` \<U>) \<noteq> {}) \<longleftrightarrow>
  3497       have eq: "((\<forall>\<F>. finite \<F> \<and> \<F> \<subseteq> \<U> \<longrightarrow> \<Inter> ((\<inter>) S ` \<F>) \<noteq> {}) \<longrightarrow> \<Inter> ((\<inter>) S ` \<U>) \<noteq> {}) \<longleftrightarrow>
  3482                 ((\<forall>\<F>. finite \<F> \<and> \<F> \<subseteq> \<U> \<longrightarrow> S \<inter> \<Inter>\<F> \<noteq> {}) \<longrightarrow> S \<inter> \<Inter>\<U> \<noteq> {})"  for \<U>
  3498                 ((\<forall>\<F>. finite \<F> \<and> \<F> \<subseteq> \<U> \<longrightarrow> S \<inter> \<Inter>\<F> \<noteq> {}) \<longrightarrow> S \<inter> \<Inter>\<U> \<noteq> {})"  for \<U>
  3483         by simp (use \<open>S \<noteq> {}\<close> in blast)
  3499         by simp (use \<open>S \<noteq> {}\<close> in blast)
  3484       show ?thesis
  3500       show ?thesis
  3485         apply (simp only: imp_conjL [symmetric] all_finite_subset_image eq)
  3501         unfolding imp_conjL [symmetric] all_finite_subset_image eq by blast
  3486         apply (simp add: subset_eq)
       
  3487         done
       
  3488     qed
  3502     qed
  3489     finally show ?thesis
  3503     finally show ?thesis
  3490       using True by simp
  3504       using True by simp
  3491   qed (simp add: compactin_subspace)
  3505   qed (simp add: compactin_subspace)
  3492 qed force
  3506 qed force
  3557    "\<lbrakk>compactin X (X closure_of S); infinite T; T \<subseteq> S; T \<subseteq> topspace X\<rbrakk> \<Longrightarrow> X derived_set_of T \<noteq> {}"
  3571    "\<lbrakk>compactin X (X closure_of S); infinite T; T \<subseteq> S; T \<subseteq> topspace X\<rbrakk> \<Longrightarrow> X derived_set_of T \<noteq> {}"
  3558   using closure_of_mono closure_of_subset compactin_imp_Bolzano_Weierstrass by fastforce
  3572   using closure_of_mono closure_of_subset compactin_imp_Bolzano_Weierstrass by fastforce
  3559 
  3573 
  3560 lemma discrete_compactin_eq_finite:
  3574 lemma discrete_compactin_eq_finite:
  3561    "S \<inter> X derived_set_of S = {} \<Longrightarrow> compactin X S \<longleftrightarrow> S \<subseteq> topspace X \<and> finite S"
  3575    "S \<inter> X derived_set_of S = {} \<Longrightarrow> compactin X S \<longleftrightarrow> S \<subseteq> topspace X \<and> finite S"
  3562   apply (rule iffI)
  3576   by (meson compactin_imp_Bolzano_Weierstrass finite_imp_compactin_eq order_refl)
  3563   using compactin_imp_Bolzano_Weierstrass compactin_subset_topspace apply blast
       
  3564   by (simp add: finite_imp_compactin_eq)
       
  3565 
  3577 
  3566 lemma discrete_compact_space_eq_finite:
  3578 lemma discrete_compact_space_eq_finite:
  3567    "X derived_set_of (topspace X) = {} \<Longrightarrow> (compact_space X \<longleftrightarrow> finite(topspace X))"
  3579    "X derived_set_of (topspace X) = {} \<Longrightarrow> (compact_space X \<longleftrightarrow> finite(topspace X))"
  3568   by (metis compact_space_discrete_topology discrete_topology_unique_derived_set)
  3580   by (metis compact_space_discrete_topology discrete_topology_unique_derived_set)
  3569 
  3581 
  3662 lemma surjective_embedding_map:
  3674 lemma surjective_embedding_map:
  3663    "embedding_map X Y f \<and> f ` (topspace X) = topspace Y \<longleftrightarrow> homeomorphic_map X Y f"
  3675    "embedding_map X Y f \<and> f ` (topspace X) = topspace Y \<longleftrightarrow> homeomorphic_map X Y f"
  3664   by (force simp: embedding_map_def homeomorphic_eq_everything_map)
  3676   by (force simp: embedding_map_def homeomorphic_eq_everything_map)
  3665 
  3677 
  3666 lemma embedding_map_in_subtopology:
  3678 lemma embedding_map_in_subtopology:
  3667    "embedding_map X (subtopology Y S) f \<longleftrightarrow> embedding_map X Y f \<and> f ` (topspace X) \<subseteq> S"
  3679    "embedding_map X (subtopology Y S) f \<longleftrightarrow> embedding_map X Y f \<and> f ` (topspace X) \<subseteq> S"  (is "?lhs = ?rhs")
  3668   apply (auto simp: embedding_map_def subtopology_subtopology Int_absorb1)
  3680 proof
  3669     apply (metis (no_types) homeomorphic_imp_surjective_map subtopology_subtopology subtopology_topspace topspace_subtopology)
  3681   show "?lhs \<Longrightarrow> ?rhs"
  3670   apply (simp add: continuous_map_def homeomorphic_eq_everything_map)
  3682     unfolding embedding_map_def
  3671   done
  3683     by (metis continuous_map_in_subtopology homeomorphic_imp_continuous_map inf_absorb2 subtopology_subtopology)
       
  3684 qed (simp add: embedding_map_def inf.absorb_iff2 subtopology_subtopology)
  3672 
  3685 
  3673 lemma injective_open_imp_embedding_map:
  3686 lemma injective_open_imp_embedding_map:
  3674    "\<lbrakk>continuous_map X Y f; open_map X Y f; inj_on f (topspace X)\<rbrakk> \<Longrightarrow> embedding_map X Y f"
  3687    "\<lbrakk>continuous_map X Y f; open_map X Y f; inj_on f (topspace X)\<rbrakk> \<Longrightarrow> embedding_map X Y f"
  3675   unfolding embedding_map_def
  3688   unfolding embedding_map_def
  3676   apply (rule bijective_open_imp_homeomorphic_map)
  3689   by (simp add: continuous_map_in_subtopology continuous_open_quotient_map eq_iff homeomorphic_map_def open_map_imp_subset open_map_into_subtopology)
  3677   using continuous_map_in_subtopology apply blast
       
  3678     apply (auto simp: continuous_map_in_subtopology open_map_into_subtopology continuous_map)
       
  3679   done
       
  3680 
  3690 
  3681 lemma injective_closed_imp_embedding_map:
  3691 lemma injective_closed_imp_embedding_map:
  3682   "\<lbrakk>continuous_map X Y f; closed_map X Y f; inj_on f (topspace X)\<rbrakk> \<Longrightarrow> embedding_map X Y f"
  3692   "\<lbrakk>continuous_map X Y f; closed_map X Y f; inj_on f (topspace X)\<rbrakk> \<Longrightarrow> embedding_map X Y f"
  3683   unfolding embedding_map_def
  3693   unfolding embedding_map_def
  3684   apply (rule bijective_closed_imp_homeomorphic_map)
  3694   by (simp add: closed_map_imp_subset closed_map_into_subtopology continuous_closed_quotient_map 
  3685      apply (simp_all add: continuous_map_into_subtopology closed_map_into_subtopology)
  3695                 continuous_map_in_subtopology dual_order.eq_iff homeomorphic_map_def)
  3686   apply (simp add: continuous_map inf.absorb_iff2)
       
  3687   done
       
  3688 
  3696 
  3689 lemma embedding_map_imp_homeomorphic_space:
  3697 lemma embedding_map_imp_homeomorphic_space:
  3690    "embedding_map X Y f \<Longrightarrow> X homeomorphic_space (subtopology Y (f ` (topspace X)))"
  3698    "embedding_map X Y f \<Longrightarrow> X homeomorphic_space (subtopology Y (f ` (topspace X)))"
  3691   unfolding embedding_map_def
  3699   unfolding embedding_map_def
  3692   using homeomorphic_space by blast
  3700   using homeomorphic_space by blast
  3725 lemma homeomorphic_imp_retraction_maps:
  3733 lemma homeomorphic_imp_retraction_maps:
  3726    "homeomorphic_maps X Y f g \<Longrightarrow> retraction_maps X Y f g"
  3734    "homeomorphic_maps X Y f g \<Longrightarrow> retraction_maps X Y f g"
  3727   by (simp add: homeomorphic_maps_def retraction_maps_def)
  3735   by (simp add: homeomorphic_maps_def retraction_maps_def)
  3728 
  3736 
  3729 lemma section_and_retraction_eq_homeomorphic_map:
  3737 lemma section_and_retraction_eq_homeomorphic_map:
  3730    "section_map X Y f \<and> retraction_map X Y f \<longleftrightarrow> homeomorphic_map X Y f"
  3738    "section_map X Y f \<and> retraction_map X Y f \<longleftrightarrow> homeomorphic_map X Y f"  (is "?lhs = ?rhs")
  3731   apply (auto simp: section_map_def retraction_map_def homeomorphic_map_maps retraction_maps_def homeomorphic_maps_def)
  3739 proof
  3732   by (metis (full_types) continuous_map_image_subset_topspace image_subset_iff)
  3740   assume ?lhs
       
  3741   then obtain g g' where f: "continuous_map X Y f" 
       
  3742     and g: "continuous_map Y X g" "\<forall>x\<in>topspace X. g (f x) = x"
       
  3743     and g': "continuous_map Y X g'" "\<forall>x\<in>topspace Y. f (g' x) = x"
       
  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
       
  3748     using homeomorphic_map_maps by blast
       
  3749 next
       
  3750   assume ?rhs
       
  3751   then show ?lhs
       
  3752     unfolding retraction_map_def section_map_def
       
  3753     by (meson homeomorphic_imp_retraction_maps homeomorphic_map_maps homeomorphic_maps_sym)
       
  3754 qed
  3733 
  3755 
  3734 lemma section_imp_embedding_map:
  3756 lemma section_imp_embedding_map:
  3735    "section_map X Y f \<Longrightarrow> embedding_map X Y f"
  3757    "section_map X Y f \<Longrightarrow> embedding_map X Y f"
  3736   unfolding section_map_def embedding_map_def homeomorphic_map_maps retraction_maps_def homeomorphic_maps_def
  3758   unfolding section_map_def embedding_map_def homeomorphic_map_maps retraction_maps_def homeomorphic_maps_def
  3737   by (force simp: continuous_map_in_subtopology continuous_map_from_subtopology)
  3759   by (force simp: continuous_map_in_subtopology continuous_map_from_subtopology)
  3808   shows "closedin (top_of_set S) (S \<inter> f -` T)"
  3830   shows "closedin (top_of_set S) (S \<inter> f -` T)"
  3809   using assms continuous_on_closed by blast
  3831   using assms continuous_on_closed by blast
  3810 
  3832 
  3811 lemma continuous_map_subtopology_eu [simp]:
  3833 lemma continuous_map_subtopology_eu [simp]:
  3812   "continuous_map (top_of_set S) (subtopology euclidean T) h \<longleftrightarrow> continuous_on S h \<and> h ` S \<subseteq> T"
  3834   "continuous_map (top_of_set S) (subtopology euclidean T) h \<longleftrightarrow> continuous_on S h \<and> h ` S \<subseteq> T"
  3813   apply safe
  3835   by (simp add: continuous_map_in_subtopology)
  3814   apply (metis continuous_map_closedin_preimage_eq continuous_map_in_subtopology continuous_on_closed order_refl topspace_euclidean_subtopology)
       
  3815   apply (simp add: continuous_map_closedin_preimage_eq image_subset_iff)
       
  3816   by (metis (no_types, hide_lams) continuous_map_closedin_preimage_eq continuous_map_in_subtopology continuous_on_closed order_refl topspace_euclidean_subtopology)
       
  3817 
  3836 
  3818 lemma continuous_map_euclidean_top_of_set:
  3837 lemma continuous_map_euclidean_top_of_set:
  3819   assumes eq: "f -` S = UNIV" and cont: "continuous_on UNIV f"
  3838   assumes eq: "f -` S = UNIV" and cont: "continuous_on UNIV f"
  3820   shows "continuous_map euclidean (top_of_set S) f"
  3839   shows "continuous_map euclidean (top_of_set S) f"
  3821   by (simp add: cont continuous_map_into_subtopology eq image_subset_iff_subset_vimage)
  3840   by (simp add: cont continuous_map_into_subtopology eq image_subset_iff_subset_vimage)
  3848     using assms(1)[unfolded continuous_on_closed, THEN spec[where x="T \<inter> f ` S"]]
  3867     using assms(1)[unfolded continuous_on_closed, THEN spec[where x="T \<inter> f ` S"]]
  3849     using * by auto
  3868     using * by auto
  3850 qed
  3869 qed
  3851 
  3870 
  3852 lemma continuous_openin_preimage_eq:
  3871 lemma continuous_openin_preimage_eq:
  3853    "continuous_on S f \<longleftrightarrow>
  3872    "continuous_on S f \<longleftrightarrow> (\<forall>T. open T \<longrightarrow> openin (top_of_set S) (S \<inter> f -` T))"
  3854     (\<forall>T. open T \<longrightarrow> openin (top_of_set S) (S \<inter> f -` T))"
  3873   by (metis Int_commute continuous_on_open_invariant open_openin openin_subtopology)
  3855 apply safe
       
  3856 apply (simp add: continuous_openin_preimage_gen)
       
  3857 apply (fastforce simp add: continuous_on_open openin_open)
       
  3858 done
       
  3859 
  3874 
  3860 lemma continuous_closedin_preimage_eq:
  3875 lemma continuous_closedin_preimage_eq:
  3861    "continuous_on S f \<longleftrightarrow>
  3876    "continuous_on S f \<longleftrightarrow>
  3862     (\<forall>T. closed T \<longrightarrow> closedin (top_of_set S) (S \<inter> f -` T))"
  3877     (\<forall>T. closed T \<longrightarrow> closedin (top_of_set S) (S \<inter> f -` T))"
  3863 apply safe
  3878   by (metis Int_commute closedin_closed continuous_on_closed_invariant)
  3864 apply (simp add: continuous_closedin_preimage)
       
  3865 apply (fastforce simp add: continuous_on_closed closedin_closed)
       
  3866 done
       
  3867 
  3879 
  3868 lemma continuous_open_preimage:
  3880 lemma continuous_open_preimage:
  3869   assumes contf: "continuous_on S f" and "open S" "open T"
  3881   assumes contf: "continuous_on S f" and "open S" "open T"
  3870   shows "open (S \<inter> f -` T)"
  3882   shows "open (S \<inter> f -` T)"
  3871 proof-
  3883 proof-
  3941     by blast
  3953     by blast
  3942   show ?thesis
  3954   show ?thesis
  3943   proof
  3955   proof
  3944     assume ?lhs
  3956     assume ?lhs
  3945     have "openin (top_of_set S) S'"
  3957     have "openin (top_of_set S) S'"
  3946       apply (subst openin_subopen, clarify)
  3958     proof (subst openin_subopen, clarify)
  3947       apply (rule Times_in_interior_subtopology [OF _ \<open>?lhs\<close>])
  3959       show "\<exists>U. openin (top_of_set S) U \<and> x \<in> U \<and> U \<subseteq> S'" if "x \<in> S'" for x
  3948       using \<open>y \<in> T'\<close>
  3960         using that \<open>y \<in> T'\<close> Times_in_interior_subtopology [OF _ \<open>?lhs\<close>, of x y]
  3949        apply auto
  3961         by simp (metis mem_Sigma_iff subsetD subsetI)
  3950       done
  3962     qed
  3951     moreover have "openin (top_of_set T) T'"
  3963     moreover have "openin (top_of_set T) T'"
  3952       apply (subst openin_subopen, clarify)
  3964     proof (subst openin_subopen, clarify)
  3953       apply (rule Times_in_interior_subtopology [OF _ \<open>?lhs\<close>])
  3965       show "\<exists>U. openin (top_of_set T) U \<and> y \<in> U \<and> U \<subseteq> T'" if "y \<in> T'" for y
  3954       using \<open>x \<in> S'\<close>
  3966         using that \<open>x \<in> S'\<close> Times_in_interior_subtopology [OF _ \<open>?lhs\<close>, of x y]
  3955        apply auto
  3967         by simp (metis mem_Sigma_iff subsetD subsetI)
  3956       done
  3968     qed
  3957     ultimately show ?rhs
  3969     ultimately show ?rhs
  3958       by simp
  3970       by simp
  3959   next
  3971   next
  3960     assume ?rhs
  3972     assume ?rhs
  3961     with False show ?lhs
  3973     with False show ?lhs
  4075 
  4087 
  4076 text \<open>The basic property of the topology generated by a set \<open>S\<close> is that it is the
  4088 text \<open>The basic property of the topology generated by a set \<open>S\<close> is that it is the
  4077 smallest topology containing all the elements of \<open>S\<close>:\<close>
  4089 smallest topology containing all the elements of \<open>S\<close>:\<close>
  4078 
  4090 
  4079 lemma generate_topology_on_coarsest:
  4091 lemma generate_topology_on_coarsest:
  4080   assumes "istopology T"
  4092   assumes T: "istopology T" "\<And>s. s \<in> S \<Longrightarrow> T s"
  4081           "\<And>s. s \<in> S \<Longrightarrow> T s"
  4093           and gen: "generate_topology_on S s0"
  4082           "generate_topology_on S s0"
       
  4083   shows "T s0"
  4094   shows "T s0"
  4084 using assms(3) apply (induct rule: generate_topology_on.induct)
  4095   using gen 
  4085 using assms(1) assms(2) unfolding istopology_def by auto
  4096 by (induct rule: generate_topology_on.induct) (use T in \<open>auto simp: istopology_def\<close>)
  4086 
  4097 
  4087 abbreviation\<^marker>\<open>tag unimportant\<close> topology_generated_by::"('a set set) \<Rightarrow> ('a topology)"
  4098 abbreviation\<^marker>\<open>tag unimportant\<close> topology_generated_by::"('a set set) \<Rightarrow> ('a topology)"
  4088   where "topology_generated_by S \<equiv> topology (generate_topology_on S)"
  4099   where "topology_generated_by S \<equiv> topology (generate_topology_on S)"
  4089 
  4100 
  4090 lemma openin_topology_generated_by_iff:
  4101 lemma openin_topology_generated_by_iff:
  4196     by (metis arbitrary_union_of_inc finite_intersection_of_empty inf.orderE istopology_subbase 
  4207     by (metis arbitrary_union_of_inc finite_intersection_of_empty inf.orderE istopology_subbase 
  4197               openin_subset relative_to_inc subset_UNIV topology_inverse')
  4208               openin_subset relative_to_inc subset_UNIV topology_inverse')
  4198 qed
  4209 qed
  4199 
  4210 
  4200 lemma minimal_topology_subbase:
  4211 lemma minimal_topology_subbase:
  4201    "\<lbrakk>\<And>S. P S \<Longrightarrow> openin X S; openin X U;
  4212   assumes X: "\<And>S. P S \<Longrightarrow> openin X S" and "openin X U"
  4202      openin(topology(arbitrary union_of (finite intersection_of P relative_to U))) S\<rbrakk>
  4213   and S: "openin(topology(arbitrary union_of (finite intersection_of P relative_to U))) S"
  4203     \<Longrightarrow> openin X S"
  4214 shows "openin X S"
  4204   apply (simp add: istopology_subbase topology_inverse)
  4215 proof -
  4205   apply (simp add: union_of_def intersection_of_def relative_to_def)
  4216   have "(arbitrary union_of (finite intersection_of P relative_to U)) S"
  4206   apply (blast intro: openin_Int_Inter)
  4217     using S openin_subbase by blast
  4207   done
  4218   with X \<open>openin X U\<close> show ?thesis
       
  4219     by (force simp add: union_of_def intersection_of_def relative_to_def intro: openin_Int_Inter)
       
  4220 qed
  4208 
  4221 
  4209 lemma istopology_subbase_UNIV:
  4222 lemma istopology_subbase_UNIV:
  4210    "istopology (arbitrary union_of (finite intersection_of P))"
  4223    "istopology (arbitrary union_of (finite intersection_of P))"
  4211   by (simp add: istopology_base finite_intersection_of_Int)
  4224   by (simp add: istopology_base finite_intersection_of_Int)
  4212 
  4225