paulson@13505
|
1 |
(* Title: ZF/Constructible/Datatype_absolute.thy
|
paulson@13505
|
2 |
ID: $Id$
|
paulson@13505
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
paulson@13505
|
4 |
Copyright 2002 University of Cambridge
|
paulson@13505
|
5 |
*)
|
paulson@13505
|
6 |
|
paulson@13306
|
7 |
header {*Absoluteness Properties for Recursive Datatypes*}
|
paulson@13306
|
8 |
|
paulson@13269
|
9 |
theory Datatype_absolute = Formula + WF_absolute:
|
paulson@13268
|
10 |
|
paulson@13268
|
11 |
|
paulson@13268
|
12 |
subsection{*The lfp of a continuous function can be expressed as a union*}
|
paulson@13268
|
13 |
|
paulson@13268
|
14 |
constdefs
|
paulson@13385
|
15 |
directed :: "i=>o"
|
paulson@13385
|
16 |
"directed(A) == A\<noteq>0 & (\<forall>x\<in>A. \<forall>y\<in>A. x \<union> y \<in> A)"
|
paulson@13385
|
17 |
|
paulson@13385
|
18 |
contin :: "(i=>i) => o"
|
paulson@13385
|
19 |
"contin(h) == (\<forall>A. directed(A) --> h(\<Union>A) = (\<Union>X\<in>A. h(X)))"
|
paulson@13268
|
20 |
|
paulson@13268
|
21 |
lemma bnd_mono_iterates_subset: "[|bnd_mono(D, h); n \<in> nat|] ==> h^n (0) <= D"
|
paulson@13268
|
22 |
apply (induct_tac n)
|
paulson@13268
|
23 |
apply (simp_all add: bnd_mono_def, blast)
|
paulson@13268
|
24 |
done
|
paulson@13268
|
25 |
|
paulson@13385
|
26 |
lemma bnd_mono_increasing [rule_format]:
|
paulson@13385
|
27 |
"[|i \<in> nat; j \<in> nat; bnd_mono(D,h)|] ==> i \<le> j --> h^i(0) \<subseteq> h^j(0)"
|
paulson@13385
|
28 |
apply (rule_tac m=i and n=j in diff_induct, simp_all)
|
paulson@13385
|
29 |
apply (blast del: subsetI
|
paulson@13398
|
30 |
intro: bnd_mono_iterates_subset bnd_monoD2 [of concl: h])
|
paulson@13385
|
31 |
done
|
paulson@13385
|
32 |
|
paulson@13385
|
33 |
lemma directed_iterates: "bnd_mono(D,h) ==> directed({h^n (0). n\<in>nat})"
|
paulson@13385
|
34 |
apply (simp add: directed_def, clarify)
|
paulson@13385
|
35 |
apply (rename_tac i j)
|
paulson@13385
|
36 |
apply (rule_tac x="i \<union> j" in bexI)
|
paulson@13385
|
37 |
apply (rule_tac i = i and j = j in Ord_linear_le)
|
paulson@13385
|
38 |
apply (simp_all add: subset_Un_iff [THEN iffD1] le_imp_subset
|
paulson@13385
|
39 |
subset_Un_iff2 [THEN iffD1])
|
paulson@13385
|
40 |
apply (simp_all add: subset_Un_iff [THEN iff_sym] bnd_mono_increasing
|
paulson@13385
|
41 |
subset_Un_iff2 [THEN iff_sym])
|
paulson@13385
|
42 |
done
|
paulson@13385
|
43 |
|
paulson@13268
|
44 |
|
paulson@13268
|
45 |
lemma contin_iterates_eq:
|
paulson@13385
|
46 |
"[|bnd_mono(D, h); contin(h)|]
|
paulson@13385
|
47 |
==> h(\<Union>n\<in>nat. h^n (0)) = (\<Union>n\<in>nat. h^n (0))"
|
paulson@13385
|
48 |
apply (simp add: contin_def directed_iterates)
|
paulson@13268
|
49 |
apply (rule trans)
|
paulson@13268
|
50 |
apply (rule equalityI)
|
paulson@13385
|
51 |
apply (simp_all add: UN_subset_iff)
|
paulson@13268
|
52 |
apply safe
|
paulson@13268
|
53 |
apply (erule_tac [2] natE)
|
paulson@13268
|
54 |
apply (rule_tac a="succ(x)" in UN_I)
|
paulson@13268
|
55 |
apply simp_all
|
paulson@13268
|
56 |
apply blast
|
paulson@13268
|
57 |
done
|
paulson@13268
|
58 |
|
paulson@13268
|
59 |
lemma lfp_subset_Union:
|
paulson@13268
|
60 |
"[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) <= (\<Union>n\<in>nat. h^n(0))"
|
paulson@13268
|
61 |
apply (rule lfp_lowerbound)
|
paulson@13268
|
62 |
apply (simp add: contin_iterates_eq)
|
paulson@13268
|
63 |
apply (simp add: contin_def bnd_mono_iterates_subset UN_subset_iff)
|
paulson@13268
|
64 |
done
|
paulson@13268
|
65 |
|
paulson@13268
|
66 |
lemma Union_subset_lfp:
|
paulson@13268
|
67 |
"bnd_mono(D,h) ==> (\<Union>n\<in>nat. h^n(0)) <= lfp(D,h)"
|
paulson@13268
|
68 |
apply (simp add: UN_subset_iff)
|
paulson@13268
|
69 |
apply (rule ballI)
|
paulson@13339
|
70 |
apply (induct_tac n, simp_all)
|
paulson@13268
|
71 |
apply (rule subset_trans [of _ "h(lfp(D,h))"])
|
paulson@13398
|
72 |
apply (blast dest: bnd_monoD2 [OF _ _ lfp_subset])
|
paulson@13268
|
73 |
apply (erule lfp_lemma2)
|
paulson@13268
|
74 |
done
|
paulson@13268
|
75 |
|
paulson@13268
|
76 |
lemma lfp_eq_Union:
|
paulson@13268
|
77 |
"[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) = (\<Union>n\<in>nat. h^n(0))"
|
paulson@13268
|
78 |
by (blast del: subsetI
|
paulson@13268
|
79 |
intro: lfp_subset_Union Union_subset_lfp)
|
paulson@13268
|
80 |
|
paulson@13268
|
81 |
|
paulson@13385
|
82 |
subsubsection{*Some Standard Datatype Constructions Preserve Continuity*}
|
paulson@13385
|
83 |
|
paulson@13385
|
84 |
lemma contin_imp_mono: "[|X\<subseteq>Y; contin(F)|] ==> F(X) \<subseteq> F(Y)"
|
paulson@13385
|
85 |
apply (simp add: contin_def)
|
paulson@13385
|
86 |
apply (drule_tac x="{X,Y}" in spec)
|
paulson@13385
|
87 |
apply (simp add: directed_def subset_Un_iff2 Un_commute)
|
paulson@13385
|
88 |
done
|
paulson@13385
|
89 |
|
paulson@13385
|
90 |
lemma sum_contin: "[|contin(F); contin(G)|] ==> contin(\<lambda>X. F(X) + G(X))"
|
paulson@13385
|
91 |
by (simp add: contin_def, blast)
|
paulson@13385
|
92 |
|
paulson@13385
|
93 |
lemma prod_contin: "[|contin(F); contin(G)|] ==> contin(\<lambda>X. F(X) * G(X))"
|
paulson@13385
|
94 |
apply (subgoal_tac "\<forall>B C. F(B) \<subseteq> F(B \<union> C)")
|
paulson@13385
|
95 |
prefer 2 apply (simp add: Un_upper1 contin_imp_mono)
|
paulson@13385
|
96 |
apply (subgoal_tac "\<forall>B C. G(C) \<subseteq> G(B \<union> C)")
|
paulson@13385
|
97 |
prefer 2 apply (simp add: Un_upper2 contin_imp_mono)
|
paulson@13385
|
98 |
apply (simp add: contin_def, clarify)
|
paulson@13385
|
99 |
apply (rule equalityI)
|
paulson@13385
|
100 |
prefer 2 apply blast
|
paulson@13385
|
101 |
apply clarify
|
paulson@13385
|
102 |
apply (rename_tac B C)
|
paulson@13385
|
103 |
apply (rule_tac a="B \<union> C" in UN_I)
|
paulson@13385
|
104 |
apply (simp add: directed_def, blast)
|
paulson@13385
|
105 |
done
|
paulson@13385
|
106 |
|
paulson@13385
|
107 |
lemma const_contin: "contin(\<lambda>X. A)"
|
paulson@13385
|
108 |
by (simp add: contin_def directed_def)
|
paulson@13385
|
109 |
|
paulson@13385
|
110 |
lemma id_contin: "contin(\<lambda>X. X)"
|
paulson@13385
|
111 |
by (simp add: contin_def)
|
paulson@13385
|
112 |
|
paulson@13385
|
113 |
|
paulson@13385
|
114 |
|
paulson@13268
|
115 |
subsection {*Absoluteness for "Iterates"*}
|
paulson@13268
|
116 |
|
paulson@13353
|
117 |
constdefs
|
paulson@13353
|
118 |
|
paulson@13353
|
119 |
iterates_MH :: "[i=>o, [i,i]=>o, i, i, i, i] => o"
|
paulson@13353
|
120 |
"iterates_MH(M,isF,v,n,g,z) ==
|
paulson@13353
|
121 |
is_nat_case(M, v, \<lambda>m u. \<exists>gm[M]. fun_apply(M,g,m,gm) & isF(gm,u),
|
paulson@13353
|
122 |
n, z)"
|
paulson@13353
|
123 |
|
paulson@13353
|
124 |
iterates_replacement :: "[i=>o, [i,i]=>o, i] => o"
|
paulson@13353
|
125 |
"iterates_replacement(M,isF,v) ==
|
paulson@13363
|
126 |
\<forall>n[M]. n\<in>nat -->
|
paulson@13353
|
127 |
wfrec_replacement(M, iterates_MH(M,isF,v), Memrel(succ(n)))"
|
paulson@13353
|
128 |
|
paulson@13564
|
129 |
lemma (in M_basic) iterates_MH_abs:
|
paulson@13353
|
130 |
"[| relativize1(M,isF,F); M(n); M(g); M(z) |]
|
paulson@13353
|
131 |
==> iterates_MH(M,isF,v,n,g,z) <-> z = nat_case(v, \<lambda>m. F(g`m), n)"
|
paulson@13363
|
132 |
by (simp add: nat_case_abs [of _ "\<lambda>m. F(g ` m)"]
|
paulson@13363
|
133 |
relativize1_def iterates_MH_def)
|
paulson@13353
|
134 |
|
paulson@13564
|
135 |
lemma (in M_basic) iterates_imp_wfrec_replacement:
|
paulson@13353
|
136 |
"[|relativize1(M,isF,F); n \<in> nat; iterates_replacement(M,isF,v)|]
|
paulson@13353
|
137 |
==> wfrec_replacement(M, \<lambda>n f z. z = nat_case(v, \<lambda>m. F(f`m), n),
|
paulson@13353
|
138 |
Memrel(succ(n)))"
|
paulson@13353
|
139 |
by (simp add: iterates_replacement_def iterates_MH_abs)
|
paulson@13353
|
140 |
|
paulson@13353
|
141 |
theorem (in M_trancl) iterates_abs:
|
paulson@13353
|
142 |
"[| iterates_replacement(M,isF,v); relativize1(M,isF,F);
|
paulson@13353
|
143 |
n \<in> nat; M(v); M(z); \<forall>x[M]. M(F(x)) |]
|
paulson@13353
|
144 |
==> is_wfrec(M, iterates_MH(M,isF,v), Memrel(succ(n)), n, z) <->
|
paulson@13353
|
145 |
z = iterates(F,n,v)"
|
paulson@13353
|
146 |
apply (frule iterates_imp_wfrec_replacement, assumption+)
|
paulson@13353
|
147 |
apply (simp add: wf_Memrel trans_Memrel relation_Memrel nat_into_M
|
paulson@13353
|
148 |
relativize2_def iterates_MH_abs
|
paulson@13353
|
149 |
iterates_nat_def recursor_def transrec_def
|
paulson@13353
|
150 |
eclose_sing_Ord_eq nat_into_M
|
paulson@13353
|
151 |
trans_wfrec_abs [of _ _ _ _ "\<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n)"])
|
paulson@13353
|
152 |
done
|
paulson@13353
|
153 |
|
paulson@13268
|
154 |
|
paulson@13268
|
155 |
lemma (in M_wfrank) iterates_closed [intro,simp]:
|
paulson@13353
|
156 |
"[| iterates_replacement(M,isF,v); relativize1(M,isF,F);
|
paulson@13353
|
157 |
n \<in> nat; M(v); \<forall>x[M]. M(F(x)) |]
|
paulson@13268
|
158 |
==> M(iterates(F,n,v))"
|
paulson@13353
|
159 |
apply (frule iterates_imp_wfrec_replacement, assumption+)
|
paulson@13353
|
160 |
apply (simp add: wf_Memrel trans_Memrel relation_Memrel nat_into_M
|
paulson@13353
|
161 |
relativize2_def iterates_MH_abs
|
paulson@13353
|
162 |
iterates_nat_def recursor_def transrec_def
|
paulson@13353
|
163 |
eclose_sing_Ord_eq nat_into_M
|
paulson@13353
|
164 |
trans_wfrec_closed [of _ _ _ "\<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n)"])
|
paulson@13353
|
165 |
done
|
paulson@13268
|
166 |
|
paulson@13268
|
167 |
|
paulson@13386
|
168 |
subsection {*lists without univ*}
|
paulson@13386
|
169 |
|
paulson@13386
|
170 |
lemmas datatype_univs = Inl_in_univ Inr_in_univ
|
paulson@13386
|
171 |
Pair_in_univ nat_into_univ A_into_univ
|
paulson@13386
|
172 |
|
paulson@13386
|
173 |
lemma list_fun_bnd_mono: "bnd_mono(univ(A), \<lambda>X. {0} + A*X)"
|
paulson@13386
|
174 |
apply (rule bnd_monoI)
|
paulson@13386
|
175 |
apply (intro subset_refl zero_subset_univ A_subset_univ
|
paulson@13386
|
176 |
sum_subset_univ Sigma_subset_univ)
|
paulson@13386
|
177 |
apply (rule subset_refl sum_mono Sigma_mono | assumption)+
|
paulson@13386
|
178 |
done
|
paulson@13386
|
179 |
|
paulson@13386
|
180 |
lemma list_fun_contin: "contin(\<lambda>X. {0} + A*X)"
|
paulson@13386
|
181 |
by (intro sum_contin prod_contin id_contin const_contin)
|
paulson@13386
|
182 |
|
paulson@13386
|
183 |
text{*Re-expresses lists using sum and product*}
|
paulson@13386
|
184 |
lemma list_eq_lfp2: "list(A) = lfp(univ(A), \<lambda>X. {0} + A*X)"
|
paulson@13386
|
185 |
apply (simp add: list_def)
|
paulson@13386
|
186 |
apply (rule equalityI)
|
paulson@13386
|
187 |
apply (rule lfp_lowerbound)
|
paulson@13386
|
188 |
prefer 2 apply (rule lfp_subset)
|
paulson@13386
|
189 |
apply (clarify, subst lfp_unfold [OF list_fun_bnd_mono])
|
paulson@13386
|
190 |
apply (simp add: Nil_def Cons_def)
|
paulson@13386
|
191 |
apply blast
|
paulson@13386
|
192 |
txt{*Opposite inclusion*}
|
paulson@13386
|
193 |
apply (rule lfp_lowerbound)
|
paulson@13386
|
194 |
prefer 2 apply (rule lfp_subset)
|
paulson@13386
|
195 |
apply (clarify, subst lfp_unfold [OF list.bnd_mono])
|
paulson@13386
|
196 |
apply (simp add: Nil_def Cons_def)
|
paulson@13386
|
197 |
apply (blast intro: datatype_univs
|
paulson@13386
|
198 |
dest: lfp_subset [THEN subsetD])
|
paulson@13386
|
199 |
done
|
paulson@13386
|
200 |
|
paulson@13386
|
201 |
text{*Re-expresses lists using "iterates", no univ.*}
|
paulson@13386
|
202 |
lemma list_eq_Union:
|
paulson@13386
|
203 |
"list(A) = (\<Union>n\<in>nat. (\<lambda>X. {0} + A*X) ^ n (0))"
|
paulson@13386
|
204 |
by (simp add: list_eq_lfp2 lfp_eq_Union list_fun_bnd_mono list_fun_contin)
|
paulson@13386
|
205 |
|
paulson@13386
|
206 |
|
paulson@13350
|
207 |
constdefs
|
paulson@13350
|
208 |
is_list_functor :: "[i=>o,i,i,i] => o"
|
paulson@13350
|
209 |
"is_list_functor(M,A,X,Z) ==
|
paulson@13350
|
210 |
\<exists>n1[M]. \<exists>AX[M].
|
paulson@13350
|
211 |
number1(M,n1) & cartprod(M,A,X,AX) & is_sum(M,n1,AX,Z)"
|
paulson@13350
|
212 |
|
paulson@13564
|
213 |
lemma (in M_basic) list_functor_abs [simp]:
|
paulson@13350
|
214 |
"[| M(A); M(X); M(Z) |] ==> is_list_functor(M,A,X,Z) <-> (Z = {0} + A*X)"
|
paulson@13350
|
215 |
by (simp add: is_list_functor_def singleton_0 nat_into_M)
|
paulson@13350
|
216 |
|
paulson@13350
|
217 |
|
paulson@13386
|
218 |
subsection {*formulas without univ*}
|
paulson@13386
|
219 |
|
paulson@13386
|
220 |
lemma formula_fun_bnd_mono:
|
paulson@13398
|
221 |
"bnd_mono(univ(0), \<lambda>X. ((nat*nat) + (nat*nat)) + (X*X + X))"
|
paulson@13386
|
222 |
apply (rule bnd_monoI)
|
paulson@13386
|
223 |
apply (intro subset_refl zero_subset_univ A_subset_univ
|
paulson@13386
|
224 |
sum_subset_univ Sigma_subset_univ nat_subset_univ)
|
paulson@13386
|
225 |
apply (rule subset_refl sum_mono Sigma_mono | assumption)+
|
paulson@13386
|
226 |
done
|
paulson@13386
|
227 |
|
paulson@13386
|
228 |
lemma formula_fun_contin:
|
paulson@13398
|
229 |
"contin(\<lambda>X. ((nat*nat) + (nat*nat)) + (X*X + X))"
|
paulson@13386
|
230 |
by (intro sum_contin prod_contin id_contin const_contin)
|
paulson@13386
|
231 |
|
paulson@13386
|
232 |
|
paulson@13386
|
233 |
text{*Re-expresses formulas using sum and product*}
|
paulson@13386
|
234 |
lemma formula_eq_lfp2:
|
paulson@13398
|
235 |
"formula = lfp(univ(0), \<lambda>X. ((nat*nat) + (nat*nat)) + (X*X + X))"
|
paulson@13386
|
236 |
apply (simp add: formula_def)
|
paulson@13386
|
237 |
apply (rule equalityI)
|
paulson@13386
|
238 |
apply (rule lfp_lowerbound)
|
paulson@13386
|
239 |
prefer 2 apply (rule lfp_subset)
|
paulson@13386
|
240 |
apply (clarify, subst lfp_unfold [OF formula_fun_bnd_mono])
|
paulson@13398
|
241 |
apply (simp add: Member_def Equal_def Nand_def Forall_def)
|
paulson@13386
|
242 |
apply blast
|
paulson@13386
|
243 |
txt{*Opposite inclusion*}
|
paulson@13386
|
244 |
apply (rule lfp_lowerbound)
|
paulson@13386
|
245 |
prefer 2 apply (rule lfp_subset, clarify)
|
paulson@13386
|
246 |
apply (subst lfp_unfold [OF formula.bnd_mono, simplified])
|
paulson@13398
|
247 |
apply (simp add: Member_def Equal_def Nand_def Forall_def)
|
paulson@13386
|
248 |
apply (elim sumE SigmaE, simp_all)
|
paulson@13386
|
249 |
apply (blast intro: datatype_univs dest: lfp_subset [THEN subsetD])+
|
paulson@13386
|
250 |
done
|
paulson@13386
|
251 |
|
paulson@13386
|
252 |
text{*Re-expresses formulas using "iterates", no univ.*}
|
paulson@13386
|
253 |
lemma formula_eq_Union:
|
paulson@13386
|
254 |
"formula =
|
paulson@13398
|
255 |
(\<Union>n\<in>nat. (\<lambda>X. ((nat*nat) + (nat*nat)) + (X*X + X)) ^ n (0))"
|
paulson@13386
|
256 |
by (simp add: formula_eq_lfp2 lfp_eq_Union formula_fun_bnd_mono
|
paulson@13386
|
257 |
formula_fun_contin)
|
paulson@13386
|
258 |
|
paulson@13386
|
259 |
|
paulson@13386
|
260 |
constdefs
|
paulson@13386
|
261 |
is_formula_functor :: "[i=>o,i,i] => o"
|
paulson@13386
|
262 |
"is_formula_functor(M,X,Z) ==
|
paulson@13398
|
263 |
\<exists>nat'[M]. \<exists>natnat[M]. \<exists>natnatsum[M]. \<exists>XX[M]. \<exists>X3[M].
|
paulson@13386
|
264 |
omega(M,nat') & cartprod(M,nat',nat',natnat) &
|
paulson@13386
|
265 |
is_sum(M,natnat,natnat,natnatsum) &
|
paulson@13398
|
266 |
cartprod(M,X,X,XX) & is_sum(M,XX,X,X3) &
|
paulson@13398
|
267 |
is_sum(M,natnatsum,X3,Z)"
|
paulson@13386
|
268 |
|
paulson@13564
|
269 |
lemma (in M_basic) formula_functor_abs [simp]:
|
paulson@13386
|
270 |
"[| M(X); M(Z) |]
|
paulson@13386
|
271 |
==> is_formula_functor(M,X,Z) <->
|
paulson@13398
|
272 |
Z = ((nat*nat) + (nat*nat)) + (X*X + X)"
|
paulson@13386
|
273 |
by (simp add: is_formula_functor_def)
|
paulson@13386
|
274 |
|
paulson@13386
|
275 |
|
paulson@13386
|
276 |
subsection{*@{term M} Contains the List and Formula Datatypes*}
|
paulson@13395
|
277 |
|
paulson@13395
|
278 |
constdefs
|
paulson@13397
|
279 |
list_N :: "[i,i] => i"
|
paulson@13397
|
280 |
"list_N(A,n) == (\<lambda>X. {0} + A * X)^n (0)"
|
paulson@13397
|
281 |
|
paulson@13397
|
282 |
lemma Nil_in_list_N [simp]: "[] \<in> list_N(A,succ(n))"
|
paulson@13397
|
283 |
by (simp add: list_N_def Nil_def)
|
paulson@13397
|
284 |
|
paulson@13397
|
285 |
lemma Cons_in_list_N [simp]:
|
paulson@13397
|
286 |
"Cons(a,l) \<in> list_N(A,succ(n)) <-> a\<in>A & l \<in> list_N(A,n)"
|
paulson@13397
|
287 |
by (simp add: list_N_def Cons_def)
|
paulson@13397
|
288 |
|
paulson@13397
|
289 |
text{*These two aren't simprules because they reveal the underlying
|
paulson@13397
|
290 |
list representation.*}
|
paulson@13397
|
291 |
lemma list_N_0: "list_N(A,0) = 0"
|
paulson@13397
|
292 |
by (simp add: list_N_def)
|
paulson@13397
|
293 |
|
paulson@13397
|
294 |
lemma list_N_succ: "list_N(A,succ(n)) = {0} + A * (list_N(A,n))"
|
paulson@13397
|
295 |
by (simp add: list_N_def)
|
paulson@13397
|
296 |
|
paulson@13397
|
297 |
lemma list_N_imp_list:
|
paulson@13397
|
298 |
"[| l \<in> list_N(A,n); n \<in> nat |] ==> l \<in> list(A)"
|
paulson@13397
|
299 |
by (force simp add: list_eq_Union list_N_def)
|
paulson@13397
|
300 |
|
paulson@13397
|
301 |
lemma list_N_imp_length_lt [rule_format]:
|
paulson@13397
|
302 |
"n \<in> nat ==> \<forall>l \<in> list_N(A,n). length(l) < n"
|
paulson@13397
|
303 |
apply (induct_tac n)
|
paulson@13397
|
304 |
apply (auto simp add: list_N_0 list_N_succ
|
paulson@13397
|
305 |
Nil_def [symmetric] Cons_def [symmetric])
|
paulson@13397
|
306 |
done
|
paulson@13397
|
307 |
|
paulson@13397
|
308 |
lemma list_imp_list_N [rule_format]:
|
paulson@13397
|
309 |
"l \<in> list(A) ==> \<forall>n\<in>nat. length(l) < n --> l \<in> list_N(A, n)"
|
paulson@13397
|
310 |
apply (induct_tac l)
|
paulson@13397
|
311 |
apply (force elim: natE)+
|
paulson@13397
|
312 |
done
|
paulson@13397
|
313 |
|
paulson@13397
|
314 |
lemma list_N_imp_eq_length:
|
paulson@13397
|
315 |
"[|n \<in> nat; l \<notin> list_N(A, n); l \<in> list_N(A, succ(n))|]
|
paulson@13397
|
316 |
==> n = length(l)"
|
paulson@13397
|
317 |
apply (rule le_anti_sym)
|
paulson@13397
|
318 |
prefer 2 apply (simp add: list_N_imp_length_lt)
|
paulson@13397
|
319 |
apply (frule list_N_imp_list, simp)
|
paulson@13397
|
320 |
apply (simp add: not_lt_iff_le [symmetric])
|
paulson@13397
|
321 |
apply (blast intro: list_imp_list_N)
|
paulson@13397
|
322 |
done
|
paulson@13397
|
323 |
|
paulson@13397
|
324 |
text{*Express @{term list_rec} without using @{term rank} or @{term Vset},
|
paulson@13397
|
325 |
neither of which is absolute.*}
|
paulson@13564
|
326 |
lemma (in M_trivial) list_rec_eq:
|
paulson@13397
|
327 |
"l \<in> list(A) ==>
|
paulson@13397
|
328 |
list_rec(a,g,l) =
|
paulson@13397
|
329 |
transrec (succ(length(l)),
|
paulson@13409
|
330 |
\<lambda>x h. Lambda (list(A),
|
paulson@13409
|
331 |
list_case' (a,
|
paulson@13409
|
332 |
\<lambda>a l. g(a, l, h ` succ(length(l)) ` l)))) ` l"
|
paulson@13397
|
333 |
apply (induct_tac l)
|
paulson@13397
|
334 |
apply (subst transrec, simp)
|
paulson@13397
|
335 |
apply (subst transrec)
|
paulson@13397
|
336 |
apply (simp add: list_imp_list_N)
|
paulson@13397
|
337 |
done
|
paulson@13397
|
338 |
|
paulson@13397
|
339 |
constdefs
|
paulson@13397
|
340 |
is_list_N :: "[i=>o,i,i,i] => o"
|
paulson@13397
|
341 |
"is_list_N(M,A,n,Z) ==
|
paulson@13395
|
342 |
\<exists>zero[M]. \<exists>sn[M]. \<exists>msn[M].
|
paulson@13395
|
343 |
empty(M,zero) &
|
paulson@13395
|
344 |
successor(M,n,sn) & membership(M,sn,msn) &
|
paulson@13395
|
345 |
is_wfrec(M, iterates_MH(M, is_list_functor(M,A),zero), msn, n, Z)"
|
paulson@13395
|
346 |
|
paulson@13395
|
347 |
mem_list :: "[i=>o,i,i] => o"
|
paulson@13395
|
348 |
"mem_list(M,A,l) ==
|
paulson@13395
|
349 |
\<exists>n[M]. \<exists>listn[M].
|
paulson@13397
|
350 |
finite_ordinal(M,n) & is_list_N(M,A,n,listn) & l \<in> listn"
|
paulson@13395
|
351 |
|
paulson@13395
|
352 |
is_list :: "[i=>o,i,i] => o"
|
paulson@13395
|
353 |
"is_list(M,A,Z) == \<forall>l[M]. l \<in> Z <-> mem_list(M,A,l)"
|
paulson@13395
|
354 |
|
paulson@13493
|
355 |
subsubsection{*Towards Absoluteness of @{term formula_rec}*}
|
paulson@13493
|
356 |
|
paulson@13493
|
357 |
consts depth :: "i=>i"
|
paulson@13493
|
358 |
primrec
|
paulson@13493
|
359 |
"depth(Member(x,y)) = 0"
|
paulson@13493
|
360 |
"depth(Equal(x,y)) = 0"
|
paulson@13493
|
361 |
"depth(Nand(p,q)) = succ(depth(p) \<union> depth(q))"
|
paulson@13493
|
362 |
"depth(Forall(p)) = succ(depth(p))"
|
paulson@13493
|
363 |
|
paulson@13493
|
364 |
lemma depth_type [TC]: "p \<in> formula ==> depth(p) \<in> nat"
|
paulson@13493
|
365 |
by (induct_tac p, simp_all)
|
paulson@13493
|
366 |
|
paulson@13493
|
367 |
|
paulson@13395
|
368 |
constdefs
|
paulson@13493
|
369 |
formula_N :: "i => i"
|
paulson@13493
|
370 |
"formula_N(n) == (\<lambda>X. ((nat*nat) + (nat*nat)) + (X*X + X)) ^ n (0)"
|
paulson@13493
|
371 |
|
paulson@13493
|
372 |
lemma Member_in_formula_N [simp]:
|
paulson@13493
|
373 |
"Member(x,y) \<in> formula_N(succ(n)) <-> x \<in> nat & y \<in> nat"
|
paulson@13493
|
374 |
by (simp add: formula_N_def Member_def)
|
paulson@13493
|
375 |
|
paulson@13493
|
376 |
lemma Equal_in_formula_N [simp]:
|
paulson@13493
|
377 |
"Equal(x,y) \<in> formula_N(succ(n)) <-> x \<in> nat & y \<in> nat"
|
paulson@13493
|
378 |
by (simp add: formula_N_def Equal_def)
|
paulson@13493
|
379 |
|
paulson@13493
|
380 |
lemma Nand_in_formula_N [simp]:
|
paulson@13493
|
381 |
"Nand(x,y) \<in> formula_N(succ(n)) <-> x \<in> formula_N(n) & y \<in> formula_N(n)"
|
paulson@13493
|
382 |
by (simp add: formula_N_def Nand_def)
|
paulson@13493
|
383 |
|
paulson@13493
|
384 |
lemma Forall_in_formula_N [simp]:
|
paulson@13493
|
385 |
"Forall(x) \<in> formula_N(succ(n)) <-> x \<in> formula_N(n)"
|
paulson@13493
|
386 |
by (simp add: formula_N_def Forall_def)
|
paulson@13493
|
387 |
|
paulson@13493
|
388 |
text{*These two aren't simprules because they reveal the underlying
|
paulson@13493
|
389 |
formula representation.*}
|
paulson@13493
|
390 |
lemma formula_N_0: "formula_N(0) = 0"
|
paulson@13493
|
391 |
by (simp add: formula_N_def)
|
paulson@13493
|
392 |
|
paulson@13493
|
393 |
lemma formula_N_succ:
|
paulson@13493
|
394 |
"formula_N(succ(n)) =
|
paulson@13493
|
395 |
((nat*nat) + (nat*nat)) + (formula_N(n) * formula_N(n) + formula_N(n))"
|
paulson@13493
|
396 |
by (simp add: formula_N_def)
|
paulson@13493
|
397 |
|
paulson@13493
|
398 |
lemma formula_N_imp_formula:
|
paulson@13493
|
399 |
"[| p \<in> formula_N(n); n \<in> nat |] ==> p \<in> formula"
|
paulson@13493
|
400 |
by (force simp add: formula_eq_Union formula_N_def)
|
paulson@13493
|
401 |
|
paulson@13493
|
402 |
lemma formula_N_imp_depth_lt [rule_format]:
|
paulson@13493
|
403 |
"n \<in> nat ==> \<forall>p \<in> formula_N(n). depth(p) < n"
|
paulson@13493
|
404 |
apply (induct_tac n)
|
paulson@13493
|
405 |
apply (auto simp add: formula_N_0 formula_N_succ
|
paulson@13493
|
406 |
depth_type formula_N_imp_formula Un_least_lt_iff
|
paulson@13493
|
407 |
Member_def [symmetric] Equal_def [symmetric]
|
paulson@13493
|
408 |
Nand_def [symmetric] Forall_def [symmetric])
|
paulson@13493
|
409 |
done
|
paulson@13493
|
410 |
|
paulson@13493
|
411 |
lemma formula_imp_formula_N [rule_format]:
|
paulson@13493
|
412 |
"p \<in> formula ==> \<forall>n\<in>nat. depth(p) < n --> p \<in> formula_N(n)"
|
paulson@13493
|
413 |
apply (induct_tac p)
|
paulson@13493
|
414 |
apply (simp_all add: succ_Un_distrib Un_least_lt_iff)
|
paulson@13493
|
415 |
apply (force elim: natE)+
|
paulson@13493
|
416 |
done
|
paulson@13493
|
417 |
|
paulson@13493
|
418 |
lemma formula_N_imp_eq_depth:
|
paulson@13493
|
419 |
"[|n \<in> nat; p \<notin> formula_N(n); p \<in> formula_N(succ(n))|]
|
paulson@13493
|
420 |
==> n = depth(p)"
|
paulson@13493
|
421 |
apply (rule le_anti_sym)
|
paulson@13493
|
422 |
prefer 2 apply (simp add: formula_N_imp_depth_lt)
|
paulson@13493
|
423 |
apply (frule formula_N_imp_formula, simp)
|
paulson@13493
|
424 |
apply (simp add: not_lt_iff_le [symmetric])
|
paulson@13493
|
425 |
apply (blast intro: formula_imp_formula_N)
|
paulson@13493
|
426 |
done
|
paulson@13493
|
427 |
|
paulson@13493
|
428 |
|
paulson@13493
|
429 |
|
paulson@13493
|
430 |
lemma formula_N_mono [rule_format]:
|
paulson@13493
|
431 |
"[| m \<in> nat; n \<in> nat |] ==> m\<le>n --> formula_N(m) \<subseteq> formula_N(n)"
|
paulson@13493
|
432 |
apply (rule_tac m = m and n = n in diff_induct)
|
paulson@13493
|
433 |
apply (simp_all add: formula_N_0 formula_N_succ, blast)
|
paulson@13493
|
434 |
done
|
paulson@13493
|
435 |
|
paulson@13493
|
436 |
lemma formula_N_distrib:
|
paulson@13493
|
437 |
"[| m \<in> nat; n \<in> nat |] ==> formula_N(m \<union> n) = formula_N(m) \<union> formula_N(n)"
|
paulson@13493
|
438 |
apply (rule_tac i = m and j = n in Ord_linear_le, auto)
|
paulson@13493
|
439 |
apply (simp_all add: subset_Un_iff [THEN iffD1] subset_Un_iff2 [THEN iffD1]
|
paulson@13493
|
440 |
le_imp_subset formula_N_mono)
|
paulson@13493
|
441 |
done
|
paulson@13493
|
442 |
|
paulson@13493
|
443 |
constdefs
|
paulson@13493
|
444 |
is_formula_N :: "[i=>o,i,i] => o"
|
paulson@13493
|
445 |
"is_formula_N(M,n,Z) ==
|
paulson@13395
|
446 |
\<exists>zero[M]. \<exists>sn[M]. \<exists>msn[M].
|
paulson@13395
|
447 |
empty(M,zero) &
|
paulson@13395
|
448 |
successor(M,n,sn) & membership(M,sn,msn) &
|
paulson@13395
|
449 |
is_wfrec(M, iterates_MH(M, is_formula_functor(M),zero), msn, n, Z)"
|
paulson@13395
|
450 |
|
paulson@13493
|
451 |
|
paulson@13493
|
452 |
constdefs
|
paulson@13493
|
453 |
|
paulson@13395
|
454 |
mem_formula :: "[i=>o,i] => o"
|
paulson@13395
|
455 |
"mem_formula(M,p) ==
|
paulson@13395
|
456 |
\<exists>n[M]. \<exists>formn[M].
|
paulson@13493
|
457 |
finite_ordinal(M,n) & is_formula_N(M,n,formn) & p \<in> formn"
|
paulson@13395
|
458 |
|
paulson@13395
|
459 |
is_formula :: "[i=>o,i] => o"
|
paulson@13395
|
460 |
"is_formula(M,Z) == \<forall>p[M]. p \<in> Z <-> mem_formula(M,p)"
|
paulson@13395
|
461 |
|
wenzelm@13428
|
462 |
locale M_datatypes = M_wfrank +
|
paulson@13353
|
463 |
assumes list_replacement1:
|
paulson@13363
|
464 |
"M(A) ==> iterates_replacement(M, is_list_functor(M,A), 0)"
|
paulson@13353
|
465 |
and list_replacement2:
|
paulson@13363
|
466 |
"M(A) ==> strong_replacement(M,
|
paulson@13353
|
467 |
\<lambda>n y. n\<in>nat &
|
paulson@13353
|
468 |
(\<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
|
paulson@13363
|
469 |
is_wfrec(M, iterates_MH(M,is_list_functor(M,A), 0),
|
paulson@13353
|
470 |
msn, n, y)))"
|
paulson@13386
|
471 |
and formula_replacement1:
|
paulson@13386
|
472 |
"iterates_replacement(M, is_formula_functor(M), 0)"
|
paulson@13386
|
473 |
and formula_replacement2:
|
paulson@13386
|
474 |
"strong_replacement(M,
|
paulson@13386
|
475 |
\<lambda>n y. n\<in>nat &
|
paulson@13386
|
476 |
(\<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
|
paulson@13386
|
477 |
is_wfrec(M, iterates_MH(M,is_formula_functor(M), 0),
|
paulson@13386
|
478 |
msn, n, y)))"
|
paulson@13422
|
479 |
and nth_replacement:
|
paulson@13422
|
480 |
"M(l) ==> iterates_replacement(M, %l t. is_tl(M,l,t), l)"
|
paulson@13422
|
481 |
|
paulson@13395
|
482 |
|
paulson@13395
|
483 |
subsubsection{*Absoluteness of the List Construction*}
|
paulson@13395
|
484 |
|
paulson@13348
|
485 |
lemma (in M_datatypes) list_replacement2':
|
paulson@13353
|
486 |
"M(A) ==> strong_replacement(M, \<lambda>n y. n\<in>nat & y = (\<lambda>X. {0} + A * X)^n (0))"
|
paulson@13353
|
487 |
apply (insert list_replacement2 [of A])
|
paulson@13353
|
488 |
apply (rule strong_replacement_cong [THEN iffD1])
|
paulson@13353
|
489 |
apply (rule conj_cong [OF iff_refl iterates_abs [of "is_list_functor(M,A)"]])
|
paulson@13363
|
490 |
apply (simp_all add: list_replacement1 relativize1_def)
|
paulson@13353
|
491 |
done
|
paulson@13268
|
492 |
|
paulson@13268
|
493 |
lemma (in M_datatypes) list_closed [intro,simp]:
|
paulson@13268
|
494 |
"M(A) ==> M(list(A))"
|
paulson@13353
|
495 |
apply (insert list_replacement1)
|
paulson@13353
|
496 |
by (simp add: RepFun_closed2 list_eq_Union
|
paulson@13353
|
497 |
list_replacement2' relativize1_def
|
paulson@13353
|
498 |
iterates_closed [of "is_list_functor(M,A)"])
|
paulson@13397
|
499 |
|
paulson@13423
|
500 |
text{*WARNING: use only with @{text "dest:"} or with variables fixed!*}
|
paulson@13423
|
501 |
lemmas (in M_datatypes) list_into_M = transM [OF _ list_closed]
|
paulson@13423
|
502 |
|
paulson@13397
|
503 |
lemma (in M_datatypes) list_N_abs [simp]:
|
paulson@13395
|
504 |
"[|M(A); n\<in>nat; M(Z)|]
|
paulson@13397
|
505 |
==> is_list_N(M,A,n,Z) <-> Z = list_N(A,n)"
|
paulson@13395
|
506 |
apply (insert list_replacement1)
|
paulson@13397
|
507 |
apply (simp add: is_list_N_def list_N_def relativize1_def nat_into_M
|
paulson@13395
|
508 |
iterates_abs [of "is_list_functor(M,A)" _ "\<lambda>X. {0} + A*X"])
|
paulson@13395
|
509 |
done
|
paulson@13268
|
510 |
|
paulson@13397
|
511 |
lemma (in M_datatypes) list_N_closed [intro,simp]:
|
paulson@13397
|
512 |
"[|M(A); n\<in>nat|] ==> M(list_N(A,n))"
|
paulson@13397
|
513 |
apply (insert list_replacement1)
|
paulson@13397
|
514 |
apply (simp add: is_list_N_def list_N_def relativize1_def nat_into_M
|
paulson@13397
|
515 |
iterates_closed [of "is_list_functor(M,A)"])
|
paulson@13397
|
516 |
done
|
paulson@13397
|
517 |
|
paulson@13395
|
518 |
lemma (in M_datatypes) mem_list_abs [simp]:
|
paulson@13395
|
519 |
"M(A) ==> mem_list(M,A,l) <-> l \<in> list(A)"
|
paulson@13395
|
520 |
apply (insert list_replacement1)
|
paulson@13397
|
521 |
apply (simp add: mem_list_def list_N_def relativize1_def list_eq_Union
|
paulson@13395
|
522 |
iterates_closed [of "is_list_functor(M,A)"])
|
paulson@13395
|
523 |
done
|
paulson@13395
|
524 |
|
paulson@13395
|
525 |
lemma (in M_datatypes) list_abs [simp]:
|
paulson@13395
|
526 |
"[|M(A); M(Z)|] ==> is_list(M,A,Z) <-> Z = list(A)"
|
paulson@13395
|
527 |
apply (simp add: is_list_def, safe)
|
paulson@13395
|
528 |
apply (rule M_equalityI, simp_all)
|
paulson@13395
|
529 |
done
|
paulson@13395
|
530 |
|
paulson@13395
|
531 |
subsubsection{*Absoluteness of Formulas*}
|
paulson@13293
|
532 |
|
paulson@13386
|
533 |
lemma (in M_datatypes) formula_replacement2':
|
paulson@13398
|
534 |
"strong_replacement(M, \<lambda>n y. n\<in>nat & y = (\<lambda>X. ((nat*nat) + (nat*nat)) + (X*X + X))^n (0))"
|
paulson@13386
|
535 |
apply (insert formula_replacement2)
|
paulson@13386
|
536 |
apply (rule strong_replacement_cong [THEN iffD1])
|
paulson@13386
|
537 |
apply (rule conj_cong [OF iff_refl iterates_abs [of "is_formula_functor(M)"]])
|
paulson@13386
|
538 |
apply (simp_all add: formula_replacement1 relativize1_def)
|
paulson@13386
|
539 |
done
|
paulson@13386
|
540 |
|
paulson@13386
|
541 |
lemma (in M_datatypes) formula_closed [intro,simp]:
|
paulson@13386
|
542 |
"M(formula)"
|
paulson@13386
|
543 |
apply (insert formula_replacement1)
|
paulson@13386
|
544 |
apply (simp add: RepFun_closed2 formula_eq_Union
|
paulson@13386
|
545 |
formula_replacement2' relativize1_def
|
paulson@13386
|
546 |
iterates_closed [of "is_formula_functor(M)"])
|
paulson@13386
|
547 |
done
|
paulson@13386
|
548 |
|
paulson@13423
|
549 |
lemmas (in M_datatypes) formula_into_M = transM [OF _ formula_closed]
|
paulson@13423
|
550 |
|
paulson@13493
|
551 |
lemma (in M_datatypes) formula_N_abs [simp]:
|
paulson@13395
|
552 |
"[|n\<in>nat; M(Z)|]
|
paulson@13493
|
553 |
==> is_formula_N(M,n,Z) <-> Z = formula_N(n)"
|
paulson@13395
|
554 |
apply (insert formula_replacement1)
|
paulson@13493
|
555 |
apply (simp add: is_formula_N_def formula_N_def relativize1_def nat_into_M
|
paulson@13395
|
556 |
iterates_abs [of "is_formula_functor(M)" _
|
paulson@13493
|
557 |
"\<lambda>X. ((nat*nat) + (nat*nat)) + (X*X + X)"])
|
paulson@13493
|
558 |
done
|
paulson@13493
|
559 |
|
paulson@13493
|
560 |
lemma (in M_datatypes) formula_N_closed [intro,simp]:
|
paulson@13493
|
561 |
"n\<in>nat ==> M(formula_N(n))"
|
paulson@13493
|
562 |
apply (insert formula_replacement1)
|
paulson@13493
|
563 |
apply (simp add: is_formula_N_def formula_N_def relativize1_def nat_into_M
|
paulson@13493
|
564 |
iterates_closed [of "is_formula_functor(M)"])
|
paulson@13395
|
565 |
done
|
paulson@13395
|
566 |
|
paulson@13395
|
567 |
lemma (in M_datatypes) mem_formula_abs [simp]:
|
paulson@13395
|
568 |
"mem_formula(M,l) <-> l \<in> formula"
|
paulson@13395
|
569 |
apply (insert formula_replacement1)
|
paulson@13493
|
570 |
apply (simp add: mem_formula_def relativize1_def formula_eq_Union formula_N_def
|
paulson@13395
|
571 |
iterates_closed [of "is_formula_functor(M)"])
|
paulson@13395
|
572 |
done
|
paulson@13395
|
573 |
|
paulson@13395
|
574 |
lemma (in M_datatypes) formula_abs [simp]:
|
paulson@13395
|
575 |
"[|M(Z)|] ==> is_formula(M,Z) <-> Z = formula"
|
paulson@13395
|
576 |
apply (simp add: is_formula_def, safe)
|
paulson@13395
|
577 |
apply (rule M_equalityI, simp_all)
|
paulson@13395
|
578 |
done
|
paulson@13395
|
579 |
|
paulson@13395
|
580 |
|
paulson@13397
|
581 |
subsection{*Absoluteness for Some List Operators*}
|
paulson@13397
|
582 |
|
paulson@13395
|
583 |
subsection{*Absoluteness for @{text \<epsilon>}-Closure: the @{term eclose} Operator*}
|
paulson@13395
|
584 |
|
paulson@13395
|
585 |
text{*Re-expresses eclose using "iterates"*}
|
paulson@13395
|
586 |
lemma eclose_eq_Union:
|
paulson@13395
|
587 |
"eclose(A) = (\<Union>n\<in>nat. Union^n (A))"
|
paulson@13395
|
588 |
apply (simp add: eclose_def)
|
paulson@13395
|
589 |
apply (rule UN_cong)
|
paulson@13395
|
590 |
apply (rule refl)
|
paulson@13395
|
591 |
apply (induct_tac n)
|
paulson@13395
|
592 |
apply (simp add: nat_rec_0)
|
paulson@13395
|
593 |
apply (simp add: nat_rec_succ)
|
paulson@13395
|
594 |
done
|
paulson@13395
|
595 |
|
paulson@13395
|
596 |
constdefs
|
paulson@13395
|
597 |
is_eclose_n :: "[i=>o,i,i,i] => o"
|
paulson@13395
|
598 |
"is_eclose_n(M,A,n,Z) ==
|
paulson@13395
|
599 |
\<exists>sn[M]. \<exists>msn[M].
|
paulson@13395
|
600 |
successor(M,n,sn) & membership(M,sn,msn) &
|
paulson@13395
|
601 |
is_wfrec(M, iterates_MH(M, big_union(M), A), msn, n, Z)"
|
paulson@13395
|
602 |
|
paulson@13395
|
603 |
mem_eclose :: "[i=>o,i,i] => o"
|
paulson@13395
|
604 |
"mem_eclose(M,A,l) ==
|
paulson@13395
|
605 |
\<exists>n[M]. \<exists>eclosen[M].
|
paulson@13395
|
606 |
finite_ordinal(M,n) & is_eclose_n(M,A,n,eclosen) & l \<in> eclosen"
|
paulson@13395
|
607 |
|
paulson@13395
|
608 |
is_eclose :: "[i=>o,i,i] => o"
|
paulson@13395
|
609 |
"is_eclose(M,A,Z) == \<forall>u[M]. u \<in> Z <-> mem_eclose(M,A,u)"
|
paulson@13395
|
610 |
|
paulson@13395
|
611 |
|
wenzelm@13428
|
612 |
locale M_eclose = M_datatypes +
|
paulson@13395
|
613 |
assumes eclose_replacement1:
|
paulson@13395
|
614 |
"M(A) ==> iterates_replacement(M, big_union(M), A)"
|
paulson@13395
|
615 |
and eclose_replacement2:
|
paulson@13395
|
616 |
"M(A) ==> strong_replacement(M,
|
paulson@13395
|
617 |
\<lambda>n y. n\<in>nat &
|
paulson@13395
|
618 |
(\<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
|
paulson@13395
|
619 |
is_wfrec(M, iterates_MH(M,big_union(M), A),
|
paulson@13395
|
620 |
msn, n, y)))"
|
paulson@13395
|
621 |
|
paulson@13395
|
622 |
lemma (in M_eclose) eclose_replacement2':
|
paulson@13395
|
623 |
"M(A) ==> strong_replacement(M, \<lambda>n y. n\<in>nat & y = Union^n (A))"
|
paulson@13395
|
624 |
apply (insert eclose_replacement2 [of A])
|
paulson@13395
|
625 |
apply (rule strong_replacement_cong [THEN iffD1])
|
paulson@13395
|
626 |
apply (rule conj_cong [OF iff_refl iterates_abs [of "big_union(M)"]])
|
paulson@13395
|
627 |
apply (simp_all add: eclose_replacement1 relativize1_def)
|
paulson@13395
|
628 |
done
|
paulson@13395
|
629 |
|
paulson@13395
|
630 |
lemma (in M_eclose) eclose_closed [intro,simp]:
|
paulson@13395
|
631 |
"M(A) ==> M(eclose(A))"
|
paulson@13395
|
632 |
apply (insert eclose_replacement1)
|
paulson@13395
|
633 |
by (simp add: RepFun_closed2 eclose_eq_Union
|
paulson@13395
|
634 |
eclose_replacement2' relativize1_def
|
paulson@13395
|
635 |
iterates_closed [of "big_union(M)"])
|
paulson@13395
|
636 |
|
paulson@13395
|
637 |
lemma (in M_eclose) is_eclose_n_abs [simp]:
|
paulson@13395
|
638 |
"[|M(A); n\<in>nat; M(Z)|] ==> is_eclose_n(M,A,n,Z) <-> Z = Union^n (A)"
|
paulson@13395
|
639 |
apply (insert eclose_replacement1)
|
paulson@13395
|
640 |
apply (simp add: is_eclose_n_def relativize1_def nat_into_M
|
paulson@13395
|
641 |
iterates_abs [of "big_union(M)" _ "Union"])
|
paulson@13395
|
642 |
done
|
paulson@13395
|
643 |
|
paulson@13395
|
644 |
lemma (in M_eclose) mem_eclose_abs [simp]:
|
paulson@13395
|
645 |
"M(A) ==> mem_eclose(M,A,l) <-> l \<in> eclose(A)"
|
paulson@13395
|
646 |
apply (insert eclose_replacement1)
|
paulson@13395
|
647 |
apply (simp add: mem_eclose_def relativize1_def eclose_eq_Union
|
paulson@13395
|
648 |
iterates_closed [of "big_union(M)"])
|
paulson@13395
|
649 |
done
|
paulson@13395
|
650 |
|
paulson@13395
|
651 |
lemma (in M_eclose) eclose_abs [simp]:
|
paulson@13395
|
652 |
"[|M(A); M(Z)|] ==> is_eclose(M,A,Z) <-> Z = eclose(A)"
|
paulson@13395
|
653 |
apply (simp add: is_eclose_def, safe)
|
paulson@13395
|
654 |
apply (rule M_equalityI, simp_all)
|
paulson@13395
|
655 |
done
|
paulson@13395
|
656 |
|
paulson@13395
|
657 |
|
paulson@13395
|
658 |
|
paulson@13395
|
659 |
|
paulson@13395
|
660 |
subsection {*Absoluteness for @{term transrec}*}
|
paulson@13395
|
661 |
|
paulson@13395
|
662 |
|
paulson@13395
|
663 |
text{* @{term "transrec(a,H) \<equiv> wfrec(Memrel(eclose({a})), a, H)"} *}
|
paulson@13395
|
664 |
constdefs
|
paulson@13395
|
665 |
|
paulson@13395
|
666 |
is_transrec :: "[i=>o, [i,i,i]=>o, i, i] => o"
|
paulson@13395
|
667 |
"is_transrec(M,MH,a,z) ==
|
paulson@13395
|
668 |
\<exists>sa[M]. \<exists>esa[M]. \<exists>mesa[M].
|
paulson@13395
|
669 |
upair(M,a,a,sa) & is_eclose(M,sa,esa) & membership(M,esa,mesa) &
|
paulson@13395
|
670 |
is_wfrec(M,MH,mesa,a,z)"
|
paulson@13395
|
671 |
|
paulson@13395
|
672 |
transrec_replacement :: "[i=>o, [i,i,i]=>o, i] => o"
|
paulson@13395
|
673 |
"transrec_replacement(M,MH,a) ==
|
paulson@13395
|
674 |
\<exists>sa[M]. \<exists>esa[M]. \<exists>mesa[M].
|
paulson@13395
|
675 |
upair(M,a,a,sa) & is_eclose(M,sa,esa) & membership(M,esa,mesa) &
|
paulson@13395
|
676 |
wfrec_replacement(M,MH,mesa)"
|
paulson@13395
|
677 |
|
paulson@13395
|
678 |
text{*The condition @{term "Ord(i)"} lets us use the simpler
|
paulson@13395
|
679 |
@{text "trans_wfrec_abs"} rather than @{text "trans_wfrec_abs"},
|
paulson@13395
|
680 |
which I haven't even proved yet. *}
|
paulson@13395
|
681 |
theorem (in M_eclose) transrec_abs:
|
paulson@13418
|
682 |
"[|transrec_replacement(M,MH,i); relativize2(M,MH,H);
|
paulson@13418
|
683 |
Ord(i); M(i); M(z);
|
paulson@13395
|
684 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|]
|
paulson@13395
|
685 |
==> is_transrec(M,MH,i,z) <-> z = transrec(i,H)"
|
paulson@13418
|
686 |
apply (rotate_tac 2)
|
paulson@13418
|
687 |
apply (simp add: trans_wfrec_abs transrec_replacement_def is_transrec_def
|
paulson@13395
|
688 |
transrec_def eclose_sing_Ord_eq wf_Memrel trans_Memrel relation_Memrel)
|
paulson@13418
|
689 |
done
|
paulson@13395
|
690 |
|
paulson@13395
|
691 |
|
paulson@13395
|
692 |
theorem (in M_eclose) transrec_closed:
|
paulson@13418
|
693 |
"[|transrec_replacement(M,MH,i); relativize2(M,MH,H);
|
paulson@13418
|
694 |
Ord(i); M(i);
|
paulson@13395
|
695 |
\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|]
|
paulson@13395
|
696 |
==> M(transrec(i,H))"
|
paulson@13418
|
697 |
apply (rotate_tac 2)
|
paulson@13418
|
698 |
apply (simp add: trans_wfrec_closed transrec_replacement_def is_transrec_def
|
paulson@13395
|
699 |
transrec_def eclose_sing_Ord_eq wf_Memrel trans_Memrel relation_Memrel)
|
paulson@13418
|
700 |
done
|
paulson@13395
|
701 |
|
paulson@13440
|
702 |
text{*Helps to prove instances of @{term transrec_replacement}*}
|
paulson@13440
|
703 |
lemma (in M_eclose) transrec_replacementI:
|
paulson@13440
|
704 |
"[|M(a);
|
paulson@13440
|
705 |
strong_replacement (M,
|
paulson@13440
|
706 |
\<lambda>x z. \<exists>y[M]. pair(M, x, y, z) \<and> is_wfrec(M,MH,Memrel(eclose({a})),x,y))|]
|
paulson@13440
|
707 |
==> transrec_replacement(M,MH,a)"
|
paulson@13440
|
708 |
by (simp add: transrec_replacement_def wfrec_replacement_def)
|
paulson@13440
|
709 |
|
paulson@13395
|
710 |
|
paulson@13397
|
711 |
subsection{*Absoluteness for the List Operator @{term length}*}
|
paulson@13397
|
712 |
constdefs
|
paulson@13397
|
713 |
|
paulson@13397
|
714 |
is_length :: "[i=>o,i,i,i] => o"
|
paulson@13397
|
715 |
"is_length(M,A,l,n) ==
|
paulson@13397
|
716 |
\<exists>sn[M]. \<exists>list_n[M]. \<exists>list_sn[M].
|
paulson@13397
|
717 |
is_list_N(M,A,n,list_n) & l \<notin> list_n &
|
paulson@13397
|
718 |
successor(M,n,sn) & is_list_N(M,A,sn,list_sn) & l \<in> list_sn"
|
paulson@13397
|
719 |
|
paulson@13397
|
720 |
|
paulson@13397
|
721 |
lemma (in M_datatypes) length_abs [simp]:
|
paulson@13397
|
722 |
"[|M(A); l \<in> list(A); n \<in> nat|] ==> is_length(M,A,l,n) <-> n = length(l)"
|
paulson@13397
|
723 |
apply (subgoal_tac "M(l) & M(n)")
|
paulson@13397
|
724 |
prefer 2 apply (blast dest: transM)
|
paulson@13397
|
725 |
apply (simp add: is_length_def)
|
paulson@13397
|
726 |
apply (blast intro: list_imp_list_N nat_into_Ord list_N_imp_eq_length
|
paulson@13397
|
727 |
dest: list_N_imp_length_lt)
|
paulson@13397
|
728 |
done
|
paulson@13397
|
729 |
|
paulson@13397
|
730 |
text{*Proof is trivial since @{term length} returns natural numbers.*}
|
paulson@13564
|
731 |
lemma (in M_trivial) length_closed [intro,simp]:
|
paulson@13397
|
732 |
"l \<in> list(A) ==> M(length(l))"
|
paulson@13398
|
733 |
by (simp add: nat_into_M)
|
paulson@13397
|
734 |
|
paulson@13397
|
735 |
|
paulson@13397
|
736 |
subsection {*Absoluteness for @{term nth}*}
|
paulson@13397
|
737 |
|
paulson@13397
|
738 |
lemma nth_eq_hd_iterates_tl [rule_format]:
|
paulson@13397
|
739 |
"xs \<in> list(A) ==> \<forall>n \<in> nat. nth(n,xs) = hd' (tl'^n (xs))"
|
paulson@13397
|
740 |
apply (induct_tac xs)
|
paulson@13397
|
741 |
apply (simp add: iterates_tl_Nil hd'_Nil, clarify)
|
paulson@13397
|
742 |
apply (erule natE)
|
paulson@13397
|
743 |
apply (simp add: hd'_Cons)
|
paulson@13397
|
744 |
apply (simp add: tl'_Cons iterates_commute)
|
paulson@13397
|
745 |
done
|
paulson@13397
|
746 |
|
paulson@13564
|
747 |
lemma (in M_basic) iterates_tl'_closed:
|
paulson@13397
|
748 |
"[|n \<in> nat; M(x)|] ==> M(tl'^n (x))"
|
paulson@13397
|
749 |
apply (induct_tac n, simp)
|
paulson@13397
|
750 |
apply (simp add: tl'_Cons tl'_closed)
|
paulson@13397
|
751 |
done
|
paulson@13397
|
752 |
|
paulson@13397
|
753 |
text{*Immediate by type-checking*}
|
paulson@13397
|
754 |
lemma (in M_datatypes) nth_closed [intro,simp]:
|
paulson@13397
|
755 |
"[|xs \<in> list(A); n \<in> nat; M(A)|] ==> M(nth(n,xs))"
|
paulson@13397
|
756 |
apply (case_tac "n < length(xs)")
|
paulson@13397
|
757 |
apply (blast intro: nth_type transM)
|
paulson@13397
|
758 |
apply (simp add: not_lt_iff_le nth_eq_0)
|
paulson@13397
|
759 |
done
|
paulson@13397
|
760 |
|
paulson@13397
|
761 |
constdefs
|
paulson@13397
|
762 |
is_nth :: "[i=>o,i,i,i] => o"
|
paulson@13397
|
763 |
"is_nth(M,n,l,Z) ==
|
paulson@13397
|
764 |
\<exists>X[M]. \<exists>sn[M]. \<exists>msn[M].
|
paulson@13397
|
765 |
successor(M,n,sn) & membership(M,sn,msn) &
|
paulson@13397
|
766 |
is_wfrec(M, iterates_MH(M, is_tl(M), l), msn, n, X) &
|
paulson@13397
|
767 |
is_hd(M,X,Z)"
|
paulson@13397
|
768 |
|
paulson@13409
|
769 |
lemma (in M_datatypes) nth_abs [simp]:
|
paulson@13422
|
770 |
"[|M(A); n \<in> nat; l \<in> list(A); M(Z)|]
|
paulson@13397
|
771 |
==> is_nth(M,n,l,Z) <-> Z = nth(n,l)"
|
paulson@13397
|
772 |
apply (subgoal_tac "M(l)")
|
paulson@13397
|
773 |
prefer 2 apply (blast intro: transM)
|
paulson@13397
|
774 |
apply (simp add: is_nth_def nth_eq_hd_iterates_tl nat_into_M
|
paulson@13397
|
775 |
tl'_closed iterates_tl'_closed
|
paulson@13422
|
776 |
iterates_abs [OF _ relativize1_tl] nth_replacement)
|
paulson@13397
|
777 |
done
|
paulson@13397
|
778 |
|
paulson@13395
|
779 |
|
paulson@13398
|
780 |
subsection{*Relativization and Absoluteness for the @{term formula} Constructors*}
|
paulson@13398
|
781 |
|
paulson@13398
|
782 |
constdefs
|
paulson@13398
|
783 |
is_Member :: "[i=>o,i,i,i] => o"
|
paulson@13398
|
784 |
--{* because @{term "Member(x,y) \<equiv> Inl(Inl(\<langle>x,y\<rangle>))"}*}
|
paulson@13398
|
785 |
"is_Member(M,x,y,Z) ==
|
paulson@13398
|
786 |
\<exists>p[M]. \<exists>u[M]. pair(M,x,y,p) & is_Inl(M,p,u) & is_Inl(M,u,Z)"
|
paulson@13398
|
787 |
|
paulson@13564
|
788 |
lemma (in M_trivial) Member_abs [simp]:
|
paulson@13398
|
789 |
"[|M(x); M(y); M(Z)|] ==> is_Member(M,x,y,Z) <-> (Z = Member(x,y))"
|
paulson@13398
|
790 |
by (simp add: is_Member_def Member_def)
|
paulson@13398
|
791 |
|
paulson@13564
|
792 |
lemma (in M_trivial) Member_in_M_iff [iff]:
|
paulson@13398
|
793 |
"M(Member(x,y)) <-> M(x) & M(y)"
|
paulson@13398
|
794 |
by (simp add: Member_def)
|
paulson@13398
|
795 |
|
paulson@13398
|
796 |
constdefs
|
paulson@13398
|
797 |
is_Equal :: "[i=>o,i,i,i] => o"
|
paulson@13398
|
798 |
--{* because @{term "Equal(x,y) \<equiv> Inl(Inr(\<langle>x,y\<rangle>))"}*}
|
paulson@13398
|
799 |
"is_Equal(M,x,y,Z) ==
|
paulson@13398
|
800 |
\<exists>p[M]. \<exists>u[M]. pair(M,x,y,p) & is_Inr(M,p,u) & is_Inl(M,u,Z)"
|
paulson@13398
|
801 |
|
paulson@13564
|
802 |
lemma (in M_trivial) Equal_abs [simp]:
|
paulson@13398
|
803 |
"[|M(x); M(y); M(Z)|] ==> is_Equal(M,x,y,Z) <-> (Z = Equal(x,y))"
|
paulson@13398
|
804 |
by (simp add: is_Equal_def Equal_def)
|
paulson@13398
|
805 |
|
paulson@13564
|
806 |
lemma (in M_trivial) Equal_in_M_iff [iff]: "M(Equal(x,y)) <-> M(x) & M(y)"
|
paulson@13398
|
807 |
by (simp add: Equal_def)
|
paulson@13398
|
808 |
|
paulson@13398
|
809 |
constdefs
|
paulson@13398
|
810 |
is_Nand :: "[i=>o,i,i,i] => o"
|
paulson@13398
|
811 |
--{* because @{term "Nand(x,y) \<equiv> Inr(Inl(\<langle>x,y\<rangle>))"}*}
|
paulson@13398
|
812 |
"is_Nand(M,x,y,Z) ==
|
paulson@13398
|
813 |
\<exists>p[M]. \<exists>u[M]. pair(M,x,y,p) & is_Inl(M,p,u) & is_Inr(M,u,Z)"
|
paulson@13398
|
814 |
|
paulson@13564
|
815 |
lemma (in M_trivial) Nand_abs [simp]:
|
paulson@13398
|
816 |
"[|M(x); M(y); M(Z)|] ==> is_Nand(M,x,y,Z) <-> (Z = Nand(x,y))"
|
paulson@13398
|
817 |
by (simp add: is_Nand_def Nand_def)
|
paulson@13398
|
818 |
|
paulson@13564
|
819 |
lemma (in M_trivial) Nand_in_M_iff [iff]: "M(Nand(x,y)) <-> M(x) & M(y)"
|
paulson@13398
|
820 |
by (simp add: Nand_def)
|
paulson@13398
|
821 |
|
paulson@13398
|
822 |
constdefs
|
paulson@13398
|
823 |
is_Forall :: "[i=>o,i,i] => o"
|
paulson@13398
|
824 |
--{* because @{term "Forall(x) \<equiv> Inr(Inr(p))"}*}
|
paulson@13398
|
825 |
"is_Forall(M,p,Z) == \<exists>u[M]. is_Inr(M,p,u) & is_Inr(M,u,Z)"
|
paulson@13398
|
826 |
|
paulson@13564
|
827 |
lemma (in M_trivial) Forall_abs [simp]:
|
paulson@13398
|
828 |
"[|M(x); M(Z)|] ==> is_Forall(M,x,Z) <-> (Z = Forall(x))"
|
paulson@13398
|
829 |
by (simp add: is_Forall_def Forall_def)
|
paulson@13398
|
830 |
|
paulson@13564
|
831 |
lemma (in M_trivial) Forall_in_M_iff [iff]: "M(Forall(x)) <-> M(x)"
|
paulson@13398
|
832 |
by (simp add: Forall_def)
|
paulson@13398
|
833 |
|
paulson@13398
|
834 |
|
paulson@13398
|
835 |
subsection {*Absoluteness for @{term formula_rec}*}
|
paulson@13398
|
836 |
|
paulson@13423
|
837 |
subsubsection{*@{term is_formula_case}: relativization of @{term formula_case}*}
|
paulson@13423
|
838 |
|
paulson@13423
|
839 |
constdefs
|
paulson@13423
|
840 |
|
paulson@13423
|
841 |
is_formula_case ::
|
paulson@13423
|
842 |
"[i=>o, [i,i,i]=>o, [i,i,i]=>o, [i,i,i]=>o, [i,i]=>o, i, i] => o"
|
paulson@13423
|
843 |
--{*no constraint on non-formulas*}
|
paulson@13423
|
844 |
"is_formula_case(M, is_a, is_b, is_c, is_d, p, z) ==
|
paulson@13493
|
845 |
(\<forall>x[M]. \<forall>y[M]. finite_ordinal(M,x) --> finite_ordinal(M,y) -->
|
paulson@13493
|
846 |
is_Member(M,x,y,p) --> is_a(x,y,z)) &
|
paulson@13493
|
847 |
(\<forall>x[M]. \<forall>y[M]. finite_ordinal(M,x) --> finite_ordinal(M,y) -->
|
paulson@13493
|
848 |
is_Equal(M,x,y,p) --> is_b(x,y,z)) &
|
paulson@13493
|
849 |
(\<forall>x[M]. \<forall>y[M]. mem_formula(M,x) --> mem_formula(M,y) -->
|
paulson@13423
|
850 |
is_Nand(M,x,y,p) --> is_c(x,y,z)) &
|
paulson@13493
|
851 |
(\<forall>x[M]. mem_formula(M,x) --> is_Forall(M,x,p) --> is_d(x,z))"
|
paulson@13423
|
852 |
|
paulson@13423
|
853 |
lemma (in M_datatypes) formula_case_abs [simp]:
|
paulson@13423
|
854 |
"[| Relativize2(M,nat,nat,is_a,a); Relativize2(M,nat,nat,is_b,b);
|
paulson@13423
|
855 |
Relativize2(M,formula,formula,is_c,c); Relativize1(M,formula,is_d,d);
|
paulson@13423
|
856 |
p \<in> formula; M(z) |]
|
paulson@13423
|
857 |
==> is_formula_case(M,is_a,is_b,is_c,is_d,p,z) <->
|
paulson@13423
|
858 |
z = formula_case(a,b,c,d,p)"
|
paulson@13423
|
859 |
apply (simp add: formula_into_M is_formula_case_def)
|
paulson@13423
|
860 |
apply (erule formula.cases)
|
paulson@13423
|
861 |
apply (simp_all add: Relativize1_def Relativize2_def)
|
paulson@13423
|
862 |
done
|
paulson@13423
|
863 |
|
paulson@13418
|
864 |
lemma (in M_datatypes) formula_case_closed [intro,simp]:
|
paulson@13418
|
865 |
"[|p \<in> formula;
|
paulson@13418
|
866 |
\<forall>x[M]. \<forall>y[M]. x\<in>nat --> y\<in>nat --> M(a(x,y));
|
paulson@13418
|
867 |
\<forall>x[M]. \<forall>y[M]. x\<in>nat --> y\<in>nat --> M(b(x,y));
|
paulson@13418
|
868 |
\<forall>x[M]. \<forall>y[M]. x\<in>formula --> y\<in>formula --> M(c(x,y));
|
paulson@13418
|
869 |
\<forall>x[M]. x\<in>formula --> M(d(x))|] ==> M(formula_case(a,b,c,d,p))"
|
paulson@13418
|
870 |
by (erule formula.cases, simp_all)
|
paulson@13418
|
871 |
|
paulson@13398
|
872 |
|
paulson@13398
|
873 |
subsection{*Absoluteness for the Formula Operator @{term depth}*}
|
paulson@13398
|
874 |
constdefs
|
paulson@13398
|
875 |
|
paulson@13398
|
876 |
is_depth :: "[i=>o,i,i] => o"
|
paulson@13398
|
877 |
"is_depth(M,p,n) ==
|
paulson@13398
|
878 |
\<exists>sn[M]. \<exists>formula_n[M]. \<exists>formula_sn[M].
|
paulson@13398
|
879 |
is_formula_N(M,n,formula_n) & p \<notin> formula_n &
|
paulson@13398
|
880 |
successor(M,n,sn) & is_formula_N(M,sn,formula_sn) & p \<in> formula_sn"
|
paulson@13398
|
881 |
|
paulson@13398
|
882 |
|
paulson@13398
|
883 |
lemma (in M_datatypes) depth_abs [simp]:
|
paulson@13398
|
884 |
"[|p \<in> formula; n \<in> nat|] ==> is_depth(M,p,n) <-> n = depth(p)"
|
paulson@13398
|
885 |
apply (subgoal_tac "M(p) & M(n)")
|
paulson@13398
|
886 |
prefer 2 apply (blast dest: transM)
|
paulson@13398
|
887 |
apply (simp add: is_depth_def)
|
paulson@13398
|
888 |
apply (blast intro: formula_imp_formula_N nat_into_Ord formula_N_imp_eq_depth
|
paulson@13398
|
889 |
dest: formula_N_imp_depth_lt)
|
paulson@13398
|
890 |
done
|
paulson@13398
|
891 |
|
paulson@13398
|
892 |
text{*Proof is trivial since @{term depth} returns natural numbers.*}
|
paulson@13564
|
893 |
lemma (in M_trivial) depth_closed [intro,simp]:
|
paulson@13398
|
894 |
"p \<in> formula ==> M(depth(p))"
|
paulson@13398
|
895 |
by (simp add: nat_into_M)
|
paulson@13398
|
896 |
|
paulson@13493
|
897 |
|
paulson@13557
|
898 |
subsection {*Absoluteness for @{term formula_rec}*}
|
paulson@13557
|
899 |
|
paulson@13557
|
900 |
constdefs
|
paulson@13557
|
901 |
|
paulson@13557
|
902 |
formula_rec_case :: "[[i,i]=>i, [i,i]=>i, [i,i,i,i]=>i, [i,i]=>i, i, i] => i"
|
paulson@13557
|
903 |
--{* the instance of @{term formula_case} in @{term formula_rec}*}
|
paulson@13557
|
904 |
"formula_rec_case(a,b,c,d,h) ==
|
paulson@13557
|
905 |
formula_case (a, b,
|
paulson@13557
|
906 |
\<lambda>u v. c(u, v, h ` succ(depth(u)) ` u,
|
paulson@13557
|
907 |
h ` succ(depth(v)) ` v),
|
paulson@13557
|
908 |
\<lambda>u. d(u, h ` succ(depth(u)) ` u))"
|
paulson@13557
|
909 |
|
paulson@13557
|
910 |
is_formula_rec :: "[i=>o, [i,i,i]=>o, i, i] => o"
|
paulson@13557
|
911 |
--{* predicate to relativize the functional @{term formula_rec}*}
|
paulson@13557
|
912 |
"is_formula_rec(M,MH,p,z) ==
|
paulson@13557
|
913 |
\<exists>dp[M]. \<exists>i[M]. \<exists>f[M]. finite_ordinal(M,dp) & is_depth(M,p,dp) &
|
paulson@13557
|
914 |
successor(M,dp,i) & fun_apply(M,f,p,z) & is_transrec(M,MH,i,f)"
|
paulson@13557
|
915 |
|
paulson@13557
|
916 |
text{*Unfold @{term formula_rec} to @{term formula_rec_case}.
|
paulson@13557
|
917 |
Express @{term formula_rec} without using @{term rank} or @{term Vset},
|
paulson@13557
|
918 |
neither of which is absolute.*}
|
paulson@13564
|
919 |
lemma (in M_trivial) formula_rec_eq:
|
paulson@13557
|
920 |
"p \<in> formula ==>
|
paulson@13557
|
921 |
formula_rec(a,b,c,d,p) =
|
paulson@13557
|
922 |
transrec (succ(depth(p)),
|
paulson@13557
|
923 |
\<lambda>x h. Lambda (formula, formula_rec_case(a,b,c,d,h))) ` p"
|
paulson@13557
|
924 |
apply (simp add: formula_rec_case_def)
|
paulson@13557
|
925 |
apply (induct_tac p)
|
paulson@13557
|
926 |
txt{*Base case for @{term Member}*}
|
paulson@13557
|
927 |
apply (subst transrec, simp add: formula.intros)
|
paulson@13557
|
928 |
txt{*Base case for @{term Equal}*}
|
paulson@13557
|
929 |
apply (subst transrec, simp add: formula.intros)
|
paulson@13557
|
930 |
txt{*Inductive step for @{term Nand}*}
|
paulson@13557
|
931 |
apply (subst transrec)
|
paulson@13557
|
932 |
apply (simp add: succ_Un_distrib formula.intros)
|
paulson@13557
|
933 |
txt{*Inductive step for @{term Forall}*}
|
paulson@13557
|
934 |
apply (subst transrec)
|
paulson@13557
|
935 |
apply (simp add: formula_imp_formula_N formula.intros)
|
paulson@13557
|
936 |
done
|
paulson@13557
|
937 |
|
paulson@13557
|
938 |
|
paulson@13557
|
939 |
text{*Sufficient conditions to relative the instance of @{term formula_case}
|
paulson@13557
|
940 |
in @{term formula_rec}*}
|
paulson@13557
|
941 |
lemma (in M_datatypes) Relativize1_formula_rec_case:
|
paulson@13557
|
942 |
"[|Relativize2(M, nat, nat, is_a, a);
|
paulson@13557
|
943 |
Relativize2(M, nat, nat, is_b, b);
|
paulson@13557
|
944 |
Relativize2 (M, formula, formula,
|
paulson@13557
|
945 |
is_c, \<lambda>u v. c(u, v, h`succ(depth(u))`u, h`succ(depth(v))`v));
|
paulson@13557
|
946 |
Relativize1(M, formula,
|
paulson@13557
|
947 |
is_d, \<lambda>u. d(u, h ` succ(depth(u)) ` u));
|
paulson@13557
|
948 |
M(h) |]
|
paulson@13557
|
949 |
==> Relativize1(M, formula,
|
paulson@13557
|
950 |
is_formula_case (M, is_a, is_b, is_c, is_d),
|
paulson@13557
|
951 |
formula_rec_case(a, b, c, d, h))"
|
paulson@13557
|
952 |
apply (simp (no_asm) add: formula_rec_case_def Relativize1_def)
|
paulson@13557
|
953 |
apply (simp add: formula_case_abs)
|
paulson@13557
|
954 |
done
|
paulson@13557
|
955 |
|
paulson@13557
|
956 |
|
paulson@13557
|
957 |
text{*This locale packages the premises of the following theorems,
|
paulson@13557
|
958 |
which is the normal purpose of locales. It doesn't accumulate
|
paulson@13557
|
959 |
constraints on the class @{term M}, as in most of this deveopment.*}
|
paulson@13557
|
960 |
locale Formula_Rec = M_eclose +
|
paulson@13557
|
961 |
fixes a and is_a and b and is_b and c and is_c and d and is_d and MH
|
paulson@13557
|
962 |
defines
|
paulson@13557
|
963 |
"MH(u::i,f,z) ==
|
paulson@13557
|
964 |
\<forall>fml[M]. is_formula(M,fml) -->
|
paulson@13557
|
965 |
is_lambda
|
paulson@13557
|
966 |
(M, fml, is_formula_case (M, is_a, is_b, is_c(f), is_d(f)), z)"
|
paulson@13557
|
967 |
|
paulson@13557
|
968 |
assumes a_closed: "[|x\<in>nat; y\<in>nat|] ==> M(a(x,y))"
|
paulson@13557
|
969 |
and a_rel: "Relativize2(M, nat, nat, is_a, a)"
|
paulson@13557
|
970 |
and b_closed: "[|x\<in>nat; y\<in>nat|] ==> M(b(x,y))"
|
paulson@13557
|
971 |
and b_rel: "Relativize2(M, nat, nat, is_b, b)"
|
paulson@13557
|
972 |
and c_closed: "[|x \<in> formula; y \<in> formula; M(gx); M(gy)|]
|
paulson@13557
|
973 |
==> M(c(x, y, gx, gy))"
|
paulson@13557
|
974 |
and c_rel:
|
paulson@13557
|
975 |
"M(f) ==>
|
paulson@13557
|
976 |
Relativize2 (M, formula, formula, is_c(f),
|
paulson@13557
|
977 |
\<lambda>u v. c(u, v, f ` succ(depth(u)) ` u, f ` succ(depth(v)) ` v))"
|
paulson@13557
|
978 |
and d_closed: "[|x \<in> formula; M(gx)|] ==> M(d(x, gx))"
|
paulson@13557
|
979 |
and d_rel:
|
paulson@13557
|
980 |
"M(f) ==>
|
paulson@13557
|
981 |
Relativize1(M, formula, is_d(f), \<lambda>u. d(u, f ` succ(depth(u)) ` u))"
|
paulson@13557
|
982 |
and fr_replace: "n \<in> nat ==> transrec_replacement(M,MH,n)"
|
paulson@13557
|
983 |
and fr_lam_replace:
|
paulson@13557
|
984 |
"M(g) ==>
|
paulson@13557
|
985 |
strong_replacement
|
paulson@13557
|
986 |
(M, \<lambda>x y. x \<in> formula &
|
paulson@13557
|
987 |
y = \<langle>x, formula_rec_case(a,b,c,d,g,x)\<rangle>)";
|
paulson@13557
|
988 |
|
paulson@13557
|
989 |
lemma (in Formula_Rec) formula_rec_case_closed:
|
paulson@13557
|
990 |
"[|M(g); p \<in> formula|] ==> M(formula_rec_case(a, b, c, d, g, p))"
|
paulson@13557
|
991 |
by (simp add: formula_rec_case_def a_closed b_closed c_closed d_closed)
|
paulson@13557
|
992 |
|
paulson@13557
|
993 |
lemma (in Formula_Rec) formula_rec_lam_closed:
|
paulson@13557
|
994 |
"M(g) ==> M(Lambda (formula, formula_rec_case(a,b,c,d,g)))"
|
paulson@13557
|
995 |
by (simp add: lam_closed2 fr_lam_replace formula_rec_case_closed)
|
paulson@13557
|
996 |
|
paulson@13557
|
997 |
lemma (in Formula_Rec) MH_rel2:
|
paulson@13557
|
998 |
"relativize2 (M, MH,
|
paulson@13557
|
999 |
\<lambda>x h. Lambda (formula, formula_rec_case(a,b,c,d,h)))"
|
paulson@13557
|
1000 |
apply (simp add: relativize2_def MH_def, clarify)
|
paulson@13557
|
1001 |
apply (rule lambda_abs2)
|
paulson@13557
|
1002 |
apply (rule fr_lam_replace, assumption)
|
paulson@13557
|
1003 |
apply (rule Relativize1_formula_rec_case)
|
paulson@13557
|
1004 |
apply (simp_all add: a_rel b_rel c_rel d_rel formula_rec_case_closed)
|
paulson@13557
|
1005 |
done
|
paulson@13557
|
1006 |
|
paulson@13557
|
1007 |
lemma (in Formula_Rec) fr_transrec_closed:
|
paulson@13557
|
1008 |
"n \<in> nat
|
paulson@13557
|
1009 |
==> M(transrec
|
paulson@13557
|
1010 |
(n, \<lambda>x h. Lambda(formula, formula_rec_case(a, b, c, d, h))))"
|
paulson@13557
|
1011 |
by (simp add: transrec_closed [OF fr_replace MH_rel2]
|
paulson@13557
|
1012 |
nat_into_M formula_rec_lam_closed)
|
paulson@13557
|
1013 |
|
paulson@13557
|
1014 |
text{*The main two results: @{term formula_rec} is absolute for @{term M}.*}
|
paulson@13557
|
1015 |
theorem (in Formula_Rec) formula_rec_closed:
|
paulson@13557
|
1016 |
"p \<in> formula ==> M(formula_rec(a,b,c,d,p))"
|
paulson@13557
|
1017 |
by (simp add: formula_rec_eq fr_transrec_closed
|
paulson@13557
|
1018 |
transM [OF _ formula_closed])
|
paulson@13557
|
1019 |
|
paulson@13557
|
1020 |
theorem (in Formula_Rec) formula_rec_abs:
|
paulson@13557
|
1021 |
"[| p \<in> formula; M(z)|]
|
paulson@13557
|
1022 |
==> is_formula_rec(M,MH,p,z) <-> z = formula_rec(a,b,c,d,p)"
|
paulson@13557
|
1023 |
by (simp add: is_formula_rec_def formula_rec_eq transM [OF _ formula_closed]
|
paulson@13557
|
1024 |
transrec_abs [OF fr_replace MH_rel2] depth_type
|
paulson@13557
|
1025 |
fr_transrec_closed formula_rec_lam_closed eq_commute)
|
paulson@13557
|
1026 |
|
paulson@13557
|
1027 |
|
paulson@13268
|
1028 |
end
|