src/HOL/Hyperreal/HyperNat.thy
author nipkow
Wed Aug 18 11:09:40 2004 +0200 (2004-08-18)
changeset 15140 322485b816ac
parent 15131 c69542757a4d
child 15169 2b5da07a0b89
permissions -rw-r--r--
import -> imports
paulson@10751
     1
(*  Title       : HyperNat.thy
paulson@10751
     2
    Author      : Jacques D. Fleuriot
paulson@10751
     3
    Copyright   : 1998  University of Cambridge
paulson@14415
     4
paulson@14415
     5
Converted to Isar and polished by lcp    
paulson@14371
     6
*)
paulson@10751
     7
paulson@14371
     8
header{*Construction of Hypernaturals using Ultrafilters*}
paulson@14371
     9
nipkow@15131
    10
theory HyperNat
nipkow@15140
    11
imports Star
nipkow@15131
    12
begin
paulson@10751
    13
paulson@10751
    14
constdefs
paulson@10751
    15
    hypnatrel :: "((nat=>nat)*(nat=>nat)) set"
paulson@14371
    16
    "hypnatrel == {p. \<exists>X Y. p = ((X::nat=>nat),Y) &
paulson@14371
    17
                       {n::nat. X(n) = Y(n)} \<in> FreeUltrafilterNat}"
paulson@10751
    18
paulson@14371
    19
typedef hypnat = "UNIV//hypnatrel"
paulson@14371
    20
    by (auto simp add: quotient_def)
paulson@10751
    21
wenzelm@14691
    22
instance hypnat :: "{ord, zero, one, plus, times, minus}" ..
paulson@10751
    23
paulson@14371
    24
consts whn :: hypnat
paulson@10751
    25
paulson@14371
    26
paulson@14371
    27
defs (overloaded)
paulson@10778
    28
paulson@10778
    29
  (** hypernatural arithmetic **)
paulson@14371
    30
paulson@14371
    31
  hypnat_zero_def:  "0 == Abs_hypnat(hypnatrel``{%n::nat. 0})"
paulson@14371
    32
  hypnat_one_def:   "1 == Abs_hypnat(hypnatrel``{%n::nat. 1})"
paulson@10778
    33
paulson@10778
    34
  (* omega is in fact an infinite hypernatural number = [<1,2,3,...>] *)
paulson@14371
    35
  hypnat_omega_def:  "whn == Abs_hypnat(hypnatrel``{%n::nat. n})"
paulson@14371
    36
paulson@14371
    37
  hypnat_add_def:
paulson@14371
    38
  "P + Q == Abs_hypnat(\<Union>X \<in> Rep_hypnat(P). \<Union>Y \<in> Rep_hypnat(Q).
nipkow@10834
    39
                hypnatrel``{%n::nat. X n + Y n})"
paulson@10751
    40
paulson@14371
    41
  hypnat_mult_def:
paulson@14371
    42
  "P * Q == Abs_hypnat(\<Union>X \<in> Rep_hypnat(P). \<Union>Y \<in> Rep_hypnat(Q).
nipkow@10834
    43
                hypnatrel``{%n::nat. X n * Y n})"
paulson@10751
    44
paulson@14371
    45
  hypnat_minus_def:
paulson@14371
    46
  "P - Q == Abs_hypnat(\<Union>X \<in> Rep_hypnat(P). \<Union>Y \<in> Rep_hypnat(Q).
nipkow@10834
    47
                hypnatrel``{%n::nat. X n - Y n})"
paulson@10751
    48
paulson@14371
    49
  hypnat_le_def:
paulson@14415
    50
  "P \<le> (Q::hypnat) == \<exists>X Y. X \<in> Rep_hypnat(P) & Y \<in> Rep_hypnat(Q) &
paulson@14415
    51
                            {n::nat. X n \<le> Y n} \<in> FreeUltrafilterNat"
paulson@10751
    52
paulson@14371
    53
  hypnat_less_def: "(x < (y::hypnat)) == (x \<le> y & x \<noteq> y)"
paulson@10751
    54
paulson@10751
    55
paulson@10751
    56
paulson@14371
    57
subsection{*Properties of @{term hypnatrel}*}
paulson@14371
    58
paulson@14371
    59
text{*Proving that @{term hypnatrel} is an equivalence relation*}
paulson@14371
    60
paulson@14371
    61
lemma hypnatrel_iff:
paulson@14371
    62
     "((X,Y) \<in> hypnatrel) = ({n. X n = Y n}: FreeUltrafilterNat)"
paulson@14468
    63
apply (simp add: hypnatrel_def)
paulson@14371
    64
done
paulson@14371
    65
paulson@14371
    66
lemma hypnatrel_refl: "(x,x) \<in> hypnatrel"
paulson@14468
    67
by (simp add: hypnatrel_def)
paulson@14371
    68
paulson@14371
    69
lemma hypnatrel_sym: "(x,y) \<in> hypnatrel ==> (y,x) \<in> hypnatrel"
paulson@14371
    70
by (auto simp add: hypnatrel_def eq_commute)
paulson@14371
    71
paulson@14371
    72
lemma hypnatrel_trans [rule_format (no_asm)]:
paulson@14371
    73
     "(x,y) \<in> hypnatrel --> (y,z) \<in> hypnatrel --> (x,z) \<in> hypnatrel"
paulson@14468
    74
by (auto simp add: hypnatrel_def, ultra)
paulson@14371
    75
paulson@14371
    76
lemma equiv_hypnatrel:
paulson@14371
    77
     "equiv UNIV hypnatrel"
paulson@14371
    78
apply (simp add: equiv_def refl_def sym_def trans_def hypnatrel_refl)
paulson@14371
    79
apply (blast intro: hypnatrel_sym hypnatrel_trans)
paulson@14371
    80
done
paulson@14371
    81
paulson@14371
    82
(* (hypnatrel `` {x} = hypnatrel `` {y}) = ((x,y) \<in> hypnatrel) *)
paulson@14371
    83
lemmas equiv_hypnatrel_iff =
paulson@14371
    84
    eq_equiv_class_iff [OF equiv_hypnatrel UNIV_I UNIV_I, simp]
paulson@14371
    85
paulson@14371
    86
lemma hypnatrel_in_hypnat [simp]: "hypnatrel``{x}:hypnat"
paulson@14468
    87
by (simp add: hypnat_def hypnatrel_def quotient_def, blast)
paulson@14371
    88
paulson@14371
    89
lemma inj_on_Abs_hypnat: "inj_on Abs_hypnat hypnat"
paulson@14371
    90
apply (rule inj_on_inverseI)
paulson@14371
    91
apply (erule Abs_hypnat_inverse)
paulson@14371
    92
done
paulson@14371
    93
paulson@14371
    94
declare inj_on_Abs_hypnat [THEN inj_on_iff, simp]
paulson@14371
    95
        Abs_hypnat_inverse [simp]
paulson@14371
    96
paulson@14371
    97
declare equiv_hypnatrel [THEN eq_equiv_class_iff, simp]
paulson@14371
    98
paulson@14371
    99
declare hypnatrel_iff [iff]
paulson@14371
   100
paulson@14371
   101
paulson@14371
   102
lemma inj_Rep_hypnat: "inj(Rep_hypnat)"
paulson@14371
   103
apply (rule inj_on_inverseI)
paulson@14371
   104
apply (rule Rep_hypnat_inverse)
paulson@14371
   105
done
paulson@14371
   106
paulson@14371
   107
lemma lemma_hypnatrel_refl: "x \<in> hypnatrel `` {x}"
paulson@14371
   108
by (simp add: hypnatrel_def)
paulson@14371
   109
paulson@14371
   110
declare lemma_hypnatrel_refl [simp]
paulson@14371
   111
paulson@14371
   112
lemma hypnat_empty_not_mem: "{} \<notin> hypnat"
paulson@14468
   113
apply (simp add: hypnat_def)
paulson@14371
   114
apply (auto elim!: quotientE equalityCE)
paulson@14371
   115
done
paulson@14371
   116
paulson@14371
   117
declare hypnat_empty_not_mem [simp]
paulson@14371
   118
paulson@14371
   119
lemma Rep_hypnat_nonempty: "Rep_hypnat x \<noteq> {}"
paulson@14371
   120
