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