author | wenzelm |
Mon, 11 Sep 2023 19:30:48 +0200 | |
changeset 78659 | b5f3d1051b13 |
parent 76987 | 4c275405faae |
permissions | -rw-r--r-- |
12560 | 1 |
(* Title: ZF/Induct/Primrec.thy |
12088 | 2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
3 |
Copyright 1994 University of Cambridge |
|
12610 | 4 |
*) |
12088 | 5 |
|
60770 | 6 |
section \<open>Primitive Recursive Functions: the inductive definition\<close> |
12088 | 7 |
|
65449
c82e63b11b8b
clarified main ZF.thy / ZFC.thy, and avoid name clash with global HOL/Main.thy;
wenzelm
parents:
61798
diff
changeset
|
8 |
theory Primrec imports ZF begin |
12560 | 9 |
|
60770 | 10 |
text \<open> |
76987 | 11 |
Proof adopted from \<^cite>\<open>szasz93\<close>. |
12610 | 12 |
|
76987 | 13 |
See also \<^cite>\<open>\<open>page 250, exercise 11\<close> in mendelson\<close>. |
60770 | 14 |
\<close> |
12610 | 15 |
|
16 |
||
60770 | 17 |
subsection \<open>Basic definitions\<close> |
12610 | 18 |
|
24893 | 19 |
definition |
20 |
SC :: "i" where |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
21 |
"SC \<equiv> \<lambda>l \<in> list(nat). list_case(0, \<lambda>x xs. succ(x), l)" |
12560 | 22 |
|
24893 | 23 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
24 |
CONSTANT :: "i\<Rightarrow>i" where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
25 |
"CONSTANT(k) \<equiv> \<lambda>l \<in> list(nat). k" |
12560 | 26 |
|
24893 | 27 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
28 |
PROJ :: "i\<Rightarrow>i" where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
29 |
"PROJ(i) \<equiv> \<lambda>l \<in> list(nat). list_case(0, \<lambda>x xs. x, drop(i,l))" |
12560 | 30 |
|
24893 | 31 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
32 |
COMP :: "[i,i]\<Rightarrow>i" where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
33 |
"COMP(g,fs) \<equiv> \<lambda>l \<in> list(nat). g ` map(\<lambda>f. f`l, fs)" |
12610 | 34 |
|
24893 | 35 |
definition |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
36 |
PREC :: "[i,i]\<Rightarrow>i" where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
37 |
"PREC(f,g) \<equiv> |
12610 | 38 |
\<lambda>l \<in> list(nat). list_case(0, |
39 |
\<lambda>x xs. rec(x, f`xs, \<lambda>y r. g ` Cons(r, Cons(y, xs))), l)" |
|
69593 | 40 |
\<comment> \<open>Note that \<open>g\<close> is applied first to \<^term>\<open>PREC(f,g)`y\<close> and then to \<open>y\<close>!\<close> |
12560 | 41 |
|
12088 | 42 |
consts |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
43 |
ACK :: "i\<Rightarrow>i" |
12560 | 44 |
primrec |
12610 | 45 |
"ACK(0) = SC" |
19676 | 46 |
"ACK(succ(i)) = PREC (CONSTANT (ACK(i) ` [1]), COMP(ACK(i), [PROJ(0)]))" |
12560 | 47 |
|
24892 | 48 |
abbreviation |
76215
a642599ffdea
More syntactic cleanup. LaTeX markup working
paulson <lp15@cam.ac.uk>
parents:
76213
diff
changeset
|
49 |
ack :: "[i,i]\<Rightarrow>i" where |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
50 |
"ack(x,y) \<equiv> ACK(x) ` [y]" |
12560 | 51 |
|
52 |
||
60770 | 53 |
text \<open> |
12610 | 54 |
\medskip Useful special cases of evaluation. |
60770 | 55 |
\<close> |
12560 | 56 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
57 |
lemma SC: "\<lbrakk>x \<in> nat; l \<in> list(nat)\<rbrakk> \<Longrightarrow> SC ` (Cons(x,l)) = succ(x)" |
12610 | 58 |
by (simp add: SC_def) |
12560 | 59 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
60 |
lemma CONSTANT: "l \<in> list(nat) \<Longrightarrow> CONSTANT(k) ` l = k" |
19676 | 61 |
by (simp add: CONSTANT_def) |
12560 | 62 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
63 |
lemma PROJ_0: "\<lbrakk>x \<in> nat; l \<in> list(nat)\<rbrakk> \<Longrightarrow> PROJ(0) ` (Cons(x,l)) = x" |
12610 | 64 |
by (simp add: PROJ_def) |
12560 | 65 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
66 |
lemma COMP_1: "l \<in> list(nat) \<Longrightarrow> COMP(g,[f]) ` l = g` [f`l]" |
12610 | 67 |
by (simp add: COMP_def) |
12560 | 68 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
69 |
lemma PREC_0: "l \<in> list(nat) \<Longrightarrow> PREC(f,g) ` (Cons(0,l)) = f`l" |
12610 | 70 |
by (simp add: PREC_def) |
12560 | 71 |
|
12610 | 72 |
lemma PREC_succ: |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
73 |
"\<lbrakk>x \<in> nat; l \<in> list(nat)\<rbrakk> |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
74 |
\<Longrightarrow> PREC(f,g) ` (Cons(succ(x),l)) = |
12610 | 75 |
g ` Cons(PREC(f,g)`(Cons(x,l)), Cons(x,l))" |
76 |
by (simp add: PREC_def) |
|
12560 | 77 |
|
78 |
||
60770 | 79 |
subsection \<open>Inductive definition of the PR functions\<close> |
12610 | 80 |
|
12560 | 81 |
consts |
12610 | 82 |
prim_rec :: i |
12088 | 83 |
|
84 |
inductive |
|
12610 | 85 |
domains prim_rec \<subseteq> "list(nat)->nat" |
12560 | 86 |
intros |
87 |
"SC \<in> prim_rec" |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
88 |
"k \<in> nat \<Longrightarrow> CONSTANT(k) \<in> prim_rec" |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
89 |
"i \<in> nat \<Longrightarrow> PROJ(i) \<in> prim_rec" |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
90 |
"\<lbrakk>g \<in> prim_rec; fs\<in>list(prim_rec)\<rbrakk> \<Longrightarrow> COMP(g,fs) \<in> prim_rec" |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
91 |
"\<lbrakk>f \<in> prim_rec; g \<in> prim_rec\<rbrakk> \<Longrightarrow> PREC(f,g) \<in> prim_rec" |
12610 | 92 |
monos list_mono |
19676 | 93 |
con_defs SC_def CONSTANT_def PROJ_def COMP_def PREC_def |
12610 | 94 |
type_intros nat_typechecks list.intros |
26059 | 95 |
lam_type list_case_type drop_type map_type |
12610 | 96 |
apply_type rec_type |
12560 | 97 |
|
98 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
99 |
lemma prim_rec_into_fun [TC]: "c \<in> prim_rec \<Longrightarrow> c \<in> list(nat) -> nat" |
12610 | 100 |
by (erule subsetD [OF prim_rec.dom_subset]) |
12560 | 101 |
|
102 |
lemmas [TC] = apply_type [OF prim_rec_into_fun] |
|
103 |
||
104 |
declare prim_rec.intros [TC] |
|
105 |
declare nat_into_Ord [TC] |
|
106 |
declare rec_type [TC] |
|
107 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
108 |
lemma ACK_in_prim_rec [TC]: "i \<in> nat \<Longrightarrow> ACK(i) \<in> prim_rec" |
18415 | 109 |
by (induct set: nat) simp_all |
12560 | 110 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
111 |
lemma ack_type [TC]: "\<lbrakk>i \<in> nat; j \<in> nat\<rbrakk> \<Longrightarrow> ack(i,j) \<in> nat" |
12610 | 112 |
by auto |
12560 | 113 |
|
12610 | 114 |
|
60770 | 115 |
subsection \<open>Ackermann's function cases\<close> |
12560 | 116 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
117 |
lemma ack_0: "j \<in> nat \<Longrightarrow> ack(0,j) = succ(j)" |
61798 | 118 |
\<comment> \<open>PROPERTY A 1\<close> |
12610 | 119 |
by (simp add: SC) |
120 |
||
12560 | 121 |
lemma ack_succ_0: "ack(succ(i), 0) = ack(i,1)" |
61798 | 122 |
\<comment> \<open>PROPERTY A 2\<close> |
19676 | 123 |
by (simp add: CONSTANT PREC_0) |
12560 | 124 |
|
125 |
lemma ack_succ_succ: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
126 |
"\<lbrakk>i\<in>nat; j\<in>nat\<rbrakk> \<Longrightarrow> ack(succ(i), succ(j)) = ack(i, ack(succ(i), j))" |
61798 | 127 |
\<comment> \<open>PROPERTY A 3\<close> |
19676 | 128 |
by (simp add: CONSTANT PREC_succ COMP_1 PROJ_0) |
12560 | 129 |
|
12610 | 130 |
lemmas [simp] = ack_0 ack_succ_0 ack_succ_succ ack_type |
131 |
and [simp del] = ACK.simps |
|
12560 | 132 |
|
133 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
134 |
lemma lt_ack2: "i \<in> nat \<Longrightarrow> j \<in> nat \<Longrightarrow> j < ack(i,j)" |
61798 | 135 |
\<comment> \<open>PROPERTY A 4\<close> |
20503 | 136 |
apply (induct i arbitrary: j set: nat) |
12610 | 137 |
apply simp |
138 |
apply (induct_tac j) |
|
139 |
apply (erule_tac [2] succ_leI [THEN lt_trans1]) |
|
140 |
apply (rule nat_0I [THEN nat_0_le, THEN lt_trans]) |
|
141 |
apply auto |
|
142 |
done |
|
12560 | 143 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
144 |
lemma ack_lt_ack_succ2: "\<lbrakk>i\<in>nat; j\<in>nat\<rbrakk> \<Longrightarrow> ack(i,j) < ack(i, succ(j))" |
61798 | 145 |
\<comment> \<open>PROPERTY A 5-, the single-step lemma\<close> |
18415 | 146 |
by (induct set: nat) (simp_all add: lt_ack2) |
12560 | 147 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
148 |
lemma ack_lt_mono2: "\<lbrakk>j<k; i \<in> nat; k \<in> nat\<rbrakk> \<Longrightarrow> ack(i,j) < ack(i,k)" |
61798 | 149 |
\<comment> \<open>PROPERTY A 5, monotonicity for \<open><\<close>\<close> |
12610 | 150 |
apply (frule lt_nat_in_nat, assumption) |
151 |
apply (erule succ_lt_induct) |
|
152 |
apply assumption |
|
153 |
apply (rule_tac [2] lt_trans) |
|
154 |
apply (auto intro: ack_lt_ack_succ2) |
|
155 |
done |
|
12560 | 156 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
157 |
lemma ack_le_mono2: "\<lbrakk>j\<le>k; i\<in>nat; k\<in>nat\<rbrakk> \<Longrightarrow> ack(i,j) \<le> ack(i,k)" |
61798 | 158 |
\<comment> \<open>PROPERTY A 5', monotonicity for \<open>\<le>\<close>\<close> |
12610 | 159 |
apply (rule_tac f = "\<lambda>j. ack (i,j) " in Ord_lt_mono_imp_le_mono) |
160 |
apply (assumption | rule ack_lt_mono2 ack_type [THEN nat_into_Ord])+ |
|
161 |
done |
|
12560 | 162 |
|
163 |
lemma ack2_le_ack1: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
164 |
"\<lbrakk>i\<in>nat; j\<in>nat\<rbrakk> \<Longrightarrow> ack(i, succ(j)) \<le> ack(succ(i), j)" |
61798 | 165 |
\<comment> \<open>PROPERTY A 6\<close> |
12610 | 166 |
apply (induct_tac j) |
167 |
apply simp_all |
|
168 |
apply (rule ack_le_mono2) |
|
169 |
apply (rule lt_ack2 [THEN succ_leI, THEN le_trans]) |
|
170 |
apply auto |
|
171 |
done |
|
12560 | 172 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
173 |
lemma ack_lt_ack_succ1: "\<lbrakk>i \<in> nat; j \<in> nat\<rbrakk> \<Longrightarrow> ack(i,j) < ack(succ(i),j)" |
61798 | 174 |
\<comment> \<open>PROPERTY A 7-, the single-step lemma\<close> |
12610 | 175 |
apply (rule ack_lt_mono2 [THEN lt_trans2]) |
176 |
apply (rule_tac [4] ack2_le_ack1) |
|
177 |
apply auto |
|
178 |
done |
|
12560 | 179 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
180 |
lemma ack_lt_mono1: "\<lbrakk>i<j; j \<in> nat; k \<in> nat\<rbrakk> \<Longrightarrow> ack(i,k) < ack(j,k)" |
61798 | 181 |
\<comment> \<open>PROPERTY A 7, monotonicity for \<open><\<close>\<close> |
12610 | 182 |
apply (frule lt_nat_in_nat, assumption) |
183 |
apply (erule succ_lt_induct) |
|
184 |
apply assumption |
|
185 |
apply (rule_tac [2] lt_trans) |
|
186 |
apply (auto intro: ack_lt_ack_succ1) |
|
187 |
done |
|
12560 | 188 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
189 |
lemma ack_le_mono1: "\<lbrakk>i\<le>j; j \<in> nat; k \<in> nat\<rbrakk> \<Longrightarrow> ack(i,k) \<le> ack(j,k)" |
61798 | 190 |
\<comment> \<open>PROPERTY A 7', monotonicity for \<open>\<le>\<close>\<close> |
12610 | 191 |
apply (rule_tac f = "\<lambda>j. ack (j,k) " in Ord_lt_mono_imp_le_mono) |
192 |
apply (assumption | rule ack_lt_mono1 ack_type [THEN nat_into_Ord])+ |
|
193 |
done |
|
12560 | 194 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
195 |
lemma ack_1: "j \<in> nat \<Longrightarrow> ack(1,j) = succ(succ(j))" |
61798 | 196 |
\<comment> \<open>PROPERTY A 8\<close> |
18415 | 197 |
by (induct set: nat) simp_all |
12560 | 198 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
199 |
lemma ack_2: "j \<in> nat \<Longrightarrow> ack(succ(1),j) = succ(succ(succ(j#+j)))" |
61798 | 200 |
\<comment> \<open>PROPERTY A 9\<close> |
18415 | 201 |
by (induct set: nat) (simp_all add: ack_1) |
12560 | 202 |
|
203 |
lemma ack_nest_bound: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
204 |
"\<lbrakk>i1 \<in> nat; i2 \<in> nat; j \<in> nat\<rbrakk> |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
205 |
\<Longrightarrow> ack(i1, ack(i2,j)) < ack(succ(succ(i1#+i2)), j)" |
61798 | 206 |
\<comment> \<open>PROPERTY A 10\<close> |
12610 | 207 |
apply (rule lt_trans2 [OF _ ack2_le_ack1]) |
208 |
apply simp |
|
209 |
apply (rule add_le_self [THEN ack_le_mono1, THEN lt_trans1]) |
|
210 |
apply auto |
|
211 |
apply (force intro: add_le_self2 [THEN ack_lt_mono1, THEN ack_lt_mono2]) |
|
212 |
done |
|
12560 | 213 |
|
214 |
lemma ack_add_bound: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
215 |
"\<lbrakk>i1 \<in> nat; i2 \<in> nat; j \<in> nat\<rbrakk> |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
216 |
\<Longrightarrow> ack(i1,j) #+ ack(i2,j) < ack(succ(succ(succ(succ(i1#+i2)))), j)" |
61798 | 217 |
\<comment> \<open>PROPERTY A 11\<close> |
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12610
diff
changeset
|
218 |
apply (rule_tac j = "ack (succ (1), ack (i1 #+ i2, j))" in lt_trans) |
12610 | 219 |
apply (simp add: ack_2) |
220 |
apply (rule_tac [2] ack_nest_bound [THEN lt_trans2]) |
|
221 |
apply (rule add_le_mono [THEN leI, THEN leI]) |
|
222 |
apply (auto intro: add_le_self add_le_self2 ack_le_mono1) |
|
223 |
done |
|
12560 | 224 |
|
225 |
lemma ack_add_bound2: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
226 |
"\<lbrakk>i < ack(k,j); j \<in> nat; k \<in> nat\<rbrakk> |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
227 |
\<Longrightarrow> i#+j < ack(succ(succ(succ(succ(k)))), j)" |
61798 | 228 |
\<comment> \<open>PROPERTY A 12.\<close> |
69593 | 229 |
\<comment> \<open>Article uses existential quantifier but the ALF proof used \<^term>\<open>k#+#4\<close>.\<close> |
61798 | 230 |
\<comment> \<open>Quantified version must be nested \<open>\<exists>k'. \<forall>i,j \<dots>\<close>.\<close> |
12610 | 231 |
apply (rule_tac j = "ack (k,j) #+ ack (0,j) " in lt_trans) |
232 |
apply (rule_tac [2] ack_add_bound [THEN lt_trans2]) |
|
233 |
apply (rule add_lt_mono) |
|
234 |
apply auto |
|
235 |
done |
|
12560 | 236 |
|
12610 | 237 |
|
60770 | 238 |
subsection \<open>Main result\<close> |
12560 | 239 |
|
240 |
declare list_add_type [simp] |
|
241 |
||
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
242 |
lemma SC_case: "l \<in> list(nat) \<Longrightarrow> SC ` l < ack(1, list_add(l))" |
76216
9fc34f76b4e8
getting rid of apply (unfold ...)
paulson <lp15@cam.ac.uk>
parents:
76215
diff
changeset
|
243 |
unfolding SC_def |
12610 | 244 |
apply (erule list.cases) |
245 |
apply (simp add: succ_iff) |
|
246 |
apply (simp add: ack_1 add_le_self) |
|
247 |
done |
|
12560 | 248 |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
249 |
lemma lt_ack1: "\<lbrakk>i \<in> nat; j \<in> nat\<rbrakk> \<Longrightarrow> i < ack(i,j)" |
61798 | 250 |
\<comment> \<open>PROPERTY A 4'? Extra lemma needed for \<open>CONSTANT\<close> case, constant functions.\<close> |
12610 | 251 |
apply (induct_tac i) |
252 |
apply (simp add: nat_0_le) |
|
253 |
apply (erule lt_trans1 [OF succ_leI ack_lt_ack_succ1]) |
|
254 |
apply auto |
|
255 |
done |
|
12560 | 256 |
|
19676 | 257 |
lemma CONSTANT_case: |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
258 |
"\<lbrakk>l \<in> list(nat); k \<in> nat\<rbrakk> \<Longrightarrow> CONSTANT(k) ` l < ack(k, list_add(l))" |
19676 | 259 |
by (simp add: CONSTANT_def lt_ack1) |
12560 | 260 |
|
12610 | 261 |
lemma PROJ_case [rule_format]: |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
262 |
"l \<in> list(nat) \<Longrightarrow> \<forall>i \<in> nat. PROJ(i) ` l < ack(0, list_add(l))" |
76216
9fc34f76b4e8
getting rid of apply (unfold ...)
paulson <lp15@cam.ac.uk>
parents:
76215
diff
changeset
|
263 |
unfolding PROJ_def |
12610 | 264 |
apply simp |
265 |
apply (erule list.induct) |
|
266 |
apply (simp add: nat_0_le) |
|
267 |
apply simp |
|
268 |
apply (rule ballI) |
|
13339
0f89104dd377
Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents:
12610
diff
changeset
|
269 |
apply (erule_tac n = i in natE) |
12610 | 270 |
apply (simp add: add_le_self) |
271 |
apply simp |
|
272 |
apply (erule bspec [THEN lt_trans2]) |
|
273 |
apply (rule_tac [2] add_le_self2 [THEN succ_leI]) |
|
274 |
apply auto |
|
275 |
done |
|
12560 | 276 |
|
60770 | 277 |
text \<open> |
61798 | 278 |
\medskip \<open>COMP\<close> case. |
60770 | 279 |
\<close> |
12560 | 280 |
|
281 |
lemma COMP_map_lemma: |
|
12610 | 282 |
"fs \<in> list({f \<in> prim_rec. \<exists>kf \<in> nat. \<forall>l \<in> list(nat). f`l < ack(kf, list_add(l))}) |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
283 |
\<Longrightarrow> \<exists>k \<in> nat. \<forall>l \<in> list(nat). |
12610 | 284 |
list_add(map(\<lambda>f. f ` l, fs)) < ack(k, list_add(l))" |
18415 | 285 |
apply (induct set: list) |
12610 | 286 |
apply (rule_tac x = 0 in bexI) |
287 |
apply (simp_all add: lt_ack1 nat_0_le) |
|
288 |
apply clarify |
|
289 |
apply (rule ballI [THEN bexI]) |
|
290 |
apply (rule add_lt_mono [THEN lt_trans]) |
|
291 |
apply (rule_tac [5] ack_add_bound) |
|
292 |
apply blast |
|
293 |
apply auto |
|
294 |
done |
|
12560 | 295 |
|
12610 | 296 |
lemma COMP_case: |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
297 |
"\<lbrakk>kg\<in>nat; |
12610 | 298 |
\<forall>l \<in> list(nat). g`l < ack(kg, list_add(l)); |
299 |
fs \<in> list({f \<in> prim_rec . |
|
300 |
\<exists>kf \<in> nat. \<forall>l \<in> list(nat). |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
301 |
f`l < ack(kf, list_add(l))})\<rbrakk> |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
302 |
\<Longrightarrow> \<exists>k \<in> nat. \<forall>l \<in> list(nat). COMP(g,fs)`l < ack(k, list_add(l))" |
12610 | 303 |
apply (simp add: COMP_def) |
304 |
apply (frule list_CollectD) |
|
305 |
apply (erule COMP_map_lemma [THEN bexE]) |
|
306 |
apply (rule ballI [THEN bexI]) |
|
307 |
apply (erule bspec [THEN lt_trans]) |
|
308 |
apply (rule_tac [2] lt_trans) |
|
309 |
apply (rule_tac [3] ack_nest_bound) |
|
310 |
apply (erule_tac [2] bspec [THEN ack_lt_mono2]) |
|
311 |
apply auto |
|
312 |
done |
|
12560 | 313 |
|
60770 | 314 |
text \<open> |
61798 | 315 |
\medskip \<open>PREC\<close> case. |
60770 | 316 |
\<close> |
12560 | 317 |
|
12610 | 318 |
lemma PREC_case_lemma: |
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
319 |
"\<lbrakk>\<forall>l \<in> list(nat). f`l #+ list_add(l) < ack(kf, list_add(l)); |
12610 | 320 |
\<forall>l \<in> list(nat). g`l #+ list_add(l) < ack(kg, list_add(l)); |
321 |
f \<in> prim_rec; kf\<in>nat; |
|
322 |
g \<in> prim_rec; kg\<in>nat; |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
323 |
l \<in> list(nat)\<rbrakk> |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
324 |
\<Longrightarrow> PREC(f,g)`l #+ list_add(l) < ack(succ(kf#+kg), list_add(l))" |
76216
9fc34f76b4e8
getting rid of apply (unfold ...)
paulson <lp15@cam.ac.uk>
parents:
76215
diff
changeset
|
325 |
unfolding PREC_def |
12610 | 326 |
apply (erule list.cases) |
327 |
apply (simp add: lt_trans [OF nat_le_refl lt_ack2]) |
|
328 |
apply simp |
|
61798 | 329 |
apply (erule ssubst) \<comment> \<open>get rid of the needless assumption\<close> |
12610 | 330 |
apply (induct_tac a) |
331 |
apply simp_all |
|
60770 | 332 |
txt \<open>base case\<close> |
12610 | 333 |
apply (rule lt_trans, erule bspec, assumption) |
334 |
apply (simp add: add_le_self [THEN ack_lt_mono1]) |
|
60770 | 335 |
txt \<open>ind step\<close> |
12610 | 336 |
apply (rule succ_leI [THEN lt_trans1]) |
59788 | 337 |
apply (rule_tac j = "g ` ll #+ mm" for ll mm in lt_trans1) |
12610 | 338 |
apply (erule_tac [2] bspec) |
339 |
apply (rule nat_le_refl [THEN add_le_mono]) |
|
340 |
apply typecheck |
|
341 |
apply (simp add: add_le_self2) |
|
60770 | 342 |
txt \<open>final part of the simplification\<close> |
12610 | 343 |
apply simp |
344 |
apply (rule add_le_self2 [THEN ack_le_mono1, THEN lt_trans1]) |
|
345 |
apply (erule_tac [4] ack_lt_mono2) |
|
346 |
apply auto |
|
347 |
done |
|
12560 | 348 |
|
349 |
lemma PREC_case: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
350 |
"\<lbrakk>f \<in> prim_rec; kf\<in>nat; |
12610 | 351 |
g \<in> prim_rec; kg\<in>nat; |
352 |
\<forall>l \<in> list(nat). f`l < ack(kf, list_add(l)); |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
353 |
\<forall>l \<in> list(nat). g`l < ack(kg, list_add(l))\<rbrakk> |
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
354 |
\<Longrightarrow> \<exists>k \<in> nat. \<forall>l \<in> list(nat). PREC(f,g)`l< ack(k, list_add(l))" |
12610 | 355 |
apply (rule ballI [THEN bexI]) |
356 |
apply (rule lt_trans1 [OF add_le_self PREC_case_lemma]) |
|
357 |
apply typecheck |
|
358 |
apply (blast intro: ack_add_bound2 list_add_type)+ |
|
359 |
done |
|
12560 | 360 |
|
361 |
lemma ack_bounds_prim_rec: |
|
76213
e44d86131648
Removal of obsolete ASCII syntax
paulson <lp15@cam.ac.uk>
parents:
69593
diff
changeset
|
362 |
"f \<in> prim_rec \<Longrightarrow> \<exists>k \<in> nat. \<forall>l \<in> list(nat). f`l < ack(k, list_add(l))" |
18415 | 363 |
apply (induct set: prim_rec) |
19676 | 364 |
apply (auto intro: SC_case CONSTANT_case PROJ_case COMP_case PREC_case) |
12610 | 365 |
done |
12560 | 366 |
|
12610 | 367 |
theorem ack_not_prim_rec: |
368 |
"(\<lambda>l \<in> list(nat). list_case(0, \<lambda>x xs. ack(x,x), l)) \<notin> prim_rec" |
|
369 |
apply (rule notI) |
|
370 |
apply (drule ack_bounds_prim_rec) |
|
371 |
apply force |
|
372 |
done |
|
12088 | 373 |
|
374 |
end |