src/ZF/Constructible/Separation.thy
author ballarin
Thu Dec 11 18:30:26 2008 +0100 (2008-12-11)
changeset 29223 e09c53289830
parent 19931 fb32b43e7f80
child 30729 461ee3e49ad3
permissions -rw-r--r--
Conversion of HOL-Main and ZF to new locales.
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
*)
paulson@13437
     5
paulson@13339
     6
header{*Early Instances of Separation and Strong Replacement*}
paulson@13323
     7
haftmann@16417
     8
theory Separation imports L_axioms WF_absolute begin
paulson@13306
     9
paulson@13564
    10
text{*This theory proves all instances needed for locale @{text "M_basic"}*}
paulson@13339
    11
paulson@13306
    12
text{*Helps us solve for de Bruijn indices!*}
paulson@13306
    13
lemma nth_ConsI: "[|nth(n,l) = x; n \<in> nat|] ==> nth(succ(n), Cons(a,l)) = x"
paulson@13306
    14
by simp
paulson@13306
    15
paulson@13316
    16
lemmas nth_rules = nth_0 nth_ConsI nat_0I nat_succI
wenzelm@13428
    17
lemmas sep_rules = nth_0 nth_ConsI FOL_iff_sats function_iff_sats
paulson@13323
    18
                   fun_plus_iff_sats
paulson@13306
    19
paulson@13306
    20
lemma Collect_conj_in_DPow:
wenzelm@13428
    21
     "[| {x\<in>A. P(x)} \<in> DPow(A);  {x\<in>A. Q(x)} \<in> DPow(A) |]
paulson@13306
    22
      ==> {x\<in>A. P(x) & Q(x)} \<in> DPow(A)"
wenzelm@13428
    23
by (simp add: Int_in_DPow Collect_Int_Collect_eq [symmetric])
paulson@13306
    24
paulson@13306
    25
lemma Collect_conj_in_DPow_Lset:
paulson@13306
    26
     "[|z \<in> Lset(j); {x \<in> Lset(j). P(x)} \<in> DPow(Lset(j))|]
paulson@13306
    27
      ==> {x \<in> Lset(j). x \<in> z & P(x)} \<in> DPow(Lset(j))"
paulson@13306
    28
apply (frule mem_Lset_imp_subset_Lset)
wenzelm@13428
    29
apply (simp add: Collect_conj_in_DPow Collect_mem_eq
paulson@13306
    30
                 subset_Int_iff2 elem_subset_in_DPow)
paulson@13306
    31
done
paulson@13306
    32
paulson@13306
    33
lemma separation_CollectI:
paulson@13306
    34
     "(\<And>z. L(z) ==> L({x \<in> z . P(x)})) ==> separation(L, \<lambda>x. P(x))"
wenzelm@13428
    35
apply (unfold separation_def, clarify)
wenzelm@13428
    36
apply (rule_tac x="{x\<in>z. P(x)}" in rexI)
paulson@13306
    37
apply simp_all
paulson@13306
    38
done
paulson@13306
    39
paulson@13306
    40
text{*Reduces the original comprehension to the reflected one*}
paulson@13306
    41
lemma reflection_imp_L_separation:
paulson@13306
    42
      "[| \<forall>x\<in>Lset(j). P(x) <-> Q(x);
wenzelm@13428
    43
          {x \<in> Lset(j) . Q(x)} \<in> DPow(Lset(j));
paulson@13306
    44
          Ord(j);  z \<in> Lset(j)|] ==> L({x \<in> z . P(x)})"
paulson@13306
    45
apply (rule_tac i = "succ(j)" in L_I)
paulson@13306
    46
 prefer 2 apply simp
paulson@13306
    47
apply (subgoal_tac "{x \<in> z. P(x)} = {x \<in> Lset(j). x \<in> z & (Q(x))}")
paulson@13306
    48
 prefer 2
wenzelm@13428
    49
 apply (blast dest: mem_Lset_imp_subset_Lset)
