src/HOL/Nonstandard_Analysis/HyperNat.thy
author wenzelm
Sun Nov 26 21:08:32 2017 +0100 (16 months ago)
changeset 67091 1393c2340eec
parent 64438 f91cae6c1d74
child 69597 ff784d5a5bfb
permissions -rw-r--r--
more symbols;
wenzelm@62479
     1
(*  Title:      HOL/Nonstandard_Analysis/HyperNat.thy
wenzelm@62479
     2
    Author:     Jacques D. Fleuriot
wenzelm@62479
     3
    Copyright:  1998  University of Cambridge
huffman@27468
     4
hoelzl@62378
     5
Converted to Isar and polished by lcp
huffman@27468
     6
*)
huffman@27468
     7
wenzelm@64435
     8
section \<open>Hypernatural numbers\<close>
huffman@27468
     9
huffman@27468
    10
theory HyperNat
wenzelm@64435
    11
  imports StarDef
huffman@27468
    12
begin
huffman@27468
    13
wenzelm@42463
    14
type_synonym hypnat = "nat star"
huffman@27468
    15
wenzelm@64435
    16
abbreviation hypnat_of_nat :: "nat \<Rightarrow> nat star"
wenzelm@64435
    17
  where "hypnat_of_nat \<equiv> star_of"
huffman@27468
    18
wenzelm@64435
    19
definition hSuc :: "hypnat \<Rightarrow> hypnat"
wenzelm@64435
    20
  where hSuc_def [transfer_unfold]: "hSuc = *f* Suc"
huffman@27468
    21
wenzelm@64435
    22
wenzelm@64435
    23
subsection \<open>Properties Transferred from Naturals\<close>
huffman@27468
    24
huffman@27468
    25
lemma hSuc_not_zero [iff]: "\<And>m. hSuc m \<noteq> 0"
wenzelm@64435
    26
  by transfer (rule Suc_not_Zero)
huffman@27468
    27
huffman@27468
    28
lemma zero_not_hSuc [iff]: "\<And>m. 0 \<noteq> hSuc m"
wenzelm@64435
    29
  by transfer (rule Zero_not_Suc)
huffman@27468
    30
wenzelm@64435
    31
lemma hSuc_hSuc_eq [iff]: "\<And>m n. hSuc m = hSuc n \<longleftrightarrow> m = n"
wenzelm@64435
    32
  by transfer (rule nat.inject)
huffman@27468
    33
huffman@27468
    34
lemma zero_less_hSuc [iff]: "\<And>n. 0 < hSuc n"
wenzelm@64435
    35
  by transfer (rule zero_less_Suc)
huffman@27468
    36
wenzelm@64435
    37
lemma hypnat_minus_zero [simp]: "\<And>z::hypnat. z - z = 0"
wenzelm@64435
    38
  by transfer (rule diff_self_eq_0)
huffman@27468
    39
wenzelm@64435
    40
lemma hypnat_diff_0_eq_0 [simp]: "\<And>n::hypnat. 0 - n = 0"
wenzelm@64435
    41
  by transfer (rule diff_0_eq_0)
huffman@27468
    42
wenzelm@64435
    43
lemma hypnat_add_is_0 [iff]: "\<And>m n::hypnat. m + n = 0 \<longleftrightarrow> m = 0 \<and> n = 0"
wenzelm@64435
    44
  by transfer (rule add_is_0)
huffman@27468
    45
wenzelm@64435
    46
lemma hypnat_diff_diff_left: "\<And>i j k::hypnat. i - j - k = i - (j + k)"
wenzelm@64435
    47
  by transfer (rule diff_diff_left)
huffman@27468
    48
wenzelm@64435
    49
lemma hypnat_diff_commute: "\<And>i j k::hypnat. i - j - k = i - k - j"
wenzelm@64435
    50
  by transfer (rule diff_commute)
huffman@27468
    51
wenzelm@64435
    52
lemma hypnat_diff_add_inverse [simp]: "\<And>m n::hypnat. n + m - n = m"
wenzelm@64435
    53
  by transfer (rule diff_add_inverse)