by (cut_tac x = x in Rep_hypnat, auto)
paulson@14371
   121
paulson@14371
   122
declare Rep_hypnat_nonempty [simp]
paulson@14371
   123
paulson@14371
   124
paulson@14371
   125
lemma eq_Abs_hypnat:
paulson@14371
   126
    "(!!x. z = Abs_hypnat(hypnatrel``{x}) ==> P) ==> P"
paulson@14371
   127
apply (rule_tac x1=z in Rep_hypnat [unfolded hypnat_def, THEN quotientE])
paulson@14371
   128
apply (drule_tac f = Abs_hypnat in arg_cong)
paulson@14371
   129
apply (force simp add: Rep_hypnat_inverse)
paulson@14371
   130
done
paulson@14371
   131
paulson@14468
   132
theorem hypnat_cases [case_names Abs_hypnat, cases type: hypnat]:
paulson@14468
   133
    "(!!x. z = Abs_hypnat(hypnatrel``{x}) ==> P) ==> P"
paulson@14468
   134
by (rule eq_Abs_hypnat [of z], blast)
paulson@14468
   135
paulson@14371
   136
subsection{*Hypernat Addition*}
paulson@14371
   137
paulson@14371
   138
lemma hypnat_add_congruent2:
paulson@14658
   139
     "congruent2 hypnatrel hypnatrel (%X Y. hypnatrel``{%n. X n + Y n})"
paulson@14658
   140
by (simp add: congruent2_def, auto, ultra)
paulson@14371
   141
paulson@14371
   142
lemma hypnat_add:
paulson@14371
   143
  "Abs_hypnat(hypnatrel``{%n. X n}) + Abs_hypnat(hypnatrel``{%n. Y n}) =
paulson@14371
   144
   Abs_hypnat(hypnatrel``{%n. X n + Y n})"
paulson@14658
   145
by (simp add: hypnat_add_def 
paulson@14658
   146
    UN_equiv_class2 [OF equiv_hypnatrel equiv_hypnatrel hypnat_add_congruent2])
paulson@14371
   147
paulson@14371
   148
lemma hypnat_add_commute: "(z::hypnat) + w = w + z"
paulson@14468
   149
apply (cases z, cases w)
paulson@14371
   150
apply (simp add: add_ac hypnat_add)
paulson@14371
   151
done
paulson@14371
   152
paulson@14371
   153
lemma hypnat_add_assoc: "((z1::hypnat) + z2) + z3 = z1 + (z2 + z3)"
paulson@14468
   154
apply (cases z1, cases z2, cases z3)
paulson@14371
   155
apply (simp add: hypnat_add nat_add_assoc)
paulson@14371
   156
done
paulson@14371
   157
paulson@14371
   158
lemma hypnat_add_zero_left: "(0::hypnat) + z = z"
paulson@14468
   159
apply (cases z)
paulson@14371
   160
apply (simp add: hypnat_zero_def hypnat_add)
paulson@14371
   161
done
paulson@14371
   162
obua@14738
   163
instance hypnat :: comm_monoid_add
wenzelm@14691
   164
  by intro_classes
wenzelm@14691
   165
    (assumption |
wenzelm@14691
   166
      rule hypnat_add_commute hypnat_add_assoc hypnat_add_zero_left)+
paulson@14371
   167
paulson@14371
   168
paulson@14371
   169
subsection{*Subtraction inverse on @{typ hypreal}*}
paulson@14371
   170
paulson@14371
   171
paulson@14371
   172
lemma hypnat_minus_congruent2:
paulson@14658
   173
    "congruent2 hypnatrel hypnatrel (%X Y. hypnatrel``{%n. X n - Y n})"
paulson@14658
   174
by (simp add: congruent2_def, auto, ultra)
paulson@14371
   175
paulson@14371
   176
lemma hypnat_minus:
paulson@14371
   177
  "Abs_hypnat(hypnatrel``{%n. X n}) - Abs_hypnat(hypnatrel``{%n. Y n}) =
paulson@14371
   178
   Abs_hypnat(hypnatrel``{%n. X n - Y n})"
paulson@14658
   179
by (simp add: hypnat_minus_def 
paulson@14658
   180
  UN_equiv_class2 [OF equiv_hypnatrel equiv_hypnatrel hypnat_minus_congruent2])
paulson@14371
   181
paulson@14371
   182
lemma hypnat_minus_zero: "z - z = (0::hypnat)"
paulson@14468
   183
apply (cases z)
paulson@14371
   184
apply (simp add: hypnat_zero_def hypnat_minus)
paulson@14371
   185
done
paulson@14371
   186
paulson@14371
   187
lemma hypnat_diff_0_eq_0: "(0::hypnat) - n = 0"
paulson@14468
   188
apply (cases n)
paulson@14371
   189
apply (simp add: hypnat_minus hypnat_zero_def)
paulson@14371
   190
done
paulson@14371
   191
paulson@14371
   192
declare hypnat_minus_zero [simp] hypnat_diff_0_eq_0 [simp]
paulson@14371
   193
paulson@14371
   194
lemma hypnat_add_is_0: "(m+n = (0::hypnat)) = (m=0 & n=0)"
paulson@14468
   195
apply (cases m, cases n)
paulson@14371
   196
apply (auto intro: FreeUltrafilterNat_subset dest: FreeUltrafilterNat_Int simp add: hypnat_zero_def hypnat_add)
paulson@14371
   197
done
paulson@14371
   198
paulson@14371
   199
declare hypnat_add_is_0 [iff]
paulson@14371
   200
paulson@14371
   201
lemma hypnat_diff_diff_left: "(i::hypnat) - j - k = i - (j+k)"
paulson@14468
   202
apply (cases i, cases j, cases k)
paulson@14371
   203
apply (simp add: hypnat_minus hypnat_add diff_diff_left)
paulson@14371
   204
done
paulson@14371
   205
paulson@14371
   206
lemma hypnat_diff_commute: "(i::hypnat) - j - k = i-k-j"
paulson@14371
   207
by (simp add: hypnat_diff_diff_left hypnat_add_commute)
paulson@14371
   208
paulson@14371
   209
lemma hypnat_diff_add_inverse: "((n::hypnat) + m) - n = m"
paulson@14468
   210
apply (cases m, cases n)
paulson@14371
   211
apply (simp add: hypnat_minus hypnat_add)
paulson@14371
   212
done
paulson@14371
   213
declare hypnat_diff_add_inverse [simp]
paulson@14371
   214
paulson@14371
   215
lemma hypnat_diff_add_inverse2:  "((m::hypnat) + n) - n = m"
paulson@14468
   216
apply (cases m, cases n)
paulson@14371
   217
apply (simp add: hypnat_minus hypnat_add)
paulson@14371
   218
done
paulson@14371
   219
declare hypnat_diff_add_inverse2 [simp]
paulson@14371
   220
paulson@14371
   221
lemma hypnat_diff_cancel: "((k::hypnat) + m) - (k+n) = m - n"
paulson@14468
   222
apply (cases k, cases m, cases n)
paulson@14371
   223
apply (simp add: hypnat_minus hypnat_add)
paulson@14371
   224
done
paulson@14371
   225
declare hypnat_diff_cancel [simp]
paulson@14371
   226
paulson@14371
   227
lemma hypnat_diff_cancel2: "((m::hypnat) + k) - (n+k) = m - n"
paulson@14371
   228
by (simp add: hypnat_add_commute [of _ k])
paulson@14371
   229
declare hypnat_diff_cancel2 [simp]
paulson@14371
   230
paulson@14371
   231
lemma hypnat_diff_add_0: "(n::hypnat) - (n+m) = (0::hypnat)"
paulson@14468
   232
apply (cases m, cases n)
paulson@14371
   233
apply (simp add: hypnat_zero_def hypnat_minus hypnat_add)
paulson@14371
   234
done
paulson@14371
   235
declare hypnat_diff_add_0 [simp]
paulson@14371
   236
paulson@14371
   237
paulson@14371
   238
subsection{*Hyperreal Multiplication*}
paulson@14371
   239
paulson@14371
   240
lemma hypnat_mult_congruent2:
paulson@14658
   241
    "congruent2 hypnatrel hypnatrel (%X Y. hypnatrel``{%n. X n * Y n})"
paulson@14468
   242
