author | wenzelm |
Wed, 04 Sep 2013 17:36:37 +0200 | |
changeset 53406 | d4374a69ddff |
parent 51717 | 9e7d1c139569 |
child 55228 | 901a6696cdd8 |
permissions | -rw-r--r-- |
17481 | 1 |
(* Title: Sequents/LK/Nat.thy |
7091 | 2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
7095 | 3 |
Copyright 1999 University of Cambridge |
7091 | 4 |
*) |
5 |
||
17481 | 6 |
header {* Theory of the natural numbers: Peano's axioms, primitive recursion *} |
7 |
||
8 |
theory Nat |
|
9 |
imports LK |
|
10 |
begin |
|
11 |
||
12 |
typedecl nat |
|
13 |
arities nat :: "term" |
|
7091 | 14 |
|
51309 | 15 |
axiomatization |
16 |
Zero :: nat ("0") and |
|
17 |
Suc :: "nat=>nat" and |
|
18 |
rec :: "[nat, 'a, [nat,'a]=>'a] => 'a" |
|
19 |
where |
|
17481 | 20 |
induct: "[| $H |- $E, P(0), $F; |
51309 | 21 |
!!x. $H, P(x) |- $E, P(Suc(x)), $F |] ==> $H |- $E, P(n), $F" and |
7095 | 22 |
|
51309 | 23 |
Suc_inject: "|- Suc(m)=Suc(n) --> m=n" and |
24 |
Suc_neq_0: "|- Suc(m) ~= 0" and |
|
25 |
rec_0: "|- rec(0,a,f) = a" and |
|
17481 | 26 |
rec_Suc: "|- rec(Suc(m), a, f) = f(m, rec(m,a,f))" |
51309 | 27 |
|
28 |
definition add :: "[nat, nat] => nat" (infixl "+" 60) |
|
29 |
where "m + n == rec(m, n, %x y. Suc(y))" |
|
17481 | 30 |
|
21426 | 31 |
|
32 |
declare Suc_neq_0 [simp] |
|
33 |
||
34 |
lemma Suc_inject_rule: "$H, $G, m = n |- $E \<Longrightarrow> $H, Suc(m) = Suc(n), $G |- $E" |
|
35 |
by (rule L_of_imp [OF Suc_inject]) |
|
36 |
||
37 |
lemma Suc_n_not_n: "|- Suc(k) ~= k" |
|
38 |
apply (rule_tac n = k in induct) |
|
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
39 |
apply (tactic {* simp_tac (put_simpset LK_ss @{context} addsimps @{thms Suc_neq_0}) 1 *}) |
22896 | 40 |
apply (tactic {* fast_tac (LK_pack add_safes @{thms Suc_inject_rule}) 1 *}) |
21426 | 41 |
done |
42 |
||
43 |
lemma add_0: "|- 0+n = n" |
|
44 |
apply (unfold add_def) |
|
45 |
apply (rule rec_0) |
|
46 |
done |
|
47 |
||
48 |
lemma add_Suc: "|- Suc(m)+n = Suc(m+n)" |
|
49 |
apply (unfold add_def) |
|
50 |
apply (rule rec_Suc) |
|
51 |
done |
|
52 |
||
53 |
declare add_0 [simp] add_Suc [simp] |
|
54 |
||
55 |
lemma add_assoc: "|- (k+m)+n = k+(m+n)" |
|
56 |
apply (rule_tac n = "k" in induct) |
|
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
57 |
apply (tactic {* simp_tac (put_simpset LK_ss @{context} addsimps @{thms add_0}) 1 *}) |
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
58 |
apply (tactic {* simp_tac (put_simpset LK_ss @{context} addsimps @{thms add_Suc}) 1 *}) |
21426 | 59 |
done |
60 |
||
61 |
lemma add_0_right: "|- m+0 = m" |
|
62 |
apply (rule_tac n = "m" in induct) |
|
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
63 |
apply (tactic {* simp_tac (put_simpset LK_ss @{context} addsimps @{thms add_0}) 1 *}) |
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
64 |
apply (tactic {* simp_tac (put_simpset LK_ss @{context} addsimps @{thms add_Suc}) 1 *}) |
21426 | 65 |
done |
66 |
||
67 |
lemma add_Suc_right: "|- m+Suc(n) = Suc(m+n)" |
|
68 |
apply (rule_tac n = "m" in induct) |
|
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
69 |
apply (tactic {* simp_tac (put_simpset LK_ss @{context} addsimps @{thms add_0}) 1 *}) |
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
70 |
apply (tactic {* simp_tac (put_simpset LK_ss @{context} addsimps @{thms add_Suc}) 1 *}) |
21426 | 71 |
done |
72 |
||
73 |
lemma "(!!n. |- f(Suc(n)) = Suc(f(n))) ==> |- f(i+j) = i+f(j)" |
|
74 |
apply (rule_tac n = "i" in induct) |
|
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
75 |
apply (tactic {* simp_tac (put_simpset LK_ss @{context} addsimps @{thms add_0}) 1 *}) |
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51309
diff
changeset
|
76 |
apply (tactic {* asm_simp_tac (put_simpset LK_ss @{context} addsimps @{thms add_Suc}) 1 *}) |
21426 | 77 |
done |
17481 | 78 |
|
7091 | 79 |
end |