huffman@27468
    54
wenzelm@64435
    55
lemma hypnat_diff_add_inverse2 [simp]:  "\<And>m n::hypnat. m + n - n = m"
wenzelm@64435
    56
  by transfer (rule diff_add_inverse2)
huffman@27468
    57
wenzelm@64435
    58
lemma hypnat_diff_cancel [simp]: "\<And>k m n::hypnat. (k + m) - (k + n) = m - n"
wenzelm@64435
    59
  by transfer (rule diff_cancel)
huffman@27468
    60
wenzelm@64435
    61
lemma hypnat_diff_cancel2 [simp]: "\<And>k m n::hypnat. (m + k) - (n + k) = m - n"
wenzelm@64435
    62
  by transfer (rule diff_cancel2)
huffman@27468
    63
wenzelm@64435
    64
lemma hypnat_diff_add_0 [simp]: "\<And>m n::hypnat. n - (n + m) = 0"
wenzelm@64435
    65
  by transfer (rule diff_add_0)
huffman@27468
    66
wenzelm@64435
    67
lemma hypnat_diff_mult_distrib: "\<And>k m n::hypnat. (m - n) * k = (m * k) - (n * k)"
wenzelm@64435
    68
  by transfer (rule diff_mult_distrib)
huffman@27468
    69
wenzelm@64435
    70
lemma hypnat_diff_mult_distrib2: "\<And>k m n::hypnat. k * (m - n) = (k * m) - (k * n)"
wenzelm@64435
    71
  by transfer (rule diff_mult_distrib2)
huffman@27468
    72
wenzelm@64435
    73
lemma hypnat_le_zero_cancel [iff]: "\<And>n::hypnat. n \<le> 0 \<longleftrightarrow> n = 0"
wenzelm@64435
    74
  by transfer (rule le_0_eq)
huffman@27468
    75
wenzelm@64435
    76
lemma hypnat_mult_is_0 [simp]: "\<And>m n::hypnat. m * n = 0 \<longleftrightarrow> m = 0 \<or> n = 0"
wenzelm@64435
    77
  by transfer (rule mult_is_0)
huffman@27468
    78
wenzelm@64435
    79
lemma hypnat_diff_is_0_eq [simp]: "\<And>m n::hypnat. m - n = 0 \<longleftrightarrow> m \<le> n"
wenzelm@64435
    80
  by transfer (rule diff_is_0_eq)
huffman@27468
    81
wenzelm@64435
    82
lemma hypnat_not_less0 [iff]: "\<And>n::hypnat. \<not> n < 0"
wenzelm@64435
    83
  by transfer (rule not_less0)
wenzelm@64435
    84
wenzelm@64435
    85
lemma hypnat_less_one [iff]: "\<And>n::hypnat. n < 1 \<longleftrightarrow> n = 0"
wenzelm@64435
    86
  by transfer (rule less_one)
huffman@27468
    87
wenzelm@64435
    88
lemma hypnat_add_diff_inverse: "\<And>m n::hypnat. \<not> m < n \<Longrightarrow> n + (m - n) = m"
wenzelm@64435
    89
  by transfer (rule add_diff_inverse)
huffman@27468
    90
wenzelm@64435
    91
lemma hypnat_le_add_diff_inverse [simp]: "\<And>m n::hypnat. n \<le> m \<Longrightarrow> n + (m - n) = m"
wenzelm@64435
    92
  by transfer (rule le_add_diff_inverse)
huffman@27468
    93
wenzelm@64435
    94
lemma hypnat_le_add_diff_inverse2 [simp]: "\<And>m n::hypnat. n \<le> m \<Longrightarrow> (m - n) + n = m"
wenzelm@64435
    95
  by transfer (rule le_add_diff_inverse2)
huffman@27468
    96
huffman@27468
    97
declare hypnat_le_add_diff_inverse2 [OF order_less_imp_le]
huffman@27468
    98
wenzelm@64435
    99
lemma hypnat_le0 [iff]: "\<And>n::hypnat. 0 \<le> n"
wenzelm@64435
   100
  by transfer (rule le0)
