3 Author: Lawrence C Paulson and Tobias Nipkow
5 Proofs about natural numbers and elementary arithmetic: addition,
6 multiplication, etc. Some from the Hoare example from Norbert Galm.
9 (** conversion rules for nat_rec **)
11 val [nat_rec_0, nat_rec_Suc] = nat.recs;
12 bind_thm ("nat_rec_0", nat_rec_0);
13 bind_thm ("nat_rec_Suc", nat_rec_Suc);
15 (*These 2 rules ease the use of primitive recursion. NOTE USE OF == *)
17 "[| !!n. f(n) == nat_rec c h n |] ==> f(0) = c";
18 by (simp_tac (simpset() addsimps prems) 1);
22 "[| !!n. f(n) == nat_rec c h n |] ==> f(Suc(n)) = h n (f n)";
23 by (simp_tac (simpset() addsimps prems) 1);
24 qed "def_nat_rec_Suc";
26 val [nat_case_0, nat_case_Suc] = nat.cases;
27 bind_thm ("nat_case_0", nat_case_0);
28 bind_thm ("nat_case_Suc", nat_case_Suc);
30 Goal "n ~= 0 ==> EX m. n = Suc m";
32 by (REPEAT (Blast_tac 1));
33 qed "not0_implies_Suc";
35 Goal "!!n::nat. m<n ==> n ~= 0";
37 by (ALLGOALS Asm_full_simp_tac);
38 qed "gr_implies_not0";
40 Goal "!!n::nat. (n ~= 0) = (0 < n)";
46 (*This theorem is useful with blast_tac: (n=0 ==> False) ==> 0<n *)
47 bind_thm ("gr0I", [neq0_conv, notI] MRS iffD1);
49 Goal "(0<n) = (EX m. n = Suc m)";
50 by(fast_tac (claset() addIs [not0_implies_Suc]) 1);
53 Goal "!!n::nat. (~(0 < n)) = (n=0)";
56 by (ALLGOALS Asm_full_simp_tac);
60 Goal "(Suc n <= m') --> (? m. m' = Suc m)";
61 by (induct_tac "m'" 1);
63 qed_spec_mp "Suc_le_D";
65 (*Useful in certain inductive arguments*)
66 Goal "(m < Suc n) = (m=0 | (EX j. m = Suc j & j < n))";
69 qed "less_Suc_eq_0_disj";
71 val prems = Goal "[| P 0; P(Suc 0); !!k. P k ==> P (Suc (Suc k)) |] ==> P n";
72 by (rtac nat_less_induct 1);
74 by (case_tac "nat" 2);
75 by (ALLGOALS (blast_tac (claset() addIs prems@[less_trans])));
78 (** LEAST theorems for type "nat" by specialization **)
80 bind_thm("LeastI", wellorder_LeastI);
81 bind_thm("Least_le", wellorder_Least_le);
82 bind_thm("not_less_Least", wellorder_not_less_Least);
84 Goal "[| P n; ~ P 0 |] ==> (LEAST n. P n) = Suc (LEAST m. P(Suc m))";
88 by (dres_inst_tac [("P","%x. P (Suc x)")] LeastI 1);
89 by (subgoal_tac "(LEAST x. P x) <= Suc (LEAST x. P (Suc x))" 1);
91 by (case_tac "LEAST x. P x" 1);
93 by (dres_inst_tac [("P","%x. P (Suc x)")] Least_le 1);
94 by (blast_tac (claset() addIs [order_antisym]) 1);
97 Goal "[|P n; Q m; ~P 0; !k. P (Suc k) = Q k|] ==> Least P = Suc (Least Q)";
98 by (eatac (Least_Suc RS ssubst) 1 1);
105 Goal "min 0 n = (0::nat)";
106 by (rtac min_leastL 1);
110 Goal "min n 0 = (0::nat)";
111 by (rtac min_leastR 1);
115 Goal "min (Suc m) (Suc n) = Suc (min m n)";
116 by (simp_tac (simpset() addsimps [min_of_mono]) 1);
119 Addsimps [min_0L,min_0R,min_Suc_Suc];
121 Goal "max 0 n = (n::nat)";
122 by (rtac max_leastL 1);
126 Goal "max n 0 = (n::nat)";
127 by (rtac max_leastR 1);
131 Goal "max (Suc m) (Suc n) = Suc(max m n)";
132 by (simp_tac (simpset() addsimps [max_of_mono]) 1);
135 Addsimps [max_0L,max_0R,max_Suc_Suc];
138 (*** Basic rewrite rules for the arithmetic operators ***)
142 Goal "0 - n = (0::nat)";
143 by (induct_tac "n" 1);
144 by (ALLGOALS Asm_simp_tac);
147 (*Must simplify BEFORE the induction! (Else we get a critical pair)
148 Suc(m) - Suc(n) rewrites to pred(Suc(m) - n) *)
149 Goal "Suc(m) - Suc(n) = m - n";
151 by (induct_tac "n" 1);
152 by (ALLGOALS Asm_simp_tac);
155 Addsimps [diff_0_eq_0, diff_Suc_Suc];
157 (* Could be (and is, below) generalized in various ways;
158 However, none of the generalizations are currently in the simpset,
159 and I dread to think what happens if I put them in *)
160 Goal "0 < n ==> Suc(n - Suc 0) = n";
161 by (asm_simp_tac (simpset() addsplits [nat.split]) 1);
168 (**** Inductive properties of the operators ****)
172 Goal "m + 0 = (m::nat)";
173 by (induct_tac "m" 1);
174 by (ALLGOALS Asm_simp_tac);
177 Goal "m + Suc(n) = Suc(m+n)";
178 by (induct_tac "m" 1);
179 by (ALLGOALS Asm_simp_tac);
182 Addsimps [add_0_right,add_Suc_right];
185 (*Associative law for addition*)
186 Goal "(m + n) + k = m + ((n + k)::nat)";
187 by (induct_tac "m" 1);
188 by (ALLGOALS Asm_simp_tac);
191 (*Commutative law for addition*)
192 Goal "m + n = n + (m::nat)";
193 by (induct_tac "m" 1);
194 by (ALLGOALS Asm_simp_tac);
197 Goal "x+(y+z)=y+((x+z)::nat)";
198 by (rtac (add_commute RS trans) 1);
199 by (rtac (add_assoc RS trans) 1);
200 by (rtac (add_commute RS arg_cong) 1);
201 qed "add_left_commute";
203 (*Addition is an AC-operator*)
204 bind_thms ("add_ac", [add_assoc, add_commute, add_left_commute]);
206 Goal "(k + m = k + n) = (m=(n::nat))";
207 by (induct_tac "k" 1);
210 qed "add_left_cancel";
212 Goal "(m + k = n + k) = (m=(n::nat))";
213 by (induct_tac "k" 1);
216 qed "add_right_cancel";
218 Goal "(k + m <= k + n) = (m<=(n::nat))";
219 by (induct_tac "k" 1);
222 qed "add_left_cancel_le";
224 Goal "(k + m < k + n) = (m<(n::nat))";
225 by (induct_tac "k" 1);
228 qed "add_left_cancel_less";
230 Addsimps [add_left_cancel, add_right_cancel,
231 add_left_cancel_le, add_left_cancel_less];
233 (** Reasoning about m+0=0, etc. **)
235 Goal "!!m::nat. (m+n = 0) = (m=0 & n=0)";
241 Goal "(m+n= Suc 0) = (m= Suc 0 & n=0 | m=0 & n= Suc 0)";
246 Goal "(Suc 0 = m+n) = (m = Suc 0 & n=0 | m=0 & n = Suc 0)";
247 by (rtac ([eq_commute, add_is_1] MRS trans) 1);
250 Goal "!!m::nat. (0<m+n) = (0<m | 0<n)";
251 by (simp_tac (simpset() delsimps [neq0_conv] addsimps [neq0_conv RS sym]) 1);
255 Goal "!!m::nat. m + n = m ==> n = 0";
256 by (dtac (add_0_right RS ssubst) 1);
257 by (asm_full_simp_tac (simpset() addsimps [add_assoc]
258 delsimps [add_0_right]) 1);
259 qed "add_eq_self_zero";
262 (**** Additional theorems about "less than" ****)
264 (*Deleted less_natE; instead use less_imp_Suc_add RS exE*)
265 Goal "m<n --> (EX k. n=Suc(m+k))";
266 by (induct_tac "n" 1);
267 by (ALLGOALS (simp_tac (simpset() addsimps [order_le_less])));
268 by (blast_tac (claset() addSEs [less_SucE]
269 addSIs [add_0_right RS sym, add_Suc_right RS sym]) 1);
270 qed_spec_mp "less_imp_Suc_add";
272 Goal "n <= ((m + n)::nat)";
273 by (induct_tac "m" 1);
274 by (ALLGOALS Simp_tac);
278 Goal "n <= ((n + m)::nat)";
279 by (simp_tac (simpset() addsimps add_ac) 1);
283 bind_thm ("less_add_Suc1", (lessI RS (le_add1 RS le_less_trans)));
284 bind_thm ("less_add_Suc2", (lessI RS (le_add2 RS le_less_trans)));
286 Goal "(m<n) = (EX k. n=Suc(m+k))";
287 by (blast_tac (claset() addSIs [less_add_Suc1, less_imp_Suc_add]) 1);
288 qed "less_iff_Suc_add";
291 (*"i <= j ==> i <= j+m"*)
292 bind_thm ("trans_le_add1", le_add1 RSN (2,le_trans));
294 (*"i <= j ==> i <= m+j"*)
295 bind_thm ("trans_le_add2", le_add2 RSN (2,le_trans));
297 (*"i < j ==> i < j+m"*)
298 bind_thm ("trans_less_add1", le_add1 RSN (2,less_le_trans));
300 (*"i < j ==> i < m+j"*)
301 bind_thm ("trans_less_add2", le_add2 RSN (2,less_le_trans));
303 Goal "i+j < (k::nat) --> i<k";
304 by (induct_tac "j" 1);
305 by (ALLGOALS Asm_simp_tac);
306 by (blast_tac (claset() addDs [Suc_lessD]) 1);
307 qed_spec_mp "add_lessD1";
309 Goal "~ (i+j < (i::nat))";
311 by (etac (add_lessD1 RS less_irrefl) 1);
314 Goal "~ (j+i < (i::nat))";
315 by (simp_tac (simpset() addsimps [add_commute, not_add_less1]) 1);
317 AddIffs [not_add_less1, not_add_less2];
319 Goal "m+k<=n --> m<=(n::nat)";
320 by (induct_tac "k" 1);
321 by (ALLGOALS (asm_simp_tac (simpset() addsimps le_simps)));
322 qed_spec_mp "add_leD1";
324 Goal "m+k<=n ==> k<=(n::nat)";
325 by (full_simp_tac (simpset() addsimps [add_commute]) 1);
326 by (etac add_leD1 1);
327 qed_spec_mp "add_leD2";
329 Goal "m+k<=n ==> m<=n & k<=(n::nat)";
330 by (blast_tac (claset() addDs [add_leD1, add_leD2]) 1);
331 bind_thm ("add_leE", result() RS conjE);
333 (*needs !!k for add_ac to work*)
334 Goal "!!k:: nat. [| k<l; m+l = k+n |] ==> m<n";
335 by (force_tac (claset(),
336 simpset() delsimps [add_Suc_right]
337 addsimps [less_iff_Suc_add,
338 add_Suc_right RS sym] @ add_ac) 1);
339 qed "less_add_eq_less";
342 (*** Monotonicity of Addition ***)
344 (*strict, in 1st argument*)
345 Goal "i < j ==> i + k < j + (k::nat)";
346 by (induct_tac "k" 1);
347 by (ALLGOALS Asm_simp_tac);
348 qed "add_less_mono1";
350 (*strict, in both arguments*)
351 Goal "[|i < j; k < l|] ==> i + k < j + (l::nat)";
352 by (rtac (add_less_mono1 RS less_trans) 1);
353 by (REPEAT (assume_tac 1));
354 by (induct_tac "j" 1);
355 by (ALLGOALS Asm_simp_tac);
358 (*A [clumsy] way of lifting < monotonicity to <= monotonicity *)
359 val [lt_mono,le] = Goal
360 "[| !!i j::nat. i<j ==> f(i) < f(j); \
362 \ |] ==> f(i) <= (f(j)::nat)";
363 by (cut_facts_tac [le] 1);
364 by (asm_full_simp_tac (simpset() addsimps [order_le_less]) 1);
365 by (blast_tac (claset() addSIs [lt_mono]) 1);
366 qed "less_mono_imp_le_mono";
368 (*non-strict, in 1st argument*)
369 Goal "i<=j ==> i + k <= j + (k::nat)";
370 by (res_inst_tac [("f", "%j. j+k")] less_mono_imp_le_mono 1);
371 by (etac add_less_mono1 1);
375 (*non-strict, in both arguments*)
376 Goal "[|i<=j; k<=l |] ==> i + k <= j + (l::nat)";
377 by (etac (add_le_mono1 RS le_trans) 1);
378 by (simp_tac (simpset() addsimps [add_commute]) 1);
382 (*** Multiplication ***)
384 (*right annihilation in product*)
385 Goal "!!m::nat. m * 0 = 0";
386 by (induct_tac "m" 1);
387 by (ALLGOALS Asm_simp_tac);
390 (*right successor law for multiplication*)
391 Goal "m * Suc(n) = m + (m * n)";
392 by (induct_tac "m" 1);
393 by (ALLGOALS(asm_simp_tac (simpset() addsimps add_ac)));
394 qed "mult_Suc_right";
396 Addsimps [mult_0_right, mult_Suc_right];
398 Goal "(1::nat) * n = n";
402 Goal "n * (1::nat) = n";
406 (*Commutative law for multiplication*)
407 Goal "m * n = n * (m::nat)";
408 by (induct_tac "m" 1);
409 by (ALLGOALS Asm_simp_tac);
412 (*addition distributes over multiplication*)
413 Goal "(m + n)*k = (m*k) + ((n*k)::nat)";
414 by (induct_tac "m" 1);
415 by (ALLGOALS(asm_simp_tac (simpset() addsimps add_ac)));
416 qed "add_mult_distrib";
418 Goal "k*(m + n) = (k*m) + ((k*n)::nat)";
419 by (induct_tac "m" 1);
420 by (ALLGOALS(asm_simp_tac (simpset() addsimps add_ac)));
421 qed "add_mult_distrib2";
423 (*Associative law for multiplication*)
424 Goal "(m * n) * k = m * ((n * k)::nat)";
425 by (induct_tac "m" 1);
426 by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_mult_distrib])));
429 Goal "x*(y*z) = y*((x*z)::nat)";
431 by (rtac mult_commute 1);
433 by (rtac mult_assoc 1);
434 by (rtac (mult_commute RS arg_cong) 1);
435 qed "mult_left_commute";
437 bind_thms ("mult_ac", [mult_assoc,mult_commute,mult_left_commute]);
439 Goal "!!m::nat. (m*n = 0) = (m=0 | n=0)";
440 by (induct_tac "m" 1);
441 by (induct_tac "n" 2);
442 by (ALLGOALS Asm_simp_tac);
444 Addsimps [mult_is_0];
449 Goal "!!m::nat. m - m = 0";
450 by (induct_tac "m" 1);
451 by (ALLGOALS Asm_simp_tac);
452 qed "diff_self_eq_0";
454 Addsimps [diff_self_eq_0];
456 (*Addition is the inverse of subtraction: if n<=m then n+(m-n) = m. *)
457 Goal "~ m<n --> n+(m-n) = (m::nat)";
458 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
459 by (ALLGOALS Asm_simp_tac);
460 qed_spec_mp "add_diff_inverse";
462 Goal "n<=m ==> n+(m-n) = (m::nat)";
463 by (asm_simp_tac (simpset() addsimps [add_diff_inverse, not_less_iff_le]) 1);
464 qed "le_add_diff_inverse";
466 Goal "n<=m ==> (m-n)+n = (m::nat)";
467 by (asm_simp_tac (simpset() addsimps [le_add_diff_inverse, add_commute]) 1);
468 qed "le_add_diff_inverse2";
470 Addsimps [le_add_diff_inverse, le_add_diff_inverse2];
473 (*** More results about difference ***)
475 Goal "n <= m ==> Suc(m)-n = Suc(m-n)";
477 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
478 by (ALLGOALS Asm_simp_tac);
481 Goal "m - n < Suc(m)";
482 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
483 by (etac less_SucE 3);
484 by (ALLGOALS (asm_simp_tac (simpset() addsimps [less_Suc_eq])));
487 Goal "m - n <= (m::nat)";
488 by (res_inst_tac [("m","m"), ("n","n")] diff_induct 1);
489 by (ALLGOALS (asm_simp_tac (simpset() addsimps [le_SucI])));
491 Addsimps [diff_le_self];
493 (* j<k ==> j-n < k *)
494 bind_thm ("less_imp_diff_less", diff_le_self RS le_less_trans);
496 Goal "!!i::nat. i-j-k = i - (j+k)";
497 by (res_inst_tac [("m","i"),("n","j")] diff_induct 1);
498 by (ALLGOALS Asm_simp_tac);
499 qed "diff_diff_left";
501 Goal "(Suc m - n) - Suc k = m - n - k";
502 by (simp_tac (simpset() addsimps [diff_diff_left]) 1);
504 Addsimps [Suc_diff_diff];
506 Goal "0<n ==> n - Suc i < n";
509 by (asm_simp_tac (simpset() addsimps le_simps) 1);
511 Addsimps [diff_Suc_less];
513 (*This and the next few suggested by Florian Kammueller*)
514 Goal "!!i::nat. i-j-k = i-k-j";
515 by (simp_tac (simpset() addsimps [diff_diff_left, add_commute]) 1);
518 Goal "k <= (j::nat) --> (i + j) - k = i + (j - k)";
519 by (res_inst_tac [("m","j"),("n","k")] diff_induct 1);
520 by (ALLGOALS Asm_simp_tac);
521 qed_spec_mp "diff_add_assoc";
523 Goal "k <= (j::nat) --> (j + i) - k = (j - k) + i";
524 by (asm_simp_tac (simpset() addsimps [add_commute, diff_add_assoc]) 1);
525 qed_spec_mp "diff_add_assoc2";
527 Goal "(n+m) - n = (m::nat)";
528 by (induct_tac "n" 1);
529 by (ALLGOALS Asm_simp_tac);
530 qed "diff_add_inverse";
532 Goal "(m+n) - n = (m::nat)";
533 by (simp_tac (simpset() addsimps [diff_add_assoc]) 1);
534 qed "diff_add_inverse2";
536 Goal "i <= (j::nat) ==> (j-i=k) = (j=k+i)";
538 by (ALLGOALS (asm_simp_tac (simpset() addsimps [diff_add_inverse2])));
539 qed "le_imp_diff_is_add";
541 Goal "!!m::nat. (m-n = 0) = (m <= n)";
542 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
543 by (ALLGOALS Asm_simp_tac);
545 Addsimps [diff_is_0_eq];
547 Goal "!!m::nat. (0<n-m) = (m<n)";
548 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
549 by (ALLGOALS Asm_simp_tac);
550 qed "zero_less_diff";
551 Addsimps [zero_less_diff];
553 Goal "i < j ==> EX k::nat. 0<k & i+k = j";
554 by (res_inst_tac [("x","j - i")] exI 1);
555 by (asm_simp_tac (simpset() addsimps [add_diff_inverse, less_not_sym]) 1);
556 qed "less_imp_add_positive";
558 Goal "P(k) --> (ALL n. P(Suc(n))--> P(n)) --> P(k-i)";
559 by (res_inst_tac [("m","k"),("n","i")] diff_induct 1);
560 by (ALLGOALS (Clarify_tac THEN' Simp_tac THEN' TRY o Blast_tac));
561 qed "zero_induct_lemma";
563 val prems = Goal "[| P(k); !!n. P(Suc(n)) ==> P(n) |] ==> P(0)";
564 by (rtac (diff_self_eq_0 RS subst) 1);
565 by (rtac (zero_induct_lemma RS mp RS mp) 1);
566 by (REPEAT (ares_tac ([impI,allI]@prems) 1));
569 Goal "(k+m) - (k+n) = m - (n::nat)";
570 by (induct_tac "k" 1);
571 by (ALLGOALS Asm_simp_tac);
574 Goal "(m+k) - (n+k) = m - (n::nat)";
576 (simpset() addsimps [diff_cancel, inst "n" "k" add_commute]) 1);
579 Goal "n - (n+m) = (0::nat)";
580 by (induct_tac "n" 1);
581 by (ALLGOALS Asm_simp_tac);
585 (** Difference distributes over multiplication **)
587 Goal "!!m::nat. (m - n) * k = (m * k) - (n * k)";
588 by (res_inst_tac [("m","m"),("n","n")] diff_induct 1);
589 by (ALLGOALS (asm_simp_tac (simpset() addsimps [diff_cancel])));
590 qed "diff_mult_distrib" ;
592 Goal "!!m::nat. k * (m - n) = (k * m) - (k * n)";
593 val mult_commute_k = read_instantiate [("m","k")] mult_commute;
594 by (simp_tac (simpset() addsimps [diff_mult_distrib, mult_commute_k]) 1);
595 qed "diff_mult_distrib2" ;
596 (*NOT added as rewrites, since sometimes they are used from right-to-left*)
598 bind_thms ("nat_distrib",
599 [add_mult_distrib, add_mult_distrib2, diff_mult_distrib, diff_mult_distrib2]);
602 (*** Monotonicity of Multiplication ***)
604 Goal "i <= (j::nat) ==> i*k<=j*k";
605 by (induct_tac "k" 1);
606 by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_le_mono])));
609 Goal "i <= (j::nat) ==> k*i <= k*j";
610 by (dtac mult_le_mono1 1);
611 by (asm_simp_tac (simpset() addsimps [mult_commute]) 1);
614 (* <= monotonicity, BOTH arguments*)
615 Goal "[| i <= (j::nat); k <= l |] ==> i*k <= j*l";
616 by (etac (mult_le_mono1 RS le_trans) 1);
617 by (etac mult_le_mono2 1);
620 (*strict, in 1st argument; proof is by induction on k>0*)
621 Goal "!!i::nat. [| i<j; 0<k |] ==> k*i < k*j";
622 by (eres_inst_tac [("m1","0")] (less_imp_Suc_add RS exE) 1);
624 by (induct_tac "x" 1);
625 by (ALLGOALS (asm_simp_tac (simpset() addsimps [add_less_mono])));
626 qed "mult_less_mono2";
628 Goal "!!i::nat. [| i<j; 0<k |] ==> i*k < j*k";
629 by (dtac mult_less_mono2 1);
630 by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [mult_commute])));
631 qed "mult_less_mono1";
633 Goal "!!m::nat. (0 < m*n) = (0<m & 0<n)";
634 by (induct_tac "m" 1);
636 by (ALLGOALS Asm_simp_tac);
637 qed "zero_less_mult_iff";
638 Addsimps [zero_less_mult_iff];
640 Goal "(Suc 0 <= m*n) = (1<=m & 1<=n)";
641 by (induct_tac "m" 1);
643 by (ALLGOALS Asm_simp_tac);
644 qed "one_le_mult_iff";
645 Addsimps [one_le_mult_iff];
647 Goal "(m*n = Suc 0) = (m=1 & n=1)";
648 by (induct_tac "m" 1);
650 by (induct_tac "n" 1);
652 by (fast_tac (claset() addss simpset()) 1);
654 Addsimps [mult_eq_1_iff];
656 Goal "(Suc 0 = m*n) = (m=1 & n=1)";
657 by(rtac (mult_eq_1_iff RSN (2,trans)) 1);
658 by (fast_tac (claset() addss simpset()) 1);
659 qed "one_eq_mult_iff";
660 Addsimps [one_eq_mult_iff];
662 Goal "!!m::nat. (m*k < n*k) = (0<k & m<n)";
663 by (safe_tac (claset() addSIs [mult_less_mono1]));
666 by (full_simp_tac (simpset() delsimps [le_0_eq]
667 addsimps [linorder_not_le RS sym]) 1);
668 by (blast_tac (claset() addIs [mult_le_mono1]) 1);
669 qed "mult_less_cancel2";
671 Goal "!!m::nat. (k*m < k*n) = (0<k & m<n)";
672 by (simp_tac (simpset() addsimps [mult_less_cancel2,
673 inst "m" "k" mult_commute]) 1);
674 qed "mult_less_cancel1";
675 Addsimps [mult_less_cancel1, mult_less_cancel2];
677 Goal "!!m::nat. (m*k <= n*k) = (0<k --> m<=n)";
678 by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1);
680 qed "mult_le_cancel2";
682 Goal "!!m::nat. (k*m <= k*n) = (0<k --> m<=n)";
683 by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1);
685 qed "mult_le_cancel1";
686 Addsimps [mult_le_cancel1, mult_le_cancel2];
688 Goal "(m*k = n*k) = (m=n | (k = (0::nat)))";
689 by (cut_facts_tac [less_linear] 1);
692 by (ALLGOALS (dtac mult_less_mono1 THEN' assume_tac));
693 by (ALLGOALS Asm_full_simp_tac);
696 Goal "(k*m = k*n) = (m=n | (k = (0::nat)))";
697 by (simp_tac (simpset() addsimps [mult_cancel2, inst "m" "k" mult_commute]) 1);
699 Addsimps [mult_cancel1, mult_cancel2];
701 Goal "(Suc k * m < Suc k * n) = (m < n)";
702 by (stac mult_less_cancel1 1);
704 qed "Suc_mult_less_cancel1";
706 Goal "(Suc k * m <= Suc k * n) = (m <= n)";
707 by (stac mult_le_cancel1 1);
709 qed "Suc_mult_le_cancel1";
711 Goal "(Suc k * m = Suc k * n) = (m = n)";
712 by (stac mult_cancel1 1);
714 qed "Suc_mult_cancel1";
718 Goal "!!m::nat. m = m*n ==> n=1 | m=0";
721 by (rtac nat_less_cases 1 THEN assume_tac 2);
722 by (fast_tac (claset() addSEs [less_SucE] addss simpset()) 1);
723 by (best_tac (claset() addDs [mult_less_mono2] addss simpset()) 1);
724 qed "mult_eq_self_implies_10";