src/HOL/Hyperreal/Lim.thy
author huffman
Wed Nov 08 02:13:02 2006 +0100 (2006-11-08)
changeset 21239 d4fbe2c87ef1
parent 21165 8fb49f668511
child 21257 b7f090c5057d
permissions -rw-r--r--
LIM_compose -> isCont_LIM_compose;
cleaned up and reorganized sections
paulson@10751
     1
(*  Title       : Lim.thy
paulson@14477
     2
    ID          : $Id$
paulson@10751
     3
    Author      : Jacques D. Fleuriot
paulson@10751
     4
    Copyright   : 1998  University of Cambridge
paulson@14477
     5
    Conversion to Isar and new proofs by Lawrence C Paulson, 2004
paulson@10751
     6
*)
paulson@10751
     7
huffman@21165
     8
header{* Limits and Continuity *}
paulson@10751
     9
nipkow@15131
    10
theory Lim
nipkow@15360
    11
imports SEQ
nipkow@15131
    12
begin
paulson@14477
    13
paulson@14477
    14
text{*Standard and Nonstandard Definitions*}
paulson@10751
    15
wenzelm@19765
    16
definition
huffman@20561
    17
  LIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool"
kleing@19023
    18
        ("((_)/ -- (_)/ --> (_))" [60, 0, 60] 60)
wenzelm@19765
    19
  "f -- a --> L =
huffman@20563
    20
     (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s
huffman@20563
    21
        --> norm (f x - L) < r)"
paulson@10751
    22
huffman@20561
    23
  NSLIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool"
kleing@19023
    24
            ("((_)/ -- (_)/ --NS> (_))" [60, 0, 60] 60)
huffman@20552
    25
  "f -- a --NS> L =
huffman@20552
    26
    (\<forall>x. (x \<noteq> star_of a & x @= star_of a --> ( *f* f) x @= star_of L))"
paulson@10751
    27
huffman@20561
    28
  isCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool"
wenzelm@19765
    29
  "isCont f a = (f -- a --> (f a))"
paulson@10751
    30
huffman@20561
    31
  isNSCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool"
paulson@15228
    32
    --{*NS definition dispenses with limit notions*}
huffman@20552
    33
  "isNSCont f a = (\<forall>y. y @= star_of a -->
huffman@20552
    34
         ( *f* f) y @= star_of (f a))"
paulson@10751
    35
huffman@20752
    36
  isUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool"
huffman@20752
    37
  "isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r)"
paulson@10751
    38
huffman@20752
    39
  isNSUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool"
wenzelm@19765
    40
  "isNSUCont f = (\<forall>x y. x @= y --> ( *f* f) x @= ( *f* f) y)"
paulson@10751
    41
paulson@10751
    42
huffman@20755
    43
subsection {* Limits of Functions *}
paulson@14477
    44
huffman@20755
    45
subsubsection {* Purely standard proofs *}
paulson@14477
    46
paulson@14477
    47
lemma LIM_eq:
paulson@14477
    48
     "f -- a --> L =
huffman@20561
    49
     (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)"
paulson@14477
    50
by (simp add: LIM_def diff_minus)
paulson@14477
    51
huffman@20552
    52
lemma LIM_I:
huffman@20561
    53
     "(!!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:
paulson@14477
    58
     "[| f -- a --> L; 0<r |]
huffman@20561
    59
      ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r"
paulson@14477
    60
by (simp add: LIM_eq)
paulson@14477
    61
huffman@21165
    62
lemma LIM_offset: "f -- a --> L \<Longrightarrow> (\<lambda>x. f (x + k)) -- a - k --> L"
huffman@20756
    63
apply (rule LIM_I)
huffman@20756
    64
apply (drule_tac r="r" in LIM_D, safe)
huffman@20756
    65
apply (rule_tac x="s" in exI, safe)
huffman@20756
    66
apply (drule_tac x="x + k" in spec)
huffman@20756
    67
apply (simp add: compare_rls)
huffman@20756
    68
done
huffman@20756
    69
huffman@21239
    70
lemma LIM_offset_zero: "f -- a --> L \<Longrightarrow> (\<lambda>h. f (a + h)) -- 0 --> L"
huffman@21239
    71
by (drule_tac k="a" in LIM_offset, simp add: add_commute)
huffman@21239
    72
huffman@21239
    73
lemma LIM_offset_zero_cancel: "(\<lambda>h. f (a + h)) -- 0 --> L \<Longrightarrow> f -- a --> L"
huffman@21239
    74
by (drule_tac k="- a" in LIM_offset, simp)
huffman@21239
    75
paulson@15228
    76
lemma LIM_const [simp]: "(%x. k) -- x --> k"
paulson@14477
    77
by (simp add: LIM_def)
paulson@14477
    78
paulson@14477
    79
lemma LIM_add:
huffman@20561
    80
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
paulson@14477
    81
  assumes f: "f -- a --> L" and g: "g -- a --> M"
paulson@14477
    82
  shows "(%x. f x + g(x)) -- a --> (L + M)"
huffman@20552
    83
proof (rule LIM_I)
paulson@14477
    84
  fix r :: real
huffman@20409
    85
  assume r: "0 < r"
paulson@14477
    86
  from LIM_D [OF f half_gt_zero [OF r]]
paulson@14477
    87
  obtain fs
paulson@14477
    88
    where fs:    "0 < fs"
huffman@20561
    89
      and fs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < fs --> norm (f x - L) < r/2"
paulson@14477
    90
  by blast
paulson@14477
    91
  from LIM_D [OF g half_gt_zero [OF r]]
paulson@14477
    92
  obtain gs
paulson@14477
    93
    where gs:    "0 < gs"
huffman@20561
    94
      and gs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < gs --> norm (g x - M) < r/2"
paulson@14477
    95
  by blast
huffman@20561
    96
  show "\<exists>s>0.\<forall>x. x \<noteq> a \<and> norm (x-a) < s \<longrightarrow> norm (f x + g x - (L + M)) < r"
paulson@14477
    97
  proof (intro exI conjI strip)
paulson@14477
    98
    show "0 < min fs gs"  by (simp add: fs gs)
huffman@20561
    99
    fix x :: 'a
huffman@20561
   100
    assume "x \<noteq> a \<and> norm (x-a) < min fs gs"
huffman@20561
   101
    hence "x \<noteq> a \<and> norm (x-a) < fs \<and> norm (x-a) < gs" by simp
paulson@14477
   102
    with fs_lt gs_lt
huffman@20552
   103
    have "norm (f x - L) < r/2" and "norm (g x - M) < r/2" by blast+
huffman@20552
   104
    hence "norm (f x - L) + norm (g x - M) < r" by arith
