src/ZF/Constructible/Rec_Separation.thy
changeset 13503 d93f41fe35d2
parent 13496 6f0c57def6d5
child 13505 52a16cb7fefb
     1.1 --- a/src/ZF/Constructible/Rec_Separation.thy	Wed Aug 14 14:33:26 2002 +0200
     1.2 +++ b/src/ZF/Constructible/Rec_Separation.thy	Thu Aug 15 21:36:26 2002 +0200
     1.3 @@ -234,151 +234,6 @@
     1.4  declare trancl_abs [simp]
     1.5  
     1.6  
     1.7 -subsection{*Well-Founded Recursion!*}
     1.8 -
     1.9 -
    1.10 -text{*Alternative definition, minimizing nesting of quantifiers around MH*}
    1.11 -lemma M_is_recfun_iff:
    1.12 -   "M_is_recfun(M,MH,r,a,f) <->
    1.13 -    (\<forall>z[M]. z \<in> f <-> 
    1.14 -     (\<exists>x[M]. \<exists>f_r_sx[M]. \<exists>y[M]. 
    1.15 -             MH(x, f_r_sx, y) & pair(M,x,y,z) &
    1.16 -             (\<exists>xa[M]. \<exists>sx[M]. \<exists>r_sx[M]. 
    1.17 -                pair(M,x,a,xa) & upair(M,x,x,sx) &
    1.18 -               pre_image(M,r,sx,r_sx) & restriction(M,f,r_sx,f_r_sx) &
    1.19 -               xa \<in> r)))"
    1.20 -apply (simp add: M_is_recfun_def)
    1.21 -apply (rule rall_cong, blast) 
    1.22 -done
    1.23 -
    1.24 -
    1.25 -(* M_is_recfun :: "[i=>o, [i,i,i]=>o, i, i, i] => o"
    1.26 -   "M_is_recfun(M,MH,r,a,f) ==
    1.27 -     \<forall>z[M]. z \<in> f <->
    1.28 -               2      1           0
    1.29 -new def     (\<exists>x[M]. \<exists>f_r_sx[M]. \<exists>y[M]. 
    1.30 -             MH(x, f_r_sx, y) & pair(M,x,y,z) &
    1.31 -             (\<exists>xa[M]. \<exists>sx[M]. \<exists>r_sx[M]. 
    1.32 -                pair(M,x,a,xa) & upair(M,x,x,sx) &
    1.33 -               pre_image(M,r,sx,r_sx) & restriction(M,f,r_sx,f_r_sx) &
    1.34 -               xa \<in> r)"
    1.35 -*)
    1.36 -
    1.37 -text{*The three arguments of @{term p} are always 2, 1, 0 and z*}
    1.38 -constdefs is_recfun_fm :: "[i, i, i, i]=>i"
    1.39 - "is_recfun_fm(p,r,a,f) == 
    1.40 -   Forall(Iff(Member(0,succ(f)),
    1.41 -    Exists(Exists(Exists(
    1.42 -     And(p, 
    1.43 -      And(pair_fm(2,0,3),
    1.44 -       Exists(Exists(Exists(
    1.45 -	And(pair_fm(5,a#+7,2),
    1.46 -	 And(upair_fm(5,5,1),
    1.47 -	  And(pre_image_fm(r#+7,1,0),
    1.48 -	   And(restriction_fm(f#+7,0,4), Member(2,r#+7)))))))))))))))"
    1.49 -
    1.50 -lemma is_recfun_type [TC]:
    1.51 -     "[| p \<in> formula; x \<in> nat; y \<in> nat; z \<in> nat |] 
    1.52 -      ==> is_recfun_fm(p,x,y,z) \<in> formula"
    1.53 -by (simp add: is_recfun_fm_def)
    1.54 -
    1.55 -
    1.56 -lemma sats_is_recfun_fm:
    1.57 -  assumes MH_iff_sats: 
    1.58 -      "!!a0 a1 a2 a3. 
    1.59 -        [|a0\<in>A; a1\<in>A; a2\<in>A; a3\<in>A|] 
    1.60 -        ==> MH(a2, a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,env)))))"
    1.61 -  shows 
    1.62 -      "[|x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
    1.63 -       ==> sats(A, is_recfun_fm(p,x,y,z), env) <->
    1.64 -           M_is_recfun(**A, MH, nth(x,env), nth(y,env), nth(z,env))"
    1.65 -by (simp add: is_recfun_fm_def M_is_recfun_iff MH_iff_sats [THEN iff_sym])
    1.66 -
    1.67 -lemma is_recfun_iff_sats:
    1.68 -  assumes MH_iff_sats: 
    1.69 -      "!!a0 a1 a2 a3. 
    1.70 -        [|a0\<in>A; a1\<in>A; a2\<in>A; a3\<in>A|] 
    1.71 -        ==> MH(a2, a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,env)))))"
    1.72 -  shows
    1.73 -  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
    1.74 -      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
    1.75 -   ==> M_is_recfun(**A, MH, x, y, z) <-> sats(A, is_recfun_fm(p,i,j,k), env)"
    1.76 -by (simp add: sats_is_recfun_fm [OF MH_iff_sats]) 
    1.77 -
    1.78 -text{*The additional variable in the premise, namely @{term f'}, is essential.
    1.79 -It lets @{term MH} depend upon @{term x}, which seems often necessary.
    1.80 -The same thing occurs in @{text is_wfrec_reflection}.*}
    1.81 -theorem is_recfun_reflection:
    1.82 -  assumes MH_reflection:
    1.83 -    "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
    1.84 -                     \<lambda>i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]"
    1.85 -  shows "REFLECTS[\<lambda>x. M_is_recfun(L, MH(L,x), f(x), g(x), h(x)), 
    1.86 -             \<lambda>i x. M_is_recfun(**Lset(i), MH(**Lset(i),x), f(x), g(x), h(x))]"
    1.87 -apply (simp (no_asm_use) only: M_is_recfun_def setclass_simps)
    1.88 -apply (intro FOL_reflections function_reflections
    1.89 -             restriction_reflection MH_reflection)
    1.90 -done
    1.91 -
    1.92 -subsubsection{*The Operator @{term is_wfrec}*}
    1.93 -
    1.94 -text{*The three arguments of @{term p} are always 2, 1, 0*}
    1.95 -
    1.96 -(* is_wfrec :: "[i=>o, i, [i,i,i]=>o, i, i] => o"
    1.97 -    "is_wfrec(M,MH,r,a,z) == 
    1.98 -      \<exists>f[M]. M_is_recfun(M,MH,r,a,f) & MH(a,f,z)" *)
    1.99 -constdefs is_wfrec_fm :: "[i, i, i, i]=>i"
   1.100 - "is_wfrec_fm(p,r,a,z) == 
   1.101 -    Exists(And(is_recfun_fm(p, succ(r), succ(a), 0),
   1.102 -           Exists(Exists(Exists(Exists(
   1.103 -             And(Equal(2,a#+5), And(Equal(1,4), And(Equal(0,z#+5), p)))))))))"
   1.104 -
   1.105 -text{*We call @{term p} with arguments a, f, z by equating them with 
   1.106 -  the corresponding quantified variables with de Bruijn indices 2, 1, 0.*}
   1.107 -
   1.108 -text{*There's an additional existential quantifier to ensure that the
   1.109 -      environments in both calls to MH have the same length.*}
   1.110 -
   1.111 -lemma is_wfrec_type [TC]:
   1.112 -     "[| p \<in> formula; x \<in> nat; y \<in> nat; z \<in> nat |] 
   1.113 -      ==> is_wfrec_fm(p,x,y,z) \<in> formula"
   1.114 -by (simp add: is_wfrec_fm_def) 
   1.115 -
   1.116 -lemma sats_is_wfrec_fm:
   1.117 -  assumes MH_iff_sats: 
   1.118 -      "!!a0 a1 a2 a3 a4. 
   1.119 -        [|a0\<in>A; a1\<in>A; a2\<in>A; a3\<in>A; a4\<in>A|] 
   1.120 -        ==> MH(a2, a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,Cons(a4,env))))))"
   1.121 -  shows 
   1.122 -      "[|x \<in> nat; y < length(env); z < length(env); env \<in> list(A)|]
   1.123 -       ==> sats(A, is_wfrec_fm(p,x,y,z), env) <-> 
   1.124 -           is_wfrec(**A, MH, nth(x,env), nth(y,env), nth(z,env))"
   1.125 -apply (frule_tac x=z in lt_length_in_nat, assumption)  
   1.126 -apply (frule lt_length_in_nat, assumption)  
   1.127 -apply (simp add: is_wfrec_fm_def sats_is_recfun_fm is_wfrec_def MH_iff_sats [THEN iff_sym], blast) 
   1.128 -done
   1.129 -
   1.130 -
   1.131 -lemma is_wfrec_iff_sats:
   1.132 -  assumes MH_iff_sats: 
   1.133 -      "!!a0 a1 a2 a3 a4. 
   1.134 -        [|a0\<in>A; a1\<in>A; a2\<in>A; a3\<in>A; a4\<in>A|] 
   1.135 -        ==> MH(a2, a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,Cons(a4,env))))))"
   1.136 -  shows
   1.137 -  "[|nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   1.138 -      i \<in> nat; j < length(env); k < length(env); env \<in> list(A)|]
   1.139 -   ==> is_wfrec(**A, MH, x, y, z) <-> sats(A, is_wfrec_fm(p,i,j,k), env)" 
   1.140 -by (simp add: sats_is_wfrec_fm [OF MH_iff_sats])
   1.141 -
   1.142 -theorem is_wfrec_reflection:
   1.143 -  assumes MH_reflection:
   1.144 -    "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
   1.145 -                     \<lambda>i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]"
   1.146 -  shows "REFLECTS[\<lambda>x. is_wfrec(L, MH(L,x), f(x), g(x), h(x)), 
   1.147 -               \<lambda>i x. is_wfrec(**Lset(i), MH(**Lset(i),x), f(x), g(x), h(x))]"
   1.148 -apply (simp (no_asm_use) only: is_wfrec_def setclass_simps)
   1.149 -apply (intro FOL_reflections MH_reflection is_recfun_reflection)
   1.150 -done
   1.151 -
   1.152  subsection{*The Locale @{text "M_wfrank"}*}
   1.153  
   1.154  subsubsection{*Separation for @{term "wfrank"}*}
   1.155 @@ -531,297 +386,8 @@
   1.156  declare wf_on_abs [simp]
   1.157  
   1.158  
   1.159 -subsection{*For Datatypes*}
   1.160 -
   1.161 -subsubsection{*Binary Products, Internalized*}
   1.162 -
   1.163 -constdefs cartprod_fm :: "[i,i,i]=>i"
   1.164 -(* "cartprod(M,A,B,z) ==
   1.165 -        \<forall>u[M]. u \<in> z <-> (\<exists>x[M]. x\<in>A & (\<exists>y[M]. y\<in>B & pair(M,x,y,u)))" *)
   1.166 -    "cartprod_fm(A,B,z) ==
   1.167 -       Forall(Iff(Member(0,succ(z)),
   1.168 -                  Exists(And(Member(0,succ(succ(A))),
   1.169 -                         Exists(And(Member(0,succ(succ(succ(B)))),
   1.170 -                                    pair_fm(1,0,2)))))))"
   1.171 -
   1.172 -lemma cartprod_type [TC]:
   1.173 -     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> cartprod_fm(x,y,z) \<in> formula"
   1.174 -by (simp add: cartprod_fm_def)
   1.175 -
   1.176 -lemma arity_cartprod_fm [simp]:
   1.177 -     "[| x \<in> nat; y \<in> nat; z \<in> nat |]
   1.178 -      ==> arity(cartprod_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   1.179 -by (simp add: cartprod_fm_def succ_Un_distrib [symmetric] Un_ac)
   1.180 -
   1.181 -lemma sats_cartprod_fm [simp]:
   1.182 -   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   1.183 -    ==> sats(A, cartprod_fm(x,y,z), env) <->
   1.184 -        cartprod(**A, nth(x,env), nth(y,env), nth(z,env))"
   1.185 -by (simp add: cartprod_fm_def cartprod_def)
   1.186 -
   1.187 -lemma cartprod_iff_sats:
   1.188 -      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
   1.189 -          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   1.190 -       ==> cartprod(**A, x, y, z) <-> sats(A, cartprod_fm(i,j,k), env)"
   1.191 -by (simp add: sats_cartprod_fm)
   1.192 -
   1.193 -theorem cartprod_reflection:
   1.194 -     "REFLECTS[\<lambda>x. cartprod(L,f(x),g(x),h(x)),
   1.195 -               \<lambda>i x. cartprod(**Lset(i),f(x),g(x),h(x))]"
   1.196 -apply (simp only: cartprod_def setclass_simps)
   1.197 -apply (intro FOL_reflections pair_reflection)
   1.198 -done
   1.199 -
   1.200 -
   1.201 -subsubsection{*Binary Sums, Internalized*}
   1.202 -
   1.203 -(* "is_sum(M,A,B,Z) ==
   1.204 -       \<exists>A0[M]. \<exists>n1[M]. \<exists>s1[M]. \<exists>B1[M].
   1.205 -         3      2       1        0
   1.206 -       number1(M,n1) & cartprod(M,n1,A,A0) & upair(M,n1,n1,s1) &
   1.207 -       cartprod(M,s1,B,B1) & union(M,A0,B1,Z)"  *)
   1.208 -constdefs sum_fm :: "[i,i,i]=>i"
   1.209 -    "sum_fm(A,B,Z) ==
   1.210 -       Exists(Exists(Exists(Exists(
   1.211 -        And(number1_fm(2),
   1.212 -            And(cartprod_fm(2,A#+4,3),
   1.213 -                And(upair_fm(2,2,1),
   1.214 -                    And(cartprod_fm(1,B#+4,0), union_fm(3,0,Z#+4)))))))))"
   1.215 -
   1.216 -lemma sum_type [TC]:
   1.217 -     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> sum_fm(x,y,z) \<in> formula"
   1.218 -by (simp add: sum_fm_def)
   1.219 -
   1.220 -lemma arity_sum_fm [simp]:
   1.221 -     "[| x \<in> nat; y \<in> nat; z \<in> nat |]
   1.222 -      ==> arity(sum_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   1.223 -by (simp add: sum_fm_def succ_Un_distrib [symmetric] Un_ac)
   1.224 -
   1.225 -lemma sats_sum_fm [simp]:
   1.226 -   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   1.227 -    ==> sats(A, sum_fm(x,y,z), env) <->
   1.228 -        is_sum(**A, nth(x,env), nth(y,env), nth(z,env))"
   1.229 -by (simp add: sum_fm_def is_sum_def)
   1.230 -
   1.231 -lemma sum_iff_sats:
   1.232 -      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
   1.233 -          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   1.234 -       ==> is_sum(**A, x, y, z) <-> sats(A, sum_fm(i,j,k), env)"
   1.235 -by simp
   1.236 -
   1.237 -theorem sum_reflection:
   1.238 -     "REFLECTS[\<lambda>x. is_sum(L,f(x),g(x),h(x)),
   1.239 -               \<lambda>i x. is_sum(**Lset(i),f(x),g(x),h(x))]"
   1.240 -apply (simp only: is_sum_def setclass_simps)
   1.241 -apply (intro FOL_reflections function_reflections cartprod_reflection)
   1.242 -done
   1.243 -
   1.244 -
   1.245 -subsubsection{*The Operator @{term quasinat}*}
   1.246 -
   1.247 -(* "is_quasinat(M,z) == empty(M,z) | (\<exists>m[M]. successor(M,m,z))" *)
   1.248 -constdefs quasinat_fm :: "i=>i"
   1.249 -    "quasinat_fm(z) == Or(empty_fm(z), Exists(succ_fm(0,succ(z))))"
   1.250 -
   1.251 -lemma quasinat_type [TC]:
   1.252 -     "x \<in> nat ==> quasinat_fm(x) \<in> formula"
   1.253 -by (simp add: quasinat_fm_def)
   1.254 -
   1.255 -lemma arity_quasinat_fm [simp]:
   1.256 -     "x \<in> nat ==> arity(quasinat_fm(x)) = succ(x)"
   1.257 -by (simp add: quasinat_fm_def succ_Un_distrib [symmetric] Un_ac)
   1.258 -
   1.259 -lemma sats_quasinat_fm [simp]:
   1.260 -   "[| x \<in> nat; env \<in> list(A)|]
   1.261 -    ==> sats(A, quasinat_fm(x), env) <-> is_quasinat(**A, nth(x,env))"
   1.262 -by (simp add: quasinat_fm_def is_quasinat_def)
   1.263 -
   1.264 -lemma quasinat_iff_sats:
   1.265 -      "[| nth(i,env) = x; nth(j,env) = y;
   1.266 -          i \<in> nat; env \<in> list(A)|]
   1.267 -       ==> is_quasinat(**A, x) <-> sats(A, quasinat_fm(i), env)"
   1.268 -by simp
   1.269 -
   1.270 -theorem quasinat_reflection:
   1.271 -     "REFLECTS[\<lambda>x. is_quasinat(L,f(x)),
   1.272 -               \<lambda>i x. is_quasinat(**Lset(i),f(x))]"
   1.273 -apply (simp only: is_quasinat_def setclass_simps)
   1.274 -apply (intro FOL_reflections function_reflections)
   1.275 -done
   1.276 -
   1.277 -
   1.278 -subsubsection{*The Operator @{term is_nat_case}*}
   1.279 -text{*I could not get it to work with the more natural assumption that 
   1.280 - @{term is_b} takes two arguments.  Instead it must be a formula where 1 and 0
   1.281 - stand for @{term m} and @{term b}, respectively.*}
   1.282 -
   1.283 -(* is_nat_case :: "[i=>o, i, [i,i]=>o, i, i] => o"
   1.284 -    "is_nat_case(M, a, is_b, k, z) ==
   1.285 -       (empty(M,k) --> z=a) &
   1.286 -       (\<forall>m[M]. successor(M,m,k) --> is_b(m,z)) &
   1.287 -       (is_quasinat(M,k) | empty(M,z))" *)
   1.288 -text{*The formula @{term is_b} has free variables 1 and 0.*}
   1.289 -constdefs is_nat_case_fm :: "[i, i, i, i]=>i"
   1.290 - "is_nat_case_fm(a,is_b,k,z) == 
   1.291 -    And(Implies(empty_fm(k), Equal(z,a)),
   1.292 -        And(Forall(Implies(succ_fm(0,succ(k)), 
   1.293 -                   Forall(Implies(Equal(0,succ(succ(z))), is_b)))),
   1.294 -            Or(quasinat_fm(k), empty_fm(z))))"
   1.295 -
   1.296 -lemma is_nat_case_type [TC]:
   1.297 -     "[| is_b \<in> formula;  
   1.298 -         x \<in> nat; y \<in> nat; z \<in> nat |] 
   1.299 -      ==> is_nat_case_fm(x,is_b,y,z) \<in> formula"
   1.300 -by (simp add: is_nat_case_fm_def)
   1.301 -
   1.302 -lemma sats_is_nat_case_fm:
   1.303 -  assumes is_b_iff_sats: 
   1.304 -      "!!a. a \<in> A ==> is_b(a,nth(z, env)) <-> 
   1.305 -                      sats(A, p, Cons(nth(z,env), Cons(a, env)))"
   1.306 -  shows 
   1.307 -      "[|x \<in> nat; y \<in> nat; z < length(env); env \<in> list(A)|]
   1.308 -       ==> sats(A, is_nat_case_fm(x,p,y,z), env) <->
   1.309 -           is_nat_case(**A, nth(x,env), is_b, nth(y,env), nth(z,env))"
   1.310 -apply (frule lt_length_in_nat, assumption)
   1.311 -apply (simp add: is_nat_case_fm_def is_nat_case_def is_b_iff_sats [THEN iff_sym])
   1.312 -done
   1.313 -
   1.314 -lemma is_nat_case_iff_sats:
   1.315 -  "[| (!!a. a \<in> A ==> is_b(a,z) <->
   1.316 -                      sats(A, p, Cons(z, Cons(a,env))));
   1.317 -      nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   1.318 -      i \<in> nat; j \<in> nat; k < length(env); env \<in> list(A)|]
   1.319 -   ==> is_nat_case(**A, x, is_b, y, z) <-> sats(A, is_nat_case_fm(i,p,j,k), env)"
   1.320 -by (simp add: sats_is_nat_case_fm [of A is_b])
   1.321 -
   1.322 -
   1.323 -text{*The second argument of @{term is_b} gives it direct access to @{term x},
   1.324 -  which is essential for handling free variable references.  Without this
   1.325 -  argument, we cannot prove reflection for @{term iterates_MH}.*}
   1.326 -theorem is_nat_case_reflection:
   1.327 -  assumes is_b_reflection:
   1.328 -    "!!h f g. REFLECTS[\<lambda>x. is_b(L, h(x), f(x), g(x)),
   1.329 -                     \<lambda>i x. is_b(**Lset(i), h(x), f(x), g(x))]"
   1.330 -  shows "REFLECTS[\<lambda>x. is_nat_case(L, f(x), is_b(L,x), g(x), h(x)),
   1.331 -               \<lambda>i x. is_nat_case(**Lset(i), f(x), is_b(**Lset(i), x), g(x), h(x))]"
   1.332 -apply (simp (no_asm_use) only: is_nat_case_def setclass_simps)
   1.333 -apply (intro FOL_reflections function_reflections
   1.334 -             restriction_reflection is_b_reflection quasinat_reflection)
   1.335 -done
   1.336 -
   1.337 -
   1.338 -
   1.339 -subsection{*The Operator @{term iterates_MH}, Needed for Iteration*}
   1.340 -
   1.341 -(*  iterates_MH :: "[i=>o, [i,i]=>o, i, i, i, i] => o"
   1.342 -   "iterates_MH(M,isF,v,n,g,z) ==
   1.343 -        is_nat_case(M, v, \<lambda>m u. \<exists>gm[M]. fun_apply(M,g,m,gm) & isF(gm,u),
   1.344 -                    n, z)" *)
   1.345 -constdefs iterates_MH_fm :: "[i, i, i, i, i]=>i"
   1.346 - "iterates_MH_fm(isF,v,n,g,z) == 
   1.347 -    is_nat_case_fm(v, 
   1.348 -      Exists(And(fun_apply_fm(succ(succ(succ(g))),2,0), 
   1.349 -                     Forall(Implies(Equal(0,2), isF)))), 
   1.350 -      n, z)"
   1.351 -
   1.352 -lemma iterates_MH_type [TC]:
   1.353 -     "[| p \<in> formula;  
   1.354 -         v \<in> nat; x \<in> nat; y \<in> nat; z \<in> nat |] 
   1.355 -      ==> iterates_MH_fm(p,v,x,y,z) \<in> formula"
   1.356 -by (simp add: iterates_MH_fm_def)
   1.357 -
   1.358 -lemma sats_iterates_MH_fm:
   1.359 -  assumes is_F_iff_sats:
   1.360 -      "!!a b c d. [| a \<in> A; b \<in> A; c \<in> A; d \<in> A|]
   1.361 -              ==> is_F(a,b) <->
   1.362 -                  sats(A, p, Cons(b, Cons(a, Cons(c, Cons(d,env)))))"
   1.363 -  shows 
   1.364 -      "[|v \<in> nat; x \<in> nat; y \<in> nat; z < length(env); env \<in> list(A)|]
   1.365 -       ==> sats(A, iterates_MH_fm(p,v,x,y,z), env) <->
   1.366 -           iterates_MH(**A, is_F, nth(v,env), nth(x,env), nth(y,env), nth(z,env))"
   1.367 -apply (frule lt_length_in_nat, assumption)  
   1.368 -apply (simp add: iterates_MH_fm_def iterates_MH_def sats_is_nat_case_fm 
   1.369 -              is_F_iff_sats [symmetric])
   1.370 -apply (rule is_nat_case_cong) 
   1.371 -apply (simp_all add: setclass_def)
   1.372 -done
   1.373 -
   1.374 -lemma iterates_MH_iff_sats:
   1.375 -  assumes is_F_iff_sats:
   1.376 -      "!!a b c d. [| a \<in> A; b \<in> A; c \<in> A; d \<in> A|]
   1.377 -              ==> is_F(a,b) <->
   1.378 -                  sats(A, p, Cons(b, Cons(a, Cons(c, Cons(d,env)))))"
   1.379 -  shows 
   1.380 -  "[| nth(i',env) = v; nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   1.381 -      i' \<in> nat; i \<in> nat; j \<in> nat; k < length(env); env \<in> list(A)|]
   1.382 -   ==> iterates_MH(**A, is_F, v, x, y, z) <->
   1.383 -       sats(A, iterates_MH_fm(p,i',i,j,k), env)"
   1.384 -by (simp add: sats_iterates_MH_fm [OF is_F_iff_sats]) 
   1.385 -
   1.386 -text{*The second argument of @{term p} gives it direct access to @{term x},
   1.387 -  which is essential for handling free variable references.  Without this
   1.388 -  argument, we cannot prove reflection for @{term list_N}.*}
   1.389 -theorem iterates_MH_reflection:
   1.390 -  assumes p_reflection:
   1.391 -    "!!f g h. REFLECTS[\<lambda>x. p(L, h(x), f(x), g(x)),
   1.392 -                     \<lambda>i x. p(**Lset(i), h(x), f(x), g(x))]"
   1.393 - shows "REFLECTS[\<lambda>x. iterates_MH(L, p(L,x), e(x), f(x), g(x), h(x)),
   1.394 -               \<lambda>i x. iterates_MH(**Lset(i), p(**Lset(i),x), e(x), f(x), g(x), h(x))]"
   1.395 -apply (simp (no_asm_use) only: iterates_MH_def)
   1.396 -txt{*Must be careful: simplifying with @{text setclass_simps} above would
   1.397 -     change @{text "\<exists>gm[**Lset(i)]"} into @{text "\<exists>gm \<in> Lset(i)"}, when
   1.398 -     it would no longer match rule @{text is_nat_case_reflection}. *}
   1.399 -apply (rule is_nat_case_reflection)
   1.400 -apply (simp (no_asm_use) only: setclass_simps)
   1.401 -apply (intro FOL_reflections function_reflections is_nat_case_reflection
   1.402 -             restriction_reflection p_reflection)
   1.403 -done
   1.404 -
   1.405 -
   1.406 -
   1.407  subsection{*@{term L} is Closed Under the Operator @{term list}*}
   1.408  
   1.409 -subsubsection{*The List Functor, Internalized*}
   1.410 -
   1.411 -constdefs list_functor_fm :: "[i,i,i]=>i"
   1.412 -(* "is_list_functor(M,A,X,Z) ==
   1.413 -        \<exists>n1[M]. \<exists>AX[M].
   1.414 -         number1(M,n1) & cartprod(M,A,X,AX) & is_sum(M,n1,AX,Z)" *)
   1.415 -    "list_functor_fm(A,X,Z) ==
   1.416 -       Exists(Exists(
   1.417 -        And(number1_fm(1),
   1.418 -            And(cartprod_fm(A#+2,X#+2,0), sum_fm(1,0,Z#+2)))))"
   1.419 -
   1.420 -lemma list_functor_type [TC]:
   1.421 -     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> list_functor_fm(x,y,z) \<in> formula"
   1.422 -by (simp add: list_functor_fm_def)
   1.423 -
   1.424 -lemma arity_list_functor_fm [simp]:
   1.425 -     "[| x \<in> nat; y \<in> nat; z \<in> nat |]
   1.426 -      ==> arity(list_functor_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   1.427 -by (simp add: list_functor_fm_def succ_Un_distrib [symmetric] Un_ac)
   1.428 -
   1.429 -lemma sats_list_functor_fm [simp]:
   1.430 -   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   1.431 -    ==> sats(A, list_functor_fm(x,y,z), env) <->
   1.432 -        is_list_functor(**A, nth(x,env), nth(y,env), nth(z,env))"
   1.433 -by (simp add: list_functor_fm_def is_list_functor_def)
   1.434 -
   1.435 -lemma list_functor_iff_sats:
   1.436 -  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
   1.437 -      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   1.438 -   ==> is_list_functor(**A, x, y, z) <-> sats(A, list_functor_fm(i,j,k), env)"
   1.439 -by simp
   1.440 -
   1.441 -theorem list_functor_reflection:
   1.442 -     "REFLECTS[\<lambda>x. is_list_functor(L,f(x),g(x),h(x)),
   1.443 -               \<lambda>i x. is_list_functor(**Lset(i),f(x),g(x),h(x))]"
   1.444 -apply (simp only: is_list_functor_def setclass_simps)
   1.445 -apply (intro FOL_reflections number1_reflection
   1.446 -             cartprod_reflection sum_reflection)
   1.447 -done
   1.448 -
   1.449 -
   1.450  subsubsection{*Instances of Replacement for Lists*}
   1.451  
   1.452  lemma list_replacement1_Reflects:
   1.453 @@ -904,48 +470,6 @@
   1.454  
   1.455  subsection{*@{term L} is Closed Under the Operator @{term formula}*}
   1.456  
   1.457 -subsubsection{*The Formula Functor, Internalized*}
   1.458 -
   1.459 -constdefs formula_functor_fm :: "[i,i]=>i"
   1.460 -(*     "is_formula_functor(M,X,Z) ==
   1.461 -        \<exists>nat'[M]. \<exists>natnat[M]. \<exists>natnatsum[M]. \<exists>XX[M]. \<exists>X3[M].
   1.462 -           4           3               2       1       0
   1.463 -          omega(M,nat') & cartprod(M,nat',nat',natnat) &
   1.464 -          is_sum(M,natnat,natnat,natnatsum) &
   1.465 -          cartprod(M,X,X,XX) & is_sum(M,XX,X,X3) &
   1.466 -          is_sum(M,natnatsum,X3,Z)" *)
   1.467 -    "formula_functor_fm(X,Z) ==
   1.468 -       Exists(Exists(Exists(Exists(Exists(
   1.469 -        And(omega_fm(4),
   1.470 -         And(cartprod_fm(4,4,3),
   1.471 -          And(sum_fm(3,3,2),
   1.472 -           And(cartprod_fm(X#+5,X#+5,1),
   1.473 -            And(sum_fm(1,X#+5,0), sum_fm(2,0,Z#+5)))))))))))"
   1.474 -
   1.475 -lemma formula_functor_type [TC]:
   1.476 -     "[| x \<in> nat; y \<in> nat |] ==> formula_functor_fm(x,y) \<in> formula"
   1.477 -by (simp add: formula_functor_fm_def)
   1.478 -
   1.479 -lemma sats_formula_functor_fm [simp]:
   1.480 -   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   1.481 -    ==> sats(A, formula_functor_fm(x,y), env) <->
   1.482 -        is_formula_functor(**A, nth(x,env), nth(y,env))"
   1.483 -by (simp add: formula_functor_fm_def is_formula_functor_def)
   1.484 -
   1.485 -lemma formula_functor_iff_sats:
   1.486 -  "[| nth(i,env) = x; nth(j,env) = y;
   1.487 -      i \<in> nat; j \<in> nat; env \<in> list(A)|]
   1.488 -   ==> is_formula_functor(**A, x, y) <-> sats(A, formula_functor_fm(i,j), env)"
   1.489 -by simp
   1.490 -
   1.491 -theorem formula_functor_reflection:
   1.492 -     "REFLECTS[\<lambda>x. is_formula_functor(L,f(x),g(x)),
   1.493 -               \<lambda>i x. is_formula_functor(**Lset(i),f(x),g(x))]"
   1.494 -apply (simp only: is_formula_functor_def setclass_simps)
   1.495 -apply (intro FOL_reflections omega_reflection
   1.496 -             cartprod_reflection sum_reflection)
   1.497 -done
   1.498 -
   1.499  subsubsection{*Instances of Replacement for Formulas*}
   1.500  
   1.501  lemma formula_replacement1_Reflects: