src/Sequents/LK/Nat.thy
author haftmann
Tue, 10 Jul 2007 17:30:50 +0200
changeset 23709 fd31da8f752a
parent 22896 1c2abcabea61
child 35762 af3ff2ba4c54
permissions -rw-r--r--
moved lfp_induct2 here
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
     1
(*  Title:      Sequents/LK/Nat.thy
7091
b76a26835a5c Sequents/LK/Nat: new example of simplification in LK
paulson
parents:
diff changeset
     2
    ID:         $Id$
b76a26835a5c Sequents/LK/Nat: new example of simplification in LK
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
7095
cfc11af6174a fixed the comments...
paulson
parents: 7091
diff changeset
     4
    Copyright   1999  University of Cambridge
7091
b76a26835a5c Sequents/LK/Nat: new example of simplification in LK
paulson
parents:
diff changeset
     5
*)
b76a26835a5c Sequents/LK/Nat: new example of simplification in LK
paulson
parents:
diff changeset
     6
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
     7
header {* Theory of the natural numbers: Peano's axioms, primitive recursion *}
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
     8
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
     9
theory Nat
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    10
imports LK
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    11
begin
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    12
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    13
typedecl nat
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    14
arities nat :: "term"
7091
b76a26835a5c Sequents/LK/Nat: new example of simplification in LK
paulson
parents:
diff changeset
    15
consts  "0" :: nat      ("0")
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    16
        Suc :: "nat=>nat"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    17
        rec :: "[nat, 'a, [nat,'a]=>'a] => 'a"
22896
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    18
        add :: "[nat, nat] => nat"                (infixl "+" 60)
7091
b76a26835a5c Sequents/LK/Nat: new example of simplification in LK
paulson
parents:
diff changeset
    19
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    20
axioms
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    21
  induct:  "[| $H |- $E, P(0), $F;
7123
4ab38de3fd20 congruence rule for |-, etc.
paulson
parents: 7095
diff changeset
    22
              !!x. $H, P(x) |- $E, P(Suc(x)), $F |] ==> $H |- $E, P(n), $F"
7095
cfc11af6174a fixed the comments...
paulson
parents: 7091
diff changeset
    23
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    24
  Suc_inject:  "|- Suc(m)=Suc(n) --> m=n"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    25
  Suc_neq_0:   "|- Suc(m) ~= 0"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    26
  rec_0:       "|- rec(0,a,f) = a"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    27
  rec_Suc:     "|- rec(Suc(m), a, f) = f(m, rec(m,a,f))"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    28
  add_def:     "m+n == rec(m, n, %x y. Suc(y))"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    29
21426
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    30
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    31
declare Suc_neq_0 [simp]
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    32
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    33
lemma Suc_inject_rule: "$H, $G, m = n |- $E \<Longrightarrow> $H, Suc(m) = Suc(n), $G |- $E"
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    34
  by (rule L_of_imp [OF Suc_inject])
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    35
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    36
lemma Suc_n_not_n: "|- Suc(k) ~= k"
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    37
  apply (rule_tac n = k in induct)
22896
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    38
  apply (tactic {* simp_tac (LK_ss addsimps @{thms Suc_neq_0}) 1 *})
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    39
  apply (tactic {* fast_tac (LK_pack add_safes @{thms Suc_inject_rule}) 1 *})
21426
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    40
  done
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    41
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    42
lemma add_0: "|- 0+n = n"
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    43
  apply (unfold add_def)
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    44
  apply (rule rec_0)
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    45
  done
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    46
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    47
lemma add_Suc: "|- Suc(m)+n = Suc(m+n)"
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    48
  apply (unfold add_def)
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    49
  apply (rule rec_Suc)
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    50
  done
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    51
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    52
declare add_0 [simp] add_Suc [simp]
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    53
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    54
lemma add_assoc: "|- (k+m)+n = k+(m+n)"
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    55
  apply (rule_tac n = "k" in induct)
22896
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    56
  apply (tactic {* simp_tac (LK_ss addsimps @{thms add_0}) 1 *})
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    57
  apply (tactic {* simp_tac (LK_ss addsimps @{thms add_Suc}) 1 *})
21426
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    58
  done
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    59
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    60
lemma add_0_right: "|- m+0 = m"
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    61
  apply (rule_tac n = "m" in induct)
22896
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    62
  apply (tactic {* simp_tac (LK_ss addsimps @{thms add_0}) 1 *})
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    63
  apply (tactic {* simp_tac (LK_ss addsimps @{thms add_Suc}) 1 *})
21426
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    64
  done
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    65
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    66
lemma add_Suc_right: "|- m+Suc(n) = Suc(m+n)"
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    67
  apply (rule_tac n = "m" in induct)
22896
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    68
  apply (tactic {* simp_tac (LK_ss addsimps @{thms add_0}) 1 *})
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    69
  apply (tactic {* simp_tac (LK_ss addsimps @{thms add_Suc}) 1 *})
21426
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    70
  done
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    71
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    72
lemma "(!!n. |- f(Suc(n)) = Suc(f(n))) ==> |- f(i+j) = i+f(j)"
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    73
  apply (rule_tac n = "i" in induct)
22896
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    74
  apply (tactic {* simp_tac (LK_ss addsimps @{thms add_0}) 1 *})
1c2abcabea61 tuned ML setup;
wenzelm
parents: 21426
diff changeset
    75
  apply (tactic {* asm_simp_tac (LK_ss addsimps @{thms add_Suc}) 1 *})
21426
87ac12bed1ab converted legacy ML scripts;
wenzelm
parents: 17481
diff changeset
    76
  done
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 7123
diff changeset
    77
7091
b76a26835a5c Sequents/LK/Nat: new example of simplification in LK
paulson
parents:
diff changeset
    78
end