# HG changeset patch # User huffman # Date 1244057049 25200 # Node ID b8bdef62bfa6e65d7256332f7e3207fad93688dd # Parent 1501fc26f11b724119939497f819243872b0b2aa# Parent f2e6b6526092904b10efe66b4bdecabee7a73a64 merged diff -r f2e6b6526092 -r b8bdef62bfa6 src/HOL/Complex.thy --- a/src/HOL/Complex.thy Wed Jun 03 15:48:54 2009 +0200 +++ b/src/HOL/Complex.thy Wed Jun 03 12:24:09 2009 -0700 @@ -268,26 +268,28 @@ instantiation complex :: real_normed_field begin -definition - complex_norm_def: "norm z = sqrt ((Re z)\ + (Im z)\)" +definition complex_norm_def: + "norm z = sqrt ((Re z)\ + (Im z)\)" abbreviation cmod :: "complex \ real" where "cmod \ norm" -definition - complex_sgn_def: "sgn x = x /\<^sub>R cmod x" +definition complex_sgn_def: + "sgn x = x /\<^sub>R cmod x" -definition - dist_complex_def: "dist x y = cmod (x - y)" +definition dist_complex_def: + "dist x y = cmod (x - y)" + +definition topo_complex_def [code del]: + "topo = {S::complex set. \x\S. \e>0. \y. dist y x < e \ y \ S}" lemmas cmod_def = complex_norm_def lemma complex_norm [simp]: "cmod (Complex x y) = sqrt (x\ + y\)" by (simp add: complex_norm_def) -instance -proof +instance proof fix r :: real and x y :: complex show "0 \ norm x" by (induct x) simp @@ -306,6 +308,8 @@ by (rule complex_sgn_def) show "dist x y = cmod (x - y)" by (rule dist_complex_def) + show "topo = {S::complex set. \x\S. \e>0. \y. dist y x < e \ y \ S}" + by (rule topo_complex_def) qed end diff -r f2e6b6526092 -r b8bdef62bfa6 src/HOL/Library/Convex_Euclidean_Space.thy --- a/src/HOL/Library/Convex_Euclidean_Space.thy Wed Jun 03 15:48:54 2009 +0200 +++ b/src/HOL/Library/Convex_Euclidean_Space.thy Wed Jun 03 12:24:09 2009 -0700 @@ -602,8 +602,8 @@ have "\x\0. x \ 1 \ (1 - x) *s x1 + x *s x2 \ e1 \ (1 - x) *s x1 + x *s x2 \ e2" apply(rule connected_real_lemma) apply (simp add: `x1\e1` `x2\e2` dist_commute)+ using * apply(simp add: dist_norm) - using as(1,2)[unfolded open_def] apply simp - using as(1,2)[unfolded open_def] apply simp + using as(1,2)[unfolded open_dist] apply simp + using as(1,2)[unfolded open_dist] apply simp using assms[unfolded convex_alt, THEN bspec[where x=x1], THEN bspec[where x=x2]] using x1 x2 using as(3) by auto then obtain x where "x\0" "x\1" "(1 - x) *s x1 + x *s x2 \ e1" "(1 - x) *s x1 + x *s x2 \ e2" by auto diff -r f2e6b6526092 -r b8bdef62bfa6 src/HOL/Library/Euclidean_Space.thy --- a/src/HOL/Library/Euclidean_Space.thy Wed Jun 03 15:48:54 2009 +0200 +++ b/src/HOL/Library/Euclidean_Space.thy Wed Jun 03 12:24:09 2009 -0700 @@ -506,6 +506,9 @@ definition dist_vector_def: "dist (x::'a^'b) (y::'a^'b) = setL2 (\i. dist (x$i) (y$i)) UNIV" +definition topo_vector_def: + "topo = {S::('a ^ 'b) set. \x\S. \e>0. \y. dist y x < e \ y \ S}" + instance proof fix x y :: "'a ^ 'b" show "dist x y = 0 \ x = y" @@ -518,6 +521,9 @@ apply (rule order_trans [OF _ setL2_triangle_ineq]) apply (simp add: setL2_mono dist_triangle2) done +next + show "topo = {S::('a ^ 'b) set. \x\S. \e>0. \y. dist y x < e \ y \ S}" + by (rule topo_vector_def) qed end diff -r f2e6b6526092 -r b8bdef62bfa6 src/HOL/Library/Inner_Product.thy --- a/src/HOL/Library/Inner_Product.thy Wed Jun 03 15:48:54 2009 +0200 +++ b/src/HOL/Library/Inner_Product.thy Wed Jun 03 12:24:09 2009 -0700 @@ -10,7 +10,7 @@ subsection {* Real inner product spaces *} -class real_inner = real_vector + sgn_div_norm + dist_norm + +class real_inner = real_vector + sgn_div_norm + dist_norm + topo_dist + fixes inner :: "'a \ 'a \ real" assumes inner_commute: "inner x y = inner y x" and inner_left_distrib: "inner (x + y) z = inner x z + inner y z" diff -r f2e6b6526092 -r b8bdef62bfa6 src/HOL/Library/Product_Vector.thy --- a/src/HOL/Library/Product_Vector.thy Wed Jun 03 15:48:54 2009 +0200 +++ b/src/HOL/Library/Product_Vector.thy Wed Jun 03 12:24:09 2009 -0700 @@ -39,6 +39,39 @@ end +subsection {* Product is a topological space *} + +instantiation + "*" :: (topological_space, topological_space) topological_space +begin + +definition topo_prod_def: + "topo = {S. \x\S. \A\topo. \B\topo. x \ A \ B \ A \ B \ S}" + +instance proof + show "(UNIV :: ('a \ 'b) set) \ topo" + unfolding topo_prod_def by (auto intro: topo_UNIV) +next + fix S T :: "('a \ 'b) set" + assume "S \ topo" "T \ topo" thus "S \ T \ topo" + unfolding topo_prod_def + apply clarify + apply (drule (1) bspec)+ + apply (clarify, rename_tac Sa Ta Sb Tb) + apply (rule_tac x="Sa \ Ta" in rev_bexI) + apply (simp add: topo_Int) + apply (rule_tac x="Sb \ Tb" in rev_bexI) + apply (simp add: topo_Int) + apply fast + done +next + fix T :: "('a \ 'b) set set" + assume "T \ topo" thus "\T \ topo" + unfolding topo_prod_def Bex_def by fast +qed + +end + subsection {* Product is a metric space *} instantiation @@ -67,6 +100,53 @@ apply (rule power_mono [OF dist_triangle2 [of _ _ "snd z"] zero_le_dist]) apply (simp only: real_sum_squared_expand) done +next + (* FIXME: long proof! *) + (* Maybe it would be easier to define topological spaces *) + (* in terms of neighborhoods instead of open sets? *) + show "topo = {S::('a \ 'b) set. \x\S. \e>0. \y. dist y x < e \ y \ S}" + unfolding topo_prod_def topo_dist + apply (safe, rename_tac S a b) + apply (drule (1) bspec) + apply clarify + apply (drule (1) bspec)+ + apply (clarify, rename_tac r s) + apply (rule_tac x="min r s" in exI, simp) + apply (clarify, rename_tac c d) + apply (erule subsetD) + apply (simp add: dist_Pair_Pair) + apply (rule conjI) + apply (drule spec, erule mp) + 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]) + + apply (rename_tac S a b) + apply (drule (1) bspec) + apply clarify + apply (subgoal_tac "\r>0. \s>0. e = sqrt (r\ + s\)") + apply clarify + apply (rule_tac x="{y. dist y a < r}" in rev_bexI) + 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 (rule_tac x="{y. dist y b < s}" in rev_bexI) + 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 (rule conjI) + apply simp + apply (clarify, rename_tac c d) + apply (drule spec, erule mp) + apply (simp add: dist_Pair_Pair add_strict_mono power_strict_mono) + apply (rule_tac x="e / sqrt 2" in exI, simp add: divide_pos_pos) + apply (rule_tac x="e / sqrt 2" in exI, simp add: divide_pos_pos) + apply (simp add: power_divide) + done qed end diff -r f2e6b6526092 -r b8bdef62bfa6 src/HOL/Library/Topology_Euclidean_Space.thy --- a/src/HOL/Library/Topology_Euclidean_Space.thy Wed Jun 03 15:48:54 2009 +0200 +++ b/src/HOL/Library/Topology_Euclidean_Space.thy Wed Jun 03 12:24:09 2009 -0700 @@ -194,35 +194,30 @@ by (simp add: subtopology_superset) subsection{* The universal Euclidean versions are what we use most of the time *} + definition - "open" :: "'a::metric_space set \ bool" where - "open S \ (\x \ S. \e >0. \x'. dist x' x < e \ x' \ S)" -definition "closed S \ open(UNIV - S)" -definition "euclidean = topology open" - -lemma open_empty[intro,simp]: "open {}" by (simp add: open_def) + "open" :: "'a::topological_space set \ bool" where + "open S \ S \ topo" + +definition + closed :: "'a::topological_space set \ bool" where + "closed S \ open(UNIV - S)" + +definition + euclidean :: "'a::topological_space topology" where + "euclidean = topology open" + lemma open_UNIV[intro,simp]: "open UNIV" - by (simp add: open_def, rule exI[where x="1"], auto) - -lemma open_inter[intro]: assumes S: "open S" and T: "open T" - shows "open (S \ T)" -proof- - note thS = S[unfolded open_def, rule_format] - note thT = T[unfolded open_def, rule_format] - {fix x assume x: "x \ S\T" - hence xS: "x \ S" and xT: "x \ T" by simp_all - from thS[OF xS] obtain eS where eS: "eS > 0" "\x'. dist x' x < eS \ x' \ S" by blast - from thT[OF xT] obtain eT where eT: "eT > 0" "\x'. dist x' x < eT \ x' \ T" by blast - from real_lbound_gt_zero[OF eS(1) eT(1)] obtain e where e: "e > 0" "e < eS" "e < eT" by blast - { fix x' assume d: "dist x' x < e" - hence dS: "dist x' x < eS" and dT: "dist x' x < eT" using e by arith+ - from eS(2)[rule_format, OF dS] eT(2)[rule_format, OF dT] have "x' \ S\T" by blast} - hence "\e >0. \x'. dist x' x < e \ x' \ (S\T)" using e by blast} - then show ?thesis unfolding open_def by blast -qed + unfolding open_def by (rule topo_UNIV) + +lemma open_inter[intro]: "open S \ open T \ open (S \ T)" + unfolding open_def by (rule topo_Int) lemma open_Union[intro]: "(\S\K. open S) \ open (\ K)" - by (simp add: open_def) metis + unfolding open_def subset_eq [symmetric] by (rule topo_Union) + +lemma open_empty[intro,simp]: "open {}" + using open_Union [of "{}"] by simp lemma open_openin: "open S \ openin euclidean S" unfolding euclidean_def @@ -242,7 +237,9 @@ lemma closed_closedin: "closed S \ closedin euclidean S" by (simp add: closed_def closedin_def topspace_euclidean open_openin) -lemma open_Un[intro]: "open S \ open T \ open (S\T)" +lemma open_Un[intro]: + fixes S T :: "'a::topological_space set" + shows "open S \ open T \ open (S\T)" by (auto simp add: open_openin) lemma open_subopen: "open S \ (\x\S. \T. open T \ x \ T \ T \ S)" @@ -320,6 +317,11 @@ subsection{* Topological properties of open balls *} +lemma open_dist: + fixes S :: "'a::metric_space set" + shows "open S \ (\x\S. \e>0. \x'. dist x' x < e \ x' \ S)" + unfolding open_def topo_dist by simp + lemma diff_less_iff: "(a::real) - b > 0 \ a > b" "(a::real) - b < 0 \ a < b" "a - b < c \ a < c +b" "a - b > c \ a > c +b" by arith+ @@ -327,7 +329,7 @@ "a - b \ c \ a \ c +b" "a - b \ c \ a \ c +b" by arith+ lemma open_ball[intro, simp]: "open (ball x e)" - unfolding open_def ball_def Collect_def Ball_def mem_def + unfolding open_dist ball_def Collect_def Ball_def mem_def unfolding dist_commute apply clarify apply (rule_tac x="e - dist xa x" in exI) @@ -340,7 +342,7 @@ lemma centre_in_ball[simp]: "x \ ball x e \ e > 0" by (metis mem_ball dist_self) lemma open_contains_ball: "open S \ (\x\S. \e>0. ball x e \ S)" - unfolding open_def subset_eq mem_ball Ball_def dist_commute .. + unfolding open_dist subset_eq mem_ball Ball_def dist_commute .. lemma open_contains_ball_eq: "open S \ \x. x\S \ (\e>0. ball x e \ S)" by (metis open_contains_ball subset_eq centre_in_ball) @@ -382,11 +384,13 @@ lemma closed_subset: "S \ T \ closed S \ closedin (subtopology euclidean T) S" by (auto simp add: closedin_closed) -lemma openin_euclidean_subtopology_iff: "openin (subtopology euclidean U) S +lemma openin_euclidean_subtopology_iff: + fixes S U :: "'a::metric_space set" + shows "openin (subtopology euclidean U) S \ S \ U \ (\x\S. \e>0. \x'\U. dist x' x < e \ x'\ S)" (is "?lhs \ ?rhs") proof- {assume ?lhs hence ?rhs unfolding openin_subtopology open_openin[symmetric] - by (simp add: open_def) blast} + by (simp add: open_dist) blast} moreover {assume SU: "S \ U" and H: "\x. x \ S \ \e>0. \x'\U. dist x' x < e \ x' \ S" from H obtain d where d: "\x . x\ S \ d x > 0 \ (\x' \ U. dist x' x < d x \ x' \ S)" @@ -441,7 +445,7 @@ e1 \ e2 = {} \ ~(e1 = {}) \ ~(e2 = {}))" -unfolding connected_def openin_open by blast +unfolding connected_def openin_open by (safe, blast+) lemma exists_diff: "(\S. P(UNIV - S)) \ (\S. P S)" (is "?lhs \ ?rhs") proof- @@ -480,31 +484,61 @@ subsection{* Hausdorff and other separation properties *} -lemma hausdorff: - assumes xy: "x \ y" - shows "\U V. open U \ open V \ x\ U \ y \ V \ (U \ V = {})" (is "\U V. ?P U V") -proof- +axclass t0_space \ topological_space + t0_space: + "x \ y \ \U. open U \ \ (x \ U \ y \ U)" + +axclass t1_space \ topological_space + t1_space: + "x \ y \ \U V. open U \ open V \ x \ U \ y \ U \ x \ V \ y \ V" + +instance t1_space \ t0_space +by default (fast dest: t1_space) + +text {* T2 spaces are also known as Hausdorff spaces. *} + +axclass t2_space \ topological_space + hausdorff: + "x \ y \ \U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" + +instance t2_space \ t1_space +by default (fast dest: hausdorff) + +instance metric_space \ t2_space +proof + fix x y :: "'a::metric_space" + assume xy: "x \ y" let ?U = "ball x (dist x y / 2)" let ?V = "ball y (dist x y / 2)" have th0: "\d x y z. (d x z :: real) <= d x y + d y z \ d y z = d z y ==> ~(d x y * 2 < d x z \ d z y * 2 < d x z)" by arith - have "?P ?U ?V" using dist_pos_lt[OF xy] th0[of dist,OF dist_triangle dist_commute] - by (auto simp add: expand_set_eq less_divide_eq_number_of1) - then show ?thesis by blast -qed - -lemma separation_t2: "x \ y \ (\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {})" + have "open ?U \ open ?V \ x \ ?U \ y \ ?V \ ?U \ ?V = {}" + using dist_pos_lt[OF xy] th0[of dist,OF dist_triangle dist_commute] + by (auto simp add: expand_set_eq) + then show "\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" + by blast +qed + +lemma separation_t2: + fixes x y :: "'a::t2_space" + shows "x \ y \ (\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {})" using hausdorff[of x y] by blast -lemma separation_t1: "x \ y \ (\U V. open U \ open V \ x \U \ y\ U \ x\V \ y\V)" - using separation_t2[of x y] by blast - -lemma separation_t0: "x \ y \ (\U. open U \ ~(x\U \ y\U))" by(metis separation_t1) +lemma separation_t1: + fixes x y :: "'a::t1_space" + shows "x \ y \ (\U V. open U \ open V \ x \U \ y\ U \ x\V \ y\V)" + using t1_space[of x y] by blast + +lemma separation_t0: + fixes x y :: "'a::t0_space" + shows "x \ y \ (\U. open U \ ~(x\U \ y\U))" + using t0_space[of x y] by blast subsection{* Limit points *} definition - islimpt:: "'a::metric_space \ 'a set \ bool" (infixr "islimpt" 60) where + islimpt:: "'a::topological_space \ 'a set \ bool" + (infixr "islimpt" 60) where "x islimpt S \ (\T. x\T \ open T \ (\y\S. y\T \ y\x))" (* FIXME: Sure this form is OK????*) @@ -513,23 +547,29 @@ using assms unfolding islimpt_def by auto lemma islimpt_subset: "x islimpt S \ S \ T ==> x islimpt T" by (auto simp add: islimpt_def) -lemma islimpt_approachable: "x islimpt S \ (\e>0. \x'\S. x' \ x \ dist x' x < e)" + +lemma islimpt_approachable: + fixes x :: "'a::metric_space" + shows "x islimpt S \ (\e>0. \x'\S. x' \ x \ dist x' x < e)" unfolding islimpt_def apply auto apply(erule_tac x="ball x e" in allE) apply auto apply(rule_tac x=y in bexI) apply (auto simp add: dist_commute) - apply (simp add: open_def, drule (1) bspec) + apply (simp add: open_dist, drule (1) bspec) apply (clarify, drule spec, drule (1) mp, auto) done -lemma islimpt_approachable_le: "x islimpt S \ (\e>0. \x'\ S. x' \ x \ dist x' x <= e)" +lemma islimpt_approachable_le: + fixes x :: "'a::metric_space" + shows "x islimpt S \ (\e>0. \x'\ S. x' \ x \ dist x' x <= e)" unfolding islimpt_approachable using approachable_lt_le[where f="\x'. dist x' x" and P="\x'. \ (x'\S \ x'\x)"] by metis (* FIXME: VERY slow! *) axclass perfect_space \ metric_space + (* FIXME: perfect_space should inherit from topological_space *) islimpt_UNIV [simp, intro]: "x islimpt UNIV" lemma perfect_choose_dist: @@ -544,7 +584,7 @@ apply (clarify, rule_tac x="x + e/2" in bexI) apply (auto simp add: dist_norm) done - + instance "^" :: (perfect_space, finite) perfect_space proof fix x :: "'a ^ 'b" @@ -576,7 +616,7 @@ by (metis DiffE DiffI UNIV_I insertCI insert_absorb mem_def) lemma islimpt_EMPTY[simp]: "\ x islimpt {}" - unfolding islimpt_approachable apply auto by ferrack + unfolding islimpt_def by auto lemma closed_positive_orthant: "closed {x::real^'n::finite. \i. 0 \x$i}" proof- @@ -616,7 +656,9 @@ ultimately show ?case by blast qed -lemma islimpt_finite: assumes fS: "finite S" shows "\ a islimpt S" +lemma islimpt_finite: + fixes S :: "'a::metric_space set" + assumes fS: "finite S" shows "\ a islimpt S" unfolding islimpt_approachable using finite_set_avoid[OF fS, of a] by (metis dist_commute not_le) @@ -624,13 +666,14 @@ apply (rule iffI) defer apply (metis Un_upper1 Un_upper2 islimpt_subset) - unfolding islimpt_approachable - apply auto - apply (erule_tac x="min e ea" in allE) - apply auto + unfolding islimpt_def + apply (rule ccontr, clarsimp, rename_tac A B) + apply (drule_tac x="A \ B" in spec) + apply (auto simp add: open_inter) done lemma discrete_imp_closed: + fixes S :: "'a::metric_space set" assumes e: "0 < e" and d: "\x \ S. \y \ S. dist y x < e \ y = x" shows "closed S" proof- @@ -644,7 +687,7 @@ by (intro dist_triangle_lt [where z=x], simp) from d[rule_format, OF y(1) z(1) th] y z have False by (auto simp add: dist_commute)} - then show ?thesis by (metis islimpt_approachable closed_limpt) + then show ?thesis by (metis islimpt_approachable closed_limpt [where 'a='a]) qed subsection{* Interior of a Set *} @@ -652,7 +695,7 @@ lemma interior_eq: "interior S = S \ open S" apply (simp add: expand_set_eq interior_def) - apply (subst (2) open_subopen) by blast + apply (subst (2) open_subopen) by (safe, blast+) lemma interior_open: "open S ==> (interior S = S)" by (metis interior_eq) @@ -701,7 +744,6 @@ qed lemma interior_closed_Un_empty_interior: - fixes S T :: "'a::metric_space set" assumes cS: "closed S" and iT: "interior T = {}" shows "interior(S \ T) = interior S" proof @@ -861,7 +903,10 @@ unfolding closure_interior by auto -lemma open_inter_closure_subset: "open S \ (S \ (closure T)) \ closure(S \ T)" +lemma open_inter_closure_subset: + fixes S :: "'a::metric_space set" + (* FIXME: generalize to topological_space *) + shows "open S \ (S \ (closure T)) \ closure(S \ T)" proof fix x assume as: "open S" "x \ S \ closure T" @@ -869,7 +914,7 @@ { fix e::real assume "e > 0" from as `open S` obtain e' where "e' > 0" and e':"\x'. dist x' x < e' \ x' \ S" - unfolding open_def + unfolding open_dist by auto let ?e = "min e e'" from `e>0` `e'>0` have "?e > 0" @@ -913,7 +958,9 @@ lemma frontier_closures: "frontier S = (closure S) \ (closure(UNIV - S))" by (auto simp add: frontier_def interior_closure) -lemma frontier_straddle: "a \ frontier S \ (\e>0. (\x\S. dist a x < e) \ (\x. x \ S \ dist a x < e))" (is "?lhs \ ?rhs") +lemma frontier_straddle: + fixes a :: "'a::metric_space" + shows "a \ frontier S \ (\e>0. (\x\S. dist a x < e) \ (\x. x \ S \ dist a x < e))" (is "?lhs \ ?rhs") proof assume "?lhs" { fix e::real @@ -1202,7 +1249,7 @@ assume ?lhs { fix e::real assume "e>0" obtain d where d: "d >0" "\x\S. 0 < dist x a \ dist x a < d \ dist (f x) l < e" using `?lhs` `e>0` unfolding Lim_within by auto - obtain d' where d': "d'>0" "\x. dist x a < d' \ x \ S" using assms unfolding open_def by auto + obtain d' where d': "d'>0" "\x. dist x a < d' \ x \ S" using assms unfolding open_dist by auto from d d' have "\d>0. \x. 0 < dist x a \ dist x a < d \ dist (f x) l < e" by (rule_tac x= "min d d'" in exI)auto } thus ?rhs unfolding Lim_at by auto @@ -1620,7 +1667,6 @@ qed lemma Lim_transform_eventually: - fixes f g :: "'a::type \ 'b::metric_space" shows "eventually (\x. f x = g x) net \ (f ---> l) net ==> (g ---> l) net" unfolding tendsto_def apply (clarify, drule spec, drule (1) mp) @@ -1628,7 +1674,6 @@ done lemma Lim_transform_within: - fixes f g :: "'a::metric_space \ 'b::metric_space" assumes "0 < d" "(\x'\S. 0 < dist x' x \ dist x' x < d \ f x' = g x')" "(f ---> l) (at x within S)" shows "(g ---> l) (at x within S)" @@ -1642,7 +1687,6 @@ done lemma Lim_transform_at: - fixes f g :: "'a::metric_space \ 'b::metric_space" shows "0 < d \ (\x'. 0 < dist x' x \ dist x' x < d \ f x' = g x') \ (f ---> l) (at x) ==> (g ---> l) (at x)" apply (subst within_UNIV[symmetric]) @@ -1652,7 +1696,6 @@ text{* Common case assuming being away from some crucial point like 0. *} lemma Lim_transform_away_within: - fixes f:: "'a::metric_space \ 'b::metric_space" assumes "a\b" "\x\ S. x \ a \ x \ b \ f x = g x" and "(f ---> l) (at a within S)" shows "(g ---> l) (at a within S)" @@ -1663,7 +1706,6 @@ qed lemma Lim_transform_away_at: - fixes f:: "'a::metric_space \ 'b::metric_space" assumes ab: "a\b" and fg: "\x. x \ a \ x \ b \ f x = g x" and fl: "(f ---> l) (at a)" shows "(g ---> l) (at a)" @@ -1673,8 +1715,6 @@ text{* Alternatively, within an open set. *} lemma Lim_transform_within_open: - fixes f:: "'a::metric_space \ 'b::metric_space" - (* FIXME: generalize to metric_space *) assumes "open S" "a \ S" "\x\S. x \ a \ f x = g x" "(f ---> l) (at a)" shows "(g ---> l) (at a)" proof- @@ -1715,15 +1755,21 @@ qed lemma closed_sequential_limits: - "closed S \ (\x l. (\n. x n \ S) \ (x ---> l) sequentially \ l \ S)" + fixes S :: "'a::metric_space set" + shows "closed S \ (\x l. (\n. x n \ S) \ (x ---> l) sequentially \ l \ S)" unfolding closed_limpt - by (metis closure_sequential closure_closed closed_limpt islimpt_sequential mem_delete) - -lemma closure_approachable: "x \ closure S \ (\e>0. \y\S. dist y x < e)" + using closure_sequential [where 'a='a] closure_closed [where 'a='a] closed_limpt [where 'a='a] islimpt_sequential [where 'a='a] mem_delete [where 'a='a] + by metis + +lemma closure_approachable: + fixes S :: "'a::metric_space set" + shows "x \ closure S \ (\e>0. \y\S. dist y x < e)" apply (auto simp add: closure_def islimpt_approachable) by (metis dist_self) -lemma closed_approachable: "closed S ==> (\e>0. \y\S. dist y x < e) \ x \ S" +lemma closed_approachable: + fixes S :: "'a::metric_space set" + shows "closed S ==> (\e>0. \y\S. dist y x < e) \ x \ S" by (metis closure_closed closure_approachable) text{* Some other lemmas about sequences. *} @@ -1758,7 +1804,7 @@ lemma closed_cball: "closed (cball x e)" unfolding cball_def closed_def Compl_eq_Diff_UNIV [symmetric] unfolding Collect_neg_eq [symmetric] not_le -apply (clarsimp simp add: open_def, rename_tac y) +apply (clarsimp simp add: open_dist, rename_tac y) apply (rule_tac x="dist x y - e" in exI, clarsimp) apply (cut_tac x=x and y=x' and z=y in dist_triangle) apply simp @@ -1876,7 +1922,7 @@ 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_def by blast + 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 @@ -2506,7 +2552,7 @@ obtain b where "l\b" "b\t" using assms(2) and l by auto then obtain e where "e>0" and e:"\z. dist z l < e \ z\b" - using assms(3)[THEN bspec[where x=b]] unfolding open_def by auto + using assms(3)[THEN bspec[where x=b]] unfolding open_dist by auto then obtain N1 where N1:"\n\N1. dist ((f \ r) n) l < e / 2" using lr[unfolded Lim_sequentially, THEN spec[where x="e/2"]] by auto @@ -2672,6 +2718,7 @@ qed lemma bolzano_weierstrass_imp_closed: + fixes s :: "'a::metric_space set" (* TODO: can this be generalized? *) assumes "\t. infinite t \ t \ s --> (\x \ s. x islimpt t)" shows "closed s" proof- @@ -2797,8 +2844,10 @@ unfolding compact_def o_def by (auto simp add: tendsto_const) -lemma closed_sing [simp]: shows "closed {a}" - apply (clarsimp simp add: closed_def open_def) +lemma closed_sing [simp]: + fixes a :: "'a::metric_space" + shows "closed {a}" + apply (clarsimp simp add: closed_def open_dist) apply (rule ccontr) apply (drule_tac x="dist x a" in spec) apply (simp add: dist_nz dist_commute) @@ -2829,7 +2878,9 @@ using frontier_subset_closed compact_eq_bounded_closed by blast -lemma open_delete: "open s ==> open(s - {x})" +lemma open_delete: + fixes s :: "'a::metric_space set" + shows "open s ==> open(s - {x})" using open_diff[of s "{x}"] closed_sing by blast @@ -3443,7 +3494,7 @@ { fix t assume as: "open t" "f x \ t" then obtain e where "e>0" and e:"ball (f x) e \ t" unfolding open_contains_ball by auto - obtain d where "d>0" and d:"\y. 0 < dist y x \ dist y x < d \ dist (f y) (f x) < e" using `e>0` using `?lhs`[unfolded continuous_at Lim_at open_def] by auto + obtain d where "d>0" and d:"\y. 0 < dist y x \ dist y x < d \ dist (f y) (f x) < e" using `e>0` using `?lhs`[unfolded continuous_at Lim_at open_dist] by auto have "open (ball x d)" using open_ball by auto moreover have "x \ ball x d" unfolding centre_in_ball using `d>0` by simp @@ -3672,7 +3723,7 @@ shows "open((\x. c *s x) ` s)" proof- { fix x assume "x \ s" - then obtain e where "e>0" and e:"\x'. dist x' x < e \ x' \ s" using assms(2)[unfolded open_def, THEN bspec[where x=x]] by auto + then obtain e where "e>0" and e:"\x'. dist x' x < e \ x' \ s" using assms(2)[unfolded open_dist, THEN bspec[where x=x]] by auto have "e * abs c > 0" using assms(1)[unfolded zero_less_abs_iff[THEN sym]] using real_mult_order[OF `e>0`] by auto moreover { fix y assume "dist y (c *s x) < e * \c\" @@ -3681,7 +3732,7 @@ assms(1)[unfolded zero_less_abs_iff[THEN sym]] by (simp del:zero_less_abs_iff) hence "y \ op *s c ` s" using rev_image_eqI[of "(1 / c) *s y" s y "op *s c"] e[THEN spec[where x="(1 / c) *s y"]] assms(1) unfolding dist_norm vector_smult_assoc by auto } ultimately have "\e>0. \x'. dist x' (c *s x) < e \ x' \ op *s c ` s" apply(rule_tac x="e * abs c" in exI) by auto } - thus ?thesis unfolding open_def by auto + thus ?thesis unfolding open_dist by auto qed lemma open_negations: @@ -3906,7 +3957,7 @@ fixes s :: "real set" shows "open(vec1 ` s) \ (\x \ s. \e>0. \x'. abs(x' - x) < e --> x' \ s)" (is "?lhs = ?rhs") - unfolding open_def apply simp unfolding forall_vec1 dist_vec1 vec1_in_image_vec1 by simp + unfolding open_dist apply simp unfolding forall_vec1 dist_vec1 vec1_in_image_vec1 by simp lemma islimpt_approachable_vec1: fixes s :: "real set" shows @@ -4666,7 +4717,7 @@ hence "a < x' \ x' < b" unfolding vector_less_def by auto } ultimately have "\e>0. \x'. dist x' x < e \ x' \ {a<..T. open T \ x \ T \ T \ {a..b}" then obtain s where s:"open s" "x \ s" "s \ {a..b}" by auto - then obtain e where "e>0" and e:"\x'. dist x' x < e \ x' \ {a..b}" unfolding open_def and subset_eq by auto + then obtain e where "e>0" and e:"\x'. dist x' x < e \ x' \ {a..b}" unfolding open_dist and subset_eq by auto { fix i have "dist (x - (e / 2) *s basis i) x < e" "dist (x + (e / 2) *s basis i) x < e" diff -r f2e6b6526092 -r b8bdef62bfa6 src/HOL/RealVector.thy --- a/src/HOL/RealVector.thy Wed Jun 03 15:48:54 2009 +0200 +++ b/src/HOL/RealVector.thy Wed Jun 03 12:24:09 2009 -0700 @@ -416,12 +416,26 @@ by (rule Reals_cases) auto +subsection {* Topological spaces *} + +class topo = + fixes topo :: "'a set set" + +class topological_space = topo + + assumes topo_UNIV: "UNIV \ topo" + assumes topo_Int: "A \ topo \ B \ topo \ A \ B \ topo" + assumes topo_Union: "T \ topo \ \T \ topo" + + subsection {* Metric spaces *} class dist = fixes dist :: "'a \ 'a \ real" -class metric_space = dist + +class topo_dist = topo + dist + + assumes topo_dist: "topo = {S. \x\S. \e>0. \y. dist y x < e \ y \ S}" + +class metric_space = topo_dist + assumes dist_eq_0_iff [simp]: "dist x y = 0 \ x = y" assumes dist_triangle2: "dist x y \ dist x z + dist y z" begin @@ -452,6 +466,26 @@ lemma dist_triangle: "dist x z \ dist x y + dist y z" using dist_triangle2 [of x z y] by (simp add: dist_commute) +subclass topological_space +proof + have "\e::real. 0 < e" + by (fast intro: zero_less_one) + then show "UNIV \ topo" + unfolding topo_dist by simp +next + fix A B assume "A \ topo" "B \ topo" + then show "A \ B \ topo" + unfolding topo_dist + apply clarify + apply (drule (1) bspec)+ + apply (clarify, rename_tac r s) + apply (rule_tac x="min r s" in exI, simp) + done +next + fix T assume "T \ topo" thus "\T \ topo" + unfolding topo_dist by fast +qed + end @@ -466,7 +500,7 @@ class dist_norm = dist + norm + minus + assumes dist_norm: "dist x y = norm (x - y)" -class real_normed_vector = real_vector + sgn_div_norm + dist_norm + +class real_normed_vector = real_vector + sgn_div_norm + dist_norm + topo_dist + assumes norm_ge_zero [simp]: "0 \ norm x" and norm_eq_zero [simp]: "norm x = 0 \ x = 0" and norm_triangle_ineq: "norm (x + y) \ norm x + norm y" @@ -497,16 +531,20 @@ instantiation real :: real_normed_field begin -definition - real_norm_def [simp]: "norm r = \r\" +definition real_norm_def [simp]: + "norm r = \r\" -definition - dist_real_def: "dist x y = \x - y\" +definition dist_real_def: + "dist x y = \x - y\" + +definition topo_real_def [code del]: + "topo = {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 (simp add: real_sgn_def) +apply (rule topo_real_def) apply (rule abs_ge_zero) apply (rule abs_eq_0) apply (rule abs_triangle_ineq)