# HG changeset patch # User paulson # Date 1684841483 -3600 # Node ID cec875dcc59ee05faf2316508d03b2e3729f2425 # Parent 070703d83cfe639d875f5f3099c0c8c8f1239502 Finally, the abstract metric space development diff -r 070703d83cfe -r cec875dcc59e src/HOL/Analysis/Abstract_Metric_Spaces.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Analysis/Abstract_Metric_Spaces.thy Tue May 23 12:31:23 2023 +0100 @@ -0,0 +1,2634 @@ +section \Abstract Metric Spaces\ + +theory Abstract_Metric_Spaces + imports Elementary_Metric_Spaces Abstract_Limits Abstract_Topological_Spaces +begin + +(*Avoid a clash with the existing metric_space locale (from the type class)*) +locale Metric_space = + fixes M :: "'a set" and d :: "'a \ 'a \ real" + assumes nonneg [simp]: "\x y. 0 \ d x y" + assumes commute: "\x y. d x y = d y x" + assumes zero [simp]: "\x y. \x \ M; y \ M\ \ d x y = 0 \ x=y" + assumes triangle: "\x y z. \x \ M; y \ M; z \ M\ \ d x z \ d x y + d y z" + +text \Link with the type class version\ +interpretation Met_TC: Metric_space UNIV dist + by (simp add: dist_commute dist_triangle Metric_space.intro) + +context Metric_space +begin + +lemma subspace: "M' \ M \ Metric_space M' d" + by (simp add: commute in_mono Metric_space.intro triangle) + +lemma abs_mdist [simp] : "\d x y\ = d x y" + by simp + +lemma mdist_pos_less: "\x \ y; x \ M; y \ M\ \ 0 < d x y" + by (metis less_eq_real_def nonneg zero) + +lemma mdist_zero [simp]: "x \ M \ d x x = 0" + by simp + +lemma mdist_pos_eq [simp]: "\x \ M; y \ M\ \ 0 < d x y \ x \ y" + using mdist_pos_less zero by fastforce + +lemma triangle': "\x \ M; y \ M; z \ M\ \ d x z \ d x y + d z y" + by (simp add: commute triangle) + +lemma triangle'': "\x \ M; y \ M; z \ M\ \ d x z \ d y x + d y z" + by (simp add: commute triangle) + +lemma mdist_reverse_triangle: "\x \ M; y \ M; z \ M\ \ \d x y - d y z\ \ d x z" + by (smt (verit) commute triangle) + +text\ Open and closed balls \ + +definition mball where "mball x r \ {y. x \ M \ y \ M \ d x y < r}" +definition mcball where "mcball x r \ {y. x \ M \ y \ M \ d x y \ r}" + +lemma in_mball [simp]: "y \ mball x r \ x \ M \ y \ M \ d x y < r" + by (simp add: local.Metric_space_axioms Metric_space.mball_def) + +lemma centre_in_mball_iff [iff]: "x \ mball x r \ x \ M \ 0 < r" + using in_mball mdist_zero by force + +lemma mball_subset_mspace: "mball x r \ M" + by auto + +lemma mball_eq_empty: "mball x r = {} \ (x \ M) \ r \ 0" + by (smt (verit, best) Collect_empty_eq centre_in_mball_iff mball_def nonneg) + +lemma mball_subset: "\d x y + a \ b; y \ M\ \ mball x a \ mball y b" + by (smt (verit) commute in_mball subsetI triangle) + +lemma disjoint_mball: "r + r' \ d x x' \ disjnt (mball x r) (mball x' r')" + by (smt (verit) commute disjnt_iff in_mball triangle) + +lemma mball_subset_concentric: "r \ s \ mball x r \ mball x s" + by auto + +lemma in_mcball [simp]: "y \ mcball x r \ x \ M \ y \ M \ d x y \ r" + by (simp add: local.Metric_space_axioms Metric_space.mcball_def) + +lemma centre_in_mcball_iff [iff]: "x \ mcball x r \ x \ M \ 0 \ r" + using mdist_zero by force + +lemma mcball_eq_empty: "mcball x r = {} \ (x \ M) \ r < 0" + by (smt (verit, best) Collect_empty_eq centre_in_mcball_iff empty_iff mcball_def nonneg) + +lemma mcball_subset_mspace: "mcball x r \ M" + by auto + +lemma mball_subset_mcball: "mball x r \ mcball x r" + by auto + +lemma mcball_subset: "\d x y + a \ b; y \ M\ \ mcball x a \ mcball y b" + by (smt (verit) in_mcball mdist_reverse_triangle subsetI) + +lemma mcball_subset_concentric: "r \ s \ mcball x r \ mcball x s" + by force + +lemma mcball_subset_mball: "\d x y + a < b; y \ M\ \ mcball x a \ mball y b" + by (smt (verit) commute in_mball in_mcball subsetI triangle) + +lemma mcball_subset_mball_concentric: "a < b \ mcball x a \ mball x b" + by force + +end + + + +subsection \Metric topology \ + +context Metric_space +begin + +definition mopen where + "mopen U \ U \ M \ (\x. x \ U \ (\r>0. mball x r \ U))" + +definition mtopology :: "'a topology" where + "mtopology \ topology mopen" + +lemma is_topology_metric_topology [iff]: "istopology mopen" +proof - + have "\S T. \mopen S; mopen T\ \ mopen (S \ T)" + by (smt (verit, del_insts) Int_iff in_mball mopen_def subset_eq) + moreover have "\\. (\K\\. mopen K) \ mopen (\\)" + using mopen_def by fastforce + ultimately show ?thesis + by (simp add: istopology_def) +qed + +lemma openin_mtopology: "openin mtopology U \ U \ M \ (\x. x \ U \ (\r>0. mball x r \ U))" + by (simp add: mopen_def mtopology_def) + +lemma topspace_mtopology [simp]: "topspace mtopology = M" + by (meson order.refl mball_subset_mspace openin_mtopology openin_subset openin_topspace subset_antisym zero_less_one) + +lemma subtopology_mspace [simp]: "subtopology mtopology M = mtopology" + by (metis subtopology_topspace topspace_mtopology) + +lemma open_in_mspace [iff]: "openin mtopology M" + by (metis openin_topspace topspace_mtopology) + +lemma closedin_mspace [iff]: "closedin mtopology M" + by (metis closedin_topspace topspace_mtopology) + +lemma openin_mball [iff]: "openin mtopology (mball x r)" +proof - + have "\y. \x \ M; d x y < r\ \ \s>0. mball y s \ mball x r" + by (metis add_diff_cancel_left' add_diff_eq commute less_add_same_cancel1 mball_subset order_refl) + then show ?thesis + by (auto simp: openin_mtopology) +qed + +lemma mcball_eq_cball [simp]: "Met_TC.mcball = cball" + by force + +lemma mball_eq_ball [simp]: "Met_TC.mball = ball" + by force + +lemma mopen_eq_open [simp]: "Met_TC.mopen = open" + by (force simp: open_contains_ball Met_TC.mopen_def) + +lemma limitin_iff_tendsto [iff]: "limitin Met_TC.mtopology \ x F = tendsto \ x F" + by (simp add: Met_TC.mtopology_def) + +lemma mtopology_is_euclideanreal [simp]: "Met_TC.mtopology = euclideanreal" + by (simp add: Met_TC.mtopology_def) + +(* +lemma metric_injective_image: + "\f m s. + f ` s \ M \ + (\x y. x \ s \ y \ s \ f x = f y \ x = y) + \ (mspace(metric(s,\(x,y). d (f x) (f y))) = s) \ + (d(metric(s,\(x,y). d (f x) (f y))) = + \(x,y). d (f x) (f y))" +oops + REWRITE_TAC[\; FORALL_IN_IMAGE; INJECTIVE_ON_ALT] THEN + REPEAT GEN_TAC THEN STRIP_TAC THEN + REWRITE_TAC[mspace; d; GSYM PAIR_EQ] THEN + REWRITE_TAC[GSYM(CONJUNCT2 metric_tybij); is_metric_space] THEN + REWRITE_TAC[GSYM mspace; GSYM d] THEN + ASM_SIMP_TAC[MDIST_POS_LE; MDIST_TRIANGLE; MDIST_0] THEN + ASM_MESON_TAC[MDIST_SYM]);; +*) + +lemma mtopology_base: + "mtopology = topology(arbitrary union_of (\U. \x \ M. \r>0. U = mball x r))" +proof - + have "\S. \x r. x \ M \ 0 < r \ S = mball x r \ openin mtopology S" + using openin_mball by blast + moreover have "\U x. \openin mtopology U; x \ U\ \ \B. (\x r. x \ M \ 0 < r \ B = mball x r) \ x \ B \ B \ U" + by (metis centre_in_mball_iff in_mono openin_mtopology) + ultimately show ?thesis + by (smt (verit) topology_base_unique) +qed + +lemma closedin_metric: + "closedin mtopology C \ C \ M \ (\x. x \ M - C \ (\r>0. disjnt C (mball x r)))" (is "?lhs = ?rhs") +proof + show "?lhs \ ?rhs" + unfolding closedin_def openin_mtopology + by (metis Diff_disjoint disjnt_def disjnt_subset2 topspace_mtopology) + show "?rhs \ ?lhs" + unfolding closedin_def openin_mtopology disjnt_def + by (metis Diff_subset Diff_triv Int_Diff Int_commute inf.absorb_iff2 mball_subset_mspace topspace_mtopology) +qed + +lemma closedin_mcball [iff]: "closedin mtopology (mcball x r)" +proof - + have "\ra>0. disjnt (mcball x r) (mball y ra)" if "x \ M" for y + by (metis disjnt_empty1 gt_ex mcball_eq_empty that) + moreover have "disjnt (mcball x r) (mball y (d x y - r))" if "y \ M" "d x y > r" for y + using that disjnt_iff in_mball in_mcball mdist_reverse_triangle by force + ultimately show ?thesis + using closedin_metric mcball_subset_mspace by fastforce +qed + +lemma mball_iff_mcball: "(\r>0. mball x r \ U) = (\r>0. mcball x r \ U)" + by (meson dense mball_subset_mcball mcball_subset_mball_concentric order_trans) + +lemma openin_mtopology_mcball: + "openin mtopology U \ U \ M \ (\x. x \ U \ (\r. 0 < r \ mcball x r \ U))" + using mball_iff_mcball openin_mtopology by presburger + +lemma metric_derived_set_of: + "mtopology derived_set_of S = {x \ M. \r>0. \y\S. y\x \ y \ mball x r}" (is "?lhs=?rhs") +proof + show "?lhs \ ?rhs" + unfolding openin_mtopology derived_set_of_def + by clarsimp (metis in_mball openin_mball openin_mtopology zero) + show "?rhs \ ?lhs" + unfolding openin_mtopology derived_set_of_def + by clarify (metis subsetD topspace_mtopology) +qed + +lemma metric_closure_of: + "mtopology closure_of S = {x \ M. \r>0. \y \ S. y \ mball x r}" +proof - + have "\x r. \0 < r; x \ mtopology closure_of S\ \ \y\S. y \ mball x r" + by (metis centre_in_mball_iff in_closure_of openin_mball topspace_mtopology) + moreover have "\x T. \x \ M; \r>0. \y\S. y \ mball x r\ \ x \ mtopology closure_of S" + by (smt (verit) in_closure_of in_mball openin_mtopology subsetD topspace_mtopology) + ultimately show ?thesis + by (auto simp: in_closure_of) +qed + +lemma metric_closure_of_alt: + "mtopology closure_of S = {x \ M. \r>0. \y \ S. y \ mcball x r}" +proof - + have "\x r. \\r>0. x \ M \ (\y\S. y \ mcball x r); 0 < r\ \ \y\S. y \ M \ d x y < r" + by (meson dense in_mcball le_less_trans) + then show ?thesis + by (fastforce simp: metric_closure_of in_closure_of) +qed + +lemma metric_interior_of: + "mtopology interior_of S = {x \ M. \\>0. mball x \ \ S}" (is "?lhs=?rhs") +proof + show "?lhs \ ?rhs" + using interior_of_maximal_eq openin_mtopology by fastforce + show "?rhs \ ?lhs" + using interior_of_def openin_mball by fastforce +qed + +lemma metric_interior_of_alt: + "mtopology interior_of S = {x \ M. \\>0. mcball x \ \ S}" + by (fastforce simp: mball_iff_mcball metric_interior_of) + +lemma in_interior_of_mball: + "x \ mtopology interior_of S \ x \ M \ (\\>0. mball x \ \ S)" + using metric_interior_of by force + +lemma in_interior_of_mcball: + "x \ mtopology interior_of S \ x \ M \ (\\>0. mcball x \ \ S)" + using metric_interior_of_alt by force + +lemma Hausdorff_space_mtopology: "Hausdorff_space mtopology" + unfolding Hausdorff_space_def +proof clarify + fix x y + assume x: "x \ topspace mtopology" and y: "y \ topspace mtopology" and "x \ y" + then have gt0: "d x y / 2 > 0" + by auto + have "disjnt (mball x (d x y / 2)) (mball y (d x y / 2))" + by (simp add: disjoint_mball) + then show "\U V. openin mtopology U \ openin mtopology V \ x \ U \ y \ V \ disjnt U V" + by (metis centre_in_mball_iff gt0 openin_mball topspace_mtopology x y) +qed + + + +subsection\Bounded sets\ + +definition mbounded where "mbounded S \ (\x B. S \ mcball x B)" + +lemma mbounded_pos: "mbounded S \ (\x B. 0 < B \ S \ mcball x B)" +proof - + have "\x' r'. 0 < r' \ S \ mcball x' r'" if "S \ mcball x r" for x r + by (metis gt_ex less_eq_real_def linorder_not_le mcball_subset_concentric order_trans that) + then show ?thesis + by (auto simp: mbounded_def) +qed + +lemma mbounded_alt: + "mbounded S \ S \ M \ (\B. \x \ S. \y \ S. d x y \ B)" +proof - + have "\x B. S \ mcball x B \ \x\S. \y\S. d x y \ 2 * B" + by (smt (verit, best) commute in_mcball subsetD triangle) + then show ?thesis + apply (auto simp: mbounded_def subset_iff) + apply blast+ + done +qed + + +lemma mbounded_alt_pos: + "mbounded S \ S \ M \ (\B>0. \x \ S. \y \ S. d x y \ B)" + by (smt (verit, del_insts) gt_ex mbounded_alt) + +lemma mbounded_subset: "\mbounded T; S \ T\ \ mbounded S" + by (meson mbounded_def order_trans) + +lemma mbounded_subset_mspace: "mbounded S \ S \ M" + by (simp add: mbounded_alt) + +lemma mbounded: + "mbounded S \ S = {} \ (\x \ S. x \ M) \ (\y B. y \ M \ (\x \ S. d y x \ B))" + by (meson all_not_in_conv in_mcball mbounded_def subset_iff) + +lemma mbounded_empty [iff]: "mbounded {}" + by (simp add: mbounded) + +lemma mbounded_mcball: "mbounded (mcball x r)" + using mbounded_def by auto + +lemma mbounded_mball [iff]: "mbounded (mball x r)" + by (meson mball_subset_mcball mbounded_def) + +lemma mbounded_insert: "mbounded (insert a S) \ a \ M \ mbounded S" +proof - + have "\y B. \y \ M; \x\S. d y x \ B\ + \ \y. y \ M \ (\B \ d y a. \x\S. d y x \ B)" + by (metis order.trans nle_le) + then show ?thesis + by (auto simp: mbounded) +qed + +lemma mbounded_Int: "mbounded S \ mbounded (S \ T)" + by (meson inf_le1 mbounded_subset) + +lemma mbounded_Un: "mbounded (S \ T) \ mbounded S \ mbounded T" (is "?lhs=?rhs") +proof + assume R: ?rhs + show ?lhs + proof (cases "S={} \ T={}") + case True then show ?thesis + using R by auto + next + case False + obtain x y B C where "S \ mcball x B" "T \ mcball y C" "B > 0" "C > 0" "x \ M" "y \ M" + using R mbounded_pos + by (metis False mcball_eq_empty subset_empty) + then have "S \ T \ mcball x (B + C + d x y)" + by (smt (verit) commute dual_order.trans le_supI mcball_subset mdist_pos_eq) + then show ?thesis + using mbounded_def by blast + qed +next + show "?lhs \ ?rhs" + using mbounded_def by auto +qed + +lemma mbounded_Union: + "\finite \; \X. X \ \ \ mbounded X\ \ mbounded (\\)" + by (induction \ rule: finite_induct) (auto simp: mbounded_Un) + +lemma mbounded_closure_of: + "mbounded S \ mbounded (mtopology closure_of S)" + by (meson closedin_mcball closure_of_minimal mbounded_def) + +lemma mbounded_closure_of_eq: + "S \ M \ (mbounded (mtopology closure_of S) \ mbounded S)" + by (metis closure_of_subset mbounded_closure_of mbounded_subset topspace_mtopology) + + +lemma maxdist_thm: + assumes "mbounded S" + and "x \ S" + and "y \ S" + shows "d x y = (SUP z\S. \d x z - d z y\)" +proof - + have "\d x z - d z y\ \ d x y" if "z \ S" for z + by (metis all_not_in_conv assms mbounded mdist_reverse_triangle that) + moreover have "d x y \ r" + if "\z. z \ S \ \d x z - d z y\ \ r" for r :: real + using that assms mbounded_subset_mspace mdist_zero by fastforce + ultimately show ?thesis + by (intro cSup_eq [symmetric]) auto +qed + + +lemma metric_eq_thm: "\S \ M; x \ S; y \ S\ \ (x = y) = (\z\S. d x z = d y z)" + by (metis commute subset_iff zero) + +lemma compactin_imp_mbounded: + assumes "compactin mtopology S" + shows "mbounded S" +proof - + have "S \ M" + and com: "\\. \\U\\. openin mtopology U; S \ \\\ \ \\. finite \ \ \ \ \ \ S \ \\" + using assms by (auto simp: compactin_def mbounded_def) + show ?thesis + proof (cases "S = {}") + case False + with \S \ M\ obtain a where "a \ S" "a \ M" + by blast + with \S \ M\ gt_ex have "S \ \(range (mball a))" + by force + moreover have "\U \ range (mball a). openin mtopology U" + by (simp add: openin_mball) + ultimately obtain \ where "finite \" "\ \ range (mball a)" "S \ \\" + by (meson com) + then show ?thesis + using mbounded_Union mbounded_subset by fastforce + qed auto +qed + +end + + +subsection\Subspace of a metric space\ + +locale submetric = Metric_space + + fixes A + assumes subset: "A \ M" + +sublocale submetric \ sub: Metric_space A d + by (simp add: subset subspace) + +context submetric +begin + +lemma mball_submetric_eq: "sub.mball a r = (if a \ A then A \ mball a r else {})" +and mcball_submetric_eq: "sub.mcball a r = (if a \ A then A \ mcball a r else {})" + using subset by force+ + +lemma mtopology_submetric: "sub.mtopology = subtopology mtopology A" + unfolding topology_eq +proof (intro allI iffI) + fix S + assume "openin sub.mtopology S" + then have "\T. openin (subtopology mtopology A) T \ x \ T \ T \ S" if "x \ S" for x + by (metis mball_submetric_eq openin_mball openin_subtopology_Int2 sub.centre_in_mball_iff sub.openin_mtopology subsetD that) + then show "openin (subtopology mtopology A) S" + by (meson openin_subopen) +next + fix S + assume "openin (subtopology mtopology A) S" + then obtain T where "openin mtopology T" "S = T \ A" + by (meson openin_subtopology) + then have "mopen T" + by (simp add: mopen_def openin_mtopology) + then have "sub.mopen (T \ A)" + unfolding sub.mopen_def mopen_def + by (metis inf.coboundedI2 mball_submetric_eq Int_iff \S = T \ A\ inf.bounded_iff subsetI) + then show "openin sub.mtopology S" + using \S = T \ A\ sub.mopen_def sub.openin_mtopology by force +qed + +lemma mbounded_submetric: "sub.mbounded T \ mbounded T \ T \ A" + by (meson mbounded_alt sub.mbounded_alt subset subset_trans) + +end + +lemma (in Metric_space) submetric_empty [iff]: "submetric M d {}" + by (simp add: Metric_space_axioms submetric.intro submetric_axioms_def) + + +subsection\The discrete metric\ + +locale discrete_metric = + fixes M :: "'a set" + +definition (in discrete_metric) dd :: "'a \ 'a \ real" + where "dd \ \x y::'a. if x=y then 0 else 1" + +lemma metric_M_dd: "Metric_space M discrete_metric.dd" + by (simp add: discrete_metric.dd_def Metric_space.intro) + +sublocale discrete_metric \ disc: Metric_space M dd + by (simp add: metric_M_dd) + + +lemma (in discrete_metric) mopen_singleton: + assumes "x \ M" shows "disc.mopen {x}" +proof - + have "disc.mball x (1/2) \ {x}" + by (smt (verit) dd_def disc.in_mball less_divide_eq_1_pos singleton_iff subsetI) + with assms show ?thesis + using disc.mopen_def half_gt_zero_iff zero_less_one by blast +qed + +lemma (in discrete_metric) mtopology_discrete_metric: + "disc.mtopology = discrete_topology M" +proof - + have "\x. x \ M \ openin disc.mtopology {x}" + by (simp add: disc.mtopology_def mopen_singleton) + then show ?thesis + by (metis disc.topspace_mtopology discrete_topology_unique) +qed + +lemma (in discrete_metric) discrete_ultrametric: + "dd x z \ max (dd x y) (dd y z)" + by (simp add: dd_def) + + +lemma (in discrete_metric) dd_le1: "dd x y \ 1" + by (simp add: dd_def) + +lemma (in discrete_metric) mbounded_discrete_metric: "disc.mbounded S \ S \ M" + by (meson dd_le1 disc.mbounded_alt) + + + +subsection\Metrizable spaces\ + +definition metrizable_space where + "metrizable_space X \ \M d. Metric_space M d \ X = Metric_space.mtopology M d" + +lemma (in Metric_space) metrizable_space_mtopology: "metrizable_space mtopology" + using local.Metric_space_axioms metrizable_space_def by blast + +lemma openin_mtopology_eq_open [simp]: "openin Met_TC.mtopology = open" + by (simp add: Met_TC.mtopology_def) + +lemma closedin_mtopology_eq_closed [simp]: "closedin Met_TC.mtopology = closed" +proof - + have "(euclidean::'a topology) = Met_TC.mtopology" + by (simp add: Met_TC.mtopology_def) + then show ?thesis + using closed_closedin by fastforce +qed + +lemma compactin_mtopology_eq_compact [simp]: "compactin Met_TC.mtopology = compact" + by (simp add: compactin_def compact_eq_Heine_Borel fun_eq_iff) meson + +lemma metrizable_space_discrete_topology: + "metrizable_space(discrete_topology U)" + by (metis discrete_metric.mtopology_discrete_metric metric_M_dd metrizable_space_def) + +lemma metrizable_space_subtopology: + assumes "metrizable_space X" + shows "metrizable_space(subtopology X S)" +proof - + obtain M d where "Metric_space M d" and X: "X = Metric_space.mtopology M d" + using assms metrizable_space_def by blast + then interpret submetric M d "M \ S" + by (simp add: submetric.intro submetric_axioms_def) + show ?thesis + unfolding metrizable_space_def + by (metis X mtopology_submetric sub.Metric_space_axioms subtopology_restrict topspace_mtopology) +qed + +lemma homeomorphic_metrizable_space_aux: + assumes "X homeomorphic_space Y" "metrizable_space X" + shows "metrizable_space Y" +proof - + obtain M d where "Metric_space M d" and X: "X = Metric_space.mtopology M d" + using assms by (auto simp: metrizable_space_def) + then interpret m: Metric_space M d + by simp + obtain f g where hmf: "homeomorphic_map X Y f" and hmg: "homeomorphic_map Y X g" + and fg: "(\x \ M. g(f x) = x) \ (\y \ topspace Y. f(g y) = y)" + using assms X homeomorphic_maps_map homeomorphic_space_def by fastforce + define d' where "d' x y \ d (g x) (g y)" for x y + interpret m': Metric_space "topspace Y" "d'" + unfolding d'_def + proof + show "(d (g x) (g y) = 0) = (x = y)" if "x \ topspace Y" "y \ topspace Y" for x y + by (metis fg X hmg homeomorphic_imp_surjective_map imageI m.topspace_mtopology m.zero that) + show "d (g x) (g z) \ d (g x) (g y) + d (g y) (g z)" + if "x \ topspace Y" and "y \ topspace Y" and "z \ topspace Y" for x y z + by (metis X that hmg homeomorphic_eq_everything_map imageI m.topspace_mtopology m.triangle) + qed (auto simp: m.nonneg m.commute) + have "Y = Metric_space.mtopology (topspace Y) d'" + unfolding topology_eq + proof (intro allI) + fix S + have "openin m'.mtopology S" if S: "S \ topspace Y" and "openin X (g ` S)" + unfolding m'.openin_mtopology + proof (intro conjI that strip) + fix y + assume "y \ S" + then obtain r where "r>0" and r: "m.mball (g y) r \ g ` S" + using X \openin X (g ` S)\ m.openin_mtopology using \y \ S\ by auto + then have "g ` m'.mball y r \ m.mball (g y) r" + using X d'_def hmg homeomorphic_imp_surjective_map by fastforce + with S fg have "m'.mball y r \ S" + by (smt (verit, del_insts) image_iff m'.in_mball r subset_iff) + then show "\r>0. m'.mball y r \ S" + using \0 < r\ by blast + qed + moreover have "openin X (g ` S)" if ope': "openin m'.mtopology S" + proof - + have "\r>0. m.mball (g y) r \ g ` S" if "y \ S" for y + proof - + have y: "y \ topspace Y" + using m'.openin_mtopology ope' that by blast + obtain r where "r > 0" and r: "m'.mball y r \ S" + using ope' by (meson \y \ S\ m'.openin_mtopology) + moreover have "\x. \x \ M; d (g y) x < r\ \ \u. u \ topspace Y \ d' y u < r \ x = g u" + using fg X d'_def hmf homeomorphic_imp_surjective_map by fastforce + ultimately have "m.mball (g y) r \ g ` m'.mball y r" + using y by (force simp: m'.openin_mtopology) + then show ?thesis + using \0 < r\ r by blast + qed + then show ?thesis + using X hmg homeomorphic_imp_surjective_map m.openin_mtopology ope' openin_subset by fastforce + qed + ultimately have "(S \ topspace Y \ openin X (g ` S)) = openin m'.mtopology S" + using m'.topspace_mtopology openin_subset by blast + then show "openin Y S = openin m'.mtopology S" + by (simp add: m'.mopen_def homeomorphic_map_openness_eq [OF hmg]) + qed + then show ?thesis + using m'.metrizable_space_mtopology by force +qed + +lemma homeomorphic_metrizable_space: + assumes "X homeomorphic_space Y" + shows "metrizable_space X \ metrizable_space Y" + using assms homeomorphic_metrizable_space_aux homeomorphic_space_sym by metis + +lemma metrizable_space_retraction_map_image: + "retraction_map X Y r \ metrizable_space X + \ metrizable_space Y" + using hereditary_imp_retractive_property metrizable_space_subtopology homeomorphic_metrizable_space + by blast + + +lemma metrizable_imp_Hausdorff_space: + "metrizable_space X \ Hausdorff_space X" + by (metis Metric_space.Hausdorff_space_mtopology metrizable_space_def) + +(** +lemma metrizable_imp_kc_space: + "metrizable_space X \ kc_space X" +oops + MESON_TAC[METRIZABLE_IMP_HAUSDORFF_SPACE; HAUSDORFF_IMP_KC_SPACE]);; + +lemma kc_space_mtopology: + "kc_space mtopology" +oops + REWRITE_TAC[GSYM FORALL_METRIZABLE_SPACE; METRIZABLE_IMP_KC_SPACE]);; +**) + +lemma metrizable_imp_t1_space: + "metrizable_space X \ t1_space X" + by (simp add: Hausdorff_imp_t1_space metrizable_imp_Hausdorff_space) + +lemma closed_imp_gdelta_in: + assumes X: "metrizable_space X" and S: "closedin X S" + shows "gdelta_in X S" +proof - + obtain M d where "Metric_space M d" and Xeq: "X = Metric_space.mtopology M d" + using X metrizable_space_def by blast + then interpret M: Metric_space M d + by blast + have "S \ M" + using M.closedin_metric \X = M.mtopology\ S by blast + show ?thesis + proof (cases "S = {}") + case True + then show ?thesis + by simp + next + case False + have "\y\S. d x y < inverse (1 + real n)" if "x \ S" for x n + using \S \ M\ M.mdist_zero [of x] that by force + moreover + have "x \ S" if "x \ M" and \
: "\n. \y\S. d x y < inverse(Suc n)" for x + proof - + have *: "\y\S. d x y < \" if "\ > 0" for \ + by (metis \
that not0_implies_Suc order_less_le order_less_le_trans real_arch_inverse) + have "closedin M.mtopology S" + using S by (simp add: Xeq) + then show ?thesis + apply (simp add: M.closedin_metric) + by (metis * \x \ M\ M.in_mball disjnt_insert1 insert_absorb subsetD) + qed + ultimately have Seq: "S = \(range (\n. {x\M. \y\S. d x y < inverse(Suc n)}))" + using \S \ M\ by force + have "openin M.mtopology {xa \ M. \y\S. d xa y < inverse (1 + real n)}" for n + proof (clarsimp simp: M.openin_mtopology) + fix x y + assume "x \ M" "y \ S" and dxy: "d x y < inverse (1 + real n)" + then have "\z. \z \ M; d x z < inverse (1 + real n) - d x y\ \ \y\S. d z y < inverse (1 + real n)" + by (smt (verit) M.commute M.triangle \S \ M\ in_mono) + with dxy show "\r>0. M.mball x r \ {z \ M. \y\S. d z y < inverse (1 + real n)}" + by (rule_tac x="inverse(Suc n) - d x y" in exI) auto + qed + then show ?thesis + apply (subst Seq) + apply (force simp: Xeq intro: gdelta_in_Inter open_imp_gdelta_in) + done + qed +qed + +lemma open_imp_fsigma_in: + "\metrizable_space X; openin X S\ \ fsigma_in X S" + by (meson closed_imp_gdelta_in fsigma_in_gdelta_in openin_closedin openin_subset) + +(*NEEDS first_countable +lemma first_countable_mtopology: + "first_countable mtopology" +oops + GEN_TAC THEN REWRITE_TAC[first_countable; TOPSPACE_MTOPOLOGY] THEN + X_GEN_TAC `x::A` THEN DISCH_TAC THEN + EXISTS_TAC `{ mball m (x::A,r) | rational r \ 0 < r}` THEN + REWRITE_TAC[FORALL_IN_GSPEC; OPEN_IN_MBALL; EXISTS_IN_GSPEC] THEN + ONCE_REWRITE_TAC[SET_RULE + `{f x | S x \ Q x} = f ` {x \ S. Q x}`] THEN + SIMP_TAC[COUNTABLE_IMAGE; COUNTABLE_RATIONAL; COUNTABLE_RESTRICT] THEN + REWRITE_TAC[OPEN_IN_MTOPOLOGY] THEN + X_GEN_TAC `U::A=>bool` THEN STRIP_TAC THEN + FIRST_X_ASSUM(MP_TAC \ SPEC `x::A`) THEN + ASM_REWRITE_TAC[LEFT_IMP_EXISTS_THM] THEN + X_GEN_TAC `r::real` THEN STRIP_TAC THEN FIRST_ASSUM + (MP_TAC \ SPEC `r::real` \ MATCH_MP RATIONAL_APPROXIMATION_BELOW) THEN + MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `q::real` THEN + REWRITE_TAC[REAL_SUB_REFL] THEN STRIP_TAC THEN + ASM_SIMP_TAC[CENTRE_IN_MBALL] THEN + TRANS_TAC SUBSET_TRANS `mball m (x::A,r)` THEN + ASM_SIMP_TAC[MBALL_SUBSET_CONCENTRIC; REAL_LT_IMP_LE]);; + +lemma metrizable_imp_first_countable: + "metrizable_space X \ first_countable X" +oops + REWRITE_TAC[FORALL_METRIZABLE_SPACE; FIRST_COUNTABLE_MTOPOLOGY]);; +*) + +lemma mball_eq_ball [simp]: "Met_TC.mball = ball" + by force + +lemma mopen_eq_open [simp]: "Met_TC.mopen = open" + by (force simp: open_contains_ball Met_TC.mopen_def) + +lemma metrizable_space_euclidean: + "metrizable_space (euclidean :: 'a::metric_space topology)" + unfolding metrizable_space_def + by (metis Met_TC.Metric_space_axioms Met_TC.mtopology_def mopen_eq_open) + +lemma (in Metric_space) regular_space_mtopology: + "regular_space mtopology" +unfolding regular_space_def +proof clarify + fix C a + assume C: "closedin mtopology C" and a: "a \ topspace mtopology" and "a \ C" + have "openin mtopology (topspace mtopology - C)" + by (simp add: C openin_diff) + then obtain r where "r>0" and r: "mball a r \ topspace mtopology - C" + unfolding openin_mtopology using \a \ C\ a by auto + show "\U V. openin mtopology U \ openin mtopology V \ a \ U \ C \ V \ disjnt U V" + proof (intro exI conjI) + show "a \ mball a (r/2)" + using \0 < r\ a by force + show "C \ topspace mtopology - mcball a (r/2)" + using C \0 < r\ r by (fastforce simp: closedin_metric) + qed (auto simp: openin_mball closedin_mcball openin_diff disjnt_iff) +qed + +lemma metrizable_imp_regular_space: + "metrizable_space X \ regular_space X" + by (metis Metric_space.regular_space_mtopology metrizable_space_def) + +lemma regular_space_euclidean: + "regular_space (euclidean :: 'a::metric_space topology)" + by (simp add: metrizable_imp_regular_space metrizable_space_euclidean) + + +subsection\Limits at a point in a topological space\ + +lemma (in Metric_space) eventually_atin_metric: + "eventually P (atin mtopology a) \ + (a \ M \ (\\>0. \x. x \ M \ 0 < d x a \ d x a < \ \ P x))" (is "?lhs=?rhs") +proof (cases "a \ M") + case True + show ?thesis + proof + assume L: ?lhs + with True obtain U where "openin mtopology U" "a \ U" and U: "\x\U - {a}. P x" + by (auto simp: eventually_atin) + then obtain r where "r>0" and "mball a r \ U" + by (meson openin_mtopology) + with U show ?rhs + by (smt (verit, ccfv_SIG) commute in_mball insert_Diff_single insert_iff subset_iff) + next + assume ?rhs + then obtain \ where "\>0" and \: "\x. x \ M \ 0 < d x a \ d x a < \ \ P x" + using True by blast + then have "\x \ mball a \ - {a}. P x" + by (simp add: commute) + then show ?lhs + unfolding eventually_atin openin_mtopology + by (metis True \0 < \\ centre_in_mball_iff openin_mball openin_mtopology) + qed +qed auto + +subsection \Normal spaces and metric spaces\ + +lemma (in Metric_space) normal_space_mtopology: + "normal_space mtopology" + unfolding normal_space_def +proof clarify + fix S T + assume "closedin mtopology S" + then have "\x. x \ M - S \ (\r>0. mball x r \ M - S)" + by (simp add: closedin_def openin_mtopology) + then obtain \ where d0: "\x. x \ M - S \ \ x > 0 \ mball x (\ x) \ M - S" + by metis + assume "closedin mtopology T" + then have "\x. x \ M - T \ (\r>0. mball x r \ M - T)" + by (simp add: closedin_def openin_mtopology) + then obtain \ where e: "\x. x \ M - T \ \ x > 0 \ mball x (\ x) \ M - T" + by metis + assume "disjnt S T" + have "S \ M" "T \ M" + using \closedin mtopology S\ \closedin mtopology T\ closedin_metric by blast+ + have \: "\x. x \ T \ \ x > 0 \ mball x (\ x) \ M - S" + by (meson DiffI \T \ M\ \disjnt S T\ d0 disjnt_iff subsetD) + have \: "\x. x \ S \ \ x > 0 \ mball x (\ x) \ M - T" + by (meson Diff_iff \S \ M\ \disjnt S T\ disjnt_iff e subsetD) + show "\U V. openin mtopology U \ openin mtopology V \ S \ U \ T \ V \ disjnt U V" + proof (intro exI conjI) + show "openin mtopology (\x\S. mball x (\ x / 2))" "openin mtopology (\x\T. mball x (\ x / 2))" + by force+ + show "S \ (\x\S. mball x (\ x / 2))" + using \ \S \ M\ by force + show "T \ (\x\T. mball x (\ x / 2))" + using \ \T \ M\ by force + show "disjnt (\x\S. mball x (\ x / 2)) (\x\T. mball x (\ x / 2))" + using \ \ + apply (clarsimp simp: disjnt_iff subset_iff) + by (smt (verit, ccfv_SIG) field_sum_of_halves triangle') + qed +qed + +lemma metrizable_imp_normal_space: + "metrizable_space X \ normal_space X" + by (metis Metric_space.normal_space_mtopology metrizable_space_def) + +subsection\Topological limitin in metric spaces\ + + +lemma (in Metric_space) limitin_mspace: + "limitin mtopology f l F \ l \ M" + using limitin_topspace by fastforce + +lemma (in Metric_space) limitin_metric_unique: + "\limitin mtopology f l1 F; limitin mtopology f l2 F; F \ bot\ \ l1 = l2" + by (meson Hausdorff_space_mtopology limitin_Hausdorff_unique) + +lemma (in Metric_space) limitin_metric: + "limitin mtopology f l F \ l \ M \ (\\>0. eventually (\x. f x \ M \ d (f x) l < \) F)" + (is "?lhs=?rhs") +proof + assume L: ?lhs + show ?rhs + unfolding limitin_def + proof (intro conjI strip) + show "l \ M" + using L limitin_mspace by blast + fix \::real + assume "\>0" + then have "\\<^sub>F x in F. f x \ mball l \" + using L openin_mball by (fastforce simp: limitin_def) + then show "\\<^sub>F x in F. f x \ M \ d (f x) l < \" + using commute eventually_mono by fastforce + qed +next + assume R: ?rhs + then show ?lhs + by (force simp: limitin_def commute openin_mtopology subset_eq elim: eventually_mono) +qed + +lemma (in Metric_space) limit_metric_sequentially: + "limitin mtopology f l sequentially \ + l \ M \ (\\>0. \N. \n\N. f n \ M \ d (f n) l < \)" + by (auto simp: limitin_metric eventually_sequentially) + +lemma (in submetric) limitin_submetric_iff: + "limitin sub.mtopology f l F \ + l \ A \ eventually (\x. f x \ A) F \ limitin mtopology f l F" (is "?lhs=?rhs") + by (simp add: limitin_subtopology mtopology_submetric) + +lemma (in Metric_space) metric_closedin_iff_sequentially_closed: + "closedin mtopology S \ + S \ M \ (\\ l. range \ \ S \ limitin mtopology \ l sequentially \ l \ S)" (is "?lhs=?rhs") +proof + assume ?lhs then show ?rhs + by (force simp: closedin_metric limitin_closedin range_subsetD) +next + assume R: ?rhs + show ?lhs + unfolding closedin_metric + proof (intro conjI strip) + show "S \ M" + using R by blast + fix x + assume "x \ M - S" + have False if "\r>0. \y. y \ M \ y \ S \ d x y < r" + proof - + have "\n. \y. y \ M \ y \ S \ d x y < inverse(Suc n)" + using that by auto + then obtain \ where \: "\n. \ n \ M \ \ n \ S \ d x (\ n) < inverse(Suc n)" + by metis + then have "range \ \ M" + by blast + have "\N. \n\N. d x (\ n) < \" if "\>0" for \ + proof - + have "real (Suc (nat \inverse \\)) \ inverse \" + by linarith + then have "\n \ nat \inverse \\. d x (\ n) < \" + by (metis \ inverse_inverse_eq inverse_le_imp_le nat_ceiling_le_eq nle_le not_less_eq_eq order.strict_trans2 that) + then show ?thesis .. + qed + with \ have "limitin mtopology \ x sequentially" + using \x \ M - S\ commute limit_metric_sequentially by auto + then show ?thesis + by (metis R DiffD2 \ image_subset_iff \x \ M - S\) + qed + then show "\r>0. disjnt S (mball x r)" + by (meson disjnt_iff in_mball) + qed +qed + +lemma (in Metric_space) limit_atin_metric: + "limitin X f y (atin mtopology x) \ + y \ topspace X \ + (x \ M + \ (\V. openin X V \ y \ V + \ (\\>0. \x'. x' \ M \ 0 < d x' x \ d x' x < \ \ f x' \ V)))" + by (force simp: limitin_def eventually_atin_metric) + +lemma (in Metric_space) limitin_metric_dist_null: + "limitin mtopology f l F \ l \ M \ eventually (\x. f x \ M) F \ ((\x. d (f x) l) \ 0) F" + by (simp add: limitin_metric tendsto_iff eventually_conj_iff all_conj_distrib imp_conjR gt_ex) + + +subsection\Cauchy sequences and complete metric spaces\ + +context Metric_space +begin + +definition MCauchy :: "(nat \ 'a) \ bool" + where "MCauchy \ \ range \ \ M \ (\\>0. \N. \n n'. N \ n \ N \ n' \ d (\ n) (\ n') < \)" + +definition mcomplete + where "mcomplete \ (\\. MCauchy \ \ (\x. limitin mtopology \ x sequentially))" + +lemma mcomplete_empty [iff]: "Metric_space.mcomplete {} d" + by (simp add: Metric_space.MCauchy_def Metric_space.mcomplete_def subspace) + +lemma MCauchy_imp_MCauchy_suffix: "MCauchy \ \ MCauchy (\ \ (+)n)" + unfolding MCauchy_def image_subset_iff comp_apply + by (metis UNIV_I add.commute trans_le_add1) + +lemma mcomplete: + "mcomplete \ + (\\. (\\<^sub>F n in sequentially. \ n \ M) \ + (\\>0. \N. \n n'. N \ n \ N \ n' \ d (\ n) (\ n') < \) \ + (\x. limitin mtopology \ x sequentially))" (is "?lhs=?rhs") +proof + assume L: ?lhs + show ?rhs + proof clarify + fix \ + assume "\\<^sub>F n in sequentially. \ n \ M" + and \: "\\>0. \N. \n n'. N \ n \ N \ n' \ d (\ n) (\ n') < \" + then obtain N where "\n. n\N \ \ n \ M" + by (auto simp: eventually_sequentially) + with \ have "MCauchy (\ \ (+)N)" + unfolding MCauchy_def image_subset_iff comp_apply by (meson le_add1 trans_le_add2) + then obtain x where "limitin mtopology (\ \ (+)N) x sequentially" + using L MCauchy_imp_MCauchy_suffix mcomplete_def by blast + then have "limitin mtopology \ x sequentially" + unfolding o_def by (auto simp: add.commute limitin_sequentially_offset_rev) + then show "\x. limitin mtopology \ x sequentially" .. + qed +qed (simp add: mcomplete_def MCauchy_def image_subset_iff) + +lemma mcomplete_empty_mspace: "M = {} \ mcomplete" + using MCauchy_def mcomplete_def by blast + +lemma MCauchy_const [simp]: "MCauchy (\n. a) \ a \ M" + using MCauchy_def mdist_zero by auto + +lemma convergent_imp_MCauchy: + assumes "range \ \ M" and lim: "limitin mtopology \ l sequentially" + shows "MCauchy \" + unfolding MCauchy_def image_subset_iff +proof (intro conjI strip) + fix \::real + assume "\ > 0" + then have "\\<^sub>F n in sequentially. \ n \ M \ d (\ n) l < \/2" + using half_gt_zero lim limitin_metric by blast + then obtain N where "\n. n\N \ \ n \ M \ d (\ n) l < \/2" + by (force simp: eventually_sequentially) + then show "\N. \n n'. N \ n \ N \ n' \ d (\ n) (\ n') < \" + by (smt (verit) Metric_space.limitin_mspace Metric_space.mdist_reverse_triangle Metric_space_axioms field_sum_of_halves lim) +qed (use assms in blast) + + +lemma mcomplete_alt: + "mcomplete \ (\\. MCauchy \ \ range \ \ M \ (\x. limitin mtopology \ x sequentially))" + using MCauchy_def convergent_imp_MCauchy mcomplete_def by blast + +lemma MCauchy_subsequence: + assumes "strict_mono r" "MCauchy \" + shows "MCauchy (\ \ r)" +proof - + have "d (\ (r n)) (\ (r n')) < \" + if "N \ n" "N \ n'" "strict_mono r" "\n n'. N \ n \ N \ n' \ d (\ n) (\ n') < \" + for \ N n n' + using that by (meson le_trans strict_mono_imp_increasing) + moreover have "range (\x. \ (r x)) \ M" + using MCauchy_def assms by blast + ultimately show ?thesis + using assms by (simp add: MCauchy_def) metis +qed + +lemma MCauchy_offset: + assumes cau: "MCauchy (\ \ (+)k)" and \: "\n. n < k \ \ n \ M" + shows "MCauchy \" + unfolding MCauchy_def image_subset_iff +proof (intro conjI strip) + fix n + show "\ n \ M" + using assms + unfolding MCauchy_def image_subset_iff + by (metis UNIV_I comp_apply le_iff_add linorder_not_le) +next + fix \ :: real + assume "\ > 0" + obtain N where "\n n'. N \ n \ N \ n' \ d ((\ \ (+)k) n) ((\ \ (+)k) n') < \" + using cau \\ > 0\ by (fastforce simp: MCauchy_def) + then show "\N. \n n'. N \ n \ N \ n' \ d (\ n) (\ n') < \" + unfolding o_def + apply (rule_tac x="k+N" in exI) + by (smt (verit, del_insts) add.assoc le_add1 less_eqE) +qed + +lemma MCauchy_convergent_subsequence: + assumes cau: "MCauchy \" and "strict_mono r" + and lim: "limitin mtopology (\ \ r) a sequentially" + shows "limitin mtopology \ a sequentially" + unfolding limitin_metric +proof (intro conjI strip) + show "a \ M" + by (meson assms limitin_mspace) + fix \ :: real + assume "\ > 0" + then obtain N1 where N1: "\n n'. \n\N1; n'\N1\ \ d (\ n) (\ n') < \/2" + using cau unfolding MCauchy_def by (meson half_gt_zero) + obtain N2 where N2: "\n. n \ N2 \ (\ \ r) n \ M \ d ((\ \ r) n) a < \/2" + by (metis (no_types, lifting) lim \\ > 0\ half_gt_zero limit_metric_sequentially) + have "\ n \ M \ d (\ n) a < \" if "n \ max N1 N2" for n + proof (intro conjI) + show "\ n \ M" + using MCauchy_def cau by blast + have "N1 \ r n" + by (meson \strict_mono r\ le_trans max.cobounded1 strict_mono_imp_increasing that) + then show "d (\ n) a < \" + using N1[of n "r n"] N2[of n] \\ n \ M\ \a \ M\ triangle that by fastforce + qed + then show "\\<^sub>F n in sequentially. \ n \ M \ d (\ n) a < \" + using eventually_sequentially by blast +qed + +lemma MCauchy_interleaving_gen: + "MCauchy (\n. if even n then x(n div 2) else y(n div 2)) \ + (MCauchy x \ MCauchy y \ (\n. d (x n) (y n)) \ 0)" (is "?lhs=?rhs") +proof + assume L: ?lhs + have evens: "strict_mono (\n::nat. 2 * n)" and odds: "strict_mono (\n::nat. Suc (2 * n))" + by (auto simp: strict_mono_def) + show ?rhs + proof (intro conjI) + show "MCauchy x" "MCauchy y" + using MCauchy_subsequence [OF evens L] MCauchy_subsequence [OF odds L] by (auto simp: o_def) + show "(\n. d (x n) (y n)) \ 0" + unfolding LIMSEQ_iff + proof (intro strip) + fix \ :: real + assume "\ > 0" + then obtain N where N: + "\n n'. \n\N; n'\N\ \ d (if even n then x (n div 2) else y (n div 2)) + (if even n' then x (n' div 2) else y (n' div 2)) < \" + using L MCauchy_def by fastforce + have "d (x n) (y n) < \" if "n\N" for n + using N [of "2*n" "Suc(2*n)"] that by auto + then show "\N. \n\N. norm (d (x n) (y n) - 0) < \" + by auto + qed + qed +next + assume R: ?rhs + show ?lhs + unfolding MCauchy_def + proof (intro conjI strip) + show "range (\n. if even n then x (n div 2) else y (n div 2)) \ M" + using R by (auto simp: MCauchy_def) + fix \ :: real + assume "\ > 0" + obtain Nx where Nx: "\n n'. \n\Nx; n'\Nx\ \ d (x n) (x n') < \/2" + by (meson half_gt_zero MCauchy_def R \\ > 0\) + obtain Ny where Ny: "\n n'. \n\Ny; n'\Ny\ \ d (y n) (y n') < \/2" + by (meson half_gt_zero MCauchy_def R \\ > 0\) + obtain Nxy where Nxy: "\n. n\Nxy \ d (x n) (y n) < \/2" + using R \\ > 0\ half_gt_zero unfolding LIMSEQ_iff + by (metis abs_mdist diff_zero real_norm_def) + define N where "N \ 2 * Max{Nx,Ny,Nxy}" + show "\N. \n n'. N \ n \ N \ n' \ d (if even n then x (n div 2) else y (n div 2)) (if even n' then x (n' div 2) else y (n' div 2)) < \" + proof (intro exI strip) + fix n n' + assume "N \ n" and "N \ n'" + then have "n div 2 \ Nx" "n div 2 \ Ny" "n div 2 \ Nxy" "n' div 2 \ Nx" "n' div 2 \ Ny" + by (auto simp: N_def) + then have dxyn: "d (x (n div 2)) (y (n div 2)) < \/2" + and dxnn': "d (x (n div 2)) (x (n' div 2)) < \/2" + and dynn': "d (y (n div 2)) (y (n' div 2)) < \/2" + using Nx Ny Nxy by blast+ + have inM: "x (n div 2) \ M" "x (n' div 2) \ M""y (n div 2) \ M" "y (n' div 2) \ M" + using Metric_space.MCauchy_def Metric_space_axioms R by blast+ + show "d (if even n then x (n div 2) else y (n div 2)) (if even n' then x (n' div 2) else y (n' div 2)) < \" + proof (cases "even n") + case nt: True + show ?thesis + proof (cases "even n'") + case True + with \\ > 0\ nt dxnn' show ?thesis by auto + next + case False + with nt dxyn dynn' inM triangle show ?thesis + by fastforce + qed + next + case nf: False + show ?thesis + proof (cases "even n'") + case True + then show ?thesis + by (smt (verit) \\ > 0\ dxyn dxnn' triangle commute inM field_sum_of_halves) + next + case False + with \\ > 0\ nf dynn' show ?thesis by auto + qed + qed + qed + qed +qed + +lemma MCauchy_interleaving: + "MCauchy (\n. if even n then \(n div 2) else a) \ + range \ \ M \ limitin mtopology \ a sequentially" (is "?lhs=?rhs") +proof - + have "?lhs \ (MCauchy \ \ a \ M \ (\n. d (\ n) a) \ 0)" + by (simp add: MCauchy_interleaving_gen [where y = "\n. a"]) + also have "... = ?rhs" + by (metis MCauchy_def always_eventually convergent_imp_MCauchy limitin_metric_dist_null range_subsetD) + finally show ?thesis . +qed + +lemma mcomplete_nest: + "mcomplete \ + (\C::nat \'a set. (\n. closedin mtopology (C n)) \ + (\n. C n \ {}) \ decseq C \ (\\>0. \n a. C n \ mcball a \) + \ \ (range C) \ {})" (is "?lhs=?rhs") +proof + assume L: ?lhs + show ?rhs + unfolding imp_conjL + proof (intro strip) + fix C :: "nat \ 'a set" + assume clo: "\n. closedin mtopology (C n)" + and ne: "\n. C n \ ({}::'a set)" + and dec: "decseq C" + and cover [rule_format]: "\\>0. \n a. C n \ mcball a \" + obtain \ where \: "\n. \ n \ C n" + by (meson ne empty_iff set_eq_iff) + have "MCauchy \" + unfolding MCauchy_def + proof (intro conjI strip) + show "range \ \ M" + using \ clo metric_closedin_iff_sequentially_closed by auto + fix \ :: real + assume "\ > 0" + then obtain N a where N: "C N \ mcball a (\/3)" + using cover by fastforce + have "d (\ m) (\ n) < \" if "N \ m" "N \ n" for m n + proof - + have "d a (\ m) \ \/3" "d a (\ n) \ \/3" + using dec N \ that by (fastforce simp: decseq_def)+ + then have "d (\ m) (\ n) \ \/3 + \/3" + using triangle \ commute dec decseq_def subsetD that N + by (smt (verit, ccfv_threshold) in_mcball) + also have "... < \" + using \\ > 0\ by auto + finally show ?thesis . + qed + then show "\N. \m n. N \ m \ N \ n \ d (\ m) (\ n) < \" + by blast + qed + then obtain x where x: "limitin mtopology \ x sequentially" + using L mcomplete_def by blast + have "x \ C n" for n + proof (rule limitin_closedin [OF x]) + show "closedin mtopology (C n)" + by (simp add: clo) + show "\\<^sub>F x in sequentially. \ x \ C n" + by (metis \ dec decseq_def eventually_sequentiallyI subsetD) + qed auto + then show "\ (range C) \ {}" + by blast +qed +next + assume R: ?rhs + show ?lhs + unfolding mcomplete_def + proof (intro strip) + fix \ + assume "MCauchy \" + then have "range \ \ M" + using MCauchy_def by blast + define C where "C \ \n. mtopology closure_of (\ ` {n..})" + have "\n. closedin mtopology (C n)" + by (auto simp: C_def) + moreover + have ne: "\n. C n \ {}" + using \MCauchy \\ by (auto simp: C_def MCauchy_def disjnt_iff closure_of_eq_empty_gen) + moreover + have dec: "decseq C" + unfolding monotone_on_def + proof (intro strip) + fix m n::nat + assume "m \ n" + then have "{n..} \ {m..}" + by auto + then show "C n \ C m" + unfolding C_def by (meson closure_of_mono image_mono) + qed + moreover + have C: "\N u. C N \ mcball u \" if "\>0" for \ + proof - + obtain N where "\m n. N \ m \ N \ n \ d (\ m) (\ n) < \" + by (meson MCauchy_def \0 < \\ \MCauchy \\) + then have "\ ` {N..} \ mcball (\ N) \" + using MCauchy_def \MCauchy \\ by (force simp: less_eq_real_def) + then have "C N \ mcball (\ N) \" + by (simp add: C_def closure_of_minimal) + then show ?thesis + by blast + qed + ultimately obtain l where x: "l \ \ (range C)" + by (metis R ex_in_conv) + then have *: "\\ N. 0 < \ \ \n'. N \ n' \ l \ M \ \ n' \ M \ d l (\ n') < \" + by (force simp: C_def metric_closure_of) + then have "l \ M" + using gt_ex by blast + show "\l. limitin mtopology \ l sequentially" + unfolding limitin_metric + proof (intro conjI strip exI) + show "l \ M" + using \\n. closedin mtopology (C n)\ closedin_subset x by fastforce + fix \::real + assume "\ > 0" + obtain N where N: "\m n. N \ m \ N \ n \ d (\ m) (\ n) < \/2" + by (meson MCauchy_def \0 < \\ \MCauchy \\ half_gt_zero) + with * [of "\/2" N] + have "\n\N. \ n \ M \ d (\ n) l < \" + by (smt (verit) \range \ \ M\ commute field_sum_of_halves range_subsetD triangle) + then show "\\<^sub>F n in sequentially. \ n \ M \ d (\ n) l < \" + using eventually_sequentially by blast + qed + qed +qed + + +lemma mcomplete_nest_sing: + "mcomplete \ + (\C. (\n. closedin mtopology (C n)) \ + (\n. C n \ {}) \ decseq C \ (\e>0. \n a. C n \ mcball a e) + \ (\l. l \ M \ \ (range C) = {l}))" +proof - + have *: False + if clo: "\n. closedin mtopology (C n)" + and cover: "\\>0. \n a. C n \ mcball a \" + and no_sing: "\y. y \ M \ \ (range C) \ {y}" + and l: "\n. l \ C n" + for C :: "nat \ 'a set" and l + proof - + have inM: "\x. x \ \ (range C) \ x \ M" + using closedin_metric clo by fastforce + then have "l \ M" + by (simp add: l) + have False if l': "l' \ \ (range C)" and "l' \ l" for l' + proof - + have "l' \ M" + using inM l' by blast + obtain n a where na: "C n \ mcball a (d l l' / 3)" + using inM \l \ M\ l' \l' \ l\ cover by force + then have "d a l \ (d l l' / 3)" "d a l' \ (d l l' / 3)" "a \ M" + using l l' na in_mcball by auto + then have "d l l' \ (d l l' / 3) + (d l l' / 3)" + using \l \ M\ \l' \ M\ mdist_reverse_triangle by fastforce + then show False + using nonneg [of l l'] \l' \ l\ \l \ M\ \l' \ M\ zero by force + qed + then show False + by (metis l \l \ M\ no_sing INT_I empty_iff insertI1 is_singletonE is_singletonI') + qed + show ?thesis + unfolding mcomplete_nest imp_conjL + apply (intro all_cong1 imp_cong refl) + using * + by (smt (verit) Inter_iff ex_in_conv range_constant range_eqI) +qed + +lemma mcomplete_fip: + "mcomplete \ + (\\. (\C \ \. closedin mtopology C) \ + (\e>0. \C a. C \ \ \ C \ mcball a e) \ (\\. finite \ \ \ \ \ \ \ \ \ {}) + \ \ \ \ {})" + (is "?lhs = ?rhs") +proof + assume L: ?lhs + show ?rhs + unfolding mcomplete_nest_sing imp_conjL + proof (intro strip) + fix \ :: "'a set set" + assume clo: "\C\\. closedin mtopology C" + and cover: "\e>0. \C a. C \ \ \ C \ mcball a e" + and fip: "\\. finite \ \ \ \ \ \ \ \ \ {}" + then have "\n. \C. C \ \ \ (\a. C \ mcball a (inverse (Suc n)))" + by simp + then obtain C where C: "\n. C n \ \" + and coverC: "\n. \a. C n \ mcball a (inverse (Suc n))" + by metis + define D where "D \ \n. \ (C ` {..n})" + have cloD: "closedin mtopology (D n)" for n + unfolding D_def using clo C by blast + have neD: "D n \ {}" for n + using fip C by (simp add: D_def image_subset_iff) + have decD: "decseq D" + by (force simp: D_def decseq_def) + have coverD: "\n a. D n \ mcball a \" if " \ >0" for \ + proof - + obtain n where "inverse (Suc n) < \" + using \0 < \\ reals_Archimedean by blast + then obtain a where "C n \ mcball a \" + by (meson coverC less_eq_real_def mcball_subset_concentric order_trans) + then show ?thesis + unfolding D_def by blast + qed + have *: "a \ \\" if a: "\ (range D) = {a}" and "a \ M" for a + proof - + have aC: "a \ C n" for n + using that by (auto simp: D_def) + have eqa: "\u. (\n. u \ C n) \ a = u" + using that by (auto simp: D_def) + have "a \ T" if "T \ \" for T + proof - + have cloT: "closedin mtopology (T \ D n)" for n + using clo cloD that by blast + have "\ (insert T (C ` {..n})) \ {}" for n + using that C by (intro fip [rule_format]) auto + then have neT: "T \ D n \ {}" for n + by (simp add: D_def) + have decT: "decseq (\n. T \ D n)" + by (force simp: D_def decseq_def) + have coverT: "\n a. T \ D n \ mcball a \" if " \ >0" for \ + by (meson coverD le_infI2 that) + show ?thesis + using L [unfolded mcomplete_nest_sing, rule_format, of "\n. T \ D n"] a + by (force simp: cloT neT decT coverT) + qed + then show ?thesis by auto + qed + show "\ \ \ {}" + by (metis L cloD neD decD coverD * empty_iff mcomplete_nest_sing) + qed +next + assume R [rule_format]: ?rhs + show ?lhs + unfolding mcomplete_nest imp_conjL + proof (intro strip) + fix C :: "nat \ 'a set" + assume clo: "\n. closedin mtopology (C n)" + and ne: "\n. C n \ {}" + and dec: "decseq C" + and cover: "\\>0. \n a. C n \ mcball a \" + have "\(C ` N) \ {}" if "finite N" for N + proof - + obtain k where "N \ {..k}" + using \finite N\ finite_nat_iff_bounded_le by auto + with dec have "C k \ \(C ` N)" by (auto simp: decseq_def) + then show ?thesis + using ne by force + qed + with clo cover R [of "range C"] show "\ (range C) \ {}" + by (metis (no_types, opaque_lifting) finite_subset_image image_iff UNIV_I) + qed +qed + + +lemma mcomplete_fip_sing: + "mcomplete \ + (\\. (\C\\. closedin mtopology C) \ + (\e>0. \c a. c \ \ \ c \ mcball a e) \ + (\\. finite \ \ \ \ \ \ \ \ \ {}) \ + (\l. l \ M \ \ \ = {l}))" + (is "?lhs = ?rhs") +proof + have *: "l \ M" "\ \ = {l}" + if clo: "Ball \ (closedin mtopology)" + and cover: "\e>0. \C a. C \ \ \ C \ mcball a e" + and fin: "\\. finite \ \ \ \ \ \ \ \ \ {}" + and l: "l \ \ \" + for \ :: "'a set set" and l + proof - + show "l \ M" + by (meson Inf_lower2 clo cover gt_ex metric_closedin_iff_sequentially_closed subsetD that(4)) + show "\ \ = {l}" + proof (cases "\ = {}") + case True + then show ?thesis + using cover mbounded_pos by auto + next + case False + have CM: "\a. a \ \\ \ a \ M" + using False clo closedin_subset by fastforce + have "l' \ \ \" if "l' \ l" for l' + proof + assume l': "l' \ \ \" + with CM have "l' \ M" by blast + with that \l \ M\ have gt0: "0 < d l l'" + by simp + then obtain C a where "C \ \" and C: "C \ mcball a (d l l' / 3)" + using cover [rule_format, of "d l l' / 3"] by auto + then have "d a l \ (d l l' / 3)" "d a l' \ (d l l' / 3)" "a \ M" + using l l' in_mcball by auto + then have "d l l' \ (d l l' / 3) + (d l l' / 3)" + using \l \ M\ \l' \ M\ mdist_reverse_triangle by fastforce + with gt0 show False by auto + qed + then show ?thesis + using l by fastforce + qed + qed + assume L: ?lhs + with * show ?rhs + unfolding mcomplete_fip imp_conjL ex_in_conv [symmetric] + by (elim all_forward imp_forward2 asm_rl) (blast intro: elim: ) +next + assume ?rhs then show ?lhs + unfolding mcomplete_fip by (force elim!: all_forward) +qed + +end + +lemma MCauchy_iff_Cauchy [iff]: "Met_TC.MCauchy = Cauchy" + by (force simp: Cauchy_def Met_TC.MCauchy_def) + +lemma mcomplete_iff_complete [iff]: + "Met_TC.mcomplete (Pure.type ::'a::metric_space itself) \ complete (UNIV::'a set)" + by (auto simp: Met_TC.mcomplete_def complete_def) + +lemma euclidean_metric: "Met_TC.mcomplete (Pure.type ::'a::euclidean_space itself)" + using complete_UNIV mcomplete_iff_complete by blast + +context submetric +begin + +lemma MCauchy_submetric: + "sub.MCauchy \ \ range \ \ A \ MCauchy \" + using MCauchy_def sub.MCauchy_def subset by force + +lemma closedin_mcomplete_imp_mcomplete: + assumes clo: "closedin mtopology A" and "mcomplete" + shows "sub.mcomplete" + unfolding sub.mcomplete_def +proof (intro strip) + fix \ + assume "sub.MCauchy \" + then have \: "MCauchy \" "range \ \ A" + using MCauchy_submetric by blast+ + then obtain x where x: "limitin mtopology \ x sequentially" + using \mcomplete\ unfolding mcomplete_def by blast + then have "x \ A" + using \ clo metric_closedin_iff_sequentially_closed by force + with \ x show "\x. limitin sub.mtopology \ x sequentially" + using limitin_submetric_iff range_subsetD by fastforce +qed + + +lemma sequentially_closedin_mcomplete_imp_mcomplete: + assumes "mcomplete" and "\\ l. range \ \ A \ limitin mtopology \ l sequentially \ l \ A" + shows "sub.mcomplete" + using assms closedin_mcomplete_imp_mcomplete metric_closedin_iff_sequentially_closed subset by blast + +end + + +context Metric_space +begin + +lemma mcomplete_Un: + assumes A: "submetric M d A" "Metric_space.mcomplete A d" + and B: "submetric M d B" "Metric_space.mcomplete B d" + shows "submetric M d (A \ B)" "Metric_space.mcomplete (A \ B) d" +proof - + show "submetric M d (A \ B)" + by (meson assms le_sup_iff submetric_axioms_def submetric_def) + then interpret MAB: Metric_space "A \ B" d + by (meson submetric.subset subspace) + interpret MA: Metric_space A d + by (meson A submetric.subset subspace) + interpret MB: Metric_space B d + by (meson B submetric.subset subspace) + show "Metric_space.mcomplete (A \ B) d" + unfolding MAB.mcomplete_def + proof (intro strip) + fix \ + assume "MAB.MCauchy \" + then have "range \ \ A \ B" + using MAB.MCauchy_def by blast + then have "UNIV \ \ -` A \ \ -` B" + by blast + then consider "infinite (\ -` A)" | "infinite (\ -` B)" + using finite_subset by auto + then show "\x. limitin MAB.mtopology \ x sequentially" + proof cases + case 1 + then obtain r where "strict_mono r" and r: "\n::nat. r n \ \ -` A" + using infinite_enumerate by blast + then have "MA.MCauchy (\ \ r)" + using MA.MCauchy_def MAB.MCauchy_def MAB.MCauchy_subsequence \MAB.MCauchy \\ by auto + with A obtain x where "limitin MA.mtopology (\ \ r) x sequentially" + using MA.mcomplete_def by blast + then have "limitin MAB.mtopology (\ \ r) x sequentially" + by (metis MA.limit_metric_sequentially MAB.limit_metric_sequentially UnCI) + then show ?thesis + using MAB.MCauchy_convergent_subsequence \MAB.MCauchy \\ \strict_mono r\ by blast + next + case 2 + then obtain r where "strict_mono r" and r: "\n::nat. r n \ \ -` B" + using infinite_enumerate by blast + then have "MB.MCauchy (\ \ r)" + using MB.MCauchy_def MAB.MCauchy_def MAB.MCauchy_subsequence \MAB.MCauchy \\ by auto + with B obtain x where "limitin MB.mtopology (\ \ r) x sequentially" + using MB.mcomplete_def by blast + then have "limitin MAB.mtopology (\ \ r) x sequentially" + by (metis MB.limit_metric_sequentially MAB.limit_metric_sequentially UnCI) + then show ?thesis + using MAB.MCauchy_convergent_subsequence \MAB.MCauchy \\ \strict_mono r\ by blast + qed + qed +qed + +lemma mcomplete_Union: + assumes "finite \" + and "\A. A \ \ \ submetric M d A" "\A. A \ \ \ Metric_space.mcomplete A d" + shows "submetric M d (\\)" "Metric_space.mcomplete (\\) d" + using assms + by (induction rule: finite_induct) (auto simp: mcomplete_Un) + +lemma mcomplete_Inter: + assumes "finite \" "\ \ {}" + and sub: "\A. A \ \ \ submetric M d A" + and comp: "\A. A \ \ \ Metric_space.mcomplete A d" + shows "submetric M d (\\)" "Metric_space.mcomplete (\\) d" +proof - + show "submetric M d (\\)" + using assms unfolding submetric_def submetric_axioms_def + by (metis Inter_lower equals0I inf.orderE le_inf_iff) + then interpret MS: submetric M d "\\" + by (meson submetric.subset subspace) + show "Metric_space.mcomplete (\\) d" + unfolding MS.sub.mcomplete_def + proof (intro strip) + fix \ + assume "MS.sub.MCauchy \" + then have "range \ \ \\" + using MS.MCauchy_submetric by blast + obtain A where "A \ \" and A: "Metric_space.mcomplete A d" + using assms by blast + then have "range \ \ A" + using \range \ \ \\\ by blast + interpret SA: submetric M d A + by (meson \A \ \\ sub submetric.subset subspace) + have "MCauchy \" + using MS.MCauchy_submetric \MS.sub.MCauchy \\ by blast + then obtain x where x: "limitin SA.sub.mtopology \ x sequentially" + by (metis A SA.sub.MCauchy_def SA.sub.mcomplete_alt MCauchy_def \range \ \ A\) + show "\x. limitin MS.sub.mtopology \ x sequentially" + apply (rule_tac x="x" in exI) + unfolding MS.limitin_submetric_iff + proof (intro conjI) + show "x \ \ \" + proof clarsimp + fix U + assume "U \ \" + interpret SU: submetric M d U + by (meson \U \ \\ sub submetric.subset subspace) + have "range \ \ U" + using \U \ \\ \range \ \ \ \\ by blast + moreover have "Metric_space.mcomplete U d" + by (simp add: \U \ \\ comp) + ultimately obtain x' where x': "limitin SU.sub.mtopology \ x' sequentially" + using MCauchy_def SU.sub.MCauchy_def SU.sub.mcomplete_alt \MCauchy \\ by meson + have "x' = x" + proof (intro limitin_metric_unique) + show "limitin mtopology \ x' sequentially" + by (meson SU.submetric_axioms submetric.limitin_submetric_iff x') + show "limitin mtopology \ x sequentially" + by (meson SA.submetric_axioms submetric.limitin_submetric_iff x) + qed auto + then show "x \ U" + using SU.sub.limitin_mspace x' by blast + qed + show "\\<^sub>F n in sequentially. \ n \ \\" + by (meson \range \ \ \ \\ always_eventually range_subsetD) + show "limitin mtopology \ x sequentially" + by (meson SA.submetric_axioms submetric.limitin_submetric_iff x) + qed + qed +qed + + +lemma mcomplete_Int: + assumes A: "submetric M d A" "Metric_space.mcomplete A d" + and B: "submetric M d B" "Metric_space.mcomplete B d" + shows "submetric M d (A \ B)" "Metric_space.mcomplete (A \ B) d" + using mcomplete_Inter [of "{A,B}"] assms by force+ + +subsection\Totally bounded subsets of metric spaces\ + +definition mtotally_bounded + where "mtotally_bounded S \ \\>0. \K. finite K \ K \ S \ S \ (\x\K. mball x \)" + +lemma mtotally_bounded_empty [iff]: "mtotally_bounded {}" +by (simp add: mtotally_bounded_def) + +lemma finite_imp_mtotally_bounded: + "\finite S; S \ M\ \ mtotally_bounded S" + by (auto simp: mtotally_bounded_def) + +lemma mtotally_bounded_imp_subset: "mtotally_bounded S \ S \ M" + by (force simp: mtotally_bounded_def intro!: zero_less_one) + +lemma mtotally_bounded_sing [simp]: + "mtotally_bounded {x} \ x \ M" + by (meson empty_subsetI finite.simps finite_imp_mtotally_bounded insert_subset mtotally_bounded_imp_subset) + +lemma mtotally_bounded_Un: + assumes "mtotally_bounded S" "mtotally_bounded T" + shows "mtotally_bounded (S \ T)" +proof - + have "\K. finite K \ K \ S \ T \ S \ T \ (\x\K. mball x e)" + if "e>0" and K: "finite K \ K \ S \ S \ (\x\K. mball x e)" + and L: "finite L \ L \ T \ T \ (\x\L. mball x e)" for K L e + using that by (rule_tac x="K \ L" in exI) auto + with assms show ?thesis + unfolding mtotally_bounded_def by presburger +qed + +lemma mtotally_bounded_Union: + assumes "finite f" "\S. S \ f \ mtotally_bounded S" + shows "mtotally_bounded (\f)" + using assms by (induction f) (auto simp: mtotally_bounded_Un) + +lemma mtotally_bounded_imp_mbounded: + assumes "mtotally_bounded S" + shows "mbounded S" +proof - + obtain K where "finite K \ K \ S \ S \ (\x\K. mball x 1)" + using assms by (force simp: mtotally_bounded_def) + then show ?thesis + by (smt (verit) finite_imageI image_iff mbounded_Union mbounded_mball mbounded_subset) +qed + + +lemma mtotally_bounded_sequentially: + "mtotally_bounded S \ + S \ M \ (\\::nat \ 'a. range \ \ S \ (\r. strict_mono r \ MCauchy (\ \ r)))" + (is "_ \ _ \ ?rhs") +proof (cases "S \ M") + case True + show ?thesis + proof - + { fix \ :: "nat \ 'a" + assume L: "mtotally_bounded S" and \: "range \ \ S" + have "\j > i. d (\ i) (\ j) < 3*\/2 \ infinite (\ -` mball (\ j) (\/2))" + if inf: "infinite (\ -` mball (\ i) \)" and "\ > 0" for i \ + proof - + obtain K where "finite K" "K \ S" and K: "S \ (\x\K. mball x (\/4))" + by (metis L mtotally_bounded_def \\ > 0\ zero_less_divide_iff zero_less_numeral) + then have K_imp_ex: "\y. y \ S \ \x\K. d x y < \/4" + by fastforce + have False if "\x\K. d x (\ i) < \ + \/4 \ finite (\ -` mball x (\/4))" + proof - + have "\w. w \ K \ d w (\ i) < 5 * \/4 \ d w (\ j) < \/4" + if "d (\ i) (\ j) < \" for j + proof - + obtain w where w: "d w (\ j) < \/4" "w \ K" + using K_imp_ex \ by blast + then have "d w (\ i) < \ + \/4" + by (smt (verit, ccfv_SIG) True \K \ S\ \ rangeI subset_eq that triangle') + with w show ?thesis + using in_mball by auto + qed + then have "(\ -` mball (\ i) \) \ (\x\K. if d x (\ i) < \ + \/4 then \ -` mball x (\/4) else {})" + using True \K \ S\ by force + then show False + using finite_subset inf \finite K\ that by fastforce + qed + then obtain x where "x \ K" and dxi: "d x (\ i) < \ + \/4" and infx: "infinite (\ -` mball x (\/4))" + by blast + then obtain j where "j \ (\ -` mball x (\/4)) - {..i}" + using bounded_nat_set_is_finite by (meson Diff_infinite_finite finite_atMost) + then have "j > i" and dxj: "d x (\ j) < \/4" + by auto + have "(\ -` mball x (\/4)) \ (\ -` mball y (\/2))" if "d x y < \/4" "y \ M" for y + using that by (simp add: mball_subset Metric_space_axioms vimage_mono) + then have infj: "infinite (\ -` mball (\ j) (\/2))" + by (meson True \d x (\ j) < \/4\ \ in_mono infx rangeI finite_subset) + have "\ i \ M" "\ j \ M" "x \ M" + using True \K \ S\ \x \ K\ \ by force+ + then have "d (\ i) (\ j) \ d x (\ i) + d x (\ j)" + using triangle'' by blast + also have "\ < 3*\/2" + using dxi dxj by auto + finally have "d (\ i) (\ j) < 3*\/2" . + with \i < j\ infj show ?thesis by blast + qed + then obtain nxt where nxt: "\i \. \\ > 0; infinite (\ -` mball (\ i) \)\ \ + nxt i \ > i \ d (\ i) (\ (nxt i \)) < 3*\/2 \ infinite (\ -` mball (\ (nxt i \)) (\/2))" + by metis + have "mbounded S" + using L by (simp add: mtotally_bounded_imp_mbounded) + then obtain B where B: "\y \ S. d (\ 0) y \ B" and "B > 0" + by (meson \ mbounded_alt_pos range_subsetD) + define eps where "eps \ \n. (B+1) / 2^n" + have [simp]: "eps (Suc n) = eps n / 2" "eps n > 0" for n + using \B > 0\ by (auto simp: eps_def) + have "UNIV \ \ -` mball (\ 0) (B+1)" + using B True \ unfolding image_iff subset_iff + by (smt (verit, best) UNIV_I in_mball vimageI) + then have inf0: "infinite (\ -` mball (\ 0) (eps 0))" + using finite_subset by (auto simp: eps_def) + define r where "r \ rec_nat 0 (\n rec. nxt rec (eps n))" + have [simp]: "r 0 = 0" "r (Suc n) = nxt (r n) (eps n)" for n + by (auto simp: r_def) + have \rM[simp]: "\ (r n) \ M" for n + using True \ by blast + have inf: "infinite (\ -` mball (\ (r n)) (eps n))" for n + proof (induction n) + case 0 then show ?case + by (simp add: inf0) + next + case (Suc n) then show ?case + using nxt [of "eps n" "r n"] by simp + qed + then have "r (Suc n) > r n" for n + by (simp add: nxt) + then have "strict_mono r" + by (simp add: strict_mono_Suc_iff) + have d_less: "d (\ (r n)) (\ (r (Suc n))) < 3 * eps n / 2" for n + using nxt [OF _ inf] by simp + have eps_plus: "eps (k + n) = eps n * (1/2)^k" for k n + by (simp add: eps_def power_add field_simps) + have *: "d (\ (r n)) (\ (r (k + n))) < 3 * eps n" for n k + proof - + have "d (\ (r n)) (\ (r (k+n))) \ 3/2 * eps n * (\i (r n)) (\ (r (Suc k + n))) \ d (\ (r n)) (\ (r (k + n))) + d (\ (r (k + n))) (\ (r (Suc (k + n))))" + by (metis \rM add.commute add_Suc_right triangle) + with d_less[of "k+n"] Suc show ?case + by (simp add: algebra_simps eps_plus) + qed + also have "\ < 3/2 * eps n * 2" + using geometric_sum [of "1/2::real" k] by simp + finally show ?thesis by simp + qed + have "\N. \n\N. \n'\N. d (\ (r n)) (\ (r n')) < \" if "\ > 0" for \ + proof - + define N where "N \ nat \(log 2 (6*(B+1) / \))\" + have \
: "b \ 2 ^ nat \log 2 b\" for b + by (smt (verit) less_log_of_power real_nat_ceiling_ge) + have N: "6 * eps N \ \" + using \
[of "(6*(B+1) / \)"] that by (auto simp: N_def eps_def field_simps) + have "d (\ (r N)) (\ (r n)) < 3 * eps N" if "n \ N" for n + by (metis * add.commute nat_le_iff_add that) + then have "\n\N. \n'\N. d (\ (r n)) (\ (r n')) < 3 * eps N + 3 * eps N" + by (smt (verit, best) \rM triangle'') + with N show ?thesis + by fastforce + qed + then have "MCauchy (\ \ r)" + unfolding MCauchy_def using True \ by auto + then have "\r. strict_mono r \ MCauchy (\ \ r)" + using \strict_mono r\ by blast + } + moreover + { assume R: ?rhs + have "mtotally_bounded S" + unfolding mtotally_bounded_def + proof (intro strip) + fix \ :: real + assume "\ > 0" + have False if \
: "\K. \finite K; K \ S\ \ \s\S. s \ (\x\K. mball x \)" + proof - + obtain f where f: "\K. \finite K; K \ S\ \ f K \ S \ f K \ (\x\K. mball x \)" + using \
by metis + define \ where "\ \ wfrec less_than (\seq n. f (seq ` {.._eq: "\ n = f (\ ` {.._def]) + have [simp]: "\ n \ S" for n + using wf_less_than + proof (induction n rule: wf_induct_rule) + case (less n) with f show ?case + by (auto simp: \_eq [of n]) + qed + then have "range \ \ S" by blast + have \: "p < n \ \ \ d (\ p) (\ n)" for n p + using f[of "\ ` {.._eq [of n] Ball_def) + then obtain r where "strict_mono r" "MCauchy (\ \ r)" + by (meson R \range \ \ S\) + with \0 < \\ obtain N + where N: "\n n'. \n\N; n'\N\ \ d (\ (r n)) (\ (r n')) < \" + by (force simp: MCauchy_def) + show ?thesis + using N [of N "Suc (r N)"] \strict_mono r\ + by (smt (verit) Suc_le_eq \ le_SucI order_refl strict_mono_imp_increasing) + qed + then show "\K. finite K \ K \ S \ S \ (\x\K. mball x \)" + by blast + qed + } + ultimately show ?thesis + using True by blast + qed +qed (use mtotally_bounded_imp_subset in auto) + + +lemma mtotally_bounded_subset: + "\mtotally_bounded S; T \ S\ \ mtotally_bounded T" + by (meson mtotally_bounded_sequentially order_trans) + +lemma mtotally_bounded_submetric: + assumes "mtotally_bounded S" "S \ T" "T \ M" + shows "Metric_space.mtotally_bounded T d S" +proof - + interpret submetric M d T + by (simp add: Metric_space_axioms assms submetric.intro submetric_axioms.intro) + show ?thesis + using assms + unfolding sub.mtotally_bounded_def mtotally_bounded_def + by (force simp: subset_iff elim!: all_forward ex_forward) +qed + +lemma mtotally_bounded_absolute: + "mtotally_bounded S \ S \ M \ Metric_space.mtotally_bounded S d S " +proof - + have "mtotally_bounded S" if "S \ M" "Metric_space.mtotally_bounded S d S" + proof - + interpret submetric M d S + by (simp add: Metric_space_axioms submetric_axioms.intro submetric_def \S \ M\) + show ?thesis + using that + by (metis MCauchy_submetric Metric_space.mtotally_bounded_sequentially Metric_space_axioms subspace) + qed + moreover have "mtotally_bounded S \ Metric_space.mtotally_bounded S d S" + by (simp add: mtotally_bounded_imp_subset mtotally_bounded_submetric) + ultimately show ?thesis + using mtotally_bounded_imp_subset by blast +qed + +lemma mtotally_bounded_closure_of: + assumes "mtotally_bounded S" + shows "mtotally_bounded (mtopology closure_of S)" +proof - + have "S \ M" + by (simp add: assms mtotally_bounded_imp_subset) + have "mtotally_bounded(mtopology closure_of S)" + unfolding mtotally_bounded_def + proof (intro strip) + fix \::real + assume "\ > 0" + then obtain K where "finite K" "K \ S" and K: "S \ (\x\K. mball x (\/2))" + by (metis assms mtotally_bounded_def half_gt_zero) + have "mtopology closure_of S \ (\x\K. mball x \)" + unfolding metric_closure_of + proof clarsimp + fix x + assume "x \ M" and x: "\r>0. \y\S. y \ M \ d x y < r" + then obtain y where "y \ S" and y: "d x y < \/2" + using \0 < \\ half_gt_zero by blast + then obtain x' where "x' \ K" "y \ mball x' (\/2)" + using K by auto + then have "d x' x < \/2 + \/2" + using triangle y \x \ M\ commute by fastforce + then show "\x'\K. x' \ M \ d x' x < \" + using \K \ S\ \S \ M\ \x' \ K\ by force + qed + then show "\K. finite K \ K \ mtopology closure_of S \ mtopology closure_of S \ (\x\K. mball x \)" + using closure_of_subset_Int \K \ S\ \finite K\ K by fastforce + qed + then show ?thesis + by (simp add: assms inf.absorb2 mtotally_bounded_imp_subset) +qed + +lemma mtotally_bounded_closure_of_eq: + "S \ M \ mtotally_bounded (mtopology closure_of S) \ mtotally_bounded S" + by (metis closure_of_subset mtotally_bounded_closure_of mtotally_bounded_subset topspace_mtopology) + +lemma mtotally_bounded_cauchy_sequence: + assumes "MCauchy \" + shows "mtotally_bounded (range \)" + unfolding MCauchy_def mtotally_bounded_def +proof (intro strip) + fix \::real + assume "\ > 0" + then obtain N where "\n. N \ n \ d (\ N) (\ n) < \" + using assms by (force simp: MCauchy_def) + then have "\m. \n\N. \ n \ M \ \ m \ M \ d (\ n) (\ m) < \" + by (metis MCauchy_def assms mdist_zero nle_le range_subsetD) + then + show "\K. finite K \ K \ range \ \ range \ \ (\x\K. mball x \)" + by (rule_tac x="\ ` {0..N}" in exI) force +qed + +lemma MCauchy_imp_mbounded: + "MCauchy \ \ mbounded (range \)" + by (simp add: mtotally_bounded_cauchy_sequence mtotally_bounded_imp_mbounded) + +subsection\Compactness in metric spaces\ + +lemma Bolzano_Weierstrass_property: + assumes "S \ U" "S \ M" + shows + "(\\::nat\'a. range \ \ S + \ (\l r. l \ U \ strict_mono r \ limitin mtopology (\ \ r) l sequentially)) \ + (\T. T \ S \ infinite T \ U \ mtopology derived_set_of T \ {})" (is "?lhs=?rhs") +proof + assume L: ?lhs + show ?rhs + proof clarify + fix T + assume "T \ S" and "infinite T" + and T: "U \ mtopology derived_set_of T = {}" + then obtain \ :: "nat\'a" where "inj \" "range \ \ T" + by (meson infinite_countable_subset) + with L obtain l r where "l \ U" "strict_mono r" + and lr: "limitin mtopology (\ \ r) l sequentially" + by (meson \T \ S\ subset_trans) + then obtain \ where "\ > 0" and \: "\y. y \ T \ y = l \ \ d l y < \" + using T \T \ S\ \S \ M\ + by (force simp: metric_derived_set_of limitin_metric disjoint_iff) + with lr have "\\<^sub>F n in sequentially. \ (r n) \ M \ d (\ (r n)) l < \" + by (auto simp: limitin_metric) + then obtain N where N: "d (\ (r N)) l < \" "d (\ (r (Suc N))) l < \" + using less_le_not_le by (auto simp: eventually_sequentially) + moreover have "\ (r N) \ l \ \ (r (Suc N)) \ l" + by (meson \inj \\ \strict_mono r\ injD n_not_Suc_n strict_mono_eq) + ultimately + show False + using \ \range \ \ T\ commute by fastforce + qed +next + assume R: ?rhs + show ?lhs + proof (intro strip) + fix \ :: "nat \ 'a" + assume "range \ \ S" + show "\l r. l \ U \ strict_mono r \ limitin mtopology (\ \ r) l sequentially" + proof (cases "finite (range \)") + case True + then obtain m where "infinite (\ -` {\ m})" + by (metis image_iff inf_img_fin_dom nat_not_finite) + then obtain r where [iff]: "strict_mono r" and r: "\n::nat. r n \ \ -` {\ m}" + using infinite_enumerate by blast + have [iff]: "\ m \ U" "\ m \ M" + using \range \ \ S\ assms by blast+ + show ?thesis + proof (intro conjI exI) + show "limitin mtopology (\ \ r) (\ m) sequentially" + using r by (simp add: limitin_metric) + qed auto + next + case False + then obtain l where "l \ U" and l: "l \ mtopology derived_set_of (range \)" + by (meson R \range \ \ S\ disjoint_iff) + then obtain g where g: "\\. \>0 \ \ (g \) \ l \ d l (\ (g \)) < \" + by (simp add: metric_derived_set_of) metis + have "range \ \ M" + using \range \ \ S\ assms by auto + have "l \ M" + using l metric_derived_set_of by auto + define E where \\a construction to ensure monotonicity\ + "E \ \rec n. insert (inverse (Suc n)) ((\i. d l (\ i)) ` (\k wfrec less_than (\rec n. g (Min (E rec n)))" + have "(\kk (r n)) > 0" for n + using wf_less_than + proof (induction n rule: wf_induct_rule) + case (less n) + then have *: "Min (E r n) > 0" + using \l \ M\ \range \ \ M\ by (auto simp: E_def image_subset_iff) + show ?case + using g [OF *] r_eq [of n] + by (metis \l \ M\ \range \ \ M\ mdist_pos_less range_subsetD) + qed + then have non_l: "\ (r n) \ l" for n + using \range \ \ M\ mdist_pos_eq by blast + have Min_pos: "Min (E r n) > 0" for n + using dl_pos \l \ M\ \range \ \ M\ by (auto simp: E_def image_subset_iff) + have d_small: "d (\(r n)) l < inverse(Suc n)" for n + proof - + have "d (\(r n)) l < Min (E r n)" + by (simp add: \0 < Min (E r n)\ commute g r_eq) + also have "... \ inverse(Suc n)" + by (simp add: E_def) + finally show ?thesis . + qed + have d_lt_d: "d l (\ (r n)) < d l (\ i)" if \
: "p < n" "i \ r p" "\ i \ l" for i p n + proof - + have 1: "d l (\ i) \ E r n" + using \
\l \ M\ \range \ \ M\ + by (force simp: E_def image_subset_iff image_iff) + have "d l (\ (g (Min (E r n)))) < Min (E r n)" + by (rule conjunct2 [OF g [OF Min_pos]]) + also have "Min (E r n) \ d l (\ i)" + using 1 unfolding E_def by (force intro!: Min.coboundedI) + finally show ?thesis + by (simp add: r_eq) + qed + have r: "r p < r n" if "p < n" for p n + using d_lt_d [OF that] non_l by (meson linorder_not_le order_less_irrefl) + show ?thesis + proof (intro exI conjI) + show "strict_mono r" + by (simp add: r strict_monoI) + show "limitin mtopology (\ \ r) l sequentially" + unfolding limitin_metric + proof (intro conjI strip \l \ M\) + fix \ :: real + assume "\ > 0" + then have "\\<^sub>F n in sequentially. inverse(Suc n) < \" + using Archimedean_eventually_inverse by auto + then show "\\<^sub>F n in sequentially. (\ \ r) n \ M \ d ((\ \ r) n) l < \" + by (smt (verit) \range \ \ M\ commute comp_apply d_small eventually_mono range_subsetD) + qed + qed (use \l \ U\ in auto) + qed + qed +qed + +subsubsection \More on Bolzano Weierstrass\ + +lemma Bolzano_Weierstrass_A: + assumes "compactin mtopology S" "T \ S" "infinite T" + shows "S \ mtopology derived_set_of T \ {}" + by (simp add: assms compactin_imp_Bolzano_Weierstrass) + +lemma Bolzano_Weierstrass_B: + fixes \ :: "nat \ 'a" + assumes "S \ M" "range \ \ S" + and "\T. \T \ S \ infinite T\ \ S \ mtopology derived_set_of T \ {}" + shows "\l r. l \ S \ strict_mono r \ limitin mtopology (\ \ r) l sequentially" + using Bolzano_Weierstrass_property assms by blast + +lemma Bolzano_Weierstrass_C: + assumes "S \ M" + assumes "\\:: nat \ 'a. range \ \ S \ + (\l r. l \ S \ strict_mono r \ limitin mtopology (\ \ r) l sequentially)" + shows "mtotally_bounded S" + unfolding mtotally_bounded_sequentially + by (metis convergent_imp_MCauchy assms image_comp image_mono subset_UNIV subset_trans) + +lemma Bolzano_Weierstrass_D: + assumes "S \ M" "S \ \\" and opeU: "\U. U \ \ \ openin mtopology U" + assumes \
: "(\\::nat\'a. range \ \ S + \ (\l r. l \ S \ strict_mono r \ limitin mtopology (\ \ r) l sequentially))" + shows "\\>0. \x \ S. \U \ \. mball x \ \ U" +proof (rule ccontr) + assume "\ (\\>0. \x \ S. \U \ \. mball x \ \ U)" + then have "\n. \x\S. \U\\. \ mball x (inverse (Suc n)) \ U" + by simp + then obtain \ where "\n. \ n \ S" + and \: "\n U. U \ \ \ \ mball (\ n) (inverse (Suc n)) \ U" + by metis + then obtain l r where "l \ S" "strict_mono r" + and lr: "limitin mtopology (\ \ r) l sequentially" + by (meson \
image_subsetI) + with \S \ \\\ obtain B where "l \ B" "B \ \" + by auto + then obtain \ where "\ > 0" and \: "\z. \z \ M; d z l < \\ \ z \ B" + by (metis opeU [OF \B \ \\] commute in_mball openin_mtopology subset_iff) + then have "\\<^sub>F n in sequentially. \ (r n) \ M \ d (\ (r n)) l < \/2" + using lr half_gt_zero unfolding limitin_metric o_def by blast + moreover have "\\<^sub>F n in sequentially. inverse (real (Suc n)) < \/2" + using Archimedean_eventually_inverse \0 < \\ half_gt_zero by blast + ultimately obtain n where n: "d (\ (r n)) l < \/2" "inverse (real (Suc n)) < \/2" + by (smt (verit, del_insts) eventually_sequentially le_add1 le_add2) + have "x \ B" if "d (\ (r n)) x < inverse (Suc(r n))" "x \ M" for x + proof - + have rle: "inverse (real (Suc (r n))) \ inverse (real (Suc n))" + using \strict_mono r\ strict_mono_imp_increasing by auto + have "d x l \ d (\ (r n)) x + d (\ (r n)) l" + using that by (metis triangle \\n. \ n \ S\ \l \ S\ \S \ M\ commute subsetD) + also have "... < \" + using that n rle by linarith + finally show ?thesis + by (simp add: \ that) + qed + then show False + using \ [of B "r n"] by (simp add: \B \ \\ subset_iff) +qed + + +lemma Bolzano_Weierstrass_E: + assumes "mtotally_bounded S" "S \ M" + and S: "\\. \\U. U \ \ \ openin mtopology U; S \ \\\ \ \\>0. \x \ S. \U \ \. mball x \ \ U" + shows "compactin mtopology S" +proof (clarsimp simp: compactin_def assms) + fix \ :: "'a set set" + assume \: "\x\\. openin mtopology x" and "S \ \\" + then obtain \ where "\>0" and \: "\x. x \ S \ \U \ \. mball x \ \ U" + by (metis S) + then obtain f where f: "\x. x \ S \ f x \ \ \ mball x \ \ f x" + by metis + then obtain K where "finite K" "K \ S" and K: "S \ (\x\K. mball x \)" + by (metis \0 < \\ \mtotally_bounded S\ mtotally_bounded_def) + show "\\. finite \ \ \ \ \ \ S \ \\" + proof (intro conjI exI) + show "finite (f ` K)" + by (simp add: \finite K\) + show "f ` K \ \" + using \K \ S\ f by blast + show "S \ \(f ` K)" + using K \K \ S\ by (force dest: f) + qed +qed + + +lemma compactin_eq_Bolzano_Weierstrass: + "compactin mtopology S \ + S \ M \ (\T. T \ S \ infinite T \ S \ mtopology derived_set_of T \ {})" + using Bolzano_Weierstrass_C Bolzano_Weierstrass_D Bolzano_Weierstrass_E + by (smt (verit, del_insts) Bolzano_Weierstrass_property compactin_imp_Bolzano_Weierstrass compactin_subspace subset_refl topspace_mtopology) + +lemma compactin_sequentially: + shows "compactin mtopology S \ + S \ M \ + ((\\::nat\'a. range \ \ S + \ (\l r. l \ S \ strict_mono r \ limitin mtopology (\ \ r) l sequentially)))" + by (metis Bolzano_Weierstrass_property compactin_eq_Bolzano_Weierstrass subset_refl) + +lemma compactin_imp_mtotally_bounded: + "compactin mtopology S \ mtotally_bounded S" + by (simp add: Bolzano_Weierstrass_C compactin_sequentially) + +lemma lebesgue_number: + "\compactin mtopology S; S \ \\; \U. U \ \ \ openin mtopology U\ + \ \\>0. \x \ S. \U \ \. mball x \ \ U" + by (simp add: Bolzano_Weierstrass_D compactin_sequentially) + +lemma compact_space_sequentially: + "compact_space mtopology \ + (\\::nat\'a. range \ \ M + \ (\l r. l \ M \ strict_mono r \ limitin mtopology (\ \ r) l sequentially))" + by (simp add: compact_space_def compactin_sequentially) + +lemma compact_space_eq_Bolzano_Weierstrass: + "compact_space mtopology \ + (\S. S \ M \ infinite S \ mtopology derived_set_of S \ {})" + using Int_absorb1 [OF derived_set_of_subset_topspace [of mtopology]] + by (force simp: compact_space_def compactin_eq_Bolzano_Weierstrass) + +lemma compact_space_nest: + "compact_space mtopology \ + (\C. (\n::nat. closedin mtopology (C n)) \ (\n. C n \ {}) \ decseq C \ \(range C) \ {})" + (is "?lhs=?rhs") +proof + assume L: ?lhs + show ?rhs + proof clarify + fix C :: "nat \ 'a set" + assume "\n. closedin mtopology (C n)" + and "\n. C n \ {}" + and "decseq C" + and "\ (range C) = {}" + then obtain K where K: "finite K" "\(C ` K) = {}" + by (metis L compact_space_imp_nest) + then obtain k where "K \ {..k}" + using finite_nat_iff_bounded_le by auto + then have "C k \ \(C ` K)" + using \decseq C\ by (auto simp:decseq_def) + then show False + by (simp add: K \\n. C n \ {}\) + qed +next + assume R [rule_format]: ?rhs + show ?lhs + unfolding compact_space_sequentially + proof (intro strip) + fix \ :: "nat \ 'a" + assume \: "range \ \ M" + have "mtopology closure_of \ ` {n..} \ {}" for n + using \range \ \ M\ by (auto simp: closure_of_eq_empty image_subset_iff) + moreover have "decseq (\n. mtopology closure_of \ ` {n..})" + using closure_of_mono image_mono by (smt (verit) atLeast_subset_iff decseq_def) + ultimately obtain l where l: "\n. l \ mtopology closure_of \ ` {n..}" + using R [of "\n. mtopology closure_of (\ ` {n..})"] by auto + then have "l \ M" and "\n. \r>0. \k\n. \ k \ M \ d l (\ k) < r" + using metric_closure_of by fastforce+ + then obtain f where f: "\n r. r>0 \ f n r \ n \ \ (f n r) \ M \ d l (\ (f n r)) < r" + by metis + define r where "r = rec_nat (f 0 1) (\n rec. (f (Suc rec) (inverse (Suc (Suc n)))))" + have r: "d l (\(r n)) < inverse(Suc n)" for n + by (induction n) (auto simp: rec_nat_0_imp [OF r_def] rec_nat_Suc_imp [OF r_def] f) + have "r n < r(Suc n)" for n + by (simp add: Suc_le_lessD f r_def) + then have "strict_mono r" + by (simp add: strict_mono_Suc_iff) + moreover have "limitin mtopology (\ \ r) l sequentially" + proof (clarsimp simp: limitin_metric \l \ M\) + fix \ :: real + assume "\ > 0" + then have "(\\<^sub>F n in sequentially. inverse (real (Suc n)) < \)" + using Archimedean_eventually_inverse by blast + then show "\\<^sub>F n in sequentially. \ (r n) \ M \ d (\ (r n)) l < \" + by eventually_elim (metis commute \range \ \ M\ order_less_trans r range_subsetD) + qed + ultimately show "\l r. l \ M \ strict_mono r \ limitin mtopology (\ \ r) l sequentially" + using \l \ M\ by blast + qed +qed + + +lemma (in discrete_metric) mcomplete_discrete_metric: "disc.mcomplete" +proof (clarsimp simp: disc.mcomplete_def) + fix \ :: "nat \ 'a" + assume "disc.MCauchy \" + then obtain N where "\n. N \ n \ \ N = \ n" + unfolding disc.MCauchy_def by (metis dd_def dual_order.refl order_less_irrefl zero_less_one) + moreover have "range \ \ M" + using \disc.MCauchy \\ disc.MCauchy_def by blast + ultimately have "limitin disc.mtopology \ (\ N) sequentially" + by (metis disc.limit_metric_sequentially disc.zero range_subsetD) + then show "\x. limitin disc.mtopology \ x sequentially" .. +qed + +lemma compact_space_imp_mcomplete: "compact_space mtopology \ mcomplete" + by (simp add: compact_space_nest mcomplete_nest) + +lemma (in submetric) compactin_imp_mcomplete: + "compactin mtopology A \ sub.mcomplete" + by (simp add: compactin_subspace mtopology_submetric sub.compact_space_imp_mcomplete) + +lemma (in submetric) mcomplete_imp_closedin: + assumes "sub.mcomplete" + shows "closedin mtopology A" +proof - + have "l \ A" + if "range \ \ A" and l: "limitin mtopology \ l sequentially" + for \ :: "nat \ 'a" and l + proof - + have "sub.MCauchy \" + using convergent_imp_MCauchy subset that by (force simp: MCauchy_submetric) + then have "limitin sub.mtopology \ l sequentially" + using assms unfolding sub.mcomplete_def + using l limitin_metric_unique limitin_submetric_iff trivial_limit_sequentially by blast + then show ?thesis + using limitin_submetric_iff by blast + qed + then show ?thesis + using metric_closedin_iff_sequentially_closed subset by auto +qed + +lemma (in submetric) closedin_eq_mcomplete: + "mcomplete \ (closedin mtopology A \ sub.mcomplete)" + using closedin_mcomplete_imp_mcomplete mcomplete_imp_closedin by blast + +lemma compact_space_eq_mcomplete_mtotally_bounded: + "compact_space mtopology \ mcomplete \ mtotally_bounded M" + by (meson Bolzano_Weierstrass_C compact_space_imp_mcomplete compact_space_sequentially limitin_mspace + mcomplete_alt mtotally_bounded_sequentially subset_refl) + + +lemma compact_closure_of_imp_mtotally_bounded: + "\compactin mtopology (mtopology closure_of S); S \ M\ + \ mtotally_bounded S" + using compactin_imp_mtotally_bounded mtotally_bounded_closure_of_eq by blast + +lemma mtotally_bounded_eq_compact_closure_of: + assumes "mcomplete" + shows "mtotally_bounded S \ S \ M \ compactin mtopology (mtopology closure_of S)" + (is "?lhs=?rhs") +proof + assume L: ?lhs + show ?rhs + unfolding compactin_subspace + proof (intro conjI) + show "S \ M" + using L by (simp add: mtotally_bounded_imp_subset) + show "mtopology closure_of S \ topspace mtopology" + by (simp add: \S \ M\ closure_of_minimal) + then have MSM: "mtopology closure_of S \ M" + by auto + interpret S: submetric M d "mtopology closure_of S" + proof qed (use MSM in auto) + have "S.sub.mtotally_bounded (mtopology closure_of S)" + using L mtotally_bounded_absolute mtotally_bounded_closure_of by blast + then + show "compact_space (subtopology mtopology (mtopology closure_of S))" + using S.closedin_mcomplete_imp_mcomplete S.mtopology_submetric S.sub.compact_space_eq_mcomplete_mtotally_bounded assms by force + qed +qed (auto simp: compact_closure_of_imp_mtotally_bounded) + + + +lemma compact_closure_of_eq_Bolzano_Weierstrass: + "compactin mtopology (mtopology closure_of S) \ + (\T. infinite T \ T \ S \ T \ M \ mtopology derived_set_of T \ {})" (is "?lhs=?rhs") +proof + assume L: ?lhs + show ?rhs + proof (intro strip) + fix T + assume T: "infinite T \ T \ S \ T \ M" + show "mtopology derived_set_of T \ {}" + proof (intro compact_closure_of_imp_Bolzano_Weierstrass) + show "compactin mtopology (mtopology closure_of S)" + by (simp add: L) + qed (use T in auto) + qed +next + have "compactin mtopology (mtopology closure_of S)" + if \
: "\T. \infinite T; T \ S\ \ mtopology derived_set_of T \ {}" and "S \ M" for S + unfolding compactin_sequentially + proof (intro conjI strip) + show MSM: "mtopology closure_of S \ M" + using closure_of_subset_topspace by fastforce + fix \ :: "nat \ 'a" + assume \: "range \ \ mtopology closure_of S" + then have "\y \ S. d (\ n) y < inverse(Suc n)" for n + by (simp add: metric_closure_of image_subset_iff) (metis inverse_Suc of_nat_Suc) + then obtain \ where \: "\n. \ n \ S \ d (\ n) (\ n) < inverse(Suc n)" + by metis + then have "range \ \ S" + by blast + moreover + have *: "\T. T \ S \ infinite T \ mtopology closure_of S \ mtopology derived_set_of T \ {}" + using "\
"(1) derived_set_of_mono derived_set_of_subset_closure_of by fastforce + moreover have "S \ mtopology closure_of S" + by (simp add: \S \ M\ closure_of_subset) + ultimately obtain l r where lr: + "l \ mtopology closure_of S" "strict_mono r" "limitin mtopology (\ \ r) l sequentially" + using Bolzano_Weierstrass_property \S \ M\ by metis + then have "l \ M" + using limitin_mspace by blast + have dr_less: "d ((\ \ r) n) ((\ \ r) n) < inverse(Suc n)" for n + proof - + have "d ((\ \ r) n) ((\ \ r) n) < inverse(Suc (r n))" + using \ by auto + also have "... \ inverse(Suc n)" + using lr strict_mono_imp_increasing by auto + finally show ?thesis . + qed + have "limitin mtopology (\ \ r) l sequentially" + unfolding limitin_metric + proof (intro conjI strip) + show "l \ M" + using limitin_mspace lr by blast + fix \ :: real + assume "\ > 0" + then have "\\<^sub>F n in sequentially. (\ \ r) n \ M \ d ((\ \ r) n) l < \/2" + using lr half_gt_zero limitin_metric by blast + moreover have "\\<^sub>F n in sequentially. inverse (real (Suc n)) < \/2" + using Archimedean_eventually_inverse \0 < \\ half_gt_zero by blast + then have "\\<^sub>F n in sequentially. d ((\ \ r) n) ((\ \ r) n) < \/2" + by eventually_elim (smt (verit, del_insts) dr_less) + ultimately have "\\<^sub>F n in sequentially. d ((\ \ r) n) l < \/2 + \/2" + by eventually_elim (smt (verit) triangle \l \ M\ MSM \ comp_apply order_trans range_subsetD) + then show "\\<^sub>F n in sequentially. (\ \ r) n \ M \ d ((\ \ r) n) l < \" + apply eventually_elim + using \mtopology closure_of S \ M\ \ by auto + qed + with lr show "\l r. l \ mtopology closure_of S \ strict_mono r \ limitin mtopology (\ \ r) l sequentially" + by blast + qed + then show "?rhs \ ?lhs" + by (metis Int_subset_iff closure_of_restrict inf_le1 topspace_mtopology) +qed + +end + +lemma (in discrete_metric) mtotally_bounded_discrete_metric: + "disc.mtotally_bounded S \ finite S \ S \ M" (is "?lhs=?rhs") +proof + assume L: ?lhs + show ?rhs + proof + show "finite S" + by (metis (no_types) L closure_of_subset_Int compactin_discrete_topology disc.mtotally_bounded_eq_compact_closure_of + disc.topspace_mtopology discrete_metric.mcomplete_discrete_metric inf.absorb_iff2 mtopology_discrete_metric finite_subset) + show "S \ M" + by (simp add: L disc.mtotally_bounded_imp_subset) + qed +qed (simp add: disc.finite_imp_mtotally_bounded) + + +context Metric_space +begin + +lemma derived_set_of_infinite_openin_metric: + "mtopology derived_set_of S = + {x \ M. \U. x \ U \ openin mtopology U \ infinite(S \ U)}" + by (simp add: derived_set_of_infinite_openin Hausdorff_space_mtopology) + +lemma derived_set_of_infinite_1: + assumes "infinite (S \ mball x \)" + shows "infinite (S \ mcball x \)" + by (meson Int_mono assms finite_subset mball_subset_mcball subset_refl) + +lemma derived_set_of_infinite_2: + assumes "openin mtopology U" "\\. 0 < \ \ infinite (S \ mcball x \)" and "x \ U" + shows "infinite (S \ U)" + by (metis assms openin_mtopology_mcball finite_Int inf.absorb_iff2 inf_assoc) + +lemma derived_set_of_infinite_mball: + "mtopology derived_set_of S = {x \ M. \e>0. infinite(S \ mball x e)}" + unfolding derived_set_of_infinite_openin_metric + by (meson centre_in_mball_iff openin_mball derived_set_of_infinite_1 derived_set_of_infinite_2) + +lemma derived_set_of_infinite_mcball: + "mtopology derived_set_of S = {x \ M. \e>0. infinite(S \ mcball x e)}" + unfolding derived_set_of_infinite_openin_metric + by (meson centre_in_mball_iff openin_mball derived_set_of_infinite_1 derived_set_of_infinite_2) + +end + +subsection\Continuous functions on metric spaces\ + +context Metric_space +begin + +lemma continuous_map_to_metric: + "continuous_map X mtopology f \ + (\x \ topspace X. \\>0. \U. openin X U \ x \ U \ (\y\U. f y \ mball (f x) \))" + (is "?lhs=?rhs") +proof + show "?lhs \ ?rhs" + unfolding continuous_map_eq_topcontinuous_at topcontinuous_at_def + by (metis centre_in_mball_iff openin_mball topspace_mtopology) +next + assume R: ?rhs + then have "\x\topspace X. f x \ M" + by (meson gt_ex in_mball) + moreover + have "\x V. \x \ topspace X; openin mtopology V; f x \ V\ \ \U. openin X U \ x \ U \ (\y\U. f y \ V)" + unfolding openin_mtopology by (metis Int_iff R inf.orderE) + ultimately + show ?lhs + by (simp add: continuous_map_eq_topcontinuous_at topcontinuous_at_def) +qed + +lemma continuous_map_from_metric: + "continuous_map mtopology X f \ + f ` M \ topspace X \ + (\a \ M. \U. openin X U \ f a \ U \ (\r>0. \x. x \ M \ d a x < r \ f x \ U))" +proof (cases "f ` M \ topspace X") + case True + then show ?thesis + by (fastforce simp: continuous_map openin_mtopology subset_eq) +next + case False + then show ?thesis + by (simp add: continuous_map_eq_image_closure_subset_gen) +qed + +text \An abstract formulation, since the limits do not have to be sequential\ +lemma continuous_map_uniform_limit: + assumes contf: "\\<^sub>F \ in F. continuous_map X mtopology (f \)" + and dfg: "\\. 0 < \ \ \\<^sub>F \ in F. \x \ topspace X. g x \ M \ d (f \ x) (g x) < \" + and nontriv: "\ trivial_limit F" + shows "continuous_map X mtopology g" + unfolding continuous_map_to_metric +proof (intro strip) + fix x and \::real + assume "x \ topspace X" and "\ > 0" + then obtain \ where k: "continuous_map X mtopology (f \)" + and gM: "\x \ topspace X. g x \ M" + and third: "\x \ topspace X. d (f \ x) (g x) < \/3" + using eventually_conj [OF contf] contf dfg [of "\/3"] eventually_happens' [OF nontriv] + by (smt (verit, ccfv_SIG) zero_less_divide_iff) + then obtain U where U: "openin X U" "x \ U" and Uthird: "\y\U. d (f \ y) (f \ x) < \/3" + unfolding continuous_map_to_metric + by (metis \0 < \\ \x \ topspace X\ commute divide_pos_pos in_mball zero_less_numeral) + have f_inM: "f \ y \ M" if "y\U" for y + using U k openin_subset that by (fastforce simp: continuous_map_def) + have "d (g y) (g x) < \" if "y\U" for y + proof - + have "g y \ M" + using U gM openin_subset that by blast + have "d (g y) (g x) \ d (g y) (f \ x) + d (f \ x) (g x)" + by (simp add: U \g y \ M\ \x \ topspace X\ f_inM gM triangle) + also have "\ \ d (g y) (f \ y) + d (f \ y) (f \ x) + d (f \ x) (g x)" + by (simp add: U \g y \ M\ commute f_inM that triangle') + also have "\ < \/3 + \/3 + \/3" + by (smt (verit) U(1) Uthird \x \ topspace X\ commute openin_subset subsetD that third) + finally show ?thesis by simp + qed + with U gM show "\U. openin X U \ x \ U \ (\y\U. g y \ mball (g x) \)" + by (metis commute in_mball in_mono openin_subset) +qed + + +lemma continuous_map_uniform_limit_alt: + assumes contf: "\\<^sub>F \ in F. continuous_map X mtopology (f \)" + and gim: "g ` (topspace X) \ M" + and dfg: "\\. 0 < \ \ \\<^sub>F \ in F. \x \ topspace X. d (f \ x) (g x) < \" + and nontriv: "\ trivial_limit F" + shows "continuous_map X mtopology g" +proof (rule continuous_map_uniform_limit [OF contf]) + fix \ :: real + assume "\ > 0" + with gim dfg show "\\<^sub>F \ in F. \x\topspace X. g x \ M \ d (f \ x) (g x) < \" + by (simp add: image_subset_iff) +qed (use nontriv in auto) + + +lemma continuous_map_uniformly_Cauchy_limit: + assumes "mcomplete" + assumes contf: "\\<^sub>F n in sequentially. continuous_map X mtopology (f n)" + and Cauchy': "\\. \ > 0 \ \N. \m n x. N \ m \ N \ n \ x \ topspace X \ d (f m x) (f n x) < \" + obtains g where + "continuous_map X mtopology g" + "\\. 0 < \ \ \\<^sub>F n in sequentially. \x\topspace X. d (f n x) (g x) < \" +proof - + have "\x. x \ topspace X \ \l. limitin mtopology (\n. f n x) l sequentially" + using \mcomplete\ [unfolded mcomplete, rule_format] assms + by (smt (verit) contf continuous_map_def eventually_mono topspace_mtopology) + then obtain g where g: "\x. x \ topspace X \ limitin mtopology (\n. f n x) (g x) sequentially" + by metis + show thesis + proof + show "\\<^sub>F n in sequentially. \x\topspace X. d (f n x) (g x) < \" + if "\ > 0" for \ :: real + proof - + obtain N where N: "\m n x. \N \ m; N \ n; x \ topspace X\ \ d (f m x) (f n x) < \/2" + by (meson Cauchy' \0 < \\ half_gt_zero) + obtain P where P: "\n x. \n \ P; x \ topspace X\ \ f n x \ M" + using contf by (auto simp: eventually_sequentially continuous_map_def) + show ?thesis + proof (intro eventually_sequentiallyI strip) + fix n x + assume "max N P \ n" and x: "x \ topspace X" + obtain L where "g x \ M" and L: "\n\L. f n x \ M \ d (f n x) (g x) < \/2" + using g [OF x] \\ > 0\ unfolding limitin_metric + by (metis (no_types, lifting) eventually_sequentially half_gt_zero) + define n' where "n' \ Max{L,N,P}" + have L': "\m \ n'. f m x \ M \ d (f m x) (g x) < \/2" + using L by (simp add: n'_def) + moreover + have "d (f n x) (f n' x) < \/2" + using N [of n n' x] \max N P \ n\ n'_def x by fastforce + ultimately have "d (f n x) (g x) < \/2 + \/2" + by (smt (verit, ccfv_SIG) P \g x \ M\ \max N P \ n\ le_refl max.bounded_iff mdist_zero triangle' x) + then show "d (f n x) (g x) < \" by simp + qed + qed + then show "continuous_map X mtopology g" + by (smt (verit, del_insts) eventually_mono g limitin_mspace trivial_limit_sequentially continuous_map_uniform_limit [OF contf]) + qed +qed + +lemma metric_continuous_map: + assumes "Metric_space M' d'" + shows + "continuous_map mtopology (Metric_space.mtopology M' d') f \ + f ` M \ M' \ (\a \ M. \\>0. \\>0. (\x. x \ M \ d a x < \ \ d' (f a) (f x) < \))" + (is "?lhs = ?rhs") +proof - + interpret M': Metric_space M' d' + by (simp add: assms) + show ?thesis + proof + assume L: ?lhs + show ?rhs + proof (intro conjI strip) + show "f ` M \ M'" + using L by (auto simp: continuous_map_def) + fix a and \ :: real + assume "a \ M" and "\ > 0" + then have "openin mtopology {x \ M. f x \ M'.mball (f a) \}" "f a \ M'" + using L unfolding continuous_map_def by fastforce+ + then obtain \ where "\ > 0" "mball a \ \ {x \ M. f x \ M' \ d' (f a) (f x) < \}" + using \0 < \\ \a \ M\ openin_mtopology by auto + then show "\\>0. \x. x \ M \ d a x < \ \ d' (f a) (f x) < \" + using \a \ M\ in_mball by blast + qed + next + assume R: ?rhs + show ?lhs + unfolding continuous_map_def + proof (intro conjI strip) + fix U + assume "openin M'.mtopology U" + then show "openin mtopology {x \ topspace mtopology. f x \ U}" + apply (simp add: continuous_map_def openin_mtopology M'.openin_mtopology subset_iff) + by (metis R image_subset_iff) + qed (use R in auto) + qed +qed + +end (*Metric_space*) + +end + diff -r 070703d83cfe -r cec875dcc59e src/HOL/Analysis/Abstract_Topological_Spaces.thy --- a/src/HOL/Analysis/Abstract_Topological_Spaces.thy Mon May 22 12:01:05 2023 +0200 +++ b/src/HOL/Analysis/Abstract_Topological_Spaces.thy Tue May 23 12:31:23 2023 +0100 @@ -1276,6 +1276,10 @@ using Hausdorff_space_closedin_diagonal embedding_imp_closed_map_eq by blast qed +lemma proper_map_diag_eq [simp]: + "proper_map X (prod_topology X X) (\x. (x,x)) \ Hausdorff_space X" + by (simp add: closed_map_diag_eq inj_on_convol_ident injective_imp_proper_eq_closed_map) + lemma closedin_continuous_maps_eq: assumes "Hausdorff_space Y" and f: "continuous_map X Y f" and g: "continuous_map X Y g" shows "closedin X {x \ topspace X. f x = g x}" @@ -1606,6 +1610,340 @@ "\Hausdorff_space X; kc_space Y\ \ kc_space (prod_topology X Y)" using kc_space_prod_topology_left homeomorphic_kc_space homeomorphic_space_prod_topology_swap by blast +subsection \Technical results about proper maps, perfect maps, etc\ + +lemma compact_imp_proper_map_gen: + assumes Y: "\S. \S \ topspace Y; \K. compactin Y K \ compactin Y (S \ K)\ + \ closedin Y S" + and fim: "f ` (topspace X) \ topspace Y" + and f: "continuous_map X Y f \ kc_space X" + and YX: "\K. compactin Y K \ compactin X {x \ topspace X. f x \ K}" + shows "proper_map X Y f" + unfolding proper_map_alt closed_map_def +proof (intro conjI strip) + fix C + assume C: "closedin X C" + show "closedin Y (f ` C)" + proof (intro Y) + show "f ` C \ topspace Y" + using C closedin_subset fim by blast + fix K + assume K: "compactin Y K" + define A where "A \ {x \ topspace X. f x \ K}" + have eq: "f ` C \ K = f ` ({x \ topspace X. f x \ K} \ C)" + using C closedin_subset by auto + show "compactin Y (f ` C \ K)" + unfolding eq + proof (rule image_compactin) + show "compactin (subtopology X A) ({x \ topspace X. f x \ K} \ C)" + proof (rule closedin_compact_space) + show "compact_space (subtopology X A)" + by (simp add: A_def K YX compact_space_subtopology) + show "closedin (subtopology X A) ({x \ topspace X. f x \ K} \ C)" + using A_def C closedin_subtopology by blast + qed + have "continuous_map (subtopology X A) (subtopology Y K) f" if "kc_space X" + unfolding continuous_map_closedin + proof (intro conjI strip) + show "f x \ topspace (subtopology Y K)" + if "x \ topspace (subtopology X A)" for x + using that A_def K compactin_subset_topspace by auto + next + fix C + assume C: "closedin (subtopology Y K) C" + show "closedin (subtopology X A) {x \ topspace (subtopology X A). f x \ C}" + proof (rule compactin_imp_closedin_gen) + show "kc_space (subtopology X A)" + by (simp add: kc_space_subtopology that) + have [simp]: "{x \ topspace X. f x \ K \ f x \ C} = {x \ topspace X. f x \ C}" + using C closedin_imp_subset by auto + have "compactin (subtopology Y K) C" + by (simp add: C K closedin_compact_space compact_space_subtopology) + then have "compactin X {x \ topspace X. x \ A \ f x \ C}" + by (auto simp: A_def compactin_subtopology dest: YX) + then show "compactin (subtopology X A) {x \ topspace (subtopology X A). f x \ C}" + by (auto simp add: compactin_subtopology) + qed + qed + with f show "continuous_map (subtopology X A) Y f" + using continuous_map_from_subtopology continuous_map_in_subtopology by blast + qed + qed +qed (simp add: YX) + +lemma tube_lemma_left: + assumes W: "openin (prod_topology X Y) W" and C: "compactin X C" + and y: "y \ topspace Y" and subW: "C \ {y} \ W" + shows "\U V. openin X U \ openin Y V \ C \ U \ y \ V \ U \ V \ W" +proof (cases "C = {}") + case True + with y show ?thesis by auto +next + case False + have "\U V. openin X U \ openin Y V \ x \ U \ y \ V \ U \ V \ W" + if "x \ C" for x + using W openin_prod_topology_alt subW subsetD that by fastforce + then obtain U V where UV: "\x. x \ C \ openin X (U x) \ openin Y (V x) \ x \ U x \ y \ V x \ U x \ V x \ W" + by metis + then obtain D where D: "finite D" "D \ C" "C \ \ (U ` D)" + using compactinD [OF C, of "U`C"] + by (smt (verit) UN_I finite_subset_image imageE subsetI) + show ?thesis + proof (intro exI conjI) + show "openin X (\ (U ` D))" "openin Y (\ (V ` D))" + using D False UV by blast+ + show "y \ \ (V ` D)" "C \ \ (U ` D)" "\(U ` D) \ \(V ` D) \ W" + using D UV by force+ + qed +qed + +lemma Wallace_theorem_prod_topology: + assumes "compactin X K" "compactin Y L" + and W: "openin (prod_topology X Y) W" and subW: "K \ L \ W" + obtains U V where "openin X U" "openin Y V" "K \ U" "L \ V" "U \ V \ W" +proof - + have "\y. y \ L \ \U V. openin X U \ openin Y V \ K \ U \ y \ V \ U \ V \ W" + proof (intro tube_lemma_left assms) + fix y assume "y \ L" + show "y \ topspace Y" + using assms \y \ L\ compactin_subset_topspace by blast + show "K \ {y} \ W" + using \y \ L\ subW by force + qed + then obtain U V where UV: + "\y. y \ L \ openin X (U y) \ openin Y (V y) \ K \ U y \ y \ V y \ U y \ V y \ W" + by metis + then obtain M where "finite M" "M \ L" and M: "L \ \ (V ` M)" + using \compactin Y L\ unfolding compactin_def + by (smt (verit) UN_iff finite_subset_image imageE subset_iff) + show thesis + proof (cases "M={}") + case True + with M have "L={}" + by blast + then show ?thesis + using \compactin X K\ compactin_subset_topspace that by fastforce + next + case False + show ?thesis + proof + show "openin X (\(U`M))" + using False UV \M \ L\ \finite M\ by blast + show "openin Y (\(V`M))" + using UV \M \ L\ by blast + show "K \ \(U`M)" + by (meson INF_greatest UV \M \ L\ subsetD) + show "L \ \(V`M)" + by (simp add: M) + show "\(U`M) \ \(V`M) \ W" + using UV \M \ L\ by fastforce + qed + qed +qed + +lemma proper_map_prod: + "proper_map (prod_topology X Y) (prod_topology X' Y') (\(x,y). (f x, g y)) \ + topspace(prod_topology X Y) = {} \ proper_map X X' f \ proper_map Y Y' g" + (is "?lhs \ _ \ ?rhs") +proof (cases "topspace(prod_topology X Y) = {}") + case True + then show ?thesis + by (simp add: proper_map_on_empty) +next + case False + then have ne: "topspace X \ {}" "topspace Y \ {}" + by auto + define h where "h \ \(x,y). (f x, g y)" + have "proper_map X X' f" "proper_map Y Y' g" if ?lhs + proof - + have cm: "closed_map X X' f" "closed_map Y Y' g" + using that False closed_map_prod proper_imp_closed_map by blast+ + show "proper_map X X' f" + proof (clarsimp simp add: proper_map_def cm) + fix y + assume y: "y \ topspace X'" + obtain z where z: "z \ topspace Y" + using ne by blast + then have eq: "{x \ topspace X. f x = y} = + fst ` {u \ topspace X \ topspace Y. h u = (y,g z)}" + by (force simp: h_def) + show "compactin X {x \ topspace X. f x = y}" + unfolding eq + proof (intro image_compactin) + have "g z \ topspace Y'" + by (meson closed_map_def closedin_subset closedin_topspace cm image_subset_iff z) + with y show "compactin (prod_topology X Y) {u \ topspace X \ topspace Y. (h u) = (y, g z)}" + using that by (simp add: h_def proper_map_def) + show "continuous_map (prod_topology X Y) X fst" + by (simp add: continuous_map_fst) + qed + qed + show "proper_map Y Y' g" + proof (clarsimp simp add: proper_map_def cm) + fix y + assume y: "y \ topspace Y'" + obtain z where z: "z \ topspace X" + using ne by blast + then have eq: "{x \ topspace Y. g x = y} = + snd ` {u \ topspace X \ topspace Y. h u = (f z,y)}" + by (force simp: h_def) + show "compactin Y {x \ topspace Y. g x = y}" + unfolding eq + proof (intro image_compactin) + have "f z \ topspace X'" + by (meson closed_map_def closedin_subset closedin_topspace cm image_subset_iff z) + with y show "compactin (prod_topology X Y) {u \ topspace X \ topspace Y. (h u) = (f z, y)}" + using that by (simp add: proper_map_def h_def) + show "continuous_map (prod_topology X Y) Y snd" + by (simp add: continuous_map_snd) + qed + qed + qed + moreover + { assume R: ?rhs + then have fgim: "f ` topspace X \ topspace X'" "g ` topspace Y \ topspace Y'" + and cm: "closed_map X X' f" "closed_map Y Y' g" + by (auto simp: proper_map_def closed_map_imp_subset_topspace) + have "closed_map (prod_topology X Y) (prod_topology X' Y') h" + unfolding closed_map_fibre_neighbourhood imp_conjL + proof (intro conjI strip) + show "h ` topspace (prod_topology X Y) \ topspace (prod_topology X' Y')" + unfolding h_def using fgim by auto + fix W w + assume W: "openin (prod_topology X Y) W" + and w: "w \ topspace (prod_topology X' Y')" + and subW: "{x \ topspace (prod_topology X Y). h x = w} \ W" + then obtain x' y' where weq: "w = (x',y')" "x' \ topspace X'" "y' \ topspace Y'" + by auto + have eq: "{u \ topspace X \ topspace Y. h u = (x',y')} = {x \ topspace X. f x = x'} \ {y \ topspace Y. g y = y'}" + by (auto simp: h_def) + obtain U V where "openin X U" "openin Y V" "U \ V \ W" + and U: "{x \ topspace X. f x = x'} \ U" + and V: "{x \ topspace Y. g x = y'} \ V" + proof (rule Wallace_theorem_prod_topology) + show "compactin X {x \ topspace X. f x = x'}" "compactin Y {x \ topspace Y. g x = y'}" + using R weq unfolding proper_map_def closed_map_fibre_neighbourhood by fastforce+ + show "{x \ topspace X. f x = x'} \ {x \ topspace Y. g x = y'} \ W" + using weq subW by (auto simp: h_def) + qed (use W in auto) + obtain U' where "openin X' U'" "x' \ U'" and U': "{x \ topspace X. f x \ U'} \ U" + using cm U \openin X U\ weq unfolding closed_map_fibre_neighbourhood by meson + obtain V' where "openin Y' V'" "y' \ V'" and V': "{x \ topspace Y. g x \ V'} \ V" + using cm V \openin Y V\ weq unfolding closed_map_fibre_neighbourhood by meson + show "\V. openin (prod_topology X' Y') V \ w \ V \ {x \ topspace (prod_topology X Y). h x \ V} \ W" + proof (intro conjI exI) + show "openin (prod_topology X' Y') (U' \ V')" + by (simp add: \openin X' U'\ \openin Y' V'\ openin_prod_Times_iff) + show "w \ U' \ V'" + using \x' \ U'\ \y' \ V'\ weq by blast + show "{x \ topspace (prod_topology X Y). h x \ U' \ V'} \ W" + using \U \ V \ W\ U' V' h_def by auto + qed + qed + moreover + have "compactin (prod_topology X Y) {u \ topspace X \ topspace Y. h u = (w, z)}" + if "w \ topspace X'" and "z \ topspace Y'" for w z + proof - + have eq: "{u \ topspace X \ topspace Y. h u = (w,z)} = + {u \ topspace X. f u = w} \ {y. y \ topspace Y \ g y = z}" + by (auto simp: h_def) + show ?thesis + using R that by (simp add: eq compactin_Times proper_map_def) + qed + ultimately have ?lhs + by (auto simp: h_def proper_map_def) + } + ultimately show ?thesis using False by metis +qed + +lemma proper_map_paired: + assumes "Hausdorff_space X \ proper_map X Y f \ proper_map X Z g \ + Hausdorff_space Y \ continuous_map X Y f \ proper_map X Z g \ + Hausdorff_space Z \ proper_map X Y f \ continuous_map X Z g" + shows "proper_map X (prod_topology Y Z) (\x. (f x,g x))" + using assms +proof (elim disjE conjE) + assume \
: "Hausdorff_space X" "proper_map X Y f" "proper_map X Z g" + have eq: "(\x. (f x, g x)) = (\(x, y). (f x, g y)) \ (\x. (x, x))" + by auto + show "proper_map X (prod_topology Y Z) (\x. (f x, g x))" + unfolding eq + proof (rule proper_map_compose) + show "proper_map X (prod_topology X X) (\x. (x,x))" + by (simp add: \
) + show "proper_map (prod_topology X X) (prod_topology Y Z) (\(x,y). (f x, g y))" + by (simp add: \
proper_map_prod) + qed +next + assume \
: "Hausdorff_space Y" "continuous_map X Y f" "proper_map X Z g" + have eq: "(\x. (f x, g x)) = (\(x,y). (x,g y)) \ (\x. (f x,x))" + by auto + show "proper_map X (prod_topology Y Z) (\x. (f x, g x))" + unfolding eq + proof (rule proper_map_compose) + show "proper_map X (prod_topology Y X) (\x. (f x,x))" + by (simp add: \
proper_map_paired_continuous_map_left) + show "proper_map (prod_topology Y X) (prod_topology Y Z) (\(x,y). (x,g y))" + by (simp add: \
proper_map_prod proper_map_id [unfolded id_def]) + qed +next + assume \
: "Hausdorff_space Z" "proper_map X Y f" "continuous_map X Z g" + have eq: "(\x. (f x, g x)) = (\(x,y). (f x,y)) \ (\x. (x,g x))" + by auto + show "proper_map X (prod_topology Y Z) (\x. (f x, g x))" + unfolding eq + proof (rule proper_map_compose) + show "proper_map X (prod_topology X Z) (\x. (x, g x))" + using \
proper_map_paired_continuous_map_right by auto + show "proper_map (prod_topology X Z) (prod_topology Y Z) (\(x,y). (f x,y))" + by (simp add: \
proper_map_prod proper_map_id [unfolded id_def]) + qed +qed + +lemma proper_map_pairwise: + assumes + "Hausdorff_space X \ proper_map X Y (fst \ f) \ proper_map X Z (snd \ f) \ + Hausdorff_space Y \ continuous_map X Y (fst \ f) \ proper_map X Z (snd \ f) \ + Hausdorff_space Z \ proper_map X Y (fst \ f) \ continuous_map X Z (snd \ f)" + shows "proper_map X (prod_topology Y Z) f" + using proper_map_paired [OF assms] by (simp add: o_def) + +lemma proper_map_from_composition_right: + assumes "Hausdorff_space Y" "proper_map X Z (g \ f)" and "continuous_map X Y f" + and contg: "continuous_map Y Z g" + shows "proper_map X Y f" +proof - + define YZ where "YZ \ subtopology (prod_topology Y Z) ((\x. (x, g x)) ` topspace Y)" + have "proper_map X Y (fst \ (\x. (f x, (g \ f) x)))" + proof (rule proper_map_compose) + have [simp]: "x \ topspace X \ f x \ topspace Y" for x + by (meson assms(3) continuous_map_def) + show "proper_map X YZ (\x. (f x, (g \ f) x))" + unfolding YZ_def + using assms + by (force intro!: proper_map_into_subtopology proper_map_paired simp: o_def image_iff)+ + show "proper_map YZ Y fst" + using contg + by (simp flip: homeomorphic_maps_graph add: YZ_def homeomorphic_maps_map homeomorphic_imp_proper_map) + qed + moreover have "fst \ (\x. (f x, (g \ f) x)) = f" + by auto + ultimately show ?thesis + by auto +qed + +lemma perfect_map_from_composition_right: + "\Hausdorff_space Y; perfect_map X Z (g \ f); + continuous_map X Y f; continuous_map Y Z g; f ` topspace X = topspace Y\ + \ perfect_map X Y f" + by (meson perfect_map_def proper_map_from_composition_right) + +lemma perfect_map_from_composition_right_inj: + "\perfect_map X Z (g \ f); f ` topspace X = topspace Y; + continuous_map X Y f; continuous_map Y Z g; inj_on g (topspace Y)\ + \ perfect_map X Y f" + by (meson continuous_map_image_subset_topspace perfect_map_def proper_map_from_composition_right_inj) + subsection \Regular spaces\ @@ -2022,6 +2360,10 @@ by auto qed +lemma continuous_imp_proper_map: + "\compact_space X; kc_space Y; continuous_map X Y f\ \ proper_map X Y f" + by (simp add: continuous_closed_imp_proper_map continuous_imp_closed_map_gen kc_imp_t1_space) + lemma tube_lemma_right: assumes W: "openin (prod_topology X Y) W" and C: "compactin Y C" @@ -2060,8 +2402,7 @@ have **: "\U y. \openin (prod_topology X Y) U; y \ topspace X; {x \ topspace X \ topspace Y. fst x = y} \ U\ \ \V. openin X V \ y \ V \ V \ topspace Y \ U" - using tube_lemma_right[of X Y _ "topspace Y"] assms compact_space_def - by force + using tube_lemma_right[of X Y _ "topspace Y"] assms by (fastforce simp: compact_space_def) show ?thesis unfolding closed_map_fibre_neighbourhood by (force simp: * openin_subset cong: conj_cong intro: **) @@ -2492,17 +2833,19 @@ qed lemma locally_compact_space_open_subset: - assumes reg: "regular_space X" and loc: "locally_compact_space X" and "openin X S" + assumes X: "Hausdorff_space X \ regular_space X" and loc: "locally_compact_space X" and "openin X S" shows "locally_compact_space (subtopology X S)" proof (clarsimp simp: locally_compact_space_def) fix x assume x: "x \ topspace X" "x \ S" then obtain U K where UK: "openin X U" "compactin X K" "x \ U" "U \ K" by (meson loc locally_compact_space_def) - have "openin X (U \ S)" + moreover have reg: "regular_space X" + using X loc locally_compact_Hausdorff_imp_regular_space by blast + moreover have "openin X (U \ S)" by (simp add: UK \openin X S\ openin_Int) - with UK reg x obtain V C + ultimately obtain V C where VC: "openin X V" "closedin X C" "x \ V" "V \ C" "C \ U" "C \ S" - by (metis IntI le_inf_iff neighbourhood_base_of neighbourhood_base_of_closedin) + by (metis \x \ S\ IntI le_inf_iff neighbourhood_base_of neighbourhood_base_of_closedin) show "\U. openin (subtopology X S) U \ (\K. compactin (subtopology X S) K \ x \ U \ U \ K)" proof (intro conjI exI) @@ -2575,19 +2918,17 @@ then have "C \ topspace X" by (simp add: closedin_subset) have "locally_compact_space (subtopology (subtopology X C) (topspace (subtopology X C) \ U))" - proof (rule locally_compact_space_open_subset) - show "regular_space (subtopology X C)" - by (simp add: \Hausdorff_space X\ loc locally_compact_Hausdorff_imp_regular_space regular_space_subtopology) - show "locally_compact_space (subtopology X C)" - by (simp add: \closedin X C\ loc locally_compact_space_closed_subset) - show "openin (subtopology X C) (topspace (subtopology X C) \ U)" - by (simp add: \openin X U\ Int_left_commute inf_commute openin_Int openin_subtopology_Int2) -qed - then show ?rhs - by (metis Seq \C \ topspace X\ inf.coboundedI1 subtopology_subtopology subtopology_topspace) + proof (rule locally_compact_space_open_subset) + show "locally_compact_space (subtopology X C)" + by (simp add: \closedin X C\ loc locally_compact_space_closed_subset) + show "openin (subtopology X C) (topspace (subtopology X C) \ U)" + by (simp add: \openin X U\ Int_left_commute inf_commute openin_Int openin_subtopology_Int2) + qed (simp add: Hausdorff_space_subtopology \Hausdorff_space X\) + then show ?rhs + by (metis Seq \C \ topspace X\ inf.coboundedI1 subtopology_subtopology subtopology_topspace) next assume ?rhs then show ?lhs - using assms locally_compact_subspace_closed_Int_openin by blast + using assms locally_compact_subspace_closed_Int_openin by blast qed lemma dense_locally_compact_openin_Hausdorff_space: @@ -3505,7 +3846,7 @@ lemma quasi_component_of: "quasi_component_of X x y \ x \ topspace X \ y \ topspace X \ (\T. x \ T \ closedin X T \ openin X T \ y \ T)" - unfolding quasi_component_of_def by blast + unfolding quasi_component_of_def by (metis Diff_iff closedin_def openin_closedin_eq) lemma quasi_component_of_alt: "quasi_component_of X x y \ @@ -4433,5 +4774,536 @@ \ X frontier_of C \ X frontier_of S \ {}" by (simp add: boundary_bumping_theorem_gen closedin_compact_space compact_imp_locally_compact_space) +subsection \Compactly generated spaces (k-spaces)\ + +text \These don't have to be Hausdorff\ + +definition k_space where + "k_space X \ + \S. S \ topspace X \ + (closedin X S \ (\K. compactin X K \ closedin (subtopology X K) (K \ S)))" + +lemma k_space: + "k_space X \ + (\S. S \ topspace X \ + (\K. compactin X K \ closedin (subtopology X K) (K \ S)) \ closedin X S)" + by (metis closedin_subtopology inf_commute k_space_def) + +lemma k_space_open: + "k_space X \ + (\S. S \ topspace X \ + (\K. compactin X K \ openin (subtopology X K) (K \ S)) \ openin X S)" +proof - + have "openin X S" + if "k_space X" "S \ topspace X" + and "\K. compactin X K \ openin (subtopology X K) (K \ S)" for S + using that unfolding k_space openin_closedin_eq + by (metis Diff_Int_distrib2 Diff_subset inf_commute topspace_subtopology) + moreover have "k_space X" + if "\S. S \ topspace X \ (\K. compactin X K \ openin (subtopology X K) (K \ S)) \ openin X S" + unfolding k_space openin_closedin_eq + by (simp add: Diff_Int_distrib closedin_def inf_commute that) + ultimately show ?thesis + by blast +qed + +lemma k_space_alt: + "k_space X \ + (\S. S \ topspace X + \ (openin X S \ (\K. compactin X K \ openin (subtopology X K) (K \ S))))" + by (meson k_space_open openin_subtopology_Int2) + +lemma k_space_quotient_map_image: + assumes q: "quotient_map X Y q" and X: "k_space X" + shows "k_space Y" + unfolding k_space +proof clarify + fix S + assume "S \ topspace Y" and S: "\K. compactin Y K \ closedin (subtopology Y K) (K \ S)" + then have iff: "closedin X {x \ topspace X. q x \ S} \ closedin Y S" + using q quotient_map_closedin by fastforce + have "closedin (subtopology X K) (K \ {x \ topspace X. q x \ S})" if "compactin X K" for K + proof - + have "{x \ topspace X. q x \ q ` K} \ K = K" + using compactin_subset_topspace that by blast + then have *: "subtopology X K = subtopology (subtopology X {x \ topspace X. q x \ q ` K}) K" + by (simp add: subtopology_subtopology) + have **: "K \ {x \ topspace X. q x \ S} = + K \ {x \ topspace (subtopology X {x \ topspace X. q x \ q ` K}). q x \ q ` K \ S}" + by auto + have "K \ topspace X" + by (simp add: compactin_subset_topspace that) + show ?thesis + unfolding * ** + proof (intro closedin_continuous_map_preimage closedin_subtopology_Int_closed) + show "continuous_map (subtopology X {x \ topspace X. q x \ q ` K}) (subtopology Y (q ` K)) q" + by (auto simp add: continuous_map_in_subtopology continuous_map_from_subtopology q quotient_imp_continuous_map) + show "closedin (subtopology Y (q ` K)) (q ` K \ S)" + by (meson S image_compactin q quotient_imp_continuous_map that) + qed + qed + then have "closedin X {x \ topspace X. q x \ S}" + by (metis (no_types, lifting) X k_space mem_Collect_eq subsetI) + with iff show "closedin Y S" by simp +qed + +lemma k_space_retraction_map_image: + "\retraction_map X Y r; k_space X\ \ k_space Y" + using k_space_quotient_map_image retraction_imp_quotient_map by blast + +lemma homeomorphic_k_space: + "X homeomorphic_space Y \ k_space X \ k_space Y" + by (meson homeomorphic_map_def homeomorphic_space homeomorphic_space_sym k_space_quotient_map_image) + +lemma k_space_perfect_map_image: + "\k_space X; perfect_map X Y f\ \ k_space Y" + using k_space_quotient_map_image perfect_imp_quotient_map by blast + +lemma locally_compact_imp_k_space: + assumes "locally_compact_space X" + shows "k_space X" + unfolding k_space +proof clarify + fix S + assume "S \ topspace X" and S: "\K. compactin X K \ closedin (subtopology X K) (K \ S)" + have False if non: "\ (X closure_of S \ S)" + proof - + obtain x where "x \ X closure_of S" "x \ S" + using non by blast + then have "x \ topspace X" + by (simp add: in_closure_of) + then obtain K U where "openin X U" "compactin X K" "x \ U" "U \ K" + by (meson assms locally_compact_space_def) + then show False + using \x \ X closure_of S\ openin_Int_closure_of_eq [OF \openin X U\] + by (smt (verit, ccfv_threshold) Int_iff S \x \ S\ closedin_Int_closure_of inf.orderE inf_assoc) + qed + then show "closedin X S" + using S \S \ topspace X\ closure_of_subset_eq by blast +qed + +lemma compact_imp_k_space: + "compact_space X \ k_space X" + by (simp add: compact_imp_locally_compact_space locally_compact_imp_k_space) + +lemma k_space_discrete_topology: "k_space(discrete_topology U)" + by (simp add: k_space_open) + +lemma k_space_closed_subtopology: + assumes "k_space X" "closedin X C" + shows "k_space (subtopology X C)" +unfolding k_space compactin_subtopology +proof clarsimp + fix S + assume Ssub: "S \ topspace X" "S \ C" + and S: "\K. compactin X K \ K \ C \ closedin (subtopology (subtopology X C) K) (K \ S)" + have "closedin (subtopology X K) (K \ S)" if "compactin X K" for K + proof - + have "closedin (subtopology (subtopology X C) (K \ C)) ((K \ C) \ S)" + by (simp add: S \closedin X C\ compact_Int_closedin that) + then show ?thesis + using \closedin X C\ Ssub by (auto simp add: closedin_subtopology) + qed + then show "closedin (subtopology X C) S" + by (metis Ssub \k_space X\ closedin_subset_topspace k_space_def) +qed + +lemma k_space_subtopology: + assumes 1: "\T. \T \ topspace X; T \ S; + \K. compactin X K \ closedin (subtopology X (K \ S)) (K \ T)\ \ closedin (subtopology X S) T" + assumes 2: "\K. compactin X K \ k_space(subtopology X (K \ S))" + shows "k_space (subtopology X S)" + unfolding k_space +proof (intro conjI strip) + fix U + assume \
: "U \ topspace (subtopology X S) \ (\K. compactin (subtopology X S) K \ closedin (subtopology (subtopology X S) K) (K \ U))" + have "closedin (subtopology X (K \ S)) (K \ U)" if "compactin X K" for K + proof - + have "K \ U \ topspace (subtopology X (K \ S))" + using "\
" by auto + moreover + have "\K'. compactin (subtopology X (K \ S)) K' \ closedin (subtopology (subtopology X (K \ S)) K') (K' \ K \ U)" + by (metis "\
" compactin_subtopology inf.orderE inf_commute subtopology_subtopology) + ultimately show ?thesis + by (metis (no_types, opaque_lifting) "2" inf.assoc k_space_def that) + qed + then show "closedin (subtopology X S) U" + using "1" \
by auto +qed + +lemma k_space_subtopology_open: + assumes 1: "\T. \T \ topspace X; T \ S; + \K. compactin X K \ openin (subtopology X (K \ S)) (K \ T)\ \ openin (subtopology X S) T" + assumes 2: "\K. compactin X K \ k_space(subtopology X (K \ S))" + shows "k_space (subtopology X S)" + unfolding k_space_open +proof (intro conjI strip) + fix U + assume \
: "U \ topspace (subtopology X S) \ (\K. compactin (subtopology X S) K \ openin (subtopology (subtopology X S) K) (K \ U))" + have "openin (subtopology X (K \ S)) (K \ U)" if "compactin X K" for K + proof - + have "K \ U \ topspace (subtopology X (K \ S))" + using "\
" by auto + moreover + have "\K'. compactin (subtopology X (K \ S)) K' \ openin (subtopology (subtopology X (K \ S)) K') (K' \ K \ U)" + by (metis "\
" compactin_subtopology inf.orderE inf_commute subtopology_subtopology) + ultimately show ?thesis + by (metis (no_types, opaque_lifting) "2" inf.assoc k_space_open that) + qed + then show "openin (subtopology X S) U" + using "1" \
by auto +qed + + +lemma k_space_open_subtopology_aux: + assumes "kc_space X" "compact_space X" "openin X V" + shows "k_space (subtopology X V)" +proof (clarsimp simp: k_space subtopology_subtopology compactin_subtopology Int_absorb1) + fix S + assume "S \ topspace X" + and "S \ V" + and S: "\K. compactin X K \ K \ V \ closedin (subtopology X K) (K \ S)" + then have "V \ topspace X" + using assms openin_subset by blast + have "S = V \ ((topspace X - V) \ S)" + using \S \ V\ by auto + moreover have "closedin (subtopology X V) (V \ ((topspace X - V) \ S))" + proof (intro closedin_subtopology_Int_closed compactin_imp_closedin_gen \kc_space X\) + show "compactin X (topspace X - V \ S)" + unfolding compactin_def + proof (intro conjI strip) + show "topspace X - V \ S \ topspace X" + by (simp add: \S \ topspace X\) + fix \ + assume \: "Ball \ (openin X) \ topspace X - V \ S \ \\" + moreover + have "compactin X (topspace X - V)" + using assms closedin_compact_space by blast + ultimately obtain \ where "finite \" "\ \ \" and \: "topspace X - V \ \\" + unfolding compactin_def using \V \ topspace X\ by (metis le_sup_iff) + then have "topspace X - \\ \ V" + by blast + then have "closedin (subtopology X (topspace X - \\)) ((topspace X - \\) \ S)" + by (meson S \ \\ \ \\ \compact_space X\ closedin_compact_space openin_Union openin_closedin_eq subset_iff) + then have "compactin X ((topspace X - \\) \ S)" + by (meson \ \\ \ \\\compact_space X\ closedin_compact_space closedin_trans_full openin_Union openin_closedin_eq subset_iff) + then obtain \ where "finite \" "\ \ \" "(topspace X - \\) \ S \ \\" + unfolding compactin_def by (smt (verit, best) \ inf_le2 subset_trans sup.boundedE) + with \ have "topspace X - V \ S \ \(\ \ \)" + using \S \ topspace X\ by auto + then show "\\. finite \ \ \ \ \ \ topspace X - V \ S \ \\" + by (metis \\ \ \\ \\ \ \\ \finite \\ \finite \\ finite_Un le_sup_iff) + qed + qed + ultimately show "closedin (subtopology X V) S" + by metis +qed + + +lemma k_space_open_subtopology: + assumes X: "kc_space X \ Hausdorff_space X \ regular_space X" and "k_space X" "openin X S" + shows "k_space(subtopology X S)" +proof (rule k_space_subtopology_open) + fix T + assume "T \ topspace X" + and "T \ S" + and T: "\K. compactin X K \ openin (subtopology X (K \ S)) (K \ T)" + have "openin (subtopology X K) (K \ T)" if "compactin X K" for K + by (smt (verit, ccfv_threshold) T assms(3) inf_assoc inf_commute openin_Int openin_subtopology that) + then show "openin (subtopology X S) T" + by (metis \T \ S\ \T \ topspace X\ assms(2) k_space_alt subset_openin_subtopology) +next + fix K + assume "compactin X K" + then have KS: "openin (subtopology X K) (K \ S)" + by (simp add: \openin X S\ openin_subtopology_Int2) + have XK: "compact_space (subtopology X K)" + by (simp add: \compactin X K\ compact_space_subtopology) + show "k_space (subtopology X (K \ S))" + using X + proof (rule disjE) + assume "kc_space X" + then show "k_space (subtopology X (K \ S))" + using k_space_open_subtopology_aux [of "subtopology X K" "K \ S"] + by (simp add: KS XK kc_space_subtopology subtopology_subtopology) + next + assume "Hausdorff_space X \ regular_space X" + then have "locally_compact_space (subtopology (subtopology X K) (K \ S))" + using locally_compact_space_open_subset Hausdorff_space_subtopology KS XK + compact_imp_locally_compact_space regular_space_subtopology by blast + then show "k_space (subtopology X (K \ S))" + by (simp add: locally_compact_imp_k_space subtopology_subtopology) + qed +qed + +lemma k_kc_space_subtopology: + "\k_space X; kc_space X; openin X S \ closedin X S\ \ k_space(subtopology X S) \ kc_space(subtopology X S)" + by (metis k_space_closed_subtopology k_space_open_subtopology kc_space_subtopology) + + +lemma k_space_as_quotient_explicit: + "k_space X \ quotient_map (sum_topology (subtopology X) {K. compactin X K}) X snd" +proof - + have [simp]: "{x \ topspace X. x \ K \ x \ U} = K \ U" if "U \ topspace X" for K U + using that by blast + show "?thesis" + apply (simp add: quotient_map_def openin_sum_topology snd_image_Sigma k_space_alt) + by (smt (verit, del_insts) Union_iff compactin_sing inf.orderE mem_Collect_eq singletonI subsetI) +qed + +lemma k_space_as_quotient: + fixes X :: "'a topology" + shows "k_space X \ (\q. \Y:: ('a set * 'a) topology. locally_compact_space Y \ quotient_map Y X q)" + (is "?lhs=?rhs") +proof + show "k_space X" if ?rhs + using that k_space_quotient_map_image locally_compact_imp_k_space by blast +next + assume "k_space X" + show ?rhs + proof (intro exI conjI) + show "locally_compact_space (sum_topology (subtopology X) {K. compactin X K})" + by (simp add: compact_imp_locally_compact_space compact_space_subtopology locally_compact_space_sum_topology) + show "quotient_map (sum_topology (subtopology X) {K. compactin X K}) X snd" + using \k_space X\ k_space_as_quotient_explicit by blast + qed +qed + +lemma k_space_prod_topology_left: + assumes X: "locally_compact_space X" "Hausdorff_space X \ regular_space X" and "k_space Y" + shows "k_space (prod_topology X Y)" +proof - + obtain q and Z :: "('b set * 'b) topology" where "locally_compact_space Z" and q: "quotient_map Z Y q" + using \k_space Y\ k_space_as_quotient by blast + then show ?thesis + using quotient_map_prod_right [OF X q] X k_space_quotient_map_image locally_compact_imp_k_space + locally_compact_space_prod_topology by blast +qed + +text \Essentially the same proof\ +lemma k_space_prod_topology_right: + assumes "k_space X" and Y: "locally_compact_space Y" "Hausdorff_space Y \ regular_space Y" + shows "k_space (prod_topology X Y)" +proof - + obtain q and Z :: "('a set * 'a) topology" where "locally_compact_space Z" and q: "quotient_map Z X q" + using \k_space X\ k_space_as_quotient by blast + then show ?thesis + using quotient_map_prod_left [OF Y q] using Y k_space_quotient_map_image locally_compact_imp_k_space + locally_compact_space_prod_topology by blast +qed + + +lemma continuous_map_from_k_space: + assumes "k_space X" and f: "\K. compactin X K \ continuous_map(subtopology X K) Y f" + shows "continuous_map X Y f" +proof - + have "\x. x \ topspace X \ f x \ topspace Y" + by (metis compactin_absolute compactin_sing f image_compactin image_empty image_insert) + moreover have "closedin X {x \ topspace X. f x \ C}" if "closedin Y C" for C + proof - + have "{x \ topspace X. f x \ C} \ topspace X" + by fastforce + moreover + have eq: "K \ {x \ topspace X. f x \ C} = {x. x \ topspace(subtopology X K) \ f x \ (f ` K \ C)}" for K + by auto + have "closedin (subtopology X K) (K \ {x \ topspace X. f x \ C})" if "compactin X K" for K + unfolding eq + proof (rule closedin_continuous_map_preimage) + show "continuous_map (subtopology X K) (subtopology Y (f`K)) f" + by (simp add: continuous_map_in_subtopology f image_mono that) + show "closedin (subtopology Y (f`K)) (f ` K \ C)" + using \closedin Y C\ closedin_subtopology by blast + qed + ultimately show ?thesis + using \k_space X\ k_space by blast + qed + ultimately show ?thesis + by (simp add: continuous_map_closedin) +qed + +lemma closed_map_into_k_space: + assumes "k_space Y" and fim: "f ` (topspace X) \ topspace Y" + and f: "\K. compactin Y K + \ closed_map(subtopology X {x \ topspace X. f x \ K}) (subtopology Y K) f" + shows "closed_map X Y f" + unfolding closed_map_def +proof (intro strip) + fix C + assume "closedin X C" + have "closedin (subtopology Y K) (K \ f ` C)" + if "compactin Y K" for K + proof - + have eq: "K \ f ` C = f ` ({x \ topspace X. f x \ K} \ C)" + using \closedin X C\ closedin_subset by auto + show ?thesis + unfolding eq + by (metis (no_types, lifting) \closedin X C\ closed_map_def closedin_subtopology f inf_commute that) + qed + then show "closedin Y (f ` C)" + using \k_space Y\ unfolding k_space + by (meson \closedin X C\ closedin_subset dual_order.trans fim image_mono) +qed + + +text \Essentially the same proof\ +lemma open_map_into_k_space: + assumes "k_space Y" and fim: "f ` (topspace X) \ topspace Y" + and f: "\K. compactin Y K + \ open_map (subtopology X {x \ topspace X. f x \ K}) (subtopology Y K) f" + shows "open_map X Y f" + unfolding open_map_def +proof (intro strip) + fix C + assume "openin X C" + have "openin (subtopology Y K) (K \ f ` C)" + if "compactin Y K" for K + proof - + have eq: "K \ f ` C = f ` ({x \ topspace X. f x \ K} \ C)" + using \openin X C\ openin_subset by auto + show ?thesis + unfolding eq + by (metis (no_types, lifting) \openin X C\ open_map_def openin_subtopology f inf_commute that) + qed + then show "openin Y (f ` C)" + using \k_space Y\ unfolding k_space_open + by (meson \openin X C\ openin_subset dual_order.trans fim image_mono) +qed + +lemma quotient_map_into_k_space: + fixes f :: "'a \ 'b" + assumes "k_space Y" and cmf: "continuous_map X Y f" + and fim: "f ` (topspace X) = topspace Y" + and f: "\k. compactin Y k + \ quotient_map (subtopology X {x \ topspace X. f x \ k}) + (subtopology Y k) f" + shows "quotient_map X Y f" +proof - + have "closedin Y C" + if "C \ topspace Y" and K: "closedin X {x \ topspace X. f x \ C}" for C + proof - + have "closedin (subtopology Y K) (K \ C)" if "compactin Y K" for K + proof - + define Kf where "Kf \ {x \ topspace X. f x \ K}" + have *: "K \ C \ topspace Y \ K \ C \ K" + using \C \ topspace Y\ by blast + then have eq: "closedin (subtopology X Kf) (Kf \ {x \ topspace X. f x \ C}) = + closedin (subtopology Y K) (K \ C)" + using f [OF that] * unfolding quotient_map_closedin Kf_def + by (smt (verit, ccfv_SIG) Collect_cong Int_def compactin_subset_topspace mem_Collect_eq that topspace_subtopology topspace_subtopology_subset) + have dd: "{x \ topspace X \ Kf. f x \ K \ C} = Kf \ {x \ topspace X. f x \ C}" + by (auto simp add: Kf_def) + have "closedin (subtopology X Kf) {x \ topspace X. x \ Kf \ f x \ K \ f x \ C}" + using K closedin_subtopology by (fastforce simp add: Kf_def) + with K closedin_subtopology_Int_closed eq show ?thesis + by blast + qed + then show ?thesis + using \k_space Y\ that unfolding k_space by blast + qed + moreover have "closedin X {x \ topspace X. f x \ K}" + if "K \ topspace Y" "closedin Y K" for K + using that cmf continuous_map_closedin by fastforce + ultimately show ?thesis + unfolding quotient_map_closedin using fim by blast +qed + +lemma quotient_map_into_k_space_eq: + assumes "k_space Y" "kc_space Y" + shows "quotient_map X Y f \ + continuous_map X Y f \ f ` (topspace X) = topspace Y \ + (\K. compactin Y K + \ quotient_map (subtopology X {x \ topspace X. f x \ K}) (subtopology Y K) f)" + using assms + by (auto simp: kc_space_def intro: quotient_map_into_k_space quotient_map_restriction + dest: quotient_imp_continuous_map quotient_imp_surjective_map) + +lemma open_map_into_k_space_eq: + assumes "k_space Y" + shows "open_map X Y f \ + f ` (topspace X) \ topspace Y \ + (\k. compactin Y k + \ open_map (subtopology X {x \ topspace X. f x \ k}) (subtopology Y k) f)" + (is "?lhs=?rhs") +proof + show "?lhs \ ?rhs" + by (simp add: open_map_imp_subset_topspace open_map_restriction) + show "?rhs \ ?lhs" + by (simp add: assms open_map_into_k_space) +qed + +lemma closed_map_into_k_space_eq: + assumes "k_space Y" + shows "closed_map X Y f \ + f ` (topspace X) \ topspace Y \ + (\k. compactin Y k + \ closed_map (subtopology X {x \ topspace X. f x \ k}) (subtopology Y k) f)" + (is "?lhs \ ?rhs") +proof + show "?lhs \ ?rhs" + by (simp add: closed_map_imp_subset_topspace closed_map_restriction) + show "?rhs \ ?lhs" + by (simp add: assms closed_map_into_k_space) +qed + +lemma proper_map_into_k_space: + assumes "k_space Y" and fim: "f ` (topspace X) \ topspace Y" + and f: "\K. compactin Y K + \ proper_map (subtopology X {x \ topspace X. f x \ K}) + (subtopology Y K) f" + shows "proper_map X Y f" +proof - + have "closed_map X Y f" + by (meson assms closed_map_into_k_space fim proper_map_def) + with f topspace_subtopology_subset show ?thesis + apply (simp add: proper_map_alt) + by (smt (verit, best) Collect_cong compactin_absolute) +qed + +lemma proper_map_into_k_space_eq: + assumes "k_space Y" + shows "proper_map X Y f \ + f ` (topspace X) \ topspace Y \ + (\K. compactin Y K + \ proper_map (subtopology X {x \ topspace X. f x \ K}) (subtopology Y K) f)" + (is "?lhs \ ?rhs") +proof + show "?lhs \ ?rhs" + by (simp add: proper_map_imp_subset_topspace proper_map_restriction) + show "?rhs \ ?lhs" + by (simp add: assms proper_map_into_k_space) +qed + +lemma compact_imp_proper_map: + assumes "k_space Y" "kc_space Y" and fim: "f ` (topspace X) \ topspace Y" + and f: "continuous_map X Y f \ kc_space X" + and comp: "\K. compactin Y K \ compactin X {x \ topspace X. f x \ K}" + shows "proper_map X Y f" +proof (rule compact_imp_proper_map_gen) + fix S + assume "S \ topspace Y" + and "\K. compactin Y K \ compactin Y (S \ K)" + with assms show "closedin Y S" + by (simp add: closedin_subset_topspace inf_commute k_space kc_space_def) +qed (use assms in auto) + +lemma proper_eq_compact_map: + assumes "k_space Y" "kc_space Y" + and f: "continuous_map X Y f \ kc_space X" + shows "proper_map X Y f \ + f ` (topspace X) \ topspace Y \ + (\K. compactin Y K \ compactin X {x \ topspace X. f x \ K})" + (is "?lhs \ ?rhs") +proof + show "?lhs \ ?rhs" + by (simp add: proper_map_alt proper_map_imp_subset_topspace) +qed (use assms compact_imp_proper_map in auto) + +lemma compact_imp_perfect_map: + assumes "k_space Y" "kc_space Y" and "f ` (topspace X) = topspace Y" + and "continuous_map X Y f" + and "\K. compactin Y K \ compactin X {x \ topspace X. f x \ K}" + shows "perfect_map X Y f" + by (simp add: assms compact_imp_proper_map perfect_map_def) + end diff -r 070703d83cfe -r cec875dcc59e src/HOL/Analysis/Abstract_Topology.thy --- a/src/HOL/Analysis/Abstract_Topology.thy Mon May 22 12:01:05 2023 +0200 +++ b/src/HOL/Analysis/Abstract_Topology.thy Tue May 23 12:31:23 2023 +0100 @@ -269,6 +269,10 @@ unfolding subtopology_def topology_inverse'[OF istopology_subtopology] by auto +lemma subset_openin_subtopology: + "\openin X S; S \ T\ \ openin (subtopology X T) S" + by (metis inf.orderE openin_subtopology) + lemma openin_subtopology_Int: "openin X S \ openin (subtopology X T) (S \ T)" using openin_subtopology by auto @@ -296,6 +300,10 @@ unfolding closedin_def topspace_subtopology by (auto simp: openin_subtopology) +lemma closedin_subtopology_Int_closed: + "closedin X T \ closedin (subtopology X S) (S \ T)" + using closedin_subtopology inf_commute by blast + lemma closedin_subset_topspace: "\closedin X S; S \ T\ \ closedin (subtopology X T) S" using closedin_subtopology by fastforce @@ -4808,6 +4816,18 @@ "proper_map X Y f \ f ` (topspace X) \ topspace Y" by (simp add: closed_map_imp_subset_topspace proper_map_def) +lemma proper_map_restriction: + assumes "proper_map X Y f" "{x \ topspace X. f x \ V} = U" + shows "proper_map (subtopology X U) (subtopology Y V) f" +proof - + have [simp]: "{x \ topspace X. f x \ V \ f x = y} = {x \ topspace X. f x = y}" + if "y \ V" for y + using that by auto + show ?thesis + using assms unfolding proper_map_def using closed_map_restriction + by (force simp: compactin_subtopology) +qed + lemma closed_injective_imp_proper_map: assumes f: "closed_map X Y f" and inj: "inj_on f (topspace X)" shows "proper_map X Y f" @@ -4976,6 +4996,45 @@ "S \ topspace X \ proper_map (subtopology X S) X id \ closedin X S \ (\k. compactin X k \ compactin X (S \ k))" by (metis closed_Int_compactin closed_map_inclusion_eq inf.absorb_iff2 inj_on_id injective_imp_proper_eq_closed_map) +lemma proper_map_into_subtopology: + "\proper_map X Y f; f ` topspace X \ C\ \ proper_map X (subtopology Y C) f" + by (simp add: closed_map_into_subtopology compactin_subtopology proper_map_alt) + +lemma proper_map_from_composition_left: + assumes gf: "proper_map X Z (g \ f)" and contf: "continuous_map X Y f" and fim: "f ` topspace X = topspace Y" + shows "proper_map Y Z g" + unfolding proper_map_def +proof (intro strip conjI) + show "closed_map Y Z g" + by (meson closed_map_from_composition_left gf contf fim proper_imp_closed_map) + fix z assume "z \ topspace Z" + have eq: "{y \ topspace Y. g y = z} = f ` {x \ topspace X. (g \ f) x = z}" + using fim by force + show "compactin Y {x \ topspace Y. g x = z}" + unfolding eq + proof (rule image_compactin [OF _ contf]) + show "compactin X {x \ topspace X. (g \ f) x = z}" + using \z \ topspace Z\ gf proper_map_def by fastforce + qed +qed + +lemma proper_map_from_composition_right_inj: + assumes gf: "proper_map X Z (g \ f)" and fim: "f ` topspace X \ topspace Y" + and contf: "continuous_map Y Z g" and inj: "inj_on g (topspace Y)" + shows "proper_map X Y f" + unfolding proper_map_def +proof (intro strip conjI) + show "closed_map X Y f" + by (meson closed_map_from_composition_right assms proper_imp_closed_map) + fix y + assume "y \ topspace Y" + with fim inj have eq: "{x \ topspace X. f x = y} = {x \ topspace X. (g \ f) x = g y}" + by (auto simp: image_subset_iff inj_onD) + show "compactin X {x \ topspace X. f x = y}" + unfolding eq + by (smt (verit) Collect_cong \y \ topspace Y\ contf continuous_map_closedin gf proper_map_def) +qed + subsection\Perfect maps (proper, continuous and surjective)\ @@ -5021,4 +5080,11 @@ "perfect_map X Y f \ f ` (topspace X) = topspace Y" by (simp add: perfect_map_def) +lemma perfect_map_from_composition_left: + assumes "perfect_map X Z (g \ f)" and "continuous_map X Y f" + and "continuous_map Y Z g" and "f ` topspace X = topspace Y" + shows "perfect_map Y Z g" + using assms unfolding perfect_map_def + by (metis image_comp proper_map_from_composition_left) + end diff -r 070703d83cfe -r cec875dcc59e src/HOL/Analysis/Analysis.thy --- a/src/HOL/Analysis/Analysis.thy Mon May 22 12:01:05 2023 +0200 +++ b/src/HOL/Analysis/Analysis.thy Tue May 23 12:31:23 2023 +0100 @@ -7,6 +7,7 @@ FSigma Sum_Topology Abstract_Topological_Spaces + Abstract_Metric_Spaces Connected Abstract_Limits Isolated diff -r 070703d83cfe -r cec875dcc59e src/HOL/Analysis/Measure_Space.thy --- a/src/HOL/Analysis/Measure_Space.thy Mon May 22 12:01:05 2023 +0200 +++ b/src/HOL/Analysis/Measure_Space.thy Tue May 23 12:31:23 2023 +0100 @@ -2288,12 +2288,8 @@ subsection\<^marker>\tag unimportant\ \Counting space\ lemma strict_monoI_Suc: - assumes ord [simp]: "(\n. f n < f (Suc n))" shows "strict_mono f" - unfolding strict_mono_def -proof safe - fix n m :: nat assume "n < m" then show "f n < f m" - by (induct m) (auto simp: less_Suc_eq intro: less_trans ord) -qed + assumes "(\n. f n < f (Suc n))" shows "strict_mono f" + by (simp add: assms strict_mono_Suc_iff) lemma emeasure_count_space: assumes "X \ A" shows "emeasure (count_space A) X = (if finite X then of_nat (card X) else \)" diff -r 070703d83cfe -r cec875dcc59e src/HOL/Analysis/Product_Topology.thy --- a/src/HOL/Analysis/Product_Topology.thy Mon May 22 12:01:05 2023 +0200 +++ b/src/HOL/Analysis/Product_Topology.thy Tue May 23 12:31:23 2023 +0100 @@ -139,6 +139,47 @@ qed qed +text \Missing the opposite direction. Does it hold? A converse is proved for proper maps, a stronger condition\ +lemma closed_map_prod: + assumes "closed_map (prod_topology X Y) (prod_topology X' Y') (\(x,y). (f x, g y))" + shows "topspace(prod_topology X Y) = {} \ closed_map X X' f \ closed_map Y Y' g" +proof (cases "topspace(prod_topology X Y) = {}") + case False + then have ne: "topspace X \ {}" "topspace Y \ {}" + by auto + have "closed_map X X' f" + unfolding closed_map_def + proof (intro strip) + fix C + assume "closedin X C" + show "closedin X' (f ` C)" + proof (cases "C={}") + case False + with assms have "closedin (prod_topology X' Y') ((\(x,y). (f x, g y)) ` (C \ topspace Y))" + by (simp add: \closedin X C\ closed_map_def closedin_prod_Times_iff) + with False ne show ?thesis + by (simp add: image_paired_Times closedin_Times closedin_prod_Times_iff) + qed auto + qed + moreover + have "closed_map Y Y' g" + unfolding closed_map_def + proof (intro strip) + fix C + assume "closedin Y C" + show "closedin Y' (g ` C)" + proof (cases "C={}") + case False + with assms have "closedin (prod_topology X' Y') ((\(x,y). (f x, g y)) ` (topspace X \ C))" + by (simp add: \closedin Y C\ closed_map_def closedin_prod_Times_iff) + with False ne show ?thesis + by (simp add: image_paired_Times closedin_Times closedin_prod_Times_iff) + qed auto + qed + ultimately show ?thesis + by (auto simp: False) +qed auto + subsection \Continuity\ lemma continuous_map_pairwise: diff -r 070703d83cfe -r cec875dcc59e src/HOL/Analysis/T1_Spaces.thy --- a/src/HOL/Analysis/T1_Spaces.thy Mon May 22 12:01:05 2023 +0200 +++ b/src/HOL/Analysis/T1_Spaces.thy Tue May 23 12:31:23 2023 +0100 @@ -49,6 +49,12 @@ apply (simp add: closedin_contains_derived_set t1_space_derived_set_of_singleton) using t1_space_alt by auto +lemma continuous_closed_imp_proper_map: + "\compact_space X; t1_space Y; continuous_map X Y f; closed_map X Y f\ \ proper_map X Y f" + unfolding proper_map_def + by (smt (verit) closedin_compact_space closedin_continuous_map_preimage + Collect_cong singleton_iff t1_space_closedin_singleton) + lemma t1_space_euclidean: "t1_space (euclidean :: 'a::metric_space topology)" by (simp add: t1_space_closedin_singleton) diff -r 070703d83cfe -r cec875dcc59e src/HOL/Nat.thy --- a/src/HOL/Nat.thy Mon May 22 12:01:05 2023 +0200 +++ b/src/HOL/Nat.thy Tue May 23 12:31:23 2023 +0100 @@ -2029,6 +2029,17 @@ lemma antimono_iff_le_Suc: "antimono f \ (\n. f (Suc n) \ f n)" unfolding antimono_def by (auto intro: lift_Suc_antimono_le [of f]) +lemma strict_mono_Suc_iff: "strict_mono f \ (\n. f n < f (Suc n))" +proof (intro iffI strict_monoI) + assume *: "\n. f n < f (Suc n)" + fix m n :: nat assume "m < n" + thus "f m < f n" + by (induction rule: less_Suc_induct) (use * in auto) +qed (auto simp: strict_mono_def) + +lemma strict_mono_add: "strict_mono (\n::'a::linordered_semidom. n + k)" + by (auto simp: strict_mono_def) + lemma mono_nat_linear_lb: fixes f :: "nat \ nat" assumes "\m n. m < n \ f m < f n" diff -r 070703d83cfe -r cec875dcc59e src/HOL/Topological_Spaces.thy --- a/src/HOL/Topological_Spaces.thy Mon May 22 12:01:05 2023 +0200 +++ b/src/HOL/Topological_Spaces.thy Tue May 23 12:31:23 2023 +0100 @@ -1319,17 +1319,6 @@ subsubsection \Subsequence (alternative definition, (e.g. Hoskins)\ -lemma strict_mono_Suc_iff: "strict_mono f \ (\n. f n < f (Suc n))" -proof (intro iffI strict_monoI) - assume *: "\n. f n < f (Suc n)" - fix m n :: nat assume "m < n" - thus "f m < f n" - by (induction rule: less_Suc_induct) (use * in auto) -qed (auto simp: strict_mono_def) - -lemma strict_mono_add: "strict_mono (\n::'a::linordered_semidom. n + k)" - by (auto simp: strict_mono_def) - text \For any sequence, there is a monotonic subsequence.\ lemma seq_monosub: fixes s :: "nat \ 'a::linorder"