src/ZF/ex/Primrec.ML
author paulson
Fri, 29 Jan 1999 17:08:20 +0100
changeset 6163 be8234f37e48
parent 6154 6a00a5baef2b
child 7499 23e090051cb8
permissions -rw-r--r--
expandshort
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
     1
(*  Title:      ZF/ex/Primrec
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     2
    ID:         $Id$
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     5
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     6
Primitive Recursive Functions
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     7
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     8
Proof adopted from
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     9
Nora Szasz, 
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    10
A Machine Checked Proof that Ackermann's Function is not Primitive Recursive,
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    11
In: Huet & Plotkin, eds., Logical Environments (CUP, 1993), 317-338.
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    12
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    13
See also E. Mendelson, Introduction to Mathematical Logic.
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    14
(Van Nostrand, 1964), page 250, exercise 11.
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    15
*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    16
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    17
(*** Inductive definition of the PR functions ***)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    18
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
    19
(* c: prim_rec ==> c: list(nat) -> nat *)
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
    20
val prim_rec_into_fun = prim_rec.dom_subset RS subsetD;
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    21
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
    22
AddTCs ([prim_rec_into_fun] @ prim_rec.intrs);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    23
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    24
Goal "i:nat ==> ACK(i): prim_rec";
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
    25
by (induct_tac "i" 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    26
by (ALLGOALS Asm_simp_tac);
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
    27
qed "ACK_in_prim_rec";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    28
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
    29
AddTCs [ACK_in_prim_rec, prim_rec_into_fun RS apply_type,
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
    30
	list_add_type, nat_into_Ord, rec_type];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    31
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
    32
Goal "[| i:nat;  j:nat |] ==>  ack(i,j): nat";
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    33
by Auto_tac;
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
    34
qed "ack_type";
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
    35
AddTCs [ack_type];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    36
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    37
(** Ackermann's function cases **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    38
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    39
(*PROPERTY A 1*)
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    40
Goal "j:nat ==> ack(0,j) = succ(j)";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
    41
by (asm_simp_tac (simpset() addsimps [SC]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    42
qed "ack_0";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    43
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    44
(*PROPERTY A 2*)
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    45
Goal "ack(succ(i), 0) = ack(i,1)";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
    46
by (asm_simp_tac (simpset() addsimps [CONST,PREC_0]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    47
qed "ack_succ_0";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    48
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    49
(*PROPERTY A 3*)
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    50
Goal "[| i:nat;  j:nat |]  \
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    51
\     ==> ack(succ(i), succ(j)) = ack(i, ack(succ(i), j))";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
    52
by (asm_simp_tac (simpset() addsimps [CONST,PREC_succ,COMP_1,PROJ_0]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    53
qed "ack_succ_succ";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    54
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    55
Addsimps [ack_0, ack_succ_0, ack_succ_succ, ack_type, nat_into_Ord];
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    56
Delsimps [ACK_0, ACK_succ];
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    57
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    58
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    59
(*PROPERTY A 4*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
    60
Goal "i:nat ==> ALL j:nat. j < ack(i,j)";
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
    61
by (induct_tac "i" 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    62
by (Asm_simp_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    63
by (rtac ballI 1);
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
    64
by (induct_tac "j" 1);
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    65
by (etac (succ_leI RS lt_trans1) 2);
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    66
by (rtac (nat_0I RS nat_0_le RS lt_trans) 1);
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
    67
by Auto_tac;
6112
5e4871c5136b datatype package improvements
paulson
parents: 6071
diff changeset
    68
qed_spec_mp "lt_ack2";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    69
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    70
(*PROPERTY A 5-, the single-step lemma*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
    71
Goal "[| i:nat; j:nat |] ==> ack(i,j) < ack(i, succ(j))";
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
    72
by (induct_tac "i" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
    73
by (ALLGOALS (asm_simp_tac (simpset() addsimps [lt_ack2])));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    74
qed "ack_lt_ack_succ2";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    75
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    76
(*PROPERTY A 5, monotonicity for < *)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
    77
Goal "[| j<k; i:nat; k:nat |] ==> ack(i,j) < ack(i,k)";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    78
by (forward_tac [lt_nat_in_nat] 1 THEN assume_tac 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    79
by (etac succ_lt_induct 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    80
by (assume_tac 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    81
by (rtac lt_trans 2);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
    82
by (auto_tac (claset() addIs [ack_lt_ack_succ2], simpset()));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
    83
qed "ack_lt_mono2";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    84
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    85
(*PROPERTY A 5', monotonicity for le *)
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
    86
Goal "[| j le k;  i: nat;  k:nat |] ==> ack(i,j) le ack(i,k)";
3840
e0baea4d485a fixed dots;
wenzelm
parents: 3328
diff changeset
    87
by (res_inst_tac [("f", "%j. ack(i,j)")] Ord_lt_mono_imp_le_mono 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    88
by (REPEAT (ares_tac [ack_lt_mono2, ack_type RS nat_into_Ord] 1));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
    89
qed "ack_le_mono2";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    90
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    91
(*PROPERTY A 6*)
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
    92
Goal "[| i:nat;  j:nat |] ==> ack(i, succ(j)) le ack(succ(i), j)";
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
    93
by (induct_tac "j" 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
    94
by (ALLGOALS Asm_simp_tac);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    95
by (rtac ack_le_mono2 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    96
by (rtac (lt_ack2 RS succ_leI RS le_trans) 1);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
    97
by Auto_tac;
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
    98
qed "ack2_le_ack1";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    99
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   100
(*PROPERTY A 7-, the single-step lemma*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   101
Goal "[| i:nat; j:nat |] ==> ack(i,j) < ack(succ(i),j)";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   102
by (rtac (ack_lt_mono2 RS lt_trans2) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   103
by (rtac ack2_le_ack1 4);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   104
by Auto_tac;
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   105
qed "ack_lt_ack_succ1";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   106
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   107
(*PROPERTY A 7, monotonicity for < *)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   108
Goal "[| i<j; j:nat; k:nat |] ==> ack(i,k) < ack(j,k)";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   109
by (forward_tac [lt_nat_in_nat] 1 THEN assume_tac 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   110
by (etac succ_lt_induct 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   111
by (assume_tac 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   112
by (rtac lt_trans 2);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   113
by (auto_tac (claset() addIs [ack_lt_ack_succ1], simpset()));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   114
qed "ack_lt_mono1";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   115
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   116
(*PROPERTY A 7', monotonicity for le *)
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   117
Goal "[| i le j; j:nat; k:nat |] ==> ack(i,k) le ack(j,k)";
3840
e0baea4d485a fixed dots;
wenzelm
parents: 3328
diff changeset
   118
by (res_inst_tac [("f", "%j. ack(j,k)")] Ord_lt_mono_imp_le_mono 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   119
by (REPEAT (ares_tac [ack_lt_mono1, ack_type RS nat_into_Ord] 1));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   120
qed "ack_le_mono1";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   121
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   122
(*PROPERTY A 8*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   123
Goal "j:nat ==> ack(1,j) = succ(succ(j))";
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
   124
by (induct_tac "j" 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   125
by (ALLGOALS Asm_simp_tac);
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   126
qed "ack_1";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   127
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   128
(*PROPERTY A 9*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   129
Goal "j:nat ==> ack(succ(1),j) = succ(succ(succ(j#+j)))";
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
   130
by (induct_tac "j" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   131
by (ALLGOALS (asm_simp_tac (simpset() addsimps [ack_1, add_succ_right])));
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   132
qed "ack_2";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   133
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   134
(*PROPERTY A 10*)
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   135
Goal "[| i1:nat; i2:nat; j:nat |] ==> \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   136
\               ack(i1, ack(i2,j)) < ack(succ(succ(i1#+i2)), j)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   137
by (rtac (ack2_le_ack1 RSN (2,lt_trans2)) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   138
by (Asm_simp_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   139
by (rtac (add_le_self RS ack_le_mono1 RS lt_trans1) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   140
by (rtac (add_le_self2 RS ack_lt_mono1 RS ack_lt_mono2) 5);
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
   141
by Auto_tac;
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   142
qed "ack_nest_bound";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   143
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   144
(*PROPERTY A 11*)
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   145
Goal "[| i1:nat; i2:nat; j:nat |] ==> \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   146
\          ack(i1,j) #+ ack(i2,j) < ack(succ(succ(succ(succ(i1#+i2)))), j)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   147
by (res_inst_tac [("j", "ack(succ(1), ack(i1 #+ i2, j))")] lt_trans 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   148
by (asm_simp_tac (simpset() addsimps [ack_2]) 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   149
by (rtac (ack_nest_bound RS lt_trans2) 2);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   150
by (Asm_simp_tac 5);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   151
by (rtac (add_le_mono RS leI RS leI) 1);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   152
by (auto_tac (claset() addIs [add_le_self, add_le_self2, ack_le_mono1], 
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   153
	      simpset()));
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   154
qed "ack_add_bound";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   155
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   156
(*PROPERTY A 12.  Article uses existential quantifier but the ALF proof
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   157
  used k#+4.  Quantified version must be nested EX k'. ALL i,j... *)
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   158
Goal "[| i < ack(k,j);  j:nat;  k:nat |] ==> \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   159
\             i#+j < ack(succ(succ(succ(succ(k)))), j)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   160
by (res_inst_tac [("j", "ack(k,j) #+ ack(0,j)")] lt_trans 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   161
by (rtac (ack_add_bound RS lt_trans2) 2);
6163
be8234f37e48 expandshort
paulson
parents: 6154
diff changeset
   162
by (rtac add_lt_mono 1);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   163
by Auto_tac;
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   164
qed "ack_add_bound2";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   165
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   166
(*** MAIN RESULT ***)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   167
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   168
Addsimps [list_add_type, nat_into_Ord];
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   169
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6044
diff changeset
   170
Goalw [SC_def] "l: list(nat) ==> SC ` l < ack(1, list_add(l))";
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6044
diff changeset
   171
by (exhaust_tac "l" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   172
by (asm_simp_tac (simpset() addsimps [succ_iff]) 1);
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   173
by (asm_simp_tac (simpset() addsimps [ack_1, add_le_self]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   174
qed "SC_case";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   175
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   176
(*PROPERTY A 4'? Extra lemma needed for CONST case, constant functions*)
5137
60205b0de9b9 Huge tidy-up: removal of leading \!\!
paulson
parents: 5068
diff changeset
   177
Goal "[| i:nat; j:nat |] ==> i < ack(i,j)";
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
   178
by (induct_tac "i" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   179
by (asm_simp_tac (simpset() addsimps [nat_0_le]) 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   180
by (etac ([succ_leI, ack_lt_ack_succ1] MRS lt_trans1) 1);
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
   181
by Auto_tac;
760
f0200e91b272 added qed and qed_goal[w]
clasohm
parents: 515
diff changeset
   182
qed "lt_ack1";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   183
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   184
Goalw [CONST_def]
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   185
    "[| l: list(nat);  k: nat |] ==> CONST(k) ` l < ack(k, list_add(l))";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   186
by (asm_simp_tac (simpset() addsimps [lt_ack1]) 1);
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   187
qed "CONST_case";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   188
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   189
Goalw [PROJ_def]
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   190
    "l: list(nat) ==> ALL i:nat. PROJ(i) ` l < ack(0, list_add(l))";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   191
by (Asm_simp_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   192
by (etac list.induct 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   193
by (asm_simp_tac (simpset() addsimps [nat_0_le]) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   194
by (Asm_simp_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   195
by (rtac ballI 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   196
by (eres_inst_tac [("n","x")] natE 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   197
by (asm_simp_tac (simpset() addsimps [add_le_self]) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   198
by (Asm_simp_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   199
by (etac (bspec RS lt_trans2) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   200
by (rtac (add_le_self2 RS succ_leI) 2);
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
   201
by Auto_tac;
6154
6a00a5baef2b automatic insertion of datatype intr rules into claset
paulson
parents: 6153
diff changeset
   202
qed_spec_mp "PROJ_case";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   203
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   204
(** COMP case **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   205
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   206
Goal "fs : list({f: prim_rec .                                 \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   207
\                  EX kf:nat. ALL l:list(nat).                  \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   208
\                             f`l < ack(kf, list_add(l))})      \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   209
\      ==> EX k:nat. ALL l: list(nat).                          \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   210
\                list_add(map(%f. f ` l, fs)) < ack(k, list_add(l))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   211
by (etac list.induct 1);
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
   212
by (res_inst_tac [("x","0")] bexI 1);
6154
6a00a5baef2b automatic insertion of datatype intr rules into claset
paulson
parents: 6153
diff changeset
   213
by (ALLGOALS (asm_simp_tac (simpset() addsimps [lt_ack1, nat_0_le])));
6a00a5baef2b automatic insertion of datatype intr rules into claset
paulson
parents: 6153
diff changeset
   214
by (Clarify_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   215
by (rtac (ballI RS bexI) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   216
by (rtac (add_lt_mono RS lt_trans) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   217
by (REPEAT (FIRSTGOAL (etac bspec)));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   218
by (rtac ack_add_bound 5);
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
   219
by Auto_tac;
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   220
qed "COMP_map_lemma";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   221
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   222
Goalw [COMP_def]
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   223
 "[| kg: nat;                                 \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   224
\         ALL l:list(nat). g`l < ack(kg, list_add(l));          \
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   225
\         fs : list({f: prim_rec .                               \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   226
\                    EX kf:nat. ALL l:list(nat).                \
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   227
\                       f`l < ack(kf, list_add(l))})            \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   228
\      |] ==> EX k:nat. ALL l: list(nat). COMP(g,fs)`l < ack(k, list_add(l))";
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   229
by (Asm_simp_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   230
by (forward_tac [list_CollectD] 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   231
by (etac (COMP_map_lemma RS bexE) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   232
by (rtac (ballI RS bexI) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   233
by (etac (bspec RS lt_trans) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   234
by (rtac lt_trans 2);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   235
by (rtac ack_nest_bound 3);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   236
by (etac (bspec RS ack_lt_mono2) 2);
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
   237
by Auto_tac;
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   238
qed "COMP_case";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   239
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   240
(** PREC case **)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   241
5068
fb28eaa07e01 isatool fixgoal;
wenzelm
parents: 4152
diff changeset
   242
Goalw [PREC_def]
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   243
 "[| ALL l:list(nat). f`l #+ list_add(l) < ack(kf, list_add(l)); \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   244
\           ALL l:list(nat). g`l #+ list_add(l) < ack(kg, list_add(l)); \
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   245
\           f: prim_rec;  kf: nat;                                       \
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   246
\           g: prim_rec;  kg: nat;                                       \
1461
6bcb44e4d6e5 expanded tabs
clasohm
parents: 782
diff changeset
   247
\           l: list(nat)                                                \
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   248
\        |] ==> PREC(f,g)`l #+ list_add(l) < ack(succ(kf#+kg), list_add(l))";
6065
3b4a29166f26 induct_tac and exhaust_tac
paulson
parents: 6044
diff changeset
   249
by (exhaust_tac "l" 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   250
by (asm_simp_tac (simpset() addsimps [[nat_le_refl, lt_ack2] MRS lt_trans]) 1);
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   251
by (Asm_simp_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   252
by (etac ssubst 1);  (*get rid of the needless assumption*)
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 6065
diff changeset
   253
by (induct_tac "a" 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   254
(*base case*)
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
   255
by (EVERY1 [Asm_simp_tac, rtac lt_trans, etac bspec,
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   256
	    assume_tac, rtac (add_le_self RS ack_lt_mono1)]);
6154
6a00a5baef2b automatic insertion of datatype intr rules into claset
paulson
parents: 6153
diff changeset
   257
by (ALLGOALS Asm_simp_tac);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   258
(*ind step*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   259
by (rtac (succ_leI RS lt_trans1) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   260
by (res_inst_tac [("j", "g ` ?ll #+ ?mm")] lt_trans1 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   261
by (etac bspec 2);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   262
by (rtac (nat_le_refl RS add_le_mono) 1);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   263
by Typecheck_tac;
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3840
diff changeset
   264
by (asm_simp_tac (simpset() addsimps [add_le_self2]) 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   265
(*final part of the simplification*)
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1461
diff changeset
   266
by (Asm_simp_tac 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   267
by (rtac (add_le_self2 RS ack_le_mono1 RS lt_trans1) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   268
by (etac ack_lt_mono2 5);
6071
1b2392ac5752 removal of DO_GOAL
paulson
parents: 6070
diff changeset
   269
by Auto_tac;
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   270
qed "PREC_case_lemma";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   271
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   272
Goal "[| f: prim_rec;  kf: nat;                               \
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   273
\        g: prim_rec;  kg: nat;                               \
5147
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   274
\        ALL l:list(nat). f`l < ack(kf, list_add(l));        \
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   275
\        ALL l:list(nat). g`l < ack(kg, list_add(l))         \
825877190618 More tidying and removal of "\!\!... from Goal commands
paulson
parents: 5137
diff changeset
   276
\     |] ==> EX k:nat. ALL l: list(nat). PREC(f,g)`l< ack(k, list_add(l))";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   277
by (rtac (ballI RS bexI) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   278
by (rtac ([add_le_self, PREC_case_lemma] MRS lt_trans1) 1);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   279
by (REPEAT_FIRST (rtac (ack_add_bound2 RS ballI) THEN' etac bspec));
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   280
by Typecheck_tac;
782
200a16083201 added bind_thm for theorems defined by "standard ..."
clasohm
parents: 760
diff changeset
   281
qed "PREC_case";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   282
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   283
Goal "f:prim_rec ==> EX k:nat. ALL l:list(nat). f`l < ack(k, list_add(l))";
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   284
by (etac prim_rec.induct 1);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   285
by (auto_tac (claset() addIs [SC_case, CONST_case, PROJ_case, COMP_case, 
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   286
			      PREC_case], 
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   287
	      simpset()));
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   288
qed "ack_bounds_prim_rec";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   289
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   290
Goal "~ (lam l:list(nat). list_case(0, %x xs. ack(x,x), l)) : prim_rec";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   291
by (rtac notI 1);
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   292
by (etac (ack_bounds_prim_rec RS bexE) 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   293
by (rtac lt_irrefl 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   294
by (dres_inst_tac [("x", "[x]")] bspec 1);
6153
bff90585cce5 new typechecking solver for the simplifier
paulson
parents: 6112
diff changeset
   295
by Auto_tac;
6044
e0f9d930e956 Needs separate theory Primrec_defs due to new inductive defs package
paulson
parents: 5268
diff changeset
   296
qed "ack_not_prim_rec";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   297