author | paulson |
Thu, 27 Nov 2003 10:47:55 +0100 | |
changeset 14268 | 5cf13e80be0e |
parent 13596 | ee5f79b210c1 |
child 14294 | f4d806fd72ce |
permissions | -rw-r--r-- |
10751 | 1 |
(* Title : HyperNat.ML |
2 |
Author : Jacques D. Fleuriot |
|
3 |
Copyright : 1998 University of Cambridge |
|
4 |
Description : Explicit construction of hypernaturals using |
|
5 |
ultrafilters |
|
6 |
*) |
|
13596 | 7 |
|
8 |
(* blast confuses different versions of < *) |
|
9 |
DelIffs [order_less_irrefl]; |
|
10 |
Addsimps [order_less_irrefl]; |
|
11 |
||
10751 | 12 |
(*------------------------------------------------------------------------ |
13 |
Properties of hypnatrel |
|
14 |
------------------------------------------------------------------------*) |
|
15 |
||
16 |
(** Proving that hyprel is an equivalence relation **) |
|
17 |
(** Natural deduction for hypnatrel - similar to hyprel! **) |
|
18 |
||
19 |
Goalw [hypnatrel_def] |
|
20 |
"((X,Y): hypnatrel) = ({n. X n = Y n}: FreeUltrafilterNat)"; |
|
21 |
by (Fast_tac 1); |
|
22 |
qed "hypnatrel_iff"; |
|
23 |
||
24 |
Goalw [hypnatrel_def] |
|
25 |
"{n. X n = Y n}: FreeUltrafilterNat ==> (X,Y): hypnatrel"; |
|
26 |
by (Fast_tac 1); |
|
27 |
qed "hypnatrelI"; |
|
28 |
||
29 |
Goalw [hypnatrel_def] |
|
30 |
"p: hypnatrel --> (EX X Y. \ |
|
31 |
\ p = (X,Y) & {n. X n = Y n} : FreeUltrafilterNat)"; |
|
32 |
by (Fast_tac 1); |
|
33 |
qed "hypnatrelE_lemma"; |
|
34 |
||
35 |
val [major,minor] = Goal |
|
36 |
"[| p: hypnatrel; \ |
|
37 |
\ !!X Y. [| p = (X,Y); {n. X n = Y n}: FreeUltrafilterNat |] \ |
|
38 |
\ ==> Q |] \ |
|
39 |
\ ==> Q"; |
|
40 |
by (cut_facts_tac [major RS (hypnatrelE_lemma RS mp)] 1); |
|
41 |
by (REPEAT (eresolve_tac [asm_rl,exE,conjE,minor] 1)); |
|
42 |
qed "hypnatrelE"; |
|
43 |
||
44 |
AddSIs [hypnatrelI]; |
|
45 |
AddSEs [hypnatrelE]; |
|
46 |
||
47 |
Goalw [hypnatrel_def] "(x,x): hypnatrel"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
48 |
by Auto_tac; |
10751 | 49 |
qed "hypnatrel_refl"; |
50 |
||
51 |
Goalw [hypnatrel_def] "(x,y): hypnatrel --> (y,x):hypnatrel"; |
|
52 |
by (auto_tac (claset() addIs [lemma_perm RS subst], simpset())); |
|
53 |
qed_spec_mp "hypnatrel_sym"; |
|
54 |
||
55 |
Goalw [hypnatrel_def] |
|
56 |
"(x,y): hypnatrel --> (y,z):hypnatrel --> (x,z):hypnatrel"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
57 |
by Auto_tac; |
10751 | 58 |
by (Fuf_tac 1); |
59 |
qed_spec_mp "hypnatrel_trans"; |
|
60 |
||
61 |
Goalw [equiv_def, refl_def, sym_def, trans_def] |
|
62 |
"equiv UNIV hypnatrel"; |
|
63 |
by (auto_tac (claset() addSIs [hypnatrel_refl] |
|
64 |
addSEs [hypnatrel_sym,hypnatrel_trans] |
|
65 |
delrules [hypnatrelI,hypnatrelE], |
|
66 |
simpset())); |
|
67 |
qed "equiv_hypnatrel"; |
|
68 |
||
69 |
val equiv_hypnatrel_iff = |
|
70 |
[UNIV_I, UNIV_I] MRS (equiv_hypnatrel RS eq_equiv_class_iff); |
|
71 |
||
10834 | 72 |
Goalw [hypnat_def,hypnatrel_def,quotient_def] "hypnatrel``{x}:hypnat"; |
10751 | 73 |
by (Blast_tac 1); |
74 |
qed "hypnatrel_in_hypnat"; |
|
75 |
||
76 |
Goal "inj_on Abs_hypnat hypnat"; |
|
77 |
by (rtac inj_on_inverseI 1); |
|
78 |
by (etac Abs_hypnat_inverse 1); |
|
79 |
qed "inj_on_Abs_hypnat"; |
|
80 |
||
81 |
Addsimps [equiv_hypnatrel_iff,inj_on_Abs_hypnat RS inj_on_iff, |
|
82 |
hypnatrel_iff, hypnatrel_in_hypnat, Abs_hypnat_inverse]; |
|
83 |
||
84 |
Addsimps [equiv_hypnatrel RS eq_equiv_class_iff]; |
|
85 |
val eq_hypnatrelD = equiv_hypnatrel RSN (2,eq_equiv_class); |
|
86 |
||
87 |
Goal "inj(Rep_hypnat)"; |
|
88 |
by (rtac inj_inverseI 1); |
|
89 |
by (rtac Rep_hypnat_inverse 1); |
|
90 |
qed "inj_Rep_hypnat"; |
|
91 |
||
10834 | 92 |
Goalw [hypnatrel_def] "x: hypnatrel `` {x}"; |
10751 | 93 |
by (Step_tac 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
94 |
by Auto_tac; |
10751 | 95 |
qed "lemma_hypnatrel_refl"; |
96 |
||
97 |
Addsimps [lemma_hypnatrel_refl]; |
|
98 |
||
99 |
Goalw [hypnat_def] "{} ~: hypnat"; |
|
100 |
by (auto_tac (claset() addSEs [quotientE],simpset())); |
|
101 |
qed "hypnat_empty_not_mem"; |
|
102 |
||
103 |
Addsimps [hypnat_empty_not_mem]; |
|
104 |
||
105 |
Goal "Rep_hypnat x ~= {}"; |
|
106 |
by (cut_inst_tac [("x","x")] Rep_hypnat 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
107 |
by Auto_tac; |
10751 | 108 |
qed "Rep_hypnat_nonempty"; |
109 |
||
110 |
Addsimps [Rep_hypnat_nonempty]; |
|
111 |
||
112 |
(*------------------------------------------------------------------------ |
|
113 |
hypnat_of_nat: the injection from nat to hypnat |
|
114 |
------------------------------------------------------------------------*) |
|
115 |
Goal "inj(hypnat_of_nat)"; |
|
116 |
by (rtac injI 1); |
|
117 |
by (rewtac hypnat_of_nat_def); |
|
118 |
by (dtac (inj_on_Abs_hypnat RS inj_onD) 1); |
|
119 |
by (REPEAT (rtac hypnatrel_in_hypnat 1)); |
|
120 |
by (dtac eq_equiv_class 1); |
|
121 |
by (rtac equiv_hypnatrel 1); |
|
122 |
by (Fast_tac 1); |
|
123 |
by (rtac ccontr 1 THEN rotate_tac 1 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
124 |
by Auto_tac; |
10751 | 125 |
qed "inj_hypnat_of_nat"; |
126 |
||
127 |
val [prem] = Goal |
|
10834 | 128 |
"(!!x. z = Abs_hypnat(hypnatrel``{x}) ==> P) ==> P"; |
10751 | 129 |
by (res_inst_tac [("x1","z")] |
130 |
(rewrite_rule [hypnat_def] Rep_hypnat RS quotientE) 1); |
|
131 |
by (dres_inst_tac [("f","Abs_hypnat")] arg_cong 1); |
|
132 |
by (res_inst_tac [("x","x")] prem 1); |
|
133 |
by (asm_full_simp_tac (simpset() addsimps [Rep_hypnat_inverse]) 1); |
|
134 |
qed "eq_Abs_hypnat"; |
|
135 |
||
136 |
(*----------------------------------------------------------- |
|
137 |
Addition for hyper naturals: hypnat_add |
|
138 |
-----------------------------------------------------------*) |
|
139 |
Goalw [congruent2_def] |
|
10834 | 140 |
"congruent2 hypnatrel (%X Y. hypnatrel``{%n. X n + Y n})"; |
10751 | 141 |
by Safe_tac; |
142 |
by (ALLGOALS(Fuf_tac)); |
|
143 |
qed "hypnat_add_congruent2"; |
|
144 |
||
145 |
Goalw [hypnat_add_def] |
|
10834 | 146 |
"Abs_hypnat(hypnatrel``{%n. X n}) + Abs_hypnat(hypnatrel``{%n. Y n}) = \ |
147 |
\ Abs_hypnat(hypnatrel``{%n. X n + Y n})"; |
|
10751 | 148 |
by (asm_simp_tac |
149 |
(simpset() addsimps [[equiv_hypnatrel, hypnat_add_congruent2] |
|
150 |
MRS UN_equiv_class2]) 1); |
|
151 |
qed "hypnat_add"; |
|
152 |
||
153 |
Goal "(z::hypnat) + w = w + z"; |
|
154 |
by (res_inst_tac [("z","z")] eq_Abs_hypnat 1); |
|
155 |
by (res_inst_tac [("z","w")] eq_Abs_hypnat 1); |
|
156 |
by (asm_simp_tac (simpset() addsimps (add_ac @ [hypnat_add])) 1); |
|
157 |
qed "hypnat_add_commute"; |
|
158 |
||
159 |
Goal "((z1::hypnat) + z2) + z3 = z1 + (z2 + z3)"; |
|
160 |
by (res_inst_tac [("z","z1")] eq_Abs_hypnat 1); |
|
161 |
by (res_inst_tac [("z","z2")] eq_Abs_hypnat 1); |
|
162 |
by (res_inst_tac [("z","z3")] eq_Abs_hypnat 1); |
|
163 |
by (asm_simp_tac (simpset() addsimps [hypnat_add,add_assoc]) 1); |
|
164 |
qed "hypnat_add_assoc"; |
|
165 |
||
166 |
(*For AC rewriting*) |
|
167 |
Goal "(x::hypnat)+(y+z)=y+(x+z)"; |
|
13438
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
12018
diff
changeset
|
168 |
by(rtac ([hypnat_add_assoc,hypnat_add_commute] MRS |
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
12018
diff
changeset
|
169 |
read_instantiate[("f","op +")](thm"mk_left_commute")) 1); |
10751 | 170 |
qed "hypnat_add_left_commute"; |
171 |
||
172 |
(* hypnat addition is an AC operator *) |
|
173 |
val hypnat_add_ac = [hypnat_add_assoc,hypnat_add_commute, |
|
174 |
hypnat_add_left_commute]; |
|
175 |
||
176 |
Goalw [hypnat_zero_def] "(0::hypnat) + z = z"; |
|
177 |
by (res_inst_tac [("z","z")] eq_Abs_hypnat 1); |
|
178 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_add]) 1); |
|
179 |
qed "hypnat_add_zero_left"; |
|
180 |
||
181 |
Goal "z + (0::hypnat) = z"; |
|
182 |
by (simp_tac (simpset() addsimps |
|
183 |
[hypnat_add_zero_left,hypnat_add_commute]) 1); |
|
184 |
qed "hypnat_add_zero_right"; |
|
185 |
||
186 |
Addsimps [hypnat_add_zero_left,hypnat_add_zero_right]; |
|
187 |
||
188 |
(*----------------------------------------------------------- |
|
189 |
Subtraction for hyper naturals: hypnat_minus |
|
190 |
-----------------------------------------------------------*) |
|
191 |
Goalw [congruent2_def] |
|
10834 | 192 |
"congruent2 hypnatrel (%X Y. hypnatrel``{%n. X n - Y n})"; |
10751 | 193 |
by Safe_tac; |
194 |
by (ALLGOALS(Fuf_tac)); |
|
195 |
qed "hypnat_minus_congruent2"; |
|
196 |
||
197 |
Goalw [hypnat_minus_def] |
|
10834 | 198 |
"Abs_hypnat(hypnatrel``{%n. X n}) - Abs_hypnat(hypnatrel``{%n. Y n}) = \ |
199 |
\ Abs_hypnat(hypnatrel``{%n. X n - Y n})"; |
|
10751 | 200 |
by (asm_simp_tac |
201 |
(simpset() addsimps [[equiv_hypnatrel, hypnat_minus_congruent2] |
|
202 |
MRS UN_equiv_class2]) 1); |
|
203 |
qed "hypnat_minus"; |
|
204 |
||
205 |
Goalw [hypnat_zero_def] "z - z = (0::hypnat)"; |
|
206 |
by (res_inst_tac [("z","z")] eq_Abs_hypnat 1); |
|
207 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_minus]) 1); |
|
208 |
qed "hypnat_minus_zero"; |
|
209 |
||
210 |
Goalw [hypnat_zero_def] "(0::hypnat) - n = 0"; |
|
211 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
212 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_minus]) 1); |
|
213 |
qed "hypnat_diff_0_eq_0"; |
|
214 |
||
215 |
Addsimps [hypnat_minus_zero,hypnat_diff_0_eq_0]; |
|
216 |
||
217 |
Goalw [hypnat_zero_def] "(m+n = (0::hypnat)) = (m=0 & n=0)"; |
|
218 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
219 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
220 |
by (auto_tac (claset() addIs [FreeUltrafilterNat_subset] |
|
221 |
addDs [FreeUltrafilterNat_Int], |
|
222 |
simpset() addsimps [hypnat_add] )); |
|
223 |
qed "hypnat_add_is_0"; |
|
224 |
||
225 |
AddIffs [hypnat_add_is_0]; |
|
226 |
||
227 |
Goal "!!i::hypnat. i-j-k = i - (j+k)"; |
|
228 |
by (res_inst_tac [("z","i")] eq_Abs_hypnat 1); |
|
229 |
by (res_inst_tac [("z","j")] eq_Abs_hypnat 1); |
|
230 |
by (res_inst_tac [("z","k")] eq_Abs_hypnat 1); |
|
231 |
by (asm_full_simp_tac (simpset() addsimps |
|
232 |
[hypnat_minus,hypnat_add,diff_diff_left]) 1); |
|
233 |
qed "hypnat_diff_diff_left"; |
|
234 |
||
235 |
Goal "!!i::hypnat. i-j-k = i-k-j"; |
|
236 |
by (simp_tac (simpset() addsimps |
|
237 |
[hypnat_diff_diff_left, hypnat_add_commute]) 1); |
|
238 |
qed "hypnat_diff_commute"; |
|
239 |
||
240 |
Goal "!!n::hypnat. (n+m) - n = m"; |
|
241 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
242 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
243 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_minus,hypnat_add]) 1); |
|
244 |
qed "hypnat_diff_add_inverse"; |
|
245 |
Addsimps [hypnat_diff_add_inverse]; |
|
246 |
||
247 |
Goal "!!n::hypnat.(m+n) - n = m"; |
|
248 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
249 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
250 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_minus,hypnat_add]) 1); |
|
251 |
qed "hypnat_diff_add_inverse2"; |
|
252 |
Addsimps [hypnat_diff_add_inverse2]; |
|
253 |
||
254 |
Goal "!!k::hypnat. (k+m) - (k+n) = m - n"; |
|
255 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
256 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
257 |
by (res_inst_tac [("z","k")] eq_Abs_hypnat 1); |
|
258 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_minus,hypnat_add]) 1); |
|
259 |
qed "hypnat_diff_cancel"; |
|
260 |
Addsimps [hypnat_diff_cancel]; |
|
261 |
||
262 |
Goal "!!m::hypnat. (m+k) - (n+k) = m - n"; |
|
263 |
val hypnat_add_commute_k = read_instantiate [("w","k")] hypnat_add_commute; |
|
264 |
by (asm_simp_tac (simpset() addsimps ([hypnat_add_commute_k])) 1); |
|
265 |
qed "hypnat_diff_cancel2"; |
|
266 |
Addsimps [hypnat_diff_cancel2]; |
|
267 |
||
268 |
Goalw [hypnat_zero_def] "!!n::hypnat. n - (n+m) = (0::hypnat)"; |
|
269 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
270 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
271 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_minus,hypnat_add]) 1); |
|
272 |
qed "hypnat_diff_add_0"; |
|
273 |
Addsimps [hypnat_diff_add_0]; |
|
274 |
||
275 |
(*----------------------------------------------------------- |
|
276 |
Multiplication for hyper naturals: hypnat_mult |
|
277 |
-----------------------------------------------------------*) |
|
278 |
Goalw [congruent2_def] |
|
10834 | 279 |
"congruent2 hypnatrel (%X Y. hypnatrel``{%n. X n * Y n})"; |
10751 | 280 |
by Safe_tac; |
281 |
by (ALLGOALS(Fuf_tac)); |
|
282 |
qed "hypnat_mult_congruent2"; |
|
283 |
||
284 |
Goalw [hypnat_mult_def] |
|
10834 | 285 |
"Abs_hypnat(hypnatrel``{%n. X n}) * Abs_hypnat(hypnatrel``{%n. Y n}) = \ |
286 |
\ Abs_hypnat(hypnatrel``{%n. X n * Y n})"; |
|
10751 | 287 |
by (asm_simp_tac |
288 |
(simpset() addsimps [[equiv_hypnatrel,hypnat_mult_congruent2] MRS |
|
289 |
UN_equiv_class2]) 1); |
|
290 |
qed "hypnat_mult"; |
|
291 |
||
292 |
Goal "(z::hypnat) * w = w * z"; |
|
293 |
by (res_inst_tac [("z","z")] eq_Abs_hypnat 1); |
|
294 |
by (res_inst_tac [("z","w")] eq_Abs_hypnat 1); |
|
295 |
by (asm_simp_tac (simpset() addsimps ([hypnat_mult] @ mult_ac)) 1); |
|
296 |
qed "hypnat_mult_commute"; |
|
297 |
||
298 |
Goal "((z1::hypnat) * z2) * z3 = z1 * (z2 * z3)"; |
|
299 |
by (res_inst_tac [("z","z1")] eq_Abs_hypnat 1); |
|
300 |
by (res_inst_tac [("z","z2")] eq_Abs_hypnat 1); |
|
301 |
by (res_inst_tac [("z","z3")] eq_Abs_hypnat 1); |
|
302 |
by (asm_simp_tac (simpset() addsimps [hypnat_mult,mult_assoc]) 1); |
|
303 |
qed "hypnat_mult_assoc"; |
|
304 |
||
305 |
||
306 |
Goal "(z1::hypnat) * (z2 * z3) = z2 * (z1 * z3)"; |
|
13438
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
12018
diff
changeset
|
307 |
by(rtac ([hypnat_mult_assoc,hypnat_mult_commute] MRS |
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
12018
diff
changeset
|
308 |
read_instantiate[("f","op *")](thm"mk_left_commute")) 1); |
10751 | 309 |
qed "hypnat_mult_left_commute"; |
310 |
||
311 |
(* hypnat multiplication is an AC operator *) |
|
312 |
val hypnat_mult_ac = [hypnat_mult_assoc, hypnat_mult_commute, |
|
313 |
hypnat_mult_left_commute]; |
|
314 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
315 |
Goalw [hypnat_one_def] "(1::hypnat) * z = z"; |
10751 | 316 |
by (res_inst_tac [("z","z")] eq_Abs_hypnat 1); |
317 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_mult]) 1); |
|
318 |
qed "hypnat_mult_1"; |
|
319 |
Addsimps [hypnat_mult_1]; |
|
320 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
321 |
Goal "z * (1::hypnat) = z"; |
10751 | 322 |
by (simp_tac (simpset() addsimps [hypnat_mult_commute]) 1); |
323 |
qed "hypnat_mult_1_right"; |
|
324 |
Addsimps [hypnat_mult_1_right]; |
|
325 |
||
326 |
Goalw [hypnat_zero_def] "(0::hypnat) * z = 0"; |
|
327 |
by (res_inst_tac [("z","z")] eq_Abs_hypnat 1); |
|
328 |
by (asm_full_simp_tac (simpset() addsimps [hypnat_mult]) 1); |
|
329 |
qed "hypnat_mult_0"; |
|
330 |
Addsimps [hypnat_mult_0]; |
|
331 |
||
332 |
Goal "z * (0::hypnat) = 0"; |
|
333 |
by (simp_tac (simpset() addsimps [hypnat_mult_commute]) 1); |
|
334 |
qed "hypnat_mult_0_right"; |
|
335 |
Addsimps [hypnat_mult_0_right]; |
|
336 |
||
337 |
Goal "!!m::hypnat. (m - n) * k = (m * k) - (n * k)"; |
|
338 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
339 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
340 |
by (res_inst_tac [("z","k")] eq_Abs_hypnat 1); |
|
341 |
by (asm_simp_tac (simpset() addsimps [hypnat_mult, |
|
342 |
hypnat_minus,diff_mult_distrib]) 1); |
|
343 |
qed "hypnat_diff_mult_distrib" ; |
|
344 |
||
345 |
Goal "!!m::hypnat. k * (m - n) = (k * m) - (k * n)"; |
|
346 |
val hypnat_mult_commute_k = read_instantiate [("z","k")] hypnat_mult_commute; |
|
347 |
by (simp_tac (simpset() addsimps [hypnat_diff_mult_distrib, |
|
348 |
hypnat_mult_commute_k]) 1); |
|
349 |
qed "hypnat_diff_mult_distrib2" ; |
|
350 |
||
351 |
(*-------------------------- |
|
352 |
A Few more theorems |
|
353 |
-------------------------*) |
|
354 |
||
355 |
Goal "(z::hypnat) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"; |
|
356 |
by (asm_simp_tac (simpset() addsimps [hypnat_add_assoc RS sym]) 1); |
|
357 |
qed "hypnat_add_assoc_cong"; |
|
358 |
||
359 |
Goal "(z::hypnat) + (v + w) = v + (z + w)"; |
|
360 |
by (REPEAT (ares_tac [hypnat_add_commute RS hypnat_add_assoc_cong] 1)); |
|
361 |
qed "hypnat_add_assoc_swap"; |
|
362 |
||
363 |
Goal "((z1::hypnat) + z2) * w = (z1 * w) + (z2 * w)"; |
|
364 |
by (res_inst_tac [("z","z1")] eq_Abs_hypnat 1); |
|
365 |
by (res_inst_tac [("z","z2")] eq_Abs_hypnat 1); |
|
366 |
by (res_inst_tac [("z","w")] eq_Abs_hypnat 1); |
|
367 |
by (asm_simp_tac (simpset() addsimps [hypnat_mult,hypnat_add, |
|
368 |
add_mult_distrib]) 1); |
|
369 |
qed "hypnat_add_mult_distrib"; |
|
370 |
Addsimps [hypnat_add_mult_distrib]; |
|
371 |
||
372 |
val hypnat_mult_commute'= read_instantiate [("z","w")] hypnat_mult_commute; |
|
373 |
||
374 |
Goal "(w::hypnat) * (z1 + z2) = (w * z1) + (w * z2)"; |
|
375 |
by (simp_tac (simpset() addsimps [hypnat_mult_commute']) 1); |
|
376 |
qed "hypnat_add_mult_distrib2"; |
|
377 |
Addsimps [hypnat_add_mult_distrib2]; |
|
378 |
||
379 |
(*** (hypnat) one and zero are distinct ***) |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
380 |
Goalw [hypnat_zero_def,hypnat_one_def] "(0::hypnat) ~= (1::hypnat)"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
381 |
by Auto_tac; |
10751 | 382 |
qed "hypnat_zero_not_eq_one"; |
383 |
Addsimps [hypnat_zero_not_eq_one]; |
|
384 |
Addsimps [hypnat_zero_not_eq_one RS not_sym]; |
|
385 |
||
386 |
Goalw [hypnat_zero_def] "(m*n = (0::hypnat)) = (m=0 | n=0)"; |
|
387 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
388 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
389 |
by (auto_tac (claset() addSDs [FreeUltrafilterNat_Compl_mem], |
|
390 |
simpset() addsimps [hypnat_mult])); |
|
391 |
by (ALLGOALS(Fuf_tac)); |
|
392 |
qed "hypnat_mult_is_0"; |
|
393 |
Addsimps [hypnat_mult_is_0]; |
|
394 |
||
395 |
(*------------------------------------------------------------------ |
|
396 |
Theorems for ordering |
|
397 |
------------------------------------------------------------------*) |
|
398 |
||
399 |
(* prove introduction and elimination rules for hypnat_less *) |
|
400 |
||
401 |
Goalw [hypnat_less_def] |
|
11655 | 402 |
"(P < (Q::hypnat)) = (EX X Y. X : Rep_hypnat(P) & \ |
10751 | 403 |
\ Y : Rep_hypnat(Q) & \ |
404 |
\ {n. X n < Y n} : FreeUltrafilterNat)"; |
|
405 |
by (Fast_tac 1); |
|
406 |
qed "hypnat_less_iff"; |
|
407 |
||
408 |
Goalw [hypnat_less_def] |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
409 |
"[| {n. X n < Y n} : FreeUltrafilterNat; \ |
10751 | 410 |
\ X : Rep_hypnat(P); \ |
411 |
\ Y : Rep_hypnat(Q) |] ==> P < (Q::hypnat)"; |
|
412 |
by (Fast_tac 1); |
|
413 |
qed "hypnat_lessI"; |
|
414 |
||
415 |
Goalw [hypnat_less_def] |
|
416 |
"!! R1. [| R1 < (R2::hypnat); \ |
|
417 |
\ !!X Y. {n. X n < Y n} : FreeUltrafilterNat ==> P; \ |
|
418 |
\ !!X. X : Rep_hypnat(R1) ==> P; \ |
|
419 |
\ !!Y. Y : Rep_hypnat(R2) ==> P |] \ |
|
420 |
\ ==> P"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
421 |
by Auto_tac; |
10751 | 422 |
qed "hypnat_lessE"; |
423 |
||
424 |
Goalw [hypnat_less_def] |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
425 |
"R1 < (R2::hypnat) ==> (EX X Y. {n. X n < Y n} : FreeUltrafilterNat & \ |
10751 | 426 |
\ X : Rep_hypnat(R1) & \ |
427 |
\ Y : Rep_hypnat(R2))"; |
|
428 |
by (Fast_tac 1); |
|
429 |
qed "hypnat_lessD"; |
|
430 |
||
431 |
Goal "~ (R::hypnat) < R"; |
|
432 |
by (res_inst_tac [("z","R")] eq_Abs_hypnat 1); |
|
433 |
by (auto_tac (claset(),simpset() addsimps [hypnat_less_def])); |
|
434 |
by (Fuf_empty_tac 1); |
|
435 |
qed "hypnat_less_not_refl"; |
|
436 |
Addsimps [hypnat_less_not_refl]; |
|
437 |
||
438 |
bind_thm("hypnat_less_irrefl",hypnat_less_not_refl RS notE); |
|
439 |
||
440 |
Goalw [hypnat_less_def,hypnat_zero_def] "~ n<(0::hypnat)"; |
|
441 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
442 |
by Auto_tac; |
10751 | 443 |
by (Fuf_empty_tac 1); |
444 |
qed "hypnat_not_less0"; |
|
445 |
AddIffs [hypnat_not_less0]; |
|
446 |
||
447 |
(* n<(0::hypnat) ==> R *) |
|
448 |
bind_thm ("hypnat_less_zeroE", hypnat_not_less0 RS notE); |
|
449 |
||
450 |
Goalw [hypnat_less_def,hypnat_zero_def,hypnat_one_def] |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
451 |
"(n<(1::hypnat)) = (n=0)"; |
10751 | 452 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
453 |
by (auto_tac (claset() addSIs [exI] addEs |
|
454 |
[FreeUltrafilterNat_subset],simpset())); |
|
455 |
by (Fuf_tac 1); |
|
456 |
qed "hypnat_less_one"; |
|
457 |
AddIffs [hypnat_less_one]; |
|
458 |
||
459 |
Goal "!!(R1::hypnat). [| R1 < R2; R2 < R3 |] ==> R1 < R3"; |
|
460 |
by (res_inst_tac [("z","R1")] eq_Abs_hypnat 1); |
|
461 |
by (res_inst_tac [("z","R2")] eq_Abs_hypnat 1); |
|
462 |
by (res_inst_tac [("z","R3")] eq_Abs_hypnat 1); |
|
463 |
by (auto_tac (claset(),simpset() addsimps [hypnat_less_def])); |
|
464 |
by (res_inst_tac [("x","X")] exI 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
465 |
by Auto_tac; |
10751 | 466 |
by (res_inst_tac [("x","Ya")] exI 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
467 |
by Auto_tac; |
10751 | 468 |
by (Fuf_tac 1); |
469 |
qed "hypnat_less_trans"; |
|
470 |
||
471 |
Goal "!! (R1::hypnat). [| R1 < R2; R2 < R1 |] ==> P"; |
|
472 |
by (dtac hypnat_less_trans 1 THEN assume_tac 1); |
|
473 |
by (Asm_full_simp_tac 1); |
|
474 |
qed "hypnat_less_asym"; |
|
475 |
||
476 |
(*----- hypnat less iff less a.e -----*) |
|
477 |
(* See comments in HYPER for corresponding thm *) |
|
478 |
||
479 |
Goalw [hypnat_less_def] |
|
10834 | 480 |
"(Abs_hypnat(hypnatrel``{%n. X n}) < \ |
481 |
\ Abs_hypnat(hypnatrel``{%n. Y n})) = \ |
|
10751 | 482 |
\ ({n. X n < Y n} : FreeUltrafilterNat)"; |
483 |
by (auto_tac (claset() addSIs [lemma_hypnatrel_refl],simpset())); |
|
484 |
by (Fuf_tac 1); |
|
485 |
qed "hypnat_less"; |
|
486 |
||
487 |
Goal "~ m<n --> n+(m-n) = (m::hypnat)"; |
|
488 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
489 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
490 |
by (auto_tac (claset(),simpset() addsimps |
|
491 |
[hypnat_minus,hypnat_add,hypnat_less])); |
|
492 |
by (dtac FreeUltrafilterNat_Compl_mem 1); |
|
493 |
by (Fuf_tac 1); |
|
494 |
qed_spec_mp "hypnat_add_diff_inverse"; |
|
495 |
||
496 |
Goal "n<=m ==> n+(m-n) = (m::hypnat)"; |
|
497 |
by (asm_full_simp_tac (simpset() addsimps |
|
498 |
[hypnat_add_diff_inverse, hypnat_le_def]) 1); |
|
499 |
qed "hypnat_le_add_diff_inverse"; |
|
500 |
||
501 |
Goal "n<=m ==> (m-n)+n = (m::hypnat)"; |
|
502 |
by (asm_simp_tac (simpset() addsimps [hypnat_le_add_diff_inverse, |
|
503 |
hypnat_add_commute]) 1); |
|
504 |
qed "hypnat_le_add_diff_inverse2"; |
|
505 |
||
506 |
(*--------------------------------------------------------------------------------- |
|
507 |
Hyper naturals as a linearly ordered field |
|
508 |
---------------------------------------------------------------------------------*) |
|
509 |
Goalw [hypnat_zero_def] |
|
510 |
"[| (0::hypnat) < x; 0 < y |] ==> 0 < x + y"; |
|
511 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
|
512 |
by (res_inst_tac [("z","y")] eq_Abs_hypnat 1); |
|
513 |
by (auto_tac (claset(),simpset() addsimps |
|
514 |
[hypnat_less_def,hypnat_add])); |
|
515 |
by (REPEAT(Step_tac 1)); |
|
516 |
by (Fuf_tac 1); |
|
517 |
qed "hypnat_add_order"; |
|
518 |
||
519 |
Goalw [hypnat_zero_def] |
|
520 |
"!!(x::hypnat). [| (0::hypnat) < x; 0 < y |] ==> 0 < x * y"; |
|
521 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
|
522 |
by (res_inst_tac [("z","y")] eq_Abs_hypnat 1); |
|
523 |
by (auto_tac (claset(),simpset() addsimps |
|
524 |
[hypnat_less_def,hypnat_mult])); |
|
525 |
by (REPEAT(Step_tac 1)); |
|
526 |
by (Fuf_tac 1); |
|
527 |
qed "hypnat_mult_order"; |
|
528 |
||
529 |
(*--------------------------------------------------------------------------------- |
|
530 |
Trichotomy of the hyper naturals |
|
531 |
--------------------------------------------------------------------------------*) |
|
10834 | 532 |
Goalw [hypnatrel_def] "EX x. x: hypnatrel `` {%n. 0}"; |
10751 | 533 |
by (res_inst_tac [("x","%n. 0")] exI 1); |
534 |
by (Step_tac 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
535 |
by Auto_tac; |
10751 | 536 |
qed "lemma_hypnatrel_0_mem"; |
537 |
||
538 |
(* linearity is actually proved further down! *) |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
539 |
Goalw [hypnat_zero_def, hypnat_less_def] |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
540 |
"(0::hypnat) < x | x = 0 | x < 0"; |
10751 | 541 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
542 |
by (Auto_tac ); |
|
543 |
by (REPEAT(Step_tac 1)); |
|
544 |
by (REPEAT(dtac FreeUltrafilterNat_Compl_mem 1)); |
|
545 |
by (Fuf_tac 1); |
|
546 |
qed "hypnat_trichotomy"; |
|
547 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
548 |
Goal "!!P. [| (0::hypnat) < x ==> P; \ |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
549 |
\ x = 0 ==> P; \ |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
550 |
\ x < 0 ==> P |] ==> P"; |
10751 | 551 |
by (cut_inst_tac [("x","x")] hypnat_trichotomy 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
552 |
by Auto_tac; |
10751 | 553 |
qed "hypnat_trichotomyE"; |
554 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
555 |
(*---------------------------------------------------------------------------- |
10751 | 556 |
More properties of < |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
557 |
----------------------------------------------------------------------------*) |
10751 | 558 |
Goal "!!(A::hypnat). A < B ==> A + C < B + C"; |
559 |
by (res_inst_tac [("z","A")] eq_Abs_hypnat 1); |
|
560 |
by (res_inst_tac [("z","B")] eq_Abs_hypnat 1); |
|
561 |
by (res_inst_tac [("z","C")] eq_Abs_hypnat 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
562 |
by (auto_tac (claset(), simpset() addsimps [hypnat_less_def,hypnat_add])); |
10751 | 563 |
by (REPEAT(Step_tac 1)); |
564 |
by (Fuf_tac 1); |
|
565 |
qed "hypnat_add_less_mono1"; |
|
566 |
||
567 |
Goal "!!(A::hypnat). A < B ==> C + A < C + B"; |
|
568 |
by (auto_tac (claset() addIs [hypnat_add_less_mono1], |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
569 |
simpset() addsimps [hypnat_add_commute])); |
10751 | 570 |
qed "hypnat_add_less_mono2"; |
571 |
||
572 |
Goal "!!k l::hypnat. [|i<j; k<l |] ==> i + k < j + l"; |
|
573 |
by (etac (hypnat_add_less_mono1 RS hypnat_less_trans) 1); |
|
574 |
by (simp_tac (simpset() addsimps [hypnat_add_commute]) 1); |
|
575 |
(*j moves to the end because it is free while k, l are bound*) |
|
576 |
by (etac hypnat_add_less_mono1 1); |
|
577 |
qed "hypnat_add_less_mono"; |
|
578 |
||
579 |
(*--------------------------------------- |
|
580 |
hypnat_minus_less |
|
581 |
---------------------------------------*) |
|
582 |
Goalw [hypnat_less_def,hypnat_zero_def] |
|
583 |
"((x::hypnat) < y) = ((0::hypnat) < y - x)"; |
|
584 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
|
585 |
by (res_inst_tac [("z","y")] eq_Abs_hypnat 1); |
|
586 |
by (auto_tac (claset(),simpset() addsimps |
|
587 |
[hypnat_minus])); |
|
588 |
by (REPEAT(Step_tac 1)); |
|
589 |
by (REPEAT(Step_tac 2)); |
|
590 |
by (ALLGOALS(fuf_tac (claset() addDs [sym],simpset()))); |
|
591 |
||
592 |
(*** linearity ***) |
|
593 |
Goalw [hypnat_less_def] "(x::hypnat) < y | x = y | y < x"; |
|
594 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
|
595 |
by (res_inst_tac [("z","y")] eq_Abs_hypnat 1); |
|
596 |
by (Auto_tac ); |
|
597 |
by (REPEAT(Step_tac 1)); |
|
598 |
by (REPEAT(dtac FreeUltrafilterNat_Compl_mem 1)); |
|
599 |
by (Fuf_tac 1); |
|
600 |
qed "hypnat_linear"; |
|
601 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
602 |
Goal "!!(x::hypnat). [| x < y ==> P; x = y ==> P; \ |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
603 |
\ y < x ==> P |] ==> P"; |
10751 | 604 |
by (cut_inst_tac [("x","x"),("y","y")] hypnat_linear 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
605 |
by Auto_tac; |
10751 | 606 |
qed "hypnat_linear_less2"; |
607 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
608 |
Goal "((w::hypnat) ~= z) = (w<z | z<w)"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
609 |
by (cut_facts_tac [hypnat_linear] 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
610 |
by Auto_tac; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
611 |
qed "hypnat_neq_iff"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
612 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
613 |
(* Axiom 'order_less_le' of class 'order': *) |
11655 | 614 |
Goal "((w::hypnat) < z) = (w <= z & w ~= z)"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
615 |
by (simp_tac (simpset() addsimps [hypnat_le_def, hypnat_neq_iff]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
616 |
by (blast_tac (claset() addIs [hypnat_less_asym]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
617 |
qed "hypnat_less_le"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
618 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
619 |
(*---------------------------------------------------------------------------- |
10751 | 620 |
Properties of <= |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
621 |
----------------------------------------------------------------------------*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
622 |
|
10751 | 623 |
(*------ hypnat le iff nat le a.e ------*) |
624 |
Goalw [hypnat_le_def,le_def] |
|
10834 | 625 |
"(Abs_hypnat(hypnatrel``{%n. X n}) <= \ |
626 |
\ Abs_hypnat(hypnatrel``{%n. Y n})) = \ |
|
10751 | 627 |
\ ({n. X n <= Y n} : FreeUltrafilterNat)"; |
628 |
by (auto_tac (claset() addSDs [FreeUltrafilterNat_Compl_mem], |
|
629 |
simpset() addsimps [hypnat_less])); |
|
630 |
by (Fuf_tac 1 THEN Fuf_empty_tac 1); |
|
631 |
qed "hypnat_le"; |
|
632 |
||
633 |
(*---------------------------------------------------------*) |
|
634 |
(*---------------------------------------------------------*) |
|
635 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
636 |
Goalw [hypnat_le_def] "z < w ==> z <= (w::hypnat)"; |
10751 | 637 |
by (fast_tac (claset() addEs [hypnat_less_asym]) 1); |
638 |
qed "hypnat_less_imp_le"; |
|
639 |
||
640 |
Goalw [hypnat_le_def] "!!(x::hypnat). x <= y ==> x < y | x = y"; |
|
641 |
by (cut_facts_tac [hypnat_linear] 1); |
|
642 |
by (fast_tac (claset() addEs [hypnat_less_irrefl,hypnat_less_asym]) 1); |
|
643 |
qed "hypnat_le_imp_less_or_eq"; |
|
644 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
645 |
Goalw [hypnat_le_def] "z<w | z=w ==> z <=(w::hypnat)"; |
10751 | 646 |
by (cut_facts_tac [hypnat_linear] 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
647 |
by (blast_tac (claset() addDs [hypnat_less_irrefl,hypnat_less_asym]) 1); |
10751 | 648 |
qed "hypnat_less_or_eq_imp_le"; |
649 |
||
650 |
Goal "(x <= (y::hypnat)) = (x < y | x=y)"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
651 |
by (REPEAT(ares_tac [iffI, hypnat_less_or_eq_imp_le, |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
652 |
hypnat_le_imp_less_or_eq] 1)); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
653 |
qed "hypnat_le_less"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
654 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
655 |
(* Axiom 'linorder_linear' of class 'linorder': *) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
656 |
Goal "(z::hypnat) <= w | w <= z"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
657 |
by (simp_tac (simpset() addsimps [hypnat_le_less]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
658 |
by (cut_facts_tac [hypnat_linear] 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
659 |
by (Blast_tac 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
660 |
qed "hypnat_le_linear"; |
10751 | 661 |
|
662 |
Goal "w <= (w::hypnat)"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
663 |
by (simp_tac (simpset() addsimps [hypnat_le_less]) 1); |
10751 | 664 |
qed "hypnat_le_refl"; |
665 |
Addsimps [hypnat_le_refl]; |
|
666 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
667 |
Goal "[| i <= j; j <= k |] ==> i <= (k::hypnat)"; |
10751 | 668 |
by (EVERY1 [dtac hypnat_le_imp_less_or_eq, dtac hypnat_le_imp_less_or_eq, |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
669 |
rtac hypnat_less_or_eq_imp_le, |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
670 |
fast_tac (claset() addIs [hypnat_less_trans])]); |
10751 | 671 |
qed "hypnat_le_trans"; |
672 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
673 |
Goal "[| z <= w; w <= z |] ==> z = (w::hypnat)"; |
10751 | 674 |
by (EVERY1 [dtac hypnat_le_imp_less_or_eq, dtac hypnat_le_imp_less_or_eq, |
675 |
fast_tac (claset() addEs [hypnat_less_irrefl,hypnat_less_asym])]); |
|
676 |
qed "hypnat_le_anti_sym"; |
|
677 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
678 |
Goal "[| (0::hypnat) <= x; 0 <= y |] ==> 0 <= x * y"; |
10751 | 679 |
by (REPEAT(dtac hypnat_le_imp_less_or_eq 1)); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
680 |
by (auto_tac (claset() addIs [hypnat_mult_order, hypnat_less_imp_le], |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
681 |
simpset() addsimps [hypnat_le_refl])); |
10751 | 682 |
qed "hypnat_le_mult_order"; |
683 |
||
684 |
Goalw [hypnat_one_def,hypnat_zero_def,hypnat_less_def] |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
685 |
"(0::hypnat) < (1::hypnat)"; |
10751 | 686 |
by (res_inst_tac [("x","%n. 0")] exI 1); |
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11655
diff
changeset
|
687 |
by (res_inst_tac [("x","%n. Suc 0")] exI 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
688 |
by Auto_tac; |
10751 | 689 |
qed "hypnat_zero_less_one"; |
690 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
691 |
Goal "[| (0::hypnat) <= x; 0 <= y |] ==> 0 <= x + y"; |
10751 | 692 |
by (REPEAT(dtac hypnat_le_imp_less_or_eq 1)); |
693 |
by (auto_tac (claset() addIs [hypnat_add_order, |
|
694 |
hypnat_less_imp_le],simpset() addsimps [hypnat_le_refl])); |
|
695 |
qed "hypnat_le_add_order"; |
|
696 |
||
697 |
Goal "!!(q1::hypnat). q1 <= q2 ==> x + q1 <= x + q2"; |
|
698 |
by (dtac hypnat_le_imp_less_or_eq 1); |
|
699 |
by (Step_tac 1); |
|
700 |
by (auto_tac (claset() addSIs [hypnat_le_refl, |
|
701 |
hypnat_less_imp_le,hypnat_add_less_mono1], |
|
702 |
simpset() addsimps [hypnat_add_commute])); |
|
703 |
qed "hypnat_add_le_mono2"; |
|
704 |
||
705 |
Goal "!!(q1::hypnat). q1 <= q2 ==> q1 + x <= q2 + x"; |
|
706 |
by (auto_tac (claset() addDs [hypnat_add_le_mono2], |
|
707 |
simpset() addsimps [hypnat_add_commute])); |
|
708 |
qed "hypnat_add_le_mono1"; |
|
709 |
||
710 |
Goal "!!k l::hypnat. [|i<=j; k<=l |] ==> i + k <= j + l"; |
|
711 |
by (etac (hypnat_add_le_mono1 RS hypnat_le_trans) 1); |
|
712 |
by (simp_tac (simpset() addsimps [hypnat_add_commute]) 1); |
|
713 |
(*j moves to the end because it is free while k, l are bound*) |
|
714 |
by (etac hypnat_add_le_mono1 1); |
|
715 |
qed "hypnat_add_le_mono"; |
|
716 |
||
717 |
Goalw [hypnat_zero_def] |
|
718 |
"!!x::hypnat. [| (0::hypnat) < z; x < y |] ==> x * z < y * z"; |
|
719 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
|
720 |
by (res_inst_tac [("z","y")] eq_Abs_hypnat 1); |
|
721 |
by (res_inst_tac [("z","z")] eq_Abs_hypnat 1); |
|
722 |
by (auto_tac (claset(),simpset() addsimps |
|
723 |
[hypnat_less,hypnat_mult])); |
|
724 |
by (Fuf_tac 1); |
|
725 |
qed "hypnat_mult_less_mono1"; |
|
726 |
||
727 |
Goal "!!x::hypnat. [| 0 < z; x < y |] ==> z * x < z * y"; |
|
728 |
by (auto_tac (claset() addIs [hypnat_mult_less_mono1], |
|
729 |
simpset() addsimps [hypnat_mult_commute])); |
|
730 |
qed "hypnat_mult_less_mono2"; |
|
731 |
||
732 |
Addsimps [hypnat_mult_less_mono2,hypnat_mult_less_mono1]; |
|
733 |
||
734 |
Goal "(x::hypnat) <= n + x"; |
|
735 |
by (res_inst_tac [("x","n")] hypnat_trichotomyE 1); |
|
736 |
by (auto_tac (claset() addDs [(hypnat_less_imp_le RS |
|
737 |
hypnat_add_le_mono1)],simpset() addsimps [hypnat_le_refl])); |
|
738 |
qed "hypnat_add_self_le"; |
|
739 |
Addsimps [hypnat_add_self_le]; |
|
740 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
741 |
Goal "(x::hypnat) < x + (1::hypnat)"; |
10751 | 742 |
by (cut_facts_tac [hypnat_zero_less_one |
743 |
RS hypnat_add_less_mono2] 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
744 |
by Auto_tac; |
10751 | 745 |
qed "hypnat_add_one_self_less"; |
746 |
Addsimps [hypnat_add_one_self_less]; |
|
747 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
748 |
Goalw [hypnat_le_def] "~ x + (1::hypnat) <= x"; |
10751 | 749 |
by (Simp_tac 1); |
750 |
qed "not_hypnat_add_one_le_self"; |
|
751 |
Addsimps [not_hypnat_add_one_le_self]; |
|
752 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
753 |
Goal "((0::hypnat) < n) = ((1::hypnat) <= n)"; |
10751 | 754 |
by (res_inst_tac [("x","n")] hypnat_trichotomyE 1); |
755 |
by (auto_tac (claset(),simpset() addsimps [hypnat_le_def])); |
|
756 |
qed "hypnat_gt_zero_iff"; |
|
757 |
||
758 |
Addsimps [hypnat_le_add_diff_inverse, hypnat_le_add_diff_inverse2, |
|
759 |
hypnat_less_imp_le RS hypnat_le_add_diff_inverse2]; |
|
760 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
761 |
Goal "(0 < n) = (EX m. n = m + (1::hypnat))"; |
10751 | 762 |
by (Step_tac 1); |
763 |
by (res_inst_tac [("x","m")] hypnat_trichotomyE 2); |
|
764 |
by (rtac hypnat_less_trans 2); |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
765 |
by (res_inst_tac [("x","n - (1::hypnat)")] exI 1); |
10751 | 766 |
by (auto_tac (claset(),simpset() addsimps |
767 |
[hypnat_gt_zero_iff,hypnat_add_commute])); |
|
768 |
qed "hypnat_gt_zero_iff2"; |
|
769 |
||
770 |
Goalw [hypnat_zero_def] "(0::hypnat) <= n"; |
|
771 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
772 |
by (asm_simp_tac (simpset() addsimps [hypnat_le]) 1); |
|
773 |
qed "hypnat_le_zero"; |
|
774 |
Addsimps [hypnat_le_zero]; |
|
775 |
||
776 |
(*------------------------------------------------------------------ |
|
777 |
hypnat_of_nat: properties embedding of naturals in hypernaturals |
|
778 |
-----------------------------------------------------------------*) |
|
779 |
(** hypnat_of_nat preserves field and order properties **) |
|
780 |
||
781 |
Goalw [hypnat_of_nat_def] |
|
782 |
"hypnat_of_nat ((z1::nat) + z2) = \ |
|
783 |
\ hypnat_of_nat z1 + hypnat_of_nat z2"; |
|
784 |
by (asm_simp_tac (simpset() addsimps [hypnat_add]) 1); |
|
785 |
qed "hypnat_of_nat_add"; |
|
786 |
||
787 |
Goalw [hypnat_of_nat_def] |
|
788 |
"hypnat_of_nat ((z1::nat) - z2) = \ |
|
789 |
\ hypnat_of_nat z1 - hypnat_of_nat z2"; |
|
790 |
by (asm_simp_tac (simpset() addsimps [hypnat_minus]) 1); |
|
791 |
qed "hypnat_of_nat_minus"; |
|
792 |
||
793 |
Goalw [hypnat_of_nat_def] |
|
794 |
"hypnat_of_nat (z1 * z2) = hypnat_of_nat z1 * hypnat_of_nat z2"; |
|
795 |
by (full_simp_tac (simpset() addsimps [hypnat_mult]) 1); |
|
796 |
qed "hypnat_of_nat_mult"; |
|
797 |
||
798 |
Goalw [hypnat_less_def,hypnat_of_nat_def] |
|
799 |
"(z1 < z2) = (hypnat_of_nat z1 < hypnat_of_nat z2)"; |
|
800 |
by (auto_tac (claset() addSIs [exI] addIs |
|
801 |
[FreeUltrafilterNat_all],simpset())); |
|
802 |
by (rtac FreeUltrafilterNat_P 1 THEN Fuf_tac 1); |
|
803 |
qed "hypnat_of_nat_less_iff"; |
|
804 |
Addsimps [hypnat_of_nat_less_iff RS sym]; |
|
805 |
||
806 |
Goalw [hypnat_le_def,le_def] |
|
807 |
"(z1 <= z2) = (hypnat_of_nat z1 <= hypnat_of_nat z2)"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
808 |
by Auto_tac; |
10751 | 809 |
qed "hypnat_of_nat_le_iff"; |
810 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
811 |
Goalw [hypnat_of_nat_def,hypnat_one_def] "hypnat_of_nat (Suc 0) = (1::hypnat)"; |
10751 | 812 |
by (Simp_tac 1); |
813 |
qed "hypnat_of_nat_one"; |
|
814 |
||
11468 | 815 |
Goalw [hypnat_of_nat_def,hypnat_zero_def] "hypnat_of_nat 0 = 0"; |
10751 | 816 |
by (Simp_tac 1); |
817 |
qed "hypnat_of_nat_zero"; |
|
818 |
||
819 |
Goal "(hypnat_of_nat n = 0) = (n = 0)"; |
|
820 |
by (auto_tac (claset() addIs [FreeUltrafilterNat_P], |
|
821 |
simpset() addsimps [hypnat_of_nat_def, |
|
822 |
hypnat_zero_def])); |
|
823 |
qed "hypnat_of_nat_zero_iff"; |
|
824 |
||
825 |
Goal "(hypnat_of_nat n ~= 0) = (n ~= 0)"; |
|
826 |
by (full_simp_tac (simpset() addsimps [hypnat_of_nat_zero_iff]) 1); |
|
827 |
qed "hypnat_of_nat_not_zero_iff"; |
|
828 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
829 |
Goalw [hypnat_of_nat_def,hypnat_one_def] |
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
830 |
"hypnat_of_nat (Suc n) = hypnat_of_nat n + (1::hypnat)"; |
10751 | 831 |
by (auto_tac (claset(),simpset() addsimps [hypnat_add])); |
832 |
qed "hypnat_of_nat_Suc"; |
|
833 |
||
834 |
(*--------------------------------------------------------------------------------- |
|
835 |
Existence of infinite hypernatural number |
|
836 |
---------------------------------------------------------------------------------*) |
|
837 |
||
10834 | 838 |
Goal "hypnatrel``{%n::nat. n} : hypnat"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
839 |
by Auto_tac; |
10751 | 840 |
qed "hypnat_omega"; |
841 |
||
842 |
Goalw [hypnat_omega_def] "Rep_hypnat(whn) : hypnat"; |
|
843 |
by (rtac Rep_hypnat 1); |
|
844 |
qed "Rep_hypnat_omega"; |
|
845 |
||
846 |
(* See Hyper.thy for similar argument*) |
|
847 |
(* existence of infinite number not corresponding to any natural number *) |
|
848 |
(* use assumption that member FreeUltrafilterNat is not finite *) |
|
849 |
(* a few lemmas first *) |
|
850 |
||
851 |
Goalw [hypnat_omega_def,hypnat_of_nat_def] |
|
852 |
"~ (EX x. hypnat_of_nat x = whn)"; |
|
853 |
by (auto_tac (claset() addDs [FreeUltrafilterNat_not_finite], |
|
854 |
simpset())); |
|
855 |
qed "not_ex_hypnat_of_nat_eq_omega"; |
|
856 |
||
857 |
Goal "hypnat_of_nat x ~= whn"; |
|
858 |
by (cut_facts_tac [not_ex_hypnat_of_nat_eq_omega] 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
859 |
by Auto_tac; |
10751 | 860 |
qed "hypnat_of_nat_not_eq_omega"; |
861 |
Addsimps [hypnat_of_nat_not_eq_omega RS not_sym]; |
|
862 |
||
863 |
(*----------------------------------------------------------- |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
864 |
Properties of the set Nats of embedded natural numbers |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
865 |
(cf. set Reals in NSA.thy/NSA.ML) |
10751 | 866 |
----------------------------------------------------------*) |
867 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
868 |
(* Infinite hypernatural not in embedded Nats *) |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
869 |
Goalw [SHNat_def] "whn ~: Nats"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
870 |
by Auto_tac; |
10751 | 871 |
qed "SHNAT_omega_not_mem"; |
872 |
Addsimps [SHNAT_omega_not_mem]; |
|
873 |
||
874 |
(*----------------------------------------------------------------------- |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
875 |
Closure laws for members of (embedded) set standard naturals Nats |
10751 | 876 |
-----------------------------------------------------------------------*) |
877 |
Goalw [SHNat_def] |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
878 |
"!!x::hypnat. [| x: Nats; y: Nats |] ==> x + y: Nats"; |
10751 | 879 |
by (Step_tac 1); |
880 |
by (res_inst_tac [("x","N + Na")] exI 1); |
|
881 |
by (simp_tac (simpset() addsimps [hypnat_of_nat_add]) 1); |
|
882 |
qed "SHNat_add"; |
|
883 |
||
884 |
Goalw [SHNat_def] |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
885 |
"!!x::hypnat. [| x: Nats; y: Nats |] ==> x - y: Nats"; |
10751 | 886 |
by (Step_tac 1); |
887 |
by (res_inst_tac [("x","N - Na")] exI 1); |
|
888 |
by (simp_tac (simpset() addsimps [hypnat_of_nat_minus]) 1); |
|
889 |
qed "SHNat_minus"; |
|
890 |
||
891 |
Goalw [SHNat_def] |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
892 |
"!!x::hypnat. [| x: Nats; y: Nats |] ==> x * y: Nats"; |
10751 | 893 |
by (Step_tac 1); |
894 |
by (res_inst_tac [("x","N * Na")] exI 1); |
|
895 |
by (simp_tac (simpset() addsimps [hypnat_of_nat_mult]) 1); |
|
896 |
qed "SHNat_mult"; |
|
897 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
898 |
Goal"!!x::hypnat. [| x + y : Nats; y: Nats |] ==> x: Nats"; |
10751 | 899 |
by (dres_inst_tac [("x","x+y")] SHNat_minus 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
900 |
by Auto_tac; |
10751 | 901 |
qed "SHNat_add_cancel"; |
902 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
903 |
Goalw [SHNat_def] "hypnat_of_nat x : Nats"; |
10751 | 904 |
by (Blast_tac 1); |
905 |
qed "SHNat_hypnat_of_nat"; |
|
906 |
Addsimps [SHNat_hypnat_of_nat]; |
|
907 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11655
diff
changeset
|
908 |
Goal "hypnat_of_nat (Suc 0) : Nats"; |
10751 | 909 |
by (Simp_tac 1); |
910 |
qed "SHNat_hypnat_of_nat_one"; |
|
911 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
912 |
Goal "hypnat_of_nat 0 : Nats"; |
10751 | 913 |
by (Simp_tac 1); |
914 |
qed "SHNat_hypnat_of_nat_zero"; |
|
915 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
916 |
Goal "(1::hypnat) : Nats"; |
10751 | 917 |
by (simp_tac (simpset() addsimps [SHNat_hypnat_of_nat_one, |
918 |
hypnat_of_nat_one RS sym]) 1); |
|
919 |
qed "SHNat_one"; |
|
920 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
921 |
Goal "(0::hypnat) : Nats"; |
10751 | 922 |
by (simp_tac (simpset() addsimps [SHNat_hypnat_of_nat_zero, |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
923 |
hypnat_of_nat_zero RS sym]) 1); |
10751 | 924 |
qed "SHNat_zero"; |
925 |
||
926 |
Addsimps [SHNat_hypnat_of_nat_one,SHNat_hypnat_of_nat_zero, |
|
927 |
SHNat_one,SHNat_zero]; |
|
928 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
929 |
Goal "(1::hypnat) + (1::hypnat) : Nats"; |
10751 | 930 |
by (rtac ([SHNat_one,SHNat_one] MRS SHNat_add) 1); |
931 |
qed "SHNat_two"; |
|
932 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
933 |
Goalw [SHNat_def] "{x. hypnat_of_nat x : Nats} = (UNIV::nat set)"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
934 |
by Auto_tac; |
10751 | 935 |
qed "SHNat_UNIV_nat"; |
936 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
937 |
Goalw [SHNat_def] "(x: Nats) = (EX y. x = hypnat_of_nat y)"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
938 |
by Auto_tac; |
10751 | 939 |
qed "SHNat_iff"; |
940 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
941 |
Goalw [SHNat_def] "hypnat_of_nat `(UNIV::nat set) = Nats"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
942 |
by Auto_tac; |
10751 | 943 |
qed "hypnat_of_nat_image"; |
944 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
945 |
Goalw [SHNat_def] "inv hypnat_of_nat `Nats = (UNIV::nat set)"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
946 |
by Auto_tac; |
10751 | 947 |
by (rtac (inj_hypnat_of_nat RS inv_f_f RS subst) 1); |
948 |
by (Blast_tac 1); |
|
949 |
qed "inv_hypnat_of_nat_image"; |
|
950 |
||
951 |
Goalw [SHNat_def] |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
952 |
"[| EX x. x: P; P <= Nats |] ==> EX Q. P = hypnat_of_nat ` Q"; |
10751 | 953 |
by (Best_tac 1); |
954 |
qed "SHNat_hypnat_of_nat_image"; |
|
955 |
||
956 |
Goalw [SHNat_def] |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
957 |
"Nats = hypnat_of_nat ` (UNIV::nat set)"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
958 |
by Auto_tac; |
10751 | 959 |
qed "SHNat_hypnat_of_nat_iff"; |
960 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
961 |
Goalw [SHNat_def] "Nats <= (UNIV::hypnat set)"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
962 |
by Auto_tac; |
10751 | 963 |
qed "SHNat_subset_UNIV"; |
964 |
||
965 |
Goal "{n. n <= Suc m} = {n. n <= m} Un {n. n = Suc m}"; |
|
966 |
by (auto_tac (claset(),simpset() addsimps [le_Suc_eq])); |
|
967 |
qed "leSuc_Un_eq"; |
|
968 |
||
969 |
Goal "finite {n::nat. n <= m}"; |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
970 |
by (induct_tac "m" 1); |
10751 | 971 |
by (auto_tac (claset(),simpset() addsimps [leSuc_Un_eq])); |
972 |
qed "finite_nat_le_segment"; |
|
973 |
||
974 |
Goal "{n::nat. m < n} : FreeUltrafilterNat"; |
|
975 |
by (cut_inst_tac [("m2","m")] (finite_nat_le_segment RS |
|
976 |
FreeUltrafilterNat_finite RS FreeUltrafilterNat_Compl_mem) 1); |
|
977 |
by (Fuf_tac 1); |
|
978 |
qed "lemma_unbounded_set"; |
|
979 |
Addsimps [lemma_unbounded_set]; |
|
980 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
981 |
Goalw [SHNat_def,hypnat_of_nat_def, hypnat_less_def,hypnat_omega_def] |
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
982 |
"ALL n: Nats. n < whn"; |
10751 | 983 |
by (Clarify_tac 1); |
984 |
by (auto_tac (claset() addSIs [exI],simpset())); |
|
985 |
qed "hypnat_omega_gt_SHNat"; |
|
986 |
||
987 |
Goal "hypnat_of_nat n < whn"; |
|
988 |
by (cut_facts_tac [hypnat_omega_gt_SHNat] 1); |
|
989 |
by (dres_inst_tac [("x","hypnat_of_nat n")] bspec 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
990 |
by Auto_tac; |
10751 | 991 |
qed "hypnat_of_nat_less_whn"; |
992 |
Addsimps [hypnat_of_nat_less_whn]; |
|
993 |
||
994 |
Goal "hypnat_of_nat n <= whn"; |
|
995 |
by (rtac (hypnat_of_nat_less_whn RS hypnat_less_imp_le) 1); |
|
996 |
qed "hypnat_of_nat_le_whn"; |
|
997 |
Addsimps [hypnat_of_nat_le_whn]; |
|
998 |
||
999 |
Goal "0 < whn"; |
|
1000 |
by (rtac (hypnat_omega_gt_SHNat RS ballE) 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1001 |
by Auto_tac; |
10751 | 1002 |
qed "hypnat_zero_less_hypnat_omega"; |
1003 |
Addsimps [hypnat_zero_less_hypnat_omega]; |
|
1004 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1005 |
Goal "(1::hypnat) < whn"; |
10751 | 1006 |
by (rtac (hypnat_omega_gt_SHNat RS ballE) 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1007 |
by Auto_tac; |
10751 | 1008 |
qed "hypnat_one_less_hypnat_omega"; |
1009 |
Addsimps [hypnat_one_less_hypnat_omega]; |
|
1010 |
||
1011 |
(*-------------------------------------------------------------------------- |
|
1012 |
Theorems about infinite hypernatural numbers -- HNatInfinite |
|
1013 |
-------------------------------------------------------------------------*) |
|
1014 |
Goalw [HNatInfinite_def,SHNat_def] "whn : HNatInfinite"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1015 |
by Auto_tac; |
10751 | 1016 |
qed "HNatInfinite_whn"; |
1017 |
Addsimps [HNatInfinite_whn]; |
|
1018 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1019 |
Goalw [HNatInfinite_def] "x: Nats ==> x ~: HNatInfinite"; |
10751 | 1020 |
by (Simp_tac 1); |
1021 |
qed "SHNat_not_HNatInfinite"; |
|
1022 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1023 |
Goalw [HNatInfinite_def] "x ~: HNatInfinite ==> x: Nats"; |
10751 | 1024 |
by (Asm_full_simp_tac 1); |
1025 |
qed "not_HNatInfinite_SHNat"; |
|
1026 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1027 |
Goalw [HNatInfinite_def] "x ~: Nats ==> x: HNatInfinite"; |
10751 | 1028 |
by (Simp_tac 1); |
1029 |
qed "not_SHNat_HNatInfinite"; |
|
1030 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1031 |
Goalw [HNatInfinite_def] "x: HNatInfinite ==> x ~: Nats"; |
10751 | 1032 |
by (Asm_full_simp_tac 1); |
1033 |
qed "HNatInfinite_not_SHNat"; |
|
1034 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1035 |
Goal "(x: Nats) = (x ~: HNatInfinite)"; |
10751 | 1036 |
by (blast_tac (claset() addSIs [SHNat_not_HNatInfinite, |
1037 |
not_HNatInfinite_SHNat]) 1); |
|
1038 |
qed "SHNat_not_HNatInfinite_iff"; |
|
1039 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1040 |
Goal "(x ~: Nats) = (x: HNatInfinite)"; |
10751 | 1041 |
by (blast_tac (claset() addSIs [not_SHNat_HNatInfinite, |
1042 |
HNatInfinite_not_SHNat]) 1); |
|
1043 |
qed "not_SHNat_HNatInfinite_iff"; |
|
1044 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1045 |
Goal "x : Nats | x : HNatInfinite"; |
10751 | 1046 |
by (simp_tac (simpset() addsimps [SHNat_not_HNatInfinite_iff]) 1); |
1047 |
qed "SHNat_HNatInfinite_disj"; |
|
1048 |
||
1049 |
(*------------------------------------------------------------------- |
|
1050 |
Proof of alternative definition for set of Infinite hypernatural |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1051 |
numbers --- HNatInfinite = {N. ALL n: Nats. n < N} |
10751 | 1052 |
-------------------------------------------------------------------*) |
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1053 |
Goal "ALL N::nat. {n. f n ~= N} : FreeUltrafilterNat \ |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1054 |
\ ==> {n. N < f n} : FreeUltrafilterNat"; |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1055 |
by (induct_tac "N" 1); |
10751 | 1056 |
by (dres_inst_tac [("x","0")] spec 1); |
1057 |
by (rtac ccontr 1 THEN dtac FreeUltrafilterNat_Compl_mem 1 |
|
1058 |
THEN dtac FreeUltrafilterNat_Int 1 THEN assume_tac 1); |
|
1059 |
by (Asm_full_simp_tac 1); |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1060 |
by (dres_inst_tac [("x","Suc n")] spec 1); |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1061 |
by (fuf_tac (claset() addSDs [Suc_leI], |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1062 |
simpset() addsimps [le_eq_less_or_eq]) 1); |
10751 | 1063 |
qed "HNatInfinite_FreeUltrafilterNat_lemma"; |
1064 |
||
1065 |
(*** alternative definition ***) |
|
1066 |
Goalw [HNatInfinite_def,SHNat_def,hypnat_of_nat_def] |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1067 |
"HNatInfinite = {N. ALL n:Nats. n < N}"; |
10751 | 1068 |
by (Step_tac 1); |
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1069 |
by (dres_inst_tac [("x","Abs_hypnat (hypnatrel `` {%n. N})")] bspec 2); |
10751 | 1070 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
1071 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
1072 |
by (auto_tac (claset(),simpset() addsimps [hypnat_less_iff])); |
|
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1073 |
by (auto_tac (claset() addSIs [exI] |
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1074 |
addEs [HNatInfinite_FreeUltrafilterNat_lemma], |
10751 | 1075 |
simpset() addsimps [FreeUltrafilterNat_Compl_iff1, |
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1076 |
CLAIM "- {n. xa n = N} = {n. xa n ~= N}"])); |
10751 | 1077 |
qed "HNatInfinite_iff"; |
1078 |
||
1079 |
(*-------------------------------------------------------------------- |
|
1080 |
Alternative definition for HNatInfinite using Free ultrafilter |
|
1081 |
--------------------------------------------------------------------*) |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1082 |
Goal "x : HNatInfinite ==> EX X: Rep_hypnat x. \ |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1083 |
\ ALL u. {n. u < X n}: FreeUltrafilterNat"; |
10751 | 1084 |
by (auto_tac (claset(),simpset() addsimps [hypnat_less_def, |
1085 |
HNatInfinite_iff,SHNat_iff,hypnat_of_nat_def])); |
|
1086 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
|
1087 |
by (EVERY[Auto_tac, rtac bexI 1, |
|
1088 |
rtac lemma_hypnatrel_refl 2, Step_tac 1]); |
|
1089 |
by (dres_inst_tac [("x","hypnat_of_nat u")] bspec 1); |
|
1090 |
by (Simp_tac 1); |
|
1091 |
by (auto_tac (claset(), |
|
1092 |
simpset() addsimps [hypnat_of_nat_def])); |
|
1093 |
by (Fuf_tac 1); |
|
1094 |
qed "HNatInfinite_FreeUltrafilterNat"; |
|
1095 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1096 |
Goal "EX X: Rep_hypnat x. ALL u. {n. u < X n}: FreeUltrafilterNat \ |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1097 |
\ ==> x: HNatInfinite"; |
10751 | 1098 |
by (auto_tac (claset(),simpset() addsimps [hypnat_less_def, |
1099 |
HNatInfinite_iff,SHNat_iff,hypnat_of_nat_def])); |
|
1100 |
by (rtac exI 1 THEN Auto_tac); |
|
1101 |
qed "FreeUltrafilterNat_HNatInfinite"; |
|
1102 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1103 |
Goal "(x : HNatInfinite) = (EX X: Rep_hypnat x. \ |
10751 | 1104 |
\ ALL u. {n. u < X n}: FreeUltrafilterNat)"; |
1105 |
by (blast_tac (claset() addIs [HNatInfinite_FreeUltrafilterNat, |
|
1106 |
FreeUltrafilterNat_HNatInfinite]) 1); |
|
1107 |
qed "HNatInfinite_FreeUltrafilterNat_iff"; |
|
1108 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1109 |
Goal "x : HNatInfinite ==> (1::hypnat) < x"; |
10751 | 1110 |
by (auto_tac (claset(),simpset() addsimps [HNatInfinite_iff])); |
1111 |
qed "HNatInfinite_gt_one"; |
|
1112 |
Addsimps [HNatInfinite_gt_one]; |
|
1113 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1114 |
Goal "0 ~: HNatInfinite"; |
10751 | 1115 |
by (auto_tac (claset(),simpset() |
1116 |
addsimps [HNatInfinite_iff])); |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1117 |
by (dres_inst_tac [("a","(1::hypnat)")] equals0D 1); |
10751 | 1118 |
by (Asm_full_simp_tac 1); |
1119 |
qed "zero_not_mem_HNatInfinite"; |
|
1120 |
Addsimps [zero_not_mem_HNatInfinite]; |
|
1121 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1122 |
Goal "x : HNatInfinite ==> x ~= 0"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1123 |
by Auto_tac; |
10751 | 1124 |
qed "HNatInfinite_not_eq_zero"; |
1125 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1126 |
Goal "x : HNatInfinite ==> (1::hypnat) <= x"; |
10751 | 1127 |
by (blast_tac (claset() addIs [hypnat_less_imp_le, |
1128 |
HNatInfinite_gt_one]) 1); |
|
1129 |
qed "HNatInfinite_ge_one"; |
|
1130 |
Addsimps [HNatInfinite_ge_one]; |
|
1131 |
||
1132 |
(*-------------------------------------------------- |
|
1133 |
Closure Rules |
|
1134 |
--------------------------------------------------*) |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1135 |
Goal "[| x: HNatInfinite; y: HNatInfinite |] \ |
10751 | 1136 |
\ ==> x + y: HNatInfinite"; |
1137 |
by (auto_tac (claset(),simpset() addsimps [HNatInfinite_iff])); |
|
1138 |
by (dtac bspec 1 THEN assume_tac 1); |
|
1139 |
by (dtac (SHNat_zero RSN (2,bspec)) 1); |
|
1140 |
by (dtac hypnat_add_less_mono 1 THEN assume_tac 1); |
|
1141 |
by (Asm_full_simp_tac 1); |
|
1142 |
qed "HNatInfinite_add"; |
|
1143 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1144 |
Goal "[| x: HNatInfinite; y: Nats |] ==> x + y: HNatInfinite"; |
10751 | 1145 |
by (rtac ccontr 1 THEN dtac not_HNatInfinite_SHNat 1); |
1146 |
by (dres_inst_tac [("x","x + y")] SHNat_minus 1); |
|
1147 |
by (auto_tac (claset(),simpset() addsimps |
|
1148 |
[SHNat_not_HNatInfinite_iff])); |
|
1149 |
qed "HNatInfinite_SHNat_add"; |
|
1150 |
||
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1151 |
Goal "[| x: HNatInfinite; y: Nats |] ==> x - y: HNatInfinite"; |
10751 | 1152 |
by (rtac ccontr 1 THEN dtac not_HNatInfinite_SHNat 1); |
1153 |
by (dres_inst_tac [("x","x - y")] SHNat_add 1); |
|
1154 |
by (subgoal_tac "y <= x" 2); |
|
1155 |
by (auto_tac (claset() addSDs [hypnat_le_add_diff_inverse2], |
|
1156 |
simpset() addsimps [not_SHNat_HNatInfinite_iff RS sym])); |
|
1157 |
by (auto_tac (claset() addSIs [hypnat_less_imp_le], |
|
1158 |
simpset() addsimps [not_SHNat_HNatInfinite_iff,HNatInfinite_iff])); |
|
1159 |
qed "HNatInfinite_SHNat_diff"; |
|
1160 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1161 |
Goal "x: HNatInfinite ==> x + (1::hypnat): HNatInfinite"; |
10751 | 1162 |
by (auto_tac (claset() addIs [HNatInfinite_SHNat_add], |
1163 |
simpset())); |
|
1164 |
qed "HNatInfinite_add_one"; |
|
1165 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1166 |
Goal "x: HNatInfinite ==> x - (1::hypnat): HNatInfinite"; |
10751 | 1167 |
by (rtac ccontr 1 THEN dtac not_HNatInfinite_SHNat 1); |
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1168 |
by (dres_inst_tac [("x","x - (1::hypnat)"),("y","(1::hypnat)")] SHNat_add 1); |
10751 | 1169 |
by (auto_tac (claset(),simpset() addsimps |
1170 |
[not_SHNat_HNatInfinite_iff RS sym])); |
|
1171 |
qed "HNatInfinite_minus_one"; |
|
1172 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1173 |
Goal "x : HNatInfinite ==> EX y. x = y + (1::hypnat)"; |
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1174 |
by (res_inst_tac [("x","x - (1::hypnat)")] exI 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1175 |
by Auto_tac; |
10751 | 1176 |
qed "HNatInfinite_is_Suc"; |
1177 |
||
1178 |
(*--------------------------------------------------------------- |
|
1179 |
HNat : the hypernaturals embedded in the hyperreals |
|
1180 |
Obtained using the NS extension of the naturals |
|
1181 |
--------------------------------------------------------------*) |
|
1182 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1183 |
Goalw [HNat_def,starset_def, hypreal_of_nat_def,hypreal_of_real_def] |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1184 |
"hypreal_of_nat N : HNat"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1185 |
by Auto_tac; |
10751 | 1186 |
by (Ultra_tac 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1187 |
by (res_inst_tac [("x","N")] exI 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1188 |
by Auto_tac; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1189 |
qed "HNat_hypreal_of_nat"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1190 |
Addsimps [HNat_hypreal_of_nat]; |
10751 | 1191 |
|
1192 |
Goalw [HNat_def,starset_def] |
|
1193 |
"[| x: HNat; y: HNat |] ==> x + y: HNat"; |
|
1194 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
1195 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
1196 |
by (auto_tac (claset() addSDs [bspec] addIs [lemma_hyprel_refl], |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1197 |
simpset() addsimps [hypreal_add])); |
10751 | 1198 |
by (Ultra_tac 1); |
10784 | 1199 |
by (res_inst_tac [("x","no+noa")] exI 1); |
1200 |
by Auto_tac; |
|
10751 | 1201 |
qed "HNat_add"; |
1202 |
||
1203 |
Goalw [HNat_def,starset_def] |
|
1204 |
"[| x: HNat; y: HNat |] ==> x * y: HNat"; |
|
1205 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
|
1206 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
1207 |
by (auto_tac (claset() addSDs [bspec] addIs [lemma_hyprel_refl], |
|
10784 | 1208 |
simpset() addsimps [hypreal_mult])); |
10751 | 1209 |
by (Ultra_tac 1); |
10784 | 1210 |
by (res_inst_tac [("x","no*noa")] exI 1); |
1211 |
by Auto_tac; |
|
10751 | 1212 |
qed "HNat_mult"; |
1213 |
||
1214 |
(*--------------------------------------------------------------- |
|
1215 |
Embedding of the hypernaturals into the hyperreal |
|
1216 |
--------------------------------------------------------------*) |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1217 |
|
10834 | 1218 |
Goal "(Ya : hyprel ``{%n. f(n)}) = \ |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1219 |
\ ({n. f n = Ya n} : FreeUltrafilterNat)"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1220 |
by Auto_tac; |
10751 | 1221 |
qed "lemma_hyprel_FUFN"; |
1222 |
||
1223 |
Goalw [hypreal_of_hypnat_def] |
|
10834 | 1224 |
"hypreal_of_hypnat (Abs_hypnat(hypnatrel``{%n. X n})) = \ |
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
1225 |
\ Abs_hypreal(hyprel `` {%n. real (X n)})"; |
10751 | 1226 |
by (res_inst_tac [("f","Abs_hypreal")] arg_cong 1); |
10784 | 1227 |
by (auto_tac (claset() |
1228 |
addEs [FreeUltrafilterNat_Int RS FreeUltrafilterNat_subset], |
|
1229 |
simpset() addsimps [lemma_hyprel_FUFN])); |
|
10751 | 1230 |
qed "hypreal_of_hypnat"; |
1231 |
||
1232 |
Goal "inj(hypreal_of_hypnat)"; |
|
1233 |
by (rtac injI 1); |
|
1234 |
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1); |
|
1235 |
by (res_inst_tac [("z","y")] eq_Abs_hypnat 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1236 |
by (auto_tac (claset(), simpset() addsimps [hypreal_of_hypnat])); |
10751 | 1237 |
qed "inj_hypreal_of_hypnat"; |
1238 |
||
1239 |
Goal "(hypreal_of_hypnat n = hypreal_of_hypnat m) = (n = m)"; |
|
1240 |
by (auto_tac (claset(),simpset() addsimps [inj_hypreal_of_hypnat RS injD])); |
|
1241 |
qed "hypreal_of_hypnat_eq_cancel"; |
|
1242 |
Addsimps [hypreal_of_hypnat_eq_cancel]; |
|
1243 |
||
1244 |
Goal "(hypnat_of_nat n = hypnat_of_nat m) = (n = m)"; |
|
1245 |
by (auto_tac (claset() addDs [inj_hypnat_of_nat RS injD], |
|
1246 |
simpset())); |
|
1247 |
qed "hypnat_of_nat_eq_cancel"; |
|
1248 |
Addsimps [hypnat_of_nat_eq_cancel]; |
|
1249 |
||
1250 |
Goalw [hypnat_zero_def] |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1251 |
"hypreal_of_hypnat 0 = 0"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1252 |
by (simp_tac (simpset() addsimps [hypreal_zero_def, hypreal_of_hypnat]) 1); |
10751 | 1253 |
qed "hypreal_of_hypnat_zero"; |
1254 |
||
1255 |
Goalw [hypnat_one_def] |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1256 |
"hypreal_of_hypnat (1::hypnat) = 1"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1257 |
by (simp_tac (simpset() addsimps [hypreal_one_def, hypreal_of_hypnat]) 1); |
10751 | 1258 |
qed "hypreal_of_hypnat_one"; |
1259 |
||
10784 | 1260 |
Goal "hypreal_of_hypnat (m + n) = hypreal_of_hypnat m + hypreal_of_hypnat n"; |
1261 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
1262 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
1263 |
by (asm_simp_tac (simpset() addsimps |
|
1264 |
[hypreal_of_hypnat, hypreal_add,hypnat_add,real_of_nat_add]) 1); |
|
10751 | 1265 |
qed "hypreal_of_hypnat_add"; |
10784 | 1266 |
Addsimps [hypreal_of_hypnat_add]; |
10751 | 1267 |
|
10784 | 1268 |
Goal "hypreal_of_hypnat (m * n) = hypreal_of_hypnat m * hypreal_of_hypnat n"; |
1269 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
1270 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
1271 |
by (asm_simp_tac (simpset() addsimps |
|
1272 |
[hypreal_of_hypnat, hypreal_mult,hypnat_mult,real_of_nat_mult]) 1); |
|
10751 | 1273 |
qed "hypreal_of_hypnat_mult"; |
10784 | 1274 |
Addsimps [hypreal_of_hypnat_mult]; |
10751 | 1275 |
|
1276 |
Goal "(hypreal_of_hypnat n < hypreal_of_hypnat m) = (n < m)"; |
|
1277 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
|
1278 |
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1); |
|
1279 |
by (asm_simp_tac (simpset() addsimps |
|
1280 |
[hypreal_of_hypnat,hypreal_less,hypnat_less]) 1); |
|
1281 |
qed "hypreal_of_hypnat_less_iff"; |
|
1282 |
Addsimps [hypreal_of_hypnat_less_iff]; |
|
1283 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
1284 |
Goal "(hypreal_of_hypnat N = 0) = (N = 0)"; |
10751 | 1285 |
by (simp_tac (simpset() addsimps [hypreal_of_hypnat_zero RS sym]) 1); |
1286 |
qed "hypreal_of_hypnat_eq_zero_iff"; |
|
1287 |
Addsimps [hypreal_of_hypnat_eq_zero_iff]; |
|
1288 |
||
1289 |
Goal "ALL n. N <= n ==> N = (0::hypnat)"; |
|
1290 |
by (dres_inst_tac [("x","0")] spec 1); |
|
1291 |
by (res_inst_tac [("z","N")] eq_Abs_hypnat 1); |
|
1292 |
by (auto_tac (claset(),simpset() addsimps [hypnat_le,hypnat_zero_def])); |
|
1293 |
qed "hypnat_eq_zero"; |
|
1294 |
Addsimps [hypnat_eq_zero]; |
|
1295 |
||
1296 |
Goal "~ (ALL n. n = (0::hypnat))"; |
|
1297 |
by Auto_tac; |
|
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1298 |
by (res_inst_tac [("x","(1::hypnat)")] exI 1); |
10751 | 1299 |
by (Simp_tac 1); |
1300 |
qed "hypnat_not_all_eq_zero"; |
|
1301 |
Addsimps [hypnat_not_all_eq_zero]; |
|
1302 |
||
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
1303 |
Goal "n ~= 0 ==> (n <= (1::hypnat)) = (n = (1::hypnat))"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10751
diff
changeset
|
1304 |
by (auto_tac (claset(), simpset() addsimps [hypnat_le_less])); |
10751 | 1305 |
qed "hypnat_le_one_eq_one"; |
1306 |
Addsimps [hypnat_le_one_eq_one]; |
|
1307 |
||
1308 |
||
1309 |
||
1310 |
||
14268
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1311 |
(*MOVE UP*) |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1312 |
Goal "n : HNatInfinite ==> inverse (hypreal_of_hypnat n) : Infinitesimal"; |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1313 |
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1); |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1314 |
by (auto_tac (claset(),simpset() addsimps [hypreal_of_hypnat,hypreal_inverse, |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1315 |
HNatInfinite_FreeUltrafilterNat_iff,Infinitesimal_FreeUltrafilterNat_iff2])); |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1316 |
by (rtac bexI 1 THEN rtac lemma_hyprel_refl 2); |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1317 |
by Auto_tac; |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1318 |
by (dres_inst_tac [("x","m + 1")] spec 1); |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1319 |
by (Ultra_tac 1); |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1320 |
by (subgoal_tac "abs(inverse (real (Y x))) = inverse(real (Y x))" 1); |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1321 |
by (auto_tac (claset() addSIs [abs_eqI2],simpset())); |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1322 |
qed "HNatInfinite_inverse_Infinitesimal"; |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1323 |
Addsimps [HNatInfinite_inverse_Infinitesimal]; |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1324 |
|
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1325 |
Goal "n : HNatInfinite ==> inverse (hypreal_of_hypnat n) ~= 0"; |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1326 |
by (auto_tac (claset() addSIs [hypreal_inverse_not_zero],simpset())); |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1327 |
qed "HNatInfinite_inverse_not_zero"; |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1328 |
Addsimps [HNatInfinite_inverse_not_zero]; |
5cf13e80be0e
Removal of Hyperreal/ExtraThms2.ML, sending the material to the correct files.
paulson
parents:
13596
diff
changeset
|
1329 |