huffman@27468
   101
wenzelm@64435
   102
lemma hypnat_le_add1 [simp]: "\<And>x n::hypnat. x \<le> x + n"
wenzelm@64435
   103
  by transfer (rule le_add1)
huffman@27468
   104
wenzelm@64435
   105
lemma hypnat_add_self_le [simp]: "\<And>x n::hypnat. x \<le> n + x"
wenzelm@64435
   106
  by transfer (rule le_add2)
huffman@27468
   107
wenzelm@64435
   108
lemma hypnat_add_one_self_less [simp]: "x < x + 1" for x :: hypnat
hoelzl@62378
   109
  by (fact less_add_one)
huffman@27468
   110
wenzelm@64435
   111
lemma hypnat_neq0_conv [iff]: "\<And>n::hypnat. n \<noteq> 0 \<longleftrightarrow> 0 < n"
wenzelm@64435
   112
  by transfer (rule neq0_conv)
huffman@27468
   113
wenzelm@64435
   114
lemma hypnat_gt_zero_iff: "0 < n \<longleftrightarrow> 1 \<le> n" for n :: hypnat
wenzelm@64435
   115
  by (auto simp add: linorder_not_less [symmetric])
huffman@27468
   116
wenzelm@64435
   117
lemma hypnat_gt_zero_iff2: "0 < n \<longleftrightarrow> (\<exists>m. n = m + 1)" for n :: hypnat
hoelzl@62378
   118
  by (auto intro!: add_nonneg_pos exI[of _ "n - 1"] simp: hypnat_gt_zero_iff)
huffman@27468
   119
wenzelm@64435
   120
lemma hypnat_add_self_not_less: "\<not> x + y < x" for x y :: hypnat
wenzelm@64435
   121
  by (simp add: linorder_not_le [symmetric] add.commute [of x])
huffman@27468
   122
wenzelm@64435
   123
lemma hypnat_diff_split: "P (a - b) \<longleftrightarrow> (a < b \<longrightarrow> P 0) \<and> (\<forall>d. a = b + d \<longrightarrow> P d)"
wenzelm@64435
   124
  for a b :: hypnat
wenzelm@64435
   125
  \<comment> \<open>elimination of \<open>-\<close> on \<open>hypnat\<close>\<close>
wenzelm@64435
   126
proof (cases "a < b" rule: case_split)
huffman@27468
   127
  case True
wenzelm@64435
   128
  then show ?thesis
wenzelm@64435
   129
    by (auto simp add: hypnat_add_self_not_less order_less_imp_le hypnat_diff_is_0_eq [THEN iffD2])
huffman@27468
   130
next
huffman@27468
   131
  case False
wenzelm@64435
   132
  then show ?thesis
wenzelm@64435
   133
    by (auto simp add: linorder_not_less dest: order_le_less_trans)
huffman@27468
   134
qed
huffman@27468
   135
wenzelm@64435
   136
wenzelm@64435
   137
subsection \<open>Properties of the set of embedded natural numbers\<close>
huffman@27468
   138
huffman@27468
   139
lemma of_nat_eq_star_of [simp]: "of_nat = star_of"
huffman@27468
   140
proof
wenzelm@64435
   141
  show "of_nat n = star_of n" for n
wenzelm@64435
   142
    by transfer simp
huffman@27468
   143
qed
huffman@27468
   144
huffman@27468
   145
lemma Nats_eq_Standard: "(Nats :: nat star set) = Standard"
wenzelm@64435
   146
  by (auto simp: Nats_def Standard_def)
huffman@27468
   147
huffman@27468
   148
lemma hypnat_of_nat_mem_Nats [simp]: "hypnat_of_nat n \<in> Nats"
wenzelm@64435
   149
  by (simp add: Nats_eq_Standard)
huffman@27468
   150
wenzelm@64435
   151
lemma hypnat_of_nat_one [simp]: "hypnat_of_nat (Suc 0) = 1"
wenzelm@64435
   152
  by transfer simp
