src/HOL/NSA/HLim.thy
author huffman
Fri Mar 30 12:32:35 2012 +0200 (2012-03-30)
changeset 47220 52426c62b5d0
parent 41959 b460124855b8
child 50249 3f0920f8a24e
permissions -rw-r--r--
replace lemmas eval_nat_numeral with a simpler reformulation
wenzelm@41959
     1
(*  Title:      HOL/NSA/HLim.thy
wenzelm@41589
     2
    Author:     Jacques D. Fleuriot, University of Cambridge
wenzelm@41589
     3
    Author:     Lawrence C Paulson
huffman@27468
     4
*)
huffman@27468
     5
huffman@27468
     6
header{* Limits and Continuity (Nonstandard) *}
huffman@27468
     7
huffman@27468
     8
theory HLim
huffman@27468
     9
imports Star Lim
huffman@27468
    10
begin
huffman@27468
    11
huffman@27468
    12
text{*Nonstandard Definitions*}
huffman@27468
    13
huffman@27468
    14
definition
huffman@27468
    15
  NSLIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool"
huffman@27468
    16
            ("((_)/ -- (_)/ --NS> (_))" [60, 0, 60] 60) where
haftmann@37765
    17
  "f -- a --NS> L =
huffman@27468
    18
    (\<forall>x. (x \<noteq> star_of a & x @= star_of a --> ( *f* f) x @= star_of L))"
huffman@27468
    19
huffman@27468
    20
definition
huffman@27468
    21
  isNSCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool" where
huffman@27468
    22
    --{*NS definition dispenses with limit notions*}
haftmann@37765
    23
  "isNSCont f a = (\<forall>y. y @= star_of a -->
huffman@27468
    24
         ( *f* f) y @= star_of (f a))"
huffman@27468
    25
huffman@27468
    26
definition
huffman@27468
    27
  isNSUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool" where
haftmann@37765
    28
  "isNSUCont f = (\<forall>x y. x @= y --> ( *f* f) x @= ( *f* f) y)"
huffman@27468
    29
huffman@27468
    30
huffman@27468
    31
subsection {* Limits of Functions *}
huffman@27468
    32
huffman@27468
    33
lemma NSLIM_I:
huffman@27468
    34
  "(\<And>x. \<lbrakk>x \<noteq> star_of a; x \<approx> star_of a\<rbrakk> \<Longrightarrow> starfun f x \<approx> star_of L)
huffman@27468
    35
   \<Longrightarrow> f -- a --NS> L"
huffman@27468
    36
by (simp add: NSLIM_def)
huffman@27468
    37
huffman@27468
    38
lemma NSLIM_D:
huffman@27468
    39
  "\<lbrakk>f -- a --NS> L; x \<noteq> star_of a; x \<approx> star_of a\<rbrakk>
huffman@27468
    40
   \<Longrightarrow> starfun f x \<approx> star_of L"
huffman@27468
    41
by (simp add: NSLIM_def)
huffman@27468
    42
huffman@27468
    43
text{*Proving properties of limits using nonstandard definition.
huffman@27468
    44
      The properties hold for standard limits as well!*}
huffman@27468
    45
huffman@27468
    46
lemma NSLIM_mult:
huffman@27468
    47
  fixes l m :: "'a::real_normed_algebra"
huffman@27468
    48
  shows "[| f -- x --NS> l; g -- x --NS> m |]
huffman@27468
    49
      ==> (%x. f(x) * g(x)) -- x --NS> (l * m)"
huffman@27468
    50
by (auto simp add: NSLIM_def intro!: approx_mult_HFinite)
huffman@27468
    51
huffman@27468
    52
lemma starfun_scaleR [simp]:
huffman@27468
    53
  "starfun (\<lambda>x. f x *\<^sub>R g x) = (\<lambda>x. scaleHR (starfun f x) (starfun g x))"
huffman@27468
    54
