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