# HG changeset patch # User paulson # Date 1672229725 0 # Node ID 18e719c6b6333841781af7bf09cb309e11b813d4 # Parent 04af11e6557a84cb432b8da2b5422caad34e60e9# Parent 454984e807db415f3c5b89724dab7eb44c0b8458 merged diff -r 04af11e6557a -r 18e719c6b633 src/HOL/Analysis/Elementary_Metric_Spaces.thy --- a/src/HOL/Analysis/Elementary_Metric_Spaces.thy Tue Dec 27 22:52:28 2022 +0100 +++ b/src/HOL/Analysis/Elementary_Metric_Spaces.thy Wed Dec 28 12:15:25 2022 +0000 @@ -33,13 +33,13 @@ by (simp add: sphere_def) lemma ball_trivial [simp]: "ball x 0 = {}" - by (simp add: ball_def) + by auto lemma cball_trivial [simp]: "cball x 0 = {x}" - by (simp add: cball_def) + by auto lemma sphere_trivial [simp]: "sphere x 0 = {x}" - by (simp add: sphere_def) + 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 @@ -196,9 +196,7 @@ by (simp add: interior_open) lemma cball_eq_empty [simp]: "cball x e = {} \ e < 0" - apply (simp add: set_eq_iff not_le) - apply (metis zero_le_dist dist_self order_less_le_trans) - done + by (smt (verit, best) Diff_empty ball_eq_empty cball_diff_sphere centre_in_ball centre_in_cball sphere_empty) lemma cball_empty [simp]: "e < 0 \ cball x e = {}" by simp @@ -215,8 +213,7 @@ using ball_divide_subset one_le_numeral by blast lemma cball_divide_subset: "d \ 1 \ cball x (e/d) \ cball x e" - apply (cases "e < 0", simp add: field_split_simps) - by (metis div_by_1 frac_le less_numeral_extra(1) not_le order_refl subset_cball) + by (smt (verit, best) cball_empty div_by_1 frac_le subset_cball zero_le_divide_iff) lemma cball_divide_subset_numeral: "cball x (e / numeral w) \ cball x e" using cball_divide_subset one_le_numeral by blast @@ -292,13 +289,7 @@ lemma limpt_of_limpts: "x islimpt {y. y islimpt S} \ x islimpt S" for x :: "'a::metric_space" - apply (clarsimp simp add: islimpt_approachable) - apply (drule_tac x="e/2" in spec) - apply (auto simp: simp del: less_divide_eq_numeral1) - apply (drule_tac x="dist x' x" in spec) - apply (auto simp del: less_divide_eq_numeral1) - apply metric - done + 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 @@ -308,14 +299,12 @@ by (auto simp: closure_def islimpt_Un dest: limpt_of_limpts) lemma islimpt_eq_infinite_ball: "x islimpt S \ (\e>0. infinite(S \ ball x e))" - apply (simp add: islimpt_eq_acc_point, safe) - apply (metis Int_commute open_ball centre_in_ball) - by (metis open_contains_ball Int_mono finite_subset inf_commute subset_refl) + 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 \ (\e>0. infinite(S \ cball x e))" - apply (simp add: islimpt_eq_infinite_ball, safe) - apply (meson Int_mono ball_subset_cball finite_subset order_refl) - by (metis open_ball centre_in_ball finite_Int inf.absorb_iff2 inf_assoc open_contains_cball_eq) + unfolding islimpt_eq_infinite_ball + by (metis open_ball ball_subset_cball centre_in_ball finite_Int inf.absorb_iff2 inf_assoc open_contains_cball_eq) subsection \Perfect Metric Spaces\ @@ -327,17 +316,11 @@ lemma cball_eq_sing: fixes x :: "'a::{metric_space,perfect_space}" shows "cball x e = {x} \ e = 0" -proof (rule linorder_cases) - assume e: "0 < e" - obtain a where "a \ x" "dist a x < e" - using perfect_choose_dist [OF e] by auto - then have "a \ x" "dist x a \ e" - by (auto simp: dist_commute) - with e show ?thesis by (auto simp: set_eq_iff) -qed auto - - -subsection \?\ + by (smt (verit, best) open_ball ball_eq_empty ball_subset_cball cball_empty cball_trivial + not_open_singleton subset_singleton_iff) + + +subsection \Finite and discrete\ lemma finite_ball_include: fixes a :: "'a::metric_space" @@ -364,19 +347,7 @@ then obtain d where "d > 0" and d: "\x\S. x \ a \ d \ dist a x" by blast show ?case - proof (cases "x = a") - case True - with \d > 0 \d show ?thesis by auto - next - case False - let ?d = "min d (dist a x)" - from False \d > 0\ have dp: "?d > 0" - by auto - from d have d': "\x\S. x \ a \ ?d \ dist a x" - by auto - with dp False show ?thesis - by (metis insert_iff le_less min_less_iff_conj not_less) - qed + by (smt (verit, del_insts) dist_pos_lt insert.IH insert_iff) qed (auto intro: zero_less_one) lemma discrete_imp_closed: @@ -388,7 +359,7 @@ have False if C: "\e. e>0 \ \x'\S. x' \ x \ dist x' x < e" for x proof - from e have e2: "e/2 > 0" by arith - from C[rule_format, OF e2] obtain y where y: "y \ S" "y \ x" "dist y x < e/2" + from C[OF e2] obtain y where y: "y \ S" "y \ x" "dist y x < e/2" by blast from e2 y(2) have mp: "min (e/2) (dist x y) > 0" by simp @@ -438,9 +409,7 @@ corollary Lim_withinI [intro?]: assumes "\e. e > 0 \ \d>0. \x \ S. 0 < dist x a \ dist x a < d \ dist (f x) l \ e" shows "(f \ l) (at a within S)" - apply (simp add: Lim_within, clarify) - apply (rule ex_forward [OF assms [OF half_gt_zero]], auto) - done + unfolding Lim_within by (smt (verit, ccfv_SIG) assms zero_less_dist_iff) proposition Lim_at: "(f \ l) (at a) \ (\e >0. \d>0. \x. 0 < dist x a \ dist x a < d \ dist (f x) l < e)" @@ -450,11 +419,7 @@ 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)" -apply (clarsimp simp: eventually_at Lim_within) -apply (drule_tac x=e in spec, clarify) -apply (rename_tac k) -apply (rule_tac x="min d k" in exI, simp) -done + by (simp add: eventually_at Lim_within) (smt (verit, best)) text \Another limit point characterization.\ @@ -471,7 +436,7 @@ 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" - "f(Suc n) = y (min (inverse(2 ^ (Suc n))) (dist (f n) x))" for n + 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) @@ -479,11 +444,10 @@ by (simp add: y) next case (Suc n) then show ?case - apply (auto simp: y) - by (metis half_gt_zero_iff inverse_positive_iff_positive less_divide_eq_numeral1(1) min_less_iff_conj y zero_less_dist_iff zero_less_numeral zero_less_power) + by (smt (verit, best) fSuc dist_pos_lt inverse_positive_iff_positive y zero_less_power) qed show ?rhs - proof (rule_tac x=f in exI, intro conjI allI) + 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 @@ -497,7 +461,7 @@ proof cases assume "m < n" have "dist (f(Suc n)) x = dist (y (min (inverse(2 ^ (Suc n))) (dist (f n) x))) x" - by simp + by (simp add: fSuc) also have "\ < dist (f n) x" by (metis dist_pos_lt f min.strict_order_iff min_less_iff_conj y) also have "\ < dist (f m) x" @@ -505,17 +469,16 @@ finally show ?thesis . next assume "m = n" then show ?case - by simp (metis dist_pos_lt f half_gt_zero_iff inverse_positive_iff_positive min_less_iff_conj y zero_less_numeral zero_less_power) + by (smt (verit, best) dist_pos_lt f fSuc y) qed qed then show "inj f" by (metis less_irrefl linorder_injI) - show "f \ x" - apply (rule tendstoI) - apply (rule_tac c="nat (ceiling(1/e))" in eventually_sequentiallyI) + have "\e n. \0 < e; nat \1 / e\ \ n\ \ dist (f n) x < e" apply (rule less_trans [OF f [THEN conjunct2, THEN conjunct2]]) - apply (simp add: field_simps) - by (meson le_less_trans mult_less_cancel_left not_le of_nat_less_two_power) + by (simp add: divide_simps order_le_less_trans) + then show "f \ x" + using lim_sequentially by blast qed next assume ?rhs @@ -548,70 +511,49 @@ assumes nondecF: "\x y. x \ y \ f x \ f y" shows "continuous (at_right a) f \ (\e>0. \d>0. f (a + d) - f a < e)" apply (simp add: greaterThan_def dist_real_def continuous_within Lim_within_le) - apply (intro all_cong ex_cong, safe) - apply (erule_tac x="a + d" in allE, simp) - apply (simp add: nondecF field_simps) - apply (drule nondecF, simp) - done + 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) = (\e > 0. \delta > 0. f a - f (a - delta) < e)" + shows "(continuous (at_left (a :: real)) f) \ (\e > 0. \delta > 0. f a - f (a - delta) < e)" apply (simp add: lessThan_def dist_real_def continuous_within Lim_within_le) - apply (intro all_cong ex_cong, safe) - apply (erule_tac x="a - d" in allE, simp) - apply (simp add: nondecF field_simps) - apply (cut_tac x="a - d" and y=x in nondecF, simp_all) - done + 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 \ - (\e > 0. \d > 0. f ` (ball x d \ s) \ ball (f x) e)" + "continuous (at x within S) f \ + (\e > 0. \d > 0. f ` (ball x d \ S) \ ball (f x) e)" (is "?lhs = ?rhs") proof assume ?lhs { fix e :: real assume "e > 0" - then obtain d where d: "d>0" "\xa\s. 0 < dist xa x \ dist xa x < d \ dist (f xa) (f x) < e" + then obtain d where "d>0" and d: "\y\S. 0 < dist y x \ dist y x < d \ dist (f y) (f x) < e" using \?lhs\[unfolded continuous_within Lim_within] by auto - { - fix y - assume "y \ f ` (ball x d \ s)" - then have "y \ ball (f x) e" - using d(2) - using \e > 0\ - by (auto simp: dist_commute) + { fix y + assume "y \ f ` (ball x d \ S)" then have "y \ ball (f x) e" + using d \e > 0\ by (auto simp: dist_commute) } - then have "\d>0. f ` (ball x d \ s) \ ball (f x) e" - using \d > 0\ - unfolding subset_eq ball_def by (auto simp: dist_commute) + then have "\d>0. f ` (ball x d \ S) \ ball (f x) e" + using \d > 0\ by blast } then show ?rhs by auto next assume ?rhs then show ?lhs - unfolding continuous_within Lim_within ball_def subset_eq - apply (auto simp: dist_commute) - apply (erule_tac x=e in allE, auto) - done + apply (simp add: continuous_within Lim_within ball_def subset_eq) + by (metis (mono_tags, lifting) Int_iff dist_commute mem_Collect_eq) qed lemma continuous_at_ball: - "continuous (at x) f \ (\e>0. \d>0. f ` (ball x d) \ ball (f x) e)" (is "?lhs = ?rhs") -proof - assume ?lhs - then show ?rhs - unfolding continuous_at Lim_at subset_eq Ball_def Bex_def image_iff mem_ball - by (metis dist_commute dist_pos_lt dist_self) -next - assume ?rhs - then show ?lhs - unfolding continuous_at Lim_at subset_eq Ball_def Bex_def image_iff mem_ball - by (metis dist_commute) -qed + "continuous (at x) f \ (\e>0. \d>0. f ` (ball x d) \ ball (f x) e)" + apply (simp add: continuous_at Lim_at subset_eq Ball_def Bex_def image_iff) + by (smt (verit, ccfv_threshold) dist_commute dist_self) + text\Define setwise continuity in terms of limits within the set.\ @@ -622,16 +564,14 @@ by (metis dist_pos_lt dist_self) lemma continuous_within_E: - assumes "continuous (at x within s) f" "e>0" - obtains d where "d>0" "\x'. \x'\ s; dist x' x \ d\ \ dist (f x') (f x) < e" - using assms apply (simp add: continuous_within_eps_delta) - apply (drule spec [of _ e], clarify) - apply (rule_tac d="d/2" in that, auto) - done + assumes "continuous (at x within S) f" "e>0" + obtains d where "d>0" "\x'. \x'\ S; dist x' x \ d\ \ dist (f x') (f x) < e" + using assms unfolding continuous_within_eps_delta + by (metis dense order_le_less_trans) lemma continuous_onI [intro?]: - assumes "\x e. \e > 0; x \ s\ \ \d>0. \x'\s. dist x' x < d \ dist (f x') (f x) \ e" - shows "continuous_on s f" + assumes "\x e. \e > 0; x \ S\ \ \d>0. \x'\S. dist x' x < d \ dist (f x') (f x) \ e" + shows "continuous_on S f" apply (simp add: continuous_on_iff, clarify) apply (rule ex_forward [OF assms [OF half_gt_zero]], auto) done @@ -642,10 +582,7 @@ assumes "continuous_on s f" "x\s" "e>0" obtains d where "d>0" "\x'. \x' \ s; dist x' x \ d\ \ dist (f x') (f x) < e" using assms - apply (simp add: continuous_on_iff) - apply (elim ballE allE) - apply (auto intro: that [where d="d/2" for d]) - done + unfolding continuous_on_iff by (metis dense order_le_less_trans) text\The usual transformation theorems.\ @@ -657,8 +594,7 @@ and "\x'. \x' \ s; dist x' x < d\ \ f x' = g x'" shows "continuous (at x within s) g" using assms - unfolding continuous_within - by (force intro: Lim_transform_within) + unfolding continuous_within by (force intro: Lim_transform_within) subsection \Closure and Limit Characterization\ @@ -666,9 +602,7 @@ lemma closure_approachable: fixes S :: "'a::metric_space set" shows "x \ closure S \ (\e>0. \y\S. dist y x < e)" - apply (auto simp: closure_def islimpt_approachable) - apply (metis dist_self) - done + using dist_self by (force simp: closure_def islimpt_approachable) lemma closure_approachable_le: fixes S :: "'a::metric_space set" @@ -693,14 +627,13 @@ proof - have *: "\x\S. Inf S \ x" using cInf_lower[of _ S] assms by metis - { - fix e :: real + { fix e :: real assume "e > 0" then have "Inf S < Inf S + e" by simp with assms obtain x where "x \ S" "x < Inf S + e" - by (subst (asm) cInf_less_iff) auto + using cInf_lessD by blast with * have "\x\S. dist x (Inf S) < e" - by (intro bexI[of _ x]) (auto simp: dist_real_def) + using dist_real_def by force } then show ?thesis unfolding closure_approachable by auto qed @@ -717,9 +650,9 @@ assume "e > 0" then have "Sup S - e < Sup S" by simp with assms obtain x where "x \ S" "Sup S - e < x" - by (subst (asm) less_cSup_iff) auto + using less_cSupE by blast with * have "\x\S. dist x (Sup S) < e" - by (intro bexI[of _ x]) (auto simp: dist_real_def) + using dist_real_def by force } then show ?thesis unfolding closure_approachable by auto qed @@ -730,8 +663,7 @@ proof show ?rhs if ?lhs proof - - { - fix e :: real + { fix e :: real assume "e > 0" then obtain y where "y \ S - {x}" and "dist y x < e" using \?lhs\ not_trivial_limit_within[of x S] closure_approachable[of x "S - {x}"] @@ -744,8 +676,7 @@ qed show ?lhs if ?rhs proof - - { - fix e :: real + { fix e :: real assume "e > 0" then obtain y where "y \ S \ ball x e - {x}" using \?rhs\ by blast @@ -804,8 +735,7 @@ proof - from assms obtain x and a where a: "\y\S. dist x y \ a" unfolding bounded_def by auto - { - fix y + { fix y assume "y \ closure S" then obtain f where f: "\n. f n \ S" "(f \ y) sequentially" unfolding closure_sequential by auto @@ -1299,10 +1229,7 @@ and xy: "\u\S. \v\S. dist u v \ dist x y" using compact_sup_maxdistance[OF assms] by auto then have "diameter S \ dist x y" - unfolding diameter_def - apply clarsimp - apply (rule cSUP_least, fast+) - done + unfolding diameter_def by (force intro!: cSUP_least) then show ?thesis by (metis b diameter_bounded_bound order_antisym xys) qed @@ -1332,12 +1259,12 @@ assumes "bounded S" shows "diameter(closure S) = diameter S" proof (rule order_antisym) - have "False" if "diameter S < diameter (closure S)" + have "False" if d_less_d: "diameter S < diameter (closure S)" proof - define d where "d = diameter(closure S) - diameter(S)" have "d > 0" using that by (simp add: d_def) - then have "diameter(closure(S)) - d / 2 < diameter(closure(S))" + then have dle: "diameter(closure(S)) - d / 2 < diameter(closure(S))" by simp have dd: "diameter (closure S) - d / 2 = (diameter(closure(S)) + diameter(S)) / 2" by (simp add: d_def field_split_simps) @@ -1346,14 +1273,13 @@ moreover have "0 \ diameter S" using assms diameter_ge_0 by blast ultimately obtain x y where "x \ closure S" "y \ closure S" and xy: "diameter(closure(S)) - d / 2 < dist x y" - using diameter_bounded(2) [OF bocl, rule_format, of "diameter(closure(S)) - d / 2"] \d > 0\ d_def by auto + by (smt (verit) dle d_less_d d_def dd diameter_lower_bounded) then obtain x' y' where x'y': "x' \ S" "dist x' x < d/4" "y' \ S" "dist y' y < d/4" - using closure_approachable - by (metis \0 < d\ zero_less_divide_iff zero_less_numeral) + by (metis \0 < d\ zero_less_divide_iff zero_less_numeral closure_approachable) then have "dist x' y' \ diameter S" using assms diameter_bounded_bound by blast with x'y' have "dist x y \ d / 4 + diameter S + d / 4" - by (meson add_mono_thms_linordered_semiring(1) dist_triangle dist_triangle3 less_eq_real_def order_trans) + by (meson add_mono dist_triangle dist_triangle3 less_eq_real_def order_trans) then show ?thesis using xy d_def by linarith qed @@ -1421,8 +1347,7 @@ then have "T \ ball y \" using \y \ T\ dia diameter_bounded_bound by fastforce then show ?thesis - apply (rule_tac x=C in bexI) - using \ball y \ \ C\ \C \ \\ by auto + by (meson \C \ \\ \ball y \ \ C\ subset_eq) qed qed qed @@ -1490,8 +1415,7 @@ obtain r :: "nat \ nat" where r: "strict_mono r" "monoseq (f \ r)" unfolding comp_def by (metis seq_monosub) then have "Bseq (f \ r)" - unfolding Bseq_eq_bounded using f - by (metis BseqI' bounded_iff comp_apply rangeI) + 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 @@ -1525,32 +1449,31 @@ using k by (rule bounded_proj) obtain l1::"'a" and r1 where r1: "strict_mono r1" - and lr1: "\e > 0. eventually (\n. \i\d. dist (f (r1 n) proj i) (l1 proj i) < e) sequentially" - using insert(3) using insert(4) by auto + and lr1: "\e > 0. \\<^sub>F n in sequentially. \i\d. dist (f (r1 n) proj i) (l1 proj i) < e" + 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') - then obtain l2 r2 where r2:"strict_mono r2" and lr2:"((\i. f (r1 (r2 i)) proj k) \ l2) sequentially" + then obtain 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" + 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 e::real + { fix e::real assume "e > 0" - from lr1 \e > 0\ have N1: "eventually (\n. \i\d. dist (f (r1 n) proj i) (l1 proj i) < e) sequentially" + from lr1 \e > 0\ have N1: "\\<^sub>F n in sequentially. \i\d. dist (f (r1 n) proj i) (l1 proj i) < e" by blast - from lr2 \e > 0\ have N2:"eventually (\n. dist (f (r1 (r2 n)) proj k) l2 < e) sequentially" + from lr2 \e > 0\ have N2: "\\<^sub>F n in sequentially. dist (f (r1 (r2 n)) proj k) l2 < e" by (rule tendstoD) - from r2 N1 have N1': "eventually (\n. \i\d. dist (f (r1 (r2 n)) proj i) (l1 proj i) < e) sequentially" + from r2 N1 have N1': "\\<^sub>F n in sequentially. \i\d. dist (f (r1 (r2 n)) proj i) (l1 proj i) < e" by (rule eventually_subseq) - have "eventually (\n. \i\(insert k d). dist (f (r n) proj i) (l proj i) < e) sequentially" + have "\\<^sub>F n in sequentially. \i\insert k d. dist (f (r n) proj i) (l proj i) < e" using N1' N2 - by eventually_elim (insert insert.prems, auto simp: l_def r_def o_def proj_unproj) + by eventually_elim (use insert.prems in \auto simp: l_def r_def o_def proj_unproj\) } ultimately show ?case by auto qed @@ -1576,7 +1499,7 @@ 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) sequentially" + 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" @@ -1619,13 +1542,9 @@ 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\ - apply (erule_tac x="e/2" in allE, auto) - done - from lr(3)[unfolded lim_sequentially, THEN spec[where x="e/2"]] - obtain M where M:"\n\M. dist ((f \ r) n) l < e/2" - using \e > 0\ by auto + 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)) { fix n :: nat assume n: "n \ max N M" @@ -1756,58 +1675,28 @@ instance heine_borel < complete_space proof fix f :: "nat \ 'a" assume "Cauchy f" - then have "bounded (range f)" - by (rule cauchy_imp_bounded) - then have "compact (closure (range f))" - unfolding compact_eq_bounded_closed by auto - then have "complete (closure (range f))" - by (rule compact_imp_complete) - moreover have "\n. f n \ closure (range f)" - using closure_subset [of "range f"] by auto - ultimately have "\l\closure (range f). (f \ l) sequentially" - using \Cauchy f\ unfolding complete_def by auto then show "convergent f" - unfolding convergent_def by auto + unfolding convergent_def + using Cauchy_converges_subseq cauchy_imp_bounded bounded_imp_convergent_subsequence by blast qed lemma complete_UNIV: "complete (UNIV :: ('a::complete_space) set)" proof (rule completeI) fix f :: "nat \ 'a" assume "Cauchy f" - then have "convergent f" by (rule Cauchy_convergent) - then show "\l\UNIV. f \ l" unfolding convergent_def by simp + then show "\l\UNIV. f \ l" + using Cauchy_convergent convergent_def by blast qed lemma complete_imp_closed: fixes S :: "'a::metric_space set" - assumes "complete S" - shows "closed S" -proof (unfold closed_sequential_limits, clarify) - fix f x assume "\n. f n \ S" and "f \ x" - from \f \ x\ have "Cauchy f" - by (rule LIMSEQ_imp_Cauchy) - with \complete S\ and \\n. f n \ S\ obtain l where "l \ S" and "f \ l" - by (rule completeE) - from \f \ x\ and \f \ l\ have "x = l" - by (rule LIMSEQ_unique) - with \l \ S\ show "x \ S" - by simp -qed + 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)" -proof (rule completeI) - fix f assume "\n. f n \ S \ t" and "Cauchy f" - then have "\n. f n \ S" and "\n. f n \ t" - by simp_all - from \complete S\ obtain l where "l \ S" and "f \ l" - using \\n. f n \ S\ and \Cauchy f\ by (rule completeE) - from \closed t\ and \\n. f n \ t\ and \f \ l\ have "l \ t" - by (rule closed_sequentially) - with \l \ S\ and \f \ l\ show "\l\S \ t. f \ l" - by fast -qed + by (metis Int_iff assms closed_sequentially completeE completeI) lemma complete_closed_subset: fixes S :: "'a::metric_space set" @@ -1845,8 +1734,7 @@ 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 \ \)" - apply (simp add: complete_eq_closed [symmetric] continuous_on_sequentially) - by (meson LIMSEQ_imp_Cauchy complete_def) + by (meson LIMSEQ_imp_Cauchy completeE complete_eq_closed continuous_on_sequentially) lemma banach_fix_type: fixes f::"'a::complete_space\'a" @@ -1866,15 +1754,13 @@ assumes "closed S" and T: "T \ \" "bounded T" and clof: "\T. T \ \ \ closed T" - and none: "\\'. \finite \'; \' \ \\ \ S \ \\' \ {}" + and "\\'. \finite \'; \' \ \\ \ S \ \\' \ {}" shows "S \ \\ \ {}" proof - have "compact (S \ T)" using \closed S\ clof compact_eq_bounded_closed T by blast then have "(S \ T) \ \\ \ {}" - apply (rule compact_imp_fip) - apply (simp add: clof) - by (metis Int_assoc complete_lattice_class.Inf_insert finite_insert insert_subset none \T \ \\) + by (smt (verit, best) Inf_insert Int_assoc assms compact_imp_fip finite_insert insert_subset) then show ?thesis by blast qed @@ -1884,33 +1770,27 @@ "\closed S; \T. T \ \ \ compact T; \\'. \finite \'; \' \ \\ \ S \ \\' \ {}\ \ S \ \\ \ {}" -by (metis Inf_greatest closed_imp_fip compact_eq_bounded_closed empty_subsetI finite.emptyI inf.orderE) + by (metis closed_imp_fip compact_eq_bounded_closed equals0I finite.emptyI order.refl) lemma closed_fip_Heine_Borel: fixes \ :: "'a::heine_borel set set" - assumes "closed S" "T \ \" "bounded T" + assumes "T \ \" "bounded T" and "\T. T \ \ \ closed T" and "\\'. \finite \'; \' \ \\ \ \\' \ {}" shows "\\ \ {}" -proof - - have "UNIV \ \\ \ {}" - using assms closed_imp_fip [OF closed_UNIV] by auto - then show ?thesis by simp -qed + using closed_imp_fip [OF closed_UNIV] assms by auto lemma compact_fip_Heine_Borel: fixes \ :: "'a::heine_borel set set" assumes clof: "\T. T \ \ \ compact T" and none: "\\'. \finite \'; \' \ \\ \ \\' \ {}" shows "\\ \ {}" -by (metis InterI all_not_in_conv clof closed_fip_Heine_Borel compact_eq_bounded_closed none) + by (metis InterI clof closed_fip_Heine_Borel compact_eq_bounded_closed equals0D none) lemma compact_sequence_with_limit: fixes f :: "nat \ 'a::heine_borel" - shows "(f \ l) sequentially \ compact (insert l (range f))" -apply (simp add: compact_eq_bounded_closed, auto) -apply (simp add: convergent_imp_bounded) -by (simp add: closed_limpt islimpt_insert sequence_unique_limpt) + shows "f \ l \ compact (insert l (range f))" + by (simp add: closed_limpt compact_eq_bounded_closed convergent_imp_bounded islimpt_insert sequence_unique_limpt) subsection \Properties of Balls and Spheres\ @@ -1918,21 +1798,18 @@ lemma compact_cball[simp]: fixes x :: "'a::heine_borel" shows "compact (cball x e)" - using compact_eq_bounded_closed bounded_cball closed_cball - by blast + using compact_eq_bounded_closed bounded_cball closed_cball by blast lemma compact_frontier_bounded[intro]: fixes S :: "'a::heine_borel set" shows "bounded S \ compact (frontier S)" unfolding frontier_def - using compact_eq_bounded_closed - by blast + using compact_eq_bounded_closed by blast lemma compact_frontier[intro]: fixes S :: "'a::heine_borel set" shows "compact S \ compact (frontier S)" - using compact_eq_bounded_closed compact_frontier_bounded - by blast + using compact_eq_bounded_closed compact_frontier_bounded by blast subsection \Distance from a Set\ @@ -2054,9 +1931,7 @@ with infdist_nonneg[of x A] have "infdist x A > 0" by auto then have "ball x (infdist x A) \ closure A = {}" - apply auto - apply (metis \x \ closure A\ closure_approachable dist_commute infdist_le not_less) - done + by (smt (verit, best) \x \ closure A\ closure_approachableD infdist_le) then have "x \ closure A" by (metis \0 < infdist x A\ centre_in_ball disjoint_iff_not_equal) then show False using \x \ closure A\ by simp @@ -2065,18 +1940,15 @@ assume x: "infdist x A = 0" then obtain a where "a \ A" by atomize_elim (metis all_not_in_conv assms) - show "x \ closure A" - unfolding closure_approachable - apply safe - proof (rule ccontr) - fix e :: real - assume "e > 0" - assume "\ (\y\A. dist y x < e)" - then have "infdist x A \ e" using \a \ A\ - unfolding infdist_def + have False if "e > 0" "\ (\y\A. dist y x < e)" for e + proof - + have "infdist x A \ e" using \a \ A\ + unfolding infdist_def using that by (force simp: dist_commute intro: cINF_greatest) with x \e > 0\ show False by auto qed + then show "x \ closure A" + using closure_approachable by blast qed lemma in_closed_iff_infdist_zero: @@ -2084,14 +1956,14 @@ shows "x \ A \ infdist x A = 0" proof - have "x \ closure A \ infdist x A = 0" - by (rule in_closure_iff_infdist_zero) fact + by (simp add: \A \ {}\ in_closure_iff_infdist_zero) with assms show ?thesis by simp qed lemma infdist_pos_not_in_closed: assumes "closed S" "S \ {}" "x \ S" shows "infdist x S > 0" -using in_closed_iff_infdist_zero[OF assms(1) assms(2), of x] assms(3) infdist_nonneg le_less by fastforce + by (smt (verit, best) assms in_closed_iff_infdist_zero infdist_nonneg) lemma infdist_attains_inf: @@ -2103,10 +1975,9 @@ have "bdd_below (dist y ` X)" by auto from distance_attains_inf[OF assms, of y] - obtain x where INF: "x \ X" "\z. z \ X \ dist y x \ dist y z" by auto - have "infdist y X = dist y x" - by (auto simp: infdist_def assms - intro!: antisym cINF_lower[OF _ \x \ X\] cINF_greatest[OF assms(2) INF(2)]) + obtain x where "x \ X" "\z. z \ X \ dist y x \ dist y z" by auto + then have "infdist y X = dist y x" + by (metis antisym assms(2) cINF_greatest infdist_def infdist_le) with \x \ X\ show ?thesis .. qed @@ -2119,13 +1990,9 @@ consider "S = {}" | "T = {}" | "S \ {} \ T \ {}" by auto then show "\U V. open U \ open V \ S \ U \ T \ V \ U \ V = {}" proof (cases) - case 1 - show ?thesis - apply (rule exI[of _ "{}"], rule exI[of _ UNIV]) using 1 by auto + case 1 then show ?thesis by blast next - case 2 - show ?thesis - apply (rule exI[of _ UNIV], rule exI[of _ "{}"]) using 2 by auto + case 2 then show ?thesis by blast next case 3 define U where "U = (\x\S. ball x ((infdist x T)/2))" @@ -2154,7 +2021,7 @@ then have E: "U \ V = {}" unfolding U_def V_def by auto show ?thesis - apply (rule exI[of _ U], rule exI[of _ V]) using A B C D E by auto + using A B C D E by blast qed qed @@ -2218,57 +2085,42 @@ subsection \Separation between Points and Sets\ proposition separate_point_closed: - fixes s :: "'a::heine_borel set" - assumes "closed s" and "a \ s" - shows "\d>0. \x\s. d \ dist a x" -proof (cases "s = {}") - case True - then show ?thesis by(auto intro!: exI[where x=1]) -next - case False - from assms obtain x where "x\s" "\y\s. dist a x \ dist a y" - using \s \ {}\ by (blast intro: distance_attains_inf [of s a]) - with \x\s\ show ?thesis using dist_pos_lt[of a x] and\a \ s\ - by blast -qed + fixes S :: "'a::heine_borel set" + assumes "closed S" and "a \ S" + shows "\d>0. \x\S. d \ dist a x" + by (metis assms distance_attains_inf empty_iff gt_ex zero_less_dist_iff) proposition separate_compact_closed: - fixes s t :: "'a::heine_borel set" - assumes "compact s" - and t: "closed t" "s \ t = {}" - shows "\d>0. \x\s. \y\t. d \ dist x y" + fixes S T :: "'a::heine_borel set" + assumes "compact S" + and T: "closed T" "S \ T = {}" + shows "\d>0. \x\S. \y\T. d \ dist x y" proof cases - assume "s \ {} \ t \ {}" - then have "s \ {}" "t \ {}" by auto - let ?inf = "\x. infdist x t" - have "continuous_on s ?inf" + assume "S \ {} \ T \ {}" + then have "S \ {}" "T \ {}" by auto + let ?inf = "\x. infdist x T" + have "continuous_on S ?inf" by (auto intro!: continuous_at_imp_continuous_on continuous_infdist continuous_ident) - then obtain x where x: "x \ s" "\y\s. ?inf x \ ?inf y" - using continuous_attains_inf[OF \compact s\ \s \ {}\] by auto + then obtain x where x: "x \ S" "\y\S. ?inf x \ ?inf y" + using continuous_attains_inf[OF \compact S\ \S \ {}\] by auto then have "0 < ?inf x" - using t \t \ {}\ in_closed_iff_infdist_zero by (auto simp: less_le infdist_nonneg) - moreover have "\x'\s. \y\t. ?inf x \ dist x' y" + using T \T \ {}\ in_closed_iff_infdist_zero by (auto simp: less_le infdist_nonneg) + moreover have "\x'\S. \y\T. ?inf x \ dist x' y" using x by (auto intro: order_trans infdist_le) ultimately show ?thesis by auto qed (auto intro!: exI[of _ 1]) proposition separate_closed_compact: - fixes s t :: "'a::heine_borel set" - assumes "closed s" - and "compact t" - and "s \ t = {}" - shows "\d>0. \x\s. \y\t. d \ dist x y" -proof - - have *: "t \ s = {}" - using assms(3) by auto - show ?thesis - using separate_compact_closed[OF assms(2,1) *] by (force simp: dist_commute) -qed + fixes S T :: "'a::heine_borel set" + assumes S: "closed S" + and T: "compact T" + and dis: "S \ T = {}" + shows "\d>0. \x\S. \y\T. d \ dist x y" + by (metis separate_compact_closed[OF T S] dis dist_commute inf_commute) proposition compact_in_open_separated: fixes A::"'a::heine_borel set" - assumes "A \ {}" - assumes "compact A" + assumes A: "A \ {}" "compact A" assumes "open B" assumes "A \ B" obtains e where "e > 0" "{x. infdist x A \ e} \ B" @@ -2287,13 +2139,8 @@ assume "\e. 0 < e \ {x. infdist x A \ e} \ B" with \d > 0\ obtain x where x: "infdist x A \ d" "x \ B" by auto - from assms have "closed A" "A \ {}" by (auto simp: compact_eq_bounded_closed) - from infdist_attains_inf[OF this] - obtain y where y: "y \ A" "infdist x A = dist x y" - by auto - have "dist x y \ d" using x y by simp - also have "\ < dist x y" using y d x by auto - finally show False by simp + then show False + by (metis A compact_eq_bounded_closed infdist_attains_inf x d linorder_not_less) qed qed @@ -2303,8 +2150,8 @@ lemma uniformly_continuous_onE: assumes "uniformly_continuous_on s f" "0 < e" obtains d where "d>0" "\x x'. \x\s; x'\s; dist x' x < d\ \ dist (f x') (f x) < e" -using assms -by (auto simp: uniformly_continuous_on_def) + using assms + by (auto simp: uniformly_continuous_on_def) lemma uniformly_continuous_on_sequentially: "uniformly_continuous_on s f \ (\x y. (\n. x n \ s) \ (\n. y n \ s) \ @@ -2320,20 +2167,11 @@ fix e :: real assume "e > 0" then obtain d where "d > 0" and d: "\x\s. \x'\s. dist x' x < d \ dist (f x') (f x) < e" - using \?lhs\[unfolded uniformly_continuous_on_def, THEN spec[where x=e]] by auto + by (metis \?lhs\ uniformly_continuous_onE) obtain N where N: "\n\N. dist (x n) (y n) < d" using xy[unfolded lim_sequentially dist_norm] and \d>0\ by auto - { - fix n - assume "n\N" - then have "dist (f (x n)) (f (y n)) < e" - using N[THEN spec[where x=n]] - using d[THEN bspec[where x="x n"], THEN bspec[where x="y n"]] - using x and y - by (simp add: dist_commute) - } then have "\N. \n\N. dist (f (x n)) (f (y n)) < e" - by auto + using d x y by blast } then have "((\n. dist (f(x n)) (f(y n))) \ 0) sequentially" unfolding lim_sequentially and dist_real_def by auto @@ -2348,8 +2186,7 @@ then obtain fa where fa: "\x. 0 < x \ fst (fa x) \ s \ snd (fa x) \ s \ dist (fst (fa x)) (snd (fa x)) < x \ \ dist (f (fst (fa x))) (f (snd (fa x))) < e" using choice[of "\d x. d>0 \ fst x \ s \ snd x \ s \ dist (snd x) (fst x) < d \ \ dist (f (snd x)) (f (fst x)) < e"] - unfolding Bex_def - by (auto simp: dist_commute) + by (auto simp: Bex_def dist_commute) define x where "x n = fst (fa (inverse (real n + 1)))" for n define y where "y n = snd (fa (inverse (real n + 1)))" for n have xyn: "\n. x n \ s \ y n \ s" @@ -2362,17 +2199,8 @@ assume "e > 0" then obtain N :: nat where "N \ 0" and N: "0 < inverse (real N) \ inverse (real N) < e" unfolding real_arch_inverse[of e] by auto - { - fix n :: nat - assume "n \ N" - then have "inverse (real n + 1) < inverse (real N)" - using of_nat_0_le_iff and \N\0\ by auto - also have "\ < e" using N by auto - finally have "inverse (real n + 1) < e" by auto - then have "dist (x n) (y n) < e" - using xy0[THEN spec[where x=n]] by auto - } - then have "\N. \n\N. dist (x n) (y n) < e" by auto + then have "\N. \n\N. dist (x n) (y n) < e" + by (smt (verit, ccfv_SIG) inverse_le_imp_le nat_le_real_less of_nat_le_0_iff xy0) } then have "\e>0. \N. \n\N. dist (f (x n)) (f (y n)) < e" using \?rhs\[THEN spec[where x=x], THEN spec[where x=y]] and xyn @@ -2415,8 +2243,7 @@ then have "dist (f (r (max N1 N2))) x < 1 / real (Suc (r (max N1 N2)))" by simp also have "... \ 1 / real (Suc (max N1 N2))" - apply (simp add: field_split_simps del: max.bounded_iff) - using \strict_mono r\ seq_suble by blast + by (meson Suc_le_mono \strict_mono r\ inverse_of_nat_le nat.discI seq_suble) also have "... \ 1 / real (Suc N2)" by (simp add: field_simps) also have "... < e/2" @@ -2447,7 +2274,7 @@ using cont by metis let ?\ = "((\x. ball x (d x (e/2))) ` S)" have Ssub: "S \ \ ?\" - by clarsimp (metis d_pos \0 < e\ dist_self half_gt_zero_iff) + using \0 < e\ d_pos by auto then obtain k where "0 < k" and k: "\x. x \ S \ \G \ ?\. ball x k \ G" by (rule Heine_Borel_lemma [OF \compact S\]) auto moreover have "dist (f v) (f u) < e" if "f \ \" "u \ S" "v \ S" "dist v u < k" for f u v @@ -2637,10 +2464,7 @@ from uc have cont_f: "continuous_on X f" by (simp add: uniformly_continuous_imp_continuous) obtain y where y: "(f \ y x) (at x within X)" if "x \ closure X" for x - apply atomize_elim - apply (rule choice) - using uniformly_continuous_on_extension_at_closure[OF assms] - by metis + using uniformly_continuous_on_extension_at_closure[OF assms] by meson let ?g = "\x. if x \ X then f x else y x" have "uniformly_continuous_on (closure X) ?g" @@ -2733,14 +2557,11 @@ proof assume ?lhs then show ?rhs - apply (simp add: openin_open) - apply (metis Int_commute Int_mono inf.cobounded2 open_contains_ball order_refl subsetCE) - done + by (metis IntD2 Int_commute Int_lower1 Int_mono inf.idem openE openin_open) next assume ?rhs then show ?lhs - apply (simp add: openin_euclidean_subtopology_iff) - by (metis (no_types) Int_iff dist_commute inf.absorb_iff2 mem_ball) + by (smt (verit) open_ball Int_commute Int_iff centre_in_ball in_mono openin_open_Int openin_subopen) qed lemma openin_contains_cball: @@ -2804,11 +2625,8 @@ "\e. e>0 \ \n. \x\S n. \y\S n. dist x y < e" obtains a where "\n. a \ S n" proof - - have "\n. \x. x \ S n" - using assms(2) by auto - then have "\t. \n. t n \ S n" - using choice[of "\n x. x \ S n"] by auto - then obtain t where t: "\n. t n \ S n" by auto + obtain t where t: "\n. t n \ S n" + by (meson assms(2) equals0I) { fix e :: real assume "e > 0" @@ -3012,15 +2830,7 @@ lemma continuous_at_real_range: fixes f :: "'a::real_normed_vector \ real" shows "continuous (at x) f \ (\e>0. \d>0. \x'. norm(x' - x) < d --> \f x' - f x\ < e)" - unfolding continuous_at - unfolding Lim_at - unfolding dist_norm - apply auto - apply (erule_tac x=e in allE, auto) - apply (rule_tac x=d in exI, auto) - apply (erule_tac x=x' in allE, auto) - apply (erule_tac x=e in allE, auto) - done + by (metis (mono_tags, opaque_lifting) LIM_eq continuous_within norm_eq_zero real_norm_def right_minus_eq) lemma continuous_on_real_range: fixes f :: "'a::real_normed_vector \ real" @@ -3091,12 +2901,7 @@ lemma le_setdist_iff: "d \ setdist S T \ (\x \ S. \y \ T. d \ dist x y) \ (S = {} \ T = {} \ d \ 0)" - apply (cases "S = {} \ T = {}") - apply (force simp add: setdist_def) - apply (intro iffI conjI) - using setdist_le_dist apply fastforce - apply (auto simp: intro: le_setdistI) - done + by (smt (verit) le_setdistI setdist_def setdist_le_dist) lemma setdist_ltE: assumes "setdist S T < b" "S \ {}" "T \ {}" @@ -3105,11 +2910,7 @@ by (auto simp: not_le [symmetric] le_setdist_iff) lemma setdist_refl: "setdist S S = 0" - apply (cases "S = {}") - apply (force simp add: setdist_def) - apply (rule antisym [OF _ setdist_pos_le]) - apply (metis all_not_in_conv dist_self setdist_le_dist) - done + by (metis dist_eq_0_iff ex_in_conv order_antisym setdist_def setdist_le_dist setdist_pos_le) lemma setdist_sym: "setdist S T = setdist T S" by (force simp: setdist_def dist_commute intro!: arg_cong [where f=Inf]) @@ -3121,10 +2922,8 @@ next case False then have "\x. x \ S \ setdist S T - dist x a \ setdist {a} T" - apply (intro le_setdistI) - apply (simp_all add: algebra_simps) - apply (metis dist_commute dist_triangle3 order_trans [OF setdist_le_dist]) - done + using dist_self dist_triangle3 empty_not_insert le_setdist_iff setdist_le_dist singleton_iff + by (smt (verit, best) dist_self dist_triangle3 empty_not_insert le_setdist_iff setdist_le_dist singleton_iff) then have "setdist S T - setdist {a} T \ setdist S {a}" using False by (fastforce intro: le_setdistI) then show ?thesis @@ -3148,9 +2947,7 @@ by (force simp: uniformly_continuous_on_def dist_real_def intro: le_less_trans [OF setdist_Lipschitz]) lemma setdist_subset_right: "\T \ {}; T \ u\ \ setdist S u \ setdist S T" - apply (cases "S = {} \ u = {}", force) - apply (auto simp: setdist_def intro!: bdd_belowI [where m=0] cInf_superset_mono) - done + by (smt (verit, best) in_mono le_setdist_iff) lemma setdist_subset_left: "\S \ {}; S \ T\ \ setdist T u \ setdist S u" by (metis setdist_subset_right setdist_sym) @@ -3166,12 +2963,9 @@ by (auto simp: continuous_intros dist_norm) then have *: "\x. x \ closure S \ setdist S T \ dist x y" by (fast intro: setdist_le_dist \y \ T\ continuous_ge_on_closure) - } note * = this + } then show ?thesis - apply (rule antisym) - using False closure_subset apply (blast intro: setdist_subset_left) - using False * apply (force intro!: le_setdistI) - done + by (metis False antisym closure_eq_empty closure_subset le_setdist_iff setdist_subset_left) qed lemma setdist_closure_2 [simp]: "setdist T (closure S) = setdist T S" @@ -3199,14 +2993,13 @@ have "Inf {dist x y |x y. x \ A \ y \ B} \ Inf (dist x ` B)" if "b \ B" "a \ A" "x \ A" for x proof - - have *: "\b'. b' \ B \ Inf {dist x y |x y. x \ A \ y \ B} \ dist x b'" + have "\b'. b' \ B \ Inf {dist x y |x y. x \ A \ y \ B} \ dist x b'" by (metis (mono_tags, lifting) ex_in_conv setdist_def setdist_le_dist that(3)) - show ?thesis - using that by (subst conditionally_complete_lattice_class.le_cInf_iff) (auto simp: *)+ + then show ?thesis + by (smt (verit) cINF_greatest ex_in_conv \b \ B\) qed then show "Inf {dist x y |x y. x \ A \ y \ B} \ (INF x\A. Inf (dist x ` B))" - using that - by (subst conditionally_complete_lattice_class.le_cInf_iff) (auto simp: bdd_below_def) + by (metis (mono_tags, lifting) cINF_greatest emptyE that) next have *: "\x y. \b \ B; a \ A; x \ A; y \ B\ \ \a\A. Inf (dist a ` B) \ dist x y" by (meson bdd_below_image_dist cINF_lower) @@ -3225,8 +3018,7 @@ shows "infdist x B \ infdist x A" by (simp add: assms infdist_eq_setdist setdist_subset_right) -lemma infdist_singleton [simp]: - "infdist x {y} = dist x y" +lemma infdist_singleton [simp]: "infdist x {y} = dist x y" by (simp add: infdist_eq_setdist) proposition setdist_attains_inf: @@ -3247,12 +3039,7 @@ also have "\ = infdist y A" proof (rule order_antisym) show "(INF y\B. infdist y A) \ infdist y A" - proof (rule cInf_lower) - show "infdist y A \ (\y. infdist y A) ` B" - using \y \ B\ by blast - show "bdd_below ((\y. infdist y A) ` B)" - by (meson bdd_belowI2 infdist_nonneg) - qed + by (meson \y \ B\ bdd_belowI2 cInf_lower image_eqI infdist_nonneg) next show "infdist y A \ (INF y\B. infdist y A)" by (simp add: \B \ {}\ cINF_greatest min) diff -r 04af11e6557a -r 18e719c6b633 src/HOL/Library/Float.thy --- a/src/HOL/Library/Float.thy Tue Dec 27 22:52:28 2022 +0100 +++ b/src/HOL/Library/Float.thy Wed Dec 28 12:15:25 2022 +0000 @@ -100,22 +100,11 @@ qed lemma uminus_float[simp]: "x \ float \ -x \ float" - apply (auto simp: float_def) - apply hypsubst_thin - apply (rename_tac m e) - apply (rule_tac x="-m" in exI) - apply (rule_tac x="e" in exI) - apply (simp add: field_simps) - done + by (simp add: float_def) (metis mult_minus_left of_int_minus) lemma times_float[simp]: "x \ float \ y \ float \ x * y \ float" - apply (auto simp: float_def) - apply hypsubst_thin - apply (rename_tac mx my ex ey) - apply (rule_tac x="mx * my" in exI) - apply (rule_tac x="ex + ey" in exI) - apply (simp add: powr_add) - done + apply (clarsimp simp: float_def) + by (metis (no_types, opaque_lifting) of_int_add powr_add mult.assoc mult.left_commute of_int_mult) lemma minus_float[simp]: "x \ float \ y \ float \ x - y \ float" using plus_float [of x "- y"] by simp @@ -126,23 +115,11 @@ lemma sgn_of_float[simp]: "x \ float \ sgn x \ float" by (cases x rule: linorder_cases[of 0]) (auto intro!: uminus_float) -lemma div_power_2_float[simp]: "x \ float \ x / 2^d \ float" - apply (auto simp add: float_def) - apply hypsubst_thin - apply (rename_tac m e) - apply (rule_tac x="m" in exI) - apply (rule_tac x="e - d" in exI) - apply (simp flip: powr_realpow powr_add add: field_simps) - done +lemma div_power_2_float[simp]: "x \ float \ x / 2^d \ float" + by (simp add: float_def) (metis of_int_diff of_int_of_nat_eq powr_diff powr_realpow zero_less_numeral times_divide_eq_right) lemma div_power_2_int_float[simp]: "x \ float \ x / (2::int)^d \ float" - apply (auto simp add: float_def) - apply hypsubst_thin - apply (rename_tac m e) - apply (rule_tac x="m" in exI) - apply (rule_tac x="e - d" in exI) - apply (simp flip: powr_realpow powr_add add: field_simps) - done + by simp lemma div_numeral_Bit0_float[simp]: assumes "x / numeral n \ float" @@ -158,13 +135,7 @@ lemma div_neg_numeral_Bit0_float[simp]: assumes "x / numeral n \ float" shows "x / (- numeral (Num.Bit0 n)) \ float" -proof - - have "- (x / numeral (Num.Bit0 n)) \ float" - using assms by simp - also have "- (x / numeral (Num.Bit0 n)) = x / - numeral (Num.Bit0 n)" - by simp - finally show ?thesis . -qed + using assms by force lemma power_float[simp]: assumes "a \ float" @@ -251,15 +222,9 @@ proof fix a b :: float show "\c. a < c" - apply (intro exI[of _ "a + 1"]) - apply transfer - apply simp - done + by (metis Float.real_of_float less_float.rep_eq reals_Archimedean2) show "\c. c < a" - apply (intro exI[of _ "a - 1"]) - apply transfer - apply simp - done + by (metis add_0 add_strict_right_mono neg_less_0_iff_less zero_less_one) show "\c. a < c \ c < b" if "a < b" apply (rule exI[of _ "(a + b) * Float 1 (- 1)"]) using that @@ -283,11 +248,10 @@ end lemma float_numeral[simp]: "real_of_float (numeral x :: float) = numeral x" - apply (induct x) - apply simp - apply (simp_all only: numeral_Bit0 numeral_Bit1 real_of_float_eq float_of_inverse - plus_float.rep_eq one_float.rep_eq plus_float numeral_float one_float) - done +proof (induct x) + case One + then show ?case by simp +qed (metis of_int_numeral real_of_float_of_int_eq)+ lemma transfer_numeral [transfer_rule]: "rel_fun (=) pcr_float (numeral :: _ \ real) (numeral :: _ \ float)" @@ -837,11 +801,11 @@ finally show ?thesis using \p + e < 0\ apply transfer - apply (simp add: round_down_def field_simps flip: floor_divide_of_int_eq) + apply (simp add: round_down_def field_simps flip: floor_divide_of_int_eq powr_add) apply (metis (no_types, opaque_lifting) Float.rep_eq add.inverse_inverse compute_real_of_float diff_minus_eq_add floor_divide_of_int_eq int_of_reals(1) linorder_not_le - minus_add_distrib of_int_eq_numeral_power_cancel_iff powr_add) + minus_add_distrib of_int_eq_numeral_power_cancel_iff ) done next case False @@ -885,10 +849,7 @@ have "real_of_int \real_of_int a / real_of_int b\ \ real_of_int a / real_of_int b" by simp moreover have "real_of_int \real_of_int a / real_of_int b\ \ real_of_int a / real_of_int b" - apply (subst (2) real_of_int_div_aux) - unfolding floor_divide_of_int_eq - using ne \b \ 0\ apply auto - done + by (smt (verit) floor_divide_of_int_eq ne real_of_int_div_aux) ultimately show "real_of_int \real_of_int a / real_of_int b\ < real_of_int a / real_of_int b" by arith qed then show ?thesis @@ -1254,12 +1215,7 @@ by (auto simp: truncate_up_uminus_eq truncate_down_uminus_eq) lemma truncate_down_mono: "x \ y \ truncate_down p x \ truncate_down p y" - apply (cases "0 \ x") - apply (rule truncate_down_nonneg_mono, assumption+) - apply (simp add: truncate_down_eq_truncate_up) - apply (cases "0 \ y") - apply (auto intro: truncate_up_nonneg_mono truncate_up_switch_sign_mono) - done + by (smt (verit) truncate_down_nonneg_mono truncate_up_nonneg_mono truncate_up_uminus_eq) lemma truncate_up_mono: "x \ y \ truncate_up p x \ truncate_up p y" by (simp add: truncate_up_eq_truncate_down truncate_down_mono) @@ -1271,22 +1227,7 @@ by (meson less_le_trans that truncate_up) lemma truncate_up_less_zero_iff[simp]: "truncate_up p x < 0 \ x < 0" -proof - - have f1: "\n r. truncate_up n r + truncate_down n (- 1 * r) = 0" - by (simp add: truncate_down_uminus_eq) - have f2: "(\v0 v1. truncate_up v0 v1 + truncate_down v0 (- 1 * v1) = 0) = (\v0 v1. truncate_up v0 v1 = - 1 * truncate_down v0 (- 1 * v1))" - by (auto simp: truncate_up_eq_truncate_down) - have f3: "\x1. ((0::real) < x1) = (\ x1 \ 0)" - by fastforce - have "(- 1 * x \ 0) = (0 \ x)" - by force - then have "0 \ x \ \ truncate_down p (- 1 * x) \ 0" - using f3 by (meson truncate_down_pos) - then have "(0 \ truncate_up p x) \ (\ 0 \ x)" - using f2 f1 truncate_up_nonneg by force - then show ?thesis - by linarith -qed + by (smt (verit) truncate_down_pos truncate_down_uminus_eq truncate_up_nonneg) lemma truncate_up_nonneg_iff[simp]: "truncate_up p x \ 0 \ x \ 0" using truncate_up_less_zero_iff[of p x] truncate_up_nonneg[of x] @@ -1913,7 +1854,6 @@ by (meson dual_order.trans mult_left_mono_neg mult_right_mono_neg that) lemma mult_float_mono1: - notes mono_rules = plus_down_mono add_mono nprt_mono nprt_le_zero zero_le_pprt pprt_mono shows "a \ b \ ab \ bb \ aa \ a \ b \ ba \ @@ -1927,20 +1867,10 @@ (plus_down prec (nprt b * nprt bb) (plus_down prec (pprt a * pprt ab) (pprt b * nprt ab)))" - apply (rule order_trans) - apply (rule mono_rules | assumption)+ - apply (rule mult_mono_nonpos_nonneg) - apply (rule mono_rules | assumption)+ - apply (rule mult_mono_nonpos_nonpos) - apply (rule mono_rules | assumption)+ - apply (rule mult_mono) - apply (rule mono_rules | assumption)+ - apply (rule mult_mono_nonneg_nonpos) - apply (rule mono_rules | assumption)+ - by (rule order_refl)+ + by (smt (verit, del_insts) mult_mono plus_down_mono add_mono nprt_mono nprt_le_zero zero_le_pprt +pprt_mono mult_mono_nonpos_nonneg mult_mono_nonpos_nonpos mult_mono_nonneg_nonpos) lemma mult_float_mono2: - notes mono_rules = plus_up_mono add_mono nprt_mono nprt_le_zero zero_le_pprt pprt_mono shows "a \ b \ ab \ bb \ aa \ a \ @@ -1955,17 +1885,8 @@ (plus_up prec (pprt aa * nprt bc) (plus_up prec (nprt ba * pprt ac) (nprt aa * nprt ac)))" - apply (rule order_trans) - apply (rule mono_rules | assumption)+ - apply (rule mult_mono) - apply (rule mono_rules | assumption)+ - apply (rule mult_mono_nonneg_nonpos) - apply (rule mono_rules | assumption)+ - apply (rule mult_mono_nonpos_nonneg) - apply (rule mono_rules | assumption)+ - apply (rule mult_mono_nonpos_nonpos) - apply (rule mono_rules | assumption)+ - by (rule order_refl)+ + by (smt (verit, del_insts) plus_up_mono add_mono mult_mono nprt_mono nprt_le_zero zero_le_pprt pprt_mono + mult_mono_nonpos_nonneg mult_mono_nonpos_nonpos mult_mono_nonneg_nonpos) subsection \Approximate Power\ @@ -2132,24 +2053,21 @@ assume [simp]: "odd j" have "power_down prec 0 (Suc (j div 2)) \ - power_down prec b (Suc (j div 2))" if "b < 0" "even (j div 2)" - apply (rule order_trans[where y=0]) - using IH that by (auto simp: div2_less_self) + by (metis even_Suc le_minus_iff Suc_neq_Zero neg_equal_zero power_down_eq_zero_iff + power_down_nonpos_iff that) then have "truncate_down (Suc prec) ((power_down prec a (Suc (j div 2)))\<^sup>2) \ truncate_down (Suc prec) ((power_down prec b (Suc (j div 2)))\<^sup>2)" - using IH - by (auto intro!: truncate_down_mono intro: order_trans[where y=0] - simp: abs_le_square_iff[symmetric] abs_real_def - div2_less_self) + by (smt (verit) IH Suc_less_eq \odd j\ div2_less_self mult_mono_nonpos_nonpos + Suc_neq_Zero power2_eq_square power_down_neg_iff power_down_nonpos_iff power_mono truncate_down_mono) then show ?thesis - unfolding j - by (simp add: power_down_simp) + unfolding j by (simp add: power_down_simp) qed qed simp qed lemma power_up_even_nonneg: "even n \ 0 \ power_up p x n" by (induct p x n rule: power_up.induct) - (auto simp: power_up.simps simp del: odd_Suc_div_two intro!: ) + (auto simp: power_up.simps simp del: odd_Suc_div_two) lemma power_up_eq_zero_iff[simp]: "power_up prec b n = 0 \ b = 0 \ n \ 0" proof (induction n arbitrary: b rule: less_induct) @@ -2253,18 +2171,7 @@ fixes a b :: int assumes "b > 0" shows "a \ b * (a div b)" -proof - - from minus_div_mult_eq_mod [symmetric, of a b] have "a = b * (a div b) + a mod b" - by simp - also have "\ \ b * (a div b) + 0" - apply (rule add_left_mono) - apply (rule pos_mod_sign) - using assms - apply simp - done - finally show ?thesis - by simp -qed + by (smt (verit, ccfv_threshold) assms minus_div_mult_eq_mod mod_int_pos_iff mult.commute) lemma lapprox_rat_nonneg: assumes "0 \ x" and "0 \ y" @@ -2393,9 +2300,8 @@ qualified lemma compute_int_floor_fl[code]: "int_floor_fl (Float m e) = (if 0 \ e then m * 2 ^ nat e else m div (2 ^ (nat (-e))))" apply transfer - apply (simp add: powr_int floor_divide_of_int_eq) - apply (metis (no_types, opaque_lifting)floor_divide_of_int_eq of_int_numeral of_int_power floor_of_int of_int_mult) - done + by (smt (verit, ccfv_threshold) Float.rep_eq compute_real_of_float floor_divide_of_int_eq + floor_of_int of_int_1 of_int_add of_int_mult of_int_power) lift_definition floor_fl :: "float \ float" is "\x. real_of_int \x\" by simp @@ -2404,8 +2310,7 @@ "floor_fl (Float m e) = (if 0 \ e then Float m e else Float (m div (2 ^ (nat (-e)))) 0)" apply transfer apply (simp add: powr_int floor_divide_of_int_eq) - apply (metis (no_types, opaque_lifting)floor_divide_of_int_eq of_int_numeral of_int_power of_int_mult) - done + by (smt (z3) floor_divide_of_int_eq of_int_1 of_int_add of_int_power) end