by (simp add: congruent2_def, auto, ultra)
paulson@14371
   243
paulson@14371
   244
lemma hypnat_mult:
paulson@14371
   245
  "Abs_hypnat(hypnatrel``{%n. X n}) * Abs_hypnat(hypnatrel``{%n. Y n}) =
paulson@14371
   246
   Abs_hypnat(hypnatrel``{%n. X n * Y n})"
paulson@14658
   247
by (simp add: hypnat_mult_def
paulson@14658
   248
   UN_equiv_class2 [OF equiv_hypnatrel equiv_hypnatrel hypnat_mult_congruent2])
paulson@14371
   249
paulson@14371
   250
lemma hypnat_mult_commute: "(z::hypnat) * w = w * z"
paulson@14658
   251
by (cases z, cases w, simp add: hypnat_mult mult_ac)
paulson@14371
   252
paulson@14371
   253
lemma hypnat_mult_assoc: "((z1::hypnat) * z2) * z3 = z1 * (z2 * z3)"
paulson@14468
   254
apply (cases z1, cases z2, cases z3)
paulson@14371
   255
apply (simp add: hypnat_mult mult_assoc)
paulson@14371
   256
done
paulson@14371
   257
paulson@14371
   258
lemma hypnat_mult_1: "(1::hypnat) * z = z"
paulson@14468
   259
apply (cases z)
paulson@14371
   260
apply (simp add: hypnat_mult hypnat_one_def)
paulson@14371
   261
done
paulson@14371
   262
paulson@14371
   263
lemma hypnat_diff_mult_distrib: "((m::hypnat) - n) * k = (m * k) - (n * k)"
paulson@14468
   264
apply (cases k, cases m, cases n)
paulson@14371
   265
apply (simp add: hypnat_mult hypnat_minus diff_mult_distrib)
paulson@14371
   266
done
paulson@14371
   267
paulson@14371
   268
lemma hypnat_diff_mult_distrib2: "(k::hypnat) * (m - n) = (k * m) - (k * n)"
paulson@14371
   269
by (simp add: hypnat_diff_mult_distrib hypnat_mult_commute [of k])
paulson@14371
   270
paulson@14371
   271
lemma hypnat_add_mult_distrib: "((z1::hypnat) + z2) * w = (z1 * w) + (z2 * w)"
paulson@14468
   272
apply (cases z1, cases z2, cases w)
paulson@14371
   273
apply (simp add: hypnat_mult hypnat_add add_mult_distrib)
paulson@14371
   274
done
paulson@14371
   275
paulson@14371
   276
lemma hypnat_add_mult_distrib2: "(w::hypnat) * (z1 + z2) = (w * z1) + (w * z2)"
paulson@14371
   277
by (simp add: hypnat_mult_commute [of w] hypnat_add_mult_distrib)
paulson@14371
   278
paulson@14371
   279
text{*one and zero are distinct*}
paulson@14371
   280
lemma hypnat_zero_not_eq_one: "(0::hypnat) \<noteq> (1::hypnat)"
paulson@14371
   281
by (auto simp add: hypnat_zero_def hypnat_one_def)
paulson@14371
   282
declare hypnat_zero_not_eq_one [THEN not_sym, simp]
paulson@14371
   283
paulson@14371
   284
nipkow@15053
   285
text{*The hypernaturals form a @{text comm_semiring_1_cancel}: *}
obua@14738
   286
instance hypnat :: comm_semiring_1_cancel
paulson@14371
   287
proof
paulson@14371
   288
  fix i j k :: hypnat
paulson@14371
   289
  show "(i * j) * k = i * (j * k)" by (rule hypnat_mult_assoc)
paulson@14371
   290
  show "i * j = j * i" by (rule hypnat_mult_commute)
paulson@14371
   291
  show "1 * i = i" by (rule hypnat_mult_1)
paulson@14371
   292
  show "(i + j) * k = i * k + j * k" by (simp add: hypnat_add_mult_distrib)
paulson@14371
   293
  show "0 \<noteq> (1::hypnat)" by (rule hypnat_zero_not_eq_one)
paulson@14371
   294
  assume "k+i = k+j"
paulson@14371
   295
  hence "(k+i) - k = (k+j) - k" by simp
paulson@14371
   296
  thus "i=j" by simp
paulson@14371
   297
qed
paulson@14371
   298
paulson@14371
   299
paulson@14371
   300
subsection{*Properties of The @{text "\<le>"} Relation*}
paulson@14371
   301
paulson@14371
   302
lemma hypnat_le:
paulson@14371
   303
      "(Abs_hypnat(hypnatrel``{%n. X n}) \<le> Abs_hypnat(hypnatrel``{%n. Y n})) =
paulson@14371
   304
       ({n. X n \<le> Y n} \<in> FreeUltrafilterNat)"
paulson@14468
   305
apply (simp add: hypnat_le_def)
paulson@14371
   306
apply (auto intro!: lemma_hypnatrel_refl, ultra)
paulson@14371
   307
done
paulson@14371
   308
paulson@14371
   309
lemma hypnat_le_refl: "w \<le> (w::hypnat)"
paulson@14468
   310
apply (cases w)
paulson@14371
   311
apply (simp add: hypnat_le)
paulson@14371
   312
done
paulson@14371
   313
paulson@14371
   314
lemma hypnat_le_trans: "[| i \<le> j; j \<le> k |] ==> i \<le> (k::hypnat)"
paulson@14468
   315
apply (cases i, cases j, cases k)
paulson@14371
   316
apply (simp add: hypnat_le, ultra)
paulson@14371
   317
done
paulson@14371
   318
paulson@14371
   319
lemma hypnat_le_anti_sym: "[| z \<le> w; w \<le> z |] ==> z = (w::hypnat)"
paulson@14468
   320
apply (cases z, cases w)
paulson@14371
   321
apply (simp add: hypnat_le, ultra)
paulson@14371
   322
done
paulson@14371
   323
paulson@14371
   324
(* Axiom 'order_less_le' of class 'order': *)
paulson@14371
   325
lemma hypnat_less_le: "((w::hypnat) < z) = (w \<le> z & w \<noteq> z)"
paulson@14371
   326
by (simp add: hypnat_less_def)
paulson@14371
   327
paulson@14371
   328
instance hypnat :: order
wenzelm@14691
   329
  by intro_classes
wenzelm@14691
   330
    (assumption |
wenzelm@14691
   331
      rule hypnat_le_refl hypnat_le_trans hypnat_le_anti_sym hypnat_less_le)+
paulson@14371
   332
paulson@14371
   333
(* Axiom 'linorder_linear' of class 'linorder': *)
paulson@14371
   334
lemma hypnat_le_linear: "(z::hypnat) \<le> w | w \<le> z"
paulson@14468
   335
apply (cases z, cases w)
paulson@14371
   336
apply (auto simp add: hypnat_le, ultra)
paulson@14371
   337
done
paulson@14371
   338
paulson@14371
   339
instance hypnat :: linorder
wenzelm@14691
   340
  by intro_classes (rule hypnat_le_linear)
paulson@14371
   341
paulson@14371
   342
lemma hypnat_add_left_mono: "x \<le> y ==> z + x \<le> z + (y::hypnat)"
paulson@14468
   343
apply (cases x, cases y, cases z)
paulson@14371
   344
apply (auto simp add: hypnat_le hypnat_add)
paulson@14371
   345
done
paulson@14371
   346
paulson@14371
   347
lemma hypnat_mult_less_mono2: "[| (0::hypnat)<z; x<y |] ==> z*x<z*y"
paulson@14468
   348
apply (cases x, cases y, cases z)
paulson@14371
   349
apply (simp add: hypnat_zero_def  hypnat_mult linorder_not_le [symmetric])
paulson@14371
   350
apply (auto simp add: hypnat_le, ultra)
paulson@14371
   351
done
paulson@14371
   352
paulson@14371
   353
nipkow@15053
   354
subsection{*The Hypernaturals Form an Ordered @{text comm_semiring_1_cancel} *}
paulson@14371
   355
obua@14738
   356
instance hypnat :: ordered_semidom
paulson@14371
   357
proof
paulson@14371
   358
  fix x y z :: hypnat
paulson@14371
   359
  show "0 < (1::hypnat)"