huffman@20552
   105
    thus "norm (f x + g x - (L + M)) < r"
huffman@20552
   106
      by (blast intro: norm_diff_triangle_ineq order_le_less_trans)
paulson@14477
   107
  qed
paulson@14477
   108
qed
paulson@14477
   109
huffman@20552
   110
lemma minus_diff_minus:
huffman@20552
   111
  fixes a b :: "'a::ab_group_add"
huffman@20552
   112
  shows "(- a) - (- b) = - (a - b)"
huffman@20552
   113
by simp
huffman@20552
   114
paulson@14477
   115
lemma LIM_minus: "f -- a --> L ==> (%x. -f(x)) -- a --> -L"
huffman@20552
   116
by (simp only: LIM_eq minus_diff_minus norm_minus_cancel)
paulson@14477
   117
paulson@14477
   118
lemma LIM_add_minus:
paulson@14477
   119
    "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
huffman@20552
   120
by (intro LIM_add LIM_minus)
paulson@14477
   121
paulson@14477
   122
lemma LIM_diff:
paulson@14477
   123
    "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) - g(x)) -- x --> l-m"
huffman@20552
   124
by (simp only: diff_minus LIM_add LIM_minus)
paulson@14477
   125
huffman@21239
   126
lemma LIM_zero: "f -- a --> l \<Longrightarrow> (\<lambda>x. f x - l) -- a --> 0"
huffman@21239
   127
by (simp add: LIM_def)
huffman@21239
   128
huffman@21239
   129
lemma LIM_zero_cancel: "(\<lambda>x. f x - l) -- a --> 0 \<Longrightarrow> f -- a --> l"
huffman@21239
   130
by (simp add: LIM_def)
huffman@21239
   131
huffman@20561
   132
lemma LIM_const_not_eq:
huffman@20561
   133
  fixes a :: "'a::real_normed_div_algebra"
huffman@20561
   134
  shows "k \<noteq> L ==> ~ ((%x. k) -- a --> L)"
huffman@20552
   135
apply (simp add: LIM_eq)
huffman@20552
   136
apply (rule_tac x="norm (k - L)" in exI, simp, safe)
huffman@20561
   137
apply (rule_tac x="a + of_real (s/2)" in exI, simp add: norm_of_real)
huffman@20552
   138
done
paulson@14477
   139
huffman@20561
   140
lemma LIM_const_eq:
huffman@20561
   141
  fixes a :: "'a::real_normed_div_algebra"
huffman@20561
   142
  shows "(%x. k) -- a --> L ==> k = L"
paulson@14477
   143
apply (rule ccontr)
kleing@19023
   144
apply (blast dest: LIM_const_not_eq)
paulson@14477
   145
done
paulson@14477
   146
huffman@20561
   147
lemma LIM_unique:
huffman@20561
   148
  fixes a :: "'a::real_normed_div_algebra"
huffman@20561
   149
  shows "[| f -- a --> L; f -- a --> M |] ==> L = M"
kleing@19023
   150
apply (drule LIM_diff, assumption)
paulson@14477
   151
apply (auto dest!: LIM_const_eq)
paulson@14477
   152
done
paulson@14477
   153
paulson@14477
   154
lemma LIM_mult_zero:
huffman@20561
   155
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
paulson@14477
   156
  assumes f: "f -- a --> 0" and g: "g -- a --> 0"
paulson@14477
   157
  shows "(%x. f(x) * g(x)) -- a --> 0"
huffman@20552
   158
proof (rule LIM_I, simp)
paulson@14477
   159
  fix r :: real
paulson@14477
   160
  assume r: "0<r"
paulson@14477
   161
  from LIM_D [OF f zero_less_one]
paulson@14477
   162
  obtain fs
paulson@14477
   163
    where fs:    "0 < fs"
huffman@20561
   164
      and fs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < fs --> norm (f x) < 1"
paulson@14477
   165
  by auto
paulson@14477
   166
  from LIM_D [OF g r]
paulson@14477
   167
  obtain gs
paulson@14477
   168
    where gs:    "0 < gs"
huffman@20561
   169
      and gs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < gs --> norm (g x) < r"
paulson@14477
   170
  by auto
huffman@20561
   171
  show "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> a \<and> norm (x-a) < s \<longrightarrow> norm (f x * g x) < r)"
paulson@14477
   172
  proof (intro exI conjI strip)
paulson@14477
   173
    show "0 < min fs gs"  by (simp add: fs gs)
huffman@20561
   174
    fix x :: 'a
huffman@20561
   175
    assume "x \<noteq> a \<and> norm (x-a) < min fs gs"
huffman@20561
   176
    hence  "x \<noteq> a \<and> norm (x-a) < fs \<and> norm (x-a) < gs" by simp
paulson@14477
   177
    with fs_lt gs_lt
huffman@20552
   178
    have "norm (f x) < 1" and "norm (g x) < r" by blast+
huffman@20552
   179
    hence "norm (f x) * norm (g x) < 1*r"
