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