src/HOL/Hyperreal/HyperDef.thy
author paulson
Mon Mar 15 10:46:19 2004 +0100 (2004-03-15)
changeset 14468 6be497cacab5
parent 14430 5cb24165a2e1
child 14477 cc61fd03e589
permissions -rw-r--r--
heavy tidying
paulson@10751
     1
(*  Title       : HOL/Real/Hyperreal/HyperDef.thy
paulson@10751
     2
    ID          : $Id$
paulson@10751
     3
    Author      : Jacques D. Fleuriot
paulson@10751
     4
    Copyright   : 1998  University of Cambridge
paulson@14468
     5
    Conversion to Isar and new proofs by Lawrence C Paulson, 2004
wenzelm@13487
     6
*)
paulson@10751
     7
paulson@14468
     8
header{*Construction of Hyperreals Using Ultrafilters*}
paulson@14468
     9
paulson@14299
    10
theory HyperDef = Filter + Real
paulson@14299
    11
files ("fuf.ML"):  (*Warning: file fuf.ML refers to the name Hyperdef!*)
paulson@10751
    12
paulson@10751
    13
paulson@10751
    14
constdefs
paulson@14299
    15
schirmer@14361
    16
  FreeUltrafilterNat   :: "nat set set"    ("\<U>")
paulson@14299
    17
    "FreeUltrafilterNat == (SOME U. U \<in> FreeUltrafilter (UNIV:: nat set))"
paulson@14299
    18
paulson@14299
    19
  hyprel :: "((nat=>real)*(nat=>real)) set"
paulson@14299
    20
    "hyprel == {p. \<exists>X Y. p = ((X::nat=>real),Y) &
paulson@10751
    21
                   {n::nat. X(n) = Y(n)}: FreeUltrafilterNat}"
paulson@10751
    22
paulson@14299
    23
typedef hypreal = "UNIV//hyprel" 
paulson@14299
    24
    by (auto simp add: quotient_def) 
paulson@10751
    25
paulson@14299
    26
instance hypreal :: ord ..
paulson@14299
    27
instance hypreal :: zero ..
paulson@14299
    28
instance hypreal :: one ..
paulson@14299
    29
instance hypreal :: plus ..
paulson@14299
    30
instance hypreal :: times ..
paulson@14299
    31
instance hypreal :: minus ..
paulson@14299
    32
instance hypreal :: inverse ..
paulson@10751
    33
paulson@10751
    34
paulson@14299
    35
defs (overloaded)
paulson@14299
    36
paulson@14299
    37
  hypreal_zero_def:
paulson@12018
    38
  "0 == Abs_hypreal(hyprel``{%n::nat. (0::real)})"
paulson@10751
    39
paulson@14299
    40
  hypreal_one_def:
paulson@12018
    41
  "1 == Abs_hypreal(hyprel``{%n::nat. (1::real)})"
paulson@10751
    42
paulson@14299
    43
  hypreal_minus_def:
paulson@14299
    44
  "- P == Abs_hypreal(\<Union>X \<in> Rep_hypreal(P). hyprel``{%n::nat. - (X n)})"
paulson@10751
    45
paulson@14299
    46
  hypreal_diff_def:
paulson@10751
    47
  "x - y == x + -(y::hypreal)"
paulson@10751
    48
paulson@14299
    49
  hypreal_inverse_def:
paulson@14299
    50
  "inverse P == Abs_hypreal(\<Union>X \<in> Rep_hypreal(P).
paulson@12018
    51
                    hyprel``{%n. if X n = 0 then 0 else inverse (X n)})"
paulson@10751
    52
paulson@14299
    53
  hypreal_divide_def:
paulson@10751
    54
  "P / Q::hypreal == P * inverse Q"
wenzelm@13487
    55
paulson@10751
    56
constdefs
paulson@10751
    57
paulson@14299
    58
  hypreal_of_real  :: "real => hypreal"
nipkow@10834
    59
  "hypreal_of_real r         == Abs_hypreal(hyprel``{%n::nat. r})"
paulson@10751
    60
paulson@10919
    61
  omega   :: hypreal   (*an infinite number = [<1,2,3,...>] *)
paulson@10919
    62
  "omega == Abs_hypreal(hyprel``{%n::nat. real (Suc n)})"
wenzelm@13487
    63
paulson@10919
    64
  epsilon :: hypreal   (*an infinitesimal number = [<1,1/2,1/3,...>] *)
paulson@10919
    65
  "epsilon == Abs_hypreal(hyprel``{%n::nat. inverse (real (Suc n))})"
paulson@10919
    66
paulson@10919
    67
syntax (xsymbols)
paulson@14299
    68
  omega   :: hypreal   ("\<omega>")
paulson@14299
    69
  epsilon :: hypreal   ("\<epsilon>")
paulson@10919
    70
paulson@10751
    71
paulson@14370
    72
defs (overloaded)
wenzelm@13487
    73
paulson@14299
    74
  hypreal_add_def:
paulson@14299
    75
  "P + Q == Abs_hypreal(\<Union>X \<in> Rep_hypreal(P). \<Union>Y \<in> Rep_hypreal(Q).
nipkow@10834
    76
                hyprel``{%n::nat. X n + Y n})"
paulson@10751
    77
paulson@14299
    78
  hypreal_mult_def:
paulson@14299
    79
  "P * Q == Abs_hypreal(\<Union>X \<in> Rep_hypreal(P). \<Union>Y \<in> Rep_hypreal(Q).
nipkow@10834
    80
                hyprel``{%n::nat. X n * Y n})"
paulson@10751
    81
paulson@14370
    82
  hypreal_le_def:
paulson@14370
    83
  "P \<le> (Q::hypreal) == \<exists>X Y. X \<in> Rep_hypreal(P) &
paulson@14299
    84
                               Y \<in> Rep_hypreal(Q) &
paulson@14370
    85
                               {n::nat. X n \<le> Y n} \<in> FreeUltrafilterNat"
paulson@14370
    86
paulson@14370
    87
  hypreal_less_def: "(x < (y::hypreal)) == (x \<le> y & x \<noteq> y)"
paulson@10751
    88
paulson@14329
    89
  hrabs_def:  "abs (r::hypreal) == (if 0 \<le> r then r else -r)"
paulson@14329
    90
paulson@14329
    91
paulson@14329
    92
subsection{*The Set of Naturals is not Finite*}
paulson@14299
    93
paulson@14299
    94
