# HG changeset patch # User huffman # Date 1244422794 25200 # Node ID 5400beeddb555d96a4d52a30c6bf643e76f87f7f # Parent f7310185481d429c21e44d19009c3344fccd640a replace 'topo' with 'open'; add extra type constraint for 'open' diff -r f7310185481d -r 5400beeddb55 src/HOL/Complex.thy --- a/src/HOL/Complex.thy Sun Jun 07 15:18:52 2009 -0700 +++ b/src/HOL/Complex.thy Sun Jun 07 17:59:54 2009 -0700 @@ -281,8 +281,8 @@ 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}" +definition open_complex_def [code del]: + "open (S :: complex set) \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" lemmas cmod_def = complex_norm_def @@ -290,7 +290,7 @@ by (simp add: complex_norm_def) instance proof - fix r :: real and x y :: complex + fix r :: real and x y :: complex and S :: "complex set" show "0 \ norm x" by (induct x) simp show "(norm x = 0) = (x = 0)" @@ -308,8 +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) + show "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" + by (rule open_complex_def) qed end diff -r f7310185481d -r 5400beeddb55 src/HOL/Library/Euclidean_Space.thy --- a/src/HOL/Library/Euclidean_Space.thy Sun Jun 07 15:18:52 2009 -0700 +++ b/src/HOL/Library/Euclidean_Space.thy Sun Jun 07 17:59:54 2009 -0700 @@ -506,8 +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}" +definition open_vector_def: + "open (S :: ('a ^ 'b) set) \ + (\x\S. \e>0. \y. dist y x < e \ y \ S)" instance proof fix x y :: "'a ^ 'b" @@ -522,8 +523,9 @@ 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) + fix S :: "('a ^ 'b) set" + show "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" + by (rule open_vector_def) qed end diff -r f7310185481d -r 5400beeddb55 src/HOL/Library/Inner_Product.thy --- a/src/HOL/Library/Inner_Product.thy Sun Jun 07 15:18:52 2009 -0700 +++ b/src/HOL/Library/Inner_Product.thy Sun Jun 07 17:59:54 2009 -0700 @@ -10,7 +10,13 @@ subsection {* Real inner product spaces *} -text {* Temporarily relax constraints for @{term dist} and @{term norm}. *} +text {* + Temporarily relax type constraints for @{term "open"}, + @{term dist}, and @{term norm}. +*} + +setup {* Sign.add_const_constraint + (@{const_name "open"}, SOME @{typ "'a::open set \ bool"}) *} setup {* Sign.add_const_constraint (@{const_name dist}, SOME @{typ "'a::dist \ 'a \ real"}) *} @@ -18,7 +24,7 @@ setup {* Sign.add_const_constraint (@{const_name norm}, SOME @{typ "'a::norm \ real"}) *} -class real_inner = real_vector + sgn_div_norm + dist_norm + topo_dist + +class real_inner = real_vector + sgn_div_norm + dist_norm + open_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" @@ -124,7 +130,13 @@ end -text {* Re-enable constraints for @{term dist} and @{term norm}. *} +text {* + Re-enable constraints for @{term "open"}, + @{term dist}, and @{term norm}. +*} + +setup {* Sign.add_const_constraint + (@{const_name "open"}, SOME @{typ "'a::topological_space set \ bool"}) *} setup {* Sign.add_const_constraint (@{const_name dist}, SOME @{typ "'a::metric_space \ 'a \ real"}) *} diff -r f7310185481d -r 5400beeddb55 src/HOL/Library/Product_Vector.thy --- a/src/HOL/Library/Product_Vector.thy Sun Jun 07 15:18:52 2009 -0700 +++ b/src/HOL/Library/Product_Vector.thy Sun Jun 07 17:59:54 2009 -0700 @@ -45,29 +45,29 @@ "*" :: (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}" +definition open_prod_def: + "open (S :: ('a \ 'b) set) \ + (\x\S. \A B. open A \ open B \ x \ A \ B \ A \ B \ S)" instance proof - show "(UNIV :: ('a \ 'b) set) \ topo" - unfolding topo_prod_def by (auto intro: topo_UNIV) + show "open (UNIV :: ('a \ 'b) set)" + unfolding open_prod_def by auto next fix S T :: "('a \ 'b) set" - assume "S \ topo" "T \ topo" thus "S \ T \ topo" - unfolding topo_prod_def + assume "open S" "open T" thus "open (S \ T)" + unfolding open_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 (rule_tac x="Sa \ Ta" in exI) + apply (rule_tac x="Sb \ Tb" in exI) + apply (simp add: open_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 + fix K :: "('a \ 'b) set set" + assume "\S\K. open S" thus "open (\K)" + unfolding open_prod_def by fast qed end @@ -104,9 +104,10 @@ (* 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) + fix S :: "('a \ 'b) set" + show "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" + unfolding open_prod_def open_dist + apply safe apply (drule (1) bspec) apply clarify apply (drule (1) bspec)+ @@ -121,18 +122,19 @@ 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 (rule_tac x="{y. dist y a < r}" in exI) + apply (rule_tac x="{y. dist y b < s}" in exI) + apply (rule conjI) 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 (rule conjI) apply clarify apply (rule_tac x="s - dist x b" in exI, rule conjI, simp) apply clarify @@ -163,13 +165,13 @@ assumes "(f ---> a) net" shows "((\x. fst (f x)) ---> fst a) net" proof (rule topological_tendstoI) - fix S assume "S \ topo" "fst a \ S" - then have "fst -` S \ topo" "a \ fst -` S" - unfolding topo_prod_def + fix S assume "open S" "fst a \ S" + then have "open (fst -` S)" "a \ fst -` S" + unfolding open_prod_def apply simp_all apply clarify - apply (erule rev_bexI, simp) - apply (rule rev_bexI [OF topo_UNIV]) + apply (rule exI, erule conjI) + apply (rule exI, rule conjI [OF open_UNIV]) apply auto done with assms have "eventually (\x. f x \ fst -` S) net" @@ -182,13 +184,13 @@ assumes "(f ---> a) net" shows "((\x. snd (f x)) ---> snd a) net" proof (rule topological_tendstoI) - fix S assume "S \ topo" "snd a \ S" - then have "snd -` S \ topo" "a \ snd -` S" - unfolding topo_prod_def + fix S assume "open S" "snd a \ S" + then have "open (snd -` S)" "a \ snd -` S" + unfolding open_prod_def apply simp_all apply clarify - apply (rule rev_bexI [OF topo_UNIV]) - apply (erule rev_bexI) + apply (rule exI, rule conjI [OF open_UNIV]) + apply (rule exI, erule conjI) apply auto done with assms have "eventually (\x. f x \ snd -` S) net" @@ -201,15 +203,15 @@ assumes "(f ---> a) net" and "(g ---> b) net" shows "((\x. (f x, g x)) ---> (a, b)) net" proof (rule topological_tendstoI) - fix S assume "S \ topo" "(a, b) \ S" - then obtain A B where "A \ topo" "B \ topo" "a \ A" "b \ B" "A \ B \ S" - unfolding topo_prod_def by auto + fix S assume "open S" "(a, b) \ S" + then obtain A B where "open A" "open B" "a \ A" "b \ B" "A \ B \ S" + unfolding open_prod_def by auto have "eventually (\x. f x \ A) net" - using `(f ---> a) net` `A \ topo` `a \ A` + using `(f ---> a) net` `open A` `a \ A` by (rule topological_tendstoD) moreover have "eventually (\x. g x \ B) net" - using `(g ---> b) net` `B \ topo` `b \ B` + using `(g ---> b) net` `open B` `b \ B` by (rule topological_tendstoD) ultimately show "eventually (\x. (f x, g x) \ S) net" diff -r f7310185481d -r 5400beeddb55 src/HOL/Library/Topology_Euclidean_Space.thy --- a/src/HOL/Library/Topology_Euclidean_Space.thy Sun Jun 07 15:18:52 2009 -0700 +++ b/src/HOL/Library/Topology_Euclidean_Space.thy Sun Jun 07 17:59:54 2009 -0700 @@ -255,11 +255,6 @@ 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+ @@ -274,7 +269,7 @@ using dist_triangle_alt[where z=x] apply (clarsimp simp add: diff_less_iff) apply atomize - apply (erule_tac x="x'" in allE) + apply (erule_tac x="y" in allE) apply (erule_tac x="xa" in allE) by arith @@ -1004,7 +999,7 @@ thus "\ a islimpt S" unfolding trivial_limit_def unfolding Rep_net_within Rep_net_at - unfolding islimpt_def open_def [symmetric] + unfolding islimpt_def apply (clarsimp simp add: expand_set_eq) apply (rename_tac T, rule_tac x=T in exI) apply (clarsimp, drule_tac x=y in spec, simp) @@ -1014,7 +1009,7 @@ thus "trivial_limit (at a within S)" unfolding trivial_limit_def unfolding Rep_net_within Rep_net_at - unfolding islimpt_def open_def [symmetric] + unfolding islimpt_def apply (clarsimp simp add: image_image) apply (rule_tac x=T in image_eqI) apply (auto simp add: expand_set_eq) @@ -1164,7 +1159,8 @@ shows "(f ---> l) (net within (S \ T))" using assms unfolding tendsto_def Limits.eventually_within apply clarify - apply (drule (1) bspec)+ + apply (drule spec, drule (1) mp, drule (1) mp) + apply (drule spec, drule (1) mp, drule (1) mp) apply (auto elim: eventually_elim2) done @@ -1177,7 +1173,7 @@ lemma Lim_at_within: "(f ---> l) net ==> (f ---> l)(net within S)" unfolding tendsto_def Limits.eventually_within - apply (clarify, drule (1) bspec) + apply (clarify, drule spec, drule (1) mp, drule (1) mp) by (auto elim!: eventually_elim1) lemma Lim_within_open: @@ -1192,13 +1188,13 @@ hence "eventually (\x. x \ S \ dist (f x) l < e) (at a)" unfolding Limits.eventually_within . then obtain T where "open T" "a \ T" "\x\T. x \ a \ x \ S \ dist (f x) l < e" - unfolding eventually_at_topological open_def by fast + unfolding eventually_at_topological by fast hence "open (T \ S)" "a \ T \ S" "\x\(T \ S). x \ a \ dist (f x) l < e" using assms by auto hence "\T. open T \ a \ T \ (\x\T. x \ a \ dist (f x) l < e)" by fast hence "eventually (\x. dist (f x) l < e) (at a)" - unfolding eventually_at_topological open_def Bex_def . + unfolding eventually_at_topological . } thus ?rhs by (rule tendstoI) next @@ -1778,6 +1774,7 @@ unfolding Collect_neg_eq [symmetric] not_le apply (clarsimp simp add: open_dist, rename_tac y) apply (rule_tac x="dist x y - e" in exI, clarsimp) +apply (rename_tac x') apply (cut_tac x=x and y=x' and z=y in dist_triangle) apply simp done diff -r f7310185481d -r 5400beeddb55 src/HOL/Limits.thy --- a/src/HOL/Limits.thy Sun Jun 07 15:18:52 2009 -0700 +++ b/src/HOL/Limits.thy Sun Jun 07 17:59:54 2009 -0700 @@ -114,7 +114,7 @@ definition at :: "'a::topological_space \ 'a net" where - [code del]: "at a = Abs_net ((\S. S - {a}) ` {S\topo. a \ S})" + [code del]: "at a = Abs_net ((\S. S - {a}) ` {S. open S \ a \ S})" lemma Rep_net_sequentially: "Rep_net sequentially = range (\n. {n..})" @@ -136,13 +136,13 @@ done lemma Rep_net_at: - "Rep_net (at a) = ((\S. S - {a}) ` {S\topo. a \ S})" + "Rep_net (at a) = ((\S. S - {a}) ` {S. open S \ a \ S})" unfolding at_def apply (rule Abs_net_inverse') apply (rule image_nonempty) -apply (rule_tac x="UNIV" in exI, simp add: topo_UNIV) +apply (rule_tac x="UNIV" in exI, simp) apply (clarsimp, rename_tac S T) -apply (rule_tac x="S \ T" in exI, auto simp add: topo_Int) +apply (rule_tac x="S \ T" in exI, auto simp add: open_Int) done lemma eventually_sequentially: @@ -154,16 +154,16 @@ unfolding eventually_def Rep_net_within by auto lemma eventually_at_topological: - "eventually P (at a) \ (\S\topo. a \ S \ (\x\S. x \ a \ P x))" + "eventually P (at a) \ (\S. open S \ a \ S \ (\x\S. x \ a \ P x))" unfolding eventually_def Rep_net_at by auto lemma eventually_at: fixes a :: "'a::metric_space" shows "eventually P (at a) \ (\d>0. \x. x \ a \ dist x a < d \ P x)" -unfolding eventually_at_topological topo_dist +unfolding eventually_at_topological open_dist apply safe apply fast -apply (rule_tac x="{x. dist x a < d}" in bexI, simp) +apply (rule_tac x="{x. dist x a < d}" in exI, simp) apply clarsimp apply (rule_tac x="d - dist x a" in exI, clarsimp) apply (simp only: less_diff_eq) @@ -356,22 +356,22 @@ tendsto :: "('a \ 'b::topological_space) \ 'b \ 'a net \ bool" (infixr "--->" 55) where [code del]: - "(f ---> l) net \ (\S\topo. l \ S \ eventually (\x. f x \ S) net)" + "(f ---> l) net \ (\S. open S \ l \ S \ eventually (\x. f x \ S) net)" lemma topological_tendstoI: - "(\S. S \ topo \ l \ S \ eventually (\x. f x \ S) net) + "(\S. open S \ l \ S \ eventually (\x. f x \ S) net) \ (f ---> l) net" unfolding tendsto_def by auto lemma topological_tendstoD: - "(f ---> l) net \ S \ topo \ l \ S \ eventually (\x. f x \ S) net" + "(f ---> l) net \ open S \ l \ S \ eventually (\x. f x \ S) net" unfolding tendsto_def by auto lemma tendstoI: assumes "\e. 0 < e \ eventually (\x. dist (f x) l < e) net" shows "(f ---> l) net" apply (rule topological_tendstoI) -apply (simp add: topo_dist) +apply (simp add: open_dist) apply (drule (1) bspec, clarify) apply (drule assms) apply (erule eventually_elim1, simp) @@ -380,7 +380,7 @@ lemma tendstoD: "(f ---> l) net \ 0 < e \ eventually (\x. dist (f x) l < e) net" apply (drule_tac S="{x. dist x l < e}" in topological_tendstoD) -apply (clarsimp simp add: topo_dist) +apply (clarsimp simp add: open_dist) apply (rule_tac x="e - dist x l" in exI, clarsimp) apply (simp only: less_diff_eq) apply (erule le_less_trans [OF dist_triangle]) diff -r f7310185481d -r 5400beeddb55 src/HOL/RealVector.thy --- a/src/HOL/RealVector.thy Sun Jun 07 15:18:52 2009 -0700 +++ b/src/HOL/RealVector.thy Sun Jun 07 17:59:54 2009 -0700 @@ -418,39 +418,19 @@ subsection {* Topological spaces *} -class topo = - fixes topo :: "'a set set" - -text {* - The syntactic class uses @{term topo} instead of @{text "open"} - so that @{text "open"} and @{text closed} will have the same type. - Maybe we could use extra type constraints instead, like with - @{text dist} and @{text norm}? -*} +class "open" = + fixes "open" :: "'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" +class topological_space = "open" + + assumes open_UNIV [simp, intro]: "open UNIV" + assumes open_Int [intro]: "open S \ open T \ open (S \ T)" + assumes open_Union [intro]: "\S\K. open S \ open (\ K)" begin definition - "open" :: "'a set \ bool" where - "open S \ S \ topo" - -definition closed :: "'a set \ bool" where "closed S \ open (- S)" -lemma open_UNIV [intro, simp]: "open UNIV" - unfolding open_def by (rule topo_UNIV) - -lemma open_Int [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)" - unfolding open_def subset_eq [symmetric] by (rule topo_Union) - lemma open_empty [intro, simp]: "open {}" using open_Union [of "{}"] by simp @@ -516,10 +496,10 @@ class dist = fixes dist :: "'a \ 'a \ real" -class topo_dist = topo + dist + - assumes topo_dist: "topo = {S. \x\S. \e>0. \y. dist y x < e \ y \ S}" +class open_dist = "open" + dist + + assumes open_dist: "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" -class metric_space = topo_dist + +class metric_space = open_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 @@ -554,20 +534,20 @@ proof have "\e::real. 0 < e" by (fast intro: zero_less_one) - then show "UNIV \ topo" - unfolding topo_dist by simp + then show "open UNIV" + unfolding open_dist by simp next - fix A B assume "A \ topo" "B \ topo" - then show "A \ B \ topo" - unfolding topo_dist + fix S T assume "open S" "open T" + then show "open (S \ T)" + unfolding open_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 + fix K assume "\S\K. open S" thus "open (\K)" + unfolding open_dist by fast qed end @@ -584,7 +564,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 + topo_dist + +class real_normed_vector = real_vector + sgn_div_norm + dist_norm + open_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" @@ -621,14 +601,14 @@ 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}" +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 topo_real_def) apply (rule abs_ge_zero) apply (rule abs_eq_0) apply (rule abs_triangle_ineq) @@ -819,6 +799,11 @@ subsection {* Extra type constraints *} +text {* Only allow @{term "open"} in class @{text topological_space}. *} + +setup {* Sign.add_const_constraint + (@{const_name "open"}, SOME @{typ "'a::topological_space set \ bool"}) *} + text {* Only allow @{term dist} in class @{text metric_space}. *} setup {* Sign.add_const_constraint