src/HOL/Hyperreal/Lim.thy
author huffman
Thu Nov 16 20:19:50 2006 +0100 (2006-11-16)
changeset 21399 700ae58d2273
parent 21282 dd647b4d7952
child 21404 eb85850d3eb7
permissions -rw-r--r--
add lemmas LIM_zero_iff, LIM_norm_zero_iff
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@21257
   110
lemma LIM_add_zero:
huffman@21257
   111
  "\<lbrakk>f -- a --> 0; g -- a --> 0\<rbrakk> \<Longrightarrow> (\<lambda>x. f x + g x) -- a --> 0"
huffman@21257
   112
by (drule (1) LIM_add, simp)
huffman@21257
   113
huffman@20552
   114
lemma minus_diff_minus:
huffman@20552
   115
  fixes a b :: "'a::ab_group_add"
huffman@20552
   116
  shows "(- a) - (- b) = - (a - b)"
huffman@20552
   117
by simp
huffman@20552
   118
paulson@14477
   119
lemma LIM_minus: "f -- a --> L ==> (%x. -f(x)) -- a --> -L"
huffman@20552
   120
by (simp only: LIM_eq minus_diff_minus norm_minus_cancel)
paulson@14477
   121
paulson@14477
   122
lemma LIM_add_minus:
paulson@14477
   123
    "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
huffman@20552
   124
by (intro LIM_add LIM_minus)
paulson@14477
   125
paulson@14477
   126
lemma LIM_diff:
paulson@14477
   127
    "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) - g(x)) -- x --> l-m"
huffman@20552
   128
by (simp only: diff_minus LIM_add LIM_minus)
paulson@14477
   129
huffman@21239
   130
lemma LIM_zero: "f -- a --> l \<Longrightarrow> (\<lambda>x. f x - l) -- a --> 0"
huffman@21239
   131
by (simp add: LIM_def)
huffman@21239
   132
huffman@21239
   133
lemma LIM_zero_cancel: "(\<lambda>x. f x - l) -- a --> 0 \<Longrightarrow> f -- a --> l"
huffman@21239
   134
by (simp add: LIM_def)
huffman@21239
   135
huffman@21399
   136
lemma LIM_zero_iff: "(\<lambda>x. f x - l) -- a --> 0 = f -- a --> l"
huffman@21399
   137
by (simp add: LIM_def)
huffman@21399
   138
huffman@21257
   139
lemma LIM_imp_LIM:
huffman@21257
   140
  assumes f: "f -- a --> l"
huffman@21257
   141
  assumes le: "\<And>x. x \<noteq> a \<Longrightarrow> norm (g x - m) \<le> norm (f x - l)"
huffman@21257
   142
  shows "g -- a --> m"
huffman@21257
   143
apply (rule LIM_I, drule LIM_D [OF f], safe)
huffman@21257
   144
apply (rule_tac x="s" in exI, safe)
huffman@21257
   145
apply (drule_tac x="x" in spec, safe)
huffman@21257
   146
apply (erule (1) order_le_less_trans [OF le])
huffman@21257
   147
done
huffman@21257
   148
huffman@21257
   149
lemma LIM_norm: "f -- a --> l \<Longrightarrow> (\<lambda>x. norm (f x)) -- a --> norm l"
huffman@21257
   150
by (erule LIM_imp_LIM, simp add: norm_triangle_ineq3)
huffman@21257
   151
huffman@21257
   152
lemma LIM_norm_zero: "f -- a --> 0 \<Longrightarrow> (\<lambda>x. norm (f x)) -- a --> 0"
huffman@21257
   153
by (drule LIM_norm, simp)
huffman@21257
   154
huffman@21257
   155
lemma LIM_norm_zero_cancel: "(\<lambda>x. norm (f x)) -- a --> 0 \<Longrightarrow> f -- a --> 0"
huffman@21257
   156
by (erule LIM_imp_LIM, simp)
huffman@21257
   157
huffman@21399
   158
lemma LIM_norm_zero_iff: "(\<lambda>x. norm (f x)) -- a --> 0 = f -- a --> 0"
huffman@21399
   159
by (rule iffI [OF LIM_norm_zero_cancel LIM_norm_zero])
huffman@21399
   160
huffman@20561
   161
lemma LIM_const_not_eq:
huffman@20561
   162
  fixes a :: "'a::real_normed_div_algebra"
huffman@20561
   163
  shows "k \<noteq> L ==> ~ ((%x. k) -- a --> L)"
huffman@20552
   164
apply (simp add: LIM_eq)
huffman@20552
   165
apply (rule_tac x="norm (k - L)" in exI, simp, safe)
huffman@20561
   166
apply (rule_tac x="a + of_real (s/2)" in exI, simp add: norm_of_real)
huffman@20552
   167
done
paulson@14477
   168
huffman@20561
   169
lemma LIM_const_eq:
huffman@20561
   170
  fixes a :: "'a::real_normed_div_algebra"
huffman@20561
   171
  shows "(%x. k) -- a --> L ==> k = L"
paulson@14477
   172
apply (rule ccontr)
kleing@19023
   173
apply (blast dest: LIM_const_not_eq)
paulson@14477
   174
done
paulson@14477
   175
huffman@20561
   176
lemma LIM_unique:
huffman@20561
   177
  fixes a :: "'a::real_normed_div_algebra"
huffman@20561
   178
  shows "[| f -- a --> L; f -- a --> M |] ==> L = M"
kleing@19023
   179
apply (drule LIM_diff, assumption)
paulson@14477
   180
apply (auto dest!: LIM_const_eq)
paulson@14477
   181
done
paulson@14477
   182
paulson@14477
   183
lemma LIM_mult_zero:
huffman@20561
   184
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
paulson@14477
   185
  assumes f: "f -- a --> 0" and g: "g -- a --> 0"
paulson@14477
   186
  shows "(%x. f(x) * g(x)) -- a --> 0"
huffman@20552
   187
proof (rule LIM_I, simp)
paulson@14477
   188
  fix r :: real
paulson@14477
   189
  assume r: "0<r"
paulson@14477
   190
  from LIM_D [OF f zero_less_one]
paulson@14477
   191
  obtain fs
paulson@14477
   192
    where fs:    "0 < fs"
huffman@20561
   193
      and fs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < fs --> norm (f x) < 1"
paulson@14477
   194
  by auto
paulson@14477
   195
  from LIM_D [OF g r]
paulson@14477
   196
  obtain gs
paulson@14477
   197
    where gs:    "0 < gs"
huffman@20561
   198
      and gs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < gs --> norm (g x) < r"
paulson@14477
   199
  by auto
huffman@20561
   200
  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
   201
  proof (intro exI conjI strip)
paulson@14477
   202
    show "0 < min fs gs"  by (simp add: fs gs)
huffman@20561
   203
    fix x :: 'a
huffman@20561
   204
    assume "x \<noteq> a \<and> norm (x-a) < min fs gs"
huffman@20561
   205
    hence  "x \<noteq> a \<and> norm (x-a) < fs \<and> norm (x-a) < gs" by simp
paulson@14477
   206
    with fs_lt gs_lt
huffman@20552
   207
    have "norm (f x) < 1" and "norm (g x) < r" by blast+
huffman@20552
   208
    hence "norm (f x) * norm (g x) < 1*r"
