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