author | nipkow |
Mon, 06 Aug 2001 13:43:24 +0200 | |
changeset 11464 | ddea204de5bc |
parent 10834 | a7897aebbffc |
child 11655 | 923e4d0d36d5 |
permissions | -rw-r--r-- |
9422 | 1 |
(* Title : HOL/Real/PNat.ML |
7219 | 2 |
ID : $Id$ |
5078 | 3 |
Author : Jacques D. Fleuriot |
4 |
Copyright : 1998 University of Cambridge |
|
9422 | 5 |
|
6 |
The positive naturals -- proofs mainly as in theory Nat. |
|
5078 | 7 |
*) |
8 |
||
11464 | 9 |
Goal "mono(%X. {1'} Un Suc`X)"; |
5078 | 10 |
by (REPEAT (ares_tac [monoI, subset_refl, image_mono, Un_mono] 1)); |
11 |
qed "pnat_fun_mono"; |
|
12 |
||
10186 | 13 |
bind_thm ("pnat_unfold", pnat_fun_mono RS (pnat_def RS def_lfp_unfold)); |
5078 | 14 |
|
11464 | 15 |
Goal "1' : pnat"; |
5078 | 16 |
by (stac pnat_unfold 1); |
17 |
by (rtac (singletonI RS UnI1) 1); |
|
18 |
qed "one_RepI"; |
|
19 |
||
20 |
Addsimps [one_RepI]; |
|
21 |
||
22 |
Goal "i: pnat ==> Suc(i) : pnat"; |
|
23 |
by (stac pnat_unfold 1); |
|
24 |
by (etac (imageI RS UnI2) 1); |
|
25 |
qed "pnat_Suc_RepI"; |
|
26 |
||
27 |
Goal "2 : pnat"; |
|
28 |
by (rtac (one_RepI RS pnat_Suc_RepI) 1); |
|
29 |
qed "two_RepI"; |
|
30 |
||
31 |
(*** Induction ***) |
|
32 |
||
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
33 |
val major::prems = Goal |
11464 | 34 |
"[| i: pnat; P(1'); \ |
5078 | 35 |
\ !!j. [| j: pnat; P(j) |] ==> P(Suc(j)) |] ==> P(i)"; |
10202 | 36 |
by (rtac ([pnat_def, pnat_fun_mono, major] MRS def_lfp_induct) 1); |
5078 | 37 |
by (blast_tac (claset() addIs prems) 1); |
38 |
qed "PNat_induct"; |
|
39 |
||
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
40 |
val prems = Goalw [pnat_one_def,pnat_Suc_def] |
5078 | 41 |
"[| P(1p); \ |
42 |
\ !!n. P(n) ==> P(pSuc n) |] ==> P(n)"; |
|
43 |
by (rtac (Rep_pnat_inverse RS subst) 1); |
|
44 |
by (rtac (Rep_pnat RS PNat_induct) 1); |
|
45 |
by (REPEAT (ares_tac prems 1 |
|
46 |
ORELSE eresolve_tac [Abs_pnat_inverse RS subst] 1)); |
|
47 |
qed "pnat_induct"; |
|
48 |
||
49 |
(*Perform induction on n. *) |
|
5184 | 50 |
fun pnat_ind_tac a i = |
9747 | 51 |
induct_thm_tac pnat_induct a i THEN rename_last_tac a [""] (i+1); |
5078 | 52 |
|
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
53 |
val prems = Goal |
5078 | 54 |
"[| !!x. P x 1p; \ |
55 |
\ !!y. P 1p (pSuc y); \ |
|
56 |
\ !!x y. [| P x y |] ==> P (pSuc x) (pSuc y) \ |
|
57 |
\ |] ==> P m n"; |
|
58 |
by (res_inst_tac [("x","m")] spec 1); |
|
59 |
by (pnat_ind_tac "n" 1); |
|
60 |
by (rtac allI 2); |
|
61 |
by (pnat_ind_tac "x" 2); |
|
62 |
by (REPEAT (ares_tac (prems@[allI]) 1 ORELSE etac spec 1)); |
|
63 |
qed "pnat_diff_induct"; |
|
64 |
||
65 |
(*Case analysis on the natural numbers*) |
|
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
66 |
val prems = Goal |
5078 | 67 |
"[| n=1p ==> P; !!x. n = pSuc(x) ==> P |] ==> P"; |
68 |
by (subgoal_tac "n=1p | (EX x. n = pSuc(x))" 1); |
|
69 |
by (fast_tac (claset() addSEs prems) 1); |
|
70 |
by (pnat_ind_tac "n" 1); |
|
71 |
by (rtac (refl RS disjI1) 1); |
|
72 |
by (Blast_tac 1); |
|
73 |
qed "pnatE"; |
|
74 |
||
75 |
(*** Isomorphisms: Abs_Nat and Rep_Nat ***) |
|
76 |
||
77 |
Goal "inj_on Abs_pnat pnat"; |
|
78 |
by (rtac inj_on_inverseI 1); |
|
79 |
by (etac Abs_pnat_inverse 1); |
|
80 |
qed "inj_on_Abs_pnat"; |
|
81 |
||
82 |
Addsimps [inj_on_Abs_pnat RS inj_on_iff]; |
|
83 |
||
84 |
Goal "inj(Rep_pnat)"; |
|
85 |
by (rtac inj_inverseI 1); |
|
86 |
by (rtac Rep_pnat_inverse 1); |
|
87 |
qed "inj_Rep_pnat"; |
|
88 |
||
89 |
Goal "0 ~: pnat"; |
|
90 |
by (stac pnat_unfold 1); |
|
91 |
by Auto_tac; |
|
92 |
qed "zero_not_mem_pnat"; |
|
93 |
||
94 |
(* 0 : pnat ==> P *) |
|
95 |
bind_thm ("zero_not_mem_pnatE", zero_not_mem_pnat RS notE); |
|
96 |
||
97 |
Addsimps [zero_not_mem_pnat]; |
|
98 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5078
diff
changeset
|
99 |
Goal "x : pnat ==> 0 < x"; |
5078 | 100 |
by (dtac (pnat_unfold RS subst) 1); |
101 |
by Auto_tac; |
|
102 |
qed "mem_pnat_gt_zero"; |
|
103 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5078
diff
changeset
|
104 |
Goal "0 < x ==> x: pnat"; |
5078 | 105 |
by (stac pnat_unfold 1); |
106 |
by (dtac (gr_implies_not0 RS not0_implies_Suc) 1); |
|
107 |
by (etac exE 1 THEN Asm_simp_tac 1); |
|
108 |
by (induct_tac "m" 1); |
|
109 |
by (auto_tac (claset(),simpset() |
|
110 |
addsimps [one_RepI]) THEN dtac pnat_Suc_RepI 1); |
|
111 |
by (Blast_tac 1); |
|
112 |
qed "gt_0_mem_pnat"; |
|
113 |
||
114 |
Goal "(x: pnat) = (0 < x)"; |
|
115 |
by (blast_tac (claset() addDs [mem_pnat_gt_zero,gt_0_mem_pnat]) 1); |
|
116 |
qed "mem_pnat_gt_0_iff"; |
|
117 |
||
118 |
Goal "0 < Rep_pnat x"; |
|
119 |
by (rtac (Rep_pnat RS mem_pnat_gt_zero) 1); |
|
120 |
qed "Rep_pnat_gt_zero"; |
|
121 |
||
122 |
Goalw [pnat_add_def] "(x::pnat) + y = y + x"; |
|
123 |
by (simp_tac (simpset() addsimps [add_commute]) 1); |
|
124 |
qed "pnat_add_commute"; |
|
125 |
||
126 |
(** alternative definition for pnat **) |
|
127 |
(** order isomorphism **) |
|
128 |
Goal "pnat = {x::nat. 0 < x}"; |
|
10292 | 129 |
by (auto_tac (claset(), simpset() addsimps [mem_pnat_gt_0_iff])); |
5078 | 130 |
qed "Collect_pnat_gt_0"; |
131 |
||
132 |
(*** Distinctness of constructors ***) |
|
133 |
||
134 |
Goalw [pnat_one_def,pnat_Suc_def] "pSuc(m) ~= 1p"; |
|
135 |
by (rtac (inj_on_Abs_pnat RS inj_on_contraD) 1); |
|
136 |
by (rtac (Rep_pnat_gt_zero RS Suc_mono RS less_not_refl2) 1); |
|
137 |
by (REPEAT (resolve_tac [Rep_pnat RS pnat_Suc_RepI, one_RepI] 1)); |
|
138 |
qed "pSuc_not_one"; |
|
139 |
||
140 |
bind_thm ("one_not_pSuc", pSuc_not_one RS not_sym); |
|
141 |
||
142 |
AddIffs [pSuc_not_one,one_not_pSuc]; |
|
143 |
||
144 |
bind_thm ("pSuc_neq_one", (pSuc_not_one RS notE)); |
|
9108 | 145 |
bind_thm ("one_neq_pSuc", pSuc_neq_one RS pSuc_neq_one); |
5078 | 146 |
|
147 |
(** Injectiveness of pSuc **) |
|
148 |
||
149 |
Goalw [pnat_Suc_def] "inj(pSuc)"; |
|
150 |
by (rtac injI 1); |
|
151 |
by (dtac (inj_on_Abs_pnat RS inj_onD) 1); |
|
152 |
by (REPEAT (resolve_tac [Rep_pnat, pnat_Suc_RepI] 1)); |
|
153 |
by (dtac (inj_Suc RS injD) 1); |
|
154 |
by (etac (inj_Rep_pnat RS injD) 1); |
|
155 |
qed "inj_pSuc"; |
|
156 |
||
9108 | 157 |
bind_thm ("pSuc_inject", inj_pSuc RS injD); |
5078 | 158 |
|
159 |
Goal "(pSuc(m)=pSuc(n)) = (m=n)"; |
|
160 |
by (EVERY1 [rtac iffI, etac pSuc_inject, etac arg_cong]); |
|
161 |
qed "pSuc_pSuc_eq"; |
|
162 |
||
163 |
AddIffs [pSuc_pSuc_eq]; |
|
164 |
||
165 |
Goal "n ~= pSuc(n)"; |
|
166 |
by (pnat_ind_tac "n" 1); |
|
167 |
by (ALLGOALS Asm_simp_tac); |
|
168 |
qed "n_not_pSuc_n"; |
|
169 |
||
170 |
bind_thm ("pSuc_n_not_n", n_not_pSuc_n RS not_sym); |
|
171 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5078
diff
changeset
|
172 |
Goal "n ~= 1p ==> EX m. n = pSuc m"; |
5078 | 173 |
by (rtac pnatE 1); |
174 |
by (REPEAT (Blast_tac 1)); |
|
175 |
qed "not1p_implies_pSuc"; |
|
176 |
||
177 |
Goal "pSuc m = m + 1p"; |
|
178 |
by (auto_tac (claset(),simpset() addsimps [pnat_Suc_def, |
|
179 |
pnat_one_def,Abs_pnat_inverse,pnat_add_def])); |
|
180 |
qed "pSuc_is_plus_one"; |
|
181 |
||
182 |
Goal |
|
183 |
"(Rep_pnat x + Rep_pnat y): pnat"; |
|
184 |
by (cut_facts_tac [[Rep_pnat_gt_zero, |
|
185 |
Rep_pnat_gt_zero] MRS add_less_mono,Collect_pnat_gt_0] 1); |
|
186 |
by (etac ssubst 1); |
|
187 |
by Auto_tac; |
|
188 |
qed "sum_Rep_pnat"; |
|
189 |
||
190 |
Goalw [pnat_add_def] |
|
191 |
"Rep_pnat x + Rep_pnat y = Rep_pnat (x + y)"; |
|
192 |
by (simp_tac (simpset() addsimps [sum_Rep_pnat RS |
|
193 |
Abs_pnat_inverse]) 1); |
|
194 |
qed "sum_Rep_pnat_sum"; |
|
195 |
||
196 |
Goalw [pnat_add_def] |
|
197 |
"(x + y) + z = x + (y + (z::pnat))"; |
|
198 |
by (res_inst_tac [("f","Abs_pnat")] arg_cong 1); |
|
199 |
by (simp_tac (simpset() addsimps [sum_Rep_pnat RS |
|
200 |
Abs_pnat_inverse,add_assoc]) 1); |
|
201 |
qed "pnat_add_assoc"; |
|
202 |
||
203 |
Goalw [pnat_add_def] "x + (y + z) = y + (x + (z::pnat))"; |
|
204 |
by (res_inst_tac [("f","Abs_pnat")] arg_cong 1); |
|
205 |
by (simp_tac (simpset() addsimps [sum_Rep_pnat RS |
|
206 |
Abs_pnat_inverse,add_left_commute]) 1); |
|
207 |
qed "pnat_add_left_commute"; |
|
208 |
||
209 |
(*Addition is an AC-operator*) |
|
9108 | 210 |
bind_thms ("pnat_add_ac", [pnat_add_assoc, pnat_add_commute, pnat_add_left_commute]); |
5078 | 211 |
|
212 |
Goalw [pnat_add_def] "((x::pnat) + y = x + z) = (y = z)"; |
|
8866 | 213 |
by (auto_tac (claset() addDs [inj_on_Abs_pnat RS inj_onD, |
5078 | 214 |
inj_Rep_pnat RS injD],simpset() addsimps [sum_Rep_pnat])); |
215 |
qed "pnat_add_left_cancel"; |
|
216 |
||
217 |
Goalw [pnat_add_def] "(y + (x::pnat) = z + x) = (y = z)"; |
|
8866 | 218 |
by (auto_tac (claset() addDs [inj_on_Abs_pnat RS inj_onD, |
5078 | 219 |
inj_Rep_pnat RS injD],simpset() addsimps [sum_Rep_pnat])); |
220 |
qed "pnat_add_right_cancel"; |
|
221 |
||
222 |
Goalw [pnat_add_def] "!(y::pnat). x + y ~= x"; |
|
223 |
by (rtac (Rep_pnat_inverse RS subst) 1); |
|
8866 | 224 |
by (auto_tac (claset() addDs [inj_on_Abs_pnat RS inj_onD] |
5078 | 225 |
addSDs [add_eq_self_zero], |
226 |
simpset() addsimps [sum_Rep_pnat, Rep_pnat,Abs_pnat_inverse, |
|
8866 | 227 |
Rep_pnat_gt_zero RS less_not_refl2])); |
5078 | 228 |
qed "pnat_no_add_ident"; |
229 |
||
230 |
||
231 |
(***) (***) (***) (***) (***) (***) (***) (***) (***) |
|
232 |
||
233 |
(*** pnat_less ***) |
|
234 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5078
diff
changeset
|
235 |
Goalw [pnat_less_def] "~ y < (y::pnat)"; |
5078 | 236 |
by Auto_tac; |
237 |
qed "pnat_less_not_refl"; |
|
238 |
||
239 |
bind_thm ("pnat_less_irrefl",pnat_less_not_refl RS notE); |
|
240 |
||
241 |
Goalw [pnat_less_def] |
|
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
242 |
"x < (y::pnat) ==> x ~= y"; |
5078 | 243 |
by Auto_tac; |
244 |
qed "pnat_less_not_refl2"; |
|
245 |
||
246 |
Goal "~ Rep_pnat y < 0"; |
|
247 |
by Auto_tac; |
|
248 |
qed "Rep_pnat_not_less0"; |
|
249 |
||
250 |
(*** Rep_pnat < 0 ==> P ***) |
|
251 |
bind_thm ("Rep_pnat_less_zeroE",Rep_pnat_not_less0 RS notE); |
|
252 |
||
11464 | 253 |
Goal "~ Rep_pnat y < 1'"; |
5078 | 254 |
by (auto_tac (claset(),simpset() addsimps [less_Suc_eq, |
255 |
Rep_pnat_gt_zero,less_not_refl2])); |
|
256 |
qed "Rep_pnat_not_less_one"; |
|
257 |
||
258 |
(*** Rep_pnat < 1 ==> P ***) |
|
259 |
bind_thm ("Rep_pnat_less_oneE",Rep_pnat_not_less_one RS notE); |
|
260 |
||
261 |
Goalw [pnat_less_def] |
|
11464 | 262 |
"x < (y::pnat) ==> Rep_pnat y ~= 1'"; |
5078 | 263 |
by (auto_tac (claset(),simpset() |
264 |
addsimps [Rep_pnat_not_less_one] delsimps [less_one])); |
|
265 |
qed "Rep_pnat_gt_implies_not0"; |
|
266 |
||
267 |
Goalw [pnat_less_def] |
|
268 |
"(x::pnat) < y | x = y | y < x"; |
|
269 |
by (cut_facts_tac [less_linear] 1); |
|
270 |
by (fast_tac (claset() addIs [inj_Rep_pnat RS injD]) 1); |
|
271 |
qed "pnat_less_linear"; |
|
272 |
||
11464 | 273 |
Goalw [le_def] "1' <= Rep_pnat x"; |
5078 | 274 |
by (rtac Rep_pnat_not_less_one 1); |
275 |
qed "Rep_pnat_le_one"; |
|
276 |
||
277 |
Goalw [pnat_less_def] |
|
9043
ca761fe227d8
First round of changes, towards installation of simprocs
paulson
parents:
8866
diff
changeset
|
278 |
"!! (z1::nat). z1 < z2 ==> EX z3. z1 + Rep_pnat z3 = z2"; |
5078 | 279 |
by (dtac less_imp_add_positive 1); |
5758
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5588
diff
changeset
|
280 |
by (force_tac (claset() addSIs [Abs_pnat_inverse], |
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5588
diff
changeset
|
281 |
simpset() addsimps [Collect_pnat_gt_0]) 1); |
5078 | 282 |
qed "lemma_less_ex_sum_Rep_pnat"; |
283 |
||
284 |
||
285 |
(*** pnat_le ***) |
|
286 |
||
287 |
(*** alternative definition for pnat_le ***) |
|
288 |
Goalw [pnat_le_def,pnat_less_def] |
|
289 |
"((m::pnat) <= n) = (Rep_pnat m <= Rep_pnat n)"; |
|
290 |
by (auto_tac (claset() addSIs [leI] addSEs [leD],simpset())); |
|
291 |
qed "pnat_le_iff_Rep_pnat_le"; |
|
292 |
||
293 |
Goal "!!k::pnat. (k + m <= k + n) = (m<=n)"; |
|
294 |
by (simp_tac (simpset() addsimps [pnat_le_iff_Rep_pnat_le, |
|
295 |
sum_Rep_pnat_sum RS sym]) 1); |
|
296 |
qed "pnat_add_left_cancel_le"; |
|
297 |
||
298 |
Goalw [pnat_less_def] "!!k::pnat. (k + m < k + n) = (m<n)"; |
|
299 |
by (simp_tac (simpset() addsimps [sum_Rep_pnat_sum RS sym]) 1); |
|
300 |
qed "pnat_add_left_cancel_less"; |
|
301 |
||
302 |
Addsimps [pnat_add_left_cancel, pnat_add_right_cancel, |
|
303 |
pnat_add_left_cancel_le, pnat_add_left_cancel_less]; |
|
304 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5078
diff
changeset
|
305 |
Goalw [pnat_less_def] "i+j < (k::pnat) ==> i<k"; |
5078 | 306 |
by (auto_tac (claset() addEs [add_lessD1], |
307 |
simpset() addsimps [sum_Rep_pnat_sum RS sym])); |
|
308 |
qed "pnat_add_lessD1"; |
|
309 |
||
310 |
Goal "!!i::pnat. ~ (i+j < i)"; |
|
311 |
by (rtac notI 1); |
|
312 |
by (etac (pnat_add_lessD1 RS pnat_less_irrefl) 1); |
|
313 |
qed "pnat_not_add_less1"; |
|
314 |
||
315 |
Goal "!!i::pnat. ~ (j+i < i)"; |
|
316 |
by (simp_tac (simpset() addsimps [pnat_add_commute, pnat_not_add_less1]) 1); |
|
317 |
qed "pnat_not_add_less2"; |
|
318 |
||
319 |
AddIffs [pnat_not_add_less1, pnat_not_add_less2]; |
|
320 |
||
321 |
Goal "m + k <= n --> m <= (n::pnat)"; |
|
322 |
by (simp_tac (simpset() addsimps [pnat_le_iff_Rep_pnat_le, |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10292
diff
changeset
|
323 |
sum_Rep_pnat_sum RS sym]) 1); |
5078 | 324 |
qed_spec_mp "pnat_add_leD1"; |
325 |
||
326 |
Goal "!!n::pnat. m + k <= n ==> k <= n"; |
|
327 |
by (full_simp_tac (simpset() addsimps [pnat_add_commute]) 1); |
|
328 |
by (etac pnat_add_leD1 1); |
|
329 |
qed_spec_mp "pnat_add_leD2"; |
|
330 |
||
331 |
Goal "!!n::pnat. m + k <= n ==> m <= n & k <= n"; |
|
332 |
by (blast_tac (claset() addDs [pnat_add_leD1, pnat_add_leD2]) 1); |
|
333 |
bind_thm ("pnat_add_leE", result() RS conjE); |
|
334 |
||
335 |
Goalw [pnat_less_def] |
|
336 |
"!!k l::pnat. [| k < l; m + l = k + n |] ==> m < n"; |
|
337 |
by (rtac less_add_eq_less 1 THEN assume_tac 1); |
|
338 |
by (auto_tac (claset(),simpset() addsimps [sum_Rep_pnat_sum])); |
|
339 |
qed "pnat_less_add_eq_less"; |
|
340 |
||
341 |
(* ordering on positive naturals in terms of existence of sum *) |
|
342 |
(* could provide alternative definition -- Gleason *) |
|
343 |
Goalw [pnat_less_def,pnat_add_def] |
|
9043
ca761fe227d8
First round of changes, towards installation of simprocs
paulson
parents:
8866
diff
changeset
|
344 |
"(z1::pnat) < z2 = (EX z3. z1 + z3 = z2)"; |
5078 | 345 |
by (rtac iffI 1); |
346 |
by (res_inst_tac [("t","z2")] (Rep_pnat_inverse RS subst) 1); |
|
347 |
by (dtac lemma_less_ex_sum_Rep_pnat 1); |
|
348 |
by (etac exE 1 THEN res_inst_tac [("x","z3")] exI 1); |
|
349 |
by (auto_tac (claset(),simpset() addsimps [sum_Rep_pnat_sum,Rep_pnat_inverse])); |
|
350 |
by (res_inst_tac [("t","Rep_pnat z1")] (add_0_right RS subst) 1); |
|
351 |
by (auto_tac (claset(),simpset() addsimps [sum_Rep_pnat_sum RS sym, |
|
352 |
Rep_pnat_gt_zero] delsimps [add_0_right])); |
|
353 |
qed "pnat_less_iff"; |
|
354 |
||
9043
ca761fe227d8
First round of changes, towards installation of simprocs
paulson
parents:
8866
diff
changeset
|
355 |
Goal "(EX (x::pnat). z1 + x = z2) | z1 = z2 \ |
ca761fe227d8
First round of changes, towards installation of simprocs
paulson
parents:
8866
diff
changeset
|
356 |
\ |(EX x. z2 + x = z1)"; |
5078 | 357 |
by (cut_facts_tac [pnat_less_linear] 1); |
358 |
by (asm_full_simp_tac (simpset() addsimps [pnat_less_iff]) 1); |
|
359 |
qed "pnat_linear_Ex_eq"; |
|
360 |
||
361 |
Goal "!!(x::pnat). x + y = z ==> x < z"; |
|
362 |
by (rtac (pnat_less_iff RS iffD2) 1); |
|
363 |
by (Blast_tac 1); |
|
364 |
qed "pnat_eq_lessI"; |
|
365 |
||
366 |
(*** Monotonicity of Addition ***) |
|
367 |
||
368 |
Goal "1 * Rep_pnat n = Rep_pnat n"; |
|
369 |
by (Asm_simp_tac 1); |
|
370 |
qed "Rep_pnat_mult_1"; |
|
371 |
||
372 |
Goal "Rep_pnat n * 1 = Rep_pnat n"; |
|
373 |
by (Asm_simp_tac 1); |
|
374 |
qed "Rep_pnat_mult_1_right"; |
|
375 |
||
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10292
diff
changeset
|
376 |
Goal "(Rep_pnat x * Rep_pnat y): pnat"; |
5078 | 377 |
by (cut_facts_tac [[Rep_pnat_gt_zero, |
378 |
Rep_pnat_gt_zero] MRS mult_less_mono1,Collect_pnat_gt_0] 1); |
|
379 |
by (etac ssubst 1); |
|
380 |
by Auto_tac; |
|
381 |
qed "mult_Rep_pnat"; |
|
382 |
||
383 |
Goalw [pnat_mult_def] |
|
384 |
"Rep_pnat x * Rep_pnat y = Rep_pnat (x * y)"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10292
diff
changeset
|
385 |
by (simp_tac (simpset() addsimps [mult_Rep_pnat RS Abs_pnat_inverse]) 1); |
5078 | 386 |
qed "mult_Rep_pnat_mult"; |
387 |
||
388 |
Goalw [pnat_mult_def] "m * n = n * (m::pnat)"; |
|
389 |
by (full_simp_tac (simpset() addsimps [mult_commute]) 1); |
|
390 |
qed "pnat_mult_commute"; |
|
391 |
||
392 |
Goalw [pnat_mult_def,pnat_add_def] "(m + n)*k = (m*k) + ((n*k)::pnat)"; |
|
393 |
by (res_inst_tac [("f","Abs_pnat")] arg_cong 1); |
|
394 |
by (simp_tac (simpset() addsimps [mult_Rep_pnat RS |
|
395 |
Abs_pnat_inverse,sum_Rep_pnat RS |
|
396 |
Abs_pnat_inverse, add_mult_distrib]) 1); |
|
397 |
qed "pnat_add_mult_distrib"; |
|
398 |
||
399 |
Goalw [pnat_mult_def,pnat_add_def] "k*(m + n) = (k*m) + ((k*n)::pnat)"; |
|
400 |
by (res_inst_tac [("f","Abs_pnat")] arg_cong 1); |
|
401 |
by (simp_tac (simpset() addsimps [mult_Rep_pnat RS |
|
402 |
Abs_pnat_inverse,sum_Rep_pnat RS |
|
403 |
Abs_pnat_inverse, add_mult_distrib2]) 1); |
|
404 |
qed "pnat_add_mult_distrib2"; |
|
405 |
||
406 |
Goalw [pnat_mult_def] |
|
407 |
"(x * y) * z = x * (y * (z::pnat))"; |
|
408 |
by (res_inst_tac [("f","Abs_pnat")] arg_cong 1); |
|
409 |
by (simp_tac (simpset() addsimps [mult_Rep_pnat RS |
|
410 |
Abs_pnat_inverse,mult_assoc]) 1); |
|
411 |
qed "pnat_mult_assoc"; |
|
412 |
||
413 |
Goalw [pnat_mult_def] "x * (y * z) = y * (x * (z::pnat))"; |
|
414 |
by (res_inst_tac [("f","Abs_pnat")] arg_cong 1); |
|
415 |
by (simp_tac (simpset() addsimps [mult_Rep_pnat RS |
|
416 |
Abs_pnat_inverse,mult_left_commute]) 1); |
|
417 |
qed "pnat_mult_left_commute"; |
|
418 |
||
11464 | 419 |
Goalw [pnat_mult_def] "x * (Abs_pnat 1') = x"; |
5078 | 420 |
by (full_simp_tac (simpset() addsimps [one_RepI RS Abs_pnat_inverse, |
421 |
Rep_pnat_inverse]) 1); |
|
422 |
qed "pnat_mult_1"; |
|
423 |
||
11464 | 424 |
Goal "Abs_pnat 1' * x = x"; |
5078 | 425 |
by (full_simp_tac (simpset() addsimps [pnat_mult_1, |
426 |
pnat_mult_commute]) 1); |
|
427 |
qed "pnat_mult_1_left"; |
|
428 |
||
429 |
(*Multiplication is an AC-operator*) |
|
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
430 |
bind_thms ("pnat_mult_ac", |
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
431 |
[pnat_mult_assoc, pnat_mult_commute, pnat_mult_left_commute]); |
5078 | 432 |
|
433 |
||
434 |
Goal "!!i::pnat. i<j ==> k*i < k*j"; |
|
435 |
by (asm_full_simp_tac (simpset() addsimps [pnat_less_def, |
|
436 |
mult_Rep_pnat_mult RS sym,Rep_pnat_gt_zero,mult_less_mono2]) 1); |
|
437 |
qed "pnat_mult_less_mono2"; |
|
438 |
||
439 |
Goal "!!i::pnat. i<j ==> i*k < j*k"; |
|
440 |
by (dtac pnat_mult_less_mono2 1); |
|
441 |
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [pnat_mult_commute]))); |
|
442 |
qed "pnat_mult_less_mono1"; |
|
443 |
||
444 |
Goalw [pnat_less_def] "(m*(k::pnat) < n*k) = (m<n)"; |
|
445 |
by (asm_full_simp_tac (simpset() addsimps [mult_Rep_pnat_mult |
|
446 |
RS sym,Rep_pnat_gt_zero]) 1); |
|
447 |
qed "pnat_mult_less_cancel2"; |
|
448 |
||
449 |
Goalw [pnat_less_def] "((k::pnat)*m < k*n) = (m<n)"; |
|
450 |
by (asm_full_simp_tac (simpset() addsimps [mult_Rep_pnat_mult |
|
451 |
RS sym,Rep_pnat_gt_zero]) 1); |
|
452 |
qed "pnat_mult_less_cancel1"; |
|
453 |
||
454 |
Addsimps [pnat_mult_less_cancel1, pnat_mult_less_cancel2]; |
|
455 |
||
456 |
Goalw [pnat_mult_def] "(m*(k::pnat) = n*k) = (m=n)"; |
|
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
457 |
by (cut_inst_tac [("x","k")] Rep_pnat_gt_zero 1); |
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
458 |
by (auto_tac (claset() addSDs [inj_on_Abs_pnat RS inj_onD, |
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
459 |
inj_Rep_pnat RS injD] |
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
460 |
addIs [mult_Rep_pnat], |
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
461 |
simpset() addsimps [mult_cancel2])); |
5078 | 462 |
qed "pnat_mult_cancel2"; |
463 |
||
464 |
Goal "((k::pnat)*m = k*n) = (m=n)"; |
|
465 |
by (rtac (pnat_mult_cancel2 RS subst) 1); |
|
466 |
by (auto_tac (claset () addIs [pnat_mult_commute RS subst],simpset())); |
|
467 |
qed "pnat_mult_cancel1"; |
|
468 |
||
469 |
Addsimps [pnat_mult_cancel1, pnat_mult_cancel2]; |
|
470 |
||
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
471 |
Goal "!!(z1::pnat). z2*z3 = z4*z5 ==> z2*(z1*z3) = z4*(z1*z5)"; |
5078 | 472 |
by (auto_tac (claset() addIs [pnat_mult_cancel1 RS iffD2], |
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
473 |
simpset() addsimps [pnat_mult_left_commute])); |
5078 | 474 |
qed "pnat_same_multI2"; |
475 |
||
9635
c9ebf0a1d712
tidied & updated proofs, deleting some unused ones
paulson
parents:
9422
diff
changeset
|
476 |
val [prem] = Goal |
5078 | 477 |
"(!!u. z = Abs_pnat(u) ==> P) ==> P"; |
478 |
by (cut_inst_tac [("x1","z")] |
|
479 |
(rewrite_rule [pnat_def] (Rep_pnat RS Abs_pnat_inverse)) 1); |
|
480 |
by (res_inst_tac [("u","Rep_pnat z")] prem 1); |
|
481 |
by (dtac (inj_Rep_pnat RS injD) 1); |
|
482 |
by (Asm_simp_tac 1); |
|
483 |
qed "eq_Abs_pnat"; |
|
484 |
||
485 |
(** embedding of naturals in positive naturals **) |
|
486 |
||
487 |
(* pnat_one_eq! *) |
|
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
488 |
Goalw [pnat_of_nat_def,pnat_one_def]"1p = pnat_of_nat 0"; |
5078 | 489 |
by (Full_simp_tac 1); |
490 |
qed "pnat_one_iff"; |
|
491 |
||
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
492 |
Goalw [pnat_of_nat_def,pnat_one_def, |
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
493 |
pnat_add_def] "1p + 1p = pnat_of_nat 1"; |
5078 | 494 |
by (res_inst_tac [("f","Abs_pnat")] arg_cong 1); |
495 |
by (auto_tac (claset() addIs [(gt_0_mem_pnat RS Abs_pnat_inverse RS ssubst)], |
|
496 |
simpset())); |
|
497 |
qed "pnat_two_eq"; |
|
498 |
||
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
499 |
Goal "inj(pnat_of_nat)"; |
5078 | 500 |
by (rtac injI 1); |
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
501 |
by (rewtac pnat_of_nat_def); |
5078 | 502 |
by (dtac (inj_on_Abs_pnat RS inj_onD) 1); |
503 |
by (auto_tac (claset() addSIs [gt_0_mem_pnat],simpset())); |
|
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
504 |
qed "inj_pnat_of_nat"; |
5078 | 505 |
|
506 |
Goal "0 < n + 1"; |
|
507 |
by Auto_tac; |
|
508 |
qed "nat_add_one_less"; |
|
509 |
||
510 |
Goal "0 < n1 + n2 + 1"; |
|
511 |
by Auto_tac; |
|
512 |
qed "nat_add_one_less1"; |
|
513 |
||
514 |
(* this worked with one call to auto_tac before! *) |
|
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
515 |
Goalw [pnat_add_def,pnat_of_nat_def,pnat_one_def] |
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
516 |
"pnat_of_nat n1 + pnat_of_nat n2 = \ |
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
517 |
\ pnat_of_nat (n1 + n2) + 1p"; |
5078 | 518 |
by (res_inst_tac [("f","Abs_pnat")] arg_cong 1); |
519 |
by (rtac (gt_0_mem_pnat RS Abs_pnat_inverse RS ssubst) 1); |
|
520 |
by (rtac (gt_0_mem_pnat RS Abs_pnat_inverse RS ssubst) 2); |
|
521 |
by (rtac (gt_0_mem_pnat RS Abs_pnat_inverse RS ssubst) 3); |
|
522 |
by (rtac (gt_0_mem_pnat RS Abs_pnat_inverse RS ssubst) 4); |
|
523 |
by (auto_tac (claset(), |
|
524 |
simpset() addsimps [sum_Rep_pnat_sum, |
|
525 |
nat_add_one_less,nat_add_one_less1])); |
|
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
526 |
qed "pnat_of_nat_add"; |
5078 | 527 |
|
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
528 |
Goalw [pnat_of_nat_def,pnat_less_def] |
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
529 |
"(n < m) = (pnat_of_nat n < pnat_of_nat m)"; |
5078 | 530 |
by (auto_tac (claset(),simpset() |
531 |
addsimps [Abs_pnat_inverse,Collect_pnat_gt_0])); |
|
7077
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
532 |
qed "pnat_of_nat_less_iff"; |
60b098bb8b8a
heavily revised by Jacques: coercions have alphabetic names;
paulson
parents:
6073
diff
changeset
|
533 |
Addsimps [pnat_of_nat_less_iff RS sym]; |
5078 | 534 |
|
9422 | 535 |
Goalw [pnat_mult_def,pnat_of_nat_def] |
7292 | 536 |
"pnat_of_nat n1 * pnat_of_nat n2 = \ |
537 |
\ pnat_of_nat (n1 * n2 + n1 + n2)"; |
|
538 |
by (auto_tac (claset(),simpset() addsimps [mult_Rep_pnat_mult, |
|
539 |
pnat_add_def,Abs_pnat_inverse,gt_0_mem_pnat])); |
|
540 |
qed "pnat_of_nat_mult"; |