by transfer (rule refl)
huffman@27468
    55
huffman@27468
    56
lemma NSLIM_scaleR:
huffman@27468
    57
  "[| f -- x --NS> l; g -- x --NS> m |]
huffman@27468
    58
      ==> (%x. f(x) *\<^sub>R g(x)) -- x --NS> (l *\<^sub>R m)"
huffman@27468
    59
by (auto simp add: NSLIM_def intro!: approx_scaleR_HFinite)
huffman@27468
    60
huffman@27468
    61
lemma NSLIM_add:
huffman@27468
    62
     "[| f -- x --NS> l; g -- x --NS> m |]
huffman@27468
    63
      ==> (%x. f(x) + g(x)) -- x --NS> (l + m)"
huffman@27468
    64
by (auto simp add: NSLIM_def intro!: approx_add)
huffman@27468
    65
huffman@27468
    66
lemma NSLIM_const [simp]: "(%x. k) -- x --NS> k"
huffman@27468
    67
by (simp add: NSLIM_def)
huffman@27468
    68
huffman@27468
    69
lemma NSLIM_minus: "f -- a --NS> L ==> (%x. -f(x)) -- a --NS> -L"
huffman@27468
    70
by (simp add: NSLIM_def)
huffman@27468
    71
huffman@27468
    72
lemma NSLIM_diff:
huffman@27468
    73
  "\<lbrakk>f -- x --NS> l; g -- x --NS> m\<rbrakk> \<Longrightarrow> (\<lambda>x. f x - g x) -- x --NS> (l - m)"
haftmann@37887
    74
by (simp only: diff_minus NSLIM_add NSLIM_minus)
huffman@27468
    75
huffman@27468
    76
lemma NSLIM_add_minus: "[| f -- x --NS> l; g -- x --NS> m |] ==> (%x. f(x) + -g(x)) -- x --NS> (l + -m)"
huffman@27468
    77
by (simp only: NSLIM_add NSLIM_minus)
huffman@27468
    78
huffman@27468
    79
lemma NSLIM_inverse:
huffman@27468
    80
  fixes L :: "'a::real_normed_div_algebra"
huffman@27468
    81
  shows "[| f -- a --NS> L;  L \<noteq> 0 |]
huffman@27468
    82
      ==> (%x. inverse(f(x))) -- a --NS> (inverse L)"
huffman@27468
    83
apply (simp add: NSLIM_def, clarify)
huffman@27468
    84
apply (drule spec)
huffman@27468
    85
apply (auto simp add: star_of_approx_inverse)
huffman@27468
    86
done
huffman@27468
    87
huffman@27468
    88
lemma NSLIM_zero:
huffman@27468
    89
  assumes f: "f -- a --NS> l" shows "(%x. f(x) - l) -- a --NS> 0"
huffman@27468
    90
proof -
huffman@27468
    91
  have "(\<lambda>x. f x - l) -- a --NS> l - l"
huffman@27468
    92
    by (rule NSLIM_diff [OF f NSLIM_const])
huffman@27468
    93
  thus ?thesis by simp
huffman@27468
    94
qed
huffman@27468
    95
huffman@27468
    96
lemma NSLIM_zero_cancel: "(%x. f(x) - l) -- x --NS> 0 ==> f -- x --NS> l"
huffman@27468
    97
apply (drule_tac g = "%x. l" and m = l in NSLIM_add)
huffman@27468
    98
apply (auto simp add: diff_minus add_assoc)
huffman@27468
    99
done
huffman@27468
   100
huffman@27468
   101
lemma NSLIM_const_not_eq:
huffman@27468
   102
  fixes a :: "'a::real_normed_algebra_1"
huffman@27468
   103
  shows "k \<noteq> L \<Longrightarrow> \<not> (\<lambda>x. k) -- a --NS> L"
huffman@27468
   104
apply (simp add: NSLIM_def)
huffman@27468
   105
