src/ZF/Constructible/Rec_Separation.thy
 author paulson Thu Aug 01 18:22:46 2002 +0200 (2002-08-01) changeset 13441 d6d620639243 parent 13440 cdde97e1db1c child 13493 5aa68c051725 permissions -rw-r--r--
better satisfies rules for is_recfun
A satisfies rule for is_wfrec!
 paulson@13437 ` 1` ```(* Title: ZF/Constructible/Rec_Separation.thy ``` paulson@13437 ` 2` ``` ID: \$Id\$ ``` paulson@13437 ` 3` ``` Author: Lawrence C Paulson, Cambridge University Computer Laboratory ``` paulson@13437 ` 4` ``` Copyright 2002 University of Cambridge ``` paulson@13437 ` 5` paulson@13437 ` 6` ```FIXME: define nth_fm and prove its "sats" theorem ``` paulson@13437 ` 7` ```*) ``` wenzelm@13429 ` 8` wenzelm@13429 ` 9` ```header {*Separation for Facts About Recursion*} ``` paulson@13348 ` 10` paulson@13363 ` 11` ```theory Rec_Separation = Separation + Datatype_absolute: ``` paulson@13348 ` 12` paulson@13348 ` 13` ```text{*This theory proves all instances needed for locales @{text ``` paulson@13348 ` 14` ```"M_trancl"}, @{text "M_wfrank"} and @{text "M_datatypes"}*} ``` paulson@13348 ` 15` paulson@13363 ` 16` ```lemma eq_succ_imp_lt: "[|i = succ(j); Ord(i)|] ==> jnnat[M]. \n[M]. \n'[M]. ``` paulson@13348 ` 27` ``` omega(M,nnat) & n\nnat & successor(M,n,n') & ``` paulson@13348 ` 28` ``` (\f[M]. typed_function(M,n',A,f) & ``` wenzelm@13428 ` 29` ``` (\x[M]. \y[M]. \zero[M]. pair(M,x,y,p) & empty(M,zero) & ``` wenzelm@13428 ` 30` ``` fun_apply(M,f,zero,x) & fun_apply(M,f,n,y)) & ``` wenzelm@13428 ` 31` ``` (\j[M]. j\n --> ``` wenzelm@13428 ` 32` ``` (\fj[M]. \sj[M]. \fsj[M]. \ffp[M]. ``` wenzelm@13428 ` 33` ``` fun_apply(M,f,j,fj) & successor(M,j,sj) & ``` wenzelm@13428 ` 34` ``` fun_apply(M,f,sj,fsj) & pair(M,fj,fsj,ffp) & ffp \ r)))"*) ``` paulson@13348 ` 35` ```constdefs rtran_closure_mem_fm :: "[i,i,i]=>i" ``` wenzelm@13428 ` 36` ``` "rtran_closure_mem_fm(A,r,p) == ``` paulson@13348 ` 37` ``` Exists(Exists(Exists( ``` paulson@13348 ` 38` ``` And(omega_fm(2), ``` paulson@13348 ` 39` ``` And(Member(1,2), ``` paulson@13348 ` 40` ``` And(succ_fm(1,0), ``` paulson@13348 ` 41` ``` Exists(And(typed_function_fm(1, A#+4, 0), ``` wenzelm@13428 ` 42` ``` And(Exists(Exists(Exists( ``` wenzelm@13428 ` 43` ``` And(pair_fm(2,1,p#+7), ``` wenzelm@13428 ` 44` ``` And(empty_fm(0), ``` wenzelm@13428 ` 45` ``` And(fun_apply_fm(3,0,2), fun_apply_fm(3,5,1))))))), ``` wenzelm@13428 ` 46` ``` Forall(Implies(Member(0,3), ``` wenzelm@13428 ` 47` ``` Exists(Exists(Exists(Exists( ``` wenzelm@13428 ` 48` ``` And(fun_apply_fm(5,4,3), ``` wenzelm@13428 ` 49` ``` And(succ_fm(4,2), ``` wenzelm@13428 ` 50` ``` And(fun_apply_fm(5,2,1), ``` wenzelm@13428 ` 51` ``` And(pair_fm(3,1,0), Member(0,r#+9))))))))))))))))))))" ``` paulson@13348 ` 52` paulson@13348 ` 53` paulson@13348 ` 54` ```lemma rtran_closure_mem_type [TC]: ``` paulson@13348 ` 55` ``` "[| x \ nat; y \ nat; z \ nat |] ==> rtran_closure_mem_fm(x,y,z) \ formula" ``` wenzelm@13428 ` 56` ```by (simp add: rtran_closure_mem_fm_def) ``` paulson@13348 ` 57` paulson@13348 ` 58` ```lemma arity_rtran_closure_mem_fm [simp]: ``` wenzelm@13428 ` 59` ``` "[| x \ nat; y \ nat; z \ nat |] ``` paulson@13348 ` 60` ``` ==> arity(rtran_closure_mem_fm(x,y,z)) = succ(x) \ succ(y) \ succ(z)" ``` wenzelm@13428 ` 61` ```by (simp add: rtran_closure_mem_fm_def succ_Un_distrib [symmetric] Un_ac) ``` paulson@13348 ` 62` paulson@13348 ` 63` ```lemma sats_rtran_closure_mem_fm [simp]: ``` paulson@13348 ` 64` ``` "[| x \ nat; y \ nat; z \ nat; env \ list(A)|] ``` wenzelm@13428 ` 65` ``` ==> sats(A, rtran_closure_mem_fm(x,y,z), env) <-> ``` paulson@13348 ` 66` ``` rtran_closure_mem(**A, nth(x,env), nth(y,env), nth(z,env))" ``` paulson@13348 ` 67` ```by (simp add: rtran_closure_mem_fm_def rtran_closure_mem_def) ``` paulson@13348 ` 68` paulson@13348 ` 69` ```lemma rtran_closure_mem_iff_sats: ``` wenzelm@13428 ` 70` ``` "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13348 ` 71` ``` i \ nat; j \ nat; k \ nat; env \ list(A)|] ``` paulson@13348 ` 72` ``` ==> rtran_closure_mem(**A, x, y, z) <-> sats(A, rtran_closure_mem_fm(i,j,k), env)" ``` paulson@13348 ` 73` ```by (simp add: sats_rtran_closure_mem_fm) ``` paulson@13348 ` 74` paulson@13348 ` 75` ```theorem rtran_closure_mem_reflection: ``` wenzelm@13428 ` 76` ``` "REFLECTS[\x. rtran_closure_mem(L,f(x),g(x),h(x)), ``` paulson@13348 ` 77` ``` \i x. rtran_closure_mem(**Lset(i),f(x),g(x),h(x))]" ``` paulson@13348 ` 78` ```apply (simp only: rtran_closure_mem_def setclass_simps) ``` wenzelm@13428 ` 79` ```apply (intro FOL_reflections function_reflections fun_plus_reflections) ``` paulson@13348 ` 80` ```done ``` paulson@13348 ` 81` paulson@13348 ` 82` ```text{*Separation for @{term "rtrancl(r)"}.*} ``` paulson@13348 ` 83` ```lemma rtrancl_separation: ``` paulson@13348 ` 84` ``` "[| L(r); L(A) |] ==> separation (L, rtran_closure_mem(L,A,r))" ``` wenzelm@13428 ` 85` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 86` ```apply (rule_tac A="{r,A,z}" in subset_LsetE, blast ) ``` paulson@13348 ` 87` ```apply (rule ReflectsE [OF rtran_closure_mem_reflection], assumption) ``` wenzelm@13428 ` 88` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13348 ` 89` ```apply (erule reflection_imp_L_separation) ``` paulson@13348 ` 90` ``` apply (simp_all add: lt_Ord2) ``` paulson@13385 ` 91` ```apply (rule DPow_LsetI) ``` paulson@13348 ` 92` ```apply (rename_tac u) ``` paulson@13348 ` 93` ```apply (rule_tac env = "[u,r,A]" in rtran_closure_mem_iff_sats) ``` paulson@13348 ` 94` ```apply (rule sep_rules | simp)+ ``` paulson@13348 ` 95` ```done ``` paulson@13348 ` 96` paulson@13348 ` 97` paulson@13348 ` 98` ```subsubsection{*Reflexive/Transitive Closure, Internalized*} ``` paulson@13348 ` 99` wenzelm@13428 ` 100` ```(* "rtran_closure(M,r,s) == ``` paulson@13348 ` 101` ``` \A[M]. is_field(M,r,A) --> ``` wenzelm@13428 ` 102` ``` (\p[M]. p \ s <-> rtran_closure_mem(M,A,r,p))" *) ``` paulson@13348 ` 103` ```constdefs rtran_closure_fm :: "[i,i]=>i" ``` wenzelm@13428 ` 104` ``` "rtran_closure_fm(r,s) == ``` paulson@13348 ` 105` ``` Forall(Implies(field_fm(succ(r),0), ``` paulson@13348 ` 106` ``` Forall(Iff(Member(0,succ(succ(s))), ``` paulson@13348 ` 107` ``` rtran_closure_mem_fm(1,succ(succ(r)),0)))))" ``` paulson@13348 ` 108` paulson@13348 ` 109` ```lemma rtran_closure_type [TC]: ``` paulson@13348 ` 110` ``` "[| x \ nat; y \ nat |] ==> rtran_closure_fm(x,y) \ formula" ``` wenzelm@13428 ` 111` ```by (simp add: rtran_closure_fm_def) ``` paulson@13348 ` 112` paulson@13348 ` 113` ```lemma arity_rtran_closure_fm [simp]: ``` wenzelm@13428 ` 114` ``` "[| x \ nat; y \ nat |] ``` paulson@13348 ` 115` ``` ==> arity(rtran_closure_fm(x,y)) = succ(x) \ succ(y)" ``` paulson@13348 ` 116` ```by (simp add: rtran_closure_fm_def succ_Un_distrib [symmetric] Un_ac) ``` paulson@13348 ` 117` paulson@13348 ` 118` ```lemma sats_rtran_closure_fm [simp]: ``` paulson@13348 ` 119` ``` "[| x \ nat; y \ nat; env \ list(A)|] ``` wenzelm@13428 ` 120` ``` ==> sats(A, rtran_closure_fm(x,y), env) <-> ``` paulson@13348 ` 121` ``` rtran_closure(**A, nth(x,env), nth(y,env))" ``` paulson@13348 ` 122` ```by (simp add: rtran_closure_fm_def rtran_closure_def) ``` paulson@13348 ` 123` paulson@13348 ` 124` ```lemma rtran_closure_iff_sats: ``` wenzelm@13428 ` 125` ``` "[| nth(i,env) = x; nth(j,env) = y; ``` paulson@13348 ` 126` ``` i \ nat; j \ nat; env \ list(A)|] ``` paulson@13348 ` 127` ``` ==> rtran_closure(**A, x, y) <-> sats(A, rtran_closure_fm(i,j), env)" ``` paulson@13348 ` 128` ```by simp ``` paulson@13348 ` 129` paulson@13348 ` 130` ```theorem rtran_closure_reflection: ``` wenzelm@13428 ` 131` ``` "REFLECTS[\x. rtran_closure(L,f(x),g(x)), ``` paulson@13348 ` 132` ``` \i x. rtran_closure(**Lset(i),f(x),g(x))]" ``` paulson@13348 ` 133` ```apply (simp only: rtran_closure_def setclass_simps) ``` paulson@13348 ` 134` ```apply (intro FOL_reflections function_reflections rtran_closure_mem_reflection) ``` paulson@13348 ` 135` ```done ``` paulson@13348 ` 136` paulson@13348 ` 137` paulson@13348 ` 138` ```subsubsection{*Transitive Closure of a Relation, Internalized*} ``` paulson@13348 ` 139` paulson@13348 ` 140` ```(* "tran_closure(M,r,t) == ``` paulson@13348 ` 141` ``` \s[M]. rtran_closure(M,r,s) & composition(M,r,s,t)" *) ``` paulson@13348 ` 142` ```constdefs tran_closure_fm :: "[i,i]=>i" ``` wenzelm@13428 ` 143` ``` "tran_closure_fm(r,s) == ``` paulson@13348 ` 144` ``` Exists(And(rtran_closure_fm(succ(r),0), composition_fm(succ(r),0,succ(s))))" ``` paulson@13348 ` 145` paulson@13348 ` 146` ```lemma tran_closure_type [TC]: ``` paulson@13348 ` 147` ``` "[| x \ nat; y \ nat |] ==> tran_closure_fm(x,y) \ formula" ``` wenzelm@13428 ` 148` ```by (simp add: tran_closure_fm_def) ``` paulson@13348 ` 149` paulson@13348 ` 150` ```lemma arity_tran_closure_fm [simp]: ``` wenzelm@13428 ` 151` ``` "[| x \ nat; y \ nat |] ``` paulson@13348 ` 152` ``` ==> arity(tran_closure_fm(x,y)) = succ(x) \ succ(y)" ``` paulson@13348 ` 153` ```by (simp add: tran_closure_fm_def succ_Un_distrib [symmetric] Un_ac) ``` paulson@13348 ` 154` paulson@13348 ` 155` ```lemma sats_tran_closure_fm [simp]: ``` paulson@13348 ` 156` ``` "[| x \ nat; y \ nat; env \ list(A)|] ``` wenzelm@13428 ` 157` ``` ==> sats(A, tran_closure_fm(x,y), env) <-> ``` paulson@13348 ` 158` ``` tran_closure(**A, nth(x,env), nth(y,env))" ``` paulson@13348 ` 159` ```by (simp add: tran_closure_fm_def tran_closure_def) ``` paulson@13348 ` 160` paulson@13348 ` 161` ```lemma tran_closure_iff_sats: ``` wenzelm@13428 ` 162` ``` "[| nth(i,env) = x; nth(j,env) = y; ``` paulson@13348 ` 163` ``` i \ nat; j \ nat; env \ list(A)|] ``` paulson@13348 ` 164` ``` ==> tran_closure(**A, x, y) <-> sats(A, tran_closure_fm(i,j), env)" ``` paulson@13348 ` 165` ```by simp ``` paulson@13348 ` 166` paulson@13348 ` 167` ```theorem tran_closure_reflection: ``` wenzelm@13428 ` 168` ``` "REFLECTS[\x. tran_closure(L,f(x),g(x)), ``` paulson@13348 ` 169` ``` \i x. tran_closure(**Lset(i),f(x),g(x))]" ``` paulson@13348 ` 170` ```apply (simp only: tran_closure_def setclass_simps) ``` wenzelm@13428 ` 171` ```apply (intro FOL_reflections function_reflections ``` paulson@13348 ` 172` ``` rtran_closure_reflection composition_reflection) ``` paulson@13348 ` 173` ```done ``` paulson@13348 ` 174` paulson@13348 ` 175` paulson@13348 ` 176` ```subsection{*Separation for the Proof of @{text "wellfounded_on_trancl"}*} ``` paulson@13348 ` 177` paulson@13348 ` 178` ```lemma wellfounded_trancl_reflects: ``` wenzelm@13428 ` 179` ``` "REFLECTS[\x. \w[L]. \wx[L]. \rp[L]. ``` wenzelm@13428 ` 180` ``` w \ Z & pair(L,w,x,wx) & tran_closure(L,r,rp) & wx \ rp, ``` wenzelm@13428 ` 181` ``` \i x. \w \ Lset(i). \wx \ Lset(i). \rp \ Lset(i). ``` paulson@13348 ` 182` ``` w \ Z & pair(**Lset(i),w,x,wx) & tran_closure(**Lset(i),r,rp) & ``` paulson@13348 ` 183` ``` wx \ rp]" ``` wenzelm@13428 ` 184` ```by (intro FOL_reflections function_reflections fun_plus_reflections ``` paulson@13348 ` 185` ``` tran_closure_reflection) ``` paulson@13348 ` 186` paulson@13348 ` 187` paulson@13348 ` 188` ```lemma wellfounded_trancl_separation: ``` wenzelm@13428 ` 189` ``` "[| L(r); L(Z) |] ==> ``` wenzelm@13428 ` 190` ``` separation (L, \x. ``` wenzelm@13428 ` 191` ``` \w[L]. \wx[L]. \rp[L]. ``` wenzelm@13428 ` 192` ``` w \ Z & pair(L,w,x,wx) & tran_closure(L,r,rp) & wx \ rp)" ``` wenzelm@13428 ` 193` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 194` ```apply (rule_tac A="{r,Z,z}" in subset_LsetE, blast ) ``` paulson@13348 ` 195` ```apply (rule ReflectsE [OF wellfounded_trancl_reflects], assumption) ``` wenzelm@13428 ` 196` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13348 ` 197` ```apply (erule reflection_imp_L_separation) ``` paulson@13348 ` 198` ``` apply (simp_all add: lt_Ord2) ``` paulson@13385 ` 199` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 200` ```apply (rename_tac u) ``` paulson@13348 ` 201` ```apply (rule bex_iff_sats conj_iff_sats)+ ``` wenzelm@13428 ` 202` ```apply (rule_tac env = "[w,u,r,Z]" in mem_iff_sats) ``` paulson@13348 ` 203` ```apply (rule sep_rules tran_closure_iff_sats | simp)+ ``` paulson@13348 ` 204` ```done ``` paulson@13348 ` 205` paulson@13363 ` 206` paulson@13363 ` 207` ```subsubsection{*Instantiating the locale @{text M_trancl}*} ``` wenzelm@13428 ` 208` paulson@13437 ` 209` ```lemma M_trancl_axioms_L: "M_trancl_axioms(L)" ``` wenzelm@13428 ` 210` ``` apply (rule M_trancl_axioms.intro) ``` paulson@13437 ` 211` ``` apply (assumption | rule rtrancl_separation wellfounded_trancl_separation)+ ``` wenzelm@13428 ` 212` ``` done ``` paulson@13363 ` 213` paulson@13437 ` 214` ```theorem M_trancl_L: "PROP M_trancl(L)" ``` paulson@13437 ` 215` ```by (rule M_trancl.intro ``` paulson@13437 ` 216` ``` [OF M_triv_axioms_L M_axioms_axioms_L M_trancl_axioms_L]) ``` paulson@13437 ` 217` wenzelm@13428 ` 218` ```lemmas iterates_abs = M_trancl.iterates_abs [OF M_trancl_L] ``` wenzelm@13428 ` 219` ``` and rtran_closure_rtrancl = M_trancl.rtran_closure_rtrancl [OF M_trancl_L] ``` wenzelm@13428 ` 220` ``` and rtrancl_closed = M_trancl.rtrancl_closed [OF M_trancl_L] ``` wenzelm@13428 ` 221` ``` and rtrancl_abs = M_trancl.rtrancl_abs [OF M_trancl_L] ``` wenzelm@13428 ` 222` ``` and trancl_closed = M_trancl.trancl_closed [OF M_trancl_L] ``` wenzelm@13428 ` 223` ``` and trancl_abs = M_trancl.trancl_abs [OF M_trancl_L] ``` wenzelm@13428 ` 224` ``` and wellfounded_on_trancl = M_trancl.wellfounded_on_trancl [OF M_trancl_L] ``` wenzelm@13428 ` 225` ``` and wellfounded_trancl = M_trancl.wellfounded_trancl [OF M_trancl_L] ``` wenzelm@13428 ` 226` ``` and wfrec_relativize = M_trancl.wfrec_relativize [OF M_trancl_L] ``` wenzelm@13428 ` 227` ``` and trans_wfrec_relativize = M_trancl.trans_wfrec_relativize [OF M_trancl_L] ``` wenzelm@13428 ` 228` ``` and trans_wfrec_abs = M_trancl.trans_wfrec_abs [OF M_trancl_L] ``` wenzelm@13428 ` 229` ``` and trans_eq_pair_wfrec_iff = M_trancl.trans_eq_pair_wfrec_iff [OF M_trancl_L] ``` wenzelm@13428 ` 230` ``` and eq_pair_wfrec_iff = M_trancl.eq_pair_wfrec_iff [OF M_trancl_L] ``` paulson@13363 ` 231` paulson@13363 ` 232` ```declare rtrancl_closed [intro,simp] ``` paulson@13363 ` 233` ```declare rtrancl_abs [simp] ``` paulson@13363 ` 234` ```declare trancl_closed [intro,simp] ``` paulson@13363 ` 235` ```declare trancl_abs [simp] ``` paulson@13363 ` 236` paulson@13363 ` 237` paulson@13348 ` 238` ```subsection{*Well-Founded Recursion!*} ``` paulson@13348 ` 239` paulson@13441 ` 240` paulson@13441 ` 241` ```text{*Alternative definition, minimizing nesting of quantifiers around MH*} ``` paulson@13441 ` 242` ```lemma M_is_recfun_iff: ``` paulson@13441 ` 243` ``` "M_is_recfun(M,MH,r,a,f) <-> ``` paulson@13441 ` 244` ``` (\z[M]. z \ f <-> ``` paulson@13441 ` 245` ``` (\x[M]. \f_r_sx[M]. \y[M]. ``` paulson@13441 ` 246` ``` MH(x, f_r_sx, y) & pair(M,x,y,z) & ``` paulson@13441 ` 247` ``` (\xa[M]. \sx[M]. \r_sx[M]. ``` paulson@13441 ` 248` ``` pair(M,x,a,xa) & upair(M,x,x,sx) & ``` paulson@13441 ` 249` ``` pre_image(M,r,sx,r_sx) & restriction(M,f,r_sx,f_r_sx) & ``` paulson@13441 ` 250` ``` xa \ r)))" ``` paulson@13441 ` 251` ```apply (simp add: M_is_recfun_def) ``` paulson@13441 ` 252` ```apply (rule rall_cong, blast) ``` paulson@13441 ` 253` ```done ``` paulson@13441 ` 254` paulson@13441 ` 255` paulson@13352 ` 256` ```(* M_is_recfun :: "[i=>o, [i,i,i]=>o, i, i, i] => o" ``` wenzelm@13428 ` 257` ``` "M_is_recfun(M,MH,r,a,f) == ``` wenzelm@13428 ` 258` ``` \z[M]. z \ f <-> ``` paulson@13441 ` 259` ``` 2 1 0 ``` paulson@13441 ` 260` ```new def (\x[M]. \f_r_sx[M]. \y[M]. ``` paulson@13441 ` 261` ``` MH(x, f_r_sx, y) & pair(M,x,y,z) & ``` paulson@13441 ` 262` ``` (\xa[M]. \sx[M]. \r_sx[M]. ``` paulson@13441 ` 263` ``` pair(M,x,a,xa) & upair(M,x,x,sx) & ``` paulson@13348 ` 264` ``` pre_image(M,r,sx,r_sx) & restriction(M,f,r_sx,f_r_sx) & ``` paulson@13441 ` 265` ``` xa \ r)" ``` paulson@13348 ` 266` ```*) ``` paulson@13348 ` 267` paulson@13441 ` 268` ```text{*The three arguments of @{term p} are always 2, 1, 0 and z*} ``` paulson@13434 ` 269` ```constdefs is_recfun_fm :: "[i, i, i, i]=>i" ``` paulson@13434 ` 270` ``` "is_recfun_fm(p,r,a,f) == ``` paulson@13348 ` 271` ``` Forall(Iff(Member(0,succ(f)), ``` paulson@13441 ` 272` ``` Exists(Exists(Exists( ``` paulson@13441 ` 273` ``` And(p, ``` paulson@13441 ` 274` ``` And(pair_fm(2,0,3), ``` paulson@13441 ` 275` ``` Exists(Exists(Exists( ``` paulson@13441 ` 276` ``` And(pair_fm(5,a#+7,2), ``` paulson@13441 ` 277` ``` And(upair_fm(5,5,1), ``` paulson@13441 ` 278` ``` And(pre_image_fm(r#+7,1,0), ``` paulson@13441 ` 279` ``` And(restriction_fm(f#+7,0,4), Member(2,r#+7)))))))))))))))" ``` paulson@13348 ` 280` paulson@13348 ` 281` ```lemma is_recfun_type [TC]: ``` paulson@13434 ` 282` ``` "[| p \ formula; x \ nat; y \ nat; z \ nat |] ``` paulson@13348 ` 283` ``` ==> is_recfun_fm(p,x,y,z) \ formula" ``` wenzelm@13428 ` 284` ```by (simp add: is_recfun_fm_def) ``` paulson@13348 ` 285` paulson@13441 ` 286` paulson@13348 ` 287` ```lemma sats_is_recfun_fm: ``` paulson@13434 ` 288` ``` assumes MH_iff_sats: ``` paulson@13441 ` 289` ``` "!!a0 a1 a2 a3. ``` paulson@13441 ` 290` ``` [|a0\A; a1\A; a2\A; a3\A|] ``` paulson@13441 ` 291` ``` ==> MH(a2, a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,env)))))" ``` paulson@13434 ` 292` ``` shows ``` paulson@13348 ` 293` ``` "[|x \ nat; y \ nat; z \ nat; env \ list(A)|] ``` wenzelm@13428 ` 294` ``` ==> sats(A, is_recfun_fm(p,x,y,z), env) <-> ``` paulson@13352 ` 295` ``` M_is_recfun(**A, MH, nth(x,env), nth(y,env), nth(z,env))" ``` paulson@13441 ` 296` ```by (simp add: is_recfun_fm_def M_is_recfun_iff MH_iff_sats [THEN iff_sym]) ``` paulson@13348 ` 297` paulson@13348 ` 298` ```lemma is_recfun_iff_sats: ``` paulson@13434 ` 299` ``` assumes MH_iff_sats: ``` paulson@13441 ` 300` ``` "!!a0 a1 a2 a3. ``` paulson@13441 ` 301` ``` [|a0\A; a1\A; a2\A; a3\A|] ``` paulson@13441 ` 302` ``` ==> MH(a2, a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,env)))))" ``` paulson@13434 ` 303` ``` shows ``` paulson@13434 ` 304` ``` "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13348 ` 305` ``` i \ nat; j \ nat; k \ nat; env \ list(A)|] ``` wenzelm@13428 ` 306` ``` ==> M_is_recfun(**A, MH, x, y, z) <-> sats(A, is_recfun_fm(p,i,j,k), env)" ``` paulson@13434 ` 307` ```apply (rule iff_sym) ``` paulson@13434 ` 308` ```apply (rule iff_trans) ``` paulson@13434 ` 309` ```apply (rule sats_is_recfun_fm [of A MH]) ``` paulson@13434 ` 310` ```apply (rule MH_iff_sats, simp_all) ``` paulson@13434 ` 311` ```done ``` paulson@13434 ` 312` ```(*FIXME: surely proof can be improved?*) ``` paulson@13434 ` 313` paulson@13348 ` 314` paulson@13437 ` 315` ```text{*The additional variable in the premise, namely @{term f'}, is essential. ``` paulson@13437 ` 316` ```It lets @{term MH} depend upon @{term x}, which seems often necessary. ``` paulson@13437 ` 317` ```The same thing occurs in @{text is_wfrec_reflection}.*} ``` paulson@13348 ` 318` ```theorem is_recfun_reflection: ``` paulson@13348 ` 319` ``` assumes MH_reflection: ``` paulson@13437 ` 320` ``` "!!f' f g h. REFLECTS[\x. MH(L, f'(x), f(x), g(x), h(x)), ``` paulson@13437 ` 321` ``` \i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]" ``` paulson@13437 ` 322` ``` shows "REFLECTS[\x. M_is_recfun(L, MH(L,x), f(x), g(x), h(x)), ``` paulson@13437 ` 323` ``` \i x. M_is_recfun(**Lset(i), MH(**Lset(i),x), f(x), g(x), h(x))]" ``` paulson@13348 ` 324` ```apply (simp (no_asm_use) only: M_is_recfun_def setclass_simps) ``` wenzelm@13428 ` 325` ```apply (intro FOL_reflections function_reflections ``` wenzelm@13428 ` 326` ``` restriction_reflection MH_reflection) ``` paulson@13348 ` 327` ```done ``` paulson@13348 ` 328` paulson@13441 ` 329` ```subsubsection{*The Operator @{term is_wfrec}*} ``` paulson@13441 ` 330` paulson@13441 ` 331` ```text{*The three arguments of @{term p} are always 2, 1, 0*} ``` paulson@13441 ` 332` paulson@13441 ` 333` ```(* is_wfrec :: "[i=>o, i, [i,i,i]=>o, i, i] => o" ``` paulson@13441 ` 334` ``` "is_wfrec(M,MH,r,a,z) == ``` paulson@13441 ` 335` ``` \f[M]. M_is_recfun(M,MH,r,a,f) & MH(a,f,z)" *) ``` paulson@13441 ` 336` ```constdefs is_wfrec_fm :: "[i, i, i, i]=>i" ``` paulson@13441 ` 337` ``` "is_wfrec_fm(p,r,a,z) == ``` paulson@13441 ` 338` ``` Exists(And(is_recfun_fm(p, succ(r), succ(a), 0), ``` paulson@13441 ` 339` ``` Exists(Exists(Exists(Exists( ``` paulson@13441 ` 340` ``` And(Equal(2,a#+5), And(Equal(1,4), And(Equal(0,z#+5), p)))))))))" ``` paulson@13441 ` 341` paulson@13441 ` 342` ```text{*We call @{term p} with arguments a, f, z by equating them with ``` paulson@13441 ` 343` ``` the corresponding quantified variables with de Bruijn indices 2, 1, 0.*} ``` paulson@13441 ` 344` paulson@13441 ` 345` ```text{*There's an additional existential quantifier to ensure that the ``` paulson@13441 ` 346` ``` environments in both calls to MH have the same length.*} ``` paulson@13441 ` 347` paulson@13441 ` 348` ```lemma is_wfrec_type [TC]: ``` paulson@13441 ` 349` ``` "[| p \ formula; x \ nat; y \ nat; z \ nat |] ``` paulson@13441 ` 350` ``` ==> is_wfrec_fm(p,x,y,z) \ formula" ``` paulson@13441 ` 351` ```by (simp add: is_wfrec_fm_def) ``` paulson@13441 ` 352` paulson@13441 ` 353` ```lemma sats_is_wfrec_fm: ``` paulson@13441 ` 354` ``` assumes MH_iff_sats: ``` paulson@13441 ` 355` ``` "!!a0 a1 a2 a3 a4. ``` paulson@13441 ` 356` ``` [|a0\A; a1\A; a2\A; a3\A; a4\A|] ``` paulson@13441 ` 357` ``` ==> MH(a2, a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,Cons(a4,env))))))" ``` paulson@13441 ` 358` ``` shows ``` paulson@13441 ` 359` ``` "[|x \ nat; y < length(env); z < length(env); env \ list(A)|] ``` paulson@13441 ` 360` ``` ==> sats(A, is_wfrec_fm(p,x,y,z), env) <-> ``` paulson@13441 ` 361` ``` is_wfrec(**A, MH, nth(x,env), nth(y,env), nth(z,env))" ``` paulson@13441 ` 362` ```apply (frule_tac x=z in lt_length_in_nat, assumption) ``` paulson@13441 ` 363` ```apply (frule lt_length_in_nat, assumption) ``` paulson@13441 ` 364` ```apply (simp add: is_wfrec_fm_def sats_is_recfun_fm is_wfrec_def MH_iff_sats [THEN iff_sym], blast) ``` paulson@13441 ` 365` ```done ``` paulson@13441 ` 366` paulson@13441 ` 367` paulson@13441 ` 368` ```lemma is_wfrec_iff_sats: ``` paulson@13441 ` 369` ``` assumes MH_iff_sats: ``` paulson@13441 ` 370` ``` "!!a0 a1 a2 a3 a4. ``` paulson@13441 ` 371` ``` [|a0\A; a1\A; a2\A; a3\A; a4\A|] ``` paulson@13441 ` 372` ``` ==> MH(a2, a1, a0) <-> sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,Cons(a4,env))))))" ``` paulson@13441 ` 373` ``` shows ``` paulson@13441 ` 374` ``` "[|nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13441 ` 375` ``` i \ nat; j < length(env); k < length(env); env \ list(A)|] ``` paulson@13441 ` 376` ``` ==> is_wfrec(**A, MH, x, y, z) <-> sats(A, is_wfrec_fm(p,i,j,k), env)" ``` paulson@13441 ` 377` ```by (simp add: sats_is_wfrec_fm [OF MH_iff_sats]) ``` paulson@13441 ` 378` paulson@13363 ` 379` ```theorem is_wfrec_reflection: ``` paulson@13363 ` 380` ``` assumes MH_reflection: ``` paulson@13437 ` 381` ``` "!!f' f g h. REFLECTS[\x. MH(L, f'(x), f(x), g(x), h(x)), ``` paulson@13437 ` 382` ``` \i x. MH(**Lset(i), f'(x), f(x), g(x), h(x))]" ``` paulson@13437 ` 383` ``` shows "REFLECTS[\x. is_wfrec(L, MH(L,x), f(x), g(x), h(x)), ``` paulson@13437 ` 384` ``` \i x. is_wfrec(**Lset(i), MH(**Lset(i),x), f(x), g(x), h(x))]" ``` paulson@13363 ` 385` ```apply (simp (no_asm_use) only: is_wfrec_def setclass_simps) ``` wenzelm@13428 ` 386` ```apply (intro FOL_reflections MH_reflection is_recfun_reflection) ``` paulson@13363 ` 387` ```done ``` paulson@13363 ` 388` paulson@13363 ` 389` ```subsection{*The Locale @{text "M_wfrank"}*} ``` paulson@13363 ` 390` paulson@13363 ` 391` ```subsubsection{*Separation for @{term "wfrank"}*} ``` paulson@13348 ` 392` paulson@13348 ` 393` ```lemma wfrank_Reflects: ``` paulson@13348 ` 394` ``` "REFLECTS[\x. \rplus[L]. tran_closure(L,r,rplus) --> ``` paulson@13352 ` 395` ``` ~ (\f[L]. M_is_recfun(L, %x f y. is_range(L,f,y), rplus, x, f)), ``` paulson@13348 ` 396` ``` \i x. \rplus \ Lset(i). tran_closure(**Lset(i),r,rplus) --> ``` wenzelm@13428 ` 397` ``` ~ (\f \ Lset(i). ``` wenzelm@13428 ` 398` ``` M_is_recfun(**Lset(i), %x f y. is_range(**Lset(i),f,y), ``` paulson@13352 ` 399` ``` rplus, x, f))]" ``` wenzelm@13428 ` 400` ```by (intro FOL_reflections function_reflections is_recfun_reflection tran_closure_reflection) ``` paulson@13348 ` 401` paulson@13348 ` 402` ```lemma wfrank_separation: ``` paulson@13348 ` 403` ``` "L(r) ==> ``` paulson@13348 ` 404` ``` separation (L, \x. \rplus[L]. tran_closure(L,r,rplus) --> ``` paulson@13352 ` 405` ``` ~ (\f[L]. M_is_recfun(L, %x f y. is_range(L,f,y), rplus, x, f)))" ``` wenzelm@13428 ` 406` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 407` ```apply (rule_tac A="{r,z}" in subset_LsetE, blast ) ``` paulson@13348 ` 408` ```apply (rule ReflectsE [OF wfrank_Reflects], assumption) ``` wenzelm@13428 ` 409` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13348 ` 410` ```apply (erule reflection_imp_L_separation) ``` paulson@13348 ` 411` ``` apply (simp_all add: lt_Ord2, clarify) ``` paulson@13385 ` 412` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 413` ```apply (rename_tac u) ``` paulson@13348 ` 414` ```apply (rule ball_iff_sats imp_iff_sats)+ ``` paulson@13348 ` 415` ```apply (rule_tac env="[rplus,u,r]" in tran_closure_iff_sats) ``` paulson@13441 ` 416` ```apply (rule sep_rules | simp)+ ``` paulson@13348 ` 417` ```apply (rule sep_rules is_recfun_iff_sats | simp)+ ``` paulson@13348 ` 418` ```done ``` paulson@13348 ` 419` paulson@13348 ` 420` paulson@13363 ` 421` ```subsubsection{*Replacement for @{term "wfrank"}*} ``` paulson@13348 ` 422` paulson@13348 ` 423` ```lemma wfrank_replacement_Reflects: ``` wenzelm@13428 ` 424` ``` "REFLECTS[\z. \x[L]. x \ A & ``` paulson@13348 ` 425` ``` (\rplus[L]. tran_closure(L,r,rplus) --> ``` wenzelm@13428 ` 426` ``` (\y[L]. \f[L]. pair(L,x,y,z) & ``` paulson@13352 ` 427` ``` M_is_recfun(L, %x f y. is_range(L,f,y), rplus, x, f) & ``` paulson@13348 ` 428` ``` is_range(L,f,y))), ``` wenzelm@13428 ` 429` ``` \i z. \x \ Lset(i). x \ A & ``` paulson@13348 ` 430` ``` (\rplus \ Lset(i). tran_closure(**Lset(i),r,rplus) --> ``` wenzelm@13428 ` 431` ``` (\y \ Lset(i). \f \ Lset(i). pair(**Lset(i),x,y,z) & ``` paulson@13352 ` 432` ``` M_is_recfun(**Lset(i), %x f y. is_range(**Lset(i),f,y), rplus, x, f) & ``` paulson@13348 ` 433` ``` is_range(**Lset(i),f,y)))]" ``` paulson@13348 ` 434` ```by (intro FOL_reflections function_reflections fun_plus_reflections ``` paulson@13348 ` 435` ``` is_recfun_reflection tran_closure_reflection) ``` paulson@13348 ` 436` paulson@13348 ` 437` paulson@13348 ` 438` ```lemma wfrank_strong_replacement: ``` paulson@13348 ` 439` ``` "L(r) ==> ``` wenzelm@13428 ` 440` ``` strong_replacement(L, \x z. ``` paulson@13348 ` 441` ``` \rplus[L]. tran_closure(L,r,rplus) --> ``` wenzelm@13428 ` 442` ``` (\y[L]. \f[L]. pair(L,x,y,z) & ``` paulson@13352 ` 443` ``` M_is_recfun(L, %x f y. is_range(L,f,y), rplus, x, f) & ``` paulson@13348 ` 444` ``` is_range(L,f,y)))" ``` wenzelm@13428 ` 445` ```apply (rule strong_replacementI) ``` paulson@13348 ` 446` ```apply (rule rallI) ``` wenzelm@13428 ` 447` ```apply (rename_tac B) ``` wenzelm@13428 ` 448` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 449` ```apply (rule_tac A="{B,r,z}" in subset_LsetE, blast ) ``` paulson@13348 ` 450` ```apply (rule ReflectsE [OF wfrank_replacement_Reflects], assumption) ``` wenzelm@13428 ` 451` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13348 ` 452` ```apply (erule reflection_imp_L_separation) ``` paulson@13348 ` 453` ``` apply (simp_all add: lt_Ord2) ``` paulson@13385 ` 454` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 455` ```apply (rename_tac u) ``` paulson@13348 ` 456` ```apply (rule bex_iff_sats ball_iff_sats conj_iff_sats)+ ``` wenzelm@13428 ` 457` ```apply (rule_tac env = "[x,u,B,r]" in mem_iff_sats) ``` paulson@13441 ` 458` ```apply (rule sep_rules list.intros app_type tran_closure_iff_sats is_recfun_iff_sats | simp)+ ``` paulson@13348 ` 459` ```done ``` paulson@13348 ` 460` paulson@13348 ` 461` paulson@13363 ` 462` ```subsubsection{*Separation for Proving @{text Ord_wfrank_range}*} ``` paulson@13348 ` 463` paulson@13348 ` 464` ```lemma Ord_wfrank_Reflects: ``` wenzelm@13428 ` 465` ``` "REFLECTS[\x. \rplus[L]. tran_closure(L,r,rplus) --> ``` wenzelm@13428 ` 466` ``` ~ (\f[L]. \rangef[L]. ``` paulson@13348 ` 467` ``` is_range(L,f,rangef) --> ``` paulson@13352 ` 468` ``` M_is_recfun(L, \x f y. is_range(L,f,y), rplus, x, f) --> ``` paulson@13348 ` 469` ``` ordinal(L,rangef)), ``` wenzelm@13428 ` 470` ``` \i x. \rplus \ Lset(i). tran_closure(**Lset(i),r,rplus) --> ``` wenzelm@13428 ` 471` ``` ~ (\f \ Lset(i). \rangef \ Lset(i). ``` paulson@13348 ` 472` ``` is_range(**Lset(i),f,rangef) --> ``` wenzelm@13428 ` 473` ``` M_is_recfun(**Lset(i), \x f y. is_range(**Lset(i),f,y), ``` paulson@13352 ` 474` ``` rplus, x, f) --> ``` paulson@13348 ` 475` ``` ordinal(**Lset(i),rangef))]" ``` wenzelm@13428 ` 476` ```by (intro FOL_reflections function_reflections is_recfun_reflection ``` paulson@13348 ` 477` ``` tran_closure_reflection ordinal_reflection) ``` paulson@13348 ` 478` paulson@13348 ` 479` ```lemma Ord_wfrank_separation: ``` paulson@13348 ` 480` ``` "L(r) ==> ``` paulson@13348 ` 481` ``` separation (L, \x. ``` wenzelm@13428 ` 482` ``` \rplus[L]. tran_closure(L,r,rplus) --> ``` wenzelm@13428 ` 483` ``` ~ (\f[L]. \rangef[L]. ``` paulson@13348 ` 484` ``` is_range(L,f,rangef) --> ``` paulson@13352 ` 485` ``` M_is_recfun(L, \x f y. is_range(L,f,y), rplus, x, f) --> ``` wenzelm@13428 ` 486` ``` ordinal(L,rangef)))" ``` wenzelm@13428 ` 487` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 488` ```apply (rule_tac A="{r,z}" in subset_LsetE, blast ) ``` paulson@13348 ` 489` ```apply (rule ReflectsE [OF Ord_wfrank_Reflects], assumption) ``` wenzelm@13428 ` 490` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13348 ` 491` ```apply (erule reflection_imp_L_separation) ``` paulson@13348 ` 492` ``` apply (simp_all add: lt_Ord2, clarify) ``` paulson@13385 ` 493` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 494` ```apply (rename_tac u) ``` paulson@13348 ` 495` ```apply (rule ball_iff_sats imp_iff_sats)+ ``` paulson@13348 ` 496` ```apply (rule_tac env="[rplus,u,r]" in tran_closure_iff_sats) ``` paulson@13348 ` 497` ```apply (rule sep_rules is_recfun_iff_sats | simp)+ ``` paulson@13348 ` 498` ```done ``` paulson@13348 ` 499` paulson@13348 ` 500` paulson@13363 ` 501` ```subsubsection{*Instantiating the locale @{text M_wfrank}*} ``` wenzelm@13428 ` 502` paulson@13437 ` 503` ```lemma M_wfrank_axioms_L: "M_wfrank_axioms(L)" ``` paulson@13437 ` 504` ``` apply (rule M_wfrank_axioms.intro) ``` paulson@13437 ` 505` ``` apply (assumption | rule ``` paulson@13437 ` 506` ``` wfrank_separation wfrank_strong_replacement Ord_wfrank_separation)+ ``` paulson@13437 ` 507` ``` done ``` paulson@13437 ` 508` wenzelm@13428 ` 509` ```theorem M_wfrank_L: "PROP M_wfrank(L)" ``` wenzelm@13428 ` 510` ``` apply (rule M_wfrank.intro) ``` wenzelm@13429 ` 511` ``` apply (rule M_trancl.axioms [OF M_trancl_L])+ ``` paulson@13437 ` 512` ``` apply (rule M_wfrank_axioms_L) ``` wenzelm@13428 ` 513` ``` done ``` paulson@13363 ` 514` wenzelm@13428 ` 515` ```lemmas iterates_closed = M_wfrank.iterates_closed [OF M_wfrank_L] ``` wenzelm@13428 ` 516` ``` and exists_wfrank = M_wfrank.exists_wfrank [OF M_wfrank_L] ``` wenzelm@13428 ` 517` ``` and M_wellfoundedrank = M_wfrank.M_wellfoundedrank [OF M_wfrank_L] ``` wenzelm@13428 ` 518` ``` and Ord_wfrank_range = M_wfrank.Ord_wfrank_range [OF M_wfrank_L] ``` wenzelm@13428 ` 519` ``` and Ord_range_wellfoundedrank = M_wfrank.Ord_range_wellfoundedrank [OF M_wfrank_L] ``` wenzelm@13428 ` 520` ``` and function_wellfoundedrank = M_wfrank.function_wellfoundedrank [OF M_wfrank_L] ``` wenzelm@13428 ` 521` ``` and domain_wellfoundedrank = M_wfrank.domain_wellfoundedrank [OF M_wfrank_L] ``` wenzelm@13428 ` 522` ``` and wellfoundedrank_type = M_wfrank.wellfoundedrank_type [OF M_wfrank_L] ``` wenzelm@13428 ` 523` ``` and Ord_wellfoundedrank = M_wfrank.Ord_wellfoundedrank [OF M_wfrank_L] ``` wenzelm@13428 ` 524` ``` and wellfoundedrank_eq = M_wfrank.wellfoundedrank_eq [OF M_wfrank_L] ``` wenzelm@13428 ` 525` ``` and wellfoundedrank_lt = M_wfrank.wellfoundedrank_lt [OF M_wfrank_L] ``` wenzelm@13428 ` 526` ``` and wellfounded_imp_subset_rvimage = M_wfrank.wellfounded_imp_subset_rvimage [OF M_wfrank_L] ``` wenzelm@13428 ` 527` ``` and wellfounded_imp_wf = M_wfrank.wellfounded_imp_wf [OF M_wfrank_L] ``` wenzelm@13428 ` 528` ``` and wellfounded_on_imp_wf_on = M_wfrank.wellfounded_on_imp_wf_on [OF M_wfrank_L] ``` wenzelm@13428 ` 529` ``` and wf_abs = M_wfrank.wf_abs [OF M_wfrank_L] ``` wenzelm@13428 ` 530` ``` and wf_on_abs = M_wfrank.wf_on_abs [OF M_wfrank_L] ``` wenzelm@13428 ` 531` ``` and wfrec_replacement_iff = M_wfrank.wfrec_replacement_iff [OF M_wfrank_L] ``` wenzelm@13428 ` 532` ``` and trans_wfrec_closed = M_wfrank.trans_wfrec_closed [OF M_wfrank_L] ``` wenzelm@13428 ` 533` ``` and wfrec_closed = M_wfrank.wfrec_closed [OF M_wfrank_L] ``` paulson@13363 ` 534` paulson@13363 ` 535` ```declare iterates_closed [intro,simp] ``` paulson@13363 ` 536` ```declare Ord_wfrank_range [rule_format] ``` paulson@13363 ` 537` ```declare wf_abs [simp] ``` paulson@13363 ` 538` ```declare wf_on_abs [simp] ``` paulson@13363 ` 539` paulson@13363 ` 540` paulson@13363 ` 541` ```subsection{*For Datatypes*} ``` paulson@13363 ` 542` paulson@13363 ` 543` ```subsubsection{*Binary Products, Internalized*} ``` paulson@13363 ` 544` paulson@13363 ` 545` ```constdefs cartprod_fm :: "[i,i,i]=>i" ``` wenzelm@13428 ` 546` ```(* "cartprod(M,A,B,z) == ``` wenzelm@13428 ` 547` ``` \u[M]. u \ z <-> (\x[M]. x\A & (\y[M]. y\B & pair(M,x,y,u)))" *) ``` wenzelm@13428 ` 548` ``` "cartprod_fm(A,B,z) == ``` paulson@13363 ` 549` ``` Forall(Iff(Member(0,succ(z)), ``` paulson@13363 ` 550` ``` Exists(And(Member(0,succ(succ(A))), ``` paulson@13363 ` 551` ``` Exists(And(Member(0,succ(succ(succ(B)))), ``` paulson@13363 ` 552` ``` pair_fm(1,0,2)))))))" ``` paulson@13363 ` 553` paulson@13363 ` 554` ```lemma cartprod_type [TC]: ``` paulson@13363 ` 555` ``` "[| x \ nat; y \ nat; z \ nat |] ==> cartprod_fm(x,y,z) \ formula" ``` wenzelm@13428 ` 556` ```by (simp add: cartprod_fm_def) ``` paulson@13363 ` 557` paulson@13363 ` 558` ```lemma arity_cartprod_fm [simp]: ``` wenzelm@13428 ` 559` ``` "[| x \ nat; y \ nat; z \ nat |] ``` paulson@13363 ` 560` ``` ==> arity(cartprod_fm(x,y,z)) = succ(x) \ succ(y) \ succ(z)" ``` wenzelm@13428 ` 561` ```by (simp add: cartprod_fm_def succ_Un_distrib [symmetric] Un_ac) ``` paulson@13363 ` 562` paulson@13363 ` 563` ```lemma sats_cartprod_fm [simp]: ``` paulson@13363 ` 564` ``` "[| x \ nat; y \ nat; z \ nat; env \ list(A)|] ``` wenzelm@13428 ` 565` ``` ==> sats(A, cartprod_fm(x,y,z), env) <-> ``` paulson@13363 ` 566` ``` cartprod(**A, nth(x,env), nth(y,env), nth(z,env))" ``` paulson@13363 ` 567` ```by (simp add: cartprod_fm_def cartprod_def) ``` paulson@13363 ` 568` paulson@13363 ` 569` ```lemma cartprod_iff_sats: ``` wenzelm@13428 ` 570` ``` "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13363 ` 571` ``` i \ nat; j \ nat; k \ nat; env \ list(A)|] ``` paulson@13363 ` 572` ``` ==> cartprod(**A, x, y, z) <-> sats(A, cartprod_fm(i,j,k), env)" ``` paulson@13363 ` 573` ```by (simp add: sats_cartprod_fm) ``` paulson@13363 ` 574` paulson@13363 ` 575` ```theorem cartprod_reflection: ``` wenzelm@13428 ` 576` ``` "REFLECTS[\x. cartprod(L,f(x),g(x),h(x)), ``` paulson@13363 ` 577` ``` \i x. cartprod(**Lset(i),f(x),g(x),h(x))]" ``` paulson@13363 ` 578` ```apply (simp only: cartprod_def setclass_simps) ``` wenzelm@13428 ` 579` ```apply (intro FOL_reflections pair_reflection) ``` paulson@13363 ` 580` ```done ``` paulson@13363 ` 581` paulson@13363 ` 582` paulson@13363 ` 583` ```subsubsection{*Binary Sums, Internalized*} ``` paulson@13363 ` 584` wenzelm@13428 ` 585` ```(* "is_sum(M,A,B,Z) == ``` wenzelm@13428 ` 586` ``` \A0[M]. \n1[M]. \s1[M]. \B1[M]. ``` paulson@13363 ` 587` ``` 3 2 1 0 ``` paulson@13363 ` 588` ``` number1(M,n1) & cartprod(M,n1,A,A0) & upair(M,n1,n1,s1) & ``` paulson@13363 ` 589` ``` cartprod(M,s1,B,B1) & union(M,A0,B1,Z)" *) ``` paulson@13363 ` 590` ```constdefs sum_fm :: "[i,i,i]=>i" ``` wenzelm@13428 ` 591` ``` "sum_fm(A,B,Z) == ``` paulson@13363 ` 592` ``` Exists(Exists(Exists(Exists( ``` wenzelm@13428 ` 593` ``` And(number1_fm(2), ``` paulson@13363 ` 594` ``` And(cartprod_fm(2,A#+4,3), ``` paulson@13363 ` 595` ``` And(upair_fm(2,2,1), ``` paulson@13363 ` 596` ``` And(cartprod_fm(1,B#+4,0), union_fm(3,0,Z#+4)))))))))" ``` paulson@13363 ` 597` paulson@13363 ` 598` ```lemma sum_type [TC]: ``` paulson@13363 ` 599` ``` "[| x \ nat; y \ nat; z \ nat |] ==> sum_fm(x,y,z) \ formula" ``` wenzelm@13428 ` 600` ```by (simp add: sum_fm_def) ``` paulson@13363 ` 601` paulson@13363 ` 602` ```lemma arity_sum_fm [simp]: ``` wenzelm@13428 ` 603` ``` "[| x \ nat; y \ nat; z \ nat |] ``` paulson@13363 ` 604` ``` ==> arity(sum_fm(x,y,z)) = succ(x) \ succ(y) \ succ(z)" ``` wenzelm@13428 ` 605` ```by (simp add: sum_fm_def succ_Un_distrib [symmetric] Un_ac) ``` paulson@13363 ` 606` paulson@13363 ` 607` ```lemma sats_sum_fm [simp]: ``` paulson@13363 ` 608` ``` "[| x \ nat; y \ nat; z \ nat; env \ list(A)|] ``` wenzelm@13428 ` 609` ``` ==> sats(A, sum_fm(x,y,z), env) <-> ``` paulson@13363 ` 610` ``` is_sum(**A, nth(x,env), nth(y,env), nth(z,env))" ``` paulson@13363 ` 611` ```by (simp add: sum_fm_def is_sum_def) ``` paulson@13363 ` 612` paulson@13363 ` 613` ```lemma sum_iff_sats: ``` wenzelm@13428 ` 614` ``` "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13363 ` 615` ``` i \ nat; j \ nat; k \ nat; env \ list(A)|] ``` paulson@13363 ` 616` ``` ==> is_sum(**A, x, y, z) <-> sats(A, sum_fm(i,j,k), env)" ``` paulson@13363 ` 617` ```by simp ``` paulson@13363 ` 618` paulson@13363 ` 619` ```theorem sum_reflection: ``` wenzelm@13428 ` 620` ``` "REFLECTS[\x. is_sum(L,f(x),g(x),h(x)), ``` paulson@13363 ` 621` ``` \i x. is_sum(**Lset(i),f(x),g(x),h(x))]" ``` paulson@13363 ` 622` ```apply (simp only: is_sum_def setclass_simps) ``` wenzelm@13428 ` 623` ```apply (intro FOL_reflections function_reflections cartprod_reflection) ``` paulson@13363 ` 624` ```done ``` paulson@13363 ` 625` paulson@13363 ` 626` paulson@13363 ` 627` ```subsubsection{*The Operator @{term quasinat}*} ``` paulson@13363 ` 628` paulson@13363 ` 629` ```(* "is_quasinat(M,z) == empty(M,z) | (\m[M]. successor(M,m,z))" *) ``` paulson@13363 ` 630` ```constdefs quasinat_fm :: "i=>i" ``` paulson@13363 ` 631` ``` "quasinat_fm(z) == Or(empty_fm(z), Exists(succ_fm(0,succ(z))))" ``` paulson@13363 ` 632` paulson@13363 ` 633` ```lemma quasinat_type [TC]: ``` paulson@13363 ` 634` ``` "x \ nat ==> quasinat_fm(x) \ formula" ``` wenzelm@13428 ` 635` ```by (simp add: quasinat_fm_def) ``` paulson@13363 ` 636` paulson@13363 ` 637` ```lemma arity_quasinat_fm [simp]: ``` paulson@13363 ` 638` ``` "x \ nat ==> arity(quasinat_fm(x)) = succ(x)" ``` wenzelm@13428 ` 639` ```by (simp add: quasinat_fm_def succ_Un_distrib [symmetric] Un_ac) ``` paulson@13363 ` 640` paulson@13363 ` 641` ```lemma sats_quasinat_fm [simp]: ``` paulson@13363 ` 642` ``` "[| x \ nat; env \ list(A)|] ``` paulson@13363 ` 643` ``` ==> sats(A, quasinat_fm(x), env) <-> is_quasinat(**A, nth(x,env))" ``` paulson@13363 ` 644` ```by (simp add: quasinat_fm_def is_quasinat_def) ``` paulson@13363 ` 645` paulson@13363 ` 646` ```lemma quasinat_iff_sats: ``` wenzelm@13428 ` 647` ``` "[| nth(i,env) = x; nth(j,env) = y; ``` paulson@13363 ` 648` ``` i \ nat; env \ list(A)|] ``` paulson@13363 ` 649` ``` ==> is_quasinat(**A, x) <-> sats(A, quasinat_fm(i), env)" ``` paulson@13363 ` 650` ```by simp ``` paulson@13363 ` 651` paulson@13363 ` 652` ```theorem quasinat_reflection: ``` wenzelm@13428 ` 653` ``` "REFLECTS[\x. is_quasinat(L,f(x)), ``` paulson@13363 ` 654` ``` \i x. is_quasinat(**Lset(i),f(x))]" ``` paulson@13363 ` 655` ```apply (simp only: is_quasinat_def setclass_simps) ``` wenzelm@13428 ` 656` ```apply (intro FOL_reflections function_reflections) ``` paulson@13363 ` 657` ```done ``` paulson@13363 ` 658` paulson@13363 ` 659` paulson@13363 ` 660` ```subsubsection{*The Operator @{term is_nat_case}*} ``` paulson@13434 ` 661` ```text{*I could not get it to work with the more natural assumption that ``` paulson@13434 ` 662` ``` @{term is_b} takes two arguments. Instead it must be a formula where 1 and 0 ``` paulson@13434 ` 663` ``` stand for @{term m} and @{term b}, respectively.*} ``` paulson@13363 ` 664` paulson@13363 ` 665` ```(* is_nat_case :: "[i=>o, i, [i,i]=>o, i, i] => o" ``` wenzelm@13428 ` 666` ``` "is_nat_case(M, a, is_b, k, z) == ``` paulson@13363 ` 667` ``` (empty(M,k) --> z=a) & ``` paulson@13363 ` 668` ``` (\m[M]. successor(M,m,k) --> is_b(m,z)) & ``` paulson@13363 ` 669` ``` (is_quasinat(M,k) | empty(M,z))" *) ``` paulson@13363 ` 670` ```text{*The formula @{term is_b} has free variables 1 and 0.*} ``` paulson@13434 ` 671` ```constdefs is_nat_case_fm :: "[i, i, i, i]=>i" ``` paulson@13434 ` 672` ``` "is_nat_case_fm(a,is_b,k,z) == ``` paulson@13363 ` 673` ``` And(Implies(empty_fm(k), Equal(z,a)), ``` paulson@13434 ` 674` ``` And(Forall(Implies(succ_fm(0,succ(k)), ``` paulson@13434 ` 675` ``` Forall(Implies(Equal(0,succ(succ(z))), is_b)))), ``` paulson@13363 ` 676` ``` Or(quasinat_fm(k), empty_fm(z))))" ``` paulson@13363 ` 677` paulson@13363 ` 678` ```lemma is_nat_case_type [TC]: ``` paulson@13434 ` 679` ``` "[| is_b \ formula; ``` paulson@13434 ` 680` ``` x \ nat; y \ nat; z \ nat |] ``` paulson@13363 ` 681` ``` ==> is_nat_case_fm(x,is_b,y,z) \ formula" ``` wenzelm@13428 ` 682` ```by (simp add: is_nat_case_fm_def) ``` paulson@13363 ` 683` paulson@13363 ` 684` ```lemma sats_is_nat_case_fm: ``` paulson@13434 ` 685` ``` assumes is_b_iff_sats: ``` paulson@13434 ` 686` ``` "!!a. a \ A ==> is_b(a,nth(z, env)) <-> ``` paulson@13434 ` 687` ``` sats(A, p, Cons(nth(z,env), Cons(a, env)))" ``` paulson@13434 ` 688` ``` shows ``` paulson@13363 ` 689` ``` "[|x \ nat; y \ nat; z < length(env); env \ list(A)|] ``` wenzelm@13428 ` 690` ``` ==> sats(A, is_nat_case_fm(x,p,y,z), env) <-> ``` paulson@13363 ` 691` ``` is_nat_case(**A, nth(x,env), is_b, nth(y,env), nth(z,env))" ``` wenzelm@13428 ` 692` ```apply (frule lt_length_in_nat, assumption) ``` paulson@13363 ` 693` ```apply (simp add: is_nat_case_fm_def is_nat_case_def is_b_iff_sats [THEN iff_sym]) ``` paulson@13363 ` 694` ```done ``` paulson@13363 ` 695` paulson@13363 ` 696` ```lemma is_nat_case_iff_sats: ``` paulson@13434 ` 697` ``` "[| (!!a. a \ A ==> is_b(a,z) <-> ``` paulson@13434 ` 698` ``` sats(A, p, Cons(z, Cons(a,env)))); ``` paulson@13434 ` 699` ``` nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13363 ` 700` ``` i \ nat; j \ nat; k < length(env); env \ list(A)|] ``` wenzelm@13428 ` 701` ``` ==> is_nat_case(**A, x, is_b, y, z) <-> sats(A, is_nat_case_fm(i,p,j,k), env)" ``` paulson@13363 ` 702` ```by (simp add: sats_is_nat_case_fm [of A is_b]) ``` paulson@13363 ` 703` paulson@13363 ` 704` paulson@13363 ` 705` ```text{*The second argument of @{term is_b} gives it direct access to @{term x}, ``` wenzelm@13428 ` 706` ``` which is essential for handling free variable references. Without this ``` paulson@13363 ` 707` ``` argument, we cannot prove reflection for @{term iterates_MH}.*} ``` paulson@13363 ` 708` ```theorem is_nat_case_reflection: ``` paulson@13363 ` 709` ``` assumes is_b_reflection: ``` wenzelm@13428 ` 710` ``` "!!h f g. REFLECTS[\x. is_b(L, h(x), f(x), g(x)), ``` paulson@13363 ` 711` ``` \i x. is_b(**Lset(i), h(x), f(x), g(x))]" ``` wenzelm@13428 ` 712` ``` shows "REFLECTS[\x. is_nat_case(L, f(x), is_b(L,x), g(x), h(x)), ``` paulson@13363 ` 713` ``` \i x. is_nat_case(**Lset(i), f(x), is_b(**Lset(i), x), g(x), h(x))]" ``` paulson@13363 ` 714` ```apply (simp (no_asm_use) only: is_nat_case_def setclass_simps) ``` wenzelm@13428 ` 715` ```apply (intro FOL_reflections function_reflections ``` wenzelm@13428 ` 716` ``` restriction_reflection is_b_reflection quasinat_reflection) ``` paulson@13363 ` 717` ```done ``` paulson@13363 ` 718` paulson@13363 ` 719` paulson@13363 ` 720` paulson@13363 ` 721` ```subsection{*The Operator @{term iterates_MH}, Needed for Iteration*} ``` paulson@13363 ` 722` paulson@13363 ` 723` ```(* iterates_MH :: "[i=>o, [i,i]=>o, i, i, i, i] => o" ``` paulson@13363 ` 724` ``` "iterates_MH(M,isF,v,n,g,z) == ``` paulson@13363 ` 725` ``` is_nat_case(M, v, \m u. \gm[M]. fun_apply(M,g,m,gm) & isF(gm,u), ``` paulson@13363 ` 726` ``` n, z)" *) ``` paulson@13434 ` 727` ```constdefs iterates_MH_fm :: "[i, i, i, i, i]=>i" ``` paulson@13434 ` 728` ``` "iterates_MH_fm(isF,v,n,g,z) == ``` paulson@13434 ` 729` ``` is_nat_case_fm(v, ``` paulson@13434 ` 730` ``` Exists(And(fun_apply_fm(succ(succ(succ(g))),2,0), ``` paulson@13434 ` 731` ``` Forall(Implies(Equal(0,2), isF)))), ``` paulson@13363 ` 732` ``` n, z)" ``` paulson@13363 ` 733` paulson@13363 ` 734` ```lemma iterates_MH_type [TC]: ``` paulson@13434 ` 735` ``` "[| p \ formula; ``` paulson@13434 ` 736` ``` v \ nat; x \ nat; y \ nat; z \ nat |] ``` paulson@13363 ` 737` ``` ==> iterates_MH_fm(p,v,x,y,z) \ formula" ``` wenzelm@13428 ` 738` ```by (simp add: iterates_MH_fm_def) ``` paulson@13363 ` 739` paulson@13363 ` 740` ```lemma sats_iterates_MH_fm: ``` wenzelm@13428 ` 741` ``` assumes is_F_iff_sats: ``` wenzelm@13428 ` 742` ``` "!!a b c d. [| a \ A; b \ A; c \ A; d \ A|] ``` paulson@13363 ` 743` ``` ==> is_F(a,b) <-> ``` paulson@13434 ` 744` ``` sats(A, p, Cons(b, Cons(a, Cons(c, Cons(d,env)))))" ``` paulson@13434 ` 745` ``` shows ``` paulson@13363 ` 746` ``` "[|v \ nat; x \ nat; y \ nat; z < length(env); env \ list(A)|] ``` wenzelm@13428 ` 747` ``` ==> sats(A, iterates_MH_fm(p,v,x,y,z), env) <-> ``` paulson@13363 ` 748` ``` iterates_MH(**A, is_F, nth(v,env), nth(x,env), nth(y,env), nth(z,env))" ``` paulson@13434 ` 749` ```apply (frule lt_length_in_nat, assumption) ``` paulson@13434 ` 750` ```apply (simp add: iterates_MH_fm_def iterates_MH_def sats_is_nat_case_fm ``` paulson@13363 ` 751` ``` is_F_iff_sats [symmetric]) ``` paulson@13434 ` 752` ```apply (rule is_nat_case_cong) ``` paulson@13434 ` 753` ```apply (simp_all add: setclass_def) ``` paulson@13434 ` 754` ```done ``` paulson@13434 ` 755` paulson@13363 ` 756` paulson@13363 ` 757` ```lemma iterates_MH_iff_sats: ``` wenzelm@13428 ` 758` ``` "[| (!!a b c d. [| a \ A; b \ A; c \ A; d \ A|] ``` paulson@13363 ` 759` ``` ==> is_F(a,b) <-> ``` paulson@13434 ` 760` ``` sats(A, p, Cons(b, Cons(a, Cons(c, Cons(d,env)))))); ``` paulson@13434 ` 761` ``` nth(i',env) = v; nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13363 ` 762` ``` i' \ nat; i \ nat; j \ nat; k < length(env); env \ list(A)|] ``` wenzelm@13428 ` 763` ``` ==> iterates_MH(**A, is_F, v, x, y, z) <-> ``` paulson@13363 ` 764` ``` sats(A, iterates_MH_fm(p,i',i,j,k), env)" ``` paulson@13434 ` 765` ```apply (rule iff_sym) ``` wenzelm@13428 ` 766` ```apply (rule iff_trans) ``` paulson@13441 ` 767` ```apply (rule sats_iterates_MH_fm [of A is_F], blast, simp_all) ``` paulson@13363 ` 768` ```done ``` paulson@13434 ` 769` ```(*FIXME: surely proof can be improved?*) ``` paulson@13434 ` 770` paulson@13363 ` 771` paulson@13363 ` 772` ```theorem iterates_MH_reflection: ``` paulson@13363 ` 773` ``` assumes p_reflection: ``` wenzelm@13428 ` 774` ``` "!!f g h. REFLECTS[\x. p(L, f(x), g(x)), ``` paulson@13363 ` 775` ``` \i x. p(**Lset(i), f(x), g(x))]" ``` wenzelm@13428 ` 776` ``` shows "REFLECTS[\x. iterates_MH(L, p(L), e(x), f(x), g(x), h(x)), ``` paulson@13363 ` 777` ``` \i x. iterates_MH(**Lset(i), p(**Lset(i)), e(x), f(x), g(x), h(x))]" ``` paulson@13363 ` 778` ```apply (simp (no_asm_use) only: iterates_MH_def) ``` paulson@13363 ` 779` ```txt{*Must be careful: simplifying with @{text setclass_simps} above would ``` paulson@13363 ` 780` ``` change @{text "\gm[**Lset(i)]"} into @{text "\gm \ Lset(i)"}, when ``` paulson@13363 ` 781` ``` it would no longer match rule @{text is_nat_case_reflection}. *} ``` wenzelm@13428 ` 782` ```apply (rule is_nat_case_reflection) ``` paulson@13363 ` 783` ```apply (simp (no_asm_use) only: setclass_simps) ``` paulson@13363 ` 784` ```apply (intro FOL_reflections function_reflections is_nat_case_reflection ``` wenzelm@13428 ` 785` ``` restriction_reflection p_reflection) ``` paulson@13363 ` 786` ```done ``` paulson@13363 ` 787` paulson@13363 ` 788` paulson@13363 ` 789` wenzelm@13428 ` 790` ```subsection{*@{term L} is Closed Under the Operator @{term list}*} ``` paulson@13363 ` 791` paulson@13386 ` 792` ```subsubsection{*The List Functor, Internalized*} ``` paulson@13386 ` 793` paulson@13386 ` 794` ```constdefs list_functor_fm :: "[i,i,i]=>i" ``` wenzelm@13428 ` 795` ```(* "is_list_functor(M,A,X,Z) == ``` wenzelm@13428 ` 796` ``` \n1[M]. \AX[M]. ``` paulson@13386 ` 797` ``` number1(M,n1) & cartprod(M,A,X,AX) & is_sum(M,n1,AX,Z)" *) ``` wenzelm@13428 ` 798` ``` "list_functor_fm(A,X,Z) == ``` paulson@13386 ` 799` ``` Exists(Exists( ``` wenzelm@13428 ` 800` ``` And(number1_fm(1), ``` paulson@13386 ` 801` ``` And(cartprod_fm(A#+2,X#+2,0), sum_fm(1,0,Z#+2)))))" ``` paulson@13386 ` 802` paulson@13386 ` 803` ```lemma list_functor_type [TC]: ``` paulson@13386 ` 804` ``` "[| x \ nat; y \ nat; z \ nat |] ==> list_functor_fm(x,y,z) \ formula" ``` wenzelm@13428 ` 805` ```by (simp add: list_functor_fm_def) ``` paulson@13386 ` 806` paulson@13386 ` 807` ```lemma arity_list_functor_fm [simp]: ``` wenzelm@13428 ` 808` ``` "[| x \ nat; y \ nat; z \ nat |] ``` paulson@13386 ` 809` ``` ==> arity(list_functor_fm(x,y,z)) = succ(x) \ succ(y) \ succ(z)" ``` wenzelm@13428 ` 810` ```by (simp add: list_functor_fm_def succ_Un_distrib [symmetric] Un_ac) ``` paulson@13386 ` 811` paulson@13386 ` 812` ```lemma sats_list_functor_fm [simp]: ``` paulson@13386 ` 813` ``` "[| x \ nat; y \ nat; z \ nat; env \ list(A)|] ``` wenzelm@13428 ` 814` ``` ==> sats(A, list_functor_fm(x,y,z), env) <-> ``` paulson@13386 ` 815` ``` is_list_functor(**A, nth(x,env), nth(y,env), nth(z,env))" ``` paulson@13386 ` 816` ```by (simp add: list_functor_fm_def is_list_functor_def) ``` paulson@13386 ` 817` paulson@13386 ` 818` ```lemma list_functor_iff_sats: ``` wenzelm@13428 ` 819` ``` "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13386 ` 820` ``` i \ nat; j \ nat; k \ nat; env \ list(A)|] ``` paulson@13386 ` 821` ``` ==> is_list_functor(**A, x, y, z) <-> sats(A, list_functor_fm(i,j,k), env)" ``` paulson@13386 ` 822` ```by simp ``` paulson@13386 ` 823` paulson@13386 ` 824` ```theorem list_functor_reflection: ``` wenzelm@13428 ` 825` ``` "REFLECTS[\x. is_list_functor(L,f(x),g(x),h(x)), ``` paulson@13386 ` 826` ``` \i x. is_list_functor(**Lset(i),f(x),g(x),h(x))]" ``` paulson@13386 ` 827` ```apply (simp only: is_list_functor_def setclass_simps) ``` paulson@13386 ` 828` ```apply (intro FOL_reflections number1_reflection ``` wenzelm@13428 ` 829` ``` cartprod_reflection sum_reflection) ``` paulson@13386 ` 830` ```done ``` paulson@13386 ` 831` paulson@13386 ` 832` paulson@13386 ` 833` ```subsubsection{*Instances of Replacement for Lists*} ``` paulson@13386 ` 834` paulson@13363 ` 835` ```lemma list_replacement1_Reflects: ``` paulson@13363 ` 836` ``` "REFLECTS ``` paulson@13363 ` 837` ``` [\x. \u[L]. u \ B \ (\y[L]. pair(L,u,y,x) \ ``` paulson@13363 ` 838` ``` is_wfrec(L, iterates_MH(L, is_list_functor(L,A), 0), memsn, u, y)), ``` paulson@13363 ` 839` ``` \i x. \u \ Lset(i). u \ B \ (\y \ Lset(i). pair(**Lset(i), u, y, x) \ ``` wenzelm@13428 ` 840` ``` is_wfrec(**Lset(i), ``` wenzelm@13428 ` 841` ``` iterates_MH(**Lset(i), ``` paulson@13363 ` 842` ``` is_list_functor(**Lset(i), A), 0), memsn, u, y))]" ``` wenzelm@13428 ` 843` ```by (intro FOL_reflections function_reflections is_wfrec_reflection ``` wenzelm@13428 ` 844` ``` iterates_MH_reflection list_functor_reflection) ``` paulson@13363 ` 845` paulson@13441 ` 846` wenzelm@13428 ` 847` ```lemma list_replacement1: ``` paulson@13363 ` 848` ``` "L(A) ==> iterates_replacement(L, is_list_functor(L,A), 0)" ``` paulson@13363 ` 849` ```apply (unfold iterates_replacement_def wfrec_replacement_def, clarify) ``` wenzelm@13428 ` 850` ```apply (rule strong_replacementI) ``` paulson@13363 ` 851` ```apply (rule rallI) ``` wenzelm@13428 ` 852` ```apply (rename_tac B) ``` wenzelm@13428 ` 853` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 854` ```apply (insert nonempty) ``` wenzelm@13428 ` 855` ```apply (subgoal_tac "L(Memrel(succ(n)))") ``` wenzelm@13428 ` 856` ```apply (rule_tac A="{B,A,n,z,0,Memrel(succ(n))}" in subset_LsetE, blast ) ``` paulson@13363 ` 857` ```apply (rule ReflectsE [OF list_replacement1_Reflects], assumption) ``` wenzelm@13428 ` 858` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13363 ` 859` ```apply (erule reflection_imp_L_separation) ``` paulson@13386 ` 860` ``` apply (simp_all add: lt_Ord2 Memrel_closed) ``` wenzelm@13428 ` 861` ```apply (elim conjE) ``` paulson@13385 ` 862` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 863` ```apply (rename_tac v) ``` paulson@13363 ` 864` ```apply (rule bex_iff_sats conj_iff_sats)+ ``` paulson@13363 ` 865` ```apply (rule_tac env = "[u,v,A,n,B,0,Memrel(succ(n))]" in mem_iff_sats) ``` paulson@13434 ` 866` ```apply (rule sep_rules is_nat_case_iff_sats list_functor_iff_sats ``` paulson@13441 ` 867` ``` is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+ ``` paulson@13363 ` 868` ```done ``` paulson@13363 ` 869` paulson@13441 ` 870` paulson@13363 ` 871` ```lemma list_replacement2_Reflects: ``` paulson@13363 ` 872` ``` "REFLECTS ``` paulson@13363 ` 873` ``` [\x. \u[L]. u \ B \ u \ nat \ ``` paulson@13363 ` 874` ``` (\sn[L]. \msn[L]. successor(L, u, sn) \ membership(L, sn, msn) \ ``` paulson@13363 ` 875` ``` is_wfrec (L, iterates_MH (L, is_list_functor(L, A), 0), ``` paulson@13363 ` 876` ``` msn, u, x)), ``` paulson@13363 ` 877` ``` \i x. \u \ Lset(i). u \ B \ u \ nat \ ``` wenzelm@13428 ` 878` ``` (\sn \ Lset(i). \msn \ Lset(i). ``` paulson@13363 ` 879` ``` successor(**Lset(i), u, sn) \ membership(**Lset(i), sn, msn) \ ``` wenzelm@13428 ` 880` ``` is_wfrec (**Lset(i), ``` paulson@13363 ` 881` ``` iterates_MH (**Lset(i), is_list_functor(**Lset(i), A), 0), ``` paulson@13363 ` 882` ``` msn, u, x))]" ``` wenzelm@13428 ` 883` ```by (intro FOL_reflections function_reflections is_wfrec_reflection ``` wenzelm@13428 ` 884` ``` iterates_MH_reflection list_functor_reflection) ``` paulson@13363 ` 885` paulson@13363 ` 886` wenzelm@13428 ` 887` ```lemma list_replacement2: ``` wenzelm@13428 ` 888` ``` "L(A) ==> strong_replacement(L, ``` wenzelm@13428 ` 889` ``` \n y. n\nat & ``` paulson@13363 ` 890` ``` (\sn[L]. \msn[L]. successor(L,n,sn) & membership(L,sn,msn) & ``` wenzelm@13428 ` 891` ``` is_wfrec(L, iterates_MH(L,is_list_functor(L,A), 0), ``` paulson@13363 ` 892` ``` msn, n, y)))" ``` wenzelm@13428 ` 893` ```apply (rule strong_replacementI) ``` paulson@13363 ` 894` ```apply (rule rallI) ``` wenzelm@13428 ` 895` ```apply (rename_tac B) ``` wenzelm@13428 ` 896` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 897` ```apply (insert nonempty) ``` wenzelm@13428 ` 898` ```apply (rule_tac A="{A,B,z,0,nat}" in subset_LsetE) ``` wenzelm@13428 ` 899` ```apply (blast intro: L_nat) ``` paulson@13363 ` 900` ```apply (rule ReflectsE [OF list_replacement2_Reflects], assumption) ``` wenzelm@13428 ` 901` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13363 ` 902` ```apply (erule reflection_imp_L_separation) ``` paulson@13363 ` 903` ``` apply (simp_all add: lt_Ord2) ``` paulson@13385 ` 904` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 905` ```apply (rename_tac v) ``` paulson@13363 ` 906` ```apply (rule bex_iff_sats conj_iff_sats)+ ``` paulson@13363 ` 907` ```apply (rule_tac env = "[u,v,A,B,0,nat]" in mem_iff_sats) ``` paulson@13434 ` 908` ```apply (rule sep_rules is_nat_case_iff_sats list_functor_iff_sats ``` paulson@13441 ` 909` ``` is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+ ``` paulson@13363 ` 910` ```done ``` paulson@13363 ` 911` paulson@13386 ` 912` wenzelm@13428 ` 913` ```subsection{*@{term L} is Closed Under the Operator @{term formula}*} ``` paulson@13386 ` 914` paulson@13386 ` 915` ```subsubsection{*The Formula Functor, Internalized*} ``` paulson@13386 ` 916` paulson@13386 ` 917` ```constdefs formula_functor_fm :: "[i,i]=>i" ``` wenzelm@13428 ` 918` ```(* "is_formula_functor(M,X,Z) == ``` wenzelm@13428 ` 919` ``` \nat'[M]. \natnat[M]. \natnatsum[M]. \XX[M]. \X3[M]. ``` paulson@13398 ` 920` ``` 4 3 2 1 0 ``` wenzelm@13428 ` 921` ``` omega(M,nat') & cartprod(M,nat',nat',natnat) & ``` paulson@13386 ` 922` ``` is_sum(M,natnat,natnat,natnatsum) & ``` wenzelm@13428 ` 923` ``` cartprod(M,X,X,XX) & is_sum(M,XX,X,X3) & ``` wenzelm@13428 ` 924` ``` is_sum(M,natnatsum,X3,Z)" *) ``` wenzelm@13428 ` 925` ``` "formula_functor_fm(X,Z) == ``` paulson@13398 ` 926` ``` Exists(Exists(Exists(Exists(Exists( ``` wenzelm@13428 ` 927` ``` And(omega_fm(4), ``` paulson@13398 ` 928` ``` And(cartprod_fm(4,4,3), ``` paulson@13398 ` 929` ``` And(sum_fm(3,3,2), ``` paulson@13398 ` 930` ``` And(cartprod_fm(X#+5,X#+5,1), ``` paulson@13398 ` 931` ``` And(sum_fm(1,X#+5,0), sum_fm(2,0,Z#+5)))))))))))" ``` paulson@13386 ` 932` paulson@13386 ` 933` ```lemma formula_functor_type [TC]: ``` paulson@13386 ` 934` ``` "[| x \ nat; y \ nat |] ==> formula_functor_fm(x,y) \ formula" ``` wenzelm@13428 ` 935` ```by (simp add: formula_functor_fm_def) ``` paulson@13386 ` 936` paulson@13386 ` 937` ```lemma sats_formula_functor_fm [simp]: ``` paulson@13386 ` 938` ``` "[| x \ nat; y \ nat; env \ list(A)|] ``` wenzelm@13428 ` 939` ``` ==> sats(A, formula_functor_fm(x,y), env) <-> ``` paulson@13386 ` 940` ``` is_formula_functor(**A, nth(x,env), nth(y,env))" ``` paulson@13386 ` 941` ```by (simp add: formula_functor_fm_def is_formula_functor_def) ``` paulson@13386 ` 942` paulson@13386 ` 943` ```lemma formula_functor_iff_sats: ``` wenzelm@13428 ` 944` ``` "[| nth(i,env) = x; nth(j,env) = y; ``` paulson@13386 ` 945` ``` i \ nat; j \ nat; env \ list(A)|] ``` paulson@13386 ` 946` ``` ==> is_formula_functor(**A, x, y) <-> sats(A, formula_functor_fm(i,j), env)" ``` paulson@13386 ` 947` ```by simp ``` paulson@13386 ` 948` paulson@13386 ` 949` ```theorem formula_functor_reflection: ``` wenzelm@13428 ` 950` ``` "REFLECTS[\x. is_formula_functor(L,f(x),g(x)), ``` paulson@13386 ` 951` ``` \i x. is_formula_functor(**Lset(i),f(x),g(x))]" ``` paulson@13386 ` 952` ```apply (simp only: is_formula_functor_def setclass_simps) ``` paulson@13386 ` 953` ```apply (intro FOL_reflections omega_reflection ``` wenzelm@13428 ` 954` ``` cartprod_reflection sum_reflection) ``` paulson@13386 ` 955` ```done ``` paulson@13386 ` 956` paulson@13386 ` 957` ```subsubsection{*Instances of Replacement for Formulas*} ``` paulson@13386 ` 958` paulson@13386 ` 959` ```lemma formula_replacement1_Reflects: ``` paulson@13386 ` 960` ``` "REFLECTS ``` paulson@13386 ` 961` ``` [\x. \u[L]. u \ B \ (\y[L]. pair(L,u,y,x) \ ``` paulson@13386 ` 962` ``` is_wfrec(L, iterates_MH(L, is_formula_functor(L), 0), memsn, u, y)), ``` paulson@13386 ` 963` ``` \i x. \u \ Lset(i). u \ B \ (\y \ Lset(i). pair(**Lset(i), u, y, x) \ ``` wenzelm@13428 ` 964` ``` is_wfrec(**Lset(i), ``` wenzelm@13428 ` 965` ``` iterates_MH(**Lset(i), ``` paulson@13386 ` 966` ``` is_formula_functor(**Lset(i)), 0), memsn, u, y))]" ``` wenzelm@13428 ` 967` ```by (intro FOL_reflections function_reflections is_wfrec_reflection ``` wenzelm@13428 ` 968` ``` iterates_MH_reflection formula_functor_reflection) ``` paulson@13386 ` 969` wenzelm@13428 ` 970` ```lemma formula_replacement1: ``` paulson@13386 ` 971` ``` "iterates_replacement(L, is_formula_functor(L), 0)" ``` paulson@13386 ` 972` ```apply (unfold iterates_replacement_def wfrec_replacement_def, clarify) ``` wenzelm@13428 ` 973` ```apply (rule strong_replacementI) ``` paulson@13386 ` 974` ```apply (rule rallI) ``` wenzelm@13428 ` 975` ```apply (rename_tac B) ``` wenzelm@13428 ` 976` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 977` ```apply (insert nonempty) ``` wenzelm@13428 ` 978` ```apply (subgoal_tac "L(Memrel(succ(n)))") ``` wenzelm@13428 ` 979` ```apply (rule_tac A="{B,n,z,0,Memrel(succ(n))}" in subset_LsetE, blast ) ``` paulson@13386 ` 980` ```apply (rule ReflectsE [OF formula_replacement1_Reflects], assumption) ``` wenzelm@13428 ` 981` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13386 ` 982` ```apply (erule reflection_imp_L_separation) ``` paulson@13386 ` 983` ``` apply (simp_all add: lt_Ord2 Memrel_closed) ``` paulson@13386 ` 984` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 985` ```apply (rename_tac v) ``` paulson@13386 ` 986` ```apply (rule bex_iff_sats conj_iff_sats)+ ``` paulson@13386 ` 987` ```apply (rule_tac env = "[u,v,n,B,0,Memrel(succ(n))]" in mem_iff_sats) ``` paulson@13434 ` 988` ```apply (rule sep_rules is_nat_case_iff_sats formula_functor_iff_sats ``` paulson@13441 ` 989` ``` is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+ ``` paulson@13386 ` 990` ```done ``` paulson@13386 ` 991` paulson@13386 ` 992` ```lemma formula_replacement2_Reflects: ``` paulson@13386 ` 993` ``` "REFLECTS ``` paulson@13386 ` 994` ``` [\x. \u[L]. u \ B \ u \ nat \ ``` paulson@13386 ` 995` ``` (\sn[L]. \msn[L]. successor(L, u, sn) \ membership(L, sn, msn) \ ``` paulson@13386 ` 996` ``` is_wfrec (L, iterates_MH (L, is_formula_functor(L), 0), ``` paulson@13386 ` 997` ``` msn, u, x)), ``` paulson@13386 ` 998` ``` \i x. \u \ Lset(i). u \ B \ u \ nat \ ``` wenzelm@13428 ` 999` ``` (\sn \ Lset(i). \msn \ Lset(i). ``` paulson@13386 ` 1000` ``` successor(**Lset(i), u, sn) \ membership(**Lset(i), sn, msn) \ ``` wenzelm@13428 ` 1001` ``` is_wfrec (**Lset(i), ``` paulson@13386 ` 1002` ``` iterates_MH (**Lset(i), is_formula_functor(**Lset(i)), 0), ``` paulson@13386 ` 1003` ``` msn, u, x))]" ``` wenzelm@13428 ` 1004` ```by (intro FOL_reflections function_reflections is_wfrec_reflection ``` wenzelm@13428 ` 1005` ``` iterates_MH_reflection formula_functor_reflection) ``` paulson@13386 ` 1006` paulson@13386 ` 1007` wenzelm@13428 ` 1008` ```lemma formula_replacement2: ``` wenzelm@13428 ` 1009` ``` "strong_replacement(L, ``` wenzelm@13428 ` 1010` ``` \n y. n\nat & ``` paulson@13386 ` 1011` ``` (\sn[L]. \msn[L]. successor(L,n,sn) & membership(L,sn,msn) & ``` wenzelm@13428 ` 1012` ``` is_wfrec(L, iterates_MH(L,is_formula_functor(L), 0), ``` paulson@13386 ` 1013` ``` msn, n, y)))" ``` wenzelm@13428 ` 1014` ```apply (rule strong_replacementI) ``` paulson@13386 ` 1015` ```apply (rule rallI) ``` wenzelm@13428 ` 1016` ```apply (rename_tac B) ``` wenzelm@13428 ` 1017` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 1018` ```apply (insert nonempty) ``` wenzelm@13428 ` 1019` ```apply (rule_tac A="{B,z,0,nat}" in subset_LsetE) ``` wenzelm@13428 ` 1020` ```apply (blast intro: L_nat) ``` paulson@13386 ` 1021` ```apply (rule ReflectsE [OF formula_replacement2_Reflects], assumption) ``` wenzelm@13428 ` 1022` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13386 ` 1023` ```apply (erule reflection_imp_L_separation) ``` paulson@13386 ` 1024` ``` apply (simp_all add: lt_Ord2) ``` paulson@13386 ` 1025` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 1026` ```apply (rename_tac v) ``` paulson@13386 ` 1027` ```apply (rule bex_iff_sats conj_iff_sats)+ ``` paulson@13386 ` 1028` ```apply (rule_tac env = "[u,v,B,0,nat]" in mem_iff_sats) ``` paulson@13434 ` 1029` ```apply (rule sep_rules is_nat_case_iff_sats formula_functor_iff_sats ``` paulson@13441 ` 1030` ``` is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+ ``` paulson@13386 ` 1031` ```done ``` paulson@13386 ` 1032` paulson@13386 ` 1033` ```text{*NB The proofs for type @{term formula} are virtually identical to those ``` paulson@13386 ` 1034` ```for @{term "list(A)"}. It was a cut-and-paste job! *} ``` paulson@13386 ` 1035` paulson@13387 ` 1036` paulson@13409 ` 1037` ```subsection{*Internalized Forms of Data Structuring Operators*} ``` paulson@13409 ` 1038` paulson@13409 ` 1039` ```subsubsection{*The Formula @{term is_Inl}, Internalized*} ``` paulson@13409 ` 1040` paulson@13409 ` 1041` ```(* is_Inl(M,a,z) == \zero[M]. empty(M,zero) & pair(M,zero,a,z) *) ``` paulson@13409 ` 1042` ```constdefs Inl_fm :: "[i,i]=>i" ``` paulson@13409 ` 1043` ``` "Inl_fm(a,z) == Exists(And(empty_fm(0), pair_fm(0,succ(a),succ(z))))" ``` paulson@13409 ` 1044` paulson@13409 ` 1045` ```lemma Inl_type [TC]: ``` paulson@13409 ` 1046` ``` "[| x \ nat; z \ nat |] ==> Inl_fm(x,z) \ formula" ``` wenzelm@13428 ` 1047` ```by (simp add: Inl_fm_def) ``` paulson@13409 ` 1048` paulson@13409 ` 1049` ```lemma sats_Inl_fm [simp]: ``` paulson@13409 ` 1050` ``` "[| x \ nat; z \ nat; env \ list(A)|] ``` paulson@13409 ` 1051` ``` ==> sats(A, Inl_fm(x,z), env) <-> is_Inl(**A, nth(x,env), nth(z,env))" ``` paulson@13409 ` 1052` ```by (simp add: Inl_fm_def is_Inl_def) ``` paulson@13409 ` 1053` paulson@13409 ` 1054` ```lemma Inl_iff_sats: ``` wenzelm@13428 ` 1055` ``` "[| nth(i,env) = x; nth(k,env) = z; ``` paulson@13409 ` 1056` ``` i \ nat; k \ nat; env \ list(A)|] ``` paulson@13409 ` 1057` ``` ==> is_Inl(**A, x, z) <-> sats(A, Inl_fm(i,k), env)" ``` paulson@13409 ` 1058` ```by simp ``` paulson@13409 ` 1059` paulson@13409 ` 1060` ```theorem Inl_reflection: ``` wenzelm@13428 ` 1061` ``` "REFLECTS[\x. is_Inl(L,f(x),h(x)), ``` paulson@13409 ` 1062` ``` \i x. is_Inl(**Lset(i),f(x),h(x))]" ``` paulson@13409 ` 1063` ```apply (simp only: is_Inl_def setclass_simps) ``` wenzelm@13428 ` 1064` ```apply (intro FOL_reflections function_reflections) ``` paulson@13409 ` 1065` ```done ``` paulson@13409 ` 1066` paulson@13409 ` 1067` paulson@13409 ` 1068` ```subsubsection{*The Formula @{term is_Inr}, Internalized*} ``` paulson@13409 ` 1069` paulson@13409 ` 1070` ```(* is_Inr(M,a,z) == \n1[M]. number1(M,n1) & pair(M,n1,a,z) *) ``` paulson@13409 ` 1071` ```constdefs Inr_fm :: "[i,i]=>i" ``` paulson@13409 ` 1072` ``` "Inr_fm(a,z) == Exists(And(number1_fm(0), pair_fm(0,succ(a),succ(z))))" ``` paulson@13409 ` 1073` paulson@13409 ` 1074` ```lemma Inr_type [TC]: ``` paulson@13409 ` 1075` ``` "[| x \ nat; z \ nat |] ==> Inr_fm(x,z) \ formula" ``` wenzelm@13428 ` 1076` ```by (simp add: Inr_fm_def) ``` paulson@13409 ` 1077` paulson@13409 ` 1078` ```lemma sats_Inr_fm [simp]: ``` paulson@13409 ` 1079` ``` "[| x \ nat; z \ nat; env \ list(A)|] ``` paulson@13409 ` 1080` ``` ==> sats(A, Inr_fm(x,z), env) <-> is_Inr(**A, nth(x,env), nth(z,env))" ``` paulson@13409 ` 1081` ```by (simp add: Inr_fm_def is_Inr_def) ``` paulson@13409 ` 1082` paulson@13409 ` 1083` ```lemma Inr_iff_sats: ``` wenzelm@13428 ` 1084` ``` "[| nth(i,env) = x; nth(k,env) = z; ``` paulson@13409 ` 1085` ``` i \ nat; k \ nat; env \ list(A)|] ``` paulson@13409 ` 1086` ``` ==> is_Inr(**A, x, z) <-> sats(A, Inr_fm(i,k), env)" ``` paulson@13409 ` 1087` ```by simp ``` paulson@13409 ` 1088` paulson@13409 ` 1089` ```theorem Inr_reflection: ``` wenzelm@13428 ` 1090` ``` "REFLECTS[\x. is_Inr(L,f(x),h(x)), ``` paulson@13409 ` 1091` ``` \i x. is_Inr(**Lset(i),f(x),h(x))]" ``` paulson@13409 ` 1092` ```apply (simp only: is_Inr_def setclass_simps) ``` wenzelm@13428 ` 1093` ```apply (intro FOL_reflections function_reflections) ``` paulson@13409 ` 1094` ```done ``` paulson@13409 ` 1095` paulson@13409 ` 1096` paulson@13409 ` 1097` ```subsubsection{*The Formula @{term is_Nil}, Internalized*} ``` paulson@13409 ` 1098` paulson@13409 ` 1099` ```(* is_Nil(M,xs) == \zero[M]. empty(M,zero) & is_Inl(M,zero,xs) *) ``` paulson@13409 ` 1100` paulson@13409 ` 1101` ```constdefs Nil_fm :: "i=>i" ``` paulson@13409 ` 1102` ``` "Nil_fm(x) == Exists(And(empty_fm(0), Inl_fm(0,succ(x))))" ``` wenzelm@13428 ` 1103` paulson@13409 ` 1104` ```lemma Nil_type [TC]: "x \ nat ==> Nil_fm(x) \ formula" ``` wenzelm@13428 ` 1105` ```by (simp add: Nil_fm_def) ``` paulson@13409 ` 1106` paulson@13409 ` 1107` ```lemma sats_Nil_fm [simp]: ``` paulson@13409 ` 1108` ``` "[| x \ nat; env \ list(A)|] ``` paulson@13409 ` 1109` ``` ==> sats(A, Nil_fm(x), env) <-> is_Nil(**A, nth(x,env))" ``` paulson@13409 ` 1110` ```by (simp add: Nil_fm_def is_Nil_def) ``` paulson@13409 ` 1111` paulson@13409 ` 1112` ```lemma Nil_iff_sats: ``` paulson@13409 ` 1113` ``` "[| nth(i,env) = x; i \ nat; env \ list(A)|] ``` paulson@13409 ` 1114` ``` ==> is_Nil(**A, x) <-> sats(A, Nil_fm(i), env)" ``` paulson@13409 ` 1115` ```by simp ``` paulson@13409 ` 1116` paulson@13409 ` 1117` ```theorem Nil_reflection: ``` wenzelm@13428 ` 1118` ``` "REFLECTS[\x. is_Nil(L,f(x)), ``` paulson@13409 ` 1119` ``` \i x. is_Nil(**Lset(i),f(x))]" ``` paulson@13409 ` 1120` ```apply (simp only: is_Nil_def setclass_simps) ``` wenzelm@13428 ` 1121` ```apply (intro FOL_reflections function_reflections Inl_reflection) ``` paulson@13409 ` 1122` ```done ``` paulson@13409 ` 1123` paulson@13409 ` 1124` paulson@13422 ` 1125` ```subsubsection{*The Formula @{term is_Cons}, Internalized*} ``` paulson@13395 ` 1126` paulson@13387 ` 1127` paulson@13409 ` 1128` ```(* "is_Cons(M,a,l,Z) == \p[M]. pair(M,a,l,p) & is_Inr(M,p,Z)" *) ``` paulson@13409 ` 1129` ```constdefs Cons_fm :: "[i,i,i]=>i" ``` wenzelm@13428 ` 1130` ``` "Cons_fm(a,l,Z) == ``` paulson@13409 ` 1131` ``` Exists(And(pair_fm(succ(a),succ(l),0), Inr_fm(0,succ(Z))))" ``` paulson@13409 ` 1132` paulson@13409 ` 1133` ```lemma Cons_type [TC]: ``` paulson@13409 ` 1134` ``` "[| x \ nat; y \ nat; z \ nat |] ==> Cons_fm(x,y,z) \ formula" ``` wenzelm@13428 ` 1135` ```by (simp add: Cons_fm_def) ``` paulson@13409 ` 1136` paulson@13409 ` 1137` ```lemma sats_Cons_fm [simp]: ``` paulson@13409 ` 1138` ``` "[| x \ nat; y \ nat; z \ nat; env \ list(A)|] ``` wenzelm@13428 ` 1139` ``` ==> sats(A, Cons_fm(x,y,z), env) <-> ``` paulson@13409 ` 1140` ``` is_Cons(**A, nth(x,env), nth(y,env), nth(z,env))" ``` paulson@13409 ` 1141` ```by (simp add: Cons_fm_def is_Cons_def) ``` paulson@13409 ` 1142` paulson@13409 ` 1143` ```lemma Cons_iff_sats: ``` wenzelm@13428 ` 1144` ``` "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; ``` paulson@13409 ` 1145` ``` i \ nat; j \ nat; k \ nat; env \ list(A)|] ``` paulson@13409 ` 1146` ``` ==>is_Cons(**A, x, y, z) <-> sats(A, Cons_fm(i,j,k), env)" ``` paulson@13409 ` 1147` ```by simp ``` paulson@13409 ` 1148` paulson@13409 ` 1149` ```theorem Cons_reflection: ``` wenzelm@13428 ` 1150` ``` "REFLECTS[\x. is_Cons(L,f(x),g(x),h(x)), ``` paulson@13409 ` 1151` ``` \i x. is_Cons(**Lset(i),f(x),g(x),h(x))]" ``` paulson@13409 ` 1152` ```apply (simp only: is_Cons_def setclass_simps) ``` wenzelm@13428 ` 1153` ```apply (intro FOL_reflections pair_reflection Inr_reflection) ``` paulson@13409 ` 1154` ```done ``` paulson@13409 ` 1155` paulson@13409 ` 1156` ```subsubsection{*The Formula @{term is_quasilist}, Internalized*} ``` paulson@13409 ` 1157` paulson@13409 ` 1158` ```(* is_quasilist(M,xs) == is_Nil(M,z) | (\x[M]. \l[M]. is_Cons(M,x,l,z))" *) ``` paulson@13409 ` 1159` paulson@13409 ` 1160` ```constdefs quasilist_fm :: "i=>i" ``` wenzelm@13428 ` 1161` ``` "quasilist_fm(x) == ``` paulson@13409 ` 1162` ``` Or(Nil_fm(x), Exists(Exists(Cons_fm(1,0,succ(succ(x))))))" ``` wenzelm@13428 ` 1163` paulson@13409 ` 1164` ```lemma quasilist_type [TC]: "x \ nat ==> quasilist_fm(x) \ formula" ``` wenzelm@13428 ` 1165` ```by (simp add: quasilist_fm_def) ``` paulson@13409 ` 1166` paulson@13409 ` 1167` ```lemma sats_quasilist_fm [simp]: ``` paulson@13409 ` 1168` ``` "[| x \ nat; env \ list(A)|] ``` paulson@13409 ` 1169` ``` ==> sats(A, quasilist_fm(x), env) <-> is_quasilist(**A, nth(x,env))" ``` paulson@13409 ` 1170` ```by (simp add: quasilist_fm_def is_quasilist_def) ``` paulson@13409 ` 1171` paulson@13409 ` 1172` ```lemma quasilist_iff_sats: ``` paulson@13409 ` 1173` ``` "[| nth(i,env) = x; i \ nat; env \ list(A)|] ``` paulson@13409 ` 1174` ``` ==> is_quasilist(**A, x) <-> sats(A, quasilist_fm(i), env)" ``` paulson@13409 ` 1175` ```by simp ``` paulson@13409 ` 1176` paulson@13409 ` 1177` ```theorem quasilist_reflection: ``` wenzelm@13428 ` 1178` ``` "REFLECTS[\x. is_quasilist(L,f(x)), ``` paulson@13409 ` 1179` ``` \i x. is_quasilist(**Lset(i),f(x))]" ``` paulson@13409 ` 1180` ```apply (simp only: is_quasilist_def setclass_simps) ``` wenzelm@13428 ` 1181` ```apply (intro FOL_reflections Nil_reflection Cons_reflection) ``` paulson@13409 ` 1182` ```done ``` paulson@13409 ` 1183` paulson@13409 ` 1184` paulson@13409 ` 1185` ```subsection{*Absoluteness for the Function @{term nth}*} ``` paulson@13409 ` 1186` paulson@13409 ` 1187` paulson@13437 ` 1188` ```subsubsection{*The Formula @{term is_hd}, Internalized*} ``` paulson@13437 ` 1189` paulson@13437 ` 1190` ```(* "is_hd(M,xs,H) == ``` paulson@13437 ` 1191` ``` (is_Nil(M,xs) --> empty(M,H)) & ``` paulson@13437 ` 1192` ``` (\x[M]. \l[M]. ~ is_Cons(M,x,l,xs) | H=x) & ``` paulson@13437 ` 1193` ``` (is_quasilist(M,xs) | empty(M,H))" *) ``` paulson@13437 ` 1194` ```constdefs hd_fm :: "[i,i]=>i" ``` paulson@13437 ` 1195` ``` "hd_fm(xs,H) == ``` paulson@13437 ` 1196` ``` And(Implies(Nil_fm(xs), empty_fm(H)), ``` paulson@13437 ` 1197` ``` And(Forall(Forall(Or(Neg(Cons_fm(1,0,xs#+2)), Equal(H#+2,1)))), ``` paulson@13437 ` 1198` ``` Or(quasilist_fm(xs), empty_fm(H))))" ``` paulson@13437 ` 1199` paulson@13437 ` 1200` ```lemma hd_type [TC]: ``` paulson@13437 ` 1201` ``` "[| x \ nat; y \ nat |] ==> hd_fm(x,y) \ formula" ``` paulson@13437 ` 1202` ```by (simp add: hd_fm_def) ``` paulson@13437 ` 1203` paulson@13437 ` 1204` ```lemma sats_hd_fm [simp]: ``` paulson@13437 ` 1205` ``` "[| x \ nat; y \ nat; env \ list(A)|] ``` paulson@13437 ` 1206` ``` ==> sats(A, hd_fm(x,y), env) <-> is_hd(**A, nth(x,env), nth(y,env))" ``` paulson@13437 ` 1207` ```by (simp add: hd_fm_def is_hd_def) ``` paulson@13437 ` 1208` paulson@13437 ` 1209` ```lemma hd_iff_sats: ``` paulson@13437 ` 1210` ``` "[| nth(i,env) = x; nth(j,env) = y; ``` paulson@13437 ` 1211` ``` i \ nat; j \ nat; env \ list(A)|] ``` paulson@13437 ` 1212` ``` ==> is_hd(**A, x, y) <-> sats(A, hd_fm(i,j), env)" ``` paulson@13437 ` 1213` ```by simp ``` paulson@13437 ` 1214` paulson@13437 ` 1215` ```theorem hd_reflection: ``` paulson@13437 ` 1216` ``` "REFLECTS[\x. is_hd(L,f(x),g(x)), ``` paulson@13437 ` 1217` ``` \i x. is_hd(**Lset(i),f(x),g(x))]" ``` paulson@13437 ` 1218` ```apply (simp only: is_hd_def setclass_simps) ``` paulson@13437 ` 1219` ```apply (intro FOL_reflections Nil_reflection Cons_reflection ``` paulson@13437 ` 1220` ``` quasilist_reflection empty_reflection) ``` paulson@13437 ` 1221` ```done ``` paulson@13437 ` 1222` paulson@13437 ` 1223` paulson@13409 ` 1224` ```subsubsection{*The Formula @{term is_tl}, Internalized*} ``` paulson@13409 ` 1225` wenzelm@13428 ` 1226` ```(* "is_tl(M,xs,T) == ``` paulson@13409 ` 1227` ``` (is_Nil(M,xs) --> T=xs) & ``` paulson@13409 ` 1228` ``` (\x[M]. \l[M]. ~ is_Cons(M,x,l,xs) | T=l) & ``` paulson@13409 ` 1229` ``` (is_quasilist(M,xs) | empty(M,T))" *) ``` paulson@13409 ` 1230` ```constdefs tl_fm :: "[i,i]=>i" ``` wenzelm@13428 ` 1231` ``` "tl_fm(xs,T) == ``` paulson@13409 ` 1232` ``` And(Implies(Nil_fm(xs), Equal(T,xs)), ``` paulson@13409 ` 1233` ``` And(Forall(Forall(Or(Neg(Cons_fm(1,0,xs#+2)), Equal(T#+2,0)))), ``` paulson@13409 ` 1234` ``` Or(quasilist_fm(xs), empty_fm(T))))" ``` paulson@13409 ` 1235` paulson@13409 ` 1236` ```lemma tl_type [TC]: ``` paulson@13409 ` 1237` ``` "[| x \ nat; y \ nat |] ==> tl_fm(x,y) \ formula" ``` wenzelm@13428 ` 1238` ```by (simp add: tl_fm_def) ``` paulson@13409 ` 1239` paulson@13409 ` 1240` ```lemma sats_tl_fm [simp]: ``` paulson@13409 ` 1241` ``` "[| x \ nat; y \ nat; env \ list(A)|] ``` paulson@13409 ` 1242` ``` ==> sats(A, tl_fm(x,y), env) <-> is_tl(**A, nth(x,env), nth(y,env))" ``` paulson@13409 ` 1243` ```by (simp add: tl_fm_def is_tl_def) ``` paulson@13409 ` 1244` paulson@13409 ` 1245` ```lemma tl_iff_sats: ``` paulson@13409 ` 1246` ``` "[| nth(i,env) = x; nth(j,env) = y; ``` paulson@13409 ` 1247` ``` i \ nat; j \ nat; env \ list(A)|] ``` paulson@13409 ` 1248` ``` ==> is_tl(**A, x, y) <-> sats(A, tl_fm(i,j), env)" ``` paulson@13409 ` 1249` ```by simp ``` paulson@13409 ` 1250` paulson@13409 ` 1251` ```theorem tl_reflection: ``` wenzelm@13428 ` 1252` ``` "REFLECTS[\x. is_tl(L,f(x),g(x)), ``` paulson@13409 ` 1253` ``` \i x. is_tl(**Lset(i),f(x),g(x))]" ``` paulson@13409 ` 1254` ```apply (simp only: is_tl_def setclass_simps) ``` paulson@13409 ` 1255` ```apply (intro FOL_reflections Nil_reflection Cons_reflection ``` wenzelm@13428 ` 1256` ``` quasilist_reflection empty_reflection) ``` paulson@13409 ` 1257` ```done ``` paulson@13409 ` 1258` paulson@13409 ` 1259` paulson@13437 ` 1260` ```subsubsection{*The Formula @{term is_nth}, Internalized*} ``` paulson@13437 ` 1261` paulson@13437 ` 1262` ```(* "is_nth(M,n,l,Z) == ``` paulson@13437 ` 1263` ``` \X[M]. \sn[M]. \msn[M]. ``` paulson@13437 ` 1264` ``` 2 1 0 ``` paulson@13437 ` 1265` ``` successor(M,n,sn) & membership(M,sn,msn) & ``` paulson@13437 ` 1266` ``` is_wfrec(M, iterates_MH(M, is_tl(M), l), msn, n, X) & ``` paulson@13437 ` 1267` ``` is_hd(M,X,Z)" ``` paulson@13437 ` 1268` ```constdefs nth_fm :: "[i,i,i]=>i" ``` paulson@13437 ` 1269` ``` "nth_fm(n,l,Z) == ``` paulson@13437 ` 1270` ``` Exists(Exists(Exists( ``` paulson@13437 ` 1271` ``` And(successor_fm(n#+3,1), ``` paulson@13437 ` 1272` ``` And(membership_fm(1,0), ``` paulson@13437 ` 1273` ``` And( ``` paulson@13437 ` 1274` ``` *) ``` paulson@13437 ` 1275` paulson@13437 ` 1276` ```theorem nth_reflection: ``` paulson@13437 ` 1277` ``` "REFLECTS[\x. is_nth(L, f(x), g(x), h(x)), ``` paulson@13437 ` 1278` ``` \i x. is_nth(**Lset(i), f(x), g(x), h(x))]" ``` paulson@13437 ` 1279` ```apply (simp only: is_nth_def setclass_simps) ``` paulson@13437 ` 1280` ```apply (intro FOL_reflections function_reflections is_wfrec_reflection ``` paulson@13437 ` 1281` ``` iterates_MH_reflection hd_reflection tl_reflection) ``` paulson@13437 ` 1282` ```done ``` paulson@13437 ` 1283` paulson@13437 ` 1284` ```theorem bool_of_o_reflection: ``` paulson@13440 ` 1285` ``` "REFLECTS [P(L), \i. P(**Lset(i))] ==> ``` paulson@13440 ` 1286` ``` REFLECTS[\x. is_bool_of_o(L, P(L,x), f(x)), ``` paulson@13440 ` 1287` ``` \i x. is_bool_of_o(**Lset(i), P(**Lset(i),x), f(x))]" ``` paulson@13440 ` 1288` ```apply (simp (no_asm) only: is_bool_of_o_def setclass_simps) ``` paulson@13441 ` 1289` ```apply (intro FOL_reflections function_reflections, assumption+) ``` paulson@13437 ` 1290` ```done ``` paulson@13437 ` 1291` paulson@13437 ` 1292` paulson@13409 ` 1293` ```subsubsection{*An Instance of Replacement for @{term nth}*} ``` paulson@13409 ` 1294` paulson@13409 ` 1295` ```lemma nth_replacement_Reflects: ``` paulson@13409 ` 1296` ``` "REFLECTS ``` paulson@13409 ` 1297` ``` [\x. \u[L]. u \ B \ (\y[L]. pair(L,u,y,x) \ ``` paulson@13409 ` 1298` ``` is_wfrec(L, iterates_MH(L, is_tl(L), z), memsn, u, y)), ``` paulson@13409 ` 1299` ``` \i x. \u \ Lset(i). u \ B \ (\y \ Lset(i). pair(**Lset(i), u, y, x) \ ``` wenzelm@13428 ` 1300` ``` is_wfrec(**Lset(i), ``` wenzelm@13428 ` 1301` ``` iterates_MH(**Lset(i), ``` paulson@13409 ` 1302` ``` is_tl(**Lset(i)), z), memsn, u, y))]" ``` wenzelm@13428 ` 1303` ```by (intro FOL_reflections function_reflections is_wfrec_reflection ``` wenzelm@13428 ` 1304` ``` iterates_MH_reflection list_functor_reflection tl_reflection) ``` paulson@13409 ` 1305` wenzelm@13428 ` 1306` ```lemma nth_replacement: ``` paulson@13409 ` 1307` ``` "L(w) ==> iterates_replacement(L, %l t. is_tl(L,l,t), w)" ``` paulson@13409 ` 1308` ```apply (unfold iterates_replacement_def wfrec_replacement_def, clarify) ``` wenzelm@13428 ` 1309` ```apply (rule strong_replacementI) ``` wenzelm@13428 ` 1310` ```apply (rule rallI) ``` wenzelm@13428 ` 1311` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 1312` ```apply (subgoal_tac "L(Memrel(succ(n)))") ``` wenzelm@13428 ` 1313` ```apply (rule_tac A="{A,n,w,z,Memrel(succ(n))}" in subset_LsetE, blast ) ``` paulson@13409 ` 1314` ```apply (rule ReflectsE [OF nth_replacement_Reflects], assumption) ``` wenzelm@13428 ` 1315` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13409 ` 1316` ```apply (erule reflection_imp_L_separation) ``` paulson@13409 ` 1317` ``` apply (simp_all add: lt_Ord2 Memrel_closed) ``` wenzelm@13428 ` 1318` ```apply (elim conjE) ``` paulson@13409 ` 1319` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 1320` ```apply (rename_tac v) ``` paulson@13409 ` 1321` ```apply (rule bex_iff_sats conj_iff_sats)+ ``` paulson@13409 ` 1322` ```apply (rule_tac env = "[u,v,A,z,w,Memrel(succ(n))]" in mem_iff_sats) ``` paulson@13434 ` 1323` ```apply (rule sep_rules is_nat_case_iff_sats tl_iff_sats ``` paulson@13441 ` 1324` ``` is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+ ``` paulson@13409 ` 1325` ```done ``` paulson@13409 ` 1326` paulson@13422 ` 1327` paulson@13422 ` 1328` paulson@13422 ` 1329` ```subsubsection{*Instantiating the locale @{text M_datatypes}*} ``` wenzelm@13428 ` 1330` paulson@13437 ` 1331` ```lemma M_datatypes_axioms_L: "M_datatypes_axioms(L)" ``` wenzelm@13428 ` 1332` ``` apply (rule M_datatypes_axioms.intro) ``` wenzelm@13428 ` 1333` ``` apply (assumption | rule ``` wenzelm@13428 ` 1334` ``` list_replacement1 list_replacement2 ``` wenzelm@13428 ` 1335` ``` formula_replacement1 formula_replacement2 ``` wenzelm@13428 ` 1336` ``` nth_replacement)+ ``` wenzelm@13428 ` 1337` ``` done ``` paulson@13422 ` 1338` paulson@13437 ` 1339` ```theorem M_datatypes_L: "PROP M_datatypes(L)" ``` paulson@13437 ` 1340` ``` apply (rule M_datatypes.intro) ``` paulson@13437 ` 1341` ``` apply (rule M_wfrank.axioms [OF M_wfrank_L])+ ``` paulson@13441 ` 1342` ``` apply (rule M_datatypes_axioms_L) ``` paulson@13437 ` 1343` ``` done ``` paulson@13437 ` 1344` wenzelm@13428 ` 1345` ```lemmas list_closed = M_datatypes.list_closed [OF M_datatypes_L] ``` wenzelm@13428 ` 1346` ``` and formula_closed = M_datatypes.formula_closed [OF M_datatypes_L] ``` wenzelm@13428 ` 1347` ``` and list_abs = M_datatypes.list_abs [OF M_datatypes_L] ``` wenzelm@13428 ` 1348` ``` and formula_abs = M_datatypes.formula_abs [OF M_datatypes_L] ``` wenzelm@13428 ` 1349` ``` and nth_abs = M_datatypes.nth_abs [OF M_datatypes_L] ``` paulson@13409 ` 1350` paulson@13422 ` 1351` ```declare list_closed [intro,simp] ``` paulson@13422 ` 1352` ```declare formula_closed [intro,simp] ``` paulson@13422 ` 1353` ```declare list_abs [simp] ``` paulson@13422 ` 1354` ```declare formula_abs [simp] ``` paulson@13422 ` 1355` ```declare nth_abs [simp] ``` paulson@13422 ` 1356` paulson@13422 ` 1357` wenzelm@13428 ` 1358` ```subsection{*@{term L} is Closed Under the Operator @{term eclose}*} ``` paulson@13422 ` 1359` paulson@13422 ` 1360` ```subsubsection{*Instances of Replacement for @{term eclose}*} ``` paulson@13422 ` 1361` paulson@13422 ` 1362` ```lemma eclose_replacement1_Reflects: ``` paulson@13422 ` 1363` ``` "REFLECTS ``` paulson@13422 ` 1364` ``` [\x. \u[L]. u \ B \ (\y[L]. pair(L,u,y,x) \ ``` paulson@13422 ` 1365` ``` is_wfrec(L, iterates_MH(L, big_union(L), A), memsn, u, y)), ``` paulson@13422 ` 1366` ``` \i x. \u \ Lset(i). u \ B \ (\y \ Lset(i). pair(**Lset(i), u, y, x) \ ``` wenzelm@13428 ` 1367` ``` is_wfrec(**Lset(i), ``` wenzelm@13428 ` 1368` ``` iterates_MH(**Lset(i), big_union(**Lset(i)), A), ``` paulson@13422 ` 1369` ``` memsn, u, y))]" ``` wenzelm@13428 ` 1370` ```by (intro FOL_reflections function_reflections is_wfrec_reflection ``` wenzelm@13428 ` 1371` ``` iterates_MH_reflection) ``` paulson@13422 ` 1372` wenzelm@13428 ` 1373` ```lemma eclose_replacement1: ``` paulson@13422 ` 1374` ``` "L(A) ==> iterates_replacement(L, big_union(L), A)" ``` paulson@13422 ` 1375` ```apply (unfold iterates_replacement_def wfrec_replacement_def, clarify) ``` wenzelm@13428 ` 1376` ```apply (rule strong_replacementI) ``` paulson@13422 ` 1377` ```apply (rule rallI) ``` wenzelm@13428 ` 1378` ```apply (rename_tac B) ``` wenzelm@13428 ` 1379` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 1380` ```apply (subgoal_tac "L(Memrel(succ(n)))") ``` wenzelm@13428 ` 1381` ```apply (rule_tac A="{B,A,n,z,Memrel(succ(n))}" in subset_LsetE, blast ) ``` paulson@13422 ` 1382` ```apply (rule ReflectsE [OF eclose_replacement1_Reflects], assumption) ``` wenzelm@13428 ` 1383` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13422 ` 1384` ```apply (erule reflection_imp_L_separation) ``` paulson@13422 ` 1385` ``` apply (simp_all add: lt_Ord2 Memrel_closed) ``` wenzelm@13428 ` 1386` ```apply (elim conjE) ``` paulson@13422 ` 1387` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 1388` ```apply (rename_tac v) ``` paulson@13422 ` 1389` ```apply (rule bex_iff_sats conj_iff_sats)+ ``` paulson@13422 ` 1390` ```apply (rule_tac env = "[u,v,A,n,B,Memrel(succ(n))]" in mem_iff_sats) ``` paulson@13434 ` 1391` ```apply (rule sep_rules iterates_MH_iff_sats is_nat_case_iff_sats ``` paulson@13441 ` 1392` ``` is_wfrec_iff_sats big_union_iff_sats quasinat_iff_sats | simp)+ ``` paulson@13409 ` 1393` ```done ``` paulson@13409 ` 1394` paulson@13422 ` 1395` paulson@13422 ` 1396` ```lemma eclose_replacement2_Reflects: ``` paulson@13422 ` 1397` ``` "REFLECTS ``` paulson@13422 ` 1398` ``` [\x. \u[L]. u \ B \ u \ nat \ ``` paulson@13422 ` 1399` ``` (\sn[L]. \msn[L]. successor(L, u, sn) \ membership(L, sn, msn) \ ``` paulson@13422 ` 1400` ``` is_wfrec (L, iterates_MH (L, big_union(L), A), ``` paulson@13422 ` 1401` ``` msn, u, x)), ``` paulson@13422 ` 1402` ``` \i x. \u \ Lset(i). u \ B \ u \ nat \ ``` wenzelm@13428 ` 1403` ``` (\sn \ Lset(i). \msn \ Lset(i). ``` paulson@13422 ` 1404` ``` successor(**Lset(i), u, sn) \ membership(**Lset(i), sn, msn) \ ``` wenzelm@13428 ` 1405` ``` is_wfrec (**Lset(i), ``` paulson@13422 ` 1406` ``` iterates_MH (**Lset(i), big_union(**Lset(i)), A), ``` paulson@13422 ` 1407` ``` msn, u, x))]" ``` wenzelm@13428 ` 1408` ```by (intro FOL_reflections function_reflections is_wfrec_reflection ``` wenzelm@13428 ` 1409` ``` iterates_MH_reflection) ``` paulson@13422 ` 1410` paulson@13422 ` 1411` wenzelm@13428 ` 1412` ```lemma eclose_replacement2: ``` wenzelm@13428 ` 1413` ``` "L(A) ==> strong_replacement(L, ``` wenzelm@13428 ` 1414` ``` \n y. n\nat & ``` paulson@13422 ` 1415` ``` (\sn[L]. \msn[L]. successor(L,n,sn) & membership(L,sn,msn) & ``` wenzelm@13428 ` 1416` ``` is_wfrec(L, iterates_MH(L,big_union(L), A), ``` paulson@13422 ` 1417` ``` msn, n, y)))" ``` wenzelm@13428 ` 1418` ```apply (rule strong_replacementI) ``` paulson@13422 ` 1419` ```apply (rule rallI) ``` wenzelm@13428 ` 1420` ```apply (rename_tac B) ``` wenzelm@13428 ` 1421` ```apply (rule separation_CollectI) ``` wenzelm@13428 ` 1422` ```apply (rule_tac A="{A,B,z,nat}" in subset_LsetE) ``` wenzelm@13428 ` 1423` ```apply (blast intro: L_nat) ``` paulson@13422 ` 1424` ```apply (rule ReflectsE [OF eclose_replacement2_Reflects], assumption) ``` wenzelm@13428 ` 1425` ```apply (drule subset_Lset_ltD, assumption) ``` paulson@13422 ` 1426` ```apply (erule reflection_imp_L_separation) ``` paulson@13422 ` 1427` ``` apply (simp_all add: lt_Ord2) ``` paulson@13422 ` 1428` ```apply (rule DPow_LsetI) ``` wenzelm@13428 ` 1429` ```apply (rename_tac v) ``` paulson@13422 ` 1430` ```apply (rule bex_iff_sats conj_iff_sats)+ ``` paulson@13422 ` 1431` ```apply (rule_tac env = "[u,v,A,B,nat]" in mem_iff_sats) ``` paulson@13434 ` 1432` ```apply (rule sep_rules is_nat_case_iff_sats iterates_MH_iff_sats ``` paulson@13441 ` 1433` ``` is_wfrec_iff_sats big_union_iff_sats quasinat_iff_sats | simp)+ ``` paulson@13422 ` 1434` ```done ``` paulson@13422 ` 1435` paulson@13422 ` 1436` paulson@13422 ` 1437` ```subsubsection{*Instantiating the locale @{text M_eclose}*} ``` paulson@13422 ` 1438` paulson@13437 ` 1439` ```lemma M_eclose_axioms_L: "M_eclose_axioms(L)" ``` paulson@13437 ` 1440` ``` apply (rule M_eclose_axioms.intro) ``` paulson@13437 ` 1441` ``` apply (assumption | rule eclose_replacement1 eclose_replacement2)+ ``` paulson@13437 ` 1442` ``` done ``` paulson@13437 ` 1443` wenzelm@13428 ` 1444` ```theorem M_eclose_L: "PROP M_eclose(L)" ``` wenzelm@13428 ` 1445` ``` apply (rule M_eclose.intro) ``` wenzelm@13429 ` 1446` ``` apply (rule M_datatypes.axioms [OF M_datatypes_L])+ ``` paulson@13437 ` 1447` ``` apply (rule M_eclose_axioms_L) ``` wenzelm@13428 ` 1448` ``` done ``` paulson@13422 ` 1449` wenzelm@13428 ` 1450` ```lemmas eclose_closed [intro, simp] = M_eclose.eclose_closed [OF M_eclose_L] ``` wenzelm@13428 ` 1451` ``` and eclose_abs [intro, simp] = M_eclose.eclose_abs [OF M_eclose_L] ``` paulson@13440 ` 1452` ``` and transrec_replacementI = M_eclose.transrec_replacementI [OF M_eclose_L] ``` paulson@13422 ` 1453` paulson@13348 ` 1454` ```end ```