renamed former datatype.ML to datatype_data.ML; datatype.ML provides uniform view on datatype.ML and datatype_rep_proofs.ML
2 Author : Jacques D. Fleuriot
3 Copyright : 1998 University of Cambridge
4 Conversion to Isar and new proofs by Lawrence C Paulson, 2004
7 header{* Limits and Continuity *}
13 text{*Standard Definitions*}
16 LIM :: "['a::metric_space \<Rightarrow> 'b::metric_space, 'a, 'b] \<Rightarrow> bool"
17 ("((_)/ -- (_)/ --> (_))" [60, 0, 60] 60) where
18 [code del]: "f -- a --> L =
19 (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & dist x a < s
20 --> dist (f x) L < r)"
23 isCont :: "['a::metric_space \<Rightarrow> 'b::metric_space, 'a] \<Rightarrow> bool" where
24 "isCont f a = (f -- a --> (f a))"
27 isUCont :: "['a::metric_space \<Rightarrow> 'b::metric_space] \<Rightarrow> bool" where
28 [code del]: "isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. dist x y < s \<longrightarrow> dist (f x) (f y) < r)"
30 subsection {* Limits of Functions *}
32 lemma LIM_conv_tendsto: "(f -- a --> L) \<longleftrightarrow> (f ---> L) (at a)"
33 unfolding LIM_def tendsto_iff eventually_at ..
36 "(\<And>r. 0 < r \<Longrightarrow> \<exists>s>0. \<forall>x. x \<noteq> a \<and> dist x a < s \<longrightarrow> dist (f x) L < r)
37 \<Longrightarrow> f -- a --> L"
38 by (simp add: LIM_def)
41 "\<lbrakk>f -- a --> L; 0 < r\<rbrakk>
42 \<Longrightarrow> \<exists>s>0. \<forall>x. x \<noteq> a \<and> dist x a < s \<longrightarrow> dist (f x) L < r"
43 by (simp add: LIM_def)
46 fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
48 (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)"
49 by (simp add: LIM_def dist_norm)
52 fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
53 shows "(!!r. 0<r ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)
58 fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
59 shows "[| f -- a --> L; 0<r |]
60 ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r"
64 fixes a :: "'a::real_normed_vector" and L :: "'b::metric_space"
65 shows "f -- a --> L \<Longrightarrow> (\<lambda>x. f (x + k)) -- a - k --> L"
66 unfolding LIM_def dist_norm
68 apply (drule_tac x="r" in spec, safe)
69 apply (rule_tac x="s" in exI, safe)
70 apply (drule_tac x="x + k" in spec)
71 apply (simp add: algebra_simps)
74 lemma LIM_offset_zero:
75 fixes a :: "'a::real_normed_vector" and L :: "'b::metric_space"
76 shows "f -- a --> L \<Longrightarrow> (\<lambda>h. f (a + h)) -- 0 --> L"
77 by (drule_tac k="a" in LIM_offset, simp add: add_commute)
79 lemma LIM_offset_zero_cancel:
80 fixes a :: "'a::real_normed_vector" and L :: "'b::metric_space"
81 shows "(\<lambda>h. f (a + h)) -- 0 --> L \<Longrightarrow> f -- a --> L"
82 by (drule_tac k="- a" in LIM_offset, simp)
84 lemma LIM_const [simp]: "(%x. k) -- x --> k"
85 by (simp add: LIM_def)
87 lemma LIM_cong_limit: "\<lbrakk> f -- x --> L ; K = L \<rbrakk> \<Longrightarrow> f -- x --> K" by simp
90 fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
91 assumes f: "f -- a --> L" and g: "g -- a --> M"
92 shows "(\<lambda>x. f x + g x) -- a --> (L + M)"
93 using assms unfolding LIM_conv_tendsto by (rule tendsto_add)
96 fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
97 shows "\<lbrakk>f -- a --> 0; g -- a --> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. f x + g x) -- a --> 0"
98 by (drule (1) LIM_add, simp)
100 lemma minus_diff_minus:
101 fixes a b :: "'a::ab_group_add"
102 shows "(- a) - (- b) = - (a - b)"
106 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
107 shows "f -- a --> L \<Longrightarrow> (\<lambda>x. - f x) -- a --> - L"
108 unfolding LIM_conv_tendsto by (rule tendsto_minus)
112 fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
113 shows "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
114 by (intro LIM_add LIM_minus)
117 fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
118 shows "\<lbrakk>f -- x --> l; g -- x --> m\<rbrakk> \<Longrightarrow> (\<lambda>x. f x - g x) -- x --> l - m"
119 unfolding LIM_conv_tendsto by (rule tendsto_diff)
122 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
123 shows "f -- a --> l \<Longrightarrow> (\<lambda>x. f x - l) -- a --> 0"
124 by (simp add: LIM_def dist_norm)
126 lemma LIM_zero_cancel:
127 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
128 shows "(\<lambda>x. f x - l) -- a --> 0 \<Longrightarrow> f -- a --> l"
129 by (simp add: LIM_def dist_norm)
132 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
133 shows "(\<lambda>x. f x - l) -- a --> 0 = f -- a --> l"
134 by (simp add: LIM_def dist_norm)
136 lemma metric_LIM_imp_LIM:
137 assumes f: "f -- a --> l"
138 assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> dist (g x) m \<le> dist (f x) l"
140 apply (rule metric_LIM_I, drule metric_LIM_D [OF f], safe)
141 apply (rule_tac x="s" in exI, safe)
142 apply (drule_tac x="x" in spec, safe)
143 apply (erule (1) order_le_less_trans [OF le])
147 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
148 fixes g :: "'a::metric_space \<Rightarrow> 'c::real_normed_vector"
149 assumes f: "f -- a --> l"
150 assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
152 apply (rule metric_LIM_imp_LIM [OF f])
153 apply (simp add: dist_norm le)
157 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
158 shows "f -- a --> l \<Longrightarrow> (\<lambda>x. norm (f x)) -- a --> norm l"
159 unfolding LIM_conv_tendsto by (rule tendsto_norm)
162 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
163 shows "f -- a --> 0 \<Longrightarrow> (\<lambda>x. norm (f x)) -- a --> 0"
164 by (drule LIM_norm, simp)
166 lemma LIM_norm_zero_cancel:
167 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
168 shows "(\<lambda>x. norm (f x)) -- a --> 0 \<Longrightarrow> f -- a --> 0"
169 by (erule LIM_imp_LIM, simp)
171 lemma LIM_norm_zero_iff:
172 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
173 shows "(\<lambda>x. norm (f x)) -- a --> 0 = f -- a --> 0"
174 by (rule iffI [OF LIM_norm_zero_cancel LIM_norm_zero])
176 lemma LIM_rabs: "f -- a --> (l::real) \<Longrightarrow> (\<lambda>x. \<bar>f x\<bar>) -- a --> \<bar>l\<bar>"
177 by (fold real_norm_def, rule LIM_norm)
179 lemma LIM_rabs_zero: "f -- a --> (0::real) \<Longrightarrow> (\<lambda>x. \<bar>f x\<bar>) -- a --> 0"
180 by (fold real_norm_def, rule LIM_norm_zero)
182 lemma LIM_rabs_zero_cancel: "(\<lambda>x. \<bar>f x\<bar>) -- a --> (0::real) \<Longrightarrow> f -- a --> 0"
183 by (fold real_norm_def, rule LIM_norm_zero_cancel)
185 lemma LIM_rabs_zero_iff: "(\<lambda>x. \<bar>f x\<bar>) -- a --> (0::real) = f -- a --> 0"
186 by (fold real_norm_def, rule LIM_norm_zero_iff)
188 lemma LIM_const_not_eq:
189 fixes a :: "'a::real_normed_algebra_1"
190 shows "k \<noteq> L \<Longrightarrow> \<not> (\<lambda>x. k) -- a --> L"
191 apply (simp add: LIM_def)
192 apply (rule_tac x="dist k L" in exI, simp add: zero_less_dist_iff, safe)
193 apply (rule_tac x="a + of_real (s/2)" in exI, simp add: dist_norm)
196 lemmas LIM_not_zero = LIM_const_not_eq [where L = 0]
199 fixes a :: "'a::real_normed_algebra_1"
200 shows "(\<lambda>x. k) -- a --> L \<Longrightarrow> k = L"
202 apply (blast dest: LIM_const_not_eq)
206 fixes a :: "'a::real_normed_algebra_1" -- {* TODO: find a more appropriate class *}
207 shows "\<lbrakk>f -- a --> L; f -- a --> M\<rbrakk> \<Longrightarrow> L = M"
209 apply (drule_tac r="dist L M / 2" in metric_LIM_D, simp add: zero_less_dist_iff)
210 apply (drule_tac r="dist L M / 2" in metric_LIM_D, simp add: zero_less_dist_iff)
211 apply (clarify, rename_tac r s)
212 apply (subgoal_tac "min r s \<noteq> 0")
213 apply (subgoal_tac "dist L M < dist L M / 2 + dist L M / 2", simp)
214 apply (subgoal_tac "dist L M \<le> dist (f (a + of_real (min r s / 2))) L +
215 dist (f (a + of_real (min r s / 2))) M")
216 apply (erule le_less_trans, rule add_strict_mono)
217 apply (drule spec, erule mp, simp add: dist_norm)
218 apply (drule spec, erule mp, simp add: dist_norm)
219 apply (subst dist_commute, rule dist_triangle)
223 lemma LIM_ident [simp]: "(\<lambda>x. x) -- a --> a"
224 by (auto simp add: LIM_def)
226 text{*Limits are equal for functions equal except at limit point*}
228 "[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)"
229 by (simp add: LIM_def)
232 "\<lbrakk>a = b; \<And>x. x \<noteq> b \<Longrightarrow> f x = g x; l = m\<rbrakk>
233 \<Longrightarrow> ((\<lambda>x. f x) -- a --> l) = ((\<lambda>x. g x) -- b --> m)"
234 by (simp add: LIM_def)
236 lemma metric_LIM_equal2:
238 assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < R\<rbrakk> \<Longrightarrow> f x = g x"
239 shows "g -- a --> l \<Longrightarrow> f -- a --> l"
240 apply (unfold LIM_def, safe)
241 apply (drule_tac x="r" in spec, safe)
242 apply (rule_tac x="min s R" in exI, safe)
248 fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::metric_space"
250 assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
251 shows "g -- a --> l \<Longrightarrow> f -- a --> l"
252 apply (unfold LIM_def dist_norm, safe)
253 apply (drule_tac x="r" in spec, safe)
254 apply (rule_tac x="min s R" in exI, safe)
259 text{*Two uses in Transcendental.ML*}
261 fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
262 shows "[| (%x. f(x) + -g(x)) -- a --> 0; g -- a --> l |] ==> f -- a --> l"
263 apply (drule LIM_add, assumption)
264 apply (auto simp add: add_assoc)
268 assumes g: "g -- l --> g l"
269 assumes f: "f -- a --> l"
270 shows "(\<lambda>x. g (f x)) -- a --> g l"
271 proof (rule metric_LIM_I)
272 fix r::real assume r: "0 < r"
273 obtain s where s: "0 < s"
274 and less_r: "\<And>y. \<lbrakk>y \<noteq> l; dist y l < s\<rbrakk> \<Longrightarrow> dist (g y) (g l) < r"
275 using metric_LIM_D [OF g r] by fast
276 obtain t where t: "0 < t"
277 and less_s: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < t\<rbrakk> \<Longrightarrow> dist (f x) l < s"
278 using metric_LIM_D [OF f s] by fast
280 show "\<exists>t>0. \<forall>x. x \<noteq> a \<and> dist x a < t \<longrightarrow> dist (g (f x)) (g l) < r"
281 proof (rule exI, safe)
282 show "0 < t" using t .
284 fix x assume "x \<noteq> a" and "dist x a < t"
285 hence "dist (f x) l < s" by (rule less_s)
286 thus "dist (g (f x)) (g l) < r"
287 using r less_r by (case_tac "f x = l", simp_all)
291 lemma metric_LIM_compose2:
292 assumes f: "f -- a --> b"
293 assumes g: "g -- b --> c"
294 assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> b"
295 shows "(\<lambda>x. g (f x)) -- a --> c"
296 proof (rule metric_LIM_I)
299 obtain s where s: "0 < s"
300 and less_r: "\<And>y. \<lbrakk>y \<noteq> b; dist y b < s\<rbrakk> \<Longrightarrow> dist (g y) c < r"
301 using metric_LIM_D [OF g r] by fast
302 obtain t where t: "0 < t"
303 and less_s: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < t\<rbrakk> \<Longrightarrow> dist (f x) b < s"
304 using metric_LIM_D [OF f s] by fast
305 obtain d where d: "0 < d"
306 and neq_b: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < d\<rbrakk> \<Longrightarrow> f x \<noteq> b"
309 show "\<exists>t>0. \<forall>x. x \<noteq> a \<and> dist x a < t \<longrightarrow> dist (g (f x)) c < r"
310 proof (safe intro!: exI)
311 show "0 < min d t" using d t by simp
314 assume "x \<noteq> a" and "dist x a < min d t"
315 hence "f x \<noteq> b" and "dist (f x) b < s"
316 using neq_b less_s by simp_all
317 thus "dist (g (f x)) c < r"
323 fixes a :: "'a::real_normed_vector"
324 assumes f: "f -- a --> b"
325 assumes g: "g -- b --> c"
326 assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
327 shows "(\<lambda>x. g (f x)) -- a --> c"
328 by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
330 lemma LIM_o: "\<lbrakk>g -- l --> g l; f -- a --> l\<rbrakk> \<Longrightarrow> (g \<circ> f) -- a --> g l"
331 unfolding o_def by (rule LIM_compose)
333 lemma real_LIM_sandwich_zero:
334 fixes f g :: "'a::metric_space \<Rightarrow> real"
335 assumes f: "f -- a --> 0"
336 assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
337 assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
339 proof (rule LIM_imp_LIM [OF f])
340 fix x assume x: "x \<noteq> a"
341 have "norm (g x - 0) = g x" by (simp add: 1 x)
342 also have "g x \<le> f x" by (rule 2 [OF x])
343 also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
344 also have "\<bar>f x\<bar> = norm (f x - 0)" by simp
345 finally show "norm (g x - 0) \<le> norm (f x - 0)" .
348 text {* Bounded Linear Operators *}
350 lemma (in bounded_linear) LIM:
351 "g -- a --> l \<Longrightarrow> (\<lambda>x. f (g x)) -- a --> f l"
352 unfolding LIM_conv_tendsto by (rule tendsto)
354 lemma (in bounded_linear) cont: "f -- a --> f a"
355 by (rule LIM [OF LIM_ident])
357 lemma (in bounded_linear) LIM_zero:
358 "g -- a --> 0 \<Longrightarrow> (\<lambda>x. f (g x)) -- a --> 0"
359 by (drule LIM, simp only: zero)
361 text {* Bounded Bilinear Operators *}
363 lemma (in bounded_bilinear) LIM:
364 "\<lbrakk>f -- a --> L; g -- a --> M\<rbrakk> \<Longrightarrow> (\<lambda>x. f x ** g x) -- a --> L ** M"
365 unfolding LIM_conv_tendsto by (rule tendsto)
367 lemma (in bounded_bilinear) LIM_prod_zero:
368 fixes a :: "'d::metric_space"
369 assumes f: "f -- a --> 0"
370 assumes g: "g -- a --> 0"
371 shows "(\<lambda>x. f x ** g x) -- a --> 0"
372 using LIM [OF f g] by (simp add: zero_left)
374 lemma (in bounded_bilinear) LIM_left_zero:
375 "f -- a --> 0 \<Longrightarrow> (\<lambda>x. f x ** c) -- a --> 0"
376 by (rule bounded_linear.LIM_zero [OF bounded_linear_left])
378 lemma (in bounded_bilinear) LIM_right_zero:
379 "f -- a --> 0 \<Longrightarrow> (\<lambda>x. c ** f x) -- a --> 0"
380 by (rule bounded_linear.LIM_zero [OF bounded_linear_right])
382 lemmas LIM_mult = mult.LIM
384 lemmas LIM_mult_zero = mult.LIM_prod_zero
386 lemmas LIM_mult_left_zero = mult.LIM_left_zero
388 lemmas LIM_mult_right_zero = mult.LIM_right_zero
390 lemmas LIM_scaleR = scaleR.LIM
392 lemmas LIM_of_real = of_real.LIM
395 fixes f :: "'a::metric_space \<Rightarrow> 'b::{power,real_normed_algebra}"
396 assumes f: "f -- a --> l"
397 shows "(\<lambda>x. f x ^ n) -- a --> l ^ n"
398 by (induct n, simp, simp add: LIM_mult f)
400 subsubsection {* Derived theorems about @{term LIM} *}
403 fixes L :: "'a::real_normed_div_algebra"
404 shows "\<lbrakk>f -- a --> L; L \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. inverse (f x)) -- a --> inverse L"
405 unfolding LIM_conv_tendsto
406 by (rule tendsto_inverse)
408 lemma LIM_inverse_fun:
409 assumes a: "a \<noteq> (0::'a::real_normed_div_algebra)"
410 shows "inverse -- a --> inverse a"
411 by (rule LIM_inverse [OF LIM_ident a])
414 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
415 shows "\<lbrakk>f -- a --> l; l \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. sgn (f x)) -- a --> sgn l"
416 unfolding sgn_div_norm
417 by (simp add: LIM_scaleR LIM_inverse LIM_norm)
420 subsection {* Continuity *}
422 lemma LIM_isCont_iff:
423 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::metric_space"
424 shows "(f -- a --> f a) = ((\<lambda>h. f (a + h)) -- 0 --> f a)"
425 by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
428 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::metric_space"
429 shows "isCont f x = (\<lambda>h. f (x + h)) -- 0 --> f x"
430 by (simp add: isCont_def LIM_isCont_iff)
432 lemma isCont_ident [simp]: "isCont (\<lambda>x. x) a"
433 unfolding isCont_def by (rule LIM_ident)
435 lemma isCont_const [simp]: "isCont (\<lambda>x. k) a"
436 unfolding isCont_def by (rule LIM_const)
439 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
440 shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a"
441 unfolding isCont_def by (rule LIM_norm)
443 lemma isCont_rabs: "isCont f a \<Longrightarrow> isCont (\<lambda>x. \<bar>f x :: real\<bar>) a"
444 unfolding isCont_def by (rule LIM_rabs)
447 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
448 shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
449 unfolding isCont_def by (rule LIM_add)
452 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
453 shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
454 unfolding isCont_def by (rule LIM_minus)
457 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
458 shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
459 unfolding isCont_def by (rule LIM_diff)
462 fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_algebra"
463 shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x * g x) a"
464 unfolding isCont_def by (rule LIM_mult)
466 lemma isCont_inverse:
467 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_div_algebra"
468 shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. inverse (f x)) a"
469 unfolding isCont_def by (rule LIM_inverse)
471 lemma isCont_LIM_compose:
472 "\<lbrakk>isCont g l; f -- a --> l\<rbrakk> \<Longrightarrow> (\<lambda>x. g (f x)) -- a --> g l"
473 unfolding isCont_def by (rule LIM_compose)
475 lemma metric_isCont_LIM_compose2:
476 assumes f [unfolded isCont_def]: "isCont f a"
477 assumes g: "g -- f a --> l"
478 assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> f a"
479 shows "(\<lambda>x. g (f x)) -- a --> l"
480 by (rule metric_LIM_compose2 [OF f g inj])
482 lemma isCont_LIM_compose2:
483 fixes a :: "'a::real_normed_vector"
484 assumes f [unfolded isCont_def]: "isCont f a"
485 assumes g: "g -- f a --> l"
486 assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
487 shows "(\<lambda>x. g (f x)) -- a --> l"
488 by (rule LIM_compose2 [OF f g inj])
490 lemma isCont_o2: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. g (f x)) a"
491 unfolding isCont_def by (rule LIM_compose)
493 lemma isCont_o: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (g o f) a"
494 unfolding o_def by (rule isCont_o2)
496 lemma (in bounded_linear) isCont: "isCont f a"
497 unfolding isCont_def by (rule cont)
499 lemma (in bounded_bilinear) isCont:
500 "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x ** g x) a"
501 unfolding isCont_def by (rule LIM)
503 lemmas isCont_scaleR = scaleR.isCont
505 lemma isCont_of_real:
506 "isCont f a \<Longrightarrow> isCont (\<lambda>x. of_real (f x)::'b::real_normed_algebra_1) a"
507 unfolding isCont_def by (rule LIM_of_real)
510 fixes f :: "'a::metric_space \<Rightarrow> 'b::{power,real_normed_algebra}"
511 shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. f x ^ n) a"
512 unfolding isCont_def by (rule LIM_power)
515 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
516 shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. sgn (f x)) a"
517 unfolding isCont_def by (rule LIM_sgn)
519 lemma isCont_abs [simp]: "isCont abs (a::real)"
520 by (rule isCont_rabs [OF isCont_ident])
523 fixes f :: "'a \<Rightarrow> 'b::metric_space \<Rightarrow> 'c::real_normed_vector"
524 fixes A :: "'a set" assumes "finite A"
525 shows "\<forall> i \<in> A. isCont (f i) x \<Longrightarrow> isCont (\<lambda> x. \<Sum> i \<in> A. f i x) x"
528 case (insert a F) show "isCont (\<lambda> x. \<Sum> i \<in> (insert a F). f i x) x"
529 unfolding setsum_insert[OF `finite F` `a \<notin> F`] by (rule isCont_add, auto simp add: insert)
532 lemma LIM_less_bound: fixes f :: "real \<Rightarrow> real" assumes "b < x"
533 and all_le: "\<forall> x' \<in> { b <..< x}. 0 \<le> f x'" and isCont: "isCont f x"
536 assume "\<not> 0 \<le> f x" hence "f x < 0" by auto
537 hence "0 < - f x / 2" by auto
538 from isCont[unfolded isCont_def, THEN LIM_D, OF this]
539 obtain s where "s > 0" and s_D: "\<And>x'. \<lbrakk> x' \<noteq> x ; \<bar> x' - x \<bar> < s \<rbrakk> \<Longrightarrow> \<bar> f x' - f x \<bar> < - f x / 2" by auto
541 let ?x = "x - min (s / 2) ((x - b) / 2)"
542 have "?x < x" and "\<bar> ?x - x \<bar> < s"
543 using `b < x` and `0 < s` by auto
545 proof (cases "s < x - b")
546 case True thus ?thesis using `0 < s` by auto
548 case False hence "s / 2 \<ge> (x - b) / 2" by auto
549 hence "?x = (x + b) / 2" by (simp add: field_simps min_max.inf_absorb2)
550 thus ?thesis using `b < x` by auto
552 hence "0 \<le> f ?x" using all_le `?x < x` by auto
553 moreover have "\<bar>f ?x - f x\<bar> < - f x / 2"
554 using s_D[OF _ `\<bar> ?x - x \<bar> < s`] `?x < x` by auto
555 hence "f ?x - f x < - f x / 2" by auto
556 hence "f ?x < f x / 2" by auto
557 hence "f ?x < 0" using `f x < 0` by auto
558 thus False using `0 \<le> f ?x` by auto
562 subsection {* Uniform Continuity *}
564 lemma isUCont_isCont: "isUCont f ==> isCont f x"
565 by (simp add: isUCont_def isCont_def LIM_def, force)
567 lemma isUCont_Cauchy:
568 "\<lbrakk>isUCont f; Cauchy X\<rbrakk> \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
569 unfolding isUCont_def
570 apply (rule metric_CauchyI)
571 apply (drule_tac x=e in spec, safe)
572 apply (drule_tac e=s in metric_CauchyD, safe)
573 apply (rule_tac x=M in exI, simp)
576 lemma (in bounded_linear) isUCont: "isUCont f"
577 unfolding isUCont_def dist_norm
578 proof (intro allI impI)
579 fix r::real assume r: "0 < r"
580 obtain K where K: "0 < K" and norm_le: "\<And>x. norm (f x) \<le> norm x * K"
581 using pos_bounded by fast
582 show "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
583 proof (rule exI, safe)
584 from r K show "0 < r / K" by (rule divide_pos_pos)
587 assume xy: "norm (x - y) < r / K"
588 have "norm (f x - f y) = norm (f (x - y))" by (simp only: diff)
589 also have "\<dots> \<le> norm (x - y) * K" by (rule norm_le)
590 also from K xy have "\<dots> < r" by (simp only: pos_less_divide_eq)
591 finally show "norm (f x - f y) < r" .
595 lemma (in bounded_linear) Cauchy: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
596 by (rule isUCont [THEN isUCont_Cauchy])
599 subsection {* Relation of LIM and LIMSEQ *}
601 lemma LIMSEQ_SEQ_conv1:
602 fixes a :: "'a::metric_space"
603 assumes X: "X -- a --> L"
604 shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
605 proof (safe intro!: metric_LIMSEQ_I)
606 fix S :: "nat \<Rightarrow> 'a"
609 assume as: "\<forall>n. S n \<noteq> a"
610 assume S: "S ----> a"
611 from metric_LIM_D [OF X rgz] obtain s
613 and aux: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < s\<rbrakk> \<Longrightarrow> dist (X x) L < r"
615 from metric_LIMSEQ_D [OF S sgz]
616 obtain no where "\<forall>n\<ge>no. dist (S n) a < s" by blast
617 hence "\<forall>n\<ge>no. dist (X (S n)) L < r" by (simp add: aux as)
618 thus "\<exists>no. \<forall>n\<ge>no. dist (X (S n)) L < r" ..
622 lemma LIMSEQ_SEQ_conv2:
624 assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
627 assume "\<not> (X -- a --> L)"
628 hence "\<not> (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s --> dist (X x) L < r)"
629 unfolding LIM_def dist_norm .
630 hence "\<exists>r > 0. \<forall>s > 0. \<exists>x. \<not>(x \<noteq> a \<and> \<bar>x - a\<bar> < s --> dist (X x) L < r)" by simp
631 hence "\<exists>r > 0. \<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x - a\<bar> < s \<and> dist (X x) L \<ge> r)" by (simp add: not_less)
632 then obtain r where rdef: "r > 0 \<and> (\<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x - a\<bar> < s \<and> dist (X x) L \<ge> r))" by auto
634 let ?F = "\<lambda>n::nat. SOME x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> dist (X x) L \<ge> r"
635 have "\<And>n. \<exists>x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> dist (X x) L \<ge> r"
637 hence F: "\<And>n. ?F n \<noteq> a \<and> \<bar>?F n - a\<bar> < inverse (real (Suc n)) \<and> dist (X (?F n)) L \<ge> r"
639 hence F1: "\<And>n. ?F n \<noteq> a"
640 and F2: "\<And>n. \<bar>?F n - a\<bar> < inverse (real (Suc n))"
641 and F3: "\<And>n. dist (X (?F n)) L \<ge> r"
645 proof (rule LIMSEQ_I, unfold real_norm_def)
648 (* choose no such that inverse (real (Suc n)) < e *)
649 then have "\<exists>no. inverse (real (Suc no)) < e" by (rule reals_Archimedean)
650 then obtain m where nodef: "inverse (real (Suc m)) < e" by auto
651 show "\<exists>no. \<forall>n. no \<le> n --> \<bar>?F n - a\<bar> < e"
652 proof (intro exI allI impI)
654 assume mlen: "m \<le> n"
655 have "\<bar>?F n - a\<bar> < inverse (real (Suc n))"
657 also have "inverse (real (Suc n)) \<le> inverse (real (Suc m))"
660 "inverse (real (Suc m)) < e" .
661 finally show "\<bar>?F n - a\<bar> < e" .
665 moreover have "\<forall>n. ?F n \<noteq> a"
666 by (rule allI) (rule F1)
668 moreover from prems have "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by simp
669 ultimately have "(\<lambda>n. X (?F n)) ----> L" by simp
671 moreover have "\<not> ((\<lambda>n. X (?F n)) ----> L)"
675 obtain n where "n = no + 1" by simp
676 then have nolen: "no \<le> n" by simp
677 (* We prove this by showing that for any m there is an n\<ge>m such that |X (?F n) - L| \<ge> r *)
678 have "dist (X (?F n)) L \<ge> r"
680 with nolen have "\<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> r" by fast
682 then have "(\<forall>no. \<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> r)" by simp
683 with rdef have "\<exists>e>0. (\<forall>no. \<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> e)" by auto
684 thus ?thesis by (unfold LIMSEQ_def, auto simp add: not_less)
686 ultimately show False by simp
689 lemma LIMSEQ_SEQ_conv:
690 "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::real) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
693 assume "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
694 thus "X -- a --> L" by (rule LIMSEQ_SEQ_conv2)
696 assume "(X -- a --> L)"
697 thus "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by (rule LIMSEQ_SEQ_conv1)