src/HOL/Nonstandard_Analysis/NSCA.thy
author haftmann
Mon Jun 05 15:59:41 2017 +0200 (2017-06-05)
changeset 66010 2f7d39285a1a
parent 63901 4ce989e962e0
child 67091 1393c2340eec
permissions -rw-r--r--
executable domain membership checks
wenzelm@62479
     1
(*  Title:      HOL/Nonstandard_Analysis/NSCA.thy
wenzelm@62479
     2
    Author:     Jacques D. Fleuriot
wenzelm@62479
     3
    Copyright:  2001, 2002 University of Edinburgh
huffman@27468
     4
*)
huffman@27468
     5
wenzelm@61975
     6
section\<open>Non-Standard Complex Analysis\<close>
huffman@27468
     7
huffman@27468
     8
theory NSCA
haftmann@28952
     9
imports NSComplex HTranscendental
huffman@27468
    10
begin
huffman@27468
    11
huffman@27468
    12
abbreviation
huffman@27468
    13
   (* standard complex numbers reagarded as an embedded subset of NS complex *)
huffman@27468
    14
   SComplex  :: "hcomplex set" where
huffman@27468
    15
   "SComplex \<equiv> Standard"
huffman@27468
    16
wenzelm@61975
    17
definition \<comment>\<open>standard part map\<close>
huffman@27468
    18
  stc :: "hcomplex => hcomplex" where 
wenzelm@61982
    19
  "stc x = (SOME r. x \<in> HFinite & r:SComplex & r \<approx> x)"
huffman@27468
    20
huffman@27468
    21
wenzelm@61975
    22
subsection\<open>Closure Laws for SComplex, the Standard Complex Numbers\<close>
huffman@27468
    23
huffman@27468
    24
lemma SComplex_minus_iff [simp]: "(-x \<in> SComplex) = (x \<in> SComplex)"
huffman@27468
    25
by (auto, drule Standard_minus, auto)
huffman@27468
    26
huffman@27468
    27
lemma SComplex_add_cancel:
huffman@27468
    28
     "[| x + y \<in> SComplex; y \<in> SComplex |] ==> x \<in> SComplex"
huffman@27468
    29
by (drule (1) Standard_diff, simp)
huffman@27468
    30
huffman@27468
    31
lemma SReal_hcmod_hcomplex_of_complex [simp]:
wenzelm@61070
    32
     "hcmod (hcomplex_of_complex r) \<in> \<real>"
huffman@27468
    33
by (simp add: Reals_eq_Standard)
huffman@27468
    34
wenzelm@61070
    35
lemma SReal_hcmod_numeral [simp]: "hcmod (numeral w ::hcomplex) \<in> \<real>"
huffman@27468
    36
by (simp add: Reals_eq_Standard)
huffman@27468
    37
wenzelm@61070
    38
lemma SReal_hcmod_SComplex: "x \<in> SComplex ==> hcmod x \<in> \<real>"
huffman@27468
    39
by (simp add: Reals_eq_Standard)
huffman@27468
    40
huffman@47108
    41
lemma SComplex_divide_numeral:
huffman@47108
    42
     "r \<in> SComplex ==> r/(numeral w::hcomplex) \<in> SComplex"
huffman@27468
    43
by simp
huffman@27468
    44
huffman@27468
    45
lemma SComplex_UNIV_complex:
huffman@27468
    46
     "{x. hcomplex_of_complex x \<in> SComplex} = (UNIV::complex set)"
huffman@27468
    47
by simp
huffman@27468
    48
huffman@27468
    49
lemma SComplex_iff: "(x \<in> SComplex) = (\<exists>y. x = hcomplex_of_complex y)"
huffman@27468
    50
by (simp add: Standard_def image_def)
huffman@27468
    51
huffman@27468
    52
lemma hcomplex_of_complex_image:
huffman@27468
    53
     "hcomplex_of_complex `(UNIV::complex set) = SComplex"
huffman@27468
    54
by (simp add: Standard_def)
huffman@27468
    55
huffman@27468
    56
lemma inv_hcomplex_of_complex_image: "inv hcomplex_of_complex `SComplex = UNIV"
lp15@59658
    57
by (auto simp add: Standard_def image_def) (metis inj_star_of inv_f_f)
huffman@27468
    58
huffman@27468
    59
lemma SComplex_hcomplex_of_complex_image: 
huffman@27468
    60
      "[| \<exists>x. x: P; P \<le> SComplex |] ==> \<exists>Q. P = hcomplex_of_complex ` Q"
huffman@27468
    61
apply (simp add: Standard_def, blast)
huffman@27468
    62
done
huffman@27468
    63
huffman@27468
    64
lemma SComplex_SReal_dense:
huffman@27468
    65
     "[| x \<in> SComplex; y \<in> SComplex; hcmod x < hcmod y  
huffman@27468
    66
      |] ==> \<exists>r \<in> Reals. hcmod x< r & r < hcmod y"
