# HG changeset patch # User huffman # Date 1243980802 25200 # Node ID 1d0478b16613412c6a65a3bf8fc401c714ffc9dd # Parent 3affcbc60c6d6caa3a44085a9d5adc1653e5bfb3 redefine nets as filter bases diff -r 3affcbc60c6d -r 1d0478b16613 src/HOL/Library/Topology_Euclidean_Space.thy --- a/src/HOL/Library/Topology_Euclidean_Space.thy Tue Jun 02 10:32:19 2009 -0700 +++ b/src/HOL/Library/Topology_Euclidean_Space.thy Tue Jun 02 15:13:22 2009 -0700 @@ -994,38 +994,37 @@ subsection{* A variant of nets (Slightly non-standard but good for our purposes). *} typedef (open) 'a net = - "{g :: 'a \ 'a \ bool. \x y. (\z. g z x \ g z y) \ (\z. g z y \ g z x)}" - morphisms "netord" "mknet" by blast -lemma net: "(\z. netord n z x \ netord n z y) \ (\z. netord n z y \ netord n z x)" - using netord[of n] by auto - -lemma oldnet: "netord n x x \ netord n y y \ - \z. netord n z z \ (\w. netord n w z \ netord n w x \ netord n w y)" - by (metis net) - -lemma net_dilemma: - "\a. (\x. netord net x a) \ (\x. netord net x a \ P x) \ - \b. (\x. netord net x b) \ (\x. netord net x b \ Q x) - \ \c. (\x. netord net x c) \ (\x. netord net x c \ P x \ Q x)" - by (metis net) + "{net :: 'a set set. (\A. A \ net) + \ (\A\net. \B\net. \C\net. C \ A \ C \ B)}" +proof + show "UNIV \ ?net" by auto +qed + +lemma Rep_net_nonempty: "\A. A \ Rep_net net" +using Rep_net [of net] by simp + +lemma Rep_net_directed: + "A \ Rep_net net \ B \ Rep_net net \ \C\Rep_net net. C \ A \ C \ B" +using Rep_net [of net] by simp + subsection{* Common nets and The "within" modifier for nets. *} definition at :: "'a::perfect_space \ 'a net" where - "at a = mknet(\x y. 0 < dist x a \ dist x a <= dist y a)" + "at a = Abs_net ((\r. {x. 0 < dist x a \ dist x a < r}) ` {r. 0 < r})" definition at_infinity :: "'a::real_normed_vector net" where - "at_infinity = mknet (\x y. norm x \ norm y)" + "at_infinity = Abs_net (range (\r. {x. r \ norm x}))" definition sequentially :: "nat net" where - "sequentially = mknet (\m n. n \ m)" + "sequentially = Abs_net (range (\n. {n..}))" definition within :: "'a net \ 'a set \ 'a net" (infixr "within" 70) where - "net within S = mknet (\x y. netord net x y \ x \ S)" + "net within S = Abs_net ((\A. A \ S) ` Rep_net net)" definition indirection :: "real ^'n::finite \ real ^'n \ (real ^'n) net" (infixr "indirection" 70) where @@ -1033,84 +1032,84 @@ text{* Prove That They are all nets. *} -lemma mknet_inverse': "netord (mknet r) = r \ (\x y. (\z. r z x \ r z y) \ (\z. r z y \ r z x))" - using mknet_inverse[of r] apply (auto simp add: netord_inverse) by (metis net) - -method_setup net = {* - let - val ss1 = HOL_basic_ss addsimps [@{thm expand_fun_eq} RS sym] - val ss2 = HOL_basic_ss addsimps [@{thm mknet_inverse'}] - fun tac ths = ObjectLogic.full_atomize_tac THEN' Simplifier.simp_tac (ss1 addsimps ths) THEN' Simplifier.asm_full_simp_tac ss2 - in Attrib.thms >> (fn ths => K (SIMPLE_METHOD' (tac ths))) end -*} "reduces goals about net" - -lemma at: "\x y. netord (at a) x y \ 0 < dist x a \ dist x a <= dist y a" - apply (net at_def) - by (metis dist_commute real_le_linear real_le_trans) - -lemma at_infinity: - "\x y. netord at_infinity x y \ norm x >= norm y" - apply (net at_infinity_def) - apply (metis real_le_linear real_le_trans) - done - -lemma sequentially: "\m n. netord sequentially m n \ m >= n" - apply (net sequentially_def) - apply (metis linorder_linear min_max.le_supI2 min_max.sup_absorb1) - done - -lemma within: "netord (n within S) x y \ netord n x y \ x \ S" -proof- - have "\x y. (\z. netord n z x \ z \ S \ netord n z y) \ (\z. netord n z y \ z \ S \ netord n z x)" - by (metis net) - thus ?thesis - unfolding within_def - using mknet_inverse[of "\x y. netord n x y \ x \ S"] - by simp -qed - -lemma in_direction: "netord (a indirection v) x y \ 0 < dist x a \ dist x a \ dist y a \ (\c \ 0. x - a = c *s v)" - by (simp add: within at indirection_def) +lemma Abs_net_inverse': + assumes "\A. A \ net" + assumes "\A B. A \ net \ B \ net \ \C\net. C \ A \ C \ B" + shows "Rep_net (Abs_net net) = net" +using assms by (simp add: Abs_net_inverse) + +lemma image_nonempty: "\x. x \ A \ \x. x \ f ` A" +by auto + +lemma Rep_net_at: + "Rep_net (at a) = ((\r. {x. 0 < dist x a \ dist x a < r}) ` {r. 0 < r})" +unfolding at_def +apply (rule Abs_net_inverse') +apply (rule image_nonempty, rule_tac x=1 in exI, simp) +apply (clarsimp, rename_tac r s) +apply (rule_tac x="min r s" in exI, auto) +done + +lemma Rep_net_at_infinity: + "Rep_net at_infinity = range (\r. {x. r \ norm x})" +unfolding at_infinity_def +apply (rule Abs_net_inverse') +apply (rule image_nonempty, simp) +apply (clarsimp, rename_tac r s) +apply (rule_tac x="max r s" in exI, auto) +done + +lemma Rep_net_sequentially: + "Rep_net sequentially = range (\n. {n..})" +unfolding sequentially_def +apply (rule Abs_net_inverse') +apply (rule image_nonempty, simp) +apply (clarsimp, rename_tac m n) +apply (rule_tac x="max m n" in exI, auto) +done + +lemma Rep_net_within: + "Rep_net (net within S) = (\A. A \ S) ` Rep_net net" +unfolding within_def +apply (rule Abs_net_inverse') +apply (rule image_nonempty, rule Rep_net_nonempty) +apply (clarsimp, rename_tac A B) +apply (drule (1) Rep_net_directed) +apply (clarify, rule_tac x=C in bexI, auto) +done lemma within_UNIV: "net within UNIV = net" - by (simp add: within_def netord_inverse) + by (simp add: Rep_net_inject [symmetric] Rep_net_within) subsection{* Identify Trivial limits, where we can't approach arbitrarily closely. *} definition trivial_limit :: "'a net \ bool" where - "trivial_limit (net:: 'a net) \ - (\(a::'a) b. a = b) \ - (\(a::'a) b. a \ b \ (\x. ~(netord (net) x a) \ ~(netord(net) x b)))" + "trivial_limit net \ {} \ Rep_net net" lemma trivial_limit_within: fixes a :: "'a::perfect_space" shows "trivial_limit (at a within S) \ \ a islimpt S" -proof- - {assume "\(a::'a) b. a = b" hence "\ a islimpt S" - apply (simp add: islimpt_approachable_le) - by (rule exI[where x=1], auto)} - moreover - {fix b c assume bc: "b \ c" "\x. \ netord (at a within S) x b \ \ netord (at a within S) x c" - have "dist a b > 0 \ dist a c > 0" using bc by (auto simp add: within at dist_nz[THEN sym]) - then have "\ a islimpt S" - using bc - unfolding within at dist_nz islimpt_approachable_le - by (auto simp add: dist_triangle dist_commute dist_eq_0_iff [symmetric] - simp del: dist_eq_0_iff) } - moreover - {assume "\ a islimpt S" - then obtain e where e: "e > 0" "\x' \ S. x' \ a \ dist x' a > e" - unfolding islimpt_approachable_le by (auto simp add: not_le) - from e perfect_choose_dist[of e a] obtain b where b: "b \ a" "dist b a < e" by auto - then have "a \ b" by auto - moreover have "\x. \ ((0 < dist x a \ dist x a \ dist a a) \ x \ S) \ - \ ((0 < dist x a \ dist x a \ dist b a) \ x \ S)" - using e(2) b by (auto simp add: dist_commute) - ultimately have "trivial_limit (at a within S)" - unfolding trivial_limit_def within at - by blast} - ultimately show ?thesis unfolding trivial_limit_def by blast +proof + assume "trivial_limit (at a within S)" + thus "\ a islimpt S" + unfolding trivial_limit_def + unfolding Rep_net_within Rep_net_at + unfolding islimpt_approachable_le dist_nz + apply (clarsimp simp add: not_le expand_set_eq) + apply (rule_tac x="r/2" in exI, clarsimp) + apply (drule_tac x=x' in spec, simp) + done +next + assume "\ a islimpt S" + thus "trivial_limit (at a within S)" + unfolding trivial_limit_def + unfolding Rep_net_within Rep_net_at + unfolding islimpt_approachable_le dist_nz + apply (clarsimp simp add: image_image not_le) + apply (rule_tac x=e in image_eqI) + apply (auto simp add: expand_set_eq) + done qed lemma trivial_limit_at: "\ trivial_limit (at a)" @@ -1119,113 +1118,102 @@ lemma trivial_limit_at_infinity: "\ trivial_limit (at_infinity :: ('a::{real_normed_vector,zero_neq_one}) net)" - apply (simp add: trivial_limit_def at_infinity) - by (metis order_refl zero_neq_one) + unfolding trivial_limit_def Rep_net_at_infinity + apply (clarsimp simp add: expand_set_eq) + apply (drule_tac x="scaleR r (sgn 1)" in spec) + apply (simp add: norm_scaleR norm_sgn) + done lemma trivial_limit_sequentially: "\ trivial_limit sequentially" - by (auto simp add: trivial_limit_def sequentially) + by (auto simp add: trivial_limit_def Rep_net_sequentially) subsection{* Some property holds "sufficiently close" to the limit point. *} definition eventually :: "('a \ bool) \ 'a net \ bool" where - "eventually P net \ trivial_limit net \ - (\y. (\x. netord net x y) \ (\x. netord net x y \ P x))" - -lemma eventually_happens: "eventually P net ==> trivial_limit net \ (\x. P x)" - by (metis eventually_def) - -lemma eventually_within_le: "eventually P (at a within S) \ - (\d>0. \x\S. 0 < dist x a \ dist x a <= d \ P x)" (is "?lhs = ?rhs") -proof - assume "?lhs" - moreover - { assume "\ a islimpt S" - then obtain e where "e>0" and e:"\x'\S. \ (x' \ a \ dist x' a \ e)" unfolding islimpt_approachable_le by auto - hence "?rhs" apply auto apply (rule_tac x=e in exI) by auto } - moreover - { assume "\y. (\x. netord (at a within S) x y) \ (\x. netord (at a within S) x y \ P x)" - then obtain x y where xy:"netord (at a within S) x y \ (\x. netord (at a within S) x y \ P x)" by auto - hence "?rhs" unfolding within at by auto - } - ultimately show "?rhs" unfolding eventually_def trivial_limit_within by auto -next - assume "?rhs" - then obtain d where "d>0" and d:"\x\S. 0 < dist x a \ dist x a \ d \ P x" by auto - thus "?lhs" - unfolding eventually_def trivial_limit_within islimpt_approachable_le within at unfolding dist_nz[THEN sym] by (clarsimp, rule_tac x=d in exI, auto) -qed + "eventually P net \ (\A\Rep_net net. \x\A. P x)" + +lemma eventually_at: + "eventually P (at a) \ (\d>0. \x. 0 < dist x a \ dist x a < d \ P x)" +unfolding eventually_def Rep_net_at by auto + +lemma eventually_at_infinity: + "eventually P at_infinity \ (\b. \x. norm x >= b \ P x)" +unfolding eventually_def Rep_net_at_infinity by auto + +lemma eventually_sequentially: + "eventually P sequentially \ (\N. \n\N. P n)" +unfolding eventually_def Rep_net_sequentially by auto + +lemma eventually_within_eq: + "eventually P (net within S) = eventually (\x. x \ S \ P x) net" +unfolding eventually_def Rep_net_within by auto lemma eventually_within: "eventually P (at a within S) \ (\d>0. \x\S. 0 < dist x a \ dist x a < d \ P x)" -proof- - { fix d - assume "d>0" "\x\S. 0 < dist x a \ dist x a < d \ P x" - hence "\x\S. 0 < dist x a \ dist x a \ (d/2) \ P x" using order_less_imp_le by auto - } - thus ?thesis unfolding eventually_within_le using approachable_lt_le - apply auto by (rule_tac x="d/2" in exI, auto) -qed - -lemma eventually_at: "eventually P (at a) \ (\d>0. \x. 0 < dist x a \ dist x a < d \ P x)" - apply (subst within_UNIV[symmetric]) - by (simp add: eventually_within) - -lemma eventually_sequentially: "eventually P sequentially \ (\N. \n\N. P n)" - apply (simp add: eventually_def sequentially trivial_limit_sequentially) -apply (metis dlo_simps(7) dlo_simps(9) le_maxI2 min_max.le_iff_sup min_max.sup_absorb1 order_antisym_conv) done - -(* FIXME Declare this with P::'a::some_type \ bool *) -lemma eventually_at_infinity: "eventually (P::(real^'n::finite \ bool)) at_infinity \ (\b. \x. norm x >= b \ P x)" (is "?lhs = ?rhs") -proof - assume "?lhs" thus "?rhs" - unfolding eventually_def at_infinity - by (auto simp add: trivial_limit_at_infinity) -next - assume "?rhs" - then obtain b where b:"\x. b \ norm x \ P x" and "b\0" - by (metis norm_ge_zero real_le_linear real_le_trans) - obtain y::"real^'n" where y:"norm y = b" using `b\0` - using vector_choose_size[of b] by auto - thus "?lhs" unfolding eventually_def at_infinity using b y by auto -qed +unfolding eventually_within_eq eventually_at by auto + +lemma eventually_within_le: "eventually P (at a within S) \ + (\d>0. \x\S. 0 < dist x a \ dist x a <= d \ P x)" (is "?lhs = ?rhs") +unfolding eventually_within +apply safe +apply (rule_tac x="d/2" in exI, simp) +apply (rule_tac x="d" in exI, simp) +done + +lemma eventually_happens: "eventually P net ==> trivial_limit net \ (\x. P x)" + unfolding eventually_def trivial_limit_def + using Rep_net_nonempty [of net] by auto lemma always_eventually: "(\x. P x) ==> eventually P net" - unfolding eventually_def trivial_limit_def by (clarify, simp) + unfolding eventually_def trivial_limit_def + using Rep_net_nonempty [of net] by auto lemma eventually_True [simp]: "eventually (\x. True) net" by (simp add: always_eventually) lemma trivial_limit_eventually: "trivial_limit net \ eventually P net" - unfolding eventually_def by simp + unfolding trivial_limit_def eventually_def by auto + +lemma eventually_False: "eventually (\x. False) net \ trivial_limit net" + unfolding trivial_limit_def eventually_def by auto lemma trivial_limit_eq: "trivial_limit net \ (\P. eventually P net)" - unfolding eventually_def trivial_limit_def by auto + apply (safe elim!: trivial_limit_eventually) + apply (simp add: eventually_False [symmetric]) + done text{* Combining theorems for "eventually" *} -lemma eventually_and: " eventually (\x. P x \ Q x) net \ eventually P net \ eventually Q net" - apply (simp add: eventually_def) - apply (cases "trivial_limit net") - using net_dilemma[of net P Q] by auto +lemma eventually_conjI: + "\eventually (\x. P x) net; eventually (\x. Q x) net\ + \ eventually (\x. P x \ Q x) net" +unfolding eventually_def +apply (clarify, rename_tac A B) +apply (drule (1) Rep_net_directed, clarify) +apply (rule_tac x=C in bexI, auto) +done lemma eventually_mono: "(\x. P x \ Q x) \ eventually P net \ eventually Q net" by (metis eventually_def) +lemma eventually_rev_mono: + "eventually P net \ (\x. P x \ Q x) \ eventually Q net" +using eventually_mono [of P Q] by fast + +lemma eventually_and: " eventually (\x. P x \ Q x) net \ eventually P net \ eventually Q net" + by (auto intro!: eventually_conjI elim: eventually_rev_mono) + lemma eventually_mp: "eventually (\x. P x \ Q x) net \ eventually P net \ eventually Q net" apply (atomize(full)) unfolding imp_conjL[symmetric] eventually_and[symmetric] by (auto simp add: eventually_def) lemma eventually_false: "eventually (\x. False) net \ trivial_limit net" - by (auto simp add: eventually_def) - -lemma not_eventually: "(\x. \ P x ) \ ~(trivial_limit net) ==> ~(eventually P net)" - by (auto simp add: eventually_def) - -lemma eventually_rev_mono: - "eventually P net \ (\x. P x \ Q x) \ eventually Q net" -using eventually_mono [of P Q] by fast + by (auto simp add: eventually_False) + +lemma not_eventually: "(\x. \ P x ) \ ~(trivial_limit net) ==> ~(eventually (\x. P x) net)" + by (simp add: eventually_False) lemma eventually_rev_mp: assumes 1: "eventually (\x. P x) net" @@ -1233,11 +1221,6 @@ shows "eventually (\x. Q x) net" using 2 1 by (rule eventually_mp) -lemma eventually_conjI: - "\eventually (\x. P x) net; eventually (\x. Q x) net\ - \ eventually (\x. P x \ Q x) net" -by (simp add: eventually_and) - subsection{* Limits, defined as vacuously true when the limit is trivial. *} definition tendsto:: "('a \ 'b::metric_space) \ 'b \ 'a net \ bool" (infixr "--->" 55) where @@ -1682,20 +1665,36 @@ text{* It's also sometimes useful to extract the limit point from the net. *} -definition "netlimit net = (SOME a. \x. ~(netord net x a))" - -lemma netlimit_within: assumes"~(trivial_limit (at a within S))" - shows "(netlimit (at a within S) = a)" -proof- - { fix x assume "x \ a" - then obtain y where y:"dist y a \ dist a a \ 0 < dist y a \ y \ S \ dist y a \ dist x a \ 0 < dist y a \ y \ S" using assms unfolding trivial_limit_def within at by blast - assume "\y. \ netord (at a within S) y x" - hence "x = a" using y unfolding within at by (auto simp add: dist_nz) - } - moreover - have "\y. \ netord (at a within S) y a" using assms unfolding trivial_limit_def within at by auto - ultimately show ?thesis unfolding netlimit_def using some_equality[of "\x. \y. \ netord (at a within S) y x"] by blast -qed +definition + netlimit :: "'a::metric_space net \ 'a" where + "netlimit net = (SOME a. \r>0. \A\Rep_net net. \x\A. dist x a < r)" + +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" +using assms +apply (simp add: trivial_limit_within) +apply (simp add: netlimit_def Rep_net_within Rep_net_at) +apply (rule some_equality, fast) +apply (rename_tac b) +apply (rule ccontr) +apply (drule_tac x="dist b a / 2" in spec, drule mp, simp add: dist_nz) +apply (clarify, rename_tac r) +apply (simp only: islimpt_approachable) +apply (drule_tac x="min r (dist b a / 2)" in spec, drule mp, simp add: dist_nz) +apply (clarify) +apply (drule_tac x=x' in bspec, simp add: dist_nz) +apply (subgoal_tac "dist b a < dist b a / 2 + dist b a / 2", simp) +apply (rule le_less_trans [OF dist_triangle3]) +apply (erule add_strict_mono) +apply simp +done lemma netlimit_at: "netlimit (at a) = a" apply (subst within_UNIV[symmetric]) @@ -3345,26 +3344,26 @@ text{* Combination results for pointwise continuity. *} -lemma continuous_const: "continuous net (\x::'a::zero_neq_one. c)" +lemma continuous_const: "continuous net (\x. c)" by (auto simp add: continuous_def Lim_const) lemma continuous_cmul: - fixes f :: "'a \ real ^ 'n::finite" + fixes f :: "'a::metric_space \ real ^ 'n::finite" shows "continuous net f ==> continuous net (\x. c *s f x)" by (auto simp add: continuous_def Lim_cmul) lemma continuous_neg: - fixes f :: "'a \ 'b::real_normed_vector" + fixes f :: "'a::metric_space \ 'b::real_normed_vector" shows "continuous net f ==> continuous net (\x. -(f x))" by (auto simp add: continuous_def Lim_neg) lemma continuous_add: - fixes f g :: "'a \ 'b::real_normed_vector" + fixes f g :: "'a::metric_space \ 'b::real_normed_vector" shows "continuous net f \ continuous net g \ continuous net (\x. f x + g x)" by (auto simp add: continuous_def Lim_add) lemma continuous_sub: - fixes f g :: "'a \ 'b::real_normed_vector" + fixes f g :: "'a::metric_space \ 'b::real_normed_vector" shows "continuous net f \ continuous net g \ continuous net (\x. f x - g x)" by (auto simp add: continuous_def Lim_sub) @@ -4115,12 +4114,12 @@ using Lim_mul[of c d net "\x. v" v] using Lim_const[of v] by auto lemma continuous_vmul: - fixes c :: "'a \ real" + fixes c :: "'a::metric_space \ real" shows "continuous net (vec1 o c) ==> continuous net (\x. c(x) *s v)" unfolding continuous_def using Lim_vmul[of c] by auto lemma continuous_mul: - fixes c :: "'a \ real" + fixes c :: "'a::metric_space \ real" shows "continuous net (vec1 o c) \ continuous net f ==> continuous net (\x. c(x) *s f x) " unfolding continuous_def using Lim_mul[of c] by auto @@ -4175,7 +4174,7 @@ qed lemma continuous_inv: - fixes f :: "'a \ real" + fixes f :: "'a::metric_space \ real" shows "continuous net (vec1 o f) \ f(netlimit net) \ 0 ==> continuous net (vec1 o inverse o f)" unfolding continuous_def using Lim_inv by auto