src/HOL/Analysis/Abstract_Metric_Spaces.thy
changeset 78248 740b23f1138a
parent 78200 264f2b69d09c
child 78258 71366be2c647
equal deleted inserted replaced
78239:4fe65149f3fd 78248:740b23f1138a
  2643 qed
  2643 qed
  2644 
  2644 
  2645 
  2645 
  2646 lemma continuous_map_uniform_limit_alt:
  2646 lemma continuous_map_uniform_limit_alt:
  2647   assumes contf: "\<forall>\<^sub>F \<xi> in F. continuous_map X mtopology (f \<xi>)"
  2647   assumes contf: "\<forall>\<^sub>F \<xi> in F. continuous_map X mtopology (f \<xi>)"
  2648     and gim: "g ` (topspace X) \<subseteq> M"
  2648     and gim: "g \<in> topspace X \<rightarrow> M"
  2649     and dfg: "\<And>\<epsilon>. 0 < \<epsilon> \<Longrightarrow> \<forall>\<^sub>F \<xi> in F. \<forall>x \<in> topspace X. d (f \<xi> x) (g x) < \<epsilon>"
  2649     and dfg: "\<And>\<epsilon>. 0 < \<epsilon> \<Longrightarrow> \<forall>\<^sub>F \<xi> in F. \<forall>x \<in> topspace X. d (f \<xi> x) (g x) < \<epsilon>"
  2650     and nontriv: "\<not> trivial_limit F"
  2650     and nontriv: "\<not> trivial_limit F"
  2651   shows "continuous_map X mtopology g"
  2651   shows "continuous_map X mtopology g"
  2652 proof (rule continuous_map_uniform_limit [OF contf])
  2652 proof (rule continuous_map_uniform_limit [OF contf])
  2653   fix \<epsilon> :: real
  2653   fix \<epsilon> :: real
  2654   assume "\<epsilon> > 0"
  2654   assume "\<epsilon> > 0"
  2655   with gim dfg show "\<forall>\<^sub>F \<xi> in F. \<forall>x\<in>topspace X. g x \<in> M \<and> d (f \<xi> x) (g x) < \<epsilon>"
  2655   with gim dfg show "\<forall>\<^sub>F \<xi> in F. \<forall>x\<in>topspace X. g x \<in> M \<and> d (f \<xi> x) (g x) < \<epsilon>"
  2656     by (simp add: image_subset_iff)
  2656     by (simp add: Pi_iff)
  2657 qed (use nontriv in auto)
  2657 qed (use nontriv in auto)
  2658 
  2658 
  2659 
  2659 
  2660 lemma continuous_map_uniformly_Cauchy_limit:
  2660 lemma continuous_map_uniformly_Cauchy_limit:
  2661   assumes "mcomplete"
  2661   assumes "mcomplete"
  2798 qed
  2798 qed
  2799 
  2799 
  2800 lemma completely_metrizable_space_cbox: "completely_metrizable_space (top_of_set (cbox a b))"
  2800 lemma completely_metrizable_space_cbox: "completely_metrizable_space (top_of_set (cbox a b))"
  2801     using closed_closedin completely_metrizable_space_closedin completely_metrizable_space_euclidean by blast
  2801     using closed_closedin completely_metrizable_space_closedin completely_metrizable_space_euclidean by blast
  2802 
  2802 
       
  2803 
  2803 lemma homeomorphic_completely_metrizable_space_aux:
  2804 lemma homeomorphic_completely_metrizable_space_aux:
  2804   assumes homXY: "X homeomorphic_space Y" and X: "completely_metrizable_space X"
  2805   assumes homXY: "X homeomorphic_space Y" and X: "completely_metrizable_space X"
  2805   shows "completely_metrizable_space Y"
  2806   shows "completely_metrizable_space Y"
  2806 proof -
  2807 proof -
  2807   obtain f g where hmf: "homeomorphic_map X Y f" and hmg: "homeomorphic_map Y X g"
  2808   obtain f g where hmf: "homeomorphic_map X Y f" and hmg: "homeomorphic_map Y X g"
  2808     and fg: "(\<forall>x \<in> topspace X. g(f x) = x) \<and> (\<forall>y \<in> topspace Y. f(g y) = y)"
  2809     and fg: "\<And>x. x \<in> topspace X \<Longrightarrow> g(f x) = x" "\<And>y. y \<in> topspace Y \<Longrightarrow> f(g y) = y"
  2809     and fim: "f ` (topspace X) = topspace Y" and gim: "g ` (topspace Y) = topspace X"
  2810     and fim: "f \<in> topspace X \<rightarrow> topspace Y" and gim: "g \<in> topspace Y \<rightarrow> topspace X"
  2810     by (smt (verit, best) homXY homeomorphic_imp_surjective_map homeomorphic_maps_map homeomorphic_space_def)
  2811     using homXY
       
  2812     using homeomorphic_space_unfold by blast
  2811   obtain M d where Md: "Metric_space M d" "Metric_space.mcomplete M d" and Xeq: "X = Metric_space.mtopology M d"
  2813   obtain M d where Md: "Metric_space M d" "Metric_space.mcomplete M d" and Xeq: "X = Metric_space.mtopology M d"
  2812     using X by (auto simp: completely_metrizable_space_def)
  2814     using X by (auto simp: completely_metrizable_space_def)
  2813   then interpret MX: Metric_space M d by metis
  2815   then interpret MX: Metric_space M d by metis
  2814   define D where "D \<equiv> \<lambda>x y. d (g x) (g y)"
  2816   define D where "D \<equiv> \<lambda>x y. d (g x) (g y)"
  2815   have "Metric_space (topspace Y) D"
  2817   have "Metric_space (topspace Y) D"
  2816   proof
  2818   proof
  2817     show "(D x y = 0) \<longleftrightarrow> (x = y)" if "x \<in> topspace Y" "y \<in> topspace Y" for x y
  2819     show "(D x y = 0) \<longleftrightarrow> (x = y)" if "x \<in> topspace Y" "y \<in> topspace Y" for x y
  2818       unfolding D_def
  2820       unfolding D_def
  2819       by (metis that MX.topspace_mtopology MX.zero Xeq fg gim imageI)
  2821       by (metis that MX.topspace_mtopology MX.zero Xeq fg gim Pi_iff)
  2820     show "D x z \<le> D x y +D y z"
  2822     show "D x z \<le> D x y +D y z"
  2821       if "x \<in> topspace Y" "y \<in> topspace Y" "z \<in> topspace Y" for x y z
  2823       if "x \<in> topspace Y" "y \<in> topspace Y" "z \<in> topspace Y" for x y z
  2822       using that MX.triangle Xeq gim by (auto simp: D_def)
  2824       using that MX.triangle Xeq gim by (auto simp: D_def)
  2823   qed (auto simp: D_def MX.commute)
  2825   qed (auto simp: D_def MX.commute)
  2824   then interpret MY: Metric_space "topspace Y" "\<lambda>x y. D x y" by metis
  2826   then interpret MY: Metric_space "topspace Y" "\<lambda>x y. D x y" by metis
  2826     unfolding completely_metrizable_space_def
  2828     unfolding completely_metrizable_space_def
  2827   proof (intro exI conjI)
  2829   proof (intro exI conjI)
  2828     show "Metric_space (topspace Y) D"
  2830     show "Metric_space (topspace Y) D"
  2829       using MY.Metric_space_axioms by blast
  2831       using MY.Metric_space_axioms by blast
  2830     have gball: "g ` MY.mball y r = MX.mball (g y) r" if "y \<in> topspace Y" for y r
  2832     have gball: "g ` MY.mball y r = MX.mball (g y) r" if "y \<in> topspace Y" for y r
  2831       using that MX.topspace_mtopology Xeq gim
  2833       using that MX.topspace_mtopology Xeq gim hmg homeomorphic_imp_surjective_map
  2832       unfolding MX.mball_def MY.mball_def by (auto simp: subset_iff image_iff D_def)
  2834       unfolding MX.mball_def MY.mball_def  by (fastforce simp: D_def)
  2833     have "\<exists>r>0. MY.mball y r \<subseteq> S" if "openin Y S" and "y \<in> S" for S y
  2835     have "\<exists>r>0. MY.mball y r \<subseteq> S" if "openin Y S" and "y \<in> S" for S y
  2834     proof -
  2836     proof -
  2835       have "openin X (g`S)"
  2837       have "openin X (g`S)"
  2836         using hmg homeomorphic_map_openness_eq that by auto
  2838         using hmg homeomorphic_map_openness_eq that by auto
  2837       then obtain r where "r>0" "MX.mball (g y) r \<subseteq> g`S"
  2839       then obtain r where "r>0" "MX.mball (g y) r \<subseteq> g`S"
  3781 
  3783 
  3782 subsubsection \<open>Lipschitz continuity\<close>
  3784 subsubsection \<open>Lipschitz continuity\<close>
  3783 
  3785 
  3784 definition Lipschitz_continuous_map 
  3786 definition Lipschitz_continuous_map 
  3785   where "Lipschitz_continuous_map \<equiv> 
  3787   where "Lipschitz_continuous_map \<equiv> 
  3786       \<lambda>m1 m2 f. f ` mspace m1 \<subseteq> mspace m2 \<and>
  3788       \<lambda>m1 m2 f. f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
  3787         (\<exists>B. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y)"
  3789         (\<exists>B. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y)"
  3788 
  3790 
  3789 lemma Lipschitz_continuous_map_image: 
  3791 lemma Lipschitz_continuous_map_image: 
  3790   "Lipschitz_continuous_map m1 m2 f \<Longrightarrow> f ` mspace m1 \<subseteq> mspace m2"
  3792   "Lipschitz_continuous_map m1 m2 f \<Longrightarrow> f \<in> mspace m1 \<rightarrow> mspace m2"
  3791   by (simp add: Lipschitz_continuous_map_def)
  3793   by (simp add: Lipschitz_continuous_map_def)
  3792 
  3794 
  3793 lemma Lipschitz_continuous_map_pos:
  3795 lemma Lipschitz_continuous_map_pos:
  3794    "Lipschitz_continuous_map m1 m2 f \<longleftrightarrow>
  3796    "Lipschitz_continuous_map m1 m2 f \<longleftrightarrow>
  3795     f ` mspace m1 \<subseteq> mspace m2 \<and>
  3797     f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
  3796         (\<exists>B>0. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y)"
  3798         (\<exists>B>0. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y)"
  3797 proof -
  3799 proof -
  3798   have "B * mdist m1 x y \<le> (\<bar>B\<bar> + 1) * mdist m1 x y" "\<bar>B\<bar> + 1 > 0" for x y B
  3800   have "B * mdist m1 x y \<le> (\<bar>B\<bar> + 1) * mdist m1 x y" "\<bar>B\<bar> + 1 > 0" for x y B
  3799     by (auto simp add: mult_right_mono)
  3801     by (auto simp add: mult_right_mono)
  3800   then show ?thesis
  3802   then show ?thesis
  3803 
  3805 
  3804 
  3806 
  3805 lemma Lipschitz_continuous_map_eq:
  3807 lemma Lipschitz_continuous_map_eq:
  3806   assumes "Lipschitz_continuous_map m1 m2 f" "\<And>x. x \<in> mspace m1 \<Longrightarrow> f x = g x"
  3808   assumes "Lipschitz_continuous_map m1 m2 f" "\<And>x. x \<in> mspace m1 \<Longrightarrow> f x = g x"
  3807   shows "Lipschitz_continuous_map m1 m2 g"
  3809   shows "Lipschitz_continuous_map m1 m2 g"
  3808   using Lipschitz_continuous_map_def assms
  3810   using Lipschitz_continuous_map_def assms by (simp add: Lipschitz_continuous_map_pos Pi_iff)
  3809   by (metis (no_types, opaque_lifting) image_subset_iff)
       
  3810 
  3811 
  3811 lemma Lipschitz_continuous_map_from_submetric:
  3812 lemma Lipschitz_continuous_map_from_submetric:
  3812   assumes "Lipschitz_continuous_map m1 m2 f"
  3813   assumes "Lipschitz_continuous_map m1 m2 f"
  3813   shows "Lipschitz_continuous_map (submetric m1 S) m2 f"
  3814   shows "Lipschitz_continuous_map (submetric m1 S) m2 f"
  3814   unfolding Lipschitz_continuous_map_def 
  3815   unfolding Lipschitz_continuous_map_def 
  3815 proof
  3816 proof
  3816   show "f ` mspace (submetric m1 S) \<subseteq> mspace m2"
  3817   show "f \<in> mspace (submetric m1 S) \<rightarrow> mspace m2"
  3817     using Lipschitz_continuous_map_pos assms by fastforce
  3818     using Lipschitz_continuous_map_pos assms by fastforce
  3818 qed (use assms in \<open>fastforce simp: Lipschitz_continuous_map_def\<close>)
  3819 qed (use assms in \<open>fastforce simp: Lipschitz_continuous_map_def\<close>)
  3819 
  3820 
  3820 lemma Lipschitz_continuous_map_from_submetric_mono:
  3821 lemma Lipschitz_continuous_map_from_submetric_mono:
  3821    "\<lbrakk>Lipschitz_continuous_map (submetric m1 T) m2 f; S \<subseteq> T\<rbrakk>
  3822    "\<lbrakk>Lipschitz_continuous_map (submetric m1 T) m2 f; S \<subseteq> T\<rbrakk>
  3822            \<Longrightarrow> Lipschitz_continuous_map (submetric m1 S) m2 f"
  3823            \<Longrightarrow> Lipschitz_continuous_map (submetric m1 S) m2 f"
  3823   by (metis Lipschitz_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
  3824   by (metis Lipschitz_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
  3824 
  3825 
  3825 lemma Lipschitz_continuous_map_into_submetric:
  3826 lemma Lipschitz_continuous_map_into_submetric:
  3826    "Lipschitz_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
  3827    "Lipschitz_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
  3827         f ` mspace m1 \<subseteq> S \<and> Lipschitz_continuous_map m1 m2 f"
  3828         f \<in> mspace m1 \<rightarrow> S \<and> Lipschitz_continuous_map m1 m2 f"
  3828   by (auto simp: Lipschitz_continuous_map_def)
  3829   by (auto simp: Lipschitz_continuous_map_def)
  3829 
  3830 
  3830 lemma Lipschitz_continuous_map_const:
  3831 lemma Lipschitz_continuous_map_const:
  3831   "Lipschitz_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow>
  3832   "Lipschitz_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow>
  3832         mspace m1 = {} \<or> c \<in> mspace m2"
  3833         mspace m1 = {} \<or> c \<in> mspace m2"
  3833   unfolding Lipschitz_continuous_map_def image_subset_iff
  3834   unfolding Lipschitz_continuous_map_def Pi_iff
  3834   by (metis all_not_in_conv mdist_nonneg mdist_zero mult_1)
  3835   by (metis all_not_in_conv mdist_nonneg mdist_zero mult_1)
  3835 
  3836 
  3836 lemma Lipschitz_continuous_map_id:
  3837 lemma Lipschitz_continuous_map_id:
  3837    "Lipschitz_continuous_map m1 m1 (\<lambda>x. x)"
  3838    "Lipschitz_continuous_map m1 m1 (\<lambda>x. x)"
  3838   by (metis Lipschitz_continuous_map_def image_ident mult_1 order_refl)
  3839   unfolding Lipschitz_continuous_map_def by (metis funcset_id mult_1 order_refl)
  3839 
  3840 
  3840 lemma Lipschitz_continuous_map_compose:
  3841 lemma Lipschitz_continuous_map_compose:
  3841   assumes f: "Lipschitz_continuous_map m1 m2 f" and g: "Lipschitz_continuous_map m2 m3 g"
  3842   assumes f: "Lipschitz_continuous_map m1 m2 f" and g: "Lipschitz_continuous_map m2 m3 g"
  3842   shows "Lipschitz_continuous_map m1 m3 (g \<circ> f)"
  3843   shows "Lipschitz_continuous_map m1 m3 (g \<circ> f)"
  3843   unfolding Lipschitz_continuous_map_def image_subset_iff
  3844   unfolding Lipschitz_continuous_map_def 
  3844 proof
  3845 proof
  3845   show "\<forall>x\<in>mspace m1. (g \<circ> f) x \<in> mspace m3"
  3846   show "g \<circ> f \<in> mspace m1 \<rightarrow> mspace m3"
  3846     by (metis Lipschitz_continuous_map_def assms comp_apply image_subset_iff)
  3847     by (smt (verit, best) Lipschitz_continuous_map_image Pi_iff comp_apply f g)
  3847   obtain B where B: "\<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
  3848   obtain B where B: "\<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
  3848     using assms unfolding Lipschitz_continuous_map_def by presburger
  3849     using assms unfolding Lipschitz_continuous_map_def by presburger
  3849   obtain C where "C>0" and C: "\<forall>x\<in>mspace m2. \<forall>y\<in>mspace m2. mdist m3 (g x) (g y) \<le> C * mdist m2 x y"
  3850   obtain C where "C>0" and C: "\<forall>x\<in>mspace m2. \<forall>y\<in>mspace m2. mdist m3 (g x) (g y) \<le> C * mdist m2 x y"
  3850     using assms unfolding Lipschitz_continuous_map_pos by metis
  3851     using assms unfolding Lipschitz_continuous_map_pos by metis
  3851   show "\<exists>B. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> B * mdist m1 x y"
  3852   show "\<exists>B. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> B * mdist m1 x y"
  3852     apply (rule_tac x="C*B" in exI)
  3853   proof (intro strip exI)
  3853   proof clarify
       
  3854     fix x y
  3854     fix x y
  3855     assume \<section>: "x \<in> mspace m1" "y \<in> mspace m1"
  3855     assume \<section>: "x \<in> mspace m1" "y \<in> mspace m1"
  3856     then have "mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> C * mdist m2 (f x) (f y)"
  3856     then have "mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> C * mdist m2 (f x) (f y)"
  3857       by (metis C Lipschitz_continuous_map_def f comp_apply image_subset_iff)
  3857       using C Lipschitz_continuous_map_image f by fastforce
  3858     also have "\<dots> \<le> C * B * mdist m1 x y"
  3858     also have "\<dots> \<le> C * B * mdist m1 x y"
  3859       by (simp add: "\<section>" B \<open>0 < C\<close>)
  3859       by (simp add: "\<section>" B \<open>0 < C\<close>)
  3860     finally show "mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> C * B * mdist m1 x y" .
  3860     finally show "mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> C * B * mdist m1 x y" .
  3861   qed
  3861   qed
  3862 qed
  3862 qed
  3863 
  3863 
  3864 subsubsection \<open>Uniform continuity\<close>
  3864 subsubsection \<open>Uniform continuity\<close>
  3865 
  3865 
  3866 definition uniformly_continuous_map 
  3866 definition uniformly_continuous_map 
  3867   where "uniformly_continuous_map \<equiv> 
  3867   where "uniformly_continuous_map \<equiv> 
  3868       \<lambda>m1 m2 f. f ` mspace m1 \<subseteq> mspace m2 \<and>
  3868       \<lambda>m1 m2 f. f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
  3869         (\<forall>\<epsilon>>0. \<exists>\<delta>>0. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. 
  3869         (\<forall>\<epsilon>>0. \<exists>\<delta>>0. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. 
  3870                            mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>)"
  3870                            mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>)"
  3871 
  3871 
  3872 lemma uniformly_continuous_map_image: 
  3872 lemma uniformly_continuous_map_funspace: 
  3873   "uniformly_continuous_map m1 m2 f \<Longrightarrow> f ` mspace m1 \<subseteq> mspace m2"
  3873   "uniformly_continuous_map m1 m2 f \<Longrightarrow> f \<in> mspace m1 \<rightarrow> mspace m2"
  3874   by (simp add: uniformly_continuous_map_def)
  3874   by (simp add: uniformly_continuous_map_def)
  3875 
  3875 
  3876 lemma ucmap_A:
  3876 lemma ucmap_A:
  3877   assumes "uniformly_continuous_map m1 m2 f"
  3877   assumes "uniformly_continuous_map m1 m2 f"
  3878   and "(\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0"
  3878   and "(\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0"
  3896 
  3896 
  3897 lemma ucmap_C: 
  3897 lemma ucmap_C: 
  3898   assumes \<section>: "\<And>\<rho> \<sigma> \<epsilon>. \<lbrakk>\<epsilon> > 0; range \<rho> \<subseteq> mspace m1; range \<sigma> \<subseteq> mspace m1;
  3898   assumes \<section>: "\<And>\<rho> \<sigma> \<epsilon>. \<lbrakk>\<epsilon> > 0; range \<rho> \<subseteq> mspace m1; range \<sigma> \<subseteq> mspace m1;
  3899                        ((\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0)\<rbrakk>
  3899                        ((\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0)\<rbrakk>
  3900                       \<Longrightarrow> \<exists>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n)) < \<epsilon>"
  3900                       \<Longrightarrow> \<exists>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n)) < \<epsilon>"
  3901     and fim: "f ` mspace m1 \<subseteq> mspace m2"
  3901     and fim: "f \<in> mspace m1 \<rightarrow> mspace m2"
  3902   shows "uniformly_continuous_map m1 m2 f"
  3902   shows "uniformly_continuous_map m1 m2 f"
  3903 proof -
  3903 proof -
  3904   {assume "\<not> (\<forall>\<epsilon>>0. \<exists>\<delta>>0. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>)" 
  3904   {assume "\<not> (\<forall>\<epsilon>>0. \<exists>\<delta>>0. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>)" 
  3905     then obtain \<epsilon> where "\<epsilon> > 0" 
  3905     then obtain \<epsilon> where "\<epsilon> > 0" 
  3906       and "\<And>n. \<exists>x\<in>mspace m1. \<exists>y\<in>mspace m1. mdist m1 y x < inverse(Suc n) \<and> mdist m2 (f y) (f x) \<ge> \<epsilon>"
  3906       and "\<And>n. \<exists>x\<in>mspace m1. \<exists>y\<in>mspace m1. mdist m1 y x < inverse(Suc n) \<and> mdist m2 (f y) (f x) \<ge> \<epsilon>"
  3919     by (fastforce simp: uniformly_continuous_map_def)
  3919     by (fastforce simp: uniformly_continuous_map_def)
  3920 qed
  3920 qed
  3921 
  3921 
  3922 lemma uniformly_continuous_map_sequentially:
  3922 lemma uniformly_continuous_map_sequentially:
  3923   "uniformly_continuous_map m1 m2 f \<longleftrightarrow>
  3923   "uniformly_continuous_map m1 m2 f \<longleftrightarrow>
  3924     f ` mspace m1 \<subseteq> mspace m2 \<and>
  3924     f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
  3925     (\<forall>\<rho> \<sigma>. range \<rho> \<subseteq> mspace m1 \<and> range \<sigma> \<subseteq> mspace m1 \<and> (\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0
  3925     (\<forall>\<rho> \<sigma>. range \<rho> \<subseteq> mspace m1 \<and> range \<sigma> \<subseteq> mspace m1 \<and> (\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0
  3926           \<longrightarrow> (\<lambda>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n))) \<longlonglongrightarrow> 0)"
  3926           \<longrightarrow> (\<lambda>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n))) \<longlonglongrightarrow> 0)"
  3927    (is "?lhs \<longleftrightarrow> ?rhs")
  3927    (is "?lhs \<longleftrightarrow> ?rhs")
  3928 proof
  3928 proof
  3929   show "?lhs \<Longrightarrow> ?rhs"
  3929   show "?lhs \<Longrightarrow> ?rhs"
  3930     by (simp add: ucmap_A uniformly_continuous_map_image)
  3930     by (simp add: ucmap_A uniformly_continuous_map_funspace)
  3931   show "?rhs \<Longrightarrow> ?lhs"
  3931   show "?rhs \<Longrightarrow> ?lhs"
  3932     by (intro ucmap_B ucmap_C) auto
  3932     by (intro ucmap_B ucmap_C) auto
  3933 qed
  3933 qed
  3934 
  3934 
  3935 
  3935 
  3936 lemma uniformly_continuous_map_sequentially_alt:
  3936 lemma uniformly_continuous_map_sequentially_alt:
  3937     "uniformly_continuous_map m1 m2 f \<longleftrightarrow>
  3937     "uniformly_continuous_map m1 m2 f \<longleftrightarrow>
  3938       f ` mspace m1 \<subseteq> mspace m2 \<and>
  3938       f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
  3939       (\<forall>\<epsilon>>0. \<forall>\<rho> \<sigma>. range \<rho> \<subseteq> mspace m1 \<and> range \<sigma> \<subseteq> mspace m1 \<and>
  3939       (\<forall>\<epsilon>>0. \<forall>\<rho> \<sigma>. range \<rho> \<subseteq> mspace m1 \<and> range \<sigma> \<subseteq> mspace m1 \<and>
  3940             ((\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0)
  3940             ((\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0)
  3941             \<longrightarrow> (\<exists>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n)) < \<epsilon>))"
  3941             \<longrightarrow> (\<exists>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n)) < \<epsilon>))"
  3942    (is "?lhs \<longleftrightarrow> ?rhs")
  3942    (is "?lhs \<longleftrightarrow> ?rhs")
  3943 proof
  3943 proof
  3944   show "?lhs \<Longrightarrow> ?rhs"
  3944   show "?lhs \<Longrightarrow> ?rhs"
  3945     using uniformly_continuous_map_image by (intro conjI strip ucmap_B | force simp: ucmap_A)+
  3945     using uniformly_continuous_map_funspace by (intro conjI strip ucmap_B | fastforce simp: ucmap_A)+
  3946   show "?rhs \<Longrightarrow> ?lhs"
  3946   show "?rhs \<Longrightarrow> ?lhs"
  3947     by (intro ucmap_C) auto
  3947     by (intro ucmap_C) auto
  3948 qed
  3948 qed
  3949 
  3949 
  3950 
  3950 
  3951 lemma uniformly_continuous_map_eq:
  3951 lemma uniformly_continuous_map_eq:
  3952    "\<lbrakk>\<And>x. x \<in> mspace m1 \<Longrightarrow> f x = g x; uniformly_continuous_map m1 m2 f\<rbrakk>
  3952    "\<lbrakk>\<And>x. x \<in> mspace m1 \<Longrightarrow> f x = g x; uniformly_continuous_map m1 m2 f\<rbrakk>
  3953       \<Longrightarrow> uniformly_continuous_map m1 m2 g"
  3953       \<Longrightarrow> uniformly_continuous_map m1 m2 g"
  3954   by (simp add: uniformly_continuous_map_def)
  3954   by (simp add: uniformly_continuous_map_def Pi_iff)
  3955 
  3955 
  3956 lemma uniformly_continuous_map_from_submetric:
  3956 lemma uniformly_continuous_map_from_submetric:
  3957   assumes "uniformly_continuous_map m1 m2 f"
  3957   assumes "uniformly_continuous_map m1 m2 f"
  3958   shows "uniformly_continuous_map (submetric m1 S) m2 f"
  3958   shows "uniformly_continuous_map (submetric m1 S) m2 f"
  3959   unfolding uniformly_continuous_map_def 
  3959   unfolding uniformly_continuous_map_def 
  3960 proof
  3960 proof
  3961   show "f ` mspace (submetric m1 S) \<subseteq> mspace m2"
  3961   show "f \<in> mspace (submetric m1 S) \<rightarrow> mspace m2"
  3962     using assms by (auto simp: uniformly_continuous_map_def)
  3962     using assms by (auto simp: uniformly_continuous_map_def)
  3963 qed (use assms in \<open>force simp: uniformly_continuous_map_def\<close>)
  3963 qed (use assms in \<open>force simp: uniformly_continuous_map_def\<close>)
  3964 
  3964 
  3965 lemma uniformly_continuous_map_from_submetric_mono:
  3965 lemma uniformly_continuous_map_from_submetric_mono:
  3966    "\<lbrakk>uniformly_continuous_map (submetric m1 T) m2 f; S \<subseteq> T\<rbrakk>
  3966    "\<lbrakk>uniformly_continuous_map (submetric m1 T) m2 f; S \<subseteq> T\<rbrakk>
  3967            \<Longrightarrow> uniformly_continuous_map (submetric m1 S) m2 f"
  3967            \<Longrightarrow> uniformly_continuous_map (submetric m1 S) m2 f"
  3968   by (metis uniformly_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
  3968   by (metis uniformly_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
  3969 
  3969 
  3970 lemma uniformly_continuous_map_into_submetric:
  3970 lemma uniformly_continuous_map_into_submetric:
  3971    "uniformly_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
  3971    "uniformly_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
  3972         f ` mspace m1 \<subseteq> S \<and> uniformly_continuous_map m1 m2 f"
  3972         f \<in> mspace m1 \<rightarrow> S \<and> uniformly_continuous_map m1 m2 f"
  3973   by (auto simp: uniformly_continuous_map_def)
  3973   by (auto simp: uniformly_continuous_map_def)
  3974 
  3974 
  3975 lemma uniformly_continuous_map_const:
  3975 lemma uniformly_continuous_map_const:
  3976   "uniformly_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow>
  3976   "uniformly_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow>
  3977         mspace m1 = {} \<or> c \<in> mspace m2"
  3977         mspace m1 = {} \<or> c \<in> mspace m2"
  3978   unfolding uniformly_continuous_map_def image_subset_iff
  3978   unfolding uniformly_continuous_map_def Pi_iff
  3979   by (metis empty_iff equals0I mdist_zero)
  3979   by (metis empty_iff equals0I mdist_zero)
  3980 
  3980 
  3981 lemma uniformly_continuous_map_id [simp]:
  3981 lemma uniformly_continuous_map_id [simp]:
  3982    "uniformly_continuous_map m1 m1 (\<lambda>x. x)"
  3982    "uniformly_continuous_map m1 m1 (\<lambda>x. x)"
  3983   by (metis image_ident order_refl uniformly_continuous_map_def)
  3983   by (metis funcset_id uniformly_continuous_map_def)
  3984 
  3984 
  3985 lemma uniformly_continuous_map_compose:
  3985 lemma uniformly_continuous_map_compose:
  3986   assumes f: "uniformly_continuous_map m1 m2 f" and g: "uniformly_continuous_map m2 m3 g"
  3986   assumes f: "uniformly_continuous_map m1 m2 f" and g: "uniformly_continuous_map m2 m3 g"
  3987   shows "uniformly_continuous_map m1 m3 (g \<circ> f)"
  3987   shows "uniformly_continuous_map m1 m3 (g \<circ> f)"
  3988   by (smt (verit, ccfv_threshold) comp_apply f g image_subset_iff uniformly_continuous_map_def)
  3988   by (smt (verit, ccfv_threshold) comp_apply f g Pi_iff uniformly_continuous_map_def)
  3989 
  3989 
  3990 lemma uniformly_continuous_map_real_const [simp]:
  3990 lemma uniformly_continuous_map_real_const [simp]:
  3991    "uniformly_continuous_map m euclidean_metric (\<lambda>x. c)"
  3991    "uniformly_continuous_map m euclidean_metric (\<lambda>x. c)"
  3992   by (simp add: euclidean_metric_def uniformly_continuous_map_const)
  3992   by (simp add: euclidean_metric_def uniformly_continuous_map_const)
  3993 
  3993 
  4007 lemma Cauchy_continuous_map_euclidean [simp]:
  4007 lemma Cauchy_continuous_map_euclidean [simp]:
  4008   "Cauchy_continuous_map (submetric euclidean_metric S) euclidean_metric f
  4008   "Cauchy_continuous_map (submetric euclidean_metric S) euclidean_metric f
  4009      = Cauchy_continuous_on S f"
  4009      = Cauchy_continuous_on S f"
  4010   by (auto simp add: Cauchy_continuous_map_def Cauchy_continuous_on_def Cauchy_def Met_TC.subspace Metric_space.MCauchy_def)
  4010   by (auto simp add: Cauchy_continuous_map_def Cauchy_continuous_on_def Cauchy_def Met_TC.subspace Metric_space.MCauchy_def)
  4011 
  4011 
  4012 lemma Cauchy_continuous_map_image:
  4012 lemma Cauchy_continuous_map_funspace:
  4013   assumes "Cauchy_continuous_map m1 m2 f"
  4013   assumes "Cauchy_continuous_map m1 m2 f"
  4014   shows "f ` mspace m1 \<subseteq> mspace m2"
  4014   shows "f \<in> mspace m1 \<rightarrow> mspace m2"
  4015 proof clarsimp
  4015 proof clarsimp
  4016   fix x
  4016   fix x
  4017   assume "x \<in> mspace m1"
  4017   assume "x \<in> mspace m1"
  4018   then have "Metric_space.MCauchy (mspace m1) (mdist m1) (\<lambda>n. x)"
  4018   then have "Metric_space.MCauchy (mspace m1) (mdist m1) (\<lambda>n. x)"
  4019     by (simp add: Metric_space.MCauchy_const Metric_space_mspace_mdist)
  4019     by (simp add: Metric_space.MCauchy_const Metric_space_mspace_mdist)
  4040            \<Longrightarrow> Cauchy_continuous_map (submetric m1 S) m2 f"
  4040            \<Longrightarrow> Cauchy_continuous_map (submetric m1 S) m2 f"
  4041   by (metis Cauchy_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
  4041   by (metis Cauchy_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
  4042 
  4042 
  4043 lemma Cauchy_continuous_map_into_submetric:
  4043 lemma Cauchy_continuous_map_into_submetric:
  4044    "Cauchy_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
  4044    "Cauchy_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
  4045    f ` mspace m1 \<subseteq> S \<and> Cauchy_continuous_map m1 m2 f"  (is "?lhs \<longleftrightarrow> ?rhs")
  4045    f \<in> mspace m1 \<rightarrow> S \<and> Cauchy_continuous_map m1 m2 f"  (is "?lhs \<longleftrightarrow> ?rhs")
  4046 proof -
  4046 proof -
  4047   have "?lhs \<Longrightarrow> Cauchy_continuous_map m1 m2 f"
  4047   have "?lhs \<Longrightarrow> Cauchy_continuous_map m1 m2 f"
  4048     by (simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
  4048     by (simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
  4049   moreover have "?rhs \<Longrightarrow> ?lhs"
  4049   moreover have "?rhs \<Longrightarrow> ?lhs"
  4050     by (bestsimp simp add: Cauchy_continuous_map_def  Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
  4050     by (auto simp: Cauchy_continuous_map_def  Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
  4051   ultimately show ?thesis
  4051   ultimately show ?thesis
  4052     by (metis Cauchy_continuous_map_image le_inf_iff mspace_submetric)
  4052     by (metis Cauchy_continuous_map_funspace Int_iff funcsetI funcset_mem mspace_submetric)
  4053 qed
  4053 qed
  4054 
  4054 
  4055 lemma Cauchy_continuous_map_const [simp]:
  4055 lemma Cauchy_continuous_map_const [simp]:
  4056   "Cauchy_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow> mspace m1 = {} \<or> c \<in> mspace m2"
  4056   "Cauchy_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow> mspace m1 = {} \<or> c \<in> mspace m2"
  4057 proof -
  4057 proof -
  4058    have "mspace m1 = {} \<Longrightarrow> Cauchy_continuous_map m1 m2 (\<lambda>x. c)"
  4058    have "mspace m1 = {} \<Longrightarrow> Cauchy_continuous_map m1 m2 (\<lambda>x. c)"
  4059     by (simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def Metric_space_mspace_mdist)
  4059     by (simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def Metric_space_mspace_mdist)
  4060   moreover have "c \<in> mspace m2 \<Longrightarrow> Cauchy_continuous_map m1 m2 (\<lambda>x. c)"
  4060   moreover have "c \<in> mspace m2 \<Longrightarrow> Cauchy_continuous_map m1 m2 (\<lambda>x. c)"
  4061     by (simp add: Cauchy_continuous_map_def o_def Metric_space.MCauchy_const [OF Metric_space_mspace_mdist])
  4061     by (simp add: Cauchy_continuous_map_def o_def Metric_space.MCauchy_const [OF Metric_space_mspace_mdist])
  4062   ultimately show ?thesis
  4062   ultimately show ?thesis
  4063     using Cauchy_continuous_map_image by blast
  4063     using Cauchy_continuous_map_funspace by blast
  4064 qed
  4064 qed
  4065 
  4065 
  4066 lemma Cauchy_continuous_map_id [simp]:
  4066 lemma Cauchy_continuous_map_id [simp]:
  4067    "Cauchy_continuous_map m1 m1 (\<lambda>x. x)"
  4067    "Cauchy_continuous_map m1 m1 (\<lambda>x. x)"
  4068   by (simp add: Cauchy_continuous_map_def o_def)
  4068   by (simp add: Cauchy_continuous_map_def o_def)
  4074 
  4074 
  4075 lemma Lipschitz_imp_uniformly_continuous_map:
  4075 lemma Lipschitz_imp_uniformly_continuous_map:
  4076   assumes "Lipschitz_continuous_map m1 m2 f"
  4076   assumes "Lipschitz_continuous_map m1 m2 f"
  4077   shows "uniformly_continuous_map m1 m2 f"
  4077   shows "uniformly_continuous_map m1 m2 f"
  4078   proof -
  4078   proof -
  4079   have "f ` mspace m1 \<subseteq> mspace m2"
  4079   have "f \<in> mspace m1 \<rightarrow> mspace m2"
  4080     by (simp add: Lipschitz_continuous_map_image assms)
  4080     by (simp add: Lipschitz_continuous_map_image assms)
  4081   moreover have "\<exists>\<delta>>0. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>"
  4081   moreover have "\<exists>\<delta>>0. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>"
  4082     if "\<epsilon> > 0" for \<epsilon>
  4082     if "\<epsilon> > 0" for \<epsilon>
  4083   proof -
  4083   proof -
  4084     obtain B where "\<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
  4084     obtain B where "\<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
  4095 
  4095 
  4096 lemma uniformly_imp_Cauchy_continuous_map:
  4096 lemma uniformly_imp_Cauchy_continuous_map:
  4097    "uniformly_continuous_map m1 m2 f \<Longrightarrow> Cauchy_continuous_map m1 m2 f"
  4097    "uniformly_continuous_map m1 m2 f \<Longrightarrow> Cauchy_continuous_map m1 m2 f"
  4098   unfolding uniformly_continuous_map_def Cauchy_continuous_map_def
  4098   unfolding uniformly_continuous_map_def Cauchy_continuous_map_def
  4099   apply (simp add: image_subset_iff o_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
  4099   apply (simp add: image_subset_iff o_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
  4100   by meson
  4100   by (metis funcset_mem)
  4101 
  4101 
  4102 lemma locally_Cauchy_continuous_map:
  4102 lemma locally_Cauchy_continuous_map:
  4103   assumes "\<epsilon> > 0"
  4103   assumes "\<epsilon> > 0"
  4104     and \<section>: "\<And>x. x \<in> mspace m1 \<Longrightarrow> Cauchy_continuous_map (submetric m1 (mball_of m1 x \<epsilon>)) m2 f"
  4104     and \<section>: "\<And>x. x \<in> mspace m1 \<Longrightarrow> Cauchy_continuous_map (submetric m1 (mball_of m1 x \<epsilon>)) m2 f"
  4105   shows "Cauchy_continuous_map m1 m2 f"
  4105   shows "Cauchy_continuous_map m1 m2 f"
  4135     have "\<sigma> n \<in> mspace m1"
  4135     have "\<sigma> n \<in> mspace m1"
  4136       by (meson Metric_space.MCauchy_def Metric_space_mspace_mdist \<sigma> range_subsetD)
  4136       by (meson Metric_space.MCauchy_def Metric_space_mspace_mdist \<sigma> range_subsetD)
  4137     then have "\<sigma> n \<in> mball_of m1 (\<sigma> n) \<epsilon>"
  4137     then have "\<sigma> n \<in> mball_of m1 (\<sigma> n) \<epsilon>"
  4138       by (simp add: Metric_space.centre_in_mball_iff Metric_space_mspace_mdist assms(1) mball_of_def)
  4138       by (simp add: Metric_space.centre_in_mball_iff Metric_space_mspace_mdist assms(1) mball_of_def)
  4139     then show "(f \<circ> \<sigma>) n \<in> mspace m2"
  4139     then show "(f \<circ> \<sigma>) n \<in> mspace m2"
  4140       using Cauchy_continuous_map_image [OF \<section> [of "\<sigma> n"]] \<open>\<sigma> n \<in> mspace m1\<close> by auto
  4140       using Cauchy_continuous_map_funspace [OF \<section> [of "\<sigma> n"]] \<open>\<sigma> n \<in> mspace m1\<close> by auto
  4141   qed
  4141   qed
  4142 qed
  4142 qed
  4143 
  4143 
  4144 context Metric_space12
  4144 context Metric_space12
  4145 begin
  4145 begin
  4152   assume "x \<in> M1"
  4152   assume "x \<in> M1"
  4153   show "limitin M2.mtopology f (f x) (atin M1.mtopology x)"
  4153   show "limitin M2.mtopology f (f x) (atin M1.mtopology x)"
  4154     unfolding limit_atin_sequentially
  4154     unfolding limit_atin_sequentially
  4155   proof (intro conjI strip)
  4155   proof (intro conjI strip)
  4156     show "f x \<in> M2"
  4156     show "f x \<in> M2"
  4157       using Cauchy_continuous_map_image \<open>x \<in> M1\<close> assms by fastforce
  4157       using Cauchy_continuous_map_funspace \<open>x \<in> M1\<close> assms by fastforce
  4158     fix \<sigma>
  4158     fix \<sigma>
  4159     assume "range \<sigma> \<subseteq> M1 - {x} \<and> limitin M1.mtopology \<sigma> x sequentially"
  4159     assume "range \<sigma> \<subseteq> M1 - {x} \<and> limitin M1.mtopology \<sigma> x sequentially"
  4160     then have "M1.MCauchy (\<lambda>n. if even n then \<sigma> (n div 2) else x)"
  4160     then have "M1.MCauchy (\<lambda>n. if even n then \<sigma> (n div 2) else x)"
  4161       by (force simp add: M1.MCauchy_interleaving)
  4161       by (force simp add: M1.MCauchy_interleaving)
  4162     then have "M2.MCauchy (f \<circ> (\<lambda>n. if even n then \<sigma> (n div 2) else x))"
  4162     then have "M2.MCauchy (f \<circ> (\<lambda>n. if even n then \<sigma> (n div 2) else x))"
  4219   assumes f: "Cauchy_continuous_map m1 m2 f"
  4219   assumes f: "Cauchy_continuous_map m1 m2 f"
  4220     and tbo: "Metric_space.mtotally_bounded (mspace m1) (mdist m1) (mspace m1)"
  4220     and tbo: "Metric_space.mtotally_bounded (mspace m1) (mdist m1) (mspace m1)"
  4221   shows "uniformly_continuous_map m1 m2 f"
  4221   shows "uniformly_continuous_map m1 m2 f"
  4222   unfolding uniformly_continuous_map_sequentially_alt imp_conjL
  4222   unfolding uniformly_continuous_map_sequentially_alt imp_conjL
  4223 proof (intro conjI strip)
  4223 proof (intro conjI strip)
  4224   show "f ` mspace m1 \<subseteq> mspace m2"
  4224   show "f \<in> mspace m1 \<rightarrow> mspace m2"
  4225     by (simp add: Cauchy_continuous_map_image f)
  4225     by (simp add: Cauchy_continuous_map_funspace f)
  4226   interpret M1: Metric_space "mspace m1" "mdist m1"
  4226   interpret M1: Metric_space "mspace m1" "mdist m1"
  4227     by (simp add: Metric_space_mspace_mdist)
  4227     by (simp add: Metric_space_mspace_mdist)
  4228   interpret M2: Metric_space "mspace m2" "mdist m2"
  4228   interpret M2: Metric_space "mspace m2" "mdist m2"
  4229     by (simp add: Metric_space_mspace_mdist)
  4229     by (simp add: Metric_space_mspace_mdist)
  4230   fix \<epsilon> :: real and \<rho> \<sigma> 
  4230   fix \<epsilon> :: real and \<rho> \<sigma> 
  4284   using Cauchy_imp_uniformly_continuous_map uniformly_imp_Cauchy_continuous_map by blast
  4284   using Cauchy_imp_uniformly_continuous_map uniformly_imp_Cauchy_continuous_map by blast
  4285 
  4285 
  4286 lemma Lipschitz_continuous_map_projections:
  4286 lemma Lipschitz_continuous_map_projections:
  4287   "Lipschitz_continuous_map (prod_metric m1 m2) m1 fst"
  4287   "Lipschitz_continuous_map (prod_metric m1 m2) m1 fst"
  4288   "Lipschitz_continuous_map (prod_metric m1 m2) m2 snd"
  4288   "Lipschitz_continuous_map (prod_metric m1 m2) m2 snd"
  4289   by (simp add: Lipschitz_continuous_map_def prod_dist_def; 
  4289   by (simp add: Lipschitz_continuous_map_def prod_dist_def fst_Pi snd_Pi; 
  4290       metis mult_numeral_1 real_sqrt_sum_squares_ge1 real_sqrt_sum_squares_ge2)+
  4290       metis mult_numeral_1 real_sqrt_sum_squares_ge1 real_sqrt_sum_squares_ge2)+
  4291 
  4291 
  4292 lemma Lipschitz_continuous_map_pairwise:
  4292 lemma Lipschitz_continuous_map_pairwise:
  4293    "Lipschitz_continuous_map m (prod_metric m1 m2) f \<longleftrightarrow>
  4293    "Lipschitz_continuous_map m (prod_metric m1 m2) f \<longleftrightarrow>
  4294     Lipschitz_continuous_map m m1 (fst \<circ> f) \<and> Lipschitz_continuous_map m m2 (snd \<circ> f)"
  4294     Lipschitz_continuous_map m m1 (fst \<circ> f) \<and> Lipschitz_continuous_map m m2 (snd \<circ> f)"
  4306       and B2: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m\<rbrakk> \<Longrightarrow> mdist m2 (f2 x) (f2 y) \<le> B2 * mdist m x y"
  4306       and B2: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m\<rbrakk> \<Longrightarrow> mdist m2 (f2 x) (f2 y) \<le> B2 * mdist m x y"
  4307       by (meson Lipschitz_continuous_map_pos f2)
  4307       by (meson Lipschitz_continuous_map_pos f2)
  4308     show ?thesis
  4308     show ?thesis
  4309       unfolding Lipschitz_continuous_map_pos
  4309       unfolding Lipschitz_continuous_map_pos
  4310     proof (intro exI conjI strip)
  4310     proof (intro exI conjI strip)
  4311       have f1im: "f1 ` mspace m \<subseteq> mspace m1"
  4311       have f1im: "f1 \<in> mspace m \<rightarrow> mspace m1"
  4312         by (simp add: Lipschitz_continuous_map_image f1)
  4312         by (simp add: Lipschitz_continuous_map_image f1)
  4313       moreover have f2im: "f2 ` mspace m \<subseteq> mspace m2"
  4313       moreover have f2im: "f2 \<in> mspace m \<rightarrow> mspace m2"
  4314         by (simp add: Lipschitz_continuous_map_image f2)
  4314         by (simp add: Lipschitz_continuous_map_image f2)
  4315       ultimately show "(\<lambda>x. (f1 x, f2 x)) ` mspace m \<subseteq> mspace (prod_metric m1 m2)"
  4315       ultimately show "(\<lambda>x. (f1 x, f2 x)) \<in> mspace m \<rightarrow> mspace (prod_metric m1 m2)"
  4316         by auto
  4316         by auto
  4317       show "B1+B2 > 0"
  4317       show "B1+B2 > 0"
  4318         using \<open>0 < B1\<close> \<open>0 < B2\<close> by linarith
  4318         using \<open>0 < B1\<close> \<open>0 < B2\<close> by linarith
  4319       fix x y
  4319       fix x y
  4320       assume xy: "x \<in> mspace m" "y \<in> mspace m"
  4320       assume xy: "x \<in> mspace m" "y \<in> mspace m"
  4341     if f1: "uniformly_continuous_map m m1 f1" and f2: "uniformly_continuous_map m m2 f2" for f1 f2
  4341     if f1: "uniformly_continuous_map m m1 f1" and f2: "uniformly_continuous_map m m2 f2" for f1 f2
  4342   proof -
  4342   proof -
  4343     show ?thesis
  4343     show ?thesis
  4344       unfolding uniformly_continuous_map_def
  4344       unfolding uniformly_continuous_map_def
  4345     proof (intro conjI strip)
  4345     proof (intro conjI strip)
  4346       have f1im: "f1 ` mspace m \<subseteq> mspace m1"
  4346       have f1im: "f1 \<in> mspace m \<rightarrow> mspace m1"
  4347         by (simp add: uniformly_continuous_map_image f1)
  4347         by (simp add: uniformly_continuous_map_funspace f1)
  4348       moreover have f2im: "f2 ` mspace m \<subseteq> mspace m2"
  4348       moreover have f2im: "f2 \<in> mspace m \<rightarrow> mspace m2"
  4349         by (simp add: uniformly_continuous_map_image f2)
  4349         by (simp add: uniformly_continuous_map_funspace f2)
  4350       ultimately show "(\<lambda>x. (f1 x, f2 x)) ` mspace m \<subseteq> mspace (prod_metric m1 m2)"
  4350       ultimately show "(\<lambda>x. (f1 x, f2 x)) \<in> mspace m \<rightarrow> mspace (prod_metric m1 m2)"
  4351         by auto
  4351         by auto
  4352       fix \<epsilon>:: real
  4352       fix \<epsilon>:: real
  4353       assume "\<epsilon> > 0"
  4353       assume "\<epsilon> > 0"
  4354       obtain \<delta>1 where "\<delta>1>0" 
  4354       obtain \<delta>1 where "\<delta>1>0" 
  4355         and \<delta>1: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m; mdist m y x < \<delta>1\<rbrakk> \<Longrightarrow> mdist m1 (f1 y) (f1 x) < \<epsilon>/2"
  4355         and \<delta>1: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m; mdist m y x < \<delta>1\<rbrakk> \<Longrightarrow> mdist m1 (f1 y) (f1 x) < \<epsilon>/2"
  4400 
  4400 
  4401 lemma mbounded_Lipschitz_continuous_image:
  4401 lemma mbounded_Lipschitz_continuous_image:
  4402   assumes f: "Lipschitz_continuous_map m1 m2 f" and S: "Metric_space.mbounded (mspace m1) (mdist m1) S"
  4402   assumes f: "Lipschitz_continuous_map m1 m2 f" and S: "Metric_space.mbounded (mspace m1) (mdist m1) S"
  4403   shows "Metric_space.mbounded (mspace m2) (mdist m2) (f`S)"
  4403   shows "Metric_space.mbounded (mspace m2) (mdist m2) (f`S)"
  4404 proof -
  4404 proof -
  4405   obtain B where fim: "f ` mspace m1 \<subseteq> mspace m2"
  4405   obtain B where fim: "f \<in> mspace m1 \<rightarrow> mspace m2"
  4406     and "B>0" and B: "\<And>x y. \<lbrakk>x \<in> mspace m1; y \<in> mspace m1\<rbrakk> \<Longrightarrow> mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
  4406     and "B>0" and B: "\<And>x y. \<lbrakk>x \<in> mspace m1; y \<in> mspace m1\<rbrakk> \<Longrightarrow> mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
  4407     by (meson Lipschitz_continuous_map_pos f)
  4407     by (metis Lipschitz_continuous_map_pos f)
  4408   show ?thesis
  4408   show ?thesis
  4409     unfolding Metric_space.mbounded_alt_pos [OF Metric_space_mspace_mdist]
  4409     unfolding Metric_space.mbounded_alt_pos [OF Metric_space_mspace_mdist]
  4410   proof
  4410   proof
  4411     obtain C where "S \<subseteq> mspace m1" and "C>0" and C: "\<And>x y. \<lbrakk>x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> mdist m1 x y \<le> C"
  4411     obtain C where "S \<subseteq> mspace m1" and "C>0" and C: "\<And>x y. \<lbrakk>x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> mdist m1 x y \<le> C"
  4412       using S by (auto simp: Metric_space.mbounded_alt_pos [OF Metric_space_mspace_mdist])
  4412       using S by (auto simp: Metric_space.mbounded_alt_pos [OF Metric_space_mspace_mdist])
  4427   unfolding Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist]
  4427   unfolding Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist]
  4428 proof (intro conjI strip)
  4428 proof (intro conjI strip)
  4429   have "S \<subseteq> mspace m1"
  4429   have "S \<subseteq> mspace m1"
  4430     using S by (simp add: Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist])
  4430     using S by (simp add: Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist])
  4431   then show "f ` S \<subseteq> mspace m2"
  4431   then show "f ` S \<subseteq> mspace m2"
  4432     using Cauchy_continuous_map_image f by blast
  4432     using Cauchy_continuous_map_funspace f by blast
  4433   fix \<sigma> :: "nat \<Rightarrow> 'b"
  4433   fix \<sigma> :: "nat \<Rightarrow> 'b"
  4434   assume "range \<sigma> \<subseteq> f ` S"
  4434   assume "range \<sigma> \<subseteq> f ` S"
  4435   then have "\<forall>n. \<exists>x. \<sigma> n = f x \<and> x \<in> S"
  4435   then have "\<forall>n. \<exists>x. \<sigma> n = f x \<and> x \<in> S"
  4436     by (meson imageE range_subsetD)
  4436     by (meson imageE range_subsetD)
  4437   then obtain \<rho> where \<rho>: "\<And>n. \<sigma> n = f (\<rho> n)" "range \<rho> \<subseteq> S"
  4437   then obtain \<rho> where \<rho>: "\<And>n. \<sigma> n = f (\<rho> n)" "range \<rho> \<subseteq> S"
  4446     using \<open>\<sigma> = f \<circ> \<rho>\<close> \<open>strict_mono r\<close> by blast
  4446     using \<open>\<sigma> = f \<circ> \<rho>\<close> \<open>strict_mono r\<close> by blast
  4447 qed
  4447 qed
  4448 
  4448 
  4449 lemma Lipschitz_coefficient_pos:
  4449 lemma Lipschitz_coefficient_pos:
  4450   assumes "x \<in> mspace m" "y \<in> mspace m" "f x \<noteq> f y" 
  4450   assumes "x \<in> mspace m" "y \<in> mspace m" "f x \<noteq> f y" 
  4451     and "f ` mspace m \<subseteq> mspace m2" 
  4451     and "f \<in> mspace m \<rightarrow> mspace m2" 
  4452     and "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m\<rbrakk>
  4452     and "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m\<rbrakk>
  4453             \<Longrightarrow> mdist m2 (f x) (f y) \<le> k * mdist m x y"
  4453             \<Longrightarrow> mdist m2 (f x) (f y) \<le> k * mdist m x y"
  4454   shows  "0 < k"
  4454   shows  "0 < k"
  4455   using assms by (smt (verit, best) image_subset_iff mdist_nonneg mdist_zero mult_nonpos_nonneg)
  4455   using assms by (smt (verit, best) Pi_iff mdist_nonneg mdist_zero mult_nonpos_nonneg)
  4456 
  4456 
  4457 lemma Lipschitz_continuous_map_metric:
  4457 lemma Lipschitz_continuous_map_metric:
  4458    "Lipschitz_continuous_map (prod_metric m m) euclidean_metric (\<lambda>(x,y). mdist m x y)"
  4458    "Lipschitz_continuous_map (prod_metric m m) euclidean_metric (\<lambda>(x,y). mdist m x y)"
  4459 proof -
  4459 proof -
  4460   have "\<And>x y x' y'. \<lbrakk>x \<in> mspace m; y \<in> mspace m; x' \<in> mspace m; y' \<in> mspace m\<rbrakk>
  4460   have "\<And>x y x' y'. \<lbrakk>x \<in> mspace m; y \<in> mspace m; x' \<in> mspace m; y' \<in> mspace m\<rbrakk>
  4561   by (simp add: continuous_map_mdist)
  4561   by (simp add: continuous_map_mdist)
  4562 
  4562 
  4563 subsection \<open>Isometries\<close>
  4563 subsection \<open>Isometries\<close>
  4564 
  4564 
  4565 lemma (in Metric_space12) isometry_imp_embedding_map:
  4565 lemma (in Metric_space12) isometry_imp_embedding_map:
  4566   assumes fim: "f ` M1 \<subseteq> M2" and d: "\<And>x y. \<lbrakk>x \<in> M1; y \<in> M1\<rbrakk> \<Longrightarrow> d2 (f x) (f y) = d1 x y"
  4566   assumes fim: "f \<in> M1 \<rightarrow> M2" and d: "\<And>x y. \<lbrakk>x \<in> M1; y \<in> M1\<rbrakk> \<Longrightarrow> d2 (f x) (f y) = d1 x y"
  4567   shows "embedding_map M1.mtopology M2.mtopology f"
  4567   shows "embedding_map M1.mtopology M2.mtopology f"
  4568 proof -
  4568 proof -
  4569   have "inj_on f M1"
  4569   have "inj_on f M1"
  4570     by (metis M1.zero d inj_onI)
  4570     by (metis M1.zero d inj_onI)
  4571   then obtain g where g: "\<And>x. x \<in> M1 \<Longrightarrow> g (f x) = x"
  4571   then obtain g where g: "\<And>x. x \<in> M1 \<Longrightarrow> g (f x) = x"
  4572     by (metis inv_into_f_f)
  4572     by (metis inv_into_f_f)
  4573   have "homeomorphic_maps M1.mtopology (subtopology M2.mtopology (f ` topspace M1.mtopology)) f g"
  4573   have "homeomorphic_maps M1.mtopology (subtopology M2.mtopology (f ` topspace M1.mtopology)) f g"
  4574     unfolding homeomorphic_maps_def
  4574     unfolding homeomorphic_maps_def
  4575   proof (intro conjI; clarsimp)
  4575   proof (intro conjI; clarsimp)
  4576     show "continuous_map M1.mtopology (subtopology M2.mtopology (f ` M1)) f"
  4576     show "continuous_map M1.mtopology (subtopology M2.mtopology (f ` M1)) f"
  4577       by (metis M1.metric_continuous_map M1.topspace_mtopology M2.Metric_space_axioms continuous_map_into_subtopology d fim order_refl)
  4577     proof (rule continuous_map_into_subtopology)
       
  4578       show "continuous_map M1.mtopology M2.mtopology f"
       
  4579         by (metis M1.metric_continuous_map M2.Metric_space_axioms d fim image_subset_iff_funcset)
       
  4580     qed simp
  4578     have "Lipschitz_continuous_map (submetric (metric(M2,d2)) (f ` M1)) (metric(M1,d1)) g"
  4581     have "Lipschitz_continuous_map (submetric (metric(M2,d2)) (f ` M1)) (metric(M1,d1)) g"
  4579       unfolding Lipschitz_continuous_map_def
  4582       unfolding Lipschitz_continuous_map_def
  4580     proof (intro conjI exI strip; simp)
  4583     proof (intro conjI exI strip; simp)
  4581       show "d1 (g x) (g y) \<le> 1 * d2 x y" if "x \<in> f ` M1 \<and> x \<in> M2" and "y \<in> f ` M1 \<and> y \<in> M2" for x y
  4584       show "d1 (g x) (g y) \<le> 1 * d2 x y" if "x \<in> f ` M1 \<and> x \<in> M2" and "y \<in> f ` M1 \<and> y \<in> M2" for x y
  4582         using that d g by force
  4585         using that d g by force
  4593 qed
  4596 qed
  4594 
  4597 
  4595 lemma (in Metric_space12) isometry_imp_homeomorphic_map:
  4598 lemma (in Metric_space12) isometry_imp_homeomorphic_map:
  4596   assumes fim: "f ` M1 = M2" and d: "\<And>x y. \<lbrakk>x \<in> M1; y \<in> M1\<rbrakk> \<Longrightarrow> d2 (f x) (f y) = d1 x y"
  4599   assumes fim: "f ` M1 = M2" and d: "\<And>x y. \<lbrakk>x \<in> M1; y \<in> M1\<rbrakk> \<Longrightarrow> d2 (f x) (f y) = d1 x y"
  4597   shows "homeomorphic_map M1.mtopology M2.mtopology f"
  4600   shows "homeomorphic_map M1.mtopology M2.mtopology f"
  4598   by (metis M1.topspace_mtopology M2.subtopology_mspace d embedding_map_def fim isometry_imp_embedding_map subsetI)
  4601   by (metis image_eqI M1.topspace_mtopology M2.subtopology_mspace d embedding_map_def fim isometry_imp_embedding_map Pi_iff)
       
  4602 
  4599 subsection\<open>"Capped" equivalent bounded metrics and general product metrics\<close>
  4603 subsection\<open>"Capped" equivalent bounded metrics and general product metrics\<close>
  4600 
  4604 
  4601 definition (in Metric_space) capped_dist where
  4605 definition (in Metric_space) capped_dist where
  4602   "capped_dist \<equiv> \<lambda>\<delta> x y. if \<delta> > 0 then min \<delta> (d x y) else d x y"
  4606   "capped_dist \<equiv> \<lambda>\<delta> x y. if \<delta> > 0 then min \<delta> (d x y) else d x y"
  4603 
  4607 
  5130 
  5134 
  5131 lemma locally_connected_Euclidean_space:
  5135 lemma locally_connected_Euclidean_space:
  5132    "locally_connected_space(Euclidean_space n)"
  5136    "locally_connected_space(Euclidean_space n)"
  5133   by (simp add: locally_path_connected_Euclidean_space locally_path_connected_imp_locally_connected_space)
  5137   by (simp add: locally_path_connected_Euclidean_space locally_path_connected_imp_locally_connected_space)
  5134 
  5138 
  5135 
       
  5136 end
  5139 end
  5137 
  5140