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::topological_space \<Rightarrow> 'b::topological_space, 'a, 'b] \<Rightarrow> bool"
17 ("((_)/ -- (_)/ --> (_))" [60, 0, 60] 60) where
18 "f -- a --> L \<equiv> (f ---> L) (at a)"
21 isCont :: "['a::topological_space \<Rightarrow> 'b::topological_space, 'a] \<Rightarrow> bool" where
22 "isCont f a = (f -- a --> (f a))"
25 isUCont :: "['a::metric_space \<Rightarrow> 'b::metric_space] \<Rightarrow> bool" where
26 "isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. dist x y < s \<longrightarrow> dist (f x) (f y) < r)"
28 subsection {* Limits of Functions *}
30 lemma LIM_def: "f -- a --> L =
31 (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & dist x a < s
32 --> dist (f x) L < r)"
33 unfolding 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"
65 shows "f -- a --> L \<Longrightarrow> (\<lambda>x. f (x + k)) -- a - k --> L"
66 apply (rule topological_tendstoI)
67 apply (drule (2) topological_tendstoD)
68 apply (simp only: eventually_at dist_norm)
69 apply (clarify, rule_tac x=d 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"
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"
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_cong_limit: "\<lbrakk> f -- x --> L ; K = L \<rbrakk> \<Longrightarrow> f -- x --> K" by simp
87 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
88 shows "(f ---> l) F \<Longrightarrow> ((\<lambda>x. f x - l) ---> 0) F"
89 unfolding tendsto_iff dist_norm by simp
91 lemma LIM_zero_cancel:
92 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
93 shows "((\<lambda>x. f x - l) ---> 0) F \<Longrightarrow> (f ---> l) F"
94 unfolding tendsto_iff dist_norm by simp
97 fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
98 shows "((\<lambda>x. f x - l) ---> 0) F = (f ---> l) F"
99 unfolding tendsto_iff dist_norm by simp
101 lemma metric_LIM_imp_LIM:
102 assumes f: "f -- a --> l"
103 assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> dist (g x) m \<le> dist (f x) l"
105 by (rule metric_tendsto_imp_tendsto [OF f],
106 auto simp add: eventually_at_topological le)
109 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
110 fixes g :: "'a::topological_space \<Rightarrow> 'c::real_normed_vector"
111 assumes f: "f -- a --> l"
112 assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
114 by (rule metric_LIM_imp_LIM [OF f],
115 simp add: dist_norm le)
117 lemma trivial_limit_at:
118 fixes a :: "'a::real_normed_algebra_1"
119 shows "\<not> trivial_limit (at a)" -- {* TODO: find a more appropriate class *}
120 unfolding trivial_limit_def
121 unfolding eventually_at dist_norm
122 by (clarsimp, rule_tac x="a + of_real (d/2)" in exI, simp)
124 lemma LIM_const_not_eq:
125 fixes a :: "'a::real_normed_algebra_1"
126 fixes k L :: "'b::t2_space"
127 shows "k \<noteq> L \<Longrightarrow> \<not> (\<lambda>x. k) -- a --> L"
128 by (simp add: tendsto_const_iff trivial_limit_at)
130 lemmas LIM_not_zero = LIM_const_not_eq [where L = 0]
133 fixes a :: "'a::real_normed_algebra_1"
134 fixes k L :: "'b::t2_space"
135 shows "(\<lambda>x. k) -- a --> L \<Longrightarrow> k = L"
136 by (simp add: tendsto_const_iff trivial_limit_at)
139 fixes a :: "'a::real_normed_algebra_1" -- {* TODO: find a more appropriate class *}
140 fixes L M :: "'b::t2_space"
141 shows "\<lbrakk>f -- a --> L; f -- a --> M\<rbrakk> \<Longrightarrow> L = M"
142 using trivial_limit_at by (rule tendsto_unique)
144 text{*Limits are equal for functions equal except at limit point*}
146 "[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)"
147 unfolding tendsto_def eventually_at_topological by simp
150 "\<lbrakk>a = b; \<And>x. x \<noteq> b \<Longrightarrow> f x = g x; l = m\<rbrakk>
151 \<Longrightarrow> ((\<lambda>x. f x) -- a --> l) = ((\<lambda>x. g x) -- b --> m)"
152 by (simp add: LIM_equal)
154 lemma metric_LIM_equal2:
156 assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < R\<rbrakk> \<Longrightarrow> f x = g x"
157 shows "g -- a --> l \<Longrightarrow> f -- a --> l"
158 apply (rule topological_tendstoI)
159 apply (drule (2) topological_tendstoD)
160 apply (simp add: eventually_at, safe)
161 apply (rule_tac x="min d R" in exI, safe)
167 fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
169 assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
170 shows "g -- a --> l \<Longrightarrow> f -- a --> l"
171 by (rule metric_LIM_equal2 [OF 1 2], simp_all add: dist_norm)
173 lemma LIM_compose_eventually:
174 assumes f: "f -- a --> b"
175 assumes g: "g -- b --> c"
176 assumes inj: "eventually (\<lambda>x. f x \<noteq> b) (at a)"
177 shows "(\<lambda>x. g (f x)) -- a --> c"
178 using g f inj by (rule tendsto_compose_eventually)
180 lemma metric_LIM_compose2:
181 assumes f: "f -- a --> b"
182 assumes g: "g -- b --> c"
183 assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> b"
184 shows "(\<lambda>x. g (f x)) -- a --> c"
185 using g f inj [folded eventually_at]
186 by (rule tendsto_compose_eventually)
189 fixes a :: "'a::real_normed_vector"
190 assumes f: "f -- a --> b"
191 assumes g: "g -- b --> c"
192 assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
193 shows "(\<lambda>x. g (f x)) -- a --> c"
194 by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
196 lemma LIM_o: "\<lbrakk>g -- l --> g l; f -- a --> l\<rbrakk> \<Longrightarrow> (g \<circ> f) -- a --> g l"
197 unfolding o_def by (rule tendsto_compose)
199 lemma real_LIM_sandwich_zero:
200 fixes f g :: "'a::topological_space \<Rightarrow> real"
201 assumes f: "f -- a --> 0"
202 assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
203 assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
205 proof (rule LIM_imp_LIM [OF f])
206 fix x assume x: "x \<noteq> a"
207 have "norm (g x - 0) = g x" by (simp add: 1 x)
208 also have "g x \<le> f x" by (rule 2 [OF x])
209 also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
210 also have "\<bar>f x\<bar> = norm (f x - 0)" by simp
211 finally show "norm (g x - 0) \<le> norm (f x - 0)" .
215 subsection {* Continuity *}
217 lemma LIM_isCont_iff:
218 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
219 shows "(f -- a --> f a) = ((\<lambda>h. f (a + h)) -- 0 --> f a)"
220 by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
223 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
224 shows "isCont f x = (\<lambda>h. f (x + h)) -- 0 --> f x"
225 by (simp add: isCont_def LIM_isCont_iff)
227 lemma isCont_ident [simp]: "isCont (\<lambda>x. x) a"
228 unfolding isCont_def by (rule tendsto_ident_at)
230 lemma isCont_const [simp]: "isCont (\<lambda>x. k) a"
231 unfolding isCont_def by (rule tendsto_const)
233 lemma isCont_norm [simp]:
234 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
235 shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a"
236 unfolding isCont_def by (rule tendsto_norm)
238 lemma isCont_rabs [simp]:
239 fixes f :: "'a::topological_space \<Rightarrow> real"
240 shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. \<bar>f x\<bar>) a"
241 unfolding isCont_def by (rule tendsto_rabs)
243 lemma isCont_add [simp]:
244 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
245 shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
246 unfolding isCont_def by (rule tendsto_add)
248 lemma isCont_minus [simp]:
249 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
250 shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
251 unfolding isCont_def by (rule tendsto_minus)
253 lemma isCont_diff [simp]:
254 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
255 shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
256 unfolding isCont_def by (rule tendsto_diff)
258 lemma isCont_mult [simp]:
259 fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_algebra"
260 shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x * g x) a"
261 unfolding isCont_def by (rule tendsto_mult)
263 lemma isCont_inverse [simp]:
264 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_div_algebra"
265 shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. inverse (f x)) a"
266 unfolding isCont_def by (rule tendsto_inverse)
268 lemma isCont_divide [simp]:
269 fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_field"
270 shows "\<lbrakk>isCont f a; isCont g a; g a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x / g x) a"
271 unfolding isCont_def by (rule tendsto_divide)
273 lemma isCont_tendsto_compose:
274 "\<lbrakk>isCont g l; (f ---> l) F\<rbrakk> \<Longrightarrow> ((\<lambda>x. g (f x)) ---> g l) F"
275 unfolding isCont_def by (rule tendsto_compose)
277 lemma metric_isCont_LIM_compose2:
278 assumes f [unfolded isCont_def]: "isCont f a"
279 assumes g: "g -- f a --> l"
280 assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> f a"
281 shows "(\<lambda>x. g (f x)) -- a --> l"
282 by (rule metric_LIM_compose2 [OF f g inj])
284 lemma isCont_LIM_compose2:
285 fixes a :: "'a::real_normed_vector"
286 assumes f [unfolded isCont_def]: "isCont f a"
287 assumes g: "g -- f a --> l"
288 assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
289 shows "(\<lambda>x. g (f x)) -- a --> l"
290 by (rule LIM_compose2 [OF f g inj])
292 lemma isCont_o2: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. g (f x)) a"
293 unfolding isCont_def by (rule tendsto_compose)
295 lemma isCont_o: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (g o f) a"
296 unfolding o_def by (rule isCont_o2)
298 lemma (in bounded_linear) isCont:
299 "isCont g a \<Longrightarrow> isCont (\<lambda>x. f (g x)) a"
300 unfolding isCont_def by (rule tendsto)
302 lemma (in bounded_bilinear) isCont:
303 "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x ** g x) a"
304 unfolding isCont_def by (rule tendsto)
306 lemmas isCont_scaleR [simp] =
307 bounded_bilinear.isCont [OF bounded_bilinear_scaleR]
309 lemmas isCont_of_real [simp] =
310 bounded_linear.isCont [OF bounded_linear_of_real]
312 lemma isCont_power [simp]:
313 fixes f :: "'a::topological_space \<Rightarrow> 'b::{power,real_normed_algebra}"
314 shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. f x ^ n) a"
315 unfolding isCont_def by (rule tendsto_power)
317 lemma isCont_sgn [simp]:
318 fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
319 shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. sgn (f x)) a"
320 unfolding isCont_def by (rule tendsto_sgn)
322 lemma isCont_setsum [simp]:
323 fixes f :: "'a \<Rightarrow> 'b::topological_space \<Rightarrow> 'c::real_normed_vector"
325 shows "\<forall>i\<in>A. isCont (f i) a \<Longrightarrow> isCont (\<lambda>x. \<Sum>i\<in>A. f i x) a"
326 unfolding isCont_def by (simp add: tendsto_setsum)
328 lemmas isCont_intros =
329 isCont_ident isCont_const isCont_norm isCont_rabs isCont_add isCont_minus
330 isCont_diff isCont_mult isCont_inverse isCont_divide isCont_scaleR
331 isCont_of_real isCont_power isCont_sgn isCont_setsum
333 lemma LIM_less_bound: fixes f :: "real \<Rightarrow> real" assumes "b < x"
334 and all_le: "\<forall> x' \<in> { b <..< x}. 0 \<le> f x'" and isCont: "isCont f x"
337 assume "\<not> 0 \<le> f x" hence "f x < 0" by auto
338 hence "0 < - f x / 2" by auto
339 from isCont[unfolded isCont_def, THEN LIM_D, OF this]
340 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
342 let ?x = "x - min (s / 2) ((x - b) / 2)"
343 have "?x < x" and "\<bar> ?x - x \<bar> < s"
344 using `b < x` and `0 < s` by auto
346 proof (cases "s < x - b")
347 case True thus ?thesis using `0 < s` by auto
349 case False hence "s / 2 \<ge> (x - b) / 2" by auto
350 hence "?x = (x + b) / 2" by (simp add: field_simps min_max.inf_absorb2)
351 thus ?thesis using `b < x` by auto
353 hence "0 \<le> f ?x" using all_le `?x < x` by auto
354 moreover have "\<bar>f ?x - f x\<bar> < - f x / 2"
355 using s_D[OF _ `\<bar> ?x - x \<bar> < s`] `?x < x` by auto
356 hence "f ?x - f x < - f x / 2" by auto
357 hence "f ?x < f x / 2" by auto
358 hence "f ?x < 0" using `f x < 0` by auto
359 thus False using `0 \<le> f ?x` by auto
363 subsection {* Uniform Continuity *}
365 lemma isUCont_isCont: "isUCont f ==> isCont f x"
366 by (simp add: isUCont_def isCont_def LIM_def, force)
368 lemma isUCont_Cauchy:
369 "\<lbrakk>isUCont f; Cauchy X\<rbrakk> \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
370 unfolding isUCont_def
371 apply (rule metric_CauchyI)
372 apply (drule_tac x=e in spec, safe)
373 apply (drule_tac e=s in metric_CauchyD, safe)
374 apply (rule_tac x=M in exI, simp)
377 lemma (in bounded_linear) isUCont: "isUCont f"
378 unfolding isUCont_def dist_norm
379 proof (intro allI impI)
380 fix r::real assume r: "0 < r"
381 obtain K where K: "0 < K" and norm_le: "\<And>x. norm (f x) \<le> norm x * K"
382 using pos_bounded by fast
383 show "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
384 proof (rule exI, safe)
385 from r K show "0 < r / K" by (rule divide_pos_pos)
388 assume xy: "norm (x - y) < r / K"
389 have "norm (f x - f y) = norm (f (x - y))" by (simp only: diff)
390 also have "\<dots> \<le> norm (x - y) * K" by (rule norm_le)
391 also from K xy have "\<dots> < r" by (simp only: pos_less_divide_eq)
392 finally show "norm (f x - f y) < r" .
396 lemma (in bounded_linear) Cauchy: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
397 by (rule isUCont [THEN isUCont_Cauchy])
400 subsection {* Relation of LIM and LIMSEQ *}
402 lemma sequentially_imp_eventually_within:
403 fixes a :: "'a::metric_space"
404 assumes "\<forall>f. (\<forall>n. f n \<in> s \<and> f n \<noteq> a) \<and> f ----> a \<longrightarrow>
405 eventually (\<lambda>n. P (f n)) sequentially"
406 shows "eventually P (at a within s)"
408 let ?I = "\<lambda>n. inverse (real (Suc n))"
409 def F \<equiv> "\<lambda>n::nat. SOME x. x \<in> s \<and> x \<noteq> a \<and> dist x a < ?I n \<and> \<not> P x"
410 assume "\<not> eventually P (at a within s)"
411 hence P: "\<forall>d>0. \<exists>x. x \<in> s \<and> x \<noteq> a \<and> dist x a < d \<and> \<not> P x"
412 unfolding Limits.eventually_within Limits.eventually_at by fast
413 hence "\<And>n. \<exists>x. x \<in> s \<and> x \<noteq> a \<and> dist x a < ?I n \<and> \<not> P x" by simp
414 hence F: "\<And>n. F n \<in> s \<and> F n \<noteq> a \<and> dist (F n) a < ?I n \<and> \<not> P (F n)"
415 unfolding F_def by (rule someI_ex)
416 hence F0: "\<forall>n. F n \<in> s" and F1: "\<forall>n. F n \<noteq> a"
417 and F2: "\<forall>n. dist (F n) a < ?I n" and F3: "\<forall>n. \<not> P (F n)"
419 from LIMSEQ_inverse_real_of_nat have "F ----> a"
420 by (rule metric_tendsto_imp_tendsto,
421 simp add: dist_norm F2 less_imp_le)
422 hence "eventually (\<lambda>n. P (F n)) sequentially"
423 using assms F0 F1 by simp
424 thus "False" by (simp add: F3)
427 lemma sequentially_imp_eventually_at:
428 fixes a :: "'a::metric_space"
429 assumes "\<forall>f. (\<forall>n. f n \<noteq> a) \<and> f ----> a \<longrightarrow>
430 eventually (\<lambda>n. P (f n)) sequentially"
431 shows "eventually P (at a)"
432 using assms sequentially_imp_eventually_within [where s=UNIV]
433 unfolding within_UNIV by simp
435 lemma LIMSEQ_SEQ_conv1:
436 fixes f :: "'a::topological_space \<Rightarrow> 'b::topological_space"
437 assumes f: "f -- a --> l"
438 shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. f (S n)) ----> l"
439 using tendsto_compose_eventually [OF f, where F=sequentially] by simp
441 lemma LIMSEQ_SEQ_conv2:
442 fixes f :: "'a::metric_space \<Rightarrow> 'b::topological_space"
443 assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. f (S n)) ----> l"
445 using assms unfolding tendsto_def [where l=l]
446 by (simp add: sequentially_imp_eventually_at)
448 lemma LIMSEQ_SEQ_conv:
449 "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::'a::metric_space) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
450 (X -- a --> (L::'b::topological_space))"
451 using LIMSEQ_SEQ_conv2 LIMSEQ_SEQ_conv1 ..