# HG changeset patch # User huffman # Date 1243614176 25200 # Node ID d41a8ba25b674ece945f773a9396c76c92f9949e # Parent a9ed5fcc5e39a32514931986a1ba2e83b9901310 generalize constants from Lim.thy to class metric_space diff -r a9ed5fcc5e39 -r d41a8ba25b67 src/HOL/Deriv.thy --- a/src/HOL/Deriv.thy Thu May 28 23:03:12 2009 -0700 +++ b/src/HOL/Deriv.thy Fri May 29 09:22:56 2009 -0700 @@ -76,7 +76,7 @@ hence "(\h. f(x+h) - f(x)) -- 0 --> 0" by (simp cong: LIM_cong) thus "(\h. f(x+h)) -- 0 --> f(x)" - by (simp add: LIM_def) + by (simp add: LIM_def dist_norm) qed lemma DERIV_mult_lemma: @@ -125,6 +125,7 @@ text{*Alternative definition for differentiability*} lemma DERIV_LIM_iff: + fixes f :: "'a::{real_normed_vector,inverse} \ 'a" shows "((%h. (f(a + h) - f(a)) / h) -- 0 --> D) = ((%x. (f(x)-f(a)) / (x-a)) -- a --> D)" apply (rule iffI) @@ -614,7 +615,7 @@ apply (cut_tac P = "% (u,v) . a \ u & u \ v & v \ b --> ~ (f (u) \ y & y \ f (v))" in lemma_BOLZANO2) apply safe apply simp_all -apply (simp add: isCont_iff LIM_def) +apply (simp add: isCont_iff LIM_eq) apply (rule ccontr) apply (subgoal_tac "a \ x & x \ b") prefer 2 @@ -675,7 +676,7 @@ apply (case_tac "a \ x & x \ b") apply (rule_tac [2] x = 1 in exI) prefer 2 apply force -apply (simp add: LIM_def isCont_iff) +apply (simp add: LIM_eq isCont_iff) apply (drule_tac x = x in spec, auto) apply (erule_tac V = "\M. \x. a \ x & x \ b & ~ f x \ M" in thin_rl) apply (drule_tac x = 1 in spec, auto) @@ -1486,7 +1487,7 @@ lemma LIM_fun_gt_zero: "[| f -- c --> (l::real); 0 < l |] ==> \r. 0 < r & (\x::real. x \ c & \c - x\ < r --> 0 < f x)" -apply (auto simp add: LIM_def) +apply (auto simp add: LIM_eq) apply (drule_tac x = "l/2" in spec, safe, force) apply (rule_tac x = s in exI) apply (auto simp only: abs_less_iff) @@ -1495,7 +1496,7 @@ lemma LIM_fun_less_zero: "[| f -- c --> (l::real); l < 0 |] ==> \r. 0 < r & (\x::real. x \ c & \c - x\ < r --> f x < 0)" -apply (auto simp add: LIM_def) +apply (auto simp add: LIM_eq) apply (drule_tac x = "-l/2" in spec, safe, force) apply (rule_tac x = s in exI) apply (auto simp only: abs_less_iff) diff -r a9ed5fcc5e39 -r d41a8ba25b67 src/HOL/Integration.thy --- a/src/HOL/Integration.thy Thu May 28 23:03:12 2009 -0700 +++ b/src/HOL/Integration.thy Fri May 29 09:22:56 2009 -0700 @@ -272,7 +272,7 @@ fix x :: real assume "a \ x" and "x \ b" with f' have "DERIV f x :> f'(x)" by simp then have "\r>0. \s>0. \z. z \ x \ \z - x\ < s \ \(f z - f x) / (z - x) - f' x\ < r" - by (simp add: DERIV_iff2 LIM_def) + by (simp add: DERIV_iff2 LIM_eq) with `0 < e` obtain s where "\z. z \ x \ \z - x\ < s \ \(f z - f x) / (z - x) - f' x\ < e/2" and "0 < s" by (drule_tac x="e/2" in spec, auto) diff -r a9ed5fcc5e39 -r d41a8ba25b67 src/HOL/Lim.thy --- a/src/HOL/Lim.thy Thu May 28 23:03:12 2009 -0700 +++ b/src/HOL/Lim.thy Fri May 29 09:22:56 2009 -0700 @@ -13,90 +13,110 @@ text{*Standard Definitions*} definition - LIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool" + LIM :: "['a::metric_space \ 'b::metric_space, 'a, 'b] \ bool" ("((_)/ -- (_)/ --> (_))" [60, 0, 60] 60) where [code del]: "f -- a --> L = - (\r > 0. \s > 0. \x. x \ a & norm (x - a) < s - --> norm (f x - L) < r)" + (\r > 0. \s > 0. \x. x \ a & dist x a < s + --> dist (f x) L < r)" definition - isCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool" where + isCont :: "['a::metric_space \ 'b::metric_space, 'a] \ bool" where "isCont f a = (f -- a --> (f a))" definition - isUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool" where - [code del]: "isUCont f = (\r>0. \s>0. \x y. norm (x - y) < s \ norm (f x - f y) < r)" + isUCont :: "['a::metric_space \ 'b::metric_space] \ bool" where + [code del]: "isUCont f = (\r>0. \s>0. \x y. dist x y < s \ dist (f x) (f y) < r)" subsection {* Limits of Functions *} -subsubsection {* Purely standard proofs *} +lemma metric_LIM_I: + "(\r. 0 < r \ \s>0. \x. x \ a \ dist x a < s \ dist (f x) L < r) + \ f -- a --> L" +by (simp add: LIM_def) + +lemma metric_LIM_D: + "\f -- a --> L; 0 < r\ + \ \s>0. \x. x \ a \ dist x a < s \ dist (f x) L < r" +by (simp add: LIM_def) lemma LIM_eq: - "f -- a --> L = + fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector" + shows "f -- a --> L = (\r>0.\s>0.\x. x \ a & norm (x-a) < s --> norm (f x - L) < r)" -by (simp add: LIM_def diff_minus) +by (simp add: LIM_def dist_norm) lemma LIM_I: - "(!!r. 0 \s>0.\x. x \ a & norm (x-a) < s --> norm (f x - L) < r) + fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector" + shows "(!!r. 0 \s>0.\x. x \ a & norm (x-a) < s --> norm (f x - L) < r) ==> f -- a --> L" by (simp add: LIM_eq) lemma LIM_D: - "[| f -- a --> L; 0 L; 0 \s>0.\x. x \ a & norm (x-a) < s --> norm (f x - L) < r" by (simp add: LIM_eq) -lemma LIM_offset: "f -- a --> L \ (\x. f (x + k)) -- a - k --> L" -apply (rule LIM_I) -apply (drule_tac r="r" in LIM_D, safe) +lemma LIM_offset: + fixes a :: "'a::real_normed_vector" and L :: "'b::metric_space" + shows "f -- a --> L \ (\x. f (x + k)) -- a - k --> L" +unfolding LIM_def dist_norm +apply clarify +apply (drule_tac x="r" in spec, safe) apply (rule_tac x="s" in exI, safe) apply (drule_tac x="x + k" in spec) apply (simp add: algebra_simps) done -lemma LIM_offset_zero: "f -- a --> L \ (\h. f (a + h)) -- 0 --> L" +lemma LIM_offset_zero: + fixes a :: "'a::real_normed_vector" and L :: "'b::metric_space" + shows "f -- a --> L \ (\h. f (a + h)) -- 0 --> L" by (drule_tac k="a" in LIM_offset, simp add: add_commute) -lemma LIM_offset_zero_cancel: "(\h. f (a + h)) -- 0 --> L \ f -- a --> L" +lemma LIM_offset_zero_cancel: + fixes a :: "'a::real_normed_vector" and L :: "'b::metric_space" + shows "(\h. f (a + h)) -- 0 --> L \ f -- a --> L" by (drule_tac k="- a" in LIM_offset, simp) lemma LIM_const [simp]: "(%x. k) -- x --> k" by (simp add: LIM_def) lemma LIM_add: - fixes f g :: "'a::real_normed_vector \ 'b::real_normed_vector" + fixes f g :: "'a::metric_space \ 'b::real_normed_vector" assumes f: "f -- a --> L" and g: "g -- a --> M" - shows "(%x. f x + g(x)) -- a --> (L + M)" -proof (rule LIM_I) + shows "(\x. f x + g x) -- a --> (L + M)" +proof (rule metric_LIM_I) fix r :: real assume r: "0 < r" - from LIM_D [OF f half_gt_zero [OF r]] + from metric_LIM_D [OF f half_gt_zero [OF r]] obtain fs where fs: "0 < fs" - and fs_lt: "\x. x \ a & norm (x-a) < fs --> norm (f x - L) < r/2" + and fs_lt: "\x. x \ a \ dist x a < fs \ dist (f x) L < r/2" by blast - from LIM_D [OF g half_gt_zero [OF r]] + from metric_LIM_D [OF g half_gt_zero [OF r]] obtain gs where gs: "0 < gs" - and gs_lt: "\x. x \ a & norm (x-a) < gs --> norm (g x - M) < r/2" + and gs_lt: "\x. x \ a \ dist x a < gs \ dist (g x) M < r/2" by blast - show "\s>0.\x. x \ a \ norm (x-a) < s \ norm (f x + g x - (L + M)) < r" + show "\s>0. \x. x \ a \ dist x a < s \ dist (f x + g x) (L + M) < r" proof (intro exI conjI strip) show "0 < min fs gs" by (simp add: fs gs) fix x :: 'a - assume "x \ a \ norm (x-a) < min fs gs" - hence "x \ a \ norm (x-a) < fs \ norm (x-a) < gs" by simp + assume "x \ a \ dist x a < min fs gs" + hence "x \ a \ dist x a < fs \ dist x a < gs" by simp with fs_lt gs_lt - have "norm (f x - L) < r/2" and "norm (g x - M) < r/2" by blast+ - hence "norm (f x - L) + norm (g x - M) < r" by arith - thus "norm (f x + g x - (L + M)) < r" + have "dist (f x) L < r/2" and "dist (g x) M < r/2" by blast+ + hence "dist (f x) L + dist (g x) M < r" by arith + thus "dist (f x + g x) (L + M) < r" + unfolding dist_norm by (blast intro: norm_diff_triangle_ineq order_le_less_trans) qed qed lemma LIM_add_zero: - "\f -- a --> 0; g -- a --> 0\ \ (\x. f x + g x) -- a --> 0" + fixes f g :: "'a::metric_space \ 'b::real_normed_vector" + shows "\f -- a --> 0; g -- a --> 0\ \ (\x. f x + g x) -- a --> 0" by (drule (1) LIM_add, simp) lemma minus_diff_minus: @@ -104,46 +124,75 @@ shows "(- a) - (- b) = - (a - b)" by simp -lemma LIM_minus: "f -- a --> L ==> (%x. -f(x)) -- a --> -L" -by (simp only: LIM_eq minus_diff_minus norm_minus_cancel) +lemma LIM_minus: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "f -- a --> L \ (\x. - f x) -- a --> - L" +by (simp only: LIM_def dist_norm minus_diff_minus norm_minus_cancel) +(* TODO: delete *) lemma LIM_add_minus: - "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)" + fixes f g :: "'a::metric_space \ 'b::real_normed_vector" + shows "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)" by (intro LIM_add LIM_minus) lemma LIM_diff: - "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) - g(x)) -- x --> l-m" + fixes f g :: "'a::metric_space \ 'b::real_normed_vector" + shows "\f -- x --> l; g -- x --> m\ \ (\x. f x - g x) -- x --> l - m" by (simp only: diff_minus LIM_add LIM_minus) -lemma LIM_zero: "f -- a --> l \ (\x. f x - l) -- a --> 0" -by (simp add: LIM_def) +lemma LIM_zero: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "f -- a --> l \ (\x. f x - l) -- a --> 0" +by (simp add: LIM_def dist_norm) -lemma LIM_zero_cancel: "(\x. f x - l) -- a --> 0 \ f -- a --> l" -by (simp add: LIM_def) +lemma LIM_zero_cancel: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "(\x. f x - l) -- a --> 0 \ f -- a --> l" +by (simp add: LIM_def dist_norm) -lemma LIM_zero_iff: "(\x. f x - l) -- a --> 0 = f -- a --> l" -by (simp add: LIM_def) +lemma LIM_zero_iff: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "(\x. f x - l) -- a --> 0 = f -- a --> l" +by (simp add: LIM_def dist_norm) -lemma LIM_imp_LIM: +lemma metric_LIM_imp_LIM: assumes f: "f -- a --> l" - assumes le: "\x. x \ a \ norm (g x - m) \ norm (f x - l)" + assumes le: "\x. x \ a \ dist (g x) m \ dist (f x) l" shows "g -- a --> m" -apply (rule LIM_I, drule LIM_D [OF f], safe) +apply (rule metric_LIM_I, drule metric_LIM_D [OF f], safe) apply (rule_tac x="s" in exI, safe) apply (drule_tac x="x" in spec, safe) apply (erule (1) order_le_less_trans [OF le]) done -lemma LIM_norm: "f -- a --> l \ (\x. norm (f x)) -- a --> norm l" +lemma LIM_imp_LIM: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + fixes g :: "'a::metric_space \ 'c::real_normed_vector" + assumes f: "f -- a --> l" + assumes le: "\x. x \ a \ norm (g x - m) \ norm (f x - l)" + shows "g -- a --> m" +apply (rule metric_LIM_imp_LIM [OF f]) +apply (simp add: dist_norm le) +done + +lemma LIM_norm: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "f -- a --> l \ (\x. norm (f x)) -- a --> norm l" by (erule LIM_imp_LIM, simp add: norm_triangle_ineq3) -lemma LIM_norm_zero: "f -- a --> 0 \ (\x. norm (f x)) -- a --> 0" +lemma LIM_norm_zero: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "f -- a --> 0 \ (\x. norm (f x)) -- a --> 0" by (drule LIM_norm, simp) -lemma LIM_norm_zero_cancel: "(\x. norm (f x)) -- a --> 0 \ f -- a --> 0" +lemma LIM_norm_zero_cancel: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "(\x. norm (f x)) -- a --> 0 \ f -- a --> 0" by (erule LIM_imp_LIM, simp) -lemma LIM_norm_zero_iff: "(\x. norm (f x)) -- a --> 0 = f -- a --> 0" +lemma LIM_norm_zero_iff: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "(\x. norm (f x)) -- a --> 0 = f -- a --> 0" by (rule iffI [OF LIM_norm_zero_cancel LIM_norm_zero]) lemma LIM_rabs: "f -- a --> (l::real) \ (\x. \f x\) -- a --> \l\" @@ -161,9 +210,9 @@ lemma LIM_const_not_eq: fixes a :: "'a::real_normed_algebra_1" shows "k \ L \ \ (\x. k) -- a --> L" -apply (simp add: LIM_eq) -apply (rule_tac x="norm (k - L)" in exI, simp, safe) -apply (rule_tac x="a + of_real (s/2)" in exI, simp add: norm_of_real) +apply (simp add: LIM_def) +apply (rule_tac x="dist k L" in exI, simp add: zero_less_dist_iff, safe) +apply (rule_tac x="a + of_real (s/2)" in exI, simp add: dist_norm) done lemmas LIM_not_zero = LIM_const_not_eq [where L = 0] @@ -176,10 +225,21 @@ done lemma LIM_unique: - fixes a :: "'a::real_normed_algebra_1" + fixes a :: "'a::real_normed_algebra_1" -- {* TODO: find a more appropriate class *} shows "\f -- a --> L; f -- a --> M\ \ L = M" -apply (drule (1) LIM_diff) -apply (auto dest!: LIM_const_eq) +apply (rule ccontr) +apply (drule_tac r="dist L M / 2" in metric_LIM_D, simp add: zero_less_dist_iff) +apply (drule_tac r="dist L M / 2" in metric_LIM_D, simp add: zero_less_dist_iff) +apply (clarify, rename_tac r s) +apply (subgoal_tac "min r s \ 0") +apply (subgoal_tac "dist L M < dist L M / 2 + dist L M / 2", simp) +apply (subgoal_tac "dist L M \ dist (f (a + of_real (min r s / 2))) L + + dist (f (a + of_real (min r s / 2))) M") +apply (erule le_less_trans, rule add_strict_mono) +apply (drule spec, erule mp, simp add: dist_norm) +apply (drule spec, erule mp, simp add: dist_norm) +apply (subst dist_commute, rule dist_triangle) +apply simp done lemma LIM_ident [simp]: "(\x. x) -- a --> a" @@ -195,9 +255,9 @@ \ ((\x. f x) -- a --> l) = ((\x. g x) -- b --> m)" by (simp add: LIM_def) -lemma LIM_equal2: +lemma metric_LIM_equal2: assumes 1: "0 < R" - assumes 2: "\x. \x \ a; norm (x - a) < R\ \ f x = g x" + assumes 2: "\x. \x \ a; dist x a < R\ \ f x = g x" shows "g -- a --> l \ f -- a --> l" apply (unfold LIM_def, safe) apply (drule_tac x="r" in spec, safe) @@ -206,9 +266,22 @@ apply (simp add: 2) done -text{*Two uses in Hyperreal/Transcendental.ML*} +lemma LIM_equal2: + fixes f g :: "'a::real_normed_vector \ 'b::metric_space" + assumes 1: "0 < R" + assumes 2: "\x. \x \ a; norm (x - a) < R\ \ f x = g x" + shows "g -- a --> l \ f -- a --> l" +apply (unfold LIM_def dist_norm, safe) +apply (drule_tac x="r" in spec, safe) +apply (rule_tac x="min s R" in exI, safe) +apply (simp add: 1) +apply (simp add: 2) +done + +text{*Two uses in Transcendental.ML*} lemma LIM_trans: - "[| (%x. f(x) + -g(x)) -- a --> 0; g -- a --> l |] ==> f -- a --> l" + fixes f g :: "'a::metric_space \ 'b::real_normed_vector" + shows "[| (%x. f(x) + -g(x)) -- a --> 0; g -- a --> l |] ==> f -- a --> l" apply (drule LIM_add, assumption) apply (auto simp add: add_assoc) done @@ -217,62 +290,70 @@ assumes g: "g -- l --> g l" assumes f: "f -- a --> l" shows "(\x. g (f x)) -- a --> g l" -proof (rule LIM_I) +proof (rule metric_LIM_I) fix r::real assume r: "0 < r" obtain s where s: "0 < s" - and less_r: "\y. \y \ l; norm (y - l) < s\ \ norm (g y - g l) < r" - using LIM_D [OF g r] by fast + and less_r: "\y. \y \ l; dist y l < s\ \ dist (g y) (g l) < r" + using metric_LIM_D [OF g r] by fast obtain t where t: "0 < t" - and less_s: "\x. \x \ a; norm (x - a) < t\ \ norm (f x - l) < s" - using LIM_D [OF f s] by fast + and less_s: "\x. \x \ a; dist x a < t\ \ dist (f x) l < s" + using metric_LIM_D [OF f s] by fast - show "\t>0. \x. x \ a \ norm (x - a) < t \ norm (g (f x) - g l) < r" + show "\t>0. \x. x \ a \ dist x a < t \ dist (g (f x)) (g l) < r" proof (rule exI, safe) show "0 < t" using t . next - fix x assume "x \ a" and "norm (x - a) < t" - hence "norm (f x - l) < s" by (rule less_s) - thus "norm (g (f x) - g l) < r" + fix x assume "x \ a" and "dist x a < t" + hence "dist (f x) l < s" by (rule less_s) + thus "dist (g (f x)) (g l) < r" using r less_r by (case_tac "f x = l", simp_all) qed qed +lemma metric_LIM_compose2: + assumes f: "f -- a --> b" + assumes g: "g -- b --> c" + assumes inj: "\d>0. \x. x \ a \ dist x a < d \ f x \ b" + shows "(\x. g (f x)) -- a --> c" +proof (rule metric_LIM_I) + fix r :: real + assume r: "0 < r" + obtain s where s: "0 < s" + and less_r: "\y. \y \ b; dist y b < s\ \ dist (g y) c < r" + using metric_LIM_D [OF g r] by fast + obtain t where t: "0 < t" + and less_s: "\x. \x \ a; dist x a < t\ \ dist (f x) b < s" + using metric_LIM_D [OF f s] by fast + obtain d where d: "0 < d" + and neq_b: "\x. \x \ a; dist x a < d\ \ f x \ b" + using inj by fast + + show "\t>0. \x. x \ a \ dist x a < t \ dist (g (f x)) c < r" + proof (safe intro!: exI) + show "0 < min d t" using d t by simp + next + fix x + assume "x \ a" and "dist x a < min d t" + hence "f x \ b" and "dist (f x) b < s" + using neq_b less_s by simp_all + thus "dist (g (f x)) c < r" + by (rule less_r) + qed +qed + lemma LIM_compose2: + fixes a :: "'a::real_normed_vector" assumes f: "f -- a --> b" assumes g: "g -- b --> c" assumes inj: "\d>0. \x. x \ a \ norm (x - a) < d \ f x \ b" shows "(\x. g (f x)) -- a --> c" -proof (rule LIM_I) - fix r :: real - assume r: "0 < r" - obtain s where s: "0 < s" - and less_r: "\y. \y \ b; norm (y - b) < s\ \ norm (g y - c) < r" - using LIM_D [OF g r] by fast - obtain t where t: "0 < t" - and less_s: "\x. \x \ a; norm (x - a) < t\ \ norm (f x - b) < s" - using LIM_D [OF f s] by fast - obtain d where d: "0 < d" - and neq_b: "\x. \x \ a; norm (x - a) < d\ \ f x \ b" - using inj by fast - - show "\t>0. \x. x \ a \ norm (x - a) < t \ norm (g (f x) - c) < r" - proof (safe intro!: exI) - show "0 < min d t" using d t by simp - next - fix x - assume "x \ a" and "norm (x - a) < min d t" - hence "f x \ b" and "norm (f x - b) < s" - using neq_b less_s by simp_all - thus "norm (g (f x) - c) < r" - by (rule less_r) - qed -qed +by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]]) lemma LIM_o: "\g -- l --> g l; f -- a --> l\ \ (g \ f) -- a --> g l" unfolding o_def by (rule LIM_compose) lemma real_LIM_sandwich_zero: - fixes f g :: "'a::real_normed_vector \ real" + fixes f g :: "'a::metric_space \ real" assumes f: "f -- a --> 0" assumes 1: "\x. x \ a \ 0 \ g x" assumes 2: "\x. x \ a \ g x \ f x" @@ -316,10 +397,11 @@ text {* Bounded Bilinear Operators *} lemma (in bounded_bilinear) LIM_prod_zero: + fixes a :: "'d::metric_space" assumes f: "f -- a --> 0" assumes g: "g -- a --> 0" shows "(\x. f x ** g x) -- a --> 0" -proof (rule LIM_I) +proof (rule metric_LIM_I, unfold dist_norm) fix r::real assume r: "0 < r" obtain K where K: "0 < K" and norm_le: "\x y. norm (x ** y) \ norm x * norm y * K" @@ -327,18 +409,18 @@ from K have K': "0 < inverse K" by (rule positive_imp_inverse_positive) obtain s where s: "0 < s" - and norm_f: "\x. \x \ a; norm (x - a) < s\ \ norm (f x) < r" - using LIM_D [OF f r] by auto + and norm_f: "\x. \x \ a; dist x a < s\ \ norm (f x) < r" + using metric_LIM_D [OF f r, unfolded dist_norm] by auto obtain t where t: "0 < t" - and norm_g: "\x. \x \ a; norm (x - a) < t\ \ norm (g x) < inverse K" - using LIM_D [OF g K'] by auto - show "\s>0. \x. x \ a \ norm (x - a) < s \ norm (f x ** g x - 0) < r" + and norm_g: "\x. \x \ a; dist x a < t\ \ norm (g x) < inverse K" + using metric_LIM_D [OF g K', unfolded dist_norm] by auto + show "\s>0. \x. x \ a \ dist x a < s \ norm (f x ** g x - 0) < r" proof (rule exI, safe) from s t show "0 < min s t" by simp next fix x assume x: "x \ a" - assume "norm (x - a) < min s t" - hence xs: "norm (x - a) < s" and xt: "norm (x - a) < t" by simp_all + assume "dist x a < min s t" + hence xs: "dist x a < s" and xt: "dist x a < t" by simp_all from x xs have 1: "norm (f x) < r" by (rule norm_f) from x xt have 2: "norm (g x) < inverse K" by (rule norm_g) have "norm (f x ** g x) \ norm (f x) * norm (g x) * K" by (rule norm_le) @@ -383,7 +465,7 @@ lemmas LIM_of_real = of_real.LIM lemma LIM_power: - fixes f :: "'a::real_normed_vector \ 'b::{power,real_normed_algebra}" + fixes f :: "'a::metric_space \ 'b::{power,real_normed_algebra}" assumes f: "f -- a --> l" shows "(\x. f x ^ n) -- a --> l ^ n" by (induct n, simp, simp add: LIM_mult f) @@ -453,19 +535,22 @@ by (rule LIM_inverse_fun [THEN LIM_compose]) lemma LIM_sgn: - "\f -- a --> l; l \ 0\ \ (\x. sgn (f x)) -- a --> sgn l" + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "\f -- a --> l; l \ 0\ \ (\x. sgn (f x)) -- a --> sgn l" unfolding sgn_div_norm by (simp add: LIM_scaleR LIM_inverse LIM_norm) subsection {* Continuity *} -subsubsection {* Purely standard proofs *} - -lemma LIM_isCont_iff: "(f -- a --> f a) = ((\h. f (a + h)) -- 0 --> f a)" +lemma LIM_isCont_iff: + fixes f :: "'a::real_normed_vector \ 'b::metric_space" + shows "(f -- a --> f a) = ((\h. f (a + h)) -- 0 --> f a)" by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel]) -lemma isCont_iff: "isCont f x = (\h. f (x + h)) -- 0 --> f x" +lemma isCont_iff: + fixes f :: "'a::real_normed_vector \ 'b::metric_space" + shows "isCont f x = (\h. f (x + h)) -- 0 --> f x" by (simp add: isCont_def LIM_isCont_iff) lemma isCont_ident [simp]: "isCont (\x. x) a" @@ -474,28 +559,36 @@ lemma isCont_const [simp]: "isCont (\x. k) a" unfolding isCont_def by (rule LIM_const) -lemma isCont_norm: "isCont f a \ isCont (\x. norm (f x)) a" +lemma isCont_norm: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "isCont f a \ isCont (\x. norm (f x)) a" unfolding isCont_def by (rule LIM_norm) lemma isCont_rabs: "isCont f a \ isCont (\x. \f x :: real\) a" unfolding isCont_def by (rule LIM_rabs) -lemma isCont_add: "\isCont f a; isCont g a\ \ isCont (\x. f x + g x) a" +lemma isCont_add: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "\isCont f a; isCont g a\ \ isCont (\x. f x + g x) a" unfolding isCont_def by (rule LIM_add) -lemma isCont_minus: "isCont f a \ isCont (\x. - f x) a" +lemma isCont_minus: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "isCont f a \ isCont (\x. - f x) a" unfolding isCont_def by (rule LIM_minus) -lemma isCont_diff: "\isCont f a; isCont g a\ \ isCont (\x. f x - g x) a" +lemma isCont_diff: + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "\isCont f a; isCont g a\ \ isCont (\x. f x - g x) a" unfolding isCont_def by (rule LIM_diff) lemma isCont_mult: - fixes f g :: "'a::real_normed_vector \ 'b::real_normed_algebra" + fixes f g :: "'a::metric_space \ 'b::real_normed_algebra" shows "\isCont f a; isCont g a\ \ isCont (\x. f x * g x) a" unfolding isCont_def by (rule LIM_mult) lemma isCont_inverse: - fixes f :: "'a::real_normed_vector \ 'b::real_normed_div_algebra" + fixes f :: "'a::metric_space \ 'b::real_normed_div_algebra" shows "\isCont f a; f a \ 0\ \ isCont (\x. inverse (f x)) a" unfolding isCont_def by (rule LIM_inverse) @@ -503,7 +596,15 @@ "\isCont g l; f -- a --> l\ \ (\x. g (f x)) -- a --> g l" unfolding isCont_def by (rule LIM_compose) +lemma metric_isCont_LIM_compose2: + assumes f [unfolded isCont_def]: "isCont f a" + assumes g: "g -- f a --> l" + assumes inj: "\d>0. \x. x \ a \ dist x a < d \ f x \ f a" + shows "(\x. g (f x)) -- a --> l" +by (rule metric_LIM_compose2 [OF f g inj]) + lemma isCont_LIM_compose2: + fixes a :: "'a::real_normed_vector" assumes f [unfolded isCont_def]: "isCont f a" assumes g: "g -- f a --> l" assumes inj: "\d>0. \x. x \ a \ norm (x - a) < d \ f x \ f a" @@ -526,22 +627,25 @@ lemmas isCont_scaleR = scaleR.isCont lemma isCont_of_real: - "isCont f a \ isCont (\x. of_real (f x)) a" + "isCont f a \ isCont (\x. of_real (f x)::'b::real_normed_algebra_1) a" unfolding isCont_def by (rule LIM_of_real) lemma isCont_power: - fixes f :: "'a::real_normed_vector \ 'b::{power,real_normed_algebra}" + fixes f :: "'a::metric_space \ 'b::{power,real_normed_algebra}" shows "isCont f a \ isCont (\x. f x ^ n) a" unfolding isCont_def by (rule LIM_power) lemma isCont_sgn: - "\isCont f a; f a \ 0\ \ isCont (\x. sgn (f x)) a" + fixes f :: "'a::metric_space \ 'b::real_normed_vector" + shows "\isCont f a; f a \ 0\ \ isCont (\x. sgn (f x)) a" unfolding isCont_def by (rule LIM_sgn) lemma isCont_abs [simp]: "isCont abs (a::real)" by (rule isCont_rabs [OF isCont_ident]) -lemma isCont_setsum: fixes A :: "nat set" assumes "finite A" +lemma isCont_setsum: + fixes f :: "'a \ 'b::metric_space \ 'c::real_normed_vector" + fixes A :: "'a set" assumes "finite A" shows "\ i \ A. isCont (f i) x \ isCont (\ x. \ i \ A. f i x) x" using `finite A` proof induct @@ -578,7 +682,7 @@ hence "f ?x < 0" using `f x < 0` by auto thus False using `0 \ f ?x` by auto qed - + subsection {* Uniform Continuity *} @@ -588,14 +692,14 @@ lemma isUCont_Cauchy: "\isUCont f; Cauchy X\ \ Cauchy (\n. f (X n))" unfolding isUCont_def -apply (rule CauchyI) +apply (rule metric_CauchyI) apply (drule_tac x=e in spec, safe) -apply (drule_tac e=s in CauchyD, safe) +apply (drule_tac e=s in metric_CauchyD, safe) apply (rule_tac x=M in exI, simp) done lemma (in bounded_linear) isUCont: "isUCont f" -unfolding isUCont_def +unfolding isUCont_def dist_norm proof (intro allI impI) fix r::real assume r: "0 < r" obtain K where K: "0 < K" and norm_le: "\x. norm (f x) \ norm x * K" @@ -620,44 +724,46 @@ subsection {* Relation of LIM and LIMSEQ *} lemma LIMSEQ_SEQ_conv1: - fixes a :: "'a::real_normed_vector" + fixes a :: "'a::metric_space" assumes X: "X -- a --> L" shows "\S. (\n. S n \ a) \ S ----> a \ (\n. X (S n)) ----> L" -proof (safe intro!: LIMSEQ_I) +proof (safe intro!: metric_LIMSEQ_I) fix S :: "nat \ 'a" fix r :: real assume rgz: "0 < r" assume as: "\n. S n \ a" assume S: "S ----> a" - from LIM_D [OF X rgz] obtain s + from metric_LIM_D [OF X rgz] obtain s where sgz: "0 < s" - and aux: "\x. \x \ a; norm (x - a) < s\ \ norm (X x - L) < r" + and aux: "\x. \x \ a; dist x a < s\ \ dist (X x) L < r" by fast - from LIMSEQ_D [OF S sgz] - obtain no where "\n\no. norm (S n - a) < s" by blast - hence "\n\no. norm (X (S n) - L) < r" by (simp add: aux as) - thus "\no. \n\no. norm (X (S n) - L) < r" .. + from metric_LIMSEQ_D [OF S sgz] + obtain no where "\n\no. dist (S n) a < s" by blast + hence "\n\no. dist (X (S n)) L < r" by (simp add: aux as) + thus "\no. \n\no. dist (X (S n)) L < r" .. qed + lemma LIMSEQ_SEQ_conv2: fixes a :: real assumes "\S. (\n. S n \ a) \ S ----> a \ (\n. X (S n)) ----> L" shows "X -- a --> L" proof (rule ccontr) assume "\ (X -- a --> L)" - hence "\ (\r > 0. \s > 0. \x. x \ a & norm (x - a) < s --> norm (X x - L) < r)" by (unfold LIM_def) - hence "\r > 0. \s > 0. \x. \(x \ a \ \x - a\ < s --> norm (X x - L) < r)" by simp - hence "\r > 0. \s > 0. \x. (x \ a \ \x - a\ < s \ norm (X x - L) \ r)" by (simp add: linorder_not_less) - then obtain r where rdef: "r > 0 \ (\s > 0. \x. (x \ a \ \x - a\ < s \ norm (X x - L) \ r))" by auto + hence "\ (\r > 0. \s > 0. \x. x \ a & norm (x - a) < s --> dist (X x) L < r)" + unfolding LIM_def dist_norm . + hence "\r > 0. \s > 0. \x. \(x \ a \ \x - a\ < s --> dist (X x) L < r)" by simp + hence "\r > 0. \s > 0. \x. (x \ a \ \x - a\ < s \ dist (X x) L \ r)" by (simp add: not_less) + then obtain r where rdef: "r > 0 \ (\s > 0. \x. (x \ a \ \x - a\ < s \ dist (X x) L \ r))" by auto - let ?F = "\n::nat. SOME x. x\a \ \x - a\ < inverse (real (Suc n)) \ norm (X x - L) \ r" - have "\n. \x. x\a \ \x - a\ < inverse (real (Suc n)) \ norm (X x - L) \ r" + let ?F = "\n::nat. SOME x. x\a \ \x - a\ < inverse (real (Suc n)) \ dist (X x) L \ r" + have "\n. \x. x\a \ \x - a\ < inverse (real (Suc n)) \ dist (X x) L \ r" using rdef by simp - hence F: "\n. ?F n \ a \ \?F n - a\ < inverse (real (Suc n)) \ norm (X (?F n) - L) \ r" + hence F: "\n. ?F n \ a \ \?F n - a\ < inverse (real (Suc n)) \ dist (X (?F n)) L \ r" by (rule someI_ex) hence F1: "\n. ?F n \ a" and F2: "\n. \?F n - a\ < inverse (real (Suc n))" - and F3: "\n. norm (X (?F n) - L) \ r" + and F3: "\n. dist (X (?F n)) L \ r" by fast+ have "?F ----> a" @@ -694,13 +800,13 @@ obtain n where "n = no + 1" by simp then have nolen: "no \ n" by simp (* We prove this by showing that for any m there is an n\m such that |X (?F n) - L| \ r *) - have "norm (X (?F n) - L) \ r" + have "dist (X (?F n)) L \ r" by (rule F3) - with nolen have "\n. no \ n \ norm (X (?F n) - L) \ r" by fast + with nolen have "\n. no \ n \ dist (X (?F n)) L \ r" by fast } - then have "(\no. \n. no \ n \ norm (X (?F n) - L) \ r)" by simp - with rdef have "\e>0. (\no. \n. no \ n \ norm (X (?F n) - L) \ e)" by auto - thus ?thesis by (unfold LIMSEQ_iff, auto simp add: linorder_not_less) + then have "(\no. \n. no \ n \ dist (X (?F n)) L \ r)" by simp + with rdef have "\e>0. (\no. \n. no \ n \ dist (X (?F n)) L \ e)" by auto + thus ?thesis by (unfold LIMSEQ_def, auto simp add: not_less) qed ultimately show False by simp qed diff -r a9ed5fcc5e39 -r d41a8ba25b67 src/HOL/Ln.thy --- a/src/HOL/Ln.thy Thu May 28 23:03:12 2009 -0700 +++ b/src/HOL/Ln.thy Fri May 29 09:22:56 2009 -0700 @@ -343,7 +343,7 @@ done lemma DERIV_ln: "0 < x ==> DERIV ln x :> 1 / x" - apply (unfold deriv_def, unfold LIM_def, clarsimp) + apply (unfold deriv_def, unfold LIM_eq, clarsimp) apply (rule exI) apply (rule conjI) prefer 2 diff -r a9ed5fcc5e39 -r d41a8ba25b67 src/HOL/NSA/CLim.thy --- a/src/HOL/NSA/CLim.thy Thu May 28 23:03:12 2009 -0700 +++ b/src/HOL/NSA/CLim.thy Fri May 29 09:22:56 2009 -0700 @@ -45,17 +45,25 @@ hIm_hcomplex_of_complex) (** get this result easily now **) -lemma LIM_Re: "f -- a --> L ==> (%x. Re(f x)) -- a --> Re(L)" +lemma LIM_Re: + fixes f :: "'a::real_normed_vector \ complex" + shows "f -- a --> L ==> (%x. Re(f x)) -- a --> Re(L)" by (simp add: LIM_NSLIM_iff NSLIM_Re) -lemma LIM_Im: "f -- a --> L ==> (%x. Im(f x)) -- a --> Im(L)" +lemma LIM_Im: + fixes f :: "'a::real_normed_vector \ complex" + shows "f -- a --> L ==> (%x. Im(f x)) -- a --> Im(L)" by (simp add: LIM_NSLIM_iff NSLIM_Im) -lemma LIM_cnj: "f -- a --> L ==> (%x. cnj (f x)) -- a --> cnj L" -by (simp add: LIM_def complex_cnj_diff [symmetric]) +lemma LIM_cnj: + fixes f :: "'a::real_normed_vector \ complex" + shows "f -- a --> L ==> (%x. cnj (f x)) -- a --> cnj L" +by (simp add: LIM_eq complex_cnj_diff [symmetric]) -lemma LIM_cnj_iff: "((%x. cnj (f x)) -- a --> cnj L) = (f -- a --> L)" -by (simp add: LIM_def complex_cnj_diff [symmetric]) +lemma LIM_cnj_iff: + fixes f :: "'a::real_normed_vector \ complex" + shows "((%x. cnj (f x)) -- a --> cnj L) = (f -- a --> L)" +by (simp add: LIM_eq complex_cnj_diff [symmetric]) lemma starfun_norm: "( *f* (\x. norm (f x))) = (\x. hnorm (( *f* f) x))" by transfer (rule refl) @@ -74,8 +82,10 @@ approx_approx_zero_iff [symmetric] approx_minus_iff [symmetric]) (** much, much easier standard proof **) -lemma CLIM_CRLIM_iff: "(f -- x --> L) = ((%y. cmod(f y - L)) -- x --> 0)" -by (simp add: LIM_def) +lemma CLIM_CRLIM_iff: + fixes f :: "'a::real_normed_vector \ complex" + shows "(f -- x --> L) = ((%y. cmod(f y - L)) -- x --> 0)" +by (simp add: LIM_eq) (* so this is nicer nonstandard proof *) lemma NSCLIM_NSCRLIM_iff2: @@ -92,7 +102,8 @@ done lemma LIM_CRLIM_Re_Im_iff: - "(f -- a --> L) = ((%x. Re(f x)) -- a --> Re(L) & + fixes f :: "'a::real_normed_vector \ complex" + shows "(f -- a --> L) = ((%x. Re(f x)) -- a --> Re(L) & (%x. Im(f x)) -- a --> Im(L))" by (simp add: LIM_NSLIM_iff NSLIM_NSCRLIM_Re_Im_iff) @@ -113,10 +124,14 @@ lemma isContCR_cmod [simp]: "isCont cmod (a)" by (simp add: isNSCont_isCont_iff [symmetric]) -lemma isCont_Re: "isCont f a ==> isCont (%x. Re (f x)) a" +lemma isCont_Re: + fixes f :: "'a::real_normed_vector \ complex" + shows "isCont f a ==> isCont (%x. Re (f x)) a" by (simp add: isCont_def LIM_Re) -lemma isCont_Im: "isCont f a ==> isCont (%x. Im (f x)) a" +lemma isCont_Im: + fixes f :: "'a::real_normed_vector \ complex" + shows "isCont f a ==> isCont (%x. Im (f x)) a" by (simp add: isCont_def LIM_Im) subsection{* Differentiation of Natural Number Powers*} diff -r a9ed5fcc5e39 -r d41a8ba25b67 src/HOL/NSA/HLim.thy --- a/src/HOL/NSA/HLim.thy Thu May 28 23:03:12 2009 -0700 +++ b/src/HOL/NSA/HLim.thy Fri May 29 09:22:56 2009 -0700 @@ -287,7 +287,7 @@ fix r::real assume r: "0 < r" with f obtain s where s: "0 < s" and less_r: "\x y. norm (x - y) < s \ norm (f x - f y) < r" - by (auto simp add: isUCont_def) + by (auto simp add: isUCont_def dist_norm) from less_r have less_r': "\x y. hnorm (x - y) < star_of s \ hnorm (starfun f x - starfun f y) < star_of r" @@ -306,7 +306,7 @@ lemma isNSUCont_isUCont: fixes f :: "'a::real_normed_vector \ 'b::real_normed_vector" assumes f: "isNSUCont f" shows "isUCont f" -proof (unfold isUCont_def, safe) +proof (unfold isUCont_def dist_norm, safe) fix r::real assume r: "0 < r" have "\s>0. \x y. hnorm (x - y) < s \ hnorm (starfun f x - starfun f y) < star_of r" diff -r a9ed5fcc5e39 -r d41a8ba25b67 src/HOL/Transcendental.thy --- a/src/HOL/Transcendental.thy Thu May 28 23:03:12 2009 -0700 +++ b/src/HOL/Transcendental.thy Fri May 29 09:22:56 2009 -0700 @@ -438,7 +438,7 @@ assumes k: "0 < (k::real)" assumes le: "\h. \h \ 0; norm h < k\ \ norm (f h) \ K * norm h" shows "f -- 0 --> 0" -unfolding LIM_def diff_0_right +unfolding LIM_eq diff_0_right proof (safe) let ?h = "of_real (k / 2)::'a" have "?h \ 0" and "norm ?h < k" using k by simp_all @@ -2145,7 +2145,7 @@ lemma lemma_tan_total: "0 < y ==> \x. 0 < x & x < pi/2 & y < tan x" apply (cut_tac LIM_cos_div_sin) -apply (simp only: LIM_def) +apply (simp only: LIM_eq) apply (drule_tac x = "inverse y" in spec, safe, force) apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero], safe) apply (rule_tac x = "(pi/2) - e" in exI)