paulson@14371
   360
    by (simp add: hypnat_zero_def hypnat_one_def linorder_not_le [symmetric],
paulson@14371
   361
        simp add: hypnat_le)
paulson@14371
   362
  show "x \<le> y ==> z + x \<le> z + y"
paulson@14371
   363
    by (rule hypnat_add_left_mono)
paulson@14371
   364
  show "x < y ==> 0 < z ==> z * x < z * y"
paulson@14371
   365
    by (simp add: hypnat_mult_less_mono2)
paulson@14371
   366
qed
paulson@14371
   367
paulson@14420
   368
lemma hypnat_le_zero_cancel [iff]: "(n \<le> (0::hypnat)) = (n = 0)"
paulson@14468
   369
apply (cases n)
paulson@14420
   370
apply (simp add: hypnat_zero_def hypnat_le)
paulson@14420
   371
done
paulson@14420
   372
paulson@14371
   373
lemma hypnat_mult_is_0 [simp]: "(m*n = (0::hypnat)) = (m=0 | n=0)"
paulson@14468
   374
apply (cases m, cases n)
paulson@14371
   375
apply (auto simp add: hypnat_zero_def hypnat_mult, ultra+)
paulson@14371
   376
done
paulson@14371
   377
paulson@14378
   378
lemma hypnat_diff_is_0_eq [simp]: "((m::hypnat) - n = 0) = (m \<le> n)"
paulson@14468
   379
apply (cases m, cases n)
paulson@14378
   380
apply (simp add: hypnat_le hypnat_minus hypnat_zero_def)
paulson@14378
   381
done
paulson@14378
   382
paulson@14378
   383
paulson@14371
   384
paulson@14371
   385
subsection{*Theorems for Ordering*}
paulson@14371
   386
paulson@14371
   387
lemma hypnat_less:
paulson@14371
   388
      "(Abs_hypnat(hypnatrel``{%n. X n}) < Abs_hypnat(hypnatrel``{%n. Y n})) =
paulson@14371
   389
       ({n. X n < Y n} \<in> FreeUltrafilterNat)"
paulson@14371
   390
apply (auto simp add: hypnat_le  linorder_not_le [symmetric])
paulson@14371
   391
apply (ultra+)
paulson@14371
   392
done
paulson@14371
   393
paulson@14371
   394
lemma hypnat_not_less0 [iff]: "~ n < (0::hypnat)"
paulson@14468
   395
apply (cases n)
paulson@14371
   396
apply (auto simp add: hypnat_zero_def hypnat_less)
paulson@14371
   397
done
paulson@14371
   398
paulson@14371
   399
lemma hypnat_less_one [iff]:
paulson@14371
   400
      "(n < (1::hypnat)) = (n=0)"
paulson@14468
   401
apply (cases n)
paulson@14371
   402
apply (auto simp add: hypnat_zero_def hypnat_one_def hypnat_less)
paulson@14371
   403
done
paulson@14371
   404
paulson@14371
   405
lemma hypnat_add_diff_inverse: "~ m<n ==> n+(m-n) = (m::hypnat)"
paulson@14468
   406
apply (cases m, cases n)
paulson@14371
   407
apply (simp add: hypnat_minus hypnat_add hypnat_less split: nat_diff_split, ultra)
paulson@14371
   408
done
paulson@14371
   409
paulson@14371
   410
lemma hypnat_le_add_diff_inverse [simp]: "n \<le> m ==> n+(m-n) = (m::hypnat)"
paulson@14371
   411
by (simp add: hypnat_add_diff_inverse linorder_not_less [symmetric])
paulson@14371
   412
paulson@14371
   413
lemma hypnat_le_add_diff_inverse2 [simp]: "n\<le>m ==> (m-n)+n = (m::hypnat)"
paulson@14371
   414
by (simp add: hypnat_le_add_diff_inverse hypnat_add_commute)
paulson@14371
   415
paulson@14371
   416
declare hypnat_le_add_diff_inverse2 [OF order_less_imp_le]
paulson@14371
   417
paulson@14371
   418
lemma hypnat_le0 [iff]: "(0::hypnat) \<le> n"
paulson@14371
   419
by (simp add: linorder_not_less [symmetric])
paulson@14371
   420
paulson@14371
   421
lemma hypnat_add_self_le [simp]: "(x::hypnat) \<le> n + x"
paulson@14371
   422
by (insert add_right_mono [of 0 n x], simp)
paulson@14371
   423
paulson@14371
   424
lemma hypnat_add_one_self_less [simp]: "(x::hypnat) < x + (1::hypnat)"
paulson@14371
   425
by (insert add_strict_left_mono [OF zero_less_one], auto)
paulson@14371
   426
paulson@14371
   427
lemma hypnat_neq0_conv [iff]: "(n \<noteq> 0) = (0 < (n::hypnat))"
paulson@14371
   428
by (simp add: order_less_le)
paulson@14371
   429
paulson@14371
   430
lemma hypnat_gt_zero_iff: "((0::hypnat) < n) = ((1::hypnat) \<le> n)"
paulson@14371
   431
by (auto simp add: linorder_not_less [symmetric])
paulson@14371
   432
paulson@14371
   433
lemma hypnat_gt_zero_iff2: "(0 < n) = (\<exists>m. n = m + (1::hypnat))"
paulson@14371
   434
apply safe
paulson@14371
   435
 apply (rule_tac x = "n - (1::hypnat) " in exI)
paulson@14371
   436
 apply (simp add: hypnat_gt_zero_iff) 
paulson@14371
   437
apply (insert add_le_less_mono [OF _ zero_less_one, of 0], auto) 
paulson@14371
   438
done
paulson@14371
   439
paulson@14378
   440
lemma hypnat_add_self_not_less: "~ (x + y < (x::hypnat))"
paulson@14378
   441
by (simp add: linorder_not_le [symmetric] add_commute [of x]) 
paulson@14378
   442
paulson@14378
   443
lemma hypnat_diff_split:
paulson@14378
   444
    "P(a - b::hypnat) = ((a<b --> P 0) & (ALL d. a = b + d --> P d))"
paulson@14378
   445
    -- {* elimination of @{text -} on @{text hypnat} *}
paulson@14378
   446
proof (cases "a<b" rule: case_split)
paulson@14378
   447
  case True
paulson@14378
   448
    thus ?thesis
paulson@14378
   449
      by (auto simp add: hypnat_add_self_not_less order_less_imp_le 
paulson@14378
   450
                         hypnat_diff_is_0_eq [THEN iffD2])
paulson@14378
   451
next
paulson@14378
   452
  case False
paulson@14378
   453
    thus ?thesis
paulson@14468
   454
      by (auto simp add: linorder_not_less dest: order_le_less_trans) 
paulson@14378
   455
qed
paulson@14378
   456
paulson@14378
   457
nipkow@15053
   458
subsection{*The Embedding @{term hypnat_of_nat} Preserves @{text
nipkow@15053
   459
comm_ring_1} and Order Properties*}
paulson@14371
   460
paulson@14378
   461
constdefs
paulson@14378
   462
paulson@14378
   463
  hypnat_of_nat   :: "nat => hypnat"
paulson@14378
   464
  "hypnat_of_nat m  == of_nat m"
paulson@14378
   465
paulson@14378
   466
  (* the set of infinite hypernatural numbers *)
paulson@14378
   467
  HNatInfinite :: "hypnat set"
paulson@14378
   468
  "HNatInfinite == {n. n \<notin> Nats}"
paulson@14378
   469
paulson@14378
   470
paulson@14371
   471
lemma hypnat_of_nat_add:
paulson@14371
   472
      "hypnat_of_nat ((z::nat) + w) = hypnat_of_nat z + hypnat_of_nat w"
paulson@14378
   473
by (simp add: hypnat_of_nat_def)
paulson@14371
   474
paulson@14371
   475
lemma hypnat_of_nat_mult:
paulson@14371
   476
      "hypnat_of_nat (z * w) = hypnat_of_nat z * hypnat_of_nat w"
paulson@14378
   477
by (simp add: hypnat_of_nat_def)
paulson@14371
   478
paulson@14371
   479
lemma hypnat_of_nat_less_iff [simp]:
paulson@14371
   480
      "(hypnat_of_nat z < hypnat_of_nat w) = (z < w)"
