100 (* 0 : pnat ==> P *) |
100 (* 0 : pnat ==> P *) |
101 bind_thm ("zero_not_mem_pnatE", zero_not_mem_pnat RS notE); |
101 bind_thm ("zero_not_mem_pnatE", zero_not_mem_pnat RS notE); |
102 |
102 |
103 Addsimps [zero_not_mem_pnat]; |
103 Addsimps [zero_not_mem_pnat]; |
104 |
104 |
105 Goal "!!x. x : pnat ==> 0 < x"; |
105 Goal "x : pnat ==> 0 < x"; |
106 by (dtac (pnat_unfold RS subst) 1); |
106 by (dtac (pnat_unfold RS subst) 1); |
107 by Auto_tac; |
107 by Auto_tac; |
108 qed "mem_pnat_gt_zero"; |
108 qed "mem_pnat_gt_zero"; |
109 |
109 |
110 Goal "!!x. 0 < x ==> x: pnat"; |
110 Goal "0 < x ==> x: pnat"; |
111 by (stac pnat_unfold 1); |
111 by (stac pnat_unfold 1); |
112 by (dtac (gr_implies_not0 RS not0_implies_Suc) 1); |
112 by (dtac (gr_implies_not0 RS not0_implies_Suc) 1); |
113 by (etac exE 1 THEN Asm_simp_tac 1); |
113 by (etac exE 1 THEN Asm_simp_tac 1); |
114 by (induct_tac "m" 1); |
114 by (induct_tac "m" 1); |
115 by (auto_tac (claset(),simpset() |
115 by (auto_tac (claset(),simpset() |
175 by (ALLGOALS Asm_simp_tac); |
175 by (ALLGOALS Asm_simp_tac); |
176 qed "n_not_pSuc_n"; |
176 qed "n_not_pSuc_n"; |
177 |
177 |
178 bind_thm ("pSuc_n_not_n", n_not_pSuc_n RS not_sym); |
178 bind_thm ("pSuc_n_not_n", n_not_pSuc_n RS not_sym); |
179 |
179 |
180 Goal "!!n. n ~= 1p ==> EX m. n = pSuc m"; |
180 Goal "n ~= 1p ==> EX m. n = pSuc m"; |
181 by (rtac pnatE 1); |
181 by (rtac pnatE 1); |
182 by (REPEAT (Blast_tac 1)); |
182 by (REPEAT (Blast_tac 1)); |
183 qed "not1p_implies_pSuc"; |
183 qed "not1p_implies_pSuc"; |
184 |
184 |
185 Goal "pSuc m = m + 1p"; |
185 Goal "pSuc m = m + 1p"; |
243 Goalw [pnat_less_def] |
243 Goalw [pnat_less_def] |
244 "!!x. [| x < (y::pnat); y < z |] ==> x < z"; |
244 "!!x. [| x < (y::pnat); y < z |] ==> x < z"; |
245 by ((etac less_trans 1) THEN assume_tac 1); |
245 by ((etac less_trans 1) THEN assume_tac 1); |
246 qed "pnat_less_trans"; |
246 qed "pnat_less_trans"; |
247 |
247 |
248 Goalw [pnat_less_def] "!!x. x < (y::pnat) ==> ~ y < x"; |
248 Goalw [pnat_less_def] "x < (y::pnat) ==> ~ y < x"; |
249 by (etac less_not_sym 1); |
249 by (etac less_not_sym 1); |
250 qed "pnat_less_not_sym"; |
250 qed "pnat_less_not_sym"; |
251 |
251 |
252 (* [| x < y; y < x |] ==> P *) |
252 (* [| x < y; y < x |] ==> P *) |
253 bind_thm ("pnat_less_asym",pnat_less_not_sym RS notE); |
253 bind_thm ("pnat_less_asym",pnat_less_not_sym RS notE); |
254 |
254 |
255 Goalw [pnat_less_def] "!!x. ~ y < (y::pnat)"; |
255 Goalw [pnat_less_def] "~ y < (y::pnat)"; |
256 by Auto_tac; |
256 by Auto_tac; |
257 qed "pnat_less_not_refl"; |
257 qed "pnat_less_not_refl"; |
258 |
258 |
259 bind_thm ("pnat_less_irrefl",pnat_less_not_refl RS notE); |
259 bind_thm ("pnat_less_irrefl",pnat_less_not_refl RS notE); |
260 |
260 |
302 qed "lemma_less_ex_sum_Rep_pnat"; |
302 qed "lemma_less_ex_sum_Rep_pnat"; |
303 |
303 |
304 |
304 |
305 (*** pnat_le ***) |
305 (*** pnat_le ***) |
306 |
306 |
307 Goalw [pnat_le_def] "!!x. ~ (x::pnat) < y ==> y <= x"; |
307 Goalw [pnat_le_def] "~ (x::pnat) < y ==> y <= x"; |
308 by (assume_tac 1); |
308 by (assume_tac 1); |
309 qed "pnat_leI"; |
309 qed "pnat_leI"; |
310 |
310 |
311 Goalw [pnat_le_def] "!!x. (x::pnat) <= y ==> ~ y < x"; |
311 Goalw [pnat_le_def] "(x::pnat) <= y ==> ~ y < x"; |
312 by (assume_tac 1); |
312 by (assume_tac 1); |
313 qed "pnat_leD"; |
313 qed "pnat_leD"; |
314 |
314 |
315 val pnat_leE = make_elim pnat_leD; |
315 val pnat_leE = make_elim pnat_leD; |
316 |
316 |
317 Goal "(~ (x::pnat) < y) = (y <= x)"; |
317 Goal "(~ (x::pnat) < y) = (y <= x)"; |
318 by (blast_tac (claset() addIs [pnat_leI] addEs [pnat_leE]) 1); |
318 by (blast_tac (claset() addIs [pnat_leI] addEs [pnat_leE]) 1); |
319 qed "pnat_not_less_iff_le"; |
319 qed "pnat_not_less_iff_le"; |
320 |
320 |
321 Goalw [pnat_le_def] "!!x. ~(x::pnat) <= y ==> y < x"; |
321 Goalw [pnat_le_def] "~(x::pnat) <= y ==> y < x"; |
322 by (Blast_tac 1); |
322 by (Blast_tac 1); |
323 qed "pnat_not_leE"; |
323 qed "pnat_not_leE"; |
324 |
324 |
325 Goalw [pnat_le_def] "!!x. (x::pnat) < y ==> x <= y"; |
325 Goalw [pnat_le_def] "(x::pnat) < y ==> x <= y"; |
326 by (blast_tac (claset() addEs [pnat_less_asym]) 1); |
326 by (blast_tac (claset() addEs [pnat_less_asym]) 1); |
327 qed "pnat_less_imp_le"; |
327 qed "pnat_less_imp_le"; |
328 |
328 |
329 (** Equivalence of m<=n and m<n | m=n **) |
329 (** Equivalence of m<=n and m<n | m=n **) |
330 |
330 |
331 Goalw [pnat_le_def] "!!m. m <= n ==> m < n | m=(n::pnat)"; |
331 Goalw [pnat_le_def] "m <= n ==> m < n | m=(n::pnat)"; |
332 by (cut_facts_tac [pnat_less_linear] 1); |
332 by (cut_facts_tac [pnat_less_linear] 1); |
333 by (blast_tac (claset() addEs [pnat_less_irrefl,pnat_less_asym]) 1); |
333 by (blast_tac (claset() addEs [pnat_less_irrefl,pnat_less_asym]) 1); |
334 qed "pnat_le_imp_less_or_eq"; |
334 qed "pnat_le_imp_less_or_eq"; |
335 |
335 |
336 Goalw [pnat_le_def] "!!m. m<n | m=n ==> m <=(n::pnat)"; |
336 Goalw [pnat_le_def] "m<n | m=n ==> m <=(n::pnat)"; |
337 by (cut_facts_tac [pnat_less_linear] 1); |
337 by (cut_facts_tac [pnat_less_linear] 1); |
338 by (blast_tac (claset() addSEs [pnat_less_irrefl] addEs [pnat_less_asym]) 1); |
338 by (blast_tac (claset() addSEs [pnat_less_irrefl] addEs [pnat_less_asym]) 1); |
339 qed "pnat_less_or_eq_imp_le"; |
339 qed "pnat_less_or_eq_imp_le"; |
340 |
340 |
341 Goal "(m <= (n::pnat)) = (m < n | m=n)"; |
341 Goal "(m <= (n::pnat)) = (m < n | m=n)"; |
349 val prems = goal thy "!!i. [| i <= j; j < k |] ==> i < (k::pnat)"; |
349 val prems = goal thy "!!i. [| i <= j; j < k |] ==> i < (k::pnat)"; |
350 by (dtac pnat_le_imp_less_or_eq 1); |
350 by (dtac pnat_le_imp_less_or_eq 1); |
351 by (blast_tac (claset() addIs [pnat_less_trans]) 1); |
351 by (blast_tac (claset() addIs [pnat_less_trans]) 1); |
352 qed "pnat_le_less_trans"; |
352 qed "pnat_le_less_trans"; |
353 |
353 |
354 Goal "!!i. [| i < j; j <= k |] ==> i < (k::pnat)"; |
354 Goal "[| i < j; j <= k |] ==> i < (k::pnat)"; |
355 by (dtac pnat_le_imp_less_or_eq 1); |
355 by (dtac pnat_le_imp_less_or_eq 1); |
356 by (blast_tac (claset() addIs [pnat_less_trans]) 1); |
356 by (blast_tac (claset() addIs [pnat_less_trans]) 1); |
357 qed "pnat_less_le_trans"; |
357 qed "pnat_less_le_trans"; |
358 |
358 |
359 Goal "!!i. [| i <= j; j <= k |] ==> i <= (k::pnat)"; |
359 Goal "[| i <= j; j <= k |] ==> i <= (k::pnat)"; |
360 by (EVERY1[dtac pnat_le_imp_less_or_eq, |
360 by (EVERY1[dtac pnat_le_imp_less_or_eq, |
361 dtac pnat_le_imp_less_or_eq, |
361 dtac pnat_le_imp_less_or_eq, |
362 rtac pnat_less_or_eq_imp_le, |
362 rtac pnat_less_or_eq_imp_le, |
363 blast_tac (claset() addIs [pnat_less_trans])]); |
363 blast_tac (claset() addIs [pnat_less_trans])]); |
364 qed "pnat_le_trans"; |
364 qed "pnat_le_trans"; |
365 |
365 |
366 Goal "!!m. [| m <= n; n <= m |] ==> m = (n::pnat)"; |
366 Goal "[| m <= n; n <= m |] ==> m = (n::pnat)"; |
367 by (EVERY1[dtac pnat_le_imp_less_or_eq, |
367 by (EVERY1[dtac pnat_le_imp_less_or_eq, |
368 dtac pnat_le_imp_less_or_eq, |
368 dtac pnat_le_imp_less_or_eq, |
369 blast_tac (claset() addIs [pnat_less_asym])]); |
369 blast_tac (claset() addIs [pnat_less_asym])]); |
370 qed "pnat_le_anti_sym"; |
370 qed "pnat_le_anti_sym"; |
371 |
371 |
438 bind_thm ("pnat_trans_less_add1", pnat_le_add1 RSN (2,pnat_less_le_trans)); |
438 bind_thm ("pnat_trans_less_add1", pnat_le_add1 RSN (2,pnat_less_le_trans)); |
439 |
439 |
440 (*"i < j ==> i < m + j"*) |
440 (*"i < j ==> i < m + j"*) |
441 bind_thm ("pnat_trans_less_add2", pnat_le_add2 RSN (2,pnat_less_le_trans)); |
441 bind_thm ("pnat_trans_less_add2", pnat_le_add2 RSN (2,pnat_less_le_trans)); |
442 |
442 |
443 Goalw [pnat_less_def] "!!i. i+j < (k::pnat) ==> i<k"; |
443 Goalw [pnat_less_def] "i+j < (k::pnat) ==> i<k"; |
444 by (auto_tac (claset() addEs [add_lessD1], |
444 by (auto_tac (claset() addEs [add_lessD1], |
445 simpset() addsimps [sum_Rep_pnat_sum RS sym])); |
445 simpset() addsimps [sum_Rep_pnat_sum RS sym])); |
446 qed "pnat_add_lessD1"; |
446 qed "pnat_add_lessD1"; |
447 |
447 |
448 Goal "!!i::pnat. ~ (i+j < i)"; |
448 Goal "!!i::pnat. ~ (i+j < i)"; |