src/HOL/Lim.thy
 author nipkow Fri Aug 28 18:52:41 2009 +0200 (2009-08-28) changeset 32436 10cd49e0c067 parent 31488 5691ccb8d6b5 child 32642 026e7c6a6d08 permissions -rw-r--r--
Turned "x <= y ==> sup x y = y" (and relatives) into simp rules
```     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 *)
```
```     6
```
```     7 header{* Limits and Continuity *}
```
```     8
```
```     9 theory Lim
```
```    10 imports SEQ
```
```    11 begin
```
```    12
```
```    13 text{*Standard Definitions*}
```
```    14
```
```    15 definition
```
```    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)"
```
```    21
```
```    22 definition
```
```    23   isCont :: "['a::metric_space \<Rightarrow> 'b::metric_space, 'a] \<Rightarrow> bool" where
```
```    24   "isCont f a = (f -- a --> (f a))"
```
```    25
```
```    26 definition
```
```    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)"
```
```    29
```
```    30 subsection {* Limits of Functions *}
```
```    31
```
```    32 lemma LIM_conv_tendsto: "(f -- a --> L) \<longleftrightarrow> (f ---> L) (at a)"
```
```    33 unfolding LIM_def tendsto_iff eventually_at ..
```
```    34
```
```    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"
```
```    38 by (simp add: LIM_def)
```
```    39
```
```    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"
```
```    43 by (simp add: LIM_def)
```
```    44
```
```    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)
```
```    50
```
```    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"
```
```    55 by (simp add: LIM_eq)
```
```    56
```
```    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"
```
```    61 by (simp add: LIM_eq)
```
```    62
```
```    63 lemma LIM_offset:
```
```    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
```
```    67 apply clarify
```
```    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)
```
```    72 done
```
```    73
```
```    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)
```
```    78
```
```    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)
```
```    83
```
```    84 lemma LIM_const [simp]: "(%x. k) -- x --> k"
```
```    85 by (simp add: LIM_def)
```
```    86
```
```    87 lemma LIM_add:
```
```    88   fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```    89   assumes f: "f -- a --> L" and g: "g -- a --> M"
```
```    90   shows "(\<lambda>x. f x + g x) -- a --> (L + M)"
```
```    91 using assms unfolding LIM_conv_tendsto by (rule tendsto_add)
```
```    92
```
```    93 lemma LIM_add_zero:
```
```    94   fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```    95   shows "\<lbrakk>f -- a --> 0; g -- a --> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. f x + g x) -- a --> 0"
```
```    96 by (drule (1) LIM_add, simp)
```
```    97
```
```    98 lemma minus_diff_minus:
```
```    99   fixes a b :: "'a::ab_group_add"
```
```   100   shows "(- a) - (- b) = - (a - b)"
```
```   101 by simp
```
```   102
```
```   103 lemma LIM_minus:
```
```   104   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   105   shows "f -- a --> L \<Longrightarrow> (\<lambda>x. - f x) -- a --> - L"
```
```   106 unfolding LIM_conv_tendsto by (rule tendsto_minus)
```
```   107
```
```   108 (* TODO: delete *)
```
```   109 lemma LIM_add_minus:
```
```   110   fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   111   shows "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
```
```   112 by (intro LIM_add LIM_minus)
```
```   113
```
```   114 lemma LIM_diff:
```
```   115   fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   116   shows "\<lbrakk>f -- x --> l; g -- x --> m\<rbrakk> \<Longrightarrow> (\<lambda>x. f x - g x) -- x --> l - m"
```
```   117 unfolding LIM_conv_tendsto by (rule tendsto_diff)
```
```   118
```
```   119 lemma LIM_zero:
```
```   120   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   121   shows "f -- a --> l \<Longrightarrow> (\<lambda>x. f x - l) -- a --> 0"
```
```   122 by (simp add: LIM_def dist_norm)
```
```   123
```
```   124 lemma LIM_zero_cancel:
```
```   125   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   126   shows "(\<lambda>x. f x - l) -- a --> 0 \<Longrightarrow> f -- a --> l"
```
```   127 by (simp add: LIM_def dist_norm)
```
```   128
```
```   129 lemma LIM_zero_iff:
```
```   130   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   131   shows "(\<lambda>x. f x - l) -- a --> 0 = f -- a --> l"
```
```   132 by (simp add: LIM_def dist_norm)
```
```   133
```
```   134 lemma metric_LIM_imp_LIM:
```
```   135   assumes f: "f -- a --> l"
```
```   136   assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> dist (g x) m \<le> dist (f x) l"
```
```   137   shows "g -- a --> m"
```
```   138 apply (rule metric_LIM_I, drule metric_LIM_D [OF f], safe)
```
```   139 apply (rule_tac x="s" in exI, safe)
```
```   140 apply (drule_tac x="x" in spec, safe)
```
```   141 apply (erule (1) order_le_less_trans [OF le])
```
```   142 done
```
```   143
```
```   144 lemma LIM_imp_LIM:
```
```   145   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   146   fixes g :: "'a::metric_space \<Rightarrow> 'c::real_normed_vector"
```
```   147   assumes f: "f -- a --> l"
```
```   148   assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
```
```   149   shows "g -- a --> m"
```
```   150 apply (rule metric_LIM_imp_LIM [OF f])
```
```   151 apply (simp add: dist_norm le)
```
```   152 done
```
```   153
```
```   154 lemma LIM_norm:
```
```   155   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   156   shows "f -- a --> l \<Longrightarrow> (\<lambda>x. norm (f x)) -- a --> norm l"
```
```   157 unfolding LIM_conv_tendsto by (rule tendsto_norm)
```
```   158
```
```   159 lemma LIM_norm_zero:
```
```   160   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   161   shows "f -- a --> 0 \<Longrightarrow> (\<lambda>x. norm (f x)) -- a --> 0"
```
```   162 by (drule LIM_norm, simp)
```
```   163
```
```   164 lemma LIM_norm_zero_cancel:
```
```   165   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   166   shows "(\<lambda>x. norm (f x)) -- a --> 0 \<Longrightarrow> f -- a --> 0"
```
```   167 by (erule LIM_imp_LIM, simp)
```
```   168
```
```   169 lemma LIM_norm_zero_iff:
```
```   170   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   171   shows "(\<lambda>x. norm (f x)) -- a --> 0 = f -- a --> 0"
```
```   172 by (rule iffI [OF LIM_norm_zero_cancel LIM_norm_zero])
```
```   173
```
```   174 lemma LIM_rabs: "f -- a --> (l::real) \<Longrightarrow> (\<lambda>x. \<bar>f x\<bar>) -- a --> \<bar>l\<bar>"
```
```   175 by (fold real_norm_def, rule LIM_norm)
```
```   176
```
```   177 lemma LIM_rabs_zero: "f -- a --> (0::real) \<Longrightarrow> (\<lambda>x. \<bar>f x\<bar>) -- a --> 0"
```
```   178 by (fold real_norm_def, rule LIM_norm_zero)
```
```   179
```
```   180 lemma LIM_rabs_zero_cancel: "(\<lambda>x. \<bar>f x\<bar>) -- a --> (0::real) \<Longrightarrow> f -- a --> 0"
```
```   181 by (fold real_norm_def, rule LIM_norm_zero_cancel)
```
```   182
```
```   183 lemma LIM_rabs_zero_iff: "(\<lambda>x. \<bar>f x\<bar>) -- a --> (0::real) = f -- a --> 0"
```
```   184 by (fold real_norm_def, rule LIM_norm_zero_iff)
```
```   185
```
```   186 lemma LIM_const_not_eq:
```
```   187   fixes a :: "'a::real_normed_algebra_1"
```
```   188   shows "k \<noteq> L \<Longrightarrow> \<not> (\<lambda>x. k) -- a --> L"
```
```   189 apply (simp add: LIM_def)
```
```   190 apply (rule_tac x="dist k L" in exI, simp add: zero_less_dist_iff, safe)
```
```   191 apply (rule_tac x="a + of_real (s/2)" in exI, simp add: dist_norm)
```
```   192 done
```
```   193
```
```   194 lemmas LIM_not_zero = LIM_const_not_eq [where L = 0]
```
```   195
```
```   196 lemma LIM_const_eq:
```
```   197   fixes a :: "'a::real_normed_algebra_1"
```
```   198   shows "(\<lambda>x. k) -- a --> L \<Longrightarrow> k = L"
```
```   199 apply (rule ccontr)
```
```   200 apply (blast dest: LIM_const_not_eq)
```
```   201 done
```
```   202
```
```   203 lemma LIM_unique:
```
```   204   fixes a :: "'a::real_normed_algebra_1" -- {* TODO: find a more appropriate class *}
```
```   205   shows "\<lbrakk>f -- a --> L; f -- a --> M\<rbrakk> \<Longrightarrow> L = M"
```
```   206 apply (rule ccontr)
```
```   207 apply (drule_tac r="dist L M / 2" in metric_LIM_D, simp add: zero_less_dist_iff)
```
```   208 apply (drule_tac r="dist L M / 2" in metric_LIM_D, simp add: zero_less_dist_iff)
```
```   209 apply (clarify, rename_tac r s)
```
```   210 apply (subgoal_tac "min r s \<noteq> 0")
```
```   211 apply (subgoal_tac "dist L M < dist L M / 2 + dist L M / 2", simp)
```
```   212 apply (subgoal_tac "dist L M \<le> dist (f (a + of_real (min r s / 2))) L +
```
```   213                                dist (f (a + of_real (min r s / 2))) M")
```
```   214 apply (erule le_less_trans, rule add_strict_mono)
```
```   215 apply (drule spec, erule mp, simp add: dist_norm)
```
```   216 apply (drule spec, erule mp, simp add: dist_norm)
```
```   217 apply (subst dist_commute, rule dist_triangle)
```
```   218 apply simp
```
```   219 done
```
```   220
```
```   221 lemma LIM_ident [simp]: "(\<lambda>x. x) -- a --> a"
```
```   222 by (auto simp add: LIM_def)
```
```   223
```
```   224 text{*Limits are equal for functions equal except at limit point*}
```
```   225 lemma LIM_equal:
```
```   226      "[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)"
```
```   227 by (simp add: LIM_def)
```
```   228
```
```   229 lemma LIM_cong:
```
```   230   "\<lbrakk>a = b; \<And>x. x \<noteq> b \<Longrightarrow> f x = g x; l = m\<rbrakk>
```
```   231    \<Longrightarrow> ((\<lambda>x. f x) -- a --> l) = ((\<lambda>x. g x) -- b --> m)"
```
```   232 by (simp add: LIM_def)
```
```   233
```
```   234 lemma metric_LIM_equal2:
```
```   235   assumes 1: "0 < R"
```
```   236   assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < R\<rbrakk> \<Longrightarrow> f x = g x"
```
```   237   shows "g -- a --> l \<Longrightarrow> f -- a --> l"
```
```   238 apply (unfold LIM_def, safe)
```
```   239 apply (drule_tac x="r" in spec, safe)
```
```   240 apply (rule_tac x="min s R" in exI, safe)
```
```   241 apply (simp add: 1)
```
```   242 apply (simp add: 2)
```
```   243 done
```
```   244
```
```   245 lemma LIM_equal2:
```
```   246   fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::metric_space"
```
```   247   assumes 1: "0 < R"
```
```   248   assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
```
```   249   shows "g -- a --> l \<Longrightarrow> f -- a --> l"
```
```   250 apply (unfold LIM_def dist_norm, safe)
```
```   251 apply (drule_tac x="r" in spec, safe)
```
```   252 apply (rule_tac x="min s R" in exI, safe)
```
```   253 apply (simp add: 1)
```
```   254 apply (simp add: 2)
```
```   255 done
```
```   256
```
```   257 text{*Two uses in Transcendental.ML*}
```
```   258 lemma LIM_trans:
```
```   259   fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   260   shows "[| (%x. f(x) + -g(x)) -- a --> 0;  g -- a --> l |] ==> f -- a --> l"
```
```   261 apply (drule LIM_add, assumption)
```
```   262 apply (auto simp add: add_assoc)
```
```   263 done
```
```   264
```
```   265 lemma LIM_compose:
```
```   266   assumes g: "g -- l --> g l"
```
```   267   assumes f: "f -- a --> l"
```
```   268   shows "(\<lambda>x. g (f x)) -- a --> g l"
```
```   269 proof (rule metric_LIM_I)
```
```   270   fix r::real assume r: "0 < r"
```
```   271   obtain s where s: "0 < s"
```
```   272     and less_r: "\<And>y. \<lbrakk>y \<noteq> l; dist y l < s\<rbrakk> \<Longrightarrow> dist (g y) (g l) < r"
```
```   273     using metric_LIM_D [OF g r] by fast
```
```   274   obtain t where t: "0 < t"
```
```   275     and less_s: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < t\<rbrakk> \<Longrightarrow> dist (f x) l < s"
```
```   276     using metric_LIM_D [OF f s] by fast
```
```   277
```
```   278   show "\<exists>t>0. \<forall>x. x \<noteq> a \<and> dist x a < t \<longrightarrow> dist (g (f x)) (g l) < r"
```
```   279   proof (rule exI, safe)
```
```   280     show "0 < t" using t .
```
```   281   next
```
```   282     fix x assume "x \<noteq> a" and "dist x a < t"
```
```   283     hence "dist (f x) l < s" by (rule less_s)
```
```   284     thus "dist (g (f x)) (g l) < r"
```
```   285       using r less_r by (case_tac "f x = l", simp_all)
```
```   286   qed
```
```   287 qed
```
```   288
```
```   289 lemma metric_LIM_compose2:
```
```   290   assumes f: "f -- a --> b"
```
```   291   assumes g: "g -- b --> c"
```
```   292   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> b"
```
```   293   shows "(\<lambda>x. g (f x)) -- a --> c"
```
```   294 proof (rule metric_LIM_I)
```
```   295   fix r :: real
```
```   296   assume r: "0 < r"
```
```   297   obtain s where s: "0 < s"
```
```   298     and less_r: "\<And>y. \<lbrakk>y \<noteq> b; dist y b < s\<rbrakk> \<Longrightarrow> dist (g y) c < r"
```
```   299     using metric_LIM_D [OF g r] by fast
```
```   300   obtain t where t: "0 < t"
```
```   301     and less_s: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < t\<rbrakk> \<Longrightarrow> dist (f x) b < s"
```
```   302     using metric_LIM_D [OF f s] by fast
```
```   303   obtain d where d: "0 < d"
```
```   304     and neq_b: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < d\<rbrakk> \<Longrightarrow> f x \<noteq> b"
```
```   305     using inj by fast
```
```   306
```
```   307   show "\<exists>t>0. \<forall>x. x \<noteq> a \<and> dist x a < t \<longrightarrow> dist (g (f x)) c < r"
```
```   308   proof (safe intro!: exI)
```
```   309     show "0 < min d t" using d t by simp
```
```   310   next
```
```   311     fix x
```
```   312     assume "x \<noteq> a" and "dist x a < min d t"
```
```   313     hence "f x \<noteq> b" and "dist (f x) b < s"
```
```   314       using neq_b less_s by simp_all
```
```   315     thus "dist (g (f x)) c < r"
```
```   316       by (rule less_r)
```
```   317   qed
```
```   318 qed
```
```   319
```
```   320 lemma LIM_compose2:
```
```   321   fixes a :: "'a::real_normed_vector"
```
```   322   assumes f: "f -- a --> b"
```
```   323   assumes g: "g -- b --> c"
```
```   324   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> b"
```
```   325   shows "(\<lambda>x. g (f x)) -- a --> c"
```
```   326 by (rule metric_LIM_compose2 [OF f g inj [folded dist_norm]])
```
```   327
```
```   328 lemma LIM_o: "\<lbrakk>g -- l --> g l; f -- a --> l\<rbrakk> \<Longrightarrow> (g \<circ> f) -- a --> g l"
```
```   329 unfolding o_def by (rule LIM_compose)
```
```   330
```
```   331 lemma real_LIM_sandwich_zero:
```
```   332   fixes f g :: "'a::metric_space \<Rightarrow> real"
```
```   333   assumes f: "f -- a --> 0"
```
```   334   assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
```
```   335   assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
```
```   336   shows "g -- a --> 0"
```
```   337 proof (rule LIM_imp_LIM [OF f])
```
```   338   fix x assume x: "x \<noteq> a"
```
```   339   have "norm (g x - 0) = g x" by (simp add: 1 x)
```
```   340   also have "g x \<le> f x" by (rule 2 [OF x])
```
```   341   also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
```
```   342   also have "\<bar>f x\<bar> = norm (f x - 0)" by simp
```
```   343   finally show "norm (g x - 0) \<le> norm (f x - 0)" .
```
```   344 qed
```
```   345
```
```   346 text {* Bounded Linear Operators *}
```
```   347
```
```   348 lemma (in bounded_linear) LIM:
```
```   349   "g -- a --> l \<Longrightarrow> (\<lambda>x. f (g x)) -- a --> f l"
```
```   350 unfolding LIM_conv_tendsto by (rule tendsto)
```
```   351
```
```   352 lemma (in bounded_linear) cont: "f -- a --> f a"
```
```   353 by (rule LIM [OF LIM_ident])
```
```   354
```
```   355 lemma (in bounded_linear) LIM_zero:
```
```   356   "g -- a --> 0 \<Longrightarrow> (\<lambda>x. f (g x)) -- a --> 0"
```
```   357 by (drule LIM, simp only: zero)
```
```   358
```
```   359 text {* Bounded Bilinear Operators *}
```
```   360
```
```   361 lemma (in bounded_bilinear) LIM:
```
```   362   "\<lbrakk>f -- a --> L; g -- a --> M\<rbrakk> \<Longrightarrow> (\<lambda>x. f x ** g x) -- a --> L ** M"
```
```   363 unfolding LIM_conv_tendsto by (rule tendsto)
```
```   364
```
```   365 lemma (in bounded_bilinear) LIM_prod_zero:
```
```   366   fixes a :: "'d::metric_space"
```
```   367   assumes f: "f -- a --> 0"
```
```   368   assumes g: "g -- a --> 0"
```
```   369   shows "(\<lambda>x. f x ** g x) -- a --> 0"
```
```   370 using LIM [OF f g] by (simp add: zero_left)
```
```   371
```
```   372 lemma (in bounded_bilinear) LIM_left_zero:
```
```   373   "f -- a --> 0 \<Longrightarrow> (\<lambda>x. f x ** c) -- a --> 0"
```
```   374 by (rule bounded_linear.LIM_zero [OF bounded_linear_left])
```
```   375
```
```   376 lemma (in bounded_bilinear) LIM_right_zero:
```
```   377   "f -- a --> 0 \<Longrightarrow> (\<lambda>x. c ** f x) -- a --> 0"
```
```   378 by (rule bounded_linear.LIM_zero [OF bounded_linear_right])
```
```   379
```
```   380 lemmas LIM_mult = mult.LIM
```
```   381
```
```   382 lemmas LIM_mult_zero = mult.LIM_prod_zero
```
```   383
```
```   384 lemmas LIM_mult_left_zero = mult.LIM_left_zero
```
```   385
```
```   386 lemmas LIM_mult_right_zero = mult.LIM_right_zero
```
```   387
```
```   388 lemmas LIM_scaleR = scaleR.LIM
```
```   389
```
```   390 lemmas LIM_of_real = of_real.LIM
```
```   391
```
```   392 lemma LIM_power:
```
```   393   fixes f :: "'a::metric_space \<Rightarrow> 'b::{power,real_normed_algebra}"
```
```   394   assumes f: "f -- a --> l"
```
```   395   shows "(\<lambda>x. f x ^ n) -- a --> l ^ n"
```
```   396 by (induct n, simp, simp add: LIM_mult f)
```
```   397
```
```   398 subsubsection {* Derived theorems about @{term LIM} *}
```
```   399
```
```   400 lemma LIM_inverse:
```
```   401   fixes L :: "'a::real_normed_div_algebra"
```
```   402   shows "\<lbrakk>f -- a --> L; L \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. inverse (f x)) -- a --> inverse L"
```
```   403 unfolding LIM_conv_tendsto
```
```   404 by (rule tendsto_inverse)
```
```   405
```
```   406 lemma LIM_inverse_fun:
```
```   407   assumes a: "a \<noteq> (0::'a::real_normed_div_algebra)"
```
```   408   shows "inverse -- a --> inverse a"
```
```   409 by (rule LIM_inverse [OF LIM_ident a])
```
```   410
```
```   411 lemma LIM_sgn:
```
```   412   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   413   shows "\<lbrakk>f -- a --> l; l \<noteq> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. sgn (f x)) -- a --> sgn l"
```
```   414 unfolding sgn_div_norm
```
```   415 by (simp add: LIM_scaleR LIM_inverse LIM_norm)
```
```   416
```
```   417
```
```   418 subsection {* Continuity *}
```
```   419
```
```   420 lemma LIM_isCont_iff:
```
```   421   fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::metric_space"
```
```   422   shows "(f -- a --> f a) = ((\<lambda>h. f (a + h)) -- 0 --> f a)"
```
```   423 by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
```
```   424
```
```   425 lemma isCont_iff:
```
```   426   fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::metric_space"
```
```   427   shows "isCont f x = (\<lambda>h. f (x + h)) -- 0 --> f x"
```
```   428 by (simp add: isCont_def LIM_isCont_iff)
```
```   429
```
```   430 lemma isCont_ident [simp]: "isCont (\<lambda>x. x) a"
```
```   431   unfolding isCont_def by (rule LIM_ident)
```
```   432
```
```   433 lemma isCont_const [simp]: "isCont (\<lambda>x. k) a"
```
```   434   unfolding isCont_def by (rule LIM_const)
```
```   435
```
```   436 lemma isCont_norm:
```
```   437   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   438   shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a"
```
```   439   unfolding isCont_def by (rule LIM_norm)
```
```   440
```
```   441 lemma isCont_rabs: "isCont f a \<Longrightarrow> isCont (\<lambda>x. \<bar>f x :: real\<bar>) a"
```
```   442   unfolding isCont_def by (rule LIM_rabs)
```
```   443
```
```   444 lemma isCont_add:
```
```   445   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   446   shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
```
```   447   unfolding isCont_def by (rule LIM_add)
```
```   448
```
```   449 lemma isCont_minus:
```
```   450   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   451   shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
```
```   452   unfolding isCont_def by (rule LIM_minus)
```
```   453
```
```   454 lemma isCont_diff:
```
```   455   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   456   shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
```
```   457   unfolding isCont_def by (rule LIM_diff)
```
```   458
```
```   459 lemma isCont_mult:
```
```   460   fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_algebra"
```
```   461   shows "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x * g x) a"
```
```   462   unfolding isCont_def by (rule LIM_mult)
```
```   463
```
```   464 lemma isCont_inverse:
```
```   465   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_div_algebra"
```
```   466   shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. inverse (f x)) a"
```
```   467   unfolding isCont_def by (rule LIM_inverse)
```
```   468
```
```   469 lemma isCont_LIM_compose:
```
```   470   "\<lbrakk>isCont g l; f -- a --> l\<rbrakk> \<Longrightarrow> (\<lambda>x. g (f x)) -- a --> g l"
```
```   471   unfolding isCont_def by (rule LIM_compose)
```
```   472
```
```   473 lemma metric_isCont_LIM_compose2:
```
```   474   assumes f [unfolded isCont_def]: "isCont f a"
```
```   475   assumes g: "g -- f a --> l"
```
```   476   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> dist x a < d \<longrightarrow> f x \<noteq> f a"
```
```   477   shows "(\<lambda>x. g (f x)) -- a --> l"
```
```   478 by (rule metric_LIM_compose2 [OF f g inj])
```
```   479
```
```   480 lemma isCont_LIM_compose2:
```
```   481   fixes a :: "'a::real_normed_vector"
```
```   482   assumes f [unfolded isCont_def]: "isCont f a"
```
```   483   assumes g: "g -- f a --> l"
```
```   484   assumes inj: "\<exists>d>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < d \<longrightarrow> f x \<noteq> f a"
```
```   485   shows "(\<lambda>x. g (f x)) -- a --> l"
```
```   486 by (rule LIM_compose2 [OF f g inj])
```
```   487
```
```   488 lemma isCont_o2: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. g (f x)) a"
```
```   489   unfolding isCont_def by (rule LIM_compose)
```
```   490
```
```   491 lemma isCont_o: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (g o f) a"
```
```   492   unfolding o_def by (rule isCont_o2)
```
```   493
```
```   494 lemma (in bounded_linear) isCont: "isCont f a"
```
```   495   unfolding isCont_def by (rule cont)
```
```   496
```
```   497 lemma (in bounded_bilinear) isCont:
```
```   498   "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x ** g x) a"
```
```   499   unfolding isCont_def by (rule LIM)
```
```   500
```
```   501 lemmas isCont_scaleR = scaleR.isCont
```
```   502
```
```   503 lemma isCont_of_real:
```
```   504   "isCont f a \<Longrightarrow> isCont (\<lambda>x. of_real (f x)::'b::real_normed_algebra_1) a"
```
```   505   unfolding isCont_def by (rule LIM_of_real)
```
```   506
```
```   507 lemma isCont_power:
```
```   508   fixes f :: "'a::metric_space \<Rightarrow> 'b::{power,real_normed_algebra}"
```
```   509   shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. f x ^ n) a"
```
```   510   unfolding isCont_def by (rule LIM_power)
```
```   511
```
```   512 lemma isCont_sgn:
```
```   513   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   514   shows "\<lbrakk>isCont f a; f a \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. sgn (f x)) a"
```
```   515   unfolding isCont_def by (rule LIM_sgn)
```
```   516
```
```   517 lemma isCont_abs [simp]: "isCont abs (a::real)"
```
```   518 by (rule isCont_rabs [OF isCont_ident])
```
```   519
```
```   520 lemma isCont_setsum:
```
```   521   fixes f :: "'a \<Rightarrow> 'b::metric_space \<Rightarrow> 'c::real_normed_vector"
```
```   522   fixes A :: "'a set" assumes "finite A"
```
```   523   shows "\<forall> i \<in> A. isCont (f i) x \<Longrightarrow> isCont (\<lambda> x. \<Sum> i \<in> A. f i x) x"
```
```   524   using `finite A`
```
```   525 proof induct
```
```   526   case (insert a F) show "isCont (\<lambda> x. \<Sum> i \<in> (insert a F). f i x) x"
```
```   527     unfolding setsum_insert[OF `finite F` `a \<notin> F`] by (rule isCont_add, auto simp add: insert)
```
```   528 qed auto
```
```   529
```
```   530 lemma LIM_less_bound: fixes f :: "real \<Rightarrow> real" assumes "b < x"
```
```   531   and all_le: "\<forall> x' \<in> { b <..< x}. 0 \<le> f x'" and isCont: "isCont f x"
```
```   532   shows "0 \<le> f x"
```
```   533 proof (rule ccontr)
```
```   534   assume "\<not> 0 \<le> f x" hence "f x < 0" by auto
```
```   535   hence "0 < - f x / 2" by auto
```
```   536   from isCont[unfolded isCont_def, THEN LIM_D, OF this]
```
```   537   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
```
```   538
```
```   539   let ?x = "x - min (s / 2) ((x - b) / 2)"
```
```   540   have "?x < x" and "\<bar> ?x - x \<bar> < s"
```
```   541     using `b < x` and `0 < s` by auto
```
```   542   have "b < ?x"
```
```   543   proof (cases "s < x - b")
```
```   544     case True thus ?thesis using `0 < s` by auto
```
```   545   next
```
```   546     case False hence "s / 2 \<ge> (x - b) / 2" by auto
```
```   547     hence "?x = (x + b) / 2" by(simp add:field_simps)
```
```   548     thus ?thesis using `b < x` by auto
```
```   549   qed
```
```   550   hence "0 \<le> f ?x" using all_le `?x < x` by auto
```
```   551   moreover have "\<bar>f ?x - f x\<bar> < - f x / 2"
```
```   552     using s_D[OF _ `\<bar> ?x - x \<bar> < s`] `?x < x` by auto
```
```   553   hence "f ?x - f x < - f x / 2" by auto
```
```   554   hence "f ?x < f x / 2" by auto
```
```   555   hence "f ?x < 0" using `f x < 0` by auto
```
```   556   thus False using `0 \<le> f ?x` by auto
```
```   557 qed
```
```   558
```
```   559
```
```   560 subsection {* Uniform Continuity *}
```
```   561
```
```   562 lemma isUCont_isCont: "isUCont f ==> isCont f x"
```
```   563 by (simp add: isUCont_def isCont_def LIM_def, force)
```
```   564
```
```   565 lemma isUCont_Cauchy:
```
```   566   "\<lbrakk>isUCont f; Cauchy X\<rbrakk> \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
```
```   567 unfolding isUCont_def
```
```   568 apply (rule metric_CauchyI)
```
```   569 apply (drule_tac x=e in spec, safe)
```
```   570 apply (drule_tac e=s in metric_CauchyD, safe)
```
```   571 apply (rule_tac x=M in exI, simp)
```
```   572 done
```
```   573
```
```   574 lemma (in bounded_linear) isUCont: "isUCont f"
```
```   575 unfolding isUCont_def dist_norm
```
```   576 proof (intro allI impI)
```
```   577   fix r::real assume r: "0 < r"
```
```   578   obtain K where K: "0 < K" and norm_le: "\<And>x. norm (f x) \<le> norm x * K"
```
```   579     using pos_bounded by fast
```
```   580   show "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
```
```   581   proof (rule exI, safe)
```
```   582     from r K show "0 < r / K" by (rule divide_pos_pos)
```
```   583   next
```
```   584     fix x y :: 'a
```
```   585     assume xy: "norm (x - y) < r / K"
```
```   586     have "norm (f x - f y) = norm (f (x - y))" by (simp only: diff)
```
```   587     also have "\<dots> \<le> norm (x - y) * K" by (rule norm_le)
```
```   588     also from K xy have "\<dots> < r" by (simp only: pos_less_divide_eq)
```
```   589     finally show "norm (f x - f y) < r" .
```
```   590   qed
```
```   591 qed
```
```   592
```
```   593 lemma (in bounded_linear) Cauchy: "Cauchy X \<Longrightarrow> Cauchy (\<lambda>n. f (X n))"
```
```   594 by (rule isUCont [THEN isUCont_Cauchy])
```
```   595
```
```   596
```
```   597 subsection {* Relation of LIM and LIMSEQ *}
```
```   598
```
```   599 lemma LIMSEQ_SEQ_conv1:
```
```   600   fixes a :: "'a::metric_space"
```
```   601   assumes X: "X -- a --> L"
```
```   602   shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
```
```   603 proof (safe intro!: metric_LIMSEQ_I)
```
```   604   fix S :: "nat \<Rightarrow> 'a"
```
```   605   fix r :: real
```
```   606   assume rgz: "0 < r"
```
```   607   assume as: "\<forall>n. S n \<noteq> a"
```
```   608   assume S: "S ----> a"
```
```   609   from metric_LIM_D [OF X rgz] obtain s
```
```   610     where sgz: "0 < s"
```
```   611     and aux: "\<And>x. \<lbrakk>x \<noteq> a; dist x a < s\<rbrakk> \<Longrightarrow> dist (X x) L < r"
```
```   612     by fast
```
```   613   from metric_LIMSEQ_D [OF S sgz]
```
```   614   obtain no where "\<forall>n\<ge>no. dist (S n) a < s" by blast
```
```   615   hence "\<forall>n\<ge>no. dist (X (S n)) L < r" by (simp add: aux as)
```
```   616   thus "\<exists>no. \<forall>n\<ge>no. dist (X (S n)) L < r" ..
```
```   617 qed
```
```   618
```
```   619
```
```   620 lemma LIMSEQ_SEQ_conv2:
```
```   621   fixes a :: real
```
```   622   assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
```
```   623   shows "X -- a --> L"
```
```   624 proof (rule ccontr)
```
```   625   assume "\<not> (X -- a --> L)"
```
```   626   hence "\<not> (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s --> dist (X x) L < r)"
```
```   627     unfolding LIM_def dist_norm .
```
```   628   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
```
```   629   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)
```
```   630   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
```
```   631
```
```   632   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"
```
```   633   have "\<And>n. \<exists>x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> dist (X x) L \<ge> r"
```
```   634     using rdef by simp
```
```   635   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"
```
```   636     by (rule someI_ex)
```
```   637   hence F1: "\<And>n. ?F n \<noteq> a"
```
```   638     and F2: "\<And>n. \<bar>?F n - a\<bar> < inverse (real (Suc n))"
```
```   639     and F3: "\<And>n. dist (X (?F n)) L \<ge> r"
```
```   640     by fast+
```
```   641
```
```   642   have "?F ----> a"
```
```   643   proof (rule LIMSEQ_I, unfold real_norm_def)
```
```   644       fix e::real
```
```   645       assume "0 < e"
```
```   646         (* choose no such that inverse (real (Suc n)) < e *)
```
```   647       then have "\<exists>no. inverse (real (Suc no)) < e" by (rule reals_Archimedean)
```
```   648       then obtain m where nodef: "inverse (real (Suc m)) < e" by auto
```
```   649       show "\<exists>no. \<forall>n. no \<le> n --> \<bar>?F n - a\<bar> < e"
```
```   650       proof (intro exI allI impI)
```
```   651         fix n
```
```   652         assume mlen: "m \<le> n"
```
```   653         have "\<bar>?F n - a\<bar> < inverse (real (Suc n))"
```
```   654           by (rule F2)
```
```   655         also have "inverse (real (Suc n)) \<le> inverse (real (Suc m))"
```
```   656           using mlen by auto
```
```   657         also from nodef have
```
```   658           "inverse (real (Suc m)) < e" .
```
```   659         finally show "\<bar>?F n - a\<bar> < e" .
```
```   660       qed
```
```   661   qed
```
```   662
```
```   663   moreover have "\<forall>n. ?F n \<noteq> a"
```
```   664     by (rule allI) (rule F1)
```
```   665
```
```   666   moreover from prems have "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by simp
```
```   667   ultimately have "(\<lambda>n. X (?F n)) ----> L" by simp
```
```   668
```
```   669   moreover have "\<not> ((\<lambda>n. X (?F n)) ----> L)"
```
```   670   proof -
```
```   671     {
```
```   672       fix no::nat
```
```   673       obtain n where "n = no + 1" by simp
```
```   674       then have nolen: "no \<le> n" by simp
```
```   675         (* We prove this by showing that for any m there is an n\<ge>m such that |X (?F n) - L| \<ge> r *)
```
```   676       have "dist (X (?F n)) L \<ge> r"
```
```   677         by (rule F3)
```
```   678       with nolen have "\<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> r" by fast
```
```   679     }
```
```   680     then have "(\<forall>no. \<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> r)" by simp
```
```   681     with rdef have "\<exists>e>0. (\<forall>no. \<exists>n. no \<le> n \<and> dist (X (?F n)) L \<ge> e)" by auto
```
```   682     thus ?thesis by (unfold LIMSEQ_def, auto simp add: not_less)
```
```   683   qed
```
```   684   ultimately show False by simp
```
```   685 qed
```
```   686
```
```   687 lemma LIMSEQ_SEQ_conv:
```
```   688   "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::real) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
```
```   689    (X -- a --> L)"
```
```   690 proof
```
```   691   assume "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
```
```   692   thus "X -- a --> L" by (rule LIMSEQ_SEQ_conv2)
```
```   693 next
```
```   694   assume "(X -- a --> L)"
```
```   695   thus "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by (rule LIMSEQ_SEQ_conv1)
```
```   696 qed
```
```   697
```
```   698 end
```