apply (rule_tac x="star_of a + of_hypreal epsilon" in exI)
huffman@27468
   106
apply (simp add: hypreal_epsilon_not_zero approx_def)
huffman@27468
   107
done
huffman@27468
   108
huffman@27468
   109
lemma NSLIM_not_zero:
huffman@27468
   110
  fixes a :: "'a::real_normed_algebra_1"
huffman@27468
   111
  shows "k \<noteq> 0 \<Longrightarrow> \<not> (\<lambda>x. k) -- a --NS> 0"
huffman@27468
   112
by (rule NSLIM_const_not_eq)
huffman@27468
   113
huffman@27468
   114
lemma NSLIM_const_eq:
huffman@27468
   115
  fixes a :: "'a::real_normed_algebra_1"
huffman@27468
   116
  shows "(\<lambda>x. k) -- a --NS> L \<Longrightarrow> k = L"
huffman@27468
   117
apply (rule ccontr)
huffman@27468
   118
apply (blast dest: NSLIM_const_not_eq)
huffman@27468
   119
done
huffman@27468
   120
huffman@27468
   121
lemma NSLIM_unique:
huffman@27468
   122
  fixes a :: "'a::real_normed_algebra_1"
huffman@27468
   123
  shows "\<lbrakk>f -- a --NS> L; f -- a --NS> M\<rbrakk> \<Longrightarrow> L = M"
huffman@27468
   124
apply (drule (1) NSLIM_diff)
huffman@27468
   125
apply (auto dest!: NSLIM_const_eq)
huffman@27468
   126
done
huffman@27468
   127
huffman@27468
   128
lemma NSLIM_mult_zero:
huffman@27468
   129
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
huffman@27468
   130
  shows "[| f -- x --NS> 0; g -- x --NS> 0 |] ==> (%x. f(x)*g(x)) -- x --NS> 0"
huffman@27468
   131
by (drule NSLIM_mult, auto)
huffman@27468
   132
huffman@27468
   133
lemma NSLIM_self: "(%x. x) -- a --NS> a"
huffman@27468
   134
by (simp add: NSLIM_def)
huffman@27468
   135
huffman@27468
   136
subsubsection {* Equivalence of @{term LIM} and @{term NSLIM} *}
huffman@27468
   137
huffman@27468
   138
lemma LIM_NSLIM:
huffman@27468
   139
  assumes f: "f -- a --> L" shows "f -- a --NS> L"
huffman@27468
   140
proof (rule NSLIM_I)
huffman@27468
   141
  fix x
huffman@27468
   142
  assume neq: "x \<noteq> star_of a"
huffman@27468
   143
  assume approx: "x \<approx> star_of a"
huffman@27468
   144
  have "starfun f x - star_of L \<in> Infinitesimal"
huffman@27468
   145
  proof (rule InfinitesimalI2)
huffman@27468
   146
    fix r::real assume r: "0 < r"
huffman@27468
   147
    from LIM_D [OF f r]
huffman@27468
   148
    obtain s where s: "0 < s" and
huffman@27468
   149
      less_r: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (f x - L) < r"
huffman@27468
   150
      by fast
huffman@27468
   151
    from less_r have less_r':
huffman@27468
   152
       "\<And>x. \<lbrakk>x \<noteq> star_of a; hnorm (x - star_of a) < star_of s\<rbrakk>
huffman@27468
   153
        \<Longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
huffman@27468
   154
      by transfer
huffman@27468
   155
    from approx have "x - star_of a \<in> Infinitesimal"
huffman@27468
   156
      by (unfold approx_def)
huffman@27468
   157
    hence "hnorm (x - star_of a) < star_of s"
huffman@27468
   158
      using s by (rule InfinitesimalD2)
huffman@27468
   159
    with neq show "hnorm (starfun f x - star_of L) < star_of r"
huffman@27468
   160
      by (rule less_r')
huffman@27468
   161
  qed
huffman@27468
   162
  thus "starfun f x \<approx> star_of L"
huffman@27468
   163
    by (unfold approx_def)
huffman@27468
   164
qed
huffman@27468
   165
huffman@27468
   166
lemma NSLIM_LIM:
huffman@27468
   167
  assumes f: "f -- a --NS> L" shows "f -- a --> L"
huffman@27468
   168
proof (rule LIM_I)
huffman@27468
   169
  fix r::real assume r: "0 < r"
huffman@27468
   170
  have "\<exists>s>0. \<forall>x. x \<noteq> star_of a \<and> hnorm (x - star_of a) < s
huffman@27468
   171
        \<longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
huffman@27468
   172
  proof (rule exI, safe)
huffman@27468
   173
    show "0 < epsilon" by (rule hypreal_epsilon_gt_zero)
huffman@27468
   174
  next
huffman@27468
   175
    fix x assume neq: "x \<noteq> star_of a"
huffman@27468
   176
    assume "hnorm (x - star_of a) < epsilon"
huffman@27468
   177
    with Infinitesimal_epsilon
huffman@27468
   178
    have "x - star_of a \<in> Infinitesimal"
huffman@27468
   179
      by (rule hnorm_less_Infinitesimal)
huffman@27468
   180
    hence "x \<approx> star_of a"
huffman@27468
   181
      by (unfold approx_def)
huffman@27468
   182
    with f neq have "starfun f x \<approx> star_of L"
huffman@27468
   183
      by (rule NSLIM_D)
huffman@27468
   184
    hence "starfun f x - star_of L \<in> Infinitesimal"
huffman@27468
   185
      by (unfold approx_def)
huffman@27468
   186
    thus "hnorm (starfun f x - star_of L) < star_of r"
huffman@27468
   187
      using r by (rule InfinitesimalD2)
huffman@27468
   188
  qed
huffman@27468
   189
  thus "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r"
huffman@27468
   190
    by transfer
huffman@27468
   191
qed
huffman@27468
   192
huffman@27468
   193
theorem LIM_NSLIM_iff: "(f -- x --> L) = (f -- x --NS> L)"
huffman@27468
   194
by (blast intro: LIM_NSLIM NSLIM_LIM)
huffman@27468
   195
huffman@27468
   196
huffman@27468
   197
subsection {* Continuity *}
huffman@27468
   198
huffman@27468
   199
lemma isNSContD:
huffman@27468
   200
  "\<lbrakk>isNSCont f a; y \<approx> star_of a\<rbrakk> \<Longrightarrow> ( *f* f) y \<approx> star_of (f a)"
huffman@27468
   201
by (simp add: isNSCont_def)
huffman@27468
   202
huffman@27468
   203
lemma isNSCont_NSLIM: "isNSCont f a ==> f -- a --NS> (f a) "
huffman@27468
   204
by (simp add: isNSCont_def NSLIM_def)
huffman@27468
   205
huffman@27468
   206
lemma NSLIM_isNSCont: "f -- a --NS> (f a) ==> isNSCont f a"
huffman@27468
   207
apply (simp add: isNSCont_def NSLIM_def, auto)
huffman@27468
   208
apply (case_tac "y = star_of a", auto)
huffman@27468
   209
done
huffman@27468
   210
huffman@27468
   211
text{*NS continuity can be defined using NS Limit in
huffman@27468
   212
    similar fashion to standard def of continuity*}
huffman@27468
   213
lemma isNSCont_NSLIM_iff: "(isNSCont f a) = (f -- a --NS> (f a))"
huffman@27468
   214
by (blast intro: isNSCont_NSLIM NSLIM_isNSCont)
huffman@27468
   215
huffman@27468
   216
text{*Hence, NS continuity can be given
huffman@27468
   217
  in terms of standard limit*}
huffman@27468
   218
lemma isNSCont_LIM_iff: "(isNSCont f a) = (f -- a --> (f a))"
huffman@27468
   219
by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff)
huffman@27468
   220