huffman@20552
   209
      by (rule mult_strict_mono' [OF _ _ norm_ge_zero norm_ge_zero])
huffman@20552
   210
    thus "norm (f x * g x) < r"
huffman@20552
   211
      by (simp add: order_le_less_trans [OF norm_mult_ineq])
paulson@14477
   212
  qed
paulson@14477
   213
qed
paulson@14477
   214
paulson@14477
   215
lemma LIM_self: "(%x. x) -- a --> a"
paulson@14477
   216
by (auto simp add: LIM_def)
paulson@14477
   217
paulson@14477
   218
text{*Limits are equal for functions equal except at limit point*}
paulson@14477
   219
lemma LIM_equal:
paulson@14477
   220
     "[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)"
paulson@14477
   221
by (simp add: LIM_def)
paulson@14477
   222
huffman@20796
   223
lemma LIM_cong:
huffman@20796
   224
  "\<lbrakk>a = b; \<And>x. x \<noteq> b \<Longrightarrow> f x = g x; l = m\<rbrakk>
huffman@21399
   225
   \<Longrightarrow> ((\<lambda>x. f x) -- a --> l) = ((\<lambda>x. g x) -- b --> m)"
huffman@20796
   226
by (simp add: LIM_def)
huffman@20796
   227
huffman@21282
   228
lemma LIM_equal2:
huffman@21282
   229
  assumes 1: "0 < R"
huffman@21282
   230
  assumes 2: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < R\<rbrakk> \<Longrightarrow> f x = g x"
huffman@21282
   231
  shows "g -- a --> l \<Longrightarrow> f -- a --> l"
huffman@21282
   232
apply (unfold LIM_def, safe)
huffman@21282
   233
apply (drule_tac x="r" in spec, safe)
huffman@21282
   234
apply (rule_tac x="min s R" in exI, safe)
huffman@21282
   235
apply (simp add: 1)
huffman@21282
   236
apply (simp add: 2)
huffman@21282
   237
done
huffman@21282
   238
paulson@14477
   239
text{*Two uses in Hyperreal/Transcendental.ML*}
paulson@14477
   240
lemma LIM_trans:
paulson@14477
   241
     "[| (%x. f(x) + -g(x)) -- a --> 0;  g -- a --> l |] ==> f -- a --> l"
paulson@14477
   242
apply (drule LIM_add, assumption)
paulson@14477
   243
apply (auto simp add: add_assoc)
paulson@14477
   244
done
paulson@14477
   245
huffman@21239
   246
lemma LIM_compose:
huffman@21239
   247
  assumes g: "g -- l --> g l"
huffman@21239
   248
  assumes f: "f -- a --> l"
huffman@21239
   249
  shows "(\<lambda>x. g (f x)) -- a --> g l"
huffman@21239
   250
proof (rule LIM_I)
huffman@21239
   251
  fix r::real assume r: "0 < r"
huffman@21239
   252
  obtain s where s: "0 < s"
huffman@21239
   253
    and less_r: "\<And>y. \<lbrakk>y \<noteq> l; norm (y - l) < s\<rbrakk> \<Longrightarrow> norm (g y - g l) < r"
huffman@21239
   254
    using LIM_D [OF g r] by fast
huffman@21239
   255
  obtain t where t: "0 < t"
huffman@21239
   256
    and less_s: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < t\<rbrakk> \<Longrightarrow> norm (f x - l) < s"
huffman@21239
   257
    using LIM_D [OF f s] by fast
huffman@21239
   258
huffman@21239
   259
  show "\<exists>t>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < t \<longrightarrow> norm (g (f x) - g l) < r"
huffman@21239
   260
  proof (rule exI, safe)
huffman@21239
   261
    show "0 < t" using t .
huffman@21239
   262
  next
huffman@21239
   263
    fix x assume "x \<noteq> a" and "norm (x - a) < t"
huffman@21239
   264
    hence "norm (f x - l) < s" by (rule less_s)
huffman@21239
   265
    thus "norm (g (f x) - g l) < r"
huffman@21239
   266
      using r less_r by (case_tac "f x = l", simp_all)
huffman@21239
   267
  qed
huffman@21239
   268
qed
huffman@21239
   269
huffman@21239
   270
lemma LIM_o: "\<lbrakk>g -- l --> g l; f -- a --> l\<rbrakk> \<Longrightarrow> (g \<circ> f) -- a --> g l"
huffman@21239
   271
unfolding o_def by (rule LIM_compose)
huffman@21239
   272
huffman@21282
   273
lemma real_LIM_sandwich_zero:
huffman@21282
   274
  fixes f g :: "'a::real_normed_vector \<Rightarrow> real"
huffman@21282
   275
  assumes f: "f -- a --> 0"
huffman@21282
   276
  assumes 1: "\<And>x. x \<noteq> a \<Longrightarrow> 0 \<le> g x"
huffman@21282
   277
  assumes 2: "\<And>x. x \<noteq> a \<Longrightarrow> g x \<le> f x"
huffman@21282
   278
  shows "g -- a --> 0"
huffman@21282
   279
proof (rule LIM_imp_LIM [OF f])
huffman@21282
   280
  fix x assume x: "x \<noteq> a"
huffman@21282
   281
  have "norm (g x - 0) = g x" by (simp add: 1 x)
huffman@21282
   282
  also have "g x \<le> f x" by (rule 2 [OF x])
huffman@21282
   283
  also have "f x \<le> \<bar>f x\<bar>" by (rule abs_ge_self)
huffman@21282
   284
  also have "\<bar>f x\<bar> = norm (f x - 0)" by simp
huffman@21282
   285
  finally show "norm (g x - 0) \<le> norm (f x - 0)" .
huffman@21282
   286
qed
huffman@21282
   287
huffman@21282
   288
subsubsection {* Bounded Linear Operators *}
huffman@21282
   289
huffman@21282
   290
locale bounded_linear = additive +
huffman@21282
   291
  constrains f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
huffman@21282
   292
  assumes scaleR: "f (scaleR r x) = scaleR r (f x)"
huffman@21282
   293
  assumes bounded: "\<exists>K. \<forall>x. norm (f x) \<le> norm x * K"
huffman@21282
   294
huffman@21282
   295
lemma (in bounded_linear) pos_bounded:
huffman@21282
   296
  "\<exists>K>0. \<forall>x. norm (f x) \<le> norm x * K"
huffman@21282
   297
apply (cut_tac bounded, erule exE)
huffman@21282
   298
apply (rule_tac x="max 1 K" in exI, safe)
huffman@21282
   299
apply (rule order_less_le_trans [OF zero_less_one le_maxI1])
huffman@21282
   300
apply (drule spec, erule order_trans)
huffman@21282
   301
apply (rule mult_left_mono [OF le_maxI2 norm_ge_zero])
huffman@21282
   302
done
huffman@21282
   303
huffman@21282
   304
lemma (in bounded_linear) pos_boundedE:
huffman@21282
   305
  obtains K where "0 < K" and "\<forall>x. norm (f x) \<le> norm x * K"
huffman@21282
   306
  using pos_bounded by fast
huffman@21282
   307
huffman@21282
   308
lemma (in bounded_linear) cont: "f -- a --> f a"
huffman@21282
   309
proof (rule LIM_I)
huffman@21282
   310
  fix r::real assume r: "0 < r"
huffman@21282
   311
  obtain K where K: "0 < K" and norm_le: "\<And>x. norm (f x) \<le> norm x * K"
huffman@21282
   312
    using pos_bounded by fast
huffman@21282
   313
  show "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - f a) < r"
huffman@21282
   314
  proof (rule exI, safe)
huffman@21282
   315
    from r K show "0 < r / K" by (rule divide_pos_pos)
huffman@21282
   316
  next
huffman@21282
   317
    fix x assume x: "norm (x - a) < r / K"
huffman@21282
   318
    have "norm (f x - f a) = norm (f (x - a))" by (simp only: diff)
huffman@21282
   319
    also have "\<dots> \<le> norm (x - a) * K" by (rule norm_le)
huffman@21282
   320
    also from K x have "\<dots> < r" by (simp only: pos_less_divide_eq)
huffman@21282
   321
    finally show "norm (f x - f a) < r" .
huffman@21282
   322
  qed
huffman@21282
   323
qed
huffman@21282
   324
huffman@21282
   325
lemma (in bounded_linear) LIM:
huffman@21282
   326
  "g -- a --> l \<Longrightarrow> (\<lambda>x. f (g x)) -- a --> f l"
huffman@21282
   327
by (rule LIM_compose [OF cont])
huffman@21282
   328
huffman@21282
   329
lemma (in bounded_linear) LIM_zero:
huffman@21282
   330
  "g -- a --> 0 \<Longrightarrow> (\<lambda>x. f (g x)) -- a --> 0"
huffman@21282
   331
by (drule LIM, simp only: zero)
huffman@21282
   332
huffman@21282
   333
subsubsection {* Bounded Bilinear Operators *}
huffman@21282
   334
huffman@21282
   335
locale bounded_bilinear =
huffman@21282
   336
  fixes prod :: "['a::real_normed_vector, 'b::real_normed_vector]
huffman@21282
   337
                 \<Rightarrow> 'c::real_normed_vector"
huffman@21282
   338
    (infixl "**" 70)
huffman@21282
   339
  assumes add_left: "prod (a + a') b = prod a b + prod a' b"
huffman@21282
   340
  assumes add_right: "prod a (b + b') = prod a b + prod a b'"
huffman@21282
   341
  assumes scaleR_left: "prod (scaleR r a) b = scaleR r (prod a b)"
huffman@21282
   342
  assumes scaleR_right: "prod a (scaleR r b) = scaleR r (prod a b)"
huffman@21282
   343
  assumes bounded: "\<exists>K. \<forall>a b. norm (prod a b) \<le> norm a * norm b * K"
huffman@21282
   344
huffman@21282
   345
lemma (in bounded_bilinear) pos_bounded:
huffman@21282
   346
  "\<exists>K>0. \<forall>a b. norm (a ** b) \<le> norm a * norm b * K"
huffman@21282
   347
apply (cut_tac bounded, erule exE)
huffman@21282
   348
apply (rule_tac x="max 1 K" in exI, safe)
huffman@21282
   349
apply (rule order_less_le_trans [OF zero_less_one le_maxI1])
huffman@21282
   350
apply (drule spec, drule spec, erule order_trans)
huffman@21282
   351
apply (rule mult_left_mono [OF le_maxI2])
huffman@21282
   352
apply (intro mult_nonneg_nonneg norm_ge_zero)
huffman@21282
   353
done
huffman@21282
   354
huffman@21282
   355
lemma (in bounded_bilinear) additive_right: "additive (\<lambda>b. prod a b)"
huffman@21282
   356
by (rule additive.intro, rule add_right)
huffman@21282
   357
huffman@21282
   358
lemma (in bounded_bilinear) additive_left: "additive (\<lambda>a. prod a b)"
huffman@21282
   359
by (rule additive.intro, rule add_left)
huffman@21282
   360
huffman@21282
   361
lemma (in bounded_bilinear) zero_left: "prod 0 b = 0"
huffman@21282
   362
by (rule additive.zero [OF additive_left])
huffman@21282
   363
huffman@21282
   364
lemma (in bounded_bilinear) zero_right: "prod a 0 = 0"
huffman@21282
   365
by (rule additive.zero [OF additive_right])
huffman@21282
   366
huffman@21282
   367
lemma (in bounded_bilinear) minus_left: "prod (- a) b = - prod a b"
huffman@21282
   368
by (rule additive.minus [OF additive_left])
huffman@21282
   369
huffman@21282
   370
lemma (in bounded_bilinear) minus_right: "prod a (- b) = - prod a b"
huffman@21282
   371
by (rule additive.minus [OF additive_right])
huffman@21282
   372
huffman@21282
   373
lemma (in bounded_bilinear) diff_left:
huffman@21282
   374
  "prod (a - a') b = prod a b - prod a' b"
huffman@21282
   375
by (rule additive.diff [OF additive_left])
huffman@21282
   376
huffman@21282
   377
lemma (in bounded_bilinear) diff_right:
huffman@21282
   378
  "prod a (b - b') = prod a b - prod a b'"
huffman@21282
   379
by (rule additive.diff [OF additive_right])
huffman@21282
   380
huffman@21282
   381
lemma (in bounded_bilinear) LIM_prod_zero:
huffman@21282
   382
  assumes f: "f -- a --> 0"
huffman@21282
   383
  assumes g: "g -- a --> 0"
huffman@21282
   384
  shows "(\<lambda>x. f x ** g x) -- a --> 0"
huffman@21282
   385
proof (rule LIM_I)
huffman@21282
   386
  fix r::real assume r: "0 < r"
huffman@21282
   387
  obtain K where K: "0 < K"
huffman@21282
   388
    and norm_le: "\<And>x y. norm (x ** y) \<le> norm x * norm y * K"
huffman@21282
   389
    using pos_bounded by fast
huffman@21282
   390
  from K have K': "0 < inverse K"
huffman@21282
   391
    by (rule positive_imp_inverse_positive)
huffman@21282
   392
  obtain s where s: "0 < s"
huffman@21282
   393
    and norm_f: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (f x) < r"
huffman@21282
   394
    using LIM_D [OF f r] by auto
huffman@21282
   395
  obtain t where t: "0 < t"
huffman@21282
   396
    and norm_g: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < t\<rbrakk> \<Longrightarrow> norm (g x) < inverse K"
huffman@21282
   397
    using LIM_D [OF g K'] by auto
huffman@21282
   398
  show "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x ** g x - 0) < r"
huffman@21282
   399
  proof (rule exI, safe)
huffman@21282
   400
    from s t show "0 < min s t" by simp
huffman@21282
   401
  next
huffman@21282
   402
    fix x assume x: "x \<noteq> a"
huffman@21282
   403
    assume "norm (x - a) < min s t"
huffman@21282
   404
    hence xs: "norm (x - a) < s" and xt: "norm (x - a) < t" by simp_all
huffman@21282
   405
    from x xs have 1: "norm (f x) < r" by (rule norm_f)
huffman@21282
   406
    from x xt have 2: "norm (g x) < inverse K" by (rule norm_g)
huffman@21282
   407
    have "norm (f x ** g x) \<le> norm (f x) * norm (g x) * K" by (rule norm_le)
huffman@21282
   408
    also from 1 2 K have "\<dots> < r * inverse K * K"
huffman@21282
   409
      by (intro mult_strict_right_mono mult_strict_mono' norm_ge_zero)
huffman@21282
   410
    also from K have "r * inverse K * K = r" by simp
huffman@21282
   411
    finally show "norm (f x ** g x - 0) < r" by simp
huffman@21282
   412
  qed
huffman@21282
   413
qed
huffman@21282
   414
huffman@21282
   415
lemma (in bounded_bilinear) bounded_linear_left:
huffman@21282
   416
  "bounded_linear (\<lambda>a. a ** b)"
huffman@21282
   417
apply (unfold_locales)
huffman@21282
   418
apply (rule add_left)
huffman@21282
   419
apply (rule scaleR_left)
huffman@21282
   420
apply (cut_tac bounded, safe)
huffman@21282
   421
apply (rule_tac x="norm b * K" in exI)
huffman@21282
   422
apply (simp add: mult_ac)
huffman@21282
   423
done
huffman@21282
   424
huffman@21282
   425
lemma (in bounded_bilinear) bounded_linear_right:
huffman@21282
   426
  "bounded_linear (\<lambda>b. a ** b)"
huffman@21282
   427
apply (unfold_locales)
huffman@21282
   428
apply (rule add_right)
huffman@21282
   429
apply (rule scaleR_right)
huffman@21282
   430
apply (cut_tac bounded, safe)
huffman@21282
   431
apply (rule_tac x="norm a * K" in exI)
huffman@21282
   432
apply (simp add: mult_ac)
huffman@21282
   433
done
huffman@21282
   434
huffman@21282
   435
lemma (in bounded_bilinear) LIM_left_zero:
huffman@21282
   436
  "f -- a --> 0 \<Longrightarrow> (\<lambda>x. f x ** c) -- a --> 0"
huffman@21282
   437
by (rule bounded_linear.LIM_zero [OF bounded_linear_left])
huffman@21282
   438
huffman@21282
   439
lemma (in bounded_bilinear) LIM_right_zero:
huffman@21282
   440
  "f -- a --> 0 \<Longrightarrow> (\<lambda>x. c ** f x) -- a --> 0"
huffman@21282
   441
by (rule bounded_linear.LIM_zero [OF bounded_linear_right])
huffman@21282
   442
huffman@21282
   443
lemma (in bounded_bilinear) prod_diff_prod:
huffman@21282
   444
  "(x ** y - a ** b) = (x - a) ** (y - b) + (x - a) ** b + a ** (y - b)"
huffman@21282
   445
by (simp add: diff_left diff_right)
huffman@21282
   446
huffman@21282
   447
lemma (in bounded_bilinear) LIM:
huffman@21282
   448
  "\<lbrakk>f -- a --> L; g -- a --> M\<rbrakk> \<Longrightarrow> (\<lambda>x. f x ** g x) -- a --> L ** M"
huffman@21282
   449
apply (drule LIM_zero)
huffman@21282
   450
apply (drule LIM_zero)
huffman@21282
   451
apply (rule LIM_zero_cancel)
huffman@21282
   452
apply (subst prod_diff_prod)
huffman@21282
   453
apply (rule LIM_add_zero)
huffman@21282
   454
apply (rule LIM_add_zero)
huffman@21282
   455
apply (erule (1) LIM_prod_zero)
huffman@21282
   456
apply (erule LIM_left_zero)
huffman@21282
   457
apply (erule LIM_right_zero)
huffman@21282
   458
done
huffman@21282
   459
huffman@21282
   460
interpretation bounded_bilinear_mult:
huffman@21282
   461
  bounded_bilinear ["op * :: 'a \<Rightarrow> 'a \<Rightarrow> 'a::real_normed_algebra"]
huffman@21282
   462
apply (rule bounded_bilinear.intro)
huffman@21282
   463
apply (rule left_distrib)
huffman@21282
   464
apply (rule right_distrib)
huffman@21282
   465
apply (rule mult_scaleR_left)
huffman@21282
   466
apply (rule mult_scaleR_right)
huffman@21282
   467
apply (rule_tac x="1" in exI)
huffman@21282
   468
apply (simp add: norm_mult_ineq)
huffman@21282
   469
done
huffman@21282
   470
huffman@21282
   471
interpretation bounded_bilinear_scaleR:
huffman@21282
   472
  bounded_bilinear ["scaleR"]
huffman@21282
   473
apply (rule bounded_bilinear.intro)
huffman@21282
   474
apply (rule scaleR_left_distrib)
huffman@21282
   475
apply (rule scaleR_right_distrib)
huffman@21282
   476
apply (simp add: real_scaleR_def)
huffman@21282
   477
apply (rule scaleR_left_commute)
huffman@21282
   478
apply (rule_tac x="1" in exI)
huffman@21282
   479
apply (simp add: norm_scaleR)
huffman@21282
   480
done
huffman@21282
   481
huffman@21282
   482
lemmas LIM_mult = bounded_bilinear_mult.LIM
huffman@21282
   483
huffman@21282
   484
lemmas LIM_mult_zero = bounded_bilinear_mult.LIM_prod_zero
huffman@21282
   485
huffman@21282
   486
lemmas LIM_mult_left_zero = bounded_bilinear_mult.LIM_left_zero
huffman@21282
   487
huffman@21282
   488
lemmas LIM_mult_right_zero = bounded_bilinear_mult.LIM_right_zero
huffman@21282
   489
huffman@21282
   490
lemmas LIM_scaleR = bounded_bilinear_scaleR.LIM
huffman@21282
   491
huffman@20755
   492
subsubsection {* Purely nonstandard proofs *}
paulson@14477
   493
huffman@20754
   494
lemma NSLIM_I:
huffman@20754
   495
  "(\<And>x. \<lbrakk>x \<noteq> star_of a; x \<approx> star_of a\<rbrakk> \<Longrightarrow> starfun f x \<approx> star_of L)
huffman@20754
   496
   \<Longrightarrow> f -- a --NS> L"
huffman@20754
   497
by (simp add: NSLIM_def)
paulson@14477
   498
huffman@20754
   499
lemma NSLIM_D:
huffman@20754
   500
  "\<lbrakk>f -- a --NS> L; x \<noteq> star_of a; x \<approx> star_of a\<rbrakk>
huffman@20754
   501
   \<Longrightarrow> starfun f x \<approx> star_of L"
huffman@20754
   502
by (simp add: NSLIM_def)
paulson@14477
   503
huffman@20755
   504
text{*Proving properties of limits using nonstandard definition.
huffman@20755
   505
      The properties hold for standard limits as well!*}
huffman@20755
   506
huffman@20755
   507
lemma NSLIM_mult:
huffman@20755
   508
  fixes l m :: "'a::real_normed_algebra"
huffman@20755
   509
  shows "[| f -- x --NS> l; g -- x --NS> m |]
huffman@20755
   510
      ==> (%x. f(x) * g(x)) -- x --NS> (l * m)"
huffman@20755
   511
by (auto simp add: NSLIM_def intro!: approx_mult_HFinite)
huffman@20755
   512
huffman@20794
   513
lemma starfun_scaleR [simp]:
huffman@20794
   514
  "starfun (\<lambda>x. f x *# g x) = (\<lambda>x. scaleHR (starfun f x) (starfun g x))"
huffman@20794
   515
by transfer (rule refl)
huffman@20794
   516
huffman@20794
   517
lemma NSLIM_scaleR:
huffman@20794
   518
  "[| f -- x --NS> l; g -- x --NS> m |]
huffman@20794
   519
      ==> (%x. f(x) *# g(x)) -- x --NS> (l *# m)"
huffman@20794
   520
by (auto simp add: NSLIM_def intro!: approx_scaleR_HFinite)
huffman@20794
   521
huffman@20755
   522
lemma NSLIM_add:
huffman@20755
   523
     "[| f -- x --NS> l; g -- x --NS> m |]
huffman@20755
   524
      ==> (%x. f(x) + g(x)) -- x --NS> (l + m)"
huffman@20755
   525
by (auto simp add: NSLIM_def intro!: approx_add)
huffman@20755
   526
huffman@20755
   527
lemma NSLIM_const [simp]: "(%x. k) -- x --NS> k"
huffman@20755
   528
by (simp add: NSLIM_def)
huffman@20755
   529
huffman@20755
   530
lemma NSLIM_minus: "f -- a --NS> L ==> (%x. -f(x)) -- a --NS> -L"
huffman@20755
   531
by (simp add: NSLIM_def)
huffman@20755
   532
huffman@20755
   533
lemma NSLIM_add_minus: "[| f -- x --NS> l; g -- x --NS> m |] ==> (%x. f(x) + -g(x)) -- x --NS> (l + -m)"
huffman@20755
   534
by (simp only: NSLIM_add NSLIM_minus)
huffman@20755
   535
huffman@20755
   536
lemma NSLIM_inverse:
huffman@20755
   537
  fixes L :: "'a::real_normed_div_algebra"
huffman@20755
   538
  shows "[| f -- a --NS> L;  L \<noteq> 0 |]
huffman@20755
   539
      ==> (%x. inverse(f(x))) -- a --NS> (inverse L)"
huffman@20755
   540
apply (simp add: NSLIM_def, clarify)
huffman@20755
   541
apply (drule spec)
huffman@20755
   542
apply (auto simp add: star_of_approx_inverse)
huffman@20755
   543
done
huffman@20755
   544
huffman@20755
   545
lemma NSLIM_zero:
huffman@20755
   546
  assumes f: "f -- a --NS> l" shows "(%x. f(x) + -l) -- a --NS> 0"
huffman@20755
   547
proof -
huffman@20755
   548
  have "(\<lambda>x. f x + - l) -- a --NS> l + -l"
huffman@20755
   549
    by (rule NSLIM_add_minus [OF f NSLIM_const])
huffman@20755
   550
  thus ?thesis by simp
huffman@20755
   551
qed
huffman@20755
   552
huffman@20755
   553
lemma NSLIM_zero_cancel: "(%x. f(x) - l) -- x --NS> 0 ==> f -- x --NS> l"
huffman@20755
   554
apply (drule_tac g = "%x. l" and m = l in NSLIM_add)
huffman@20755
   555
apply (auto simp add: diff_minus add_assoc)
huffman@20755
   556
done
huffman@20755
   557
huffman@20755
   558
lemma NSLIM_const_not_eq:
huffman@20755
   559
  fixes a :: real (* TODO: generalize to real_normed_div_algebra *)
huffman@20755
   560
  shows "k \<noteq> L ==> ~ ((%x. k) -- a --NS> L)"
huffman@20755
   561
apply (simp add: NSLIM_def)
huffman@20755
   562
apply (rule_tac x="star_of a + epsilon" in exI)
huffman@20755
   563
apply (auto intro: Infinitesimal_add_approx_self [THEN approx_sym]
huffman@20755
   564
            simp add: hypreal_epsilon_not_zero)
huffman@20755
   565
done
huffman@20755
   566
huffman@20755
   567
lemma NSLIM_not_zero:
huffman@20755
   568
  fixes a :: real
huffman@20755
   569
  shows "k \<noteq> 0 ==> ~ ((%x. k) -- a --NS> 0)"
huffman@20755
   570
by (rule NSLIM_const_not_eq)
huffman@20755
   571
huffman@20755
   572
lemma NSLIM_const_eq:
huffman@20755
   573
  fixes a :: real
huffman@20755
   574
  shows "(%x. k) -- a --NS> L ==> k = L"
huffman@20755
   575
apply (rule ccontr)
huffman@20755
   576
apply (blast dest: NSLIM_const_not_eq)
huffman@20755
   577
done
huffman@20755
   578
huffman@20755
   579
text{* can actually be proved more easily by unfolding the definition!*}
huffman@20755
   580
lemma NSLIM_unique:
huffman@20755
   581
  fixes a :: real
huffman@20755
   582
  shows "[| f -- a --NS> L; f -- a --NS> M |] ==> L = M"
huffman@20755
   583
apply (drule NSLIM_minus)
huffman@20755
   584
apply (drule NSLIM_add, assumption)
huffman@20755
   585
apply (auto dest!: NSLIM_const_eq [symmetric])
huffman@20755
   586
apply (simp add: diff_def [symmetric])
huffman@20755
   587
done
huffman@20755
   588
huffman@20755
   589
lemma NSLIM_mult_zero:
huffman@20755
   590
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
huffman@20755
   591
  shows "[| f -- x --NS> 0; g -- x --NS> 0 |] ==> (%x. f(x)*g(x)) -- x --NS> 0"
huffman@20755
   592
by (drule NSLIM_mult, auto)
huffman@20755
   593
huffman@20755
   594
lemma NSLIM_self: "(%x. x) -- a --NS> a"
huffman@20755
   595
by (simp add: NSLIM_def)
huffman@20755
   596
huffman@20755
   597
subsubsection {* Equivalence of @{term LIM} and @{term NSLIM} *}
huffman@20755
   598
huffman@20754
   599
lemma LIM_NSLIM:
huffman@20754
   600
  assumes f: "f -- a --> L" shows "f -- a --NS> L"
huffman@20754
   601
proof (rule NSLIM_I)
huffman@20754
   602
  fix x
huffman@20754
   603
  assume neq: "x \<noteq> star_of a"
huffman@20754
   604
  assume approx: "x \<approx> star_of a"
huffman@20754
   605
  have "starfun f x - star_of L \<in> Infinitesimal"
huffman@20754
   606
  proof (rule InfinitesimalI2)
huffman@20754
   607
    fix r::real assume r: "0 < r"
huffman@20754
   608
    from LIM_D [OF f r]
huffman@20754
   609
    obtain s where s: "0 < s" and
huffman@20754
   610
      less_r: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (f x - L) < r"
huffman@20754
   611
      by fast
huffman@20754
   612
    from less_r have less_r':
huffman@20754
   613
       "\<And>x. \<lbrakk>x \<noteq> star_of a; hnorm (x - star_of a) < star_of s\<rbrakk>
huffman@20754
   614
        \<Longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
huffman@20754
   615
      by transfer
huffman@20754
   616
    from approx have "x - star_of a \<in> Infinitesimal"
huffman@20754
   617
      by (unfold approx_def)
huffman@20754
   618
    hence "hnorm (x - star_of a) < star_of s"
huffman@20754
   619
      using s by (rule InfinitesimalD2)
huffman@20754
   620
    with neq show "hnorm (starfun f x - star_of L) < star_of r"
huffman@20754
   621
      by (rule less_r')
huffman@20754
   622
  qed
huffman@20754
   623
  thus "starfun f x \<approx> star_of L"
huffman@20754
   624
    by (unfold approx_def)
huffman@20754
   625
qed
huffman@20552
   626
huffman@20754
   627
lemma NSLIM_LIM:
huffman@20754
   628
  assumes f: "f -- a --NS> L" shows "f -- a --> L"
huffman@20754
   629
proof (rule LIM_I)
huffman@20754
   630
  fix r::real assume r: "0 < r"
huffman@20754
   631
  have "\<exists>s>0. \<forall>x. x \<noteq> star_of a \<and> hnorm (x - star_of a) < s
huffman@20754
   632
        \<longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
huffman@20754
   633
  proof (rule exI, safe)
huffman@20754
   634
    show "0 < epsilon" by (rule hypreal_epsilon_gt_zero)
huffman@20754
   635
  next
huffman@20754
   636
    fix x assume neq: "x \<noteq> star_of a"
huffman@20754
   637
    assume "hnorm (x - star_of a) < epsilon"
huffman@20754
   638
    with Infinitesimal_epsilon
huffman@20754
   639
    have "x - star_of a \<in> Infinitesimal"
huffman@20754
   640
      by (rule hnorm_less_Infinitesimal)
huffman@20754
   641
    hence "x \<approx> star_of a"
huffman@20754
   642
      by (unfold approx_def)
huffman@20754
   643
    with f neq have "starfun f x \<approx> star_of L"
huffman@20754
   644
      by (rule NSLIM_D)
huffman@20754
   645
    hence "starfun f x - star_of L \<in> Infinitesimal"
huffman@20754
   646
      by (unfold approx_def)
huffman@20754
   647
    thus "hnorm (starfun f x - star_of L) < star_of r"
huffman@20754
   648
      using r by (rule InfinitesimalD2)
huffman@20754
   649
  qed
huffman@20754
   650
  thus "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r"
huffman@20754
   651
    by transfer
huffman@20754
   652
qed
paulson@14477
   653
paulson@15228
   654
theorem LIM_NSLIM_iff: "(f -- x --> L) = (f -- x --NS> L)"
paulson@14477
   655
by (blast intro: LIM_NSLIM NSLIM_LIM)
paulson@14477
   656
huffman@20755
   657
subsubsection {* Derived theorems about @{term LIM} *}
paulson@14477
   658
paulson@15228
   659
lemma LIM_mult2:
huffman@20552
   660
  fixes l m :: "'a::real_normed_algebra"
huffman@20552
   661
  shows "[| f -- x --> l; g -- x --> m |]
huffman@20552
   662
      ==> (%x. f(x) * g(x)) -- x --> (l * m)"
paulson@14477
   663
by (simp add: LIM_NSLIM_iff NSLIM_mult)
paulson@14477
   664
huffman@20794
   665
lemma LIM_scaleR:
huffman@20794
   666
  "[| f -- x --> l; g -- x --> m |]
huffman@20794
   667
      ==> (%x. f(x) *# g(x)) -- x --> (l *# m)"
huffman@20794
   668
by (simp add: LIM_NSLIM_iff NSLIM_scaleR)
huffman@20794
   669
paulson@15228
   670
lemma LIM_add2:
paulson@15228
   671
     "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + g(x)) -- x --> (l + m)"
paulson@14477
   672
by (simp add: LIM_NSLIM_iff NSLIM_add)
paulson@14477
   673
paulson@14477
   674
lemma LIM_const2: "(%x. k) -- x --> k"
paulson@14477
   675
by (simp add: LIM_NSLIM_iff)
paulson@14477
   676
paulson@14477
   677
lemma LIM_minus2: "f -- a --> L ==> (%x. -f(x)) -- a --> -L"
paulson@14477
   678
by (simp add: LIM_NSLIM_iff NSLIM_minus)
paulson@14477
   679
paulson@14477
   680
lemma LIM_add_minus2: "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
paulson@14477
   681
by (simp add: LIM_NSLIM_iff NSLIM_add_minus)
paulson@14477
   682
huffman@20552
   683
lemma LIM_inverse:
huffman@20653
   684
  fixes L :: "'a::real_normed_div_algebra"
huffman@20552
   685
  shows "[| f -- a --> L; L \<noteq> 0 |]
huffman@20552
   686
      ==> (%x. inverse(f(x))) -- a --> (inverse L)"
paulson@14477
   687
by (simp add: LIM_NSLIM_iff NSLIM_inverse)
paulson@14477
   688
paulson@14477
   689
lemma LIM_zero2: "f -- a --> l ==> (%x. f(x) + -l) -- a --> 0"
paulson@14477
   690
by (simp add: LIM_NSLIM_iff NSLIM_zero)
paulson@14477
   691
huffman@20561
   692
lemma LIM_unique2:
huffman@20561
   693
  fixes a :: real
huffman@20561
   694
  shows "[| f -- a --> L; f -- a --> M |] ==> L = M"
paulson@14477
   695
by (simp add: LIM_NSLIM_iff NSLIM_unique)
paulson@14477
   696
paulson@14477
   697
(* we can use the corresponding thm LIM_mult2 *)
paulson@14477
   698
(* for standard definition of limit           *)
paulson@14477
   699
huffman@20552
   700
lemma LIM_mult_zero2:
huffman@20561
   701
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
huffman@20552
   702
  shows "[| f -- x --> 0; g -- x --> 0 |] ==> (%x. f(x)*g(x)) -- x --> 0"
paulson@14477
   703
by (drule LIM_mult2, auto)
paulson@14477
   704
paulson@14477
   705
huffman@20755
   706
subsection {* Continuity *}
paulson@14477
   707
huffman@21239
   708
subsubsection {* Purely standard proofs *}
huffman@21239
   709
huffman@21239
   710
lemma LIM_isCont_iff: "(f -- a --> f a) = ((\<lambda>h. f (a + h)) -- 0 --> f a)"
huffman@21239
   711
by (rule iffI [OF LIM_offset_zero LIM_offset_zero_cancel])
huffman@21239
   712
huffman@21239
   713
lemma isCont_iff: "isCont f x = (\<lambda>h. f (x + h)) -- 0 --> f x"
huffman@21239
   714
by (simp add: isCont_def LIM_isCont_iff)
huffman@21239
   715
huffman@21239
   716
lemma isCont_Id: "isCont (\<lambda>x. x) a"
huffman@21282
   717
  unfolding isCont_def by (rule LIM_self)
huffman@21239
   718
huffman@21239
   719
lemma isCont_const [simp]: "isCont (%x. k) a"
huffman@21282
   720
  unfolding isCont_def by (rule LIM_const)
huffman@21239
   721
huffman@21239
   722
lemma isCont_add: "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x + g x) a"
huffman@21282
   723
  unfolding isCont_def by (rule LIM_add)
huffman@21239
   724
huffman@21239
   725
lemma isCont_minus: "isCont f a \<Longrightarrow> isCont (\<lambda>x. - f x) a"
huffman@21282
   726
  unfolding isCont_def by (rule LIM_minus)
huffman@21239
   727
huffman@21239
   728
lemma isCont_diff: "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x - g x) a"
huffman@21282
   729
  unfolding isCont_def by (rule LIM_diff)
huffman@21239
   730
huffman@21239
   731
lemma isCont_mult:
huffman@21239
   732
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
huffman@21239
   733
  shows "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) * g(x)) a"
huffman@21282
   734
  unfolding isCont_def by (rule LIM_mult)
huffman@21239
   735
huffman@21239
   736
lemma isCont_inverse:
huffman@21239
   737
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
huffman@21239
   738
  shows "[| isCont f x; f x \<noteq> 0 |] ==> isCont (%x. inverse (f x)) x"
huffman@21282
   739
  unfolding isCont_def by (rule LIM_inverse)
huffman@21239
   740
huffman@21239
   741
lemma isCont_LIM_compose:
huffman@21239
   742
  "\<lbrakk>isCont g l; f -- a --> l\<rbrakk> \<Longrightarrow> (\<lambda>x. g (f x)) -- a --> g l"
huffman@21282
   743
  unfolding isCont_def by (rule LIM_compose)
huffman@21239
   744
huffman@21239
   745
lemma isCont_o2: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. g (f x)) a"
huffman@21282
   746
  unfolding isCont_def by (rule LIM_compose)
huffman@21239
   747
huffman@21239
   748
lemma isCont_o: "\<lbrakk>isCont f a; isCont g (f a)\<rbrakk> \<Longrightarrow> isCont (g o f) a"
huffman@21282
   749
  unfolding o_def by (rule isCont_o2)
huffman@21282
   750
huffman@21282
   751
lemma (in bounded_linear) isCont: "isCont f a"
huffman@21282
   752
  unfolding isCont_def by (rule cont)
huffman@21282
   753
huffman@21282
   754
lemma (in bounded_bilinear) isCont:
huffman@21282
   755
  "\<lbrakk>isCont f a; isCont g a\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. f x ** g x) a"
huffman@21282
   756
  unfolding isCont_def by (rule LIM)
huffman@21282
   757
huffman@21282
   758
lemmas isCont_scaleR = bounded_bilinear_scaleR.isCont
huffman@21239
   759
huffman@21239
   760
subsubsection {* Nonstandard proofs *}
huffman@21239
   761
paulson@14477
   762
lemma isNSContD: "[| isNSCont f a; y \<approx> hypreal_of_real a |] ==> ( *f* f) y \<approx> hypreal_of_real (f a)"
paulson@14477
   763
by (simp add: isNSCont_def)
paulson@14477
   764
paulson@14477
   765
lemma isNSCont_NSLIM: "isNSCont f a ==> f -- a --NS> (f a) "
paulson@14477
   766
by (simp add: isNSCont_def NSLIM_def)
paulson@14477
   767
paulson@14477
   768
lemma NSLIM_isNSCont: "f -- a --NS> (f a) ==> isNSCont f a"
paulson@14477
   769
apply (simp add: isNSCont_def NSLIM_def, auto)
huffman@20561
   770
apply (case_tac "y = star_of a", auto)
paulson@14477
   771
done
paulson@14477
   772
paulson@15228
   773
text{*NS continuity can be defined using NS Limit in
paulson@15228
   774
    similar fashion to standard def of continuity*}
paulson@14477
   775
lemma isNSCont_NSLIM_iff: "(isNSCont f a) = (f -- a --NS> (f a))"
paulson@14477
   776
by (blast intro: isNSCont_NSLIM NSLIM_isNSCont)
paulson@14477
   777
paulson@15228
   778
text{*Hence, NS continuity can be given
paulson@15228
   779
  in terms of standard limit*}
paulson@14477
   780
lemma isNSCont_LIM_iff: "(isNSCont f a) = (f -- a --> (f a))"
paulson@14477
   781
by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff)
paulson@14477
   782
paulson@15228
   783
text{*Moreover, it's trivial now that NS continuity
paulson@15228
   784
  is equivalent to standard continuity*}
paulson@14477
   785
lemma isNSCont_isCont_iff: "(isNSCont f a) = (isCont f a)"
paulson@14477
   786
apply (simp add: isCont_def)
paulson@14477
   787
apply (rule isNSCont_LIM_iff)
paulson@14477
   788
done
paulson@14477
   789
paulson@15228
   790
text{*Standard continuity ==> NS continuity*}
paulson@14477
   791
lemma isCont_isNSCont: "isCont f a ==> isNSCont f a"
paulson@14477
   792
by (erule isNSCont_isCont_iff [THEN iffD2])
paulson@14477
   793
paulson@15228
   794
text{*NS continuity ==> Standard continuity*}
paulson@14477
   795
lemma isNSCont_isCont: "isNSCont f a ==> isCont f a"
paulson@14477
   796
by (erule isNSCont_isCont_iff [THEN iffD1])
paulson@14477
   797
paulson@14477
   798
text{*Alternative definition of continuity*}
paulson@14477
   799
(* Prove equivalence between NS limits - *)
paulson@14477
   800
(* seems easier than using standard def  *)
paulson@14477
   801
lemma NSLIM_h_iff: "(f -- a --NS> L) = ((%h. f(a + h)) -- 0 --NS> L)"
paulson@14477
   802
apply (simp add: NSLIM_def, auto)
huffman@20561
   803
apply (drule_tac x = "star_of a + x" in spec)
huffman@20561
   804
apply (drule_tac [2] x = "- star_of a + x" in spec, safe, simp)
huffman@20561
   805
apply (erule mem_infmal_iff [THEN iffD2, THEN Infinitesimal_add_approx_self [THEN approx_sym]])
huffman@20561
   806
apply (erule_tac [3] approx_minus_iff2 [THEN iffD1])
huffman@20561
   807
 prefer 2 apply (simp add: add_commute diff_def [symmetric])
huffman@20561
   808
apply (rule_tac x = x in star_cases)
huffman@17318
   809
apply (rule_tac [2] x = x in star_cases)
huffman@17318
   810
apply (auto simp add: starfun star_of_def star_n_minus star_n_add add_assoc approx_refl star_n_zero_num)
paulson@14477
   811
done
paulson@14477
   812
paulson@14477
   813
lemma NSLIM_isCont_iff: "(f -- a --NS> f a) = ((%h. f(a + h)) -- 0 --NS> f a)"
paulson@14477
   814
by (rule NSLIM_h_iff)
paulson@14477
   815
paulson@14477
   816
lemma isNSCont_minus: "isNSCont f a ==> isNSCont (%x. - f x) a"
paulson@14477
   817
by (simp add: isNSCont_def)
paulson@14477
   818
huffman@20552
   819
lemma isNSCont_inverse:
huffman@20653
   820
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
huffman@20552
   821
  shows "[| isNSCont f x; f x \<noteq> 0 |] ==> isNSCont (%x. inverse (f x)) x"
paulson@14477
   822
by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff)
paulson@14477
   823
paulson@15228
   824
lemma isNSCont_const [simp]: "isNSCont (%x. k) a"
paulson@14477
   825
by (simp add: isNSCont_def)
paulson@14477
   826
huffman@20561
   827
lemma isNSCont_abs [simp]: "isNSCont abs (a::real)"
paulson@14477
   828
apply (simp add: isNSCont_def)
paulson@14477
   829
apply (auto intro: approx_hrabs simp add: hypreal_of_real_hrabs [symmetric] starfun_rabs_hrabs)
paulson@14477
   830
done
paulson@14477
   831
huffman@20561
   832
lemma isCont_abs [simp]: "isCont abs (a::real)"
paulson@14477
   833
by (auto simp add: isNSCont_isCont_iff [symmetric])
paulson@15228
   834
paulson@14477
   835
paulson@14477
   836
(****************************************************************
paulson@14477
   837
(%* Leave as commented until I add topology theory or remove? *%)
paulson@14477
   838
(%*------------------------------------------------------------
paulson@14477
   839
  Elementary topology proof for a characterisation of
paulson@14477
   840
  continuity now: a function f is continuous if and only
paulson@14477
   841
  if the inverse image, {x. f(x) \<in> A}, of any open set A
paulson@14477
   842
  is always an open set
paulson@14477
   843
 ------------------------------------------------------------*%)
paulson@14477
   844
Goal "[| isNSopen A; \<forall>x. isNSCont f x |]
paulson@14477
   845
               ==> isNSopen {x. f x \<in> A}"
paulson@14477
   846
by (auto_tac (claset(),simpset() addsimps [isNSopen_iff1]));
paulson@14477
   847
by (dtac (mem_monad_approx RS approx_sym);
paulson@14477
   848
by (dres_inst_tac [("x","a")] spec 1);
paulson@14477
   849
by (dtac isNSContD 1 THEN assume_tac 1)
paulson@14477
   850
by (dtac bspec 1 THEN assume_tac 1)
paulson@14477
   851
by (dres_inst_tac [("x","( *f* f) x")] approx_mem_monad2 1);
paulson@14477
   852
by (blast_tac (claset() addIs [starfun_mem_starset]);
paulson@14477
   853
qed "isNSCont_isNSopen";
paulson@14477
   854
paulson@14477
   855
Goalw [isNSCont_def]
paulson@14477
   856
          "\<forall>A. isNSopen A --> isNSopen {x. f x \<in> A} \
paulson@14477
   857
\              ==> isNSCont f x";
paulson@14477
   858
by (auto_tac (claset() addSIs [(mem_infmal_iff RS iffD1) RS
paulson@14477
   859
     (approx_minus_iff RS iffD2)],simpset() addsimps
paulson@14477
   860
      [Infinitesimal_def,SReal_iff]));
paulson@14477
   861
by (dres_inst_tac [("x","{z. abs(z + -f(x)) < ya}")] spec 1);
paulson@14477
   862
by (etac (isNSopen_open_interval RSN (2,impE));
paulson@14477
   863
by (auto_tac (claset(),simpset() addsimps [isNSopen_def,isNSnbhd_def]));
paulson@14477
   864
by (dres_inst_tac [("x","x")] spec 1);
paulson@14477
   865
by (auto_tac (claset() addDs [approx_sym RS approx_mem_monad],
paulson@14477
   866
    simpset() addsimps [hypreal_of_real_zero RS sym,STAR_starfun_rabs_add_minus]));
paulson@14477
   867
qed "isNSopen_isNSCont";
paulson@14477
   868
paulson@14477
   869
Goal "(\<forall>x. isNSCont f x) = \
paulson@14477
   870
\     (\<forall>A. isNSopen A --> isNSopen {x. f(x) \<in> A})";
paulson@14477
   871
by (blast_tac (claset() addIs [isNSCont_isNSopen,
paulson@14477
   872
    isNSopen_isNSCont]);
paulson@14477
   873
qed "isNSCont_isNSopen_iff";
paulson@14477
   874
paulson@14477
   875
(%*------- Standard version of same theorem --------*%)
paulson@14477
   876
Goal "(\<forall>x. isCont f x) = \
paulson@14477
   877
\         (\<forall>A. isopen A --> isopen {x. f(x) \<in> A})";
paulson@14477
   878
by (auto_tac (claset() addSIs [isNSCont_isNSopen_iff],
paulson@14477
   879
              simpset() addsimps [isNSopen_isopen_iff RS sym,
paulson@14477
   880
              isNSCont_isCont_iff RS sym]));
paulson@14477
   881
qed "isCont_isopen_iff";
paulson@14477
   882
*******************************************************************)
paulson@14477
   883
huffman@20755
   884
subsection {* Uniform Continuity *}
huffman@20755
   885
paulson@14477
   886
lemma isNSUContD: "[| isNSUCont f; x \<approx> y|] ==> ( *f* f) x \<approx> ( *f* f) y"
paulson@14477
   887
by (simp add: isNSUCont_def)
paulson@14477
   888
paulson@14477
   889
lemma isUCont_isCont: "isUCont f ==> isCont f x"
paulson@14477
   890
by (simp add: isUCont_def isCont_def LIM_def, meson)
paulson@14477
   891
huffman@20754
   892
lemma isUCont_isNSUCont:
huffman@20754
   893
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
huffman@20754
   894
  assumes f: "isUCont f" shows "isNSUCont f"
huffman@20754
   895
proof (unfold isNSUCont_def, safe)
huffman@20754
   896
  fix x y :: "'a star"
huffman@20754
   897
  assume approx: "x \<approx> y"
huffman@20754
   898
  have "starfun f x - starfun f y \<in> Infinitesimal"
huffman@20754
   899
  proof (rule InfinitesimalI2)
huffman@20754
   900
    fix r::real assume r: "0 < r"
huffman@20754
   901
    with f obtain s where s: "0 < s" and
huffman@20754
   902
      less_r: "\<And>x y. norm (x - y) < s \<Longrightarrow> norm (f x - f y) < r"
huffman@20754
   903
      by (auto simp add: isUCont_def)
huffman@20754
   904
    from less_r have less_r':
huffman@20754
   905
       "\<And>x y. hnorm (x - y) < star_of s
huffman@20754
   906
        \<Longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
huffman@20754
   907
      by transfer
huffman@20754
   908
    from approx have "x - y \<in> Infinitesimal"
huffman@20754
   909
      by (unfold approx_def)
huffman@20754
   910
    hence "hnorm (x - y) < star_of s"
huffman@20754
   911
      using s by (rule InfinitesimalD2)
huffman@20754
   912
    thus "hnorm (starfun f x - starfun f y) < star_of r"
huffman@20754
   913
      by (rule less_r')
huffman@20754
   914
  qed
huffman@20754
   915
  thus "starfun f x \<approx> starfun f y"
huffman@20754
   916
    by (unfold approx_def)
huffman@20754
   917
qed
paulson@14477
   918
paulson@14477
   919
lemma isNSUCont_isUCont:
huffman@20754
   920
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
huffman@20754
   921
  assumes f: "isNSUCont f" shows "isUCont f"
huffman@20754
   922
proof (unfold isUCont_def, safe)
huffman@20754
   923
  fix r::real assume r: "0 < r"
huffman@20754
   924
  have "\<exists>s>0. \<forall>x y. hnorm (x - y) < s
huffman@20754
   925
        \<longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
huffman@20754
   926
  proof (rule exI, safe)
huffman@20754
   927
    show "0 < epsilon" by (rule hypreal_epsilon_gt_zero)
huffman@20754
   928
  next
huffman@20754
   929
    fix x y :: "'a star"
huffman@20754
   930
    assume "hnorm (x - y) < epsilon"
huffman@20754
   931
    with Infinitesimal_epsilon
huffman@20754
   932
    have "x - y \<in> Infinitesimal"
huffman@20754
   933
      by (rule hnorm_less_Infinitesimal)
huffman@20754
   934
    hence "x \<approx> y"
huffman@20754
   935
      by (unfold approx_def)
huffman@20754
   936
    with f have "starfun f x \<approx> starfun f y"
huffman@20754
   937
      by (simp add: isNSUCont_def)
huffman@20754
   938
    hence "starfun f x - starfun f y \<in> Infinitesimal"
huffman@20754
   939
      by (unfold approx_def)
huffman@20754
   940
    thus "hnorm (starfun f x - starfun f y) < star_of r"
huffman@20754
   941
      using r by (rule InfinitesimalD2)
huffman@20754
   942
  qed
huffman@20754
   943
  thus "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
huffman@20754
   944
    by transfer
huffman@20754
   945
qed
paulson@14477
   946
huffman@21165
   947
subsection {* Relation of LIM and LIMSEQ *}
kleing@19023
   948
kleing@19023
   949
lemma LIMSEQ_SEQ_conv1:
huffman@21165
   950
  fixes a :: "'a::real_normed_vector"
huffman@21165
   951
  assumes X: "X -- a --> L"
kleing@19023
   952
  shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
huffman@21165
   953
proof (safe intro!: LIMSEQ_I)
huffman@21165
   954
  fix S :: "nat \<Rightarrow> 'a"
huffman@21165
   955
  fix r :: real
huffman@21165
   956
  assume rgz: "0 < r"
huffman@21165
   957
  assume as: "\<forall>n. S n \<noteq> a"
huffman@21165
   958
  assume S: "S ----> a"
huffman@21165
   959
  from LIM_D [OF X rgz] obtain s
huffman@21165
   960
    where sgz: "0 < s"
huffman@21165
   961
    and aux: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (X x - L) < r"
huffman@21165
   962
    by fast
huffman@21165
   963
  from LIMSEQ_D [OF S sgz]
huffman@21165
   964
  obtain no where "\<forall>n\<ge>no. norm (S n - a) < s" by fast
huffman@21165
   965
  hence "\<forall>n\<ge>no. norm (X (S n) - L) < r" by (simp add: aux as)
huffman@21165
   966
  thus "\<exists>no. \<forall>n\<ge>no. norm (X (S n) - L) < r" ..
kleing@19023
   967
qed
kleing@19023
   968
kleing@19023
   969
lemma LIMSEQ_SEQ_conv2:
huffman@20561
   970
  fixes a :: real
kleing@19023
   971
  assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
kleing@19023
   972
  shows "X -- a --> L"
kleing@19023
   973
proof (rule ccontr)
kleing@19023
   974
  assume "\<not> (X -- a --> L)"
huffman@20563
   975
  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
   976
  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
   977
  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
   978
  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
   979
huffman@20563
   980
  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
   981
  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
   982
    using rdef by simp
huffman@21165
   983
  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
   984
    by (rule someI_ex)
huffman@21165
   985
  hence F1: "\<And>n. ?F n \<noteq> a"
huffman@21165
   986
    and F2: "\<And>n. \<bar>?F n - a\<bar> < inverse (real (Suc n))"
huffman@21165
   987
    and F3: "\<And>n. norm (X (?F n) - L) \<ge> r"
huffman@21165
   988
    by fast+
huffman@21165
   989
kleing@19023
   990
  have "?F ----> a"
huffman@21165
   991
  proof (rule LIMSEQ_I, unfold real_norm_def)
kleing@19023
   992
      fix e::real
kleing@19023
   993
      assume "0 < e"
kleing@19023
   994
        (* choose no such that inverse (real (Suc n)) < e *)
kleing@19023
   995
      have "\<exists>no. inverse (real (Suc no)) < e" by (rule reals_Archimedean)
kleing@19023
   996
      then obtain m where nodef: "inverse (real (Suc m)) < e" by auto
huffman@21165
   997
      show "\<exists>no. \<forall>n. no \<le> n --> \<bar>?F n - a\<bar> < e"
huffman@21165
   998
      proof (intro exI allI impI)
kleing@19023
   999
        fix n
kleing@19023
  1000
        assume mlen: "m \<le> n"
huffman@21165
  1001
        have "\<bar>?F n - a\<bar> < inverse (real (Suc n))"
huffman@21165
  1002
          by (rule F2)
huffman@21165
  1003
        also have "inverse (real (Suc n)) \<le> inverse (real (Suc m))"
kleing@19023
  1004
          by auto
huffman@21165
  1005
        also from nodef have
kleing@19023
  1006
          "inverse (real (Suc m)) < e" .
huffman@21165
  1007
        finally show "\<bar>?F n - a\<bar> < e" .
huffman@21165
  1008
      qed
kleing@19023
  1009
  qed
kleing@19023
  1010
  
kleing@19023
  1011
  moreover have "\<forall>n. ?F n \<noteq> a"
huffman@21165
  1012
    by (rule allI) (rule F1)
huffman@21165
  1013
kleing@19023
  1014
  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
  1015
  ultimately have "(\<lambda>n. X (?F n)) ----> L" by simp
kleing@19023
  1016
  
kleing@19023
  1017
  moreover have "\<not> ((\<lambda>n. X (?F n)) ----> L)"
kleing@19023
  1018
  proof -
kleing@19023
  1019
    {
kleing@19023
  1020
      fix no::nat
kleing@19023
  1021
      obtain n where "n = no + 1" by simp
kleing@19023
  1022
      then have nolen: "no \<le> n" by simp
kleing@19023
  1023
        (* 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
  1024
      have "norm (X (?F n) - L) \<ge> r"
huffman@21165
  1025
        by (rule F3)
huffman@21165
  1026
      with nolen have "\<exists>n. no \<le> n \<and> norm (X (?F n) - L) \<ge> r" by fast
kleing@19023
  1027
    }
huffman@20563
  1028
    then have "(\<forall>no. \<exists>n. no \<le> n \<and> norm (X (?F n) - L) \<ge> r)" by simp
huffman@20563
  1029
    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
  1030
    thus ?thesis by (unfold LIMSEQ_def, auto simp add: linorder_not_less)
kleing@19023
  1031
  qed
kleing@19023
  1032
  ultimately show False by simp
kleing@19023
  1033
qed
kleing@19023
  1034
kleing@19023
  1035
lemma LIMSEQ_SEQ_conv:
huffman@20561
  1036
  "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::real) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
huffman@20561
  1037
   (X -- a --> L)"
kleing@19023
  1038
proof
kleing@19023
  1039
  assume "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
kleing@19023
  1040
  show "X -- a --> L" by (rule LIMSEQ_SEQ_conv2)
kleing@19023
  1041
next
kleing@19023
  1042
  assume "(X -- a --> L)"
kleing@19023
  1043
  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
  1044
qed
kleing@19023
  1045
paulson@10751
  1046
end