huffman@27468
   153
wenzelm@64435
   154
lemma hypnat_of_nat_Suc [simp]: "hypnat_of_nat (Suc n) = hypnat_of_nat n + 1"
wenzelm@64435
   155
  by transfer simp
huffman@27468
   156
wenzelm@67091
   157
lemma of_nat_eq_add [rule_format]: "\<forall>d::hypnat. of_nat m = of_nat n + d \<longrightarrow> d \<in> range of_nat"
wenzelm@64435
   158
  apply (induct n)
wenzelm@64435
   159
   apply (auto simp add: add.assoc)
wenzelm@64435
   160
  apply (case_tac x)
wenzelm@64435
   161
   apply (auto simp add: add.commute [of 1])
wenzelm@64435
   162
  done
huffman@27468
   163
wenzelm@64435
   164
lemma Nats_diff [simp]: "a \<in> Nats \<Longrightarrow> b \<in> Nats \<Longrightarrow> a - b \<in> Nats" for a b :: hypnat
wenzelm@64435
   165
  by (simp add: Nats_eq_Standard)
huffman@27468
   166
huffman@27468
   167
wenzelm@64435
   168
subsection \<open>Infinite Hypernatural Numbers -- @{term HNatInfinite}\<close>
wenzelm@64435
   169
wenzelm@64435
   170
text \<open>The set of infinite hypernatural numbers.\<close>
wenzelm@64435
   171
definition HNatInfinite :: "hypnat set"
wenzelm@64435
   172
  where "HNatInfinite = {n. n \<notin> Nats}"
huffman@27468
   173
wenzelm@64435
   174
lemma Nats_not_HNatInfinite_iff: "x \<in> Nats \<longleftrightarrow> x \<notin> HNatInfinite"
wenzelm@64435
   175
  by (simp add: HNatInfinite_def)
huffman@27468
   176
wenzelm@64435
   177
lemma HNatInfinite_not_Nats_iff: "x \<in> HNatInfinite \<longleftrightarrow> x \<notin> Nats"
wenzelm@64435
   178
  by (simp add: HNatInfinite_def)
huffman@27468
   179
huffman@27468
   180
lemma star_of_neq_HNatInfinite: "N \<in> HNatInfinite \<Longrightarrow> star_of n \<noteq> N"
wenzelm@64435
   181
  by (auto simp add: HNatInfinite_def Nats_eq_Standard)
huffman@27468
   182
wenzelm@64435
   183
lemma star_of_Suc_lessI: "\<And>N. star_of n < N \<Longrightarrow> star_of (Suc n) \<noteq> N \<Longrightarrow> star_of (Suc n) < N"
wenzelm@64435
   184
  by transfer (rule Suc_lessI)
huffman@27468
   185
huffman@27468
   186
lemma star_of_less_HNatInfinite:
huffman@27468
   187
  assumes N: "N \<in> HNatInfinite"
huffman@27468
   188
  shows "star_of n < N"
huffman@27468
   189
proof (induct n)
huffman@27468
   190
  case 0
wenzelm@64435
   191
  from N have "star_of 0 \<noteq> N"
wenzelm@64435
   192
    by (rule star_of_neq_HNatInfinite)
wenzelm@64435
   193
  then show ?case by simp
huffman@27468
   194
next
huffman@27468
   195
  case (Suc n)
wenzelm@64435
   196
  from N have "star_of (Suc n) \<noteq> N"
wenzelm@64435
   197
    by (rule star_of_neq_HNatInfinite)
wenzelm@64435
   198
  with Suc show ?case
wenzelm@64435
   199
    by (rule star_of_Suc_lessI)
huffman@27468
   200
qed
huffman@27468
   201
huffman@27468
   202
lemma star_of_le_HNatInfinite: "N \<in> HNatInfinite \<Longrightarrow> star_of n \<le> N"
wenzelm@64435
   203
  by (rule star_of_less_HNatInfinite [THEN order_less_imp_le])
wenzelm@64435
   204
huffman@27468
   205
wenzelm@61975
   206