huffman@27468
    67
apply (auto intro: SReal_dense simp add: SReal_hcmod_SComplex)
huffman@27468
    68
done
huffman@27468
    69
huffman@27468
    70
wenzelm@61975
    71
subsection\<open>The Finite Elements form a Subring\<close>
huffman@27468
    72
huffman@27468
    73
lemma HFinite_hcmod_hcomplex_of_complex [simp]:
huffman@27468
    74
     "hcmod (hcomplex_of_complex r) \<in> HFinite"
huffman@27468
    75
by (auto intro!: SReal_subset_HFinite [THEN subsetD])
huffman@27468
    76
huffman@27468
    77
lemma HFinite_hcmod_iff: "(x \<in> HFinite) = (hcmod x \<in> HFinite)"
huffman@27468
    78
by (simp add: HFinite_def)
huffman@27468
    79
huffman@27468
    80
lemma HFinite_bounded_hcmod:
huffman@27468
    81
  "[|x \<in> HFinite; y \<le> hcmod x; 0 \<le> y |] ==> y: HFinite"
huffman@27468
    82
by (auto intro: HFinite_bounded simp add: HFinite_hcmod_iff)
huffman@27468
    83
huffman@27468
    84
wenzelm@61975
    85
subsection\<open>The Complex Infinitesimals form a Subring\<close>
huffman@27468
    86
huffman@27468
    87
lemma hcomplex_sum_of_halves: "x/(2::hcomplex) + x/(2::hcomplex) = x"
huffman@27468
    88
by auto
huffman@27468
    89
huffman@27468
    90
lemma Infinitesimal_hcmod_iff: 
huffman@27468
    91
   "(z \<in> Infinitesimal) = (hcmod z \<in> Infinitesimal)"
huffman@27468
    92
by (simp add: Infinitesimal_def)
huffman@27468
    93
huffman@27468
    94
lemma HInfinite_hcmod_iff: "(z \<in> HInfinite) = (hcmod z \<in> HInfinite)"
huffman@27468
    95
by (simp add: HInfinite_def)
huffman@27468
    96
huffman@27468
    97
lemma HFinite_diff_Infinitesimal_hcmod:
huffman@27468
    98
     "x \<in> HFinite - Infinitesimal ==> hcmod x \<in> HFinite - Infinitesimal"
huffman@27468
    99
by (simp add: HFinite_hcmod_iff Infinitesimal_hcmod_iff)
huffman@27468
   100
huffman@27468
   101
lemma hcmod_less_Infinitesimal:
huffman@27468
   102
     "[| e \<in> Infinitesimal; hcmod x < hcmod e |] ==> x \<in> Infinitesimal"
huffman@27468
   103
by (auto elim: hrabs_less_Infinitesimal simp add: Infinitesimal_hcmod_iff)
huffman@27468
   104
huffman@27468
   105
lemma hcmod_le_Infinitesimal:
huffman@27468
   106
     "[| e \<in> Infinitesimal; hcmod x \<le> hcmod e |] ==> x \<in> Infinitesimal"
huffman@27468
   107
by (auto elim: hrabs_le_Infinitesimal simp add: Infinitesimal_hcmod_iff)
huffman@27468
   108
huffman@27468
   109
lemma Infinitesimal_interval_hcmod:
huffman@27468
   110
     "[| e \<in> Infinitesimal;  
huffman@27468
   111
          e' \<in> Infinitesimal;  
huffman@27468
   112
          hcmod e' < hcmod x ; hcmod x < hcmod e  
huffman@27468
   113
       |] ==> x \<in> Infinitesimal"
huffman@27468
   114
by (auto intro: Infinitesimal_interval simp add: Infinitesimal_hcmod_iff)
huffman@27468
   115
huffman@27468
   116
lemma Infinitesimal_interval2_hcmod:
huffman@27468
   117
     "[| e \<in> Infinitesimal;  
huffman@27468
   118
         e' \<in> Infinitesimal;  
huffman@27468
   119
         hcmod e' \<le> hcmod x ; hcmod x \<le> hcmod e  
huffman@27468
   120
      |] ==> x \<in> Infinitesimal"
huffman@27468
   121
by (auto intro: Infinitesimal_interval2 simp add: Infinitesimal_hcmod_iff)
huffman@27468
   122
huffman@27468
   123
wenzelm@61975
   124
subsection\<open>The ``Infinitely Close'' Relation\<close>
huffman@27468
   125
huffman@27468
   126
(*
wenzelm@61982
   127
Goalw [capprox_def,approx_def] "(z @c= w) = (hcmod z \<approx> hcmod w)"
huffman@27468
   128
by (auto_tac (claset(),simpset() addsimps [Infinitesimal_hcmod_iff]));
huffman@27468
   129
*)
huffman@27468
   130
huffman@27468
   131
lemma approx_SComplex_mult_cancel_zero:
wenzelm@61982
   132
     "[| a \<in> SComplex; a \<noteq> 0; a*x \<approx> 0 |] ==> x \<approx> 0"
