# HG changeset patch # User immler # Date 1546860668 -3600 # Node ID e502cd4d706242adb39d30330ae5518099aa73f2 # Parent d469a1340e21ad2d5b82b41b681902bb9e51c06e moved material from Connected.thy to more appropriate places diff -r d469a1340e21 -r e502cd4d7062 src/HOL/Analysis/Connected.thy --- a/src/HOL/Analysis/Connected.thy Mon Jan 07 11:51:18 2019 +0100 +++ b/src/HOL/Analysis/Connected.thy Mon Jan 07 12:31:08 2019 +0100 @@ -494,118 +494,8 @@ using closedin_connected_component componentsE by blast -subsection%unimportant\Quotient maps\ - -lemma quotient_map_imp_continuous_open: - assumes T: "f ` S \ T" - and ope: "\U. U \ T - \ (openin (subtopology euclidean S) (S \ f -` U) \ - openin (subtopology euclidean T) U)" - shows "continuous_on S f" -proof - - have [simp]: "S \ f -` f ` S = S" by auto - show ?thesis - using ope [OF T] - apply (simp add: continuous_on_open) - by (meson ope openin_imp_subset openin_trans) -qed - -lemma quotient_map_imp_continuous_closed: - assumes T: "f ` S \ T" - and ope: "\U. U \ T - \ (closedin (subtopology euclidean S) (S \ f -` U) \ - closedin (subtopology euclidean T) U)" - shows "continuous_on S f" -proof - - have [simp]: "S \ f -` f ` S = S" by auto - show ?thesis - using ope [OF T] - apply (simp add: continuous_on_closed) - by (metis (no_types, lifting) ope closedin_imp_subset closedin_trans) -qed - -lemma open_map_imp_quotient_map: - assumes contf: "continuous_on S f" - and T: "T \ f ` S" - and ope: "\T. openin (subtopology euclidean S) T - \ openin (subtopology euclidean (f ` S)) (f ` T)" - shows "openin (subtopology euclidean S) (S \ f -` T) = - openin (subtopology euclidean (f ` S)) T" -proof - - have "T = f ` (S \ f -` T)" - using T by blast - then show ?thesis - using "ope" contf continuous_on_open by metis -qed - -lemma closed_map_imp_quotient_map: - assumes contf: "continuous_on S f" - and T: "T \ f ` S" - and ope: "\T. closedin (subtopology euclidean S) T - \ closedin (subtopology euclidean (f ` S)) (f ` T)" - shows "openin (subtopology euclidean S) (S \ f -` T) \ - openin (subtopology euclidean (f ` S)) T" - (is "?lhs = ?rhs") -proof - assume ?lhs - then have *: "closedin (subtopology euclidean S) (S - (S \ f -` T))" - using closedin_diff by fastforce - have [simp]: "(f ` S - f ` (S - (S \ f -` T))) = T" - using T by blast - show ?rhs - using ope [OF *, unfolded closedin_def] by auto -next - assume ?rhs - with contf show ?lhs - by (auto simp: continuous_on_open) -qed - -lemma continuous_right_inverse_imp_quotient_map: - assumes contf: "continuous_on S f" and imf: "f ` S \ T" - and contg: "continuous_on T g" and img: "g ` T \ S" - and fg [simp]: "\y. y \ T \ f(g y) = y" - and U: "U \ T" - shows "openin (subtopology euclidean S) (S \ f -` U) \ - openin (subtopology euclidean T) U" - (is "?lhs = ?rhs") -proof - - have f: "\Z. openin (subtopology euclidean (f ` S)) Z \ - openin (subtopology euclidean S) (S \ f -` Z)" - and g: "\Z. openin (subtopology euclidean (g ` T)) Z \ - openin (subtopology euclidean T) (T \ g -` Z)" - using contf contg by (auto simp: continuous_on_open) - show ?thesis - proof - have "T \ g -` (g ` T \ (S \ f -` U)) = {x \ T. f (g x) \ U}" - using imf img by blast - also have "... = U" - using U by auto - finally have eq: "T \ g -` (g ` T \ (S \ f -` U)) = U" . - assume ?lhs - then have *: "openin (subtopology euclidean (g ` T)) (g ` T \ (S \ f -` U))" - by (meson img openin_Int openin_subtopology_Int_subset openin_subtopology_self) - show ?rhs - using g [OF *] eq by auto - next - assume rhs: ?rhs - show ?lhs - by (metis f fg image_eqI image_subset_iff imf img openin_subopen openin_subtopology_self openin_trans rhs) - qed -qed - -lemma continuous_left_inverse_imp_quotient_map: - assumes "continuous_on S f" - and "continuous_on (f ` S) g" - and "\x. x \ S \ g(f x) = x" - and "U \ f ` S" - shows "openin (subtopology euclidean S) (S \ f -` U) \ - openin (subtopology euclidean (f ` S)) U" -apply (rule continuous_right_inverse_imp_quotient_map) -using assms apply force+ -done - - -subsection%unimportant \Proving a function is constant by proving that a level set is open\ +subsection%unimportant \Proving a function is constant on a connected set + by proving that a level set is open\ lemma continuous_levelset_openin_cases: fixes f :: "_ \ 'b::t1_space" @@ -635,273 +525,13 @@ by fast -subsection%unimportant \Connectedness is invariant under homeomorphisms.\ +subsection%unimportant \Preservation of Connectedness\ lemma homeomorphic_connectedness: assumes "s homeomorphic t" shows "connected s \ connected t" using assms unfolding homeomorphic_def homeomorphism_def by (metis connected_continuous_image) - -subsection\Various separability-type properties\ - -lemma univ_second_countable: - obtains \ :: "'a::second_countable_topology set set" - where "countable \" "\C. C \ \ \ open C" - "\S. open S \ \U. U \ \ \ S = \U" -by (metis ex_countable_basis topological_basis_def) - -lemma subset_second_countable: - obtains \ :: "'a:: second_countable_topology set set" - where "countable \" - "{} \ \" - "\C. C \ \ \ openin(subtopology euclidean S) C" - "\T. openin(subtopology euclidean S) T \ \\. \ \ \ \ T = \\" -proof - - obtain \ :: "'a set set" - where "countable \" - and opeB: "\C. C \ \ \ openin(subtopology euclidean S) C" - and \: "\T. openin(subtopology euclidean S) T \ \\. \ \ \ \ T = \\" - proof - - obtain \ :: "'a set set" - where "countable \" and ope: "\C. C \ \ \ open C" - and \: "\S. open S \ \U. U \ \ \ S = \U" - by (metis univ_second_countable that) - show ?thesis - proof - show "countable ((\C. S \ C) ` \)" - by (simp add: \countable \\) - show "\C. C \ (\) S ` \ \ openin (subtopology euclidean S) C" - using ope by auto - show "\T. openin (subtopology euclidean S) T \ \\\(\) S ` \. T = \\" - by (metis \ image_mono inf_Sup openin_open) - qed - qed - show ?thesis - proof - show "countable (\ - {{}})" - using \countable \\ by blast - show "\C. \C \ \ - {{}}\ \ openin (subtopology euclidean S) C" - by (simp add: \\C. C \ \ \ openin (subtopology euclidean S) C\) - show "\\\\ - {{}}. T = \\" if "openin (subtopology euclidean S) T" for T - using \ [OF that] - apply clarify - apply (rule_tac x="\ - {{}}" in exI, auto) - done - qed auto -qed - -lemma univ_second_countable_sequence: - obtains B :: "nat \ 'a::euclidean_space set" - where "inj B" "\n. open(B n)" "\S. open S \ \k. S = \{B n |n. n \ k}" -proof - - obtain \ :: "'a set set" - where "countable \" - and opn: "\C. C \ \ \ open C" - and Un: "\S. open S \ \U. U \ \ \ S = \U" - using univ_second_countable by blast - have *: "infinite (range (\n. ball (0::'a) (inverse(Suc n))))" - apply (rule Infinite_Set.range_inj_infinite) - apply (simp add: inj_on_def ball_eq_ball_iff) - done - have "infinite \" - proof - assume "finite \" - then have "finite (Union ` (Pow \))" - by simp - then have "finite (range (\n. ball (0::'a) (inverse(Suc n))))" - apply (rule rev_finite_subset) - by (metis (no_types, lifting) PowI image_eqI image_subset_iff Un [OF open_ball]) - with * show False by simp - qed - obtain f :: "nat \ 'a set" where "\ = range f" "inj f" - by (blast intro: countable_as_injective_image [OF \countable \\ \infinite \\]) - have *: "\k. S = \{f n |n. n \ k}" if "open S" for S - using Un [OF that] - apply clarify - apply (rule_tac x="f-`U" in exI) - using \inj f\ \\ = range f\ apply force - done - show ?thesis - apply (rule that [OF \inj f\ _ *]) - apply (auto simp: \\ = range f\ opn) - done -qed - -proposition separable: - fixes S :: "'a::{metric_space, second_countable_topology} set" - obtains T where "countable T" "T \ S" "S \ closure T" -proof - - obtain \ :: "'a set set" - where "countable \" - and "{} \ \" - and ope: "\C. C \ \ \ openin(subtopology euclidean S) C" - and if_ope: "\T. openin(subtopology euclidean S) T \ \\. \ \ \ \ T = \\" - by (meson subset_second_countable) - then obtain f where f: "\C. C \ \ \ f C \ C" - by (metis equals0I) - show ?thesis - proof - show "countable (f ` \)" - by (simp add: \countable \\) - show "f ` \ \ S" - using ope f openin_imp_subset by blast - show "S \ closure (f ` \)" - proof (clarsimp simp: closure_approachable) - fix x and e::real - assume "x \ S" "0 < e" - have "openin (subtopology euclidean S) (S \ ball x e)" - by (simp add: openin_Int_open) - with if_ope obtain \ where \: "\ \ \" "S \ ball x e = \\" - by meson - show "\C \ \. dist (f C) x < e" - proof (cases "\ = {}") - case True - then show ?thesis - using \0 < e\ \ \x \ S\ by auto - next - case False - then obtain C where "C \ \" by blast - show ?thesis - proof - show "dist (f C) x < e" - by (metis Int_iff Union_iff \ \C \ \\ dist_commute f mem_ball subsetCE) - show "C \ \" - using \\ \ \\ \C \ \\ by blast - qed - qed - qed - qed -qed - -proposition Lindelof: - fixes \ :: "'a::second_countable_topology set set" - assumes \: "\S. S \ \ \ open S" - obtains \' where "\' \ \" "countable \'" "\\' = \\" -proof - - obtain \ :: "'a set set" - where "countable \" "\C. C \ \ \ open C" - and \: "\S. open S \ \U. U \ \ \ S = \U" - using univ_second_countable by blast - define \ where "\ \ {S. S \ \ \ (\U. U \ \ \ S \ U)}" - have "countable \" - apply (rule countable_subset [OF _ \countable \\]) - apply (force simp: \_def) - done - have "\S. \U. S \ \ \ U \ \ \ S \ U" - by (simp add: \_def) - then obtain G where G: "\S. S \ \ \ G S \ \ \ S \ G S" - by metis - have "\\ \ \\" - unfolding \_def by (blast dest: \ \) - moreover have "\\ \ \\" - using \_def by blast - ultimately have eq1: "\\ = \\" .. - have eq2: "\\ = \ (G ` \)" - using G eq1 by auto - show ?thesis - apply (rule_tac \' = "G ` \" in that) - using G \countable \\ apply (auto simp: eq1 eq2) - done -qed - -lemma Lindelof_openin: - fixes \ :: "'a::second_countable_topology set set" - assumes "\S. S \ \ \ openin (subtopology euclidean U) S" - obtains \' where "\' \ \" "countable \'" "\\' = \\" -proof - - have "\S. S \ \ \ \T. open T \ S = U \ T" - using assms by (simp add: openin_open) - then obtain tf where tf: "\S. S \ \ \ open (tf S) \ (S = U \ tf S)" - by metis - have [simp]: "\\'. \' \ \ \ \\' = U \ \(tf ` \')" - using tf by fastforce - obtain \ where "countable \ \ \ \ tf ` \" "\\ = \(tf ` \)" - using tf by (force intro: Lindelof [of "tf ` \"]) - then obtain \' where \': "\' \ \" "countable \'" "\\' = \\" - by (clarsimp simp add: countable_subset_image) - then show ?thesis .. -qed - -lemma countable_disjoint_open_subsets: - fixes \ :: "'a::second_countable_topology set set" - assumes "\S. S \ \ \ open S" and pw: "pairwise disjnt \" - shows "countable \" -proof - - obtain \' where "\' \ \" "countable \'" "\\' = \\" - by (meson assms Lindelof) - with pw have "\ \ insert {} \'" - by (fastforce simp add: pairwise_def disjnt_iff) - then show ?thesis - by (simp add: \countable \'\ countable_subset) -qed - -lemma countable_disjoint_nonempty_interior_subsets: - fixes \ :: "'a::second_countable_topology set set" - assumes pw: "pairwise disjnt \" and int: "\S. \S \ \; interior S = {}\ \ S = {}" - shows "countable \" -proof (rule countable_image_inj_on) - have "disjoint (interior ` \)" - using pw by (simp add: disjoint_image_subset interior_subset) - then show "countable (interior ` \)" - by (auto intro: countable_disjoint_open_subsets) - show "inj_on interior \" - using pw apply (clarsimp simp: inj_on_def pairwise_def) - apply (metis disjnt_def disjnt_subset1 inf.orderE int interior_subset) - done -qed - -lemma closedin_compact: - "\compact S; closedin (subtopology euclidean S) T\ \ compact T" -by (metis closedin_closed compact_Int_closed) - -lemma closedin_compact_eq: - fixes S :: "'a::t2_space set" - shows - "compact S - \ (closedin (subtopology euclidean S) T \ - compact T \ T \ S)" -by (metis closedin_imp_subset closedin_compact closed_subset compact_imp_closed) - -lemma continuous_imp_closed_map: - fixes f :: "'a::metric_space \ 'b::metric_space" - assumes "closedin (subtopology euclidean S) U" - "continuous_on S f" "f ` S = T" "compact S" - shows "closedin (subtopology euclidean T) (f ` U)" - by (metis assms closedin_compact_eq compact_continuous_image continuous_on_subset subset_image_iff) - -lemma continuous_imp_quotient_map: - fixes f :: "'a::metric_space \ 'b::metric_space" - assumes "continuous_on S f" "f ` S = T" "compact S" "U \ T" - shows "openin (subtopology euclidean S) (S \ f -` U) \ - openin (subtopology euclidean T) U" - by (metis (no_types, lifting) assms closed_map_imp_quotient_map continuous_imp_closed_map) - - -lemma open_map_restrict: - assumes opeU: "openin (subtopology euclidean (S \ f -` T')) U" - and oo: "\U. openin (subtopology euclidean S) U \ openin (subtopology euclidean T) (f ` U)" - and "T' \ T" - shows "openin (subtopology euclidean T') (f ` U)" -proof - - obtain V where "open V" "U = S \ f -` T' \ V" - using opeU by (auto simp: openin_open) - with oo [of "S \ V"] \T' \ T\ show ?thesis - by (fastforce simp add: openin_open) -qed - -lemma closed_map_restrict: - assumes cloU: "closedin (subtopology euclidean (S \ f -` T')) U" - and cc: "\U. closedin (subtopology euclidean S) U \ closedin (subtopology euclidean T) (f ` U)" - and "T' \ T" - shows "closedin (subtopology euclidean T') (f ` U)" -proof - - obtain V where "closed V" "U = S \ f -` T' \ V" - using cloU by (auto simp: closedin_closed) - with cc [of "S \ V"] \T' \ T\ show ?thesis - by (fastforce simp add: closedin_closed) -qed - lemma connected_monotone_quotient_preimage: assumes "connected T" and contf: "continuous_on S f" and fim: "f ` S = T" @@ -1124,348 +754,6 @@ by auto qed -subsection%unimportant\ Finite intersection property\ - -text\Also developed in HOL's toplogical spaces theory, but the Heine-Borel type class isn't available there.\ - -lemma closed_imp_fip: - fixes S :: "'a::heine_borel set" - assumes "closed S" - and T: "T \ \" "bounded T" - and clof: "\T. T \ \ \ closed T" - and none: "\\'. \finite \'; \' \ \\ \ S \ \\' \ {}" - shows "S \ \\ \ {}" -proof - - have "compact (S \ T)" - using \closed S\ clof compact_eq_bounded_closed T by blast - then have "(S \ T) \ \\ \ {}" - apply (rule compact_imp_fip) - apply (simp add: clof) - by (metis Int_assoc complete_lattice_class.Inf_insert finite_insert insert_subset none \T \ \\) - then show ?thesis by blast -qed - -lemma closed_imp_fip_compact: - fixes S :: "'a::heine_borel set" - shows - "\closed S; \T. T \ \ \ compact T; - \\'. \finite \'; \' \ \\ \ S \ \\' \ {}\ - \ S \ \\ \ {}" -by (metis Inf_greatest closed_imp_fip compact_eq_bounded_closed empty_subsetI finite.emptyI inf.orderE) - -lemma closed_fip_Heine_Borel: - fixes \ :: "'a::heine_borel set set" - assumes "closed S" "T \ \" "bounded T" - and "\T. T \ \ \ closed T" - and "\\'. \finite \'; \' \ \\ \ \\' \ {}" - shows "\\ \ {}" -proof - - have "UNIV \ \\ \ {}" - using assms closed_imp_fip [OF closed_UNIV] by auto - then show ?thesis by simp -qed - -lemma compact_fip_Heine_Borel: - fixes \ :: "'a::heine_borel set set" - assumes clof: "\T. T \ \ \ compact T" - and none: "\\'. \finite \'; \' \ \\ \ \\' \ {}" - shows "\\ \ {}" -by (metis InterI all_not_in_conv clof closed_fip_Heine_Borel compact_eq_bounded_closed none) - -lemma compact_sequence_with_limit: - fixes f :: "nat \ 'a::heine_borel" - shows "(f \ l) sequentially \ compact (insert l (range f))" -apply (simp add: compact_eq_bounded_closed, auto) -apply (simp add: convergent_imp_bounded) -by (simp add: closed_limpt islimpt_insert sequence_unique_limpt) - - -subsection%unimportant\Componentwise limits and continuity\ - -text\But is the premise really necessary? Need to generalise @{thm euclidean_dist_l2}\ -lemma Euclidean_dist_upper: "i \ Basis \ dist (x \ i) (y \ i) \ dist x y" - by (metis (no_types) member_le_L2_set euclidean_dist_l2 finite_Basis) - -text\But is the premise \<^term>\i \ Basis\ really necessary?\ -lemma open_preimage_inner: - assumes "open S" "i \ Basis" - shows "open {x. x \ i \ S}" -proof (rule openI, simp) - fix x - assume x: "x \ i \ S" - with assms obtain e where "0 < e" and e: "ball (x \ i) e \ S" - by (auto simp: open_contains_ball_eq) - have "\e>0. ball (y \ i) e \ S" if dxy: "dist x y < e / 2" for y - proof (intro exI conjI) - have "dist (x \ i) (y \ i) < e / 2" - by (meson \i \ Basis\ dual_order.trans Euclidean_dist_upper not_le that) - then have "dist (x \ i) z < e" if "dist (y \ i) z < e / 2" for z - by (metis dist_commute dist_triangle_half_l that) - then have "ball (y \ i) (e / 2) \ ball (x \ i) e" - using mem_ball by blast - with e show "ball (y \ i) (e / 2) \ S" - by (metis order_trans) - qed (simp add: \0 < e\) - then show "\e>0. ball x e \ {s. s \ i \ S}" - by (metis (no_types, lifting) \0 < e\ \open S\ half_gt_zero_iff mem_Collect_eq mem_ball open_contains_ball_eq subsetI) -qed - -proposition tendsto_componentwise_iff: - fixes f :: "_ \ 'b::euclidean_space" - shows "(f \ l) F \ (\i \ Basis. ((\x. (f x \ i)) \ (l \ i)) F)" - (is "?lhs = ?rhs") -proof - assume ?lhs - then show ?rhs - unfolding tendsto_def - apply clarify - apply (drule_tac x="{s. s \ i \ S}" in spec) - apply (auto simp: open_preimage_inner) - done -next - assume R: ?rhs - then have "\e. e > 0 \ \i\Basis. \\<^sub>F x in F. dist (f x \ i) (l \ i) < e" - unfolding tendsto_iff by blast - then have R': "\e. e > 0 \ \\<^sub>F x in F. \i\Basis. dist (f x \ i) (l \ i) < e" - by (simp add: eventually_ball_finite_distrib [symmetric]) - show ?lhs - unfolding tendsto_iff - proof clarify - fix e::real - assume "0 < e" - have *: "L2_set (\i. dist (f x \ i) (l \ i)) Basis < e" - if "\i\Basis. dist (f x \ i) (l \ i) < e / real DIM('b)" for x - proof - - have "L2_set (\i. dist (f x \ i) (l \ i)) Basis \ sum (\i. dist (f x \ i) (l \ i)) Basis" - by (simp add: L2_set_le_sum) - also have "... < DIM('b) * (e / real DIM('b))" - apply (rule sum_bounded_above_strict) - using that by auto - also have "... = e" - by (simp add: field_simps) - finally show "L2_set (\i. dist (f x \ i) (l \ i)) Basis < e" . - qed - have "\\<^sub>F x in F. \i\Basis. dist (f x \ i) (l \ i) < e / DIM('b)" - apply (rule R') - using \0 < e\ by simp - then show "\\<^sub>F x in F. dist (f x) l < e" - apply (rule eventually_mono) - apply (subst euclidean_dist_l2) - using * by blast - qed -qed - - -corollary continuous_componentwise: - "continuous F f \ (\i \ Basis. continuous F (\x. (f x \ i)))" -by (simp add: continuous_def tendsto_componentwise_iff [symmetric]) - -corollary continuous_on_componentwise: - fixes S :: "'a :: t2_space set" - shows "continuous_on S f \ (\i \ Basis. continuous_on S (\x. (f x \ i)))" - apply (simp add: continuous_on_eq_continuous_within) - using continuous_componentwise by blast - -lemma linear_componentwise_iff: - "(linear f') \ (\i\Basis. linear (\x. f' x \ i))" - apply (auto simp: linear_iff inner_left_distrib) - apply (metis inner_left_distrib euclidean_eq_iff) - by (metis euclidean_eqI inner_scaleR_left) - -lemma bounded_linear_componentwise_iff: - "(bounded_linear f') \ (\i\Basis. bounded_linear (\x. f' x \ i))" - (is "?lhs = ?rhs") -proof - assume ?lhs then show ?rhs - by (simp add: bounded_linear_inner_left_comp) -next - assume ?rhs - then have "(\i\Basis. \K. \x. \f' x \ i\ \ norm x * K)" "linear f'" - by (auto simp: bounded_linear_def bounded_linear_axioms_def linear_componentwise_iff [symmetric] ball_conj_distrib) - then obtain F where F: "\i x. i \ Basis \ \f' x \ i\ \ norm x * F i" - by metis - have "norm (f' x) \ norm x * sum F Basis" for x - proof - - have "norm (f' x) \ (\i\Basis. \f' x \ i\)" - by (rule norm_le_l1) - also have "... \ (\i\Basis. norm x * F i)" - by (metis F sum_mono) - also have "... = norm x * sum F Basis" - by (simp add: sum_distrib_left) - finally show ?thesis . - qed - then show ?lhs - by (force simp: bounded_linear_def bounded_linear_axioms_def \linear f'\) -qed - -subsection%unimportant\Pasting functions together\ - -subsubsection%unimportant\on open sets\ - -lemma pasting_lemma: - fixes f :: "'i \ 'a::topological_space \ 'b::topological_space" - assumes clo: "\i. i \ I \ openin (subtopology euclidean S) (T i)" - and cont: "\i. i \ I \ continuous_on (T i) (f i)" - and f: "\i j x. \i \ I; j \ I; x \ S \ T i \ T j\ \ f i x = f j x" - and g: "\x. x \ S \ \j. j \ I \ x \ T j \ g x = f j x" - shows "continuous_on S g" -proof (clarsimp simp: continuous_openin_preimage_eq) - fix U :: "'b set" - assume "open U" - have S: "\i. i \ I \ (T i) \ S" - using clo openin_imp_subset by blast - have *: "(S \ g -` U) = (\i \ I. T i \ f i -` U)" - using S f g by fastforce - show "openin (subtopology euclidean S) (S \ g -` U)" - apply (subst *) - apply (rule openin_Union, clarify) - using \open U\ clo cont continuous_openin_preimage_gen openin_trans by blast -qed - -lemma pasting_lemma_exists: - fixes f :: "'i \ 'a::topological_space \ 'b::topological_space" - assumes S: "S \ (\i \ I. T i)" - and clo: "\i. i \ I \ openin (subtopology euclidean S) (T i)" - and cont: "\i. i \ I \ continuous_on (T i) (f i)" - and f: "\i j x. \i \ I; j \ I; x \ S \ T i \ T j\ \ f i x = f j x" - obtains g where "continuous_on S g" "\x i. \i \ I; x \ S \ T i\ \ g x = f i x" -proof - show "continuous_on S (\x. f (SOME i. i \ I \ x \ T i) x)" - apply (rule pasting_lemma [OF clo cont]) - apply (blast intro: f)+ - apply (metis (mono_tags, lifting) S UN_iff subsetCE someI) - done -next - fix x i - assume "i \ I" "x \ S \ T i" - then show "f (SOME i. i \ I \ x \ T i) x = f i x" - by (metis (no_types, lifting) IntD2 IntI f someI_ex) -qed - -subsubsection%unimportant\Likewise on closed sets, with a finiteness assumption\ - -lemma pasting_lemma_closed: - fixes f :: "'i \ 'a::topological_space \ 'b::topological_space" - assumes "finite I" - and clo: "\i. i \ I \ closedin (subtopology euclidean S) (T i)" - and cont: "\i. i \ I \ continuous_on (T i) (f i)" - and f: "\i j x. \i \ I; j \ I; x \ S \ T i \ T j\ \ f i x = f j x" - and g: "\x. x \ S \ \j. j \ I \ x \ T j \ g x = f j x" - shows "continuous_on S g" -proof (clarsimp simp: continuous_closedin_preimage_eq) - fix U :: "'b set" - assume "closed U" - have S: "\i. i \ I \ (T i) \ S" - using clo closedin_imp_subset by blast - have *: "(S \ g -` U) = (\i \ I. T i \ f i -` U)" - using S f g by fastforce - show "closedin (subtopology euclidean S) (S \ g -` U)" - apply (subst *) - apply (rule closedin_Union) - using \finite I\ apply simp - apply (blast intro: \closed U\ continuous_closedin_preimage cont clo closedin_trans) - done -qed - -lemma pasting_lemma_exists_closed: - fixes f :: "'i \ 'a::topological_space \ 'b::topological_space" - assumes "finite I" - and S: "S \ (\i \ I. T i)" - and clo: "\i. i \ I \ closedin (subtopology euclidean S) (T i)" - and cont: "\i. i \ I \ continuous_on (T i) (f i)" - and f: "\i j x. \i \ I; j \ I; x \ S \ T i \ T j\ \ f i x = f j x" - obtains g where "continuous_on S g" "\x i. \i \ I; x \ S \ T i\ \ g x = f i x" -proof - show "continuous_on S (\x. f (SOME i. i \ I \ x \ T i) x)" - apply (rule pasting_lemma_closed [OF \finite I\ clo cont]) - apply (blast intro: f)+ - apply (metis (mono_tags, lifting) S UN_iff subsetCE someI) - done -next - fix x i - assume "i \ I" "x \ S \ T i" - then show "f (SOME i. i \ I \ x \ T i) x = f i x" - by (metis (no_types, lifting) IntD2 IntI f someI_ex) -qed - -lemma tube_lemma: - assumes "compact K" - assumes "open W" - assumes "{x0} \ K \ W" - shows "\X0. x0 \ X0 \ open X0 \ X0 \ K \ W" -proof - - { - fix y assume "y \ K" - then have "(x0, y) \ W" using assms by auto - with \open W\ - have "\X0 Y. open X0 \ open Y \ x0 \ X0 \ y \ Y \ X0 \ Y \ W" - by (rule open_prod_elim) blast - } - then obtain X0 Y where - *: "\y \ K. open (X0 y) \ open (Y y) \ x0 \ X0 y \ y \ Y y \ X0 y \ Y y \ W" - by metis - from * have "\t\Y ` K. open t" "K \ \(Y ` K)" by auto - with \compact K\ obtain CC where CC: "CC \ Y ` K" "finite CC" "K \ \CC" - by (meson compactE) - then obtain c where c: "\C. C \ CC \ c C \ K \ C = Y (c C)" - by (force intro!: choice) - with * CC show ?thesis - by (force intro!: exI[where x="\C\CC. X0 (c C)"]) (* SLOW *) -qed - -lemma continuous_on_prod_compactE: - fixes fx::"'a::topological_space \ 'b::topological_space \ 'c::metric_space" - and e::real - assumes cont_fx: "continuous_on (U \ C) fx" - assumes "compact C" - assumes [intro]: "x0 \ U" - notes [continuous_intros] = continuous_on_compose2[OF cont_fx] - assumes "e > 0" - obtains X0 where "x0 \ X0" "open X0" - "\x\X0 \ U. \t \ C. dist (fx (x, t)) (fx (x0, t)) \ e" -proof - - define psi where "psi = (\(x, t). dist (fx (x, t)) (fx (x0, t)))" - define W0 where "W0 = {(x, t) \ U \ C. psi (x, t) < e}" - have W0_eq: "W0 = psi -` {.. U \ C" - by (auto simp: vimage_def W0_def) - have "open {.. C) psi" - by (auto intro!: continuous_intros simp: psi_def split_beta') - from this[unfolded continuous_on_open_invariant, rule_format, OF \open {..] - obtain W where W: "open W" "W \ U \ C = W0 \ U \ C" - unfolding W0_eq by blast - have "{x0} \ C \ W \ U \ C" - unfolding W - by (auto simp: W0_def psi_def \0 < e\) - then have "{x0} \ C \ W" by blast - from tube_lemma[OF \compact C\ \open W\ this] - obtain X0 where X0: "x0 \ X0" "open X0" "X0 \ C \ W" - by blast - - have "\x\X0 \ U. \t \ C. dist (fx (x, t)) (fx (x0, t)) \ e" - proof safe - fix x assume x: "x \ X0" "x \ U" - fix t assume t: "t \ C" - have "dist (fx (x, t)) (fx (x0, t)) = psi (x, t)" - by (auto simp: psi_def) - also - { - have "(x, t) \ X0 \ C" - using t x - by auto - also note \\ \ W\ - finally have "(x, t) \ W" . - with t x have "(x, t) \ W \ U \ C" - by blast - also note \W \ U \ C = W0 \ U \ C\ - finally have "psi (x, t) < e" - by (auto simp: W0_def) - } - finally show "dist (fx (x, t)) (fx (x0, t)) \ e" by simp - qed - from X0(1,2) this show ?thesis .. -qed - subsection%unimportant\Constancy of a function from a connected set into a finite, disconnected or discrete set\ @@ -1523,33 +811,6 @@ by blast qed -lemma finite_implies_discrete: - fixes S :: "'a::topological_space set" - assumes "finite (f ` S)" - shows "(\x \ S. \e>0. \y. y \ S \ f y \ f x \ e \ norm (f y - f x))" -proof - - have "\e>0. \y. y \ S \ f y \ f x \ e \ norm (f y - f x)" if "x \ S" for x - proof (cases "f ` S - {f x} = {}") - case True - with zero_less_numeral show ?thesis - by (fastforce simp add: Set.image_subset_iff cong: conj_cong) - next - case False - then obtain z where z: "z \ S" "f z \ f x" - by blast - have finn: "finite {norm (z - f x) |z. z \ f ` S - {f x}}" - using assms by simp - then have *: "0 < Inf{norm(z - f x) | z. z \ f ` S - {f x}}" - apply (rule finite_imp_less_Inf) - using z apply force+ - done - show ?thesis - by (force intro!: * cInf_le_finite [OF finn]) - qed - with assms show ?thesis - by blast -qed - text\This proof requires the existence of two separate values of the range type.\ lemma finite_range_constant_imp_connected: assumes "\f::'a::topological_space \ 'b::real_normed_algebra_1. @@ -1624,108 +885,4 @@ shows "f constant_on S" using assms continuous_finite_range_constant_eq by blast - - -subsection%unimportant \Continuous Extension\ - -definition clamp :: "'a::euclidean_space \ 'a \ 'a \ 'a" where - "clamp a b x = (if (\i\Basis. a \ i \ b \ i) - then (\i\Basis. (if x\i < a\i then a\i else if x\i \ b\i then x\i else b\i) *\<^sub>R i) - else a)" - -lemma clamp_in_interval[simp]: - assumes "\i. i \ Basis \ a \ i \ b \ i" - shows "clamp a b x \ cbox a b" - unfolding clamp_def - using box_ne_empty(1)[of a b] assms by (auto simp: cbox_def) - -lemma clamp_cancel_cbox[simp]: - fixes x a b :: "'a::euclidean_space" - assumes x: "x \ cbox a b" - shows "clamp a b x = x" - using assms - by (auto simp: clamp_def mem_box intro!: euclidean_eqI[where 'a='a]) - -lemma clamp_empty_interval: - assumes "i \ Basis" "a \ i > b \ i" - shows "clamp a b = (\_. a)" - using assms - by (force simp: clamp_def[abs_def] split: if_splits intro!: ext) - -lemma dist_clamps_le_dist_args: - fixes x :: "'a::euclidean_space" - shows "dist (clamp a b y) (clamp a b x) \ dist y x" -proof cases - assume le: "(\i\Basis. a \ i \ b \ i)" - then have "(\i\Basis. (dist (clamp a b y \ i) (clamp a b x \ i))\<^sup>2) \ - (\i\Basis. (dist (y \ i) (x \ i))\<^sup>2)" - by (auto intro!: sum_mono simp: clamp_def dist_real_def abs_le_square_iff[symmetric]) - then show ?thesis - by (auto intro: real_sqrt_le_mono - simp: euclidean_dist_l2[where y=x] euclidean_dist_l2[where y="clamp a b x"] L2_set_def) -qed (auto simp: clamp_def) - -lemma clamp_continuous_at: - fixes f :: "'a::euclidean_space \ 'b::metric_space" - and x :: 'a - assumes f_cont: "continuous_on (cbox a b) f" - shows "continuous (at x) (\x. f (clamp a b x))" -proof cases - assume le: "(\i\Basis. a \ i \ b \ i)" - show ?thesis - unfolding continuous_at_eps_delta - proof safe - fix x :: 'a - fix e :: real - assume "e > 0" - moreover have "clamp a b x \ cbox a b" - by (simp add: clamp_in_interval le) - moreover note f_cont[simplified continuous_on_iff] - ultimately - obtain d where d: "0 < d" - "\x'. x' \ cbox a b \ dist x' (clamp a b x) < d \ dist (f x') (f (clamp a b x)) < e" - by force - show "\d>0. \x'. dist x' x < d \ - dist (f (clamp a b x')) (f (clamp a b x)) < e" - using le - by (auto intro!: d clamp_in_interval dist_clamps_le_dist_args[THEN le_less_trans]) - qed -qed (auto simp: clamp_empty_interval) - -lemma clamp_continuous_on: - fixes f :: "'a::euclidean_space \ 'b::metric_space" - assumes f_cont: "continuous_on (cbox a b) f" - shows "continuous_on S (\x. f (clamp a b x))" - using assms - by (auto intro: continuous_at_imp_continuous_on clamp_continuous_at) - -lemma clamp_bounded: - fixes f :: "'a::euclidean_space \ 'b::metric_space" - assumes bounded: "bounded (f ` (cbox a b))" - shows "bounded (range (\x. f (clamp a b x)))" -proof cases - assume le: "(\i\Basis. a \ i \ b \ i)" - from bounded obtain c where f_bound: "\x\f ` cbox a b. dist undefined x \ c" - by (auto simp: bounded_any_center[where a=undefined]) - then show ?thesis - by (auto intro!: exI[where x=c] clamp_in_interval[OF le[rule_format]] - simp: bounded_any_center[where a=undefined]) -qed (auto simp: clamp_empty_interval image_def) - - -definition ext_cont :: "('a::euclidean_space \ 'b::metric_space) \ 'a \ 'a \ 'a \ 'b" - where "ext_cont f a b = (\x. f (clamp a b x))" - -lemma ext_cont_cancel_cbox[simp]: - fixes x a b :: "'a::euclidean_space" - assumes x: "x \ cbox a b" - shows "ext_cont f a b x = f x" - using assms - unfolding ext_cont_def - by (auto simp: clamp_def mem_box intro!: euclidean_eqI[where 'a='a] arg_cong[where f=f]) - -lemma continuous_on_ext_cont[continuous_intros]: - "continuous_on (cbox a b) f \ continuous_on S (ext_cont f a b)" - by (auto intro!: clamp_continuous_on simp: ext_cont_def) - end diff -r d469a1340e21 -r e502cd4d7062 src/HOL/Analysis/Elementary_Metric_Spaces.thy --- a/src/HOL/Analysis/Elementary_Metric_Spaces.thy Mon Jan 07 11:51:18 2019 +0100 +++ b/src/HOL/Analysis/Elementary_Metric_Spaces.thy Mon Jan 07 12:31:08 2019 +0100 @@ -85,6 +85,18 @@ openin (subtopology euclidean (S \ T)) (S' \ T')" unfolding openin_open using open_Times by blast +lemma closedin_compact: + "\compact S; closedin (subtopology euclidean S) T\ \ compact T" +by (metis closedin_closed compact_Int_closed) + +lemma closedin_compact_eq: + fixes S :: "'a::t2_space set" + shows + "compact S + \ (closedin (subtopology euclidean S) T \ + compact T \ T \ S)" +by (metis closedin_imp_subset closedin_compact closed_subset compact_imp_closed) + subsubsection \Closure\ @@ -395,6 +407,310 @@ by (simp add: continuous_on_closed oo) qed +subsubsection%unimportant \Seperability\ + +lemma subset_second_countable: + obtains \ :: "'a:: second_countable_topology set set" + where "countable \" + "{} \ \" + "\C. C \ \ \ openin(subtopology euclidean S) C" + "\T. openin(subtopology euclidean S) T \ \\. \ \ \ \ T = \\" +proof - + obtain \ :: "'a set set" + where "countable \" + and opeB: "\C. C \ \ \ openin(subtopology euclidean S) C" + and \: "\T. openin(subtopology euclidean S) T \ \\. \ \ \ \ T = \\" + proof - + obtain \ :: "'a set set" + where "countable \" and ope: "\C. C \ \ \ open C" + and \: "\S. open S \ \U. U \ \ \ S = \U" + by (metis univ_second_countable that) + show ?thesis + proof + show "countable ((\C. S \ C) ` \)" + by (simp add: \countable \\) + show "\C. C \ (\) S ` \ \ openin (subtopology euclidean S) C" + using ope by auto + show "\T. openin (subtopology euclidean S) T \ \\\(\) S ` \. T = \\" + by (metis \ image_mono inf_Sup openin_open) + qed + qed + show ?thesis + proof + show "countable (\ - {{}})" + using \countable \\ by blast + show "\C. \C \ \ - {{}}\ \ openin (subtopology euclidean S) C" + by (simp add: \\C. C \ \ \ openin (subtopology euclidean S) C\) + show "\\\\ - {{}}. T = \\" if "openin (subtopology euclidean S) T" for T + using \ [OF that] + apply clarify + apply (rule_tac x="\ - {{}}" in exI, auto) + done + qed auto +qed + +lemma Lindelof_openin: + fixes \ :: "'a::second_countable_topology set set" + assumes "\S. S \ \ \ openin (subtopology euclidean U) S" + obtains \' where "\' \ \" "countable \'" "\\' = \\" +proof - + have "\S. S \ \ \ \T. open T \ S = U \ T" + using assms by (simp add: openin_open) + then obtain tf where tf: "\S. S \ \ \ open (tf S) \ (S = U \ tf S)" + by metis + have [simp]: "\\'. \' \ \ \ \\' = U \ \(tf ` \')" + using tf by fastforce + obtain \ where "countable \ \ \ \ tf ` \" "\\ = \(tf ` \)" + using tf by (force intro: Lindelof [of "tf ` \"]) + then obtain \' where \': "\' \ \" "countable \'" "\\' = \\" + by (clarsimp simp add: countable_subset_image) + then show ?thesis .. +qed + + +subsubsection%unimportant\Closed Maps\ + +lemma continuous_imp_closed_map: + fixes f :: "'a::t2_space \ 'b::t2_space" + assumes "closedin (subtopology euclidean S) U" + "continuous_on S f" "f ` S = T" "compact S" + shows "closedin (subtopology euclidean T) (f ` U)" + by (metis assms closedin_compact_eq compact_continuous_image continuous_on_subset subset_image_iff) + +lemma closed_map_restrict: + assumes cloU: "closedin (subtopology euclidean (S \ f -` T')) U" + and cc: "\U. closedin (subtopology euclidean S) U \ closedin (subtopology euclidean T) (f ` U)" + and "T' \ T" + shows "closedin (subtopology euclidean T') (f ` U)" +proof - + obtain V where "closed V" "U = S \ f -` T' \ V" + using cloU by (auto simp: closedin_closed) + with cc [of "S \ V"] \T' \ T\ show ?thesis + by (fastforce simp add: closedin_closed) +qed + +subsubsection%unimportant\Open Maps\ + +lemma open_map_restrict: + assumes opeU: "openin (subtopology euclidean (S \ f -` T')) U" + and oo: "\U. openin (subtopology euclidean S) U \ openin (subtopology euclidean T) (f ` U)" + and "T' \ T" + shows "openin (subtopology euclidean T') (f ` U)" +proof - + obtain V where "open V" "U = S \ f -` T' \ V" + using opeU by (auto simp: openin_open) + with oo [of "S \ V"] \T' \ T\ show ?thesis + by (fastforce simp add: openin_open) +qed + + +subsubsection%unimportant\Quotient maps\ + +lemma quotient_map_imp_continuous_open: + assumes T: "f ` S \ T" + and ope: "\U. U \ T + \ (openin (subtopology euclidean S) (S \ f -` U) \ + openin (subtopology euclidean T) U)" + shows "continuous_on S f" +proof - + have [simp]: "S \ f -` f ` S = S" by auto + show ?thesis + using ope [OF T] + apply (simp add: continuous_on_open) + by (meson ope openin_imp_subset openin_trans) +qed + +lemma quotient_map_imp_continuous_closed: + assumes T: "f ` S \ T" + and ope: "\U. U \ T + \ (closedin (subtopology euclidean S) (S \ f -` U) \ + closedin (subtopology euclidean T) U)" + shows "continuous_on S f" +proof - + have [simp]: "S \ f -` f ` S = S" by auto + show ?thesis + using ope [OF T] + apply (simp add: continuous_on_closed) + by (metis (no_types, lifting) ope closedin_imp_subset closedin_trans) +qed + +lemma open_map_imp_quotient_map: + assumes contf: "continuous_on S f" + and T: "T \ f ` S" + and ope: "\T. openin (subtopology euclidean S) T + \ openin (subtopology euclidean (f ` S)) (f ` T)" + shows "openin (subtopology euclidean S) (S \ f -` T) = + openin (subtopology euclidean (f ` S)) T" +proof - + have "T = f ` (S \ f -` T)" + using T by blast + then show ?thesis + using "ope" contf continuous_on_open by metis +qed + +lemma closed_map_imp_quotient_map: + assumes contf: "continuous_on S f" + and T: "T \ f ` S" + and ope: "\T. closedin (subtopology euclidean S) T + \ closedin (subtopology euclidean (f ` S)) (f ` T)" + shows "openin (subtopology euclidean S) (S \ f -` T) \ + openin (subtopology euclidean (f ` S)) T" + (is "?lhs = ?rhs") +proof + assume ?lhs + then have *: "closedin (subtopology euclidean S) (S - (S \ f -` T))" + using closedin_diff by fastforce + have [simp]: "(f ` S - f ` (S - (S \ f -` T))) = T" + using T by blast + show ?rhs + using ope [OF *, unfolded closedin_def] by auto +next + assume ?rhs + with contf show ?lhs + by (auto simp: continuous_on_open) +qed + +lemma continuous_right_inverse_imp_quotient_map: + assumes contf: "continuous_on S f" and imf: "f ` S \ T" + and contg: "continuous_on T g" and img: "g ` T \ S" + and fg [simp]: "\y. y \ T \ f(g y) = y" + and U: "U \ T" + shows "openin (subtopology euclidean S) (S \ f -` U) \ + openin (subtopology euclidean T) U" + (is "?lhs = ?rhs") +proof - + have f: "\Z. openin (subtopology euclidean (f ` S)) Z \ + openin (subtopology euclidean S) (S \ f -` Z)" + and g: "\Z. openin (subtopology euclidean (g ` T)) Z \ + openin (subtopology euclidean T) (T \ g -` Z)" + using contf contg by (auto simp: continuous_on_open) + show ?thesis + proof + have "T \ g -` (g ` T \ (S \ f -` U)) = {x \ T. f (g x) \ U}" + using imf img by blast + also have "... = U" + using U by auto + finally have eq: "T \ g -` (g ` T \ (S \ f -` U)) = U" . + assume ?lhs + then have *: "openin (subtopology euclidean (g ` T)) (g ` T \ (S \ f -` U))" + by (meson img openin_Int openin_subtopology_Int_subset openin_subtopology_self) + show ?rhs + using g [OF *] eq by auto + next + assume rhs: ?rhs + show ?lhs + by (metis f fg image_eqI image_subset_iff imf img openin_subopen openin_subtopology_self openin_trans rhs) + qed +qed + +lemma continuous_left_inverse_imp_quotient_map: + assumes "continuous_on S f" + and "continuous_on (f ` S) g" + and "\x. x \ S \ g(f x) = x" + and "U \ f ` S" + shows "openin (subtopology euclidean S) (S \ f -` U) \ + openin (subtopology euclidean (f ` S)) U" +apply (rule continuous_right_inverse_imp_quotient_map) +using assms apply force+ +done + +lemma continuous_imp_quotient_map: + fixes f :: "'a::t2_space \ 'b::t2_space" + assumes "continuous_on S f" "f ` S = T" "compact S" "U \ T" + shows "openin (subtopology euclidean S) (S \ f -` U) \ + openin (subtopology euclidean T) U" + by (metis (no_types, lifting) assms closed_map_imp_quotient_map continuous_imp_closed_map) + +subsubsection%unimportant\Pasting functions together\ + +text\on open sets\ + +lemma pasting_lemma: + fixes f :: "'i \ 'a::topological_space \ 'b::topological_space" + assumes clo: "\i. i \ I \ openin (subtopology euclidean S) (T i)" + and cont: "\i. i \ I \ continuous_on (T i) (f i)" + and f: "\i j x. \i \ I; j \ I; x \ S \ T i \ T j\ \ f i x = f j x" + and g: "\x. x \ S \ \j. j \ I \ x \ T j \ g x = f j x" + shows "continuous_on S g" +proof (clarsimp simp: continuous_openin_preimage_eq) + fix U :: "'b set" + assume "open U" + have S: "\i. i \ I \ (T i) \ S" + using clo openin_imp_subset by blast + have *: "(S \ g -` U) = (\i \ I. T i \ f i -` U)" + using S f g by fastforce + show "openin (subtopology euclidean S) (S \ g -` U)" + apply (subst *) + apply (rule openin_Union, clarify) + using \open U\ clo cont continuous_openin_preimage_gen openin_trans by blast +qed + +lemma pasting_lemma_exists: + fixes f :: "'i \ 'a::topological_space \ 'b::topological_space" + assumes S: "S \ (\i \ I. T i)" + and clo: "\i. i \ I \ openin (subtopology euclidean S) (T i)" + and cont: "\i. i \ I \ continuous_on (T i) (f i)" + and f: "\i j x. \i \ I; j \ I; x \ S \ T i \ T j\ \ f i x = f j x" + obtains g where "continuous_on S g" "\x i. \i \ I; x \ S \ T i\ \ g x = f i x" +proof + show "continuous_on S (\x. f (SOME i. i \ I \ x \ T i) x)" + apply (rule pasting_lemma [OF clo cont]) + apply (blast intro: f)+ + apply (metis (mono_tags, lifting) S UN_iff subsetCE someI) + done +next + fix x i + assume "i \ I" "x \ S \ T i" + then show "f (SOME i. i \ I \ x \ T i) x = f i x" + by (metis (no_types, lifting) IntD2 IntI f someI_ex) +qed + +text\Likewise on closed sets, with a finiteness assumption\ + +lemma pasting_lemma_closed: + fixes f :: "'i \ 'a::topological_space \ 'b::topological_space" + assumes "finite I" + and clo: "\i. i \ I \ closedin (subtopology euclidean S) (T i)" + and cont: "\i. i \ I \ continuous_on (T i) (f i)" + and f: "\i j x. \i \ I; j \ I; x \ S \ T i \ T j\ \ f i x = f j x" + and g: "\x. x \ S \ \j. j \ I \ x \ T j \ g x = f j x" + shows "continuous_on S g" +proof (clarsimp simp: continuous_closedin_preimage_eq) + fix U :: "'b set" + assume "closed U" + have S: "\i. i \ I \ (T i) \ S" + using clo closedin_imp_subset by blast + have *: "(S \ g -` U) = (\i \ I. T i \ f i -` U)" + using S f g by fastforce + show "closedin (subtopology euclidean S) (S \ g -` U)" + apply (subst *) + apply (rule closedin_Union) + using \finite I\ apply simp + apply (blast intro: \closed U\ continuous_closedin_preimage cont clo closedin_trans) + done +qed + +lemma pasting_lemma_exists_closed: + fixes f :: "'i \ 'a::topological_space \ 'b::topological_space" + assumes "finite I" + and S: "S \ (\i \ I. T i)" + and clo: "\i. i \ I \ closedin (subtopology euclidean S) (T i)" + and cont: "\i. i \ I \ continuous_on (T i) (f i)" + and f: "\i j x. \i \ I; j \ I; x \ S \ T i \ T j\ \ f i x = f j x" + obtains g where "continuous_on S g" "\x i. \i \ I; x \ S \ T i\ \ g x = f i x" +proof + show "continuous_on S (\x. f (SOME i. i \ I \ x \ T i) x)" + apply (rule pasting_lemma_closed [OF \finite I\ clo cont]) + apply (blast intro: f)+ + apply (metis (mono_tags, lifting) S UN_iff subsetCE someI) + done +next + fix x i + assume "i \ I" "x \ S \ T i" + then show "f (SOME i. i \ I \ x \ T i) x = f i x" + by (metis (no_types, lifting) IntD2 IntI f someI_ex) +qed + subsection \Open and closed balls\ @@ -2227,6 +2543,62 @@ by auto +subsection%unimportant\ Finite intersection property\ + +text\Also developed in HOL's toplogical spaces theory, but the Heine-Borel type class isn't available there.\ + +lemma closed_imp_fip: + fixes S :: "'a::heine_borel set" + assumes "closed S" + and T: "T \ \" "bounded T" + and clof: "\T. T \ \ \ closed T" + and none: "\\'. \finite \'; \' \ \\ \ S \ \\' \ {}" + shows "S \ \\ \ {}" +proof - + have "compact (S \ T)" + using \closed S\ clof compact_eq_bounded_closed T by blast + then have "(S \ T) \ \\ \ {}" + apply (rule compact_imp_fip) + apply (simp add: clof) + by (metis Int_assoc complete_lattice_class.Inf_insert finite_insert insert_subset none \T \ \\) + then show ?thesis by blast +qed + +lemma closed_imp_fip_compact: + fixes S :: "'a::heine_borel set" + shows + "\closed S; \T. T \ \ \ compact T; + \\'. \finite \'; \' \ \\ \ S \ \\' \ {}\ + \ S \ \\ \ {}" +by (metis Inf_greatest closed_imp_fip compact_eq_bounded_closed empty_subsetI finite.emptyI inf.orderE) + +lemma closed_fip_Heine_Borel: + fixes \ :: "'a::heine_borel set set" + assumes "closed S" "T \ \" "bounded T" + and "\T. T \ \ \ closed T" + and "\\'. \finite \'; \' \ \\ \ \\' \ {}" + shows "\\ \ {}" +proof - + have "UNIV \ \\ \ {}" + using assms closed_imp_fip [OF closed_UNIV] by auto + then show ?thesis by simp +qed + +lemma compact_fip_Heine_Borel: + fixes \ :: "'a::heine_borel set set" + assumes clof: "\T. T \ \ \ compact T" + and none: "\\'. \finite \'; \' \ \\ \ \\' \ {}" + shows "\\ \ {}" +by (metis InterI all_not_in_conv clof closed_fip_Heine_Borel compact_eq_bounded_closed none) + +lemma compact_sequence_with_limit: + fixes f :: "nat \ 'a::heine_borel" + shows "(f \ l) sequentially \ compact (insert l (range f))" +apply (simp add: compact_eq_bounded_closed, auto) +apply (simp add: convergent_imp_bounded) +by (simp add: closed_limpt islimpt_insert sequence_unique_limpt) + + subsection \Properties of Balls and Spheres\ lemma compact_cball[simp]: diff -r d469a1340e21 -r e502cd4d7062 src/HOL/Analysis/Elementary_Normed_Spaces.thy --- a/src/HOL/Analysis/Elementary_Normed_Spaces.thy Mon Jan 07 11:51:18 2019 +0100 +++ b/src/HOL/Analysis/Elementary_Normed_Spaces.thy Mon Jan 07 12:31:08 2019 +0100 @@ -1573,6 +1573,36 @@ using assms homeomorphic_ball01_UNIV homeomorphic_balls(1) homeomorphic_trans zero_less_one by blast +subsection%unimportant \Discrete\ + +lemma finite_implies_discrete: + fixes S :: "'a::topological_space set" + assumes "finite (f ` S)" + shows "(\x \ S. \e>0. \y. y \ S \ f y \ f x \ e \ norm (f y - f x))" +proof - + have "\e>0. \y. y \ S \ f y \ f x \ e \ norm (f y - f x)" if "x \ S" for x + proof (cases "f ` S - {f x} = {}") + case True + with zero_less_numeral show ?thesis + by (fastforce simp add: Set.image_subset_iff cong: conj_cong) + next + case False + then obtain z where z: "z \ S" "f z \ f x" + by blast + have finn: "finite {norm (z - f x) |z. z \ f ` S - {f x}}" + using assms by simp + then have *: "0 < Inf{norm(z - f x) | z. z \ f ` S - {f x}}" + apply (rule finite_imp_less_Inf) + using z apply force+ + done + show ?thesis + by (force intro!: * cInf_le_finite [OF finn]) + qed + with assms show ?thesis + by blast +qed + + subsection%unimportant \Completeness of "Isometry" (up to constant bounds)\ lemma cauchy_isometric:\ \TODO: rename lemma to \Cauchy_isometric\\ diff -r d469a1340e21 -r e502cd4d7062 src/HOL/Analysis/Elementary_Topology.thy --- a/src/HOL/Analysis/Elementary_Topology.thy Mon Jan 07 11:51:18 2019 +0100 +++ b/src/HOL/Analysis/Elementary_Topology.thy Mon Jan 07 12:31:08 2019 +0100 @@ -9,6 +9,7 @@ theory Elementary_Topology imports "HOL-Library.Set_Idioms" + "HOL-Library.Disjoint_Sets" Product_Vector begin @@ -463,13 +464,65 @@ qed qed + end +lemma univ_second_countable: + obtains \ :: "'a::second_countable_topology set set" + where "countable \" "\C. C \ \ \ open C" + "\S. open S \ \U. U \ \ \ S = \U" +by (metis ex_countable_basis topological_basis_def) + +proposition Lindelof: + fixes \ :: "'a::second_countable_topology set set" + assumes \: "\S. S \ \ \ open S" + obtains \' where "\' \ \" "countable \'" "\\' = \\" +proof - + obtain \ :: "'a set set" + where "countable \" "\C. C \ \ \ open C" + and \: "\S. open S \ \U. U \ \ \ S = \U" + using univ_second_countable by blast + define \ where "\ \ {S. S \ \ \ (\U. U \ \ \ S \ U)}" + have "countable \" + apply (rule countable_subset [OF _ \countable \\]) + apply (force simp: \_def) + done + have "\S. \U. S \ \ \ U \ \ \ S \ U" + by (simp add: \_def) + then obtain G where G: "\S. S \ \ \ G S \ \ \ S \ G S" + by metis + have "\\ \ \\" + unfolding \_def by (blast dest: \ \) + moreover have "\\ \ \\" + using \_def by blast + ultimately have eq1: "\\ = \\" .. + have eq2: "\\ = \ (G ` \)" + using G eq1 by auto + show ?thesis + apply (rule_tac \' = "G ` \" in that) + using G \countable \\ + by (auto simp: eq1 eq2) +qed + +lemma countable_disjoint_open_subsets: + fixes \ :: "'a::second_countable_topology set set" + assumes "\S. S \ \ \ open S" and pw: "pairwise disjnt \" + shows "countable \" +proof - + obtain \' where "\' \ \" "countable \'" "\\' = \\" + by (meson assms Lindelof) + with pw have "\ \ insert {} \'" + by (fastforce simp add: pairwise_def disjnt_iff) + then show ?thesis + by (simp add: \countable \'\ countable_subset) +qed + sublocale second_countable_topology < countable_basis "SOME B. countable B \ topological_basis B" using someI_ex[OF ex_countable_basis] by unfold_locales safe + instance prod :: (second_countable_topology, second_countable_topology) second_countable_topology proof obtain A :: "'a set set" where "countable A" "topological_basis A" @@ -594,6 +647,7 @@ then show ?thesis using B(1) by auto qed + subsection%important \Polish spaces\ text \Textbooks define Polish spaces as completely metrizable. @@ -966,6 +1020,20 @@ by (auto simp: subset_eq less_le) qed auto +lemma countable_disjoint_nonempty_interior_subsets: + fixes \ :: "'a::second_countable_topology set set" + assumes pw: "pairwise disjnt \" and int: "\S. \S \ \; interior S = {}\ \ S = {}" + shows "countable \" +proof (rule countable_image_inj_on) + have "disjoint (interior ` \)" + using pw by (simp add: disjoint_image_subset interior_subset) + then show "countable (interior ` \)" + by (auto intro: countable_disjoint_open_subsets) + show "inj_on interior \" + using pw apply (clarsimp simp: inj_on_def pairwise_def) + apply (metis disjnt_def disjnt_subset1 inf.orderE int interior_subset) + done +qed subsection \Closure of a Set\ @@ -2172,6 +2240,85 @@ qed +lemma tube_lemma: + assumes "compact K" + assumes "open W" + assumes "{x0} \ K \ W" + shows "\X0. x0 \ X0 \ open X0 \ X0 \ K \ W" +proof - + { + fix y assume "y \ K" + then have "(x0, y) \ W" using assms by auto + with \open W\ + have "\X0 Y. open X0 \ open Y \ x0 \ X0 \ y \ Y \ X0 \ Y \ W" + by (rule open_prod_elim) blast + } + then obtain X0 Y where + *: "\y \ K. open (X0 y) \ open (Y y) \ x0 \ X0 y \ y \ Y y \ X0 y \ Y y \ W" + by metis + from * have "\t\Y ` K. open t" "K \ \(Y ` K)" by auto + with \compact K\ obtain CC where CC: "CC \ Y ` K" "finite CC" "K \ \CC" + by (meson compactE) + then obtain c where c: "\C. C \ CC \ c C \ K \ C = Y (c C)" + by (force intro!: choice) + with * CC show ?thesis + by (force intro!: exI[where x="\C\CC. X0 (c C)"]) (* SLOW *) +qed + +lemma continuous_on_prod_compactE: + fixes fx::"'a::topological_space \ 'b::topological_space \ 'c::metric_space" + and e::real + assumes cont_fx: "continuous_on (U \ C) fx" + assumes "compact C" + assumes [intro]: "x0 \ U" + notes [continuous_intros] = continuous_on_compose2[OF cont_fx] + assumes "e > 0" + obtains X0 where "x0 \ X0" "open X0" + "\x\X0 \ U. \t \ C. dist (fx (x, t)) (fx (x0, t)) \ e" +proof - + define psi where "psi = (\(x, t). dist (fx (x, t)) (fx (x0, t)))" + define W0 where "W0 = {(x, t) \ U \ C. psi (x, t) < e}" + have W0_eq: "W0 = psi -` {.. U \ C" + by (auto simp: vimage_def W0_def) + have "open {.. C) psi" + by (auto intro!: continuous_intros simp: psi_def split_beta') + from this[unfolded continuous_on_open_invariant, rule_format, OF \open {..] + obtain W where W: "open W" "W \ U \ C = W0 \ U \ C" + unfolding W0_eq by blast + have "{x0} \ C \ W \ U \ C" + unfolding W + by (auto simp: W0_def psi_def \0 < e\) + then have "{x0} \ C \ W" by blast + from tube_lemma[OF \compact C\ \open W\ this] + obtain X0 where X0: "x0 \ X0" "open X0" "X0 \ C \ W" + by blast + + have "\x\X0 \ U. \t \ C. dist (fx (x, t)) (fx (x0, t)) \ e" + proof safe + fix x assume x: "x \ X0" "x \ U" + fix t assume t: "t \ C" + have "dist (fx (x, t)) (fx (x0, t)) = psi (x, t)" + by (auto simp: psi_def) + also + { + have "(x, t) \ X0 \ C" + using t x + by auto + also note \\ \ W\ + finally have "(x, t) \ W" . + with t x have "(x, t) \ W \ U \ C" + by blast + also note \W \ U \ C = W0 \ U \ C\ + finally have "psi (x, t) < e" + by (auto simp: W0_def) + } + finally show "dist (fx (x, t)) (fx (x0, t)) \ e" by simp + qed + from X0(1,2) this show ?thesis .. +qed + + subsection \Continuity\ lemma continuous_at_imp_continuous_within: diff -r d469a1340e21 -r e502cd4d7062 src/HOL/Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Analysis/Topology_Euclidean_Space.thy Mon Jan 07 11:51:18 2019 +0100 +++ b/src/HOL/Analysis/Topology_Euclidean_Space.thy Mon Jan 07 12:31:08 2019 +0100 @@ -1586,6 +1586,313 @@ qed +subsection%unimportant\Componentwise limits and continuity\ + +text\But is the premise really necessary? Need to generalise @{thm euclidean_dist_l2}\ +lemma Euclidean_dist_upper: "i \ Basis \ dist (x \ i) (y \ i) \ dist x y" + by (metis (no_types) member_le_L2_set euclidean_dist_l2 finite_Basis) + +text\But is the premise \<^term>\i \ Basis\ really necessary?\ +lemma open_preimage_inner: + assumes "open S" "i \ Basis" + shows "open {x. x \ i \ S}" +proof (rule openI, simp) + fix x + assume x: "x \ i \ S" + with assms obtain e where "0 < e" and e: "ball (x \ i) e \ S" + by (auto simp: open_contains_ball_eq) + have "\e>0. ball (y \ i) e \ S" if dxy: "dist x y < e / 2" for y + proof (intro exI conjI) + have "dist (x \ i) (y \ i) < e / 2" + by (meson \i \ Basis\ dual_order.trans Euclidean_dist_upper not_le that) + then have "dist (x \ i) z < e" if "dist (y \ i) z < e / 2" for z + by (metis dist_commute dist_triangle_half_l that) + then have "ball (y \ i) (e / 2) \ ball (x \ i) e" + using mem_ball by blast + with e show "ball (y \ i) (e / 2) \ S" + by (metis order_trans) + qed (simp add: \0 < e\) + then show "\e>0. ball x e \ {s. s \ i \ S}" + by (metis (no_types, lifting) \0 < e\ \open S\ half_gt_zero_iff mem_Collect_eq mem_ball open_contains_ball_eq subsetI) +qed + +proposition tendsto_componentwise_iff: + fixes f :: "_ \ 'b::euclidean_space" + shows "(f \ l) F \ (\i \ Basis. ((\x. (f x \ i)) \ (l \ i)) F)" + (is "?lhs = ?rhs") +proof + assume ?lhs + then show ?rhs + unfolding tendsto_def + apply clarify + apply (drule_tac x="{s. s \ i \ S}" in spec) + apply (auto simp: open_preimage_inner) + done +next + assume R: ?rhs + then have "\e. e > 0 \ \i\Basis. \\<^sub>F x in F. dist (f x \ i) (l \ i) < e" + unfolding tendsto_iff by blast + then have R': "\e. e > 0 \ \\<^sub>F x in F. \i\Basis. dist (f x \ i) (l \ i) < e" + by (simp add: eventually_ball_finite_distrib [symmetric]) + show ?lhs + unfolding tendsto_iff + proof clarify + fix e::real + assume "0 < e" + have *: "L2_set (\i. dist (f x \ i) (l \ i)) Basis < e" + if "\i\Basis. dist (f x \ i) (l \ i) < e / real DIM('b)" for x + proof - + have "L2_set (\i. dist (f x \ i) (l \ i)) Basis \ sum (\i. dist (f x \ i) (l \ i)) Basis" + by (simp add: L2_set_le_sum) + also have "... < DIM('b) * (e / real DIM('b))" + apply (rule sum_bounded_above_strict) + using that by auto + also have "... = e" + by (simp add: field_simps) + finally show "L2_set (\i. dist (f x \ i) (l \ i)) Basis < e" . + qed + have "\\<^sub>F x in F. \i\Basis. dist (f x \ i) (l \ i) < e / DIM('b)" + apply (rule R') + using \0 < e\ by simp + then show "\\<^sub>F x in F. dist (f x) l < e" + apply (rule eventually_mono) + apply (subst euclidean_dist_l2) + using * by blast + qed +qed + + +corollary continuous_componentwise: + "continuous F f \ (\i \ Basis. continuous F (\x. (f x \ i)))" +by (simp add: continuous_def tendsto_componentwise_iff [symmetric]) + +corollary continuous_on_componentwise: + fixes S :: "'a :: t2_space set" + shows "continuous_on S f \ (\i \ Basis. continuous_on S (\x. (f x \ i)))" + apply (simp add: continuous_on_eq_continuous_within) + using continuous_componentwise by blast + +lemma linear_componentwise_iff: + "(linear f') \ (\i\Basis. linear (\x. f' x \ i))" + apply (auto simp: linear_iff inner_left_distrib) + apply (metis inner_left_distrib euclidean_eq_iff) + by (metis euclidean_eqI inner_scaleR_left) + +lemma bounded_linear_componentwise_iff: + "(bounded_linear f') \ (\i\Basis. bounded_linear (\x. f' x \ i))" + (is "?lhs = ?rhs") +proof + assume ?lhs then show ?rhs + by (simp add: bounded_linear_inner_left_comp) +next + assume ?rhs + then have "(\i\Basis. \K. \x. \f' x \ i\ \ norm x * K)" "linear f'" + by (auto simp: bounded_linear_def bounded_linear_axioms_def linear_componentwise_iff [symmetric] ball_conj_distrib) + then obtain F where F: "\i x. i \ Basis \ \f' x \ i\ \ norm x * F i" + by metis + have "norm (f' x) \ norm x * sum F Basis" for x + proof - + have "norm (f' x) \ (\i\Basis. \f' x \ i\)" + by (rule norm_le_l1) + also have "... \ (\i\Basis. norm x * F i)" + by (metis F sum_mono) + also have "... = norm x * sum F Basis" + by (simp add: sum_distrib_left) + finally show ?thesis . + qed + then show ?lhs + by (force simp: bounded_linear_def bounded_linear_axioms_def \linear f'\) +qed + +subsection%unimportant \Continuous Extension\ + +definition clamp :: "'a::euclidean_space \ 'a \ 'a \ 'a" where + "clamp a b x = (if (\i\Basis. a \ i \ b \ i) + then (\i\Basis. (if x\i < a\i then a\i else if x\i \ b\i then x\i else b\i) *\<^sub>R i) + else a)" + +lemma clamp_in_interval[simp]: + assumes "\i. i \ Basis \ a \ i \ b \ i" + shows "clamp a b x \ cbox a b" + unfolding clamp_def + using box_ne_empty(1)[of a b] assms by (auto simp: cbox_def) + +lemma clamp_cancel_cbox[simp]: + fixes x a b :: "'a::euclidean_space" + assumes x: "x \ cbox a b" + shows "clamp a b x = x" + using assms + by (auto simp: clamp_def mem_box intro!: euclidean_eqI[where 'a='a]) + +lemma clamp_empty_interval: + assumes "i \ Basis" "a \ i > b \ i" + shows "clamp a b = (\_. a)" + using assms + by (force simp: clamp_def[abs_def] split: if_splits intro!: ext) + +lemma dist_clamps_le_dist_args: + fixes x :: "'a::euclidean_space" + shows "dist (clamp a b y) (clamp a b x) \ dist y x" +proof cases + assume le: "(\i\Basis. a \ i \ b \ i)" + then have "(\i\Basis. (dist (clamp a b y \ i) (clamp a b x \ i))\<^sup>2) \ + (\i\Basis. (dist (y \ i) (x \ i))\<^sup>2)" + by (auto intro!: sum_mono simp: clamp_def dist_real_def abs_le_square_iff[symmetric]) + then show ?thesis + by (auto intro: real_sqrt_le_mono + simp: euclidean_dist_l2[where y=x] euclidean_dist_l2[where y="clamp a b x"] L2_set_def) +qed (auto simp: clamp_def) + +lemma clamp_continuous_at: + fixes f :: "'a::euclidean_space \ 'b::metric_space" + and x :: 'a + assumes f_cont: "continuous_on (cbox a b) f" + shows "continuous (at x) (\x. f (clamp a b x))" +proof cases + assume le: "(\i\Basis. a \ i \ b \ i)" + show ?thesis + unfolding continuous_at_eps_delta + proof safe + fix x :: 'a + fix e :: real + assume "e > 0" + moreover have "clamp a b x \ cbox a b" + by (simp add: clamp_in_interval le) + moreover note f_cont[simplified continuous_on_iff] + ultimately + obtain d where d: "0 < d" + "\x'. x' \ cbox a b \ dist x' (clamp a b x) < d \ dist (f x') (f (clamp a b x)) < e" + by force + show "\d>0. \x'. dist x' x < d \ + dist (f (clamp a b x')) (f (clamp a b x)) < e" + using le + by (auto intro!: d clamp_in_interval dist_clamps_le_dist_args[THEN le_less_trans]) + qed +qed (auto simp: clamp_empty_interval) + +lemma clamp_continuous_on: + fixes f :: "'a::euclidean_space \ 'b::metric_space" + assumes f_cont: "continuous_on (cbox a b) f" + shows "continuous_on S (\x. f (clamp a b x))" + using assms + by (auto intro: continuous_at_imp_continuous_on clamp_continuous_at) + +lemma clamp_bounded: + fixes f :: "'a::euclidean_space \ 'b::metric_space" + assumes bounded: "bounded (f ` (cbox a b))" + shows "bounded (range (\x. f (clamp a b x)))" +proof cases + assume le: "(\i\Basis. a \ i \ b \ i)" + from bounded obtain c where f_bound: "\x\f ` cbox a b. dist undefined x \ c" + by (auto simp: bounded_any_center[where a=undefined]) + then show ?thesis + by (auto intro!: exI[where x=c] clamp_in_interval[OF le[rule_format]] + simp: bounded_any_center[where a=undefined]) +qed (auto simp: clamp_empty_interval image_def) + + +definition ext_cont :: "('a::euclidean_space \ 'b::metric_space) \ 'a \ 'a \ 'a \ 'b" + where "ext_cont f a b = (\x. f (clamp a b x))" + +lemma ext_cont_cancel_cbox[simp]: + fixes x a b :: "'a::euclidean_space" + assumes x: "x \ cbox a b" + shows "ext_cont f a b x = f x" + using assms + unfolding ext_cont_def + by (auto simp: clamp_def mem_box intro!: euclidean_eqI[where 'a='a] arg_cong[where f=f]) + +lemma continuous_on_ext_cont[continuous_intros]: + "continuous_on (cbox a b) f \ continuous_on S (ext_cont f a b)" + by (auto intro!: clamp_continuous_on simp: ext_cont_def) + + +subsection \Separability\ + +lemma univ_second_countable_sequence: + obtains B :: "nat \ 'a::euclidean_space set" + where "inj B" "\n. open(B n)" "\S. open S \ \k. S = \{B n |n. n \ k}" +proof - + obtain \ :: "'a set set" + where "countable \" + and opn: "\C. C \ \ \ open C" + and Un: "\S. open S \ \U. U \ \ \ S = \U" + using univ_second_countable by blast + have *: "infinite (range (\n. ball (0::'a) (inverse(Suc n))))" + apply (rule Infinite_Set.range_inj_infinite) + apply (simp add: inj_on_def ball_eq_ball_iff) + done + have "infinite \" + proof + assume "finite \" + then have "finite (Union ` (Pow \))" + by simp + then have "finite (range (\n. ball (0::'a) (inverse(Suc n))))" + apply (rule rev_finite_subset) + by (metis (no_types, lifting) PowI image_eqI image_subset_iff Un [OF open_ball]) + with * show False by simp + qed + obtain f :: "nat \ 'a set" where "\ = range f" "inj f" + by (blast intro: countable_as_injective_image [OF \countable \\ \infinite \\]) + have *: "\k. S = \{f n |n. n \ k}" if "open S" for S + using Un [OF that] + apply clarify + apply (rule_tac x="f-`U" in exI) + using \inj f\ \\ = range f\ apply force + done + show ?thesis + apply (rule that [OF \inj f\ _ *]) + apply (auto simp: \\ = range f\ opn) + done +qed + +proposition separable: + fixes S :: "'a::{metric_space, second_countable_topology} set" + obtains T where "countable T" "T \ S" "S \ closure T" +proof - + obtain \ :: "'a set set" + where "countable \" + and "{} \ \" + and ope: "\C. C \ \ \ openin(subtopology euclidean S) C" + and if_ope: "\T. openin(subtopology euclidean S) T \ \\. \ \ \ \ T = \\" + by (meson subset_second_countable) + then obtain f where f: "\C. C \ \ \ f C \ C" + by (metis equals0I) + show ?thesis + proof + show "countable (f ` \)" + by (simp add: \countable \\) + show "f ` \ \ S" + using ope f openin_imp_subset by blast + show "S \ closure (f ` \)" + proof (clarsimp simp: closure_approachable) + fix x and e::real + assume "x \ S" "0 < e" + have "openin (subtopology euclidean S) (S \ ball x e)" + by (simp add: openin_Int_open) + with if_ope obtain \ where \: "\ \ \" "S \ ball x e = \\" + by meson + show "\C \ \. dist (f C) x < e" + proof (cases "\ = {}") + case True + then show ?thesis + using \0 < e\ \ \x \ S\ by auto + next + case False + then obtain C where "C \ \" by blast + show ?thesis + proof + show "dist (f C) x < e" + by (metis Int_iff Union_iff \ \C \ \\ dist_commute f mem_ball subsetCE) + show "C \ \" + using \\ \ \\ \C \ \\ by blast + qed + qed + qed + qed +qed + + subsection%unimportant \Diameter\ lemma diameter_cball [simp]: