src/ZF/Constructible/Separation.thy
author paulson
Wed Aug 21 15:57:24 2002 +0200 (2002-08-21)
changeset 13513 b9e14471629c
parent 13505 52a16cb7fefb
child 13564 1500a2e48d44
permissions -rw-r--r--
tweaks
     1 (*  Title:      ZF/Constructible/Separation.thy
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   2002  University of Cambridge
     5 *)
     6 
     7 header{*Early Instances of Separation and Strong Replacement*}
     8 
     9 theory Separation = L_axioms + WF_absolute:
    10 
    11 text{*This theory proves all instances needed for locale @{text "M_axioms"}*}
    12 
    13 text{*Helps us solve for de Bruijn indices!*}
    14 lemma nth_ConsI: "[|nth(n,l) = x; n \<in> nat|] ==> nth(succ(n), Cons(a,l)) = x"
    15 by simp
    16 
    17 lemmas nth_rules = nth_0 nth_ConsI nat_0I nat_succI
    18 lemmas sep_rules = nth_0 nth_ConsI FOL_iff_sats function_iff_sats
    19                    fun_plus_iff_sats
    20 
    21 lemma Collect_conj_in_DPow:
    22      "[| {x\<in>A. P(x)} \<in> DPow(A);  {x\<in>A. Q(x)} \<in> DPow(A) |]
    23       ==> {x\<in>A. P(x) & Q(x)} \<in> DPow(A)"
    24 by (simp add: Int_in_DPow Collect_Int_Collect_eq [symmetric])
    25 
    26 lemma Collect_conj_in_DPow_Lset:
    27      "[|z \<in> Lset(j); {x \<in> Lset(j). P(x)} \<in> DPow(Lset(j))|]
    28       ==> {x \<in> Lset(j). x \<in> z & P(x)} \<in> DPow(Lset(j))"
    29 apply (frule mem_Lset_imp_subset_Lset)
    30 apply (simp add: Collect_conj_in_DPow Collect_mem_eq
    31                  subset_Int_iff2 elem_subset_in_DPow)
    32 done
    33 
    34 lemma separation_CollectI:
    35      "(\<And>z. L(z) ==> L({x \<in> z . P(x)})) ==> separation(L, \<lambda>x. P(x))"
    36 apply (unfold separation_def, clarify)
    37 apply (rule_tac x="{x\<in>z. P(x)}" in rexI)
    38 apply simp_all
    39 done
    40 
    41 text{*Reduces the original comprehension to the reflected one*}
    42 lemma reflection_imp_L_separation:
    43       "[| \<forall>x\<in>Lset(j). P(x) <-> Q(x);
    44           {x \<in> Lset(j) . Q(x)} \<in> DPow(Lset(j));
    45           Ord(j);  z \<in> Lset(j)|] ==> L({x \<in> z . P(x)})"
    46 apply (rule_tac i = "succ(j)" in L_I)
    47  prefer 2 apply simp
    48 apply (subgoal_tac "{x \<in> z. P(x)} = {x \<in> Lset(j). x \<in> z & (Q(x))}")
    49  prefer 2
    50  apply (blast dest: mem_Lset_imp_subset_Lset)
    51 apply (simp add: Lset_succ Collect_conj_in_DPow_Lset)
    52 done
    53 
    54 
    55 subsection{*Separation for Intersection*}
    56 
    57 lemma Inter_Reflects:
    58      "REFLECTS[\<lambda>x. \<forall>y[L]. y\<in>A --> x \<in> y,
    59                \<lambda>i x. \<forall>y\<in>Lset(i). y\<in>A --> x \<in> y]"
    60 by (intro FOL_reflections)
    61 
    62 lemma Inter_separation:
    63      "L(A) ==> separation(L, \<lambda>x. \<forall>y[L]. y\<in>A --> x\<in>y)"
    64 apply (rule separation_CollectI)
    65 apply (rule_tac A="{A,z}" in subset_LsetE, blast)
    66 apply (rule ReflectsE [OF Inter_Reflects], assumption)
    67 apply (drule subset_Lset_ltD, assumption)
    68 apply (erule reflection_imp_L_separation)
    69   apply (simp_all add: lt_Ord2, clarify)
    70 apply (rule DPow_LsetI)
    71 apply (rule ball_iff_sats)
    72 apply (rule imp_iff_sats)
    73 apply (rule_tac [2] i=1 and j=0 and env="[y,x,A]" in mem_iff_sats)
    74 apply (rule_tac i=0 and j=2 in mem_iff_sats)
    75 apply (simp_all add: succ_Un_distrib [symmetric])
    76 done
    77 
    78 subsection{*Separation for Set Difference*}
    79 
    80 lemma Diff_Reflects:
    81      "REFLECTS[\<lambda>x. x \<notin> B, \<lambda>i x. x \<notin> B]"
    82 by (intro FOL_reflections)  
    83 
    84 lemma Diff_separation:
    85      "L(B) ==> separation(L, \<lambda>x. x \<notin> B)"
    86 apply (rule separation_CollectI) 
    87 apply (rule_tac A="{B,z}" in subset_LsetE, blast) 
    88 apply (rule ReflectsE [OF Diff_Reflects], assumption)
    89 apply (drule subset_Lset_ltD, assumption) 
    90 apply (erule reflection_imp_L_separation)
    91   apply (simp_all add: lt_Ord2, clarify)
    92 apply (rule DPow_LsetI) 
    93 apply (rule not_iff_sats) 
    94 apply (rule_tac env="[x,B]" in mem_iff_sats)
    95 apply (rule sep_rules | simp)+
    96 done
    97 
    98 subsection{*Separation for Cartesian Product*}
    99 
   100 lemma cartprod_Reflects:
   101      "REFLECTS[\<lambda>z. \<exists>x[L]. x\<in>A & (\<exists>y[L]. y\<in>B & pair(L,x,y,z)),
   102                 \<lambda>i z. \<exists>x\<in>Lset(i). x\<in>A & (\<exists>y\<in>Lset(i). y\<in>B &
   103                                    pair(**Lset(i),x,y,z))]"
   104 by (intro FOL_reflections function_reflections)
   105 
   106 lemma cartprod_separation:
   107      "[| L(A); L(B) |]
   108       ==> separation(L, \<lambda>z. \<exists>x[L]. x\<in>A & (\<exists>y[L]. y\<in>B & pair(L,x,y,z)))"
   109 apply (rule separation_CollectI)
   110 apply (rule_tac A="{A,B,z}" in subset_LsetE, blast)
   111 apply (rule ReflectsE [OF cartprod_Reflects], assumption)
   112 apply (drule subset_Lset_ltD, assumption)
   113 apply (erule reflection_imp_L_separation)
   114   apply (simp_all add: lt_Ord2, clarify)
   115 apply (rule DPow_LsetI)
   116 apply (rename_tac u)
   117 apply (rule bex_iff_sats)
   118 apply (rule conj_iff_sats)
   119 apply (rule_tac i=0 and j=2 and env="[x,u,A,B]" in mem_iff_sats, simp_all)
   120 apply (rule sep_rules | simp)+
   121 done
   122 
   123 subsection{*Separation for Image*}
   124 
   125 lemma image_Reflects:
   126      "REFLECTS[\<lambda>y. \<exists>p[L]. p\<in>r & (\<exists>x[L]. x\<in>A & pair(L,x,y,p)),
   127            \<lambda>i y. \<exists>p\<in>Lset(i). p\<in>r & (\<exists>x\<in>Lset(i). x\<in>A & pair(**Lset(i),x,y,p))]"
   128 by (intro FOL_reflections function_reflections)
   129 
   130 lemma image_separation:
   131      "[| L(A); L(r) |]
   132       ==> separation(L, \<lambda>y. \<exists>p[L]. p\<in>r & (\<exists>x[L]. x\<in>A & pair(L,x,y,p)))"
   133 apply (rule separation_CollectI)
   134 apply (rule_tac A="{A,r,z}" in subset_LsetE, blast)
   135 apply (rule ReflectsE [OF image_Reflects], assumption)
   136 apply (drule subset_Lset_ltD, assumption)
   137 apply (erule reflection_imp_L_separation)
   138   apply (simp_all add: lt_Ord2, clarify)
   139 apply (rule DPow_LsetI)
   140 apply (rule bex_iff_sats)
   141 apply (rule conj_iff_sats)
   142 apply (rule_tac env="[p,y,A,r]" in mem_iff_sats)
   143 apply (rule sep_rules | simp)+
   144 done
   145 
   146 
   147 subsection{*Separation for Converse*}
   148 
   149 lemma converse_Reflects:
   150   "REFLECTS[\<lambda>z. \<exists>p[L]. p\<in>r & (\<exists>x[L]. \<exists>y[L]. pair(L,x,y,p) & pair(L,y,x,z)),
   151      \<lambda>i z. \<exists>p\<in>Lset(i). p\<in>r & (\<exists>x\<in>Lset(i). \<exists>y\<in>Lset(i).
   152                      pair(**Lset(i),x,y,p) & pair(**Lset(i),y,x,z))]"
   153 by (intro FOL_reflections function_reflections)
   154 
   155 lemma converse_separation:
   156      "L(r) ==> separation(L,
   157          \<lambda>z. \<exists>p[L]. p\<in>r & (\<exists>x[L]. \<exists>y[L]. pair(L,x,y,p) & pair(L,y,x,z)))"
   158 apply (rule separation_CollectI)
   159 apply (rule_tac A="{r,z}" in subset_LsetE, blast)
   160 apply (rule ReflectsE [OF converse_Reflects], assumption)
   161 apply (drule subset_Lset_ltD, assumption)
   162 apply (erule reflection_imp_L_separation)
   163   apply (simp_all add: lt_Ord2, clarify)
   164 apply (rule DPow_LsetI)
   165 apply (rename_tac u)
   166 apply (rule bex_iff_sats)
   167 apply (rule conj_iff_sats)
   168 apply (rule_tac i=0 and j=2 and env="[p,u,r]" in mem_iff_sats, simp_all)
   169 apply (rule sep_rules | simp)+
   170 done
   171 
   172 
   173 subsection{*Separation for Restriction*}
   174 
   175 lemma restrict_Reflects:
   176      "REFLECTS[\<lambda>z. \<exists>x[L]. x\<in>A & (\<exists>y[L]. pair(L,x,y,z)),
   177         \<lambda>i z. \<exists>x\<in>Lset(i). x\<in>A & (\<exists>y\<in>Lset(i). pair(**Lset(i),x,y,z))]"
   178 by (intro FOL_reflections function_reflections)
   179 
   180 lemma restrict_separation:
   181    "L(A) ==> separation(L, \<lambda>z. \<exists>x[L]. x\<in>A & (\<exists>y[L]. pair(L,x,y,z)))"
   182 apply (rule separation_CollectI)
   183 apply (rule_tac A="{A,z}" in subset_LsetE, blast)
   184 apply (rule ReflectsE [OF restrict_Reflects], assumption)
   185 apply (drule subset_Lset_ltD, assumption)
   186 apply (erule reflection_imp_L_separation)
   187   apply (simp_all add: lt_Ord2, clarify)
   188 apply (rule DPow_LsetI)
   189 apply (rename_tac u)
   190 apply (rule bex_iff_sats)
   191 apply (rule conj_iff_sats)
   192 apply (rule_tac i=0 and j=2 and env="[x,u,A]" in mem_iff_sats, simp_all)
   193 apply (rule sep_rules | simp)+
   194 done
   195 
   196 
   197 subsection{*Separation for Composition*}
   198 
   199 lemma comp_Reflects:
   200      "REFLECTS[\<lambda>xz. \<exists>x[L]. \<exists>y[L]. \<exists>z[L]. \<exists>xy[L]. \<exists>yz[L].
   201                   pair(L,x,z,xz) & pair(L,x,y,xy) & pair(L,y,z,yz) &
   202                   xy\<in>s & yz\<in>r,
   203         \<lambda>i xz. \<exists>x\<in>Lset(i). \<exists>y\<in>Lset(i). \<exists>z\<in>Lset(i). \<exists>xy\<in>Lset(i). \<exists>yz\<in>Lset(i).
   204                   pair(**Lset(i),x,z,xz) & pair(**Lset(i),x,y,xy) &
   205                   pair(**Lset(i),y,z,yz) & xy\<in>s & yz\<in>r]"
   206 by (intro FOL_reflections function_reflections)
   207 
   208 lemma comp_separation:
   209      "[| L(r); L(s) |]
   210       ==> separation(L, \<lambda>xz. \<exists>x[L]. \<exists>y[L]. \<exists>z[L]. \<exists>xy[L]. \<exists>yz[L].
   211                   pair(L,x,z,xz) & pair(L,x,y,xy) & pair(L,y,z,yz) &
   212                   xy\<in>s & yz\<in>r)"
   213 apply (rule separation_CollectI)
   214 apply (rule_tac A="{r,s,z}" in subset_LsetE, blast)
   215 apply (rule ReflectsE [OF comp_Reflects], assumption)
   216 apply (drule subset_Lset_ltD, assumption)
   217 apply (erule reflection_imp_L_separation)
   218   apply (simp_all add: lt_Ord2, clarify)
   219 apply (rule DPow_LsetI)
   220 apply (rename_tac u)
   221 apply (rule bex_iff_sats)+
   222 apply (rename_tac x y z)
   223 apply (rule conj_iff_sats)
   224 apply (rule_tac env="[z,y,x,u,r,s]" in pair_iff_sats)
   225 apply (rule sep_rules | simp)+
   226 done
   227 
   228 subsection{*Separation for Predecessors in an Order*}
   229 
   230 lemma pred_Reflects:
   231      "REFLECTS[\<lambda>y. \<exists>p[L]. p\<in>r & pair(L,y,x,p),
   232                     \<lambda>i y. \<exists>p \<in> Lset(i). p\<in>r & pair(**Lset(i),y,x,p)]"
   233 by (intro FOL_reflections function_reflections)
   234 
   235 lemma pred_separation:
   236      "[| L(r); L(x) |] ==> separation(L, \<lambda>y. \<exists>p[L]. p\<in>r & pair(L,y,x,p))"
   237 apply (rule separation_CollectI)
   238 apply (rule_tac A="{r,x,z}" in subset_LsetE, blast)
   239 apply (rule ReflectsE [OF pred_Reflects], assumption)
   240 apply (drule subset_Lset_ltD, assumption)
   241 apply (erule reflection_imp_L_separation)
   242   apply (simp_all add: lt_Ord2, clarify)
   243 apply (rule DPow_LsetI)
   244 apply (rename_tac u)
   245 apply (rule bex_iff_sats)
   246 apply (rule conj_iff_sats)
   247 apply (rule_tac env = "[p,u,r,x]" in mem_iff_sats)
   248 apply (rule sep_rules | simp)+
   249 done
   250 
   251 
   252 subsection{*Separation for the Membership Relation*}
   253 
   254 lemma Memrel_Reflects:
   255      "REFLECTS[\<lambda>z. \<exists>x[L]. \<exists>y[L]. pair(L,x,y,z) & x \<in> y,
   256             \<lambda>i z. \<exists>x \<in> Lset(i). \<exists>y \<in> Lset(i). pair(**Lset(i),x,y,z) & x \<in> y]"
   257 by (intro FOL_reflections function_reflections)
   258 
   259 lemma Memrel_separation:
   260      "separation(L, \<lambda>z. \<exists>x[L]. \<exists>y[L]. pair(L,x,y,z) & x \<in> y)"
   261 apply (rule separation_CollectI)
   262 apply (rule_tac A="{z}" in subset_LsetE, blast)
   263 apply (rule ReflectsE [OF Memrel_Reflects], assumption)
   264 apply (drule subset_Lset_ltD, assumption)
   265 apply (erule reflection_imp_L_separation)
   266   apply (simp_all add: lt_Ord2)
   267 apply (rule DPow_LsetI)
   268 apply (rename_tac u)
   269 apply (rule bex_iff_sats conj_iff_sats)+
   270 apply (rule_tac env = "[y,x,u]" in pair_iff_sats)
   271 apply (rule sep_rules | simp)+
   272 done
   273 
   274 
   275 subsection{*Replacement for FunSpace*}
   276 
   277 lemma funspace_succ_Reflects:
   278  "REFLECTS[\<lambda>z. \<exists>p[L]. p\<in>A & (\<exists>f[L]. \<exists>b[L]. \<exists>nb[L]. \<exists>cnbf[L].
   279             pair(L,f,b,p) & pair(L,n,b,nb) & is_cons(L,nb,f,cnbf) &
   280             upair(L,cnbf,cnbf,z)),
   281         \<lambda>i z. \<exists>p \<in> Lset(i). p\<in>A & (\<exists>f \<in> Lset(i). \<exists>b \<in> Lset(i).
   282               \<exists>nb \<in> Lset(i). \<exists>cnbf \<in> Lset(i).
   283                 pair(**Lset(i),f,b,p) & pair(**Lset(i),n,b,nb) &
   284                 is_cons(**Lset(i),nb,f,cnbf) & upair(**Lset(i),cnbf,cnbf,z))]"
   285 by (intro FOL_reflections function_reflections)
   286 
   287 lemma funspace_succ_replacement:
   288      "L(n) ==>
   289       strong_replacement(L, \<lambda>p z. \<exists>f[L]. \<exists>b[L]. \<exists>nb[L]. \<exists>cnbf[L].
   290                 pair(L,f,b,p) & pair(L,n,b,nb) & is_cons(L,nb,f,cnbf) &
   291                 upair(L,cnbf,cnbf,z))"
   292 apply (rule strong_replacementI)
   293 apply (rule rallI)
   294 apply (rule separation_CollectI)
   295 apply (rule_tac A="{n,A,z}" in subset_LsetE, blast)
   296 apply (rule ReflectsE [OF funspace_succ_Reflects], assumption)
   297 apply (drule subset_Lset_ltD, assumption)
   298 apply (erule reflection_imp_L_separation)
   299   apply (simp_all add: lt_Ord2)
   300 apply (rule DPow_LsetI)
   301 apply (rename_tac u)
   302 apply (rule bex_iff_sats)
   303 apply (rule conj_iff_sats)
   304 apply (rule_tac env = "[p,u,n,A]" in mem_iff_sats)
   305 apply (rule sep_rules | simp)+
   306 done
   307 
   308 
   309 subsection{*Separation for Order-Isomorphisms*}
   310 
   311 lemma well_ord_iso_Reflects:
   312   "REFLECTS[\<lambda>x. x\<in>A -->
   313                 (\<exists>y[L]. \<exists>p[L]. fun_apply(L,f,x,y) & pair(L,y,x,p) & p \<in> r),
   314         \<lambda>i x. x\<in>A --> (\<exists>y \<in> Lset(i). \<exists>p \<in> Lset(i).
   315                 fun_apply(**Lset(i),f,x,y) & pair(**Lset(i),y,x,p) & p \<in> r)]"
   316 by (intro FOL_reflections function_reflections)
   317 
   318 lemma well_ord_iso_separation:
   319      "[| L(A); L(f); L(r) |]
   320       ==> separation (L, \<lambda>x. x\<in>A --> (\<exists>y[L]. (\<exists>p[L].
   321                      fun_apply(L,f,x,y) & pair(L,y,x,p) & p \<in> r)))"
   322 apply (rule separation_CollectI)
   323 apply (rule_tac A="{A,f,r,z}" in subset_LsetE, blast)
   324 apply (rule ReflectsE [OF well_ord_iso_Reflects], assumption)
   325 apply (drule subset_Lset_ltD, assumption)
   326 apply (erule reflection_imp_L_separation)
   327   apply (simp_all add: lt_Ord2)
   328 apply (rule DPow_LsetI)
   329 apply (rename_tac u)
   330 apply (rule imp_iff_sats)
   331 apply (rule_tac env = "[u,A,f,r]" in mem_iff_sats)
   332 apply (rule sep_rules | simp)+
   333 done
   334 
   335 
   336 subsection{*Separation for @{term "obase"}*}
   337 
   338 lemma obase_reflects:
   339   "REFLECTS[\<lambda>a. \<exists>x[L]. \<exists>g[L]. \<exists>mx[L]. \<exists>par[L].
   340              ordinal(L,x) & membership(L,x,mx) & pred_set(L,A,a,r,par) &
   341              order_isomorphism(L,par,r,x,mx,g),
   342         \<lambda>i a. \<exists>x \<in> Lset(i). \<exists>g \<in> Lset(i). \<exists>mx \<in> Lset(i). \<exists>par \<in> Lset(i).
   343              ordinal(**Lset(i),x) & membership(**Lset(i),x,mx) & pred_set(**Lset(i),A,a,r,par) &
   344              order_isomorphism(**Lset(i),par,r,x,mx,g)]"
   345 by (intro FOL_reflections function_reflections fun_plus_reflections)
   346 
   347 lemma obase_separation:
   348      --{*part of the order type formalization*}
   349      "[| L(A); L(r) |]
   350       ==> separation(L, \<lambda>a. \<exists>x[L]. \<exists>g[L]. \<exists>mx[L]. \<exists>par[L].
   351              ordinal(L,x) & membership(L,x,mx) & pred_set(L,A,a,r,par) &
   352              order_isomorphism(L,par,r,x,mx,g))"
   353 apply (rule separation_CollectI)
   354 apply (rule_tac A="{A,r,z}" in subset_LsetE, blast)
   355 apply (rule ReflectsE [OF obase_reflects], assumption)
   356 apply (drule subset_Lset_ltD, assumption)
   357 apply (erule reflection_imp_L_separation)
   358   apply (simp_all add: lt_Ord2)
   359 apply (rule DPow_LsetI)
   360 apply (rename_tac u)
   361 apply (rule bex_iff_sats)
   362 apply (rule conj_iff_sats)
   363 apply (rule_tac env = "[x,u,A,r]" in ordinal_iff_sats)
   364 apply (rule sep_rules | simp)+
   365 done
   366 
   367 
   368 subsection{*Separation for a Theorem about @{term "obase"}*}
   369 
   370 lemma obase_equals_reflects:
   371   "REFLECTS[\<lambda>x. x\<in>A --> ~(\<exists>y[L]. \<exists>g[L].
   372                 ordinal(L,y) & (\<exists>my[L]. \<exists>pxr[L].
   373                 membership(L,y,my) & pred_set(L,A,x,r,pxr) &
   374                 order_isomorphism(L,pxr,r,y,my,g))),
   375         \<lambda>i x. x\<in>A --> ~(\<exists>y \<in> Lset(i). \<exists>g \<in> Lset(i).
   376                 ordinal(**Lset(i),y) & (\<exists>my \<in> Lset(i). \<exists>pxr \<in> Lset(i).
   377                 membership(**Lset(i),y,my) & pred_set(**Lset(i),A,x,r,pxr) &
   378                 order_isomorphism(**Lset(i),pxr,r,y,my,g)))]"
   379 by (intro FOL_reflections function_reflections fun_plus_reflections)
   380 
   381 
   382 lemma obase_equals_separation:
   383      "[| L(A); L(r) |]
   384       ==> separation (L, \<lambda>x. x\<in>A --> ~(\<exists>y[L]. \<exists>g[L].
   385                               ordinal(L,y) & (\<exists>my[L]. \<exists>pxr[L].
   386                               membership(L,y,my) & pred_set(L,A,x,r,pxr) &
   387                               order_isomorphism(L,pxr,r,y,my,g))))"
   388 apply (rule separation_CollectI)
   389 apply (rule_tac A="{A,r,z}" in subset_LsetE, blast)
   390 apply (rule ReflectsE [OF obase_equals_reflects], assumption)
   391 apply (drule subset_Lset_ltD, assumption)
   392 apply (erule reflection_imp_L_separation)
   393   apply (simp_all add: lt_Ord2)
   394 apply (rule DPow_LsetI)
   395 apply (rename_tac u)
   396 apply (rule imp_iff_sats ball_iff_sats disj_iff_sats not_iff_sats)+
   397 apply (rule_tac env = "[u,A,r]" in mem_iff_sats)
   398 apply (rule sep_rules | simp)+
   399 done
   400 
   401 
   402 subsection{*Replacement for @{term "omap"}*}
   403 
   404 lemma omap_reflects:
   405  "REFLECTS[\<lambda>z. \<exists>a[L]. a\<in>B & (\<exists>x[L]. \<exists>g[L]. \<exists>mx[L]. \<exists>par[L].
   406      ordinal(L,x) & pair(L,a,x,z) & membership(L,x,mx) &
   407      pred_set(L,A,a,r,par) & order_isomorphism(L,par,r,x,mx,g)),
   408  \<lambda>i z. \<exists>a \<in> Lset(i). a\<in>B & (\<exists>x \<in> Lset(i). \<exists>g \<in> Lset(i). \<exists>mx \<in> Lset(i).
   409         \<exists>par \<in> Lset(i).
   410          ordinal(**Lset(i),x) & pair(**Lset(i),a,x,z) &
   411          membership(**Lset(i),x,mx) & pred_set(**Lset(i),A,a,r,par) &
   412          order_isomorphism(**Lset(i),par,r,x,mx,g))]"
   413 by (intro FOL_reflections function_reflections fun_plus_reflections)
   414 
   415 lemma omap_replacement:
   416      "[| L(A); L(r) |]
   417       ==> strong_replacement(L,
   418              \<lambda>a z. \<exists>x[L]. \<exists>g[L]. \<exists>mx[L]. \<exists>par[L].
   419              ordinal(L,x) & pair(L,a,x,z) & membership(L,x,mx) &
   420              pred_set(L,A,a,r,par) & order_isomorphism(L,par,r,x,mx,g))"
   421 apply (rule strong_replacementI)
   422 apply (rule rallI)
   423 apply (rename_tac B)
   424 apply (rule separation_CollectI)
   425 apply (rule_tac A="{A,B,r,z}" in subset_LsetE, blast)
   426 apply (rule ReflectsE [OF omap_reflects], assumption)
   427 apply (drule subset_Lset_ltD, assumption)
   428 apply (erule reflection_imp_L_separation)
   429   apply (simp_all add: lt_Ord2)
   430 apply (rule DPow_LsetI)
   431 apply (rename_tac u)
   432 apply (rule bex_iff_sats conj_iff_sats)+
   433 apply (rule_tac env = "[a,u,A,B,r]" in mem_iff_sats)
   434 apply (rule sep_rules | simp)+
   435 done
   436 
   437 
   438 subsection{*Separation for a Theorem about @{term "obase"}*}
   439 
   440 lemma is_recfun_reflects:
   441   "REFLECTS[\<lambda>x. \<exists>xa[L]. \<exists>xb[L].
   442                 pair(L,x,a,xa) & xa \<in> r & pair(L,x,b,xb) & xb \<in> r &
   443                 (\<exists>fx[L]. \<exists>gx[L]. fun_apply(L,f,x,fx) & fun_apply(L,g,x,gx) &
   444                                    fx \<noteq> gx),
   445    \<lambda>i x. \<exists>xa \<in> Lset(i). \<exists>xb \<in> Lset(i).
   446           pair(**Lset(i),x,a,xa) & xa \<in> r & pair(**Lset(i),x,b,xb) & xb \<in> r &
   447                 (\<exists>fx \<in> Lset(i). \<exists>gx \<in> Lset(i). fun_apply(**Lset(i),f,x,fx) &
   448                   fun_apply(**Lset(i),g,x,gx) & fx \<noteq> gx)]"
   449 by (intro FOL_reflections function_reflections fun_plus_reflections)
   450 
   451 lemma is_recfun_separation:
   452      --{*for well-founded recursion*}
   453      "[| L(r); L(f); L(g); L(a); L(b) |]
   454      ==> separation(L,
   455             \<lambda>x. \<exists>xa[L]. \<exists>xb[L].
   456                 pair(L,x,a,xa) & xa \<in> r & pair(L,x,b,xb) & xb \<in> r &
   457                 (\<exists>fx[L]. \<exists>gx[L]. fun_apply(L,f,x,fx) & fun_apply(L,g,x,gx) &
   458                                    fx \<noteq> gx))"
   459 apply (rule separation_CollectI)
   460 apply (rule_tac A="{r,f,g,a,b,z}" in subset_LsetE, blast)
   461 apply (rule ReflectsE [OF is_recfun_reflects], assumption)
   462 apply (drule subset_Lset_ltD, assumption)
   463 apply (erule reflection_imp_L_separation)
   464   apply (simp_all add: lt_Ord2)
   465 apply (rule DPow_LsetI)
   466 apply (rename_tac u)
   467 apply (rule bex_iff_sats conj_iff_sats)+
   468 apply (rule_tac env = "[xa,u,r,f,g,a,b]" in pair_iff_sats)
   469 apply (rule sep_rules | simp)+
   470 done
   471 
   472 
   473 subsection{*Instantiating the locale @{text M_axioms}*}
   474 text{*Separation (and Strong Replacement) for basic set-theoretic constructions
   475 such as intersection, Cartesian Product and image.*}
   476 
   477 lemma M_axioms_axioms_L: "M_axioms_axioms(L)"
   478   apply (rule M_axioms_axioms.intro)
   479        apply (assumption | rule
   480 	 Inter_separation Diff_separation cartprod_separation image_separation
   481 	 converse_separation restrict_separation
   482 	 comp_separation pred_separation Memrel_separation
   483 	 funspace_succ_replacement well_ord_iso_separation
   484 	 obase_separation obase_equals_separation
   485 	 omap_replacement is_recfun_separation)+
   486   done
   487 
   488 theorem M_axioms_L: "PROP M_axioms(L)"
   489 by (rule M_axioms.intro [OF M_triv_axioms_L M_axioms_axioms_L])
   490 
   491 
   492 lemmas cartprod_iff = M_axioms.cartprod_iff [OF M_axioms_L]
   493   and cartprod_closed = M_axioms.cartprod_closed [OF M_axioms_L]
   494   and sum_closed = M_axioms.sum_closed [OF M_axioms_L]
   495   and M_converse_iff = M_axioms.M_converse_iff [OF M_axioms_L]
   496   and converse_closed = M_axioms.converse_closed [OF M_axioms_L]
   497   and converse_abs = M_axioms.converse_abs [OF M_axioms_L]
   498   and image_closed = M_axioms.image_closed [OF M_axioms_L]
   499   and vimage_abs = M_axioms.vimage_abs [OF M_axioms_L]
   500   and vimage_closed = M_axioms.vimage_closed [OF M_axioms_L]
   501   and domain_abs = M_axioms.domain_abs [OF M_axioms_L]
   502   and domain_closed = M_axioms.domain_closed [OF M_axioms_L]
   503   and range_abs = M_axioms.range_abs [OF M_axioms_L]
   504   and range_closed = M_axioms.range_closed [OF M_axioms_L]
   505   and field_abs = M_axioms.field_abs [OF M_axioms_L]
   506   and field_closed = M_axioms.field_closed [OF M_axioms_L]
   507   and relation_abs = M_axioms.relation_abs [OF M_axioms_L]
   508   and function_abs = M_axioms.function_abs [OF M_axioms_L]
   509   and apply_closed = M_axioms.apply_closed [OF M_axioms_L]
   510   and apply_abs = M_axioms.apply_abs [OF M_axioms_L]
   511   and typed_function_abs = M_axioms.typed_function_abs [OF M_axioms_L]
   512   and injection_abs = M_axioms.injection_abs [OF M_axioms_L]
   513   and surjection_abs = M_axioms.surjection_abs [OF M_axioms_L]
   514   and bijection_abs = M_axioms.bijection_abs [OF M_axioms_L]
   515   and M_comp_iff = M_axioms.M_comp_iff [OF M_axioms_L]
   516   and comp_closed = M_axioms.comp_closed [OF M_axioms_L]
   517   and composition_abs = M_axioms.composition_abs [OF M_axioms_L]
   518   and restriction_is_function = M_axioms.restriction_is_function [OF M_axioms_L]
   519   and restriction_abs = M_axioms.restriction_abs [OF M_axioms_L]
   520   and M_restrict_iff = M_axioms.M_restrict_iff [OF M_axioms_L]
   521   and restrict_closed = M_axioms.restrict_closed [OF M_axioms_L]
   522   and Inter_abs = M_axioms.Inter_abs [OF M_axioms_L]
   523   and Inter_closed = M_axioms.Inter_closed [OF M_axioms_L]
   524   and Int_closed = M_axioms.Int_closed [OF M_axioms_L]
   525   and finite_fun_closed = M_axioms.finite_fun_closed [OF M_axioms_L]
   526   and is_funspace_abs = M_axioms.is_funspace_abs [OF M_axioms_L]
   527   and succ_fun_eq2 = M_axioms.succ_fun_eq2 [OF M_axioms_L]
   528   and funspace_succ = M_axioms.funspace_succ [OF M_axioms_L]
   529   and finite_funspace_closed = M_axioms.finite_funspace_closed [OF M_axioms_L]
   530 
   531 lemmas is_recfun_equal = M_axioms.is_recfun_equal [OF M_axioms_L]
   532   and is_recfun_cut = M_axioms.is_recfun_cut [OF M_axioms_L]
   533   and is_recfun_functional = M_axioms.is_recfun_functional [OF M_axioms_L]
   534   and is_recfun_relativize = M_axioms.is_recfun_relativize [OF M_axioms_L]
   535   and is_recfun_restrict = M_axioms.is_recfun_restrict [OF M_axioms_L]
   536   and univalent_is_recfun = M_axioms.univalent_is_recfun [OF M_axioms_L]
   537   and exists_is_recfun_indstep = M_axioms.exists_is_recfun_indstep [OF M_axioms_L]
   538   and wellfounded_exists_is_recfun = M_axioms.wellfounded_exists_is_recfun [OF M_axioms_L]
   539   and wf_exists_is_recfun = M_axioms.wf_exists_is_recfun [OF M_axioms_L]
   540   and is_recfun_abs = M_axioms.is_recfun_abs [OF M_axioms_L]
   541   and irreflexive_abs = M_axioms.irreflexive_abs [OF M_axioms_L]
   542   and transitive_rel_abs = M_axioms.transitive_rel_abs [OF M_axioms_L]
   543   and linear_rel_abs = M_axioms.linear_rel_abs [OF M_axioms_L]
   544   and wellordered_is_trans_on = M_axioms.wellordered_is_trans_on [OF M_axioms_L]
   545   and wellordered_is_linear = M_axioms.wellordered_is_linear [OF M_axioms_L]
   546   and wellordered_is_wellfounded_on = M_axioms.wellordered_is_wellfounded_on [OF M_axioms_L]
   547   and wellfounded_imp_wellfounded_on = M_axioms.wellfounded_imp_wellfounded_on [OF M_axioms_L]
   548   and wellfounded_on_subset_A = M_axioms.wellfounded_on_subset_A [OF M_axioms_L]
   549   and wellfounded_on_iff_wellfounded = M_axioms.wellfounded_on_iff_wellfounded [OF M_axioms_L]
   550   and wellfounded_on_imp_wellfounded = M_axioms.wellfounded_on_imp_wellfounded [OF M_axioms_L]
   551   and wellfounded_on_field_imp_wellfounded = M_axioms.wellfounded_on_field_imp_wellfounded [OF M_axioms_L]
   552   and wellfounded_iff_wellfounded_on_field = M_axioms.wellfounded_iff_wellfounded_on_field [OF M_axioms_L]
   553   and wellfounded_induct = M_axioms.wellfounded_induct [OF M_axioms_L]
   554   and wellfounded_on_induct = M_axioms.wellfounded_on_induct [OF M_axioms_L]
   555   and wellfounded_on_induct2 = M_axioms.wellfounded_on_induct2 [OF M_axioms_L]
   556   and linear_imp_relativized = M_axioms.linear_imp_relativized [OF M_axioms_L]
   557   and trans_on_imp_relativized = M_axioms.trans_on_imp_relativized [OF M_axioms_L]
   558   and wf_on_imp_relativized = M_axioms.wf_on_imp_relativized [OF M_axioms_L]
   559   and wf_imp_relativized = M_axioms.wf_imp_relativized [OF M_axioms_L]
   560   and well_ord_imp_relativized = M_axioms.well_ord_imp_relativized [OF M_axioms_L]
   561   and order_isomorphism_abs = M_axioms.order_isomorphism_abs [OF M_axioms_L]
   562   and pred_set_abs = M_axioms.pred_set_abs [OF M_axioms_L]
   563 
   564 lemmas pred_closed = M_axioms.pred_closed [OF M_axioms_L]
   565   and membership_abs = M_axioms.membership_abs [OF M_axioms_L]
   566   and M_Memrel_iff = M_axioms.M_Memrel_iff [OF M_axioms_L]
   567   and Memrel_closed = M_axioms.Memrel_closed [OF M_axioms_L]
   568   and wellordered_iso_predD = M_axioms.wellordered_iso_predD [OF M_axioms_L]
   569   and wellordered_iso_pred_eq = M_axioms.wellordered_iso_pred_eq [OF M_axioms_L]
   570   and wellfounded_on_asym = M_axioms.wellfounded_on_asym [OF M_axioms_L]
   571   and wellordered_asym = M_axioms.wellordered_asym [OF M_axioms_L]
   572   and ord_iso_pred_imp_lt = M_axioms.ord_iso_pred_imp_lt [OF M_axioms_L]
   573   and obase_iff = M_axioms.obase_iff [OF M_axioms_L]
   574   and omap_iff = M_axioms.omap_iff [OF M_axioms_L]
   575   and omap_unique = M_axioms.omap_unique [OF M_axioms_L]
   576   and omap_yields_Ord = M_axioms.omap_yields_Ord [OF M_axioms_L]
   577   and otype_iff = M_axioms.otype_iff [OF M_axioms_L]
   578   and otype_eq_range = M_axioms.otype_eq_range [OF M_axioms_L]
   579   and Ord_otype = M_axioms.Ord_otype [OF M_axioms_L]
   580   and domain_omap = M_axioms.domain_omap [OF M_axioms_L]
   581   and omap_subset = M_axioms.omap_subset [OF M_axioms_L]
   582   and omap_funtype = M_axioms.omap_funtype [OF M_axioms_L]
   583   and wellordered_omap_bij = M_axioms.wellordered_omap_bij [OF M_axioms_L]
   584   and omap_ord_iso = M_axioms.omap_ord_iso [OF M_axioms_L]
   585   and Ord_omap_image_pred = M_axioms.Ord_omap_image_pred [OF M_axioms_L]
   586   and restrict_omap_ord_iso = M_axioms.restrict_omap_ord_iso [OF M_axioms_L]
   587   and obase_equals = M_axioms.obase_equals [OF M_axioms_L]
   588   and omap_ord_iso_otype = M_axioms.omap_ord_iso_otype [OF M_axioms_L]
   589   and obase_exists = M_axioms.obase_exists [OF M_axioms_L]
   590   and omap_exists = M_axioms.omap_exists [OF M_axioms_L]
   591   and otype_exists = M_axioms.otype_exists [OF M_axioms_L]
   592   and omap_ord_iso_otype' = M_axioms.omap_ord_iso_otype' [OF M_axioms_L]
   593   and ordertype_exists = M_axioms.ordertype_exists [OF M_axioms_L]
   594   and relativized_imp_well_ord = M_axioms.relativized_imp_well_ord [OF M_axioms_L]
   595   and well_ord_abs = M_axioms.well_ord_abs [OF M_axioms_L]
   596 
   597 declare cartprod_closed [intro, simp]
   598 declare sum_closed [intro, simp]
   599 declare converse_closed [intro, simp]
   600 declare converse_abs [simp]
   601 declare image_closed [intro, simp]
   602 declare vimage_abs [simp]
   603 declare vimage_closed [intro, simp]
   604 declare domain_abs [simp]
   605 declare domain_closed [intro, simp]
   606 declare range_abs [simp]
   607 declare range_closed [intro, simp]
   608 declare field_abs [simp]
   609 declare field_closed [intro, simp]
   610 declare relation_abs [simp]
   611 declare function_abs [simp]
   612 declare apply_closed [intro, simp]
   613 declare typed_function_abs [simp]
   614 declare injection_abs [simp]
   615 declare surjection_abs [simp]
   616 declare bijection_abs [simp]
   617 declare comp_closed [intro, simp]
   618 declare composition_abs [simp]
   619 declare restriction_abs [simp]
   620 declare restrict_closed [intro, simp]
   621 declare Inter_abs [simp]
   622 declare Inter_closed [intro, simp]
   623 declare Int_closed [intro, simp]
   624 declare is_funspace_abs [simp]
   625 declare finite_funspace_closed [intro, simp]
   626 declare membership_abs [simp] 
   627 declare Memrel_closed  [intro,simp]
   628 
   629 end