huffman@27468
   133
apply (drule Standard_inverse [THEN Standard_subset_HFinite [THEN subsetD]])
haftmann@57512
   134
apply (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
huffman@27468
   135
done
huffman@27468
   136
wenzelm@61982
   137
lemma approx_mult_SComplex1: "[| a \<in> SComplex; x \<approx> 0 |] ==> x*a \<approx> 0"
huffman@27468
   138
by (auto dest: Standard_subset_HFinite [THEN subsetD] approx_mult1)
huffman@27468
   139
wenzelm@61982
   140
lemma approx_mult_SComplex2: "[| a \<in> SComplex; x \<approx> 0 |] ==> a*x \<approx> 0"
huffman@27468
   141
by (auto dest: Standard_subset_HFinite [THEN subsetD] approx_mult2)
huffman@27468
   142
huffman@27468
   143
lemma approx_mult_SComplex_zero_cancel_iff [simp]:
wenzelm@61982
   144
     "[|a \<in> SComplex; a \<noteq> 0 |] ==> (a*x \<approx> 0) = (x \<approx> 0)"
huffman@27468
   145
by (blast intro: approx_SComplex_mult_cancel_zero approx_mult_SComplex2)
huffman@27468
   146
huffman@27468
   147
lemma approx_SComplex_mult_cancel:
wenzelm@61982
   148
     "[| a \<in> SComplex; a \<noteq> 0; a* w \<approx> a*z |] ==> w \<approx> z"
huffman@27468
   149
apply (drule Standard_inverse [THEN Standard_subset_HFinite [THEN subsetD]])
haftmann@57512
   150
apply (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
huffman@27468
   151
done
huffman@27468
   152
huffman@27468
   153
lemma approx_SComplex_mult_cancel_iff1 [simp]:
wenzelm@61982
   154
     "[| a \<in> SComplex; a \<noteq> 0|] ==> (a* w \<approx> a*z) = (w \<approx> z)"
huffman@27468
   155
by (auto intro!: approx_mult2 Standard_subset_HFinite [THEN subsetD]
huffman@27468
   156
            intro: approx_SComplex_mult_cancel)
huffman@27468
   157
huffman@27468
   158
(* TODO: generalize following theorems: hcmod -> hnorm *)
huffman@27468
   159
wenzelm@61982
   160
lemma approx_hcmod_approx_zero: "(x \<approx> y) = (hcmod (y - x) \<approx> 0)"
huffman@27468
   161
apply (subst hnorm_minus_commute)
haftmann@54230
   162
apply (simp add: approx_def Infinitesimal_hcmod_iff)
huffman@27468
   163
done
huffman@27468
   164
wenzelm@61982
   165
lemma approx_approx_zero_iff: "(x \<approx> 0) = (hcmod x \<approx> 0)"
huffman@27468
   166
by (simp add: approx_hcmod_approx_zero)
huffman@27468
   167
wenzelm@61982
   168
lemma approx_minus_zero_cancel_iff [simp]: "(-x \<approx> 0) = (x \<approx> 0)"
huffman@27468
   169
by (simp add: approx_def)
huffman@27468
   170
huffman@27468
   171
lemma Infinitesimal_hcmod_add_diff:
wenzelm@61982
   172
     "u \<approx> 0 ==> hcmod(x + u) - hcmod x \<in> Infinitesimal"
huffman@27468
   173
apply (drule approx_approx_zero_iff [THEN iffD1])
huffman@27468
   174
apply (rule_tac e = "hcmod u" and e' = "- hcmod u" in Infinitesimal_interval2)
haftmann@54230
   175
apply (auto simp add: mem_infmal_iff [symmetric])
huffman@27468
   176
apply (rule_tac c1 = "hcmod x" in add_le_cancel_left [THEN iffD1])
haftmann@54230
   177
apply auto
huffman@27468
   178
done
huffman@27468
   179
wenzelm@61982
   180
lemma approx_hcmod_add_hcmod: "u \<approx> 0 ==> hcmod(x + u) \<approx> hcmod x"
huffman@27468
   181
apply (rule approx_minus_iff [THEN iffD2])
haftmann@54230
   182
apply (auto intro: Infinitesimal_hcmod_add_diff simp add: mem_infmal_iff [symmetric])
huffman@27468
   183
done
huffman@27468
   184
huffman@27468
   185
wenzelm@61975
   186
subsection\<open>Zero is the Only Infinitesimal Complex Number\<close>
huffman@27468
   187
huffman@27468
   188
lemma Infinitesimal_less_SComplex:
huffman@27468
   189
   "[| x \<in> SComplex; y \<in> Infinitesimal; 0 < hcmod x |] ==> hcmod y < hcmod x"
lp15@59658
   190
by (auto intro: Infinitesimal_less_SReal SReal_hcmod_SComplex simp add: Infinitesimal_hcmod_iff)
huffman@27468
   191
huffman@27468
   192
lemma SComplex_Int_Infinitesimal_zero: "SComplex Int Infinitesimal = {0}"
huffman@27468
   193
by (auto simp add: Standard_def Infinitesimal_hcmod_iff)
huffman@27468
   194
huffman@27468
   195
lemma SComplex_Infinitesimal_zero:
huffman@27468
   196
     "[| x \<in> SComplex; x \<in> Infinitesimal|] ==> x = 0"
huffman@27468
   197
by (cut_tac SComplex_Int_Infinitesimal_zero, blast)
huffman@27468
   198
huffman@27468
   199
lemma SComplex_HFinite_diff_Infinitesimal:
huffman@27468
   200
     "[| x \<in> SComplex; x \<noteq> 0 |] ==> x \<in> HFinite - Infinitesimal"
huffman@27468
   201
by (auto dest: SComplex_Infinitesimal_zero Standard_subset_HFinite [THEN subsetD])
huffman@27468
   202
huffman@27468
   203
lemma hcomplex_of_complex_HFinite_diff_Infinitesimal:
huffman@27468
   204
     "hcomplex_of_complex x \<noteq> 0 
huffman@27468
   205
      ==> hcomplex_of_complex x \<in> HFinite - Infinitesimal"
huffman@27468
   206
by (rule SComplex_HFinite_diff_Infinitesimal, auto)
huffman@27468
   207
huffman@47108
   208
lemma numeral_not_Infinitesimal [simp]:
huffman@47108
   209
     "numeral w \<noteq> (0::hcomplex) ==> (numeral w::hcomplex) \<notin> Infinitesimal"
huffman@47108
   210
by (fast dest: Standard_numeral [THEN SComplex_Infinitesimal_zero])
huffman@27468
   211
huffman@27468
   212
lemma approx_SComplex_not_zero:
wenzelm@61982
   213
     "[| y \<in> SComplex; x \<approx> y; y\<noteq> 0 |] ==> x \<noteq> 0"
huffman@27468
   214
by (auto dest: SComplex_Infinitesimal_zero approx_sym [THEN mem_infmal_iff [THEN iffD2]])
huffman@27468
   215
huffman@27468
   216
lemma SComplex_approx_iff:
wenzelm@61982
   217
     "[|x \<in> SComplex; y \<in> SComplex|] ==> (x \<approx> y) = (x = y)"
huffman@27468
   218
by (auto simp add: Standard_def)
huffman@27468
   219
huffman@47108
   220
lemma numeral_Infinitesimal_iff [simp]:
huffman@47108
   221
     "((numeral w :: hcomplex) \<in> Infinitesimal) =
huffman@47108
   222
      (numeral w = (0::hcomplex))"
huffman@27468
   223
apply (rule iffI)
huffman@47108
   224
apply (fast dest: Standard_numeral [THEN SComplex_Infinitesimal_zero])
huffman@27468
   225
apply (simp (no_asm_simp))
huffman@27468
   226
done
huffman@27468
   227
huffman@27468
   228
lemma approx_unique_complex:
wenzelm@61982
   229
     "[| r \<in> SComplex; s \<in> SComplex; r \<approx> x; s \<approx> x|] ==> r = s"
huffman@27468
   230
by (blast intro: SComplex_approx_iff [THEN iffD1] approx_trans2)
huffman@27468
   231
wenzelm@61975
   232
subsection \<open>Properties of @{term hRe}, @{term hIm} and @{term HComplex}\<close>
huffman@27468
   233
huffman@27468
   234
huffman@27468
   235
lemma abs_hRe_le_hcmod: "\<And>x. \<bar>hRe x\<bar> \<le> hcmod x"
huffman@27468
   236
by transfer (rule abs_Re_le_cmod)
huffman@27468
   237
huffman@27468
   238
lemma abs_hIm_le_hcmod: "\<And>x. \<bar>hIm x\<bar> \<le> hcmod x"
huffman@27468
   239
by transfer (rule abs_Im_le_cmod)
huffman@27468
   240
huffman@27468
   241
lemma Infinitesimal_hRe: "x \<in> Infinitesimal \<Longrightarrow> hRe x \<in> Infinitesimal"
huffman@27468
   242
apply (rule InfinitesimalI2, simp)
huffman@27468
   243
apply (rule order_le_less_trans [OF abs_hRe_le_hcmod])
huffman@27468
   244
apply (erule (1) InfinitesimalD2)
huffman@27468
   245
done
huffman@27468
   246
huffman@27468
   247
lemma Infinitesimal_hIm: "x \<in> Infinitesimal \<Longrightarrow> hIm x \<in> Infinitesimal"
huffman@27468
   248
apply (rule InfinitesimalI2, simp)
huffman@27468
   249
apply (rule order_le_less_trans [OF abs_hIm_le_hcmod])
huffman@27468
   250
apply (erule (1) InfinitesimalD2)
huffman@27468
   251
done
huffman@27468
   252
wenzelm@53015
   253
lemma real_sqrt_lessI: "\<lbrakk>0 < u; x < u\<^sup>2\<rbrakk> \<Longrightarrow> sqrt x < u"
huffman@27468
   254
(* TODO: this belongs somewhere else *)
huffman@27468
   255
by (frule real_sqrt_less_mono) simp
huffman@27468
   256
huffman@27468
   257
lemma hypreal_sqrt_lessI:
wenzelm@53015
   258
  "\<And>x u. \<lbrakk>0 < u; x < u\<^sup>2\<rbrakk> \<Longrightarrow> ( *f* sqrt) x < u"
huffman@27468
   259
by transfer (rule real_sqrt_lessI)
huffman@27468
   260
 
huffman@27468
   261
lemma hypreal_sqrt_ge_zero: "\<And>x. 0 \<le> x \<Longrightarrow> 0 \<le> ( *f* sqrt) x"
huffman@27468
   262
by transfer (rule real_sqrt_ge_zero)
huffman@27468
   263
huffman@27468
   264
lemma Infinitesimal_sqrt:
huffman@27468
   265
  "\<lbrakk>x \<in> Infinitesimal; 0 \<le> x\<rbrakk> \<Longrightarrow> ( *f* sqrt) x \<in> Infinitesimal"
huffman@27468
   266
apply (rule InfinitesimalI2)
wenzelm@53015
   267
apply (drule_tac r="r\<^sup>2" in InfinitesimalD2, simp)
huffman@27468
   268
apply (simp add: hypreal_sqrt_ge_zero)
huffman@27468
   269
apply (rule hypreal_sqrt_lessI, simp_all)
huffman@27468
   270
done
huffman@27468
   271
huffman@27468
   272
lemma Infinitesimal_HComplex:
huffman@27468
   273
  "\<lbrakk>x \<in> Infinitesimal; y \<in> Infinitesimal\<rbrakk> \<Longrightarrow> HComplex x y \<in> Infinitesimal"
huffman@27468
   274
apply (rule Infinitesimal_hcmod_iff [THEN iffD2])
huffman@27468
   275
apply (simp add: hcmod_i)
huffman@27468
   276
apply (rule Infinitesimal_add)
huffman@27468
   277
apply (erule Infinitesimal_hrealpow, simp)
huffman@27468
   278
apply (erule Infinitesimal_hrealpow, simp)
huffman@27468
   279
done
huffman@27468
   280
huffman@27468
   281
lemma hcomplex_Infinitesimal_iff:
huffman@27468
   282
  "(x \<in> Infinitesimal) = (hRe x \<in> Infinitesimal \<and> hIm x \<in> Infinitesimal)"
huffman@27468
   283
apply (safe intro!: Infinitesimal_hRe Infinitesimal_hIm)
huffman@27468
   284
apply (drule (1) Infinitesimal_HComplex, simp)
huffman@27468
   285
done
huffman@27468
   286
huffman@27468
   287
lemma hRe_diff [simp]: "\<And>x y. hRe (x - y) = hRe x - hRe y"
hoelzl@56889
   288
by transfer simp
huffman@27468
   289
huffman@27468
   290
lemma hIm_diff [simp]: "\<And>x y. hIm (x - y) = hIm x - hIm y"
hoelzl@56889
   291
by transfer simp
huffman@27468
   292
huffman@27468
   293
lemma approx_hRe: "x \<approx> y \<Longrightarrow> hRe x \<approx> hRe y"
huffman@27468
   294
unfolding approx_def by (drule Infinitesimal_hRe) simp
huffman@27468
   295
huffman@27468
   296
lemma approx_hIm: "x \<approx> y \<Longrightarrow> hIm x \<approx> hIm y"
huffman@27468
   297
unfolding approx_def by (drule Infinitesimal_hIm) simp
huffman@27468
   298
huffman@27468
   299
lemma approx_HComplex:
huffman@27468
   300
  "\<lbrakk>a \<approx> b; c \<approx> d\<rbrakk> \<Longrightarrow> HComplex a c \<approx> HComplex b d"
huffman@27468
   301
unfolding approx_def by (simp add: Infinitesimal_HComplex)
huffman@27468
   302
huffman@27468
   303
lemma hcomplex_approx_iff:
huffman@27468
   304
  "(x \<approx> y) = (hRe x \<approx> hRe y \<and> hIm x \<approx> hIm y)"
huffman@27468
   305
unfolding approx_def by (simp add: hcomplex_Infinitesimal_iff)
huffman@27468
   306
huffman@27468
   307
lemma HFinite_hRe: "x \<in> HFinite \<Longrightarrow> hRe x \<in> HFinite"
huffman@27468
   308
apply (auto simp add: HFinite_def SReal_def)
huffman@27468
   309
apply (rule_tac x="star_of r" in exI, simp)
huffman@27468
   310
apply (erule order_le_less_trans [OF abs_hRe_le_hcmod])
huffman@27468
   311
done
huffman@27468
   312
huffman@27468
   313
lemma HFinite_hIm: "x \<in> HFinite \<Longrightarrow> hIm x \<in> HFinite"
huffman@27468
   314
apply (auto simp add: HFinite_def SReal_def)
huffman@27468
   315
apply (rule_tac x="star_of r" in exI, simp)
huffman@27468
   316
apply (erule order_le_less_trans [OF abs_hIm_le_hcmod])
huffman@27468
   317
done
huffman@27468
   318
huffman@27468
   319
lemma HFinite_HComplex:
huffman@27468
   320
  "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> HComplex x y \<in> HFinite"
huffman@27468
   321
apply (subgoal_tac "HComplex x 0 + HComplex 0 y \<in> HFinite", simp)
huffman@27468
   322
apply (rule HFinite_add)
huffman@27468
   323
apply (simp add: HFinite_hcmod_iff hcmod_i)
huffman@27468
   324
apply (simp add: HFinite_hcmod_iff hcmod_i)
huffman@27468
   325
done
huffman@27468
   326
huffman@27468
   327
lemma hcomplex_HFinite_iff:
huffman@27468
   328
  "(x \<in> HFinite) = (hRe x \<in> HFinite \<and> hIm x \<in> HFinite)"
huffman@27468
   329
apply (safe intro!: HFinite_hRe HFinite_hIm)
huffman@27468
   330
apply (drule (1) HFinite_HComplex, simp)
huffman@27468
   331
done
huffman@27468
   332
huffman@27468
   333
lemma hcomplex_HInfinite_iff:
huffman@27468
   334
  "(x \<in> HInfinite) = (hRe x \<in> HInfinite \<or> hIm x \<in> HInfinite)"
huffman@27468
   335
by (simp add: HInfinite_HFinite_iff hcomplex_HFinite_iff)
huffman@27468
   336
huffman@27468
   337
lemma hcomplex_of_hypreal_approx_iff [simp]:
wenzelm@61982
   338
     "(hcomplex_of_hypreal x \<approx> hcomplex_of_hypreal z) = (x \<approx> z)"
huffman@27468
   339
by (simp add: hcomplex_approx_iff)
huffman@27468
   340
huffman@27468
   341
lemma Standard_HComplex:
huffman@27468
   342
  "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> HComplex x y \<in> Standard"
huffman@27468
   343
by (simp add: HComplex_def)
huffman@27468
   344
huffman@27468
   345
(* Here we go - easy proof now!! *)
wenzelm@61982
   346
lemma stc_part_Ex: "x:HFinite ==> \<exists>t \<in> SComplex. x \<approx> t"
huffman@27468
   347
apply (simp add: hcomplex_HFinite_iff hcomplex_approx_iff)
huffman@27468
   348
apply (rule_tac x="HComplex (st (hRe x)) (st (hIm x))" in bexI)
huffman@27468
   349
apply (simp add: st_approx_self [THEN approx_sym])
huffman@27468
   350
apply (simp add: Standard_HComplex st_SReal [unfolded Reals_eq_Standard])
huffman@27468
   351
done
huffman@27468
   352
wenzelm@63901
   353
lemma stc_part_Ex1: "x:HFinite ==> \<exists>!t. t \<in> SComplex &  x \<approx> t"
huffman@27468
   354
apply (drule stc_part_Ex, safe)
huffman@27468
   355
apply (drule_tac [2] approx_sym, drule_tac [2] approx_sym, drule_tac [2] approx_sym)
huffman@27468
   356
apply (auto intro!: approx_unique_complex)
huffman@27468
   357
done
huffman@27468
   358
huffman@27468
   359
lemmas hcomplex_of_complex_approx_inverse =
huffman@27468
   360
  hcomplex_of_complex_HFinite_diff_Infinitesimal [THEN [2] approx_inverse]
huffman@27468
   361
huffman@27468
   362
wenzelm@61975
   363
subsection\<open>Theorems About Monads\<close>
huffman@27468
   364
huffman@27468
   365
lemma monad_zero_hcmod_iff: "(x \<in> monad 0) = (hcmod x:monad 0)"
huffman@27468
   366
by (simp add: Infinitesimal_monad_zero_iff [symmetric] Infinitesimal_hcmod_iff)
huffman@27468
   367
huffman@27468
   368
wenzelm@61975
   369
subsection\<open>Theorems About Standard Part\<close>
huffman@27468
   370
wenzelm@61982
   371
lemma stc_approx_self: "x \<in> HFinite ==> stc x \<approx> x"
huffman@27468
   372
apply (simp add: stc_def)
huffman@27468
   373
apply (frule stc_part_Ex, safe)
huffman@27468
   374
apply (rule someI2)
huffman@27468
   375
apply (auto intro: approx_sym)
huffman@27468
   376
done
huffman@27468
   377
huffman@27468
   378
lemma stc_SComplex: "x \<in> HFinite ==> stc x \<in> SComplex"
huffman@27468
   379
apply (simp add: stc_def)
huffman@27468
   380
apply (frule stc_part_Ex, safe)
huffman@27468
   381
apply (rule someI2)
huffman@27468
   382
apply (auto intro: approx_sym)
huffman@27468
   383
done
huffman@27468
   384
huffman@27468
   385
lemma stc_HFinite: "x \<in> HFinite ==> stc x \<in> HFinite"
huffman@27468
   386
by (erule stc_SComplex [THEN Standard_subset_HFinite [THEN subsetD]])
huffman@27468
   387
huffman@27468
   388
lemma stc_unique: "\<lbrakk>y \<in> SComplex; y \<approx> x\<rbrakk> \<Longrightarrow> stc x = y"
huffman@27468
   389
apply (frule Standard_subset_HFinite [THEN subsetD])
huffman@27468
   390
apply (drule (1) approx_HFinite)
huffman@27468
   391
apply (unfold stc_def)
huffman@27468
   392
apply (rule some_equality)
huffman@27468
   393
apply (auto intro: approx_unique_complex)
huffman@27468
   394
done
huffman@27468
   395
huffman@27468
   396
lemma stc_SComplex_eq [simp]: "x \<in> SComplex ==> stc x = x"
huffman@27468
   397
apply (erule stc_unique)
huffman@27468
   398
apply (rule approx_refl)
huffman@27468
   399
done
huffman@27468
   400
huffman@27468
   401
lemma stc_hcomplex_of_complex:
huffman@27468
   402
     "stc (hcomplex_of_complex x) = hcomplex_of_complex x"
huffman@27468
   403
by auto
huffman@27468
   404
huffman@27468
   405
lemma stc_eq_approx:
wenzelm@61982
   406
     "[| x \<in> HFinite; y \<in> HFinite; stc x = stc y |] ==> x \<approx> y"
huffman@27468
   407
by (auto dest!: stc_approx_self elim!: approx_trans3)
huffman@27468
   408
huffman@27468
   409
lemma approx_stc_eq:
wenzelm@61982
   410
     "[| x \<in> HFinite; y \<in> HFinite; x \<approx> y |] ==> stc x = stc y"
huffman@27468
   411
by (blast intro: approx_trans approx_trans2 SComplex_approx_iff [THEN iffD1]
huffman@27468
   412
          dest: stc_approx_self stc_SComplex)
huffman@27468
   413
huffman@27468
   414
lemma stc_eq_approx_iff:
wenzelm@61982
   415
     "[| x \<in> HFinite; y \<in> HFinite|] ==> (x \<approx> y) = (stc x = stc y)"
huffman@27468
   416
by (blast intro: approx_stc_eq stc_eq_approx)
huffman@27468
   417
huffman@27468
   418
lemma stc_Infinitesimal_add_SComplex:
huffman@27468
   419
     "[| x \<in> SComplex; e \<in> Infinitesimal |] ==> stc(x + e) = x"
huffman@27468
   420
apply (erule stc_unique)
huffman@27468
   421
apply (erule Infinitesimal_add_approx_self)
huffman@27468
   422
done
huffman@27468
   423
huffman@27468
   424
lemma stc_Infinitesimal_add_SComplex2:
huffman@27468
   425
     "[| x \<in> SComplex; e \<in> Infinitesimal |] ==> stc(e + x) = x"
huffman@27468
   426
apply (erule stc_unique)
huffman@27468
   427
apply (erule Infinitesimal_add_approx_self2)
huffman@27468
   428
done
huffman@27468
   429
huffman@27468
   430
lemma HFinite_stc_Infinitesimal_add:
huffman@27468
   431
     "x \<in> HFinite ==> \<exists>e \<in> Infinitesimal. x = stc(x) + e"
huffman@27468
   432
by (blast dest!: stc_approx_self [THEN approx_sym] bex_Infinitesimal_iff2 [THEN iffD2])
huffman@27468
   433
huffman@27468
   434
lemma stc_add:
huffman@27468
   435
     "[| x \<in> HFinite; y \<in> HFinite |] ==> stc (x + y) = stc(x) + stc(y)"
huffman@27468
   436
by (simp add: stc_unique stc_SComplex stc_approx_self approx_add)
huffman@27468
   437
huffman@47108
   438
lemma stc_numeral [simp]: "stc (numeral w) = numeral w"
huffman@47108
   439
by (rule Standard_numeral [THEN stc_SComplex_eq])
huffman@27468
   440
huffman@27468
   441
lemma stc_zero [simp]: "stc 0 = 0"
huffman@27468
   442
by simp
huffman@27468
   443
huffman@27468
   444
lemma stc_one [simp]: "stc 1 = 1"
huffman@27468
   445
by simp
huffman@27468
   446
huffman@27468
   447
lemma stc_minus: "y \<in> HFinite ==> stc(-y) = -stc(y)"
huffman@27468
   448
by (simp add: stc_unique stc_SComplex stc_approx_self approx_minus)
huffman@27468
   449
huffman@27468
   450
lemma stc_diff: 
huffman@27468
   451
     "[| x \<in> HFinite; y \<in> HFinite |] ==> stc (x-y) = stc(x) - stc(y)"
huffman@27468
   452
by (simp add: stc_unique stc_SComplex stc_approx_self approx_diff)
huffman@27468
   453
huffman@27468
   454
lemma stc_mult:
huffman@27468
   455
     "[| x \<in> HFinite; y \<in> HFinite |]  
huffman@27468
   456
               ==> stc (x * y) = stc(x) * stc(y)"
huffman@27468
   457
by (simp add: stc_unique stc_SComplex stc_approx_self approx_mult_HFinite)
huffman@27468
   458
huffman@27468
   459
lemma stc_Infinitesimal: "x \<in> Infinitesimal ==> stc x = 0"
huffman@27468
   460
by (simp add: stc_unique mem_infmal_iff)
huffman@27468
   461
huffman@27468
   462
lemma stc_not_Infinitesimal: "stc(x) \<noteq> 0 ==> x \<notin> Infinitesimal"
huffman@27468
   463
by (fast intro: stc_Infinitesimal)
huffman@27468
   464
huffman@27468
   465
lemma stc_inverse:
huffman@27468
   466
     "[| x \<in> HFinite; stc x \<noteq> 0 |]  
huffman@27468
   467
      ==> stc(inverse x) = inverse (stc x)"
huffman@27468
   468
apply (drule stc_not_Infinitesimal)
huffman@27468
   469
apply (simp add: stc_unique stc_SComplex stc_approx_self approx_inverse)
huffman@27468
   470
done
huffman@27468
   471
huffman@27468
   472
lemma stc_divide [simp]:
huffman@27468
   473
     "[| x \<in> HFinite; y \<in> HFinite; stc y \<noteq> 0 |]  
huffman@27468
   474
      ==> stc(x/y) = (stc x) / (stc y)"
huffman@27468
   475
by (simp add: divide_inverse stc_mult stc_not_Infinitesimal HFinite_inverse stc_inverse)
huffman@27468
   476
huffman@27468
   477
lemma stc_idempotent [simp]: "x \<in> HFinite ==> stc(stc(x)) = stc(x)"
huffman@27468
   478
by (blast intro: stc_HFinite stc_approx_self approx_stc_eq)
huffman@27468
   479
huffman@27468
   480
lemma HFinite_HFinite_hcomplex_of_hypreal:
huffman@27468
   481
     "z \<in> HFinite ==> hcomplex_of_hypreal z \<in> HFinite"
huffman@27468
   482
by (simp add: hcomplex_HFinite_iff)
huffman@27468
   483
huffman@27468
   484
lemma SComplex_SReal_hcomplex_of_hypreal:
wenzelm@61070
   485
     "x \<in> \<real> ==>  hcomplex_of_hypreal x \<in> SComplex"
huffman@27468
   486
apply (rule Standard_of_hypreal)
huffman@27468
   487
apply (simp add: Reals_eq_Standard)
huffman@27468
   488
done
huffman@27468
   489
huffman@27468
   490
lemma stc_hcomplex_of_hypreal: 
huffman@27468
   491
 "z \<in> HFinite ==> stc(hcomplex_of_hypreal z) = hcomplex_of_hypreal (st z)"
huffman@27468
   492
apply (rule stc_unique)
huffman@27468
   493
apply (rule SComplex_SReal_hcomplex_of_hypreal)
huffman@27468
   494
apply (erule st_SReal)
huffman@27468
   495
apply (simp add: hcomplex_of_hypreal_approx_iff st_approx_self)
huffman@27468
   496
done
huffman@27468
   497
huffman@27468
   498
(*
huffman@27468
   499
Goal "x \<in> HFinite ==> hcmod(stc x) = st(hcmod x)"
huffman@27468
   500
by (dtac stc_approx_self 1)
huffman@27468
   501
by (auto_tac (claset(),simpset() addsimps [bex_Infinitesimal_iff2 RS sym]));
huffman@27468
   502
huffman@27468
   503
huffman@27468
   504
approx_hcmod_add_hcmod
huffman@27468
   505
*)
huffman@27468
   506
huffman@27468
   507
lemma Infinitesimal_hcnj_iff [simp]:
huffman@27468
   508
     "(hcnj z \<in> Infinitesimal) = (z \<in> Infinitesimal)"
huffman@27468
   509
by (simp add: Infinitesimal_hcmod_iff)
huffman@27468
   510
huffman@27468
   511
lemma Infinitesimal_hcomplex_of_hypreal_epsilon [simp]:
wenzelm@61981
   512
     "hcomplex_of_hypreal \<epsilon> \<in> Infinitesimal"
huffman@27468
   513
by (simp add: Infinitesimal_hcmod_iff)
huffman@27468
   514
huffman@27468
   515
end