# HG changeset patch # User paulson # Date 1539782347 -3600 # Node ID f13b82281715b09ca46a571a68bf7d57ba1ebe20 # Parent 5acb1eece41bbc3fb66147a488f9f531ee648be2 new theory Abstract_Topology with lots of stuff from HOL Light's metric.sml diff -r 5acb1eece41b -r f13b82281715 src/HOL/Analysis/Abstract_Topology.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Analysis/Abstract_Topology.thy Wed Oct 17 14:19:07 2018 +0100 @@ -0,0 +1,2884 @@ +(* Author: L C Paulson, University of Cambridge [ported from HOL Light] +*) + +section \Operators involving abstract topology\ + +theory Abstract_Topology + imports Topology_Euclidean_Space Path_Connected +begin + + +subsection\Derived set (set of limit points)\ + +definition derived_set_of :: "'a topology \ 'a set \ 'a set" (infixl "derived'_set'_of" 80) + where "X derived_set_of S \ + {x \ topspace X. + (\T. x \ T \ openin X T \ (\y\x. y \ S \ y \ T))}" + +lemma derived_set_of_restrict: + "X derived_set_of (topspace X \ S) = X derived_set_of S" + by (simp add: derived_set_of_def) (metis openin_subset subset_iff) + +lemma in_derived_set_of: + "x \ X derived_set_of S \ x \ topspace X \ (\T. x \ T \ openin X T \ (\y\x. y \ S \ y \ T))" + by (simp add: derived_set_of_def) + +lemma derived_set_of_subset_topspace: + "X derived_set_of S \ topspace X" + by (auto simp add: derived_set_of_def) + +lemma derived_set_of_subtopology: + "(subtopology X U) derived_set_of S = U \ (X derived_set_of (U \ S))" + by (simp add: derived_set_of_def openin_subtopology topspace_subtopology) blast + +lemma derived_set_of_subset_subtopology: + "(subtopology X S) derived_set_of T \ S" + by (simp add: derived_set_of_subtopology) + +lemma derived_set_of_empty [simp]: "X derived_set_of {} = {}" + by (auto simp: derived_set_of_def) + +lemma derived_set_of_mono: + "S \ T \ X derived_set_of S \ X derived_set_of T" + unfolding derived_set_of_def by blast + +lemma derived_set_of_union: + "X derived_set_of (S \ T) = X derived_set_of S \ X derived_set_of T" (is "?lhs = ?rhs") +proof + show "?lhs \ ?rhs" + apply (clarsimp simp: in_derived_set_of) + by (metis IntE IntI openin_Int) + show "?rhs \ ?lhs" + by (simp add: derived_set_of_mono) +qed + +lemma derived_set_of_unions: + "finite \ \ X derived_set_of (\\) = (\S \ \. X derived_set_of S)" +proof (induction \ rule: finite_induct) + case (insert S \) + then show ?case + by (simp add: derived_set_of_union) +qed auto + +lemma derived_set_of_topspace: + "X derived_set_of (topspace X) = {x \ topspace X. \ openin X {x}}" + apply (auto simp: in_derived_set_of) + by (metis Set.set_insert all_not_in_conv insertCI openin_subset subsetCE) + +lemma discrete_topology_unique_derived_set: + "discrete_topology U = X \ topspace X = U \ X derived_set_of U = {}" + by (auto simp: discrete_topology_unique derived_set_of_topspace) + +lemma subtopology_eq_discrete_topology_eq: + "subtopology X U = discrete_topology U \ U \ topspace X \ U \ X derived_set_of U = {}" + using discrete_topology_unique_derived_set [of U "subtopology X U"] + by (auto simp: eq_commute topspace_subtopology derived_set_of_subtopology) + +lemma subtopology_eq_discrete_topology: + "S \ topspace X \ S \ X derived_set_of S = {} + \ subtopology X S = discrete_topology S" + by (simp add: subtopology_eq_discrete_topology_eq) + +lemma subtopology_eq_discrete_topology_gen: + "S \ X derived_set_of S = {} \ subtopology X S = discrete_topology(topspace X \ S)" + by (metis Int_lower1 derived_set_of_restrict inf_assoc inf_bot_right subtopology_eq_discrete_topology_eq subtopology_subtopology subtopology_topspace) + +lemma openin_Int_derived_set_of_subset: + "openin X S \ S \ X derived_set_of T \ X derived_set_of (S \ T)" + by (auto simp: derived_set_of_def) + +lemma openin_Int_derived_set_of_eq: + "openin X S \ S \ X derived_set_of T = S \ X derived_set_of (S \ T)" + apply auto + apply (meson IntI openin_Int_derived_set_of_subset subsetCE) + by (meson derived_set_of_mono inf_sup_ord(2) subset_eq) + + +subsection\ Closure with respect to a topological space\ + +definition closure_of :: "'a topology \ 'a set \ 'a set" (infixr "closure'_of" 80) + where "X closure_of S \ {x \ topspace X. \T. x \ T \ openin X T \ (\y \ S. y \ T)}" + +lemma closure_of_restrict: "X closure_of S = X closure_of (topspace X \ S)" + unfolding closure_of_def + apply safe + apply (meson IntI openin_subset subset_iff) + by auto + +lemma in_closure_of: + "x \ X closure_of S \ + x \ topspace X \ (\T. x \ T \ openin X T \ (\y. y \ S \ y \ T))" + by (auto simp: closure_of_def) + +lemma closure_of: "X closure_of S = topspace X \ (S \ X derived_set_of S)" + by (fastforce simp: in_closure_of in_derived_set_of) + +lemma closure_of_alt: "X closure_of S = topspace X \ S \ X derived_set_of S" + using derived_set_of_subset_topspace [of X S] + unfolding closure_of_def in_derived_set_of + by safe (auto simp: in_derived_set_of) + +lemma derived_set_of_subset_closure_of: + "X derived_set_of S \ X closure_of S" + by (fastforce simp: closure_of_def in_derived_set_of) + +lemma closure_of_subtopology: + "(subtopology X U) closure_of S = U \ (X closure_of (U \ S))" + unfolding closure_of_def topspace_subtopology openin_subtopology + by safe (metis (full_types) IntI Int_iff inf.commute)+ + +lemma closure_of_empty [simp]: "X closure_of {} = {}" + by (simp add: closure_of_alt) + +lemma closure_of_topspace [simp]: "X closure_of topspace X = topspace X" + by (simp add: closure_of) + +lemma closure_of_UNIV [simp]: "X closure_of UNIV = topspace X" + by (simp add: closure_of) + +lemma closure_of_subset_topspace: "X closure_of S \ topspace X" + by (simp add: closure_of) + +lemma closure_of_subset_subtopology: "(subtopology X S) closure_of T \ S" + by (simp add: closure_of_subtopology) + +lemma closure_of_mono: "S \ T \ X closure_of S \ X closure_of T" + by (fastforce simp add: closure_of_def) + +lemma closure_of_subtopology_subset: + "(subtopology X U) closure_of S \ (X closure_of S)" + unfolding closure_of_subtopology + by clarsimp (meson closure_of_mono contra_subsetD inf.cobounded2) + +lemma closure_of_subtopology_mono: + "T \ U \ (subtopology X T) closure_of S \ (subtopology X U) closure_of S" + unfolding closure_of_subtopology + by auto (meson closure_of_mono inf_mono subset_iff) + +lemma closure_of_Un [simp]: "X closure_of (S \ T) = X closure_of S \ X closure_of T" + by (simp add: Un_assoc Un_left_commute closure_of_alt derived_set_of_union inf_sup_distrib1) + +lemma closure_of_Union: + "finite \ \ X closure_of (\\) = (\S \ \. X closure_of S)" +by (induction \ rule: finite_induct) auto + +lemma closure_of_subset: "S \ topspace X \ S \ X closure_of S" + by (auto simp: closure_of_def) + +lemma closure_of_subset_Int: "topspace X \ S \ X closure_of S" + by (auto simp: closure_of_def) + +lemma closure_of_subset_eq: "S \ topspace X \ X closure_of S \ S \ closedin X S" +proof (cases "S \ topspace X") + case True + then have "\x. x \ topspace X \ (\T. x \ T \ openin X T \ (\y\S. y \ T)) \ x \ S + \ openin X (topspace X - S)" + apply (subst openin_subopen, safe) + by (metis DiffI subset_eq openin_subset [of X]) + then show ?thesis + by (auto simp: closedin_def closure_of_def) +next + case False + then show ?thesis + by (simp add: closedin_def) +qed + +lemma closure_of_eq: "X closure_of S = S \ closedin X S" +proof (cases "S \ topspace X") + case True + then show ?thesis + by (metis closure_of_subset closure_of_subset_eq set_eq_subset) +next + case False + then show ?thesis + using closure_of closure_of_subset_eq by fastforce +qed + +lemma closedin_contains_derived_set: + "closedin X S \ X derived_set_of S \ S \ S \ topspace X" +proof (intro iffI conjI) + show "closedin X S \ X derived_set_of S \ S" + using closure_of_eq derived_set_of_subset_closure_of by fastforce + show "closedin X S \ S \ topspace X" + using closedin_subset by blast + show "X derived_set_of S \ S \ S \ topspace X \ closedin X S" + by (metis closure_of closure_of_eq inf.absorb_iff2 sup.orderE) +qed + +lemma derived_set_subset_gen: + "X derived_set_of S \ S \ closedin X (topspace X \ S)" + by (simp add: closedin_contains_derived_set derived_set_of_restrict derived_set_of_subset_topspace) + +lemma derived_set_subset: "S \ topspace X \ (X derived_set_of S \ S \ closedin X S)" + by (simp add: closedin_contains_derived_set) + +lemma closedin_derived_set: + "closedin (subtopology X T) S \ + S \ topspace X \ S \ T \ (\x. x \ X derived_set_of S \ x \ T \ x \ S)" + by (auto simp: closedin_contains_derived_set topspace_subtopology derived_set_of_subtopology Int_absorb1) + +lemma closedin_Int_closure_of: + "closedin (subtopology X S) T \ S \ X closure_of T = T" + by (metis Int_left_absorb closure_of_eq closure_of_subtopology) + +lemma closure_of_closedin: "closedin X S \ X closure_of S = S" + by (simp add: closure_of_eq) + +lemma closure_of_eq_diff: "X closure_of S = topspace X - \{T. openin X T \ disjnt S T}" + by (auto simp: closure_of_def disjnt_iff) + +lemma closedin_closure_of [simp]: "closedin X (X closure_of S)" + unfolding closure_of_eq_diff by blast + +lemma closure_of_closure_of [simp]: "X closure_of (X closure_of S) = X closure_of S" + by (simp add: closure_of_eq) + +lemma closure_of_hull: + assumes "S \ topspace X" shows "X closure_of S = (closedin X) hull S" +proof (rule hull_unique [THEN sym]) + show "S \ X closure_of S" + by (simp add: closure_of_subset assms) +next + show "closedin X (X closure_of S)" + by simp + show "\T. \S \ T; closedin X T\ \ X closure_of S \ T" + by (metis closure_of_eq closure_of_mono) +qed + +lemma closure_of_minimal: + "\S \ T; closedin X T\ \ (X closure_of S) \ T" + by (metis closure_of_eq closure_of_mono) + +lemma closure_of_minimal_eq: + "\S \ topspace X; closedin X T\ \ (X closure_of S) \ T \ S \ T" + by (meson closure_of_minimal closure_of_subset subset_trans) + +lemma closure_of_unique: + "\S \ T; closedin X T; + \T'. \S \ T'; closedin X T'\ \ T \ T'\ + \ X closure_of S = T" + by (meson closedin_closure_of closedin_subset closure_of_minimal closure_of_subset eq_iff order.trans) + +lemma closure_of_eq_empty_gen: "X closure_of S = {} \ disjnt (topspace X) S" + unfolding disjnt_def closure_of_restrict [where S=S] + using closure_of by fastforce + +lemma closure_of_eq_empty: "S \ topspace X \ X closure_of S = {} \ S = {}" + using closure_of_subset by fastforce + +lemma openin_Int_closure_of_subset: + assumes "openin X S" + shows "S \ X closure_of T \ X closure_of (S \ T)" +proof - + have "S \ X derived_set_of T = S \ X derived_set_of (S \ T)" + by (meson assms openin_Int_derived_set_of_eq) + moreover have "S \ (S \ T) = S \ T" + by fastforce + ultimately show ?thesis + by (metis closure_of_alt inf.cobounded2 inf_left_commute inf_sup_distrib1) +qed + +lemma closure_of_openin_Int_closure_of: + assumes "openin X S" + shows "X closure_of (S \ X closure_of T) = X closure_of (S \ T)" +proof + show "X closure_of (S \ X closure_of T) \ X closure_of (S \ T)" + by (simp add: assms closure_of_minimal openin_Int_closure_of_subset) +next + show "X closure_of (S \ T) \ X closure_of (S \ X closure_of T)" + by (metis Int_lower1 Int_subset_iff assms closedin_closure_of closure_of_minimal_eq closure_of_mono inf_le2 le_infI1 openin_subset) +qed + +lemma openin_Int_closure_of_eq: + "openin X S \ S \ X closure_of T = S \ X closure_of (S \ T)" + apply (rule equalityI) + apply (simp add: openin_Int_closure_of_subset) + by (meson closure_of_mono inf.cobounded2 inf_mono subset_refl) + +lemma openin_Int_closure_of_eq_empty: + "openin X S \ S \ X closure_of T = {} \ S \ T = {}" + apply (subst openin_Int_closure_of_eq, auto) + by (meson IntI closure_of_subset_Int disjoint_iff_not_equal openin_subset subset_eq) + +lemma closure_of_openin_Int_superset: + "openin X S \ S \ X closure_of T + \ X closure_of (S \ T) = X closure_of S" + by (metis closure_of_openin_Int_closure_of inf.orderE) + +lemma closure_of_openin_subtopology_Int_closure_of: + assumes S: "openin (subtopology X U) S" and "T \ U" + shows "X closure_of (S \ X closure_of T) = X closure_of (S \ T)" (is "?lhs = ?rhs") +proof + obtain S0 where S0: "openin X S0" "S = S0 \ U" + using assms by (auto simp: openin_subtopology) + show "?lhs \ ?rhs" + proof - + have "S0 \ X closure_of T = S0 \ X closure_of (S0 \ T)" + by (meson S0(1) openin_Int_closure_of_eq) + moreover have "S0 \ T = S0 \ U \ T" + using \T \ U\ by fastforce + ultimately have "S \ X closure_of T \ X closure_of (S \ T)" + using S0(2) by auto + then show ?thesis + by (meson closedin_closure_of closure_of_minimal) + qed +next + show "?rhs \ ?lhs" + proof - + have "T \ S \ T \ X derived_set_of T" + by force + then show ?thesis + by (metis Int_subset_iff S closure_of closure_of_mono inf.cobounded2 inf.coboundedI2 inf_commute openin_closedin_eq topspace_subtopology) + qed +qed + +lemma closure_of_subtopology_open: + "openin X U \ S \ U \ (subtopology X U) closure_of S = U \ X closure_of S" + by (metis closure_of_subtopology inf_absorb2 openin_Int_closure_of_eq) + +lemma discrete_topology_closure_of: + "(discrete_topology U) closure_of S = U \ S" + by (metis closedin_discrete_topology closure_of_restrict closure_of_unique discrete_topology_unique inf_sup_ord(1) order_refl) + + +text\ Interior with respect to a topological space. \ + +definition interior_of :: "'a topology \ 'a set \ 'a set" (infixr "interior'_of" 80) + where "X interior_of S \ {x. \T. openin X T \ x \ T \ T \ S}" + +lemma interior_of_restrict: + "X interior_of S = X interior_of (topspace X \ S)" + using openin_subset by (auto simp: interior_of_def) + +lemma interior_of_eq: "(X interior_of S = S) \ openin X S" + unfolding interior_of_def using openin_subopen by blast + +lemma interior_of_openin: "openin X S \ X interior_of S = S" + by (simp add: interior_of_eq) + +lemma interior_of_empty [simp]: "X interior_of {} = {}" + by (simp add: interior_of_eq) + +lemma interior_of_topspace [simp]: "X interior_of (topspace X) = topspace X" + by (simp add: interior_of_eq) + +lemma openin_interior_of [simp]: "openin X (X interior_of S)" + unfolding interior_of_def + using openin_subopen by fastforce + +lemma interior_of_interior_of [simp]: + "X interior_of X interior_of S = X interior_of S" + by (simp add: interior_of_eq) + +lemma interior_of_subset: "X interior_of S \ S" + by (auto simp: interior_of_def) + +lemma interior_of_subset_closure_of: "X interior_of S \ X closure_of S" + by (metis closure_of_subset_Int dual_order.trans interior_of_restrict interior_of_subset) + +lemma subset_interior_of_eq: "S \ X interior_of S \ openin X S" + by (metis interior_of_eq interior_of_subset subset_antisym) + +lemma interior_of_mono: "S \ T \ X interior_of S \ X interior_of T" + by (auto simp: interior_of_def) + +lemma interior_of_maximal: "\T \ S; openin X T\ \ T \ X interior_of S" + by (auto simp: interior_of_def) + +lemma interior_of_maximal_eq: "openin X T \ T \ X interior_of S \ T \ S" + by (meson interior_of_maximal interior_of_subset order_trans) + +lemma interior_of_unique: + "\T \ S; openin X T; \T'. \T' \ S; openin X T'\ \ T' \ T\ \ X interior_of S = T" + by (simp add: interior_of_maximal_eq interior_of_subset subset_antisym) + +lemma interior_of_subset_topspace: "X interior_of S \ topspace X" + by (simp add: openin_subset) + +lemma interior_of_subset_subtopology: "(subtopology X S) interior_of T \ S" + by (meson openin_imp_subset openin_interior_of) + +lemma interior_of_Int: "X interior_of (S \ T) = X interior_of S \ X interior_of T" + apply (rule equalityI) + apply (simp add: interior_of_mono) + apply (auto simp: interior_of_maximal_eq openin_Int interior_of_subset le_infI1 le_infI2) + done + +lemma interior_of_Inter_subset: "X interior_of (\\) \ (\S \ \. X interior_of S)" + by (simp add: INT_greatest Inf_lower interior_of_mono) + +lemma union_interior_of_subset: + "X interior_of S \ X interior_of T \ X interior_of (S \ T)" + by (simp add: interior_of_mono) + +lemma interior_of_eq_empty: + "X interior_of S = {} \ (\T. openin X T \ T \ S \ T = {})" + by (metis bot.extremum_uniqueI interior_of_maximal interior_of_subset openin_interior_of) + +lemma interior_of_eq_empty_alt: + "X interior_of S = {} \ (\T. openin X T \ T \ {} \ T - S \ {})" + by (auto simp: interior_of_eq_empty) + +lemma interior_of_Union_openin_subsets: + "\{T. openin X T \ T \ S} = X interior_of S" + by (rule interior_of_unique [symmetric]) auto + +lemma interior_of_complement: + "X interior_of (topspace X - S) = topspace X - X closure_of S" + by (auto simp: interior_of_def closure_of_def) + +lemma interior_of_closure_of: + "X interior_of S = topspace X - X closure_of (topspace X - S)" + unfolding interior_of_complement [symmetric] + by (metis Diff_Diff_Int interior_of_restrict) + +lemma closure_of_interior_of: + "X closure_of S = topspace X - X interior_of (topspace X - S)" + by (simp add: interior_of_complement Diff_Diff_Int closure_of) + +lemma closure_of_complement: "X closure_of (topspace X - S) = topspace X - X interior_of S" + unfolding interior_of_def closure_of_def + by (blast dest: openin_subset) + +lemma interior_of_eq_empty_complement: + "X interior_of S = {} \ X closure_of (topspace X - S) = topspace X" + using interior_of_subset_topspace [of X S] closure_of_complement by fastforce + +lemma closure_of_eq_topspace: + "X closure_of S = topspace X \ X interior_of (topspace X - S) = {}" + using closure_of_subset_topspace [of X S] interior_of_complement by fastforce + +lemma interior_of_subtopology_subset: + "U \ X interior_of S \ (subtopology X U) interior_of S" + by (auto simp: interior_of_def openin_subtopology) + +lemma interior_of_subtopology_subsets: + "T \ U \ T \ (subtopology X U) interior_of S \ (subtopology X T) interior_of S" + by (metis inf.absorb_iff2 interior_of_subtopology_subset subtopology_subtopology) + +lemma interior_of_subtopology_mono: + "\S \ T; T \ U\ \ (subtopology X U) interior_of S \ (subtopology X T) interior_of S" + by (metis dual_order.trans inf.orderE inf_commute interior_of_subset interior_of_subtopology_subsets) + +lemma interior_of_subtopology_open: + assumes "openin X U" + shows "(subtopology X U) interior_of S = U \ X interior_of S" +proof - + have "\A. U \ X closure_of (U \ A) = U \ X closure_of A" + using assms openin_Int_closure_of_eq by blast + then have "topspace X \ U - U \ X closure_of (topspace X \ U - S) = U \ (topspace X - X closure_of (topspace X - S))" + by (metis (no_types) Diff_Int_distrib Int_Diff inf_commute) + then show ?thesis + unfolding interior_of_closure_of closure_of_subtopology_open topspace_subtopology + using openin_Int_closure_of_eq [OF assms] + by (metis assms closure_of_subtopology_open) +qed + +lemma dense_intersects_open: + "X closure_of S = topspace X \ (\T. openin X T \ T \ {} \ S \ T \ {})" +proof - + have "X closure_of S = topspace X \ (topspace X - X interior_of (topspace X - S) = topspace X)" + by (simp add: closure_of_interior_of) + also have "\ \ X interior_of (topspace X - S) = {}" + by (simp add: closure_of_complement interior_of_eq_empty_complement) + also have "\ \ (\T. openin X T \ T \ {} \ S \ T \ {})" + unfolding interior_of_eq_empty_alt + using openin_subset by fastforce + finally show ?thesis . +qed + +lemma interior_of_closedin_union_empty_interior_of: + assumes "closedin X S" and disj: "X interior_of T = {}" + shows "X interior_of (S \ T) = X interior_of S" +proof - + have "X closure_of (topspace X - T) = topspace X" + by (metis Diff_Diff_Int disj closure_of_eq_topspace closure_of_restrict interior_of_closure_of) + then show ?thesis + unfolding interior_of_closure_of + by (metis Diff_Un Diff_subset assms(1) closedin_def closure_of_openin_Int_superset) +qed + +lemma interior_of_union_eq_empty: + "closedin X S + \ (X interior_of (S \ T) = {} \ + X interior_of S = {} \ X interior_of T = {})" + by (metis interior_of_closedin_union_empty_interior_of le_sup_iff subset_empty union_interior_of_subset) + +lemma discrete_topology_interior_of [simp]: + "(discrete_topology U) interior_of S = U \ S" + by (simp add: interior_of_restrict [of _ S] interior_of_eq) + + +subsection \Frontier with respect to topological space \ + +definition frontier_of :: "'a topology \ 'a set \ 'a set" (infixr "frontier'_of" 80) + where "X frontier_of S \ X closure_of S - X interior_of S" + +lemma frontier_of_closures: + "X frontier_of S = X closure_of S \ X closure_of (topspace X - S)" + by (metis Diff_Diff_Int closure_of_complement closure_of_subset_topspace double_diff frontier_of_def interior_of_subset_closure_of) + + +lemma interior_of_union_frontier_of [simp]: + "X interior_of S \ X frontier_of S = X closure_of S" + by (simp add: frontier_of_def interior_of_subset_closure_of subset_antisym) + +lemma frontier_of_restrict: "X frontier_of S = X frontier_of (topspace X \ S)" + by (metis closure_of_restrict frontier_of_def interior_of_restrict) + +lemma closedin_frontier_of: "closedin X (X frontier_of S)" + by (simp add: closedin_Int frontier_of_closures) + +lemma frontier_of_subset_topspace: "X frontier_of S \ topspace X" + by (simp add: closedin_frontier_of closedin_subset) + +lemma frontier_of_subset_subtopology: "(subtopology X S) frontier_of T \ S" + by (metis (no_types) closedin_derived_set closedin_frontier_of) + +lemma frontier_of_subtopology_subset: + "U \ (subtopology X U) frontier_of S \ (X frontier_of S)" +proof - + have "U \ X interior_of S - subtopology X U interior_of S = {}" + by (simp add: interior_of_subtopology_subset) + moreover have "X closure_of S \ subtopology X U closure_of S = subtopology X U closure_of S" + by (meson closure_of_subtopology_subset inf.absorb_iff2) + ultimately show ?thesis + unfolding frontier_of_def + by blast +qed + +lemma frontier_of_subtopology_mono: + "\S \ T; T \ U\ \ (subtopology X T) frontier_of S \ (subtopology X U) frontier_of S" + by (simp add: frontier_of_def Diff_mono closure_of_subtopology_mono interior_of_subtopology_mono) + +lemma clopenin_eq_frontier_of: + "closedin X S \ openin X S \ S \ topspace X \ X frontier_of S = {}" +proof (cases "S \ topspace X") + case True + then show ?thesis + by (metis Diff_eq_empty_iff closure_of_eq closure_of_subset_eq frontier_of_def interior_of_eq interior_of_subset interior_of_union_frontier_of sup_bot_right) +next + case False + then show ?thesis + by (simp add: frontier_of_closures openin_closedin_eq) +qed + +lemma frontier_of_eq_empty: + "S \ topspace X \ (X frontier_of S = {} \ closedin X S \ openin X S)" + by (simp add: clopenin_eq_frontier_of) + +lemma frontier_of_openin: + "openin X S \ X frontier_of S = X closure_of S - S" + by (metis (no_types) frontier_of_def interior_of_eq) + +lemma frontier_of_openin_straddle_Int: + assumes "openin X U" "U \ X frontier_of S \ {}" + shows "U \ S \ {}" "U - S \ {}" +proof - + have "U \ (X closure_of S \ X closure_of (topspace X - S)) \ {}" + using assms by (simp add: frontier_of_closures) + then show "U \ S \ {}" + using assms openin_Int_closure_of_eq_empty by fastforce + show "U - S \ {}" + proof - + have "\A. X closure_of (A - S) \ U \ {}" + using \U \ (X closure_of S \ X closure_of (topspace X - S)) \ {}\ by blast + then have "\ U \ S" + by (metis Diff_disjoint Diff_eq_empty_iff Int_Diff assms(1) inf_commute openin_Int_closure_of_eq_empty) + then show ?thesis + by blast + qed +qed + +lemma frontier_of_subset_closedin: "closedin X S \ (X frontier_of S) \ S" + using closure_of_eq frontier_of_def by fastforce + +lemma frontier_of_empty [simp]: "X frontier_of {} = {}" + by (simp add: frontier_of_def) + +lemma frontier_of_topspace [simp]: "X frontier_of topspace X = {}" + by (simp add: frontier_of_def) + +lemma frontier_of_subset_eq: + assumes "S \ topspace X" + shows "(X frontier_of S) \ S \ closedin X S" +proof + show "X frontier_of S \ S \ closedin X S" + by (metis assms closure_of_subset_eq interior_of_subset interior_of_union_frontier_of le_sup_iff) + show "closedin X S \ X frontier_of S \ S" + by (simp add: frontier_of_subset_closedin) +qed + +lemma frontier_of_complement: "X frontier_of (topspace X - S) = X frontier_of S" + by (metis Diff_Diff_Int closure_of_restrict frontier_of_closures inf_commute) + +lemma frontier_of_disjoint_eq: + assumes "S \ topspace X" + shows "((X frontier_of S) \ S = {} \ openin X S)" +proof + assume "X frontier_of S \ S = {}" + then have "closedin X (topspace X - S)" + using assms closure_of_subset frontier_of_def interior_of_eq interior_of_subset by fastforce + then show "openin X S" + using assms by (simp add: openin_closedin) +next + show "openin X S \ X frontier_of S \ S = {}" + by (simp add: Diff_Diff_Int closedin_def frontier_of_openin inf.absorb_iff2 inf_commute) +qed + +lemma frontier_of_disjoint_eq_alt: + "S \ (topspace X - X frontier_of S) \ openin X S" +proof (cases "S \ topspace X") + case True + show ?thesis + using True frontier_of_disjoint_eq by auto +next + case False + then show ?thesis + by (meson Diff_subset openin_subset subset_trans) +qed + +lemma frontier_of_Int: + "X frontier_of (S \ T) = + X closure_of (S \ T) \ (X frontier_of S \ X frontier_of T)" +proof - + have *: "U \ S \ U \ T \ U \ (S \ A \ T \ B) = U \ (A \ B)" for U S T A B :: "'a set" + by blast + show ?thesis + by (simp add: frontier_of_closures closure_of_mono Diff_Int * flip: closure_of_Un) +qed + +lemma frontier_of_Int_subset: "X frontier_of (S \ T) \ X frontier_of S \ X frontier_of T" + by (simp add: frontier_of_Int) + +lemma frontier_of_Int_closedin: + "\closedin X S; closedin X T\ \ X frontier_of(S \ T) = X frontier_of S \ T \ S \ X frontier_of T" + apply (simp add: frontier_of_Int closedin_Int closure_of_closedin) + using frontier_of_subset_closedin by blast + +lemma frontier_of_Un_subset: "X frontier_of(S \ T) \ X frontier_of S \ X frontier_of T" + by (metis Diff_Un frontier_of_Int_subset frontier_of_complement) + +lemma frontier_of_Union_subset: + "finite \ \ X frontier_of (\\) \ (\T \ \. X frontier_of T)" +proof (induction \ rule: finite_induct) + case (insert A \) + then show ?case + using frontier_of_Un_subset by fastforce +qed simp + +lemma frontier_of_frontier_of_subset: + "X frontier_of (X frontier_of S) \ X frontier_of S" + by (simp add: closedin_frontier_of frontier_of_subset_closedin) + +lemma frontier_of_subtopology_open: + "openin X U \ (subtopology X U) frontier_of S = U \ X frontier_of S" + by (simp add: Diff_Int_distrib closure_of_subtopology_open frontier_of_def interior_of_subtopology_open) + +lemma discrete_topology_frontier_of [simp]: + "(discrete_topology U) frontier_of S = {}" + by (simp add: Diff_eq discrete_topology_closure_of frontier_of_closures) + + +subsection\Continuous maps\ + +definition continuous_map where + "continuous_map X Y f \ + (\x \ topspace X. f x \ topspace Y) \ + (\U. openin Y U \ openin X {x \ topspace X. f x \ U})" + +lemma continuous_map: + "continuous_map X Y f \ + f ` (topspace X) \ topspace Y \ (\U. openin Y U \ openin X {x \ topspace X. f x \ U})" + by (auto simp: continuous_map_def) + +lemma continuous_map_image_subset_topspace: + "continuous_map X Y f \ f ` (topspace X) \ topspace Y" + by (auto simp: continuous_map_def) + +lemma continuous_map_on_empty: "topspace X = {} \ continuous_map X Y f" + by (auto simp: continuous_map_def) + +lemma continuous_map_closedin: + "continuous_map X Y f \ + (\x \ topspace X. f x \ topspace Y) \ + (\C. closedin Y C \ closedin X {x \ topspace X. f x \ C})" +proof - + have "(\U. openin Y U \ openin X {x \ topspace X. f x \ U}) = + (\C. closedin Y C \ closedin X {x \ topspace X. f x \ C})" + if "\x. x \ topspace X \ f x \ topspace Y" + proof - + have eq: "{x \ topspace X. f x \ topspace Y \ f x \ C} = (topspace X - {x \ topspace X. f x \ C})" for C + using that by blast + show ?thesis + proof (intro iffI allI impI) + fix C + assume "\U. openin Y U \ openin X {x \ topspace X. f x \ U}" and "closedin Y C" + then have "openin X {x \ topspace X. f x \ topspace Y - C}" by blast + then show "closedin X {x \ topspace X. f x \ C}" + by (auto simp add: closedin_def eq) + next + fix U + assume "\C. closedin Y C \ closedin X {x \ topspace X. f x \ C}" and "openin Y U" + then have "closedin X {x \ topspace X. f x \ topspace Y - U}" by blast + then show "openin X {x \ topspace X. f x \ U}" + by (auto simp add: openin_closedin_eq eq) + qed + qed + then show ?thesis + by (auto simp: continuous_map_def) +qed + +lemma openin_continuous_map_preimage: + "\continuous_map X Y f; openin Y U\ \ openin X {x \ topspace X. f x \ U}" + by (simp add: continuous_map_def) + +lemma closedin_continuous_map_preimage: + "\continuous_map X Y f; closedin Y C\ \ closedin X {x \ topspace X. f x \ C}" + by (simp add: continuous_map_closedin) + +lemma openin_continuous_map_preimage_gen: + assumes "continuous_map X Y f" "openin X U" "openin Y V" + shows "openin X {x \ U. f x \ V}" +proof - + have eq: "{x \ U. f x \ V} = U \ {x \ topspace X. f x \ V}" + using assms(2) openin_closedin_eq by fastforce + show ?thesis + unfolding eq + using assms openin_continuous_map_preimage by fastforce +qed + +lemma closedin_continuous_map_preimage_gen: + assumes "continuous_map X Y f" "closedin X U" "closedin Y V" + shows "closedin X {x \ U. f x \ V}" +proof - + have eq: "{x \ U. f x \ V} = U \ {x \ topspace X. f x \ V}" + using assms(2) closedin_def by fastforce + show ?thesis + unfolding eq + using assms closedin_continuous_map_preimage by fastforce +qed + +lemma continuous_map_image_closure_subset: + assumes "continuous_map X Y f" + shows "f ` (X closure_of S) \ Y closure_of f ` S" +proof - + have *: "f ` (topspace X) \ topspace Y" + by (meson assms continuous_map) + have "X closure_of T \ {x \ X closure_of T. f x \ Y closure_of (f ` T)}" if "T \ topspace X" for T + proof (rule closure_of_minimal) + show "T \ {x \ X closure_of T. f x \ Y closure_of f ` T}" + using closure_of_subset * that by (fastforce simp: in_closure_of) + next + show "closedin X {x \ X closure_of T. f x \ Y closure_of f ` T}" + using assms closedin_continuous_map_preimage_gen by fastforce + qed + then have "f ` (X closure_of (topspace X \ S)) \ Y closure_of (f ` (topspace X \ S))" + by blast + also have "\ \ Y closure_of (topspace Y \ f ` S)" + using * by (blast intro!: closure_of_mono) + finally have "f ` (X closure_of (topspace X \ S)) \ Y closure_of (topspace Y \ f ` S)" . + then show ?thesis + by (metis closure_of_restrict) +qed + +lemma continuous_map_subset_aux1: "continuous_map X Y f \ + (\S. f ` (X closure_of S) \ Y closure_of f ` S)" + using continuous_map_image_closure_subset by blast + +lemma continuous_map_subset_aux2: + assumes "\S. S \ topspace X \ f ` (X closure_of S) \ Y closure_of f ` S" + shows "continuous_map X Y f" + unfolding continuous_map_closedin +proof (intro conjI ballI allI impI) + fix x + assume "x \ topspace X" + then show "f x \ topspace Y" + using assms closure_of_subset_topspace by fastforce +next + fix C + assume "closedin Y C" + then show "closedin X {x \ topspace X. f x \ C}" + proof (clarsimp simp flip: closure_of_subset_eq, intro conjI) + fix x + assume x: "x \ X closure_of {x \ topspace X. f x \ C}" + and "C \ topspace Y" and "Y closure_of C \ C" + show "x \ topspace X" + by (meson x in_closure_of) + have "{a \ topspace X. f a \ C} \ topspace X" + by simp + moreover have "Y closure_of f ` {a \ topspace X. f a \ C} \ C" + by (simp add: \closedin Y C\ closure_of_minimal image_subset_iff) + ultimately have "f ` (X closure_of {a \ topspace X. f a \ C}) \ C" + using assms by blast + then show "f x \ C" + using x by auto + qed +qed + +lemma continuous_map_eq_image_closure_subset: + "continuous_map X Y f \ (\S. f ` (X closure_of S) \ Y closure_of f ` S)" + using continuous_map_subset_aux1 continuous_map_subset_aux2 by metis + +lemma continuous_map_eq_image_closure_subset_alt: + "continuous_map X Y f \ (\S. S \ topspace X \ f ` (X closure_of S) \ Y closure_of f ` S)" + using continuous_map_subset_aux1 continuous_map_subset_aux2 by metis + +lemma continuous_map_eq_image_closure_subset_gen: + "continuous_map X Y f \ + f ` (topspace X) \ topspace Y \ + (\S. f ` (X closure_of S) \ Y closure_of f ` S)" + using continuous_map_subset_aux1 continuous_map_subset_aux2 continuous_map_image_subset_topspace by metis + +lemma continuous_map_closure_preimage_subset: + "continuous_map X Y f + \ X closure_of {x \ topspace X. f x \ T} + \ {x \ topspace X. f x \ Y closure_of T}" + unfolding continuous_map_closedin + by (rule closure_of_minimal) (use in_closure_of in \fastforce+\) + + +lemma continuous_map_frontier_frontier_preimage_subset: + assumes "continuous_map X Y f" + shows "X frontier_of {x \ topspace X. f x \ T} \ {x \ topspace X. f x \ Y frontier_of T}" +proof - + have eq: "topspace X - {x \ topspace X. f x \ T} = {x \ topspace X. f x \ topspace Y - T}" + using assms unfolding continuous_map_def by blast + have "X closure_of {x \ topspace X. f x \ T} \ {x \ topspace X. f x \ Y closure_of T}" + by (simp add: assms continuous_map_closure_preimage_subset) + moreover + have "X closure_of (topspace X - {x \ topspace X. f x \ T}) \ {x \ topspace X. f x \ Y closure_of (topspace Y - T)}" + using continuous_map_closure_preimage_subset [OF assms] eq by presburger + ultimately show ?thesis + by (auto simp: frontier_of_closures) +qed + +lemma continuous_map_id [simp]: "continuous_map X X id" + unfolding continuous_map_def using openin_subopen topspace_def by fastforce + +lemma topology_finer_continuous_id: + "topspace X = topspace Y \ ((\S. openin X S \ openin Y S) \ continuous_map Y X id)" + unfolding continuous_map_def + apply auto + using openin_subopen openin_subset apply fastforce + using openin_subopen topspace_def by fastforce + +lemma continuous_map_const [simp]: + "continuous_map X Y (\x. C) \ topspace X = {} \ C \ topspace Y" +proof (cases "topspace X = {}") + case False + show ?thesis + proof (cases "C \ topspace Y") + case True + with openin_subopen show ?thesis + by (auto simp: continuous_map_def) + next + case False + then show ?thesis + unfolding continuous_map_def by fastforce + qed +qed (auto simp: continuous_map_on_empty) + +lemma continuous_map_compose: + assumes f: "continuous_map X X' f" and g: "continuous_map X' X'' g" + shows "continuous_map X X'' (g \ f)" + unfolding continuous_map_def +proof (intro conjI ballI allI impI) + fix x + assume "x \ topspace X" + then show "(g \ f) x \ topspace X''" + using assms unfolding continuous_map_def by force +next + fix U + assume "openin X'' U" + have eq: "{x \ topspace X. (g \ f) x \ U} = {x \ topspace X. f x \ {y. y \ topspace X' \ g y \ U}}" + by auto (meson f continuous_map_def) + show "openin X {x \ topspace X. (g \ f) x \ U}" + unfolding eq + using assms unfolding continuous_map_def + using \openin X'' U\ by blast +qed + +lemma continuous_map_eq: + assumes "continuous_map X X' f" and "\x. x \ topspace X \ f x = g x" shows "continuous_map X X' g" +proof - + have eq: "{x \ topspace X. f x \ U} = {x \ topspace X. g x \ U}" for U + using assms by auto + show ?thesis + using assms by (simp add: continuous_map_def eq) +qed + +lemma restrict_continuous_map [simp]: + "topspace X \ S \ continuous_map X X' (restrict f S) \ continuous_map X X' f" + by (auto simp: elim!: continuous_map_eq) + +lemma continuous_map_in_subtopology: + "continuous_map X (subtopology X' S) f \ continuous_map X X' f \ f ` (topspace X) \ S" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + show ?rhs + proof - + have "\A. f ` (X closure_of A) \ subtopology X' S closure_of f ` A" + by (meson L continuous_map_image_closure_subset) + then show ?thesis + by (metis (no_types) closure_of_subset_subtopology closure_of_subtopology_subset closure_of_topspace continuous_map_eq_image_closure_subset dual_order.trans) + qed +next + assume R: ?rhs + then have eq: "{x \ topspace X. f x \ U} = {x \ topspace X. f x \ U \ f x \ S}" for U + by auto + show ?lhs + using R + unfolding continuous_map + by (auto simp: topspace_subtopology openin_subtopology eq) +qed + + +lemma continuous_map_from_subtopology: + "continuous_map X X' f \ continuous_map (subtopology X S) X' f" + by (auto simp: continuous_map topspace_subtopology openin_subtopology) + +lemma continuous_map_into_fulltopology: + "continuous_map X (subtopology X' T) f \ continuous_map X X' f" + by (auto simp: continuous_map_in_subtopology) + +lemma continuous_map_into_subtopology: + "\continuous_map X X' f; f ` topspace X \ T\ \ continuous_map X (subtopology X' T) f" + by (auto simp: continuous_map_in_subtopology) + +lemma continuous_map_from_subtopology_mono: + "\continuous_map (subtopology X T) X' f; S \ T\ + \ continuous_map (subtopology X S) X' f" + by (metis inf.absorb_iff2 continuous_map_from_subtopology subtopology_subtopology) + +lemma continuous_map_from_discrete_topology [simp]: + "continuous_map (discrete_topology U) X f \ f ` U \ topspace X" + by (auto simp: continuous_map_def) + +lemma continuous_map_iff_continuous_real [simp]: "continuous_map (subtopology euclideanreal S) euclideanreal g = continuous_on S g" + by (force simp: continuous_map openin_subtopology continuous_on_open_invariant) + + +subsection\Open and closed maps (not a priori assumed continuous)\ + +definition open_map :: "'a topology \ 'b topology \ ('a \ 'b) \ bool" + where "open_map X1 X2 f \ \U. openin X1 U \ openin X2 (f ` U)" + +definition closed_map :: "'a topology \ 'b topology \ ('a \ 'b) \ bool" + where "closed_map X1 X2 f \ \U. closedin X1 U \ closedin X2 (f ` U)" + +lemma open_map_imp_subset_topspace: + "open_map X1 X2 f \ f ` (topspace X1) \ topspace X2" + unfolding open_map_def by (simp add: openin_subset) + +lemma open_map_imp_subset: + "\open_map X1 X2 f; S \ topspace X1\ \ f ` S \ topspace X2" + by (meson order_trans open_map_imp_subset_topspace subset_image_iff) + +lemma topology_finer_open_id: + "(\S. openin X S \ openin X' S) \ open_map X X' id" + unfolding open_map_def by auto + +lemma open_map_id: "open_map X X id" + unfolding open_map_def by auto + +lemma open_map_eq: + "\open_map X X' f; \x. x \ topspace X \ f x = g x\ \ open_map X X' g" + unfolding open_map_def + by (metis image_cong openin_subset subset_iff) + +lemma open_map_inclusion_eq: + "open_map (subtopology X S) X id \ openin X (topspace X \ S)" +proof - + have *: "openin X (T \ S)" if "openin X (S \ topspace X)" "openin X T" for T + proof - + have "T \ topspace X" + using that by (simp add: openin_subset) + with that show "openin X (T \ S)" + by (metis inf.absorb1 inf.left_commute inf_commute openin_Int) + qed + show ?thesis + by (fastforce simp add: open_map_def Int_commute openin_subtopology_alt intro: *) +qed + +lemma open_map_inclusion: + "openin X S \ open_map (subtopology X S) X id" + by (simp add: open_map_inclusion_eq openin_Int) + +lemma open_map_compose: + "\open_map X X' f; open_map X' X'' g\ \ open_map X X'' (g \ f)" + by (metis (no_types, lifting) image_comp open_map_def) + +lemma closed_map_imp_subset_topspace: + "closed_map X1 X2 f \ f ` (topspace X1) \ topspace X2" + by (simp add: closed_map_def closedin_subset) + +lemma closed_map_imp_subset: + "\closed_map X1 X2 f; S \ topspace X1\ \ f ` S \ topspace X2" + using closed_map_imp_subset_topspace by blast + +lemma topology_finer_closed_id: + "(\S. closedin X S \ closedin X' S) \ closed_map X X' id" + by (simp add: closed_map_def) + +lemma closed_map_id: "closed_map X X id" + by (simp add: closed_map_def) + +lemma closed_map_eq: + "\closed_map X X' f; \x. x \ topspace X \ f x = g x\ \ closed_map X X' g" + unfolding closed_map_def + by (metis image_cong closedin_subset subset_iff) + +lemma closed_map_compose: + "\closed_map X X' f; closed_map X' X'' g\ \ closed_map X X'' (g \ f)" + by (metis (no_types, lifting) closed_map_def image_comp) + +lemma closed_map_inclusion_eq: + "closed_map (subtopology X S) X id \ + closedin X (topspace X \ S)" +proof - + have *: "closedin X (T \ S)" if "closedin X (S \ topspace X)" "closedin X T" for T + proof - + have "T \ topspace X" + using that by (simp add: closedin_subset) + with that show "closedin X (T \ S)" + by (metis inf.absorb1 inf.left_commute inf_commute closedin_Int) + qed + show ?thesis + by (fastforce simp add: closed_map_def Int_commute closedin_subtopology_alt intro: *) +qed + +lemma closed_map_inclusion: "closedin X S \ closed_map (subtopology X S) X id" + by (simp add: closed_map_inclusion_eq closedin_Int) + +lemma open_map_into_subtopology: + "\open_map X X' f; f ` topspace X \ S\ \ open_map X (subtopology X' S) f" + unfolding open_map_def openin_subtopology + using openin_subset by fastforce + +lemma closed_map_into_subtopology: + "\closed_map X X' f; f ` topspace X \ S\ \ closed_map X (subtopology X' S) f" + unfolding closed_map_def closedin_subtopology + using closedin_subset by fastforce + +lemma open_map_into_discrete_topology: + "open_map X (discrete_topology U) f \ f ` (topspace X) \ U" + unfolding open_map_def openin_discrete_topology using openin_subset by blast + +lemma closed_map_into_discrete_topology: + "closed_map X (discrete_topology U) f \ f ` (topspace X) \ U" + unfolding closed_map_def closedin_discrete_topology using closedin_subset by blast + +lemma bijective_open_imp_closed_map: + "\open_map X X' f; f ` (topspace X) = topspace X'; inj_on f (topspace X)\ \ closed_map X X' f" + unfolding open_map_def closed_map_def closedin_def + by auto (metis Diff_subset inj_on_image_set_diff) + +lemma bijective_closed_imp_open_map: + "\closed_map X X' f; f ` (topspace X) = topspace X'; inj_on f (topspace X)\ \ open_map X X' f" + unfolding closed_map_def open_map_def openin_closedin_eq + by auto (metis Diff_subset inj_on_image_set_diff) + +lemma open_map_from_subtopology: + "\open_map X X' f; openin X U\ \ open_map (subtopology X U) X' f" + unfolding open_map_def openin_subtopology_alt by blast + +lemma closed_map_from_subtopology: + "\closed_map X X' f; closedin X U\ \ closed_map (subtopology X U) X' f" + unfolding closed_map_def closedin_subtopology_alt by blast + +lemma open_map_restriction: + "\open_map X X' f; {x. x \ topspace X \ f x \ V} = U\ + \ open_map (subtopology X U) (subtopology X' V) f" + unfolding open_map_def openin_subtopology_alt + apply clarify + apply (rename_tac T) + apply (rule_tac x="f ` T" in image_eqI) + using openin_closedin_eq by force+ + +lemma closed_map_restriction: + "\closed_map X X' f; {x. x \ topspace X \ f x \ V} = U\ + \ closed_map (subtopology X U) (subtopology X' V) f" + unfolding closed_map_def closedin_subtopology_alt + apply clarify + apply (rename_tac T) + apply (rule_tac x="f ` T" in image_eqI) + using closedin_def by force+ + +subsection\Quotient maps\ + +definition quotient_map where + "quotient_map X X' f \ + f ` (topspace X) = topspace X' \ + (\U. U \ topspace X' \ (openin X {x. x \ topspace X \ f x \ U} \ openin X' U))" + +lemma quotient_map_eq: + assumes "quotient_map X X' f" "\x. x \ topspace X \ f x = g x" + shows "quotient_map X X' g" +proof - + have eq: "{x \ topspace X. f x \ U} = {x \ topspace X. g x \ U}" for U + using assms by auto + show ?thesis + using assms + unfolding quotient_map_def + by (metis (mono_tags, lifting) eq image_cong) +qed + +lemma quotient_map_compose: + assumes f: "quotient_map X X' f" and g: "quotient_map X' X'' g" + shows "quotient_map X X'' (g \ f)" + unfolding quotient_map_def +proof (intro conjI allI impI) + show "(g \ f) ` topspace X = topspace X''" + using assms image_comp unfolding quotient_map_def by force +next + fix U'' + assume "U'' \ topspace X''" + define U' where "U' \ {y \ topspace X'. g y \ U''}" + have "U' \ topspace X'" + by (auto simp add: U'_def) + then have U': "openin X {x \ topspace X. f x \ U'} = openin X' U'" + using assms unfolding quotient_map_def by simp + have eq: "{x \ topspace X. f x \ topspace X' \ g (f x) \ U''} = {x \ topspace X. (g \ f) x \ U''}" + using f quotient_map_def by fastforce + have "openin X {x \ topspace X. (g \ f) x \ U''} = openin X {x \ topspace X. f x \ U'}" + using assms by (simp add: quotient_map_def U'_def eq) + also have "\ = openin X'' U''" + using U'_def \U'' \ topspace X''\ U' g quotient_map_def by fastforce + finally show "openin X {x \ topspace X. (g \ f) x \ U''} = openin X'' U''" . +qed + +lemma quotient_map_from_composition: + assumes f: "continuous_map X X' f" and g: "continuous_map X' X'' g" and gf: "quotient_map X X'' (g \ f)" + shows "quotient_map X' X'' g" + unfolding quotient_map_def +proof (intro conjI allI impI) + show "g ` topspace X' = topspace X''" + using assms unfolding continuous_map_def quotient_map_def by fastforce +next + fix U'' :: "'c set" + assume U'': "U'' \ topspace X''" + have eq: "{x \ topspace X. g (f x) \ U''} = {x \ topspace X. f x \ {y. y \ topspace X' \ g y \ U''}}" + using continuous_map_def f by fastforce + show "openin X' {x \ topspace X'. g x \ U''} = openin X'' U''" + using assms unfolding continuous_map_def quotient_map_def + by (metis (mono_tags, lifting) Collect_cong U'' comp_apply eq) +qed + +lemma quotient_imp_continuous_map: + "quotient_map X X' f \ continuous_map X X' f" + by (simp add: continuous_map openin_subset quotient_map_def) + +lemma quotient_imp_surjective_map: + "quotient_map X X' f \ f ` (topspace X) = topspace X'" + by (simp add: quotient_map_def) + +lemma quotient_map_closedin: + "quotient_map X X' f \ + f ` (topspace X) = topspace X' \ + (\U. U \ topspace X' \ (closedin X {x. x \ topspace X \ f x \ U} \ closedin X' U))" +proof - + have eq: "(topspace X - {x \ topspace X. f x \ U'}) = {x \ topspace X. f x \ topspace X' \ f x \ U'}" + if "f ` topspace X = topspace X'" "U' \ topspace X'" for U' + using that by auto + have "(\U\topspace X'. openin X {x \ topspace X. f x \ U} = openin X' U) = + (\U\topspace X'. closedin X {x \ topspace X. f x \ U} = closedin X' U)" + if "f ` topspace X = topspace X'" + proof (rule iffI; intro allI impI subsetI) + fix U' + assume *[rule_format]: "\U\topspace X'. openin X {x \ topspace X. f x \ U} = openin X' U" + and U': "U' \ topspace X'" + show "closedin X {x \ topspace X. f x \ U'} = closedin X' U'" + using U' by (auto simp add: closedin_def Diff_subset simp flip: * [of "topspace X' - U'"] eq [OF that]) + next + fix U' :: "'b set" + assume *[rule_format]: "\U\topspace X'. closedin X {x \ topspace X. f x \ U} = closedin X' U" + and U': "U' \ topspace X'" + show "openin X {x \ topspace X. f x \ U'} = openin X' U'" + using U' by (auto simp add: openin_closedin_eq Diff_subset simp flip: * [of "topspace X' - U'"] eq [OF that]) + qed + then show ?thesis + unfolding quotient_map_def by force +qed + +lemma continuous_open_imp_quotient_map: + assumes "continuous_map X X' f" and om: "open_map X X' f" and feq: "f ` (topspace X) = topspace X'" + shows "quotient_map X X' f" +proof - + { fix U + assume U: "U \ topspace X'" and "openin X {x \ topspace X. f x \ U}" + then have ope: "openin X' (f ` {x \ topspace X. f x \ U})" + using om unfolding open_map_def by blast + then have "openin X' U" + using U feq by (subst openin_subopen) force + } + moreover have "openin X {x \ topspace X. f x \ U}" if "U \ topspace X'" and "openin X' U" for U + using that assms unfolding continuous_map_def by blast + ultimately show ?thesis + unfolding quotient_map_def using assms by blast +qed + +lemma continuous_closed_imp_quotient_map: + assumes "continuous_map X X' f" and om: "closed_map X X' f" and feq: "f ` (topspace X) = topspace X'" + shows "quotient_map X X' f" +proof - + have "f ` {x \ topspace X. f x \ U} = U" if "U \ topspace X'" for U + using that feq by auto + with assms show ?thesis + unfolding quotient_map_closedin closed_map_def continuous_map_closedin by auto +qed + +lemma continuous_open_quotient_map: + "\continuous_map X X' f; open_map X X' f\ \ quotient_map X X' f \ f ` (topspace X) = topspace X'" + by (meson continuous_open_imp_quotient_map quotient_map_def) + +lemma continuous_closed_quotient_map: + "\continuous_map X X' f; closed_map X X' f\ \ quotient_map X X' f \ f ` (topspace X) = topspace X'" + by (meson continuous_closed_imp_quotient_map quotient_map_def) + +lemma injective_quotient_map: + assumes "inj_on f (topspace X)" + shows "quotient_map X X' f \ + continuous_map X X' f \ open_map X X' f \ closed_map X X' f \ f ` (topspace X) = topspace X'" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + have "open_map X X' f" + proof (clarsimp simp add: open_map_def) + fix U + assume "openin X U" + then have "U \ topspace X" + by (simp add: openin_subset) + moreover have "{x \ topspace X. f x \ f ` U} = U" + using \U \ topspace X\ assms inj_onD by fastforce + ultimately show "openin X' (f ` U)" + using L unfolding quotient_map_def + by (metis (no_types, lifting) Collect_cong \openin X U\ image_mono) + qed + moreover have "closed_map X X' f" + proof (clarsimp simp add: closed_map_def) + fix U + assume "closedin X U" + then have "U \ topspace X" + by (simp add: closedin_subset) + moreover have "{x \ topspace X. f x \ f ` U} = U" + using \U \ topspace X\ assms inj_onD by fastforce + ultimately show "closedin X' (f ` U)" + using L unfolding quotient_map_closedin + by (metis (no_types, lifting) Collect_cong \closedin X U\ image_mono) + qed + ultimately show ?rhs + using L by (simp add: quotient_imp_continuous_map quotient_imp_surjective_map) +next + assume ?rhs + then show ?lhs + by (simp add: continuous_closed_imp_quotient_map) +qed + +lemma continuous_compose_quotient_map: + assumes f: "quotient_map X X' f" and g: "continuous_map X X'' (g \ f)" + shows "continuous_map X' X'' g" + unfolding quotient_map_def continuous_map_def +proof (intro conjI ballI allI impI) + show "\x'. x' \ topspace X' \ g x' \ topspace X''" + using assms unfolding quotient_map_def + by (metis (no_types, hide_lams) continuous_map_image_subset_topspace image_comp image_subset_iff) +next + fix U'' :: "'c set" + assume U'': "openin X'' U''" + have "f ` topspace X = topspace X'" + by (simp add: f quotient_imp_surjective_map) + then have eq: "{x \ topspace X. f x \ topspace X' \ g (f x) \ U} = {x \ topspace X. g (f x) \ U}" for U + by auto + have "openin X {x \ topspace X. f x \ topspace X' \ g (f x) \ U''}" + unfolding eq using U'' g openin_continuous_map_preimage by fastforce + then have *: "openin X {x \ topspace X. f x \ {x \ topspace X'. g x \ U''}}" + by auto + show "openin X' {x \ topspace X'. g x \ U''}" + using f unfolding quotient_map_def + by (metis (no_types) Collect_subset *) +qed + +lemma continuous_compose_quotient_map_eq: + "quotient_map X X' f \ continuous_map X X'' (g \ f) \ continuous_map X' X'' g" + using continuous_compose_quotient_map continuous_map_compose quotient_imp_continuous_map by blast + +lemma quotient_map_compose_eq: + "quotient_map X X' f \ quotient_map X X'' (g \ f) \ quotient_map X' X'' g" + apply safe + apply (meson continuous_compose_quotient_map_eq quotient_imp_continuous_map quotient_map_from_composition) + by (simp add: quotient_map_compose) + +lemma quotient_map_restriction: + assumes quo: "quotient_map X Y f" and U: "{x \ topspace X. f x \ V} = U" and disj: "openin Y V \ closedin Y V" + shows "quotient_map (subtopology X U) (subtopology Y V) f" + using disj +proof + assume V: "openin Y V" + with U have sub: "U \ topspace X" "V \ topspace Y" + by (auto simp: openin_subset) + have fim: "f ` topspace X = topspace Y" + and Y: "\U. U \ topspace Y \ openin X {x \ topspace X. f x \ U} = openin Y U" + using quo unfolding quotient_map_def by auto + have "openin X U" + using U V Y sub(2) by blast + show ?thesis + unfolding quotient_map_def + proof (intro conjI allI impI) + show "f ` topspace (subtopology X U) = topspace (subtopology Y V)" + using sub U fim by (auto simp: topspace_subtopology) + next + fix Y' :: "'b set" + assume "Y' \ topspace (subtopology Y V)" + then have "Y' \ topspace Y" "Y' \ V" + by (simp_all add: topspace_subtopology) + then have eq: "{x \ topspace X. x \ U \ f x \ Y'} = {x \ topspace X. f x \ Y'}" + using U by blast + then show "openin (subtopology X U) {x \ topspace (subtopology X U). f x \ Y'} = openin (subtopology Y V) Y'" + using U V Y \openin X U\ \Y' \ topspace Y\ \Y' \ V\ + by (simp add: topspace_subtopology openin_open_subtopology eq) (auto simp: openin_closedin_eq) + qed +next + assume V: "closedin Y V" + with U have sub: "U \ topspace X" "V \ topspace Y" + by (auto simp: closedin_subset) + have fim: "f ` topspace X = topspace Y" + and Y: "\U. U \ topspace Y \ closedin X {x \ topspace X. f x \ U} = closedin Y U" + using quo unfolding quotient_map_closedin by auto + have "closedin X U" + using U V Y sub(2) by blast + show ?thesis + unfolding quotient_map_closedin + proof (intro conjI allI impI) + show "f ` topspace (subtopology X U) = topspace (subtopology Y V)" + using sub U fim by (auto simp: topspace_subtopology) + next + fix Y' :: "'b set" + assume "Y' \ topspace (subtopology Y V)" + then have "Y' \ topspace Y" "Y' \ V" + by (simp_all add: topspace_subtopology) + then have eq: "{x \ topspace X. x \ U \ f x \ Y'} = {x \ topspace X. f x \ Y'}" + using U by blast + then show "closedin (subtopology X U) {x \ topspace (subtopology X U). f x \ Y'} = closedin (subtopology Y V) Y'" + using U V Y \closedin X U\ \Y' \ topspace Y\ \Y' \ V\ + by (simp add: topspace_subtopology closedin_closed_subtopology eq) (auto simp: closedin_def) + qed +qed + +lemma quotient_map_saturated_open: + "quotient_map X Y f \ + continuous_map X Y f \ f ` (topspace X) = topspace Y \ + (\U. openin X U \ {x \ topspace X. f x \ f ` U} \ U \ openin Y (f ` U))" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + then have fim: "f ` topspace X = topspace Y" + and Y: "\U. U \ topspace Y \ openin Y U = openin X {x \ topspace X. f x \ U}" + unfolding quotient_map_def by auto + show ?rhs + proof (intro conjI allI impI) + show "continuous_map X Y f" + by (simp add: L quotient_imp_continuous_map) + show "f ` topspace X = topspace Y" + by (simp add: fim) + next + fix U :: "'a set" + assume U: "openin X U \ {x \ topspace X. f x \ f ` U} \ U" + then have sub: "f ` U \ topspace Y" and eq: "{x \ topspace X. f x \ f ` U} = U" + using fim openin_subset by fastforce+ + show "openin Y (f ` U)" + by (simp add: sub Y eq U) + qed +next + assume ?rhs + then have YX: "\U. openin Y U \ openin X {x \ topspace X. f x \ U}" + and fim: "f ` topspace X = topspace Y" + and XY: "\U. \openin X U; {x \ topspace X. f x \ f ` U} \ U\ \ openin Y (f ` U)" + by (auto simp: quotient_map_def continuous_map_def) + show ?lhs + proof (simp add: quotient_map_def fim, intro allI impI iffI) + fix U :: "'b set" + assume "U \ topspace Y" and X: "openin X {x \ topspace X. f x \ U}" + have feq: "f ` {x \ topspace X. f x \ U} = U" + using \U \ topspace Y\ fim by auto + show "openin Y U" + using XY [OF X] by (simp add: feq) + next + fix U :: "'b set" + assume "U \ topspace Y" and Y: "openin Y U" + show "openin X {x \ topspace X. f x \ U}" + by (metis YX [OF Y]) + qed +qed + +subsection\ Separated Sets\ + +definition separatedin :: "'a topology \ 'a set \ 'a set \ bool" + where "separatedin X S T \ + S \ topspace X \ T \ topspace X \ + S \ X closure_of T = {} \ T \ X closure_of S = {}" + +lemma separatedin_empty [simp]: + "separatedin X S {} \ S \ topspace X" + "separatedin X {} S \ S \ topspace X" + by (simp_all add: separatedin_def) + +lemma separatedin_refl [simp]: + "separatedin X S S \ S = {}" +proof - + have "\x. \separatedin X S S; x \ S\ \ False" + by (metis all_not_in_conv closure_of_subset inf.orderE separatedin_def) + then show ?thesis + by auto +qed + +lemma separatedin_sym: + "separatedin X S T \ separatedin X T S" + by (auto simp: separatedin_def) + +lemma separatedin_imp_disjoint: + "separatedin X S T \ disjnt S T" + by (meson closure_of_subset disjnt_def disjnt_subset2 separatedin_def) + +lemma separatedin_mono: + "\separatedin X S T; S' \ S; T' \ T\ \ separatedin X S' T'" + unfolding separatedin_def + using closure_of_mono by blast + +lemma separatedin_open_sets: + "\openin X S; openin X T\ \ separatedin X S T \ disjnt S T" + unfolding disjnt_def separatedin_def + by (auto simp: openin_Int_closure_of_eq_empty openin_subset) + +lemma separatedin_closed_sets: + "\closedin X S; closedin X T\ \ separatedin X S T \ disjnt S T" + by (metis closedin_def closure_of_eq disjnt_def inf_commute separatedin_def) + +lemma separatedin_subtopology: + "separatedin (subtopology X U) S T \ S \ U \ T \ U \ separatedin X S T" + apply (simp add: separatedin_def closure_of_subtopology topspace_subtopology) + apply (safe; metis Int_absorb1 inf.assoc inf.orderE insert_disjoint(2) mk_disjoint_insert) + done + +lemma separatedin_discrete_topology: + "separatedin (discrete_topology U) S T \ S \ U \ T \ U \ disjnt S T" + by (metis openin_discrete_topology separatedin_def separatedin_open_sets topspace_discrete_topology) + +lemma separated_eq_distinguishable: + "separatedin X {x} {y} \ + x \ topspace X \ y \ topspace X \ + (\U. openin X U \ x \ U \ (y \ U)) \ + (\v. openin X v \ y \ v \ (x \ v))" + by (force simp: separatedin_def closure_of_def) + +lemma separatedin_Un [simp]: + "separatedin X S (T \ U) \ separatedin X S T \ separatedin X S U" + "separatedin X (S \ T) U \ separatedin X S U \ separatedin X T U" + by (auto simp: separatedin_def) + +lemma separatedin_Union: + "finite \ \ separatedin X S (\\) \ S \ topspace X \ (\T \ \. separatedin X S T)" + "finite \ \ separatedin X (\\) S \ (\T \ \. separatedin X S T) \ S \ topspace X" + by (auto simp: separatedin_def closure_of_Union) + +lemma separatedin_openin_diff: + "\openin X S; openin X T\ \ separatedin X (S - T) (T - S)" + unfolding separatedin_def + apply (intro conjI) + apply (meson Diff_subset openin_subset subset_trans)+ + using openin_Int_closure_of_eq_empty by fastforce+ + +lemma separatedin_closedin_diff: + "\closedin X S; closedin X T\ \ separatedin X (S - T) (T - S)" + apply (simp add: separatedin_def Diff_Int_distrib2 Diff_subset closure_of_minimal inf_absorb2) + apply (meson Diff_subset closedin_subset subset_trans) + done + +lemma separation_closedin_Un_gen: + "separatedin X S T \ + S \ topspace X \ T \ topspace X \ disjnt S T \ + closedin (subtopology X (S \ T)) S \ + closedin (subtopology X (S \ T)) T" + apply (simp add: separatedin_def closedin_Int_closure_of disjnt_iff) + using closure_of_subset apply blast + done + +lemma separation_openin_Un_gen: + "separatedin X S T \ + S \ topspace X \ T \ topspace X \ disjnt S T \ + openin (subtopology X (S \ T)) S \ + openin (subtopology X (S \ T)) T" + unfolding openin_closedin_eq topspace_subtopology separation_closedin_Un_gen disjnt_def + by (auto simp: Diff_triv Int_commute Un_Diff inf_absorb1 topspace_def) + + +subsection\Homeomorphisms\ +text\(1-way and 2-way versions may be useful in places)\ + +definition homeomorphic_map :: "'a topology \ 'b topology \ ('a \ 'b) \ bool" + where + "homeomorphic_map X Y f \ quotient_map X Y f \ inj_on f (topspace X)" + +definition homeomorphic_maps :: "'a topology \ 'b topology \ ('a \ 'b) \ ('b \ 'a) \ bool" + where + "homeomorphic_maps X Y f g \ + continuous_map X Y f \ continuous_map Y X g \ + (\x \ topspace X. g(f x) = x) \ (\y \ topspace Y. f(g y) = y)" + + +lemma homeomorphic_map_eq: + "\homeomorphic_map X Y f; \x. x \ topspace X \ f x = g x\ \ homeomorphic_map X Y g" + by (meson homeomorphic_map_def inj_on_cong quotient_map_eq) + +lemma homeomorphic_maps_eq: + "\homeomorphic_maps X Y f g; + \x. x \ topspace X \ f x = f' x; \y. y \ topspace Y \ g y = g' y\ + \ homeomorphic_maps X Y f' g'" + apply (simp add: homeomorphic_maps_def) + by (metis continuous_map_eq continuous_map_eq_image_closure_subset_gen image_subset_iff) + +lemma homeomorphic_maps_sym: + "homeomorphic_maps X Y f g \ homeomorphic_maps Y X g f" + by (auto simp: homeomorphic_maps_def) + +lemma homeomorphic_maps_id: + "homeomorphic_maps X Y id id \ Y = X" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + then have "topspace X = topspace Y" + by (auto simp: homeomorphic_maps_def continuous_map_def) + with L show ?rhs + unfolding homeomorphic_maps_def + by (metis topology_finer_continuous_id topology_eq) +next + assume ?rhs + then show ?lhs + unfolding homeomorphic_maps_def by auto +qed + +lemma homeomorphic_map_id [simp]: "homeomorphic_map X Y id \ Y = X" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + then have eq: "topspace X = topspace Y" + by (auto simp: homeomorphic_map_def continuous_map_def quotient_map_def) + then have "\S. openin X S \ openin Y S" + by (meson L homeomorphic_map_def injective_quotient_map topology_finer_open_id) + then show ?rhs + using L unfolding homeomorphic_map_def + by (metis eq quotient_imp_continuous_map topology_eq topology_finer_continuous_id) +next + assume ?rhs + then show ?lhs + unfolding homeomorphic_map_def + by (simp add: closed_map_id continuous_closed_imp_quotient_map) +qed + +lemma homeomorphic_maps_i [simp]:"homeomorphic_maps X Y id id \ Y = X" + by (metis (full_types) eq_id_iff homeomorphic_maps_id) + +lemma homeomorphic_map_i [simp]: "homeomorphic_map X Y id \ Y = X" + by (metis (no_types) eq_id_iff homeomorphic_map_id) + +lemma homeomorphic_map_compose: + assumes "homeomorphic_map X Y f" "homeomorphic_map Y X'' g" + shows "homeomorphic_map X X'' (g \ f)" +proof - + have "inj_on g (f ` topspace X)" + by (metis (no_types) assms homeomorphic_map_def quotient_imp_surjective_map) + then show ?thesis + using assms by (meson comp_inj_on homeomorphic_map_def quotient_map_compose_eq) +qed + +lemma homeomorphic_maps_compose: + "homeomorphic_maps X Y f h \ + homeomorphic_maps Y X'' g k + \ homeomorphic_maps X X'' (g \ f) (h \ k)" + unfolding homeomorphic_maps_def + by (auto simp: continuous_map_compose; simp add: continuous_map_def) + +lemma homeomorphic_eq_everything_map: + "homeomorphic_map X Y f \ + continuous_map X Y f \ open_map X Y f \ closed_map X Y f \ + f ` (topspace X) = topspace Y \ inj_on f (topspace X)" + unfolding homeomorphic_map_def + by (force simp: injective_quotient_map intro: injective_quotient_map) + +lemma homeomorphic_imp_continuous_map: + "homeomorphic_map X Y f \ continuous_map X Y f" + by (simp add: homeomorphic_eq_everything_map) + +lemma homeomorphic_imp_open_map: + "homeomorphic_map X Y f \ open_map X Y f" + by (simp add: homeomorphic_eq_everything_map) + +lemma homeomorphic_imp_closed_map: + "homeomorphic_map X Y f \ closed_map X Y f" + by (simp add: homeomorphic_eq_everything_map) + +lemma homeomorphic_imp_surjective_map: + "homeomorphic_map X Y f \ f ` (topspace X) = topspace Y" + by (simp add: homeomorphic_eq_everything_map) + +lemma homeomorphic_imp_injective_map: + "homeomorphic_map X Y f \ inj_on f (topspace X)" + by (simp add: homeomorphic_eq_everything_map) + +lemma bijective_open_imp_homeomorphic_map: + "\continuous_map X Y f; open_map X Y f; f ` (topspace X) = topspace Y; inj_on f (topspace X)\ + \ homeomorphic_map X Y f" + by (simp add: homeomorphic_map_def continuous_open_imp_quotient_map) + +lemma bijective_closed_imp_homeomorphic_map: + "\continuous_map X Y f; closed_map X Y f; f ` (topspace X) = topspace Y; inj_on f (topspace X)\ + \ homeomorphic_map X Y f" + by (simp add: continuous_closed_quotient_map homeomorphic_map_def) + +lemma open_eq_continuous_inverse_map: + assumes X: "\x. x \ topspace X \ f x \ topspace Y \ g(f x) = x" + and Y: "\y. y \ topspace Y \ g y \ topspace X \ f(g y) = y" + shows "open_map X Y f \ continuous_map Y X g" +proof - + have eq: "{x \ topspace Y. g x \ U} = f ` U" if "openin X U" for U + using openin_subset [OF that] by (force simp: X Y image_iff) + show ?thesis + by (auto simp: Y open_map_def continuous_map_def eq) +qed + +lemma closed_eq_continuous_inverse_map: + assumes X: "\x. x \ topspace X \ f x \ topspace Y \ g(f x) = x" + and Y: "\y. y \ topspace Y \ g y \ topspace X \ f(g y) = y" + shows "closed_map X Y f \ continuous_map Y X g" +proof - + have eq: "{x \ topspace Y. g x \ U} = f ` U" if "closedin X U" for U + using closedin_subset [OF that] by (force simp: X Y image_iff) + show ?thesis + by (auto simp: Y closed_map_def continuous_map_closedin eq) +qed + +lemma homeomorphic_maps_map: + "homeomorphic_maps X Y f g \ + homeomorphic_map X Y f \ homeomorphic_map Y X g \ + (\x \ topspace X. g(f x) = x) \ (\y \ topspace Y. f(g y) = y)" + (is "?lhs = ?rhs") +proof + assume ?lhs + then have L: "continuous_map X Y f" "continuous_map Y X g" "\x\topspace X. g (f x) = x" "\x'\topspace Y. f (g x') = x'" + by (auto simp: homeomorphic_maps_def) + show ?rhs + proof (intro conjI bijective_open_imp_homeomorphic_map L) + show "open_map X Y f" + using L using open_eq_continuous_inverse_map [of concl: X Y f g] by (simp add: continuous_map_def) + show "open_map Y X g" + using L using open_eq_continuous_inverse_map [of concl: Y X g f] by (simp add: continuous_map_def) + show "f ` topspace X = topspace Y" "g ` topspace Y = topspace X" + using L by (force simp: continuous_map_closedin)+ + show "inj_on f (topspace X)" "inj_on g (topspace Y)" + using L unfolding inj_on_def by metis+ + qed +next + assume ?rhs + then show ?lhs + by (auto simp: homeomorphic_maps_def homeomorphic_imp_continuous_map) +qed + +lemma homeomorphic_maps_imp_map: + "homeomorphic_maps X Y f g \ homeomorphic_map X Y f" + using homeomorphic_maps_map by blast + +lemma homeomorphic_map_maps: + "homeomorphic_map X Y f \ (\g. homeomorphic_maps X Y f g)" + (is "?lhs = ?rhs") +proof + assume ?lhs + then have L: "continuous_map X Y f" "open_map X Y f" "closed_map X Y f" + "f ` (topspace X) = topspace Y" "inj_on f (topspace X)" + by (auto simp: homeomorphic_eq_everything_map) + have X: "\x. x \ topspace X \ f x \ topspace Y \ inv_into (topspace X) f (f x) = x" + using L by auto + have Y: "\y. y \ topspace Y \ inv_into (topspace X) f y \ topspace X \ f (inv_into (topspace X) f y) = y" + by (simp add: L f_inv_into_f inv_into_into) + have "homeomorphic_maps X Y f (inv_into (topspace X) f)" + unfolding homeomorphic_maps_def + proof (intro conjI L) + show "continuous_map Y X (inv_into (topspace X) f)" + by (simp add: L X Y flip: open_eq_continuous_inverse_map [where f=f]) + next + show "\x\topspace X. inv_into (topspace X) f (f x) = x" + "\y\topspace Y. f (inv_into (topspace X) f y) = y" + using X Y by auto + qed + then show ?rhs + by metis +next + assume ?rhs + then show ?lhs + using homeomorphic_maps_map by blast +qed + +lemma homeomorphic_maps_involution: + "\continuous_map X X f; \x. x \ topspace X \ f(f x) = x\ \ homeomorphic_maps X X f f" + by (auto simp: homeomorphic_maps_def) + +lemma homeomorphic_map_involution: + "\continuous_map X X f; \x. x \ topspace X \ f(f x) = x\ \ homeomorphic_map X X f" + using homeomorphic_maps_involution homeomorphic_maps_map by blast + +lemma homeomorphic_map_openness: + assumes hom: "homeomorphic_map X Y f" and U: "U \ topspace X" + shows "openin Y (f ` U) \ openin X U" +proof - + obtain g where "homeomorphic_maps X Y f g" + using assms by (auto simp: homeomorphic_map_maps) + then have g: "homeomorphic_map Y X g" and gf: "\x. x \ topspace X \ g(f x) = x" + by (auto simp: homeomorphic_maps_map) + then have "openin X U \ openin Y (f ` U)" + using hom homeomorphic_imp_open_map open_map_def by blast + show "openin Y (f ` U) = openin X U" + proof + assume L: "openin Y (f ` U)" + have "U = g ` (f ` U)" + using U gf by force + then show "openin X U" + by (metis L homeomorphic_imp_open_map open_map_def g) + next + assume "openin X U" + then show "openin Y (f ` U)" + using hom homeomorphic_imp_open_map open_map_def by blast + qed +qed + + +lemma homeomorphic_map_closedness: + assumes hom: "homeomorphic_map X Y f" and U: "U \ topspace X" + shows "closedin Y (f ` U) \ closedin X U" +proof - + obtain g where "homeomorphic_maps X Y f g" + using assms by (auto simp: homeomorphic_map_maps) + then have g: "homeomorphic_map Y X g" and gf: "\x. x \ topspace X \ g(f x) = x" + by (auto simp: homeomorphic_maps_map) + then have "closedin X U \ closedin Y (f ` U)" + using hom homeomorphic_imp_closed_map closed_map_def by blast + show "closedin Y (f ` U) = closedin X U" + proof + assume L: "closedin Y (f ` U)" + have "U = g ` (f ` U)" + using U gf by force + then show "closedin X U" + by (metis L homeomorphic_imp_closed_map closed_map_def g) + next + assume "closedin X U" + then show "closedin Y (f ` U)" + using hom homeomorphic_imp_closed_map closed_map_def by blast + qed +qed + +lemma homeomorphic_map_openness_eq: + "homeomorphic_map X Y f \ openin X U \ U \ topspace X \ openin Y (f ` U)" + by (meson homeomorphic_map_openness openin_closedin_eq) + +lemma homeomorphic_map_closedness_eq: + "homeomorphic_map X Y f \ closedin X U \ U \ topspace X \ closedin Y (f ` U)" + by (meson closedin_subset homeomorphic_map_closedness) + +lemma all_openin_homeomorphic_image: + assumes "homeomorphic_map X Y f" + shows "(\V. openin Y V \ P V) \ (\U. openin X U \ P(f ` U))" (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + by (meson assms homeomorphic_map_openness_eq) +next + assume ?rhs + then show ?lhs + by (metis (no_types, lifting) assms homeomorphic_imp_surjective_map homeomorphic_map_openness openin_subset subset_image_iff) +qed + +lemma all_closedin_homeomorphic_image: + assumes "homeomorphic_map X Y f" + shows "(\V. closedin Y V \ P V) \ (\U. closedin X U \ P(f ` U))" (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + by (meson assms homeomorphic_map_closedness_eq) +next + assume ?rhs + then show ?lhs + by (metis (no_types, lifting) assms homeomorphic_imp_surjective_map homeomorphic_map_closedness closedin_subset subset_image_iff) +qed + + +lemma homeomorphic_map_derived_set_of: + assumes hom: "homeomorphic_map X Y f" and S: "S \ topspace X" + shows "Y derived_set_of (f ` S) = f ` (X derived_set_of S)" +proof - + have fim: "f ` (topspace X) = topspace Y" and inj: "inj_on f (topspace X)" + using hom by (auto simp: homeomorphic_eq_everything_map) + have iff: "(\T. x \ T \ openin X T \ (\y. y \ x \ y \ S \ y \ T)) = + (\T. T \ topspace Y \ f x \ T \ openin Y T \ (\y. y \ f x \ y \ f ` S \ y \ T))" + if "x \ topspace X" for x + proof - + have 1: "(x \ T \ openin X T) = (T \ topspace X \ f x \ f ` T \ openin Y (f ` T))" for T + by (meson hom homeomorphic_map_openness_eq inj inj_on_image_mem_iff that) + have 2: "(\y. y \ x \ y \ S \ y \ T) = (\y. y \ f x \ y \ f ` S \ y \ f ` T)" (is "?lhs = ?rhs") + if "T \ topspace X \ f x \ f ` T \ openin Y (f ` T)" for T + proof + show "?lhs \ ?rhs" + by (meson "1" imageI inj inj_on_eq_iff inj_on_subset that) + show "?rhs \ ?lhs" + using S inj inj_onD that by fastforce + qed + show ?thesis + apply (simp flip: fim add: all_subset_image) + apply (simp flip: imp_conjL) + by (intro all_cong1 imp_cong 1 2) + qed + have *: "\T = f ` S; \x. x \ S \ P x \ Q(f x)\ \ {y. y \ T \ Q y} = f ` {x \ S. P x}" for T S P Q + by auto + show ?thesis + unfolding derived_set_of_def + apply (rule *) + using fim apply blast + using iff openin_subset by force +qed + + +lemma homeomorphic_map_closure_of: + assumes hom: "homeomorphic_map X Y f" and S: "S \ topspace X" + shows "Y closure_of (f ` S) = f ` (X closure_of S)" + unfolding closure_of + using homeomorphic_imp_surjective_map [OF hom] S + by (auto simp: in_derived_set_of homeomorphic_map_derived_set_of [OF assms]) + +lemma homeomorphic_map_interior_of: + assumes hom: "homeomorphic_map X Y f" and S: "S \ topspace X" + shows "Y interior_of (f ` S) = f ` (X interior_of S)" +proof - + { fix y + assume "y \ topspace Y" and "y \ Y closure_of (topspace Y - f ` S)" + then have "y \ f ` (topspace X - X closure_of (topspace X - S))" + using homeomorphic_eq_everything_map [THEN iffD1, OF hom] homeomorphic_map_closure_of [OF hom] + by (metis DiffI Diff_subset S closure_of_subset_topspace inj_on_image_set_diff) } + moreover + { fix x + assume "x \ topspace X" + then have "f x \ topspace Y" + using hom homeomorphic_imp_surjective_map by blast } + moreover + { fix x + assume "x \ topspace X" and "x \ X closure_of (topspace X - S)" and "f x \ Y closure_of (topspace Y - f ` S)" + then have "False" + using homeomorphic_map_closure_of [OF hom] hom + unfolding homeomorphic_eq_everything_map + by (metis (no_types, lifting) Diff_subset S closure_of_subset_topspace inj_on_image_mem_iff_alt inj_on_image_set_diff) } + ultimately show ?thesis + by (auto simp: interior_of_closure_of) +qed + +lemma homeomorphic_map_frontier_of: + assumes hom: "homeomorphic_map X Y f" and S: "S \ topspace X" + shows "Y frontier_of (f ` S) = f ` (X frontier_of S)" + unfolding frontier_of_def +proof (intro equalityI subsetI DiffI) + fix y + assume "y \ Y closure_of f ` S - Y interior_of f ` S" + then show "y \ f ` (X closure_of S - X interior_of S)" + using S hom homeomorphic_map_closure_of homeomorphic_map_interior_of by fastforce +next + fix y + assume "y \ f ` (X closure_of S - X interior_of S)" + then show "y \ Y closure_of f ` S" + using S hom homeomorphic_map_closure_of by fastforce +next + fix x + assume "x \ f ` (X closure_of S - X interior_of S)" + then obtain y where y: "x = f y" "y \ X closure_of S" "y \ X interior_of S" + by blast + then have "y \ topspace X" + by (simp add: in_closure_of) + then have "f y \ f ` (X interior_of S)" + by (meson hom homeomorphic_eq_everything_map inj_on_image_mem_iff_alt interior_of_subset_topspace y(3)) + then show "x \ Y interior_of f ` S" + using S hom homeomorphic_map_interior_of y(1) by blast +qed + +lemma homeomorphic_maps_subtopologies: + "\homeomorphic_maps X Y f g; f ` (topspace X \ S) = topspace Y \ T\ + \ homeomorphic_maps (subtopology X S) (subtopology Y T) f g" + unfolding homeomorphic_maps_def + by (force simp: continuous_map_from_subtopology topspace_subtopology continuous_map_in_subtopology) + +lemma homeomorphic_maps_subtopologies_alt: + "\homeomorphic_maps X Y f g; f ` (topspace X \ S) \ T; g ` (topspace Y \ T) \ S\ + \ homeomorphic_maps (subtopology X S) (subtopology Y T) f g" + unfolding homeomorphic_maps_def + by (force simp: continuous_map_from_subtopology topspace_subtopology continuous_map_in_subtopology) + +lemma homeomorphic_map_subtopologies: + "\homeomorphic_map X Y f; f ` (topspace X \ S) = topspace Y \ T\ + \ homeomorphic_map (subtopology X S) (subtopology Y T) f" + by (meson homeomorphic_map_maps homeomorphic_maps_subtopologies) + +lemma homeomorphic_map_subtopologies_alt: + "\homeomorphic_map X Y f; + \x. \x \ topspace X; f x \ topspace Y\ \ f x \ T \ x \ S\ + \ homeomorphic_map (subtopology X S) (subtopology Y T) f" + unfolding homeomorphic_map_maps + apply (erule ex_forward) + apply (rule homeomorphic_maps_subtopologies) + apply (auto simp: homeomorphic_maps_def continuous_map_def) + by (metis IntI image_iff) + + +subsection\Relation of homeomorphism between topological spaces\ + +definition homeomorphic_space (infixr "homeomorphic'_space" 50) + where "X homeomorphic_space Y \ \f g. homeomorphic_maps X Y f g" + +lemma homeomorphic_space_refl: "X homeomorphic_space X" + by (meson homeomorphic_maps_id homeomorphic_space_def) + +lemma homeomorphic_space_sym: + "X homeomorphic_space Y \ Y homeomorphic_space X" + unfolding homeomorphic_space_def by (metis homeomorphic_maps_sym) + +lemma homeomorphic_space_trans: + "\X1 homeomorphic_space X2; X2 homeomorphic_space X3\ \ X1 homeomorphic_space X3" + unfolding homeomorphic_space_def by (metis homeomorphic_maps_compose) + +lemma homeomorphic_space: + "X homeomorphic_space Y \ (\f. homeomorphic_map X Y f)" + by (simp add: homeomorphic_map_maps homeomorphic_space_def) + +lemma homeomorphic_maps_imp_homeomorphic_space: + "homeomorphic_maps X Y f g \ X homeomorphic_space Y" + unfolding homeomorphic_space_def by metis + +lemma homeomorphic_map_imp_homeomorphic_space: + "homeomorphic_map X Y f \ X homeomorphic_space Y" + unfolding homeomorphic_map_maps + using homeomorphic_space_def by blast + +lemma homeomorphic_empty_space: + "X homeomorphic_space Y \ topspace X = {} \ topspace Y = {}" + by (metis homeomorphic_imp_surjective_map homeomorphic_space image_is_empty) + +lemma homeomorphic_empty_space_eq: + assumes "topspace X = {}" + shows "X homeomorphic_space Y \ topspace Y = {}" +proof - + have "\f t. continuous_map X (t::'b topology) f" + using assms continuous_map_on_empty by blast + then show ?thesis + by (metis (no_types) assms continuous_map_on_empty empty_iff homeomorphic_empty_space homeomorphic_maps_def homeomorphic_space_def) +qed + +subsection\Connected topological spaces\ + +definition connected_space :: "'a topology \ bool" where + "connected_space X \ + ~(\E1 E2. openin X E1 \ openin X E2 \ + topspace X \ E1 \ E2 \ E1 \ E2 = {} \ E1 \ {} \ E2 \ {})" + +definition connectedin :: "'a topology \ 'a set \ bool" where + "connectedin X S \ S \ topspace X \ connected_space (subtopology X S)" + +lemma connectedin_subset_topspace: "connectedin X S \ S \ topspace X" + by (simp add: connectedin_def) + +lemma connectedin_topspace: + "connectedin X (topspace X) \ connected_space X" + by (simp add: connectedin_def) + +lemma connected_space_subtopology: + "connectedin X S \ connected_space (subtopology X S)" + by (simp add: connectedin_def) + +lemma connectedin_subtopology: + "connectedin (subtopology X S) T \ connectedin X T \ T \ S" + by (force simp: connectedin_def subtopology_subtopology topspace_subtopology inf_absorb2) + +lemma connected_space_eq: + "connected_space X \ + (\E1 E2. openin X E1 \ openin X E2 \ E1 \ E2 = topspace X \ E1 \ E2 = {} \ E1 \ {} \ E2 \ {})" + unfolding connected_space_def + by (metis openin_Un openin_subset subset_antisym) + +lemma connected_space_closedin: + "connected_space X \ + (\E1 E2. closedin X E1 \ closedin X E2 \ topspace X \ E1 \ E2 \ + E1 \ E2 = {} \ E1 \ {} \ E2 \ {})" (is "?lhs = ?rhs") +proof + assume ?lhs + then have L: "\E1 E2. \openin X E1; E1 \ E2 = {}; topspace X \ E1 \ E2; openin X E2\ \ E1 = {} \ E2 = {}" + by (simp add: connected_space_def) + show ?rhs + unfolding connected_space_def + proof clarify + fix E1 E2 + assume "closedin X E1" and "closedin X E2" and "topspace X \ E1 \ E2" and "E1 \ E2 = {}" + and "E1 \ {}" and "E2 \ {}" + have "E1 \ E2 = topspace X" + by (meson Un_subset_iff \closedin X E1\ \closedin X E2\ \topspace X \ E1 \ E2\ closedin_def subset_antisym) + then have "topspace X - E2 = E1" + using \E1 \ E2 = {}\ by fastforce + then have "topspace X = E1" + using \E1 \ {}\ L \closedin X E1\ \closedin X E2\ by blast + then show "False" + using \E1 \ E2 = {}\ \E1 \ E2 = topspace X\ \E2 \ {}\ by blast + qed +next + assume R: ?rhs + show ?lhs + unfolding connected_space_def + proof clarify + fix E1 E2 + assume "openin X E1" and "openin X E2" and "topspace X \ E1 \ E2" and "E1 \ E2 = {}" + and "E1 \ {}" and "E2 \ {}" + have "E1 \ E2 = topspace X" + by (meson Un_subset_iff \openin X E1\ \openin X E2\ \topspace X \ E1 \ E2\ openin_closedin_eq subset_antisym) + then have "topspace X - E2 = E1" + using \E1 \ E2 = {}\ by fastforce + then have "topspace X = E1" + using \E1 \ {}\ R \openin X E1\ \openin X E2\ by blast + then show "False" + using \E1 \ E2 = {}\ \E1 \ E2 = topspace X\ \E2 \ {}\ by blast + qed +qed + +lemma connected_space_closedin_eq: + "connected_space X \ + (\E1 E2. closedin X E1 \ closedin X E2 \ + E1 \ E2 = topspace X \ E1 \ E2 = {} \ E1 \ {} \ E2 \ {})" + apply (simp add: connected_space_closedin) + apply (intro all_cong) + using closedin_subset apply blast + done + +lemma connected_space_clopen_in: + "connected_space X \ + (\T. openin X T \ closedin X T \ T = {} \ T = topspace X)" +proof - + have eq: "openin X E1 \ openin X E2 \ E1 \ E2 = topspace X \ E1 \ E2 = {} \ P + \ E2 = topspace X - E1 \ openin X E1 \ openin X E2 \ P" for E1 E2 P + using openin_subset by blast + show ?thesis + unfolding connected_space_eq eq closedin_def + by (auto simp: openin_closedin_eq) +qed + +lemma connectedin: + "connectedin X S \ + S \ topspace X \ + (\E1 E2. + openin X E1 \ openin X E2 \ + S \ E1 \ E2 \ E1 \ E2 \ S = {} \ E1 \ S \ {} \ E2 \ S \ {})" +proof - + have *: "(\E1:: 'a set. \E2:: 'a set. (\T1:: 'a set. P1 T1 \ E1 = f1 T1) \ (\T2:: 'a set. P2 T2 \ E2 = f2 T2) \ + R E1 E2) \ (\T1 T2. P1 T1 \ P2 T2 \ R(f1 T1) (f2 T2))" for P1 f1 P2 f2 R + by auto + show ?thesis + unfolding connectedin_def connected_space_def openin_subtopology topspace_subtopology Not_eq_iff * + apply (intro conj_cong arg_cong [where f=Not] ex_cong1 refl) + apply (blast elim: dest!: openin_subset)+ + done +qed + +lemma connectedin_iff_connected_real [simp]: + "connectedin euclideanreal S \ connected S" + by (simp add: connected_def connectedin) + +lemma connectedin_closedin: + "connectedin X S \ + S \ topspace X \ + ~(\E1 E2. closedin X E1 \ closedin X E2 \ + S \ (E1 \ E2) \ + (E1 \ E2 \ S = {}) \ + ~(E1 \ S = {}) \ ~(E2 \ S = {}))" +proof - + have *: "(\E1:: 'a set. \E2:: 'a set. (\T1:: 'a set. P1 T1 \ E1 = f1 T1) \ (\T2:: 'a set. P2 T2 \ E2 = f2 T2) \ + R E1 E2) \ (\T1 T2. P1 T1 \ P2 T2 \ R(f1 T1) (f2 T2))" for P1 f1 P2 f2 R + by auto + show ?thesis + unfolding connectedin_def connected_space_closedin closedin_subtopology topspace_subtopology Not_eq_iff * + apply (intro conj_cong arg_cong [where f=Not] ex_cong1 refl) + apply (blast elim: dest!: openin_subset)+ + done +qed + +lemma connectedin_empty [simp]: "connectedin X {}" + by (simp add: connectedin) + +lemma connected_space_topspace_empty: + "topspace X = {} \ connected_space X" + using connectedin_topspace by fastforce + +lemma connectedin_sing [simp]: "connectedin X {a} \ a \ topspace X" + by (simp add: connectedin) + +lemma connectedin_absolute [simp]: + "connectedin (subtopology X S) S \ connectedin X S" + apply (simp only: connectedin_def topspace_subtopology subtopology_subtopology) + apply (intro conj_cong imp_cong arg_cong [where f=Not] all_cong1 ex_cong1 refl) + by auto + +lemma connectedin_Union: + assumes \: "\S. S \ \ \ connectedin X S" and ne: "\\ \ {}" + shows "connectedin X (\\)" +proof - + have "\\ \ topspace X" + using \ by (simp add: Union_least connectedin_def) + moreover have False + if "openin X E1" "openin X E2" and cover: "\\ \ E1 \ E2" and disj: "E1 \ E2 \ \\ = {}" + and overlap1: "E1 \ \\ \ {}" and overlap2: "E2 \ \\ \ {}" + for E1 E2 + proof - + have disjS: "E1 \ E2 \ S = {}" if "S \ \" for S + using Diff_triv that disj by auto + have coverS: "S \ E1 \ E2" if "S \ \" for S + using that cover by blast + have "\ \ {}" + using overlap1 by blast + obtain a where a: "\U. U \ \ \ a \ U" + using ne by force + with \\ \ {}\ have "a \ \\" + by blast + then consider "a \ E1" | "a \ E2" + using \\\ \ E1 \ E2\ by auto + then show False + proof cases + case 1 + then obtain b S where "b \ E2" "b \ S" "S \ \" + using overlap2 by blast + then show ?thesis + using "1" \openin X E1\ \openin X E2\ disjS coverS a [OF \S \ \\] \[OF \S \ \\] + unfolding connectedin + by (meson disjoint_iff_not_equal) + next + case 2 + then obtain b S where "b \ E1" "b \ S" "S \ \" + using overlap1 by blast + then show ?thesis + using "2" \openin X E1\ \openin X E2\ disjS coverS a [OF \S \ \\] \[OF \S \ \\] + unfolding connectedin + by (meson disjoint_iff_not_equal) + qed + qed + ultimately show ?thesis + unfolding connectedin by blast +qed + +lemma connectedin_Un: + "\connectedin X S; connectedin X T; S \ T \ {}\ \ connectedin X (S \ T)" + using connectedin_Union [of "{S,T}"] by auto + +lemma connected_space_subconnected: + "connected_space X \ (\x \ topspace X. \y \ topspace X. \S. connectedin X S \ x \ S \ y \ S)" (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + using connectedin_topspace by blast +next + assume R [rule_format]: ?rhs + have False if "openin X U" "openin X V" and disj: "U \ V = {}" and cover: "topspace X \ U \ V" + and "U \ {}" "V \ {}" for U V + proof - + obtain u v where "u \ U" "v \ V" + using \U \ {}\ \V \ {}\ by auto + then obtain T where "u \ T" "v \ T" and T: "connectedin X T" + using R [of u v] that + by (meson \openin X U\ \openin X V\ subsetD openin_subset) + then show False + using that unfolding connectedin + by (metis IntI \u \ U\ \v \ V\ empty_iff inf_bot_left subset_trans) + qed + then show ?lhs + by (auto simp: connected_space_def) +qed + +lemma connectedin_intermediate_closure_of: + assumes "connectedin X S" "S \ T" "T \ X closure_of S" + shows "connectedin X T" +proof - + have S: "S \ topspace X"and T: "T \ topspace X" + using assms by (meson closure_of_subset_topspace dual_order.trans)+ + show ?thesis + using assms + apply (simp add: connectedin closure_of_subset_topspace S T) + apply (elim all_forward imp_forward2 asm_rl) + apply (blast dest: openin_Int_closure_of_eq_empty [of X _ S])+ + done +qed + +lemma connectedin_closure_of: + "connectedin X S \ connectedin X (X closure_of S)" + by (meson closure_of_subset connectedin_def connectedin_intermediate_closure_of subset_refl) + +lemma connectedin_separation: + "connectedin X S \ + S \ topspace X \ + (\C1 C2. C1 \ C2 = S \ C1 \ {} \ C2 \ {} \ C1 \ X closure_of C2 = {} \ C2 \ X closure_of C1 = {})" (is "?lhs = ?rhs") + unfolding connectedin_def connected_space_closedin_eq closedin_Int_closure_of topspace_subtopology + apply (intro conj_cong refl arg_cong [where f=Not]) + apply (intro ex_cong1 iffI, blast) + using closure_of_subset_Int by force + +lemma connectedin_eq_not_separated: + "connectedin X S \ + S \ topspace X \ + (\C1 C2. C1 \ C2 = S \ C1 \ {} \ C2 \ {} \ separatedin X C1 C2)" + apply (simp add: separatedin_def connectedin_separation) + apply (intro conj_cong all_cong1 refl, blast) + done + +lemma connectedin_eq_not_separated_subset: + "connectedin X S \ + S \ topspace X \ (\C1 C2. S \ C1 \ C2 \ S \ C1 \ {} \ S \ C2 \ {} \ separatedin X C1 C2)" +proof - + have *: "\C1 C2. S \ C1 \ C2 \ S \ C1 = {} \ S \ C2 = {} \ \ separatedin X C1 C2" + if "\C1 C2. C1 \ C2 = S \ C1 = {} \ C2 = {} \ \ separatedin X C1 C2" + proof (intro allI) + fix C1 C2 + show "S \ C1 \ C2 \ S \ C1 = {} \ S \ C2 = {} \ \ separatedin X C1 C2" + using that [of "S \ C1" "S \ C2"] + by (auto simp: separatedin_mono) + qed + show ?thesis + apply (simp add: connectedin_eq_not_separated) + apply (intro conj_cong refl iffI *) + apply (blast elim!: all_forward)+ + done +qed + +lemma connected_space_eq_not_separated: + "connected_space X \ + (\C1 C2. C1 \ C2 = topspace X \ C1 \ {} \ C2 \ {} \ separatedin X C1 C2)" + by (simp add: connectedin_eq_not_separated flip: connectedin_topspace) + +lemma connected_space_eq_not_separated_subset: + "connected_space X \ + (\C1 C2. topspace X \ C1 \ C2 \ C1 \ {} \ C2 \ {} \ separatedin X C1 C2)" + apply (simp add: connected_space_eq_not_separated) + apply (intro all_cong1) + by (metis Un_absorb dual_order.antisym separatedin_def subset_refl sup_mono) + +lemma connectedin_subset_separated_union: + "\connectedin X C; separatedin X S T; C \ S \ T\ \ C \ S \ C \ T" + unfolding connectedin_eq_not_separated_subset by blast + +lemma connectedin_nonseparated_union: + "\connectedin X S; connectedin X T; ~separatedin X S T\ \ connectedin X (S \ T)" + apply (simp add: connectedin_eq_not_separated_subset, auto) + apply (metis (no_types, hide_lams) Diff_subset_conv Diff_triv disjoint_iff_not_equal separatedin_mono sup_commute) + apply (metis (no_types, hide_lams) Diff_subset_conv Diff_triv disjoint_iff_not_equal separatedin_mono separatedin_sym sup_commute) + by (meson disjoint_iff_not_equal) + +lemma connected_space_closures: + "connected_space X \ + (\e1 e2. e1 \ e2 = topspace X \ X closure_of e1 \ X closure_of e2 = {} \ e1 \ {} \ e2 \ {})" + (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + unfolding connected_space_closedin_eq + by (metis Un_upper1 Un_upper2 closedin_closure_of closure_of_Un closure_of_eq_empty closure_of_topspace) +next + assume ?rhs + then show ?lhs + unfolding connected_space_closedin_eq + by (metis closure_of_eq) +qed + +lemma connectedin_inter_frontier_of: + assumes "connectedin X S" "S \ T \ {}" "S - T \ {}" + shows "S \ X frontier_of T \ {}" +proof - + have "S \ topspace X" and *: + "\E1 E2. openin X E1 \ openin X E2 \ E1 \ E2 \ S = {} \ S \ E1 \ E2 \ E1 \ S = {} \ E2 \ S = {}" + using \connectedin X S\ by (auto simp: connectedin) + have "S - (topspace X \ T) \ {}" + using assms(3) by blast + moreover + have "S \ topspace X \ T \ {}" + using assms(1) assms(2) connectedin by fastforce + moreover + have False if "S \ T \ {}" "S - T \ {}" "T \ topspace X" "S \ X frontier_of T = {}" for T + proof - + have null: "S \ (X closure_of T - X interior_of T) = {}" + using that unfolding frontier_of_def by blast + have 1: "X interior_of T \ (topspace X - X closure_of T) \ S = {}" + by (metis Diff_disjoint inf_bot_left interior_of_Int interior_of_complement interior_of_empty) + have 2: "S \ X interior_of T \ (topspace X - X closure_of T)" + using that \S \ topspace X\ null by auto + have 3: "S \ X interior_of T \ {}" + using closure_of_subset that(1) that(3) null by fastforce + show ?thesis + using null \S \ topspace X\ that * [of "X interior_of T" "topspace X - X closure_of T"] + apply (clarsimp simp add: openin_diff 1 2) + apply (simp add: Int_commute Diff_Int_distrib 3) + by (metis Int_absorb2 contra_subsetD interior_of_subset) + qed + ultimately show ?thesis + by (metis Int_lower1 frontier_of_restrict inf_assoc) +qed + +lemma connectedin_continuous_map_image: + assumes f: "continuous_map X Y f" and "connectedin X S" + shows "connectedin Y (f ` S)" +proof - + have "S \ topspace X" and *: + "\E1 E2. openin X E1 \ openin X E2 \ E1 \ E2 \ S = {} \ S \ E1 \ E2 \ E1 \ S = {} \ E2 \ S = {}" + using \connectedin X S\ by (auto simp: connectedin) + show ?thesis + unfolding connectedin connected_space_def + proof (intro conjI notI; clarify) + show "f x \ topspace Y" if "x \ S" for x + using \S \ topspace X\ continuous_map_image_subset_topspace f that by blast + next + fix U V + let ?U = "{x \ topspace X. f x \ U}" + let ?V = "{x \ topspace X. f x \ V}" + assume UV: "openin Y U" "openin Y V" "f ` S \ U \ V" "U \ V \ f ` S = {}" "U \ f ` S \ {}" "V \ f ` S \ {}" + then have 1: "?U \ ?V \ S = {}" + by auto + have 2: "openin X ?U" "openin X ?V" + using \openin Y U\ \openin Y V\ continuous_map f by fastforce+ + show "False" + using * [of ?U ?V] UV \S \ topspace X\ + by (auto simp: 1 2) + qed +qed + +lemma homeomorphic_connected_space: + "X homeomorphic_space Y \ connected_space X \ connected_space Y" + unfolding homeomorphic_space_def homeomorphic_maps_def + apply safe + apply (metis connectedin_continuous_map_image connected_space_subconnected continuous_map_image_subset_topspace image_eqI image_subset_iff) + 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) + +lemma homeomorphic_map_connectedness: + assumes f: "homeomorphic_map X Y f" and U: "U \ topspace X" + shows "connectedin Y (f ` U) \ connectedin X U" +proof - + have 1: "f ` U \ topspace Y \ U \ topspace X" + using U f homeomorphic_imp_surjective_map by blast + moreover have "connected_space (subtopology Y (f ` U)) \ connected_space (subtopology X U)" + proof (rule homeomorphic_connected_space) + have "f ` U \ topspace Y" + by (simp add: U 1) + then have "topspace Y \ f ` U = f ` U" + by (simp add: subset_antisym) + then show "subtopology Y (f ` U) homeomorphic_space subtopology X U" + by (metis (no_types) Int_subset_iff U f homeomorphic_map_imp_homeomorphic_space homeomorphic_map_subtopologies homeomorphic_space_sym subset_antisym subset_refl) + qed + ultimately show ?thesis + by (auto simp: connectedin_def) +qed + +lemma homeomorphic_map_connectedness_eq: + "homeomorphic_map X Y f + \ connectedin X U \ + U \ topspace X \ connectedin Y (f ` U)" + using homeomorphic_map_connectedness connectedin_subset_topspace by metis + +lemma connectedin_discrete_topology: + "connectedin (discrete_topology U) S \ S \ U \ (\a. S \ {a})" +proof (cases "S \ U") + case True + show ?thesis + proof (cases "S = {}") + case False + moreover have "connectedin (discrete_topology U) S \ (\a. S = {a})" + apply safe + using False connectedin_inter_frontier_of insert_Diff apply fastforce + using True by auto + ultimately show ?thesis + by auto + qed simp +next + case False + then show ?thesis + by (simp add: connectedin_def) +qed + +lemma connected_space_discrete_topology: + "connected_space (discrete_topology U) \ (\a. U \ {a})" + by (metis connectedin_discrete_topology connectedin_topspace order_refl topspace_discrete_topology) + + +subsection\Compact sets\ + +definition compactin where + "compactin X S \ + S \ topspace X \ + (\\. (\U \ \. openin X U) \ S \ \\ + \ (\\. finite \ \ \ \ \ \ S \ \\))" + +definition compact_space where + "compact_space X \ compactin X (topspace X)" + +lemma compact_space_alt: + "compact_space X \ + (\\. (\U \ \. openin X U) \ topspace X \ \\ + \ (\\. finite \ \ \ \ \ \ topspace X \ \\))" + by (simp add: compact_space_def compactin_def) + +lemma compact_space: + "compact_space X \ + (\\. (\U \ \. openin X U) \ \\ = topspace X + \ (\\. finite \ \ \ \ \ \ \\ = topspace X))" + unfolding compact_space_alt + using openin_subset by fastforce + +lemma compactin_euclideanreal_iff [simp]: "compactin euclideanreal S \ compact S" + by (simp add: compact_eq_heine_borel compactin_def) meson + +lemma compactin_absolute [simp]: + "compactin (subtopology X S) S \ compactin X S" +proof - + have eq: "(\U \ \. \Y. openin X Y \ U = Y \ S) \ \ \ (\Y. Y \ S) ` {y. openin X y}" for \ + by auto + show ?thesis + by (auto simp: compactin_def topspace_subtopology openin_subtopology eq imp_conjL all_subset_image exists_finite_subset_image) +qed + +lemma compactin_subspace: "compactin X S \ S \ topspace X \ compact_space (subtopology X S)" + unfolding compact_space_def topspace_subtopology + by (metis compactin_absolute compactin_def inf.absorb2) + +lemma compact_space_subtopology: "compactin X S \ compact_space (subtopology X S)" + by (simp add: compactin_subspace) + +lemma compactin_subtopology: "compactin (subtopology X S) T \ compactin X T \ T \ S" +apply (simp add: compactin_subspace topspace_subtopology) + by (metis inf.orderE inf_commute subtopology_subtopology) + + +lemma compactin_subset_topspace: "compactin X S \ S \ topspace X" + by (simp add: compactin_subspace) + +lemma compactin_contractive: + "\compactin X' S; topspace X' = topspace X; + \U. openin X U \ openin X' U\ \ compactin X S" + by (simp add: compactin_def) + +lemma finite_imp_compactin: + "\S \ topspace X; finite S\ \ compactin X S" + by (metis compactin_subspace compact_space finite_UnionD inf.absorb_iff2 order_refl topspace_subtopology) + +lemma compactin_empty [iff]: "compactin X {}" + by (simp add: finite_imp_compactin) + +lemma compact_space_topspace_empty: + "topspace X = {} \ compact_space X" + by (simp add: compact_space_def) + +lemma finite_imp_compactin_eq: + "finite S \ (compactin X S \ S \ topspace X)" + using compactin_subset_topspace finite_imp_compactin by blast + +lemma compactin_sing [simp]: "compactin X {a} \ a \ topspace X" + by (simp add: finite_imp_compactin_eq) + +lemma closed_compactin: + assumes XK: "compactin X K" and "C \ K" and XC: "closedin X C" + shows "compactin X C" + unfolding compactin_def +proof (intro conjI allI impI) + show "C \ topspace X" + by (simp add: XC closedin_subset) +next + fix \ :: "'a set set" + assume \: "Ball \ (openin X) \ C \ \\" + have "(\U\insert (topspace X - C) \. openin X U)" + using XC \ by blast + moreover have "K \ \insert (topspace X - C) \" + using \ XK compactin_subset_topspace by fastforce + ultimately obtain \ where "finite \" "\ \ insert (topspace X - C) \" "K \ \\" + using assms unfolding compactin_def by metis + moreover have "openin X (topspace X - C)" + using XC by auto + ultimately show "\\. finite \ \ \ \ \ \ C \ \\" + using \C \ K\ + by (rule_tac x="\ - {topspace X - C}" in exI) auto +qed + +lemma closedin_compact_space: + "\compact_space X; closedin X S\ \ compactin X S" + by (simp add: closed_compactin closedin_subset compact_space_def) + +lemma compact_Int_closedin: + assumes "compactin X S" "closedin X T" shows "compactin X (S \ T)" +proof - + have "compactin (subtopology X S) (S \ T)" + by (metis assms closedin_compact_space closedin_subtopology compactin_subspace inf_commute) + then show ?thesis + by (simp add: compactin_subtopology) +qed + +lemma closed_Int_compactin: "\closedin X S; compactin X T\ \ compactin X (S \ T)" + by (metis compact_Int_closedin inf_commute) + +lemma compactin_Un: + assumes S: "compactin X S" and T: "compactin X T" shows "compactin X (S \ T)" + unfolding compactin_def +proof (intro conjI allI impI) + show "S \ T \ topspace X" + using assms by (auto simp: compactin_def) +next + fix \ :: "'a set set" + assume \: "Ball \ (openin X) \ S \ T \ \\" + with S obtain \ where \: "finite \" "\ \ \" "S \ \\" + unfolding compactin_def by (meson sup.bounded_iff) + obtain \ where "finite \" "\ \ \" "T \ \\" + using \ T + unfolding compactin_def by (meson sup.bounded_iff) + with \ show "\\. finite \ \ \ \ \ \ S \ T \ \\" + by (rule_tac x="\ \ \" in exI) auto +qed + +lemma compactin_Union: + "\finite \; \S. S \ \ \ compactin X S\ \ compactin X (\\)" +by (induction rule: finite_induct) (simp_all add: compactin_Un) + +lemma compactin_subtopology_imp_compact: + assumes "compactin (subtopology X S) K" shows "compactin X K" + using assms +proof (clarsimp simp add: compactin_def topspace_subtopology) + fix \ + define \ where "\ \ (\U. U \ S) ` \" + assume "K \ topspace X" and "K \ S" and "\x\\. openin X x" and "K \ \\" + then have "\V \ \. openin (subtopology X S) V" "K \ \\" + unfolding \_def by (auto simp: openin_subtopology) + moreover + assume "\\. (\x\\. openin (subtopology X S) x) \ K \ \\ \ (\\. finite \ \ \ \ \ \ K \ \\)" + ultimately obtain \ where "finite \" "\ \ \" "K \ \\" + by meson + then have \: "\U. U \ \ \ V = U \ S" if "V \ \" for V + unfolding \_def using that by blast + let ?\ = "(\F. @U. U \ \ \ F = U \ S) ` \" + show "\\. finite \ \ \ \ \ \ K \ \\" + proof (intro exI conjI) + show "finite ?\" + using \finite \\ by blast + show "?\ \ \" + using someI_ex [OF \] by blast + show "K \ \?\" + proof clarsimp + fix x + assume "x \ K" + then show "\V \ \. x \ (SOME U. U \ \ \ V = U \ S)" + using \K \ \\\ someI_ex [OF \] + by (metis (no_types, lifting) IntD1 Union_iff subsetCE) + qed + qed +qed + +lemma compact_imp_compactin_subtopology: + assumes "compactin X K" "K \ S" shows "compactin (subtopology X S) K" + using assms +proof (clarsimp simp add: compactin_def topspace_subtopology) + fix \ :: "'a set set" + define \ where "\ \ {V. openin X V \ (\U \ \. U = V \ S)}" + assume "K \ S" and "K \ topspace X" and "\U\\. openin (subtopology X S) U" and "K \ \\" + then have "\V \ \. openin X V" "K \ \\" + unfolding \_def by (fastforce simp: subset_eq openin_subtopology)+ + moreover + assume "\\. (\U\\. openin X U) \ K \ \\ \ (\\. finite \ \ \ \ \ \ K \ \\)" + ultimately obtain \ where "finite \" "\ \ \" "K \ \\" + by meson + let ?\ = "(\F. F \ S) ` \" + show "\\. finite \ \ \ \ \ \ K \ \\" + proof (intro exI conjI) + show "finite ?\" + using \finite \\ by blast + show "?\ \ \" + using \_def \\ \ \\ by blast + show "K \ \?\" + using \K \ \\\ assms(2) by auto + qed +qed + + +proposition compact_space_fip: + "compact_space X \ + (\\. (\C\\. closedin X C) \ (\\. finite \ \ \ \ \ \ \\ \ {}) \ \\ \ {})" + (is "_ = ?rhs") +proof (cases "topspace X = {}") + case True + then show ?thesis + apply (clarsimp simp add: compact_space_def closedin_topspace_empty) + by (metis finite.emptyI finite_insert infinite_super insertI1 subsetI) +next + case False + show ?thesis + proof safe + fix \ :: "'a set set" + assume * [rule_format]: "\\. finite \ \ \ \ \ \ \\ \ {}" + define \ where "\ \ (\S. topspace X - S) ` \" + assume clo: "\C\\. closedin X C" and [simp]: "\\ = {}" + then have "\V \ \. openin X V" "topspace X \ \\" + by (auto simp: \_def) + moreover assume [unfolded compact_space_alt, rule_format, of \]: "compact_space X" + ultimately obtain \ where \: "finite \" "\ \ \" "topspace X \ topspace X - \\" + by (auto simp: exists_finite_subset_image \_def) + moreover have "\ \ {}" + using \ \topspace X \ {}\ by blast + ultimately show "False" + using * [of \] + by auto (metis Diff_iff Inter_iff clo closedin_def subsetD) + next + assume R [rule_format]: ?rhs + show "compact_space X" + unfolding compact_space_alt + proof clarify + fix \ :: "'a set set" + define \ where "\ \ (\S. topspace X - S) ` \" + assume "\C\\. openin X C" and "topspace X \ \\" + with \topspace X \ {}\ have *: "\V \ \. closedin X V" "\ \ {}" + by (auto simp: \_def) + show "\\. finite \ \ \ \ \ \ topspace X \ \\" + proof (rule ccontr; simp) + assume "\\\\. finite \ \ \ topspace X \ \\" + then have "\\. finite \ \ \ \ \ \ \\ \ {}" + by (simp add: \_def all_finite_subset_image) + with \topspace X \ \\\ show False + using R [of \] * by (simp add: \_def) + qed + qed + qed +qed + +corollary compactin_fip: + "compactin X S \ + S \ topspace X \ + (\\. (\C\\. closedin X C) \ (\\. finite \ \ \ \ \ \ S \ \\ \ {}) \ S \ \\ \ {})" +proof (cases "S = {}") + case False + show ?thesis + proof (cases "S \ topspace X") + case True + then have "compactin X S \ + (\\. \ \ (\T. S \ T) ` {T. closedin X T} \ + (\\. finite \ \ \ \ \ \ \\ \ {}) \ \\ \ {})" + by (simp add: compact_space_fip compactin_subspace closedin_subtopology image_def subset_eq Int_commute imp_conjL) + also have "\ = (\\\Collect (closedin X). (\\. finite \ \ \ \ (\) S ` \ \ \\ \ {}) \ INTER \ ((\) S) \ {})" + by (simp add: all_subset_image) + also have "\ = (\\. (\C\\. closedin X C) \ (\\. finite \ \ \ \ \ \ S \ \\ \ {}) \ S \ \\ \ {})" + proof - + have eq: "((\\. finite \ \ \ \ \ \ INTER \ ((\) S) \ {}) \ INTER \ ((\) S) \ {}) = + ((\\. finite \ \ \ \ \ \ S \ \\ \ {}) \ S \ \\ \ {})" for \ + by simp (use \S \ {}\ in blast) + show ?thesis + apply (simp only: imp_conjL [symmetric] all_finite_subset_image eq) + apply (simp add: subset_eq) + done + qed + finally show ?thesis + using True by simp + qed (simp add: compactin_subspace) +qed force + +corollary compact_space_imp_nest: + fixes C :: "nat \ 'a set" + assumes "compact_space X" and clo: "\n. closedin X (C n)" + and ne: "\n. C n \ {}" and inc: "\m n. m \ n \ C n \ C m" + shows "(\n. C n) \ {}" +proof - + let ?\ = "range (\n. \m \ n. C m)" + have "closedin X A" if "A \ ?\" for A + using that clo by auto + moreover have "(\n\K. \m \ n. C m) \ {}" if "finite K" for K + proof - + obtain n where "\k. k \ K \ k \ n" + using Max.coboundedI \finite K\ by blast + with inc have "C n \ (\n\K. \m \ n. C m)" + by blast + with ne [of n] show ?thesis + by blast + qed + ultimately show ?thesis + using \compact_space X\ [unfolded compact_space_fip, rule_format, of ?\] + by (simp add: all_finite_subset_image INT_extend_simps UN_atMost_UNIV del: INT_simps) +qed + +lemma compactin_discrete_topology: + "compactin (discrete_topology X) S \ S \ X \ finite S" (is "?lhs = ?rhs") +proof (intro iffI conjI) + assume L: ?lhs + then show "S \ X" + by (auto simp: compactin_def) + have *: "\\. Ball \ (openin (discrete_topology X)) \ S \ \\ \ + (\\. finite \ \ \ \ \ \ S \ \\)" + using L by (auto simp: compactin_def) + show "finite S" + using * [of "(\x. {x}) ` X"] \S \ X\ + by clarsimp (metis UN_singleton finite_subset_image infinite_super) +next + assume ?rhs + then show ?lhs + by (simp add: finite_imp_compactin) +qed + +lemma compact_space_discrete_topology: "compact_space(discrete_topology X) \ finite X" + by (simp add: compactin_discrete_topology compact_space_def) + +lemma compact_space_imp_bolzano_weierstrass: + assumes "compact_space X" "infinite S" "S \ topspace X" + shows "X derived_set_of S \ {}" +proof + assume X: "X derived_set_of S = {}" + then have "closedin X S" + by (simp add: closedin_contains_derived_set assms) + then have "compactin X S" + by (rule closedin_compact_space [OF \compact_space X\]) + with X show False + by (metis \infinite S\ compactin_subspace compact_space_discrete_topology inf_bot_right subtopology_eq_discrete_topology_eq) +qed + +lemma compactin_imp_bolzano_weierstrass: + "\compactin X S; infinite T \ T \ S\ \ S \ X derived_set_of T \ {}" + using compact_space_imp_bolzano_weierstrass [of "subtopology X S"] + by (simp add: compactin_subspace derived_set_of_subtopology inf_absorb2 topspace_subtopology) + +lemma compact_closure_of_imp_bolzano_weierstrass: + "\compactin X (X closure_of S); infinite T; T \ S; T \ topspace X\ \ X derived_set_of T \ {}" + using closure_of_mono closure_of_subset compactin_imp_bolzano_weierstrass by fastforce + +lemma discrete_compactin_eq_finite: + "S \ X derived_set_of S = {} \ compactin X S \ S \ topspace X \ finite S" + apply (rule iffI) + using compactin_imp_bolzano_weierstrass compactin_subset_topspace apply blast + by (simp add: finite_imp_compactin_eq) + +lemma discrete_compact_space_eq_finite: + "X derived_set_of (topspace X) = {} \ (compact_space X \ finite(topspace X))" + by (metis compact_space_discrete_topology discrete_topology_unique_derived_set) + +lemma image_compactin: + assumes cpt: "compactin X S" and cont: "continuous_map X Y f" + shows "compactin Y (f ` S)" + unfolding compactin_def +proof (intro conjI allI impI) + show "f ` S \ topspace Y" + using compactin_subset_topspace cont continuous_map_image_subset_topspace cpt by blast +next + fix \ :: "'b set set" + assume \: "Ball \ (openin Y) \ f ` S \ \\" + define \ where "\ \ (\U. {x \ topspace X. f x \ U}) ` \" + have "S \ topspace X" + and *: "\\. \\U\\. openin X U; S \ \\\ \ \\. finite \ \ \ \ \ \ S \ \\" + using cpt by (auto simp: compactin_def) + obtain \ where \: "finite \" "\ \ \" "S \ \\" + proof - + have 1: "\U\\. openin X U" + unfolding \_def using \ cont continuous_map by blast + have 2: "S \ \\" + unfolding \_def using compactin_subset_topspace cpt \ by fastforce + show thesis + using * [OF 1 2] that by metis + qed + have "\v \ \. \U. U \ \ \ v = {x \ topspace X. f x \ U}" + using \_def by blast + then obtain U where U: "\v \ \. U v \ \ \ v = {x \ topspace X. f x \ U v}" + by metis + show "\\. finite \ \ \ \ \ \ f ` S \ \\" + proof (intro conjI exI) + show "finite (U ` \)" + by (simp add: \finite \\) + next + show "U ` \ \ \" + using \\ \ \\ U by auto + next + show "f ` S \ UNION \ U" + using \(2-3) U UnionE subset_eq U by fastforce + qed +qed + + +lemma homeomorphic_compact_space: + assumes "X homeomorphic_space Y" + shows "compact_space X \ compact_space Y" + using homeomorphic_space_sym + by (metis assms compact_space_def homeomorphic_eq_everything_map homeomorphic_space image_compactin) + +lemma homeomorphic_map_compactness: + assumes hom: "homeomorphic_map X Y f" and U: "U \ topspace X" + shows "compactin Y (f ` U) \ compactin X U" +proof - + have "f ` U \ topspace Y" + using hom U homeomorphic_imp_surjective_map by blast + moreover have "homeomorphic_map (subtopology X U) (subtopology Y (f ` U)) f" + using U hom homeomorphic_imp_surjective_map by (blast intro: homeomorphic_map_subtopologies) + then have "compact_space (subtopology Y (f ` U)) = compact_space (subtopology X U)" + using homeomorphic_compact_space homeomorphic_map_imp_homeomorphic_space by blast + ultimately show ?thesis + by (simp add: compactin_subspace U) +qed + +lemma homeomorphic_map_compactness_eq: + "homeomorphic_map X Y f + \ compactin X U \ U \ topspace X \ compactin Y (f ` U)" + by (meson compactin_subset_topspace homeomorphic_map_compactness) + + +subsection\Embedding maps\ + +definition embedding_map + where "embedding_map X Y f \ homeomorphic_map X (subtopology Y (f ` (topspace X))) f" + +lemma embedding_map_eq: + "\embedding_map X Y f; \x. x \ topspace X \ f x = g x\ \ embedding_map X Y g" + unfolding embedding_map_def + by (metis homeomorphic_map_eq image_cong) + +lemma embedding_map_compose: + assumes "embedding_map X X' f" "embedding_map X' X'' g" + shows "embedding_map X X'' (g \ f)" +proof - + have hm: "homeomorphic_map X (subtopology X' (f ` topspace X)) f" "homeomorphic_map X' (subtopology X'' (g ` topspace X')) g" + using assms by (auto simp: embedding_map_def) + then obtain C where "g ` topspace X' \ C = (g \ f) ` topspace X" + by (metis (no_types) Int_absorb1 continuous_map_image_subset_topspace continuous_map_in_subtopology homeomorphic_eq_everything_map image_comp image_mono) + then have "homeomorphic_map (subtopology X' (f ` topspace X)) (subtopology X'' ((g \ f) ` topspace X)) g" + by (metis hm homeomorphic_imp_surjective_map homeomorphic_map_subtopologies image_comp subtopology_subtopology topspace_subtopology) + then show ?thesis + unfolding embedding_map_def + using hm(1) homeomorphic_map_compose by blast +qed + +lemma surjective_embedding_map: + "embedding_map X Y f \ f ` (topspace X) = topspace Y \ homeomorphic_map X Y f" + by (force simp: embedding_map_def homeomorphic_eq_everything_map) + +lemma embedding_map_in_subtopology: + "embedding_map X (subtopology Y S) f \ embedding_map X Y f \ f ` (topspace X) \ S" + apply (auto simp: embedding_map_def subtopology_subtopology Int_absorb1) + apply (metis (no_types) homeomorphic_imp_surjective_map subtopology_subtopology subtopology_topspace topspace_subtopology) + apply (simp add: continuous_map_def homeomorphic_eq_everything_map topspace_subtopology) + done + +lemma injective_open_imp_embedding_map: + "\continuous_map X Y f; open_map X Y f; inj_on f (topspace X)\ \ embedding_map X Y f" + unfolding embedding_map_def + apply (rule bijective_open_imp_homeomorphic_map) + using continuous_map_in_subtopology apply blast + apply (auto simp: continuous_map_in_subtopology open_map_into_subtopology topspace_subtopology continuous_map) + done + +lemma injective_closed_imp_embedding_map: + "\continuous_map X Y f; closed_map X Y f; inj_on f (topspace X)\ \ embedding_map X Y f" + unfolding embedding_map_def + apply (rule bijective_closed_imp_homeomorphic_map) + apply (simp_all add: continuous_map_into_subtopology closed_map_into_subtopology) + apply (simp add: continuous_map inf.absorb_iff2 topspace_subtopology) + done + +lemma embedding_map_imp_homeomorphic_space: + "embedding_map X Y f \ X homeomorphic_space (subtopology Y (f ` (topspace X)))" + unfolding embedding_map_def + using homeomorphic_space by blast + +end diff -r 5acb1eece41b -r f13b82281715 src/HOL/Analysis/Analysis.thy --- a/src/HOL/Analysis/Analysis.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Analysis/Analysis.thy Wed Oct 17 14:19:07 2018 +0100 @@ -10,6 +10,7 @@ Cross3 Homeomorphism Bounded_Continuous_Function + Abstract_Topology Function_Topology Infinite_Products Infinite_Set_Sum diff -r 5acb1eece41b -r f13b82281715 src/HOL/Analysis/Bochner_Integration.thy --- a/src/HOL/Analysis/Bochner_Integration.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Analysis/Bochner_Integration.thy Wed Oct 17 14:19:07 2018 +0100 @@ -2853,8 +2853,6 @@ by (simp cong: measurable_cong) qed -lemma%unimportant Collect_subset [simp]: "{x\A. P x} \ A" by auto - lemma%unimportant (in sigma_finite_measure) measurable_measure[measurable (raw)]: "(\x. x \ space N \ A x \ space M) \ {x \ space (N \\<^sub>M M). snd x \ A (fst x)} \ sets (N \\<^sub>M M) \ diff -r 5acb1eece41b -r f13b82281715 src/HOL/Analysis/Path_Connected.thy --- a/src/HOL/Analysis/Path_Connected.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Analysis/Path_Connected.thy Wed Oct 17 14:19:07 2018 +0100 @@ -1263,6 +1263,10 @@ using assms by auto qed +lemma linepath_le_1: + fixes a::"'a::linordered_idom" shows "\a \ 1; b \ 1; 0 \ u; u \ 1\ \ (1 - u) * a + u * b \ 1" + using mult_left_le [of a "1-u"] mult_left_le [of b u] by auto + subsection%unimportant\Segments via convex hulls\ diff -r 5acb1eece41b -r f13b82281715 src/HOL/Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Analysis/Topology_Euclidean_Space.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Analysis/Topology_Euclidean_Space.thy Wed Oct 17 14:19:07 2018 +0100 @@ -635,8 +635,8 @@ then show "T1 = T2" unfolding openin_inverse . qed -text\Infer the "universe" from union of all sets in the topology.\ - + +text\The "universe": the union of all sets in the topology.\ definition "topspace T = \{S. openin T S}" subsubsection \Main properties of open sets\ @@ -778,7 +778,52 @@ qed -subsubsection \Subspace topology\ +subsection\The discrete topology\ + +definition discrete_topology where "discrete_topology U \ topology (\S. S \ U)" + +lemma openin_discrete_topology [simp]: "openin (discrete_topology U) S \ S \ U" +proof - + have "istopology (\S. S \ U)" + by (auto simp: istopology_def) + then show ?thesis + by (simp add: discrete_topology_def topology_inverse') +qed + +lemma topspace_discrete_topology [simp]: "topspace(discrete_topology U) = U" + by (meson openin_discrete_topology openin_subset openin_topspace order_refl subset_antisym) + +lemma closedin_discrete_topology [simp]: "closedin (discrete_topology U) S \ S \ U" + by (simp add: Diff_subset closedin_def) + +lemma discrete_topology_unique: + "discrete_topology U = X \ topspace X = U \ (\x \ U. openin X {x})" (is "?lhs = ?rhs") +proof + assume R: ?rhs + then have "openin X S" if "S \ U" for S + using openin_subopen subsetD that by fastforce + moreover have "x \ topspace X" if "openin X S" and "x \ S" for x S + using openin_subset that by blast + ultimately + show ?lhs + using R by (auto simp: topology_eq) +qed auto + +lemma discrete_topology_unique_alt: + "discrete_topology U = X \ topspace X \ U \ (\x \ U. openin X {x})" + using openin_subset + by (auto simp: discrete_topology_unique) + +lemma subtopology_eq_discrete_topology_empty: + "X = discrete_topology {} \ topspace X = {}" + using discrete_topology_unique [of "{}" X] by auto + +lemma subtopology_eq_discrete_topology_sing: + "X = discrete_topology {a} \ topspace X = {a}" + by (metis discrete_topology_unique openin_topspace singletonD) + + +subsection \Subspace topology\ definition%important "subtopology U V = topology (\T. \S. T = S \ V \ openin U S)" @@ -818,6 +863,19 @@ unfolding subtopology_def topology_inverse'[OF istopology_subtopology] by auto +lemma openin_subtopology_Int: + "openin X S \ openin (subtopology X T) (S \ T)" + using openin_subtopology by auto + +lemma openin_subtopology_Int2: + "openin X T \ openin (subtopology X S) (S \ T)" + using openin_subtopology by auto + +lemma openin_subtopology_diff_closed: + "\S \ topspace X; closedin X T\ \ openin (subtopology X S) (S - T)" + unfolding closedin_def openin_subtopology + by (rule_tac x="topspace X - T" in exI) auto + lemma openin_relative_to: "(openin X relative_to S) = openin (subtopology X S)" by (force simp: relative_to_def openin_subtopology) @@ -927,7 +985,7 @@ by (simp add: closedin_subtopology) blast -subsubsection \The standard Euclidean topology\ +subsection \The standard Euclidean topology\ definition%important euclidean :: "'a::topological_space topology" where "euclidean = topology open" @@ -958,7 +1016,25 @@ lemma openin_subtopology_self [simp]: "openin (subtopology euclidean S) S" by (metis openin_topspace topspace_euclidean_subtopology) -text \Basic "localization" results are handy for connectedness.\ +subsubsection\The most basic facts about the usual topology and metric on R\ + +abbreviation euclideanreal :: "real topology" + where "euclideanreal \ topology open" + +lemma real_openin [simp]: "openin euclideanreal S = open S" + by (simp add: euclidean_def open_openin) + +lemma topspace_euclideanreal [simp]: "topspace euclideanreal = UNIV" + using openin_subset open_UNIV real_openin by blast + +lemma topspace_euclideanreal_subtopology [simp]: + "topspace (subtopology euclideanreal S) = S" + by (simp add: topspace_subtopology) + +lemma real_closedin [simp]: "closedin euclideanreal S = closed S" + by (simp add: closed_closedin euclidean_def) + +subsection \Basic "localization" results are handy for connectedness.\ lemma openin_open: "openin (subtopology euclidean U) S \ (\T. open T \ (S = U \ T))" by (auto simp: openin_subtopology) diff -r 5acb1eece41b -r f13b82281715 src/HOL/Groups_Big.thy --- a/src/HOL/Groups_Big.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Groups_Big.thy Wed Oct 17 14:19:07 2018 +0100 @@ -974,6 +974,12 @@ then show ?thesis by simp qed +lemma sum_bounded_above_divide: + fixes K :: "'a::linordered_field" + assumes le: "\i. i\A \ f i \ K / of_nat (card A)" and fin: "finite A" "A \ {}" + shows "sum f A \ K" + using sum_bounded_above [of A f "K / of_nat (card A)", OF le] fin by simp + lemma sum_bounded_above_strict: fixes K :: "'a::{ordered_cancel_comm_monoid_add,semiring_1}" assumes "\i. i\A \ f i < K" "card A > 0" @@ -994,6 +1000,27 @@ then show ?thesis by simp qed +lemma convex_sum_bound_le: + fixes x :: "'a \ 'b::linordered_idom" + assumes 0: "\i. i \ I \ 0 \ x i" and 1: "sum x I = 1" + and \: "\i. i \ I \ \a i - b\ \ \" + shows "\(\i\I. a i * x i) - b\ \ \" +proof - + have [simp]: "(\i\I. c * x i) = c" for c + by (simp flip: sum_distrib_left 1) + then have "\(\i\I. a i * x i) - b\ = \\i\I. (a i - b) * x i\" + by (simp add: sum_subtractf left_diff_distrib) + also have "\ \ (\i\I. \(a i - b) * x i\)" + using abs_abs abs_of_nonneg by blast + also have "\ \ (\i\I. \(a i - b)\ * x i)" + by (simp add: abs_mult 0) + also have "\ \ (\i\I. \ * x i)" + by (rule sum_mono) (use \ "0" mult_right_mono in blast) + also have "\ = \" + by simp + finally show ?thesis . +qed + lemma card_UN_disjoint: assumes "finite I" and "\i\I. finite (A i)" and "\i\I. \j\I. i \ j \ A i \ A j = {}" diff -r 5acb1eece41b -r f13b82281715 src/HOL/Library/FuncSet.thy --- a/src/HOL/Library/FuncSet.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Library/FuncSet.thy Wed Oct 17 14:19:07 2018 +0100 @@ -570,6 +570,40 @@ done +subsubsection \Misc properties of functions, composition and restriction from HOL Light\ + +lemma function_factors_left_gen: + "(\x y. P x \ P y \ g x = g y \ f x = f y) \ (\h. \x. P x \ f x = h(g x))" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + then show ?rhs + apply (rule_tac x="f \ inv_into (Collect P) g" in exI) + unfolding o_def + by (metis (mono_tags, hide_lams) f_inv_into_f imageI inv_into_into mem_Collect_eq) +qed auto + +lemma function_factors_left: + "(\x y. (g x = g y) \ (f x = f y)) \ (\h. f = h \ g)" + using function_factors_left_gen [of "\x. True" g f] unfolding o_def by blast + +lemma function_factors_right_gen: + "(\x. P x \ (\y. g y = f x)) \ (\h. \x. P x \ f x = g(h x))" + by metis + +lemma function_factors_right: + "(\x. \y. g y = f x) \ (\h. f = g \ h)" + unfolding o_def by metis + +lemma restrict_compose_right: + "restrict (g \ restrict f S) S = restrict (g \ f) S" + by auto + +lemma restrict_compose_left: + "f ` S \ T \ restrict (restrict g T \ f) S = restrict (g \ f) S" + by fastforce + + subsubsection \Cardinality\ lemma finite_PiE: "finite S \ (\i. i \ S \ finite (T i)) \ finite (\\<^sub>E i \ S. T i)" diff -r 5acb1eece41b -r f13b82281715 src/HOL/Meson.thy --- a/src/HOL/Meson.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Meson.thy Wed Oct 17 14:19:07 2018 +0100 @@ -106,6 +106,9 @@ lemma imp_forward: "\P' \ Q'; P \ P'; Q' \ Q \ \ P \ Q" by blast +lemma imp_forward2: "\P' \ Q'; P \ P'; P' \ Q' \ Q \ \ P \ Q" + by blast + (*Version of @{text disj_forward} for removal of duplicate literals*) lemma disj_forward2: "\ P'\Q'; P' \ P; \Q'; P\False\ \ Q\ \ P\Q" apply blast diff -r 5acb1eece41b -r f13b82281715 src/HOL/Metis_Examples/Tarski.thy --- a/src/HOL/Metis_Examples/Tarski.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Metis_Examples/Tarski.thy Wed Oct 17 14:19:07 2018 +0100 @@ -436,7 +436,7 @@ subsection \fixed points\ lemma fix_subset: "fix f A \ A" -by (simp add: fix_def, fast) +by (auto simp add: fix_def) lemma fix_imp_eq: "x \ fix f A ==> f x = x" by (simp add: fix_def) diff -r 5acb1eece41b -r f13b82281715 src/HOL/Product_Type.thy --- a/src/HOL/Product_Type.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Product_Type.thy Wed Oct 17 14:19:07 2018 +0100 @@ -1100,6 +1100,9 @@ lemma Times_empty [simp]: "A \ B = {} \ A = {} \ B = {}" by auto +lemma times_subset_iff: "A \ C \ B \ D \ A={} \ C={} \ A \ B \ C \ D" + by blast + lemma times_eq_iff: "A \ B = C \ D \ A = C \ B = D \ (A = {} \ B = {}) \ (C = {} \ D = {})" by auto diff -r 5acb1eece41b -r f13b82281715 src/HOL/Set.thy --- a/src/HOL/Set.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/Set.thy Wed Oct 17 14:19:07 2018 +0100 @@ -1140,6 +1140,8 @@ lemma not_psubset_empty [iff]: "\ (A < {})" by (fact not_less_bot) (* FIXME: already simp *) +lemma Collect_subset [simp]: "{x\A. P x} \ A" by auto + lemma Collect_empty_eq [simp]: "Collect P = {} \ (\x. \ P x)" by blast diff -r 5acb1eece41b -r f13b82281715 src/HOL/UNITY/ProgressSets.thy --- a/src/HOL/UNITY/ProgressSets.thy Wed Oct 17 07:50:46 2018 +0200 +++ b/src/HOL/UNITY/ProgressSets.thy Wed Oct 17 14:19:07 2018 +0100 @@ -62,10 +62,7 @@ text\The next three results state that @{term "cl L r"} is the minimal element of @{term L} that includes @{term r}.\ lemma cl_in_lattice: "lattice L ==> cl L r \ L" -apply (simp add: lattice_def cl_def) -apply (erule conjE) -apply (drule spec, erule mp, blast) -done + by (simp add: lattice_def cl_def) lemma cl_least: "[|c\L; r\c|] ==> cl L r \ c" by (force simp add: cl_def)