(* Author: L C Paulson, University of Cambridge Author:AmineChaieb,UniversityofCambridge Author:RobertHimmelmann,TUMuenchen Author:BrianHuffman,PortlandStateUniversity Author:AtaKeskin,TUMuenchen
*)
chapter‹Elementary Metric Spaces›
theory Elementary_Metric_Spaces imports
Abstract_Topology_2
Metric_Arith begin
section‹Open and closed balls›
definition✐‹tag important› ball :: "'a::metric_space → real → 'a set" where"ball x ε = {y. dist x y < ε}"
definition✐‹tag important› cball :: "'a::metric_space → real → 'a set" where"cball x ε = {y. dist x y ≤ ε}"
definition✐‹tag important› sphere :: "'a::metric_space → real → 'a set" where"sphere x ε = {y. dist x y = ε}"
lemma mem_ball [simp, metric_unfold]: "y ∈ ball x ε ⟷ dist x y < ε" by (simp add: ball_def)
lemma mem_cball [simp, metric_unfold]: "y ∈ cball x ε ⟷ dist x y ≤ ε" by (simp add: cball_def)
lemma mem_sphere [simp]: "y ∈ sphere x ε ⟷ dist x y = ε" by (simp add: sphere_def)
lemma ball_trivial [simp]: "ball x 0 = {}" by auto
lemma cball_trivial [simp]: "cball x 0 = {x}" by auto
lemma sphere_trivial [simp]: "sphere x 0 = {x}" by auto
lemma disjoint_ballI: "dist x y ≥ r+s ==> ball x r ∩ ball y s = {}" using dist_triangle_less_add not_le by fastforce
lemma disjoint_cballI: "dist x y > r + s ==> cball x r ∩ cball y s = {}" by (metis add_mono disjoint_iff_not_equal dist_triangle2 dual_order.trans leD mem_cball)
lemma sphere_empty [simp]: "r < 0 ==> sphere a r = {}" for a :: "'a::metric_space" by auto
lemma centre_in_ball [simp]: "x ∈ ball x ε ⟷ 0 < ε" by simp
lemma centre_in_cball [simp]: "x ∈ cball x ε ⟷ 0 ≤ ε" by simp
lemma ball_subset_cball [simp, intro]: "ball x ε ⊆ cball x ε" by (simp add: subset_eq)
lemma mem_ball_imp_mem_cball: "x ∈ ball y ε ==> x ∈ cball y ε" by auto
lemma sphere_cball [simp,intro]: "sphere z r ⊆ cball z r" by force
lemma cball_diff_sphere: "cball a r - sphere a r = ball a r" by auto
lemma subset_ball[intro]: "δ ≤ ε ==> ball x δ ⊆ ball x ε" by auto
lemma subset_cball[intro]: "δ ≤ ε ==> cball x δ ⊆ cball x ε" by auto
lemma mem_ball_leI: "x ∈ ball y ε ==> ε ≤ f ==> x ∈ ball y f" by auto
lemma mem_cball_leI: "x ∈ cball y ε ==> ε ≤ f ==> x ∈ cball y f" by auto
lemma cball_trans: "y ∈ cball z b ==> x ∈ cball y a ==> x ∈ cball z (b + a)" by metric
lemma ball_max_Un: "ball a (max r s) = ball a r ∪ ball a s" by auto
lemma ball_min_Int: "ball a (min r s) = ball a r ∩ ball a s" by auto
lemma cball_max_Un: "cball a (max r s) = cball a r ∪ cball a s" by auto
lemma cball_min_Int: "cball a (min r s) = cball a r ∩ cball a s" by auto
lemma cball_diff_eq_sphere: "cball a r - ball a r = sphere a r" by auto
lemma open_ball [intro, simp]: "open (ball x ε)" proof - have"open (dist x -` {..<ε})" by (intro open_vimage open_lessThan continuous_intros) alsohave"dist x -` {..<ε} = ball x ε" by auto finallyshow ?thesis . qed
lemma open_contains_ball: "open S ⟷ (∀x∈S. ∃ε>0. ball x ε ⊆ S)" by (simp add: open_dist subset_eq Ball_def dist_commute)
lemma openI [intro?]: "(∧x. x∈S ==>∃ε>0. ball x ε ⊆ S) ==> open S" by (auto simp: open_contains_ball)
lemma openE[elim?]: assumes"open S""x∈S" obtains ε where"ε>0""ball x ε ⊆ S" using assms unfolding open_contains_ball by auto
lemma open_contains_ball_eq: "open S ==> x∈S ⟷ (∃ε>0. ball x ε ⊆ S)" by (metis open_contains_ball subset_eq centre_in_ball)
lemma ball_eq_empty[simp]: "ball x ε = {} ⟷ ε ≤ 0" unfolding mem_ball set_eq_iff by (simp add: not_less) metric
lemma ball_empty: "ε ≤ 0 ==> ball x ε = {}" by simp
lemma closed_cball [iff]: "closed (cball x ε)" proof - have"closed (dist x -` {..ε})" by (intro closed_vimage closed_atMost continuous_intros) alsohave"dist x -` {..ε} = cball x ε" by auto finallyshow ?thesis . qed
lemma cball_subset_ball: assumes"ε>0" shows"∃δ>0. cball x δ ⊆ ball x ε" using assms unfolding subset_eq by (intro exI [where x="ε/2"], auto)
lemma open_contains_cball: "open S ⟷ (∀x∈S. ∃ε>0. cball x ε ⊆ S)" by (meson ball_subset_cball cball_subset_ball open_contains_ball subset_trans)
lemma open_contains_cball_eq: "open S ==> (∀x. x ∈ S ⟷ (∃ε>0. cball x ε ⊆ S))" by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball)
lemma eventually_nhds_ball: "δ > 0 ==> eventually (λx. x ∈ ball z δ) (nhds z)" by (rule eventually_nhds_in_open) simp_all
lemma eventually_at_ball: "δ > 0 ==> eventually (λt. t ∈ ball z δ ∧ t ∈ A) (at z within A)" unfolding eventually_at by (intro exI[of _ δ]) (simp_all add: dist_commute)
lemma eventually_at_ball': "δ > 0 ==> eventually (λt. t ∈ ball z δ ∧ t ≠ z ∧ t ∈ A) (at z within A)" unfolding eventually_at by (intro exI[of _ δ]) (simp_all add: dist_commute)
lemma at_within_ball: "ε > 0 ==> dist x y < ε ==> at y within ball x ε = at y" by (subst at_within_open) auto
lemma ball_eq_greaterThanLessThan: fixes a b::real shows"ball a b = {a - b <..< a + b}" by (auto simp: dist_real_def)
lemma interior_ball [simp]: "interior (ball x ε) = ball x ε" by (simp add: interior_open)
lemma cball_eq_empty [simp]: "cball x ε = {} ⟷ ε < 0" by (metis centre_in_cball order.trans ex_in_conv linorder_not_le mem_cball
zero_le_dist)
lemma cball_empty [simp]: "ε < 0 ==> cball x ε = {}" by simp
lemma cball_sing: fixes x :: "'a::metric_space" shows"ε = 0 ==> cball x ε = {x}" by simp
lemma ball_divide_subset: "δ ≥ 1 ==> ball x (ε/δ) ⊆ ball x ε" by (metis ball_eq_empty div_by_1 frac_le linear subset_ball zero_less_one)
lemma ball_divide_subset_numeral: "ball x (ε / numeral w) ⊆ ball x ε" using ball_divide_subset one_le_numeral by blast
lemma cball_divide_subset: assumes"δ ≥ 1" shows"cball x (ε/δ) ⊆ cball x ε" proof (cases "ε≥0") case True thenshow ?thesis by (metis assms div_by_1 divide_mono order_le_less subset_cball zero_less_one) next case False thenhave"(ε/δ) < 0" using assms divide_less_0_iff by fastforce thenshow ?thesis by auto qed
lemma cball_divide_subset_numeral: "cball x (ε / numeral w) ⊆ cball x ε" using cball_divide_subset one_le_numeral by blast
lemma cball_scale: assumes"a ≠ 0" shows"(λx. a *R x) ` cball c r = cball (a *R c :: 'a :: real_normed_vector) (∣a∣* r)" proof - have *: "(λx. a *R x) ` cball c r ⊆ cball (a *R c) (∣a∣ * r)"for a r and c :: 'a by (auto simp: dist_norm simp flip: scaleR_right_diff_distrib intro!: mult_left_mono) have"cball (a *R c) (∣a∣ * r) = (λx. a *R x) ` (λx. inverse a *R x) ` cball (a *Rc) (∣a∣ * r)" unfolding image_image using assms by simp alsohave"…⊆ (λx. a *R x) ` cball (inverse a *R (a *R c)) (∣inverse a∣ * (∣a∣ * r))" using"*"by blast alsohave"… = (λx. a *R x) ` cball c r" using assms by (simp add: algebra_simps) finallyhave"cball (a *R c) (∣a∣ * r) ⊆ (λx. a *R x) ` cball c r" . moreoverfrom assms have"(λx. a *R x) ` cball c r ⊆ cball (a *R c) (∣a∣ * r)" using"*"by blast ultimatelyshow ?thesis by blast qed
lemma ball_scale: assumes"a ≠ 0" shows"(λx. a *R x) ` ball c r = ball (a *R c :: 'a :: real_normed_vector) (∣a∣ * r)" proof - have *: "(λx. a *R x) ` ball c r ⊆ ball (a *R c) (∣a∣ * r)"if"a ≠ 0"for a r and c :: 'a using that by (auto simp: dist_norm simp flip: scaleR_right_diff_distrib) have"ball (a *R c) (∣a∣ * r) = (λx. a *R x) ` (λx. inverse a *R x) ` ball (a *R c) (∣a∣ * r)" unfolding image_image using assms by simp alsohave"…⊆ (λx. a *R x) ` ball (inverse a *R (a *R c)) (∣inverse a∣ * (∣a∣ * r))" using assms by (intro image_mono *) auto alsohave"… = (λx. a *R x) ` ball c r" using assms by (simp add: algebra_simps) finallyhave"ball (a *R c) (∣a∣ * r) ⊆ (λx. a *R x) ` ball c r" . moreoverfrom assms have"(λx. a *R x) ` ball c r ⊆ ball (a *R c) (∣a∣ * r)" by (intro *) auto ultimatelyshow ?thesis by blast qed
lemma sphere_scale: assumes"a ≠ 0" shows"(λx. a *R x) ` sphere c r = sphere (a *R c :: 'a :: real_normed_vector) (∣a∣ * r)" proof - have *: "(λx. a *R x) ` sphere c r ⊆ sphere (a *R c) (∣a∣ * r)"for a r and c :: 'a by (metis (no_types, opaque_lifting) scaleR_right_diff_distrib dist_norm image_subsetI mem_sphere norm_scaleR) have"sphere (a *R c) (∣a∣ * r) = (λx. a *R x) ` (λx. inverse a *R x) ` sphere (a *R c) (∣a∣ * r)" unfolding image_image using assms by simp alsohave"…⊆ (λx. a *R x) ` sphere (inverse a *R (a *R c)) (∣inverse a∣ * (∣a∣ * r))" using"*"by blast alsohave"… = (λx. a *R x) ` sphere c r" using assms by (simp add: algebra_simps) finallyhave"sphere (a *R c) (∣a∣ * r) ⊆ (λx. a *R x) ` sphere c r" . moreoverhave"(λx. a *R x) ` sphere c r ⊆ sphere (a *R c) (∣a∣ * r)" using"*"by blast ultimatelyshow ?thesis by blast qed
text‹As above, but scaled by a complex number› lemma sphere_cscale: assumes"a ≠ 0" shows"(λx. a * x) ` sphere c r = sphere (a * c :: complex) (cmod a * r)" proof - have *: "(λx. a * x) ` sphere c r ⊆ sphere (a * c) (cmod a * r)"for a r c using dist_mult_left by fastforce have"sphere (a * c) (cmod a * r) = (λx. a * x) ` (λx. inverse a * x) ` sphere (a * c) (cmod a * r)" by (simp add: image_image inverse_eq_divide) alsohave"…⊆ (λx. a * x) ` sphere (inverse a * (a * c)) (cmod (inverse a) * (cmod a * r))" using"*"by blast alsohave"… = (λx. a * x) ` sphere c r" using assms by (simp add: field_simps flip: norm_mult) finallyhave"sphere (a * c) (cmod a * r) ⊆ (λx. a * x) ` sphere c r" . moreoverhave"(λx. a * x) ` sphere c r ⊆ sphere (a * c) (cmod a * r)" using"*"by blast ultimatelyshow ?thesis by blast qed
lemma frequently_atE: fixes x :: "'a :: metric_space" assumes"frequently P (at x within s)" shows"∃f. filterlim f (at x within s) sequentially ∧ (∀n. P (f n))" proof - have"∃y. y ∈ s ∩ (ball x (1 / real (Suc n)) - {x}) ∧ P y"for n proof - have"∃z∈s. z ≠ x ∧ dist z x < (1 / real (Suc n)) ∧ P z" by (metis assms divide_pos_pos frequently_at of_nat_0_less_iff zero_less_Suc zero_less_one) thenshow ?thesis by (auto simp: dist_commute conj_commute) qed thenobtain f where f: "∧n. f n ∈ s ∩ (ball x (1 / real (Suc n)) - {x}) ∧ P (f n)" by metis have"filterlim f (nhds x) sequentially" unfolding tendsto_iff proof clarify fix ε :: real assume ε: "ε > 0" thenobtain n where n: "Suc n > 1 / ε" by (meson le_nat_floor lessI not_le) have"dist (f k) x < ε"if"k ≥ n"for k proof - have"dist (f k) x < 1 / real (Suc k)" using f[of k] by (auto simp: dist_commute) alsohave"…≤ 1 / real (Suc n)" using that by (intro divide_left_mono) auto alsohave"… < ε" using n ε by (simp add: field_simps) finallyshow ?thesis . qed thus"∀F k in sequentially. dist (f k) x < ε" unfolding eventually_at_top_linorder by blast qed moreoverhave"f n ≠ x"for n using f[of n] by auto ultimatelyhave"filterlim f (at x within s) sequentially" using f by (auto simp: filterlim_at) with f show ?thesis by blast qed
section‹Limit Points›
lemma islimpt_approachable: fixes x :: "'a::metric_space" shows"x islimpt S ⟷ (∀ε>0. ∃x'∈S. x' ≠ x ∧ dist x' x < ε)" unfolding islimpt_iff_eventually eventually_at by fast
lemma islimpt_approachable_le: "x islimpt S ⟷ (∀ε>0. ∃x'∈ S. x' ≠ x ∧ dist x' x ≤ ε)" for x :: "'a::metric_space" unfolding islimpt_approachable using approachable_lt_le2 [where f="λy. dist y x"and P="λy. y ∉ S ∨ y = x"and Q="λx. True"] by auto
lemma limpt_of_limpts: "x islimpt {y. y islimpt S} ==> x islimpt S" for x :: "'a::metric_space" by (metis islimpt_def islimpt_eq_acc_point mem_Collect_eq)
lemma closed_limpts: "closed {x::'a::metric_space. x islimpt S}" using closed_limpt limpt_of_limpts by blast
lemma limpt_of_closure: "x islimpt closure S ⟷ x islimpt S" for x :: "'a::metric_space" by (auto simp: closure_def islimpt_Un dest: limpt_of_limpts)
lemma islimpt_eq_infinite_ball: "x islimpt S ⟷ (∀ε>0. infinite(S ∩ ball x ε))" unfolding islimpt_eq_acc_point by (metis open_ball Int_commute Int_mono finite_subset open_contains_ball_eq subset_eq)
lemma islimpt_eq_infinite_cball: "x islimpt S ⟷ (∀ε>0. infinite(S ∩ cball x ε))" unfolding islimpt_eq_infinite_ball by (metis ball_subset_cball cball_subset_ball finite_Int inf.absorb_iff2 inf_assoc)
section‹Perfect Metric Spaces›
lemma perfect_choose_dist: "0 < r ==>∃a. a ≠ x ∧ dist a x < r" for x :: "'a::{perfect_space,metric_space}" using islimpt_UNIV [of x] by (simp add: islimpt_approachable)
lemma pointed_ball_nonempty: assumes"r > 0" shows"ball x r - {x :: 'a :: {perfect_space, metric_space}} ≠ {}" using perfect_choose_dist[of r x] assms by (auto simp: ball_def dist_commute)
lemma cball_eq_sing: fixes x :: "'a::{metric_space,perfect_space}" shows"cball x ε = {x} ⟷ ε = 0" using cball_eq_empty [of x ε] by (metis open_ball ball_subset_cball cball_trivial
centre_in_ball not_less_iff_gr_or_eq not_open_singleton subset_singleton_iff)
section‹Finite and discrete›
lemma finite_ball_include: fixes a :: "'a::metric_space" assumes"finite S" shows"∃ε>0. S ⊆ ball a ε" using assms proofinduction case (insert x S) thenobtain e0 where"e0>0"and e0:"S ⊆ ball a e0"by auto define ε where"ε = max e0 (2 * dist a x)" have"ε>0"unfolding ε_defusing‹e0>0›by auto moreoverhave"insert x S ⊆ ball a ε" using e0 ‹ε>0›unfolding ε_defby auto ultimatelyshow ?caseby auto qed (auto intro: zero_less_one)
lemma finite_set_avoid: fixes a :: "'a::metric_space" assumes"finite S" shows"∃δ>0. ∀x∈S. x ≠ a ⟶ δ ≤ dist a x" using assms proofinduction case (insert x S) thenobtain δ where"δ > 0"and δ: "∀x∈S. x ≠ a ⟶ δ ≤ dist a x" by blast thenshow ?case by (metis dist_nz dual_order.strict_implies_order insertE leI order.strict_trans2) qed (auto intro: zero_less_one)
lemma discrete_imp_closed: fixes S :: "'a::metric_space set" assumes ε: "0 < ε" and δ: "∀x ∈ S. ∀y ∈ S. dist y x < ε ⟶ y = x" shows"closed S" proof - have False if C: "∧ε. ε>0 ==>∃x'∈S. x' ≠ x ∧ dist x' x < ε"for x proof - obtain y where y: "y ∈ S""y ≠ x""dist y x < ε/2" by (meson C ε half_gt_zero) thenhave mp: "min (ε/2) (dist x y) > 0" by (simp add: dist_commute) from δ y C[OF mp] show ?thesis by metric qed thenshow ?thesis by (metis islimpt_approachable closed_limpt [where 'a='a]) qed
lemma discrete_imp_not_islimpt: assumes ε: "0 < ε" and δ: "∧x y. x ∈ S ==> y ∈ S ==> dist y x < ε ==> y = x" shows"¬ x islimpt S" by (metis closed_limpt δ discrete_imp_closed ε islimpt_approachable)
section‹Interior›
lemma mem_interior: "x ∈ interior S ⟷ (∃ε>0. ball x ε ⊆ S)" using open_contains_ball_eq [where S="interior S"] by (simp add: open_subset_interior)
lemma mem_interior_cball: "x ∈ interior S ⟷ (∃ε>0. cball x ε ⊆ S)" by (meson ball_subset_cball interior_subset mem_interior open_contains_cball open_interior
subset_trans)
lemma ball_iff_cball: "(∃r>0. ball x r ⊆ U) ⟷ (∃r>0. cball x r ⊆ U)" by (meson mem_interior mem_interior_cball)
section‹Frontier›
lemma frontier_straddle: fixes a :: "'a::metric_space" shows"a ∈ frontier S ⟷ (∀ε>0. (∃x∈S. dist a x < ε) ∧ (∃x. x ∉ S ∧ dist a x < ε))" unfolding frontier_def closure_interior by (auto simp: mem_interior subset_eq ball_def)
section‹Limits›
proposition Lim: "(f ---> l) net ⟷ trivial_limit net ∨ (∀ε>0. eventually (λx. dist (f x) l < ε) net)" by (auto simp: tendsto_iff trivial_limit_eq)
text‹Show that they yield usual definitions in the various cases.›
proposition Lim_within_le: "(f ---> l)(at a within S) ⟷ (∀ε>0. ∃δ>0. ∀x∈S. 0 < dist x a ∧ dist x a ≤ δ ⟶ dist (f x) l < ε)" by (auto simp: tendsto_iff eventually_at_le)
proposition Lim_within: "(f ---> l) (at a within S) ⟷ (∀ε >0. ∃δ>0. ∀x ∈ S. 0 < dist x a ∧ dist x a < δ ⟶ dist (f x) l < ε)" by (auto simp: tendsto_iff eventually_at)
corollary Lim_withinI [intro?]: assumes"∧ε. ε > 0 ==>∃δ>0. ∀x ∈ S. 0 < dist x a ∧ dist x a < δ ⟶ dist (f x) l ≤ ε" shows"(f ---> l) (at a within S)" unfolding Lim_within by (smt (verit, best) assms)
proposition Lim_at: "(f ---> l) (at a) ⟷ (∀ε >0. ∃δ>0. ∀x. 0 < dist x a ∧ dist x a < δ ⟶ dist (f x) l < ε)" by (auto simp: tendsto_iff eventually_at)
lemma Lim_transform_within_set: fixes a :: "'a::metric_space"and l :: "'b::metric_space" shows"[(f ---> l) (at a within S); eventually (λx. x ∈ S ⟷ x ∈ T) (at a)] ==> (f ---> l) (at a within T)" by (simp add: eventually_at Lim_within) (smt (verit, best))
text‹Another limit point characterization.›
lemma limpt_sequential_inj: fixes x :: "'a::metric_space" shows"x islimpt S ⟷ (∃f. (∀n::nat. f n ∈ S - {x}) ∧ inj f ∧ (f ---> x) sequentially)"
(is"?lhs = ?rhs") proof assume ?lhs thenhave"∀ε>0. ∃x'∈S. x' ≠ x ∧ dist x' x < ε" by (force simp: islimpt_approachable) thenobtain y where y: "∧ε. ε>0 ==> y ε ∈ S ∧ y ε ≠ x ∧ dist (y ε) x < ε" by metis define f where"f ≡ rec_nat (y 1) (λn fn. y (min (inverse(2 ^ (Suc n))) (dist fn x)))" have [simp]: "f 0 = y 1" and fSuc: "f(Suc n) = y (min (inverse(2 ^ (Suc n))) (dist (f n) x))"for n by (simp_all add: f_def) have f: "f n ∈ S ∧ (f n ≠ x) ∧ dist (f n) x < inverse(2 ^ n)"for n proof (induction n) case0show ?case by (simp add: y) next case (Suc n) thenhave"dist (f (Suc n)) x < inverse (2 ^ Suc n)" unfolding fSuc by (metis dist_nz min_less_iff_conj positive_imp_inverse_positive y zero_less_numeral
zero_less_power) with Suc show ?case by (auto simp: y fSuc) qed show ?rhs proof (intro exI conjI allI) show"∧n. f n ∈ S - {x}" using f by blast have"dist (f n) x < dist (f m) x"if"m < n"for m n using that proof (induction n) case0thenshow ?caseby simp next case (Suc n) then consider "m < n" | "m = n"using less_Suc_eq by blast thenshow ?case unfolding fSuc by (smt (verit, ccfv_threshold) Suc.IH dist_nz f y) qed thenshow"inj f" by (metis less_irrefl linorder_injI) have"∧ε n. [0 < ε; nat ⌈1 / ε::real⌉≤ n]==> inverse (2 ^ n) < ε" by (simp add: divide_simps order_le_less_trans) thenshow"f <---- x" by (meson order.strict_trans f lim_sequentially) qed next assume ?rhs thenshow ?lhs by (fastforce simp: islimpt_approachable lim_sequentially) qed
lemma Lim_dist_ubound: assumes"¬(trivial_limit net)" and"(f ---> l) net" and"eventually (λx. dist a (f x) ≤ ε) net" shows"dist a l ≤ ε" using assms by (fast intro: tendsto_le tendsto_intros)
section‹Continuity›
text‹Derive the epsilon-delta forms, which we often use as "definitions"›
proposition continuous_within_eps_delta: "continuous (at x within s) f ⟷ (∀ε>0. ∃δ>0. ∀x'∈ s. dist x' x < δ --> dist (f x') (f x) < ε)" unfolding continuous_within and Lim_within by fastforce
corollary continuous_at_eps_delta: "continuous (at x) f ⟷ (∀ε > 0. ∃δ > 0. ∀x'. dist x' x < δ ⟶ dist (f x') (f x) < ε)" using continuous_within_eps_delta [of x UNIV f] by simp
lemma continuous_at_right_real_increasing: fixes f :: "real → real" assumes nondecF: "∧x y. x ≤ y ==> f x ≤ f y" shows"continuous (at_right a) f ⟷ (∀ε>0. ∃δ>0. f (a + δ) - f a < ε)" apply (simp add: greaterThan_def dist_real_def continuous_within Lim_within_le) apply (intro all_cong ex_cong) by (smt (verit, best) nondecF)
lemma continuous_at_left_real_increasing: assumes nondecF: "∧ x y. x ≤ y ==> f x ≤ ((f y) :: real)" shows"(continuous (at_left (a :: real)) f) ⟷ (∀ε > 0. ∃δ > 0. f a - f (a - δ) < ε)" apply (simp add: lessThan_def dist_real_def continuous_within Lim_within_le) apply (intro all_cong ex_cong) by (smt (verit) nondecF)
text‹Versions in terms of open balls.›
lemma continuous_within_ball: "continuous (at x within S) f ⟷ (∀ε > 0. ∃δ > 0. f ` (ball x δ ∩ S) ⊆ ball (f x) ε)"
(is"?lhs = ?rhs") proof assume ?lhs
{ fix ε :: real assume"ε > 0" thenobtain δ where"δ>0"and δ: "∀y∈S. 0 < dist y x ∧ dist y x < δ ⟶ dist (f y) (f x) < ε" using‹?lhs›[unfolded continuous_within Lim_within] by auto have"y ∈ ball (f x) ε"if"y ∈ f ` (ball x δ ∩ S)"for y using that δ ‹ε > 0›by (auto simp: dist_commute) thenhave"∃δ>0. f ` (ball x δ ∩ S) ⊆ ball (f x) ε" using‹δ > 0›by blast
} thenshow ?rhs by auto next assume ?rhs thenshow ?lhs apply (simp add: continuous_within Lim_within ball_def subset_eq) by (metis (mono_tags, lifting) Int_iff dist_commute mem_Collect_eq) qed
corollary continuous_at_ball: "continuous (at x) f ⟷ (∀ε>0. ∃δ>0. f ` (ball x δ) ⊆ ball (f x) ε)" by (simp add: continuous_within_ball)
text‹Define setwise continuity in terms of limits within the set.›
lemma continuous_on_iff: "continuous_on s f ⟷ (∀x∈s. ∀ε>0. ∃δ>0. ∀x'∈s. dist x' x < δ ⟶ dist (f x') (f x) < ε)" unfolding continuous_on_def Lim_within by (metis dist_pos_lt dist_self)
lemma continuous_within_E: assumes"continuous (at x within S) f""ε>0" obtains δ where"δ>0""∧x'. [x'∈ S; dist x' x ≤ δ]==> dist (f x') (f x) < ε" using assms unfolding continuous_within_eps_delta by (metis dense order_le_less_trans)
lemma continuous_onI [intro?]: assumes"∧x ε. [ε > 0; x ∈ S]==>∃δ>0. ∀x'∈S. dist x' x < δ ⟶ dist (f x') (f x) ≤ ε" shows"continuous_on S f" using assms [OF half_gt_zero] by (force simp add: continuous_on_iff)
text‹Some simple consequential lemmas.›
lemma continuous_onE: assumes"continuous_on s f""x∈s""ε>0" obtains δ where"δ>0""∧x'. [x' ∈ s; dist x' x ≤ δ]==> dist (f x') (f x) < ε" using assms unfolding continuous_on_iff by (metis dense order_le_less_trans)
text‹The usual transformation theorems.›
lemma continuous_transform_within: fixes f g :: "'a::metric_space → 'b::topological_space" assumes"continuous (at x within s) f" and"0 < δ" and"x ∈ s" and"∧x'. [x' ∈ s; dist x' x < δ]==> f x' = g x'" shows"continuous (at x within s) g" using assms unfolding continuous_within by (force intro: Lim_transform_within)
section‹Closure and Limit Characterization›
lemma closure_approachable: fixes S :: "'a::metric_space set" shows"x ∈ closure S ⟷ (∀ε>0. ∃y∈S. dist y x < ε)" using dist_self by (force simp: closure_def islimpt_approachable)
lemma closure_approachable_le: fixes S :: "'a::metric_space set" shows"x ∈ closure S ⟷ (∀ε>0. ∃y∈S. dist y x ≤ ε)" unfolding closure_approachable using dense by force
lemma closure_approachableD: assumes"x ∈ closure S""ε>0" shows"∃y∈S. dist x y < ε" using assms unfolding closure_approachable by (auto simp: dist_commute)
lemma closed_approachable: fixes S :: "'a::metric_space set" shows"closed S ==> (∀ε>0. ∃y∈S. dist y x < ε) ⟷ x ∈ S" by (metis closure_closed closure_approachable)
lemma closure_contains_Inf: fixes S :: "real set" assumes"S ≠ {}""bdd_below S" shows"Inf S ∈ closure S" proof - have *: "∀x∈S. Inf S ≤ x" using cInf_lower[of _ S] assms by metis
{ fix ε :: real assume"ε > 0" thenhave"Inf S < Inf S + ε"by simp with assms obtain x where"x ∈ S""x < Inf S + ε" using cInf_lessD by blast with * have"∃x∈S. dist x (Inf S) < ε" using dist_real_def by force
} thenshow ?thesis unfolding closure_approachable by auto qed
lemma closure_contains_Sup: fixes S :: "real set" assumes"S ≠ {}""bdd_above S" shows"Sup S ∈ closure S" proof - have *: "∀x∈S. x ≤ Sup S" using cSup_upper[of _ S] assms by metis
{ fix ε :: real assume"ε > 0" thenhave"Sup S - ε < Sup S"by simp with assms obtain x where"x ∈ S""Sup S - ε < x" using less_cSupE by blast with * have"∃x∈S. dist x (Sup S) < ε" using dist_real_def by force
} thenshow ?thesis unfolding closure_approachable by auto qed
lemma not_trivial_limit_within_ball: "¬ trivial_limit (at x within S) ⟷ (∀ε>0. S ∩ ball x ε - {x} ≠ {})"
(is"?lhs ⟷ ?rhs") proof show ?rhs if ?lhs proof -
{ fix ε :: real assume"ε > 0" thenobtain y where"y ∈ S - {x}"and"dist y x < ε" using‹?lhs› not_trivial_limit_within[of x S] closure_approachable[of x "S - {x}"] by auto thenhave"y ∈ S ∩ ball x ε - {x}" unfolding ball_def by (simp add: dist_commute) thenhave"S ∩ ball x ε - {x} ≠ {}"by blast
} thenshow ?thesis by auto qed show ?lhs if ?rhs proof -
{ fix ε :: real assume"ε > 0" thenobtain y where"y ∈ S ∩ ball x ε - {x}" using‹?rhs›by blast thenhave"y ∈ S - {x}"and"dist y x < ε" unfolding ball_def by (simp_all add: dist_commute) thenhave"∃y ∈ S - {x}. dist y x < ε" by auto
} thenshow ?thesis using not_trivial_limit_within[of x S] closure_approachable[of x "S - {x}"] by auto qed qed
section‹Boundedness›
(* FIXME: This has to be unified with BSEQ!! *) definition✐‹tag important› (in metric_space) bounded :: "'a set → bool" where"bounded S ⟷ (∃x ε. ∀y∈S. dist x y ≤ ε)"
lemma bounded_subset_cball: "bounded S ⟷ (∃ε x. S ⊆ cball x ε ∧ 0 ≤ ε)" unfolding bounded_def subset_eq by auto (meson order_trans zero_le_dist)
lemma bounded_any_center: "bounded S ⟷ (∃ε. ∀y∈S. dist a y ≤ ε)" unfolding bounded_def by auto (metis add.commute add_le_cancel_right dist_commute dist_triangle_le)
lemma bounded_iff: "bounded S ⟷ (∃a. ∀x∈S. norm x ≤ a)" unfolding bounded_any_center [where a=0] by (simp add: dist_norm)
lemma boundedI: assumes"∧x. x ∈ S ==> norm x ≤ B" shows"bounded S" using assms bounded_iff by blast
lemma bounded_empty [simp]: "bounded {}" by (simp add: bounded_def)
lemma bounded_subset: "bounded T ==> S ⊆ T ==> bounded S" by (metis bounded_def subset_eq)
lemma bounded_interior[intro]: "bounded S ==> bounded(interior S)" by (metis bounded_subset interior_subset)
lemma bounded_closure[intro]: assumes"bounded S" shows"bounded (closure S)" proof - from assms obtain x and a where a: "∀y∈S. dist x y ≤ a" unfolding bounded_def by auto
{ fix y assume"y ∈ closure S" thenobtain f where f: "∀n. f n ∈ S""(f ---> y) sequentially" unfolding closure_sequential by auto have"∀n. f n ∈ S ⟶ dist x (f n) ≤ a"using a by simp thenhave"eventually (λn. dist x (f n) ≤ a) sequentially" by (simp add: f(1)) thenhave"dist x y ≤ a" using Lim_dist_ubound f(2) trivial_limit_sequentially by blast
} thenshow ?thesis unfolding bounded_def by auto qed
lemma bounded_cball[simp,intro]: "bounded (cball x ε)" unfolding bounded_def using mem_cball by blast
lemma bounded_ball[simp,intro]: "bounded (ball x ε)" by (metis ball_subset_cball bounded_cball bounded_subset)
lemma bounded_Un[simp]: "bounded (S ∪ T) ⟷ bounded S ∧ bounded T" unfolding bounded_def by (metis Un_iff bounded_any_center order.trans linorder_linear)
lemma bounded_Union[intro]: "finite F ==>∀S∈F. bounded S ==> bounded (∪F)" by (induct rule: finite_induct[of F]) auto
lemma bounded_UN [intro]: "finite A ==>∀x∈A. bounded (B x) ==> bounded (∪x∈A. B x)" by auto
lemma bounded_insert [simp]: "bounded (insert x S) ⟷ bounded S" by (metis bounded_Un bounded_cball cball_trivial insert_is_Un)
lemma bounded_subset_ballI: "S ⊆ ball x r ==> bounded S" by (meson bounded_ball bounded_subset)
lemma bounded_subset_ballD: assumes"bounded S"shows"∃r. 0 < r ∧ S ⊆ ball x r" proof - obtain ε::real and y where"S ⊆ cball y ε""0 ≤ ε" using assms by (auto simp: bounded_subset_cball) thenshow ?thesis by (intro exI[where x="dist x y + ε + 1"]) metric qed
lemma finite_imp_bounded [intro]: "finite S ==> bounded S" by (induct set: finite) simp_all
lemma bounded_Int[intro]: "bounded S ∨ bounded T ==> bounded (S ∩ T)" by (metis Int_lower1 Int_lower2 bounded_subset)
lemma bounded_diff[intro]: "bounded S ==> bounded (S - T)" by (metis Diff_subset bounded_subset)
lemma bounded_dist_comp: assumes"bounded (f ` S)""bounded (g ` S)" shows"bounded ((λx. dist (f x) (g x)) ` S)" proof - from assms obtain M1 M2 where *: "dist (f x) undefined ≤ M1""dist undefined (g x) ≤ M2"if"x ∈ S"for x by (auto simp: bounded_any_center[of _ undefined] dist_commute) have"dist (f x) (g x) ≤ M1 + M2"if"x ∈ S"for x using *[OF that] by metric thenshow ?thesis by (auto intro!: boundedI) qed
lemma bounded_Times: assumes"bounded S""bounded T" shows"bounded (S × T)" proof - obtain x y a b where"∀z∈S. dist x z ≤ a""∀z∈T. dist y z ≤ b" using assms [unfolded bounded_def] by auto thenhave"∀z∈S × T. dist (x, y) z ≤ sqrt (a2 + b2)" by (auto simp: dist_Pair_Pair real_sqrt_le_mono add_mono power_mono) thenshow ?thesis unfolding bounded_any_center [where a="(x, y)"] by auto qed
section‹Compactness›
lemma compact_imp_bounded: assumes"compact U" shows"bounded U" proof - have"compact U""∀x∈U. open (ball x 1)""U ⊆ (∪x∈U. ball x 1)" using assms by auto thenobtain D where D: "D ⊆ U""finite D""U ⊆ (∪x∈D. ball x 1)" by (metis compactE_image) from‹finite D›have"bounded (∪x∈D. ball x 1)" by (simp add: bounded_UN) thenshow"bounded U"using‹U ⊆ (∪x∈D. ball x 1)› by (rule bounded_subset) qed
lemma continuous_on_compact_bound: assumes"compact A""continuous_on A f" obtains B where"B ≥ 0""∧x. x ∈ A ==> norm (f x) ≤ B" proof - have"compact (f ` A)"by (metis assms compact_continuous_image) thenobtain B where"∀x∈A. norm (f x) ≤ B" by (auto dest!: compact_imp_bounded simp: bounded_iff) hence"max B 0 ≥ 0"and"∀x∈A. norm (f x) ≤ max B 0"by auto thus ?thesis using that by blast qed
lemma closure_Int_ball_not_empty: assumes"S ⊆ closure T""x ∈ S""r > 0" shows"T ∩ ball x r ≠ {}" using assms centre_in_ball closure_iff_nhds_not_empty by blast
lemma compact_sup_maxdistance: fixes S :: "'a::metric_space set" assumes"compact S" and"S ≠ {}" shows"∃x∈S. ∃y∈S. ∀u∈S. ∀v∈S. dist u v ≤ dist x y" proof - have"compact (S × S)" using‹compact S›by (intro compact_Times) moreoverhave"S × S ≠ {}" using‹S ≠ {}›by auto moreoverhave"continuous_on (S × S) (λx. dist (fst x) (snd x))" by (intro continuous_at_imp_continuous_on ballI continuous_intros) ultimatelyshow ?thesis using continuous_attains_sup[of "S × S""λx. dist (fst x) (snd x)"] by auto qed
text‹
If ‹A› is a compact subset of an open set ‹B› in a metric space, then there exists an ‹ε > 0›
such that the Minkowski sum of ‹A› with an open ball of radius ‹ε› is also a subset of ‹B›. › lemma compact_subset_open_imp_ball_epsilon_subset: assumes"compact A""open B""A ⊆ B" obtains ε where"ε > 0""(∪x∈A. ball x ε) ⊆ B" proof - have"∀x∈A. ∃ε. ε > 0 ∧ ball x ε ⊆ B" using assms unfolding open_contains_ball by blast thenobtain ε where ε: "∧x. x ∈ A ==> ε x > 0""∧x. x ∈ A ==> ball x (ε x) ⊆ B" by metis define C where"C = ε ` A" obtain X where X: "X ⊆ A""finite X""A ⊆ (∪c∈X. ball c (ε c / 2))" using‹compact A› proof (rule compactE_image) show"open (ball x (ε x / 2))"if"x ∈ A"for x by simp show"A ⊆ (∪c∈A. ball c (ε c / 2))" using ε by auto qed auto
define e' where"e' = Min (insert 1 ((λx. ε x / 2) ` X))" have"e' > 0" unfolding e'_defusing ε X by (subst Min_gr_iff) auto have e': "e' ≤ ε x / 2"if"x ∈ X"for x using that X unfolding e'_defby (intro Min.coboundedI) auto
show ?thesis proof show"e' > 0" by fact next show"(∪x∈A. ball x e') ⊆ B" proof clarify fix x y assume xy: "x ∈ A""y ∈ ball x e'" from xy(1) X obtain z where z: "z ∈ X""x ∈ ball z (ε z / 2)" by auto have"dist y z ≤ dist x y + dist z x" by (metis dist_commute dist_triangle) alsohave"dist z x < ε z / 2" using xy z by auto alsohave"dist x y < e'" using xy by auto alsohave"…≤ ε z / 2" using z by (intro e') auto finallyhave"y ∈ ball z (ε z)" by (simp add: dist_commute) alsohave"…⊆ B" using z X by (intro ε) auto finallyshow"y ∈ B" . qed qed qed
lemma compact_subset_open_imp_cball_epsilon_subset: assumes"compact A""open B""A ⊆ B" obtains ε where"ε > 0""(∪x∈A. cball x ε) ⊆ B" proof - obtain ε where"ε > 0"and ε: "(∪x∈A. ball x ε) ⊆ B" using compact_subset_open_imp_ball_epsilon_subset [OF assms] by blast thenhave"(∪x∈A. cball x (ε / 2)) ⊆ (∪x∈A. ball x ε)" by auto with‹0 < \ε› that show ?thesis by (metis ε half_gt_zero_iff order_trans) qed
subsubsection‹Totally bounded›
proposition seq_compact_imp_totally_bounded: assumes"seq_compact S" shows"∀ε>0. ∃k. finite k ∧ k ⊆ S ∧ S ⊆ (∪x∈k. ball x ε)" proof -
{ fix ε::real assume"ε > 0"assume *: "∧k. finite k ==> k ⊆ S ==>¬ S ⊆ (∪x∈k. ball x ε)" let ?Q = "λx n r. r ∈ S ∧ (∀m < (n::nat). ¬ (dist (x m) r < ε))" have"∃x. ∀n::nat. ?Q x n (x n)" proof (rule dependent_wellorder_choice) fix n x assume"∧y. y < n ==> ?Q x y (x y)" thenhave"¬ S ⊆ (∪x∈x ` {0..<n}. ball x ε)" using *[of "x ` {0 ..< n}"] by (auto simp: subset_eq) thenobtain z where z:"z∈S""z ∉ (∪x∈x ` {0..<n}. ball x ε)" unfolding subset_eq by auto show"∃r. ?Q x n r" using z by auto qed simp thenobtain x where"∀n::nat. x n ∈ S"and x:"∧n m. m < n ==>¬ (dist (x m) (x n) < ε)" by blast thenobtain l r where"l ∈ S"and r:"strict_mono r"and"(x ∘ r) <---- l" using assms by (metis seq_compact_def) thenhave"Cauchy (x ∘ r)" using LIMSEQ_imp_Cauchy by auto thenobtain N::nat where"∧m n. N ≤ m ==> N ≤ n ==> dist ((x ∘ r) m) ((x ∘ r) n) < ε" unfolding Cauchy_def using‹ε > 0›by blast thenhave False using x[of "r N""r (N+1)"] r by (auto simp: strict_mono_def) } thenshow ?thesis by metis qed
subsubsection‹Heine-Borel theorem›
proposition seq_compact_imp_Heine_Borel: fixes S :: "'a :: metric_space set" assumes"seq_compact S" shows"compact S" proof - obtain f where f: "∀ε>0. finite (f ε) ∧ f ε ⊆ S ∧ S ⊆ (∪x∈f ε. ball x ε)" by (metis assms seq_compact_imp_totally_bounded) define K where"K = (λ(x, r). ball x r) ` ((∪ε ∈ℚ∩ {0 <..}. f ε) ×ℚ)" have"countably_compact S" using‹seq_compact S›by (rule seq_compact_imp_countably_compact) thenshow"compact S" proof (rule countably_compact_imp_compact) show"countable K" unfolding K_def using f by (meson countable_Int1 countable_SIGMA countable_UN countable_finite
countable_image countable_rat greaterThan_iff inf_le2 subset_iff) show"∀b∈K. open b"by (auto simp: K_def) next fix T x assume T: "open T""x ∈ T"and x: "x ∈ S" from openE[OF T] obtain ε where"0 < ε""ball x ε ⊆ T" by auto thenhave"0 < ε/2""ball x (ε/2) ⊆ T" by auto from Rats_dense_in_real[OF ‹0 < \ε/2›] obtain r where"r ∈ℚ""0 < r""r < ε/2" by auto from f[rule_format, of r] ‹0 < r›‹x ∈ S›obtain k where"k ∈ f r""x ∈ ball k r" by auto from‹r ∈ℚ›‹0 < r›‹k ∈ f r›have"ball k r ∈ K" by (auto simp: K_def) thenshow"∃b∈K. x ∈ b ∧ b ∩ S ⊆ T" proof (rule rev_bexI, intro conjI subsetI) fix y assume"y ∈ ball k r ∩ S" with‹r < \ε/2›‹x ∈ ball k r›have"dist x y < ε" by (intro dist_triangle_half_r [of k _ ε]) (auto simp: dist_commute) with‹ball x ε ⊆ T›show"y ∈ T" by auto next show"x ∈ ball k r"by fact qed qed qed
proposition compact_eq_seq_compact_metric: "compact (S :: 'a::metric_space set) ⟷ seq_compact S" using compact_imp_seq_compact seq_compact_imp_Heine_Borel by blast
proposition compact_def: ―‹this is the definition of compactness in HOL Light› "compact (S :: 'a::metric_space set) ⟷ (∀f. (∀n. f n ∈ S) ⟶ (∃l∈S. ∃r::nat→nat. strict_mono r ∧ (f ∘ r) <---- l))" unfolding compact_eq_seq_compact_metric seq_compact_def by auto
subsubsection‹Complete the chain of compactness variants›
proposition compact_eq_Bolzano_Weierstrass: fixes S :: "'a::metric_space set" shows"compact S ⟷ (∀T. infinite T ∧ T ⊆ S ⟶ (∃x ∈ S. x islimpt T))" by (meson Bolzano_Weierstrass_imp_seq_compact Heine_Borel_imp_Bolzano_Weierstrass seq_compact_imp_Heine_Borel)
proposition Bolzano_Weierstrass_imp_bounded: "(∧T. [infinite T; T ⊆ S]==> (∃x ∈ S. x islimpt T)) ==> bounded S" using compact_imp_bounded unfolding compact_eq_Bolzano_Weierstrass by metis
section‹Banach fixed point theorem›
theorem Banach_fix: assumes S: "complete S""S ≠ {}" and c: "0 ≤ c""c < 1" and f: "f ` S ⊆ S" and lipschitz: "∧x y. [x∈S; y∈S]==> dist (f x) (f y) ≤ c * dist x y" shows"∃!x∈S. f x = x" proof - from S obtain z0 where z0: "z0 ∈ S"by blast define z where"z n = (f ^^ n) z0"for n with f z0 have z_in_s: "z n ∈ S"for n :: nat by (induct n) auto define δ where"δ = dist (z 0) (z 1)"
have fzn: "f (z n) = z (Suc n)"for n by (simp add: z_def) have cf_z: "dist (z n) (z (Suc n)) ≤ (c ^ n) * δ"for n :: nat proof (induct n) case0 thenshow ?case by (simp add: δ_def) next case (Suc m) with‹0 ≤ c›have"c * dist (z m) (z (Suc m)) ≤ c ^ Suc m * δ" using mult_left_mono[of "dist (z m) (z (Suc m))""c ^ m * δ" c] by simp thenshow ?case by (metis fzn lipschitz order_trans z_in_s) qed
have cf_z2: "(1 - c) * dist (z m) (z (m + n)) ≤ (c ^ m) * δ * (1 - c ^ n)"for n m :: nat proof (induct n) case0 show ?caseby simp next case (Suc k) from c have"(1 - c) * dist (z m) (z (m + Suc k)) ≤ (1 - c) * (dist (z m) (z (m + k)) + dist (z (m + k)) (z (Suc (m + k))))" by (simp add: dist_triangle) alsofrom c cf_z[of "m + k"] have"…≤ (1 - c) * (dist (z m) (z (m + k)) + c ^ (m + k) * δ)" by simp alsofrom Suc have"…≤ c ^ m * δ * (1 - c ^ k) + (1 - c) * c ^ (m + k) * δ" by (simp add: field_simps) alsohave"… = (c ^ m) * (δ * (1 - c ^ k) + (1 - c) * c ^ k * δ)" by (simp add: power_add field_simps) alsofrom c have"…≤ (c ^ m) * δ * (1 - c ^ Suc k)" by (simp add: field_simps) finallyshow ?case . qed
have"∃N. ∀m n. N ≤ m ∧ N ≤ n ⟶ dist (z m) (z n) < ε"if"ε > 0"for ε proof (cases "δ = 0") case True have"(1 - c) * x ≤ 0 ⟷ x ≤ 0"for x using c mult_le_0_iff nle_le by fastforce with c cf_z2[of 0] True have"z n = z0"for n by (simp add: z_def) with‹ε > 0›show ?thesis by simp next case False with zero_le_dist[of "z 0""z 1"] have"δ > 0" by (metis δ_def less_le) with c ‹ε > 0›have"0 < ε * (1 - c) / δ" by simp with c obtain N where N: "c ^ N < ε * (1 - c) / δ" using real_arch_pow_inv[of "ε * (1 - c) / δ" c] by auto have *: "dist (z m) (z n) < ε"if"m > n"and as: "m ≥ N""n ≥ N"for m n :: nat proof - have *: "c ^ n ≤ c ^ N" using power_decreasing[OF ‹n≥N›, of c] c by simp have"1 - c ^ (m - n) > 0" using power_strict_mono[of c 1"m - n"] c ‹m > n›by simp with‹δ > 0› c have **: "δ * (1 - c ^ (m - n)) / (1 - c) > 0" by simp from cf_z2[of n "m - n"] ‹m > n› have"dist (z m) (z n) ≤ c ^ n * δ * (1 - c ^ (m - n)) / (1 - c)" by (simp add: pos_le_divide_eq c mult.commute dist_commute) alsohave"…≤ c ^ N * δ * (1 - c ^ (m - n)) / (1 - c)" using mult_right_mono[OF * order_less_imp_le[OF **]] by (simp add: mult.assoc) alsohave"… < (ε * (1 - c) / δ) * δ * (1 - c ^ (m - n)) / (1 - c)" using mult_strict_right_mono[OF N **] by (auto simp: mult.assoc) alsofrom c ‹1 - c ^ (m - n) > 0›‹ε > 0›have"…≤ ε" using mult_right_le_one_le[of ε "1 - c ^ (m - n)"] by auto finallyshow ?thesis . qed have"dist (z n) (z m) < ε"if"N ≤ m""N ≤ n"for m n :: nat using *[of n m] *[of m n] using‹0 < \ε› dist_commute_lessI that by fastforce thenshow ?thesis by auto qed thenhave"Cauchy z" by (metis metric_CauchyI) thenobtain x where"x∈S"and x:"(z ---> x) sequentially" using‹complete S› complete_def z_in_s by blast
define ε where"ε = dist (f x) x" have"ε = 0" proof (rule ccontr) assume"ε ≠ 0" thenhave"ε > 0" unfolding ε_defusing zero_le_dist[of "f x" x] by (metis dist_eq_0_iff dist_nz ε_def) thenobtain N where N:"∀n≥N. dist (z n) x < ε/2" using x[unfolded lim_sequentially, THEN spec[where x="ε/2"]] by auto thenhave N':"dist (z N) x < ε/2"by auto have *: "c * dist (z N) x ≤ dist (z N) x" unfolding mult_le_cancel_right2 using zero_le_dist[of "z N" x] and c by (metis dist_eq_0_iff dist_nz order_less_asym less_le) have"dist (f (z N)) (f x) ≤ c * dist (z N) x" by (simp add: ‹x ∈ S› lipschitz z_in_s) alsohave"… < ε/2" using N' and c using * by auto finallyshow False unfolding fzn by (metis N ε_def dist_commute dist_triangle_half_l le_eq_less_or_eq lessI
order_less_irrefl) qed thenhave"f x = x"by (auto simp: ε_def) moreoverhave"y = x"if"f y = y""y ∈ S"for y proof - from‹x ∈ S›‹f x = x› that have"dist x y ≤ c * dist x y" using lipschitz by fastforce with c and zero_le_dist[of x y] have"dist x y = 0" by (simp add: mult_le_cancel_right1) thenshow ?thesis by simp qed ultimatelyshow ?thesis using‹x∈S›by blast qed
section‹Edelstein fixed point theorem›
theorem Edelstein_fix: fixes S :: "'a::metric_space set" assumes S: "compact S""S ≠ {}" and gs: "(g ` S) ⊆ S" and dist: "∧x y. [x∈S; y∈S]==> x ≠ y ⟶ dist (g x) (g y) < dist x y" shows"∃!x∈S. g x = x" proof - let ?D = "(λx. (x, x)) ` S" have D: "compact ?D""?D ≠ {}" by (rule compact_continuous_image)
(auto intro!: S continuous_Pair continuous_ident simp: continuous_on_eq_continuous_within)
have"∧x y ε. x ∈ S ==> y ∈ S ==> 0 < ε ==> dist y x < ε ==> dist (g y) (g x) < ε" using dist by fastforce thenhave"continuous_on S g" by (auto simp: continuous_on_iff) thenhave cont: "continuous_on ?D (λx. dist ((g ∘ fst) x) (snd x))" unfolding continuous_on_eq_continuous_within by (intro continuous_dist ballI continuous_within_compose)
(auto intro!: continuous_fst continuous_snd continuous_ident simp: image_image)
obtain a where"a ∈ S"and le: "∧x. x ∈ S ==> dist (g a) a ≤ dist (g x) x" using continuous_attains_inf[OF D cont] by auto
have"g a = a" by (metis ‹a ∈ S› dist gs image_subset_iff le order.strict_iff_not) moreoverhave"∧x. x ∈ S ==> g x = x ==> x = a" using‹a ∈ S› calculation dist by fastforce ultimatelyshow"∃!x∈S. g x = x" using‹a ∈ S›by blast qed
section‹The diameter of a set›
definition✐‹tag important› diameter :: "'a::metric_space set → real"where "diameter S = (if S = {} then 0 else SUP (x,y)∈S×S. dist x y)"
lemma diameter_empty [simp]: "diameter{} = 0" by (auto simp: diameter_def)
lemma diameter_singleton [simp]: "diameter{x} = 0" by (auto simp: diameter_def)
lemma diameter_le: assumes"S ≠ {} ∨ 0 ≤ δ" and no: "∧x y. [x ∈ S; y ∈ S]==> norm(x - y) ≤ δ" shows"diameter S ≤ δ" using assms by (auto simp: dist_norm diameter_def intro: cSUP_least)
lemma diameter_bounded_bound: fixes S :: "'a :: metric_space set" assumes S: "bounded S""x ∈ S""y ∈ S" shows"dist x y ≤ diameter S" proof - from S obtain z δ where z: "∧x. x ∈ S ==> dist z x ≤ δ" unfolding bounded_def by auto have"bdd_above (case_prod dist ` (S×S))" proof (intro bdd_aboveI, safe) fix a b assume"a ∈ S""b ∈ S" with z[of a] z[of b] dist_triangle[of a b z] show"dist a b ≤ 2 * δ" by (simp add: dist_commute) qed moreoverhave"(x,y) ∈ S×S"using S by auto ultimatelyhave"dist x y ≤ (SUP (x,y)∈S×S. dist x y)" by (rule cSUP_upper2) simp with‹x ∈ S›show ?thesis by (auto simp: diameter_def) qed
lemma diameter_lower_bounded: fixes S :: "'a :: metric_space set" assumes S: "bounded S" and δ: "0 < δ""δ < diameter S" shows"∃x∈S. ∃y∈S. δ < dist x y" proof (rule ccontr) assume contr: "¬ ?thesis" moreoverhave"S ≠ {}" using δ by (auto simp: diameter_def) ultimatelyhave"diameter S ≤ δ" by (auto simp: not_less diameter_def intro!: cSUP_least) with‹δ < diameter S›show False by auto qed
lemma diameter_bounded: assumes"bounded S" shows"∀x∈S. ∀y∈S. dist x y ≤ diameter S" and"∀δ>0. δ < diameter S ⟶ (∃x∈S. ∃y∈S. dist x y > δ)" using diameter_bounded_bound[of S] diameter_lower_bounded[of S] assms by auto
lemma bounded_two_points: "bounded S ⟷ (∃ε. ∀x∈S. ∀y∈S. dist x y ≤ ε)" by (meson bounded_def diameter_bounded(1))
lemma diameter_compact_attained: assumes"compact S" and"S ≠ {}" shows"∃x∈S. ∃y∈S. dist x y = diameter S" proof - have b: "bounded S"using assms(1) by (rule compact_imp_bounded) thenobtain x y where xys: "x∈S""y∈S" and xy: "∀u∈S. ∀v∈S. dist u v ≤ dist x y" using compact_sup_maxdistance[OF assms] by auto thenhave"diameter S ≤ dist x y" unfolding diameter_def by (force intro!: cSUP_least) thenshow ?thesis by (metis b diameter_bounded_bound order_antisym xys) qed
lemma diameter_subset: assumes"S ⊆ T""bounded T" shows"diameter S ≤ diameter T" proof (cases "S = {} ∨ T = {}") case True with assms show ?thesis by (force simp: diameter_ge_0) next case False thenhave"bdd_above ((λx. case x of (x, xa) → dist x xa) ` (T × T))" using‹bounded T› diameter_bounded_bound by (force simp: bdd_above_def) with False ‹S ⊆ T›show ?thesis by (simp add: diameter_def cSUP_subset_mono times_subset_iff) qed
lemma diameter_closure: assumes"bounded S" shows"diameter(closure S) = diameter S" proof (rule order_antisym) have False if d_less_d: "diameter S < diameter (closure S)" proof - define δ where"δ = diameter(closure S) - diameter(S)" have"δ > 0" using that by (simp add: δ_def) thenhave dle: "diameter(closure(S)) - δ / 2 < diameter(closure(S))" by simp have dd: "diameter (closure S) - δ / 2 = (diameter(closure(S)) + diameter(S)) / 2" by (simp add: δ_def field_split_simps) have bocl: "bounded (closure S)" using assms by blast moreover have"diameter S ≠ 0" using diameter_bounded_bound [OF assms] by (metis closure_closed discrete_imp_closed dist_le_zero_iff not_less_iff_gr_or_eq
that) thenhave"0 < diameter S" using assms diameter_ge_0 by fastforce ultimatelyobtain x y where"x ∈ closure S""y ∈ closure S"and xy: "diameter(closure(S)) - δ / 2 < dist x y" using diameter_lower_bounded [OF bocl, of "diameter S"] by (metis d_less_d diameter_bounded(2) dist_not_less_zero dist_self dle
not_less_iff_gr_or_eq) thenobtain x' y' where x'y': "x' ∈ S""dist x' x < δ/4""y' ∈ S""dist y' y < δ/4" by (metis ‹0 < \δ› zero_less_divide_iff zero_less_numeral closure_approachable) thenhave"dist x' y' ≤ diameter S" using assms diameter_bounded_bound by blast with x'y' have"dist x y ≤ δ / 4 + diameter S + δ / 4" by (meson add_mono dist_triangle dist_triangle3 less_eq_real_def order_trans) thenshow ?thesis using xy δ_defby linarith qed thenshow"diameter (closure S) ≤ diameter S" by fastforce next show"diameter S ≤ diameter (closure S)" by (simp add: assms bounded_closure closure_subset diameter_subset) qed
proposition Lebesgue_number_lemma: assumes"compact S""C≠ {}""S ⊆∪C"and ope: "∧B. B ∈C==> open B" obtains δ where"0 < δ""∧T. [T ⊆ S; diameter T < δ]==>∃B ∈C. T ⊆ B" proof (cases "S = {}") case True thenshow ?thesis by (metis ‹C≠ {}› zero_less_one empty_subsetI equals0I subset_trans that) next case False have"∃r C. r > 0 ∧ ball x (2*r) ⊆ C ∧ C ∈C"if"x ∈ S"for x by (metis ‹S ⊆∪C› field_sum_of_halves half_gt_zero mult.commute mult_2_right
UnionE ope open_contains_ball subset_eq that) thenobtain r where r: "∧x. x ∈ S ==> r x > 0 ∧ (∃C ∈C. ball x (2*r x) ⊆ C)" by metis thenhave"S ⊆ (∪x ∈ S. ball x (r x))" by auto thenobtainTwhere"finite T""S ⊆∪T"andT: "T⊆ (λx. ball x (r x)) ` S" by (rule compactE [OF ‹compact S›]) auto thenobtain S0 where"S0 ⊆ S""finite S0"and S0: "T = (λx. ball x (r x)) ` S0" by (meson finite_subset_image) thenhave"S0 ≠ {}" using False ‹S ⊆∪T›by auto define δ where"δ = Inf (r ` S0)" have"δ > 0" using‹finite S0›‹S0 ⊆ S›‹S0 ≠ {}› r by (auto simp: δ_def finite_less_Inf_iff) show ?thesis proof show"0 < δ" by (simp add: ‹0 < \δ›) show"∃B ∈C. T ⊆ B"if"T ⊆ S"and dia: "diameter T < δ"for T proof (cases "T = {}") case False thenobtain y where"y ∈ T"by blast thenhave"y ∈ S" using‹T ⊆ S›by auto thenobtain x where"x ∈ S0"and x: "y ∈ ball x (r x)" using‹S ⊆∪T› S0 that by blast have"ball y δ ⊆ ball y (r x)" by (metis δ_def‹S0 ≠ {}›‹finite S0›‹x ∈ S0› empty_is_image finite_imageI finite_less_Inf_iff imageI less_irrefl not_le subset_ball) alsohave"…⊆ ball x (2*r x)" using x by metric finallyobtain C where"C ∈C""ball y δ ⊆ C" by (meson r ‹S0 ⊆ S›‹x ∈ S0› dual_order.trans subsetCE) have"bounded T" using‹compact S› bounded_subset compact_imp_bounded ‹T ⊆ S›by blast thenhave"T ⊆ ball y δ" using‹y ∈ T› dia diameter_bounded_bound by fastforce thenshow ?thesis by (meson ‹C ∈C›‹ball y δ ⊆ C› subset_eq) qed (use‹C≠ {}›in auto) qed qed
section‹Metric spaces with the Heine-Borel property›
text‹
A metric space (or topological vector space) is said to have the
Heine-Borel property if every closed and bounded subset is compact. ›
proposition bounded_closed_imp_seq_compact: fixes S::"'a::heine_borel set" assumes"bounded S" and"closed S" shows"seq_compact S" unfolding seq_compact_def proof (intro strip) fix f :: "nat → 'a" assume f: "∀n. f n ∈ S" with‹bounded S›have"bounded (range f)" by (auto intro: bounded_subset) obtain l r where r: "strict_mono (r :: nat → nat)"and l: "((f ∘ r) ---> l) sequentially" using bounded_imp_convergent_subsequence [OF ‹bounded (range f)›] by auto from f have fr: "∀n. (f ∘ r) n ∈ S" by simp show"∃l∈S. ∃r. strict_mono r ∧ (f ∘ r) <---- l" using assms(2) closed_sequentially fr l r by blast qed
lemma compact_eq_bounded_closed: fixes S :: "'a::heine_borel set" shows"compact S ⟷ bounded S ∧ closed S" using bounded_closed_imp_seq_compact compact_eq_seq_compact_metric compact_imp_bounded compact_imp_closed by auto
lemma bounded_infinite_imp_islimpt: fixes S :: "'a::heine_borel set" assumes"T ⊆ S""bounded S""infinite T" obtains x where"x islimpt S" by (meson assms closed_limpt compact_eq_Bolzano_Weierstrass compact_eq_bounded_closed islimpt_subset)
lemma compact_Inter: fixesF :: "'a :: heine_borel set set" assumes com: "∧S. S ∈F==> compact S"and"F≠ {}" shows"compact(∩F)" using assms by (meson Inf_lower all_not_in_conv bounded_subset closed_Inter compact_eq_bounded_closed)
lemma compact_closure [simp]: fixes S :: "'a::heine_borel set" shows"compact(closure S) ⟷ bounded S" by (meson bounded_closure bounded_subset closed_closure closure_subset compact_eq_bounded_closed)
instance✐‹tag important› real :: heine_borel proof fix f :: "nat → real" assume f: "bounded (range f)" obtain r :: "nat → nat"where r: "strict_mono r""monoseq (f ∘ r)" unfolding comp_def by (metis seq_monosub) thenhave"Bseq (f ∘ r)" unfolding Bseq_eq_bounded by (metis f BseqI' bounded_iff comp_apply rangeI) with r show"∃l r. strict_mono r ∧ (f ∘ r) <---- l" using Bseq_monoseq_convergent[of "f ∘ r"] by (auto simp: convergent_def) qed
lemma compact_lemma_general: fixes f :: "nat → 'a" fixes proj::"'a → 'b → 'c::heine_borel" (infixl‹proj›60) fixes unproj:: "('b → 'c) → 'a" assumes finite_basis: "finite basis" assumes bounded_proj: "∧k. k ∈ basis ==> bounded ((λx. x proj k) ` range f)" assumes proj_unproj: "∧ε k. k ∈ basis ==> (unproj ε) proj k = ε k" assumes unproj_proj: "∧x. unproj (λk. x proj k) = x" shows"∀δ⊆basis. ∃l::'a. ∃ r::nat→nat. strict_mono r ∧ (∀ε>0. eventually (λn. ∀i∈δ. dist (f (r n) proj i) (l proj i) < ε) sequentially)" proof safe fix δ :: "'b set" assume δ: "δ ⊆ basis" with finite_basis have"finite δ" by (blast intro: finite_subset) from this δ show"∃l::'a. ∃r::nat→nat. strict_mono r ∧ (∀ε>0. eventually (λn. ∀i∈δ. dist (f (r n) proj i) (l proj i) < ε) sequentially)" proof (induct δ) case empty thenshow ?case unfolding strict_mono_def by auto next case (insert k δ) have k[intro]: "k ∈ basis" using insert by auto have s': "bounded ((λx. x proj k) ` range f)" using k by (rule bounded_proj) obtain l1::"'a"and r1 where r1: "strict_mono r1" and lr1: "∀ε > 0. ∀F n in sequentially. ∀i∈δ. dist (f (r1 n) proj i) (l1 proj i) < ε" using insert by auto have f': "∀n. f (r1 n) proj k ∈ (λx. x proj k) ` range f" by simp have"bounded (range (λi. f (r1 i) proj k))" by (metis (lifting) bounded_subset f' image_subsetI s') thenobtain l2 r2 where r2: "strict_mono r2"and lr2: "(λi. f (r1 (r2 i)) proj k) <---- l2" using bounded_imp_convergent_subsequence[of "λi. f (r1 i) proj k"] by (auto simp: o_def) define r where"r = r1 ∘ r2" have r: "strict_mono r" using r1 and r2 unfolding r_def o_def strict_mono_def by auto moreover define l where"l = unproj (λi. if i = k then l2 else l1 proj i)"
{ fix ε::real assume"ε > 0" from lr1 ‹ε > 0›have N1: "∀F n in sequentially. ∀i∈δ. dist (f (r1 n) proj i) (l1 proj i) < ε" by blast from lr2 ‹ε > 0›have N2: "∀F n in sequentially. dist (f (r1 (r2 n)) proj k) l2 < ε" by (rule tendstoD) from r2 N1 have N1': "∀F n in sequentially. ∀i∈δ. dist (f (r1 (r2 n)) proj i) (l1 proj i) < ε" by (rule eventually_subseq) have"∀F n in sequentially. ∀i∈insert k δ. dist (f (r n) proj i) (l proj i) < ε" using N1' N2 by eventually_elim (use insert.prems in‹auto simp: l_def r_def o_def proj_unproj›)
} ultimatelyshow ?caseby auto qed qed
lemma bounded_fst: "bounded s ==> bounded (fst ` s)" unfolding bounded_def by (metis (erased, opaque_lifting) dist_fst_le image_iff order_trans)
lemma bounded_snd: "bounded s ==> bounded (snd ` s)" unfolding bounded_def by (metis (no_types, opaque_lifting) dist_snd_le image_iff order.trans)
instance✐‹tag important› prod :: (heine_borel, heine_borel) heine_borel proof fix f :: "nat → 'a × 'b" assume f: "bounded (range f)" thenhave"bounded (fst ` range f)" by (rule bounded_fst) thenhave s1: "bounded (range (fst ∘ f))" by (simp add: image_comp) obtain l1 r1 where r1: "strict_mono r1"and l1: "(λn. fst (f (r1 n))) <---- l1" using bounded_imp_convergent_subsequence [OF s1] unfolding o_def by fast from f have s2: "bounded (range (snd ∘ f ∘ r1))" by (auto simp: image_comp intro: bounded_snd bounded_subset) obtain l2 r2 where r2: "strict_mono r2"and l2: "(λn. snd (f (r1 (r2 n)))) <---- l2" using bounded_imp_convergent_subsequence [OF s2] unfolding o_def by fast have l1': "((λn. fst (f (r1 (r2 n)))) ---> l1) sequentially" using LIMSEQ_subseq_LIMSEQ [OF l1 r2] unfolding o_def . have l: "((f ∘ (r1 ∘ r2)) ---> (l1, l2)) sequentially" using tendsto_Pair [OF l1' l2] unfolding o_def by simp have r: "strict_mono (r1 ∘ r2)" using r1 r2 unfolding strict_mono_def by simp show"∃l r. strict_mono r ∧ ((f ∘ r) ---> l) sequentially" using l r by fast qed
section‹Completeness›
proposition (in metric_space) completeI: assumes"∧f. ∀n. f n ∈ s ==> Cauchy f ==>∃l∈s. f <---- l" shows"complete s" using assms unfolding complete_def by fast
proposition (in metric_space) completeE: assumes"complete s"and"∀n. f n ∈ s"and"Cauchy f" obtains l where"l ∈ s"and"f <---- l" using assms unfolding complete_def by fast
(* TODO: generalize to uniform spaces *) lemma compact_imp_complete: fixes S :: "'a::metric_space set" assumes"compact S" shows"complete S" unfolding complete_def proof clarify fix f assume as: "(∀n::nat. f n ∈ S)""Cauchy f" from as(1) obtain l r where lr: "l∈S""strict_mono r""(f ∘ r) <---- l" using assms unfolding compact_def by blast
note lr' = seq_suble [OF lr(2)]
{ fix ε :: real assume"ε > 0" from as(2) obtain N where N:"∀m n. N ≤ m ∧ N ≤ n ⟶ dist (f m) (f n) < ε/2" unfolding Cauchy_def using‹ε > 0›by (meson half_gt_zero) thenobtain M where M:"∀n≥M. dist ((f ∘ r) n) l < ε/2" by (metis dist_self lim_sequentially lr(3))
{ fix n :: nat assume n: "n ≥ max N M" have"dist ((f ∘ r) n) l < ε/2" using n M by auto moreoverhave"r n ≥ N" using lr'[of n] n by auto thenhave"dist (f n) ((f ∘ r) n) < ε/2" using N and n by auto ultimatelyhave"dist (f n) l < ε"using n M by metric
} thenhave"∃N. ∀n≥N. dist (f n) l < ε"by blast
} thenshow"∃l∈S. (f ---> l) sequentially"using‹l∈S› unfolding lim_sequentially by auto qed
proposition compact_eq_totally_bounded: "compact S ⟷ complete S ∧ (∀ε>0. ∃k. finite k ∧ S ⊆ (∪x∈k. ball x ε))"
(is"_ ⟷ ?rhs") proof assume assms: "?rhs" thenobtain k where k: "∧ε. 0 < ε ==> finite (k ε)""∧ε. 0 < ε ==> S ⊆ (∪x∈k ε. ball x ε)" by metis
show"compact S" proof cases assume"S = {}" thenshow"compact S"by (simp add: compact_def) next assume"S ≠ {}" show ?thesis unfolding compact_def proof safe fix f :: "nat → 'a" assume f: "∀n. f n ∈ S"
define ε where"ε n = 1 / (2 * Suc n)"for n thenhave [simp]: "∧n. 0 < ε n"by auto define B where"B n U = (SOME b. infinite {n. f n ∈ b} ∧ (∃x. b ⊆ ball x (ε n) ∩ U))"for n U
{ fix n U assume"infinite {n. f n ∈ U}" thenhave"∃b∈k (ε n). infinite {i∈{n. f n ∈ U}. f i ∈ ball b (ε n)}" using k f by (intro pigeonhole_infinite_rel) (auto simp: subset_eq) thenobtain a where "a ∈ k (ε n)" "infinite {i ∈ {n. f n ∈ U}. f i ∈ ball a (ε n)}" .. thenhave"∃b. infinite {i. f i ∈ b} ∧ (∃x. b ⊆ ball x (ε n) ∩ U)" by (intro exI[of _ "ball a (ε n) ∩ U"] exI[of _ a]) (auto simp: ac_simps) from someI_ex[OF this] have"infinite {i. f i ∈ B n U}""∃x. B n U ⊆ ball x (ε n) ∩ U" unfolding B_def by auto
} note B = this
define F where"F = rec_nat (B 0 UNIV) B"
{ fix n have"infinite {i. f i ∈ F n}" by (induct n) (auto simp: F_def B)
} thenhave F: "∧n. ∃x. F (Suc n) ⊆ ball x (ε n) ∩ F n" using B by (simp add: F_def) thenhave F_dec: "∧m n. m ≤ n ==> F n ⊆ F m" using decseq_SucI[of F] by (auto simp: decseq_def) have"∃x>i. f x ∈ F k"for k i proof - have"infinite ({n. f n ∈ F k} - {.. i})" using‹infinite {n. f n ∈ F k}›by auto from infinite_imp_nonempty[OF this] show"∃x>i. f x ∈ F k" by (simp add: set_eq_iff not_le conj_commute) qed thenobtain sel where sel: "∧k i. i < sel k i""∧k i. f (sel k i) ∈ F k" by meson
define t where"t = rec_nat (sel 0 0) (λn i. sel (Suc n) i)" have"strict_mono t" unfolding strict_mono_Suc_iff by (simp add: t_def sel) moreoverhave"∀i. (f ∘ t) i ∈ S" using f by auto moreover have t: "(f ∘ t) n ∈ F n"for n by (cases n) (simp_all add: t_def sel)
have"Cauchy (f ∘ t)" proof (safe intro!: metric_CauchyI exI elim!: nat_approx_posE) fix r :: real and N n m assume"1 / Suc N < r""Suc N ≤ n""Suc N ≤ m" thenhave"(f ∘ t) n ∈ F (Suc N)""(f ∘ t) m ∈ F (Suc N)""2 * ε N < r" using F_dec t by (auto simp: ε_def field_simps) with F[of N] obtain x where"dist x ((f ∘ t) n) < ε N""dist x ((f ∘ t) m) < ε N" by (auto simp: subset_eq) with‹2 * ε N < r›show"dist ((f ∘ t) m) ((f ∘ t) n) < r" by metric qed
ultimatelyshow"∃l∈S. ∃r. strict_mono r ∧ (f ∘ r) <---- l" using assms unfolding complete_def by blast qed qed next show"compact S ==> ?rhs" by (metis compact_imp_complete compact_imp_seq_compact seq_compact_imp_totally_bounded) qed
lemma cauchy_imp_bounded: assumes"Cauchy S" shows"bounded (range S)" proof - from assms obtain N :: nat where"∀m n. N ≤ m ∧ N ≤ n ⟶ dist (S m) (S n) < 1" by (meson Cauchy_def zero_less_one) thenhave N:"∀n. N ≤ n ⟶ dist (S N) (S n) < 1"by auto moreover have"bounded (S ` {0..N})" using finite_imp_bounded[of "S ` {1..N}"] by auto thenobtain a where a:"∀x∈S ` {0..N}. dist (S N) x ≤ a" unfolding bounded_any_center [where a="S N"] by auto ultimatelyhave"∀y∈range S. dist (S N) y ≤ max a 1" by (force simp: le_max_iff_disj less_le_not_le) thenshow ?thesis unfolding bounded_any_center [where a="S N"] by blast qed
instance heine_borel < complete_space proof fix f :: "nat → 'a"assume"Cauchy f" thenshow"convergent f" unfolding convergent_def using Cauchy_converges_subseq cauchy_imp_bounded bounded_imp_convergent_subsequence by blast qed
lemma complete_imp_closed: fixes S :: "'a::metric_space set" shows"complete S ==> closed S" by (metis LIMSEQ_imp_Cauchy LIMSEQ_unique closed_sequential_limits completeE)
lemma complete_Int_closed: fixes S :: "'a::metric_space set" assumes"complete S"and"closed t" shows"complete (S ∩ t)" by (metis Int_iff assms closed_sequentially completeE completeI)
lemma complete_closed_subset: fixes S :: "'a::metric_space set" assumes"closed S"and"S ⊆ t"and"complete t" shows"complete S" by (metis assms complete_Int_closed inf.absorb_iff2)
lemma complete_eq_closed: fixes S :: "('a::complete_space) set" shows"complete S ⟷ closed S" using complete_UNIV complete_closed_subset complete_imp_closed by auto
lemma convergent_eq_Cauchy: fixes S :: "nat → 'a::complete_space" shows"(∃l. (S ---> l) sequentially) ⟷ Cauchy S" unfolding Cauchy_convergent_iff convergent_def ..
lemma convergent_imp_bounded: fixes S :: "nat → 'a::metric_space" shows"(S ---> l) sequentially ==> bounded (range S)" by (intro cauchy_imp_bounded LIMSEQ_imp_Cauchy)
lemma frontier_subset_compact: fixes S :: "'a::heine_borel set" shows"compact S ==> frontier S ⊆ S" using frontier_subset_closed compact_eq_bounded_closed by blast
lemma banach_fix_type: fixes f::"'a::complete_space→'a" assumes c:"0 ≤ c""c < 1" and lipschitz:"∀x. ∀y. dist (f x) (f y) ≤ c * dist x y" shows"∃!x. (f x = x)" using assms Banach_fix[OF complete_UNIV UNIV_not_empty c subset_UNIV, of f] by auto
section‹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 (metis (no_types, lifting) ext Cauchy_continuous_on_def UNIV_I image_subset_iff
o_apply uniformly_continuous_on_Cauchy)
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 ε :: real assume"ε>0" thenobtain N where"inverse (Suc N) < ε" using reals_Archimedean by blast thenhave"∀n. N ≤ n ⟶ dist (ρ n) x < ε" by (metis dx inverse_positive_iff_positive le_imp_inverse_le nless_le not_less_eq_eq
of_nat_mono order_le_less_trans zero_le_dist) with‹ε>0›show"∀F n in sequentially. dist (σ n) x < ε" by (auto simp: eventually_sequentially σ_def) qed thenhave"Cauchy σ" by (intro LIMSEQ_imp_Cauchy) thenhave Cf: "Cauchy (f ∘ σ)" by (meson Cauchy_continuous_on_def ‹range σ ⊆ S› assms) have"(f ∘ σ) <---- f x" unfolding tendsto_iff proof (intro strip) fix ε :: real assume"ε>0" thenobtain N where N: "∀m≥N. ∀n≥N. dist ((f ∘ σ) m) ((f ∘ σ) n) < ε" using Cf unfolding Cauchy_def by presburger moreoverhave"(f ∘ σ) (Suc(N+N)) = f x" by (simp add: σ_def) ultimatelyhave"∀n≥N. dist ((f ∘ σ) n) (f x) < ε" by (metis add_Suc le_add2) thenshow"∀F n in sequentially. dist ((f ∘ σ) n) (f x) < ε" using eventually_sequentially by blast qed moreoverhave"∧n. ¬ dist (f (σ (2*n))) (f x) < ε" using dfx by (simp add: σ_def) ultimatelyshow False using‹ε>0›by (fastforce simp: mult_2 nat_le_iff_add tendsto_iff eventually_sequentially) qed thenshow ?thesis unfolding continuous_on_iff by (meson inverse_Suc) qed
text\<open>AsequenceisCauchy,ifandonlyifitisboundedanditsdiametertendstozero. Thediameteriswell-definedonlyifthesequenceisbounded.\<close> lemmacauchy_iff_diameter_tends_to_zero_and_bounded: fixess::"nat\<Rightarrow>'a::metric_space" shows"Cauchys\<longleftrightarrow>((\<lambda>n.diameter{si|i.i\<ge>n})\<longlonglongrightarrow>0\<and>bounded(ranges))" (is"_=?rhs") proof- have"{si|i.N\<le>i}\<noteq>{}"forNbyblast hencediameter_SUP:"diameter{si|i.N\<le>i}=(SUP(i,j)\<in>{N..}\<times>{N..}.dist(si)(sj))"forN unfoldingdiameter_defby(autointro!:arg_cong[of__Sup]) show?thesis proof(introiffI) assume"Cauchys" have"\<exists>N.\<forall>n\<ge>N.norm(diameter{si|i.n\<le>i})<\<epsilon>"ife_pos:"\<epsilon>>0"for\<epsilon> proof- obtainNwheredist_less:"dist(sn)(sm)<(1/2)*\<epsilon>" if"n\<ge>N""m\<ge>N"fornm using\<open>Cauchys\<close>e_pos by(mesonhalf_gt_zeroless_numeral_extra(1)metric_CauchyDmult_pos_pos) have"diameter{si|i.r\<le>i}<\<epsilon>" if"r\<ge>N"forr proof- have"dist(sn)(sm)<(1/2)*\<epsilon>"if"n\<ge>r""m\<ge>r"fornm using\<open>r\<ge>N\<close>dist_lessthatbysimp hence"(SUP(i,j)\<in>{r..}\<times>{r..}.dist(si)(sj))\<le>(1/2)*\<epsilon>" by(introcSup_least)fastforce+ alsohave"\<dots><\<epsilon>"usinge_posbysimp finallyshow?thesis usingdiameter_SUPbypresburger qed moreoverhave"diameter{si|i.r\<le>i}\<ge>0"forr unfoldingdiameter_SUP usingbounded_imp_dist_bounded[OFcauchy_imp_bounded,THENbounded_imp_bdd_above]\<open>Cauchys\<close> by(forceintro:cSup_upper2) ultimatelyshow?thesis byauto qed thus"(\<lambda>n.diameter{si|i.n\<le>i})\<longlonglongrightarrow>0\<and>bounded(ranges)" usingcauchy_imp_bounded[OF\<open>Cauchys\<close>]by(simpadd:LIMSEQ_iff) next assumeR:?rhs have"\<exists>N.\<forall>n\<ge>N.\<forall>m\<ge>N.dist(sn)(sm)<\<epsilon>"ife_pos:"\<epsilon>>0"for\<epsilon> proof- obtainNwherediam_less:"diameter{si|i.r\<le>i}<\<epsilon>"if"r\<ge>N"forr usingLIMSEQ_DRe_posbyfastforce have"dist(sn)(sm)<\<epsilon>" if"n\<ge>N""m\<ge>N"fornm usingcSUP_lessD[OFbounded_imp_dist_bounded[THENbounded_imp_bdd_above], OF_diam_less[unfoldeddiameter_SUP]] usingRthatbyauto thus?thesisbyblast qed thenshow"Cauchys" by(simpadd:Cauchy_def) qed qed end
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.304Bemerkung:
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-30)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.