paulson@13306
    50
apply (simp add: Lset_succ Collect_conj_in_DPow_Lset)
paulson@13306
    51
done
paulson@13306
    52
paulson@13566
    53
text{*Encapsulates the standard proof script for proving instances of 
paulson@13687
    54
      Separation.*}
paulson@13566
    55
lemma gen_separation:
paulson@13566
    56
 assumes reflection: "REFLECTS [P,Q]"
paulson@13566
    57
     and Lu:         "L(u)"
paulson@13566
    58
     and collI: "!!j. u \<in> Lset(j)
paulson@13566
    59
                \<Longrightarrow> Collect(Lset(j), Q(j)) \<in> DPow(Lset(j))"
paulson@13566
    60
 shows "separation(L,P)"
paulson@13566
    61
apply (rule separation_CollectI)
paulson@13566
    62
apply (rule_tac A="{u,z}" in subset_LsetE, blast intro: Lu)
paulson@13566
    63
apply (rule ReflectsE [OF reflection], assumption)
paulson@13566
    64
apply (drule subset_Lset_ltD, assumption)
paulson@13566
    65
apply (erule reflection_imp_L_separation)
paulson@13566
    66
  apply (simp_all add: lt_Ord2, clarify)
paulson@13691
    67
apply (rule collI, assumption)
paulson@13687
    68
done
paulson@13687
    69
paulson@13687
    70
text{*As above, but typically @{term u} is a finite enumeration such as
paulson@13687
    71
  @{term "{a,b}"}; thus the new subgoal gets the assumption
paulson@13687
    72
  @{term "{a,b} \<subseteq> Lset(i)"}, which is logically equivalent to 
paulson@13687
    73
  @{term "a \<in> Lset(i)"} and @{term "b \<in> Lset(i)"}.*}
paulson@13687
    74
lemma gen_separation_multi:
paulson@13687
    75
 assumes reflection: "REFLECTS [P,Q]"
paulson@13687
    76
     and Lu:         "L(u)"
paulson@13687
    77
     and collI: "!!j. u \<subseteq> Lset(j)
paulson@13687
    78
                \<Longrightarrow> Collect(Lset(j), Q(j)) \<in> DPow(Lset(j))"
paulson@13687
    79
 shows "separation(L,P)"
paulson@13687
    80
apply (rule gen_separation [OF reflection Lu])
paulson@13687
    81
apply (drule mem_Lset_imp_subset_Lset)
paulson@13687
    82
apply (erule collI) 
paulson@13566
    83
done
paulson@13566
    84
paulson@13306
    85
paulson@13316
    86
subsection{*Separation for Intersection*}
paulson@13306
    87
paulson@13306
    88
lemma Inter_Reflects:
wenzelm@13428
    89
     "REFLECTS[\<lambda>x. \<forall>y[L]. y\<in>A --> x \<in> y,
paulson@13314
    90
               \<lambda>i x. \<forall>y\<in>Lset(i). y\<in>A --> x \<in> y]"
wenzelm@13428
    91
by (intro FOL_reflections)
paulson@13306
    92
paulson@13306
    93
lemma Inter_separation:
paulson@13306
    94
     "L(A) ==> separation(L, \<lambda>x. \<forall>y[L]. y\<in>A --> x\<in>y)"
paulson@13566
    95
apply (rule gen_separation [OF Inter_Reflects], simp)
wenzelm@13428
    96
apply (rule DPow_LsetI)
paulson@13687
    97
 txt{*I leave this one example of a manual proof.  The tedium of manually
paulson@13687
    98
      instantiating @{term i}, @{term j} and @{term env} is obvious. *}
wenzelm@13428
    99
apply (rule ball_iff_sats)
paulson@13306
   100
apply (rule imp_iff_sats)
paulson@13306
   101
apply (rule_tac [2] i=1 and j=0 and env="[y,x,A]" in mem_iff_sats)
paulson@13306
   102