paulson@14378
   481
by (simp add: hypnat_of_nat_def)
paulson@14371
   482
paulson@14371
   483
lemma hypnat_of_nat_le_iff [simp]:
paulson@14371
   484
      "(hypnat_of_nat z \<le> hypnat_of_nat w) = (z \<le> w)"
paulson@14378
   485
by (simp add: hypnat_of_nat_def)
paulson@14371
   486
paulson@14378
   487
lemma hypnat_of_nat_eq_iff [simp]:
paulson@14378
   488
      "(hypnat_of_nat z = hypnat_of_nat w) = (z = w)"
paulson@14378
   489
by (simp add: hypnat_of_nat_def)
paulson@14371
   490
paulson@14378
   491
lemma hypnat_of_nat_one [simp]: "hypnat_of_nat (Suc 0) = (1::hypnat)"
paulson@14378
   492
by (simp add: hypnat_of_nat_def)
paulson@14371
   493
paulson@14378
   494
lemma hypnat_of_nat_zero [simp]: "hypnat_of_nat 0 = 0"
paulson@14378
   495
by (simp add: hypnat_of_nat_def)
paulson@14378
   496
paulson@14378
   497
lemma hypnat_of_nat_zero_iff [simp]: "(hypnat_of_nat n = 0) = (n = 0)"
paulson@14378
   498
by (simp add: hypnat_of_nat_def)
paulson@14371
   499
paulson@14378
   500
lemma hypnat_of_nat_Suc [simp]:
paulson@14371
   501
     "hypnat_of_nat (Suc n) = hypnat_of_nat n + (1::hypnat)"
paulson@14378
   502
by (simp add: hypnat_of_nat_def)
paulson@14378
   503
paulson@14378
   504
lemma hypnat_of_nat_minus:
paulson@14378
   505
      "hypnat_of_nat ((j::nat) - k) = hypnat_of_nat j - hypnat_of_nat k"
paulson@14378
   506
by (simp add: hypnat_of_nat_def split: nat_diff_split hypnat_diff_split)
paulson@14371
   507
paulson@14371
   508
nipkow@15070
   509
subsection{*Existence of an infinite hypernatural number*}
paulson@14371
   510
paulson@14371
   511
lemma hypnat_omega: "hypnatrel``{%n::nat. n} \<in> hypnat"
paulson@14371
   512
by auto
paulson@14371
   513
paulson@14371
   514
lemma Rep_hypnat_omega: "Rep_hypnat(whn) \<in> hypnat"
paulson@14371
   515
by (simp add: hypnat_omega_def)
paulson@14371
   516
paulson@14371
   517
text{*Existence of infinite number not corresponding to any natural number
paulson@14371
   518
follows because member @{term FreeUltrafilterNat} is not finite.
paulson@14371
   519
See @{text HyperDef.thy} for similar argument.*}
paulson@14371
   520
paulson@14371
   521
nipkow@15070
   522
subsection{*Properties of the set of embedded natural numbers*}
paulson@14371
   523
paulson@14378
   524
lemma of_nat_eq_add [rule_format]:
paulson@14378
   525
     "\<forall>d::hypnat. of_nat m = of_nat n + d --> d \<in> range of_nat"
paulson@14378
   526
apply (induct n) 
paulson@14378
   527
apply (auto simp add: add_assoc) 
paulson@14378
   528
apply (case_tac x) 
paulson@14378
   529
apply (auto simp add: add_commute [of 1]) 
paulson@14371
   530
done
paulson@14371
   531
paulson@14378
   532
lemma Nats_diff [simp]: "[|a \<in> Nats; b \<in> Nats|] ==> (a-b :: hypnat) \<in> Nats"
paulson@14468
   533
by (auto simp add: of_nat_eq_add Nats_def split: hypnat_diff_split)
paulson@14371
   534
paulson@14371
   535
lemma lemma_unbounded_set [simp]: "{n::nat. m < n} \<in> FreeUltrafilterNat"
paulson@14378
   536
apply (insert finite_atMost [of m]) 
paulson@14378
   537
apply (simp add: atMost_def) 
paulson@14378
   538
apply (drule FreeUltrafilterNat_finite) 
paulson@14468
   539
apply (drule FreeUltrafilterNat_Compl_mem, ultra)
paulson@14371
   540
done
paulson@14371
   541
paulson@14371
   542
lemma Compl_Collect_le: "- {n::nat. N \<le> n} = {n. n < N}"
paulson@14371
   543
by (simp add: Collect_neg_eq [symmetric] linorder_not_le) 
paulson@14371
   544
paulson@14378
   545
paulson@14378
   546
lemma hypnat_of_nat_eq:
paulson@14378
   547
     "hypnat_of_nat m  = Abs_hypnat(hypnatrel``{%n::nat. m})"
paulson@14378
   548
apply (induct m) 
paulson@14468
   549
apply (simp_all add: hypnat_zero_def hypnat_one_def hypnat_add) 
paulson@14378
   550
done
paulson@14378
   551
paulson@14378
   552
lemma SHNat_eq: "Nats = {n. \<exists>N. n = hypnat_of_nat N}"
paulson@14378
   553
by (force simp add: hypnat_of_nat_def Nats_def) 
paulson@14378
   554
paulson@14371
   555
lemma hypnat_omega_gt_SHNat:
paulson@14371
   556
     "n \<in> Nats ==> n < whn"
paulson@14378
   557
apply (auto simp add: hypnat_of_nat_eq hypnat_less_def hypnat_le_def
paulson@14378
   558
                      hypnat_omega_def SHNat_eq)
paulson@14371
   559
 prefer 2 apply (force dest: FreeUltrafilterNat_not_finite)
paulson@14371
   560
apply (auto intro!: exI)
paulson@14371
   561
apply (rule cofinite_mem_FreeUltrafilterNat)
paulson@14371
   562
apply (simp add: Compl_Collect_le finite_nat_segment) 
paulson@14371
   563
done
paulson@14371
   564
paulson@14378
   565
(* Infinite hypernatural not in embedded Nats *)
paulson@14378
   566
lemma SHNAT_omega_not_mem [simp]: "whn \<notin> Nats"
paulson@14468
   567
by (blast dest: hypnat_omega_gt_SHNat)
paulson@14371
   568
paulson@14378
   569
lemma hypnat_of_nat_less_whn [simp]: "hypnat_of_nat n < whn"
paulson@14378
   570
apply (insert hypnat_omega_gt_SHNat [of "hypnat_of_nat n"])
paulson@14378
   571
apply (simp add: hypnat_of_nat_def) 
paulson@14378
   572
done
paulson@14378
   573
paulson@14378
   574
lemma hypnat_of_nat_le_whn [simp]: "hypnat_of_nat n \<le> whn"
paulson@14371
   575
by (rule hypnat_of_nat_less_whn [THEN order_less_imp_le])
paulson@14371
   576
paulson@14371
   577
lemma hypnat_zero_less_hypnat_omega [simp]: "0 < whn"
paulson@14371
   578
by (simp add: hypnat_omega_gt_SHNat)
paulson@14371
   579
paulson@14371
   580
lemma hypnat_one_less_hypnat_omega [simp]: "(1::hypnat) < whn"
paulson@14371
   581
by (simp add: hypnat_omega_gt_SHNat)
paulson@14371
   582
paulson@14371
   583
paulson@14371
   584
subsection{*Infinite Hypernatural Numbers -- @{term HNatInfinite}*}
paulson@14371
   585
paulson@14378
   586
lemma HNatInfinite_whn [simp]: "whn \<in> HNatInfinite"
paulson@14371
   587
by (simp add: HNatInfinite_def)
paulson@14371
   588
paulson@14378
   589
lemma Nats_not_HNatInfinite_iff: "(x \<in> Nats) = (x \<notin> HNatInfinite)"
paulson@14371
   590
by (simp add: HNatInfinite_def)
paulson@14371
   591
paulson@14378
   592
lemma HNatInfinite_not_Nats_iff: "(x \<in> HNatInfinite) = (x \<notin> Nats)"
paulson@14378
   593
by (simp add: HNatInfinite_def)
paulson@14371
   594
paulson@14371
   595
nipkow@15070
   596
subsection{*Alternative characterization of the set of infinite hypernaturals*}
nipkow@15070
   597
