3115
|
1 |
(* Title: FOL/ex/Nat.ML
|
0
|
2 |
ID: $Id$
|
1459
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
0
|
4 |
Copyright 1992 University of Cambridge
|
|
5 |
|
3115
|
6 |
Proofs about the natural numbers.
|
0
|
7 |
|
|
8 |
To generate similar output to manual, execute these commands:
|
|
9 |
Pretty.setmargin 72; print_depth 0;
|
|
10 |
*)
|
|
11 |
|
|
12 |
open Nat;
|
|
13 |
|
5050
|
14 |
Goal "Suc(k) ~= k";
|
0
|
15 |
by (res_inst_tac [("n","k")] induct 1);
|
1459
|
16 |
by (rtac notI 1);
|
|
17 |
by (etac Suc_neq_0 1);
|
|
18 |
by (rtac notI 1);
|
|
19 |
by (etac notE 1);
|
|
20 |
by (etac Suc_inject 1);
|
755
|
21 |
qed "Suc_n_not_n";
|
0
|
22 |
|
|
23 |
|
5050
|
24 |
Goal "(k+m)+n = k+(m+n)";
|
0
|
25 |
prths ([induct] RL [topthm()]); (*prints all 14 next states!*)
|
1459
|
26 |
by (rtac induct 1);
|
0
|
27 |
back();
|
|
28 |
back();
|
|
29 |
back();
|
|
30 |
back();
|
|
31 |
back();
|
|
32 |
back();
|
|
33 |
|
5050
|
34 |
Goalw [add_def] "0+n = n";
|
1459
|
35 |
by (rtac rec_0 1);
|
755
|
36 |
qed "add_0";
|
0
|
37 |
|
5050
|
38 |
Goalw [add_def] "Suc(m)+n = Suc(m+n)";
|
1459
|
39 |
by (rtac rec_Suc 1);
|
755
|
40 |
qed "add_Suc";
|
0
|
41 |
|
2469
|
42 |
Addsimps [add_0, add_Suc];
|
0
|
43 |
|
5050
|
44 |
Goal "(k+m)+n = k+(m+n)";
|
0
|
45 |
by (res_inst_tac [("n","k")] induct 1);
|
2469
|
46 |
by (Simp_tac 1);
|
|
47 |
by (Asm_simp_tac 1);
|
755
|
48 |
qed "add_assoc";
|
0
|
49 |
|
5050
|
50 |
Goal "m+0 = m";
|
0
|
51 |
by (res_inst_tac [("n","m")] induct 1);
|
2469
|
52 |
by (Simp_tac 1);
|
|
53 |
by (Asm_simp_tac 1);
|
755
|
54 |
qed "add_0_right";
|
0
|
55 |
|
5050
|
56 |
Goal "m+Suc(n) = Suc(m+n)";
|
0
|
57 |
by (res_inst_tac [("n","m")] induct 1);
|
2469
|
58 |
by (ALLGOALS (Asm_simp_tac));
|
755
|
59 |
qed "add_Suc_right";
|
0
|
60 |
|
5204
|
61 |
(*Example used in Reference Manual, Doc/Ref/simplifier.tex*)
|
|
62 |
val [prem] = Goal "(!!n. f(Suc(n)) = Suc(f(n))) ==> f(i+j) = i+f(j)";
|
0
|
63 |
by (res_inst_tac [("n","i")] induct 1);
|
2469
|
64 |
by (Simp_tac 1);
|
5204
|
65 |
by (asm_simp_tac (simpset() addsimps [prem]) 1);
|
0
|
66 |
result();
|