# HG changeset patch # User immler # Date 1546793689 -3600 # Node ID 42cc3609fedfb1bf572b4c68af8fa0f11ab7bc47 # Parent 10644973cddef9b89b9b3c941891e71b7453e093 moved some material from Connected.thy to more appropriate places diff -r 10644973cdde -r 42cc3609fedf src/HOL/Analysis/Connected.thy --- a/src/HOL/Analysis/Connected.thy Sun Jan 06 16:27:52 2019 +0100 +++ b/src/HOL/Analysis/Connected.thy Sun Jan 06 17:54:49 2019 +0100 @@ -10,342 +10,60 @@ Topology_Euclidean_Space begin -subsection%unimportant \More properties of closed balls, spheres, etc\ - -lemma mem_interior_cball: "x \ interior S \ (\e>0. cball x e \ S)" - apply (simp add: interior_def, safe) - apply (force simp: open_contains_cball) - apply (rule_tac x="ball x e" in exI) - apply (simp add: subset_trans [OF ball_subset_cball]) - done - -lemma islimpt_ball: - fixes x y :: "'a::{real_normed_vector,perfect_space}" - shows "y islimpt ball x e \ 0 < e \ y \ cball x e" - (is "?lhs \ ?rhs") -proof - show ?rhs if ?lhs - proof - { - assume "e \ 0" - then have *: "ball x e = {}" - using ball_eq_empty[of x e] by auto - have False using \?lhs\ - unfolding * using islimpt_EMPTY[of y] by auto - } - then show "e > 0" by (metis not_less) - show "y \ cball x e" - using closed_cball[of x e] islimpt_subset[of y "ball x e" "cball x e"] - ball_subset_cball[of x e] \?lhs\ - unfolding closed_limpt by auto +subsection%unimportant\Lemmas Combining Imports\ + +lemma isCont_indicator: + fixes x :: "'a::t2_space" + shows "isCont (indicator A :: 'a \ real) x = (x \ frontier A)" +proof auto + fix x + assume cts_at: "isCont (indicator A :: 'a \ real) x" and fr: "x \ frontier A" + with continuous_at_open have 1: "\V::real set. open V \ indicator A x \ V \ + (\U::'a set. open U \ x \ U \ (\y\U. indicator A y \ V))" by auto + show False + proof (cases "x \ A") + assume x: "x \ A" + hence "indicator A x \ ({0<..<2} :: real set)" by simp + hence "\U. open U \ x \ U \ (\y\U. indicator A y \ ({0<..<2} :: real set))" + using 1 open_greaterThanLessThan by blast + then guess U .. note U = this + hence "\y\U. indicator A y > (0::real)" + unfolding greaterThanLessThan_def by auto + hence "U \ A" using indicator_eq_0_iff by force + hence "x \ interior A" using U interiorI by auto + thus ?thesis using fr unfolding frontier_def by simp + next + assume x: "x \ A" + hence "indicator A x \ ({-1<..<1} :: real set)" by simp + hence "\U. open U \ x \ U \ (\y\U. indicator A y \ ({-1<..<1} :: real set))" + using 1 open_greaterThanLessThan by blast + then guess U .. note U = this + hence "\y\U. indicator A y < (1::real)" + unfolding greaterThanLessThan_def by auto + hence "U \ -A" by auto + hence "x \ interior (-A)" using U interiorI by auto + thus ?thesis using fr interior_complement unfolding frontier_def by auto qed - show ?lhs if ?rhs - proof - - from that have "e > 0" by auto - { - fix d :: real - assume "d > 0" - have "\x'\ball x e. x' \ y \ dist x' y < d" - proof (cases "d \ dist x y") - case True - then show "\x'\ball x e. x' \ y \ dist x' y < d" - proof (cases "x = y") - case True - then have False - using \d \ dist x y\ \d>0\ by auto - then show "\x'\ball x e. x' \ y \ dist x' y < d" - by auto - next - case False - have "dist x (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) = - norm (x - y + (d / (2 * norm (y - x))) *\<^sub>R (y - x))" - unfolding mem_cball mem_ball dist_norm diff_diff_eq2 diff_add_eq[symmetric] - by auto - also have "\ = \- 1 + d / (2 * norm (x - y))\ * norm (x - y)" - using scaleR_left_distrib[of "- 1" "d / (2 * norm (y - x))", symmetric, of "y - x"] - unfolding scaleR_minus_left scaleR_one - by (auto simp: norm_minus_commute) - also have "\ = \- norm (x - y) + d / 2\" - unfolding abs_mult_pos[of "norm (x - y)", OF norm_ge_zero[of "x - y"]] - unfolding distrib_right using \x\y\ by auto - also have "\ \ e - d/2" using \d \ dist x y\ and \d>0\ and \?rhs\ - by (auto simp: dist_norm) - finally have "y - (d / (2 * dist y x)) *\<^sub>R (y - x) \ ball x e" using \d>0\ - by auto - moreover - have "(d / (2*dist y x)) *\<^sub>R (y - x) \ 0" - using \x\y\[unfolded dist_nz] \d>0\ unfolding scaleR_eq_0_iff - by (auto simp: dist_commute) - moreover - have "dist (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) y < d" - unfolding dist_norm - apply simp - unfolding norm_minus_cancel - using \d > 0\ \x\y\[unfolded dist_nz] dist_commute[of x y] - unfolding dist_norm - apply auto - done - ultimately show "\x'\ball x e. x' \ y \ dist x' y < d" - apply (rule_tac x = "y - (d / (2*dist y x)) *\<^sub>R (y - x)" in bexI) - apply auto - done - qed - next - case False - then have "d > dist x y" by auto - show "\x' \ ball x e. x' \ y \ dist x' y < d" - proof (cases "x = y") - case True - obtain z where **: "z \ y" "dist z y < min e d" - using perfect_choose_dist[of "min e d" y] - using \d > 0\ \e>0\ by auto - show "\x'\ball x e. x' \ y \ dist x' y < d" - unfolding \x = y\ - using \z \ y\ ** - apply (rule_tac x=z in bexI) - apply (auto simp: dist_commute) - done - next - case False - then show "\x'\ball x e. x' \ y \ dist x' y < d" - using \d>0\ \d > dist x y\ \?rhs\ - apply (rule_tac x=x in bexI, auto) - done - qed - qed - } - then show ?thesis - unfolding mem_cball islimpt_approachable mem_ball by auto +next + assume nfr: "x \ frontier A" + hence "x \ interior A \ x \ interior (-A)" + by (auto simp: frontier_def closure_interior) + thus "isCont ((indicator A)::'a \ real) x" + proof + assume int: "x \ interior A" + then obtain U where U: "open U" "x \ U" "U \ A" unfolding interior_def by auto + hence "\y\U. indicator A y = (1::real)" unfolding indicator_def by auto + hence "continuous_on U (indicator A)" by (simp add: continuous_on_const indicator_eq_1_iff) + thus ?thesis using U continuous_on_eq_continuous_at by auto + next + assume ext: "x \ interior (-A)" + then obtain U where U: "open U" "x \ U" "U \ -A" unfolding interior_def by auto + then have "continuous_on U (indicator A)" + using continuous_on_topological by (auto simp: subset_iff) + thus ?thesis using U continuous_on_eq_continuous_at by auto qed qed -lemma closure_ball_lemma: - fixes x y :: "'a::real_normed_vector" - assumes "x \ y" - shows "y islimpt ball x (dist x y)" -proof (rule islimptI) - fix T - assume "y \ T" "open T" - then obtain r where "0 < r" "\z. dist z y < r \ z \ T" - unfolding open_dist by fast - (* choose point between x and y, within distance r of y. *) - define k where "k = min 1 (r / (2 * dist x y))" - define z where "z = y + scaleR k (x - y)" - have z_def2: "z = x + scaleR (1 - k) (y - x)" - unfolding z_def by (simp add: algebra_simps) - have "dist z y < r" - unfolding z_def k_def using \0 < r\ - by (simp add: dist_norm min_def) - then have "z \ T" - using \\z. dist z y < r \ z \ T\ by simp - have "dist x z < dist x y" - unfolding z_def2 dist_norm - apply (simp add: norm_minus_commute) - apply (simp only: dist_norm [symmetric]) - apply (subgoal_tac "\1 - k\ * dist x y < 1 * dist x y", simp) - apply (rule mult_strict_right_mono) - apply (simp add: k_def \0 < r\ \x \ y\) - apply (simp add: \x \ y\) - done - then have "z \ ball x (dist x y)" - by simp - have "z \ y" - unfolding z_def k_def using \x \ y\ \0 < r\ - by (simp add: min_def) - show "\z\ball x (dist x y). z \ T \ z \ y" - using \z \ ball x (dist x y)\ \z \ T\ \z \ y\ - by fast -qed - -lemma at_within_ball_bot_iff: - fixes x y :: "'a::{real_normed_vector,perfect_space}" - shows "at x within ball y r = bot \ (r=0 \ x \ cball y r)" - unfolding trivial_limit_within -apply (auto simp add:trivial_limit_within islimpt_ball ) -by (metis le_less_trans less_eq_real_def zero_le_dist) - -lemma closure_ball [simp]: - fixes x :: "'a::real_normed_vector" - shows "0 < e \ closure (ball x e) = cball x e" - apply (rule equalityI) - apply (rule closure_minimal) - apply (rule ball_subset_cball) - apply (rule closed_cball) - apply (rule subsetI, rename_tac y) - apply (simp add: le_less [where 'a=real]) - apply (erule disjE) - apply (rule subsetD [OF closure_subset], simp) - apply (simp add: closure_def, clarify) - apply (rule closure_ball_lemma) - apply simp - done - -(* In a trivial vector space, this fails for e = 0. *) -lemma interior_cball [simp]: - fixes x :: "'a::{real_normed_vector, perfect_space}" - shows "interior (cball x e) = ball x e" -proof (cases "e \ 0") - case False note cs = this - from cs have null: "ball x e = {}" - using ball_empty[of e x] by auto - moreover - { - fix y - assume "y \ cball x e" - then have False - by (metis ball_eq_empty null cs dist_eq_0_iff dist_le_zero_iff empty_subsetI mem_cball subset_antisym subset_ball) - } - then have "cball x e = {}" by auto - then have "interior (cball x e) = {}" - using interior_empty by auto - ultimately show ?thesis by blast -next - case True note cs = this - have "ball x e \ cball x e" - using ball_subset_cball by auto - moreover - { - fix S y - assume as: "S \ cball x e" "open S" "y\S" - then obtain d where "d>0" and d: "\x'. dist x' y < d \ x' \ S" - unfolding open_dist by blast - then obtain xa where xa_y: "xa \ y" and xa: "dist xa y < d" - using perfect_choose_dist [of d] by auto - have "xa \ S" - using d[THEN spec[where x = xa]] - using xa by (auto simp: dist_commute) - then have xa_cball: "xa \ cball x e" - using as(1) by auto - then have "y \ ball x e" - proof (cases "x = y") - case True - then have "e > 0" using cs order.order_iff_strict xa_cball xa_y by fastforce - then show "y \ ball x e" - using \x = y \ by simp - next - case False - have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) y < d" - unfolding dist_norm - using \d>0\ norm_ge_zero[of "y - x"] \x \ y\ by auto - then have *: "y + (d / 2 / dist y x) *\<^sub>R (y - x) \ cball x e" - using d as(1)[unfolded subset_eq] by blast - have "y - x \ 0" using \x \ y\ by auto - hence **:"d / (2 * norm (y - x)) > 0" - unfolding zero_less_norm_iff[symmetric] using \d>0\ by auto - have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) x = - norm (y + (d / (2 * norm (y - x))) *\<^sub>R y - (d / (2 * norm (y - x))) *\<^sub>R x - x)" - by (auto simp: dist_norm algebra_simps) - also have "\ = norm ((1 + d / (2 * norm (y - x))) *\<^sub>R (y - x))" - by (auto simp: algebra_simps) - also have "\ = \1 + d / (2 * norm (y - x))\ * norm (y - x)" - using ** by auto - also have "\ = (dist y x) + d/2" - using ** by (auto simp: distrib_right dist_norm) - finally have "e \ dist x y +d/2" - using *[unfolded mem_cball] by (auto simp: dist_commute) - then show "y \ ball x e" - unfolding mem_ball using \d>0\ by auto - qed - } - then have "\S \ cball x e. open S \ S \ ball x e" - by auto - ultimately show ?thesis - using interior_unique[of "ball x e" "cball x e"] - using open_ball[of x e] - by auto -qed - -lemma interior_ball [simp]: "interior (ball x e) = ball x e" - by (simp add: interior_open) - -lemma frontier_ball [simp]: - fixes a :: "'a::real_normed_vector" - shows "0 < e \ frontier (ball a e) = sphere a e" - by (force simp: frontier_def) - -lemma frontier_cball [simp]: - fixes a :: "'a::{real_normed_vector, perfect_space}" - shows "frontier (cball a e) = sphere a e" - by (force simp: frontier_def) - -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 - -lemma cball_empty [simp]: "e < 0 \ cball x e = {}" - by simp - -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 - -lemma cball_sing: - fixes x :: "'a::metric_space" - shows "e = 0 \ cball x e = {x}" - by (auto simp: set_eq_iff) - -lemma ball_divide_subset: "d \ 1 \ ball x (e/d) \ ball x e" - apply (cases "e \ 0") - apply (simp add: ball_empty divide_simps) - apply (rule subset_ball) - apply (simp add: divide_simps) - done - -lemma ball_divide_subset_numeral: "ball x (e / numeral w) \ ball x e" - 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") - apply (simp add: divide_simps) - apply (rule subset_cball) - apply (metis div_by_1 frac_le not_le order_refl zero_less_one) - done - -lemma cball_divide_subset_numeral: "cball x (e / numeral w) \ cball x e" - using cball_divide_subset one_le_numeral by blast - -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 - -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 - -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 - -corollary compact_sphere [simp]: - fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}" - shows "compact (sphere a r)" -using compact_frontier [of "cball a r"] by simp - -corollary bounded_sphere [simp]: - fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}" - shows "bounded (sphere a r)" -by (simp add: compact_imp_bounded) - -corollary closed_sphere [simp]: - fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}" - shows "closed (sphere a r)" -by (simp add: compact_imp_closed) subsection%unimportant \Connectedness\ @@ -776,1325 +494,6 @@ using closedin_connected_component componentsE by blast -subsection \Intersecting chains of compact sets and the Baire property\ - -proposition bounded_closed_chain: - fixes \ :: "'a::heine_borel set set" - assumes "B \ \" "bounded B" and \: "\S. S \ \ \ closed S" and "{} \ \" - and chain: "\S T. S \ \ \ T \ \ \ S \ T \ T \ S" - shows "\\ \ {}" -proof - - have "B \ \\ \ {}" - proof (rule compact_imp_fip) - show "compact B" "\T. T \ \ \ closed T" - by (simp_all add: assms compact_eq_bounded_closed) - show "\finite \; \ \ \\ \ B \ \\ \ {}" for \ - proof (induction \ rule: finite_induct) - case empty - with assms show ?case by force - next - case (insert U \) - then have "U \ \" and ne: "B \ \\ \ {}" by auto - then consider "B \ U" | "U \ B" - using \B \ \\ chain by blast - then show ?case - proof cases - case 1 - then show ?thesis - using Int_left_commute ne by auto - next - case 2 - have "U \ {}" - using \U \ \\ \{} \ \\ by blast - moreover - have False if "\x. x \ U \ \Y\\. x \ Y" - proof - - have "\x. x \ U \ \Y\\. Y \ U" - by (metis chain contra_subsetD insert.prems insert_subset that) - then obtain Y where "Y \ \" "Y \ U" - by (metis all_not_in_conv \U \ {}\) - moreover obtain x where "x \ \\" - by (metis Int_emptyI ne) - ultimately show ?thesis - by (metis Inf_lower subset_eq that) - qed - with 2 show ?thesis - by blast - qed - qed - qed - then show ?thesis by blast -qed - -corollary compact_chain: - fixes \ :: "'a::heine_borel set set" - assumes "\S. S \ \ \ compact S" "{} \ \" - "\S T. S \ \ \ T \ \ \ S \ T \ T \ S" - shows "\ \ \ {}" -proof (cases "\ = {}") - case True - then show ?thesis by auto -next - case False - show ?thesis - by (metis False all_not_in_conv assms compact_imp_bounded compact_imp_closed bounded_closed_chain) -qed - -lemma compact_nest: - fixes F :: "'a::linorder \ 'b::heine_borel set" - assumes F: "\n. compact(F n)" "\n. F n \ {}" and mono: "\m n. m \ n \ F n \ F m" - shows "\range F \ {}" -proof - - have *: "\S T. S \ range F \ T \ range F \ S \ T \ T \ S" - by (metis mono image_iff le_cases) - show ?thesis - apply (rule compact_chain [OF _ _ *]) - using F apply (blast intro: dest: *)+ - done -qed - -text\The Baire property of dense sets\ -theorem Baire: - fixes S::"'a::{real_normed_vector,heine_borel} set" - assumes "closed S" "countable \" - and ope: "\T. T \ \ \ openin (subtopology euclidean S) T \ S \ closure T" - shows "S \ closure(\\)" -proof (cases "\ = {}") - case True - then show ?thesis - using closure_subset by auto -next - let ?g = "from_nat_into \" - case False - then have gin: "?g n \ \" for n - by (simp add: from_nat_into) - show ?thesis - proof (clarsimp simp: closure_approachable) - fix x and e::real - assume "x \ S" "0 < e" - obtain TF where opeF: "\n. openin (subtopology euclidean S) (TF n)" - and ne: "\n. TF n \ {}" - and subg: "\n. S \ closure(TF n) \ ?g n" - and subball: "\n. closure(TF n) \ ball x e" - and decr: "\n. TF(Suc n) \ TF n" - proof - - have *: "\Y. (openin (subtopology euclidean S) Y \ Y \ {} \ - S \ closure Y \ ?g n \ closure Y \ ball x e) \ Y \ U" - if opeU: "openin (subtopology euclidean S) U" and "U \ {}" and cloU: "closure U \ ball x e" for U n - proof - - obtain T where T: "open T" "U = T \ S" - using \openin (subtopology euclidean S) U\ by (auto simp: openin_subtopology) - with \U \ {}\ have "T \ closure (?g n) \ {}" - using gin ope by fastforce - then have "T \ ?g n \ {}" - using \open T\ open_Int_closure_eq_empty by blast - then obtain y where "y \ U" "y \ ?g n" - using T ope [of "?g n", OF gin] by (blast dest: openin_imp_subset) - moreover have "openin (subtopology euclidean S) (U \ ?g n)" - using gin ope opeU by blast - ultimately obtain d where U: "U \ ?g n \ S" and "d > 0" and d: "ball y d \ S \ U \ ?g n" - by (force simp: openin_contains_ball) - show ?thesis - proof (intro exI conjI) - show "openin (subtopology euclidean S) (S \ ball y (d/2))" - by (simp add: openin_open_Int) - show "S \ ball y (d/2) \ {}" - using \0 < d\ \y \ U\ opeU openin_imp_subset by fastforce - have "S \ closure (S \ ball y (d/2)) \ S \ closure (ball y (d/2))" - using closure_mono by blast - also have "... \ ?g n" - using \d > 0\ d by force - finally show "S \ closure (S \ ball y (d/2)) \ ?g n" . - have "closure (S \ ball y (d/2)) \ S \ ball y d" - proof - - have "closure (ball y (d/2)) \ ball y d" - using \d > 0\ by auto - then have "closure (S \ ball y (d/2)) \ ball y d" - by (meson closure_mono inf.cobounded2 subset_trans) - then show ?thesis - by (simp add: \closed S\ closure_minimal) - qed - also have "... \ ball x e" - using cloU closure_subset d by blast - finally show "closure (S \ ball y (d/2)) \ ball x e" . - show "S \ ball y (d/2) \ U" - using ball_divide_subset_numeral d by blast - qed - qed - let ?\ = "\n X. openin (subtopology euclidean S) X \ X \ {} \ - S \ closure X \ ?g n \ closure X \ ball x e" - have "closure (S \ ball x (e / 2)) \ closure(ball x (e/2))" - by (simp add: closure_mono) - also have "... \ ball x e" - using \e > 0\ by auto - finally have "closure (S \ ball x (e / 2)) \ ball x e" . - moreover have"openin (subtopology euclidean S) (S \ ball x (e / 2))" "S \ ball x (e / 2) \ {}" - using \0 < e\ \x \ S\ by auto - ultimately obtain Y where Y: "?\ 0 Y \ Y \ S \ ball x (e / 2)" - using * [of "S \ ball x (e/2)" 0] by metis - show thesis - proof (rule exE [OF dependent_nat_choice [of ?\ "\n X Y. Y \ X"]]) - show "\x. ?\ 0 x" - using Y by auto - show "\Y. ?\ (Suc n) Y \ Y \ X" if "?\ n X" for X n - using that by (blast intro: *) - qed (use that in metis) - qed - have "(\n. S \ closure (TF n)) \ {}" - proof (rule compact_nest) - show "\n. compact (S \ closure (TF n))" - by (metis closed_closure subball bounded_subset_ballI compact_eq_bounded_closed closed_Int_compact [OF \closed S\]) - show "\n. S \ closure (TF n) \ {}" - by (metis Int_absorb1 opeF \closed S\ closure_eq_empty closure_minimal ne openin_imp_subset) - show "\m n. m \ n \ S \ closure (TF n) \ S \ closure (TF m)" - by (meson closure_mono decr dual_order.refl inf_mono lift_Suc_antimono_le) - qed - moreover have "(\n. S \ closure (TF n)) \ {y \ \\. dist y x < e}" - proof (clarsimp, intro conjI) - fix y - assume "y \ S" and y: "\n. y \ closure (TF n)" - then show "\T\\. y \ T" - by (metis Int_iff from_nat_into_surj [OF \countable \\] set_mp subg) - show "dist y x < e" - by (metis y dist_commute mem_ball subball subsetCE) - qed - ultimately show "\y \ \\. dist y x < e" - by auto - qed -qed - -subsection%unimportant \Some theorems on sups and infs using the notion "bounded"\ - -lemma bounded_real: "bounded (S::real set) \ (\a. \x\S. \x\ \ a)" - by (simp add: bounded_iff) - -lemma bounded_imp_bdd_above: "bounded S \ bdd_above (S :: real set)" - by (auto simp: bounded_def bdd_above_def dist_real_def) - (metis abs_le_D1 abs_minus_commute diff_le_eq) - -lemma bounded_imp_bdd_below: "bounded S \ bdd_below (S :: real set)" - by (auto simp: bounded_def bdd_below_def dist_real_def) - (metis abs_le_D1 add.commute diff_le_eq) - -lemma bounded_inner_imp_bdd_above: - assumes "bounded s" - shows "bdd_above ((\x. x \ a) ` s)" -by (simp add: assms bounded_imp_bdd_above bounded_linear_image bounded_linear_inner_left) - -lemma bounded_inner_imp_bdd_below: - assumes "bounded s" - shows "bdd_below ((\x. x \ a) ` s)" -by (simp add: assms bounded_imp_bdd_below bounded_linear_image bounded_linear_inner_left) - -lemma bounded_has_Sup: - fixes S :: "real set" - assumes "bounded S" - and "S \ {}" - shows "\x\S. x \ Sup S" - and "\b. (\x\S. x \ b) \ Sup S \ b" -proof - show "\b. (\x\S. x \ b) \ Sup S \ b" - using assms by (metis cSup_least) -qed (metis cSup_upper assms(1) bounded_imp_bdd_above) - -lemma Sup_insert: - fixes S :: "real set" - shows "bounded S \ Sup (insert x S) = (if S = {} then x else max x (Sup S))" - by (auto simp: bounded_imp_bdd_above sup_max cSup_insert_If) - -lemma Sup_insert_finite: - fixes S :: "'a::conditionally_complete_linorder set" - shows "finite S \ Sup (insert x S) = (if S = {} then x else max x (Sup S))" -by (simp add: cSup_insert sup_max) - -lemma bounded_has_Inf: - fixes S :: "real set" - assumes "bounded S" - and "S \ {}" - shows "\x\S. x \ Inf S" - and "\b. (\x\S. x \ b) \ Inf S \ b" -proof - show "\b. (\x\S. x \ b) \ Inf S \ b" - using assms by (metis cInf_greatest) -qed (metis cInf_lower assms(1) bounded_imp_bdd_below) - -lemma Inf_insert: - fixes S :: "real set" - shows "bounded S \ Inf (insert x S) = (if S = {} then x else min x (Inf S))" - by (auto simp: bounded_imp_bdd_below inf_min cInf_insert_If) - -lemma Inf_insert_finite: - fixes S :: "'a::conditionally_complete_linorder set" - shows "finite S \ Inf (insert x S) = (if S = {} then x else min x (Inf S))" -by (simp add: cInf_eq_Min) - -lemma finite_imp_less_Inf: - fixes a :: "'a::conditionally_complete_linorder" - shows "\finite X; x \ X; \x. x\X \ a < x\ \ a < Inf X" - by (induction X rule: finite_induct) (simp_all add: cInf_eq_Min Inf_insert_finite) - -lemma finite_less_Inf_iff: - fixes a :: "'a :: conditionally_complete_linorder" - shows "\finite X; X \ {}\ \ a < Inf X \ (\x \ X. a < x)" - by (auto simp: cInf_eq_Min) - -lemma finite_imp_Sup_less: - fixes a :: "'a::conditionally_complete_linorder" - shows "\finite X; x \ X; \x. x\X \ a > x\ \ a > Sup X" - by (induction X rule: finite_induct) (simp_all add: cSup_eq_Max Sup_insert_finite) - -lemma finite_Sup_less_iff: - fixes a :: "'a :: conditionally_complete_linorder" - shows "\finite X; X \ {}\ \ a > Sup X \ (\x \ X. a > x)" - by (auto simp: cSup_eq_Max) - -proposition is_interval_compact: - "is_interval S \ compact S \ (\a b. S = cbox a b)" (is "?lhs = ?rhs") -proof (cases "S = {}") - case True - with empty_as_interval show ?thesis by auto -next - case False - show ?thesis - proof - assume L: ?lhs - then have "is_interval S" "compact S" by auto - define a where "a \ \i\Basis. (INF x\S. x \ i) *\<^sub>R i" - define b where "b \ \i\Basis. (SUP x\S. x \ i) *\<^sub>R i" - have 1: "\x i. \x \ S; i \ Basis\ \ (INF x\S. x \ i) \ x \ i" - by (simp add: cInf_lower bounded_inner_imp_bdd_below compact_imp_bounded L) - have 2: "\x i. \x \ S; i \ Basis\ \ x \ i \ (SUP x\S. x \ i)" - by (simp add: cSup_upper bounded_inner_imp_bdd_above compact_imp_bounded L) - have 3: "x \ S" if inf: "\i. i \ Basis \ (INF x\S. x \ i) \ x \ i" - and sup: "\i. i \ Basis \ x \ i \ (SUP x\S. x \ i)" for x - proof (rule mem_box_componentwiseI [OF \is_interval S\]) - fix i::'a - assume i: "i \ Basis" - have cont: "continuous_on S (\x. x \ i)" - by (intro continuous_intros) - obtain a where "a \ S" and a: "\y. y\S \ a \ i \ y \ i" - using continuous_attains_inf [OF \compact S\ False cont] by blast - obtain b where "b \ S" and b: "\y. y\S \ y \ i \ b \ i" - using continuous_attains_sup [OF \compact S\ False cont] by blast - have "a \ i \ (INF x\S. x \ i)" - by (simp add: False a cINF_greatest) - also have "\ \ x \ i" - by (simp add: i inf) - finally have ai: "a \ i \ x \ i" . - have "x \ i \ (SUP x\S. x \ i)" - by (simp add: i sup) - also have "(SUP x\S. x \ i) \ b \ i" - by (simp add: False b cSUP_least) - finally have bi: "x \ i \ b \ i" . - show "x \ i \ (\x. x \ i) ` S" - apply (rule_tac x="\j\Basis. (if j = i then x \ i else a \ j) *\<^sub>R j" in image_eqI) - apply (simp add: i) - apply (rule mem_is_intervalI [OF \is_interval S\ \a \ S\ \b \ S\]) - using i ai bi apply force - done - qed - have "S = cbox a b" - by (auto simp: a_def b_def mem_box intro: 1 2 3) - then show ?rhs - by blast - next - assume R: ?rhs - then show ?lhs - using compact_cbox is_interval_cbox by blast - qed -qed - -text \Hence some handy theorems on distance, diameter etc. of/from a set.\ - -lemma distance_attains_sup: - assumes "compact s" "s \ {}" - shows "\x\s. \y\s. dist a y \ dist a x" -proof (rule continuous_attains_sup [OF assms]) - { - fix x - assume "x\s" - have "(dist a \ dist a x) (at x within s)" - by (intro tendsto_dist tendsto_const tendsto_ident_at) - } - then show "continuous_on s (dist a)" - unfolding continuous_on .. -qed - -text \For \emph{minimal} distance, we only need closure, not compactness.\ - -lemma distance_attains_inf: - fixes a :: "'a::heine_borel" - assumes "closed s" and "s \ {}" - obtains x where "x\s" "\y. y \ s \ dist a x \ dist a y" -proof - - from assms obtain b where "b \ s" by auto - let ?B = "s \ cball a (dist b a)" - have "?B \ {}" using \b \ s\ - by (auto simp: dist_commute) - moreover have "continuous_on ?B (dist a)" - by (auto intro!: continuous_at_imp_continuous_on continuous_dist continuous_ident continuous_const) - moreover have "compact ?B" - by (intro closed_Int_compact \closed s\ compact_cball) - ultimately obtain x where "x \ ?B" "\y\?B. dist a x \ dist a y" - by (metis continuous_attains_inf) - with that show ?thesis by fastforce -qed - - -subsection%unimportant\Relations among convergence and absolute convergence for power series\ - -lemma summable_imp_bounded: - fixes f :: "nat \ 'a::real_normed_vector" - shows "summable f \ bounded (range f)" -by (frule summable_LIMSEQ_zero) (simp add: convergent_imp_bounded) - -lemma summable_imp_sums_bounded: - "summable f \ bounded (range (\n. sum f {.. 'a::{real_normed_div_algebra,banach}" and w :: 'a - assumes sum: "summable (\n. a n * z ^ n)" and no: "norm w < norm z" - shows "summable (\n. of_real(norm(a n)) * w ^ n)" -proof - - obtain M where M: "\x. norm (a x * z ^ x) \ M" - using summable_imp_bounded [OF sum] by (force simp: bounded_iff) - then have *: "summable (\n. norm (a n) * norm w ^ n)" - by (rule_tac M=M in Abel_lemma) (auto simp: norm_mult norm_power intro: no) - show ?thesis - apply (rule series_comparison_complex [of "(\n. of_real(norm(a n) * norm w ^ n))"]) - apply (simp only: summable_complex_of_real *) - apply (auto simp: norm_mult norm_power) - done -qed - -subsection%unimportant \Bounded closed nest property (proof does not use Heine-Borel)\ - -lemma bounded_closed_nest: - fixes S :: "nat \ ('a::heine_borel) set" - assumes "\n. closed (S n)" - and "\n. S n \ {}" - and "\m n. m \ n \ S n \ S m" - and "bounded (S 0)" - obtains a where "\n. a \ S n" -proof - - from assms(2) obtain x where x: "\n. x n \ S n" - using choice[of "\n x. x \ S n"] by auto - from assms(4,1) have "seq_compact (S 0)" - by (simp add: bounded_closed_imp_seq_compact) - then obtain l r where lr: "l \ S 0" "strict_mono r" "(x \ r) \ l" - using x and assms(3) unfolding seq_compact_def by blast - have "\n. l \ S n" - proof - fix n :: nat - have "closed (S n)" - using assms(1) by simp - moreover have "\i. (x \ r) i \ S i" - using x and assms(3) and lr(2) [THEN seq_suble] by auto - then have "\i. (x \ r) (i + n) \ S n" - using assms(3) by (fast intro!: le_add2) - moreover have "(\i. (x \ r) (i + n)) \ l" - using lr(3) by (rule LIMSEQ_ignore_initial_segment) - ultimately show "l \ S n" - by (rule closed_sequentially) - qed - then show ?thesis - using that by blast -qed - -text \Decreasing case does not even need compactness, just completeness.\ - -lemma decreasing_closed_nest: - fixes S :: "nat \ ('a::complete_space) set" - assumes "\n. closed (S n)" - "\n. S n \ {}" - "\m n. m \ n \ S n \ S m" - "\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 - { - fix e :: real - assume "e > 0" - then obtain N where N: "\x\S N. \y\S N. dist x y < e" - using assms(4) by blast - { - fix m n :: nat - assume "N \ m \ N \ n" - then have "t m \ S N" "t n \ S N" - using assms(3) t unfolding subset_eq t by blast+ - then have "dist (t m) (t n) < e" - using N by auto - } - then have "\N. \m n. N \ m \ N \ n \ dist (t m) (t n) < e" - by auto - } - then have "Cauchy t" - unfolding cauchy_def by auto - then obtain l where l:"(t \ l) sequentially" - using complete_UNIV unfolding complete_def by auto - { fix n :: nat - { fix e :: real - assume "e > 0" - then obtain N :: nat where N: "\n\N. dist (t n) l < e" - using l[unfolded lim_sequentially] by auto - have "t (max n N) \ S n" - by (meson assms(3) contra_subsetD max.cobounded1 t) - then have "\y\S n. dist y l < e" - using N max.cobounded2 by blast - } - then have "l \ S n" - using closed_approachable[of "S n" l] assms(1) by auto - } - then show ?thesis - using that by blast -qed - -text \Strengthen it to the intersection actually being a singleton.\ - -lemma decreasing_closed_nest_sing: - fixes S :: "nat \ 'a::complete_space set" - assumes "\n. closed(S n)" - "\n. S n \ {}" - "\m n. m \ n \ S n \ S m" - "\e. e>0 \ \n. \x \ (S n). \ y\(S n). dist x y < e" - shows "\a. \(range S) = {a}" -proof - - obtain a where a: "\n. a \ S n" - using decreasing_closed_nest[of S] using assms by auto - { fix b - assume b: "b \ \(range S)" - { fix e :: real - assume "e > 0" - then have "dist a b < e" - using assms(4) and b and a by blast - } - then have "dist a b = 0" - by (metis dist_eq_0_iff dist_nz less_le) - } - with a have "\(range S) = {a}" - unfolding image_def by auto - then show ?thesis .. -qed - - -subsection \Infimum Distance\ - -definition%important "infdist x A = (if A = {} then 0 else INF a\A. dist x a)" - -lemma bdd_below_image_dist[intro, simp]: "bdd_below (dist x ` A)" - by (auto intro!: zero_le_dist) - -lemma infdist_notempty: "A \ {} \ infdist x A = (INF a\A. dist x a)" - by (simp add: infdist_def) - -lemma infdist_nonneg: "0 \ infdist x A" - by (auto simp: infdist_def intro: cINF_greatest) - -lemma infdist_le: "a \ A \ infdist x A \ dist x a" - by (auto intro: cINF_lower simp add: infdist_def) - -lemma infdist_le2: "a \ A \ dist x a \ d \ infdist x A \ d" - by (auto intro!: cINF_lower2 simp add: infdist_def) - -lemma infdist_zero[simp]: "a \ A \ infdist a A = 0" - by (auto intro!: antisym infdist_nonneg infdist_le2) - -lemma infdist_triangle: "infdist x A \ infdist y A + dist x y" -proof (cases "A = {}") - case True - then show ?thesis by (simp add: infdist_def) -next - case False - then obtain a where "a \ A" by auto - have "infdist x A \ Inf {dist x y + dist y a |a. a \ A}" - proof (rule cInf_greatest) - from \A \ {}\ show "{dist x y + dist y a |a. a \ A} \ {}" - by simp - fix d - assume "d \ {dist x y + dist y a |a. a \ A}" - then obtain a where d: "d = dist x y + dist y a" "a \ A" - by auto - show "infdist x A \ d" - unfolding infdist_notempty[OF \A \ {}\] - proof (rule cINF_lower2) - show "a \ A" by fact - show "dist x a \ d" - unfolding d by (rule dist_triangle) - qed simp - qed - also have "\ = dist x y + infdist y A" - proof (rule cInf_eq, safe) - fix a - assume "a \ A" - then show "dist x y + infdist y A \ dist x y + dist y a" - by (auto intro: infdist_le) - next - fix i - assume inf: "\d. d \ {dist x y + dist y a |a. a \ A} \ i \ d" - then have "i - dist x y \ infdist y A" - unfolding infdist_notempty[OF \A \ {}\] using \a \ A\ - by (intro cINF_greatest) (auto simp: field_simps) - then show "i \ dist x y + infdist y A" - by simp - qed - finally show ?thesis by simp -qed - -lemma in_closure_iff_infdist_zero: - assumes "A \ {}" - shows "x \ closure A \ infdist x A = 0" -proof - assume "x \ closure A" - show "infdist x A = 0" - proof (rule ccontr) - assume "infdist x A \ 0" - 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 - 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 - qed -next - 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 - by (force simp: dist_commute intro: cINF_greatest) - with x \e > 0\ show False by auto - qed -qed - -lemma in_closed_iff_infdist_zero: - assumes "closed A" "A \ {}" - shows "x \ A \ infdist x A = 0" -proof - - have "x \ closure A \ infdist x A = 0" - by (rule in_closure_iff_infdist_zero) fact - 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 - -lemma - infdist_attains_inf: - fixes X::"'a::heine_borel set" - assumes "closed X" - assumes "X \ {}" - obtains x where "x \ X" "infdist y X = dist y x" -proof - - 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)]) - with \x \ X\ show ?thesis .. -qed - - -text \Every metric space is a T4 space:\ - -instance metric_space \ t4_space -proof - fix S T::"'a set" assume H: "closed S" "closed T" "S \ T = {}" - 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 - next - case 2 - show ?thesis - apply (rule exI[of _ UNIV], rule exI[of _ "{}"]) using 2 by auto - next - case 3 - define U where "U = (\x\S. ball x ((infdist x T)/2))" - have A: "open U" unfolding U_def by auto - have "infdist x T > 0" if "x \ S" for x - using H that 3 by (auto intro!: infdist_pos_not_in_closed) - then have B: "S \ U" unfolding U_def by auto - define V where "V = (\x\T. ball x ((infdist x S)/2))" - have C: "open V" unfolding V_def by auto - have "infdist x S > 0" if "x \ T" for x - using H that 3 by (auto intro!: infdist_pos_not_in_closed) - then have D: "T \ V" unfolding V_def by auto - - have "(ball x ((infdist x T)/2)) \ (ball y ((infdist y S)/2)) = {}" if "x \ S" "y \ T" for x y - proof (auto) - fix z assume H: "dist x z * 2 < infdist x T" "dist y z * 2 < infdist y S" - have "2 * dist x y \ 2 * dist x z + 2 * dist y z" - using dist_triangle[of x y z] by (auto simp add: dist_commute) - also have "... < infdist x T + infdist y S" - using H by auto - finally have "dist x y < infdist x T \ dist x y < infdist y S" - by auto - then show False - using infdist_le[OF \x \ S\, of y] infdist_le[OF \y \ T\, of x] by (auto simp add: dist_commute) - qed - 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 - qed -qed - -lemma tendsto_infdist [tendsto_intros]: - assumes f: "(f \ l) F" - shows "((\x. infdist (f x) A) \ infdist l A) F" -proof (rule tendstoI) - fix e ::real - assume "e > 0" - from tendstoD[OF f this] - show "eventually (\x. dist (infdist (f x) A) (infdist l A) < e) F" - proof (eventually_elim) - fix x - from infdist_triangle[of l A "f x"] infdist_triangle[of "f x" A l] - have "dist (infdist (f x) A) (infdist l A) \ dist (f x) l" - by (simp add: dist_commute dist_real_def) - also assume "dist (f x) l < e" - finally show "dist (infdist (f x) A) (infdist l A) < e" . - qed -qed - -lemma continuous_infdist[continuous_intros]: - assumes "continuous F f" - shows "continuous F (\x. infdist (f x) A)" - using assms unfolding continuous_def by (rule tendsto_infdist) - -lemma compact_infdist_le: - fixes A::"'a::heine_borel set" - assumes "A \ {}" - assumes "compact A" - assumes "e > 0" - shows "compact {x. infdist x A \ e}" -proof - - from continuous_closed_vimage[of "{0..e}" "\x. infdist x A"] - continuous_infdist[OF continuous_ident, of _ UNIV A] - have "closed {x. infdist x A \ e}" by (auto simp: vimage_def infdist_nonneg) - moreover - from assms obtain x0 b where b: "\x. x \ A \ dist x0 x \ b" "closed A" - by (auto simp: compact_eq_bounded_closed bounded_def) - { - fix y - assume le: "infdist y A \ e" - from infdist_attains_inf[OF \closed A\ \A \ {}\, of y] - obtain z where z: "z \ A" "infdist y A = dist y z" by blast - have "dist x0 y \ dist y z + dist x0 z" - by (metis dist_commute dist_triangle) - also have "dist y z \ e" using le z by simp - also have "dist x0 z \ b" using b z by simp - finally have "dist x0 y \ b + e" by arith - } then - have "bounded {x. infdist x A \ e}" - by (auto simp: bounded_any_center[where a=x0] intro!: exI[where x="b + e"]) - ultimately show "compact {x. infdist x A \ e}" - by (simp add: compact_eq_bounded_closed) -qed - -subsection%unimportant \Equality of continuous functions on closure and related results\ - -lemma continuous_closedin_preimage_constant: - fixes f :: "_ \ 'b::t1_space" - shows "continuous_on S f \ closedin (subtopology euclidean S) {x \ S. f x = a}" - using continuous_closedin_preimage[of S f "{a}"] by (simp add: vimage_def Collect_conj_eq) - -lemma continuous_closed_preimage_constant: - fixes f :: "_ \ 'b::t1_space" - shows "continuous_on S f \ closed S \ closed {x \ S. f x = a}" - using continuous_closed_preimage[of S f "{a}"] by (simp add: vimage_def Collect_conj_eq) - -lemma continuous_constant_on_closure: - fixes f :: "_ \ 'b::t1_space" - assumes "continuous_on (closure S) f" - and "\x. x \ S \ f x = a" - and "x \ closure S" - shows "f x = a" - using continuous_closed_preimage_constant[of "closure S" f a] - assms closure_minimal[of S "{x \ closure S. f x = a}"] closure_subset - unfolding subset_eq - by auto - -lemma image_closure_subset: - assumes contf: "continuous_on (closure S) f" - and "closed T" - and "(f ` S) \ T" - shows "f ` (closure S) \ T" -proof - - have "S \ {x \ closure S. f x \ T}" - using assms(3) closure_subset by auto - moreover have "closed (closure S \ f -` T)" - using continuous_closed_preimage[OF contf] \closed T\ by auto - ultimately have "closure S = (closure S \ f -` T)" - using closure_minimal[of S "(closure S \ f -` T)"] by auto - then show ?thesis by auto -qed - -lemma continuous_on_closure_norm_le: - fixes f :: "'a::metric_space \ 'b::real_normed_vector" - assumes "continuous_on (closure s) f" - and "\y \ s. norm(f y) \ b" - and "x \ (closure s)" - shows "norm (f x) \ b" -proof - - have *: "f ` s \ cball 0 b" - using assms(2)[unfolded mem_cball_0[symmetric]] by auto - show ?thesis - by (meson "*" assms(1) assms(3) closed_cball image_closure_subset image_subset_iff mem_cball_0) -qed - -lemma isCont_indicator: - fixes x :: "'a::t2_space" - shows "isCont (indicator A :: 'a \ real) x = (x \ frontier A)" -proof auto - fix x - assume cts_at: "isCont (indicator A :: 'a \ real) x" and fr: "x \ frontier A" - with continuous_at_open have 1: "\V::real set. open V \ indicator A x \ V \ - (\U::'a set. open U \ x \ U \ (\y\U. indicator A y \ V))" by auto - show False - proof (cases "x \ A") - assume x: "x \ A" - hence "indicator A x \ ({0<..<2} :: real set)" by simp - hence "\U. open U \ x \ U \ (\y\U. indicator A y \ ({0<..<2} :: real set))" - using 1 open_greaterThanLessThan by blast - then guess U .. note U = this - hence "\y\U. indicator A y > (0::real)" - unfolding greaterThanLessThan_def by auto - hence "U \ A" using indicator_eq_0_iff by force - hence "x \ interior A" using U interiorI by auto - thus ?thesis using fr unfolding frontier_def by simp - next - assume x: "x \ A" - hence "indicator A x \ ({-1<..<1} :: real set)" by simp - hence "\U. open U \ x \ U \ (\y\U. indicator A y \ ({-1<..<1} :: real set))" - using 1 open_greaterThanLessThan by blast - then guess U .. note U = this - hence "\y\U. indicator A y < (1::real)" - unfolding greaterThanLessThan_def by auto - hence "U \ -A" by auto - hence "x \ interior (-A)" using U interiorI by auto - thus ?thesis using fr interior_complement unfolding frontier_def by auto - qed -next - assume nfr: "x \ frontier A" - hence "x \ interior A \ x \ interior (-A)" - by (auto simp: frontier_def closure_interior) - thus "isCont ((indicator A)::'a \ real) x" - proof - assume int: "x \ interior A" - then obtain U where U: "open U" "x \ U" "U \ A" unfolding interior_def by auto - hence "\y\U. indicator A y = (1::real)" unfolding indicator_def by auto - hence "continuous_on U (indicator A)" by (simp add: continuous_on_const indicator_eq_1_iff) - thus ?thesis using U continuous_on_eq_continuous_at by auto - next - assume ext: "x \ interior (-A)" - then obtain U where U: "open U" "x \ U" "U \ -A" unfolding interior_def by auto - then have "continuous_on U (indicator A)" - using continuous_on_topological by (auto simp: subset_iff) - thus ?thesis using U continuous_on_eq_continuous_at by auto - qed -qed - -subsection%unimportant \A function constant on a set\ - -definition constant_on (infixl "(constant'_on)" 50) - where "f constant_on A \ \y. \x\A. f x = y" - -lemma constant_on_subset: "\f constant_on A; B \ A\ \ f constant_on B" - unfolding constant_on_def by blast - -lemma injective_not_constant: - fixes S :: "'a::{perfect_space} set" - shows "\open S; inj_on f S; f constant_on S\ \ S = {}" -unfolding constant_on_def -by (metis equals0I inj_on_contraD islimpt_UNIV islimpt_def) - -lemma constant_on_closureI: - fixes f :: "_ \ 'b::t1_space" - assumes cof: "f constant_on S" and contf: "continuous_on (closure S) f" - shows "f constant_on (closure S)" -using continuous_constant_on_closure [OF contf] cof unfolding constant_on_def -by metis - -subsection%unimportant\Relating linear images to open/closed/interior/closure\ - -proposition open_surjective_linear_image: - fixes f :: "'a::real_normed_vector \ 'b::euclidean_space" - assumes "open A" "linear f" "surj f" - shows "open(f ` A)" -unfolding open_dist -proof clarify - fix x - assume "x \ A" - have "bounded (inv f ` Basis)" - by (simp add: finite_imp_bounded) - with bounded_pos obtain B where "B > 0" and B: "\x. x \ inv f ` Basis \ norm x \ B" - by metis - obtain e where "e > 0" and e: "\z. dist z x < e \ z \ A" - by (metis open_dist \x \ A\ \open A\) - define \ where "\ \ e / B / DIM('b)" - show "\e>0. \y. dist y (f x) < e \ y \ f ` A" - proof (intro exI conjI) - show "\ > 0" - using \e > 0\ \B > 0\ by (simp add: \_def divide_simps) - have "y \ f ` A" if "dist y (f x) * (B * real DIM('b)) < e" for y - proof - - define u where "u \ y - f x" - show ?thesis - proof (rule image_eqI) - show "y = f (x + (\i\Basis. (u \ i) *\<^sub>R inv f i))" - apply (simp add: linear_add linear_sum linear.scaleR \linear f\ surj_f_inv_f \surj f\) - apply (simp add: euclidean_representation u_def) - done - have "dist (x + (\i\Basis. (u \ i) *\<^sub>R inv f i)) x \ (\i\Basis. norm ((u \ i) *\<^sub>R inv f i))" - by (simp add: dist_norm sum_norm_le) - also have "... = (\i\Basis. \u \ i\ * norm (inv f i))" - by simp - also have "... \ (\i\Basis. \u \ i\) * B" - by (simp add: B sum_distrib_right sum_mono mult_left_mono) - also have "... \ DIM('b) * dist y (f x) * B" - apply (rule mult_right_mono [OF sum_bounded_above]) - using \0 < B\ by (auto simp: Basis_le_norm dist_norm u_def) - also have "... < e" - by (metis mult.commute mult.left_commute that) - finally show "x + (\i\Basis. (u \ i) *\<^sub>R inv f i) \ A" - by (rule e) - qed - qed - then show "\y. dist y (f x) < \ \ y \ f ` A" - using \e > 0\ \B > 0\ - by (auto simp: \_def divide_simps mult_less_0_iff) - qed -qed - -corollary open_bijective_linear_image_eq: - fixes f :: "'a::euclidean_space \ 'b::euclidean_space" - assumes "linear f" "bij f" - shows "open(f ` A) \ open A" -proof - assume "open(f ` A)" - then have "open(f -` (f ` A))" - using assms by (force simp: linear_continuous_at linear_conv_bounded_linear continuous_open_vimage) - then show "open A" - by (simp add: assms bij_is_inj inj_vimage_image_eq) -next - assume "open A" - then show "open(f ` A)" - by (simp add: assms bij_is_surj open_surjective_linear_image) -qed - -corollary interior_bijective_linear_image: - fixes f :: "'a::euclidean_space \ 'b::euclidean_space" - assumes "linear f" "bij f" - shows "interior (f ` S) = f ` interior S" (is "?lhs = ?rhs") -proof safe - fix x - assume x: "x \ ?lhs" - then obtain T where "open T" and "x \ T" and "T \ f ` S" - by (metis interiorE) - then show "x \ ?rhs" - by (metis (no_types, hide_lams) assms subsetD interior_maximal open_bijective_linear_image_eq subset_image_iff) -next - fix x - assume x: "x \ interior S" - then show "f x \ interior (f ` S)" - by (meson assms imageI image_mono interiorI interior_subset open_bijective_linear_image_eq open_interior) -qed - -lemma interior_injective_linear_image: - fixes f :: "'a::euclidean_space \ 'a::euclidean_space" - assumes "linear f" "inj f" - shows "interior(f ` S) = f ` (interior S)" - by (simp add: linear_injective_imp_surjective assms bijI interior_bijective_linear_image) - -lemma interior_surjective_linear_image: - fixes f :: "'a::euclidean_space \ 'a::euclidean_space" - assumes "linear f" "surj f" - shows "interior(f ` S) = f ` (interior S)" - by (simp add: assms interior_injective_linear_image linear_surjective_imp_injective) - -lemma interior_negations: - fixes S :: "'a::euclidean_space set" - shows "interior(uminus ` S) = image uminus (interior S)" - by (simp add: bij_uminus interior_bijective_linear_image linear_uminus) - -text \Preservation of compactness and connectedness under continuous function.\ - -lemma compact_eq_openin_cover: - "compact S \ - (\C. (\c\C. openin (subtopology euclidean S) c) \ S \ \C \ - (\D\C. finite D \ S \ \D))" -proof safe - fix C - assume "compact S" and "\c\C. openin (subtopology euclidean S) c" and "S \ \C" - then have "\c\{T. open T \ S \ T \ C}. open c" and "S \ \{T. open T \ S \ T \ C}" - unfolding openin_open by force+ - with \compact S\ obtain D where "D \ {T. open T \ S \ T \ C}" and "finite D" and "S \ \D" - by (meson compactE) - then have "image (\T. S \ T) D \ C \ finite (image (\T. S \ T) D) \ S \ \(image (\T. S \ T) D)" - by auto - then show "\D\C. finite D \ S \ \D" .. -next - assume 1: "\C. (\c\C. openin (subtopology euclidean S) c) \ S \ \C \ - (\D\C. finite D \ S \ \D)" - show "compact S" - proof (rule compactI) - fix C - let ?C = "image (\T. S \ T) C" - assume "\t\C. open t" and "S \ \C" - then have "(\c\?C. openin (subtopology euclidean S) c) \ S \ \?C" - unfolding openin_open by auto - with 1 obtain D where "D \ ?C" and "finite D" and "S \ \D" - by metis - let ?D = "inv_into C (\T. S \ T) ` D" - have "?D \ C \ finite ?D \ S \ \?D" - proof (intro conjI) - from \D \ ?C\ show "?D \ C" - by (fast intro: inv_into_into) - from \finite D\ show "finite ?D" - by (rule finite_imageI) - from \S \ \D\ show "S \ \?D" - apply (rule subset_trans, clarsimp) - apply (frule subsetD [OF \D \ ?C\, THEN f_inv_into_f]) - apply (erule rev_bexI, fast) - done - qed - then show "\D\C. finite D \ S \ \D" .. - qed -qed - -subsection%unimportant\ Theorems relating continuity and uniform continuity to closures\ - -lemma continuous_on_closure: - "continuous_on (closure S) f \ - (\x e. x \ closure S \ 0 < e - \ (\d. 0 < d \ (\y. y \ S \ dist y x < d \ dist (f y) (f x) < e)))" - (is "?lhs = ?rhs") -proof - assume ?lhs then show ?rhs - unfolding continuous_on_iff by (metis Un_iff closure_def) -next - assume R [rule_format]: ?rhs - show ?lhs - proof - fix x and e::real - assume "0 < e" and x: "x \ closure S" - obtain \::real where "\ > 0" - and \: "\y. \y \ S; dist y x < \\ \ dist (f y) (f x) < e/2" - using R [of x "e/2"] \0 < e\ x by auto - have "dist (f y) (f x) \ e" if y: "y \ closure S" and dyx: "dist y x < \/2" for y - proof - - obtain \'::real where "\' > 0" - and \': "\z. \z \ S; dist z y < \'\ \ dist (f z) (f y) < e/2" - using R [of y "e/2"] \0 < e\ y by auto - obtain z where "z \ S" and z: "dist z y < min \' \ / 2" - using closure_approachable y - by (metis \0 < \'\ \0 < \\ divide_pos_pos min_less_iff_conj zero_less_numeral) - have "dist (f z) (f y) < e/2" - apply (rule \' [OF \z \ S\]) - using z \0 < \'\ by linarith - moreover have "dist (f z) (f x) < e/2" - apply (rule \ [OF \z \ S\]) - using z \0 < \\ dist_commute[of y z] dist_triangle_half_r [of y] dyx by auto - ultimately show ?thesis - by (metis dist_commute dist_triangle_half_l less_imp_le) - qed - then show "\d>0. \x'\closure S. dist x' x < d \ dist (f x') (f x) \ e" - by (rule_tac x="\/2" in exI) (simp add: \\ > 0\) - qed -qed - -lemma continuous_on_closure_sequentially: - fixes f :: "'a::metric_space \ 'b :: metric_space" - shows - "continuous_on (closure S) f \ - (\x a. a \ closure S \ (\n. x n \ S) \ x \ a \ (f \ x) \ f a)" - (is "?lhs = ?rhs") -proof - - have "continuous_on (closure S) f \ - (\x \ closure S. continuous (at x within S) f)" - by (force simp: continuous_on_closure continuous_within_eps_delta) - also have "... = ?rhs" - by (force simp: continuous_within_sequentially) - finally show ?thesis . -qed - -lemma uniformly_continuous_on_closure: - fixes f :: "'a::metric_space \ 'b::metric_space" - assumes ucont: "uniformly_continuous_on S f" - and cont: "continuous_on (closure S) f" - shows "uniformly_continuous_on (closure S) f" -unfolding uniformly_continuous_on_def -proof (intro allI impI) - fix e::real - assume "0 < e" - then obtain d::real - where "d>0" - and d: "\x x'. \x\S; x'\S; dist x' x < d\ \ dist (f x') (f x) < e/3" - using ucont [unfolded uniformly_continuous_on_def, rule_format, of "e/3"] by auto - show "\d>0. \x\closure S. \x'\closure S. dist x' x < d \ dist (f x') (f x) < e" - proof (rule exI [where x="d/3"], clarsimp simp: \d > 0\) - fix x y - assume x: "x \ closure S" and y: "y \ closure S" and dyx: "dist y x * 3 < d" - obtain d1::real where "d1 > 0" - and d1: "\w. \w \ closure S; dist w x < d1\ \ dist (f w) (f x) < e/3" - using cont [unfolded continuous_on_iff, rule_format, of "x" "e/3"] \0 < e\ x by auto - obtain x' where "x' \ S" and x': "dist x' x < min d1 (d / 3)" - using closure_approachable [of x S] - by (metis \0 < d1\ \0 < d\ divide_pos_pos min_less_iff_conj x zero_less_numeral) - obtain d2::real where "d2 > 0" - and d2: "\w \ closure S. dist w y < d2 \ dist (f w) (f y) < e/3" - using cont [unfolded continuous_on_iff, rule_format, of "y" "e/3"] \0 < e\ y by auto - obtain y' where "y' \ S" and y': "dist y' y < min d2 (d / 3)" - using closure_approachable [of y S] - by (metis \0 < d2\ \0 < d\ divide_pos_pos min_less_iff_conj y zero_less_numeral) - have "dist x' x < d/3" using x' by auto - moreover have "dist x y < d/3" - by (metis dist_commute dyx less_divide_eq_numeral1(1)) - moreover have "dist y y' < d/3" - by (metis (no_types) dist_commute min_less_iff_conj y') - ultimately have "dist x' y' < d/3 + d/3 + d/3" - by (meson dist_commute_lessI dist_triangle_lt add_strict_mono) - then have "dist x' y' < d" by simp - then have "dist (f x') (f y') < e/3" - by (rule d [OF \y' \ S\ \x' \ S\]) - moreover have "dist (f x') (f x) < e/3" using \x' \ S\ closure_subset x' d1 - by (simp add: closure_def) - moreover have "dist (f y') (f y) < e/3" using \y' \ S\ closure_subset y' d2 - by (simp add: closure_def) - ultimately have "dist (f y) (f x) < e/3 + e/3 + e/3" - by (meson dist_commute_lessI dist_triangle_lt add_strict_mono) - then show "dist (f y) (f x) < e" by simp - qed -qed - -lemma uniformly_continuous_on_extension_at_closure: - fixes f::"'a::metric_space \ 'b::complete_space" - assumes uc: "uniformly_continuous_on X f" - assumes "x \ closure X" - obtains l where "(f \ l) (at x within X)" -proof - - from assms obtain xs where xs: "xs \ x" "\n. xs n \ X" - by (auto simp: closure_sequential) - - from uniformly_continuous_on_Cauchy[OF uc LIMSEQ_imp_Cauchy, OF xs] - obtain l where l: "(\n. f (xs n)) \ l" - by atomize_elim (simp only: convergent_eq_Cauchy) - - have "(f \ l) (at x within X)" - proof (safe intro!: Lim_within_LIMSEQ) - fix xs' - assume "\n. xs' n \ x \ xs' n \ X" - and xs': "xs' \ x" - then have "xs' n \ x" "xs' n \ X" for n by auto - - from uniformly_continuous_on_Cauchy[OF uc LIMSEQ_imp_Cauchy, OF \xs' \ x\ \xs' _ \ X\] - obtain l' where l': "(\n. f (xs' n)) \ l'" - by atomize_elim (simp only: convergent_eq_Cauchy) - - show "(\n. f (xs' n)) \ l" - proof (rule tendstoI) - fix e::real assume "e > 0" - define e' where "e' \ e / 2" - have "e' > 0" using \e > 0\ by (simp add: e'_def) - - have "\\<^sub>F n in sequentially. dist (f (xs n)) l < e'" - by (simp add: \0 < e'\ l tendstoD) - moreover - from uc[unfolded uniformly_continuous_on_def, rule_format, OF \e' > 0\] - obtain d where d: "d > 0" "\x x'. x \ X \ x' \ X \ dist x x' < d \ dist (f x) (f x') < e'" - by auto - have "\\<^sub>F n in sequentially. dist (xs n) (xs' n) < d" - by (auto intro!: \0 < d\ order_tendstoD tendsto_eq_intros xs xs') - ultimately - show "\\<^sub>F n in sequentially. dist (f (xs' n)) l < e" - proof eventually_elim - case (elim n) - have "dist (f (xs' n)) l \ dist (f (xs n)) (f (xs' n)) + dist (f (xs n)) l" - by (metis dist_triangle dist_commute) - also have "dist (f (xs n)) (f (xs' n)) < e'" - by (auto intro!: d xs \xs' _ \ _\ elim) - also note \dist (f (xs n)) l < e'\ - also have "e' + e' = e" by (simp add: e'_def) - finally show ?case by simp - qed - qed - qed - thus ?thesis .. -qed - -lemma uniformly_continuous_on_extension_on_closure: - fixes f::"'a::metric_space \ 'b::complete_space" - assumes uc: "uniformly_continuous_on X f" - obtains g where "uniformly_continuous_on (closure X) g" "\x. x \ X \ f x = g x" - "\Y h x. X \ Y \ Y \ closure X \ continuous_on Y h \ (\x. x \ X \ f x = h x) \ x \ Y \ h x = g x" -proof - - 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 - let ?g = "\x. if x \ X then f x else y x" - - have "uniformly_continuous_on (closure X) ?g" - unfolding uniformly_continuous_on_def - proof safe - fix e::real assume "e > 0" - define e' where "e' \ e / 3" - have "e' > 0" using \e > 0\ by (simp add: e'_def) - from uc[unfolded uniformly_continuous_on_def, rule_format, OF \0 < e'\] - obtain d where "d > 0" and d: "\x x'. x \ X \ x' \ X \ dist x' x < d \ dist (f x') (f x) < e'" - by auto - define d' where "d' = d / 3" - have "d' > 0" using \d > 0\ by (simp add: d'_def) - show "\d>0. \x\closure X. \x'\closure X. dist x' x < d \ dist (?g x') (?g x) < e" - proof (safe intro!: exI[where x=d'] \d' > 0\) - fix x x' assume x: "x \ closure X" and x': "x' \ closure X" and dist: "dist x' x < d'" - then obtain xs xs' where xs: "xs \ x" "\n. xs n \ X" - and xs': "xs' \ x'" "\n. xs' n \ X" - by (auto simp: closure_sequential) - have "\\<^sub>F n in sequentially. dist (xs' n) x' < d'" - and "\\<^sub>F n in sequentially. dist (xs n) x < d'" - by (auto intro!: \0 < d'\ order_tendstoD tendsto_eq_intros xs xs') - moreover - have "(\x. f (xs x)) \ y x" if "x \ closure X" "x \ X" "xs \ x" "\n. xs n \ X" for xs x - using that not_eventuallyD - by (force intro!: filterlim_compose[OF y[OF \x \ closure X\]] simp: filterlim_at) - then have "(\x. f (xs' x)) \ ?g x'" "(\x. f (xs x)) \ ?g x" - using x x' - by (auto intro!: continuous_on_tendsto_compose[OF cont_f] simp: xs' xs) - then have "\\<^sub>F n in sequentially. dist (f (xs' n)) (?g x') < e'" - "\\<^sub>F n in sequentially. dist (f (xs n)) (?g x) < e'" - by (auto intro!: \0 < e'\ order_tendstoD tendsto_eq_intros) - ultimately - have "\\<^sub>F n in sequentially. dist (?g x') (?g x) < e" - proof eventually_elim - case (elim n) - have "dist (?g x') (?g x) \ - dist (f (xs' n)) (?g x') + dist (f (xs' n)) (f (xs n)) + dist (f (xs n)) (?g x)" - by (metis add.commute add_le_cancel_left dist_commute dist_triangle dist_triangle_le) - also - { - have "dist (xs' n) (xs n) \ dist (xs' n) x' + dist x' x + dist (xs n) x" - by (metis add.commute add_le_cancel_left dist_triangle dist_triangle_le) - also note \dist (xs' n) x' < d'\ - also note \dist x' x < d'\ - also note \dist (xs n) x < d'\ - finally have "dist (xs' n) (xs n) < d" by (simp add: d'_def) - } - with \xs _ \ X\ \xs' _ \ X\ have "dist (f (xs' n)) (f (xs n)) < e'" - by (rule d) - also note \dist (f (xs' n)) (?g x') < e'\ - also note \dist (f (xs n)) (?g x) < e'\ - finally show ?case by (simp add: e'_def) - qed - then show "dist (?g x') (?g x) < e" by simp - qed - qed - moreover have "f x = ?g x" if "x \ X" for x using that by simp - moreover - { - fix Y h x - assume Y: "x \ Y" "X \ Y" "Y \ closure X" and cont_h: "continuous_on Y h" - and extension: "(\x. x \ X \ f x = h x)" - { - assume "x \ X" - have "x \ closure X" using Y by auto - then obtain xs where xs: "xs \ x" "\n. xs n \ X" - by (auto simp: closure_sequential) - from continuous_on_tendsto_compose[OF cont_h xs(1)] xs(2) Y - have hx: "(\x. f (xs x)) \ h x" - by (auto simp: set_mp extension) - then have "(\x. f (xs x)) \ y x" - using \x \ X\ not_eventuallyD xs(2) - by (force intro!: filterlim_compose[OF y[OF \x \ closure X\]] simp: filterlim_at xs) - with hx have "h x = y x" by (rule LIMSEQ_unique) - } then - have "h x = ?g x" - using extension by auto - } - ultimately show ?thesis .. -qed - -lemma bounded_uniformly_continuous_image: - fixes f :: "'a :: heine_borel \ 'b :: heine_borel" - assumes "uniformly_continuous_on S f" "bounded S" - shows "bounded(f ` S)" - by (metis (no_types, lifting) assms bounded_closure_image compact_closure compact_continuous_image compact_eq_bounded_closed image_cong uniformly_continuous_imp_continuous uniformly_continuous_on_extension_on_closure) - -subsection%unimportant \Making a continuous function avoid some value in a neighbourhood\ - -lemma continuous_within_avoid: - fixes f :: "'a::metric_space \ 'b::t1_space" - assumes "continuous (at x within s) f" - and "f x \ a" - shows "\e>0. \y \ s. dist x y < e --> f y \ a" -proof - - obtain U where "open U" and "f x \ U" and "a \ U" - using t1_space [OF \f x \ a\] by fast - have "(f \ f x) (at x within s)" - using assms(1) by (simp add: continuous_within) - then have "eventually (\y. f y \ U) (at x within s)" - using \open U\ and \f x \ U\ - unfolding tendsto_def by fast - then have "eventually (\y. f y \ a) (at x within s)" - using \a \ U\ by (fast elim: eventually_mono) - then show ?thesis - using \f x \ a\ by (auto simp: dist_commute eventually_at) -qed - -lemma continuous_at_avoid: - fixes f :: "'a::metric_space \ 'b::t1_space" - assumes "continuous (at x) f" - and "f x \ a" - shows "\e>0. \y. dist x y < e \ f y \ a" - using assms continuous_within_avoid[of x UNIV f a] by simp - -lemma continuous_on_avoid: - fixes f :: "'a::metric_space \ 'b::t1_space" - assumes "continuous_on s f" - and "x \ s" - and "f x \ a" - shows "\e>0. \y \ s. dist x y < e \ f y \ a" - using assms(1)[unfolded continuous_on_eq_continuous_within, THEN bspec[where x=x], - OF assms(2)] continuous_within_avoid[of x s f a] - using assms(3) - by auto - -lemma continuous_on_open_avoid: - fixes f :: "'a::metric_space \ 'b::t1_space" - assumes "continuous_on s f" - and "open s" - and "x \ s" - and "f x \ a" - shows "\e>0. \y. dist x y < e \ f y \ a" - using assms(1)[unfolded continuous_on_eq_continuous_at[OF assms(2)], THEN bspec[where x=x], OF assms(3)] - using continuous_at_avoid[of x f a] assms(4) - by auto - subsection%unimportant\Quotient maps\ lemma quotient_map_imp_continuous_open: diff -r 10644973cdde -r 42cc3609fedf src/HOL/Analysis/Elementary_Metric_Spaces.thy --- a/src/HOL/Analysis/Elementary_Metric_Spaces.thy Sun Jan 06 16:27:52 2019 +0100 +++ b/src/HOL/Analysis/Elementary_Metric_Spaces.thy Sun Jan 06 17:54:49 2019 +0100 @@ -43,6 +43,7 @@ from power2_le_imp_le[OF th yz] show ?thesis . qed + subsection \Combination of Elementary and Abstract Topology\ lemma closedin_limpt: @@ -132,8 +133,51 @@ \ openin (subtopology euclidean u) (s - {a})" by (metis Int_Diff open_delete openin_open) +lemma compact_eq_openin_cover: + "compact S \ + (\C. (\c\C. openin (subtopology euclidean S) c) \ S \ \C \ + (\D\C. finite D \ S \ \D))" +proof safe + fix C + assume "compact S" and "\c\C. openin (subtopology euclidean S) c" and "S \ \C" + then have "\c\{T. open T \ S \ T \ C}. open c" and "S \ \{T. open T \ S \ T \ C}" + unfolding openin_open by force+ + with \compact S\ obtain D where "D \ {T. open T \ S \ T \ C}" and "finite D" and "S \ \D" + by (meson compactE) + then have "image (\T. S \ T) D \ C \ finite (image (\T. S \ T) D) \ S \ \(image (\T. S \ T) D)" + by auto + then show "\D\C. finite D \ S \ \D" .. +next + assume 1: "\C. (\c\C. openin (subtopology euclidean S) c) \ S \ \C \ + (\D\C. finite D \ S \ \D)" + show "compact S" + proof (rule compactI) + fix C + let ?C = "image (\T. S \ T) C" + assume "\t\C. open t" and "S \ \C" + then have "(\c\?C. openin (subtopology euclidean S) c) \ S \ \?C" + unfolding openin_open by auto + with 1 obtain D where "D \ ?C" and "finite D" and "S \ \D" + by metis + let ?D = "inv_into C (\T. S \ T) ` D" + have "?D \ C \ finite ?D \ S \ \?D" + proof (intro conjI) + from \D \ ?C\ show "?D \ C" + by (fast intro: inv_into_into) + from \finite D\ show "finite ?D" + by (rule finite_imageI) + from \S \ \D\ show "S \ \?D" + apply (rule subset_trans, clarsimp) + apply (frule subsetD [OF \D \ ?C\, THEN f_inv_into_f]) + apply (erule rev_bexI, fast) + done + qed + then show "\D\C. finite D \ S \ \D" .. + qed +qed -subsection \Continuity\ + +subsubsection \Continuity\ lemma interior_image_subset: assumes "inj f" "\x. continuous (at x) f" @@ -153,6 +197,66 @@ with \x = f y\ show "x \ f ` interior S" .. qed +subsubsection%unimportant \Equality of continuous functions on closure and related results\ + +lemma continuous_closedin_preimage_constant: + fixes f :: "_ \ 'b::t1_space" + shows "continuous_on S f \ closedin (subtopology euclidean S) {x \ S. f x = a}" + using continuous_closedin_preimage[of S f "{a}"] by (simp add: vimage_def Collect_conj_eq) + +lemma continuous_closed_preimage_constant: + fixes f :: "_ \ 'b::t1_space" + shows "continuous_on S f \ closed S \ closed {x \ S. f x = a}" + using continuous_closed_preimage[of S f "{a}"] by (simp add: vimage_def Collect_conj_eq) + +lemma continuous_constant_on_closure: + fixes f :: "_ \ 'b::t1_space" + assumes "continuous_on (closure S) f" + and "\x. x \ S \ f x = a" + and "x \ closure S" + shows "f x = a" + using continuous_closed_preimage_constant[of "closure S" f a] + assms closure_minimal[of S "{x \ closure S. f x = a}"] closure_subset + unfolding subset_eq + by auto + +lemma image_closure_subset: + assumes contf: "continuous_on (closure S) f" + and "closed T" + and "(f ` S) \ T" + shows "f ` (closure S) \ T" +proof - + have "S \ {x \ closure S. f x \ T}" + using assms(3) closure_subset by auto + moreover have "closed (closure S \ f -` T)" + using continuous_closed_preimage[OF contf] \closed T\ by auto + ultimately have "closure S = (closure S \ f -` T)" + using closure_minimal[of S "(closure S \ f -` T)"] by auto + then show ?thesis by auto +qed + +subsubsection%unimportant \A function constant on a set\ + +definition constant_on (infixl "(constant'_on)" 50) + where "f constant_on A \ \y. \x\A. f x = y" + +lemma constant_on_subset: "\f constant_on A; B \ A\ \ f constant_on B" + unfolding constant_on_def by blast + +lemma injective_not_constant: + fixes S :: "'a::{perfect_space} set" + shows "\open S; inj_on f S; f constant_on S\ \ S = {}" +unfolding constant_on_def +by (metis equals0I inj_on_contraD islimpt_UNIV islimpt_def) + +lemma constant_on_closureI: + fixes f :: "_ \ 'b::t1_space" + assumes cof: "f constant_on S" and contf: "continuous_on (closure S) f" + shows "f constant_on (closure S)" +using continuous_constant_on_closure [OF contf] cof unfolding constant_on_def +by metis + + subsection \Open and closed balls\ definition%important ball :: "'a::metric_space \ real \ 'a set" @@ -182,24 +286,12 @@ lemma sphere_trivial [simp]: "sphere x 0 = {x}" by (simp add: sphere_def) -lemma mem_ball_0 [simp]: "x \ ball 0 e \ norm x < e" - for x :: "'a::real_normed_vector" - by (simp add: dist_norm) - -lemma mem_cball_0 [simp]: "x \ cball 0 e \ norm x \ e" - for x :: "'a::real_normed_vector" - by (simp add: dist_norm) - 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 mem_sphere_0 [simp]: "x \ sphere 0 e \ norm x = e" - for x :: "'a::real_normed_vector" - by (simp add: dist_norm) - lemma sphere_empty [simp]: "r < 0 \ sphere a r = {}" for a :: "'a::metric_space" by auto @@ -259,24 +351,6 @@ lemma cball_diff_eq_sphere: "cball a r - ball a r = sphere a r" by (auto simp: cball_def ball_def dist_commute) -lemma image_add_ball [simp]: - fixes a :: "'a::real_normed_vector" - shows "(+) b ` ball a r = ball (a+b) r" -apply (intro equalityI subsetI) -apply (force simp: dist_norm) -apply (rule_tac x="x-b" in image_eqI) -apply (auto simp: dist_norm algebra_simps) -done - -lemma image_add_cball [simp]: - fixes a :: "'a::real_normed_vector" - shows "(+) b ` cball a r = cball (a+b) r" -apply (intro equalityI subsetI) -apply (force simp: dist_norm) -apply (rule_tac x="x-b" in image_eqI) -apply (auto simp: dist_norm algebra_simps) -done - lemma open_ball [intro, simp]: "open (ball x e)" proof - have "open (dist x -` {.. e < 0" + apply (simp add: set_eq_iff not_le) + apply (metis zero_le_dist dist_self order_less_le_trans) + done + +lemma cball_empty [simp]: "e < 0 \ cball x e = {}" + by simp + +lemma cball_sing: + fixes x :: "'a::metric_space" + shows "e = 0 \ cball x e = {x}" + by (auto simp: set_eq_iff) + +lemma ball_divide_subset: "d \ 1 \ ball x (e/d) \ ball x e" + apply (cases "e \ 0") + apply (simp add: ball_empty divide_simps) + apply (rule subset_ball) + apply (simp add: divide_simps) + done + +lemma ball_divide_subset_numeral: "ball x (e / numeral w) \ ball x e" + 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") + apply (simp add: divide_simps) + apply (rule subset_cball) + apply (metis div_by_1 frac_le not_le order_refl zero_less_one) + done + +lemma cball_divide_subset_numeral: "cball x (e / numeral w) \ cball x e" + using cball_divide_subset one_le_numeral by blast + subsection \Limit Points\ @@ -377,10 +487,6 @@ THEN arg_cong [where f=Not]] by (simp add: Bex_def conj_commute conj_left_commute) -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 limpt_of_limpts: "x islimpt {y. y islimpt S} \ x islimpt S" for x :: "'a::metric_space" apply (clarsimp simp add: islimpt_approachable) @@ -410,6 +516,25 @@ by (metis open_ball centre_in_ball finite_Int inf.absorb_iff2 inf_assoc open_contains_cball_eq) +subsection \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 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 \?\ lemma finite_ball_include: @@ -484,6 +609,10 @@ using open_contains_ball_eq [where S="interior S"] by (simp add: open_subset_interior) +lemma mem_interior_cball: "x \ interior S \ (\e>0. cball x e \ S)" + by (meson ball_subset_cball interior_subset mem_interior open_contains_cball open_interior + subset_trans) + subsection \Frontier\ @@ -835,6 +964,50 @@ by (rule closed_subset_contains_Inf) (auto intro: closed_real_atLeastAtMost intro!: bdd_belowI[of A a]) +lemma bounded_real: "bounded (S::real set) \ (\a. \x\S. \x\ \ a)" + by (simp add: bounded_iff) + +lemma bounded_imp_bdd_above: "bounded S \ bdd_above (S :: real set)" + by (auto simp: bounded_def bdd_above_def dist_real_def) + (metis abs_le_D1 abs_minus_commute diff_le_eq) + +lemma bounded_imp_bdd_below: "bounded S \ bdd_below (S :: real set)" + by (auto simp: bounded_def bdd_below_def dist_real_def) + (metis abs_le_D1 add.commute diff_le_eq) + +lemma bounded_has_Sup: + fixes S :: "real set" + assumes "bounded S" + and "S \ {}" + shows "\x\S. x \ Sup S" + and "\b. (\x\S. x \ b) \ Sup S \ b" +proof + show "\b. (\x\S. x \ b) \ Sup S \ b" + using assms by (metis cSup_least) +qed (metis cSup_upper assms(1) bounded_imp_bdd_above) + +lemma Sup_insert: + fixes S :: "real set" + shows "bounded S \ Sup (insert x S) = (if S = {} then x else max x (Sup S))" + by (auto simp: bounded_imp_bdd_above sup_max cSup_insert_If) + +lemma bounded_has_Inf: + fixes S :: "real set" + assumes "bounded S" + and "S \ {}" + shows "\x\S. x \ Inf S" + and "\b. (\x\S. x \ b) \ Inf S \ b" +proof + show "\b. (\x\S. x \ b) \ Inf S \ b" + using assms by (metis cInf_greatest) +qed (metis cInf_lower assms(1) bounded_imp_bdd_below) + +lemma Inf_insert: + fixes S :: "real set" + shows "bounded S \ Inf (insert x S) = (if S = {} then x else min x (Inf S))" + by (auto simp: bounded_imp_bdd_below inf_min cInf_insert_If) + + subsection \Compactness\ lemma compact_imp_bounded: @@ -1134,6 +1307,7 @@ using l r by fast qed + subsubsection \Completeness\ proposition (in metric_space) completeI: @@ -1392,6 +1566,297 @@ using frontier_subset_closed compact_eq_bounded_closed by blast + +subsubsection \Properties of Balls and Spheres\ + +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 + +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 + +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 + + +subsubsection \Distance from a Set\ + +lemma distance_attains_sup: + assumes "compact s" "s \ {}" + shows "\x\s. \y\s. dist a y \ dist a x" +proof (rule continuous_attains_sup [OF assms]) + { + fix x + assume "x\s" + have "(dist a \ dist a x) (at x within s)" + by (intro tendsto_dist tendsto_const tendsto_ident_at) + } + then show "continuous_on s (dist a)" + unfolding continuous_on .. +qed + +text \For \emph{minimal} distance, we only need closure, not compactness.\ + +lemma distance_attains_inf: + fixes a :: "'a::heine_borel" + assumes "closed s" and "s \ {}" + obtains x where "x\s" "\y. y \ s \ dist a x \ dist a y" +proof - + from assms obtain b where "b \ s" by auto + let ?B = "s \ cball a (dist b a)" + have "?B \ {}" using \b \ s\ + by (auto simp: dist_commute) + moreover have "continuous_on ?B (dist a)" + by (auto intro!: continuous_at_imp_continuous_on continuous_dist continuous_ident continuous_const) + moreover have "compact ?B" + by (intro closed_Int_compact \closed s\ compact_cball) + ultimately obtain x where "x \ ?B" "\y\?B. dist a x \ dist a y" + by (metis continuous_attains_inf) + with that show ?thesis by fastforce +qed + +subsection \Infimum Distance\ + +definition%important "infdist x A = (if A = {} then 0 else INF a\A. dist x a)" + +lemma bdd_below_image_dist[intro, simp]: "bdd_below (dist x ` A)" + by (auto intro!: zero_le_dist) + +lemma infdist_notempty: "A \ {} \ infdist x A = (INF a\A. dist x a)" + by (simp add: infdist_def) + +lemma infdist_nonneg: "0 \ infdist x A" + by (auto simp: infdist_def intro: cINF_greatest) + +lemma infdist_le: "a \ A \ infdist x A \ dist x a" + by (auto intro: cINF_lower simp add: infdist_def) + +lemma infdist_le2: "a \ A \ dist x a \ d \ infdist x A \ d" + by (auto intro!: cINF_lower2 simp add: infdist_def) + +lemma infdist_zero[simp]: "a \ A \ infdist a A = 0" + by (auto intro!: antisym infdist_nonneg infdist_le2) + +lemma infdist_triangle: "infdist x A \ infdist y A + dist x y" +proof (cases "A = {}") + case True + then show ?thesis by (simp add: infdist_def) +next + case False + then obtain a where "a \ A" by auto + have "infdist x A \ Inf {dist x y + dist y a |a. a \ A}" + proof (rule cInf_greatest) + from \A \ {}\ show "{dist x y + dist y a |a. a \ A} \ {}" + by simp + fix d + assume "d \ {dist x y + dist y a |a. a \ A}" + then obtain a where d: "d = dist x y + dist y a" "a \ A" + by auto + show "infdist x A \ d" + unfolding infdist_notempty[OF \A \ {}\] + proof (rule cINF_lower2) + show "a \ A" by fact + show "dist x a \ d" + unfolding d by (rule dist_triangle) + qed simp + qed + also have "\ = dist x y + infdist y A" + proof (rule cInf_eq, safe) + fix a + assume "a \ A" + then show "dist x y + infdist y A \ dist x y + dist y a" + by (auto intro: infdist_le) + next + fix i + assume inf: "\d. d \ {dist x y + dist y a |a. a \ A} \ i \ d" + then have "i - dist x y \ infdist y A" + unfolding infdist_notempty[OF \A \ {}\] using \a \ A\ + by (intro cINF_greatest) (auto simp: field_simps) + then show "i \ dist x y + infdist y A" + by simp + qed + finally show ?thesis by simp +qed + +lemma in_closure_iff_infdist_zero: + assumes "A \ {}" + shows "x \ closure A \ infdist x A = 0" +proof + assume "x \ closure A" + show "infdist x A = 0" + proof (rule ccontr) + assume "infdist x A \ 0" + 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 + 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 + qed +next + 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 + by (force simp: dist_commute intro: cINF_greatest) + with x \e > 0\ show False by auto + qed +qed + +lemma in_closed_iff_infdist_zero: + assumes "closed A" "A \ {}" + shows "x \ A \ infdist x A = 0" +proof - + have "x \ closure A \ infdist x A = 0" + by (rule in_closure_iff_infdist_zero) fact + 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 + +lemma + infdist_attains_inf: + fixes X::"'a::heine_borel set" + assumes "closed X" + assumes "X \ {}" + obtains x where "x \ X" "infdist y X = dist y x" +proof - + 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)]) + with \x \ X\ show ?thesis .. +qed + + +text \Every metric space is a T4 space:\ + +instance metric_space \ t4_space +proof + fix S T::"'a set" assume H: "closed S" "closed T" "S \ T = {}" + 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 + next + case 2 + show ?thesis + apply (rule exI[of _ UNIV], rule exI[of _ "{}"]) using 2 by auto + next + case 3 + define U where "U = (\x\S. ball x ((infdist x T)/2))" + have A: "open U" unfolding U_def by auto + have "infdist x T > 0" if "x \ S" for x + using H that 3 by (auto intro!: infdist_pos_not_in_closed) + then have B: "S \ U" unfolding U_def by auto + define V where "V = (\x\T. ball x ((infdist x S)/2))" + have C: "open V" unfolding V_def by auto + have "infdist x S > 0" if "x \ T" for x + using H that 3 by (auto intro!: infdist_pos_not_in_closed) + then have D: "T \ V" unfolding V_def by auto + + have "(ball x ((infdist x T)/2)) \ (ball y ((infdist y S)/2)) = {}" if "x \ S" "y \ T" for x y + proof (auto) + fix z assume H: "dist x z * 2 < infdist x T" "dist y z * 2 < infdist y S" + have "2 * dist x y \ 2 * dist x z + 2 * dist y z" + using dist_triangle[of x y z] by (auto simp add: dist_commute) + also have "... < infdist x T + infdist y S" + using H by auto + finally have "dist x y < infdist x T \ dist x y < infdist y S" + by auto + then show False + using infdist_le[OF \x \ S\, of y] infdist_le[OF \y \ T\, of x] by (auto simp add: dist_commute) + qed + 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 + qed +qed + +lemma tendsto_infdist [tendsto_intros]: + assumes f: "(f \ l) F" + shows "((\x. infdist (f x) A) \ infdist l A) F" +proof (rule tendstoI) + fix e ::real + assume "e > 0" + from tendstoD[OF f this] + show "eventually (\x. dist (infdist (f x) A) (infdist l A) < e) F" + proof (eventually_elim) + fix x + from infdist_triangle[of l A "f x"] infdist_triangle[of "f x" A l] + have "dist (infdist (f x) A) (infdist l A) \ dist (f x) l" + by (simp add: dist_commute dist_real_def) + also assume "dist (f x) l < e" + finally show "dist (infdist (f x) A) (infdist l A) < e" . + qed +qed + +lemma continuous_infdist[continuous_intros]: + assumes "continuous F f" + shows "continuous F (\x. infdist (f x) A)" + using assms unfolding continuous_def by (rule tendsto_infdist) + +lemma compact_infdist_le: + fixes A::"'a::heine_borel set" + assumes "A \ {}" + assumes "compact A" + assumes "e > 0" + shows "compact {x. infdist x A \ e}" +proof - + from continuous_closed_vimage[of "{0..e}" "\x. infdist x A"] + continuous_infdist[OF continuous_ident, of _ UNIV A] + have "closed {x. infdist x A \ e}" by (auto simp: vimage_def infdist_nonneg) + moreover + from assms obtain x0 b where b: "\x. x \ A \ dist x0 x \ b" "closed A" + by (auto simp: compact_eq_bounded_closed bounded_def) + { + fix y + assume le: "infdist y A \ e" + from infdist_attains_inf[OF \closed A\ \A \ {}\, of y] + obtain z where z: "z \ A" "infdist y A = dist y z" by blast + have "dist x0 y \ dist y z + dist x0 z" + by (metis dist_commute dist_triangle) + also have "dist y z \ e" using le z by simp + also have "dist x0 z \ b" using b z by simp + finally have "dist x0 y \ b + e" by arith + } then + have "bounded {x. infdist x A \ e}" + by (auto simp: bounded_any_center[where a=x0] intro!: exI[where x="b + e"]) + ultimately show "compact {x. infdist x A \ e}" + by (simp add: compact_eq_bounded_closed) +qed + + subsection \Continuity\ text\Derive the epsilon-delta forms, which we often use as "definitions"\ @@ -1633,6 +2098,267 @@ unfolding dist_norm tendsto_norm_zero_iff diff[symmetric] by (auto intro: tendsto_zero) +subsection%unimportant\ Theorems relating continuity and uniform continuity to closures\ + +lemma continuous_on_closure: + "continuous_on (closure S) f \ + (\x e. x \ closure S \ 0 < e + \ (\d. 0 < d \ (\y. y \ S \ dist y x < d \ dist (f y) (f x) < e)))" + (is "?lhs = ?rhs") +proof + assume ?lhs then show ?rhs + unfolding continuous_on_iff by (metis Un_iff closure_def) +next + assume R [rule_format]: ?rhs + show ?lhs + proof + fix x and e::real + assume "0 < e" and x: "x \ closure S" + obtain \::real where "\ > 0" + and \: "\y. \y \ S; dist y x < \\ \ dist (f y) (f x) < e/2" + using R [of x "e/2"] \0 < e\ x by auto + have "dist (f y) (f x) \ e" if y: "y \ closure S" and dyx: "dist y x < \/2" for y + proof - + obtain \'::real where "\' > 0" + and \': "\z. \z \ S; dist z y < \'\ \ dist (f z) (f y) < e/2" + using R [of y "e/2"] \0 < e\ y by auto + obtain z where "z \ S" and z: "dist z y < min \' \ / 2" + using closure_approachable y + by (metis \0 < \'\ \0 < \\ divide_pos_pos min_less_iff_conj zero_less_numeral) + have "dist (f z) (f y) < e/2" + apply (rule \' [OF \z \ S\]) + using z \0 < \'\ by linarith + moreover have "dist (f z) (f x) < e/2" + apply (rule \ [OF \z \ S\]) + using z \0 < \\ dist_commute[of y z] dist_triangle_half_r [of y] dyx by auto + ultimately show ?thesis + by (metis dist_commute dist_triangle_half_l less_imp_le) + qed + then show "\d>0. \x'\closure S. dist x' x < d \ dist (f x') (f x) \ e" + by (rule_tac x="\/2" in exI) (simp add: \\ > 0\) + qed +qed + +lemma continuous_on_closure_sequentially: + fixes f :: "'a::metric_space \ 'b :: metric_space" + shows + "continuous_on (closure S) f \ + (\x a. a \ closure S \ (\n. x n \ S) \ x \ a \ (f \ x) \ f a)" + (is "?lhs = ?rhs") +proof - + have "continuous_on (closure S) f \ + (\x \ closure S. continuous (at x within S) f)" + by (force simp: continuous_on_closure continuous_within_eps_delta) + also have "... = ?rhs" + by (force simp: continuous_within_sequentially) + finally show ?thesis . +qed + +lemma uniformly_continuous_on_closure: + fixes f :: "'a::metric_space \ 'b::metric_space" + assumes ucont: "uniformly_continuous_on S f" + and cont: "continuous_on (closure S) f" + shows "uniformly_continuous_on (closure S) f" +unfolding uniformly_continuous_on_def +proof (intro allI impI) + fix e::real + assume "0 < e" + then obtain d::real + where "d>0" + and d: "\x x'. \x\S; x'\S; dist x' x < d\ \ dist (f x') (f x) < e/3" + using ucont [unfolded uniformly_continuous_on_def, rule_format, of "e/3"] by auto + show "\d>0. \x\closure S. \x'\closure S. dist x' x < d \ dist (f x') (f x) < e" + proof (rule exI [where x="d/3"], clarsimp simp: \d > 0\) + fix x y + assume x: "x \ closure S" and y: "y \ closure S" and dyx: "dist y x * 3 < d" + obtain d1::real where "d1 > 0" + and d1: "\w. \w \ closure S; dist w x < d1\ \ dist (f w) (f x) < e/3" + using cont [unfolded continuous_on_iff, rule_format, of "x" "e/3"] \0 < e\ x by auto + obtain x' where "x' \ S" and x': "dist x' x < min d1 (d / 3)" + using closure_approachable [of x S] + by (metis \0 < d1\ \0 < d\ divide_pos_pos min_less_iff_conj x zero_less_numeral) + obtain d2::real where "d2 > 0" + and d2: "\w \ closure S. dist w y < d2 \ dist (f w) (f y) < e/3" + using cont [unfolded continuous_on_iff, rule_format, of "y" "e/3"] \0 < e\ y by auto + obtain y' where "y' \ S" and y': "dist y' y < min d2 (d / 3)" + using closure_approachable [of y S] + by (metis \0 < d2\ \0 < d\ divide_pos_pos min_less_iff_conj y zero_less_numeral) + have "dist x' x < d/3" using x' by auto + moreover have "dist x y < d/3" + by (metis dist_commute dyx less_divide_eq_numeral1(1)) + moreover have "dist y y' < d/3" + by (metis (no_types) dist_commute min_less_iff_conj y') + ultimately have "dist x' y' < d/3 + d/3 + d/3" + by (meson dist_commute_lessI dist_triangle_lt add_strict_mono) + then have "dist x' y' < d" by simp + then have "dist (f x') (f y') < e/3" + by (rule d [OF \y' \ S\ \x' \ S\]) + moreover have "dist (f x') (f x) < e/3" using \x' \ S\ closure_subset x' d1 + by (simp add: closure_def) + moreover have "dist (f y') (f y) < e/3" using \y' \ S\ closure_subset y' d2 + by (simp add: closure_def) + ultimately have "dist (f y) (f x) < e/3 + e/3 + e/3" + by (meson dist_commute_lessI dist_triangle_lt add_strict_mono) + then show "dist (f y) (f x) < e" by simp + qed +qed + +lemma uniformly_continuous_on_extension_at_closure: + fixes f::"'a::metric_space \ 'b::complete_space" + assumes uc: "uniformly_continuous_on X f" + assumes "x \ closure X" + obtains l where "(f \ l) (at x within X)" +proof - + from assms obtain xs where xs: "xs \ x" "\n. xs n \ X" + by (auto simp: closure_sequential) + + from uniformly_continuous_on_Cauchy[OF uc LIMSEQ_imp_Cauchy, OF xs] + obtain l where l: "(\n. f (xs n)) \ l" + by atomize_elim (simp only: convergent_eq_Cauchy) + + have "(f \ l) (at x within X)" + proof (safe intro!: Lim_within_LIMSEQ) + fix xs' + assume "\n. xs' n \ x \ xs' n \ X" + and xs': "xs' \ x" + then have "xs' n \ x" "xs' n \ X" for n by auto + + from uniformly_continuous_on_Cauchy[OF uc LIMSEQ_imp_Cauchy, OF \xs' \ x\ \xs' _ \ X\] + obtain l' where l': "(\n. f (xs' n)) \ l'" + by atomize_elim (simp only: convergent_eq_Cauchy) + + show "(\n. f (xs' n)) \ l" + proof (rule tendstoI) + fix e::real assume "e > 0" + define e' where "e' \ e / 2" + have "e' > 0" using \e > 0\ by (simp add: e'_def) + + have "\\<^sub>F n in sequentially. dist (f (xs n)) l < e'" + by (simp add: \0 < e'\ l tendstoD) + moreover + from uc[unfolded uniformly_continuous_on_def, rule_format, OF \e' > 0\] + obtain d where d: "d > 0" "\x x'. x \ X \ x' \ X \ dist x x' < d \ dist (f x) (f x') < e'" + by auto + have "\\<^sub>F n in sequentially. dist (xs n) (xs' n) < d" + by (auto intro!: \0 < d\ order_tendstoD tendsto_eq_intros xs xs') + ultimately + show "\\<^sub>F n in sequentially. dist (f (xs' n)) l < e" + proof eventually_elim + case (elim n) + have "dist (f (xs' n)) l \ dist (f (xs n)) (f (xs' n)) + dist (f (xs n)) l" + by (metis dist_triangle dist_commute) + also have "dist (f (xs n)) (f (xs' n)) < e'" + by (auto intro!: d xs \xs' _ \ _\ elim) + also note \dist (f (xs n)) l < e'\ + also have "e' + e' = e" by (simp add: e'_def) + finally show ?case by simp + qed + qed + qed + thus ?thesis .. +qed + +lemma uniformly_continuous_on_extension_on_closure: + fixes f::"'a::metric_space \ 'b::complete_space" + assumes uc: "uniformly_continuous_on X f" + obtains g where "uniformly_continuous_on (closure X) g" "\x. x \ X \ f x = g x" + "\Y h x. X \ Y \ Y \ closure X \ continuous_on Y h \ (\x. x \ X \ f x = h x) \ x \ Y \ h x = g x" +proof - + 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 + let ?g = "\x. if x \ X then f x else y x" + + have "uniformly_continuous_on (closure X) ?g" + unfolding uniformly_continuous_on_def + proof safe + fix e::real assume "e > 0" + define e' where "e' \ e / 3" + have "e' > 0" using \e > 0\ by (simp add: e'_def) + from uc[unfolded uniformly_continuous_on_def, rule_format, OF \0 < e'\] + obtain d where "d > 0" and d: "\x x'. x \ X \ x' \ X \ dist x' x < d \ dist (f x') (f x) < e'" + by auto + define d' where "d' = d / 3" + have "d' > 0" using \d > 0\ by (simp add: d'_def) + show "\d>0. \x\closure X. \x'\closure X. dist x' x < d \ dist (?g x') (?g x) < e" + proof (safe intro!: exI[where x=d'] \d' > 0\) + fix x x' assume x: "x \ closure X" and x': "x' \ closure X" and dist: "dist x' x < d'" + then obtain xs xs' where xs: "xs \ x" "\n. xs n \ X" + and xs': "xs' \ x'" "\n. xs' n \ X" + by (auto simp: closure_sequential) + have "\\<^sub>F n in sequentially. dist (xs' n) x' < d'" + and "\\<^sub>F n in sequentially. dist (xs n) x < d'" + by (auto intro!: \0 < d'\ order_tendstoD tendsto_eq_intros xs xs') + moreover + have "(\x. f (xs x)) \ y x" if "x \ closure X" "x \ X" "xs \ x" "\n. xs n \ X" for xs x + using that not_eventuallyD + by (force intro!: filterlim_compose[OF y[OF \x \ closure X\]] simp: filterlim_at) + then have "(\x. f (xs' x)) \ ?g x'" "(\x. f (xs x)) \ ?g x" + using x x' + by (auto intro!: continuous_on_tendsto_compose[OF cont_f] simp: xs' xs) + then have "\\<^sub>F n in sequentially. dist (f (xs' n)) (?g x') < e'" + "\\<^sub>F n in sequentially. dist (f (xs n)) (?g x) < e'" + by (auto intro!: \0 < e'\ order_tendstoD tendsto_eq_intros) + ultimately + have "\\<^sub>F n in sequentially. dist (?g x') (?g x) < e" + proof eventually_elim + case (elim n) + have "dist (?g x') (?g x) \ + dist (f (xs' n)) (?g x') + dist (f (xs' n)) (f (xs n)) + dist (f (xs n)) (?g x)" + by (metis add.commute add_le_cancel_left dist_commute dist_triangle dist_triangle_le) + also + { + have "dist (xs' n) (xs n) \ dist (xs' n) x' + dist x' x + dist (xs n) x" + by (metis add.commute add_le_cancel_left dist_triangle dist_triangle_le) + also note \dist (xs' n) x' < d'\ + also note \dist x' x < d'\ + also note \dist (xs n) x < d'\ + finally have "dist (xs' n) (xs n) < d" by (simp add: d'_def) + } + with \xs _ \ X\ \xs' _ \ X\ have "dist (f (xs' n)) (f (xs n)) < e'" + by (rule d) + also note \dist (f (xs' n)) (?g x') < e'\ + also note \dist (f (xs n)) (?g x) < e'\ + finally show ?case by (simp add: e'_def) + qed + then show "dist (?g x') (?g x) < e" by simp + qed + qed + moreover have "f x = ?g x" if "x \ X" for x using that by simp + moreover + { + fix Y h x + assume Y: "x \ Y" "X \ Y" "Y \ closure X" and cont_h: "continuous_on Y h" + and extension: "(\x. x \ X \ f x = h x)" + { + assume "x \ X" + have "x \ closure X" using Y by auto + then obtain xs where xs: "xs \ x" "\n. xs n \ X" + by (auto simp: closure_sequential) + from continuous_on_tendsto_compose[OF cont_h xs(1)] xs(2) Y + have hx: "(\x. f (xs x)) \ h x" + by (auto simp: set_mp extension) + then have "(\x. f (xs x)) \ y x" + using \x \ X\ not_eventuallyD xs(2) + by (force intro!: filterlim_compose[OF y[OF \x \ closure X\]] simp: filterlim_at xs) + with hx have "h x = y x" by (rule LIMSEQ_unique) + } then + have "h x = ?g x" + using extension by auto + } + ultimately show ?thesis .. +qed + +lemma bounded_uniformly_continuous_image: + fixes f :: "'a :: heine_borel \ 'b :: heine_borel" + assumes "uniformly_continuous_on S f" "bounded S" + shows "bounded(f ` S)" + by (metis (no_types, lifting) assms bounded_closure_image compact_closure compact_continuous_image compact_eq_bounded_closed image_cong uniformly_continuous_imp_continuous uniformly_continuous_on_extension_on_closure) + subsection \With Abstract Topology (TODO: move and remove dependency?)\ @@ -1837,4 +2563,171 @@ shows "continuous (at a within T) g" using assms by (simp add: Lim_transform_within_openin continuous_within) + +subsection \Closed Nest\ + +text \Bounded closed nest property (proof does not use Heine-Borel)\ + +lemma bounded_closed_nest: + fixes S :: "nat \ ('a::heine_borel) set" + assumes "\n. closed (S n)" + and "\n. S n \ {}" + and "\m n. m \ n \ S n \ S m" + and "bounded (S 0)" + obtains a where "\n. a \ S n" +proof - + from assms(2) obtain x where x: "\n. x n \ S n" + using choice[of "\n x. x \ S n"] by auto + from assms(4,1) have "seq_compact (S 0)" + by (simp add: bounded_closed_imp_seq_compact) + then obtain l r where lr: "l \ S 0" "strict_mono r" "(x \ r) \ l" + using x and assms(3) unfolding seq_compact_def by blast + have "\n. l \ S n" + proof + fix n :: nat + have "closed (S n)" + using assms(1) by simp + moreover have "\i. (x \ r) i \ S i" + using x and assms(3) and lr(2) [THEN seq_suble] by auto + then have "\i. (x \ r) (i + n) \ S n" + using assms(3) by (fast intro!: le_add2) + moreover have "(\i. (x \ r) (i + n)) \ l" + using lr(3) by (rule LIMSEQ_ignore_initial_segment) + ultimately show "l \ S n" + by (rule closed_sequentially) + qed + then show ?thesis + using that by blast +qed + +text \Decreasing case does not even need compactness, just completeness.\ + +lemma decreasing_closed_nest: + fixes S :: "nat \ ('a::complete_space) set" + assumes "\n. closed (S n)" + "\n. S n \ {}" + "\m n. m \ n \ S n \ S m" + "\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 + { + fix e :: real + assume "e > 0" + then obtain N where N: "\x\S N. \y\S N. dist x y < e" + using assms(4) by blast + { + fix m n :: nat + assume "N \ m \ N \ n" + then have "t m \ S N" "t n \ S N" + using assms(3) t unfolding subset_eq t by blast+ + then have "dist (t m) (t n) < e" + using N by auto + } + then have "\N. \m n. N \ m \ N \ n \ dist (t m) (t n) < e" + by auto + } + then have "Cauchy t" + unfolding cauchy_def by auto + then obtain l where l:"(t \ l) sequentially" + using complete_UNIV unfolding complete_def by auto + { fix n :: nat + { fix e :: real + assume "e > 0" + then obtain N :: nat where N: "\n\N. dist (t n) l < e" + using l[unfolded lim_sequentially] by auto + have "t (max n N) \ S n" + by (meson assms(3) contra_subsetD max.cobounded1 t) + then have "\y\S n. dist y l < e" + using N max.cobounded2 by blast + } + then have "l \ S n" + using closed_approachable[of "S n" l] assms(1) by auto + } + then show ?thesis + using that by blast +qed + +text \Strengthen it to the intersection actually being a singleton.\ + +lemma decreasing_closed_nest_sing: + fixes S :: "nat \ 'a::complete_space set" + assumes "\n. closed(S n)" + "\n. S n \ {}" + "\m n. m \ n \ S n \ S m" + "\e. e>0 \ \n. \x \ (S n). \ y\(S n). dist x y < e" + shows "\a. \(range S) = {a}" +proof - + obtain a where a: "\n. a \ S n" + using decreasing_closed_nest[of S] using assms by auto + { fix b + assume b: "b \ \(range S)" + { fix e :: real + assume "e > 0" + then have "dist a b < e" + using assms(4) and b and a by blast + } + then have "dist a b = 0" + by (metis dist_eq_0_iff dist_nz less_le) + } + with a have "\(range S) = {a}" + unfolding image_def by auto + then show ?thesis .. +qed + +subsection%unimportant \Making a continuous function avoid some value in a neighbourhood\ + +lemma continuous_within_avoid: + fixes f :: "'a::metric_space \ 'b::t1_space" + assumes "continuous (at x within s) f" + and "f x \ a" + shows "\e>0. \y \ s. dist x y < e --> f y \ a" +proof - + obtain U where "open U" and "f x \ U" and "a \ U" + using t1_space [OF \f x \ a\] by fast + have "(f \ f x) (at x within s)" + using assms(1) by (simp add: continuous_within) + then have "eventually (\y. f y \ U) (at x within s)" + using \open U\ and \f x \ U\ + unfolding tendsto_def by fast + then have "eventually (\y. f y \ a) (at x within s)" + using \a \ U\ by (fast elim: eventually_mono) + then show ?thesis + using \f x \ a\ by (auto simp: dist_commute eventually_at) +qed + +lemma continuous_at_avoid: + fixes f :: "'a::metric_space \ 'b::t1_space" + assumes "continuous (at x) f" + and "f x \ a" + shows "\e>0. \y. dist x y < e \ f y \ a" + using assms continuous_within_avoid[of x UNIV f a] by simp + +lemma continuous_on_avoid: + fixes f :: "'a::metric_space \ 'b::t1_space" + assumes "continuous_on s f" + and "x \ s" + and "f x \ a" + shows "\e>0. \y \ s. dist x y < e \ f y \ a" + using assms(1)[unfolded continuous_on_eq_continuous_within, THEN bspec[where x=x], + OF assms(2)] continuous_within_avoid[of x s f a] + using assms(3) + by auto + +lemma continuous_on_open_avoid: + fixes f :: "'a::metric_space \ 'b::t1_space" + assumes "continuous_on s f" + and "open s" + and "x \ s" + and "f x \ a" + shows "\e>0. \y. dist x y < e \ f y \ a" + using assms(1)[unfolded continuous_on_eq_continuous_at[OF assms(2)], THEN bspec[where x=x], OF assms(3)] + using continuous_at_avoid[of x f a] assms(4) + by auto + + end \ No newline at end of file diff -r 10644973cdde -r 42cc3609fedf src/HOL/Analysis/Elementary_Normed_Spaces.thy --- a/src/HOL/Analysis/Elementary_Normed_Spaces.thy Sun Jan 06 16:27:52 2019 +0100 +++ b/src/HOL/Analysis/Elementary_Normed_Spaces.thy Sun Jan 06 17:54:49 2019 +0100 @@ -136,6 +136,296 @@ qed qed +subsection \Limit Points\ + +lemma islimpt_ball: + fixes x y :: "'a::{real_normed_vector,perfect_space}" + shows "y islimpt ball x e \ 0 < e \ y \ cball x e" + (is "?lhs \ ?rhs") +proof + show ?rhs if ?lhs + proof + { + assume "e \ 0" + then have *: "ball x e = {}" + using ball_eq_empty[of x e] by auto + have False using \?lhs\ + unfolding * using islimpt_EMPTY[of y] by auto + } + then show "e > 0" by (metis not_less) + show "y \ cball x e" + using closed_cball[of x e] islimpt_subset[of y "ball x e" "cball x e"] + ball_subset_cball[of x e] \?lhs\ + unfolding closed_limpt by auto + qed + show ?lhs if ?rhs + proof - + from that have "e > 0" by auto + { + fix d :: real + assume "d > 0" + have "\x'\ball x e. x' \ y \ dist x' y < d" + proof (cases "d \ dist x y") + case True + then show "\x'\ball x e. x' \ y \ dist x' y < d" + proof (cases "x = y") + case True + then have False + using \d \ dist x y\ \d>0\ by auto + then show "\x'\ball x e. x' \ y \ dist x' y < d" + by auto + next + case False + have "dist x (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) = + norm (x - y + (d / (2 * norm (y - x))) *\<^sub>R (y - x))" + unfolding mem_cball mem_ball dist_norm diff_diff_eq2 diff_add_eq[symmetric] + by auto + also have "\ = \- 1 + d / (2 * norm (x - y))\ * norm (x - y)" + using scaleR_left_distrib[of "- 1" "d / (2 * norm (y - x))", symmetric, of "y - x"] + unfolding scaleR_minus_left scaleR_one + by (auto simp: norm_minus_commute) + also have "\ = \- norm (x - y) + d / 2\" + unfolding abs_mult_pos[of "norm (x - y)", OF norm_ge_zero[of "x - y"]] + unfolding distrib_right using \x\y\ by auto + also have "\ \ e - d/2" using \d \ dist x y\ and \d>0\ and \?rhs\ + by (auto simp: dist_norm) + finally have "y - (d / (2 * dist y x)) *\<^sub>R (y - x) \ ball x e" using \d>0\ + by auto + moreover + have "(d / (2*dist y x)) *\<^sub>R (y - x) \ 0" + using \x\y\[unfolded dist_nz] \d>0\ unfolding scaleR_eq_0_iff + by (auto simp: dist_commute) + moreover + have "dist (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) y < d" + unfolding dist_norm + apply simp + unfolding norm_minus_cancel + using \d > 0\ \x\y\[unfolded dist_nz] dist_commute[of x y] + unfolding dist_norm + apply auto + done + ultimately show "\x'\ball x e. x' \ y \ dist x' y < d" + apply (rule_tac x = "y - (d / (2*dist y x)) *\<^sub>R (y - x)" in bexI) + apply auto + done + qed + next + case False + then have "d > dist x y" by auto + show "\x' \ ball x e. x' \ y \ dist x' y < d" + proof (cases "x = y") + case True + obtain z where **: "z \ y" "dist z y < min e d" + using perfect_choose_dist[of "min e d" y] + using \d > 0\ \e>0\ by auto + show "\x'\ball x e. x' \ y \ dist x' y < d" + unfolding \x = y\ + using \z \ y\ ** + apply (rule_tac x=z in bexI) + apply (auto simp: dist_commute) + done + next + case False + then show "\x'\ball x e. x' \ y \ dist x' y < d" + using \d>0\ \d > dist x y\ \?rhs\ + apply (rule_tac x=x in bexI, auto) + done + qed + qed + } + then show ?thesis + unfolding mem_cball islimpt_approachable mem_ball by auto + qed +qed + +lemma closure_ball_lemma: + fixes x y :: "'a::real_normed_vector" + assumes "x \ y" + shows "y islimpt ball x (dist x y)" +proof (rule islimptI) + fix T + assume "y \ T" "open T" + then obtain r where "0 < r" "\z. dist z y < r \ z \ T" + unfolding open_dist by fast + (* choose point between x and y, within distance r of y. *) + define k where "k = min 1 (r / (2 * dist x y))" + define z where "z = y + scaleR k (x - y)" + have z_def2: "z = x + scaleR (1 - k) (y - x)" + unfolding z_def by (simp add: algebra_simps) + have "dist z y < r" + unfolding z_def k_def using \0 < r\ + by (simp add: dist_norm min_def) + then have "z \ T" + using \\z. dist z y < r \ z \ T\ by simp + have "dist x z < dist x y" + unfolding z_def2 dist_norm + apply (simp add: norm_minus_commute) + apply (simp only: dist_norm [symmetric]) + apply (subgoal_tac "\1 - k\ * dist x y < 1 * dist x y", simp) + apply (rule mult_strict_right_mono) + apply (simp add: k_def \0 < r\ \x \ y\) + apply (simp add: \x \ y\) + done + then have "z \ ball x (dist x y)" + by simp + have "z \ y" + unfolding z_def k_def using \x \ y\ \0 < r\ + by (simp add: min_def) + show "\z\ball x (dist x y). z \ T \ z \ y" + using \z \ ball x (dist x y)\ \z \ T\ \z \ y\ + by fast +qed + + +subsection \Balls and Spheres in Normed Spaces\ + +lemma mem_ball_0 [simp]: "x \ ball 0 e \ norm x < e" + for x :: "'a::real_normed_vector" + by (simp add: dist_norm) + +lemma mem_cball_0 [simp]: "x \ cball 0 e \ norm x \ e" + for x :: "'a::real_normed_vector" + by (simp add: dist_norm) + +lemma closure_ball [simp]: + fixes x :: "'a::real_normed_vector" + shows "0 < e \ closure (ball x e) = cball x e" + apply (rule equalityI) + apply (rule closure_minimal) + apply (rule ball_subset_cball) + apply (rule closed_cball) + apply (rule subsetI, rename_tac y) + apply (simp add: le_less [where 'a=real]) + apply (erule disjE) + apply (rule subsetD [OF closure_subset], simp) + apply (simp add: closure_def, clarify) + apply (rule closure_ball_lemma) + apply simp + done + +lemma mem_sphere_0 [simp]: "x \ sphere 0 e \ norm x = e" + for x :: "'a::real_normed_vector" + by (simp add: dist_norm) + +(* In a trivial vector space, this fails for e = 0. *) +lemma interior_cball [simp]: + fixes x :: "'a::{real_normed_vector, perfect_space}" + shows "interior (cball x e) = ball x e" +proof (cases "e \ 0") + case False note cs = this + from cs have null: "ball x e = {}" + using ball_empty[of e x] by auto + moreover + have "cball x e = {}" + proof (rule equals0I) + fix y + assume "y \ cball x e" + then show False + by (metis ball_eq_empty null cs dist_eq_0_iff dist_le_zero_iff empty_subsetI mem_cball + subset_antisym subset_ball) + qed + then have "interior (cball x e) = {}" + using interior_empty by auto + ultimately show ?thesis by blast +next + case True note cs = this + have "ball x e \ cball x e" + using ball_subset_cball by auto + moreover + { + fix S y + assume as: "S \ cball x e" "open S" "y\S" + then obtain d where "d>0" and d: "\x'. dist x' y < d \ x' \ S" + unfolding open_dist by blast + then obtain xa where xa_y: "xa \ y" and xa: "dist xa y < d" + using perfect_choose_dist [of d] by auto + have "xa \ S" + using d[THEN spec[where x = xa]] + using xa by (auto simp: dist_commute) + then have xa_cball: "xa \ cball x e" + using as(1) by auto + then have "y \ ball x e" + proof (cases "x = y") + case True + then have "e > 0" using cs order.order_iff_strict xa_cball xa_y by fastforce + then show "y \ ball x e" + using \x = y \ by simp + next + case False + have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) y < d" + unfolding dist_norm + using \d>0\ norm_ge_zero[of "y - x"] \x \ y\ by auto + then have *: "y + (d / 2 / dist y x) *\<^sub>R (y - x) \ cball x e" + using d as(1)[unfolded subset_eq] by blast + have "y - x \ 0" using \x \ y\ by auto + hence **:"d / (2 * norm (y - x)) > 0" + unfolding zero_less_norm_iff[symmetric] using \d>0\ by auto + have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) x = + norm (y + (d / (2 * norm (y - x))) *\<^sub>R y - (d / (2 * norm (y - x))) *\<^sub>R x - x)" + by (auto simp: dist_norm algebra_simps) + also have "\ = norm ((1 + d / (2 * norm (y - x))) *\<^sub>R (y - x))" + by (auto simp: algebra_simps) + also have "\ = \1 + d / (2 * norm (y - x))\ * norm (y - x)" + using ** by auto + also have "\ = (dist y x) + d/2" + using ** by (auto simp: distrib_right dist_norm) + finally have "e \ dist x y +d/2" + using *[unfolded mem_cball] by (auto simp: dist_commute) + then show "y \ ball x e" + unfolding mem_ball using \d>0\ by auto + qed + } + then have "\S \ cball x e. open S \ S \ ball x e" + by auto + ultimately show ?thesis + using interior_unique[of "ball x e" "cball x e"] + using open_ball[of x e] + by auto +qed + +lemma frontier_ball [simp]: + fixes a :: "'a::real_normed_vector" + shows "0 < e \ frontier (ball a e) = sphere a e" + by (force simp: frontier_def) + +lemma frontier_cball [simp]: + fixes a :: "'a::{real_normed_vector, perfect_space}" + shows "frontier (cball a e) = sphere a e" + by (force simp: frontier_def) + +corollary compact_sphere [simp]: + fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}" + shows "compact (sphere a r)" +using compact_frontier [of "cball a r"] by simp + +corollary bounded_sphere [simp]: + fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}" + shows "bounded (sphere a r)" +by (simp add: compact_imp_bounded) + +corollary closed_sphere [simp]: + fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}" + shows "closed (sphere a r)" +by (simp add: compact_imp_closed) + +lemma image_add_ball [simp]: + fixes a :: "'a::real_normed_vector" + shows "(+) b ` ball a r = ball (a+b) r" +apply (intro equalityI subsetI) +apply (force simp: dist_norm) +apply (rule_tac x="x-b" in image_eqI) +apply (auto simp: dist_norm algebra_simps) +done + +lemma image_add_cball [simp]: + fixes a :: "'a::real_normed_vector" + shows "(+) b ` cball a r = cball (a+b) r" +apply (intro equalityI subsetI) +apply (force simp: dist_norm) +apply (rule_tac x="x-b" in image_eqI) +apply (auto simp: dist_norm algebra_simps) +done + subsection%unimportant \Various Lemmas on Normed Algebras\ @@ -181,6 +471,14 @@ apply (drule_tac x=UNIV in spec, simp) done +lemma at_within_ball_bot_iff: + fixes x y :: "'a::{real_normed_vector,perfect_space}" + shows "at x within ball y r = bot \ (r=0 \ x \ cball y r)" + unfolding trivial_limit_within + apply (auto simp add:trivial_limit_within islimpt_ball ) + by (metis le_less_trans less_eq_real_def zero_le_dist) + + subsection \Limits\ proposition Lim_at_infinity: "(f \ l) at_infinity \ (\e>0. \b. \x. norm x \ b \ dist (f x) l < e)" @@ -326,6 +624,19 @@ subsection \Boundedness\ +lemma continuous_on_closure_norm_le: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + assumes "continuous_on (closure s) f" + and "\y \ s. norm(f y) \ b" + and "x \ (closure s)" + shows "norm (f x) \ b" +proof - + have *: "f ` s \ cball 0 b" + using assms(2)[unfolded mem_cball_0[symmetric]] by auto + show ?thesis + by (meson "*" assms(1) assms(3) closed_cball image_closure_subset image_subset_iff mem_cball_0) +qed + lemma bounded_pos: "bounded S \ (\b>0. \x\ S. norm x \ b)" apply (simp add: bounded_iff) apply (subgoal_tac "\x (y::real). 0 < 1 + \y\ \ (x \ y \ x \ 1 + \y\)") @@ -463,6 +774,33 @@ shows "bounded (- S) \ \ bounded S" using bounded_Un [of S "-S"] by (simp add: sup_compl_top) +subsection%unimportant\Relations among convergence and absolute convergence for power series\ + +lemma summable_imp_bounded: + fixes f :: "nat \ 'a::real_normed_vector" + shows "summable f \ bounded (range f)" +by (frule summable_LIMSEQ_zero) (simp add: convergent_imp_bounded) + +lemma summable_imp_sums_bounded: + "summable f \ bounded (range (\n. sum f {.. 'a::{real_normed_div_algebra,banach}" and w :: 'a + assumes sum: "summable (\n. a n * z ^ n)" and no: "norm w < norm z" + shows "summable (\n. of_real(norm(a n)) * w ^ n)" +proof - + obtain M where M: "\x. norm (a x * z ^ x) \ M" + using summable_imp_bounded [OF sum] by (force simp: bounded_iff) + then have *: "summable (\n. norm (a n) * norm w ^ n)" + by (rule_tac M=M in Abel_lemma) (auto simp: norm_mult norm_power intro: no) + show ?thesis + apply (rule series_comparison_complex [of "(\n. of_real(norm(a n) * norm w ^ n))"]) + apply (simp only: summable_complex_of_real *) + apply (auto simp: norm_mult norm_power) + done +qed + subsection \Normed spaces with the Heine-Borel property\ @@ -492,6 +830,193 @@ by (metis of_nat_le_iff Int_subset_iff \K \ S\ real_arch_simple subset_cball subset_trans) qed auto +subsection \Intersecting chains of compact sets and the Baire property\ + +proposition bounded_closed_chain: + fixes \ :: "'a::heine_borel set set" + assumes "B \ \" "bounded B" and \: "\S. S \ \ \ closed S" and "{} \ \" + and chain: "\S T. S \ \ \ T \ \ \ S \ T \ T \ S" + shows "\\ \ {}" +proof - + have "B \ \\ \ {}" + proof (rule compact_imp_fip) + show "compact B" "\T. T \ \ \ closed T" + by (simp_all add: assms compact_eq_bounded_closed) + show "\finite \; \ \ \\ \ B \ \\ \ {}" for \ + proof (induction \ rule: finite_induct) + case empty + with assms show ?case by force + next + case (insert U \) + then have "U \ \" and ne: "B \ \\ \ {}" by auto + then consider "B \ U" | "U \ B" + using \B \ \\ chain by blast + then show ?case + proof cases + case 1 + then show ?thesis + using Int_left_commute ne by auto + next + case 2 + have "U \ {}" + using \U \ \\ \{} \ \\ by blast + moreover + have False if "\x. x \ U \ \Y\\. x \ Y" + proof - + have "\x. x \ U \ \Y\\. Y \ U" + by (metis chain contra_subsetD insert.prems insert_subset that) + then obtain Y where "Y \ \" "Y \ U" + by (metis all_not_in_conv \U \ {}\) + moreover obtain x where "x \ \\" + by (metis Int_emptyI ne) + ultimately show ?thesis + by (metis Inf_lower subset_eq that) + qed + with 2 show ?thesis + by blast + qed + qed + qed + then show ?thesis by blast +qed + +corollary compact_chain: + fixes \ :: "'a::heine_borel set set" + assumes "\S. S \ \ \ compact S" "{} \ \" + "\S T. S \ \ \ T \ \ \ S \ T \ T \ S" + shows "\ \ \ {}" +proof (cases "\ = {}") + case True + then show ?thesis by auto +next + case False + show ?thesis + by (metis False all_not_in_conv assms compact_imp_bounded compact_imp_closed bounded_closed_chain) +qed + +lemma compact_nest: + fixes F :: "'a::linorder \ 'b::heine_borel set" + assumes F: "\n. compact(F n)" "\n. F n \ {}" and mono: "\m n. m \ n \ F n \ F m" + shows "\range F \ {}" +proof - + have *: "\S T. S \ range F \ T \ range F \ S \ T \ T \ S" + by (metis mono image_iff le_cases) + show ?thesis + apply (rule compact_chain [OF _ _ *]) + using F apply (blast intro: dest: *)+ + done +qed + +text\The Baire property of dense sets\ +theorem Baire: + fixes S::"'a::{real_normed_vector,heine_borel} set" + assumes "closed S" "countable \" + and ope: "\T. T \ \ \ openin (subtopology euclidean S) T \ S \ closure T" + shows "S \ closure(\\)" +proof (cases "\ = {}") + case True + then show ?thesis + using closure_subset by auto +next + let ?g = "from_nat_into \" + case False + then have gin: "?g n \ \" for n + by (simp add: from_nat_into) + show ?thesis + proof (clarsimp simp: closure_approachable) + fix x and e::real + assume "x \ S" "0 < e" + obtain TF where opeF: "\n. openin (subtopology euclidean S) (TF n)" + and ne: "\n. TF n \ {}" + and subg: "\n. S \ closure(TF n) \ ?g n" + and subball: "\n. closure(TF n) \ ball x e" + and decr: "\n. TF(Suc n) \ TF n" + proof - + have *: "\Y. (openin (subtopology euclidean S) Y \ Y \ {} \ + S \ closure Y \ ?g n \ closure Y \ ball x e) \ Y \ U" + if opeU: "openin (subtopology euclidean S) U" and "U \ {}" and cloU: "closure U \ ball x e" for U n + proof - + obtain T where T: "open T" "U = T \ S" + using \openin (subtopology euclidean S) U\ by (auto simp: openin_subtopology) + with \U \ {}\ have "T \ closure (?g n) \ {}" + using gin ope by fastforce + then have "T \ ?g n \ {}" + using \open T\ open_Int_closure_eq_empty by blast + then obtain y where "y \ U" "y \ ?g n" + using T ope [of "?g n", OF gin] by (blast dest: openin_imp_subset) + moreover have "openin (subtopology euclidean S) (U \ ?g n)" + using gin ope opeU by blast + ultimately obtain d where U: "U \ ?g n \ S" and "d > 0" and d: "ball y d \ S \ U \ ?g n" + by (force simp: openin_contains_ball) + show ?thesis + proof (intro exI conjI) + show "openin (subtopology euclidean S) (S \ ball y (d/2))" + by (simp add: openin_open_Int) + show "S \ ball y (d/2) \ {}" + using \0 < d\ \y \ U\ opeU openin_imp_subset by fastforce + have "S \ closure (S \ ball y (d/2)) \ S \ closure (ball y (d/2))" + using closure_mono by blast + also have "... \ ?g n" + using \d > 0\ d by force + finally show "S \ closure (S \ ball y (d/2)) \ ?g n" . + have "closure (S \ ball y (d/2)) \ S \ ball y d" + proof - + have "closure (ball y (d/2)) \ ball y d" + using \d > 0\ by auto + then have "closure (S \ ball y (d/2)) \ ball y d" + by (meson closure_mono inf.cobounded2 subset_trans) + then show ?thesis + by (simp add: \closed S\ closure_minimal) + qed + also have "... \ ball x e" + using cloU closure_subset d by blast + finally show "closure (S \ ball y (d/2)) \ ball x e" . + show "S \ ball y (d/2) \ U" + using ball_divide_subset_numeral d by blast + qed + qed + let ?\ = "\n X. openin (subtopology euclidean S) X \ X \ {} \ + S \ closure X \ ?g n \ closure X \ ball x e" + have "closure (S \ ball x (e / 2)) \ closure(ball x (e/2))" + by (simp add: closure_mono) + also have "... \ ball x e" + using \e > 0\ by auto + finally have "closure (S \ ball x (e / 2)) \ ball x e" . + moreover have"openin (subtopology euclidean S) (S \ ball x (e / 2))" "S \ ball x (e / 2) \ {}" + using \0 < e\ \x \ S\ by auto + ultimately obtain Y where Y: "?\ 0 Y \ Y \ S \ ball x (e / 2)" + using * [of "S \ ball x (e/2)" 0] by metis + show thesis + proof (rule exE [OF dependent_nat_choice [of ?\ "\n X Y. Y \ X"]]) + show "\x. ?\ 0 x" + using Y by auto + show "\Y. ?\ (Suc n) Y \ Y \ X" if "?\ n X" for X n + using that by (blast intro: *) + qed (use that in metis) + qed + have "(\n. S \ closure (TF n)) \ {}" + proof (rule compact_nest) + show "\n. compact (S \ closure (TF n))" + by (metis closed_closure subball bounded_subset_ballI compact_eq_bounded_closed closed_Int_compact [OF \closed S\]) + show "\n. S \ closure (TF n) \ {}" + by (metis Int_absorb1 opeF \closed S\ closure_eq_empty closure_minimal ne openin_imp_subset) + show "\m n. m \ n \ S \ closure (TF n) \ S \ closure (TF m)" + by (meson closure_mono decr dual_order.refl inf_mono lift_Suc_antimono_le) + qed + moreover have "(\n. S \ closure (TF n)) \ {y \ \\. dist y x < e}" + proof (clarsimp, intro conjI) + fix y + assume "y \ S" and y: "\n. y \ closure (TF n)" + then show "\T\\. y \ T" + by (metis Int_iff from_nat_into_surj [OF \countable \\] set_mp subg) + show "dist y x < e" + by (metis y dist_commute mem_ball subball subsetCE) + qed + ultimately show "\y \ \\. dist y x < e" + by auto + qed +qed + subsection \Continuity\ diff -r 10644973cdde -r 42cc3609fedf src/HOL/Analysis/Elementary_Topology.thy --- a/src/HOL/Analysis/Elementary_Topology.thy Sun Jan 06 16:27:52 2019 +0100 +++ b/src/HOL/Analysis/Elementary_Topology.thy Sun Jan 06 17:54:49 2019 +0100 @@ -2096,4 +2096,5 @@ using T_def by (auto elim!: eventually_mono) qed + end \ No newline at end of file diff -r 10644973cdde -r 42cc3609fedf src/HOL/Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Analysis/Topology_Euclidean_Space.thy Sun Jan 06 16:27:52 2019 +0100 +++ b/src/HOL/Analysis/Topology_Euclidean_Space.thy Sun Jan 06 17:54:49 2019 +0100 @@ -715,58 +715,21 @@ using is_interval_translation[of "-c" X] by (metis image_cong uminus_add_conv_diff) -lemma compact_lemma: - fixes f :: "nat \ 'a::euclidean_space" - assumes "bounded (range f)" - shows "\d\Basis. \l::'a. \ r. - strict_mono r \ (\e>0. eventually (\n. \i\d. dist (f (r n) \ i) (l \ i) < e) sequentially)" - by (rule compact_lemma_general[where unproj="\e. \i\Basis. e i *\<^sub>R i"]) - (auto intro!: assms bounded_linear_inner_left bounded_linear_image - simp: euclidean_representation) + +subsection%unimportant \Bounded Projections\ -instance%important euclidean_space \ heine_borel -proof%unimportant - fix f :: "nat \ 'a" - assume f: "bounded (range f)" - then obtain l::'a and r where r: "strict_mono r" - and l: "\e>0. eventually (\n. \i\Basis. dist (f (r n) \ i) (l \ i) < e) sequentially" - using compact_lemma [OF f] by blast - { - fix e::real - assume "e > 0" - hence "e / real_of_nat DIM('a) > 0" by (simp add: DIM_positive) - with l have "eventually (\n. \i\Basis. dist (f (r n) \ i) (l \ i) < e / (real_of_nat DIM('a))) sequentially" - by simp - moreover - { - fix n - assume n: "\i\Basis. dist (f (r n) \ i) (l \ i) < e / (real_of_nat DIM('a))" - have "dist (f (r n)) l \ (\i\Basis. dist (f (r n) \ i) (l \ i))" - apply (subst euclidean_dist_l2) - using zero_le_dist - apply (rule L2_set_le_sum) - done - also have "\ < (\i\(Basis::'a set). e / (real_of_nat DIM('a)))" - apply (rule sum_strict_mono) - using n - apply auto - done - finally have "dist (f (r n)) l < e" - by auto - } - ultimately have "eventually (\n. dist (f (r n)) l < e) sequentially" - by (rule eventually_mono) - } - then have *: "((f \ r) \ l) sequentially" - unfolding o_def tendsto_iff by simp - with r show "\l r. strict_mono r \ ((f \ r) \ l) sequentially" - by auto -qed +lemma bounded_inner_imp_bdd_above: + assumes "bounded s" + shows "bdd_above ((\x. x \ a) ` s)" +by (simp add: assms bounded_imp_bdd_above bounded_linear_image bounded_linear_inner_left) -instance euclidean_space \ banach .. +lemma bounded_inner_imp_bdd_below: + assumes "bounded s" + shows "bdd_below ((\x. x \ a) ` s)" +by (simp add: assms bounded_imp_bdd_below bounded_linear_image bounded_linear_inner_left) -subsubsection%unimportant \Structural rules for pointwise continuity\ +subsection%unimportant \Structural rules for pointwise continuity\ lemma continuous_infnorm[continuous_intros]: "continuous F f \ continuous F (\x. infnorm (f x))" @@ -779,7 +742,7 @@ using assms unfolding continuous_def by (rule tendsto_inner) -subsubsection%unimportant \Structural rules for setwise continuity\ +subsection%unimportant \Structural rules for setwise continuity\ lemma continuous_on_infnorm[continuous_intros]: "continuous_on s f \ continuous_on s (\x. infnorm (f x))" @@ -793,9 +756,7 @@ using bounded_bilinear_inner assms by (rule bounded_bilinear.continuous_on) -subsection%unimportant \Intervals\ - -text \Openness of halfspaces.\ +subsection \Openness of halfspaces.\ lemma open_halfspace_lt: "open {x. inner a x < b}" by (simp add: open_Collect_less continuous_on_inner continuous_on_const continuous_on_id) @@ -809,7 +770,19 @@ lemma open_halfspace_component_gt: "open {x::'a::euclidean_space. x\i > a}" by (simp add: open_Collect_less continuous_on_inner continuous_on_const continuous_on_id) -text \This gives a simple derivation of limit component bounds.\ +lemma eucl_less_eq_halfspaces: + fixes a :: "'a::euclidean_space" + shows "{x. x i\Basis. {x. x \ i < a \ i})" + "{x. a i\Basis. {x. a \ i < x \ i})" + by (auto simp: eucl_less_def) + +lemma open_Collect_eucl_less[simp, intro]: + fixes a :: "'a::euclidean_space" + shows "open {x. x Limit Component Bounds\ lemma open_box[intro]: "open (box a b)" proof - @@ -820,40 +793,6 @@ finally show ?thesis . qed -instance euclidean_space \ second_countable_topology -proof - define a where "a f = (\i\Basis. fst (f i) *\<^sub>R i)" for f :: "'a \ real \ real" - then have a: "\f. (\i\Basis. fst (f i) *\<^sub>R i) = a f" - by simp - define b where "b f = (\i\Basis. snd (f i) *\<^sub>R i)" for f :: "'a \ real \ real" - then have b: "\f. (\i\Basis. snd (f i) *\<^sub>R i) = b f" - by simp - define B where "B = (\f. box (a f) (b f)) ` (Basis \\<^sub>E (\ \ \))" - - have "Ball B open" by (simp add: B_def open_box) - moreover have "(\A. open A \ (\B'\B. \B' = A))" - proof safe - fix A::"'a set" - assume "open A" - show "\B'\B. \B' = A" - apply (rule exI[of _ "{b\B. b \ A}"]) - apply (subst (3) open_UNION_box[OF \open A\]) - apply (auto simp: a b B_def) - done - qed - ultimately - have "topological_basis B" - unfolding topological_basis_def by blast - moreover - have "countable B" - unfolding B_def - by (intro countable_image countable_PiE finite_Basis countable_SIGMA countable_rat) - ultimately show "\B::'a set set. countable B \ open = generate_topology B" - by (blast intro: topological_basis_imp_subbasis) -qed - -instance euclidean_space \ polish_space .. - lemma closed_cbox[intro]: fixes a b :: "'a::euclidean_space" shows "closed (cbox a b)" @@ -939,12 +878,6 @@ shows "UNIV \ cbox a b" "UNIV \ box a b" using bounded_box[of a b] bounded_cbox[of a b] by force+ -lemma compact_cbox [simp]: - fixes a :: "'a::euclidean_space" - shows "compact (cbox a b)" - using bounded_closed_imp_seq_compact[of "cbox a b"] using bounded_cbox[of a b] - by (auto simp: compact_eq_seq_compact_metric) - lemma box_midpoint: fixes a :: "'a::euclidean_space" assumes "box a b \ {}" @@ -1107,16 +1040,259 @@ unfolding closure_box[OF assms, symmetric] unfolding open_Int_closure_eq_empty[OF open_box] .. -lemma eucl_less_eq_halfspaces: +subsection \Class Instances\ + +lemma compact_lemma: + fixes f :: "nat \ 'a::euclidean_space" + assumes "bounded (range f)" + shows "\d\Basis. \l::'a. \ r. + strict_mono r \ (\e>0. eventually (\n. \i\d. dist (f (r n) \ i) (l \ i) < e) sequentially)" + by (rule compact_lemma_general[where unproj="\e. \i\Basis. e i *\<^sub>R i"]) + (auto intro!: assms bounded_linear_inner_left bounded_linear_image + simp: euclidean_representation) + +instance%important euclidean_space \ heine_borel +proof%unimportant + fix f :: "nat \ 'a" + assume f: "bounded (range f)" + then obtain l::'a and r where r: "strict_mono r" + and l: "\e>0. eventually (\n. \i\Basis. dist (f (r n) \ i) (l \ i) < e) sequentially" + using compact_lemma [OF f] by blast + { + fix e::real + assume "e > 0" + hence "e / real_of_nat DIM('a) > 0" by (simp add: DIM_positive) + with l have "eventually (\n. \i\Basis. dist (f (r n) \ i) (l \ i) < e / (real_of_nat DIM('a))) sequentially" + by simp + moreover + { + fix n + assume n: "\i\Basis. dist (f (r n) \ i) (l \ i) < e / (real_of_nat DIM('a))" + have "dist (f (r n)) l \ (\i\Basis. dist (f (r n) \ i) (l \ i))" + apply (subst euclidean_dist_l2) + using zero_le_dist + apply (rule L2_set_le_sum) + done + also have "\ < (\i\(Basis::'a set). e / (real_of_nat DIM('a)))" + apply (rule sum_strict_mono) + using n + apply auto + done + finally have "dist (f (r n)) l < e" + by auto + } + ultimately have "eventually (\n. dist (f (r n)) l < e) sequentially" + by (rule eventually_mono) + } + then have *: "((f \ r) \ l) sequentially" + unfolding o_def tendsto_iff by simp + with r show "\l r. strict_mono r \ ((f \ r) \ l) sequentially" + by auto +qed + +instance%important euclidean_space \ banach .. + +instance euclidean_space \ second_countable_topology +proof + define a where "a f = (\i\Basis. fst (f i) *\<^sub>R i)" for f :: "'a \ real \ real" + then have a: "\f. (\i\Basis. fst (f i) *\<^sub>R i) = a f" + by simp + define b where "b f = (\i\Basis. snd (f i) *\<^sub>R i)" for f :: "'a \ real \ real" + then have b: "\f. (\i\Basis. snd (f i) *\<^sub>R i) = b f" + by simp + define B where "B = (\f. box (a f) (b f)) ` (Basis \\<^sub>E (\ \ \))" + + have "Ball B open" by (simp add: B_def open_box) + moreover have "(\A. open A \ (\B'\B. \B' = A))" + proof safe + fix A::"'a set" + assume "open A" + show "\B'\B. \B' = A" + apply (rule exI[of _ "{b\B. b \ A}"]) + apply (subst (3) open_UNION_box[OF \open A\]) + apply (auto simp: a b B_def) + done + qed + ultimately + have "topological_basis B" + unfolding topological_basis_def by blast + moreover + have "countable B" + unfolding B_def + by (intro countable_image countable_PiE finite_Basis countable_SIGMA countable_rat) + ultimately show "\B::'a set set. countable B \ open = generate_topology B" + by (blast intro: topological_basis_imp_subbasis) +qed + +instance euclidean_space \ polish_space .. + + +subsection \Compact Boxes\ + +lemma compact_cbox [simp]: fixes a :: "'a::euclidean_space" - shows "{x. x i\Basis. {x. x \ i < a \ i})" - "{x. a i\Basis. {x. a \ i < x \ i})" - by (auto simp: eucl_less_def) + shows "compact (cbox a b)" + using bounded_closed_imp_seq_compact[of "cbox a b"] using bounded_cbox[of a b] + by (auto simp: compact_eq_seq_compact_metric) + +proposition is_interval_compact: + "is_interval S \ compact S \ (\a b. S = cbox a b)" (is "?lhs = ?rhs") +proof (cases "S = {}") + case True + with empty_as_interval show ?thesis by auto +next + case False + show ?thesis + proof + assume L: ?lhs + then have "is_interval S" "compact S" by auto + define a where "a \ \i\Basis. (INF x\S. x \ i) *\<^sub>R i" + define b where "b \ \i\Basis. (SUP x\S. x \ i) *\<^sub>R i" + have 1: "\x i. \x \ S; i \ Basis\ \ (INF x\S. x \ i) \ x \ i" + by (simp add: cInf_lower bounded_inner_imp_bdd_below compact_imp_bounded L) + have 2: "\x i. \x \ S; i \ Basis\ \ x \ i \ (SUP x\S. x \ i)" + by (simp add: cSup_upper bounded_inner_imp_bdd_above compact_imp_bounded L) + have 3: "x \ S" if inf: "\i. i \ Basis \ (INF x\S. x \ i) \ x \ i" + and sup: "\i. i \ Basis \ x \ i \ (SUP x\S. x \ i)" for x + proof (rule mem_box_componentwiseI [OF \is_interval S\]) + fix i::'a + assume i: "i \ Basis" + have cont: "continuous_on S (\x. x \ i)" + by (intro continuous_intros) + obtain a where "a \ S" and a: "\y. y\S \ a \ i \ y \ i" + using continuous_attains_inf [OF \compact S\ False cont] by blast + obtain b where "b \ S" and b: "\y. y\S \ y \ i \ b \ i" + using continuous_attains_sup [OF \compact S\ False cont] by blast + have "a \ i \ (INF x\S. x \ i)" + by (simp add: False a cINF_greatest) + also have "\ \ x \ i" + by (simp add: i inf) + finally have ai: "a \ i \ x \ i" . + have "x \ i \ (SUP x\S. x \ i)" + by (simp add: i sup) + also have "(SUP x\S. x \ i) \ b \ i" + by (simp add: False b cSUP_least) + finally have bi: "x \ i \ b \ i" . + show "x \ i \ (\x. x \ i) ` S" + apply (rule_tac x="\j\Basis. (if j = i then x \ i else a \ j) *\<^sub>R j" in image_eqI) + apply (simp add: i) + apply (rule mem_is_intervalI [OF \is_interval S\ \a \ S\ \b \ S\]) + using i ai bi apply force + done + qed + have "S = cbox a b" + by (auto simp: a_def b_def mem_box intro: 1 2 3) + then show ?rhs + by blast + next + assume R: ?rhs + then show ?lhs + using compact_cbox is_interval_cbox by blast + qed +qed + + +subsection%unimportant\Relating linear images to open/closed/interior/closure\ -lemma open_Collect_eucl_less[simp, intro]: - fixes a :: "'a::euclidean_space" - shows "open {x. x 'b::euclidean_space" + assumes "open A" "linear f" "surj f" + shows "open(f ` A)" +unfolding open_dist +proof clarify + fix x + assume "x \ A" + have "bounded (inv f ` Basis)" + by (simp add: finite_imp_bounded) + with bounded_pos obtain B where "B > 0" and B: "\x. x \ inv f ` Basis \ norm x \ B" + by metis + obtain e where "e > 0" and e: "\z. dist z x < e \ z \ A" + by (metis open_dist \x \ A\ \open A\) + define \ where "\ \ e / B / DIM('b)" + show "\e>0. \y. dist y (f x) < e \ y \ f ` A" + proof (intro exI conjI) + show "\ > 0" + using \e > 0\ \B > 0\ by (simp add: \_def divide_simps) + have "y \ f ` A" if "dist y (f x) * (B * real DIM('b)) < e" for y + proof - + define u where "u \ y - f x" + show ?thesis + proof (rule image_eqI) + show "y = f (x + (\i\Basis. (u \ i) *\<^sub>R inv f i))" + apply (simp add: linear_add linear_sum linear.scaleR \linear f\ surj_f_inv_f \surj f\) + apply (simp add: euclidean_representation u_def) + done + have "dist (x + (\i\Basis. (u \ i) *\<^sub>R inv f i)) x \ (\i\Basis. norm ((u \ i) *\<^sub>R inv f i))" + by (simp add: dist_norm sum_norm_le) + also have "... = (\i\Basis. \u \ i\ * norm (inv f i))" + by simp + also have "... \ (\i\Basis. \u \ i\) * B" + by (simp add: B sum_distrib_right sum_mono mult_left_mono) + also have "... \ DIM('b) * dist y (f x) * B" + apply (rule mult_right_mono [OF sum_bounded_above]) + using \0 < B\ by (auto simp: Basis_le_norm dist_norm u_def) + also have "... < e" + by (metis mult.commute mult.left_commute that) + finally show "x + (\i\Basis. (u \ i) *\<^sub>R inv f i) \ A" + by (rule e) + qed + qed + then show "\y. dist y (f x) < \ \ y \ f ` A" + using \e > 0\ \B > 0\ + by (auto simp: \_def divide_simps mult_less_0_iff) + qed +qed + +corollary open_bijective_linear_image_eq: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "linear f" "bij f" + shows "open(f ` A) \ open A" +proof + assume "open(f ` A)" + then have "open(f -` (f ` A))" + using assms by (force simp: linear_continuous_at linear_conv_bounded_linear continuous_open_vimage) + then show "open A" + by (simp add: assms bij_is_inj inj_vimage_image_eq) +next + assume "open A" + then show "open(f ` A)" + by (simp add: assms bij_is_surj open_surjective_linear_image) +qed + +corollary interior_bijective_linear_image: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "linear f" "bij f" + shows "interior (f ` S) = f ` interior S" (is "?lhs = ?rhs") +proof safe + fix x + assume x: "x \ ?lhs" + then obtain T where "open T" and "x \ T" and "T \ f ` S" + by (metis interiorE) + then show "x \ ?rhs" + by (metis (no_types, hide_lams) assms subsetD interior_maximal open_bijective_linear_image_eq subset_image_iff) +next + fix x + assume x: "x \ interior S" + then show "f x \ interior (f ` S)" + by (meson assms imageI image_mono interiorI interior_subset open_bijective_linear_image_eq open_interior) +qed + +lemma interior_injective_linear_image: + fixes f :: "'a::euclidean_space \ 'a::euclidean_space" + assumes "linear f" "inj f" + shows "interior(f ` S) = f ` (interior S)" + by (simp add: linear_injective_imp_surjective assms bijI interior_bijective_linear_image) + +lemma interior_surjective_linear_image: + fixes f :: "'a::euclidean_space \ 'a::euclidean_space" + assumes "linear f" "surj f" + shows "interior(f ` S) = f ` (interior S)" + by (simp add: assms interior_injective_linear_image linear_surjective_imp_injective) + +lemma interior_negations: + fixes S :: "'a::euclidean_space set" + shows "interior(uminus ` S) = image uminus (interior S)" + by (simp add: bij_uminus interior_bijective_linear_image linear_uminus) no_notation eucl_less (infix " Inf {y<.. Inf (insert x S) = (if S = {} then x else min x (Inf S))" + by (simp add: cInf_eq_Min) + +lemma Sup_insert_finite: + fixes S :: "'a::conditionally_complete_linorder set" + shows "finite S \ Sup (insert x S) = (if S = {} then x else max x (Sup S))" + by (simp add: cSup_insert sup_max) + +lemma finite_imp_less_Inf: + fixes a :: "'a::conditionally_complete_linorder" + shows "\finite X; x \ X; \x. x\X \ a < x\ \ a < Inf X" + by (induction X rule: finite_induct) (simp_all add: cInf_eq_Min Inf_insert_finite) + +lemma finite_less_Inf_iff: + fixes a :: "'a :: conditionally_complete_linorder" + shows "\finite X; X \ {}\ \ a < Inf X \ (\x \ X. a < x)" + by (auto simp: cInf_eq_Min) + +lemma finite_imp_Sup_less: + fixes a :: "'a::conditionally_complete_linorder" + shows "\finite X; x \ X; \x. x\X \ a > x\ \ a > Sup X" + by (induction X rule: finite_induct) (simp_all add: cSup_eq_Max Sup_insert_finite) + +lemma finite_Sup_less_iff: + fixes a :: "'a :: conditionally_complete_linorder" + shows "\finite X; X \ {}\ \ a > Sup X \ (\x \ X. a > x)" + by (auto simp: cSup_eq_Max) + class linear_continuum = conditionally_complete_linorder + dense_linorder + assumes UNIV_not_singleton: "\a b::'a. a \ b" begin