nipkow@15070
   598
text{* @{term "HNatInfinite = {N. \<forall>n \<in> Nats. n < N}"}*}
paulson@14371
   599
paulson@14371
   600
(*??delete? similar reasoning in hypnat_omega_gt_SHNat above*)
paulson@14378
   601
lemma HNatInfinite_FreeUltrafilterNat_lemma:
paulson@14378
   602
     "\<forall>N::nat. {n. f n \<noteq> N} \<in> FreeUltrafilterNat
paulson@14371
   603
      ==> {n. N < f n} \<in> FreeUltrafilterNat"
paulson@14371
   604
apply (induct_tac "N")
paulson@14371
   605
apply (drule_tac x = 0 in spec)
paulson@14371
   606
apply (rule ccontr, drule FreeUltrafilterNat_Compl_mem, drule FreeUltrafilterNat_Int, assumption, simp)
paulson@14371
   607
apply (drule_tac x = "Suc n" in spec, ultra)
paulson@14371
   608
done
paulson@14371
   609
paulson@14371
   610
lemma HNatInfinite_iff: "HNatInfinite = {N. \<forall>n \<in> Nats. n < N}"
paulson@14378
   611
apply (auto simp add: HNatInfinite_def SHNat_eq hypnat_of_nat_eq)
paulson@14371
   612
apply (rule_tac z = x in eq_Abs_hypnat)
paulson@14378
   613
apply (auto elim: HNatInfinite_FreeUltrafilterNat_lemma 
paulson@14378
   614
            simp add: hypnat_less FreeUltrafilterNat_Compl_iff1 
paulson@14378
   615
                      Collect_neg_eq [symmetric])
paulson@14371
   616
done
paulson@14371
   617
paulson@14378
   618
paulson@14371
   619
subsection{*Alternative Characterization of @{term HNatInfinite} using 
paulson@14371
   620
Free Ultrafilter*}
paulson@14371
   621
paulson@14371
   622
lemma HNatInfinite_FreeUltrafilterNat:
paulson@14371
   623
     "x \<in> HNatInfinite 
paulson@14371
   624
      ==> \<exists>X \<in> Rep_hypnat x. \<forall>u. {n. u < X n}:  FreeUltrafilterNat"
paulson@14468
   625
apply (cases x)
paulson@14378
   626
apply (auto simp add: HNatInfinite_iff SHNat_eq hypnat_of_nat_eq)
paulson@14371
   627
apply (rule bexI [OF _ lemma_hypnatrel_refl], clarify) 
paulson@14371
   628
apply (auto simp add: hypnat_of_nat_def hypnat_less)
paulson@14371
   629
done
paulson@14371
   630
paulson@14371
   631
lemma FreeUltrafilterNat_HNatInfinite:
paulson@14371
   632
     "\<exists>X \<in> Rep_hypnat x. \<forall>u. {n. u < X n}:  FreeUltrafilterNat
paulson@14371
   633
      ==> x \<in> HNatInfinite"
paulson@14468
   634
apply (cases x)
paulson@14378
   635
apply (auto simp add: hypnat_less HNatInfinite_iff SHNat_eq hypnat_of_nat_eq)
paulson@14371
   636
apply (drule spec, ultra, auto) 
paulson@14371
   637
done
paulson@14371
   638
paulson@14371
   639
lemma HNatInfinite_FreeUltrafilterNat_iff:
paulson@14371
   640
     "(x \<in> HNatInfinite) = 
paulson@14371
   641
      (\<exists>X \<in> Rep_hypnat x. \<forall>u. {n. u < X n}:  FreeUltrafilterNat)"
paulson@14378
   642
by (blast intro: HNatInfinite_FreeUltrafilterNat 
paulson@14378
   643
                 FreeUltrafilterNat_HNatInfinite)
paulson@14371
   644
paulson@14378
   645
lemma HNatInfinite_gt_one [simp]: "x \<in> HNatInfinite ==> (1::hypnat) < x"
paulson@14371
   646
by (auto simp add: HNatInfinite_iff)
paulson@14371
   647
paulson@14378
   648
lemma zero_not_mem_HNatInfinite [simp]: "0 \<notin> HNatInfinite"
paulson@14371
   649
apply (auto simp add: HNatInfinite_iff)
paulson@14371
   650
apply (drule_tac a = " (1::hypnat) " in equals0D)
paulson@14371
   651
apply simp
paulson@14371
   652
done
paulson@14371
   653
paulson@14371
   654
lemma HNatInfinite_not_eq_zero: "x \<in> HNatInfinite ==> 0 < x"
paulson@14371
   655
apply (drule HNatInfinite_gt_one) 
paulson@14371
   656
apply (auto simp add: order_less_trans [OF zero_less_one])
paulson@14371
   657
done
paulson@14371
   658
paulson@14371
   659
lemma HNatInfinite_ge_one [simp]: "x \<in> HNatInfinite ==> (1::hypnat) \<le> x"
paulson@14371
   660
by (blast intro: order_less_imp_le HNatInfinite_gt_one)
paulson@14371
   661
paulson@14371
   662
paulson@14371
   663
subsection{*Closure Rules*}
paulson@14371
   664
paulson@14378
   665
lemma HNatInfinite_add:
paulson@14378
   666
     "[| x \<in> HNatInfinite; y \<in> HNatInfinite |] ==> x + y \<in> HNatInfinite"
paulson@14371
   667
apply (auto simp add: HNatInfinite_iff)
paulson@14371
   668
apply (drule bspec, assumption)
paulson@14378
   669
apply (drule bspec [OF _ Nats_0])
paulson@14371
   670
apply (drule add_strict_mono, assumption, simp)
paulson@14371
   671
done
paulson@14371
   672
paulson@14378
   673
lemma HNatInfinite_SHNat_add:
paulson@14378
   674
     "[| x \<in> HNatInfinite; y \<in> Nats |] ==> x + y \<in> HNatInfinite"
paulson@14378
   675
apply (auto simp add: HNatInfinite_not_Nats_iff) 
paulson@14468
   676
apply (drule_tac a = "x + y" in Nats_diff, auto) 
paulson@14371
   677
done
paulson@14371
   678
paulson@14378
   679
lemma HNatInfinite_Nats_imp_less: "[| x \<in> HNatInfinite; y \<in> Nats |] ==> y < x"
paulson@14378
   680
by (simp add: HNatInfinite_iff) 
paulson@14378
   681
paulson@14378
   682
lemma HNatInfinite_SHNat_diff:
paulson@14378
   683
  assumes x: "x \<in> HNatInfinite" and y: "y \<in> Nats" 
paulson@14378
   684
  shows "x - y \<in> HNatInfinite"
paulson@14378
   685
proof -
paulson@14378
   686
  have "y < x" by (simp add: HNatInfinite_Nats_imp_less prems)
paulson@14378
   687
  hence "x - y + y = x" by (simp add: order_less_imp_le)
paulson@14378
   688
  with x show ?thesis
paulson@14378
   689
    by (force simp add: HNatInfinite_not_Nats_iff 
paulson@14378
   690
              dest: Nats_add [of "x-y", OF _ y]) 
paulson@14378
   691
qed
paulson@14371
   692
paulson@14415
   693
lemma HNatInfinite_add_one:
paulson@14415
   694
     "x \<in> HNatInfinite ==> x + (1::hypnat) \<in> HNatInfinite"
paulson@14371
   695
by (auto intro: HNatInfinite_SHNat_add)
paulson@14371
   696
paulson@14371
   697
lemma HNatInfinite_is_Suc: "x \<in> HNatInfinite ==> \<exists>y. x = y + (1::hypnat)"
paulson@14371
   698
apply (rule_tac x = "x - (1::hypnat) " in exI)
paulson@14371
   699
apply auto
paulson@14371
   700
done
paulson@14371
   701
paulson@14371
   702
paulson@14378
   703
subsection{*Embedding of the Hypernaturals into the Hyperreals*}
paulson@14371
   704
text{*Obtained using the nonstandard extension of the naturals*}
paulson@14371
   705
paulson@14378
   706
constdefs
paulson@14378
   707
  hypreal_of_hypnat :: "hypnat => hypreal"
paulson@14378
   708
   "hypreal_of_hypnat N  == 
