# HG changeset patch # User paulson # Date 1685617713 -3600 # Node ID 1cadc477f644c89c0fae513f51ff81f4af684c1d # Parent 8234c42d20e64ee90644b7fec3e795d3611c912f Even more material from the HOL Light metric space library diff -r 8234c42d20e6 -r 1cadc477f644 src/HOL/Analysis/Abstract_Metric_Spaces.thy --- a/src/HOL/Analysis/Abstract_Metric_Spaces.thy Wed May 31 11:28:31 2023 +0100 +++ b/src/HOL/Analysis/Abstract_Metric_Spaces.thy Thu Jun 01 12:08:33 2023 +0100 @@ -542,6 +542,9 @@ lemma mdist_euclidean_metric [simp]: "mdist euclidean_metric = dist" by (simp add: euclidean_metric_def) +lemma mtopology_of_euclidean [simp]: "mtopology_of euclidean_metric = euclidean" + by (simp add: Met_TC.mtopology_def mtopology_of_def) + text\ Subspace of a metric space\ definition submetric where @@ -570,6 +573,16 @@ "submetric m S = submetric m (mspace m \ S)" by (metis submetric_mspace submetric_submetric) +lemma mtopology_of_submetric: "mtopology_of (submetric m A) = subtopology (mtopology_of m) A" +proof - + interpret Submetric "mspace m" "mdist m" "A \ mspace m" + using Metric_space_mspace_mdist Submetric.intro Submetric_axioms.intro inf_le2 by blast + have "sub.mtopology = subtopology (mtopology_of m) A" + by (metis inf_commute mtopology_of_def mtopology_submetric subtopology_mspace subtopology_subtopology) + then show ?thesis + by (simp add: submetric_def) +qed + subsection\The discrete metric\ @@ -809,35 +822,6 @@ "\metrizable_space X; openin X S\ \ fsigma_in X S" by (meson closed_imp_gdelta_in fsigma_in_gdelta_in openin_closedin openin_subset) -(*NEEDS first_countable -lemma first_countable_mtopology: - "first_countable mtopology" -oops - GEN_TAC THEN REWRITE_TAC[first_countable; TOPSPACE_MTOPOLOGY] THEN - X_GEN_TAC `x::A` THEN DISCH_TAC THEN - EXISTS_TAC `{ mball m (x::A,r) | rational r \ 0 < r}` THEN - REWRITE_TAC[FORALL_IN_GSPEC; OPEN_IN_MBALL; EXISTS_IN_GSPEC] THEN - ONCE_REWRITE_TAC[SET_RULE - `{f x | S x \ Q x} = f ` {x \ S. Q x}`] THEN - SIMP_TAC[COUNTABLE_IMAGE; COUNTABLE_RATIONAL; COUNTABLE_RESTRICT] THEN - REWRITE_TAC[OPEN_IN_MTOPOLOGY] THEN - X_GEN_TAC `U::A=>bool` THEN STRIP_TAC THEN - FIRST_X_ASSUM(MP_TAC \ SPEC `x::A`) THEN - ASM_REWRITE_TAC[LEFT_IMP_EXISTS_THM] THEN - X_GEN_TAC `r::real` THEN STRIP_TAC THEN FIRST_ASSUM - (MP_TAC \ SPEC `r::real` \ MATCH_MP RATIONAL_APPROXIMATION_BELOW) THEN - MATCH_MP_TAC MONO_EXISTS THEN X_GEN_TAC `q::real` THEN - REWRITE_TAC[REAL_SUB_REFL] THEN STRIP_TAC THEN - ASM_SIMP_TAC[CENTRE_IN_MBALL] THEN - TRANS_TAC SUBSET_TRANS `mball m (x::A,r)` THEN - ASM_SIMP_TAC[MBALL_SUBSET_CONCENTRIC; REAL_LT_IMP_LE]);; - -lemma metrizable_imp_first_countable: - "metrizable_space X \ first_countable X" -oops - REWRITE_TAC[FORALL_METRIZABLE_SPACE; FIRST_COUNTABLE_MTOPOLOGY]);; -*) - lemma mball_eq_ball [simp]: "Met_TC.mball = ball" by force @@ -2950,7 +2934,14 @@ "mdist (prod_metric m1 m2) = prod_dist (mdist m1) (mdist m2)" by (metis Metric_space.mdist_metric Metric_space12.prod_metric Metric_space12_mspace_mdist prod_metric_def) -context Metric_space12 +lemma prod_dist_dist [simp]: "prod_dist dist dist = dist" + by (simp add: prod_dist_def dist_prod_def fun_eq_iff) + +lemma prod_metric_euclidean [simp]: + "prod_metric euclidean_metric euclidean_metric = euclidean_metric" + by (simp add: prod_metric_def euclidean_metric_def) + +context Metric_space12 begin lemma component_le_prod_metric: @@ -3343,6 +3334,1232 @@ qed (simp add: empty_completely_metrizable_space) +subsection \The "atin-within" filter for topologies\ + +(*FIXME: replace original definition of atin to be an abbreviation, like at / at_within + ("atin (_) (_)/ within (_)" [1000, 60] 60)*) +definition atin_within :: "['a topology, 'a, 'a set] \ 'a filter" + where "atin_within X a S = inf (nhdsin X a) (principal (topspace X \ S - {a}))" + +lemma atin_within_UNIV [simp]: + shows "atin_within X a UNIV = atin X a" + by (simp add: atin_def atin_within_def) + +lemma eventually_atin_subtopology: + assumes "a \ topspace X" + shows "eventually P (atin (subtopology X S) a) \ + (a \ S \ (\U. openin (subtopology X S) U \ a \ U \ (\x\U - {a}. P x)))" + using assms by (simp add: eventually_atin) + +lemma eventually_atin_within: + "eventually P (atin_within X a S) \ a \ topspace X \ (\T. openin X T \ a \ T \ (\x\T. x \ S \ x \ a \ P x))" +proof (cases "a \ topspace X") + case True + hence "eventually P (atin_within X a S) \ + (\T. openin X T \ a \ T \ + (\x\T. x \ topspace X \ x \ S \ x \ a \ P x))" + by (simp add: atin_within_def eventually_inf_principal eventually_nhdsin) + also have "\ \ (\T. openin X T \ a \ T \ (\x\T. x \ S \ x \ a \ P x))" + using openin_subset by (intro ex_cong) auto + finally show ?thesis by (simp add: True) +qed (simp add: atin_within_def) + +lemma atin_subtopology_within: + assumes "a \ S" + shows "atin (subtopology X S) a = atin_within X a S" +proof - + have "eventually P (atin (subtopology X S) a) \ eventually P (atin_within X a S)" for P + unfolding eventually_atin eventually_atin_within openin_subtopology + using assms by auto + then show ?thesis + by (meson le_filter_def order.eq_iff) +qed + +lemma limit_continuous_map_within: + "\continuous_map (subtopology X S) Y f; a \ S; a \ topspace X\ + \ limitin Y f (f a) (atin_within X a S)" + by (metis Int_iff atin_subtopology_within continuous_map_atin topspace_subtopology) + +lemma atin_subtopology_within_if: + shows "atin (subtopology X S) a = (if a \ S then atin_within X a S else bot)" + by (simp add: atin_subtopology_within) + +lemma trivial_limit_atpointof_within: + "trivial_limit(atin_within X a S) \ + (a \ X derived_set_of S)" + by (auto simp: trivial_limit_def eventually_atin_within in_derived_set_of) + +lemma derived_set_of_trivial_limit: + "a \ X derived_set_of S \ \ trivial_limit(atin_within X a S)" + by (simp add: trivial_limit_atpointof_within) + + +subsection\More sequential characterizations in a metric space\ + +context Metric_space +begin + +definition decreasing_dist :: "(nat \ 'a) \ 'a \ bool" + where "decreasing_dist \ x \ (\m n. m < n \ d (\ n) x < d (\ m) x)" + +lemma decreasing_dist_imp_inj: "decreasing_dist \ a \ inj \" + by (metis decreasing_dist_def dual_order.irrefl linorder_inj_onI') + +lemma eventually_atin_within_metric: + "eventually P (atin_within mtopology a S) \ + (a \ M \ (\\>0. \x. x \ M \ x \ S \ 0 < d x a \ d x a < \ \ P x))" (is "?lhs=?rhs") +proof + assume ?lhs then show ?rhs +unfolding eventually_atin_within openin_mtopology subset_iff + by (metis commute in_mball mdist_zero order_less_irrefl topspace_mtopology) +next + assume R: ?rhs + show ?lhs + proof (cases "a \ M") + case True + then obtain \ where "\ > 0" and \: "\x. \x \ M; x \ S; 0 < d x a; d x a < \\ \ P x" + using R by blast + then have "openin mtopology (mball a \) \ (\x \ mball a \. x \ S \ x \ a \ P x)" + by (simp add: commute openin_mball) + then show ?thesis + by (metis True \0 < \\ centre_in_mball_iff eventually_atin_within) + next + case False + with R show ?thesis + by (simp add: eventually_atin_within) + qed +qed + + +lemma eventually_atin_within_A: + assumes + "(\\. \range \ \ (S \ M) - {a}; decreasing_dist \ a; + inj \; limitin mtopology \ a sequentially\ + \ eventually (\n. P (\ n)) sequentially)" + shows "eventually P (atin_within mtopology a S)" +proof - + have False if SP: "\\. \>0 \ \x \ M-{a}. d x a < \ \ x \ S \ \ P x" and "a \ M" + proof - + define \ where "\ \ \n x. x \ M-{a} \ d x a < inverse (Suc n) \ x \ S \ \ P x" + obtain \ where \: "\n. \ n (\ n)" and dless: "\n. d (\(Suc n)) a < d (\ n) a" + proof - + obtain x0 where x0: "\ 0 x0" + using SP [OF zero_less_one] by (force simp: \_def) + have "\y. \ (Suc n) y \ d y a < d x a" if "\ n x" for n x + using SP [of "min (inverse (Suc (Suc n))) (d x a)"] \a \ M\ that + by (auto simp: \_def) + then obtain f where f: "\n x. \ n x \ \ (Suc n) (f n x) \ d (f n x) a < d x a" + by metis + show thesis + proof + show "\ n (rec_nat x0 f n)" for n + by (induction n) (auto simp: x0 dest: f) + with f show "d (rec_nat x0 f (Suc n)) a < d (rec_nat x0 f n) a" for n + by auto + qed + qed + have 1: "range \ \ (S \ M) - {a}" + using \ by (auto simp: \_def) + have "d (\(Suc (m+n))) a < d (\ n) a" for m n + by (induction m) (auto intro: order_less_trans dless) + then have 2: "decreasing_dist \ a" + unfolding decreasing_dist_def by (metis add.commute less_imp_Suc_add) + have "\\<^sub>F xa in sequentially. d (\ xa) a < \" if "\ > 0" for \ + proof - + obtain N where "inverse (Suc N) < \" + using \\ > 0\ reals_Archimedean by blast + with \ 2 show ?thesis + unfolding decreasing_dist_def by (smt (verit, best) \_def eventually_at_top_dense) + qed + then have 4: "limitin mtopology \ a sequentially" + using \ \a \ M\ by (simp add: \_def limitin_metric) + show False + using 2 assms [OF 1 _ decreasing_dist_imp_inj 4] \ by (force simp: \_def) + qed + then show ?thesis + by (fastforce simp: eventually_atin_within_metric) +qed + + +lemma eventually_atin_within_B: + assumes ev: "eventually P (atin_within mtopology a S)" + and ran: "range \ \ (S \ M) - {a}" + and lim: "limitin mtopology \ a sequentially" + shows "eventually (\n. P (\ n)) sequentially" +proof - + have "a \ M" + using lim limitin_mspace by auto + with ev obtain \ where "0 < \" + and \: "\\. \\ \ M; \ \ S; 0 < d \ a; d \ a < \\ \ P \" + by (auto simp: eventually_atin_within_metric) + then have *: "\n. \ n \ M \ d (\ n) a < \ \ P (\ n)" + using \a \ M\ ran by auto + have "\\<^sub>F n in sequentially. \ n \ M \ d (\ n) a < \" + using lim \0 < \\ by (auto simp: limitin_metric) + then show ?thesis + by (simp add: "*" eventually_mono) +qed + +lemma eventually_atin_within_sequentially: + "eventually P (atin_within mtopology a S) \ + (\\. range \ \ (S \ M) - {a} \ + limitin mtopology \ a sequentially + \ eventually (\n. P(\ n)) sequentially)" + by (metis eventually_atin_within_A eventually_atin_within_B) + +lemma eventually_atin_within_sequentially_inj: + "eventually P (atin_within mtopology a S) \ + (\\. range \ \ (S \ M) - {a} \ inj \ \ + limitin mtopology \ a sequentially + \ eventually (\n. P(\ n)) sequentially)" + by (metis eventually_atin_within_A eventually_atin_within_B) + +lemma eventually_atin_within_sequentially_decreasing: + "eventually P (atin_within mtopology a S) \ + (\\. range \ \ (S \ M) - {a} \ decreasing_dist \ a \ + limitin mtopology \ a sequentially + \ eventually (\n. P(\ n)) sequentially)" + by (metis eventually_atin_within_A eventually_atin_within_B) + + +lemma eventually_atin_sequentially: + "eventually P (atin mtopology a) \ + (\\. range \ \ M - {a} \ limitin mtopology \ a sequentially + \ eventually (\n. P(\ n)) sequentially)" + using eventually_atin_within_sequentially [where S=UNIV] by simp + +lemma eventually_atin_sequentially_inj: + "eventually P (atin mtopology a) \ + (\\. range \ \ M - {a} \ inj \ \ + limitin mtopology \ a sequentially + \ eventually (\n. P(\ n)) sequentially)" + using eventually_atin_within_sequentially_inj [where S=UNIV] by simp + +lemma eventually_atin_sequentially_decreasing: + "eventually P (atin mtopology a) \ + (\\. range \ \ M - {a} \ decreasing_dist \ a \ + limitin mtopology \ a sequentially + \ eventually (\n. P(\ n)) sequentially)" + using eventually_atin_within_sequentially_decreasing [where S=UNIV] by simp + +end + +context Metric_space12 +begin + +lemma limit_atin_sequentially_within: + "limitin M2.mtopology f l (atin_within M1.mtopology a S) \ + l \ M2 \ + (\\. range \ \ S \ M1 - {a} \ + limitin M1.mtopology \ a sequentially + \ limitin M2.mtopology (f \ \) l sequentially)" + by (auto simp: M1.eventually_atin_within_sequentially limitin_def) + +lemma limit_atin_sequentially_within_inj: + "limitin M2.mtopology f l (atin_within M1.mtopology a S) \ + l \ M2 \ + (\\. range \ \ S \ M1 - {a} \ inj \ \ + limitin M1.mtopology \ a sequentially + \ limitin M2.mtopology (f \ \) l sequentially)" + by (auto simp: M1.eventually_atin_within_sequentially_inj limitin_def) + +lemma limit_atin_sequentially_within_decreasing: + "limitin M2.mtopology f l (atin_within M1.mtopology a S) \ + l \ M2 \ + (\\. range \ \ S \ M1 - {a} \ M1.decreasing_dist \ a \ + limitin M1.mtopology \ a sequentially + \ limitin M2.mtopology (f \ \) l sequentially)" + by (auto simp: M1.eventually_atin_within_sequentially_decreasing limitin_def) + +lemma limit_atin_sequentially: + "limitin M2.mtopology f l (atin M1.mtopology a) \ + l \ M2 \ + (\\. range \ \ M1 - {a} \ + limitin M1.mtopology \ a sequentially + \ limitin M2.mtopology (f \ \) l sequentially)" + using limit_atin_sequentially_within [where S=UNIV] by simp + +lemma limit_atin_sequentially_inj: + "limitin M2.mtopology f l (atin M1.mtopology a) \ + l \ M2 \ + (\\. range \ \ M1 - {a} \ inj \ \ + limitin M1.mtopology \ a sequentially + \ limitin M2.mtopology (f \ \) l sequentially)" + using limit_atin_sequentially_within_inj [where S=UNIV] by simp + +lemma limit_atin_sequentially_decreasing: + "limitin M2.mtopology f l (atin M1.mtopology a) \ + l \ M2 \ + (\\. range \ \ M1 - {a} \ M1.decreasing_dist \ a \ + limitin M1.mtopology \ a sequentially + \ limitin M2.mtopology (f \ \) l sequentially)" + using limit_atin_sequentially_within_decreasing [where S=UNIV] by simp end +text \An experiment: same result as within the locale, but using metric space variables\ +lemma limit_atin_sequentially_within: + "limitin (mtopology_of m2) f l (atin_within (mtopology_of m1) a S) \ + l \ mspace m2 \ + (\\. range \ \ S \ mspace m1 - {a} \ + limitin (mtopology_of m1) \ a sequentially + \ limitin (mtopology_of m2) (f \ \) l sequentially)" + using Metric_space12.limit_atin_sequentially_within [OF Metric_space12_mspace_mdist] + by (metis mtopology_of_def) + + +context Metric_space +begin + +lemma atin_within_imp_M: + "atin_within mtopology x S \ bot \ x \ M" + by (metis derived_set_of_trivial_limit in_derived_set_of topspace_mtopology) + +lemma atin_within_sequentially_sequence: + assumes "atin_within mtopology x S \ bot" + obtains \ where "range \ \ S \ M - {x}" + "decreasing_dist \ x" "inj \" "limitin mtopology \ x sequentially" + by (metis eventually_atin_within_A eventually_False assms) + +lemma derived_set_of_sequentially: + "mtopology derived_set_of S = + {x \ M. \\. range \ \ S \ M - {x} \ limitin mtopology \ x sequentially}" +proof - + have False + if "range \ \ S \ M - {x}" + and "limitin mtopology \ x sequentially" + and "atin_within mtopology x S = bot" + for x \ + proof - + have "\\<^sub>F n in sequentially. P (\ n)" for P + using that by (metis eventually_atin_within_B eventually_bot) + then show False + by (meson eventually_False_sequentially eventually_mono) + qed + then show ?thesis + using derived_set_of_trivial_limit + by (fastforce elim!: atin_within_sequentially_sequence intro: atin_within_imp_M) +qed + +lemma derived_set_of_sequentially_alt: + "mtopology derived_set_of S = + {x. \\. range \ \ S - {x} \ limitin mtopology \ x sequentially}" +proof - + have *: "\\. range \ \ S \ M - {x} \ limitin mtopology \ x sequentially" + if \: "range \ \ S - {x}" and lim: "limitin mtopology \ x sequentially" for x \ + proof - + obtain N where "\n\N. \ n \ M \ d (\ n) x < 1" + using lim limit_metric_sequentially by fastforce + with \ obtain a where a:"a \ S \ M - {x}" by auto + show ?thesis + proof (intro conjI exI) + show "range (\n. if \ n \ M then \ n else a) \ S \ M - {x}" + using a \ by fastforce + show "limitin mtopology (\n. if \ n \ M then \ n else a) x sequentially" + using lim limit_metric_sequentially by fastforce + qed + qed + show ?thesis + by (auto simp: limitin_mspace derived_set_of_sequentially intro!: *) +qed + +lemma derived_set_of_sequentially_inj: + "mtopology derived_set_of S = + {x \ M. \\. range \ \ S \ M - {x} \ inj \ \ limitin mtopology \ x sequentially}" +proof - + have False + if "x \ M" and "range \ \ S \ M - {x}" + and "limitin mtopology \ x sequentially" + and "atin_within mtopology x S = bot" + for x \ + proof - + have "\\<^sub>F n in sequentially. P (\ n)" for P + using that derived_set_of_sequentially_alt derived_set_of_trivial_limit by fastforce + then show False + by (meson eventually_False_sequentially eventually_mono) + qed + then show ?thesis + using derived_set_of_trivial_limit + by (fastforce elim!: atin_within_sequentially_sequence intro: atin_within_imp_M) +qed + + +lemma derived_set_of_sequentially_inj_alt: + "mtopology derived_set_of S = + {x. \\. range \ \ S - {x} \ inj \ \ limitin mtopology \ x sequentially}" +proof - + have "\\. range \ \ S - {x} \ inj \ \ limitin mtopology \ x sequentially" + if "atin_within mtopology x S \ bot" for x + by (metis Diff_empty Int_subset_iff atin_within_sequentially_sequence subset_Diff_insert that) + moreover have False + if "range (\x. \ (x::nat)) \ S - {x}" + and "limitin mtopology \ x sequentially" + and "atin_within mtopology x S = bot" + for x \ + proof - + have "\\<^sub>F n in sequentially. P (\ n)" for P + using that derived_set_of_sequentially_alt derived_set_of_trivial_limit by fastforce + then show False + by (meson eventually_False_sequentially eventually_mono) + qed + ultimately show ?thesis + using derived_set_of_trivial_limit by (fastforce intro: atin_within_imp_M) +qed + +lemma derived_set_of_sequentially_decreasing: + "mtopology derived_set_of S = + {x \ M. \\. range \ \ S - {x} \ decreasing_dist \ x \ limitin mtopology \ x sequentially}" +proof - + have "\\. range \ \ S - {x} \ decreasing_dist \ x \ limitin mtopology \ x sequentially" + if "atin_within mtopology x S \ bot" for x + by (metis Diff_empty atin_within_sequentially_sequence le_infE subset_Diff_insert that) + moreover have False + if "x \ M" and "range \ \ S - {x}" + and "limitin mtopology \ x sequentially" + and "atin_within mtopology x S = bot" + for x \ + proof - + have "\\<^sub>F n in sequentially. P (\ n)" for P + using that derived_set_of_sequentially_alt derived_set_of_trivial_limit by fastforce + then show False + by (meson eventually_False_sequentially eventually_mono) + qed + ultimately show ?thesis + using derived_set_of_trivial_limit by (fastforce intro: atin_within_imp_M) +qed + +lemma derived_set_of_sequentially_decreasing_alt: + "mtopology derived_set_of S = + {x. \\. range \ \ S - {x} \ decreasing_dist \ x \ limitin mtopology \ x sequentially}" + using derived_set_of_sequentially_alt derived_set_of_sequentially_decreasing by auto + +lemma closure_of_sequentially: + "mtopology closure_of S = + {x \ M. \\. range \ \ S \ M \ limitin mtopology \ x sequentially}" + by (auto simp: closure_of derived_set_of_sequentially) + +end (*Metric_space*) + + +subsection \Three strong notions of continuity for metric spaces\ + +subsubsection \Lipschitz continuity\ + +definition Lipschitz_continuous_map + where "Lipschitz_continuous_map \ + \m1 m2 f. f ` mspace m1 \ mspace m2 \ + (\B. \x \ mspace m1. \y \ mspace m1. mdist m2 (f x) (f y) \ B * mdist m1 x y)" + +lemma Lipschitz_continuous_map_image: + "Lipschitz_continuous_map m1 m2 f \ f ` mspace m1 \ mspace m2" + by (simp add: Lipschitz_continuous_map_def) + +lemma Lipschitz_continuous_map_pos: + "Lipschitz_continuous_map m1 m2 f \ + f ` mspace m1 \ mspace m2 \ + (\B>0. \x \ mspace m1. \y \ mspace m1. mdist m2 (f x) (f y) \ B * mdist m1 x y)" +proof - + have "B * mdist m1 x y \ (\B\ + 1) * mdist m1 x y" "\B\ + 1 > 0" for x y B + by (auto simp add: mult_right_mono) + then show ?thesis + unfolding Lipschitz_continuous_map_def by (meson dual_order.trans) +qed + + +lemma Lipschitz_continuous_map_eq: + assumes "Lipschitz_continuous_map m1 m2 f" "\x. x \ mspace m1 \ f x = g x" + shows "Lipschitz_continuous_map m1 m2 g" + using Lipschitz_continuous_map_def assms + by (metis (no_types, opaque_lifting) image_subset_iff) + +lemma Lipschitz_continuous_map_from_submetric: + assumes "Lipschitz_continuous_map m1 m2 f" + shows "Lipschitz_continuous_map (submetric m1 S) m2 f" + unfolding Lipschitz_continuous_map_def +proof + show "f ` mspace (submetric m1 S) \ mspace m2" + using Lipschitz_continuous_map_pos assms by fastforce +qed (use assms in \fastforce simp: Lipschitz_continuous_map_def\) + +lemma Lipschitz_continuous_map_from_submetric_mono: + "\Lipschitz_continuous_map (submetric m1 T) m2 f; S \ T\ + \ Lipschitz_continuous_map (submetric m1 S) m2 f" + by (metis Lipschitz_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric) + +lemma Lipschitz_continuous_map_into_submetric: + "Lipschitz_continuous_map m1 (submetric m2 S) f \ + f ` mspace m1 \ S \ Lipschitz_continuous_map m1 m2 f" + by (auto simp: Lipschitz_continuous_map_def) + +lemma Lipschitz_continuous_map_const: + "Lipschitz_continuous_map m1 m2 (\x. c) \ + mspace m1 = {} \ c \ mspace m2" + unfolding Lipschitz_continuous_map_def image_subset_iff + by (metis all_not_in_conv mdist_nonneg mdist_zero mult_1) + +lemma Lipschitz_continuous_map_id: + "Lipschitz_continuous_map m1 m1 (\x. x)" + by (metis Lipschitz_continuous_map_def image_ident mult_1 order_refl) + +lemma Lipschitz_continuous_map_compose: + assumes f: "Lipschitz_continuous_map m1 m2 f" and g: "Lipschitz_continuous_map m2 m3 g" + shows "Lipschitz_continuous_map m1 m3 (g \ f)" + unfolding Lipschitz_continuous_map_def image_subset_iff +proof + show "\x\mspace m1. (g \ f) x \ mspace m3" + by (metis Lipschitz_continuous_map_def assms comp_apply image_subset_iff) + obtain B where B: "\x\mspace m1. \y\mspace m1. mdist m2 (f x) (f y) \ B * mdist m1 x y" + using assms unfolding Lipschitz_continuous_map_def by presburger + obtain C where "C>0" and C: "\x\mspace m2. \y\mspace m2. mdist m3 (g x) (g y) \ C * mdist m2 x y" + using assms unfolding Lipschitz_continuous_map_pos by metis + show "\B. \x\mspace m1. \y\mspace m1. mdist m3 ((g \ f) x) ((g \ f) y) \ B * mdist m1 x y" + apply (rule_tac x="C*B" in exI) + proof clarify + fix x y + assume \
: "x \ mspace m1" "y \ mspace m1" + then have "mdist m3 ((g \ f) x) ((g \ f) y) \ C * mdist m2 (f x) (f y)" + by (metis C Lipschitz_continuous_map_def f comp_apply image_subset_iff) + also have "\ \ C * B * mdist m1 x y" + by (simp add: "\
" B \0 < C\) + finally show "mdist m3 ((g \ f) x) ((g \ f) y) \ C * B * mdist m1 x y" . + qed +qed + +subsubsection \Uniform continuity\ + +definition uniformly_continuous_map + where "uniformly_continuous_map \ + \m1 m2 f. f ` mspace m1 \ mspace m2 \ + (\\>0. \\>0. \x \ mspace m1. \y \ mspace m1. + mdist m1 y x < \ \ mdist m2 (f y) (f x) < \)" + +lemma uniformly_continuous_map_image: + "uniformly_continuous_map m1 m2 f \ f ` mspace m1 \ mspace m2" + by (simp add: uniformly_continuous_map_def) + +lemma ucmap_A: + assumes "uniformly_continuous_map m1 m2 f" + and "(\n. mdist m1 (\ n) (\ n)) \ 0" + and "range \ \ mspace m1" "range \ \ mspace m1" + shows "(\n. mdist m2 (f (\ n)) (f (\ n))) \ 0" + using assms + unfolding uniformly_continuous_map_def image_subset_iff tendsto_iff + apply clarsimp + by (metis (mono_tags, lifting) eventually_sequentially) + +lemma ucmap_B: + assumes \
: "\\ \. \range \ \ mspace m1; range \ \ mspace m1; + (\n. mdist m1 (\ n) (\ n)) \ 0\ + \ (\n. mdist m2 (f (\ n)) (f (\ n))) \ 0" + and "0 < \" + and \: "range \ \ mspace m1" + and \: "range \ \ mspace m1" + and "(\n. mdist m1 (\ n) (\ n)) \ 0" + shows "\n. mdist m2 (f (\ (n::nat))) (f (\ n)) < \" + using \
[OF \ \] assms by (meson LIMSEQ_le_const linorder_not_less) + +lemma ucmap_C: + assumes \
: "\\ \ \. \\ > 0; range \ \ mspace m1; range \ \ mspace m1; + ((\n. mdist m1 (\ n) (\ n)) \ 0)\ + \ \n. mdist m2 (f (\ n)) (f (\ n)) < \" + and fim: "f ` mspace m1 \ mspace m2" + shows "uniformly_continuous_map m1 m2 f" +proof - + {assume "\ (\\>0. \\>0. \x\mspace m1. \y\mspace m1. mdist m1 y x < \ \ mdist m2 (f y) (f x) < \)" + then obtain \ where "\ > 0" + and "\n. \x\mspace m1. \y\mspace m1. mdist m1 y x < inverse(Suc n) \ mdist m2 (f y) (f x) \ \" + by (meson inverse_Suc linorder_not_le) + then obtain \ \ where space: "range \ \ mspace m1" "range \ \ mspace m1" + and dist: "\n. mdist m1 (\ n) (\ n) < inverse(Suc n) \ mdist m2 (f(\ n)) (f(\ n)) \ \" + by (metis image_subset_iff) + have False + using \
[OF \\ > 0\ space] dist Lim_null_comparison + by (smt (verit) LIMSEQ_norm_0 inverse_eq_divide mdist_commute mdist_nonneg real_norm_def) + } + moreover + have "t \ mspace m2" if "t \ f ` mspace m1" for t + using fim that by blast + ultimately show ?thesis + by (fastforce simp: uniformly_continuous_map_def) +qed + +lemma uniformly_continuous_map_sequentially: + "uniformly_continuous_map m1 m2 f \ + f ` mspace m1 \ mspace m2 \ + (\\ \. range \ \ mspace m1 \ range \ \ mspace m1 \ (\n. mdist m1 (\ n) (\ n)) \ 0 + \ (\n. mdist m2 (f (\ n)) (f (\ n))) \ 0)" + (is "?lhs \ ?rhs") +proof + show "?lhs \ ?rhs" + by (simp add: ucmap_A uniformly_continuous_map_image) + show "?rhs \ ?lhs" + by (intro ucmap_B ucmap_C) auto +qed + + +lemma uniformly_continuous_map_sequentially_alt: + "uniformly_continuous_map m1 m2 f \ + f ` mspace m1 \ mspace m2 \ + (\\>0. \\ \. range \ \ mspace m1 \ range \ \ mspace m1 \ + ((\n. mdist m1 (\ n) (\ n)) \ 0) + \ (\n. mdist m2 (f (\ n)) (f (\ n)) < \))" + (is "?lhs \ ?rhs") +proof + show "?lhs \ ?rhs" + using uniformly_continuous_map_image by (intro conjI strip ucmap_B | force simp: ucmap_A)+ + show "?rhs \ ?lhs" + by (intro ucmap_C) auto +qed + + +lemma uniformly_continuous_map_eq: + "\\x. x \ mspace m1 \ f x = g x; uniformly_continuous_map m1 m2 f\ + \ uniformly_continuous_map m1 m2 g" + by (simp add: uniformly_continuous_map_def) + +lemma uniformly_continuous_map_from_submetric: + assumes "uniformly_continuous_map m1 m2 f" + shows "uniformly_continuous_map (submetric m1 S) m2 f" + unfolding uniformly_continuous_map_def +proof + show "f ` mspace (submetric m1 S) \ mspace m2" + using assms by (auto simp: uniformly_continuous_map_def) +qed (use assms in \force simp: uniformly_continuous_map_def\) + +lemma uniformly_continuous_map_from_submetric_mono: + "\uniformly_continuous_map (submetric m1 T) m2 f; S \ T\ + \ uniformly_continuous_map (submetric m1 S) m2 f" + by (metis uniformly_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric) + +lemma uniformly_continuous_map_into_submetric: + "uniformly_continuous_map m1 (submetric m2 S) f \ + f ` mspace m1 \ S \ uniformly_continuous_map m1 m2 f" + by (auto simp: uniformly_continuous_map_def) + +lemma uniformly_continuous_map_const: + "uniformly_continuous_map m1 m2 (\x. c) \ + mspace m1 = {} \ c \ mspace m2" + unfolding uniformly_continuous_map_def image_subset_iff + by (metis empty_iff equals0I mdist_zero) + +lemma uniformly_continuous_map_id [simp]: + "uniformly_continuous_map m1 m1 (\x. x)" + by (metis image_ident order_refl uniformly_continuous_map_def) + +lemma uniformly_continuous_map_compose: + assumes f: "uniformly_continuous_map m1 m2 f" and g: "uniformly_continuous_map m2 m3 g" + shows "uniformly_continuous_map m1 m3 (g \ f)" + by (smt (verit, ccfv_threshold) comp_apply f g image_subset_iff uniformly_continuous_map_def) + +lemma uniformly_continuous_map_real_const [simp]: + "uniformly_continuous_map m euclidean_metric (\x. c)" + by (simp add: euclidean_metric_def uniformly_continuous_map_const) + +text \Equivalence between "abstract" and "type class" notions\ +lemma uniformly_continuous_map_euclidean [simp]: + "uniformly_continuous_map (submetric euclidean_metric S) euclidean_metric f + = uniformly_continuous_on S f" + by (auto simp add: uniformly_continuous_map_def uniformly_continuous_on_def) + +subsubsection \Cauchy continuity\ + +definition Cauchy_continuous_map where + "Cauchy_continuous_map \ + \m1 m2 f. \\. Metric_space.MCauchy (mspace m1) (mdist m1) \ + \ Metric_space.MCauchy (mspace m2) (mdist m2) (f \ \)" + +lemma Cauchy_continuous_map_euclidean [simp]: + "Cauchy_continuous_map (submetric euclidean_metric S) euclidean_metric f + = Cauchy_continuous_on S f" + by (auto simp add: Cauchy_continuous_map_def Cauchy_continuous_on_def Cauchy_def Met_TC.subspace Metric_space.MCauchy_def) + +lemma Cauchy_continuous_map_image: + assumes "Cauchy_continuous_map m1 m2 f" + shows "f ` mspace m1 \ mspace m2" +proof clarsimp + fix x + assume "x \ mspace m1" + then have "Metric_space.MCauchy (mspace m1) (mdist m1) (\n. x)" + by (simp add: Metric_space.MCauchy_const Metric_space_mspace_mdist) + then have "Metric_space.MCauchy (mspace m2) (mdist m2) (f \ (\n. x))" + by (meson Cauchy_continuous_map_def assms) + then show "f x \ mspace m2" + by (simp add: Metric_space.MCauchy_def [OF Metric_space_mspace_mdist]) +qed + + +lemma Cauchy_continuous_map_eq: + "\\x. x \ mspace m1 \ f x = g x; Cauchy_continuous_map m1 m2 f\ + \ Cauchy_continuous_map m1 m2 g" + by (simp add: image_subset_iff Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist]) + +lemma Cauchy_continuous_map_from_submetric: + assumes "Cauchy_continuous_map m1 m2 f" + shows "Cauchy_continuous_map (submetric m1 S) m2 f" + using assms + by (simp add: image_subset_iff Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist]) + +lemma Cauchy_continuous_map_from_submetric_mono: + "\Cauchy_continuous_map (submetric m1 T) m2 f; S \ T\ + \ Cauchy_continuous_map (submetric m1 S) m2 f" + by (metis Cauchy_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric) + +lemma Cauchy_continuous_map_into_submetric: + "Cauchy_continuous_map m1 (submetric m2 S) f \ + f ` mspace m1 \ S \ Cauchy_continuous_map m1 m2 f" (is "?lhs \ ?rhs") +proof - + have "?lhs \ Cauchy_continuous_map m1 m2 f" + by (simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist]) + moreover have "?rhs \ ?lhs" + by (bestsimp simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist]) + ultimately show ?thesis + by (metis Cauchy_continuous_map_image le_inf_iff mspace_submetric) +qed + +lemma Cauchy_continuous_map_const [simp]: + "Cauchy_continuous_map m1 m2 (\x. c) \ mspace m1 = {} \ c \ mspace m2" +proof - + have "mspace m1 = {} \ Cauchy_continuous_map m1 m2 (\x. c)" + by (simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def Metric_space_mspace_mdist) + moreover have "c \ mspace m2 \ Cauchy_continuous_map m1 m2 (\x. c)" + by (simp add: Cauchy_continuous_map_def o_def Metric_space.MCauchy_const [OF Metric_space_mspace_mdist]) + ultimately show ?thesis + using Cauchy_continuous_map_image by blast +qed + +lemma Cauchy_continuous_map_id [simp]: + "Cauchy_continuous_map m1 m1 (\x. x)" + by (simp add: Cauchy_continuous_map_def o_def) + +lemma Cauchy_continuous_map_compose: + assumes f: "Cauchy_continuous_map m1 m2 f" and g: "Cauchy_continuous_map m2 m3 g" + shows "Cauchy_continuous_map m1 m3 (g \ f)" + by (metis (no_types, lifting) Cauchy_continuous_map_def f fun.map_comp g) + +lemma Lipschitz_imp_uniformly_continuous_map: + assumes "Lipschitz_continuous_map m1 m2 f" + shows "uniformly_continuous_map m1 m2 f" + proof - + have "f ` mspace m1 \ mspace m2" + by (simp add: Lipschitz_continuous_map_image assms) + moreover have "\\>0. \x\mspace m1. \y\mspace m1. mdist m1 y x < \ \ mdist m2 (f y) (f x) < \" + if "\ > 0" for \ + proof - + obtain B where "\x\mspace m1. \y\mspace m1. mdist m2 (f x) (f y) \ B * mdist m1 x y" + and "B>0" + using that assms by (force simp add: Lipschitz_continuous_map_pos) + then have "\x\mspace m1. \y\mspace m1. mdist m1 y x < \/B \ mdist m2 (f y) (f x) < \" + by (smt (verit, ccfv_SIG) less_divide_eq mdist_nonneg mult.commute that zero_less_divide_iff) + with \B>0\ show ?thesis + by (metis divide_pos_pos that) + qed + ultimately show ?thesis + by (auto simp: uniformly_continuous_map_def) +qed + +lemma uniformly_imp_Cauchy_continuous_map: + "uniformly_continuous_map m1 m2 f \ Cauchy_continuous_map m1 m2 f" + unfolding uniformly_continuous_map_def Cauchy_continuous_map_def + apply (simp add: image_subset_iff o_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist]) + by meson + +lemma locally_Cauchy_continuous_map: + assumes "\ > 0" + and \
: "\x. x \ mspace m1 \ Cauchy_continuous_map (submetric m1 (mball_of m1 x \)) m2 f" + shows "Cauchy_continuous_map m1 m2 f" + unfolding Cauchy_continuous_map_def +proof (intro strip) + interpret M1: Metric_space "mspace m1" "mdist m1" + by (simp add: Metric_space_mspace_mdist) + interpret M2: Metric_space "mspace m2" "mdist m2" + by (simp add: Metric_space_mspace_mdist) + fix \ + assume \: "M1.MCauchy \" + with \\ > 0\ obtain N where N: "\n n'. \n\N; n'\N\ \ mdist m1 (\ n) (\ n') < \" + using M1.MCauchy_def by fastforce + then have "M1.mball (\ N) \ \ mspace m1" + by (auto simp: image_subset_iff M1.mball_def) + then interpret MS1: Metric_space "mball_of m1 (\ N) \ \ mspace m1" "mdist m1" + by (simp add: M1.subspace) + show "M2.MCauchy (f \ \)" + proof (rule M2.MCauchy_offset) + have "M1.MCauchy (\ \ (+) N)" + by (simp add: M1.MCauchy_imp_MCauchy_suffix \) + moreover have "range (\ \ (+) N) \ M1.mball (\ N) \" + using N [OF order_refl] M1.MCauchy_def \ by fastforce + ultimately have "MS1.MCauchy (\ \ (+) N)" + unfolding M1.MCauchy_def MS1.MCauchy_def by (simp add: mball_of_def) + moreover have "\ N \ mspace m1" + using M1.MCauchy_def \ by auto + ultimately show "M2.MCauchy (f \ \ \ (+) N)" + unfolding comp_assoc + by (metis "\
" Cauchy_continuous_map_def mdist_submetric mspace_submetric) + next + fix n + have "\ n \ mspace m1" + by (meson Metric_space.MCauchy_def Metric_space_mspace_mdist \ range_subsetD) + then have "\ n \ mball_of m1 (\ n) \" + by (simp add: Metric_space.centre_in_mball_iff Metric_space_mspace_mdist assms(1) mball_of_def) + then show "(f \ \) n \ mspace m2" + using Cauchy_continuous_map_image [OF \
[of "\ n"]] \\ n \ mspace m1\ by auto + qed +qed + +context Metric_space12 +begin + +lemma Cauchy_continuous_imp_continuous_map: + assumes "Cauchy_continuous_map (metric (M1,d1)) (metric (M2,d2)) f" + shows "continuous_map M1.mtopology M2.mtopology f" +proof (clarsimp simp: continuous_map_atin) + fix x + assume "x \ M1" + show "limitin M2.mtopology f (f x) (atin M1.mtopology x)" + unfolding limit_atin_sequentially + proof (intro conjI strip) + show "f x \ M2" + using Cauchy_continuous_map_image \x \ M1\ assms by fastforce + fix \ + assume "range \ \ M1 - {x} \ limitin M1.mtopology \ x sequentially" + then have "M1.MCauchy (\n. if even n then \ (n div 2) else x)" + by (force simp add: M1.MCauchy_interleaving) + then have "M2.MCauchy (f \ (\n. if even n then \ (n div 2) else x))" + using assms by (simp add: Cauchy_continuous_map_def) + then show "limitin M2.mtopology (f \ \) (f x) sequentially" + using M2.MCauchy_interleaving [of "f \ \" "f x"] + by (simp add: o_def if_distrib cong: if_cong) + qed +qed + +lemma continuous_imp_Cauchy_continuous_map: + assumes "M1.mcomplete" + and f: "continuous_map M1.mtopology M2.mtopology f" + shows "Cauchy_continuous_map (metric (M1,d1)) (metric (M2,d2)) f" + unfolding Cauchy_continuous_map_def +proof clarsimp + fix \ + assume \: "M1.MCauchy \" + then obtain y where y: "limitin M1.mtopology \ y sequentially" + using M1.mcomplete_def assms by blast + have "range (f \ \) \ M2" + using \ f by (simp add: M2.subspace M1.MCauchy_def M1.metric_continuous_map image_subset_iff) + then show "M2.MCauchy (f \ \)" + using continuous_map_limit [OF f y] M2.convergent_imp_MCauchy + by blast +qed + +end + +text \The same outside the locale\ +lemma Cauchy_continuous_imp_continuous_map: + assumes "Cauchy_continuous_map m1 m2 f" + shows "continuous_map (mtopology_of m1) (mtopology_of m2) f" + using assms Metric_space12.Cauchy_continuous_imp_continuous_map [OF Metric_space12_mspace_mdist] + by (auto simp add: mtopology_of_def) + +lemma continuous_imp_Cauchy_continuous_map: + assumes "Metric_space.mcomplete (mspace m1) (mdist m1)" + and "continuous_map (mtopology_of m1) (mtopology_of m2) f" + shows "Cauchy_continuous_map m1 m2 f" + using assms Metric_space12.continuous_imp_Cauchy_continuous_map [OF Metric_space12_mspace_mdist] + by (auto simp add: mtopology_of_def) + +lemma uniformly_continuous_imp_continuous_map: + "uniformly_continuous_map m1 m2 f + \ continuous_map (mtopology_of m1) (mtopology_of m2) f" + by (simp add: Cauchy_continuous_imp_continuous_map uniformly_imp_Cauchy_continuous_map) + +lemma Lipschitz_continuous_imp_continuous_map: + "Lipschitz_continuous_map m1 m2 f + \ continuous_map (mtopology_of m1) (mtopology_of m2) f" + by (simp add: Lipschitz_imp_uniformly_continuous_map uniformly_continuous_imp_continuous_map) + +lemma Lipschitz_imp_Cauchy_continuous_map: + "Lipschitz_continuous_map m1 m2 f + \ Cauchy_continuous_map m1 m2 f" + by (simp add: Lipschitz_imp_uniformly_continuous_map uniformly_imp_Cauchy_continuous_map) + +lemma Cauchy_imp_uniformly_continuous_map: + assumes f: "Cauchy_continuous_map m1 m2 f" + and tbo: "Metric_space.mtotally_bounded (mspace m1) (mdist m1) (mspace m1)" + shows "uniformly_continuous_map m1 m2 f" + unfolding uniformly_continuous_map_sequentially_alt imp_conjL +proof (intro conjI strip) + show "f ` mspace m1 \ mspace m2" + by (simp add: Cauchy_continuous_map_image f) + interpret M1: Metric_space "mspace m1" "mdist m1" + by (simp add: Metric_space_mspace_mdist) + interpret M2: Metric_space "mspace m2" "mdist m2" + by (simp add: Metric_space_mspace_mdist) + fix \ :: real and \ \ + assume "\ > 0" + and \: "range \ \ mspace m1" + and \: "range \ \ mspace m1" + and 0: "(\n. mdist m1 (\ n) (\ n)) \ 0" + then obtain r1 where "strict_mono r1" and r1: "M1.MCauchy (\ \ r1)" + using M1.mtotally_bounded_sequentially tbo by meson + then obtain r2 where "strict_mono r2" and r2: "M1.MCauchy (\ \ r1 \ r2)" + by (metis M1.mtotally_bounded_sequentially tbo \ image_comp image_subset_iff range_subsetD) + define r where "r \ r1 \ r2" + have r: "strict_mono r" + by (simp add: r_def \strict_mono r1\ \strict_mono r2\ strict_mono_o) + define \ where "\ \ \n. if even n then (\ \ r) (n div 2) else (\ \ r) (n div 2)" + have "M1.MCauchy \" + unfolding \_def M1.MCauchy_interleaving_gen + proof (intro conjI) + show "M1.MCauchy (\ \ r)" + by (simp add: M1.MCauchy_subsequence \strict_mono r2\ fun.map_comp r1 r_def) + show "M1.MCauchy (\ \ r)" + by (simp add: fun.map_comp r2 r_def) + show "(\n. mdist m1 ((\ \ r) n) ((\ \ r) n)) \ 0" + using LIMSEQ_subseq_LIMSEQ [OF 0 r] by (simp add: o_def) + qed + then have "Metric_space.MCauchy (mspace m2) (mdist m2) (f \ \)" + by (meson Cauchy_continuous_map_def f) + then have "(\n. mdist m2 (f (\ (r n))) (f (\ (r n)))) \ 0" + using M2.MCauchy_interleaving_gen [of "f \ \ \ r" "f \ \ \ r"] + by (simp add: \_def o_def if_distrib cong: if_cong) + then show "\n. mdist m2 (f (\ n)) (f (\ n)) < \" + by (meson LIMSEQ_le_const \0 < \\ linorder_not_le) +qed + +lemma continuous_imp_uniformly_continuous_map: + "compact_space (mtopology_of m1) \ + continuous_map (mtopology_of m1) (mtopology_of m2) f + \ uniformly_continuous_map m1 m2 f" + by (simp add: Cauchy_imp_uniformly_continuous_map continuous_imp_Cauchy_continuous_map + Metric_space.compact_space_eq_mcomplete_mtotally_bounded + Metric_space_mspace_mdist mtopology_of_def) + +lemma continuous_eq_Cauchy_continuous_map: + "Metric_space.mcomplete (mspace m1) (mdist m1) \ + continuous_map (mtopology_of m1) (mtopology_of m2) f \ Cauchy_continuous_map m1 m2 f" + using Cauchy_continuous_imp_continuous_map continuous_imp_Cauchy_continuous_map by blast + +lemma continuous_eq_uniformly_continuous_map: + "compact_space (mtopology_of m1) + \ continuous_map (mtopology_of m1) (mtopology_of m2) f \ + uniformly_continuous_map m1 m2 f" + using continuous_imp_uniformly_continuous_map uniformly_continuous_imp_continuous_map by blast + +lemma Cauchy_eq_uniformly_continuous_map: + "Metric_space.mtotally_bounded (mspace m1) (mdist m1) (mspace m1) + \ Cauchy_continuous_map m1 m2 f \ uniformly_continuous_map m1 m2 f" + using Cauchy_imp_uniformly_continuous_map uniformly_imp_Cauchy_continuous_map by blast + +lemma Lipschitz_continuous_map_projections: + "Lipschitz_continuous_map (prod_metric m1 m2) m1 fst" + "Lipschitz_continuous_map (prod_metric m1 m2) m2 snd" + by (simp add: Lipschitz_continuous_map_def prod_dist_def; + metis mult_numeral_1 real_sqrt_sum_squares_ge1 real_sqrt_sum_squares_ge2)+ + +lemma Lipschitz_continuous_map_pairwise: + "Lipschitz_continuous_map m (prod_metric m1 m2) f \ + Lipschitz_continuous_map m m1 (fst \ f) \ Lipschitz_continuous_map m m2 (snd \ f)" + (is "?lhs \ ?rhs") +proof + show "?lhs \ ?rhs" + by (simp add: Lipschitz_continuous_map_compose Lipschitz_continuous_map_projections) + have "Lipschitz_continuous_map m (prod_metric m1 m2) (\x. (f1 x, f2 x))" + if f1: "Lipschitz_continuous_map m m1 f1" and f2: "Lipschitz_continuous_map m m2 f2" for f1 f2 + proof - + obtain B1 where "B1 > 0" + and B1: "\x y. \x \ mspace m; y \ mspace m\ \ mdist m1 (f1 x) (f1 y) \ B1 * mdist m x y" + by (meson Lipschitz_continuous_map_pos f1) + obtain B2 where "B2 > 0" + and B2: "\x y. \x \ mspace m; y \ mspace m\ \ mdist m2 (f2 x) (f2 y) \ B2 * mdist m x y" + by (meson Lipschitz_continuous_map_pos f2) + show ?thesis + unfolding Lipschitz_continuous_map_pos + proof (intro exI conjI strip) + have f1im: "f1 ` mspace m \ mspace m1" + by (simp add: Lipschitz_continuous_map_image f1) + moreover have f2im: "f2 ` mspace m \ mspace m2" + by (simp add: Lipschitz_continuous_map_image f2) + ultimately show "(\x. (f1 x, f2 x)) ` mspace m \ mspace (prod_metric m1 m2)" + by auto + show "B1+B2 > 0" + using \0 < B1\ \0 < B2\ by linarith + fix x y + assume xy: "x \ mspace m" "y \ mspace m" + with f1im f2im have "mdist (prod_metric m1 m2) (f1 x, f2 x) (f1 y, f2 y) \ mdist m1 (f1 x) (f1 y) + mdist m2 (f2 x) (f2 y)" + unfolding mdist_prod_metric + by (intro Metric_space12.prod_metric_le_components [OF Metric_space12_mspace_mdist]) auto + also have "... \ (B1+B2) * mdist m x y" + using B1 [OF xy] B2 [OF xy] by (simp add: vector_space_over_itself.scale_left_distrib) + finally show "mdist (prod_metric m1 m2) (f1 x, f2 x) (f1 y, f2 y) \ (B1+B2) * mdist m x y" . + qed + qed + then show "?rhs \ ?lhs" + by force +qed + +lemma uniformly_continuous_map_pairwise: + "uniformly_continuous_map m (prod_metric m1 m2) f \ + uniformly_continuous_map m m1 (fst \ f) \ uniformly_continuous_map m m2 (snd \ f)" + (is "?lhs \ ?rhs") +proof + show "?lhs \ ?rhs" + by (simp add: Lipschitz_continuous_map_projections Lipschitz_imp_uniformly_continuous_map uniformly_continuous_map_compose) + have "uniformly_continuous_map m (prod_metric m1 m2) (\x. (f1 x, f2 x))" + if f1: "uniformly_continuous_map m m1 f1" and f2: "uniformly_continuous_map m m2 f2" for f1 f2 + proof - + show ?thesis + unfolding uniformly_continuous_map_def + proof (intro conjI strip) + have f1im: "f1 ` mspace m \ mspace m1" + by (simp add: uniformly_continuous_map_image f1) + moreover have f2im: "f2 ` mspace m \ mspace m2" + by (simp add: uniformly_continuous_map_image f2) + ultimately show "(\x. (f1 x, f2 x)) ` mspace m \ mspace (prod_metric m1 m2)" + by auto + fix \:: real + assume "\ > 0" + obtain \1 where "\1>0" + and \1: "\x y. \x \ mspace m; y \ mspace m; mdist m y x < \1\ \ mdist m1 (f1 y) (f1 x) < \/2" + by (metis \0 < \\ f1 half_gt_zero uniformly_continuous_map_def) + obtain \2 where "\2>0" + and \2: "\x y. \x \ mspace m; y \ mspace m; mdist m y x < \2\ \ mdist m2 (f2 y) (f2 x) < \/2" + by (metis \0 < \\ f2 half_gt_zero uniformly_continuous_map_def) + show "\\>0. \x\mspace m. \y\mspace m. mdist m y x < \ \ mdist (prod_metric m1 m2) (f1 y, f2 y) (f1 x, f2 x) < \" + proof (intro exI conjI strip) + show "min \1 \2>0" + using \0 < \1\ \0 < \2\ by auto + fix x y + assume xy: "x \ mspace m" "y \ mspace m" and d: "mdist m y x < min \1 \2" + have *: "mdist m1 (f1 y) (f1 x) < \/2" "mdist m2 (f2 y) (f2 x) < \/2" + using \1 \2 d xy by auto + have "mdist (prod_metric m1 m2) (f1 y, f2 y) (f1 x, f2 x) \ mdist m1 (f1 y) (f1 x) + mdist m2 (f2 y) (f2 x)" + unfolding mdist_prod_metric using f1im f2im xy + by (intro Metric_space12.prod_metric_le_components [OF Metric_space12_mspace_mdist]) auto + also have "... < \/2 + \/2" + using * by simp + finally show "mdist (prod_metric m1 m2) (f1 y, f2 y) (f1 x, f2 x) < \" + by simp + qed + qed + qed + then show "?rhs \ ?lhs" + by force +qed + +lemma Cauchy_continuous_map_pairwise: + "Cauchy_continuous_map m (prod_metric m1 m2) f \ Cauchy_continuous_map m m1 (fst \ f) \ Cauchy_continuous_map m m2 (snd \ f)" + by (auto simp: Cauchy_continuous_map_def Metric_space12.MCauchy_prod_metric[OF Metric_space12_mspace_mdist] comp_assoc) + +lemma Lipschitz_continuous_map_paired: + "Lipschitz_continuous_map m (prod_metric m1 m2) (\x. (f x, g x)) \ + Lipschitz_continuous_map m m1 f \ Lipschitz_continuous_map m m2 g" + by (simp add: Lipschitz_continuous_map_pairwise o_def) + +lemma uniformly_continuous_map_paired: + "uniformly_continuous_map m (prod_metric m1 m2) (\x. (f x, g x)) \ + uniformly_continuous_map m m1 f \ uniformly_continuous_map m m2 g" + by (simp add: uniformly_continuous_map_pairwise o_def) + +lemma Cauchy_continuous_map_paired: + "Cauchy_continuous_map m (prod_metric m1 m2) (\x. (f x, g x)) \ + Cauchy_continuous_map m m1 f \ Cauchy_continuous_map m m2 g" + by (simp add: Cauchy_continuous_map_pairwise o_def) + +lemma mbounded_Lipschitz_continuous_image: + assumes f: "Lipschitz_continuous_map m1 m2 f" and S: "Metric_space.mbounded (mspace m1) (mdist m1) S" + shows "Metric_space.mbounded (mspace m2) (mdist m2) (f`S)" +proof - + obtain B where fim: "f ` mspace m1 \ mspace m2" + and "B>0" and B: "\x y. \x \ mspace m1; y \ mspace m1\ \ mdist m2 (f x) (f y) \ B * mdist m1 x y" + by (meson Lipschitz_continuous_map_pos f) + show ?thesis + unfolding Metric_space.mbounded_alt_pos [OF Metric_space_mspace_mdist] + proof + obtain C where "S \ mspace m1" and "C>0" and C: "\x y. \x \ S; y \ S\ \ mdist m1 x y \ C" + using S by (auto simp: Metric_space.mbounded_alt_pos [OF Metric_space_mspace_mdist]) + show "f ` S \ mspace m2" + using fim \S \ mspace m1\ by blast + have "\x y. \x \ S; y \ S\ \ mdist m2 (f x) (f y) \ B * C" + by (smt (verit) B C \0 < B\ \S \ mspace m1\ mdist_nonneg mult_mono subsetD) + moreover have "B*C > 0" + by (simp add: \0 < B\ \0 < C\) + ultimately show "\B>0. \x\f ` S. \y\f ` S. mdist m2 x y \ B" + by auto + qed +qed + +lemma mtotally_bounded_Cauchy_continuous_image: + assumes f: "Cauchy_continuous_map m1 m2 f" and S: "Metric_space.mtotally_bounded (mspace m1) (mdist m1) S" + shows "Metric_space.mtotally_bounded (mspace m2) (mdist m2) (f ` S)" + unfolding Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist] +proof (intro conjI strip) + have "S \ mspace m1" + using S by (simp add: Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist]) + then show "f ` S \ mspace m2" + using Cauchy_continuous_map_image f by blast + fix \ :: "nat \ 'b" + assume "range \ \ f ` S" + then have "\n. \x. \ n = f x \ x \ S" + by (meson imageE range_subsetD) + then obtain \ where \: "\n. \ n = f (\ n)" "range \ \ S" + by (metis image_subset_iff) + then have "\ = f \ \" + by fastforce + obtain r where "strict_mono r" "Metric_space.MCauchy (mspace m1) (mdist m1) (\ \ r)" + by (meson \ S Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist]) + then have "Metric_space.MCauchy (mspace m2) (mdist m2) (f \ \ \ r)" + using f unfolding Cauchy_continuous_map_def by (metis fun.map_comp) + then show "\r. strict_mono r \ Metric_space.MCauchy (mspace m2) (mdist m2) (\ \ r)" + using \\ = f \ \\ \strict_mono r\ by blast +qed + +lemma Lipschitz_coefficient_pos: + assumes "x \ mspace m" "y \ mspace m" "f x \ f y" + and "f ` mspace m \ mspace m2" + and "\x y. \x \ mspace m; y \ mspace m\ + \ mdist m2 (f x) (f y) \ k * mdist m x y" + shows "0 < k" + using assms by (smt (verit, best) image_subset_iff mdist_nonneg mdist_zero mult_nonpos_nonneg) + +lemma Lipschitz_continuous_map_metric: + "Lipschitz_continuous_map (prod_metric m m) euclidean_metric (\(x,y). mdist m x y)" +proof - + have "\x y x' y'. \x \ mspace m; y \ mspace m; x' \ mspace m; y' \ mspace m\ + \ \mdist m x y - mdist m x' y'\ \ 2 * sqrt ((mdist m x x')\<^sup>2 + (mdist m y y')\<^sup>2)" + by (smt (verit, del_insts) mdist_commute mdist_triangle real_sqrt_sum_squares_ge2) + then show ?thesis + by (fastforce simp add: Lipschitz_continuous_map_def prod_dist_def dist_real_def) +qed + +lemma Lipschitz_continuous_map_mdist: + assumes f: "Lipschitz_continuous_map m m' f" + and g: "Lipschitz_continuous_map m m' g" + shows "Lipschitz_continuous_map m euclidean_metric (\x. mdist m' (f x) (g x))" + (is "Lipschitz_continuous_map m _ ?h") +proof - + have eq: "?h = ((\(x,y). mdist m' x y) \ (\x. (f x,g x)))" + by force + show ?thesis + unfolding eq + proof (rule Lipschitz_continuous_map_compose) + show "Lipschitz_continuous_map m (prod_metric m' m') (\x. (f x, g x))" + by (simp add: Lipschitz_continuous_map_paired f g) + show "Lipschitz_continuous_map (prod_metric m' m') euclidean_metric (\(x,y). mdist m' x y)" + by (simp add: Lipschitz_continuous_map_metric) + qed +qed + +lemma uniformly_continuous_map_mdist: + assumes f: "uniformly_continuous_map m m' f" + and g: "uniformly_continuous_map m m' g" + shows "uniformly_continuous_map m euclidean_metric (\x. mdist m' (f x) (g x))" + (is "uniformly_continuous_map m _ ?h") +proof - + have eq: "?h = ((\(x,y). mdist m' x y) \ (\x. (f x,g x)))" + by force + show ?thesis + unfolding eq + proof (rule uniformly_continuous_map_compose) + show "uniformly_continuous_map m (prod_metric m' m') (\x. (f x, g x))" + by (simp add: uniformly_continuous_map_paired f g) + show "uniformly_continuous_map (prod_metric m' m') euclidean_metric (\(x,y). mdist m' x y)" + by (simp add: Lipschitz_continuous_map_metric Lipschitz_imp_uniformly_continuous_map) + qed +qed + +lemma Cauchy_continuous_map_mdist: + assumes f: "Cauchy_continuous_map m m' f" + and g: "Cauchy_continuous_map m m' g" + shows "Cauchy_continuous_map m euclidean_metric (\x. mdist m' (f x) (g x))" + (is "Cauchy_continuous_map m _ ?h") +proof - + have eq: "?h = ((\(x,y). mdist m' x y) \ (\x. (f x,g x)))" + by force + show ?thesis + unfolding eq + proof (rule Cauchy_continuous_map_compose) + show "Cauchy_continuous_map m (prod_metric m' m') (\x. (f x, g x))" + by (simp add: Cauchy_continuous_map_paired f g) + show "Cauchy_continuous_map (prod_metric m' m') euclidean_metric (\(x,y). mdist m' x y)" + by (simp add: Lipschitz_continuous_map_metric Lipschitz_imp_Cauchy_continuous_map) + qed +qed + +lemma mtopology_of_prod_metric [simp]: + "mtopology_of (prod_metric m1 m2) = prod_topology (mtopology_of m1) (mtopology_of m2)" + by (simp add: mtopology_of_def Metric_space12.mtopology_prod_metric[OF Metric_space12_mspace_mdist]) + +lemma continuous_map_metric: + "continuous_map (prod_topology (mtopology_of m) (mtopology_of m)) euclidean + (\(x,y). mdist m x y)" + using Lipschitz_continuous_imp_continuous_map [OF Lipschitz_continuous_map_metric] + by auto + +lemma continuous_map_mdist_alt: + assumes "continuous_map X (prod_topology (mtopology_of m) (mtopology_of m)) f" + shows "continuous_map X euclidean (\x. case_prod (mdist m) (f x))" + (is "continuous_map _ _ ?h") +proof - + have eq: "?h = case_prod (mdist m) \ f" + by force + show ?thesis + unfolding eq + using assms continuous_map_compose continuous_map_metric by blast +qed + +lemma continuous_map_mdist: + assumes f: "continuous_map X (mtopology_of m) f" + and g: "continuous_map X (mtopology_of m) g" + shows "continuous_map X euclidean (\x. mdist m (f x) (g x))" + (is "continuous_map X _ ?h") +proof - + have eq: "?h = ((\(x,y). mdist m x y) \ (\x. (f x,g x)))" + by force + show ?thesis + unfolding eq + proof (rule continuous_map_compose) + show "continuous_map X (prod_topology (mtopology_of m) (mtopology_of m)) (\x. (f x, g x))" + by (simp add: continuous_map_paired f g) + qed (simp add: continuous_map_metric) +qed + +lemma continuous_on_mdist: + "a \ mspace m \ continuous_map (mtopology_of m) euclidean (mdist m a)" + by (simp add: continuous_map_mdist) + +subsection \Isometries\ + +lemma (in Metric_space12) isometry_imp_embedding_map: + assumes fim: "f ` M1 \ M2" and d: "\x y. \x \ M1; y \ M1\ \ d2 (f x) (f y) = d1 x y" + shows "embedding_map M1.mtopology M2.mtopology f" +proof - + have "inj_on f M1" + by (metis M1.zero d inj_onI) + then obtain g where g: "\x. x \ M1 \ g (f x) = x" + by (metis inv_into_f_f) + have "homeomorphic_maps M1.mtopology (subtopology M2.mtopology (f ` topspace M1.mtopology)) f g" + unfolding homeomorphic_maps_def + proof (intro conjI; clarsimp) + show "continuous_map M1.mtopology (subtopology M2.mtopology (f ` M1)) f" + by (metis M1.metric_continuous_map M1.topspace_mtopology M2.Metric_space_axioms continuous_map_into_subtopology d fim order_refl) + have "Lipschitz_continuous_map (submetric (metric(M2,d2)) (f ` M1)) (metric(M1,d1)) g" + unfolding Lipschitz_continuous_map_def + proof (intro conjI exI strip; simp) + show "d1 (g x) (g y) \ 1 * d2 x y" if "x \ f ` M1 \ x \ M2" and "y \ f ` M1 \ y \ M2" for x y + using that d g by force + qed (use g in auto) + then have "continuous_map (mtopology_of (submetric (metric(M2,d2)) (f ` M1))) M1.mtopology g" + using Lipschitz_continuous_imp_continuous_map by force + moreover have "mtopology_of (submetric (metric(M2,d2)) (f ` M1)) = subtopology M2.mtopology (f ` M1)" + by (simp add: mtopology_of_submetric) + ultimately show "continuous_map (subtopology M2.mtopology (f ` M1)) M1.mtopology g" + by simp + qed (use g in auto) + then show ?thesis + by (auto simp: embedding_map_def homeomorphic_map_maps) +qed + +lemma (in Metric_space12) isometry_imp_homeomorphic_map: + assumes fim: "f ` M1 = M2" and d: "\x y. \x \ M1; y \ M1\ \ d2 (f x) (f y) = d1 x y" + shows "homeomorphic_map M1.mtopology M2.mtopology f" + by (metis M1.topspace_mtopology M2.subtopology_mspace d embedding_map_def fim isometry_imp_embedding_map subsetI) + +end + diff -r 8234c42d20e6 -r 1cadc477f644 src/HOL/Analysis/Elementary_Metric_Spaces.thy --- a/src/HOL/Analysis/Elementary_Metric_Spaces.thy Wed May 31 11:28:31 2023 +0100 +++ b/src/HOL/Analysis/Elementary_Metric_Spaces.thy Thu Jun 01 12:08:33 2023 +0100 @@ -999,9 +999,6 @@ subsubsection\Totally bounded\ -lemma cauchy_def: "Cauchy S \ (\e>0. \N. \m n. m \ N \ n \ N \ dist (S m) (S n) < e)" - unfolding Cauchy_def by metis - proposition seq_compact_imp_totally_bounded: assumes "seq_compact S" shows "\e>0. \k. finite k \ k \ S \ S \ (\x\k. ball x e)" @@ -1025,7 +1022,7 @@ then have "Cauchy (x \ r)" using LIMSEQ_imp_Cauchy by auto then obtain N::nat where "\m n. N \ m \ N \ n \ dist ((x \ r) m) ((x \ r) n) < e" - unfolding cauchy_def using \e > 0\ by blast + unfolding Cauchy_def using \e > 0\ by blast then have False using x[of "r N" "r (N+1)"] r by (auto simp: strict_mono_def) } then show ?thesis @@ -1204,7 +1201,7 @@ then show ?thesis by auto qed then have "Cauchy z" - by (simp add: cauchy_def) + by (metis metric_CauchyI) then obtain x where "x\s" and x:"(z \ x) sequentially" using s(1)[unfolded compact_def complete_def, THEN spec[where x=z]] and z_in_s by auto @@ -1678,7 +1675,7 @@ fix e :: real assume "e > 0" from as(2) obtain N where N:"\m n. N \ m \ N \ n \ dist (f m) (f n) < e/2" - unfolding cauchy_def using \e > 0\ by (meson half_gt_zero) + unfolding Cauchy_def using \e > 0\ by (meson half_gt_zero) then obtain M where M:"\n\M. dist ((f \ r) n) l < e/2" by (metis dist_self lim_sequentially lr(3)) { @@ -1793,7 +1790,7 @@ shows "bounded (range s)" proof - from assms obtain N :: nat where "\m n. N \ m \ N \ n \ dist (s m) (s n) < 1" - unfolding cauchy_def by force + by (meson Cauchy_def zero_less_one) then have N:"\n. N \ n \ dist (s N) (s n) < 1" by auto moreover have "bounded (s ` {0..N})" @@ -1867,11 +1864,6 @@ using frontier_subset_closed compact_eq_bounded_closed by blast -lemma continuous_closed_imp_Cauchy_continuous: - fixes S :: "('a::complete_space) set" - shows "\continuous_on S f; closed S; Cauchy \; \n. (\ n) \ S\ \ Cauchy(f \ \)" - by (meson LIMSEQ_imp_Cauchy completeE complete_eq_closed continuous_on_sequentially) - lemma banach_fix_type: fixes f::"'a::complete_space\'a" assumes c:"0 \ c" "c < 1" @@ -1880,6 +1872,73 @@ using assms banach_fix[OF complete_UNIV UNIV_not_empty assms(1,2) subset_UNIV, of f] by auto +subsection \Cauchy continuity\ + +definition Cauchy_continuous_on where + "Cauchy_continuous_on \ \S f. \\. Cauchy \ \ range \ \ S \ Cauchy (f \ \)" + +lemma continuous_closed_imp_Cauchy_continuous: + fixes S :: "('a::complete_space) set" + shows "\continuous_on S f; closed S\ \ Cauchy_continuous_on S f" + unfolding Cauchy_continuous_on_def + by (metis LIMSEQ_imp_Cauchy completeE complete_eq_closed continuous_on_sequentially range_subsetD) + +lemma uniformly_continuous_imp_Cauchy_continuous: + fixes f :: "'a::metric_space \ 'b::metric_space" + shows "uniformly_continuous_on S f \ Cauchy_continuous_on S f" + by (simp add: uniformly_continuous_on_def Cauchy_continuous_on_def Cauchy_def image_subset_iff) metis + +lemma Cauchy_continuous_on_imp_continuous: + fixes f :: "'a::metric_space \ 'b::metric_space" + assumes "Cauchy_continuous_on S f" + shows "continuous_on S f" +proof - + have False if x: "\n. \x'\S. dist x' x < inverse(Suc n) \ \ dist (f x') (f x) < \" "\>0" "x \ S" for x and \::real + proof - + obtain \ where \: "\n. \ n \ S" and dx: "\n. dist (\ n) x < inverse(Suc n)" and dfx: "\n. \ dist (f (\ n)) (f x) < \" + using x by metis + define \ where "\ \ \n. if even n then \ n else x" + with \ \x \ S\ have "range \ \ S" + by auto + have "\ \ x" + unfolding tendsto_iff + proof (intro strip) + fix e :: real + assume "e>0" + then obtain N where "inverse (Suc N) < e" + using reals_Archimedean by blast + then have "\n. N \ n \ dist (\ n) x < e" + by (smt (verit, ccfv_SIG) dx inverse_Suc inverse_less_iff_less inverse_positive_iff_positive of_nat_Suc of_nat_mono) + with \e>0\ show "\\<^sub>F n in sequentially. dist (\ n) x < e" + by (auto simp add: eventually_sequentially \_def) + qed + then have "Cauchy \" + by (intro LIMSEQ_imp_Cauchy) + then have Cf: "Cauchy (f \ \)" + by (meson Cauchy_continuous_on_def \range \ \ S\ assms) + have "(f \ \) \ f x" + unfolding tendsto_iff + proof (intro strip) + fix e :: real + assume "e>0" + then obtain N where N: "\m\N. \n\N. dist ((f \ \) m) ((f \ \) n) < e" + using Cf unfolding Cauchy_def by presburger + moreover have "(f \ \) (Suc(N+N)) = f x" + by (simp add: \_def) + ultimately have "\n\N. dist ((f \ \) n) (f x) < e" + by (metis add_Suc le_add2) + then show "\\<^sub>F n in sequentially. dist ((f \ \) n) (f x) < e" + using eventually_sequentially by blast + qed + moreover have "\n. \ dist (f (\ (2*n))) (f x) < \" + using dfx by (simp add: \_def) + ultimately show False + using \\>0\ by (fastforce simp: mult_2 nat_le_iff_add tendsto_iff eventually_sequentially) + qed + then show ?thesis + unfolding continuous_on_iff by (meson inverse_Suc) +qed + subsection\<^marker>\tag unimportant\\ Finite intersection property\ @@ -2805,7 +2864,7 @@ by auto } then have "Cauchy t" - unfolding cauchy_def by auto + by (metis metric_CauchyI) then obtain l where l:"(t \ l) sequentially" using complete_UNIV unfolding complete_def by auto { fix n :: nat diff -r 8234c42d20e6 -r 1cadc477f644 src/HOL/Analysis/Function_Metric.thy --- a/src/HOL/Analysis/Function_Metric.thy Wed May 31 11:28:31 2023 +0100 +++ b/src/HOL/Analysis/Function_Metric.thy Thu Jun 01 12:08:33 2023 +0100 @@ -308,13 +308,14 @@ proof fix u::"nat \ ('a \ 'b)" assume "Cauchy u" have "Cauchy (\n. u n i)" for i - unfolding cauchy_def proof (intro impI allI) - fix e assume "e>(0::real)" + unfolding Cauchy_def + proof (intro strip) + fix e::real assume "e>0" obtain k where "i = from_nat k" using from_nat_to_nat[of i] by metis have "(1/2)^k * min e 1 > 0" using \e>0\ by auto then have "\N. \m n. N \ m \ N \ n \ dist (u m) (u n) < (1/2)^k * min e 1" - using \Cauchy u\ unfolding cauchy_def by blast + using \Cauchy u\ by (meson Cauchy_def) then obtain N::nat where C: "\m n. N \ m \ N \ n \ dist (u m) (u n) < (1/2)^k * min e 1" by blast have "\m n. N \ m \ N \ n \ dist (u m i) (u n i) < e" @@ -334,7 +335,7 @@ by (auto simp add: field_split_simps) then show "dist (u m i) (u n i) < e" by auto qed - then show "\N. \m n. N \ m \ N \ n \ dist (u m i) (u n i) < e" + then show "\M. \m\M. \n\M. dist (u m i) (u n i) < e" by blast qed then have "\x. (\n. u n i) \ x" for i diff -r 8234c42d20e6 -r 1cadc477f644 src/HOL/Analysis/Further_Topology.thy --- a/src/HOL/Analysis/Further_Topology.thy Wed May 31 11:28:31 2023 +0100 +++ b/src/HOL/Analysis/Further_Topology.thy Thu Jun 01 12:08:33 2023 +0100 @@ -2684,7 +2684,8 @@ fix \ assume \: "\n. \ n \ S" and "Cauchy \" have "Cauchy (f o \)" - using uniformly_continuous_imp_Cauchy_continuous \Cauchy \\ \ contf by blast + using uniformly_continuous_imp_Cauchy_continuous \Cauchy \\ \ contf + unfolding Cauchy_continuous_on_def by blast then obtain l where "(f \ \) \ l" by (auto simp: convergent_eq_Cauchy [symmetric]) show "\l\S. \ \ l" diff -r 8234c42d20e6 -r 1cadc477f644 src/HOL/Analysis/Lipschitz.thy --- a/src/HOL/Analysis/Lipschitz.thy Wed May 31 11:28:31 2023 +0100 +++ b/src/HOL/Analysis/Lipschitz.thy Thu Jun 01 12:08:33 2023 +0100 @@ -6,7 +6,7 @@ theory Lipschitz imports - Derivative + Derivative Abstract_Metric_Spaces begin definition\<^marker>\tag important\ lipschitz_on @@ -117,6 +117,17 @@ from lipschitz_on_concat[OF this fg] show ?thesis . qed +text \Equivalence between "abstract" and "type class" Lipschitz notions, +for all types in the metric space class\ +lemma Lipschitz_map_euclidean [simp]: + "Lipschitz_continuous_map euclidean_metric euclidean_metric f + \ (\B. lipschitz_on B UNIV f)" (is "?lhs \ ?rhs") +proof + show "?lhs \ ?rhs" + by (force simp add: Lipschitz_continuous_map_pos lipschitz_on_def less_le_not_le) + show "?rhs \ ?lhs" + by (metis Lipschitz_continuous_map_def lipschitz_onD mdist_euclidean_metric mspace_euclidean_metric top_greatest) +qed subsubsection \Continuity\ diff -r 8234c42d20e6 -r 1cadc477f644 src/HOL/Homology/Invariance_of_Domain.thy --- a/src/HOL/Homology/Invariance_of_Domain.thy Wed May 31 11:28:31 2023 +0100 +++ b/src/HOL/Homology/Invariance_of_Domain.thy Thu Jun 01 12:08:33 2023 +0100 @@ -2799,7 +2799,8 @@ fix \ assume \: "\n. \ n \ S" and "Cauchy \" have "Cauchy (f o \)" - using uniformly_continuous_imp_Cauchy_continuous \Cauchy \\ \ contf by blast + using uniformly_continuous_imp_Cauchy_continuous \Cauchy \\ \ contf + unfolding Cauchy_continuous_on_def by blast then obtain l where "(f \ \) \ l" by (auto simp: convergent_eq_Cauchy [symmetric]) show "\l\S. \ \ l" diff -r 8234c42d20e6 -r 1cadc477f644 src/HOL/Limits.thy --- a/src/HOL/Limits.thy Wed May 31 11:28:31 2023 +0100 +++ b/src/HOL/Limits.thy Thu Jun 01 12:08:33 2023 +0100 @@ -2949,11 +2949,6 @@ lemma isUCont_Cauchy: "isUCont f \ Cauchy X \ Cauchy (\n. f (X n))" by (rule uniformly_continuous_on_Cauchy[where S=UNIV and f=f]) simp_all -lemma uniformly_continuous_imp_Cauchy_continuous: - fixes f :: "'a::metric_space \ 'b::metric_space" - shows "\uniformly_continuous_on S f; Cauchy \; \n. (\ n) \ S\ \ Cauchy(f \ \)" - by (simp add: uniformly_continuous_on_def Cauchy_def) meson - lemma (in bounded_linear) isUCont: "isUCont f" unfolding isUCont_def dist_norm proof (intro allI impI)