(*** based on James' proof that the set of naturals is not finite ***)
paulson@14329
    95
lemma finite_exhausts [rule_format]:
paulson@14329
    96
     "finite (A::nat set) --> (\<exists>n. \<forall>m. Suc (n + m) \<notin> A)"
paulson@14299
    97
apply (rule impI)
paulson@14301
    98
apply (erule_tac F = A in finite_induct)
paulson@14301
    99
apply (blast, erule exE)
paulson@14299
   100
apply (rule_tac x = "n + x" in exI)
paulson@14301
   101
apply (rule allI, erule_tac x = "x + m" in allE)
paulson@14299
   102
apply (auto simp add: add_ac)
paulson@14299
   103
done
paulson@14299
   104
paulson@14329
   105
lemma finite_not_covers [rule_format (no_asm)]:
paulson@14329
   106
     "finite (A :: nat set) --> (\<exists>n. n \<notin>A)"
paulson@14301
   107
by (rule impI, drule finite_exhausts, blast)
paulson@14299
   108
paulson@14299
   109
lemma not_finite_nat: "~ finite(UNIV:: nat set)"
paulson@14301
   110
by (fast dest!: finite_exhausts)
paulson@14299
   111
paulson@14329
   112
paulson@14329
   113
subsection{*Existence of Free Ultrafilter over the Naturals*}
paulson@14329
   114
paulson@14329
   115
text{*Also, proof of various properties of @{term FreeUltrafilterNat}: 
paulson@14329
   116
an arbitrary free ultrafilter*}
paulson@14299
   117
paulson@14299
   118
lemma FreeUltrafilterNat_Ex: "\<exists>U. U: FreeUltrafilter (UNIV::nat set)"
paulson@14301
   119
by (rule not_finite_nat [THEN FreeUltrafilter_Ex])
paulson@14299
   120
paulson@14301
   121
lemma FreeUltrafilterNat_mem [simp]: 
paulson@14299
   122
     "FreeUltrafilterNat: FreeUltrafilter(UNIV:: nat set)"
paulson@14299
   123
apply (unfold FreeUltrafilterNat_def)
paulson@14299
   124
apply (rule FreeUltrafilterNat_Ex [THEN exE])
paulson@14301
   125
apply (rule someI2, assumption+)
paulson@14299
   126
done
paulson@14299
   127
paulson@14299
   128
lemma FreeUltrafilterNat_finite: "finite x ==> x \<notin> FreeUltrafilterNat"
paulson@14299
   129
apply (unfold FreeUltrafilterNat_def)
paulson@14299
   130
apply (rule FreeUltrafilterNat_Ex [THEN exE])
paulson@14301
   131
apply (rule someI2, assumption)
paulson@14299
   132
apply (blast dest: mem_FreeUltrafiltersetD1)
paulson@14299
   133
done
paulson@14299
   134
paulson@14299
   135
lemma FreeUltrafilterNat_not_finite: "x: FreeUltrafilterNat ==> ~ finite x"
paulson@14301
   136
by (blast dest: FreeUltrafilterNat_finite)
paulson@14299
   137
paulson@14301
   138
lemma FreeUltrafilterNat_empty [simp]: "{} \<notin> FreeUltrafilterNat"
paulson@14299
   139
apply (unfold FreeUltrafilterNat_def)
paulson@14299
   140
apply (rule FreeUltrafilterNat_Ex [THEN exE])
paulson@14301
   141
apply (rule someI2, assumption)
paulson@14301
   142
apply (blast dest: FreeUltrafilter_Ultrafilter Ultrafilter_Filter 
paulson@14301
   143
                   Filter_empty_not_mem)
paulson@14299
   144
done
paulson@14299
   145
paulson@14329
   146
lemma FreeUltrafilterNat_Int:
paulson@14329
   147
     "[| X: FreeUltrafilterNat;  Y: FreeUltrafilterNat |]   
paulson@14299
   148
      ==> X Int Y \<in> FreeUltrafilterNat"
paulson@14299
   149
apply (cut_tac FreeUltrafilterNat_mem)
paulson@14299
   150
apply (blast dest: FreeUltrafilter_Ultrafilter Ultrafilter_Filter mem_FiltersetD1)
paulson@14299
   151
done
paulson@14299
   152
paulson@14329
   153
lemma FreeUltrafilterNat_subset:
paulson@14365
   154
     "[| X: FreeUltrafilterNat;  X \<subseteq> Y |]  
paulson@14299
   155
      ==> Y \<in> FreeUltrafilterNat"
paulson@14299
   156
apply (cut_tac FreeUltrafilterNat_mem)
paulson@14299
   157
apply (blast dest: FreeUltrafilter_Ultrafilter Ultrafilter_Filter mem_FiltersetD2)
paulson@14299
   158
done
paulson@14299
   159
paulson@14329
   160
lemma FreeUltrafilterNat_Compl:
paulson@14329
   161
     "X: FreeUltrafilterNat ==> -X \<notin> FreeUltrafilterNat"
paulson@14301
   162
apply safe
paulson@14301
   163
apply (drule FreeUltrafilterNat_Int, assumption, auto)
paulson@14299
   164
done
paulson@14299
   165
paulson@14329
   166
lemma FreeUltrafilterNat_Compl_mem:
paulson@14329
   167
     "X\<notin> FreeUltrafilterNat ==> -X \<in> FreeUltrafilterNat"
paulson@14299
   168
apply (cut_tac FreeUltrafilterNat_mem [THEN FreeUltrafilter_iff [THEN iffD1]])
paulson@14301
   169
apply (safe, drule_tac x = X in bspec)
paulson@14299
   170
apply (auto simp add: UNIV_diff_Compl)
paulson@14299
   171
done
paulson@14299
   172
paulson@14329
   173
lemma FreeUltrafilterNat_Compl_iff1:
paulson@14329
   174
     "(X \<notin> FreeUltrafilterNat) = (-X: FreeUltrafilterNat)"
paulson@14301
   175
by (blast dest: FreeUltrafilterNat_Compl FreeUltrafilterNat_Compl_mem)
paulson@14299
   176
paulson@14329
   177
lemma FreeUltrafilterNat_Compl_iff2:
paulson@14329
   178
     "(X: FreeUltrafilterNat) = (-X \<notin> FreeUltrafilterNat)"
paulson@14301
   179
by (auto simp add: FreeUltrafilterNat_Compl_iff1 [symmetric])
paulson@14299
   180
paulson@14378
   181
lemma cofinite_mem_FreeUltrafilterNat: "finite (-X) ==> X \<in> FreeUltrafilterNat"
paulson@14378
   182
apply (drule FreeUltrafilterNat_finite)  
paulson@14378
   183
apply (simp add: FreeUltrafilterNat_Compl_iff2 [symmetric])
paulson@14378
   184
done
paulson@14378
   185
paulson@14301
   186
lemma FreeUltrafilterNat_UNIV [simp]: "(UNIV::nat set) \<in> FreeUltrafilterNat"
paulson@14301
   187
by (rule FreeUltrafilterNat_mem [THEN FreeUltrafilter_Ultrafilter, THEN Ultrafilter_Filter, THEN mem_FiltersetD4])
paulson@14299
   188
paulson@14301
   189
lemma FreeUltrafilterNat_Nat_set [simp]: "UNIV \<in> FreeUltrafilterNat"
paulson@14301
   190
by auto
paulson@14299
   191
paulson@14329
   192
lemma FreeUltrafilterNat_Nat_set_refl [intro]:
paulson@14329
   193
     "{n. P(n) = P(n)} \<in> FreeUltrafilterNat"
paulson@14301
   194
by simp
paulson@14299
   195
paulson@14299
   196
lemma FreeUltrafilterNat_P: "{n::nat. P} \<in> FreeUltrafilterNat ==> P"
paulson@14301
   197
by (rule ccontr, simp)
paulson@14299
   198
paulson@14299
   199
lemma FreeUltrafilterNat_Ex_P: "{n. P(n)} \<in> FreeUltrafilterNat ==> \<exists>n. P(n)"
paulson@14301
   200
by (rule ccontr, simp)
paulson@14299
   201
paulson@14299
   202
lemma FreeUltrafilterNat_all: "\<forall>n. P(n) ==> {n. P(n)} \<in> FreeUltrafilterNat"
paulson@14301
   203
by (auto intro: FreeUltrafilterNat_Nat_set)
paulson@14299
   204
paulson@14329
   205
paulson@14329
   206
text{*Define and use Ultrafilter tactics*}
paulson@14299
   207
use "fuf.ML"
paulson@14299
   208
paulson@14299
   209
method_setup fuf = {*
paulson@14299
   210
    Method.ctxt_args (fn ctxt =>
paulson@14299
   211
        Method.METHOD (fn facts =>
paulson@14299
   212
            fuf_tac (Classical.get_local_claset ctxt,
paulson@14299
   213
                     Simplifier.get_local_simpset ctxt) 1)) *}
paulson@14299
   214
    "free ultrafilter tactic"
paulson@14299
   215
paulson@14299
   216
method_setup ultra = {*
paulson@14299
   217
    Method.ctxt_args (fn ctxt =>
paulson@14299
   218
        Method.METHOD (fn facts =>
paulson@14299
   219
            ultra_tac (Classical.get_local_claset ctxt,
paulson@14299
   220
                       Simplifier.get_local_simpset ctxt) 1)) *}
paulson@14299
   221
    "ultrafilter tactic"
paulson@14299
   222
paulson@14299
   223
paulson@14329
   224
text{*One further property of our free ultrafilter*}
paulson@14329
   225
lemma FreeUltrafilterNat_Un:
paulson@14329
   226
     "X Un Y: FreeUltrafilterNat  
paulson@14299
   227
      ==> X: FreeUltrafilterNat | Y: FreeUltrafilterNat"
paulson@14299
   228
apply auto
paulson@14301
   229
apply ultra
paulson@14299
   230
done
paulson@14299
   231
paulson@14299
   232
paulson@14329
   233
subsection{*Properties of @{term hyprel}*}
paulson@14329
   234
paulson@14329
   235
text{*Proving that @{term hyprel} is an equivalence relation*}
paulson@14299
   236
paulson@14365
   237
lemma hyprel_iff: "((X,Y) \<in> hyprel) = ({n. X n = Y n}: FreeUltrafilterNat)"
paulson@14468
   238
by (simp add: hyprel_def)
paulson@14299
   239
paulson@14365
   240
lemma hyprel_refl: "(x,x) \<in> hyprel"
paulson@14468
   241
by (simp add: hyprel_def)
paulson@14299
   242
paulson@14365
   243
lemma hyprel_sym [rule_format (no_asm)]: "(x,y) \<in> hyprel --> (y,x) \<in> hyprel"
paulson@14301
   244
by (simp add: hyprel_def eq_commute)
paulson@14299
   245
paulson@14299
   246
lemma hyprel_trans: 
paulson@14365
   247
      "[|(x,y) \<in> hyprel; (y,z) \<in> hyprel|] ==> (x,z) \<in> hyprel"
paulson@14468
   248
by (simp add: hyprel_def, ultra)
paulson@14299
   249
paulson@14299
   250
lemma equiv_hyprel: "equiv UNIV hyprel"
paulson@14299
   251
apply (simp add: equiv_def refl_def sym_def trans_def hyprel_refl)
paulson@14299
   252
apply (blast intro: hyprel_sym hyprel_trans) 
paulson@14299
   253
done
paulson@14299
   254
paulson@14299
   255
(* (hyprel `` {x} = hyprel `` {y}) = ((x,y) \<in> hyprel) *)
paulson@14299
   256
lemmas equiv_hyprel_iff =
paulson@14299
   257
    eq_equiv_class_iff [OF equiv_hyprel UNIV_I UNIV_I, simp] 
paulson@14299
   258
paulson@14301
   259
lemma hyprel_in_hypreal [simp]: "hyprel``{x}:hypreal"
paulson@14468
   260
by (simp add: hypreal_def hyprel_def quotient_def, blast)
paulson@14299
   261
paulson@14299
   262
lemma inj_on_Abs_hypreal: "inj_on Abs_hypreal hypreal"
paulson@14299
   263
apply (rule inj_on_inverseI)
paulson@14299
   264
apply (erule Abs_hypreal_inverse)
paulson@14299
   265
done
paulson@14299
   266
paulson@14299
   267
declare inj_on_Abs_hypreal [THEN inj_on_iff, simp] 
paulson@14301
   268
        Abs_hypreal_inverse [simp]
paulson@14299
   269
paulson@14299
   270
declare equiv_hyprel [THEN eq_equiv_class_iff, simp]
paulson@14299
   271
paulson@14299
   272
declare hyprel_iff [iff]
paulson@14299
   273
paulson@14299
   274
lemmas eq_hyprelD = eq_equiv_class [OF _ equiv_hyprel]
paulson@14299
   275
paulson@14299
   276
lemma inj_Rep_hypreal: "inj(Rep_hypreal)"
paulson@14299
   277
apply (rule inj_on_inverseI)
paulson@14299
   278
apply (rule Rep_hypreal_inverse)
paulson@14299
   279
done
paulson@14299
   280
paulson@14301
   281
lemma lemma_hyprel_refl [simp]: "x \<in> hyprel `` {x}"
paulson@14468
   282
by (simp add: hyprel_def)
paulson@14299
   283
paulson@14301
   284
lemma hypreal_empty_not_mem [simp]: "{} \<notin> hypreal"
paulson@14468
   285
apply (simp add: hypreal_def)
paulson@14299
   286
apply (auto elim!: quotientE equalityCE)
paulson@14299
   287
done
paulson@14299
   288
paulson@14301
   289
lemma Rep_hypreal_nonempty [simp]: "Rep_hypreal x \<noteq> {}"
paulson@14301
   290
by (cut_tac x = x in Rep_hypreal, auto)
paulson@14299
   291
paulson@14299
   292
paulson@14329
   293
subsection{*@{term hypreal_of_real}: 
paulson@14329
   294
            the Injection from @{typ real} to @{typ hypreal}*}
paulson@14299
   295
paulson@14299
   296
lemma inj_hypreal_of_real: "inj(hypreal_of_real)"
paulson@14299
   297
apply (rule inj_onI)
paulson@14468
   298
apply (simp add: hypreal_of_real_def split: split_if_asm)
paulson@14299
   299
done
paulson@14299
   300
paulson@14299
   301
lemma eq_Abs_hypreal:
paulson@14468
   302
    "(!!x. z = Abs_hypreal(hyprel``{x}) ==> P) ==> P"
paulson@14299
   303
apply (rule_tac x1=z in Rep_hypreal [unfolded hypreal_def, THEN quotientE])
paulson@14301
   304
apply (drule_tac f = Abs_hypreal in arg_cong)
paulson@14299
   305
apply (force simp add: Rep_hypreal_inverse)
paulson@14299
   306
done
paulson@14299
   307
paulson@14468
   308
theorem hypreal_cases [case_names Abs_hypreal, cases type: hypreal]:
paulson@14468
   309
    "(!!x. z = Abs_hypreal(hyprel``{x}) ==> P) ==> P"
paulson@14468
   310
by (rule eq_Abs_hypreal [of z], blast)
paulson@14468
   311
paulson@14329
   312
paulson@14329
   313
subsection{*Hyperreal Addition*}
paulson@14329
   314
paulson@14329
   315
lemma hypreal_add_congruent2: 
paulson@14329
   316
    "congruent2 hyprel (%X Y. hyprel``{%n. X n + Y n})"
paulson@14468
   317
apply (simp add: congruent2_def, auto, ultra)
paulson@14329
   318
done
paulson@14329
   319
paulson@14329
   320
lemma hypreal_add: 
paulson@14329
   321
  "Abs_hypreal(hyprel``{%n. X n}) + Abs_hypreal(hyprel``{%n. Y n}) =  
paulson@14329
   322
   Abs_hypreal(hyprel``{%n. X n + Y n})"
paulson@14468
   323
apply (simp add: hypreal_add_def)
paulson@14329
   324
apply (simp add: UN_equiv_class2 [OF equiv_hyprel hypreal_add_congruent2])
paulson@14329
   325
done
paulson@14329
   326
paulson@14329
   327
lemma hypreal_add_commute: "(z::hypreal) + w = w + z"
paulson@14468
   328
apply (cases z, cases w)
paulson@14334
   329
apply (simp add: add_ac hypreal_add)
paulson@14329
   330
done
paulson@14329
   331
paulson@14329
   332
lemma hypreal_add_assoc: "((z1::hypreal) + z2) + z3 = z1 + (z2 + z3)"
paulson@14468
   333
apply (cases z1, cases z2, cases z3)
paulson@14329
   334
apply (simp add: hypreal_add real_add_assoc)
paulson@14329
   335
done
paulson@14329
   336
paulson@14331
   337
lemma hypreal_add_zero_left: "(0::hypreal) + z = z"
paulson@14468
   338
by (cases z, simp add: hypreal_zero_def hypreal_add)
paulson@14329
   339
paulson@14329
   340
instance hypreal :: plus_ac0
paulson@14329
   341
  by (intro_classes,
paulson@14329
   342
      (assumption | 
paulson@14329
   343
       rule hypreal_add_commute hypreal_add_assoc hypreal_add_zero_left)+)
paulson@14329
   344
paulson@14329
   345
lemma hypreal_add_zero_right [simp]: "z + (0::hypreal) = z"
paulson@14329
   346
by (simp add: hypreal_add_zero_left hypreal_add_commute)
paulson@14329
   347
paulson@14329
   348
paulson@14329
   349
subsection{*Additive inverse on @{typ hypreal}*}
paulson@14299
   350
paulson@14299
   351
lemma hypreal_minus_congruent: 
paulson@14299
   352
  "congruent hyprel (%X. hyprel``{%n. - (X n)})"
paulson@14299
   353
by (force simp add: congruent_def)
paulson@14299
   354
paulson@14299
   355
lemma hypreal_minus: 
paulson@14299
   356
   "- (Abs_hypreal(hyprel``{%n. X n})) = Abs_hypreal(hyprel `` {%n. -(X n)})"
paulson@14468
   357
apply (simp add: hypreal_minus_def)
paulson@14301
   358
apply (rule_tac f = Abs_hypreal in arg_cong)
paulson@14301
   359
apply (simp add: hyprel_in_hypreal [THEN Abs_hypreal_inverse] 
paulson@14299
   360
               UN_equiv_class [OF equiv_hyprel hypreal_minus_congruent])
paulson@14299
   361
done
paulson@14299
   362
paulson@14329
   363
lemma hypreal_diff:
paulson@14329
   364
     "Abs_hypreal(hyprel``{%n. X n}) - Abs_hypreal(hyprel``{%n. Y n}) =  
paulson@14299
   365
      Abs_hypreal(hyprel``{%n. X n - Y n})"
paulson@14301
   366
apply (simp add: hypreal_diff_def hypreal_minus hypreal_add)
paulson@14299
   367
done
paulson@14299
   368
paulson@14301
   369
lemma hypreal_add_minus [simp]: "z + -z = (0::hypreal)"
paulson@14468
   370
apply (simp add: hypreal_zero_def)
paulson@14301
   371
apply (rule_tac z = z in eq_Abs_hypreal)
paulson@14299
   372
apply (simp add: hypreal_minus hypreal_add)
paulson@14299
   373
done
paulson@14299
   374
paulson@14331
   375
lemma hypreal_add_minus_left: "-z + z = (0::hypreal)"
paulson@14301
   376
by (simp add: hypreal_add_commute hypreal_add_minus)
paulson@14299
   377
paulson@14329
   378
paulson@14329
   379
subsection{*Hyperreal Multiplication*}
paulson@14299
   380
paulson@14299
   381
lemma hypreal_mult_congruent2: 
paulson@14299
   382
    "congruent2 hyprel (%X Y. hyprel``{%n. X n * Y n})"
paulson@14468
   383
apply (simp add: congruent2_def, auto, ultra)
paulson@14299
   384
done
paulson@14299
   385
paulson@14299
   386
lemma hypreal_mult: 
paulson@14299
   387
  "Abs_hypreal(hyprel``{%n. X n}) * Abs_hypreal(hyprel``{%n. Y n}) =  
paulson@14299
   388
   Abs_hypreal(hyprel``{%n. X n * Y n})"
paulson@14468
   389
apply (simp add: hypreal_mult_def)
paulson@14299
   390
apply (simp add: UN_equiv_class2 [OF equiv_hyprel hypreal_mult_congruent2])
paulson@14299
   391
done
paulson@14299
   392
paulson@14299
   393
lemma hypreal_mult_commute: "(z::hypreal) * w = w * z"
paulson@14468
   394
apply (cases z, cases w)
paulson@14331
   395
apply (simp add: hypreal_mult mult_ac)
paulson@14299
   396
done
paulson@14299
   397
paulson@14299
   398
lemma hypreal_mult_assoc: "((z1::hypreal) * z2) * z3 = z1 * (z2 * z3)"
paulson@14468
   399
apply (cases z1, cases z2, cases z3)
paulson@14331
   400
apply (simp add: hypreal_mult mult_assoc)
paulson@14299
   401
done
paulson@14299
   402
paulson@14331
   403
lemma hypreal_mult_1: "(1::hypreal) * z = z"
paulson@14468
   404
apply (simp add: hypreal_one_def)
paulson@14301
   405
apply (rule_tac z = z in eq_Abs_hypreal)
paulson@14299
   406
apply (simp add: hypreal_mult)
paulson@14299
   407
done
paulson@14301
   408
paulson@14329
   409
lemma hypreal_add_mult_distrib:
paulson@14329
   410
     "((z1::hypreal) + z2) * w = (z1 * w) + (z2 * w)"
paulson@14468
   411
apply (cases z1, cases z2, cases w)
paulson@14334
   412
apply (simp add: hypreal_mult hypreal_add left_distrib)
paulson@14299
   413
done
paulson@14299
   414
paulson@14331
   415
text{*one and zero are distinct*}
paulson@14299
   416
lemma hypreal_zero_not_eq_one: "0 \<noteq> (1::hypreal)"
paulson@14468
   417
by (simp add: hypreal_zero_def hypreal_one_def)
paulson@14299
   418
paulson@14299
   419
paulson@14329
   420
subsection{*Multiplicative Inverse on @{typ hypreal} *}
paulson@14299
   421
paulson@14299
   422
lemma hypreal_inverse_congruent: 
paulson@14299
   423
  "congruent hyprel (%X. hyprel``{%n. if X n = 0 then 0 else inverse(X n)})"
paulson@14468
   424
apply (simp add: congruent_def)
paulson@14301
   425
apply (auto, ultra)
paulson@14299
   426
done
paulson@14299
   427
paulson@14299
   428
lemma hypreal_inverse: 
paulson@14299
   429
      "inverse (Abs_hypreal(hyprel``{%n. X n})) =  
paulson@14299
   430
       Abs_hypreal(hyprel `` {%n. if X n = 0 then 0 else inverse(X n)})"
paulson@14468
   431
apply (simp add: hypreal_inverse_def)
paulson@14301
   432
apply (rule_tac f = Abs_hypreal in arg_cong)
paulson@14301
   433
apply (simp add: hyprel_in_hypreal [THEN Abs_hypreal_inverse] 
paulson@14299
   434
           UN_equiv_class [OF equiv_hyprel hypreal_inverse_congruent])
paulson@14299
   435
done
paulson@14299
   436
paulson@14331
   437
lemma hypreal_mult_inverse: 
paulson@14299
   438
     "x \<noteq> 0 ==> x*inverse(x) = (1::hypreal)"
paulson@14468
   439
apply (simp add: hypreal_one_def hypreal_zero_def)
paulson@14468
   440
apply (cases x)
paulson@14299
   441
apply (simp add: hypreal_inverse hypreal_mult)
paulson@14299
   442
apply (drule FreeUltrafilterNat_Compl_mem)
paulson@14334
   443
apply (blast intro!: right_inverse FreeUltrafilterNat_subset)
paulson@14299
   444
done
paulson@14299
   445
paulson@14331
   446
lemma hypreal_mult_inverse_left:
paulson@14329
   447
     "x \<noteq> 0 ==> inverse(x)*x = (1::hypreal)"
paulson@14301
   448
by (simp add: hypreal_mult_inverse hypreal_mult_commute)
paulson@14299
   449
paulson@14331
   450
instance hypreal :: field
paulson@14331
   451
proof
paulson@14331
   452
  fix x y z :: hypreal
paulson@14331
   453
  show "(x + y) + z = x + (y + z)" by (rule hypreal_add_assoc)
paulson@14331
   454
  show "x + y = y + x" by (rule hypreal_add_commute)
paulson@14331
   455
  show "0 + x = x" by simp
paulson@14331
   456
  show "- x + x = 0" by (simp add: hypreal_add_minus_left)
paulson@14331
   457
  show "x - y = x + (-y)" by (simp add: hypreal_diff_def)
paulson@14331
   458
  show "(x * y) * z = x * (y * z)" by (rule hypreal_mult_assoc)
paulson@14331
   459
  show "x * y = y * x" by (rule hypreal_mult_commute)
paulson@14331
   460
  show "1 * x = x" by (simp add: hypreal_mult_1)
paulson@14331
   461
  show "(x + y) * z = x * z + y * z" by (simp add: hypreal_add_mult_distrib)
paulson@14331
   462
  show "0 \<noteq> (1::hypreal)" by (rule hypreal_zero_not_eq_one)
paulson@14331
   463
  show "x \<noteq> 0 ==> inverse x * x = 1" by (simp add: hypreal_mult_inverse_left)
paulson@14430
   464
  show "x / y = x * inverse y" by (simp add: hypreal_divide_def)
paulson@14331
   465
qed
paulson@14331
   466
paulson@14331
   467
paulson@14331
   468
instance hypreal :: division_by_zero
paulson@14331
   469
proof
paulson@14430
   470
  show "inverse 0 = (0::hypreal)" 
paulson@14421
   471
    by (simp add: hypreal_inverse hypreal_zero_def)
paulson@14331
   472
qed
paulson@14331
   473
paulson@14329
   474
paulson@14329
   475
subsection{*Properties of The @{text "\<le>"} Relation*}
paulson@14299
   476
paulson@14299
   477
lemma hypreal_le: 
paulson@14365
   478
      "(Abs_hypreal(hyprel``{%n. X n}) \<le> Abs_hypreal(hyprel``{%n. Y n})) =  
paulson@14365
   479
       ({n. X n \<le> Y n} \<in> FreeUltrafilterNat)"
paulson@14468
   480
apply (simp add: hypreal_le_def)
paulson@14387
   481
apply (auto intro!: lemma_hyprel_refl, ultra)
paulson@14299
   482
done
paulson@14299
   483
paulson@14365
   484
lemma hypreal_le_refl: "w \<le> (w::hypreal)"
paulson@14468
   485
apply (cases w)
paulson@14370
   486
apply (simp add: hypreal_le) 
paulson@14299
   487
done
paulson@14299
   488
paulson@14365
   489
lemma hypreal_le_trans: "[| i \<le> j; j \<le> k |] ==> i \<le> (k::hypreal)"
paulson@14468
   490
apply (cases i, cases j, cases k)
paulson@14387
   491
apply (simp add: hypreal_le, ultra)
paulson@14299
   492
done
paulson@14299
   493
paulson@14365
   494
lemma hypreal_le_anti_sym: "[| z \<le> w; w \<le> z |] ==> z = (w::hypreal)"
paulson@14468
   495
apply (cases z, cases w)
paulson@14387
   496
apply (simp add: hypreal_le, ultra)
paulson@14299
   497
done
paulson@14299
   498
paulson@14299
   499
(* Axiom 'order_less_le' of class 'order': *)
paulson@14365
   500
lemma hypreal_less_le: "((w::hypreal) < z) = (w \<le> z & w \<noteq> z)"
paulson@14387
   501
by (simp add: hypreal_less_def)
paulson@14299
   502
paulson@14329
   503
instance hypreal :: order
paulson@14370
   504
proof qed
paulson@14370
   505
 (assumption |
paulson@14370
   506
  rule hypreal_le_refl hypreal_le_trans hypreal_le_anti_sym hypreal_less_le)+
paulson@14370
   507
paulson@14370
   508
paulson@14370
   509
(* Axiom 'linorder_linear' of class 'linorder': *)
paulson@14370
   510
lemma hypreal_le_linear: "(z::hypreal) \<le> w | w \<le> z"
paulson@14468
   511
apply (cases z, cases w)
paulson@14387
   512
apply (auto simp add: hypreal_le, ultra)
paulson@14370
   513
done
paulson@14329
   514
paulson@14329
   515
instance hypreal :: linorder 
paulson@14329
   516
  by (intro_classes, rule hypreal_le_linear)
paulson@14329
   517
paulson@14370
   518
lemma hypreal_not_refl2: "!!(x::hypreal). x < y ==> x \<noteq> y"
paulson@14370
   519
by (auto simp add: order_less_irrefl)
paulson@14329
   520
paulson@14370
   521
lemma hypreal_add_left_mono: "x \<le> y ==> z + x \<le> z + (y::hypreal)"
paulson@14468
   522
apply (cases x, cases y, cases z)
paulson@14370
   523
apply (auto simp add: hypreal_le hypreal_add) 
paulson@14329
   524
done
paulson@14329
   525
paulson@14329
   526
lemma hypreal_mult_less_mono2: "[| (0::hypreal)<z; x<y |] ==> z*x<z*y"
paulson@14468
   527
apply (cases x, cases y, cases z)
paulson@14370
   528
apply (auto simp add: hypreal_zero_def hypreal_le hypreal_mult 
paulson@14387
   529
                      linorder_not_le [symmetric], ultra) 
paulson@14329
   530
done
paulson@14329
   531
paulson@14370
   532
paulson@14329
   533
subsection{*The Hyperreals Form an Ordered Field*}
paulson@14329
   534
paulson@14329
   535
instance hypreal :: ordered_field
paulson@14329
   536
proof
paulson@14329
   537
  fix x y z :: hypreal
paulson@14348
   538
  show "x \<le> y ==> z + x \<le> z + y" 
paulson@14370
   539
    by (rule hypreal_add_left_mono)
paulson@14348
   540
  show "x < y ==> 0 < z ==> z * x < z * y" 
paulson@14348
   541
    by (simp add: hypreal_mult_less_mono2)
paulson@14329
   542
  show "\<bar>x\<bar> = (if x < 0 then -x else x)"
paulson@14329
   543
    by (auto dest: order_le_less_trans simp add: hrabs_def linorder_not_le)
paulson@14329
   544
qed
paulson@14329
   545
paulson@14331
   546
lemma hypreal_mult_1_right: "z * (1::hypreal) = z"
paulson@14331
   547
  by (rule Ring_and_Field.mult_1_right)
paulson@14331
   548
paulson@14331
   549
lemma hypreal_mult_minus_1 [simp]: "(- (1::hypreal)) * z = -z"
paulson@14387
   550
by simp
paulson@14331
   551
paulson@14331
   552
lemma hypreal_mult_minus_1_right [simp]: "z * (- (1::hypreal)) = -z"
paulson@14331
   553
by (subst hypreal_mult_commute, simp)
paulson@14329
   554
paulson@14329
   555
(*Used ONCE: in NSA.ML*)
paulson@14329
   556
lemma hypreal_minus_distrib1: "-(y + -(x::hypreal)) = x + -y"
paulson@14329
   557
by (simp add: hypreal_add_commute)
paulson@14329
   558
paulson@14329
   559
(*Used ONCE: in Lim.ML*)
paulson@14329
   560
lemma hypreal_eq_minus_iff3: "(x = y + z) = (x + -z = (y::hypreal))"
paulson@14329
   561
by (auto simp add: hypreal_add_assoc)
paulson@14329
   562
paulson@14331
   563
lemma hypreal_eq_minus_iff: "((x::hypreal) = y) = (x + - y = 0)"
paulson@14331
   564
apply auto
paulson@14331
   565
apply (rule Ring_and_Field.add_right_cancel [of _ "-y", THEN iffD1], auto)
paulson@14331
   566
done
paulson@14331
   567
paulson@14331
   568
(*Used 3 TIMES: in Lim.ML*)
paulson@14329
   569
lemma hypreal_not_eq_minus_iff: "(x \<noteq> a) = (x + -a \<noteq> (0::hypreal))"
paulson@14329
   570
by (auto dest: hypreal_eq_minus_iff [THEN iffD2])
paulson@14329
   571
paulson@14329
   572
lemma hypreal_mult_left_cancel: "(c::hypreal) \<noteq> 0 ==> (c*a=c*b) = (a=b)"
paulson@14387
   573
by auto
paulson@14329
   574
    
paulson@14329
   575
lemma hypreal_mult_right_cancel: "(c::hypreal) \<noteq> 0 ==> (a*c=b*c) = (a=b)"
paulson@14387
   576
by auto
paulson@14329
   577
paulson@14329
   578
lemma hypreal_mult_not_0: "[| x \<noteq> 0; y \<noteq> 0 |] ==> x * y \<noteq> (0::hypreal)"
paulson@14329
   579
by simp
paulson@14329
   580
paulson@14329
   581
lemma hypreal_minus_inverse: "inverse(-x) = -inverse(x::hypreal)"
paulson@14329
   582
  by (rule Ring_and_Field.inverse_minus_eq)
paulson@14329
   583
paulson@14329
   584
lemma hypreal_inverse_distrib: "inverse(x*y) = inverse(x)*inverse(y::hypreal)"
paulson@14329
   585
  by (rule Ring_and_Field.inverse_mult_distrib)
paulson@14329
   586
paulson@14329
   587
paulson@14329
   588
subsection{* Division lemmas *}
paulson@14329
   589
paulson@14329
   590
lemma hypreal_divide_one: "x/(1::hypreal) = x"
paulson@14329
   591
by (simp add: hypreal_divide_def)
paulson@14329
   592
paulson@14329
   593
paulson@14329
   594
(** As with multiplication, pull minus signs OUT of the / operator **)
paulson@14329
   595
paulson@14329
   596
lemma hypreal_add_divide_distrib: "(x+y)/(z::hypreal) = x/z + y/z"
paulson@14329
   597
  by (rule Ring_and_Field.add_divide_distrib)
paulson@14329
   598
paulson@14329
   599
lemma hypreal_inverse_add:
paulson@14329
   600
     "[|(x::hypreal) \<noteq> 0;  y \<noteq> 0 |]   
paulson@14329
   601
      ==> inverse(x) + inverse(y) = (x + y)*inverse(x*y)"
paulson@14329
   602
by (simp add: Ring_and_Field.inverse_add mult_assoc)
paulson@14329
   603
paulson@14329
   604
paulson@14371
   605
subsection{*The Embedding @{term hypreal_of_real} Preserves Field and 
paulson@14371
   606
      Order Properties*}
paulson@14329
   607
paulson@14301
   608
lemma hypreal_of_real_add [simp]: 
paulson@14369
   609
     "hypreal_of_real (w + z) = hypreal_of_real w + hypreal_of_real z"
paulson@14468
   610
apply (simp add: hypreal_of_real_def)
paulson@14331
   611
apply (simp add: hypreal_add left_distrib)
paulson@14299
   612
done
paulson@14299
   613
paulson@14301
   614
lemma hypreal_of_real_mult [simp]: 
paulson@14369
   615
     "hypreal_of_real (w * z) = hypreal_of_real w * hypreal_of_real z"
paulson@14468
   616
apply (simp add: hypreal_of_real_def)
paulson@14331
   617
apply (simp add: hypreal_mult right_distrib)
paulson@14299
   618
done
paulson@14299
   619
paulson@14301
   620
lemma hypreal_of_real_one [simp]: "hypreal_of_real 1 = (1::hypreal)"
paulson@14468
   621
by (simp add: hypreal_of_real_def hypreal_one_def)
paulson@14299
   622
paulson@14301
   623
lemma hypreal_of_real_zero [simp]: "hypreal_of_real 0 = 0"
paulson@14468
   624
by (simp add: hypreal_of_real_def hypreal_zero_def)
paulson@14299
   625
paulson@14370
   626
lemma hypreal_of_real_le_iff [simp]: 
paulson@14370
   627
     "(hypreal_of_real w \<le> hypreal_of_real z) = (w \<le> z)"
paulson@14468
   628
apply (simp add: hypreal_le_def hypreal_of_real_def, auto)
paulson@14369
   629
apply (rule_tac [2] x = "%n. w" in exI, safe)
paulson@14369
   630
apply (rule_tac [3] x = "%n. z" in exI, auto)
paulson@14369
   631
apply (rule FreeUltrafilterNat_P, ultra)
paulson@14369
   632
done
paulson@14369
   633
paulson@14370
   634
lemma hypreal_of_real_less_iff [simp]: 
paulson@14370
   635
     "(hypreal_of_real w < hypreal_of_real z) = (w < z)"
paulson@14370
   636
by (simp add: linorder_not_le [symmetric]) 
paulson@14369
   637
paulson@14369
   638
lemma hypreal_of_real_eq_iff [simp]:
paulson@14369
   639
     "(hypreal_of_real w = hypreal_of_real z) = (w = z)"
paulson@14369
   640
by (force intro: order_antisym hypreal_of_real_le_iff [THEN iffD1])
paulson@14369
   641
paulson@14369
   642
text{*As above, for 0*}
paulson@14369
   643
paulson@14369
   644
declare hypreal_of_real_less_iff [of 0, simplified, simp]
paulson@14369
   645
declare hypreal_of_real_le_iff   [of 0, simplified, simp]
paulson@14369
   646
declare hypreal_of_real_eq_iff   [of 0, simplified, simp]
paulson@14369
   647
paulson@14369
   648
declare hypreal_of_real_less_iff [of _ 0, simplified, simp]
paulson@14369
   649
declare hypreal_of_real_le_iff   [of _ 0, simplified, simp]
paulson@14369
   650
declare hypreal_of_real_eq_iff   [of _ 0, simplified, simp]
paulson@14369
   651
paulson@14369
   652
text{*As above, for 1*}
paulson@14369
   653
paulson@14369
   654
declare hypreal_of_real_less_iff [of 1, simplified, simp]
paulson@14369
   655
declare hypreal_of_real_le_iff   [of 1, simplified, simp]
paulson@14369
   656
declare hypreal_of_real_eq_iff   [of 1, simplified, simp]
paulson@14369
   657
paulson@14369
   658
declare hypreal_of_real_less_iff [of _ 1, simplified, simp]
paulson@14369
   659
declare hypreal_of_real_le_iff   [of _ 1, simplified, simp]
paulson@14369
   660
declare hypreal_of_real_eq_iff   [of _ 1, simplified, simp]
paulson@14369
   661
paulson@14369
   662
lemma hypreal_of_real_minus [simp]:
paulson@14369
   663
     "hypreal_of_real (-r) = - hypreal_of_real  r"
paulson@14370
   664
by (auto simp add: hypreal_of_real_def hypreal_minus)
paulson@14299
   665
paulson@14329
   666
lemma hypreal_of_real_inverse [simp]:
paulson@14329
   667
     "hypreal_of_real (inverse r) = inverse (hypreal_of_real r)"
paulson@14370
   668
apply (case_tac "r=0", simp)
paulson@14299
   669
apply (rule_tac c1 = "hypreal_of_real r" in hypreal_mult_left_cancel [THEN iffD1])
paulson@14369
   670
apply (auto simp add: hypreal_of_real_mult [symmetric])
paulson@14299
   671
done
paulson@14299
   672
paulson@14329
   673
lemma hypreal_of_real_divide [simp]:
paulson@14369
   674
     "hypreal_of_real (w / z) = hypreal_of_real w / hypreal_of_real z"
paulson@14301
   675
by (simp add: hypreal_divide_def real_divide_def)
paulson@14299
   676
paulson@14299
   677
paulson@14329
   678
subsection{*Misc Others*}
paulson@14299
   679
paulson@14370
   680
lemma hypreal_less: 
paulson@14370
   681
      "(Abs_hypreal(hyprel``{%n. X n}) < Abs_hypreal(hyprel``{%n. Y n})) =  
paulson@14370
   682
       ({n. X n < Y n} \<in> FreeUltrafilterNat)"
paulson@14387
   683
apply (auto simp add: hypreal_le linorder_not_le [symmetric], ultra+)
paulson@14370
   684
done
paulson@14370
   685
paulson@14299
   686
lemma hypreal_zero_num: "0 = Abs_hypreal (hyprel `` {%n. 0})"
paulson@14301
   687
by (simp add: hypreal_zero_def [THEN meta_eq_to_obj_eq, symmetric])
paulson@14299
   688
paulson@14299
   689
lemma hypreal_one_num: "1 = Abs_hypreal (hyprel `` {%n. 1})"
paulson@14301
   690
by (simp add: hypreal_one_def [THEN meta_eq_to_obj_eq, symmetric])
paulson@14299
   691
paulson@14301
   692
lemma hypreal_omega_gt_zero [simp]: "0 < omega"
paulson@14468
   693
apply (simp add: omega_def)
paulson@14299
   694
apply (auto simp add: hypreal_less hypreal_zero_num)
paulson@14299
   695
done
paulson@14299
   696
paulson@14329
   697
lemma hypreal_hrabs:
paulson@14329
   698
     "abs (Abs_hypreal (hyprel `` {X})) = 
paulson@14329
   699
      Abs_hypreal(hyprel `` {%n. abs (X n)})"
paulson@14329
   700
apply (auto simp add: hrabs_def hypreal_zero_def hypreal_le hypreal_minus)
paulson@14329
   701
apply (ultra, arith)+
paulson@14329
   702
done
paulson@14329
   703
paulson@14370
   704
paulson@14370
   705
paulson@14370
   706
lemma hypreal_add_zero_less_le_mono: "[|r < x; (0::hypreal) \<le> y|] ==> r < x+y"
paulson@14370
   707
by (auto dest: add_less_le_mono)
paulson@14370
   708
paulson@14370
   709
text{*The precondition could be weakened to @{term "0\<le>x"}*}
paulson@14370
   710
lemma hypreal_mult_less_mono:
paulson@14370
   711
     "[| u<v;  x<y;  (0::hypreal) < v;  0 < x |] ==> u*x < v* y"
paulson@14370
   712
 by (simp add: Ring_and_Field.mult_strict_mono order_less_imp_le)
paulson@14370
   713
paulson@14370
   714
paulson@14370
   715
subsection{*Existence of Infinite Hyperreal Number*}
paulson@14370
   716
paulson@14370
   717
lemma Rep_hypreal_omega: "Rep_hypreal(omega) \<in> hypreal"
paulson@14468
   718
by (simp add: omega_def)
paulson@14370
   719
paulson@14370
   720
text{*Existence of infinite number not corresponding to any real number.
paulson@14370
   721
Use assumption that member @{term FreeUltrafilterNat} is not finite.*}
paulson@14370
   722
paulson@14370
   723
paulson@14370
   724
text{*A few lemmas first*}
paulson@14370
   725
paulson@14370
   726
lemma lemma_omega_empty_singleton_disj: "{n::nat. x = real n} = {} |  
paulson@14370
   727
      (\<exists>y. {n::nat. x = real n} = {y})"
paulson@14387
   728
by force
paulson@14370
   729
paulson@14370
   730
lemma lemma_finite_omega_set: "finite {n::nat. x = real n}"
paulson@14370
   731
by (cut_tac x = x in lemma_omega_empty_singleton_disj, auto)
paulson@14370
   732
paulson@14370
   733
lemma not_ex_hypreal_of_real_eq_omega: 
paulson@14370
   734
      "~ (\<exists>x. hypreal_of_real x = omega)"
paulson@14468
   735
apply (simp add: omega_def hypreal_of_real_def)
paulson@14370
   736
apply (auto simp add: real_of_nat_Suc diff_eq_eq [symmetric] 
paulson@14370
   737
            lemma_finite_omega_set [THEN FreeUltrafilterNat_finite])
paulson@14370
   738
done
paulson@14370
   739
paulson@14370
   740
lemma hypreal_of_real_not_eq_omega: "hypreal_of_real x \<noteq> omega"
paulson@14370
   741
by (cut_tac not_ex_hypreal_of_real_eq_omega, auto)
paulson@14370
   742
paulson@14370
   743
text{*Existence of infinitesimal number also not corresponding to any
paulson@14370
   744
 real number*}
paulson@14370
   745
paulson@14370
   746
lemma lemma_epsilon_empty_singleton_disj:
paulson@14370
   747
     "{n::nat. x = inverse(real(Suc n))} = {} |  
paulson@14370
   748
      (\<exists>y. {n::nat. x = inverse(real(Suc n))} = {y})"
paulson@14387
   749
by auto
paulson@14370
   750
paulson@14370
   751
lemma lemma_finite_epsilon_set: "finite {n. x = inverse(real(Suc n))}"
paulson@14370
   752
by (cut_tac x = x in lemma_epsilon_empty_singleton_disj, auto)
paulson@14370
   753
paulson@14370
   754
lemma not_ex_hypreal_of_real_eq_epsilon: 
paulson@14370
   755
      "~ (\<exists>x. hypreal_of_real x = epsilon)"
paulson@14468
   756
apply (simp add: epsilon_def hypreal_of_real_def)
paulson@14370
   757
apply (auto simp add: lemma_finite_epsilon_set [THEN FreeUltrafilterNat_finite])
paulson@14370
   758
done
paulson@14370
   759
paulson@14370
   760
lemma hypreal_of_real_not_eq_epsilon: "hypreal_of_real x \<noteq> epsilon"
paulson@14370
   761
by (cut_tac not_ex_hypreal_of_real_eq_epsilon, auto)
paulson@14370
   762
paulson@14370
   763
lemma hypreal_epsilon_not_zero: "epsilon \<noteq> 0"
paulson@14468
   764
by (simp add: epsilon_def hypreal_zero_def)
paulson@14370
   765
paulson@14370
   766
lemma hypreal_epsilon_inverse_omega: "epsilon = inverse(omega)"
paulson@14370
   767
by (simp add: hypreal_inverse omega_def epsilon_def)
paulson@14370
   768
paulson@14370
   769
paulson@14299
   770
ML
paulson@14299
   771
{*
paulson@14329
   772
val hrabs_def = thm "hrabs_def";
paulson@14329
   773
val hypreal_hrabs = thm "hypreal_hrabs";
paulson@14329
   774
paulson@14299
   775
val hypreal_zero_def = thm "hypreal_zero_def";
paulson@14299
   776
val hypreal_one_def = thm "hypreal_one_def";
paulson@14299
   777
val hypreal_minus_def = thm "hypreal_minus_def";
paulson@14299
   778
val hypreal_diff_def = thm "hypreal_diff_def";
paulson@14299
   779
val hypreal_inverse_def = thm "hypreal_inverse_def";
paulson@14299
   780
val hypreal_divide_def = thm "hypreal_divide_def";
paulson@14299
   781
val hypreal_of_real_def = thm "hypreal_of_real_def";
paulson@14299
   782
val omega_def = thm "omega_def";
paulson@14299
   783
val epsilon_def = thm "epsilon_def";
paulson@14299
   784
val hypreal_add_def = thm "hypreal_add_def";
paulson@14299
   785
val hypreal_mult_def = thm "hypreal_mult_def";
paulson@14299
   786
val hypreal_less_def = thm "hypreal_less_def";
paulson@14299
   787
val hypreal_le_def = thm "hypreal_le_def";
paulson@14299
   788
paulson@14299
   789
val finite_exhausts = thm "finite_exhausts";
paulson@14299
   790
val finite_not_covers = thm "finite_not_covers";
paulson@14299
   791
val not_finite_nat = thm "not_finite_nat";
paulson@14299
   792
val FreeUltrafilterNat_Ex = thm "FreeUltrafilterNat_Ex";
paulson@14299
   793
val FreeUltrafilterNat_mem = thm "FreeUltrafilterNat_mem";
paulson@14299
   794
val FreeUltrafilterNat_finite = thm "FreeUltrafilterNat_finite";
paulson@14299
   795
val FreeUltrafilterNat_not_finite = thm "FreeUltrafilterNat_not_finite";
paulson@14299
   796
val FreeUltrafilterNat_empty = thm "FreeUltrafilterNat_empty";
paulson@14299
   797
val FreeUltrafilterNat_Int = thm "FreeUltrafilterNat_Int";
paulson@14299
   798
val FreeUltrafilterNat_subset = thm "FreeUltrafilterNat_subset";
paulson@14299
   799
val FreeUltrafilterNat_Compl = thm "FreeUltrafilterNat_Compl";
paulson@14299
   800
val FreeUltrafilterNat_Compl_mem = thm "FreeUltrafilterNat_Compl_mem";
paulson@14299
   801
val FreeUltrafilterNat_Compl_iff1 = thm "FreeUltrafilterNat_Compl_iff1";
paulson@14299
   802
val FreeUltrafilterNat_Compl_iff2 = thm "FreeUltrafilterNat_Compl_iff2";
paulson@14299
   803
val FreeUltrafilterNat_UNIV = thm "FreeUltrafilterNat_UNIV";
paulson@14299
   804
val FreeUltrafilterNat_Nat_set = thm "FreeUltrafilterNat_Nat_set";
paulson@14299
   805
val FreeUltrafilterNat_Nat_set_refl = thm "FreeUltrafilterNat_Nat_set_refl";
paulson@14299
   806
val FreeUltrafilterNat_P = thm "FreeUltrafilterNat_P";
paulson@14299
   807
val FreeUltrafilterNat_Ex_P = thm "FreeUltrafilterNat_Ex_P";
paulson@14299
   808
val FreeUltrafilterNat_all = thm "FreeUltrafilterNat_all";
paulson@14299
   809
val FreeUltrafilterNat_Un = thm "FreeUltrafilterNat_Un";
paulson@14299
   810
val hyprel_iff = thm "hyprel_iff";
paulson@14299
   811
val hyprel_refl = thm "hyprel_refl";
paulson@14299
   812
val hyprel_sym = thm "hyprel_sym";
paulson@14299
   813
val hyprel_trans = thm "hyprel_trans";
paulson@14299
   814
val equiv_hyprel = thm "equiv_hyprel";
paulson@14299
   815
val hyprel_in_hypreal = thm "hyprel_in_hypreal";
paulson@14299
   816
val Abs_hypreal_inverse = thm "Abs_hypreal_inverse";
paulson@14299
   817
val inj_on_Abs_hypreal = thm "inj_on_Abs_hypreal";
paulson@14299
   818
val inj_Rep_hypreal = thm "inj_Rep_hypreal";
paulson@14299
   819
val lemma_hyprel_refl = thm "lemma_hyprel_refl";
paulson@14299
   820
val hypreal_empty_not_mem = thm "hypreal_empty_not_mem";
paulson@14299
   821
val Rep_hypreal_nonempty = thm "Rep_hypreal_nonempty";
paulson@14299
   822
val inj_hypreal_of_real = thm "inj_hypreal_of_real";
paulson@14299
   823
val eq_Abs_hypreal = thm "eq_Abs_hypreal";
paulson@14299
   824
val hypreal_minus_congruent = thm "hypreal_minus_congruent";
paulson@14299
   825
val hypreal_minus = thm "hypreal_minus";
paulson@14299
   826
val hypreal_add_congruent2 = thm "hypreal_add_congruent2";
paulson@14299
   827
val hypreal_add = thm "hypreal_add";
paulson@14299
   828
val hypreal_diff = thm "hypreal_diff";
paulson@14299
   829
val hypreal_add_commute = thm "hypreal_add_commute";
paulson@14299
   830
val hypreal_add_assoc = thm "hypreal_add_assoc";
paulson@14299
   831
val hypreal_add_zero_left = thm "hypreal_add_zero_left";
paulson@14299
   832
val hypreal_add_zero_right = thm "hypreal_add_zero_right";
paulson@14299
   833
val hypreal_add_minus = thm "hypreal_add_minus";
paulson@14299
   834
val hypreal_add_minus_left = thm "hypreal_add_minus_left";
paulson@14299
   835
val hypreal_minus_distrib1 = thm "hypreal_minus_distrib1";
paulson@14299
   836
val hypreal_mult_congruent2 = thm "hypreal_mult_congruent2";
paulson@14299
   837
val hypreal_mult = thm "hypreal_mult";
paulson@14299
   838
val hypreal_mult_commute = thm "hypreal_mult_commute";
paulson@14299
   839
val hypreal_mult_assoc = thm "hypreal_mult_assoc";
paulson@14299
   840
val hypreal_mult_1 = thm "hypreal_mult_1";
paulson@14299
   841
val hypreal_mult_1_right = thm "hypreal_mult_1_right";
paulson@14299
   842
val hypreal_mult_minus_1 = thm "hypreal_mult_minus_1";
paulson@14299
   843
val hypreal_mult_minus_1_right = thm "hypreal_mult_minus_1_right";
paulson@14299
   844
val hypreal_zero_not_eq_one = thm "hypreal_zero_not_eq_one";
paulson@14299
   845
val hypreal_inverse_congruent = thm "hypreal_inverse_congruent";
paulson@14299
   846
val hypreal_inverse = thm "hypreal_inverse";
paulson@14299
   847
val hypreal_mult_inverse = thm "hypreal_mult_inverse";
paulson@14299
   848
val hypreal_mult_inverse_left = thm "hypreal_mult_inverse_left";
paulson@14299
   849
val hypreal_mult_left_cancel = thm "hypreal_mult_left_cancel";
paulson@14299
   850
val hypreal_mult_right_cancel = thm "hypreal_mult_right_cancel";
paulson@14299
   851
val hypreal_mult_not_0 = thm "hypreal_mult_not_0";
paulson@14299
   852
val hypreal_minus_inverse = thm "hypreal_minus_inverse";
paulson@14299
   853
val hypreal_inverse_distrib = thm "hypreal_inverse_distrib";
paulson@14299
   854
val hypreal_not_refl2 = thm "hypreal_not_refl2";
paulson@14299
   855
val hypreal_less = thm "hypreal_less";
paulson@14299
   856
val hypreal_eq_minus_iff = thm "hypreal_eq_minus_iff";
paulson@14299
   857
val hypreal_eq_minus_iff3 = thm "hypreal_eq_minus_iff3";
paulson@14299
   858
val hypreal_not_eq_minus_iff = thm "hypreal_not_eq_minus_iff";
paulson@14299
   859
val hypreal_le = thm "hypreal_le";
paulson@14299
   860
val hypreal_le_refl = thm "hypreal_le_refl";
paulson@14299
   861
val hypreal_le_linear = thm "hypreal_le_linear";
paulson@14299
   862
val hypreal_le_trans = thm "hypreal_le_trans";
paulson@14299
   863
val hypreal_le_anti_sym = thm "hypreal_le_anti_sym";
paulson@14299
   864
val hypreal_less_le = thm "hypreal_less_le";
paulson@14299
   865
val hypreal_of_real_add = thm "hypreal_of_real_add";
paulson@14299
   866
val hypreal_of_real_mult = thm "hypreal_of_real_mult";
paulson@14299
   867
val hypreal_of_real_less_iff = thm "hypreal_of_real_less_iff";
paulson@14299
   868
val hypreal_of_real_le_iff = thm "hypreal_of_real_le_iff";
paulson@14299
   869
val hypreal_of_real_eq_iff = thm "hypreal_of_real_eq_iff";
paulson@14299
   870
val hypreal_of_real_minus = thm "hypreal_of_real_minus";
paulson@14299
   871
val hypreal_of_real_one = thm "hypreal_of_real_one";
paulson@14299
   872
val hypreal_of_real_zero = thm "hypreal_of_real_zero";
paulson@14299
   873
val hypreal_of_real_inverse = thm "hypreal_of_real_inverse";
paulson@14299
   874
val hypreal_of_real_divide = thm "hypreal_of_real_divide";
paulson@14299
   875
val hypreal_divide_one = thm "hypreal_divide_one";
paulson@14299
   876
val hypreal_add_divide_distrib = thm "hypreal_add_divide_distrib";
paulson@14299
   877
val hypreal_inverse_add = thm "hypreal_inverse_add";
paulson@14299
   878
val hypreal_zero_num = thm "hypreal_zero_num";
paulson@14299
   879
val hypreal_one_num = thm "hypreal_one_num";
paulson@14299
   880
val hypreal_omega_gt_zero = thm "hypreal_omega_gt_zero";
paulson@14370
   881
paulson@14370
   882
val hypreal_add_zero_less_le_mono = thm"hypreal_add_zero_less_le_mono";
paulson@14370
   883
val Rep_hypreal_omega = thm"Rep_hypreal_omega";
paulson@14370
   884
val lemma_omega_empty_singleton_disj = thm"lemma_omega_empty_singleton_disj";
paulson@14370
   885
val lemma_finite_omega_set = thm"lemma_finite_omega_set";
paulson@14370
   886
val not_ex_hypreal_of_real_eq_omega = thm"not_ex_hypreal_of_real_eq_omega";
paulson@14370
   887
val hypreal_of_real_not_eq_omega = thm"hypreal_of_real_not_eq_omega";
paulson@14370
   888
val not_ex_hypreal_of_real_eq_epsilon = thm"not_ex_hypreal_of_real_eq_epsilon";
paulson@14370
   889
val hypreal_of_real_not_eq_epsilon = thm"hypreal_of_real_not_eq_epsilon";
paulson@14370
   890
val hypreal_epsilon_not_zero = thm"hypreal_epsilon_not_zero";
paulson@14370
   891
val hypreal_epsilon_inverse_omega = thm"hypreal_epsilon_inverse_omega";
paulson@14299
   892
*}
paulson@14299
   893
paulson@10751
   894
end