paulson@14378
   709
      Abs_hypreal(\<Union>X \<in> Rep_hypnat(N). hyprel``{%n::nat. real (X n)})"
paulson@14371
   710
paulson@14371
   711
paulson@14378
   712
lemma HNat_hypreal_of_nat [simp]: "hypreal_of_nat N \<in> Nats"
paulson@14378
   713
by (simp add: hypreal_of_nat_def) 
paulson@14371
   714
paulson@14371
   715
(*WARNING: FRAGILE!*)
paulson@14378
   716
lemma lemma_hyprel_FUFN:
paulson@14378
   717
     "(Ya \<in> hyprel ``{%n. f(n)}) = ({n. f n = Ya n} \<in> FreeUltrafilterNat)"
paulson@14378
   718
by force
paulson@14371
   719
paulson@14371
   720
lemma hypreal_of_hypnat:
paulson@14371
   721
      "hypreal_of_hypnat (Abs_hypnat(hypnatrel``{%n. X n})) =
paulson@14371
   722
       Abs_hypreal(hyprel `` {%n. real (X n)})"
paulson@14371
   723
apply (simp add: hypreal_of_hypnat_def)
paulson@14371
   724
apply (rule_tac f = Abs_hypreal in arg_cong)
paulson@14371
   725
apply (auto elim: FreeUltrafilterNat_Int [THEN FreeUltrafilterNat_subset] 
paulson@14371
   726
       simp add: lemma_hyprel_FUFN)
paulson@14371
   727
done
paulson@14371
   728
paulson@14378
   729
lemma hypreal_of_hypnat_inject [simp]:
paulson@14378
   730
     "(hypreal_of_hypnat m = hypreal_of_hypnat n) = (m=n)"
paulson@14468
   731
apply (cases m, cases n)
paulson@14371
   732
apply (auto simp add: hypreal_of_hypnat)
paulson@14371
   733
done
paulson@14371
   734
paulson@14371
   735
lemma hypreal_of_hypnat_zero: "hypreal_of_hypnat 0 = 0"
paulson@14371
   736
by (simp add: hypnat_zero_def hypreal_zero_def hypreal_of_hypnat)
paulson@14371
   737
paulson@14371
   738
lemma hypreal_of_hypnat_one: "hypreal_of_hypnat (1::hypnat) = 1"
paulson@14371
   739
by (simp add: hypnat_one_def hypreal_one_def hypreal_of_hypnat)
paulson@14371
   740
paulson@14371
   741
lemma hypreal_of_hypnat_add [simp]:
paulson@14371
   742
     "hypreal_of_hypnat (m + n) = hypreal_of_hypnat m + hypreal_of_hypnat n"
paulson@14468
   743
apply (cases m, cases n)
paulson@14371
   744
apply (simp add: hypreal_of_hypnat hypreal_add hypnat_add real_of_nat_add)
paulson@14371
   745
done
paulson@14371
   746
paulson@14371
   747
lemma hypreal_of_hypnat_mult [simp]:
paulson@14371
   748
     "hypreal_of_hypnat (m * n) = hypreal_of_hypnat m * hypreal_of_hypnat n"
paulson@14468
   749
apply (cases m, cases n)
paulson@14371
   750
apply (simp add: hypreal_of_hypnat hypreal_mult hypnat_mult real_of_nat_mult)
paulson@14371
   751
done
paulson@14371
   752
paulson@14371
   753
lemma hypreal_of_hypnat_less_iff [simp]:
paulson@14371
   754
     "(hypreal_of_hypnat n < hypreal_of_hypnat m) = (n < m)"
paulson@14468
   755
apply (cases m, cases n)
paulson@14371
   756
apply (simp add: hypreal_of_hypnat hypreal_less hypnat_less)
paulson@14371
   757
done
paulson@14371
   758
paulson@14371
   759
lemma hypreal_of_hypnat_eq_zero_iff: "(hypreal_of_hypnat N = 0) = (N = 0)"
paulson@14371
   760
by (simp add: hypreal_of_hypnat_zero [symmetric])
paulson@14371
   761
declare hypreal_of_hypnat_eq_zero_iff [simp]
paulson@14371
   762
paulson@14371
   763
lemma hypreal_of_hypnat_ge_zero [simp]: "0 \<le> hypreal_of_hypnat n"
paulson@14468
   764
apply (cases n)
paulson@14371
   765
apply (simp add: hypreal_of_hypnat hypreal_zero_num hypreal_le)
paulson@14371
   766
done
paulson@14371
   767
paulson@14378
   768
lemma HNatInfinite_inverse_Infinitesimal [simp]:
paulson@14378
   769
     "n \<in> HNatInfinite ==> inverse (hypreal_of_hypnat n) \<in> Infinitesimal"
paulson@14468
   770
apply (cases n)
paulson@14378
   771
apply (auto simp add: hypreal_of_hypnat hypreal_inverse 
paulson@14378
   772
      HNatInfinite_FreeUltrafilterNat_iff Infinitesimal_FreeUltrafilterNat_iff2)
paulson@14371
   773
apply (rule bexI, rule_tac [2] lemma_hyprel_refl, auto)
paulson@14371
   774
apply (drule_tac x = "m + 1" in spec, ultra)
paulson@14371
   775
done
paulson@14371
   776
paulson@14420
   777
lemma HNatInfinite_hypreal_of_hypnat_gt_zero:
paulson@14420
   778
     "N \<in> HNatInfinite ==> 0 < hypreal_of_hypnat N"
paulson@14420
   779
apply (rule ccontr)
paulson@14420
   780
apply (simp add: hypreal_of_hypnat_zero [symmetric] linorder_not_less)
paulson@14420
   781
done
paulson@14420
   782
paulson@14371
   783
paulson@14371
   784
