# HG changeset patch # User bulwahn # Date 1244784225 -7200 # Node ID f9c35a72390ad82dfb5c1de99d565ce8bad4499d # Parent 86eeb9b7a4ba604c555708dd7e986b7023b983f9# Parent 809dfb3d9c76cb1571da166515bb96a7fdb2a79a merged diff -r 86eeb9b7a4ba -r f9c35a72390a src/HOL/Library/Convex_Euclidean_Space.thy --- a/src/HOL/Library/Convex_Euclidean_Space.thy Fri Jun 12 00:45:28 2009 +0200 +++ b/src/HOL/Library/Convex_Euclidean_Space.thy Fri Jun 12 07:23:45 2009 +0200 @@ -1213,32 +1213,56 @@ qed qed +lemma open_dest_vec1_vimage: "open S \ open (dest_vec1 -` S)" +unfolding open_vector_def all_1 +by (auto simp add: dest_vec1_def) + +lemma tendsto_dest_vec1 [tendsto_intros]: + "(f ---> l) net \ ((\x. dest_vec1 (f x)) ---> dest_vec1 l) net" + unfolding tendsto_def + apply clarify + apply (drule_tac x="dest_vec1 -` S" in spec) + apply (simp add: open_dest_vec1_vimage) + done + +lemma continuous_dest_vec1: "continuous net f \ continuous net (\x. dest_vec1 (f x))" + unfolding continuous_def by (rule tendsto_dest_vec1) + +(* TODO: move *) +lemma compact_real_interval: + fixes a b :: real shows "compact {a..b}" +proof - + have "continuous_on {vec1 a .. vec1 b} dest_vec1" + unfolding continuous_on + by (simp add: tendsto_dest_vec1 Lim_at_within Lim_ident_at) + moreover have "compact {vec1 a .. vec1 b}" by (rule compact_interval) + ultimately have "compact (dest_vec1 ` {vec1 a .. vec1 b})" + by (rule compact_continuous_image) + also have "dest_vec1 ` {vec1 a .. vec1 b} = {a..b}" + by (auto simp add: image_def Bex_def exists_vec1) + finally show ?thesis . +qed lemma compact_convex_combinations: - fixes s t :: "(real ^ _) set" + fixes s t :: "(real ^ 'n::finite) set" assumes "compact s" "compact t" shows "compact { (1 - u) *s x + u *s y | x y u. 0 \ u \ u \ 1 \ x \ s \ y \ t}" proof- - let ?X = "{ pastecart u w | u w. u \ {vec1 0 .. vec1 1} \ w \ { pastecart x y |x y. x \ s \ y \ t} }" - let ?h = "(\z. (1 - dest_vec1(fstcart z)) *s fstcart(sndcart z) + dest_vec1(fstcart z) *s sndcart(sndcart z))" + let ?X = "{0..1} \ s \ t" + let ?h = "(\z. (1 - fst z) *s fst (snd z) + fst z *s snd (snd z))" have *:"{ (1 - u) *s x + u *s y | x y u. 0 \ u \ u \ 1 \ x \ s \ y \ t} = ?h ` ?X" - apply(rule set_ext) unfolding image_iff mem_Collect_eq unfolding mem_interval_1 vec1_dest_vec1 - apply rule apply auto apply(rule_tac x="pastecart (vec1 u) (pastecart xa y)" in exI) apply simp - apply(rule_tac x="vec1 u" in exI) apply(rule_tac x="pastecart xa y" in exI) by auto - { fix u::"real^1" fix x y assume as:"0 \ dest_vec1 u" "dest_vec1 u \ 1" "x \ s" "y \ t" - hence "continuous (at (pastecart u (pastecart x y))) - (\z. fstcart (sndcart z) - dest_vec1 (fstcart z) *s fstcart (sndcart z) + - dest_vec1 (fstcart z) *s sndcart (sndcart z))" - apply (auto intro!: continuous_add continuous_sub continuous_mul simp add: o_def vec1_dest_vec1) - using linear_continuous_at linear_fstcart linear_sndcart linear_sndcart - using linear_compose[unfolded o_def] by auto } - hence "continuous_on {pastecart u w |u w. u \ {vec1 0..vec1 1} \ w \ {pastecart x y |x y. x \ s \ y \ t}} - (\z. (1 - dest_vec1 (fstcart z)) *s fstcart (sndcart z) + dest_vec1 (fstcart z) *s sndcart (sndcart z))" - apply(rule_tac continuous_at_imp_continuous_on) unfolding mem_Collect_eq - unfolding mem_interval_1 vec1_dest_vec1 by auto - thus ?thesis unfolding * apply(rule compact_continuous_image) - defer apply(rule compact_pastecart) defer apply(rule compact_pastecart) - using compact_interval assms by auto + apply(rule set_ext) unfolding image_iff mem_Collect_eq + apply rule apply auto + apply (rule_tac x=u in rev_bexI, simp) + apply (erule rev_bexI, erule rev_bexI, simp) + by auto + have "continuous_on ({0..1} \ s \ t) + (\z. (1 - fst z) *s fst (snd z) + fst z *s snd (snd z))" + unfolding continuous_on by (rule ballI) (intro tendsto_intros) + thus ?thesis unfolding * + apply (rule compact_continuous_image) + apply (intro compact_Times compact_real_interval assms) + done qed lemma compact_convex_hull: fixes s::"(real^'n::finite) set" @@ -1888,7 +1912,9 @@ unfolding image_image[of "\u. u *s x" "\x. dest_vec1 x", THEN sym] unfolding dest_vec1_inverval vec1_dest_vec1 by auto have "compact ?A" unfolding A apply(rule compact_continuous_image, rule continuous_at_imp_continuous_on) - apply(rule, rule continuous_vmul) unfolding o_def vec1_dest_vec1 apply(rule continuous_at_id) by(rule compact_interval) + apply(rule, rule continuous_vmul) + apply (rule continuous_dest_vec1) + apply(rule continuous_at_id) by(rule compact_interval) moreover have "{y. \u\0. u \ b / norm x \ y = u *s x} \ s \ {}" apply(rule not_disjointI[OF _ assms(2)]) unfolding mem_Collect_eq using `b>0` assms(3) by(auto intro!: divide_nonneg_pos) ultimately obtain u y where obt: "u\0" "u \ b / norm x" "y = u *s x" @@ -1925,12 +1951,13 @@ have injpi:"\x y. pi x = pi y \ norm x = norm y \ x = y" unfolding pi_def by auto have contpi:"continuous_on (UNIV - {0}) pi" apply(rule continuous_at_imp_continuous_on) - apply rule unfolding pi_def apply(rule continuous_mul) unfolding o_def - apply(rule continuous_at_inv[unfolded o_def]) unfolding continuous_at_vec1_range[unfolded o_def] - apply(rule,rule) apply(rule_tac x=e in exI) apply(rule,assumption,rule,rule) - proof- fix e x y assume "0 < e" "norm (y - x::real^'n) < e" - thus "\norm y - norm x\ < e" using norm_triangle_ineq3[of y x] by auto - qed(auto intro!:continuous_at_id) + apply rule unfolding pi_def + apply (rule continuous_mul) + apply (rule continuous_at_inv[unfolded o_def]) + apply (rule continuous_at_norm) + apply simp + apply (rule continuous_at_id) + done def sphere \ "{x::real^'n. norm x = 1}" have pi:"\x. x \ 0 \ pi x \ sphere" "\x u. u>0 \ pi (u *s x) = pi x" unfolding pi_def sphere_def by auto @@ -2015,7 +2042,7 @@ prefer 4 apply(rule continuous_at_imp_continuous_on, rule) apply(rule_tac [3] hom2) proof- fix x::"real^'n" assume as:"x \ cball 0 1" thus "continuous (at x) (\x. norm x *s surf (pi x))" proof(cases "x=0") - case False thus ?thesis apply(rule_tac continuous_mul, rule_tac continuous_at_vec1_norm) + case False thus ?thesis apply(rule_tac continuous_mul, rule_tac continuous_at_norm) using cont_surfpi unfolding continuous_on_eq_continuous_at[OF open_delete[OF open_UNIV]] o_def by auto next guess a using UNIV_witness[where 'a = 'n] .. obtain B where B:"\x\s. norm x \ B" using compact_imp_bounded[OF assms(1)] unfolding bounded_iff by auto @@ -2332,8 +2359,8 @@ lemma convex_on_bounded_continuous: assumes "open s" "convex_on s f" "\x\s. abs(f x) \ b" - shows "continuous_on s (vec1 o f)" - apply(rule continuous_at_imp_continuous_on) unfolding continuous_at_vec1_range proof(rule,rule,rule) + shows "continuous_on s f" + apply(rule continuous_at_imp_continuous_on) unfolding continuous_at_real_range proof(rule,rule,rule) fix x e assume "x\s" "(0::real) < e" def B \ "abs b + 1" have B:"0 < B" "\x. x\s \ abs (f x) \ B" @@ -2398,7 +2425,7 @@ lemma convex_on_continuous: assumes "open (s::(real^'n::finite) set)" "convex_on s f" - shows "continuous_on s (vec1 \ f)" + shows "continuous_on s f" unfolding continuous_on_eq_continuous_at[OF assms(1)] proof note dimge1 = dimindex_ge_1[where 'a='n] fix x assume "x\s" @@ -2428,9 +2455,9 @@ using order_trans[OF component_le_norm y[unfolded mem_cball dist_norm], of i] by(auto simp add: vector_component) } thus "f y \ k" apply(rule_tac k[rule_format]) unfolding mem_cball mem_interval dist_norm by(auto simp add: vector_component_simps) qed - hence "continuous_on (ball x d) (vec1 \ f)" apply(rule_tac convex_on_bounded_continuous) + hence "continuous_on (ball x d) f" apply(rule_tac convex_on_bounded_continuous) apply(rule open_ball, rule convex_on_subset[OF conv], rule ball_subset_cball) by auto - thus "continuous (at x) (vec1 \ f)" unfolding continuous_on_eq_continuous_at[OF open_ball] using `d>0` by auto qed + thus "continuous (at x) f" unfolding continuous_on_eq_continuous_at[OF open_ball] using `d>0` by auto qed subsection {* Line segments, starlike sets etc. *) (* Use the same overloading tricks as for intervals, so that *) @@ -2975,7 +3002,8 @@ unfolding pathfinish_def linepath_def by auto lemma continuous_linepath_at[intro]: "continuous (at x) (linepath a b)" - unfolding linepath_def by(auto simp add: vec1_dest_vec1 o_def intro!: continuous_intros) + unfolding linepath_def + by (intro continuous_intros continuous_dest_vec1) lemma continuous_on_linepath[intro]: "continuous_on s (linepath a b)" using continuous_linepath_at by(auto intro!: continuous_at_imp_continuous_on) @@ -3202,9 +3230,9 @@ have ***:"\xa. (if xa = 0 then 0 else 1) \ 1 \ xa = 0" apply(rule ccontr) by auto have **:"{x::real^'n. norm x = 1} = (\x. (1/norm x) *s x) ` (UNIV - {0})" apply(rule set_ext,rule) unfolding image_iff apply(rule_tac x=x in bexI) unfolding mem_Collect_eq norm_mul by(auto intro!: ***) - have "continuous_on (UNIV - {0}) (vec1 \ (\x::real^'n. 1 / norm x))" unfolding o_def continuous_on_eq_continuous_within + have "continuous_on (UNIV - {0}) (\x::real^'n. 1 / norm x)" unfolding o_def continuous_on_eq_continuous_within apply(rule, rule continuous_at_within_inv[unfolded o_def inverse_eq_divide]) apply(rule continuous_at_within) - apply(rule continuous_at_vec1_norm[unfolded o_def]) by auto + apply(rule continuous_at_norm[unfolded o_def]) by auto thus ?thesis unfolding * ** using path_connected_punctured_universe[OF assms] by(auto intro!: path_connected_continuous_image continuous_on_intros continuous_on_mul) qed diff -r 86eeb9b7a4ba -r f9c35a72390a src/HOL/Library/Euclidean_Space.thy --- a/src/HOL/Library/Euclidean_Space.thy Fri Jun 12 00:45:28 2009 +0200 +++ b/src/HOL/Library/Euclidean_Space.thy Fri Jun 12 07:23:45 2009 +0200 @@ -369,19 +369,33 @@ end -lemma tendsto_Cart_nth: - fixes f :: "'a \ 'b::topological_space ^ 'n::finite" +lemma open_vector_box: "\i. open (S i) \ open {x. \i. x $ i \ S i}" +unfolding open_vector_def by auto + +lemma open_vimage_Cart_nth: "open S \ open ((\x. x $ i) -` S)" +unfolding open_vector_def +apply clarify +apply (rule_tac x="\k. if k = i then S else UNIV" in exI, simp) +done + +lemma closed_vimage_Cart_nth: "closed S \ closed ((\x. x $ i) -` S)" +unfolding closed_open vimage_Compl [symmetric] +by (rule open_vimage_Cart_nth) + +lemma closed_vector_box: "\i. closed (S i) \ closed {x. \i. x $ i \ S i}" +proof - + have "{x. \i. x $ i \ S i} = (\i. (\x. x $ i) -` S i)" by auto + thus "\i. closed (S i) \ closed {x. \i. x $ i \ S i}" + by (simp add: closed_INT closed_vimage_Cart_nth) +qed + +lemma tendsto_Cart_nth [tendsto_intros]: assumes "((\x. f x) ---> a) net" shows "((\x. f x $ i) ---> a $ i) net" proof (rule topological_tendstoI) - fix S :: "'b set" assume "open S" "a $ i \ S" + fix S assume "open S" "a $ i \ S" then have "open ((\y. y $ i) -` S)" "a \ ((\y. y $ i) -` S)" - unfolding open_vector_def - apply simp_all - apply clarify - apply (rule_tac x="\k. if k = i then S else UNIV" in exI) - apply simp - done + by (simp_all add: open_vimage_Cart_nth) with assms have "eventually (\x. f x \ (\y. y $ i) -` S) net" by (rule topological_tendstoD) then show "eventually (\x. f x $ i \ S) net" diff -r 86eeb9b7a4ba -r f9c35a72390a src/HOL/Library/Product_Vector.thy --- a/src/HOL/Library/Product_Vector.thy Fri Jun 12 00:45:28 2009 +0200 +++ b/src/HOL/Library/Product_Vector.thy Fri Jun 12 07:23:45 2009 +0200 @@ -72,6 +72,37 @@ end +lemma open_Times: "open S \ open T \ open (S \ T)" +unfolding open_prod_def by auto + +lemma fst_vimage_eq_Times: "fst -` S = S \ UNIV" +by auto + +lemma snd_vimage_eq_Times: "snd -` S = UNIV \ S" +by auto + +lemma open_vimage_fst: "open S \ open (fst -` S)" +by (simp add: fst_vimage_eq_Times open_Times) + +lemma open_vimage_snd: "open S \ open (snd -` S)" +by (simp add: snd_vimage_eq_Times open_Times) + +lemma closed_vimage_fst: "closed S \ closed (fst -` S)" +unfolding closed_open vimage_Compl [symmetric] +by (rule open_vimage_fst) + +lemma closed_vimage_snd: "closed S \ closed (snd -` S)" +unfolding closed_open vimage_Compl [symmetric] +by (rule open_vimage_snd) + +lemma closed_Times: "closed S \ closed T \ closed (S \ T)" +proof - + have "S \ T = (fst -` S) \ (snd -` T)" by auto + thus "closed S \ closed T \ closed (S \ T)" + by (simp add: closed_vimage_fst closed_vimage_snd closed_Int) +qed + + subsection {* Product is a metric space *} instantiation @@ -87,25 +118,21 @@ instance proof fix x y :: "'a \ 'b" show "dist x y = 0 \ x = y" - unfolding dist_prod_def - by (simp add: expand_prod_eq) + unfolding dist_prod_def expand_prod_eq by simp next fix x y z :: "'a \ 'b" show "dist x y \ dist x z + dist y z" unfolding dist_prod_def - apply (rule order_trans [OF _ real_sqrt_sum_squares_triangle_ineq]) - apply (rule real_sqrt_le_mono) - apply (rule order_trans [OF add_mono]) - apply (rule power_mono [OF dist_triangle2 [of _ _ "fst z"] zero_le_dist]) - apply (rule power_mono [OF dist_triangle2 [of _ _ "snd z"] zero_le_dist]) - apply (simp only: real_sum_squared_expand) - done + by (intro order_trans [OF _ real_sqrt_sum_squares_triangle_ineq] + real_sqrt_le_mono add_mono power_mono dist_triangle2 zero_le_dist) next (* FIXME: long proof! *) (* Maybe it would be easier to define topological spaces *) (* in terms of neighborhoods instead of open sets? *) fix S :: "('a \ 'b) set" show "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" + proof + assume "open S" thus "\x\S. \e>0. \y. dist y x < e \ y \ S" unfolding open_prod_def open_dist apply safe apply (drule (1) bspec) @@ -121,7 +148,11 @@ apply (erule le_less_trans [OF real_sqrt_sum_squares_ge1]) apply (drule spec, erule mp) apply (erule le_less_trans [OF real_sqrt_sum_squares_ge2]) - + done + next + assume "\x\S. \e>0. \y. dist y x < e \ y \ S" thus "open S" + unfolding open_prod_def open_dist + apply safe apply (drule (1) bspec) apply clarify apply (subgoal_tac "\r>0. \s>0. e = sqrt (r\ + s\)") @@ -132,14 +163,14 @@ apply clarify apply (rule_tac x="r - dist x a" in exI, rule conjI, simp) apply clarify - apply (rule le_less_trans [OF dist_triangle]) - apply (erule less_le_trans [OF add_strict_right_mono], simp) + apply (simp add: less_diff_eq) + apply (erule le_less_trans [OF dist_triangle]) apply (rule conjI) apply clarify apply (rule_tac x="s - dist x b" in exI, rule conjI, simp) apply clarify - apply (rule le_less_trans [OF dist_triangle]) - apply (erule less_le_trans [OF add_strict_right_mono], simp) + apply (simp add: less_diff_eq) + apply (erule le_less_trans [OF dist_triangle]) apply (rule conjI) apply simp apply (clarify, rename_tac c d) @@ -149,6 +180,7 @@ apply (rule_tac x="e / sqrt 2" in exI, simp add: divide_pos_pos) apply (simp add: power_divide) done + qed qed end @@ -161,7 +193,7 @@ lemma dist_snd_le: "dist (snd x) (snd y) \ dist x y" unfolding dist_prod_def by simp -lemma tendsto_fst: +lemma tendsto_fst [tendsto_intros]: assumes "(f ---> a) net" shows "((\x. fst (f x)) ---> fst a) net" proof (rule topological_tendstoI) @@ -180,7 +212,7 @@ by simp qed -lemma tendsto_snd: +lemma tendsto_snd [tendsto_intros]: assumes "(f ---> a) net" shows "((\x. snd (f x)) ---> snd a) net" proof (rule topological_tendstoI) @@ -199,7 +231,7 @@ by simp qed -lemma tendsto_Pair: +lemma tendsto_Pair [tendsto_intros]: assumes "(f ---> a) net" and "(g ---> b) net" shows "((\x. (f x, g x)) ---> (a, b)) net" proof (rule topological_tendstoI) diff -r 86eeb9b7a4ba -r f9c35a72390a src/HOL/Library/Topology_Euclidean_Space.thy --- a/src/HOL/Library/Topology_Euclidean_Space.thy Fri Jun 12 00:45:28 2009 +0200 +++ b/src/HOL/Library/Topology_Euclidean_Space.thy Fri Jun 12 07:23:45 2009 +0200 @@ -6,7 +6,7 @@ header {* Elementary topology in Euclidean space. *} theory Topology_Euclidean_Space -imports SEQ Euclidean_Space +imports SEQ Euclidean_Space Product_Vector begin declare fstcart_pastecart[simp] sndcart_pastecart[simp] @@ -1245,6 +1245,9 @@ unfolding linear_conv_bounded_linear by (rule bounded_linear.tendsto) +lemma Lim_ident_at: "((\x. x) ---> a) (at a)" + unfolding tendsto_def Limits.eventually_at_topological by fast + lemma Lim_const: "((\x. a) ---> a) net" by (rule tendsto_const) @@ -1277,38 +1280,34 @@ lemma Lim_null_norm: fixes f :: "'a \ 'b::real_normed_vector" - shows "(f ---> 0) net \ ((\x. vec1(norm(f x))) ---> 0) net" - by (simp add: Lim dist_norm norm_vec1) + shows "(f ---> 0) net \ ((\x. norm(f x)) ---> 0) net" + by (simp add: Lim dist_norm) lemma Lim_null_comparison: fixes f :: "'a \ 'b::real_normed_vector" - assumes "eventually (\x. norm(f x) <= g x) net" "((\x. vec1(g x)) ---> 0) net" + assumes "eventually (\x. norm (f x) \ g x) net" "(g ---> 0) net" shows "(f ---> 0) net" proof(simp add: tendsto_iff, rule+) fix e::real assume "0 g x" "dist (vec1 (g x)) 0 < e" - hence "dist (f x) 0 < e" unfolding vec_def using dist_vec1[of "g x" "0"] - by (vector dist_norm norm_vec1 real_vector_norm_def dot_def vec1_def) + assume "norm (f x) \ g x" "dist (g x) 0 < e" + hence "dist (f x) 0 < e" by (simp add: dist_norm) } thus "eventually (\x. dist (f x) 0 < e) net" - using eventually_and[of "\x. norm(f x) <= g x" "\x. dist (vec1 (g x)) 0 < e" net] - using eventually_mono[of "(\x. norm (f x) \ g x \ dist (vec1 (g x)) 0 < e)" "(\x. dist (f x) 0 < e)" net] + using eventually_and[of "\x. norm(f x) <= g x" "\x. dist (g x) 0 < e" net] + using eventually_mono[of "(\x. norm (f x) \ g x \ dist (g x) 0 < e)" "(\x. dist (f x) 0 < e)" net] using assms `e>0` unfolding tendsto_iff by auto qed -lemma Lim_component: "(f ---> l) net - ==> ((\a. vec1((f a :: real ^'n::finite)$i)) ---> vec1(l$i)) net" +lemma Lim_component: + fixes f :: "'a \ 'b::metric_space ^ 'n::finite" + shows "(f ---> l) net \ ((\a. f a $i) ---> l$i) net" unfolding tendsto_iff - apply (simp add: dist_norm vec1_sub[symmetric] norm_vec1 vector_minus_component[symmetric] del: vector_minus_component) - apply (auto simp del: vector_minus_component) - apply (erule_tac x=e in allE) - apply clarify - apply (erule eventually_rev_mono) - apply (auto simp del: vector_minus_component) - apply (rule order_le_less_trans) - apply (rule component_le_norm) - by auto + apply (clarify) + apply (drule spec, drule (1) mp) + apply (erule eventually_elim1) + apply (erule le_less_trans [OF dist_nth_le]) + done lemma Lim_transform_bound: fixes f :: "'a \ 'b::real_normed_vector" @@ -1504,12 +1503,6 @@ netlimit :: "'a::metric_space net \ 'a" where "netlimit net = (SOME a. \r>0. eventually (\x. dist x a < r) net)" -lemma dist_triangle3: - fixes x y :: "'a::metric_space" - shows "dist x y \ dist a x + dist a y" -using dist_triangle2 [of x y a] -by (simp add: dist_commute) - lemma netlimit_within: assumes "\ trivial_limit (at a within S)" shows "netlimit (at a within S) = a" @@ -1694,14 +1687,14 @@ apply (subgoal_tac "\N k (n::nat). N + k <= n ==> N <= n - k \ (n - k) + k = n") by metis arith -lemma seq_harmonic: "((\n. vec1(inverse (real n))) ---> 0) sequentially" +lemma seq_harmonic: "((\n. inverse (real n)) ---> 0) sequentially" proof- { fix e::real assume "e>0" hence "\N::nat. \n::nat\N. inverse (real n) < e" using real_arch_inv[of e] apply auto apply(rule_tac x=n in exI) - by (metis dlo_simps(4) le_imp_inverse_le linorder_not_less real_of_nat_gt_zero_cancel_iff real_of_nat_less_iff xt1(7)) + by (metis not_le le_imp_inverse_le not_less real_of_nat_gt_zero_cancel_iff real_of_nat_less_iff xt1(7)) } - thus ?thesis unfolding Lim_sequentially dist_norm apply simp unfolding norm_vec1 by auto + thus ?thesis unfolding Lim_sequentially dist_norm by simp qed text{* More properties of closed balls. *} @@ -1856,9 +1849,10 @@ apply (simp add: zero_less_dist_iff) done +(* In a trivial vector space, this fails for e = 0. *) lemma interior_cball: - fixes x :: "real ^ _" (* FIXME: generalize *) - shows "interior(cball x e) = ball x e" + 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 "ball x e = {}" using ball_empty[of e x] by auto moreover @@ -1873,9 +1867,9 @@ { 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:"dist y xa = d / 2" using vector_choose_dist[of "d/2" y] by auto - hence xa_y:"xa \ y" using dist_nz[of y xa] using `d>0` by auto - have "xa\S" using d[THEN spec[where x=xa]] using xa apply(auto simp add: dist_commute) unfolding dist_nz[THEN sym] using xa_y by auto + 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 add: dist_commute) hence xa_cball:"xa \ cball x e" using as(1) by auto hence "y \ ball x e" proof(cases "x = y") @@ -1884,18 +1878,19 @@ thus "y \ ball x e" using `x = y ` by simp next case False - have "dist (y + (d / 2 / dist y x) *s (y - x)) y < d" unfolding dist_norm - using `d>0` norm_ge_zero[of "y - x"] `x \ y` by auto - hence *:"y + (d / 2 / dist y x) *s (y - x) \ cball x e" using d as(1)[unfolded subset_eq] by blast + 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 simp add: norm_scaleR) + hence *:"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[THEN sym] using `d>0` divide_pos_pos[of d "2*norm (y - x)"] by auto - have "dist (y + (d / 2 / dist y x) *s (y - x)) x = norm (y + (d / (2 * norm (y - x))) *s y - (d / (2 * norm (y - x))) *s x - x)" - by (auto simp add: dist_norm vector_ssub_ldistrib add_diff_eq) - also have "\ = norm ((1 + d / (2 * norm (y - x))) *s (y - x))" - by (auto simp add: vector_sadd_rdistrib vector_smult_lid ring_simps vector_sadd_rdistrib vector_ssub_ldistrib) - also have "\ = \1 + d / (2 * norm (y - x))\ * norm (y - x)" using ** 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 add: dist_norm algebra_simps) + also have "\ = norm ((1 + d / (2 * norm (y - x))) *\<^sub>R (y - x))" + by (auto simp add: algebra_simps) + also have "\ = \1 + d / (2 * norm (y - x))\ * norm (y - x)" + using ** by (auto simp add: norm_scaleR) also have "\ = (dist y x) + d/2"using ** by (auto simp add: left_distrib dist_norm) finally have "e \ dist x y +d/2" using *[unfolded mem_cball] by (auto simp add: dist_commute) thus "y \ ball x e" unfolding mem_ball using `d>0` by auto @@ -1905,14 +1900,14 @@ qed lemma frontier_ball: - fixes a :: "real ^ _" (* FIXME: generalize *) + fixes a :: "'a::real_normed_vector" shows "0 < e ==> frontier(ball a e) = {x. dist a x = e}" apply (simp add: frontier_def closure_ball interior_open open_ball order_less_imp_le) apply (simp add: expand_set_eq) by arith lemma frontier_cball: - fixes a :: "real ^ _" (* FIXME: generalize *) + fixes a :: "'a::{real_normed_vector, perfect_space}" shows "frontier(cball a e) = {x. dist a x = e}" apply (simp add: frontier_def interior_cball closed_cball closure_closed order_less_imp_le) apply (simp add: expand_set_eq) @@ -1924,20 +1919,20 @@ lemma cball_empty: "e < 0 ==> cball x e = {}" by (simp add: cball_eq_empty) lemma cball_eq_sing: - fixes x :: "real ^ _" (* FIXME: generalize *) + fixes x :: "'a::perfect_space" shows "(cball x e = {x}) \ e = 0" -proof- - { assume as:"\xa. (dist x xa \ e) = (xa = x)" - hence "e \ 0" apply (erule_tac x=x in allE) by auto - then obtain y where y:"dist x y = e" using vector_choose_dist[of e] by auto - hence "e = 0" using as apply(erule_tac x=y in allE) by auto - } - thus ?thesis unfolding expand_set_eq mem_cball by (auto simp add: dist_nz) -qed +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 + hence "a \ x" "dist x a \ e" by (auto simp add: dist_commute) + with e show ?thesis by (auto simp add: expand_set_eq) +qed auto lemma cball_sing: - fixes x :: "real ^ _" (* FIXME: generalize *) - shows "e = 0 ==> cball x e = {x}" by (simp add: cball_eq_sing) + fixes x :: "'a::metric_space" + shows "e = 0 ==> cball x e = {x}" + by (auto simp add: expand_set_eq) text{* For points in the interior, localization of limits makes no difference. *} @@ -2123,26 +2118,26 @@ text{* Some theorems on sups and infs using the notion "bounded". *} -lemma bounded_vec1: +lemma bounded_real: fixes S :: "real set" - shows "bounded(vec1 ` S) \ (\a. \x\S. abs x <= a)" - by (simp add: bounded_iff forall_vec1 norm_vec1 vec1_in_image_vec1) - -lemma bounded_has_rsup: assumes "bounded(vec1 ` S)" "S \ {}" + shows "bounded S \ (\a. \x\S. abs x <= a)" + by (simp add: bounded_iff) + +lemma bounded_has_rsup: assumes "bounded S" "S \ {}" shows "\x\S. x <= rsup S" and "\b. (\x\S. x <= b) \ rsup S <= b" proof fix x assume "x\S" - from assms(1) obtain a where a:"\x\S. \x\ \ a" unfolding bounded_vec1 by auto + from assms(1) obtain a where a:"\x\S. \x\ \ a" unfolding bounded_real by auto hence *:"S *<= a" using setleI[of S a] by (metis abs_le_interval_iff mem_def) - thus "x \ rsup S" using rsup[OF `S\{}`] using assms(1)[unfolded bounded_vec1] using isLubD2[of UNIV S "rsup S" x] using `x\S` by auto + thus "x \ rsup S" using rsup[OF `S\{}`] using assms(1)[unfolded bounded_real] using isLubD2[of UNIV S "rsup S" x] using `x\S` by auto next show "\b. (\x\S. x \ b) \ rsup S \ b" using assms using rsup[of S, unfolded isLub_def isUb_def leastP_def setle_def setge_def] - apply (auto simp add: bounded_vec1) + apply (auto simp add: bounded_real) by (auto simp add: isLub_def isUb_def leastP_def setle_def setge_def) qed -lemma rsup_insert: assumes "bounded (vec1 ` S)" +lemma rsup_insert: assumes "bounded S" shows "rsup(insert x S) = (if S = {} then x else max x (rsup S))" proof(cases "S={}") case True thus ?thesis using rsup_finite_in[of "{x}"] by auto @@ -2168,17 +2163,17 @@ by simp lemma bounded_has_rinf: - assumes "bounded(vec1 ` S)" "S \ {}" + assumes "bounded S" "S \ {}" shows "\x\S. x >= rinf S" and "\b. (\x\S. x >= b) \ rinf S >= b" proof fix x assume "x\S" - from assms(1) obtain a where a:"\x\S. \x\ \ a" unfolding bounded_vec1 by auto + from assms(1) obtain a where a:"\x\S. \x\ \ a" unfolding bounded_real by auto hence *:"- a <=* S" using setgeI[of S "-a"] unfolding abs_le_interval_iff by auto thus "x \ rinf S" using rinf[OF `S\{}`] using isGlbD2[of UNIV S "rinf S" x] using `x\S` by auto next show "\b. (\x\S. x >= b) \ rinf S \ b" using assms using rinf[of S, unfolded isGlb_def isLb_def greatestP_def setle_def setge_def] - apply (auto simp add: bounded_vec1) + apply (auto simp add: bounded_real) by (auto simp add: isGlb_def isLb_def greatestP_def setle_def setge_def) qed @@ -2189,7 +2184,7 @@ apply (blast intro!: order_antisym dest!: isGlb_le_isLb) done -lemma rinf_insert: assumes "bounded (vec1 ` S)" +lemma rinf_insert: assumes "bounded S" shows "rinf(insert x S) = (if S = {} then x else min x (rinf S))" (is "?lhs = ?rhs") proof(cases "S={}") case True thus ?thesis using rinf_finite_in[of "{x}"] by auto @@ -2217,8 +2212,8 @@ definition compact :: "'a::metric_space set \ bool" where (* TODO: generalize *) "compact S \ - (\f. (\n::nat. f n \ S) \ - (\l\S. \r. (\m n. m < n \ r m < r n) \ ((f o r) ---> l) sequentially))" + (\f. (\n. f n \ S) \ + (\l\S. \r. subseq r \ ((f o r) ---> l) sequentially))" text {* A metric space (or topological vector space) is said to have the @@ -2227,44 +2222,43 @@ class heine_borel = assumes bounded_imp_convergent_subsequence: - "bounded s \ \n::nat. f n \ s - \ \l r. (\m n. m < n --> r m < r n) \ ((f \ r) ---> l) sequentially" + "bounded s \ \n. f n \ s + \ \l r. subseq r \ ((f \ r) ---> l) sequentially" lemma bounded_closed_imp_compact: fixes s::"'a::heine_borel set" assumes "bounded s" and "closed s" shows "compact s" proof (unfold compact_def, clarify) fix f :: "nat \ 'a" assume f: "\n. f n \ s" - obtain l r where r: "\m n. m < n \ r m < r n" and l: "((f \ r) ---> l) sequentially" + obtain l r where r: "subseq r" and l: "((f \ r) ---> l) sequentially" using bounded_imp_convergent_subsequence [OF `bounded s` `\n. f n \ s`] by auto from f have fr: "\n. (f \ r) n \ s" by simp have "l \ s" using `closed s` fr l unfolding closed_sequential_limits by blast - show "\l\s. \r. (\m n. m < n \ r m < r n) \ ((f \ r) ---> l) sequentially" + show "\l\s. \r. subseq r \ ((f \ r) ---> l) sequentially" using `l \ s` r l by blast qed -lemma monotone_bigger: fixes r::"nat\nat" - assumes "\m n::nat. m < n --> r m < r n" - shows "n \ r n" +lemma subseq_bigger: assumes "subseq r" shows "n \ r n" proof(induct n) show "0 \ r 0" by auto next fix n assume "n \ r n" - moreover have "r n < r (Suc n)" using assms by auto + moreover have "r n < r (Suc n)" + using assms [unfolded subseq_def] by auto ultimately show "Suc n \ r (Suc n)" by auto qed -lemma eventually_subsequence: - assumes r: "\m n. m < n \ r m < r n" +lemma eventually_subseq: + assumes r: "subseq r" shows "eventually P sequentially \ eventually (\n. P (r n)) sequentially" unfolding eventually_sequentially -by (metis monotone_bigger [OF r] le_trans) - -lemma lim_subsequence: - fixes l :: "'a::metric_space" (* TODO: generalize *) - shows "\m n. m < n \ r m < r n \ (s ---> l) sequentially \ ((s o r) ---> l) sequentially" -unfolding Lim_sequentially by (simp, metis monotone_bigger le_trans) +by (metis subseq_bigger [OF r] le_trans) + +lemma lim_subseq: + "subseq r \ (s ---> l) sequentially \ ((s o r) ---> l) sequentially" +unfolding tendsto_def eventually_sequentially o_def +by (metis subseq_bigger le_trans) lemma num_Axiom: "EX! g. g 0 = e \ (\n. g (Suc n) = f n (g n))" unfolding Ex1_def @@ -2280,9 +2274,8 @@ apply (simp) done - lemma convergent_bounded_increasing: fixes s ::"nat\real" - assumes "\m n. m \ n --> s m \ s n" and "\n. abs(s n) \ b" + assumes "incseq s" and "\n. abs(s n) \ b" shows "\ l. \e::real>0. \ N. \n \ N. abs(s n - l) < e" proof- have "isUb UNIV (range s) b" using assms(2) and abs_le_D1 unfolding isUb_def and setle_def by auto @@ -2292,27 +2285,27 @@ obtain N where "N\n" and n:"\s N - t\ \ e" using as[THEN spec[where x=n]] by auto have "t \ s N" using isLub_isUb[OF t, unfolded isUb_def setle_def] by auto with n have "s N \ t - e" using `e>0` by auto - hence "s n \ t - e" using assms(1)[THEN spec[where x=n], THEN spec[where x=N]] using `n\N` by auto } + hence "s n \ t - e" using assms(1)[unfolded incseq_def, THEN spec[where x=n], THEN spec[where x=N]] using `n\N` by auto } hence "isUb UNIV (range s) (t - e)" unfolding isUb_def and setle_def by auto hence False using isLub_le_isUb[OF t, of "t - e"] and `e>0` by auto } thus ?thesis by blast qed lemma convergent_bounded_monotone: fixes s::"nat \ real" - assumes "\n. abs(s n) \ b" and "(\m n. m \ n --> s m \ s n) \ (\m n. m \ n --> s n \ s m)" + assumes "\n. abs(s n) \ b" and "monoseq s" shows "\l. \e::real>0. \N. \n\N. abs(s n - l) < e" using convergent_bounded_increasing[of s b] assms using convergent_bounded_increasing[of "\n. - s n" b] + unfolding monoseq_def incseq_def apply auto unfolding minus_add_distrib[THEN sym, unfolded diff_minus[THEN sym]] unfolding abs_minus_cancel by(rule_tac x="-l" in exI)auto lemma compact_real_lemma: assumes "\n::nat. abs(s n) \ b" - shows "\(l::real) r. (\m n::nat. m < n --> r m < r n) \ ((s \ r) ---> l) sequentially" + shows "\(l::real) r. subseq r \ ((s \ r) ---> l) sequentially" proof- - obtain r where r:"\m n::nat. m < n \ r m < r n" - "(\m n. m \ n \ s (r m) \ s (r n)) \ (\m n. m \ n \ s (r n) \ s (r m))" - using seq_monosub[of s] by (auto simp add: subseq_def monoseq_def) - thus ?thesis using convergent_bounded_monotone[of "s o r" b] and assms + obtain r where r:"subseq r" "monoseq (\n. s (r n))" + using seq_monosub[of s] by auto + thus ?thesis using convergent_bounded_monotone[of "\n. s (r n)" b] and assms unfolding tendsto_iff dist_norm eventually_sequentially by auto qed @@ -2323,9 +2316,9 @@ then obtain b where b: "\n. abs (f n) \ b" unfolding bounded_iff by auto obtain l :: real and r :: "nat \ nat" where - r: "\m n. m < n \ r m < r n" and l: "((f \ r) ---> l) sequentially" + r: "subseq r" and l: "((f \ r) ---> l) sequentially" using compact_real_lemma [OF b] by auto - thus "\l r. (\m n. m < n \ r m < r n) \ ((f \ r) ---> l) sequentially" + thus "\l r. subseq r \ ((f \ r) ---> l) sequentially" by auto qed @@ -2342,28 +2335,29 @@ fixes f :: "nat \ 'a::heine_borel ^ 'n::finite" assumes "bounded s" and "\n. f n \ s" shows "\d. - \l r. (\n m::nat. m < n --> r m < r n) \ + \l r. subseq r \ (\e>0. eventually (\n. \i\d. dist (f (r n) $ i) (l $ i) < e) sequentially)" proof fix d::"'n set" have "finite d" by simp - thus "\l::'a ^ 'n. \r. (\n m::nat. m < n --> r m < r n) \ + thus "\l::'a ^ 'n. \r. subseq r \ (\e>0. eventually (\n. \i\d. dist (f (r n) $ i) (l $ i) < e) sequentially)" - proof(induct d) case empty thus ?case by auto + proof(induct d) case empty thus ?case unfolding subseq_def by auto next case (insert k d) have s': "bounded ((\x. x $ k) ` s)" using `bounded s` by (rule bounded_component) - obtain l1::"'a^'n" and r1 where r1:"\n m::nat. m < n \ r1 m < r1 n" and lr1:"\e>0. eventually (\n. \i\d. dist (f (r1 n) $ i) (l1 $ i) < e) sequentially" + obtain l1::"'a^'n" and r1 where r1:"subseq r1" and lr1:"\e>0. eventually (\n. \i\d. dist (f (r1 n) $ i) (l1 $ i) < e) sequentially" using insert(3) by auto have f': "\n. f (r1 n) $ k \ (\x. x $ k) ` s" using `\n. f n \ s` by simp - obtain l2 r2 where r2:"\m n::nat. m < n \ r2 m < r2 n" and lr2:"((\i. f (r1 (r2 i)) $ k) ---> l2) sequentially" + obtain l2 r2 where r2:"subseq r2" and lr2:"((\i. f (r1 (r2 i)) $ k) ---> l2) sequentially" using bounded_imp_convergent_subsequence[OF s' f'] unfolding o_def by auto - def r \ "r1 \ r2" have r:"\m n. m < n \ r m < r n" unfolding r_def o_def using r1 and r2 by auto + def r \ "r1 \ r2" have r:"subseq r" + using r1 and r2 unfolding r_def o_def subseq_def by auto moreover def l \ "(\ i. if i = k then l2 else l1$i)::'a^'n" { fix e::real assume "e>0" from lr1 `e>0` have N1:"eventually (\n. \i\d. dist (f (r1 n) $ i) (l1 $ i) < e) sequentially" by blast from lr2 `e>0` have N2:"eventually (\n. dist (f (r1 (r2 n)) $ k) l2 < e) sequentially" by (rule tendstoD) from r2 N1 have N1': "eventually (\n. \i\d. dist (f (r1 (r2 n)) $ i) (l1 $ i) < e) sequentially" - by (rule eventually_subsequence) + by (rule eventually_subseq) have "eventually (\n. \i\(insert k d). dist (f (r n) $ i) (l $ i) < e) sequentially" using N1' N2 by (rule eventually_elim2, simp add: l_def r_def) } @@ -2375,7 +2369,7 @@ proof fix s :: "('a ^ 'b) set" and f :: "nat \ 'a ^ 'b" assume s: "bounded s" and f: "\n. f n \ s" - then obtain l r where r: "\n m::nat. m < n --> r m < r n" + then obtain l r where r: "subseq r" and l: "\e>0. eventually (\n. \i\UNIV. dist (f (r n) $ i) (l $ i) < e) sequentially" using compact_lemma [OF s f] by blast let ?d = "UNIV::'b set" @@ -2396,7 +2390,55 @@ by (rule eventually_elim1) } hence *:"((f \ r) ---> l) sequentially" unfolding o_def tendsto_iff by simp - with r show "\l r. (\m n. m < n \ r m < r n) \ ((f \ r) ---> l) sequentially" by auto + with r show "\l r. subseq r \ ((f \ r) ---> l) sequentially" by auto +qed + +lemma bounded_fst: "bounded s \ bounded (fst ` s)" +unfolding bounded_def +apply clarify +apply (rule_tac x="a" in exI) +apply (rule_tac x="e" in exI) +apply clarsimp +apply (drule (1) bspec) +apply (simp add: dist_Pair_Pair) +apply (erule order_trans [OF real_sqrt_sum_squares_ge1]) +done + +lemma bounded_snd: "bounded s \ bounded (snd ` s)" +unfolding bounded_def +apply clarify +apply (rule_tac x="b" in exI) +apply (rule_tac x="e" in exI) +apply clarsimp +apply (drule (1) bspec) +apply (simp add: dist_Pair_Pair) +apply (erule order_trans [OF real_sqrt_sum_squares_ge2]) +done + +instance "*" :: (heine_borel, heine_borel) heine_borel +proof + fix s :: "('a * 'b) set" and f :: "nat \ 'a * 'b" + assume s: "bounded s" and f: "\n. f n \ s" + from s have s1: "bounded (fst ` s)" by (rule bounded_fst) + from f have f1: "\n. fst (f n) \ fst ` s" by simp + obtain l1 r1 where r1: "subseq r1" + and l1: "((\n. fst (f (r1 n))) ---> l1) sequentially" + using bounded_imp_convergent_subsequence [OF s1 f1] + unfolding o_def by fast + from s have s2: "bounded (snd ` s)" by (rule bounded_snd) + from f have f2: "\n. snd (f (r1 n)) \ snd ` s" by simp + obtain l2 r2 where r2: "subseq r2" + and l2: "((\n. snd (f (r1 (r2 n)))) ---> l2) sequentially" + using bounded_imp_convergent_subsequence [OF s2 f2] + unfolding o_def by fast + have l1': "((\n. fst (f (r1 (r2 n)))) ---> l1) sequentially" + using lim_subseq [OF r2 l1] unfolding o_def . + have l: "((f \ (r1 \ r2)) ---> (l1, l2)) sequentially" + using tendsto_Pair [OF l1' l2] unfolding o_def by simp + have r: "subseq (r1 \ r2)" + using r1 r2 unfolding subseq_def by simp + show "\l r. subseq r \ ((f \ r) ---> l) sequentially" + using l r by fast qed subsection{* Completeness. *} @@ -2461,14 +2503,9 @@ lemma compact_imp_complete: assumes "compact s" shows "complete s" proof- { fix f assume as: "(\n::nat. f n \ s)" "Cauchy f" - from as(1) obtain l r where lr: "l\s" "(\m n. m < n \ r m < r n)" "((f \ r) ---> l) sequentially" using assms unfolding compact_def by blast - - { fix n :: nat have lr':"n \ r n" - proof (induct n) - show "0 \ r 0" using lr(2) by blast - next fix na assume "na \ r na" moreover have "na < Suc na \ r na < r (Suc na)" using lr(2) by blast - ultimately show "Suc na \ r (Suc na)" by auto - qed } note lr' = this + from as(1) obtain l r where lr: "l\s" "subseq r" "((f \ r) ---> l) sequentially" using assms unfolding compact_def by blast + + note lr' = subseq_bigger [OF lr(2)] { fix e::real assume "e>0" from as(2) obtain N where N:"\m n. N \ m \ N \ n \ dist (f m) (f n) < e/2" unfolding cauchy_def using `e>0` apply (erule_tac x="e/2" in allE) by auto @@ -2575,12 +2612,12 @@ thus "x n \ s \ (\m dist (x m) (x n) < e)" unfolding Q_def by auto qed } hence "\n::nat. x n \ s" and x:"\n. \m < n. \ (dist (x m) (x n) < e)" by blast+ - then obtain l r where "l\s" and r:"\m n. m < n \ r m < r n" and "((x \ r) ---> l) sequentially" using assms(1)[unfolded compact_def, THEN spec[where x=x]] by auto + then obtain l r where "l\s" and r:"subseq r" and "((x \ r) ---> l) sequentially" using assms(1)[unfolded compact_def, THEN spec[where x=x]] by auto from this(3) have "Cauchy (x \ r)" using convergent_imp_cauchy by auto then obtain N::nat where N:"\m n. N \ m \ N \ n \ dist ((x \ r) m) ((x \ r) n) < e" unfolding cauchy_def using `e>0` by auto show False using N[THEN spec[where x=N], THEN spec[where x="N+1"]] - using r[THEN spec[where x=N], THEN spec[where x="N+1"]] + using r[unfolded subseq_def, THEN spec[where x=N], THEN spec[where x="N+1"]] using x[THEN spec[where x="r (N+1)"], THEN spec[where x="r (N)"]] by auto qed @@ -2599,7 +2636,7 @@ then obtain f where f:"\n::nat. f n \ s \ (\xa\t. \ ball (f n) (inverse (real (n + 1))) \ xa)" using choice[of "\n::nat. \x. x\s \ (\xa\t. \ ball x (inverse (real (n + 1))) \ xa)"] by auto - then obtain l r where l:"l\s" and r:"\m n. m < n \ r m < r n" and lr:"((f \ r) ---> l) sequentially" + then obtain l r where l:"l\s" and r:"subseq r" and lr:"((f \ r) ---> l) sequentially" using assms(1)[unfolded compact_def, THEN spec[where x=f]] by auto obtain b where "l\b" "b\t" using assms(2) and l by auto @@ -2612,7 +2649,7 @@ obtain N2::nat where N2:"N2>0" "inverse (real N2) < e /2" using real_arch_inv[of "e/2"] and `e>0` by auto have N2':"inverse (real (r (N1 + N2) +1 )) < e/2" apply(rule order_less_trans) apply(rule less_imp_inverse_less) using N2 - using monotone_bigger[OF r, of "N1 + N2"] by auto + using subseq_bigger[OF r, of "N1 + N2"] by auto def x \ "(f (r (N1 + N2)))" have x:"\ ball x (inverse (real (r (N1 + N2) + 1))) \ b" unfolding x_def @@ -2926,7 +2963,7 @@ by blast lemma compact_sing [simp]: "compact {a}" - unfolding compact_def o_def + unfolding compact_def o_def subseq_def by (auto simp add: tendsto_const) lemma compact_cball[simp]: @@ -2987,7 +3024,7 @@ from assms(2) obtain x where x:"\n::nat. x n \ s n" using choice[of "\n x. x\ s n"] by auto from assms(4,1) have *:"compact (s 0)" using bounded_closed_imp_compact[of "s 0"] by auto - then obtain l r where lr:"l\s 0" "\m n. m < n \ r m < r n" "((x \ r) ---> l) sequentially" + then obtain l r where lr:"l\s 0" "subseq r" "((x \ r) ---> l) sequentially" unfolding compact_def apply(erule_tac x=x in allE) using x using assms(3) by blast { fix n::nat @@ -2995,7 +3032,7 @@ with lr(3) obtain N where N:"\m\N. dist ((x \ r) m) l < e" unfolding Lim_sequentially by auto hence "dist ((x \ r) (max N n)) l < e" by auto moreover - have "r (max N n) \ n" using lr(2) using monotone_bigger[of r "max N n"] by auto + have "r (max N n) \ n" using lr(2) using subseq_bigger[of r "max N n"] by auto hence "(x \ r) (max N n) \ s n" using x apply(erule_tac x=n in allE) using x apply(erule_tac x="r (max N n)" in allE) @@ -3701,13 +3738,11 @@ qed lemma continuous_open_preimage_univ: - fixes f :: "real ^ _ \ real ^ _" (* FIXME: generalize *) - shows "\x. continuous (at x) f \ open s \ open {x. f x \ s}" + "\x. continuous (at x) f \ open s \ open {x. f x \ s}" using continuous_open_preimage[of UNIV f s] open_UNIV continuous_at_imp_continuous_on by auto lemma continuous_closed_preimage_univ: - fixes f :: "real ^ _ \ real ^ _" (* FIXME: generalize *) - shows "(\x. continuous (at x) f) \ closed s ==> closed {x. f x \ s}" + "(\x. continuous (at x) f) \ closed s ==> closed {x. f x \ s}" using continuous_closed_preimage[of UNIV f s] closed_UNIV continuous_at_imp_continuous_on by auto text{* Equality of continuous functions on closure and related results. *} @@ -3830,7 +3865,7 @@ unfolding vector_sneg_minus1 by auto lemma open_translation: - fixes s :: "(real ^ _) set" (* FIXME: generalize *) + fixes s :: "'a::real_normed_vector set" assumes "open s" shows "open((\x. a + x) ` s)" proof- { fix x have "continuous (at x) (\x. x - a)" using continuous_sub[of "at x" "\x. x" "\x. a"] continuous_at_id[of x] continuous_const[of "at x" a] by auto } @@ -3875,13 +3910,13 @@ proof- { fix x assume x:"\n::nat. x n \ f ` s" then obtain y where y:"\n. y n \ s \ x n = f (y n)" unfolding image_iff Bex_def using choice[of "\n xa. xa \ s \ x n = f xa"] by auto - then obtain l r where "l\s" and r:"\m n. m < n \ r m < r n" and lr:"((y \ r) ---> l) sequentially" using assms(2)[unfolded compact_def, THEN spec[where x=y]] by auto + then obtain l r where "l\s" and r:"subseq r" and lr:"((y \ r) ---> l) sequentially" using assms(2)[unfolded compact_def, THEN spec[where x=y]] by auto { fix e::real assume "e>0" then obtain d where "d>0" and d:"\x'\s. dist x' l < d \ dist (f x') (f l) < e" using assms(1)[unfolded continuous_on_def, THEN bspec[where x=l], OF `l\s`] by auto then obtain N::nat where N:"\n\N. dist ((y \ r) n) l < d" using lr[unfolded Lim_sequentially, THEN spec[where x=d]] by auto { fix n::nat assume "n\N" hence "dist ((x \ r) n) (f l) < e" using N[THEN spec[where x=n]] d[THEN bspec[where x="y (r n)"]] y[THEN spec[where x="r n"]] by auto } hence "\N. \n\N. dist ((x \ r) n) (f l) < e" by auto } - hence "\l\f ` s. \r. (\m n. m < n \ r m < r n) \ ((x \ r) ---> l) sequentially" unfolding Lim_sequentially using r lr `l\s` by auto } + hence "\l\f ` s. \r. subseq r \ ((x \ r) ---> l) sequentially" unfolding Lim_sequentially using r lr `l\s` by auto } thus ?thesis unfolding compact_def by auto qed @@ -3938,7 +3973,8 @@ text{* Continuity of inverse function on compact domain. *} lemma continuous_on_inverse: - fixes f :: "real ^ _ \ real ^ _" + fixes f :: "'a::heine_borel \ 'b::heine_borel" + (* TODO: can this be generalized more? *) assumes "continuous_on s f" "compact s" "\x \ s. g (f x) = x" shows "continuous_on (f ` s) g" proof- @@ -4050,68 +4086,52 @@ subsection{* Topological stuff lifted from and dropped to R *} -lemma open_vec1: - fixes s :: "real set" shows - "open(vec1 ` s) \ - (\x \ s. \e>0. \x'. abs(x' - x) < e --> x' \ s)" (is "?lhs = ?rhs") - unfolding open_dist apply simp unfolding forall_vec1 dist_vec1 vec1_in_image_vec1 by simp - -lemma islimpt_approachable_vec1: +lemma open_real: fixes s :: "real set" shows - "(vec1 x) islimpt (vec1 ` s) \ - (\e>0. \x'\ s. x' \ x \ abs(x' - x) < e)" - by (auto simp add: islimpt_approachable dist_vec1 vec1_eq) - -lemma closed_vec1: - fixes s :: "real set" shows - "closed (vec1 ` s) \ + "open s \ + (\x \ s. \e>0. \x'. abs(x' - x) < e --> x' \ s)" (is "?lhs = ?rhs") + unfolding open_dist dist_norm by simp + +lemma islimpt_approachable_real: + fixes s :: "real set" + shows "x islimpt s \ (\e>0. \x'\ s. x' \ x \ abs(x' - x) < e)" + unfolding islimpt_approachable dist_norm by simp + +lemma closed_real: + fixes s :: "real set" + shows "closed s \ (\x. (\e>0. \x' \ s. x' \ x \ abs(x' - x) < e) --> x \ s)" - unfolding closed_limpt islimpt_approachable forall_vec1 apply simp - unfolding dist_vec1 vec1_in_image_vec1 abs_minus_commute by auto - -lemma continuous_at_vec1_range: - fixes f :: "real ^ _ \ real" - shows "continuous (at x) (vec1 o f) \ (\e>0. \d>0. + unfolding closed_limpt islimpt_approachable dist_norm by simp + +lemma continuous_at_real_range: + fixes f :: "'a::real_normed_vector \ real" + shows "continuous (at x) f \ (\e>0. \d>0. \x'. norm(x' - x) < d --> abs(f x' - f x) < e)" - unfolding continuous_at unfolding Lim_at apply simp unfolding dist_vec1 unfolding dist_nz[THEN sym] unfolding dist_norm apply auto + unfolding continuous_at unfolding Lim_at + unfolding dist_nz[THEN sym] unfolding dist_norm apply auto apply(erule_tac x=e in allE) apply auto apply (rule_tac x=d in exI) apply auto apply (erule_tac x=x' in allE) apply auto apply(erule_tac x=e in allE) by auto -lemma continuous_on_vec1_range: +lemma continuous_on_real_range: fixes f :: "'a::real_normed_vector \ real" - shows "continuous_on s (vec1 o f) \ (\x \ s. \e>0. \d>0. (\x' \ s. norm(x' - x) < d --> abs(f x' - f x) < e))" - unfolding continuous_on_def apply (simp del: dist_commute) unfolding dist_vec1 unfolding dist_norm .. - -lemma continuous_at_vec1_norm: - fixes x :: "real ^ _" - shows "continuous (at x) (vec1 o norm)" - unfolding continuous_at_vec1_range using real_abs_sub_norm order_le_less_trans by blast - -lemma continuous_on_vec1_norm: - fixes s :: "(real ^ _) set" - shows "continuous_on s (vec1 o norm)" -unfolding continuous_on_vec1_range norm_vec1[THEN sym] by (metis norm_vec1 order_le_less_trans real_abs_sub_norm) - -lemma continuous_at_vec1_component: - shows "continuous (at (a::real^'a::finite)) (\ x. vec1(x$i))" -proof- - { fix e::real and x assume "0 < dist x a" "dist x a < e" "e>0" - hence "\x $ i - a $ i\ < e" using component_le_norm[of "x - a" i] unfolding dist_norm by auto } - thus ?thesis unfolding continuous_at tendsto_iff eventually_at dist_vec1 by auto -qed - -lemma continuous_on_vec1_component: - shows "continuous_on s (\ x::real^'a::finite. vec1(x$i))" -proof- - { fix e::real and x xa assume "x\s" "e>0" "xa\s" "0 < norm (xa - x) \ norm (xa - x) < e" - hence "\xa $ i - x $ i\ < e" using component_le_norm[of "xa - x" i] by auto } - thus ?thesis unfolding continuous_on Lim_within dist_vec1 unfolding dist_norm by auto -qed - -lemma continuous_at_vec1_infnorm: - "continuous (at x) (vec1 o infnorm)" - unfolding continuous_at Lim_at o_def unfolding dist_vec1 unfolding dist_norm + shows "continuous_on s f \ (\x \ s. \e>0. \d>0. (\x' \ s. norm(x' - x) < d --> abs(f x' - f x) < e))" + unfolding continuous_on_def dist_norm by simp + +lemma continuous_at_norm: "continuous (at x) norm" + unfolding continuous_at by (intro tendsto_intros) + +lemma continuous_on_norm: "continuous_on s norm" +unfolding continuous_on by (intro ballI tendsto_intros) + +lemma continuous_at_component: "continuous (at a) (\x. x $ i)" +unfolding continuous_at by (intro tendsto_intros) + +lemma continuous_on_component: "continuous_on s (\x. x $ i)" +unfolding continuous_on by (intro ballI tendsto_intros) + +lemma continuous_at_infnorm: "continuous (at x) infnorm" + unfolding continuous_at Lim_at o_def unfolding dist_norm apply auto apply (rule_tac x=e in exI) apply auto using order_trans[OF real_abs_sub_infnorm infnorm_le_norm, of _ x] by (metis xt1(7)) @@ -4119,23 +4139,23 @@ lemma compact_attains_sup: fixes s :: "real set" - assumes "compact (vec1 ` s)" "s \ {}" + assumes "compact s" "s \ {}" shows "\x \ s. \y \ s. y \ x" proof- - from assms(1) have a:"bounded (vec1 ` s)" "closed (vec1 ` s)" unfolding compact_eq_bounded_closed by auto + from assms(1) have a:"bounded s" "closed s" unfolding compact_eq_bounded_closed by auto { fix e::real assume as: "\x\s. x \ rsup s" "rsup s \ s" "0 < e" "\x'\s. x' = rsup s \ \ rsup s - x' < e" have "isLub UNIV s (rsup s)" using rsup[OF assms(2)] unfolding setle_def using as(1) by auto moreover have "isUb UNIV s (rsup s - e)" unfolding isUb_def unfolding setle_def using as(4,2) by auto ultimately have False using isLub_le_isUb[of UNIV s "rsup s" "rsup s - e"] using `e>0` by auto } - thus ?thesis using bounded_has_rsup(1)[OF a(1) assms(2)] using a(2)[unfolded closed_vec1, THEN spec[where x="rsup s"]] + thus ?thesis using bounded_has_rsup(1)[OF a(1) assms(2)] using a(2)[unfolded closed_real, THEN spec[where x="rsup s"]] apply(rule_tac x="rsup s" in bexI) by auto qed lemma compact_attains_inf: fixes s :: "real set" - assumes "compact (vec1 ` s)" "s \ {}" shows "\x \ s. \y \ s. x \ y" + assumes "compact s" "s \ {}" shows "\x \ s. \y \ s. x \ y" proof- - from assms(1) have a:"bounded (vec1 ` s)" "closed (vec1 ` s)" unfolding compact_eq_bounded_closed by auto + from assms(1) have a:"bounded s" "closed s" unfolding compact_eq_bounded_closed by auto { fix e::real assume as: "\x\s. x \ rinf s" "rinf s \ s" "0 < e" "\x'\s. x' = rinf s \ \ abs (x' - rinf s) < e" have "isGlb UNIV s (rinf s)" using rinf[OF assms(2)] unfolding setge_def using as(1) by auto @@ -4145,43 +4165,40 @@ have "rinf s + e \ x" using as(4)[THEN bspec[where x=x]] using as(2) `x\s` unfolding * by auto } hence "isLb UNIV s (rinf s + e)" unfolding isLb_def and setge_def by auto ultimately have False using isGlb_le_isLb[of UNIV s "rinf s" "rinf s + e"] using `e>0` by auto } - thus ?thesis using bounded_has_rinf(1)[OF a(1) assms(2)] using a(2)[unfolded closed_vec1, THEN spec[where x="rinf s"]] + thus ?thesis using bounded_has_rinf(1)[OF a(1) assms(2)] using a(2)[unfolded closed_real, THEN spec[where x="rinf s"]] apply(rule_tac x="rinf s" in bexI) by auto qed lemma continuous_attains_sup: fixes f :: "'a::metric_space \ real" - shows "compact s \ s \ {} \ continuous_on s (vec1 o f) + shows "compact s \ s \ {} \ continuous_on s f ==> (\x \ s. \y \ s. f y \ f x)" using compact_attains_sup[of "f ` s"] - using compact_continuous_image[of s "vec1 \ f"] unfolding image_compose by auto + using compact_continuous_image[of s f] by auto lemma continuous_attains_inf: fixes f :: "'a::metric_space \ real" - shows "compact s \ s \ {} \ continuous_on s (vec1 o f) + shows "compact s \ s \ {} \ continuous_on s f \ (\x \ s. \y \ s. f x \ f y)" using compact_attains_inf[of "f ` s"] - using compact_continuous_image[of s "vec1 \ f"] unfolding image_compose by auto + using compact_continuous_image[of s f] by auto lemma distance_attains_sup: - fixes s :: "(real ^ _) set" assumes "compact s" "s \ {}" shows "\x \ s. \y \ s. dist a y \ dist a x" -proof- - { fix x assume "x\s" fix e::real assume "e>0" - { fix x' assume "x'\s" and as:"norm (x' - x) < e" - hence "\norm (x' - a) - norm (x - a)\ < e" - using real_abs_sub_norm[of "x' - a" "x - a"] by auto } - hence "\d>0. \x'\s. norm (x' - x) < d \ \dist x' a - dist x a\ < e" using `e>0` unfolding dist_norm by auto } - thus ?thesis using assms - using continuous_attains_sup[of s "\x. dist a x"] - unfolding continuous_on_vec1_range by (auto simp add: dist_commute) +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 Lim_at_within Lim_ident_at) + } + thus "continuous_on s (dist a)" + unfolding continuous_on .. qed text{* For *minimal* distance, we only need closure, not compactness. *} lemma distance_attains_inf: - fixes a :: "real ^ _" (* FIXME: generalize *) + fixes a :: "'a::heine_borel" assumes "closed s" "s \ {}" shows "\x \ s. \y \ s. dist a x \ dist a y" proof- @@ -4192,54 +4209,60 @@ moreover { fix x assume "x\?B" fix e::real assume "e>0" - { fix x' assume "x'\?B" and as:"norm (x' - x) < e" - hence "\norm (x' - a) - norm (x - a)\ < e" - using real_abs_sub_norm[of "x' - a" "x - a"] by auto } - hence "\d>0. \x'\?B. norm (x' - x) < d \ \dist x' a - dist x a\ < e" using `e>0` unfolding dist_norm by auto } - hence "continuous_on (cball a (dist b a) \ s) (vec1 \ dist a)" unfolding continuous_on_vec1_range - by (auto simp add: dist_commute) - moreover have "compact ?B" using compact_cball[of a "dist b a"] unfolding compact_eq_bounded_closed using bounded_Int and closed_Int and assms(1) by auto - ultimately obtain x where "x\cball a (dist b a) \ s" "\y\cball a (dist b a) \ s. dist a x \ dist a y" using continuous_attains_inf[of ?B "dist a"] by fastsimp + { fix x' assume "x'\?B" and as:"dist x' x < e" + from as have "\dist a x' - dist a x\ < e" + unfolding abs_less_iff minus_diff_eq + using dist_triangle2 [of a x' x] + using dist_triangle [of a x x'] + by arith + } + hence "\d>0. \x'\?B. dist x' x < d \ \dist a x' - dist a x\ < e" + using `e>0` by auto + } + hence "continuous_on (cball a (dist b a) \ s) (dist a)" + unfolding continuous_on Lim_within dist_norm real_norm_def + by fast + moreover have "compact ?B" + using compact_cball[of a "dist b a"] + unfolding compact_eq_bounded_closed + using bounded_Int and closed_Int and assms(1) by auto + ultimately obtain x where "x\cball a (dist b a) \ s" "\y\cball a (dist b a) \ s. dist a x \ dist a y" + using continuous_attains_inf[of ?B "dist a"] by fastsimp thus ?thesis by fastsimp qed subsection{* We can now extend limit compositions to consider the scalar multiplier. *} -lemma Lim_mul: +lemma Lim_mul [tendsto_intros]: fixes f :: "'a \ real ^ _" - assumes "((vec1 o c) ---> vec1 d) net" "(f ---> l) net" + assumes "(c ---> d) net" "(f ---> l) net" shows "((\x. c(x) *s f x) ---> (d *s l)) net" -proof- - have "bilinear (\x. op *s (dest_vec1 (x::real^1)))" unfolding bilinear_def linear_def - unfolding dest_vec1_add dest_vec1_cmul - apply vector apply auto unfolding semiring_class.right_distrib semiring_class.left_distrib by auto - thus ?thesis using Lim_bilinear[OF assms, of "\x y. (dest_vec1 x) *s y"] by auto -qed + unfolding smult_conv_scaleR using assms by (rule scaleR.tendsto) lemma Lim_vmul: fixes c :: "'a \ real" - shows "((vec1 o c) ---> vec1 d) net ==> ((\x. c(x) *s v) ---> d *s v) net" + shows "(c ---> d) net ==> ((\x. c(x) *s v) ---> d *s v) net" using Lim_mul[of c d net "\x. v" v] using Lim_const[of v] by auto lemma continuous_vmul: fixes c :: "'a::metric_space \ real" - shows "continuous net (vec1 o c) ==> continuous net (\x. c(x) *s v)" + shows "continuous net c ==> continuous net (\x. c(x) *s v)" unfolding continuous_def using Lim_vmul[of c] by auto lemma continuous_mul: fixes c :: "'a::metric_space \ real" - shows "continuous net (vec1 o c) \ continuous net f + shows "continuous net c \ continuous net f ==> continuous net (\x. c(x) *s f x) " unfolding continuous_def using Lim_mul[of c] by auto lemma continuous_on_vmul: fixes c :: "'a::metric_space \ real" - shows "continuous_on s (vec1 o c) ==> continuous_on s (\x. c(x) *s v)" + shows "continuous_on s c ==> continuous_on s (\x. c(x) *s v)" unfolding continuous_on_eq_continuous_within using continuous_vmul[of _ c] by auto lemma continuous_on_mul: fixes c :: "'a::metric_space \ real" - shows "continuous_on s (vec1 o c) \ continuous_on s f + shows "continuous_on s c \ continuous_on s f ==> continuous_on s (\x. c(x) *s f x)" unfolding continuous_on_eq_continuous_within using continuous_mul[of _ c] by auto @@ -4247,59 +4270,27 @@ lemma Lim_inv: fixes f :: "'a \ real" - assumes "((vec1 o f) ---> vec1 l) (net::'a net)" "l \ 0" - shows "((vec1 o inverse o f) ---> vec1(inverse l)) net" -proof - - { fix e::real assume "e>0" - let ?d = "min (\l\ / 2) (l\ * e / 2)" - have "0 < ?d" using `l\0` `e>0` mult_pos_pos[of "l^2" "e/2"] by auto - with assms(1) have "eventually (\x. dist ((vec1 o f) x) (vec1 l) < ?d) net" - by (rule tendstoD) - moreover - { fix x assume "dist ((vec1 o f) x) (vec1 l) < ?d" - hence *:"\f x - l\ < min (\l\ / 2) (l\ * e / 2)" unfolding o_def dist_vec1 by auto - hence fx0:"f x \ 0" using `l \ 0` by auto - hence fxl0: "(f x) * l \ 0" using `l \ 0` by auto - from * have **:"\f x - l\ < l\ * e / 2" by auto - have "\f x\ * 2 \ \l\" using * by (auto simp del: less_divide_eq_number_of1) - hence "\f x\ * 2 * \l\ \ \l\ * \l\" unfolding mult_le_cancel_right by auto - hence "\f x * l\ * 2 \ \l\^2" unfolding real_mult_commute and power2_eq_square by auto - hence ***:"inverse \f x * l\ \ inverse (l\ / 2)" using fxl0 - using le_imp_inverse_le[of "l^2 / 2" "\f x * l\"] by auto - - have "dist ((vec1 \ inverse \ f) x) (vec1 (inverse l)) < e" unfolding o_def unfolding dist_vec1 - unfolding inverse_diff_inverse[OF fx0 `l\0`] apply simp - unfolding mult_commute[of "inverse (f x)"] - unfolding real_divide_def[THEN sym] - unfolding divide_divide_eq_left - unfolding nonzero_abs_divide[OF fxl0] - using mult_less_le_imp_less[OF **, of "inverse \f x * l\", of "inverse (l^2 / 2)"] using *** using fx0 `l\0` - unfolding inverse_eq_divide using `e>0` by auto - } - ultimately - have "eventually (\x. dist ((vec1 o inverse o f) x) (vec1(inverse l)) < e) net" - by (auto elim: eventually_rev_mono) - } - thus ?thesis unfolding tendsto_iff by auto -qed + assumes "(f ---> l) (net::'a net)" "l \ 0" + shows "((inverse o f) ---> inverse l) net" + unfolding o_def using assms by (rule tendsto_inverse) lemma continuous_inv: fixes f :: "'a::metric_space \ real" - shows "continuous net (vec1 o f) \ f(netlimit net) \ 0 - ==> continuous net (vec1 o inverse o f)" + shows "continuous net f \ f(netlimit net) \ 0 + ==> continuous net (inverse o f)" unfolding continuous_def using Lim_inv by auto lemma continuous_at_within_inv: - fixes f :: "real ^ _ \ real" - assumes "continuous (at a within s) (vec1 o f)" "f a \ 0" - shows "continuous (at a within s) (vec1 o inverse o f)" - using assms unfolding continuous_within o_apply - by (rule Lim_inv) + fixes f :: "'a::metric_space \ 'b::real_normed_field" + assumes "continuous (at a within s) f" "f a \ 0" + shows "continuous (at a within s) (inverse o f)" + using assms unfolding continuous_within o_def + by (intro tendsto_intros) lemma continuous_at_inv: - fixes f :: "real ^ _ \ real" - shows "continuous (at a) (vec1 o f) \ f a \ 0 - ==> continuous (at a) (vec1 o inverse o f) " + fixes f :: "'a::metric_space \ 'b::real_normed_field" + shows "continuous (at a) f \ f a \ 0 + ==> continuous (at a) (inverse o f) " using within_UNIV[THEN sym, of "at a"] using continuous_at_within_inv[of a UNIV] by auto subsection{* Preservation properties for pasted sets. *} @@ -4316,6 +4307,16 @@ thus ?thesis unfolding bounded_iff by auto qed +lemma bounded_Times: + assumes "bounded s" "bounded t" shows "bounded (s \ t)" +proof- + obtain x y a b where "\z\s. dist x z \ a" "\z\t. dist y z \ b" + using assms [unfolded bounded_def] by auto + then have "\z\s \ t. dist (x, y) z \ sqrt (a\ + b\)" + by (auto simp add: dist_Pair_Pair real_sqrt_le_mono add_mono power_mono) + thus ?thesis unfolding bounded_any_center [where a="(x, y)"] by auto +qed + lemma closed_pastecart: fixes s :: "(real ^ 'a::finite) set" (* FIXME: generalize *) assumes "closed s" "closed t" @@ -4343,6 +4344,26 @@ shows "compact s \ compact t ==> compact {pastecart x y | x y . x \ s \ y \ t}" unfolding compact_eq_bounded_closed using bounded_pastecart[of s t] closed_pastecart[of s t] by auto +lemma mem_Times_iff: "x \ A \ B \ fst x \ A \ snd x \ B" +by (induct x) simp + +lemma compact_Times: "compact s \ compact t \ compact (s \ t)" +unfolding compact_def +apply clarify +apply (drule_tac x="fst \ f" in spec) +apply (drule mp, simp add: mem_Times_iff) +apply (clarify, rename_tac l1 r1) +apply (drule_tac x="snd \ f \ r1" in spec) +apply (drule mp, simp add: mem_Times_iff) +apply (clarify, rename_tac l2 r2) +apply (rule_tac x="(l1, l2)" in rev_bexI, simp) +apply (rule_tac x="r1 \ r2" in exI) +apply (rule conjI, simp add: subseq_def) +apply (drule_tac r=r2 in lim_subseq [COMP swap_prems_rl], assumption) +apply (drule (1) tendsto_Pair) back +apply (simp add: o_def) +done + text{* Hence some useful properties follow quite easily. *} lemma compact_scaleR_image: @@ -4366,30 +4387,27 @@ using compact_scaleR_image [OF assms, of "- 1"] by auto lemma compact_sums: - fixes s t :: "(real ^ _) set" + fixes s t :: "'a::real_normed_vector set" assumes "compact s" "compact t" shows "compact {x + y | x y. x \ s \ y \ t}" proof- - have *:"{x + y | x y. x \ s \ y \ t} =(\z. fstcart z + sndcart z) ` {pastecart x y | x y. x \ s \ y \ t}" - apply auto unfolding image_iff apply(rule_tac x="pastecart xa y" in bexI) unfolding fstcart_pastecart sndcart_pastecart by auto - have "linear (\z::real^('a + 'a). fstcart z + sndcart z)" unfolding linear_def - unfolding fstcart_add sndcart_add apply auto - unfolding vector_add_ldistrib fstcart_cmul[THEN sym] sndcart_cmul[THEN sym] by auto - hence "continuous_on {pastecart x y |x y. x \ s \ y \ t} (\z. fstcart z + sndcart z)" - using continuous_at_imp_continuous_on linear_continuous_at by auto - thus ?thesis unfolding * using compact_continuous_image compact_pastecart[OF assms] by auto + have *:"{x + y | x y. x \ s \ y \ t} = (\z. fst z + snd z) ` (s \ t)" + apply auto unfolding image_iff apply(rule_tac x="(xa, y)" in bexI) by auto + have "continuous_on (s \ t) (\z. fst z + snd z)" + unfolding continuous_on by (rule ballI) (intro tendsto_intros) + thus ?thesis unfolding * using compact_continuous_image compact_Times [OF assms] by auto qed lemma compact_differences: - fixes s t :: "(real ^ 'a::finite) set" + fixes s t :: "'a::real_normed_vector set" assumes "compact s" "compact t" shows "compact {x - y | x y. x \ s \ y \ t}" proof- - have "{x - y | x y::real^'a. x\s \ y \ t} = {x + y | x y. x \ s \ y \ (uminus ` t)}" + have "{x - y | x y. x\s \ y \ t} = {x + y | x y. x \ s \ y \ (uminus ` t)}" apply auto apply(rule_tac x= xa in exI) apply auto apply(rule_tac x=xa in exI) by auto thus ?thesis using compact_sums[OF assms(1) compact_negations[OF assms(2)]] by auto qed lemma compact_translation: - fixes s :: "(real ^ _) set" + fixes s :: "'a::real_normed_vector set" assumes "compact s" shows "compact ((\x. a + x) ` s)" proof- have "{x + y |x y. x \ s \ y \ {a}} = (\x. a + x) ` s" by auto @@ -4407,14 +4425,14 @@ text{* Hence we get the following. *} lemma compact_sup_maxdistance: - fixes s :: "(real ^ _) set" + fixes s :: "'a::real_normed_vector set" assumes "compact s" "s \ {}" shows "\x\s. \y\s. \u\s. \v\s. norm(u - v) \ norm(x - y)" proof- have "{x - y | x y . x\s \ y\s} \ {}" using `s \ {}` by auto then obtain x where x:"x\{x - y |x y. x \ s \ y \ s}" "\y\{x - y |x y. x \ s \ y \ s}. norm y \ norm x" using compact_differences[OF assms(1) assms(1)] - using distance_attains_sup[unfolded dist_norm, of "{x - y | x y . x\s \ y\s}" 0] by(auto simp add: norm_minus_cancel) + using distance_attains_sup[where 'a="'a", unfolded dist_norm, of "{x - y | x y . x\s \ y\s}" 0] by(auto simp add: norm_minus_cancel) from x(1) obtain a b where "a\s" "b\s" "x = a - b" by auto thus ?thesis using x(2)[unfolded `x = a - b`] by blast qed @@ -4458,11 +4476,11 @@ using diameter_bounded by blast lemma diameter_compact_attained: - fixes s :: "(real ^ _) set" + fixes s :: "'a::real_normed_vector set" assumes "compact s" "s \ {}" shows "\x\s. \y\s. (norm(x - y) = diameter s)" proof- - have b:"bounded s" using assms(1) compact_eq_bounded_closed by auto + have b:"bounded s" using assms(1) by (rule compact_imp_bounded) then obtain x y where xys:"x\s" "y\s" and xy:"\u\s. \v\s. norm (u - v) \ norm (x - y)" using compact_sup_maxdistance[OF assms] by auto hence "diameter s \ norm (x - y)" using rsup_le[of "{norm (x - y) |x y. x \ s \ y \ s}" "norm (x - y)"] unfolding setle_def and diameter_def by auto @@ -4523,10 +4541,10 @@ { fix x l assume as:"\n. x n \ ?S" "(x ---> l) sequentially" from as(1) obtain f where f:"\n. x n = fst (f n) + snd (f n)" "\n. fst (f n) \ s" "\n. snd (f n) \ t" using choice[of "\n y. x n = (fst y) + (snd y) \ fst y \ s \ snd y \ t"] by auto - obtain l' r where "l'\s" and r:"\m n. m < n \ r m < r n" and lr:"(((\n. fst (f n)) \ r) ---> l') sequentially" + obtain l' r where "l'\s" and r:"subseq r" and lr:"(((\n. fst (f n)) \ r) ---> l') sequentially" using assms(1)[unfolded compact_def, THEN spec[where x="\ n. fst (f n)"]] using f(2) by auto have "((\n. snd (f (r n))) ---> l - l') sequentially" - using Lim_sub[OF lim_subsequence[OF r as(2)] lr] and f(1) unfolding o_def by auto + using Lim_sub[OF lim_subseq[OF r as(2)] lr] and f(1) unfolding o_def by auto hence "l - l' \ t" using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\ n. snd (f (r n))"], THEN spec[where x="l - l'"]] using f(3) by auto @@ -4600,7 +4618,7 @@ subsection{* Separation between points and sets. *} lemma separate_point_closed: - fixes s :: "(real ^ _) set" (* FIXME: generalize *) + fixes s :: "'a::heine_borel set" shows "closed s \ a \ s ==> (\d>0. \x\s. d \ dist a x)" proof(cases "s = {}") case True @@ -4613,7 +4631,8 @@ qed lemma separate_compact_closed: - fixes s t :: "(real ^ _) set" + fixes s t :: "'a::{heine_borel, real_normed_vector} set" + (* TODO: does this generalize to heine_borel? *) assumes "compact s" and "closed t" and "s \ t = {}" shows "\d>0. \x\s. \y\t. d \ dist x y" proof- @@ -4629,7 +4648,7 @@ qed lemma separate_closed_compact: - fixes s t :: "(real ^ _) set" + fixes s t :: "'a::{heine_borel, real_normed_vector} set" assumes "closed s" and "compact t" and "s \ t = {}" shows "\d>0. \x\s. \y\t. d \ dist x y" proof- @@ -4965,8 +4984,8 @@ then obtain N::nat where "inverse (real (N + 1)) < e" by auto hence "\n\N. inverse (real n + 1) < e" by (auto, metis Suc_le_mono le_SucE less_imp_inverse_less nat_le_real_less order_less_trans real_of_nat_Suc real_of_nat_Suc_gt_zero) hence "\N::nat. \n\N. inverse (real n + 1) < e" by auto } - hence "((vec1 \ (\n. inverse (real n + 1))) ---> vec1 0) sequentially" - unfolding Lim_sequentially by(auto simp add: dist_vec1) + hence "((\n. inverse (real n + 1)) ---> 0) sequentially" + unfolding Lim_sequentially by(auto simp add: dist_norm) hence "(f ---> x) sequentially" unfolding f_def using Lim_add[OF Lim_const, of "\n::nat. (inverse (real n + 1)) *s ((1 / 2) *s (a + b) - x)" 0 sequentially x] using Lim_vmul[of "\n::nat. inverse (real n + 1)" 0 sequentially "((1 / 2) *s (a + b) - x)"] by auto } @@ -5320,7 +5339,7 @@ have "\ n. n\m \ dest_vec1 (s m) \ dest_vec1 (s n)" apply(induct_tac n) apply simp using assms(2) apply(erule_tac x="na" in allE) by(auto simp add: not_less_eq_eq) } hence "\m n. m \ n \ dest_vec1 (s m) \ dest_vec1 (s n)" by auto - then obtain l where "\e>0. \N. \n\N. \dest_vec1 (s n) - l\ < e" using convergent_bounded_monotone[OF a] by auto + then obtain l where "\e>0. \N. \n\N. \dest_vec1 (s n) - l\ < e" using convergent_bounded_monotone[OF a] unfolding monoseq_def by auto thus ?thesis unfolding Lim_sequentially apply(rule_tac x="vec1 l" in exI) unfolding dist_norm unfolding abs_dest_vec1 and dest_vec1_sub by auto qed @@ -5940,9 +5959,10 @@ subsection{* Edelstein fixed point theorem. *} lemma edelstein_fix: + fixes s :: "'a::real_normed_vector set" assumes s:"compact s" "s \ {}" and gs:"(g ` s) \ s" and dist:"\x\s. \y\s. x \ y \ dist (g x) (g y) < dist x y" - shows "\! x::real^'a::finite\s. g x = x" + shows "\! x\s. g x = x" proof(cases "\x\s. g x \ x") obtain x where "x\s" using s(2) by auto case False hence g:"\x\s. g x = x" by auto @@ -5985,26 +6005,23 @@ qed qed } note distf = this - def h \ "\n. pastecart (f n x) (f n y)" - let ?s2 = "{pastecart x y |x y. x \ s \ y \ s}" - obtain l r where "l\?s2" and r:"\m n. m < n \ r m < r n" and lr:"((h \ r) ---> l) sequentially" - using compact_pastecart[OF s(1) s(1), unfolded compact_def, THEN spec[where x=h]] unfolding h_def + def h \ "\n. (f n x, f n y)" + let ?s2 = "s \ s" + obtain l r where "l\?s2" and r:"subseq r" and lr:"((h \ r) ---> l) sequentially" + using compact_Times [OF s(1) s(1), unfolded compact_def, THEN spec[where x=h]] unfolding h_def using fs[OF `x\s`] and fs[OF `y\s`] by blast - def a \ "fstcart l" def b \ "sndcart l" - have lab:"l = pastecart a b" unfolding a_def b_def and pastecart_fst_snd by simp + def a \ "fst l" def b \ "snd l" + have lab:"l = (a, b)" unfolding a_def b_def by simp have [simp]:"a\s" "b\s" unfolding a_def b_def using `l\?s2` by auto - have "continuous_on (UNIV :: (real ^ _) set) fstcart" - and "continuous_on (UNIV :: (real ^ _) set) sndcart" - using linear_continuous_on using linear_fstcart and linear_sndcart by auto - hence lima:"((fstcart \ (h \ r)) ---> a) sequentially" and limb:"((sndcart \ (h \ r)) ---> b) sequentially" - unfolding atomize_conj unfolding continuous_on_sequentially - apply(erule_tac x="h \ r" in allE) apply(erule_tac x="h \ r" in allE) using lr - unfolding o_def and h_def a_def b_def by auto + have lima:"((fst \ (h \ r)) ---> a) sequentially" + and limb:"((snd \ (h \ r)) ---> b) sequentially" + using lr + unfolding o_def a_def b_def by (simp_all add: tendsto_intros) { fix n::nat - have *:"\fx fy (x::real^_) y. dist fx fy \ dist x y \ \ (dist (fx - fy) (a - b) < dist a b - dist x y)" unfolding dist_norm by norm - { fix x y ::"real^'a" + have *:"\fx fy (x::'a) y. dist fx fy \ dist x y \ \ (dist (fx - fy) (a - b) < dist a b - dist x y)" unfolding dist_norm by norm + { fix x y :: 'a have "dist (-x) (-y) = dist x y" unfolding dist_norm using norm_minus_cancel[of "x - y"] by (auto simp add: uminus_add_conv_diff) } note ** = this @@ -6021,7 +6038,7 @@ moreover have "dist (f (r (Na + Nb + n)) x - f (r (Na + Nb + n)) y) (a - b) \ dist a b - dist (f n x) (f n y)" using distf[of n "r (Na+Nb+n)", OF _ `x\s` `y\s`] - using monotone_bigger[OF r, of "Na+Nb+n"] + using subseq_bigger[OF r, of "Na+Nb+n"] using *[of "f (r (Na + Nb + n)) x" "f (r (Na + Nb + n)) y" "f n x" "f n y"] by auto ultimately have False by simp } @@ -6049,8 +6066,8 @@ have "dist y x < e \ dist (g y) (g x) < e" using dist by fastsimp } hence "continuous_on s g" unfolding continuous_on_def by auto - hence "((sndcart \ h \ r) ---> g a) sequentially" unfolding continuous_on_sequentially - apply (rule allE[where x="\n. (fstcart \ h \ r) n"]) apply (erule ballE[where x=a]) + hence "((snd \ h \ r) ---> g a) sequentially" unfolding continuous_on_sequentially + apply (rule allE[where x="\n. (fst \ h \ r) n"]) apply (erule ballE[where x=a]) using lima unfolding h_def o_def using fs[OF `x\s`] by (auto simp add: y_def) hence "g a = a" using Lim_unique[OF trivial_limit_sequentially limb, of "g a"] unfolding `a=b` and o_assoc by auto diff -r 86eeb9b7a4ba -r f9c35a72390a src/HOL/Limits.thy --- a/src/HOL/Limits.thy Fri Jun 12 00:45:28 2009 +0200 +++ b/src/HOL/Limits.thy Fri Jun 12 07:23:45 2009 +0200 @@ -358,6 +358,14 @@ where [code del]: "(f ---> l) net \ (\S. open S \ l \ S \ eventually (\x. f x \ S) net)" +ML{* +structure TendstoIntros = + NamedThmsFun(val name = "tendsto_intros" + val description = "introduction rules for tendsto"); +*} + +setup TendstoIntros.setup + lemma topological_tendstoI: "(\S. open S \ l \ S \ eventually (\x. f x \ S) net) \ (f ---> l) net" @@ -395,12 +403,38 @@ lemma tendsto_Zfun_iff: "(f ---> a) net = Zfun (\x. f x - a) net" by (simp only: tendsto_iff Zfun_def dist_norm) -lemma tendsto_const: "((\x. k) ---> k) net" +lemma tendsto_ident_at [tendsto_intros]: "((\x. x) ---> a) (at a)" +unfolding tendsto_def eventually_at_topological by auto + +lemma tendsto_ident_at_within [tendsto_intros]: + "a \ S \ ((\x. x) ---> a) (at a within S)" +unfolding tendsto_def eventually_within eventually_at_topological by auto + +lemma tendsto_const [tendsto_intros]: "((\x. k) ---> k) net" by (simp add: tendsto_def) -lemma tendsto_norm: - fixes a :: "'a::real_normed_vector" - shows "(f ---> a) net \ ((\x. norm (f x)) ---> norm a) net" +lemma tendsto_dist [tendsto_intros]: + assumes f: "(f ---> l) net" and g: "(g ---> m) net" + shows "((\x. dist (f x) (g x)) ---> dist l m) net" +proof (rule tendstoI) + fix e :: real assume "0 < e" + hence e2: "0 < e/2" by simp + from tendstoD [OF f e2] tendstoD [OF g e2] + show "eventually (\x. dist (dist (f x) (g x)) (dist l m) < e) net" + proof (rule eventually_elim2) + fix x assume "dist (f x) l < e/2" "dist (g x) m < e/2" + then show "dist (dist (f x) (g x)) (dist l m) < e" + unfolding dist_real_def + using dist_triangle2 [of "f x" "g x" "l"] + using dist_triangle2 [of "g x" "l" "m"] + using dist_triangle3 [of "l" "m" "f x"] + using dist_triangle [of "f x" "m" "g x"] + by arith + qed +qed + +lemma tendsto_norm [tendsto_intros]: + "(f ---> a) net \ ((\x. norm (f x)) ---> norm a) net" apply (simp add: tendsto_iff dist_norm, safe) apply (drule_tac x="e" in spec, safe) apply (erule eventually_elim1) @@ -417,12 +451,12 @@ shows "(- a) - (- b) = - (a - b)" by simp -lemma tendsto_add: +lemma tendsto_add [tendsto_intros]: fixes a b :: "'a::real_normed_vector" shows "\(f ---> a) net; (g ---> b) net\ \ ((\x. f x + g x) ---> a + b) net" by (simp only: tendsto_Zfun_iff add_diff_add Zfun_add) -lemma tendsto_minus: +lemma tendsto_minus [tendsto_intros]: fixes a :: "'a::real_normed_vector" shows "(f ---> a) net \ ((\x. - f x) ---> - a) net" by (simp only: tendsto_Zfun_iff minus_diff_minus Zfun_minus) @@ -432,16 +466,16 @@ shows "((\x. - f x) ---> - a) net \ (f ---> a) net" by (drule tendsto_minus, simp) -lemma tendsto_diff: +lemma tendsto_diff [tendsto_intros]: fixes a b :: "'a::real_normed_vector" shows "\(f ---> a) net; (g ---> b) net\ \ ((\x. f x - g x) ---> a - b) net" by (simp add: diff_minus tendsto_add tendsto_minus) -lemma (in bounded_linear) tendsto: +lemma (in bounded_linear) tendsto [tendsto_intros]: "(g ---> a) net \ ((\x. f (g x)) ---> f a) net" by (simp only: tendsto_Zfun_iff diff [symmetric] Zfun) -lemma (in bounded_bilinear) tendsto: +lemma (in bounded_bilinear) tendsto [tendsto_intros]: "\(f ---> a) net; (g ---> b) net\ \ ((\x. f x ** g x) ---> a ** b) net" by (simp only: tendsto_Zfun_iff prod_diff_prod Zfun_add Zfun Zfun_left Zfun_right) @@ -556,7 +590,7 @@ apply (simp add: tendsto_Zfun_iff) done -lemma tendsto_inverse: +lemma tendsto_inverse [tendsto_intros]: fixes a :: "'a::real_normed_div_algebra" assumes f: "(f ---> a) net" assumes a: "a \ 0" @@ -571,7 +605,7 @@ by (rule tendsto_inverse_lemma) qed -lemma tendsto_divide: +lemma tendsto_divide [tendsto_intros]: fixes a b :: "'a::real_normed_field" shows "\(f ---> a) net; (g ---> b) net; b \ 0\ \ ((\x. f x / g x) ---> a / b) net" diff -r 86eeb9b7a4ba -r f9c35a72390a src/HOL/RealVector.thy --- a/src/HOL/RealVector.thy Fri Jun 12 00:45:28 2009 +0200 +++ b/src/HOL/RealVector.thy Fri Jun 12 07:23:45 2009 +0200 @@ -530,6 +530,9 @@ lemma dist_triangle: "dist x z \ dist x y + dist y z" using dist_triangle2 [of x z y] by (simp add: dist_commute) +lemma dist_triangle3: "dist x y \ dist a x + dist a y" +using dist_triangle2 [of x y a] by (simp add: dist_commute) + subclass topological_space proof have "\e::real. 0 < e" @@ -592,32 +595,6 @@ thus "norm (1::'a) = 1" by simp qed -instantiation real :: real_normed_field -begin - -definition real_norm_def [simp]: - "norm r = \r\" - -definition dist_real_def: - "dist x y = \x - y\" - -definition open_real_def [code del]: - "open (S :: real set) \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" - -instance -apply (intro_classes, unfold real_norm_def real_scaleR_def) -apply (rule dist_real_def) -apply (rule open_real_def) -apply (simp add: real_sgn_def) -apply (rule abs_ge_zero) -apply (rule abs_eq_0) -apply (rule abs_triangle_ineq) -apply (rule abs_mult) -apply (rule abs_mult) -done - -end - lemma norm_zero [simp]: "norm (0::'a::real_normed_vector) = 0" by simp @@ -797,6 +774,76 @@ using norm_triangle_ineq4 [of "x - z" "y - z"] by simp qed + +subsection {* Class instances for real numbers *} + +instantiation real :: real_normed_field +begin + +definition real_norm_def [simp]: + "norm r = \r\" + +definition dist_real_def: + "dist x y = \x - y\" + +definition open_real_def [code del]: + "open (S :: real set) \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" + +instance +apply (intro_classes, unfold real_norm_def real_scaleR_def) +apply (rule dist_real_def) +apply (rule open_real_def) +apply (simp add: real_sgn_def) +apply (rule abs_ge_zero) +apply (rule abs_eq_0) +apply (rule abs_triangle_ineq) +apply (rule abs_mult) +apply (rule abs_mult) +done + +end + +lemma open_real_lessThan [simp]: + fixes a :: real shows "open {.. (\y. \y - x\ < a - x \ y \ {..e>0. \y. \y - x\ < e \ y \ {.. (\y. \y - x\ < x - a \ y \ {a<..})" by auto + thus "\e>0. \y. \y - x\ < e \ y \ {a<..}" .. +qed + +lemma open_real_greaterThanLessThan [simp]: + fixes a b :: real shows "open {a<.. {.. {..b}" by auto + thus "closed {a..b}" by (simp add: closed_Int) +qed + + subsection {* Extra type constraints *} text {* Only allow @{term "open"} in class @{text topological_space}. *}