subsubsection \<open>Closure Rules\<close>
huffman@27468
   207
wenzelm@64435
   208
lemma Nats_less_HNatInfinite: "x \<in> Nats \<Longrightarrow> y \<in> HNatInfinite \<Longrightarrow> x < y"
wenzelm@64435
   209
  by (auto simp add: Nats_def star_of_less_HNatInfinite)
huffman@27468
   210
wenzelm@64435
   211
lemma Nats_le_HNatInfinite: "x \<in> Nats \<Longrightarrow> y \<in> HNatInfinite \<Longrightarrow> x \<le> y"
wenzelm@64435
   212
  by (rule Nats_less_HNatInfinite [THEN order_less_imp_le])
huffman@27468
   213
huffman@27468
   214
lemma zero_less_HNatInfinite: "x \<in> HNatInfinite \<Longrightarrow> 0 < x"
wenzelm@64435
   215
  by (simp add: Nats_less_HNatInfinite)
huffman@27468
   216
huffman@27468
   217
lemma one_less_HNatInfinite: "x \<in> HNatInfinite \<Longrightarrow> 1 < x"
wenzelm@64435
   218
  by (simp add: Nats_less_HNatInfinite)
huffman@27468
   219
huffman@27468
   220
lemma one_le_HNatInfinite: "x \<in> HNatInfinite \<Longrightarrow> 1 \<le> x"
wenzelm@64435
   221
  by (simp add: Nats_le_HNatInfinite)
huffman@27468
   222
huffman@27468
   223
lemma zero_not_mem_HNatInfinite [simp]: "0 \<notin> HNatInfinite"
wenzelm@64435
   224
  by (simp add: HNatInfinite_def)
huffman@27468
   225
wenzelm@64435
   226
lemma Nats_downward_closed: "x \<in> Nats \<Longrightarrow> y \<le> x \<Longrightarrow> y \<in> Nats" for x y :: hypnat
wenzelm@64435
   227
  apply (simp only: linorder_not_less [symmetric])
wenzelm@64435
   228
  apply (erule contrapos_np)
wenzelm@64435
   229
  apply (drule HNatInfinite_not_Nats_iff [THEN iffD2])
wenzelm@64435
   230
  apply (erule (1) Nats_less_HNatInfinite)
wenzelm@64435
   231
  done
huffman@27468
   232
wenzelm@64435
   233
lemma HNatInfinite_upward_closed: "x \<in> HNatInfinite \<Longrightarrow> x \<le> y \<Longrightarrow> y \<in> HNatInfinite"
wenzelm@64435
   234
  apply (simp only: HNatInfinite_not_Nats_iff)
wenzelm@64435
   235
  apply (erule contrapos_nn)
wenzelm@64435
   236
  apply (erule (1) Nats_downward_closed)
wenzelm@64435
   237
  done
huffman@27468
   238
huffman@27468
   239
lemma HNatInfinite_add: "x \<in> HNatInfinite \<Longrightarrow> x + y \<in> HNatInfinite"
wenzelm@64435
   240
  apply (erule HNatInfinite_upward_closed)
wenzelm@64435
   241
  apply (rule hypnat_le_add1)
wenzelm@64435
   242
  done
huffman@27468
   243
huffman@27468
   244
lemma HNatInfinite_add_one: "x \<in> HNatInfinite \<Longrightarrow> x + 1 \<in> HNatInfinite"
wenzelm@64435
   245
  by (rule HNatInfinite_add)
huffman@27468
   246
wenzelm@64435
   247
lemma HNatInfinite_diff: "x \<in> HNatInfinite \<Longrightarrow> y \<in> Nats \<Longrightarrow> x - y \<in> HNatInfinite"
wenzelm@64435
   248
  apply (frule (1) Nats_le_HNatInfinite)
wenzelm@64435
   249
  apply (simp only: HNatInfinite_not_Nats_iff)
wenzelm@64435
   250
  apply (erule contrapos_nn)
wenzelm@64435
   251
  apply (drule (1) Nats_add, simp)
wenzelm@64435
   252
  done
