src/HOL/Lim.thy
 author huffman Mon Aug 15 16:48:05 2011 -0700 (2011-08-15) changeset 44218 f0e442e24816 parent 44217 5cdad94bdc29 child 44233 aa74ce315bae permissions -rw-r--r--
1 (*  Title       : Lim.thy
2     Author      : Jacques D. Fleuriot
3     Copyright   : 1998  University of Cambridge
4     Conversion to Isar and new proofs by Lawrence C Paulson, 2004
5 *)
7 header{* Limits and Continuity *}
9 theory Lim
10 imports SEQ
11 begin
13 text{*Standard Definitions*}
15 abbreviation
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)"
20 definition
21   isCont :: "['a::topological_space \<Rightarrow> 'b::topological_space, 'a] \<Rightarrow> bool" where
22   "isCont f a = (f -- a --> (f a))"
24 definition
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 ..
35 lemma metric_LIM_I:
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"
40 lemma metric_LIM_D:
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"
45 lemma LIM_eq:
46   fixes a :: "'a::real_normed_vector" and L :: "'b::real_normed_vector"
47   shows "f -- a --> L =
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)
51 lemma LIM_I:
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)
54       ==> f -- a --> L"
57 lemma LIM_D:
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"
63 lemma LIM_offset:
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)
72 done
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"
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_const [simp]: "(%x. k) -- x --> k"
85 by (rule tendsto_const)
87 lemma LIM_cong_limit: "\<lbrakk> f -- x --> L ; K = L \<rbrakk> \<Longrightarrow> f -- x --> K" by simp
90   fixes f g :: "'a::topological_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 by (rule tendsto_add)
96   fixes f g :: "'a::topological_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"
100 lemma LIM_minus:
101   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
102   shows "f -- a --> L \<Longrightarrow> (\<lambda>x. - f x) -- a --> - L"
103 by (rule tendsto_minus)
105 (* TODO: delete *)
107   fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
108   shows "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
111 lemma LIM_diff:
112   fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
113   shows "\<lbrakk>f -- x --> l; g -- x --> m\<rbrakk> \<Longrightarrow> (\<lambda>x. f x - g x) -- x --> l - m"
114 by (rule tendsto_diff)
116 lemma LIM_zero:
117   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
118   shows "f -- a --> l \<Longrightarrow> (\<lambda>x. f x - l) -- a --> 0"
119 unfolding tendsto_iff dist_norm by simp
121 lemma LIM_zero_cancel:
122   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
123   shows "(\<lambda>x. f x - l) -- a --> 0 \<Longrightarrow> f -- a --> l"
124 unfolding tendsto_iff dist_norm by simp
126 lemma LIM_zero_iff:
127   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
128   shows "(\<lambda>x. f x - l) -- a --> 0 = f -- a --> l"
129 unfolding tendsto_iff dist_norm by simp
131 lemma metric_LIM_imp_LIM:
132   assumes f: "f -- a --> l"
133   assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> dist (g x) m \<le> dist (f x) l"
134   shows "g -- a --> m"
135 apply (rule tendstoI, drule tendstoD [OF f])
136 apply (simp add: eventually_at_topological, safe)
137 apply (rule_tac x="S" in exI, safe)
138 apply (drule_tac x="x" in bspec, safe)
139 apply (erule (1) order_le_less_trans [OF le])
140 done
142 lemma LIM_imp_LIM:
143   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
144   fixes g :: "'a::topological_space \<Rightarrow> 'c::real_normed_vector"
145   assumes f: "f -- a --> l"
146   assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
147   shows "g -- a --> m"
148 apply (rule metric_LIM_imp_LIM [OF f])
149 apply (simp add: dist_norm le)
150 done
152 lemma LIM_norm:
153   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
154   shows "f -- a --> l \<Longrightarrow> (\<lambda>x. norm (f x)) -- a --> norm l"
155 by (rule tendsto_norm)
157 lemma LIM_norm_zero:
158   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
159   shows "f -- a --> 0 \<Longrightarrow> (\<lambda>x. norm (f x)) -- a --> 0"
160 by (rule tendsto_norm_zero)
162 lemma LIM_norm_zero_cancel:
163   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
164   shows "(\<lambda>x. norm (f x)) -- a --> 0 \<Longrightarrow> f -- a --> 0"
165 by (rule tendsto_norm_zero_cancel)
167 lemma LIM_norm_zero_iff:
168   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
169   shows "(\<lambda>x. norm (f x)) -- a --> 0 = f -- a --> 0"
170 by (rule tendsto_norm_zero_iff)
172 lemma LIM_rabs: "f -- a --> (l::real) \<Longrightarrow> (\<lambda>x. \<bar>f x\<bar>) -- a --> \<bar>l\<bar>"
173   by (rule tendsto_rabs)
175 lemma LIM_rabs_zero: "f -- a --> (0::real) \<Longrightarrow> (\<lambda>x. \<bar>f x\<bar>) -- a --> 0"
176   by (rule tendsto_rabs_zero)
178 lemma LIM_rabs_zero_cancel: "(\<lambda>x. \<bar>f x\<bar>) -- a --> (0::real) \<Longrightarrow> f -- a --> 0"
179   by (rule tendsto_rabs_zero_cancel)
181 lemma LIM_rabs_zero_iff: "(\<lambda>x. \<bar>f x\<bar>) -- a --> (0::real) = f -- a --> 0"
182   by (rule tendsto_rabs_zero_iff)
184 lemma trivial_limit_at:
185   fixes a :: "'a::real_normed_algebra_1"
186   shows "\<not> trivial_limit (at a)"  -- {* TODO: find a more appropriate class *}
187 unfolding trivial_limit_def
188 unfolding eventually_at dist_norm
189 by (clarsimp, rule_tac x="a + of_real (d/2)" in exI, simp)
191 lemma LIM_const_not_eq:
192   fixes a :: "'a::real_normed_algebra_1"
193   fixes k L :: "'b::t2_space"
194   shows "k \<noteq> L \<Longrightarrow> \<not> (\<lambda>x. k) -- a --> L"
195 by (simp add: tendsto_const_iff trivial_limit_at)
197 lemmas LIM_not_zero = LIM_const_not_eq [where L = 0]
199 lemma LIM_const_eq:
200   fixes a :: "'a::real_normed_algebra_1"
201   fixes k L :: "'b::t2_space"
202   shows "(\<lambda>x. k) -- a --> L \<Longrightarrow> k = L"
203   by (simp add: tendsto_const_iff trivial_limit_at)
205 lemma LIM_unique:
206   fixes a :: "'a::real_normed_algebra_1" -- {* TODO: find a more appropriate class *}
207   fixes L M :: "'b::t2_space"
208   shows "\<lbrakk>f -- a --> L; f -- a --> M\<rbrakk> \<Longrightarrow> L = M"
209   using trivial_limit_at by (rule tendsto_unique)
211 lemma LIM_ident [simp]: "(\<lambda>x. x) -- a --> a"
212 by (rule tendsto_ident_at)
214 text{*Limits are equal for functions equal except at limit point*}
215 lemma LIM_equal:
216      "[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)"
217 unfolding tendsto_def eventually_at_topological by simp
219 lemma LIM_cong:
220   "\<lbrakk>a = b; \<And>x. x \<noteq> b \<Longrightarrow> f x = g x; l = m\<rbrakk>
221    \<Longrightarrow> ((\<lambda>x. f x) -- a --> l) = ((\<lambda>x. g x) -- b --> m)"
224 lemma metric_LIM_equal2:
225   assumes 1: "0 < R"
226   assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < R\<rbrakk> \<Longrightarrow> f x = g x"
227   shows "g -- a --> l \<Longrightarrow> f -- a --> l"
228 apply (rule topological_tendstoI)
229 apply (drule (2) topological_tendstoD)
230 apply (simp add: eventually_at, safe)
231 apply (rule_tac x="min d R" in exI, safe)
234 done
236 lemma LIM_equal2:
237   fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
238   assumes 1: "0 < R"
239   assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
240   shows "g -- a --> l \<Longrightarrow> f -- a --> l"
241 by (rule metric_LIM_equal2 [OF 1 2], simp_all add: dist_norm)
243 text{*Two uses in Transcendental.ML*} (* BH: no longer true; delete? *)
244 lemma LIM_trans:
245   fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
246   shows "[| (%x. f(x) + -g(x)) -- a --> 0;  g -- a --> l |] ==> f -- a --> l"
249 done
251 lemma LIM_compose:
252   assumes g: "g -- l --> g l"
253   assumes f: "f -- a --> l"
254   shows "(\<lambda>x. g (f x)) -- a --> g l"
255   using assms by (rule tendsto_compose)
257 lemma LIM_compose_eventually:
258   assumes f: "f -- a --> b"
259   assumes g: "g -- b --> c"
260   assumes inj: "eventually (\<lambda>x. f x \<noteq> b) (at a)"
261   shows "(\<lambda>x. g (f x)) -- a --> c"
262 proof (rule topological_tendstoI)
263   fix C assume C: "open C" "c \<in> C"
264   obtain B where B: "open B" "b \<in> B"
265     and gC: "\<And>y. y \<in> B \<Longrightarrow> y \<noteq> b \<Longrightarrow> g y \<in> C"
266     using topological_tendstoD [OF g C]
267     unfolding eventually_at_topological by fast
268   obtain A where A: "open A" "a \<in> A"
269     and fB: "\<And>x. x \<in> A \<Longrightarrow> x \<noteq> a \<Longrightarrow> f x \<in> B"
270     using topological_tendstoD [OF f B]
271     unfolding eventually_at_topological by fast
272   have "eventually (\<lambda>x. f x \<noteq> b \<longrightarrow> g (f x) \<in> C) (at a)"
273   unfolding eventually_at_topological
274   proof (intro exI conjI ballI impI)
275     show "open A" and "a \<in> A" using A .
276   next
277     fix x assume "x \<in> A" and "x \<noteq> a" and "f x \<noteq> b"
278     then show "g (f x) \<in> C" by (simp add: gC fB)
279   qed
280   with inj show "eventually (\<lambda>x. g (f x) \<in> C) (at a)"
281     by (rule eventually_rev_mp)
282 qed
284 lemma metric_LIM_compose2:
285   assumes f: "f -- a --> b"
286   assumes g: "g -- b --> c"
287   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> b"
288   shows "(\<lambda>x. g (f x)) -- a --> c"
289 using f g inj [folded eventually_at]
290 by (rule LIM_compose_eventually)
292 lemma LIM_compose2:
293   fixes a :: "'a::real_normed_vector"
294   assumes f: "f -- a --> b"
295   assumes g: "g -- b --> c"
296   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
297   shows "(\<lambda>x. g (f x)) -- a --> c"
298 by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
300 lemma LIM_o: "\<lbrakk>g -- l --> g l; f -- a --> l\<rbrakk> \<Longrightarrow> (g \<circ> f) -- a --> g l"
301 unfolding o_def by (rule LIM_compose)
303 lemma real_LIM_sandwich_zero:
304   fixes f g :: "'a::topological_space \<Rightarrow> real"
305   assumes f: "f -- a --> 0"
306   assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
307   assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
308   shows "g -- a --> 0"
309 proof (rule LIM_imp_LIM [OF f])
310   fix x assume x: "x \<noteq> a"
311   have "norm (g x - 0) = g x" by (simp add: 1 x)
312   also have "g x \<le> f x" by (rule 2 [OF x])
313   also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
314   also have "\<bar>f x\<bar> = norm (f x - 0)" by simp
315   finally show "norm (g x - 0) \<le> norm (f x - 0)" .
316 qed
318 text {* Bounded Linear Operators *}
320 lemma (in bounded_linear) LIM:
321   "g -- a --> l \<Longrightarrow> (\<lambda>x. f (g x)) -- a --> f l"
322 by (rule tendsto)
324 lemma (in bounded_linear) cont: "f -- a --> f a"
325 by (rule LIM [OF LIM_ident])
327 lemma (in bounded_linear) LIM_zero:
328   "g -- a --> 0 \<Longrightarrow> (\<lambda>x. f (g x)) -- a --> 0"
329   by (rule tendsto_zero)
331 text {* Bounded Bilinear Operators *}
333 lemma (in bounded_bilinear) LIM:
334   "\<lbrakk>f -- a --> L; g -- a --> M\<rbrakk> \<Longrightarrow> (\<lambda>x. f x ** g x) -- a --> L ** M"
335 by (rule tendsto)
337 lemma (in bounded_bilinear) LIM_prod_zero:
338   fixes a :: "'d::metric_space"
339   assumes f: "f -- a --> 0"
340   assumes g: "g -- a --> 0"
341   shows "(\<lambda>x. f x ** g x) -- a --> 0"
342   using f g by (rule tendsto_zero)
344 lemma (in bounded_bilinear) LIM_left_zero:
345   "f -- a --> 0 \<Longrightarrow> (\<lambda>x. f x ** c) -- a --> 0"
346   by (rule tendsto_left_zero)
348 lemma (in bounded_bilinear) LIM_right_zero:
349   "f -- a --> 0 \<Longrightarrow> (\<lambda>x. c ** f x) -- a --> 0"
350   by (rule tendsto_right_zero)
352 lemmas LIM_mult = mult.LIM
354 lemmas LIM_mult_zero = mult.LIM_prod_zero
356 lemmas LIM_mult_left_zero = mult.LIM_left_zero
358 lemmas LIM_mult_right_zero = mult.LIM_right_zero
360 lemmas LIM_scaleR = scaleR.LIM
362 lemmas LIM_of_real = of_real.LIM
364 lemma LIM_power:
365   fixes f :: "'a::topological_space \<Rightarrow> 'b::{power,real_normed_algebra}"
366   assumes f: "f -- a --> l"
367   shows "(\<lambda>x. f x ^ n) -- a --> l ^ n"
368   using assms by (rule tendsto_power)
370 lemma LIM_inverse:
371   fixes L :: "'a::real_normed_div_algebra"
372   shows "\<lbrakk>f -- a --> L; L \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. inverse (f x)) -- a --> inverse L"
373 by (rule tendsto_inverse)
375 lemma LIM_inverse_fun:
376   assumes a: "a \<noteq> (0::'a::real_normed_div_algebra)"
377   shows "inverse -- a --> inverse a"
378 by (rule LIM_inverse [OF LIM_ident a])
380 lemma LIM_sgn:
381   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
382   shows "\<lbrakk>f -- a --> l; l \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. sgn (f x)) -- a --> sgn l"
383   by (rule tendsto_sgn)
386 subsection {* Continuity *}
388 lemma LIM_isCont_iff:
389   fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
390   shows "(f -- a --> f a) = ((\<lambda>h. f (a + h)) -- 0 --> f a)"
391 by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
393 lemma isCont_iff:
394   fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::topological_space"
395   shows "isCont f x = (\<lambda>h. f (x + h)) -- 0 --> f x"
396 by (simp add: isCont_def LIM_isCont_iff)
398 lemma isCont_ident [simp]: "isCont (\<lambda>x. x) a"
399   unfolding isCont_def by (rule LIM_ident)
401 lemma isCont_const [simp]: "isCont (\<lambda>x. k) a"
402   unfolding isCont_def by (rule LIM_const)
404 lemma isCont_norm:
405   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
406   shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a"
407   unfolding isCont_def by (rule LIM_norm)
409 lemma isCont_rabs: "isCont f a \<Longrightarrow> isCont (\<lambda>x. \<bar>f x :: real\<bar>) a"
410   unfolding isCont_def by (rule LIM_rabs)
413   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
414   shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
415   unfolding isCont_def by (rule LIM_add)
417 lemma isCont_minus:
418   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
419   shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
420   unfolding isCont_def by (rule LIM_minus)
422 lemma isCont_diff:
423   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
424   shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
425   unfolding isCont_def by (rule LIM_diff)
427 lemma isCont_mult:
428   fixes f g :: "'a::topological_space \<Rightarrow> 'b::real_normed_algebra"
429   shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x * g x) a"
430   unfolding isCont_def by (rule LIM_mult)
432 lemma isCont_inverse:
433   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_div_algebra"
434   shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. inverse (f x)) a"
435   unfolding isCont_def by (rule LIM_inverse)
437 lemma isCont_LIM_compose:
438   "\<lbrakk>isCont g l; f -- a --> l\<rbrakk> \<Longrightarrow> (\<lambda>x. g (f x)) -- a --> g l"
439   unfolding isCont_def by (rule LIM_compose)
441 lemma metric_isCont_LIM_compose2:
442   assumes f [unfolded isCont_def]: "isCont f a"
443   assumes g: "g -- f a --> l"
444   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> f a"
445   shows "(\<lambda>x. g (f x)) -- a --> l"
446 by (rule metric_LIM_compose2 [OF f g inj])
448 lemma isCont_LIM_compose2:
449   fixes a :: "'a::real_normed_vector"
450   assumes f [unfolded isCont_def]: "isCont f a"
451   assumes g: "g -- f a --> l"
452   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
453   shows "(\<lambda>x. g (f x)) -- a --> l"
454 by (rule LIM_compose2 [OF f g inj])
456 lemma isCont_o2: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. g (f x)) a"
457   unfolding isCont_def by (rule LIM_compose)
459 lemma isCont_o: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (g o f) a"
460   unfolding o_def by (rule isCont_o2)
462 lemma (in bounded_linear) isCont: "isCont f a"
463   unfolding isCont_def by (rule cont)
465 lemma (in bounded_bilinear) isCont:
466   "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x ** g x) a"
467   unfolding isCont_def by (rule LIM)
469 lemmas isCont_scaleR = scaleR.isCont
471 lemma isCont_of_real:
472   "isCont f a \<Longrightarrow> isCont (\<lambda>x. of_real (f x)::'b::real_normed_algebra_1) a"
473   unfolding isCont_def by (rule LIM_of_real)
475 lemma isCont_power:
476   fixes f :: "'a::topological_space \<Rightarrow> 'b::{power,real_normed_algebra}"
477   shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. f x ^ n) a"
478   unfolding isCont_def by (rule LIM_power)
480 lemma isCont_sgn:
481   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_vector"
482   shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. sgn (f x)) a"
483   unfolding isCont_def by (rule LIM_sgn)
485 lemma isCont_abs [simp]: "isCont abs (a::real)"
486 by (rule isCont_rabs [OF isCont_ident])
488 lemma isCont_setsum:
489   fixes f :: "'a \<Rightarrow> 'b::topological_space \<Rightarrow> 'c::real_normed_vector"
490   fixes A :: "'a set" assumes "finite A"
491   shows "\<forall> i \<in> A. isCont (f i) x \<Longrightarrow> isCont (\<lambda> x. \<Sum> i \<in> A. f i x) x"
492   unfolding isCont_def by (simp add: tendsto_setsum)
494 lemma LIM_less_bound: fixes f :: "real \<Rightarrow> real" assumes "b < x"
495   and all_le: "\<forall> x' \<in> { b <..< x}. 0 \<le> f x'" and isCont: "isCont f x"
496   shows "0 \<le> f x"
497 proof (rule ccontr)
498   assume "\<not> 0 \<le> f x" hence "f x < 0" by auto
499   hence "0 < - f x / 2" by auto
500   from isCont[unfolded isCont_def, THEN LIM_D, OF this]
501   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
503   let ?x = "x - min (s / 2) ((x - b) / 2)"
504   have "?x < x" and "\<bar> ?x - x \<bar> < s"
505     using `b < x` and `0 < s` by auto
506   have "b < ?x"
507   proof (cases "s < x - b")
508     case True thus ?thesis using `0 < s` by auto
509   next
510     case False hence "s / 2 \<ge> (x - b) / 2" by auto
511     hence "?x = (x + b) / 2" by (simp add: field_simps min_max.inf_absorb2)
512     thus ?thesis using `b < x` by auto
513   qed
514   hence "0 \<le> f ?x" using all_le `?x < x` by auto
515   moreover have "\<bar>f ?x - f x\<bar> < - f x / 2"
516     using s_D[OF _ `\<bar> ?x - x \<bar> < s`] `?x < x` by auto
517   hence "f ?x - f x < - f x / 2" by auto
518   hence "f ?x < f x / 2" by auto
519   hence "f ?x < 0" using `f x < 0` by auto
520   thus False using `0 \<le> f ?x` by auto
521 qed
524 subsection {* Uniform Continuity *}
526 lemma isUCont_isCont: "isUCont f ==> isCont f x"
527 by (simp add: isUCont_def isCont_def LIM_def, force)
529 lemma isUCont_Cauchy:
530   "\<lbrakk>isUCont f; Cauchy X\<rbrakk> \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
531 unfolding isUCont_def
532 apply (rule metric_CauchyI)
533 apply (drule_tac x=e in spec, safe)
534 apply (drule_tac e=s in metric_CauchyD, safe)
535 apply (rule_tac x=M in exI, simp)
536 done
538 lemma (in bounded_linear) isUCont: "isUCont f"
539 unfolding isUCont_def dist_norm
540 proof (intro allI impI)
541   fix r::real assume r: "0 < r"
542   obtain K where K: "0 < K" and norm_le: "\<And>x. norm (f x) \<le> norm x * K"
543     using pos_bounded by fast
544   show "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
545   proof (rule exI, safe)
546     from r K show "0 < r / K" by (rule divide_pos_pos)
547   next
548     fix x y :: 'a
549     assume xy: "norm (x - y) < r / K"
550     have "norm (f x - f y) = norm (f (x - y))" by (simp only: diff)
551     also have "\<dots> \<le> norm (x - y) * K" by (rule norm_le)
552     also from K xy have "\<dots> < r" by (simp only: pos_less_divide_eq)
553     finally show "norm (f x - f y) < r" .
554   qed
555 qed
557 lemma (in bounded_linear) Cauchy: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
558 by (rule isUCont [THEN isUCont_Cauchy])
561 subsection {* Relation of LIM and LIMSEQ *}
563 lemma LIMSEQ_SEQ_conv1:
564   fixes a :: "'a::metric_space" and L :: "'b::metric_space"
565   assumes X: "X -- a --> L"
566   shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
567 proof (safe intro!: metric_LIMSEQ_I)
568   fix S :: "nat \<Rightarrow> 'a"
569   fix r :: real
570   assume rgz: "0 < r"
571   assume as: "\<forall>n. S n \<noteq> a"
572   assume S: "S ----> a"
573   from metric_LIM_D [OF X rgz] obtain s
574     where sgz: "0 < s"
575     and aux: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < s\<rbrakk> \<Longrightarrow> dist (X x) L < r"
576     by fast
577   from metric_LIMSEQ_D [OF S sgz]
578   obtain no where "\<forall>n\<ge>no. dist (S n) a < s" by blast
579   hence "\<forall>n\<ge>no. dist (X (S n)) L < r" by (simp add: aux as)
580   thus "\<exists>no. \<forall>n\<ge>no. dist (X (S n)) L < r" ..
581 qed
584 lemma LIMSEQ_SEQ_conv2:
585   fixes a :: real and L :: "'a::metric_space"
586   assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
587   shows "X -- a --> L"
588 proof (rule ccontr)
589   assume "\<not> (X -- a --> L)"
590   hence "\<not> (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s --> dist (X x) L < r)"
591     unfolding LIM_def dist_norm .
592   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
593   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)
594   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
596   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"
597   have "\<And>n. \<exists>x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> dist (X x) L \<ge> r"
598     using rdef by simp
599   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"
600     by (rule someI_ex)
601   hence F1: "\<And>n. ?F n \<noteq> a"
602     and F2: "\<And>n. \<bar>?F n - a\<bar> < inverse (real (Suc n))"
603     and F3: "\<And>n. dist (X (?F n)) L \<ge> r"
604     by fast+
606   have "?F ----> a"
607   proof (rule LIMSEQ_I, unfold real_norm_def)
608       fix e::real
609       assume "0 < e"
610         (* choose no such that inverse (real (Suc n)) < e *)
611       then have "\<exists>no. inverse (real (Suc no)) < e" by (rule reals_Archimedean)
612       then obtain m where nodef: "inverse (real (Suc m)) < e" by auto
613       show "\<exists>no. \<forall>n. no \<le> n --> \<bar>?F n - a\<bar> < e"
614       proof (intro exI allI impI)
615         fix n
616         assume mlen: "m \<le> n"
617         have "\<bar>?F n - a\<bar> < inverse (real (Suc n))"
618           by (rule F2)
619         also have "inverse (real (Suc n)) \<le> inverse (real (Suc m))"
620           using mlen by auto
621         also from nodef have
622           "inverse (real (Suc m)) < e" .
623         finally show "\<bar>?F n - a\<bar> < e" .
624       qed
625   qed
627   moreover have "\<forall>n. ?F n \<noteq> a"
628     by (rule allI) (rule F1)
630   moreover note `\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L`
631   ultimately have "(\<lambda>n. X (?F n)) ----> L" by simp
633   moreover have "\<not> ((\<lambda>n. X (?F n)) ----> L)"
634   proof -
635     {
636       fix no::nat
637       obtain n where "n = no + 1" by simp
638       then have nolen: "no \<le> n" by simp
639         (* We prove this by showing that for any m there is an n\<ge>m such that |X (?F n) - L| \<ge> r *)
640       have "dist (X (?F n)) L \<ge> r"
641         by (rule F3)
642       with nolen have "\<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> r" by fast
643     }
644     then have "(\<forall>no. \<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> r)" by simp
645     with rdef have "\<exists>e>0. (\<forall>no. \<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> e)" by auto
646     thus ?thesis by (unfold LIMSEQ_def, auto simp add: not_less)
647   qed
648   ultimately show False by simp
649 qed
651 lemma LIMSEQ_SEQ_conv:
652   "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::real) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
653    (X -- a --> (L::'a::metric_space))"
654 proof
655   assume "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
656   thus "X -- a --> L" by (rule LIMSEQ_SEQ_conv2)
657 next
658   assume "(X -- a --> L)"
659   thus "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by (rule LIMSEQ_SEQ_conv1)
660 qed
662 end