huffman@20552
   180
      by (rule mult_strict_mono' [OF _ _ norm_ge_zero norm_ge_zero])
huffman@20552
   181
    thus "norm (f x * g x) < r"
huffman@20552
   182
      by (simp add: order_le_less_trans [OF norm_mult_ineq])
paulson@14477
   183
  qed
paulson@14477
   184
qed
paulson@14477
   185
paulson@14477
   186
lemma LIM_self: "(%x. x) -- a --> a"
paulson@14477
   187
by (auto simp add: LIM_def)
paulson@14477
   188
paulson@14477
   189
text{*Limits are equal for functions equal except at limit point*}
paulson@14477
   190
lemma LIM_equal:
paulson@14477
   191
     "[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)"
paulson@14477
   192
by (simp add: LIM_def)
paulson@14477
   193
huffman@20796
   194
lemma LIM_cong:
huffman@20796
   195
  "\<lbrakk>a = b; \<And>x. x \<noteq> b \<Longrightarrow> f x = g x; l = m\<rbrakk>
huffman@20796
   196
   \<Longrightarrow> (f -- a --> l) = (g -- b --> m)"
huffman@20796
   197
by (simp add: LIM_def)
huffman@20796
   198
paulson@14477
   199
text{*Two uses in Hyperreal/Transcendental.ML*}
paulson@14477
   200
lemma LIM_trans:
paulson@14477
   201
     "[| (%x. f(x) + -g(x)) -- a --> 0;  g -- a --> l |] ==> f -- a --> l"
paulson@14477
   202
apply (drule LIM_add, assumption)
paulson@14477
   203
apply (auto simp add: add_assoc)
paulson@14477
   204
done
paulson@14477
   205
huffman@21239
   206
lemma LIM_compose:
huffman@21239
   207
  assumes g: "g -- l --> g l"
huffman@21239
   208
  assumes f: "f -- a --> l"
huffman@21239
   209
  shows "(\<lambda>x. g (f x)) -- a --> g l"
huffman@21239
   210
proof (rule LIM_I)
huffman@21239
   211
  fix r::real assume r: "0 < r"
huffman@21239
   212
  obtain s where s: "0 < s"
huffman@21239
   213
    and less_r: "\<And>y. \<lbrakk>y \<noteq> l; norm (y - l) < s\<rbrakk> \<Longrightarrow> norm (g y - g l) < r"
huffman@21239
   214
    using LIM_D [OF g r] by fast
huffman@21239
   215
  obtain t where t: "0 < t"
huffman@21239
   216
    and less_s: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < t\<rbrakk> \<Longrightarrow> norm (f x - l) < s"
huffman@21239
   217
    using LIM_D [OF f s] by fast
huffman@21239
   218
huffman@21239
   219
  show "\<exists>t>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < t \<longrightarrow> norm (g (f x) - g l) < r"
huffman@21239
   220
  proof (rule exI, safe)
huffman@21239
   221
    show "0 < t" using t .
huffman@21239
   222
  next
huffman@21239
   223
    fix x assume "x \<noteq> a" and "norm (x - a) < t"
huffman@21239
   224
    hence "norm (f x - l) < s" by (rule less_s)
huffman@21239
   225
    thus "norm (g (f x) - g l) < r"
huffman@21239
   226
      using r less_r by (case_tac "f x = l", simp_all)
huffman@21239
   227
  qed
huffman@21239
   228
qed
huffman@21239
   229
huffman@21239
   230
lemma LIM_o: "\<lbrakk>g -- l --> g l; f -- a --> l\<rbrakk> \<Longrightarrow> (g \<circ> f) -- a --> g l"
huffman@21239
   231
unfolding o_def by (rule LIM_compose)
huffman@21239
   232
huffman@20755
   233
subsubsection {* Purely nonstandard proofs *}
paulson@14477
   234
huffman@20754
   235
lemma NSLIM_I:
huffman@20754
   236
  "(\<And>x. \<lbrakk>x \<noteq> star_of a; x \<approx> star_of a\<rbrakk> \<Longrightarrow> starfun f x \<approx> star_of L)
huffman@20754
   237
   \<Longrightarrow> f -- a --NS> L"
huffman@20754
   238
by (simp add: NSLIM_def)
paulson@14477
   239
huffman@20754
   240
lemma NSLIM_D:
huffman@20754
   241
  "\<lbrakk>f -- a --NS> L; x \<noteq> star_of a; x \<approx> star_of a\<rbrakk>
huffman@20754
   242
   \<Longrightarrow> starfun f x \<approx> star_of L"
huffman@20754
   243
by (simp add: NSLIM_def)
paulson@14477
   244
huffman@20755
   245
text{*Proving properties of limits using nonstandard definition.
huffman@20755
   246
      The properties hold for standard limits as well!*}
huffman@20755
   247
huffman@20755
   248
lemma NSLIM_mult:
huffman@20755
   249
  fixes l m :: "'a::real_normed_algebra"
huffman@20755
   250
  shows "[| f -- x --NS> l; g -- x --NS> m |]
huffman@20755
   251
      ==> (%x. f(x) * g(x)) -- x --NS> (l * m)"
huffman@20755
   252
by (auto simp add: NSLIM_def intro!: approx_mult_HFinite)
huffman@20755
   253
huffman@20794
   254
lemma starfun_scaleR [simp]:
huffman@20794
   255
  "starfun (\<lambda>x. f x *# g x) = (\<lambda>x. scaleHR (starfun f x) (starfun g x))"
huffman@20794
   256
by transfer (rule refl)
huffman@20794
   257
huffman@20794
   258
lemma NSLIM_scaleR:
huffman@20794
   259
  "[| f -- x --NS> l; g -- x --NS> m |]
huffman@20794
   260
      ==> (%x. f(x) *# g(x)) -- x --NS> (l *# m)"
huffman@20794
   261
by (auto simp add: NSLIM_def intro!: approx_scaleR_HFinite)
huffman@20794
   262
huffman@20755
   263
lemma NSLIM_add:
huffman@20755
   264
     "[| f -- x --NS> l; g -- x --NS> m |]
huffman@20755
   265
      ==> (%x. f(x) + g(x)) -- x --NS> (l + m)"
huffman@20755
   266
by (auto simp add: NSLIM_def intro!: approx_add)
huffman@20755
   267
huffman@20755
   268
lemma NSLIM_const [simp]: "(%x. k) -- x --NS> k"
huffman@20755
   269
by (simp add: NSLIM_def)
huffman@20755
   270
huffman@20755
   271
lemma NSLIM_minus: "f -- a --NS> L ==> (%x. -f(x)) -- a --NS> -L"
huffman@20755
   272
by (simp add: NSLIM_def)
huffman@20755
   273
huffman@20755
   274
lemma NSLIM_add_minus: "[| f -- x --NS> l; g -- x --NS> m |] ==> (%x. f(x) + -g(x)) -- x --NS> (l + -m)"
huffman@20755
   275
by (simp only: NSLIM_add NSLIM_minus)
huffman@20755
   276
huffman@20755
   277
lemma NSLIM_inverse:
huffman@20755
   278
  fixes L :: "'a::real_normed_div_algebra"
huffman@20755
   279
  shows "[| f -- a --NS> L;  L \<noteq> 0 |]
huffman@20755
   280
      ==> (%x. inverse(f(x))) -- a --NS> (inverse L)"
huffman@20755
   281
apply (simp add: NSLIM_def, clarify)
huffman@20755
   282
apply (drule spec)
huffman@20755
   283
apply (auto simp add: star_of_approx_inverse)
huffman@20755
   284
done
huffman@20755
   285
huffman@20755
   286
lemma NSLIM_zero:
huffman@20755
   287
  assumes f: "f -- a --NS> l" shows "(%x. f(x) + -l) -- a --NS> 0"
huffman@20755
   288
proof -
huffman@20755
   289
  have "(\<lambda>x. f x + - l) -- a --NS> l + -l"
huffman@20755
   290
    by (rule NSLIM_add_minus [OF f NSLIM_const])
huffman@20755
   291
  thus ?thesis by simp
huffman@20755
   292
qed
huffman@20755
   293
huffman@20755
   294
lemma NSLIM_zero_cancel: "(%x. f(x) - l) -- x --NS> 0 ==> f -- x --NS> l"
huffman@20755
   295
apply (drule_tac g = "%x. l" and m = l in NSLIM_add)
huffman@20755
   296
apply (auto simp add: diff_minus add_assoc)
huffman@20755
   297
done
huffman@20755
   298
huffman@20755
   299
lemma NSLIM_const_not_eq:
huffman@20755
   300
  fixes a :: real (* TODO: generalize to real_normed_div_algebra *)
huffman@20755
   301
  shows "k \<noteq> L ==> ~ ((%x. k) -- a --NS> L)"
huffman@20755
   302
apply (simp add: NSLIM_def)
huffman@20755
   303
apply (rule_tac x="star_of a + epsilon" in exI)
huffman@20755
   304
apply (auto intro: Infinitesimal_add_approx_self [THEN approx_sym]
huffman@20755
   305
            simp add: hypreal_epsilon_not_zero)
huffman@20755
   306
done
huffman@20755
   307
huffman@20755
   308
lemma NSLIM_not_zero:
huffman@20755
   309
  fixes a :: real
huffman@20755
   310
  shows "k \<noteq> 0 ==> ~ ((%x. k) -- a --NS> 0)"
huffman@20755
   311
by (rule NSLIM_const_not_eq)
huffman@20755
   312
huffman@20755
   313
lemma NSLIM_const_eq:
huffman@20755
   314
  fixes a :: real
huffman@20755
   315
  shows "(%x. k) -- a --NS> L ==> k = L"
huffman@20755
   316
apply (rule ccontr)
huffman@20755
   317
apply (blast dest: NSLIM_const_not_eq)
huffman@20755
   318
done
huffman@20755
   319
huffman@20755
   320
text{* can actually be proved more easily by unfolding the definition!*}
huffman@20755
   321
lemma NSLIM_unique:
huffman@20755
   322
  fixes a :: real
huffman@20755
   323
  shows "[| f -- a --NS> L; f -- a --NS> M |] ==> L = M"
huffman@20755
   324
apply (drule NSLIM_minus)
huffman@20755
   325
apply (drule NSLIM_add, assumption)
huffman@20755
   326
apply (auto dest!: NSLIM_const_eq [symmetric])
huffman@20755
   327
apply (simp add: diff_def [symmetric])
huffman@20755
   328
done
huffman@20755
   329
huffman@20755
   330
lemma NSLIM_mult_zero:
huffman@20755
   331
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
huffman@20755
   332
  shows "[| f -- x --NS> 0; g -- x --NS> 0 |] ==> (%x. f(x)*g(x)) -- x --NS> 0"
huffman@20755
   333
by (drule NSLIM_mult, auto)
huffman@20755
   334
huffman@20755
   335
lemma NSLIM_self: "(%x. x) -- a --NS> a"
huffman@20755
   336
by (simp add: NSLIM_def)
huffman@20755
   337
huffman@20755
   338
subsubsection {* Equivalence of @{term LIM} and @{term NSLIM} *}
huffman@20755
   339
huffman@20754
   340
lemma LIM_NSLIM:
huffman@20754
   341
  assumes f: "f -- a --> L" shows "f -- a --NS> L"
huffman@20754
   342
proof (rule NSLIM_I)
huffman@20754
   343
  fix x
huffman@20754
   344
  assume neq: "x \<noteq> star_of a"
huffman@20754
   345
  assume approx: "x \<approx> star_of a"
huffman@20754
   346
  have "starfun f x - star_of L \<in> Infinitesimal"
huffman@20754
   347
  proof (rule InfinitesimalI2)
huffman@20754
   348
    fix r::real assume r: "0 < r"
huffman@20754
   349
    from LIM_D [OF f r]
huffman@20754
   350
    obtain s where s: "0 < s" and
huffman@20754
   351
      less_r: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (f x - L) < r"
huffman@20754
   352
      by fast
huffman@20754
   353
    from less_r have less_r':
huffman@20754
   354
       "\<And>x. \<lbrakk>x \<noteq> star_of a; hnorm (x - star_of a) < star_of s\<rbrakk>
huffman@20754
   355
        \<Longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
huffman@20754
   356
      by transfer
huffman@20754
   357
    from approx have "x - star_of a \<in> Infinitesimal"
huffman@20754
   358
      by (unfold approx_def)
huffman@20754
   359
    hence "hnorm (x - star_of a) < star_of s"
huffman@20754
   360
      using s by (rule InfinitesimalD2)
huffman@20754
   361
    with neq show "hnorm (starfun f x - star_of L) < star_of r"
huffman@20754
   362
      by (rule less_r')
huffman@20754
   363
  qed
huffman@20754
   364
  thus "starfun f x \<approx> star_of L"
huffman@20754
   365
    by (unfold approx_def)
huffman@20754
   366
qed
huffman@20552
   367
huffman@20754
   368
lemma NSLIM_LIM:
huffman@20754
   369
  assumes f: "f -- a --NS> L" shows "f -- a --> L"
huffman@20754
   370
proof (rule LIM_I)
huffman@20754
   371
  fix r::real assume r: "0 < r"
huffman@20754
   372
  have "\<exists>s>0. \<forall>x. x \<noteq> star_of a \<and> hnorm (x - star_of a) < s
huffman@20754
   373
        \<longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
huffman@20754
   374
  proof (rule exI, safe)
huffman@20754
   375
    show "0 < epsilon" by (rule hypreal_epsilon_gt_zero)
huffman@20754
   376
  next
huffman@20754
   377
    fix x assume neq: "x \<noteq> star_of a"
huffman@20754
   378
    assume "hnorm (x - star_of a) < epsilon"
huffman@20754
   379
    with Infinitesimal_epsilon
huffman@20754
   380
    have "x - star_of a \<in> Infinitesimal"
huffman@20754
   381
      by (rule hnorm_less_Infinitesimal)
huffman@20754
   382
    hence "x \<approx> star_of a"
huffman@20754
   383
      by (unfold approx_def)
huffman@20754
   384
    with f neq have "starfun f x \<approx> star_of L"
huffman@20754
   385
      by (rule NSLIM_D)
huffman@20754
   386
    hence "starfun f x - star_of L \<in> Infinitesimal"
huffman@20754
   387
      by (unfold approx_def)
huffman@20754
   388
    thus "hnorm (starfun f x - star_of L) < star_of r"
huffman@20754
   389
      using r by (rule InfinitesimalD2)
huffman@20754
   390
  qed
huffman@20754
   391
  thus "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r"
huffman@20754
   392
    by transfer
huffman@20754
   393
qed
paulson@14477
   394
paulson@15228
   395
theorem LIM_NSLIM_iff: "(f -- x --> L) = (f -- x --NS> L)"
paulson@14477
   396
by (blast intro: LIM_NSLIM NSLIM_LIM)
paulson@14477
   397
huffman@20755
   398
subsubsection {* Derived theorems about @{term LIM} *}
paulson@14477
   399
paulson@15228
   400
lemma LIM_mult2:
huffman@20552
   401
  fixes l m :: "'a::real_normed_algebra"
huffman@20552
   402
  shows "[| f -- x --> l; g -- x --> m |]
huffman@20552
   403
      ==> (%x. f(x) * g(x)) -- x --> (l * m)"
paulson@14477
   404
by (simp add: LIM_NSLIM_iff NSLIM_mult)
paulson@14477
   405
huffman@20794
   406
lemma LIM_scaleR:
huffman@20794
   407
  "[| f -- x --> l; g -- x --> m |]
huffman@20794
   408
      ==> (%x. f(x) *# g(x)) -- x --> (l *# m)"
huffman@20794
   409
by (simp add: LIM_NSLIM_iff NSLIM_scaleR)
huffman@20794
   410
paulson@15228
   411
lemma LIM_add2:
paulson@15228
   412
     "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + g(x)) -- x --> (l + m)"
paulson@14477
   413
by (simp add: LIM_NSLIM_iff NSLIM_add)
paulson@14477
   414
paulson@14477
   415
lemma LIM_const2: "(%x. k) -- x --> k"
paulson@14477
   416
by (simp add: LIM_NSLIM_iff)
paulson@14477
   417
paulson@14477
   418
lemma LIM_minus2: "f -- a --> L ==> (%x. -f(x)) -- a --> -L"
paulson@14477
   419
by (simp add: LIM_NSLIM_iff NSLIM_minus)
paulson@14477
   420
paulson@14477
   421
lemma LIM_add_minus2: "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
paulson@14477
   422
by (simp add: LIM_NSLIM_iff NSLIM_add_minus)
paulson@14477
   423
huffman@20552
   424
lemma LIM_inverse:
huffman@20653
   425
  fixes L :: "'a::real_normed_div_algebra"
huffman@20552
   426
  shows "[| f -- a --> L; L \<noteq> 0 |]
huffman@20552
   427
      ==> (%x. inverse(f(x))) -- a --> (inverse L)"
paulson@14477
   428
by (simp add: LIM_NSLIM_iff NSLIM_inverse)
paulson@14477
   429
paulson@14477
   430
lemma LIM_zero2: "f -- a --> l ==> (%x. f(x) + -l) -- a --> 0"
paulson@14477
   431
by (simp add: LIM_NSLIM_iff NSLIM_zero)
paulson@14477
   432
huffman@20561
   433
lemma LIM_unique2:
huffman@20561
   434
  fixes a :: real
huffman@20561
   435
  shows "[| f -- a --> L; f -- a --> M |] ==> L = M"
paulson@14477
   436
by (simp add: LIM_NSLIM_iff NSLIM_unique)
paulson@14477
   437
paulson@14477
   438
(* we can use the corresponding thm LIM_mult2 *)
paulson@14477
   439
(* for standard definition of limit           *)
paulson@14477
   440
huffman@20552
   441
lemma LIM_mult_zero2:
huffman@20561
   442
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
huffman@20552
   443
  shows "[| f -- x --> 0; g -- x --> 0 |] ==> (%x. f(x)*g(x)) -- x --> 0"
paulson@14477
   444
by (drule LIM_mult2, auto)
paulson@14477
   445
paulson@14477
   446
huffman@20755
   447
subsection {* Continuity *}
paulson@14477
   448
huffman@21239
   449
subsubsection {* Purely standard proofs *}
huffman@21239
   450
huffman@21239
   451
lemma LIM_isCont_iff: "(f -- a --> f a) = ((\<lambda>h. f (a + h)) -- 0 --> f a)"
huffman@21239
   452
by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
huffman@21239
   453
huffman@21239
   454
lemma isCont_iff: "isCont f x = (\<lambda>h. f (x + h)) -- 0 --> f x"
huffman@21239
   455
by (simp add: isCont_def LIM_isCont_iff)
huffman@21239
   456
huffman@21239
   457
lemma isCont_Id: "isCont (\<lambda>x. x) a"
huffman@21239
   458
unfolding isCont_def by (rule LIM_self)
huffman@21239
   459
huffman@21239
   460
lemma isCont_const [simp]: "isCont (%x. k) a"
huffman@21239
   461
unfolding isCont_def by (rule LIM_const)
huffman@21239
   462
huffman@21239
   463
lemma isCont_add: "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
huffman@21239
   464
unfolding isCont_def by (rule LIM_add)
huffman@21239
   465
huffman@21239
   466
lemma isCont_minus: "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
huffman@21239
   467
unfolding isCont_def by (rule LIM_minus)
huffman@21239
   468
huffman@21239
   469
lemma isCont_diff: "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
huffman@21239
   470
unfolding isCont_def by (rule LIM_diff)
huffman@21239
   471
huffman@21239
   472
lemma isCont_mult:
huffman@21239
   473
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
huffman@21239
   474
  shows "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) * g(x)) a"
huffman@21239
   475
unfolding isCont_def by (rule LIM_mult2)
huffman@21239
   476
huffman@21239
   477
lemma isCont_inverse:
huffman@21239
   478
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
huffman@21239
   479
  shows "[| isCont f x; f x \<noteq> 0 |] ==> isCont (%x. inverse (f x)) x"
huffman@21239
   480
unfolding isCont_def by (rule LIM_inverse)
huffman@21239
   481
huffman@21239
   482
lemma isCont_LIM_compose:
huffman@21239
   483
  "\<lbrakk>isCont g l; f -- a --> l\<rbrakk> \<Longrightarrow> (\<lambda>x. g (f x)) -- a --> g l"
huffman@21239
   484
unfolding isCont_def by (rule LIM_compose)
huffman@21239
   485
huffman@21239
   486
lemma isCont_o2: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. g (f x)) a"
huffman@21239
   487
unfolding isCont_def by (rule LIM_compose)
huffman@21239
   488
huffman@21239
   489
lemma isCont_o: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (g o f) a"
huffman@21239
   490
unfolding o_def by (rule isCont_o2)
huffman@21239
   491
huffman@21239
   492
subsubsection {* Nonstandard proofs *}
huffman@21239
   493
paulson@14477
   494
lemma isNSContD: "[| isNSCont f a; y \<approx> hypreal_of_real a |] ==> ( *f* f) y \<approx> hypreal_of_real (f a)"
paulson@14477
   495
by (simp add: isNSCont_def)
paulson@14477
   496
paulson@14477
   497
lemma isNSCont_NSLIM: "isNSCont f a ==> f -- a --NS> (f a) "
paulson@14477
   498
by (simp add: isNSCont_def NSLIM_def)
paulson@14477
   499
paulson@14477
   500
lemma NSLIM_isNSCont: "f -- a --NS> (f a) ==> isNSCont f a"
paulson@14477
   501
apply (simp add: isNSCont_def NSLIM_def, auto)
huffman@20561
   502
apply (case_tac "y = star_of a", auto)
paulson@14477
   503
done
paulson@14477
   504
paulson@15228
   505
text{*NS continuity can be defined using NS Limit in
paulson@15228
   506
    similar fashion to standard def of continuity*}
paulson@14477
   507
lemma isNSCont_NSLIM_iff: "(isNSCont f a) = (f -- a --NS> (f a))"
paulson@14477
   508
by (blast intro: isNSCont_NSLIM NSLIM_isNSCont)
paulson@14477
   509
paulson@15228
   510
text{*Hence, NS continuity can be given
paulson@15228
   511
  in terms of standard limit*}
paulson@14477
   512
lemma isNSCont_LIM_iff: "(isNSCont f a) = (f -- a --> (f a))"
paulson@14477
   513
by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff)
paulson@14477
   514
paulson@15228
   515
text{*Moreover, it's trivial now that NS continuity
paulson@15228
   516
  is equivalent to standard continuity*}
paulson@14477
   517
lemma isNSCont_isCont_iff: "(isNSCont f a) = (isCont f a)"
paulson@14477
   518
apply (simp add: isCont_def)
paulson@14477
   519
apply (rule isNSCont_LIM_iff)
paulson@14477
   520
done
paulson@14477
   521
paulson@15228
   522
text{*Standard continuity ==> NS continuity*}
paulson@14477
   523
lemma isCont_isNSCont: "isCont f a ==> isNSCont f a"
paulson@14477
   524
by (erule isNSCont_isCont_iff [THEN iffD2])
paulson@14477
   525
paulson@15228
   526
text{*NS continuity ==> Standard continuity*}
paulson@14477
   527
lemma isNSCont_isCont: "isNSCont f a ==> isCont f a"
paulson@14477
   528
by (erule isNSCont_isCont_iff [THEN iffD1])
paulson@14477
   529
paulson@14477
   530
text{*Alternative definition of continuity*}
paulson@14477
   531
(* Prove equivalence between NS limits - *)
paulson@14477
   532
(* seems easier than using standard def  *)
paulson@14477
   533
lemma NSLIM_h_iff: "(f -- a --NS> L) = ((%h. f(a + h)) -- 0 --NS> L)"
paulson@14477
   534
apply (simp add: NSLIM_def, auto)
huffman@20561
   535
apply (drule_tac x = "star_of a + x" in spec)
huffman@20561
   536
apply (drule_tac [2] x = "- star_of a + x" in spec, safe, simp)
huffman@20561
   537
apply (erule mem_infmal_iff [THEN iffD2, THEN Infinitesimal_add_approx_self [THEN approx_sym]])
huffman@20561
   538
apply (erule_tac [3] approx_minus_iff2 [THEN iffD1])
huffman@20561
   539
 prefer 2 apply (simp add: add_commute diff_def [symmetric])
huffman@20561
   540
apply (rule_tac x = x in star_cases)
huffman@17318
   541
apply (rule_tac [2] x = x in star_cases)
huffman@17318
   542
apply (auto simp add: starfun star_of_def star_n_minus star_n_add add_assoc approx_refl star_n_zero_num)
paulson@14477
   543
done
paulson@14477
   544
paulson@14477
   545
lemma NSLIM_isCont_iff: "(f -- a --NS> f a) = ((%h. f(a + h)) -- 0 --NS> f a)"
paulson@14477
   546
by (rule NSLIM_h_iff)
paulson@14477
   547
paulson@14477
   548
lemma isNSCont_minus: "isNSCont f a ==> isNSCont (%x. - f x) a"
paulson@14477
   549
by (simp add: isNSCont_def)
paulson@14477
   550
huffman@20552
   551
lemma isNSCont_inverse:
huffman@20653
   552
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
huffman@20552
   553
  shows "[| isNSCont f x; f x \<noteq> 0 |] ==> isNSCont (%x. inverse (f x)) x"
paulson@14477
   554
by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff)
paulson@14477
   555
paulson@15228
   556
lemma isNSCont_const [simp]: "isNSCont (%x. k) a"
paulson@14477
   557
by (simp add: isNSCont_def)
paulson@14477
   558
huffman@20561
   559
lemma isNSCont_abs [simp]: "isNSCont abs (a::real)"
paulson@14477
   560
apply (simp add: isNSCont_def)
paulson@14477
   561
apply (auto intro: approx_hrabs simp add: hypreal_of_real_hrabs [symmetric] starfun_rabs_hrabs)
paulson@14477
   562
done
paulson@14477
   563
huffman@20561
   564
lemma isCont_abs [simp]: "isCont abs (a::real)"
paulson@14477
   565
by (auto simp add: isNSCont_isCont_iff [symmetric])
paulson@15228
   566
paulson@14477
   567
paulson@14477
   568
(****************************************************************
paulson@14477
   569
(%* Leave as commented until I add topology theory or remove? *%)
paulson@14477
   570
(%*------------------------------------------------------------
paulson@14477
   571
  Elementary topology proof for a characterisation of
paulson@14477
   572
  continuity now: a function f is continuous if and only
paulson@14477
   573
  if the inverse image, {x. f(x) \<in> A}, of any open set A
paulson@14477
   574
  is always an open set
paulson@14477
   575
 ------------------------------------------------------------*%)
paulson@14477
   576
Goal "[| isNSopen A; \<forall>x. isNSCont f x |]
paulson@14477
   577
               ==> isNSopen {x. f x \<in> A}"
paulson@14477
   578
by (auto_tac (claset(),simpset() addsimps [isNSopen_iff1]));
paulson@14477
   579
by (dtac (mem_monad_approx RS approx_sym);
paulson@14477
   580
by (dres_inst_tac [("x","a")] spec 1);
paulson@14477
   581
by (dtac isNSContD 1 THEN assume_tac 1)
paulson@14477
   582
by (dtac bspec 1 THEN assume_tac 1)
paulson@14477
   583
by (dres_inst_tac [("x","( *f* f) x")] approx_mem_monad2 1);
paulson@14477
   584
by (blast_tac (claset() addIs [starfun_mem_starset]);
paulson@14477
   585
qed "isNSCont_isNSopen";
paulson@14477
   586
paulson@14477
   587
Goalw [isNSCont_def]
paulson@14477
   588
          "\<forall>A. isNSopen A --> isNSopen {x. f x \<in> A} \
paulson@14477
   589
\              ==> isNSCont f x";
paulson@14477
   590
by (auto_tac (claset() addSIs [(mem_infmal_iff RS iffD1) RS
paulson@14477
   591
     (approx_minus_iff RS iffD2)],simpset() addsimps
paulson@14477
   592
      [Infinitesimal_def,SReal_iff]));
paulson@14477
   593
by (dres_inst_tac [("x","{z. abs(z + -f(x)) < ya}")] spec 1);
paulson@14477
   594
by (etac (isNSopen_open_interval RSN (2,impE));
paulson@14477
   595
by (auto_tac (claset(),simpset() addsimps [isNSopen_def,isNSnbhd_def]));
paulson@14477
   596
by (dres_inst_tac [("x","x")] spec 1);
paulson@14477
   597
by (auto_tac (claset() addDs [approx_sym RS approx_mem_monad],
paulson@14477
   598
    simpset() addsimps [hypreal_of_real_zero RS sym,STAR_starfun_rabs_add_minus]));
paulson@14477
   599
qed "isNSopen_isNSCont";
paulson@14477
   600
paulson@14477
   601
Goal "(\<forall>x. isNSCont f x) = \
paulson@14477
   602
\     (\<forall>A. isNSopen A --> isNSopen {x. f(x) \<in> A})";
paulson@14477
   603
by (blast_tac (claset() addIs [isNSCont_isNSopen,
paulson@14477
   604
    isNSopen_isNSCont]);
paulson@14477
   605
qed "isNSCont_isNSopen_iff";
paulson@14477
   606
paulson@14477
   607
(%*------- Standard version of same theorem --------*%)
paulson@14477
   608
Goal "(\<forall>x. isCont f x) = \
paulson@14477
   609
\         (\<forall>A. isopen A --> isopen {x. f(x) \<in> A})";
paulson@14477
   610
by (auto_tac (claset() addSIs [isNSCont_isNSopen_iff],
paulson@14477
   611
              simpset() addsimps [isNSopen_isopen_iff RS sym,
paulson@14477
   612
              isNSCont_isCont_iff RS sym]));
paulson@14477
   613
qed "isCont_isopen_iff";
paulson@14477
   614
*******************************************************************)
paulson@14477
   615
huffman@20755
   616
subsection {* Uniform Continuity *}
huffman@20755
   617
paulson@14477
   618
lemma isNSUContD: "[| isNSUCont f; x \<approx> y|] ==> ( *f* f) x \<approx> ( *f* f) y"
paulson@14477
   619
by (simp add: isNSUCont_def)
paulson@14477
   620
paulson@14477
   621
lemma isUCont_isCont: "isUCont f ==> isCont f x"
paulson@14477
   622
by (simp add: isUCont_def isCont_def LIM_def, meson)
paulson@14477
   623
huffman@20754
   624
lemma isUCont_isNSUCont:
huffman@20754
   625
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
huffman@20754
   626
  assumes f: "isUCont f" shows "isNSUCont f"
huffman@20754
   627
proof (unfold isNSUCont_def, safe)
huffman@20754
   628
  fix x y :: "'a star"
huffman@20754
   629
  assume approx: "x \<approx> y"
huffman@20754
   630
  have "starfun f x - starfun f y \<in> Infinitesimal"
huffman@20754
   631
  proof (rule InfinitesimalI2)
huffman@20754
   632
    fix r::real assume r: "0 < r"
huffman@20754
   633
    with f obtain s where s: "0 < s" and
huffman@20754
   634
      less_r: "\<And>x y. norm (x - y) < s \<Longrightarrow> norm (f x - f y) < r"
huffman@20754
   635
      by (auto simp add: isUCont_def)
huffman@20754
   636
    from less_r have less_r':
huffman@20754
   637
       "\<And>x y. hnorm (x - y) < star_of s
huffman@20754
   638
        \<Longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
huffman@20754
   639
      by transfer
huffman@20754
   640
    from approx have "x - y \<in> Infinitesimal"
huffman@20754
   641
      by (unfold approx_def)
huffman@20754
   642
    hence "hnorm (x - y) < star_of s"
huffman@20754
   643
      using s by (rule InfinitesimalD2)
huffman@20754
   644
    thus "hnorm (starfun f x - starfun f y) < star_of r"
huffman@20754
   645
      by (rule less_r')
huffman@20754
   646
  qed
huffman@20754
   647
  thus "starfun f x \<approx> starfun f y"
huffman@20754
   648
    by (unfold approx_def)
huffman@20754
   649
qed
paulson@14477
   650
paulson@14477
   651
lemma isNSUCont_isUCont:
huffman@20754
   652
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
huffman@20754
   653
  assumes f: "isNSUCont f" shows "isUCont f"
huffman@20754
   654
proof (unfold isUCont_def, safe)
huffman@20754
   655
  fix r::real assume r: "0 < r"
huffman@20754
   656
  have "\<exists>s>0. \<forall>x y. hnorm (x - y) < s
huffman@20754
   657
        \<longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
huffman@20754
   658
  proof (rule exI, safe)
huffman@20754
   659
    show "0 < epsilon" by (rule hypreal_epsilon_gt_zero)
huffman@20754
   660
  next
huffman@20754
   661
    fix x y :: "'a star"
huffman@20754
   662
    assume "hnorm (x - y) < epsilon"
huffman@20754
   663
    with Infinitesimal_epsilon
huffman@20754
   664
    have "x - y \<in> Infinitesimal"
huffman@20754
   665
      by (rule hnorm_less_Infinitesimal)
huffman@20754
   666
    hence "x \<approx> y"
huffman@20754
   667
      by (unfold approx_def)
huffman@20754
   668
    with f have "starfun f x \<approx> starfun f y"
huffman@20754
   669
      by (simp add: isNSUCont_def)
huffman@20754
   670
    hence "starfun f x - starfun f y \<in> Infinitesimal"
huffman@20754
   671
      by (unfold approx_def)
huffman@20754
   672
    thus "hnorm (starfun f x - starfun f y) < star_of r"
huffman@20754
   673
      using r by (rule InfinitesimalD2)
huffman@20754
   674
  qed
huffman@20754
   675
  thus "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
huffman@20754
   676
    by transfer
huffman@20754
   677
qed
paulson@14477
   678
huffman@21165
   679
subsection {* Relation of LIM and LIMSEQ *}
kleing@19023
   680
kleing@19023
   681
lemma LIMSEQ_SEQ_conv1:
huffman@21165
   682
  fixes a :: "'a::real_normed_vector"
huffman@21165
   683
  assumes X: "X -- a --> L"
kleing@19023
   684
  shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
huffman@21165
   685
proof (safe intro!: LIMSEQ_I)
huffman@21165
   686
  fix S :: "nat \<Rightarrow> 'a"
huffman@21165
   687
  fix r :: real
huffman@21165
   688
  assume rgz: "0 < r"
huffman@21165
   689
  assume as: "\<forall>n. S n \<noteq> a"
huffman@21165
   690
  assume S: "S ----> a"
huffman@21165
   691
  from LIM_D [OF X rgz] obtain s
huffman@21165
   692
    where sgz: "0 < s"
huffman@21165
   693
    and aux: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (X x - L) < r"
huffman@21165
   694
    by fast
huffman@21165
   695
  from LIMSEQ_D [OF S sgz]
huffman@21165
   696
  obtain no where "\<forall>n\<ge>no. norm (S n - a) < s" by fast
huffman@21165
   697
  hence "\<forall>n\<ge>no. norm (X (S n) - L) < r" by (simp add: aux as)
huffman@21165
   698
  thus "\<exists>no. \<forall>n\<ge>no. norm (X (S n) - L) < r" ..
kleing@19023
   699
qed
kleing@19023
   700
kleing@19023
   701
lemma LIMSEQ_SEQ_conv2:
huffman@20561
   702
  fixes a :: real
kleing@19023
   703
  assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
kleing@19023
   704
  shows "X -- a --> L"
kleing@19023
   705
proof (rule ccontr)
kleing@19023
   706
  assume "\<not> (X -- a --> L)"
huffman@20563
   707
  hence "\<not> (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s --> norm (X x - L) < r)" by (unfold LIM_def)
huffman@20563
   708
  hence "\<exists>r > 0. \<forall>s > 0. \<exists>x. \<not>(x \<noteq> a \<and> \<bar>x - a\<bar> < s --> norm (X x - L) < r)" by simp
huffman@20563
   709
  hence "\<exists>r > 0. \<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x - a\<bar> < s \<and> norm (X x - L) \<ge> r)" by (simp add: linorder_not_less)
huffman@20563
   710
  then obtain r where rdef: "r > 0 \<and> (\<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x - a\<bar> < s \<and> norm (X x - L) \<ge> r))" by auto
kleing@19023
   711
huffman@20563
   712
  let ?F = "\<lambda>n::nat. SOME x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> norm (X x - L) \<ge> r"
huffman@21165
   713
  have "\<And>n. \<exists>x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> norm (X x - L) \<ge> r"
huffman@21165
   714
    using rdef by simp
huffman@21165
   715
  hence F: "\<And>n. ?F n \<noteq> a \<and> \<bar>?F n - a\<bar> < inverse (real (Suc n)) \<and> norm (X (?F n) - L) \<ge> r"
huffman@21165
   716
    by (rule someI_ex)
huffman@21165
   717
  hence F1: "\<And>n. ?F n \<noteq> a"
huffman@21165
   718
    and F2: "\<And>n. \<bar>?F n - a\<bar> < inverse (real (Suc n))"
huffman@21165
   719
    and F3: "\<And>n. norm (X (?F n) - L) \<ge> r"
huffman@21165
   720
    by fast+
huffman@21165
   721
kleing@19023
   722
  have "?F ----> a"
huffman@21165
   723
  proof (rule LIMSEQ_I, unfold real_norm_def)
kleing@19023
   724
      fix e::real
kleing@19023
   725
      assume "0 < e"
kleing@19023
   726
        (* choose no such that inverse (real (Suc n)) < e *)
kleing@19023
   727
      have "\<exists>no. inverse (real (Suc no)) < e" by (rule reals_Archimedean)
kleing@19023
   728
      then obtain m where nodef: "inverse (real (Suc m)) < e" by auto
huffman@21165
   729
      show "\<exists>no. \<forall>n. no \<le> n --> \<bar>?F n - a\<bar> < e"
huffman@21165
   730
      proof (intro exI allI impI)
kleing@19023
   731
        fix n
kleing@19023
   732
        assume mlen: "m \<le> n"
huffman@21165
   733
        have "\<bar>?F n - a\<bar> < inverse (real (Suc n))"
huffman@21165
   734
          by (rule F2)
huffman@21165
   735
        also have "inverse (real (Suc n)) \<le> inverse (real (Suc m))"
kleing@19023
   736
          by auto
huffman@21165
   737
        also from nodef have
kleing@19023
   738
          "inverse (real (Suc m)) < e" .
huffman@21165
   739
        finally show "\<bar>?F n - a\<bar> < e" .
huffman@21165
   740
      qed
kleing@19023
   741
  qed
kleing@19023
   742
  
kleing@19023
   743
  moreover have "\<forall>n. ?F n \<noteq> a"
huffman@21165
   744
    by (rule allI) (rule F1)
huffman@21165
   745
kleing@19023
   746
  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
   747
  ultimately have "(\<lambda>n. X (?F n)) ----> L" by simp
kleing@19023
   748
  
kleing@19023
   749
  moreover have "\<not> ((\<lambda>n. X (?F n)) ----> L)"
kleing@19023
   750
  proof -
kleing@19023
   751
    {
kleing@19023
   752
      fix no::nat
kleing@19023
   753
      obtain n where "n = no + 1" by simp
kleing@19023
   754
      then have nolen: "no \<le> n" by simp
kleing@19023
   755
        (* We prove this by showing that for any m there is an n\<ge>m such that |X (?F n) - L| \<ge> r *)
huffman@21165
   756
      have "norm (X (?F n) - L) \<ge> r"
huffman@21165
   757
        by (rule F3)
huffman@21165
   758
      with nolen have "\<exists>n. no \<le> n \<and> norm (X (?F n) - L) \<ge> r" by fast
kleing@19023
   759
    }
huffman@20563
   760
    then have "(\<forall>no. \<exists>n. no \<le> n \<and> norm (X (?F n) - L) \<ge> r)" by simp
huffman@20563
   761
    with rdef have "\<exists>e>0. (\<forall>no. \<exists>n. no \<le> n \<and> norm (X (?F n) - L) \<ge> e)" by auto
kleing@19023
   762
    thus ?thesis by (unfold LIMSEQ_def, auto simp add: linorder_not_less)
kleing@19023
   763
  qed
kleing@19023
   764
  ultimately show False by simp
kleing@19023
   765
qed
kleing@19023
   766
kleing@19023
   767
lemma LIMSEQ_SEQ_conv:
huffman@20561
   768
  "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::real) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
huffman@20561
   769
   (X -- a --> L)"
kleing@19023
   770
proof
kleing@19023
   771
  assume "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
kleing@19023
   772
  show "X -- a --> L" by (rule LIMSEQ_SEQ_conv2)
kleing@19023
   773
next
kleing@19023
   774
  assume "(X -- a --> L)"
kleing@19023
   775
  show "\<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
   776
qed
kleing@19023
   777
paulson@10751
   778
end