huffman@27468
   221
text{*Moreover, it's trivial now that NS continuity
huffman@27468
   222
  is equivalent to standard continuity*}
huffman@27468
   223
lemma isNSCont_isCont_iff: "(isNSCont f a) = (isCont f a)"
huffman@27468
   224
apply (simp add: isCont_def)
huffman@27468
   225
apply (rule isNSCont_LIM_iff)
huffman@27468
   226
done
huffman@27468
   227
huffman@27468
   228
text{*Standard continuity ==> NS continuity*}
huffman@27468
   229
lemma isCont_isNSCont: "isCont f a ==> isNSCont f a"
huffman@27468
   230
by (erule isNSCont_isCont_iff [THEN iffD2])
huffman@27468
   231
huffman@27468
   232
text{*NS continuity ==> Standard continuity*}
huffman@27468
   233
lemma isNSCont_isCont: "isNSCont f a ==> isCont f a"
huffman@27468
   234
by (erule isNSCont_isCont_iff [THEN iffD1])
huffman@27468
   235
huffman@27468
   236
text{*Alternative definition of continuity*}
huffman@27468
   237
huffman@27468
   238
(* Prove equivalence between NS limits - *)
huffman@27468
   239
(* seems easier than using standard def  *)
huffman@27468
   240
lemma NSLIM_h_iff: "(f -- a --NS> L) = ((%h. f(a + h)) -- 0 --NS> L)"
huffman@27468
   241
apply (simp add: NSLIM_def, auto)
huffman@27468
   242
apply (drule_tac x = "star_of a + x" in spec)
huffman@27468
   243
apply (drule_tac [2] x = "- star_of a + x" in spec, safe, simp)
huffman@27468
   244
apply (erule mem_infmal_iff [THEN iffD2, THEN Infinitesimal_add_approx_self [THEN approx_sym]])
huffman@27468
   245
apply (erule_tac [3] approx_minus_iff2 [THEN iffD1])
haftmann@37887
   246
 prefer 2 apply (simp add: add_commute diff_minus [symmetric])
huffman@27468
   247
apply (rule_tac x = x in star_cases)
huffman@27468
   248
apply (rule_tac [2] x = x in star_cases)
huffman@27468
   249
apply (auto simp add: starfun star_of_def star_n_minus star_n_add add_assoc approx_refl star_n_zero_num)
huffman@27468
   250
done
huffman@27468
   251
huffman@27468
   252
lemma NSLIM_isCont_iff: "(f -- a --NS> f a) = ((%h. f(a + h)) -- 0 --NS> f a)"
huffman@27468
   253
by (rule NSLIM_h_iff)
huffman@27468
   254
huffman@27468
   255
lemma isNSCont_minus: "isNSCont f a ==> isNSCont (%x. - f x) a"
huffman@27468
   256
by (simp add: isNSCont_def)
huffman@27468
   257
huffman@27468
   258
lemma isNSCont_inverse:
huffman@27468
   259
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
huffman@27468
   260
  shows "[| isNSCont f x; f x \<noteq> 0 |] ==> isNSCont (%x. inverse (f x)) x"
huffman@27468
   261
by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff)
huffman@27468
   262
huffman@27468
   263
lemma isNSCont_const [simp]: "isNSCont (%x. k) a"
huffman@27468
   264
by (simp add: isNSCont_def)
huffman@27468
   265
huffman@27468
   266
lemma isNSCont_abs [simp]: "isNSCont abs (a::real)"
huffman@27468
   267
apply (simp add: isNSCont_def)
huffman@27468
   268
apply (auto intro: approx_hrabs simp add: starfun_rabs_hrabs)
huffman@27468
   269
done
huffman@27468
   270
huffman@27468
   271
huffman@27468
   272