ML
paulson@14371
   785
{*
paulson@14371
   786
val hypnat_of_nat_def = thm"hypnat_of_nat_def";
paulson@14371
   787
val HNatInfinite_def = thm"HNatInfinite_def";
paulson@14371
   788
val hypreal_of_hypnat_def = thm"hypreal_of_hypnat_def";
paulson@14371
   789
val hypnat_zero_def = thm"hypnat_zero_def";
paulson@14371
   790
val hypnat_one_def = thm"hypnat_one_def";
paulson@14371
   791
val hypnat_omega_def = thm"hypnat_omega_def";
paulson@14371
   792
paulson@14371
   793
val hypnatrel_iff = thm "hypnatrel_iff";
paulson@14371
   794
val hypnatrel_in_hypnat = thm "hypnatrel_in_hypnat";
paulson@14371
   795
val inj_on_Abs_hypnat = thm "inj_on_Abs_hypnat";
paulson@14371
   796
val inj_Rep_hypnat = thm "inj_Rep_hypnat";
paulson@14371
   797
val lemma_hypnatrel_refl = thm "lemma_hypnatrel_refl";
paulson@14371
   798
val hypnat_empty_not_mem = thm "hypnat_empty_not_mem";
paulson@14371
   799
val Rep_hypnat_nonempty = thm "Rep_hypnat_nonempty";
paulson@14371
   800
val eq_Abs_hypnat = thm "eq_Abs_hypnat";
paulson@14371
   801
val hypnat_add = thm "hypnat_add";
paulson@14371
   802
val hypnat_add_commute = thm "hypnat_add_commute";
paulson@14371
   803
val hypnat_add_assoc = thm "hypnat_add_assoc";
paulson@14371
   804
val hypnat_add_zero_left = thm "hypnat_add_zero_left";
paulson@14371
   805
val hypnat_minus_congruent2 = thm "hypnat_minus_congruent2";
paulson@14371
   806
val hypnat_minus = thm "hypnat_minus";
paulson@14371
   807
val hypnat_minus_zero = thm "hypnat_minus_zero";
paulson@14371
   808
val hypnat_diff_0_eq_0 = thm "hypnat_diff_0_eq_0";
paulson@14371
   809
val hypnat_add_is_0 = thm "hypnat_add_is_0";
paulson@14371
   810
val hypnat_diff_diff_left = thm "hypnat_diff_diff_left";
paulson@14371
   811
val hypnat_diff_commute = thm "hypnat_diff_commute";
paulson@14371
   812
val hypnat_diff_add_inverse = thm "hypnat_diff_add_inverse";
paulson@14371
   813
val hypnat_diff_add_inverse2 = thm "hypnat_diff_add_inverse2";
paulson@14371
   814
val hypnat_diff_cancel = thm "hypnat_diff_cancel";
paulson@14371
   815
val hypnat_diff_cancel2 = thm "hypnat_diff_cancel2";
paulson@14371
   816
val hypnat_diff_add_0 = thm "hypnat_diff_add_0";
paulson@14371
   817
val hypnat_mult_congruent2 = thm "hypnat_mult_congruent2";
paulson@14371
   818
val hypnat_mult = thm "hypnat_mult";
paulson@14371
   819
val hypnat_mult_commute = thm "hypnat_mult_commute";
paulson@14371
   820
val hypnat_mult_assoc = thm "hypnat_mult_assoc";
paulson@14371
   821
val hypnat_mult_1 = thm "hypnat_mult_1";
paulson@14371
   822
val hypnat_diff_mult_distrib = thm "hypnat_diff_mult_distrib";
paulson@14371
   823
val hypnat_diff_mult_distrib2 = thm "hypnat_diff_mult_distrib2";
paulson@14371
   824
val hypnat_add_mult_distrib = thm "hypnat_add_mult_distrib";
paulson@14371
   825
val hypnat_add_mult_distrib2 = thm "hypnat_add_mult_distrib2";
paulson@14371
   826
val hypnat_zero_not_eq_one = thm "hypnat_zero_not_eq_one";
paulson@14371
   827
val hypnat_le = thm "hypnat_le";
paulson@14371
   828
val hypnat_le_refl = thm "hypnat_le_refl";
paulson@14371
   829
val hypnat_le_trans = thm "hypnat_le_trans";
paulson@14371
   830
val hypnat_le_anti_sym = thm "hypnat_le_anti_sym";
paulson@14371
   831
val hypnat_less_le = thm "hypnat_less_le";
paulson@14371
   832
val hypnat_le_linear = thm "hypnat_le_linear";
paulson@14371
   833
val hypnat_add_left_mono = thm "hypnat_add_left_mono";
paulson@14371
   834
val hypnat_mult_less_mono2 = thm "hypnat_mult_less_mono2";
paulson@14371
   835
val hypnat_mult_is_0 = thm "hypnat_mult_is_0";
paulson@14371
   836
val hypnat_less = thm "hypnat_less";
paulson@14371
   837
val hypnat_not_less0 = thm "hypnat_not_less0";
paulson@14371
   838
val hypnat_less_one = thm "hypnat_less_one";
paulson@14371
   839
val hypnat_add_diff_inverse = thm "hypnat_add_diff_inverse";
paulson@14371
   840
val hypnat_le_add_diff_inverse = thm "hypnat_le_add_diff_inverse";
paulson@14371
   841
val hypnat_le_add_diff_inverse2 = thm "hypnat_le_add_diff_inverse2";
paulson@14371
   842
val hypnat_le0 = thm "hypnat_le0";
paulson@14371
   843
val hypnat_add_self_le = thm "hypnat_add_self_le";
paulson@14371
   844
val hypnat_add_one_self_less = thm "hypnat_add_one_self_less";
paulson@14371
   845
val hypnat_neq0_conv = thm "hypnat_neq0_conv";
paulson@14371
   846
val hypnat_gt_zero_iff = thm "hypnat_gt_zero_iff";
paulson@14371
   847
val hypnat_gt_zero_iff2 = thm "hypnat_gt_zero_iff2";
paulson@14371
   848
val hypnat_of_nat_add = thm "hypnat_of_nat_add";
paulson@14371
   849
val hypnat_of_nat_minus = thm "hypnat_of_nat_minus";
paulson@14371
   850
val hypnat_of_nat_mult = thm "hypnat_of_nat_mult";
paulson@14371
   851
val hypnat_of_nat_less_iff = thm "hypnat_of_nat_less_iff";
paulson@14371
   852
val hypnat_of_nat_le_iff = thm "hypnat_of_nat_le_iff";
paulson@14415
   853
val hypnat_of_nat_eq = thm"hypnat_of_nat_eq"
paulson@14415
   854
val SHNat_eq = thm"SHNat_eq"
paulson@14371
   855
val hypnat_of_nat_one = thm "hypnat_of_nat_one";
paulson@14371
   856
val hypnat_of_nat_zero = thm "hypnat_of_nat_zero";
paulson@14371
   857
val hypnat_of_nat_zero_iff = thm "hypnat_of_nat_zero_iff";
paulson@14371
   858
val hypnat_of_nat_Suc = thm "hypnat_of_nat_Suc";
paulson@14371
   859
val hypnat_omega = thm "hypnat_omega";
paulson@14371
   860
val Rep_hypnat_omega = thm "Rep_hypnat_omega";
paulson@14371
   861
val SHNAT_omega_not_mem = thm "SHNAT_omega_not_mem";
paulson@14371
   862
val cofinite_mem_FreeUltrafilterNat = thm "cofinite_mem_FreeUltrafilterNat";
paulson@14371
   863
val hypnat_omega_gt_SHNat = thm "hypnat_omega_gt_SHNat";
paulson@14371
   864
val hypnat_of_nat_less_whn = thm "hypnat_of_nat_less_whn";
paulson@14371
   865
val hypnat_of_nat_le_whn = thm "hypnat_of_nat_le_whn";
paulson@14371
   866
val hypnat_zero_less_hypnat_omega = thm "hypnat_zero_less_hypnat_omega";
paulson@14371
   867
val hypnat_one_less_hypnat_omega = thm "hypnat_one_less_hypnat_omega";
paulson@14371
   868
val HNatInfinite_whn = thm "HNatInfinite_whn";
paulson@14371
   869
val HNatInfinite_iff = thm "HNatInfinite_iff";
paulson@14371
   870
val HNatInfinite_FreeUltrafilterNat = thm "HNatInfinite_FreeUltrafilterNat";
paulson@14371
   871
val FreeUltrafilterNat_HNatInfinite = thm "FreeUltrafilterNat_HNatInfinite";
paulson@14371
   872
val HNatInfinite_FreeUltrafilterNat_iff = thm "HNatInfinite_FreeUltrafilterNat_iff";
paulson@14371
   873
val HNatInfinite_gt_one = thm "HNatInfinite_gt_one";
paulson@14371
   874
val zero_not_mem_HNatInfinite = thm "zero_not_mem_HNatInfinite";
paulson@14371
   875
val HNatInfinite_not_eq_zero = thm "HNatInfinite_not_eq_zero";
paulson@14371
   876
val HNatInfinite_ge_one = thm "HNatInfinite_ge_one";
paulson@14371
   877
val HNatInfinite_add = thm "HNatInfinite_add";
paulson@14371
   878
val HNatInfinite_SHNat_add = thm "HNatInfinite_SHNat_add";
paulson@14371
   879
val HNatInfinite_SHNat_diff = thm "HNatInfinite_SHNat_diff";
paulson@14371
   880
val HNatInfinite_add_one = thm "HNatInfinite_add_one";
paulson@14371
   881
val HNatInfinite_is_Suc = thm "HNatInfinite_is_Suc";
paulson@14371
   882
val HNat_hypreal_of_nat = thm "HNat_hypreal_of_nat";
paulson@14371
   883
val hypreal_of_hypnat = thm "hypreal_of_hypnat";
paulson@14371
   884
val hypreal_of_hypnat_zero = thm "hypreal_of_hypnat_zero";
paulson@14371
   885
val hypreal_of_hypnat_one = thm "hypreal_of_hypnat_one";
paulson@14371
   886
val hypreal_of_hypnat_add = thm "hypreal_of_hypnat_add";
paulson@14371
   887
val hypreal_of_hypnat_mult = thm "hypreal_of_hypnat_mult";
paulson@14371
   888
val hypreal_of_hypnat_less_iff = thm "hypreal_of_hypnat_less_iff";
paulson@14371
   889
val hypreal_of_hypnat_ge_zero = thm "hypreal_of_hypnat_ge_zero";
paulson@14371
   890
val HNatInfinite_inverse_Infinitesimal = thm "HNatInfinite_inverse_Infinitesimal";
paulson@14371
   891
*}
paulson@14371
   892
paulson@14371
   893
end