huffman@27468
   253
wenzelm@64435
   254
lemma HNatInfinite_is_Suc: "x \<in> HNatInfinite \<Longrightarrow> \<exists>y. x = y + 1" for x :: hypnat
wenzelm@64435
   255
  apply (rule_tac x = "x - (1::hypnat) " in exI)
wenzelm@64435
   256
  apply (simp add: Nats_le_HNatInfinite)
wenzelm@64435
   257
  done
huffman@27468
   258
huffman@27468
   259
wenzelm@64435
   260
subsection \<open>Existence of an infinite hypernatural number\<close>
huffman@27468
   261
wenzelm@64435
   262
text \<open>\<open>\<omega>\<close> is in fact an infinite hypernatural number = \<open>[<1, 2, 3, \<dots>>]\<close>\<close>
wenzelm@64435
   263
definition whn :: hypnat
wenzelm@64435
   264
  where hypnat_omega_def: "whn = star_n (\<lambda>n::nat. n)"
huffman@27468
   265
huffman@27468
   266
lemma hypnat_of_nat_neq_whn: "hypnat_of_nat n \<noteq> whn"
wenzelm@64435
   267
  by (simp add: FreeUltrafilterNat.singleton' hypnat_omega_def star_of_def star_n_eq_iff)
huffman@27468
   268
huffman@27468
   269
lemma whn_neq_hypnat_of_nat: "whn \<noteq> hypnat_of_nat n"
wenzelm@64435
   270
  by (simp add: FreeUltrafilterNat.singleton hypnat_omega_def star_of_def star_n_eq_iff)
huffman@27468
   271
huffman@27468
   272
lemma whn_not_Nats [simp]: "whn \<notin> Nats"
wenzelm@64435
   273
  by (simp add: Nats_def image_def whn_neq_hypnat_of_nat)
huffman@27468
   274
huffman@27468
   275
lemma HNatInfinite_whn [simp]: "whn \<in> HNatInfinite"
wenzelm@64435
   276
  by (simp add: HNatInfinite_def)
huffman@27468
   277
hoelzl@60041
   278
lemma lemma_unbounded_set [simp]: "eventually (\<lambda>n::nat. m < n) \<U>"
hoelzl@60041
   279
  by (rule filter_leD[OF FreeUltrafilterNat.le_cofinite])
hoelzl@60041
   280
     (auto simp add: cofinite_eq_sequentially eventually_at_top_dense)
huffman@27468
   281
wenzelm@64435
   282
lemma hypnat_of_nat_eq: "hypnat_of_nat m  = star_n (\<lambda>n::nat. m)"
wenzelm@64435
   283
  by (simp add: star_of_def)
huffman@27468
   284
huffman@27468
   285
lemma SHNat_eq: "Nats = {n. \<exists>N. n = hypnat_of_nat N}"
wenzelm@64435
   286
  by (simp add: Nats_def image_def)
huffman@27468
   287
huffman@27468
   288
lemma Nats_less_whn: "n \<in> Nats \<Longrightarrow> n < whn"
wenzelm@64435
   289
  by (simp add: Nats_less_HNatInfinite)
huffman@27468
   290
huffman@27468
   291
lemma Nats_le_whn: "n \<in> Nats \<Longrightarrow> n \<le> whn"
wenzelm@64435
   292
  by (simp add: Nats_le_HNatInfinite)
huffman@27468
   293
huffman@27468
   294
lemma hypnat_of_nat_less_whn [simp]: "hypnat_of_nat n < whn"
wenzelm@64435
   295
  by (simp add: Nats_less_whn)
huffman@27468
   296
huffman@27468
   297
lemma hypnat_of_nat_le_whn [simp]: "hypnat_of_nat n \<le> whn"
wenzelm@64435
   298
  by (simp add: Nats_le_whn)
huffman@27468
   299
huffman@27468
   300
lemma hypnat_zero_less_hypnat_omega [simp]: "0 < whn"
wenzelm@64435
   301
  by (simp add: Nats_less_whn)
huffman@27468
   302
huffman@27468
   303
lemma hypnat_one_less_hypnat_omega [simp]: "1 < whn"
wenzelm@64435
   304
  by (simp add: Nats_less_whn)
huffman@27468
   305
huffman@27468
   306
wenzelm@64435
   307
subsubsection \<open>Alternative characterization of the set of infinite hypernaturals\<close>
huffman@27468
   308
wenzelm@64435
   309
text \<open>@{term "HNatInfinite = {N. \<forall>n \<in> Nats. n < N}"}\<close>
huffman@27468
   310
huffman@27468
   311
(*??delete? similar reasoning in hypnat_omega_gt_SHNat above*)
huffman@27468
   312
lemma HNatInfinite_FreeUltrafilterNat_lemma:
hoelzl@60041
   313
  assumes "\<forall>N::nat. eventually (\<lambda>n. f n \<noteq> N) \<U>"
hoelzl@60041
   314
  shows "eventually (\<lambda>n. N < f n) \<U>"
wenzelm@64435
   315
  apply (induct N)
wenzelm@64435
   316
  using assms
wenzelm@64435
   317
   apply (drule_tac x = 0 in spec, simp)
wenzelm@64435
   318
  using assms
wenzelm@64435
   319
  apply (drule_tac x = "Suc N" in spec)
wenzelm@64435
   320
  apply (auto elim: eventually_elim2)
wenzelm@64435
   321
  done
huffman@27468
   322
huffman@27468
   323
lemma HNatInfinite_iff: "HNatInfinite = {N. \<forall>n \<in> Nats. n < N}"
wenzelm@64435
   324
  apply (safe intro!: Nats_less_HNatInfinite)
wenzelm@64435
   325
  apply (auto simp add: HNatInfinite_def)
wenzelm@64435
   326
  done
huffman@27468
   327
huffman@27468
   328
wenzelm@64435
   329
subsubsection \<open>Alternative Characterization of @{term HNatInfinite} using Free Ultrafilter\<close>
huffman@27468
   330
huffman@27468
   331
lemma HNatInfinite_FreeUltrafilterNat:
wenzelm@64438
   332
  "star_n X \<in> HNatInfinite \<Longrightarrow> \<forall>u. eventually (\<lambda>n. u < X n) \<U>"
wenzelm@64435
   333
  apply (auto simp add: HNatInfinite_iff SHNat_eq)
wenzelm@64435
   334
  apply (drule_tac x="star_of u" in spec, simp)
wenzelm@64435
   335
  apply (simp add: star_of_def star_less_def starP2_star_n)
wenzelm@64435
   336
  done
huffman@27468
   337
huffman@27468
   338
lemma FreeUltrafilterNat_HNatInfinite:
wenzelm@64438
   339
  "\<forall>u. eventually (\<lambda>n. u < X n) \<U> \<Longrightarrow> star_n X \<in> HNatInfinite"
wenzelm@64435
   340
  by (auto simp add: star_less_def starP2_star_n HNatInfinite_iff SHNat_eq hypnat_of_nat_eq)
huffman@27468
   341
huffman@27468
   342
lemma HNatInfinite_FreeUltrafilterNat_iff:
wenzelm@64438
   343
  "(star_n X \<in> HNatInfinite) = (\<forall>u. eventually (\<lambda>n. u < X n) \<U>)"
wenzelm@64435
   344
  by (rule iffI [OF HNatInfinite_FreeUltrafilterNat FreeUltrafilterNat_HNatInfinite])
wenzelm@64435
   345
huffman@27468
   346
wenzelm@61975
   347
subsection \<open>Embedding of the Hypernaturals into other types\<close>
huffman@27468
   348
wenzelm@64435
   349
definition of_hypnat :: "hypnat \<Rightarrow> 'a::semiring_1_cancel star"
wenzelm@64435
   350
  where of_hypnat_def [transfer_unfold]: "of_hypnat = *f* of_nat"
huffman@27468
   351
huffman@27468
   352
lemma of_hypnat_0 [simp]: "of_hypnat 0 = 0"
wenzelm@64435
   353
  by transfer (rule of_nat_0)
huffman@27468
   354
huffman@27468
   355
lemma of_hypnat_1 [simp]: "of_hypnat 1 = 1"
wenzelm@64435
   356
  by transfer (rule of_nat_1)
huffman@27468
   357
huffman@27468
   358
lemma of_hypnat_hSuc: "\<And>m. of_hypnat (hSuc m) = 1 + of_hypnat m"
wenzelm@64435
   359
  by transfer (rule of_nat_Suc)
huffman@27468
   360
wenzelm@64435
   361
lemma of_hypnat_add [simp]: "\<And>m n. of_hypnat (m + n) = of_hypnat m + of_hypnat n"
wenzelm@64435
   362
  by transfer (rule of_nat_add)
huffman@27468
   363
wenzelm@64435
   364
lemma of_hypnat_mult [simp]: "\<And>m n. of_hypnat (m * n) = of_hypnat m * of_hypnat n"
wenzelm@64435
   365
  by transfer (rule of_nat_mult)
huffman@27468
   366
huffman@27468
   367
lemma of_hypnat_less_iff [simp]:
wenzelm@64435
   368
  "\<And>m n. of_hypnat m < (of_hypnat n::'a::linordered_semidom star) \<longleftrightarrow> m < n"
wenzelm@64435
   369
  by transfer (rule of_nat_less_iff)
huffman@27468
   370
huffman@27468
   371
lemma of_hypnat_0_less_iff [simp]:
wenzelm@64435
   372
  "\<And>n. 0 < (of_hypnat n::'a::linordered_semidom star) \<longleftrightarrow> 0 < n"
wenzelm@64435
   373
  by transfer (rule of_nat_0_less_iff)
huffman@27468
   374
wenzelm@64435
   375
lemma of_hypnat_less_0_iff [simp]: "\<And>m. \<not> (of_hypnat m::'a::linordered_semidom star) < 0"
wenzelm@64435
   376
  by transfer (rule of_nat_less_0_iff)
huffman@27468
   377
huffman@27468
   378
lemma of_hypnat_le_iff [simp]:
wenzelm@64435
   379
  "\<And>m n. of_hypnat m \<le> (of_hypnat n::'a::linordered_semidom star) \<longleftrightarrow> m \<le> n"
wenzelm@64435
   380
  by transfer (rule of_nat_le_iff)
huffman@27468
   381
wenzelm@64435
   382
lemma of_hypnat_0_le_iff [simp]: "\<And>n. 0 \<le> (of_hypnat n::'a::linordered_semidom star)"
wenzelm@64435
   383
  by transfer (rule of_nat_0_le_iff)
huffman@27468
   384
wenzelm@64435
   385
lemma of_hypnat_le_0_iff [simp]: "\<And>m. (of_hypnat m::'a::linordered_semidom star) \<le> 0 \<longleftrightarrow> m = 0"
wenzelm@64435
   386
  by transfer (rule of_nat_le_0_iff)
huffman@27468
   387
huffman@27468
   388
lemma of_hypnat_eq_iff [simp]:
wenzelm@64435
   389
  "\<And>m n. of_hypnat m = (of_hypnat n::'a::linordered_semidom star) \<longleftrightarrow> m = n"
wenzelm@64435
   390
  by transfer (rule of_nat_eq_iff)
huffman@27468
   391
wenzelm@64435
   392
lemma of_hypnat_eq_0_iff [simp]: "\<And>m. (of_hypnat m::'a::linordered_semidom star) = 0 \<longleftrightarrow> m = 0"
wenzelm@64435
   393
  by transfer (rule of_nat_eq_0_iff)
huffman@27468
   394
huffman@27468
   395
lemma HNatInfinite_of_hypnat_gt_zero:
haftmann@35028
   396
  "N \<in> HNatInfinite \<Longrightarrow> (0::'a::linordered_semidom star) < of_hypnat N"
wenzelm@64435
   397
  by (rule ccontr) (simp add: linorder_not_less)
huffman@27468
   398
huffman@27468
   399
end