subsection {* Uniform Continuity *}
huffman@27468
   273
huffman@27468
   274
lemma isNSUContD: "[| isNSUCont f; x \<approx> y|] ==> ( *f* f) x \<approx> ( *f* f) y"
huffman@27468
   275
by (simp add: isNSUCont_def)
huffman@27468
   276
huffman@27468
   277
lemma isUCont_isNSUCont:
huffman@27468
   278
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
huffman@27468
   279
  assumes f: "isUCont f" shows "isNSUCont f"
huffman@27468
   280
proof (unfold isNSUCont_def, safe)
huffman@27468
   281
  fix x y :: "'a star"
huffman@27468
   282
  assume approx: "x \<approx> y"
huffman@27468
   283
  have "starfun f x - starfun f y \<in> Infinitesimal"
huffman@27468
   284
  proof (rule InfinitesimalI2)
huffman@27468
   285
    fix r::real assume r: "0 < r"
huffman@27468
   286
    with f obtain s where s: "0 < s" and
huffman@27468
   287
      less_r: "\<And>x y. norm (x - y) < s \<Longrightarrow> norm (f x - f y) < r"
huffman@31338
   288
      by (auto simp add: isUCont_def dist_norm)
huffman@27468
   289
    from less_r have less_r':
huffman@27468
   290
       "\<And>x y. hnorm (x - y) < star_of s
huffman@27468
   291
        \<Longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
huffman@27468
   292
      by transfer
huffman@27468
   293
    from approx have "x - y \<in> Infinitesimal"
huffman@27468
   294
      by (unfold approx_def)
huffman@27468
   295
    hence "hnorm (x - y) < star_of s"
huffman@27468
   296
      using s by (rule InfinitesimalD2)
huffman@27468
   297
    thus "hnorm (starfun f x - starfun f y) < star_of r"
huffman@27468
   298
      by (rule less_r')
huffman@27468
   299
  qed
huffman@27468
   300
  thus "starfun f x \<approx> starfun f y"
huffman@27468
   301
    by (unfold approx_def)
huffman@27468
   302
qed
huffman@27468
   303
huffman@27468
   304
lemma isNSUCont_isUCont:
huffman@27468
   305
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
huffman@27468
   306
  assumes f: "isNSUCont f" shows "isUCont f"
huffman@31338
   307
proof (unfold isUCont_def dist_norm, safe)
huffman@27468
   308
  fix r::real assume r: "0 < r"
huffman@27468
   309
  have "\<exists>s>0. \<forall>x y. hnorm (x - y) < s
huffman@27468
   310
        \<longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
huffman@27468
   311
  proof (rule exI, safe)
huffman@27468
   312
    show "0 < epsilon" by (rule hypreal_epsilon_gt_zero)
huffman@27468
   313
  next
huffman@27468
   314
    fix x y :: "'a star"
huffman@27468
   315
    assume "hnorm (x - y) < epsilon"
huffman@27468
   316
    with Infinitesimal_epsilon
huffman@27468
   317
    have "x - y \<in> Infinitesimal"
huffman@27468
   318
      by (rule hnorm_less_Infinitesimal)
huffman@27468
   319
    hence "x \<approx> y"
huffman@27468
   320
      by (unfold approx_def)
huffman@27468
   321
    with f have "starfun f x \<approx> starfun f y"
huffman@27468
   322
      by (simp add: isNSUCont_def)
huffman@27468
   323
    hence "starfun f x - starfun f y \<in> Infinitesimal"
huffman@27468
   324
      by (unfold approx_def)
huffman@27468
   325
    thus "hnorm (starfun f x - starfun f y) < star_of r"
huffman@27468
   326
      using r by (rule InfinitesimalD2)
huffman@27468
   327
  qed
huffman@27468
   328
  thus "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
huffman@27468
   329
    by transfer
huffman@27468
   330
qed
huffman@27468
   331
huffman@27468
   332
end