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