src/ZF/Constructible/Rec_Separation.thy
author paulson
Fri Oct 18 17:50:13 2002 +0200 (2002-10-18)
changeset 13655 95b95cdb4704
parent 13651 ac80e101306a
child 13687 22dce9134953
permissions -rw-r--r--
Tidying up. New primitives is_iterates and is_iterates_fm.
     1 (*  Title:      ZF/Constructible/Rec_Separation.thy
     2     ID:   $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4 *)
     5 
     6 header {*Separation for Facts About Recursion*}
     7 
     8 theory Rec_Separation = Separation + Internalize:
     9 
    10 text{*This theory proves all instances needed for locales @{text
    11 "M_trancl"} and @{text "M_datatypes"}*}
    12 
    13 lemma eq_succ_imp_lt: "[|i = succ(j); Ord(i)|] ==> j<i"
    14 by simp
    15 
    16 
    17 subsection{*The Locale @{text "M_trancl"}*}
    18 
    19 subsubsection{*Separation for Reflexive/Transitive Closure*}
    20 
    21 text{*First, The Defining Formula*}
    22 
    23 (* "rtran_closure_mem(M,A,r,p) ==
    24       \<exists>nnat[M]. \<exists>n[M]. \<exists>n'[M].
    25        omega(M,nnat) & n\<in>nnat & successor(M,n,n') &
    26        (\<exists>f[M]. typed_function(M,n',A,f) &
    27         (\<exists>x[M]. \<exists>y[M]. \<exists>zero[M]. pair(M,x,y,p) & empty(M,zero) &
    28           fun_apply(M,f,zero,x) & fun_apply(M,f,n,y)) &
    29         (\<forall>j[M]. j\<in>n -->
    30           (\<exists>fj[M]. \<exists>sj[M]. \<exists>fsj[M]. \<exists>ffp[M].
    31             fun_apply(M,f,j,fj) & successor(M,j,sj) &
    32             fun_apply(M,f,sj,fsj) & pair(M,fj,fsj,ffp) & ffp \<in> r)))"*)
    33 constdefs rtran_closure_mem_fm :: "[i,i,i]=>i"
    34  "rtran_closure_mem_fm(A,r,p) ==
    35    Exists(Exists(Exists(
    36     And(omega_fm(2),
    37      And(Member(1,2),
    38       And(succ_fm(1,0),
    39        Exists(And(typed_function_fm(1, A#+4, 0),
    40         And(Exists(Exists(Exists(
    41               And(pair_fm(2,1,p#+7),
    42                And(empty_fm(0),
    43                 And(fun_apply_fm(3,0,2), fun_apply_fm(3,5,1))))))),
    44             Forall(Implies(Member(0,3),
    45              Exists(Exists(Exists(Exists(
    46               And(fun_apply_fm(5,4,3),
    47                And(succ_fm(4,2),
    48                 And(fun_apply_fm(5,2,1),
    49                  And(pair_fm(3,1,0), Member(0,r#+9))))))))))))))))))))"
    50 
    51 
    52 lemma rtran_closure_mem_type [TC]:
    53  "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> rtran_closure_mem_fm(x,y,z) \<in> formula"
    54 by (simp add: rtran_closure_mem_fm_def)
    55 
    56 lemma sats_rtran_closure_mem_fm [simp]:
    57    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
    58     ==> sats(A, rtran_closure_mem_fm(x,y,z), env) <->
    59         rtran_closure_mem(**A, nth(x,env), nth(y,env), nth(z,env))"
    60 by (simp add: rtran_closure_mem_fm_def rtran_closure_mem_def)
    61 
    62 lemma rtran_closure_mem_iff_sats:
    63       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
    64           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
    65        ==> rtran_closure_mem(**A, x, y, z) <-> sats(A, rtran_closure_mem_fm(i,j,k), env)"
    66 by (simp add: sats_rtran_closure_mem_fm)
    67 
    68 lemma rtran_closure_mem_reflection:
    69      "REFLECTS[\<lambda>x. rtran_closure_mem(L,f(x),g(x),h(x)),
    70                \<lambda>i x. rtran_closure_mem(**Lset(i),f(x),g(x),h(x))]"
    71 apply (simp only: rtran_closure_mem_def)
    72 apply (intro FOL_reflections function_reflections fun_plus_reflections)
    73 done
    74 
    75 text{*Separation for @{term "rtrancl(r)"}.*}
    76 lemma rtrancl_separation:
    77      "[| L(r); L(A) |] ==> separation (L, rtran_closure_mem(L,A,r))"
    78 apply (rule gen_separation [OF rtran_closure_mem_reflection, of "{r,A}"], simp)
    79 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
    80 apply (rule DPow_LsetI)
    81 apply (rule_tac env = "[x,r,A]" in rtran_closure_mem_iff_sats)
    82 apply (rule sep_rules | simp)+
    83 done
    84 
    85 
    86 subsubsection{*Reflexive/Transitive Closure, Internalized*}
    87 
    88 (*  "rtran_closure(M,r,s) ==
    89         \<forall>A[M]. is_field(M,r,A) -->
    90          (\<forall>p[M]. p \<in> s <-> rtran_closure_mem(M,A,r,p))" *)
    91 constdefs rtran_closure_fm :: "[i,i]=>i"
    92  "rtran_closure_fm(r,s) ==
    93    Forall(Implies(field_fm(succ(r),0),
    94                   Forall(Iff(Member(0,succ(succ(s))),
    95                              rtran_closure_mem_fm(1,succ(succ(r)),0)))))"
    96 
    97 lemma rtran_closure_type [TC]:
    98      "[| x \<in> nat; y \<in> nat |] ==> rtran_closure_fm(x,y) \<in> formula"
    99 by (simp add: rtran_closure_fm_def)
   100 
   101 lemma sats_rtran_closure_fm [simp]:
   102    "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   103     ==> sats(A, rtran_closure_fm(x,y), env) <->
   104         rtran_closure(**A, nth(x,env), nth(y,env))"
   105 by (simp add: rtran_closure_fm_def rtran_closure_def)
   106 
   107 lemma rtran_closure_iff_sats:
   108       "[| nth(i,env) = x; nth(j,env) = y;
   109           i \<in> nat; j \<in> nat; env \<in> list(A)|]
   110        ==> rtran_closure(**A, x, y) <-> sats(A, rtran_closure_fm(i,j), env)"
   111 by simp
   112 
   113 theorem rtran_closure_reflection:
   114      "REFLECTS[\<lambda>x. rtran_closure(L,f(x),g(x)),
   115                \<lambda>i x. rtran_closure(**Lset(i),f(x),g(x))]"
   116 apply (simp only: rtran_closure_def)
   117 apply (intro FOL_reflections function_reflections rtran_closure_mem_reflection)
   118 done
   119 
   120 
   121 subsubsection{*Transitive Closure of a Relation, Internalized*}
   122 
   123 (*  "tran_closure(M,r,t) ==
   124          \<exists>s[M]. rtran_closure(M,r,s) & composition(M,r,s,t)" *)
   125 constdefs tran_closure_fm :: "[i,i]=>i"
   126  "tran_closure_fm(r,s) ==
   127    Exists(And(rtran_closure_fm(succ(r),0), composition_fm(succ(r),0,succ(s))))"
   128 
   129 lemma tran_closure_type [TC]:
   130      "[| x \<in> nat; y \<in> nat |] ==> tran_closure_fm(x,y) \<in> formula"
   131 by (simp add: tran_closure_fm_def)
   132 
   133 lemma sats_tran_closure_fm [simp]:
   134    "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   135     ==> sats(A, tran_closure_fm(x,y), env) <->
   136         tran_closure(**A, nth(x,env), nth(y,env))"
   137 by (simp add: tran_closure_fm_def tran_closure_def)
   138 
   139 lemma tran_closure_iff_sats:
   140       "[| nth(i,env) = x; nth(j,env) = y;
   141           i \<in> nat; j \<in> nat; env \<in> list(A)|]
   142        ==> tran_closure(**A, x, y) <-> sats(A, tran_closure_fm(i,j), env)"
   143 by simp
   144 
   145 theorem tran_closure_reflection:
   146      "REFLECTS[\<lambda>x. tran_closure(L,f(x),g(x)),
   147                \<lambda>i x. tran_closure(**Lset(i),f(x),g(x))]"
   148 apply (simp only: tran_closure_def)
   149 apply (intro FOL_reflections function_reflections
   150              rtran_closure_reflection composition_reflection)
   151 done
   152 
   153 
   154 subsubsection{*Separation for the Proof of @{text "wellfounded_on_trancl"}*}
   155 
   156 lemma wellfounded_trancl_reflects:
   157   "REFLECTS[\<lambda>x. \<exists>w[L]. \<exists>wx[L]. \<exists>rp[L].
   158                  w \<in> Z & pair(L,w,x,wx) & tran_closure(L,r,rp) & wx \<in> rp,
   159    \<lambda>i x. \<exists>w \<in> Lset(i). \<exists>wx \<in> Lset(i). \<exists>rp \<in> Lset(i).
   160        w \<in> Z & pair(**Lset(i),w,x,wx) & tran_closure(**Lset(i),r,rp) &
   161        wx \<in> rp]"
   162 by (intro FOL_reflections function_reflections fun_plus_reflections
   163           tran_closure_reflection)
   164 
   165 lemma wellfounded_trancl_separation:
   166          "[| L(r); L(Z) |] ==>
   167           separation (L, \<lambda>x.
   168               \<exists>w[L]. \<exists>wx[L]. \<exists>rp[L].
   169                w \<in> Z & pair(L,w,x,wx) & tran_closure(L,r,rp) & wx \<in> rp)"
   170 apply (rule gen_separation [OF wellfounded_trancl_reflects, of "{r,Z}"], simp)
   171 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
   172 apply (rule DPow_LsetI)
   173 apply (rule bex_iff_sats conj_iff_sats)+
   174 apply (rule_tac env = "[w,x,r,Z]" in mem_iff_sats)
   175 apply (rule sep_rules tran_closure_iff_sats | simp)+
   176 done
   177 
   178 
   179 subsubsection{*Instantiating the locale @{text M_trancl}*}
   180 
   181 lemma M_trancl_axioms_L: "M_trancl_axioms(L)"
   182   apply (rule M_trancl_axioms.intro)
   183    apply (assumption | rule rtrancl_separation wellfounded_trancl_separation)+
   184   done
   185 
   186 theorem M_trancl_L: "PROP M_trancl(L)"
   187 by (rule M_trancl.intro
   188          [OF M_trivial_L M_basic_axioms_L M_trancl_axioms_L])
   189 
   190 lemmas iterates_abs = M_trancl.iterates_abs [OF M_trancl_L]
   191   and rtran_closure_rtrancl = M_trancl.rtran_closure_rtrancl [OF M_trancl_L]
   192   and trans_wfrec_abs = M_trancl.trans_wfrec_abs [OF M_trancl_L]
   193   and eq_pair_wfrec_iff = M_trancl.eq_pair_wfrec_iff [OF M_trancl_L]
   194 
   195 
   196 
   197 subsection{*@{term L} is Closed Under the Operator @{term list}*}
   198 
   199 subsubsection{*Instances of Replacement for Lists*}
   200 
   201 lemma list_replacement1_Reflects:
   202  "REFLECTS
   203    [\<lambda>x. \<exists>u[L]. u \<in> B \<and> (\<exists>y[L]. pair(L,u,y,x) \<and>
   204          is_wfrec(L, iterates_MH(L, is_list_functor(L,A), 0), memsn, u, y)),
   205     \<lambda>i x. \<exists>u \<in> Lset(i). u \<in> B \<and> (\<exists>y \<in> Lset(i). pair(**Lset(i), u, y, x) \<and>
   206          is_wfrec(**Lset(i),
   207                   iterates_MH(**Lset(i),
   208                           is_list_functor(**Lset(i), A), 0), memsn, u, y))]"
   209 by (intro FOL_reflections function_reflections is_wfrec_reflection
   210           iterates_MH_reflection list_functor_reflection)
   211 
   212 
   213 lemma list_replacement1:
   214    "L(A) ==> iterates_replacement(L, is_list_functor(L,A), 0)"
   215 apply (unfold iterates_replacement_def wfrec_replacement_def, clarify)
   216 apply (rule strong_replacementI)
   217 apply (rename_tac B)
   218 apply (rule_tac u="{B,A,n,0,Memrel(succ(n))}" 
   219          in gen_separation [OF list_replacement1_Reflects], 
   220        simp add: nonempty)
   221 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
   222 apply (rule DPow_LsetI)
   223 apply (rule bex_iff_sats conj_iff_sats)+
   224 apply (rule_tac env = "[u,x,A,n,B,0,Memrel(succ(n))]" in mem_iff_sats)
   225 apply (rule sep_rules is_nat_case_iff_sats list_functor_iff_sats
   226             is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+
   227 done
   228 
   229 
   230 lemma list_replacement2_Reflects:
   231  "REFLECTS
   232    [\<lambda>x. \<exists>u[L]. u \<in> B & u \<in> nat &
   233                 is_iterates(L, is_list_functor(L, A), 0, u, x),
   234     \<lambda>i x. \<exists>u \<in> Lset(i). u \<in> B & u \<in> nat &
   235                is_iterates(**Lset(i), is_list_functor(**Lset(i), A), 0, u, x)]"
   236 by (intro FOL_reflections 
   237           is_iterates_reflection list_functor_reflection)
   238 
   239 lemma list_replacement2:
   240    "L(A) ==> strong_replacement(L,
   241          \<lambda>n y. n\<in>nat & is_iterates(L, is_list_functor(L,A), 0, n, y))"
   242 apply (rule strong_replacementI)
   243 apply (rename_tac B)
   244 apply (rule_tac u="{A,B,0,nat}" 
   245          in gen_separation [OF list_replacement2_Reflects], 
   246        simp add: L_nat nonempty)
   247 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
   248 apply (rule DPow_LsetI)
   249 apply (rule bex_iff_sats conj_iff_sats)+
   250 apply (rule_tac env = "[u,x,A,B,0,nat]" in mem_iff_sats)
   251 apply (rule sep_rules list_functor_iff_sats is_iterates_iff_sats | simp)+
   252 done
   253 
   254 
   255 subsection{*@{term L} is Closed Under the Operator @{term formula}*}
   256 
   257 subsubsection{*Instances of Replacement for Formulas*}
   258 
   259 (*FIXME: could prove a lemma iterates_replacementI to eliminate the 
   260 need to expand iterates_replacement and wfrec_replacement*)
   261 lemma formula_replacement1_Reflects:
   262  "REFLECTS
   263    [\<lambda>x. \<exists>u[L]. u \<in> B & (\<exists>y[L]. pair(L,u,y,x) &
   264          is_wfrec(L, iterates_MH(L, is_formula_functor(L), 0), memsn, u, y)),
   265     \<lambda>i x. \<exists>u \<in> Lset(i). u \<in> B & (\<exists>y \<in> Lset(i). pair(**Lset(i), u, y, x) &
   266          is_wfrec(**Lset(i),
   267                   iterates_MH(**Lset(i),
   268                           is_formula_functor(**Lset(i)), 0), memsn, u, y))]"
   269 by (intro FOL_reflections function_reflections is_wfrec_reflection
   270           iterates_MH_reflection formula_functor_reflection)
   271 
   272 lemma formula_replacement1:
   273    "iterates_replacement(L, is_formula_functor(L), 0)"
   274 apply (unfold iterates_replacement_def wfrec_replacement_def, clarify)
   275 apply (rule strong_replacementI)
   276 apply (rename_tac B)
   277 apply (rule_tac u="{B,n,0,Memrel(succ(n))}" 
   278          in gen_separation [OF formula_replacement1_Reflects], 
   279        simp add: nonempty)
   280 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
   281 apply (rule DPow_LsetI)
   282 apply (rule bex_iff_sats conj_iff_sats)+
   283 apply (rule_tac env = "[u,x,n,B,0,Memrel(succ(n))]" in mem_iff_sats)
   284 apply (rule sep_rules is_nat_case_iff_sats formula_functor_iff_sats
   285             is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+
   286 done
   287 
   288 lemma formula_replacement2_Reflects:
   289  "REFLECTS
   290    [\<lambda>x. \<exists>u[L]. u \<in> B & u \<in> nat &
   291                 is_iterates(L, is_formula_functor(L), 0, u, x),
   292     \<lambda>i x. \<exists>u \<in> Lset(i). u \<in> B & u \<in> nat &
   293                is_iterates(**Lset(i), is_formula_functor(**Lset(i)), 0, u, x)]"
   294 by (intro FOL_reflections 
   295           is_iterates_reflection formula_functor_reflection)
   296 
   297 lemma formula_replacement2:
   298    "strong_replacement(L,
   299          \<lambda>n y. n\<in>nat & is_iterates(L, is_formula_functor(L), 0, n, y))"
   300 apply (rule strong_replacementI)
   301 apply (rename_tac B)
   302 apply (rule_tac u="{B,0,nat}" 
   303          in gen_separation [OF formula_replacement2_Reflects], 
   304        simp add: nonempty L_nat)
   305 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
   306 apply (rule DPow_LsetI)
   307 apply (rule bex_iff_sats conj_iff_sats)+
   308 apply (rule_tac env = "[u,x,B,0,nat]" in mem_iff_sats)
   309 apply (rule sep_rules formula_functor_iff_sats is_iterates_iff_sats | simp)+
   310 done
   311 
   312 text{*NB The proofs for type @{term formula} are virtually identical to those
   313 for @{term "list(A)"}.  It was a cut-and-paste job! *}
   314 
   315 
   316 subsubsection{*The Formula @{term is_nth}, Internalized*}
   317 
   318 (* "is_nth(M,n,l,Z) ==
   319       \<exists>X[M]. is_iterates(M, is_tl(M), l, n, X) & is_hd(M,X,Z)" *)
   320 constdefs nth_fm :: "[i,i,i]=>i"
   321     "nth_fm(n,l,Z) == 
   322        Exists(And(is_iterates_fm(tl_fm(1,0), succ(l), succ(n), 0), 
   323               hd_fm(0,succ(Z))))"
   324 
   325 lemma nth_fm_type [TC]:
   326  "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> nth_fm(x,y,z) \<in> formula"
   327 by (simp add: nth_fm_def)
   328 
   329 lemma sats_nth_fm [simp]:
   330    "[| x < length(env); y \<in> nat; z \<in> nat; env \<in> list(A)|]
   331     ==> sats(A, nth_fm(x,y,z), env) <->
   332         is_nth(**A, nth(x,env), nth(y,env), nth(z,env))"
   333 apply (frule lt_length_in_nat, assumption)  
   334 apply (simp add: nth_fm_def is_nth_def sats_is_iterates_fm) 
   335 done
   336 
   337 lemma nth_iff_sats:
   338       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
   339           i < length(env); j \<in> nat; k \<in> nat; env \<in> list(A)|]
   340        ==> is_nth(**A, x, y, z) <-> sats(A, nth_fm(i,j,k), env)"
   341 by (simp add: sats_nth_fm)
   342 
   343 theorem nth_reflection:
   344      "REFLECTS[\<lambda>x. is_nth(L, f(x), g(x), h(x)),  
   345                \<lambda>i x. is_nth(**Lset(i), f(x), g(x), h(x))]"
   346 apply (simp only: is_nth_def)
   347 apply (intro FOL_reflections is_iterates_reflection
   348              hd_reflection tl_reflection) 
   349 done
   350 
   351 
   352 subsubsection{*An Instance of Replacement for @{term nth}*}
   353 
   354 (*FIXME: could prove a lemma iterates_replacementI to eliminate the 
   355 need to expand iterates_replacement and wfrec_replacement*)
   356 lemma nth_replacement_Reflects:
   357  "REFLECTS
   358    [\<lambda>x. \<exists>u[L]. u \<in> B & (\<exists>y[L]. pair(L,u,y,x) &
   359          is_wfrec(L, iterates_MH(L, is_tl(L), z), memsn, u, y)),
   360     \<lambda>i x. \<exists>u \<in> Lset(i). u \<in> B & (\<exists>y \<in> Lset(i). pair(**Lset(i), u, y, x) &
   361          is_wfrec(**Lset(i),
   362                   iterates_MH(**Lset(i),
   363                           is_tl(**Lset(i)), z), memsn, u, y))]"
   364 by (intro FOL_reflections function_reflections is_wfrec_reflection
   365           iterates_MH_reflection tl_reflection)
   366 
   367 lemma nth_replacement:
   368    "L(w) ==> iterates_replacement(L, is_tl(L), w)"
   369 apply (unfold iterates_replacement_def wfrec_replacement_def, clarify)
   370 apply (rule strong_replacementI)
   371 apply (rule_tac u="{A,n,w,Memrel(succ(n))}" 
   372          in gen_separation [OF nth_replacement_Reflects], 
   373        simp add: nonempty)
   374 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
   375 apply (rule DPow_LsetI)
   376 apply (rule bex_iff_sats conj_iff_sats)+
   377 apply (rule_tac env = "[u,x,A,w,Memrel(succ(n))]" in mem_iff_sats)
   378 apply (rule sep_rules is_nat_case_iff_sats tl_iff_sats
   379             is_wfrec_iff_sats iterates_MH_iff_sats quasinat_iff_sats | simp)+
   380 done
   381 
   382 
   383 subsubsection{*Instantiating the locale @{text M_datatypes}*}
   384 
   385 lemma M_datatypes_axioms_L: "M_datatypes_axioms(L)"
   386   apply (rule M_datatypes_axioms.intro)
   387       apply (assumption | rule
   388         list_replacement1 list_replacement2
   389         formula_replacement1 formula_replacement2
   390         nth_replacement)+
   391   done
   392 
   393 theorem M_datatypes_L: "PROP M_datatypes(L)"
   394   apply (rule M_datatypes.intro)
   395       apply (rule M_trancl.axioms [OF M_trancl_L])+
   396  apply (rule M_datatypes_axioms_L) 
   397  done
   398 
   399 lemmas list_closed = M_datatypes.list_closed [OF M_datatypes_L]
   400   and formula_closed = M_datatypes.formula_closed [OF M_datatypes_L]
   401   and list_abs = M_datatypes.list_abs [OF M_datatypes_L]
   402   and formula_abs = M_datatypes.formula_abs [OF M_datatypes_L]
   403   and nth_abs = M_datatypes.nth_abs [OF M_datatypes_L]
   404 
   405 declare list_closed [intro,simp]
   406 declare formula_closed [intro,simp]
   407 declare list_abs [simp]
   408 declare formula_abs [simp]
   409 declare nth_abs [simp]
   410 
   411 
   412 subsection{*@{term L} is Closed Under the Operator @{term eclose}*}
   413 
   414 subsubsection{*Instances of Replacement for @{term eclose}*}
   415 
   416 lemma eclose_replacement1_Reflects:
   417  "REFLECTS
   418    [\<lambda>x. \<exists>u[L]. u \<in> B & (\<exists>y[L]. pair(L,u,y,x) &
   419          is_wfrec(L, iterates_MH(L, big_union(L), A), memsn, u, y)),
   420     \<lambda>i x. \<exists>u \<in> Lset(i). u \<in> B & (\<exists>y \<in> Lset(i). pair(**Lset(i), u, y, x) &
   421          is_wfrec(**Lset(i),
   422                   iterates_MH(**Lset(i), big_union(**Lset(i)), A),
   423                   memsn, u, y))]"
   424 by (intro FOL_reflections function_reflections is_wfrec_reflection
   425           iterates_MH_reflection)
   426 
   427 lemma eclose_replacement1:
   428    "L(A) ==> iterates_replacement(L, big_union(L), A)"
   429 apply (unfold iterates_replacement_def wfrec_replacement_def, clarify)
   430 apply (rule strong_replacementI)
   431 apply (rename_tac B)
   432 apply (rule_tac u="{B,A,n,Memrel(succ(n))}" 
   433          in gen_separation [OF eclose_replacement1_Reflects], simp)
   434 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
   435 apply (rule DPow_LsetI)
   436 apply (rule bex_iff_sats conj_iff_sats)+
   437 apply (rule_tac env = "[u,x,A,n,B,Memrel(succ(n))]" in mem_iff_sats)
   438 apply (rule sep_rules iterates_MH_iff_sats is_nat_case_iff_sats
   439              is_wfrec_iff_sats big_union_iff_sats quasinat_iff_sats | simp)+
   440 done
   441 
   442 
   443 lemma eclose_replacement2_Reflects:
   444  "REFLECTS
   445    [\<lambda>x. \<exists>u[L]. u \<in> B & u \<in> nat &
   446                 is_iterates(L, big_union(L), A, u, x),
   447     \<lambda>i x. \<exists>u \<in> Lset(i). u \<in> B & u \<in> nat &
   448                is_iterates(**Lset(i), big_union(**Lset(i)), A, u, x)]"
   449 by (intro FOL_reflections function_reflections is_iterates_reflection)
   450 
   451 lemma eclose_replacement2:
   452    "L(A) ==> strong_replacement(L,
   453          \<lambda>n y. n\<in>nat & is_iterates(L, big_union(L), A, n, y))"
   454 apply (rule strong_replacementI)
   455 apply (rename_tac B)
   456 apply (rule_tac u="{A,B,nat}" 
   457          in gen_separation [OF eclose_replacement2_Reflects], simp add: L_nat)
   458 apply (drule mem_Lset_imp_subset_Lset, clarsimp)
   459 apply (rule DPow_LsetI)
   460 apply (rule bex_iff_sats conj_iff_sats)+
   461 apply (rule_tac env = "[u,x,A,B,nat]" in mem_iff_sats)
   462 apply (rule sep_rules is_iterates_iff_sats big_union_iff_sats | simp)+
   463 done
   464 
   465 
   466 subsubsection{*Instantiating the locale @{text M_eclose}*}
   467 
   468 lemma M_eclose_axioms_L: "M_eclose_axioms(L)"
   469   apply (rule M_eclose_axioms.intro)
   470    apply (assumption | rule eclose_replacement1 eclose_replacement2)+
   471   done
   472 
   473 theorem M_eclose_L: "PROP M_eclose(L)"
   474   apply (rule M_eclose.intro)
   475        apply (rule M_datatypes.axioms [OF M_datatypes_L])+
   476   apply (rule M_eclose_axioms_L)
   477   done
   478 
   479 lemmas eclose_closed [intro, simp] = M_eclose.eclose_closed [OF M_eclose_L]
   480   and eclose_abs [intro, simp] = M_eclose.eclose_abs [OF M_eclose_L]
   481   and transrec_replacementI = M_eclose.transrec_replacementI [OF M_eclose_L]
   482 
   483 end