apply (rule_tac i=0 and j=2 in mem_iff_sats)
paulson@13306
   103
apply (simp_all add: succ_Un_distrib [symmetric])
paulson@13306
   104
done
paulson@13306
   105
paulson@13437
   106
subsection{*Separation for Set Difference*}
paulson@13437
   107
paulson@13437
   108
lemma Diff_Reflects:
paulson@13437
   109
     "REFLECTS[\<lambda>x. x \<notin> B, \<lambda>i x. x \<notin> B]"
paulson@13437
   110
by (intro FOL_reflections)  
paulson@13437
   111
paulson@13437
   112
lemma Diff_separation:
paulson@13437
   113
     "L(B) ==> separation(L, \<lambda>x. x \<notin> B)"
paulson@13566
   114
apply (rule gen_separation [OF Diff_Reflects], simp)
paulson@13687
   115
apply (rule_tac env="[B]" in DPow_LsetI)
paulson@13437
   116
apply (rule sep_rules | simp)+
paulson@13437
   117
done
paulson@13437
   118
paulson@13316
   119
subsection{*Separation for Cartesian Product*}
paulson@13306
   120
paulson@13323
   121
lemma cartprod_Reflects:
paulson@13314
   122
     "REFLECTS[\<lambda>z. \<exists>x[L]. x\<in>A & (\<exists>y[L]. y\<in>B & pair(L,x,y,z)),
wenzelm@13428
   123
                \<lambda>i z. \<exists>x\<in>Lset(i). x\<in>A & (\<exists>y\<in>Lset(i). y\<in>B &
paulson@13807
   124
                                   pair(##Lset(i),x,y,z))]"
paulson@13323
   125
by (intro FOL_reflections function_reflections)
paulson@13306
   126
paulson@13306
   127
lemma cartprod_separation:
wenzelm@13428
   128
     "[| L(A); L(B) |]
paulson@13306
   129
      ==> separation(L, \<lambda>z. \<exists>x[L]. x\<in>A & (\<exists>y[L]. y\<in>B & pair(L,x,y,z)))"
paulson@13687
   130
apply (rule gen_separation_multi [OF cartprod_Reflects, of "{A,B}"], auto)
paulson@13687
   131
apply (rule_tac env="[A,B]" in DPow_LsetI)
paulson@13316
   132
apply (rule sep_rules | simp)+
paulson@13306
   133
done
paulson@13306
   134
paulson@13316
   135
subsection{*Separation for Image*}
paulson@13306
   136
paulson@13306
   137
lemma image_Reflects:
paulson@13314
   138
     "REFLECTS[\<lambda>y. \<exists>p[L]. p\<in>r & (\<exists>x[L]. x\<in>A & pair(L,x,y,p)),
paulson@13807
   139
           \<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
   140
by (intro FOL_reflections function_reflections)
paulson@13306
   141
paulson@13306
   142
lemma image_separation:
wenzelm@13428
   143
     "[| L(A); L(r) |]
paulson@13306
   144
      ==> separation(L, \<lambda>y. \<exists>p[L]. p\<in>r & (\<exists>x[L]. x\<in>A & pair(L,x,y,p)))"
paulson@13687
   145
apply (rule gen_separation_multi [OF image_Reflects, of "{A,r}"], auto)
paulson@13687
   146
apply (rule_tac env="[A,r]" in DPow_LsetI)
paulson@13316
   147
apply (rule sep_rules | simp)+
paulson@13306
   148
done
paulson@13306
   149
paulson@13306
   150
paulson@13316
   151
subsection{*Separation for Converse*}
paulson@13306
   152
paulson@13306
   153
lemma converse_Reflects:
paulson@13314
   154
  "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
   155
     \<lambda>i z. \<exists>p\<in>Lset(i). p\<in>r & (\<exists>x\<in>Lset(i). \<exists>y\<in>Lset(i).
paulson@13807
   156
                     pair(##Lset(i),x,y,p) & pair(##Lset(i),y,x,z))]"
paulson@13323
   157
by (intro FOL_reflections function_reflections)
paulson@13306
   158
paulson@13306
   159
lemma converse_separation:
wenzelm@13428
   160
     "L(r) ==> separation(L,
paulson@13306
   161
         \<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
   162
apply (rule gen_separation [OF converse_Reflects], simp)
paulson@13687
   163
apply (rule_tac env="[r]" in DPow_LsetI)
paulson@13316
   164
apply (rule sep_rules | simp)+
paulson@13306
   165
done
paulson@13306
   166
paulson@13306
   167
paulson@13316
   168
subsection{*Separation for Restriction*}
paulson@13306
   169
paulson@13306
   170
lemma restrict_Reflects:
paulson@13314
   171
     "REFLECTS[\<lambda>z. \<exists>x[L]. x\<in>A & (\<exists>y[L]. pair(L,x,y,z)),
paulson@13807
   172
        \<lambda>i z. \<exists>x\<in>Lset(i). x\<in>A & (\<exists>y\<in>Lset(i). pair(##Lset(i),x,y,z))]"
paulson@13323
   173
by (intro FOL_reflections function_reflections)
paulson@13306
   174
paulson@13306
   175
lemma restrict_separation:
paulson@13306
   176
   "L(A) ==> separation(L, \<lambda>z. \<exists>x[L]. x\<in>A & (\<exists>y[L]. pair(L,x,y,z)))"
paulson@13566
   177
apply (rule gen_separation [OF restrict_Reflects], simp)
paulson@13687
   178
apply (rule_tac env="[A]" in DPow_LsetI)
paulson@13316
   179
apply (rule sep_rules | simp)+
paulson@13306
   180
done
paulson@13306
   181
paulson@13306
   182
paulson@13316
   183
subsection{*Separation for Composition*}
paulson@13306
   184
paulson@13306
   185
lemma comp_Reflects:
wenzelm@13428
   186
     "REFLECTS[\<lambda>xz. \<exists>x[L]. \<exists>y[L]. \<exists>z[L]. \<exists>xy[L]. \<exists>yz[L].
wenzelm@13428
   187
                  pair(L,x,z,xz) & pair(L,x,y,xy) & pair(L,y,z,yz) &
paulson@13306
   188
                  xy\<in>s & yz\<in>r,
wenzelm@13428
   189
        \<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).
paulson@13807
   190
                  pair(##Lset(i),x,z,xz) & pair(##Lset(i),x,y,xy) &
paulson@13807
   191
                  pair(##Lset(i),y,z,yz) & xy\<in>s & yz\<in>r]"
paulson@13323
   192
by (intro FOL_reflections function_reflections)
paulson@13306
   193
paulson@13306
   194
lemma comp_separation:
paulson@13306
   195
     "[| L(r); L(s) |]
wenzelm@13428
   196
      ==> separation(L, \<lambda>xz. \<exists>x[L]. \<exists>y[L]. \<exists>z[L]. \<exists>xy[L]. \<exists>yz[L].
wenzelm@13428
   197
                  pair(L,x,z,xz) & pair(L,x,y,xy) & pair(L,y,z,yz) &
paulson@13306
   198
                  xy\<in>s & yz\<in>r)"
paulson@13687
   199
apply (rule gen_separation_multi [OF comp_Reflects, of "{r,s}"], auto)
paulson@13687
   200
txt{*Subgoals after applying general ``separation'' rule:
paulson@13687
   201
     @{subgoals[display,indent=0,margin=65]}*}
paulson@13687
   202
apply (rule_tac env="[r,s]" in DPow_LsetI)
paulson@13687
   203
txt{*Subgoals ready for automatic synthesis of a formula:
paulson@13687
   204
     @{subgoals[display,indent=0,margin=65]}*}
paulson@13316
   205
apply (rule sep_rules | simp)+
paulson@13306
   206
done
paulson@13306
   207
paulson@13687
   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@13807
   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@13687
   218
apply (rule gen_separation_multi [OF pred_Reflects, of "{r,x}"], auto)
paulson@13687
   219
apply (rule_tac env="[r,x]" in DPow_LsetI)
paulson@13316
   220
apply (rule sep_rules | simp)+
paulson@13306
   221
done
paulson@13306
   222
paulson@13306
   223
paulson@13316
   224
subsection{*Separation for the Membership Relation*}
paulson@13306
   225
paulson@13306
   226
lemma Memrel_Reflects:
paulson@13314
   227
     "REFLECTS[\<lambda>z. \<exists>x[L]. \<exists>y[L]. pair(L,x,y,z) & x \<in> y,
paulson@13807
   228
            \<lambda>i z. \<exists>x \<in> Lset(i). \<exists>y \<in> Lset(i). pair(##Lset(i),x,y,z) & x \<in> y]"
paulson@13323
   229
by (intro FOL_reflections function_reflections)
paulson@13306
   230
paulson@13306
   231
lemma Memrel_separation:
paulson@13306
   232
     "separation(L, \<lambda>z. \<exists>x[L]. \<exists>y[L]. pair(L,x,y,z) & x \<in> y)"
paulson@13566
   233
apply (rule gen_separation [OF Memrel_Reflects nonempty])
paulson@13687
   234
apply (rule_tac env="[]" in DPow_LsetI)
paulson@13316
   235
apply (rule sep_rules | simp)+
paulson@13306
   236
done
paulson@13306
   237
paulson@13306
   238
paulson@13316
   239
subsection{*Replacement for FunSpace*}
wenzelm@13428
   240
paulson@13306
   241
lemma funspace_succ_Reflects:
wenzelm@13428
   242
 "REFLECTS[\<lambda>z. \<exists>p[L]. p\<in>A & (\<exists>f[L]. \<exists>b[L]. \<exists>nb[L]. \<exists>cnbf[L].
wenzelm@13428
   243
            pair(L,f,b,p) & pair(L,n,b,nb) & is_cons(L,nb,f,cnbf) &
wenzelm@13428
   244
            upair(L,cnbf,cnbf,z)),
wenzelm@13428
   245
        \<lambda>i z. \<exists>p \<in> Lset(i). p\<in>A & (\<exists>f \<in> Lset(i). \<exists>b \<in> Lset(i).
wenzelm@13428
   246
              \<exists>nb \<in> Lset(i). \<exists>cnbf \<in> Lset(i).
paulson@13807
   247
                pair(##Lset(i),f,b,p) & pair(##Lset(i),n,b,nb) &
paulson@13807
   248
                is_cons(##Lset(i),nb,f,cnbf) & upair(##Lset(i),cnbf,cnbf,z))]"
paulson@13323
   249
by (intro FOL_reflections function_reflections)
paulson@13306
   250
paulson@13306
   251
lemma funspace_succ_replacement:
wenzelm@13428
   252
     "L(n) ==>
wenzelm@13428
   253
      strong_replacement(L, \<lambda>p z. \<exists>f[L]. \<exists>b[L]. \<exists>nb[L]. \<exists>cnbf[L].
paulson@13306
   254
                pair(L,f,b,p) & pair(L,n,b,nb) & is_cons(L,nb,f,cnbf) &
paulson@13306
   255
                upair(L,cnbf,cnbf,z))"
wenzelm@13428
   256
apply (rule strong_replacementI)
paulson@13687
   257
apply (rule_tac u="{n,B}" in gen_separation_multi [OF funspace_succ_Reflects], 
paulson@13687
   258
       auto)
paulson@13687
   259
apply (rule_tac env="[n,B]" in DPow_LsetI)
paulson@13316
   260
apply (rule sep_rules | simp)+
paulson@13306
   261
done
paulson@13306
   262
paulson@13306
   263
paulson@13634
   264
subsection{*Separation for a Theorem about @{term "is_recfun"}*}
paulson@13323
   265
paulson@13323
   266
lemma is_recfun_reflects:
wenzelm@13428
   267
  "REFLECTS[\<lambda>x. \<exists>xa[L]. \<exists>xb[L].
wenzelm@13428
   268
                pair(L,x,a,xa) & xa \<in> r & pair(L,x,b,xb) & xb \<in> r &
wenzelm@13428
   269
                (\<exists>fx[L]. \<exists>gx[L]. fun_apply(L,f,x,fx) & fun_apply(L,g,x,gx) &
paulson@13323
   270
                                   fx \<noteq> gx),
wenzelm@13428
   271
   \<lambda>i x. \<exists>xa \<in> Lset(i). \<exists>xb \<in> Lset(i).
paulson@13807
   272
          pair(##Lset(i),x,a,xa) & xa \<in> r & pair(##Lset(i),x,b,xb) & xb \<in> r &
paulson@13807
   273
                (\<exists>fx \<in> Lset(i). \<exists>gx \<in> Lset(i). fun_apply(##Lset(i),f,x,fx) &
paulson@13807
   274
                  fun_apply(##Lset(i),g,x,gx) & fx \<noteq> gx)]"
paulson@13323
   275
by (intro FOL_reflections function_reflections fun_plus_reflections)
paulson@13323
   276
paulson@13323
   277
lemma is_recfun_separation:
paulson@13323
   278
     --{*for well-founded recursion*}
wenzelm@13428
   279
     "[| L(r); L(f); L(g); L(a); L(b) |]
wenzelm@13428
   280
     ==> separation(L,
wenzelm@13428
   281
            \<lambda>x. \<exists>xa[L]. \<exists>xb[L].
wenzelm@13428
   282
                pair(L,x,a,xa) & xa \<in> r & pair(L,x,b,xb) & xb \<in> r &
wenzelm@13428
   283
                (\<exists>fx[L]. \<exists>gx[L]. fun_apply(L,f,x,fx) & fun_apply(L,g,x,gx) &
paulson@13323
   284
                                   fx \<noteq> gx))"
paulson@13687
   285
apply (rule gen_separation_multi [OF is_recfun_reflects, of "{r,f,g,a,b}"], 
paulson@13687
   286
            auto)
paulson@13687
   287
apply (rule_tac env="[r,f,g,a,b]" in DPow_LsetI)
paulson@13323
   288
apply (rule sep_rules | simp)+
paulson@13323
   289
done
paulson@13323
   290
paulson@13323
   291
paulson@13564
   292
subsection{*Instantiating the locale @{text M_basic}*}
paulson@13363
   293
text{*Separation (and Strong Replacement) for basic set-theoretic constructions
paulson@13363
   294
such as intersection, Cartesian Product and image.*}
paulson@13363
   295
paulson@13564
   296
lemma M_basic_axioms_L: "M_basic_axioms(L)"
paulson@13564
   297
  apply (rule M_basic_axioms.intro)
paulson@13437
   298
       apply (assumption | rule
paulson@13437
   299
	 Inter_separation Diff_separation cartprod_separation image_separation
paulson@13437
   300
	 converse_separation restrict_separation
paulson@13437
   301
	 comp_separation pred_separation Memrel_separation
paulson@13634
   302
	 funspace_succ_replacement is_recfun_separation)+
wenzelm@13428
   303
  done
paulson@13323
   304
paulson@13564
   305
theorem M_basic_L: "PROP M_basic(L)"
paulson@13564
   306
by (rule M_basic.intro [OF M_trivial_L M_basic_axioms_L])
paulson@13437
   307
ballarin@29223
   308
interpretation L: M_basic L by (rule M_basic_L)
paulson@13323
   309
paulson@13323
   310
paulson@13306
   311
end