src/ZF/Constructible/Formula.thy
author paulson
Thu Jul 04 10:52:33 2002 +0200 (2002-07-04)
changeset 13291 a73ab154f75c
parent 13269 3ba9be497c33
child 13298 b4f370679c65
permissions -rw-r--r--
towards proving separation for L
     1 header {* First-Order Formulas and the Definition of the Class L *}
     2 
     3 theory Formula = Main:
     4 
     5 subsection{*Internalized formulas of FOL*}
     6 
     7 text{*De Bruijn representation.
     8   Unbound variables get their denotations from an environment.*}
     9 
    10 consts   formula :: i
    11 datatype
    12   "formula" = Member ("x: nat", "y: nat")
    13             | Equal  ("x: nat", "y: nat")
    14             | Neg ("p: formula")
    15             | And ("p: formula", "q: formula")
    16             | Forall ("p: formula")
    17 
    18 declare formula.intros [TC]
    19 
    20 constdefs Or :: "[i,i]=>i"
    21     "Or(p,q) == Neg(And(Neg(p),Neg(q)))"
    22 
    23 constdefs Implies :: "[i,i]=>i"
    24     "Implies(p,q) == Neg(And(p,Neg(q)))"
    25 
    26 constdefs Iff :: "[i,i]=>i"
    27     "Iff(p,q) == And(Implies(p,q), Implies(q,p))"
    28 
    29 constdefs Exists :: "i=>i"
    30     "Exists(p) == Neg(Forall(Neg(p)))";
    31 
    32 lemma Or_type [TC]: "[| p \<in> formula; q \<in> formula |] ==> Or(p,q) \<in> formula"
    33 by (simp add: Or_def) 
    34 
    35 lemma Implies_type [TC]:
    36      "[| p \<in> formula; q \<in> formula |] ==> Implies(p,q) \<in> formula"
    37 by (simp add: Implies_def) 
    38 
    39 lemma Iff_type [TC]:
    40      "[| p \<in> formula; q \<in> formula |] ==> Iff(p,q) \<in> formula"
    41 by (simp add: Iff_def) 
    42 
    43 lemma Exists_type [TC]: "p \<in> formula ==> Exists(p) \<in> formula"
    44 by (simp add: Exists_def) 
    45 
    46 
    47 consts   satisfies :: "[i,i]=>i"
    48 primrec (*explicit lambda is required because the environment varies*)
    49   "satisfies(A,Member(x,y)) = 
    50       (\<lambda>env \<in> list(A). bool_of_o (nth(x,env) \<in> nth(y,env)))"
    51 
    52   "satisfies(A,Equal(x,y)) = 
    53       (\<lambda>env \<in> list(A). bool_of_o (nth(x,env) = nth(y,env)))"
    54 
    55   "satisfies(A,Neg(p)) = 
    56       (\<lambda>env \<in> list(A). not(satisfies(A,p)`env))"
    57 
    58   "satisfies(A,And(p,q)) =
    59       (\<lambda>env \<in> list(A). (satisfies(A,p)`env) and (satisfies(A,q)`env))"
    60 
    61   "satisfies(A,Forall(p)) = 
    62       (\<lambda>env \<in> list(A). bool_of_o (\<forall>x\<in>A. satisfies(A,p) ` (Cons(x,env)) = 1))"
    63 
    64 
    65 lemma "p \<in> formula ==> satisfies(A,p) \<in> list(A) -> bool"
    66 by (induct_tac p, simp_all) 
    67 
    68 syntax sats :: "[i,i,i] => o"
    69 translations "sats(A,p,env)" == "satisfies(A,p)`env = 1"
    70 
    71 lemma [simp]:
    72   "env \<in> list(A) 
    73    ==> sats(A, Member(x,y), env) <-> nth(x,env) \<in> nth(y,env)"
    74 by simp
    75 
    76 lemma [simp]:
    77   "env \<in> list(A) 
    78    ==> sats(A, Equal(x,y), env) <-> nth(x,env) = nth(y,env)"
    79 by simp
    80 
    81 lemma sats_Neg_iff [simp]:
    82   "env \<in> list(A) 
    83    ==> sats(A, Neg(p), env) <-> ~ sats(A,p,env)"
    84 by (simp add: Bool.not_def cond_def) 
    85 
    86 lemma sats_And_iff [simp]:
    87   "env \<in> list(A) 
    88    ==> (sats(A, And(p,q), env)) <-> sats(A,p,env) & sats(A,q,env)"
    89 by (simp add: Bool.and_def cond_def) 
    90 
    91 lemma sats_Forall_iff [simp]:
    92   "env \<in> list(A) 
    93    ==> sats(A, Forall(p), env) <-> (\<forall>x\<in>A. sats(A, p, Cons(x,env)))"
    94 by simp
    95 
    96 declare satisfies.simps [simp del]; 
    97 
    98 subsubsection{*Dividing line between primitive and derived connectives*}
    99 
   100 lemma sats_Or_iff [simp]:
   101   "env \<in> list(A) 
   102    ==> (sats(A, Or(p,q), env)) <-> sats(A,p,env) | sats(A,q,env)"
   103 by (simp add: Or_def)
   104 
   105 lemma sats_Implies_iff [simp]:
   106   "env \<in> list(A) 
   107    ==> (sats(A, Implies(p,q), env)) <-> (sats(A,p,env) --> sats(A,q,env))"
   108 by (simp add: Implies_def, blast) 
   109 
   110 lemma sats_Iff_iff [simp]:
   111   "env \<in> list(A) 
   112    ==> (sats(A, Iff(p,q), env)) <-> (sats(A,p,env) <-> sats(A,q,env))"
   113 by (simp add: Iff_def, blast) 
   114 
   115 lemma sats_Exists_iff [simp]:
   116   "env \<in> list(A) 
   117    ==> sats(A, Exists(p), env) <-> (\<exists>x\<in>A. sats(A, p, Cons(x,env)))"
   118 by (simp add: Exists_def)
   119 
   120 
   121 subsubsection{*Derived rules to help build up formulas*}
   122 
   123 lemma mem_iff_sats:
   124       "[| nth(i,env) = x; nth(j,env) = y; env \<in> list(A)|]
   125        ==> (x\<in>y) <-> sats(A, Member(i,j), env)" 
   126 by (simp add: satisfies.simps)
   127 
   128 lemma conj_iff_sats:
   129       "[| P <-> sats(A,p,env); Q <-> sats(A,q,env); env \<in> list(A)|]
   130        ==> (P & Q) <-> sats(A, And(p,q), env)"
   131 by (simp add: sats_And_iff)
   132 
   133 lemma disj_iff_sats:
   134       "[| P <-> sats(A,p,env); Q <-> sats(A,q,env); env \<in> list(A)|]
   135        ==> (P | Q) <-> sats(A, Or(p,q), env)"
   136 by (simp add: sats_Or_iff)
   137 
   138 lemma imp_iff_sats:
   139       "[| P <-> sats(A,p,env); Q <-> sats(A,q,env); env \<in> list(A)|]
   140        ==> (P --> Q) <-> sats(A, Implies(p,q), env)"
   141 by (simp add: sats_Forall_iff) 
   142 
   143 lemma iff_iff_sats:
   144       "[| P <-> sats(A,p,env); Q <-> sats(A,q,env); env \<in> list(A)|]
   145        ==> (P <-> Q) <-> sats(A, Iff(p,q), env)"
   146 by (simp add: sats_Forall_iff) 
   147 
   148 lemma imp_iff_sats:
   149       "[| P <-> sats(A,p,env); Q <-> sats(A,q,env); env \<in> list(A)|]
   150        ==> (P --> Q) <-> sats(A, Implies(p,q), env)"
   151 by (simp add: sats_Forall_iff) 
   152 
   153 lemma ball_iff_sats:
   154       "[| !!x. x\<in>A ==> P(x) <-> sats(A, p, Cons(x, env)); env \<in> list(A)|]
   155        ==> (\<forall>x\<in>A. P(x)) <-> sats(A, Forall(p), env)"
   156 by (simp add: sats_Forall_iff) 
   157 
   158 lemma bex_iff_sats:
   159       "[| !!x. x\<in>A ==> P(x) <-> sats(A, p, Cons(x, env)); env \<in> list(A)|]
   160        ==> (\<exists>x\<in>A. P(x)) <-> sats(A, Exists(p), env)"
   161 by (simp add: sats_Exists_iff) 
   162 
   163 
   164 
   165 (*pretty but unnecessary
   166 constdefs sat     :: "[i,i] => o"
   167   "sat(A,p) == satisfies(A,p)`[] = 1"
   168 
   169 syntax "_sat"  :: "[i,i] => o"    (infixl "|=" 50)
   170 translations "A |= p" == "sat(A,p)"
   171 
   172 lemma [simp]: "(A |= Neg(p)) <-> ~ (A |= p)"
   173 by (simp add: sat_def)
   174 
   175 lemma [simp]: "(A |= And(p,q)) <-> A|=p & A|=q"
   176 by (simp add: sat_def)
   177 *) 
   178 
   179 
   180 constdefs incr_var :: "[i,i]=>i"
   181     "incr_var(x,lev) == if x<lev then x else succ(x)"
   182 
   183 lemma incr_var_lt: "x<lev ==> incr_var(x,lev) = x"
   184 by (simp add: incr_var_def)
   185 
   186 lemma incr_var_le: "lev\<le>x ==> incr_var(x,lev) = succ(x)"
   187 apply (simp add: incr_var_def) 
   188 apply (blast dest: lt_trans1) 
   189 done
   190 
   191 consts   incr_bv :: "i=>i"
   192 primrec
   193   "incr_bv(Member(x,y)) = 
   194       (\<lambda>lev \<in> nat. Member (incr_var(x,lev), incr_var(y,lev)))"
   195 
   196   "incr_bv(Equal(x,y)) = 
   197       (\<lambda>lev \<in> nat. Equal (incr_var(x,lev), incr_var(y,lev)))"
   198 
   199   "incr_bv(Neg(p)) = 
   200       (\<lambda>lev \<in> nat. Neg(incr_bv(p)`lev))"
   201 
   202   "incr_bv(And(p,q)) =
   203       (\<lambda>lev \<in> nat. And (incr_bv(p)`lev, incr_bv(q)`lev))"
   204 
   205   "incr_bv(Forall(p)) = 
   206       (\<lambda>lev \<in> nat. Forall (incr_bv(p) ` succ(lev)))"
   207 
   208 
   209 constdefs incr_boundvars :: "i => i"
   210     "incr_boundvars(p) == incr_bv(p)`0"
   211 
   212 
   213 lemma [TC]: "x \<in> nat ==> incr_var(x,lev) \<in> nat"
   214 by (simp add: incr_var_def) 
   215 
   216 lemma incr_bv_type [TC]: "p \<in> formula ==> incr_bv(p) \<in> nat -> formula"
   217 by (induct_tac p, simp_all) 
   218 
   219 lemma incr_boundvars_type [TC]: "p \<in> formula ==> incr_boundvars(p) \<in> formula"
   220 by (simp add: incr_boundvars_def) 
   221 
   222 (*Obviously DPow is closed under complements and finite intersections and
   223 unions.  Needs an inductive lemma to allow two lists of parameters to 
   224 be combined.*)
   225 
   226 lemma sats_incr_bv_iff [rule_format]:
   227   "[| p \<in> formula; env \<in> list(A); x \<in> A |]
   228    ==> \<forall>bvs \<in> list(A). 
   229            sats(A, incr_bv(p) ` length(bvs), bvs @ Cons(x,env)) <-> 
   230            sats(A, p, bvs@env)"
   231 apply (induct_tac p)
   232 apply (simp_all add: incr_var_def nth_append succ_lt_iff length_type)
   233 apply (auto simp add: diff_succ not_lt_iff_le)
   234 done
   235 
   236 (*UNUSED*)
   237 lemma sats_incr_boundvars_iff:
   238   "[| p \<in> formula; env \<in> list(A); x \<in> A |]
   239    ==> sats(A, incr_boundvars(p), Cons(x,env)) <-> sats(A, p, env)"
   240 apply (insert sats_incr_bv_iff [of p env A x Nil])
   241 apply (simp add: incr_boundvars_def) 
   242 done
   243 
   244 (*UNUSED
   245 lemma formula_add_params [rule_format]:
   246   "[| p \<in> formula; n \<in> nat |]
   247    ==> \<forall>bvs \<in> list(A). \<forall>env \<in> list(A). 
   248          length(bvs) = n --> 
   249          sats(A, iterates(incr_boundvars,n,p), bvs@env) <-> sats(A, p, env)"
   250 apply (induct_tac n, simp, clarify) 
   251 apply (erule list.cases)
   252 apply (auto simp add: sats_incr_boundvars_iff)  
   253 done
   254 *)
   255 
   256 consts   arity :: "i=>i"
   257 primrec
   258   "arity(Member(x,y)) = succ(x) \<union> succ(y)"
   259 
   260   "arity(Equal(x,y)) = succ(x) \<union> succ(y)"
   261 
   262   "arity(Neg(p)) = arity(p)"
   263 
   264   "arity(And(p,q)) = arity(p) \<union> arity(q)"
   265 
   266   "arity(Forall(p)) = nat_case(0, %x. x, arity(p))"
   267 
   268 
   269 lemma arity_type [TC]: "p \<in> formula ==> arity(p) \<in> nat"
   270 by (induct_tac p, simp_all) 
   271 
   272 lemma arity_Or [simp]: "arity(Or(p,q)) = arity(p) \<union> arity(q)"
   273 by (simp add: Or_def) 
   274 
   275 lemma arity_Implies [simp]: "arity(Implies(p,q)) = arity(p) \<union> arity(q)"
   276 by (simp add: Implies_def) 
   277 
   278 lemma arity_Iff [simp]: "arity(Iff(p,q)) = arity(p) \<union> arity(q)"
   279 by (simp add: Iff_def, blast)
   280 
   281 lemma arity_Exists [simp]: "arity(Exists(p)) = nat_case(0, %x. x, arity(p))"
   282 by (simp add: Exists_def) 
   283 
   284 
   285 lemma arity_sats_iff [rule_format]:
   286   "[| p \<in> formula; extra \<in> list(A) |]
   287    ==> \<forall>env \<in> list(A). 
   288            arity(p) \<le> length(env) --> 
   289            sats(A, p, env @ extra) <-> sats(A, p, env)"
   290 apply (induct_tac p)
   291 apply (simp_all add: nth_append Un_least_lt_iff arity_type nat_imp_quasinat
   292                 split: split_nat_case, auto) 
   293 done
   294 
   295 lemma arity_sats1_iff:
   296   "[| arity(p) \<le> succ(length(env)); p \<in> formula; x \<in> A; env \<in> list(A); 
   297     extra \<in> list(A) |]
   298    ==> sats(A, p, Cons(x, env @ extra)) <-> sats(A, p, Cons(x, env))"
   299 apply (insert arity_sats_iff [of p extra A "Cons(x,env)"])
   300 apply simp 
   301 done
   302 
   303 (*the following two lemmas prevent huge case splits in arity_incr_bv_lemma*)
   304 lemma incr_var_lemma:
   305      "[| x \<in> nat; y \<in> nat; lev \<le> x |]
   306       ==> succ(x) \<union> incr_var(y,lev) = succ(x \<union> y)"
   307 apply (simp add: incr_var_def Ord_Un_if, auto)
   308   apply (blast intro: leI)
   309  apply (simp add: not_lt_iff_le)  
   310  apply (blast intro: le_anti_sym) 
   311 apply (blast dest: lt_trans2) 
   312 done
   313 
   314 lemma incr_And_lemma:
   315      "y < x ==> y \<union> succ(x) = succ(x \<union> y)"
   316 apply (simp add: Ord_Un_if lt_Ord lt_Ord2 succ_lt_iff) 
   317 apply (blast dest: lt_asym) 
   318 done
   319 
   320 lemma arity_incr_bv_lemma [rule_format]:
   321   "p \<in> formula 
   322    ==> \<forall>n \<in> nat. arity (incr_bv(p) ` n) = 
   323                  (if n < arity(p) then succ(arity(p)) else arity(p))"
   324 apply (induct_tac p) 
   325 apply (simp_all add: imp_disj not_lt_iff_le Un_least_lt_iff lt_Un_iff le_Un_iff
   326                      succ_Un_distrib [symmetric] incr_var_lt incr_var_le
   327                      Un_commute incr_var_lemma arity_type nat_imp_quasinat
   328             split: split_nat_case) 
   329  txt{*the Forall case reduces to linear arithmetic*}
   330  prefer 2
   331  apply clarify 
   332  apply (blast dest: lt_trans1) 
   333 txt{*left with the And case*}
   334 apply safe
   335  apply (blast intro: incr_And_lemma lt_trans1) 
   336 apply (subst incr_And_lemma)
   337  apply (blast intro: lt_trans1) 
   338 apply (simp add: Un_commute)
   339 done
   340 
   341 lemma arity_incr_boundvars_eq:
   342   "p \<in> formula
   343    ==> arity(incr_boundvars(p)) =
   344         (if 0 < arity(p) then succ(arity(p)) else arity(p))"
   345 apply (insert arity_incr_bv_lemma [of p 0])
   346 apply (simp add: incr_boundvars_def) 
   347 done
   348 
   349 lemma arity_iterates_incr_boundvars_eq:
   350   "[| p \<in> formula; n \<in> nat |]
   351    ==> arity(incr_boundvars^n(p)) =
   352          (if 0 < arity(p) then n #+ arity(p) else arity(p))"
   353 apply (induct_tac n) 
   354 apply (simp_all add: arity_incr_boundvars_eq not_lt_iff_le) 
   355 done
   356 
   357 
   358 (**** TRYING INCR_BV1 AGAIN ****)
   359 
   360 constdefs incr_bv1 :: "i => i"
   361     "incr_bv1(p) == incr_bv(p)`1"
   362 
   363 
   364 lemma incr_bv1_type [TC]: "p \<in> formula ==> incr_bv1(p) \<in> formula"
   365 by (simp add: incr_bv1_def) 
   366 
   367 (*For renaming all but the bound variable at level 0*)
   368 lemma sats_incr_bv1_iff [rule_format]:
   369   "[| p \<in> formula; env \<in> list(A); x \<in> A; y \<in> A |]
   370    ==> sats(A, incr_bv1(p), Cons(x, Cons(y, env))) <-> 
   371        sats(A, p, Cons(x,env))"
   372 apply (insert sats_incr_bv_iff [of p env A y "Cons(x,Nil)"])
   373 apply (simp add: incr_bv1_def) 
   374 done
   375 
   376 lemma formula_add_params1 [rule_format]:
   377   "[| p \<in> formula; n \<in> nat; x \<in> A |]
   378    ==> \<forall>bvs \<in> list(A). \<forall>env \<in> list(A). 
   379           length(bvs) = n --> 
   380           sats(A, iterates(incr_bv1, n, p), Cons(x, bvs@env)) <-> 
   381           sats(A, p, Cons(x,env))"
   382 apply (induct_tac n, simp, clarify) 
   383 apply (erule list.cases)
   384 apply (simp_all add: sats_incr_bv1_iff) 
   385 done
   386 
   387 
   388 lemma arity_incr_bv1_eq:
   389   "p \<in> formula
   390    ==> arity(incr_bv1(p)) =
   391         (if 1 < arity(p) then succ(arity(p)) else arity(p))"
   392 apply (insert arity_incr_bv_lemma [of p 1])
   393 apply (simp add: incr_bv1_def) 
   394 done
   395 
   396 lemma arity_iterates_incr_bv1_eq:
   397   "[| p \<in> formula; n \<in> nat |]
   398    ==> arity(incr_bv1^n(p)) =
   399          (if 1 < arity(p) then n #+ arity(p) else arity(p))"
   400 apply (induct_tac n) 
   401 apply (simp_all add: arity_incr_bv1_eq )
   402 apply (simp add: not_lt_iff_le)
   403 apply (blast intro: le_trans add_le_self2 arity_type) 
   404 done
   405 
   406 
   407 (*Definable powerset operation: Kunen's definition 1.1, page 165.*)
   408 constdefs DPow :: "i => i"
   409   "DPow(A) == {X \<in> Pow(A). 
   410                \<exists>env \<in> list(A). \<exists>p \<in> formula. 
   411                  arity(p) \<le> succ(length(env)) & 
   412                  X = {x\<in>A. sats(A, p, Cons(x,env))}}"
   413 
   414 lemma DPowI:
   415   "[|env \<in> list(A);  p \<in> formula;  arity(p) \<le> succ(length(env))|]
   416    ==> {x\<in>A. sats(A, p, Cons(x,env))} \<in> DPow(A)"
   417 by (simp add: DPow_def, blast) 
   418 
   419 text{*With this rule we can specify @{term p} later.*}
   420 lemma DPowI2 [rule_format]:
   421   "[|\<forall>x\<in>A. P(x) <-> sats(A, p, Cons(x,env));
   422      env \<in> list(A);  p \<in> formula;  arity(p) \<le> succ(length(env))|]
   423    ==> {x\<in>A. P(x)} \<in> DPow(A)"
   424 by (simp add: DPow_def, blast) 
   425 
   426 lemma DPowD:
   427   "X \<in> DPow(A) 
   428    ==> X <= A &
   429        (\<exists>env \<in> list(A). 
   430         \<exists>p \<in> formula. arity(p) \<le> succ(length(env)) & 
   431                       X = {x\<in>A. sats(A, p, Cons(x,env))})"
   432 by (simp add: DPow_def) 
   433 
   434 lemmas DPow_imp_subset = DPowD [THEN conjunct1]
   435 
   436 (*Lemma 1.2*)
   437 lemma "[| p \<in> formula; env \<in> list(A); arity(p) \<le> succ(length(env)) |] 
   438        ==> {x\<in>A. sats(A, p, Cons(x,env))} \<in> DPow(A)"
   439 by (blast intro: DPowI)
   440 
   441 lemma DPow_subset_Pow: "DPow(A) <= Pow(A)"
   442 by (simp add: DPow_def, blast)
   443 
   444 lemma empty_in_DPow: "0 \<in> DPow(A)"
   445 apply (simp add: DPow_def)
   446 apply (rule_tac x="Nil" in bexI) 
   447  apply (rule_tac x="Neg(Equal(0,0))" in bexI) 
   448   apply (auto simp add: Un_least_lt_iff) 
   449 done
   450 
   451 lemma Compl_in_DPow: "X \<in> DPow(A) ==> (A-X) \<in> DPow(A)"
   452 apply (simp add: DPow_def, clarify, auto) 
   453 apply (rule bexI) 
   454  apply (rule_tac x="Neg(p)" in bexI) 
   455   apply auto 
   456 done
   457 
   458 lemma Int_in_DPow: "[| X \<in> DPow(A); Y \<in> DPow(A) |] ==> X Int Y \<in> DPow(A)"
   459 apply (simp add: DPow_def, auto) 
   460 apply (rename_tac envp p envq q) 
   461 apply (rule_tac x="envp@envq" in bexI) 
   462  apply (rule_tac x="And(p, iterates(incr_bv1,length(envp),q))" in bexI)
   463   apply typecheck
   464 apply (rule conjI) 
   465 (*finally check the arity!*)
   466  apply (simp add: arity_iterates_incr_bv1_eq length_app Un_least_lt_iff)
   467  apply (force intro: add_le_self le_trans) 
   468 apply (simp add: arity_sats1_iff formula_add_params1, blast) 
   469 done
   470 
   471 lemma Un_in_DPow: "[| X \<in> DPow(A); Y \<in> DPow(A) |] ==> X Un Y \<in> DPow(A)"
   472 apply (subgoal_tac "X Un Y = A - ((A-X) Int (A-Y))") 
   473 apply (simp add: Int_in_DPow Compl_in_DPow) 
   474 apply (simp add: DPow_def, blast) 
   475 done
   476 
   477 lemma singleton_in_DPow: "x \<in> A ==> {x} \<in> DPow(A)"
   478 apply (simp add: DPow_def)
   479 apply (rule_tac x="Cons(x,Nil)" in bexI) 
   480  apply (rule_tac x="Equal(0,1)" in bexI) 
   481   apply typecheck
   482 apply (force simp add: succ_Un_distrib [symmetric])  
   483 done
   484 
   485 lemma cons_in_DPow: "[| a \<in> A; X \<in> DPow(A) |] ==> cons(a,X) \<in> DPow(A)"
   486 apply (rule cons_eq [THEN subst]) 
   487 apply (blast intro: singleton_in_DPow Un_in_DPow) 
   488 done
   489 
   490 (*Part of Lemma 1.3*)
   491 lemma Fin_into_DPow: "X \<in> Fin(A) ==> X \<in> DPow(A)"
   492 apply (erule Fin.induct) 
   493  apply (rule empty_in_DPow) 
   494 apply (blast intro: cons_in_DPow) 
   495 done
   496 
   497 (*DPow is not monotonic.  For example, let A be some non-constructible set
   498   of natural numbers, and let B be nat.  Then A<=B and obviously A : DPow(A)
   499   but A ~: DPow(B).*)
   500 lemma DPow_mono: "A : DPow(B) ==> DPow(A) <= DPow(B)"
   501 apply (simp add: DPow_def, auto) 
   502 (*must use the formula defining A in B to relativize the new formula...*)
   503 oops
   504 
   505 lemma DPow_0: "DPow(0) = {0}" 
   506 by (blast intro: empty_in_DPow dest: DPow_imp_subset)
   507 
   508 lemma Finite_Pow_subset_Pow: "Finite(A) ==> Pow(A) <= DPow(A)" 
   509 by (blast intro: Fin_into_DPow Finite_into_Fin Fin_subset)
   510 
   511 lemma Finite_DPow_eq_Pow: "Finite(A) ==> DPow(A) = Pow(A)"
   512 apply (rule equalityI) 
   513 apply (rule DPow_subset_Pow) 
   514 apply (erule Finite_Pow_subset_Pow) 
   515 done
   516 
   517 (*This may be true but the proof looks difficult, requiring relativization 
   518 lemma DPow_insert: "DPow (cons(a,A)) = DPow(A) Un {cons(a,X) . X: DPow(A)}"
   519 apply (rule equalityI, safe)
   520 oops
   521 *)
   522 
   523 subsection{* Constant Lset: Levels of the Constructible Universe *}
   524 
   525 constdefs Lset :: "i=>i"
   526     "Lset(i) == transrec(i, %x f. \<Union>y\<in>x. DPow(f`y))"
   527 
   528 text{*NOT SUITABLE FOR REWRITING -- RECURSIVE!*}
   529 lemma Lset: "Lset(i) = (UN j:i. DPow(Lset(j)))"
   530 by (subst Lset_def [THEN def_transrec], simp)
   531 
   532 lemma LsetI: "[|y\<in>x; A \<in> DPow(Lset(y))|] ==> A \<in> Lset(x)";
   533 by (subst Lset, blast)
   534 
   535 lemma LsetD: "A \<in> Lset(x) ==> \<exists>y\<in>x. A \<in> DPow(Lset(y))";
   536 apply (insert Lset [of x]) 
   537 apply (blast intro: elim: equalityE) 
   538 done
   539 
   540 subsubsection{* Transitivity *}
   541 
   542 lemma elem_subset_in_DPow: "[|X \<in> A; X \<subseteq> A|] ==> X \<in> DPow(A)"
   543 apply (simp add: Transset_def DPow_def)
   544 apply (rule_tac x="[X]" in bexI) 
   545  apply (rule_tac x="Member(0,1)" in bexI) 
   546   apply (auto simp add: Un_least_lt_iff) 
   547 done
   548 
   549 lemma Transset_subset_DPow: "Transset(A) ==> A <= DPow(A)"
   550 apply clarify  
   551 apply (simp add: Transset_def)
   552 apply (blast intro: elem_subset_in_DPow) 
   553 done
   554 
   555 lemma Transset_DPow: "Transset(A) ==> Transset(DPow(A))"
   556 apply (simp add: Transset_def) 
   557 apply (blast intro: elem_subset_in_DPow dest: DPowD) 
   558 done
   559 
   560 text{*Kunen's VI, 1.6 (a)*}
   561 lemma Transset_Lset: "Transset(Lset(i))"
   562 apply (rule_tac a=i in eps_induct)
   563 apply (subst Lset)
   564 apply (blast intro!: Transset_Union_family Transset_Un Transset_DPow)
   565 done
   566 
   567 lemma mem_Lset_imp_subset_Lset: "a \<in> Lset(i) ==> a \<subseteq> Lset(i)"
   568 apply (insert Transset_Lset) 
   569 apply (simp add: Transset_def) 
   570 done
   571 
   572 subsubsection{* Monotonicity *}
   573 
   574 text{*Kunen's VI, 1.6 (b)*}
   575 lemma Lset_mono [rule_format]:
   576      "ALL j. i<=j --> Lset(i) <= Lset(j)"
   577 apply (rule_tac a=i in eps_induct)
   578 apply (rule impI [THEN allI])
   579 apply (subst Lset)
   580 apply (subst Lset, blast) 
   581 done
   582 
   583 text{*This version lets us remove the premise @{term "Ord(i)"} sometimes.*}
   584 lemma Lset_mono_mem [rule_format]:
   585      "ALL j. i:j --> Lset(i) <= Lset(j)"
   586 apply (rule_tac a=i in eps_induct)
   587 apply (rule impI [THEN allI])
   588 apply (subst Lset, auto) 
   589 apply (rule rev_bexI, assumption)
   590 apply (blast intro: elem_subset_in_DPow dest: LsetD DPowD) 
   591 done
   592 
   593 text{*Useful with Reflection to bump up the ordinal*}
   594 lemma subset_Lset_ltD: "[|A \<subseteq> Lset(i); i < j|] ==> A \<subseteq> Lset(j)"
   595 by (blast dest: ltD [THEN Lset_mono_mem]) 
   596 
   597 subsubsection{* 0, successor and limit equations fof Lset *}
   598 
   599 lemma Lset_0 [simp]: "Lset(0) = 0"
   600 by (subst Lset, blast)
   601 
   602 lemma Lset_succ_subset1: "DPow(Lset(i)) <= Lset(succ(i))"
   603 by (subst Lset, rule succI1 [THEN RepFunI, THEN Union_upper])
   604 
   605 lemma Lset_succ_subset2: "Lset(succ(i)) <= DPow(Lset(i))"
   606 apply (subst Lset, rule UN_least)
   607 apply (erule succE) 
   608  apply blast 
   609 apply clarify
   610 apply (rule elem_subset_in_DPow)
   611  apply (subst Lset)
   612  apply blast 
   613 apply (blast intro: dest: DPowD Lset_mono_mem) 
   614 done
   615 
   616 lemma Lset_succ: "Lset(succ(i)) = DPow(Lset(i))"
   617 by (intro equalityI Lset_succ_subset1 Lset_succ_subset2) 
   618 
   619 lemma Lset_Union [simp]: "Lset(\<Union>(X)) = (\<Union>y\<in>X. Lset(y))"
   620 apply (subst Lset)
   621 apply (rule equalityI)
   622  txt{*first inclusion*}
   623  apply (rule UN_least)
   624  apply (erule UnionE)
   625  apply (rule subset_trans)
   626   apply (erule_tac [2] UN_upper, subst Lset, erule UN_upper)
   627 txt{*opposite inclusion*}
   628 apply (rule UN_least)
   629 apply (subst Lset, blast)
   630 done
   631 
   632 subsubsection{* Lset applied to Limit ordinals *}
   633 
   634 lemma Limit_Lset_eq:
   635     "Limit(i) ==> Lset(i) = (\<Union>y\<in>i. Lset(y))"
   636 by (simp add: Lset_Union [symmetric] Limit_Union_eq)
   637 
   638 lemma lt_LsetI: "[| a: Lset(j);  j<i |] ==> a : Lset(i)"
   639 by (blast dest: Lset_mono [OF le_imp_subset [OF leI]])
   640 
   641 lemma Limit_LsetE:
   642     "[| a: Lset(i);  ~R ==> Limit(i);
   643         !!x. [| x<i;  a: Lset(x) |] ==> R
   644      |] ==> R"
   645 apply (rule classical)
   646 apply (rule Limit_Lset_eq [THEN equalityD1, THEN subsetD, THEN UN_E])
   647   prefer 2 apply assumption
   648  apply blast 
   649 apply (blast intro: ltI  Limit_is_Ord)
   650 done
   651 
   652 subsubsection{* Basic closure properties *}
   653 
   654 lemma zero_in_Lset: "y:x ==> 0 : Lset(x)"
   655 by (subst Lset, blast intro: empty_in_DPow)
   656 
   657 lemma notin_Lset: "x \<notin> Lset(x)"
   658 apply (rule_tac a=x in eps_induct)
   659 apply (subst Lset)
   660 apply (blast dest: DPowD)  
   661 done
   662 
   663 
   664 
   665 text{*Kunen's VI, 1.9 (b)*}
   666 
   667 constdefs subset_fm :: "[i,i]=>i"
   668     "subset_fm(x,y) == Forall(Implies(Member(0,succ(x)), Member(0,succ(y))))"
   669 
   670 lemma subset_type [TC]: "[| x \<in> nat; y \<in> nat |] ==> subset_fm(x,y) \<in> formula"
   671 by (simp add: subset_fm_def) 
   672 
   673 lemma arity_subset_fm [simp]:
   674      "[| x \<in> nat; y \<in> nat |] ==> arity(subset_fm(x,y)) = succ(x) \<union> succ(y)"
   675 by (simp add: subset_fm_def succ_Un_distrib [symmetric]) 
   676 
   677 lemma sats_subset_fm [simp]:
   678    "[|x < length(env); y \<in> nat; env \<in> list(A); Transset(A)|]
   679     ==> sats(A, subset_fm(x,y), env) <-> nth(x,env) \<subseteq> nth(y,env)"
   680 apply (frule lt_nat_in_nat, erule length_type) 
   681 apply (simp add: subset_fm_def Transset_def) 
   682 apply (blast intro: nth_type ) 
   683 done
   684 
   685 constdefs transset_fm :: "i=>i"
   686    "transset_fm(x) == Forall(Implies(Member(0,succ(x)), subset_fm(0,succ(x))))"
   687 
   688 lemma transset_type [TC]: "x \<in> nat ==> transset_fm(x) \<in> formula"
   689 by (simp add: transset_fm_def) 
   690 
   691 lemma arity_transset_fm [simp]:
   692      "x \<in> nat ==> arity(transset_fm(x)) = succ(x)"
   693 by (simp add: transset_fm_def succ_Un_distrib [symmetric]) 
   694 
   695 lemma sats_transset_fm [simp]:
   696    "[|x < length(env); env \<in> list(A); Transset(A)|]
   697     ==> sats(A, transset_fm(x), env) <-> Transset(nth(x,env))"
   698 apply (frule lt_nat_in_nat, erule length_type) 
   699 apply (simp add: transset_fm_def Transset_def) 
   700 apply (blast intro: nth_type ) 
   701 done
   702 
   703 constdefs ordinal_fm :: "i=>i"
   704    "ordinal_fm(x) == 
   705       And(transset_fm(x), Forall(Implies(Member(0,succ(x)), transset_fm(0))))"
   706 
   707 lemma ordinal_type [TC]: "x \<in> nat ==> ordinal_fm(x) \<in> formula"
   708 by (simp add: ordinal_fm_def) 
   709 
   710 lemma arity_ordinal_fm [simp]:
   711      "x \<in> nat ==> arity(ordinal_fm(x)) = succ(x)"
   712 by (simp add: ordinal_fm_def succ_Un_distrib [symmetric]) 
   713 
   714 lemma sats_ordinal_fm [simp]:
   715    "[|x < length(env); env \<in> list(A); Transset(A)|]
   716     ==> sats(A, ordinal_fm(x), env) <-> Ord(nth(x,env))"
   717 apply (frule lt_nat_in_nat, erule length_type) 
   718 apply (simp add: ordinal_fm_def Ord_def Transset_def)
   719 apply (blast intro: nth_type ) 
   720 done
   721 
   722 text{*The subset consisting of the ordinals is definable.*}
   723 lemma Ords_in_DPow: "Transset(A) ==> {x \<in> A. Ord(x)} \<in> DPow(A)"
   724 apply (simp add: DPow_def Collect_subset) 
   725 apply (rule_tac x="Nil" in bexI) 
   726  apply (rule_tac x="ordinal_fm(0)" in bexI) 
   727 apply (simp_all add: sats_ordinal_fm)
   728 done 
   729 
   730 lemma Ords_of_Lset_eq: "Ord(i) ==> {x\<in>Lset(i). Ord(x)} = i"
   731 apply (erule trans_induct3)
   732   apply (simp_all add: Lset_succ Limit_Lset_eq Limit_Union_eq)
   733 txt{*The successor case remains.*} 
   734 apply (rule equalityI)
   735 txt{*First inclusion*}
   736  apply clarify  
   737  apply (erule Ord_linear_lt, assumption) 
   738    apply (blast dest: DPow_imp_subset ltD notE [OF notin_Lset]) 
   739   apply blast 
   740  apply (blast dest: ltD)
   741 txt{*Opposite inclusion, @{term "succ(x) \<subseteq> DPow(Lset(x)) \<inter> ON"}*}
   742 apply auto
   743 txt{*Key case: *}
   744   apply (erule subst, rule Ords_in_DPow [OF Transset_Lset]) 
   745  apply (blast intro: elem_subset_in_DPow dest: OrdmemD elim: equalityE) 
   746 apply (blast intro: Ord_in_Ord) 
   747 done
   748 
   749 
   750 lemma Ord_subset_Lset: "Ord(i) ==> i \<subseteq> Lset(i)"
   751 by (subst Ords_of_Lset_eq [symmetric], assumption, fast)
   752 
   753 lemma Ord_in_Lset: "Ord(i) ==> i \<in> Lset(succ(i))"
   754 apply (simp add: Lset_succ)
   755 apply (subst Ords_of_Lset_eq [symmetric], assumption, 
   756        rule Ords_in_DPow [OF Transset_Lset]) 
   757 done
   758 
   759 subsubsection{* Unions *}
   760 
   761 lemma Union_in_Lset:
   762      "X \<in> Lset(j) ==> Union(X) \<in> Lset(succ(j))"
   763 apply (insert Transset_Lset)
   764 apply (rule LsetI [OF succI1])
   765 apply (simp add: Transset_def DPow_def) 
   766 apply (intro conjI, blast)
   767 txt{*Now to create the formula @{term "\<exists>y. y \<in> X \<and> x \<in> y"} *}
   768 apply (rule_tac x="Cons(X,Nil)" in bexI) 
   769  apply (rule_tac x="Exists(And(Member(0,2), Member(1,0)))" in bexI) 
   770   apply typecheck
   771 apply (simp add: succ_Un_distrib [symmetric], blast) 
   772 done
   773 
   774 lemma Union_in_LLimit:
   775      "[| X: Lset(i);  Limit(i) |] ==> Union(X) : Lset(i)"
   776 apply (rule Limit_LsetE, assumption+)
   777 apply (blast intro: Limit_has_succ lt_LsetI Union_in_Lset)
   778 done
   779 
   780 subsubsection{* Finite sets and ordered pairs *}
   781 
   782 lemma singleton_in_Lset: "a: Lset(i) ==> {a} : Lset(succ(i))"
   783 by (simp add: Lset_succ singleton_in_DPow) 
   784 
   785 lemma doubleton_in_Lset:
   786      "[| a: Lset(i);  b: Lset(i) |] ==> {a,b} : Lset(succ(i))"
   787 by (simp add: Lset_succ empty_in_DPow cons_in_DPow) 
   788 
   789 lemma Pair_in_Lset:
   790     "[| a: Lset(i);  b: Lset(i); Ord(i) |] ==> <a,b> : Lset(succ(succ(i)))"
   791 apply (unfold Pair_def)
   792 apply (blast intro: doubleton_in_Lset) 
   793 done
   794 
   795 lemmas zero_in_LLimit = Limit_has_0 [THEN ltD, THEN zero_in_Lset, standard]
   796 
   797 lemma singleton_in_LLimit:
   798     "[| a: Lset(i);  Limit(i) |] ==> {a} : Lset(i)"
   799 apply (erule Limit_LsetE, assumption)
   800 apply (erule singleton_in_Lset [THEN lt_LsetI])
   801 apply (blast intro: Limit_has_succ) 
   802 done
   803 
   804 lemmas Lset_UnI1 = Un_upper1 [THEN Lset_mono [THEN subsetD], standard]
   805 lemmas Lset_UnI2 = Un_upper2 [THEN Lset_mono [THEN subsetD], standard]
   806 
   807 text{*Hard work is finding a single j:i such that {a,b}<=Lset(j)*}
   808 lemma doubleton_in_LLimit:
   809     "[| a: Lset(i);  b: Lset(i);  Limit(i) |] ==> {a,b} : Lset(i)"
   810 apply (erule Limit_LsetE, assumption)
   811 apply (erule Limit_LsetE, assumption)
   812 apply (blast intro: lt_LsetI [OF doubleton_in_Lset]
   813                     Lset_UnI1 Lset_UnI2 Limit_has_succ Un_least_lt)
   814 done
   815 
   816 lemma Pair_in_LLimit:
   817     "[| a: Lset(i);  b: Lset(i);  Limit(i) |] ==> <a,b> : Lset(i)"
   818 txt{*Infer that a, b occur at ordinals x,xa < i.*}
   819 apply (erule Limit_LsetE, assumption)
   820 apply (erule Limit_LsetE, assumption)
   821 txt{*Infer that succ(succ(x Un xa)) < i *}
   822 apply (blast intro: lt_Ord lt_LsetI [OF Pair_in_Lset]
   823                     Lset_UnI1 Lset_UnI2 Limit_has_succ Un_least_lt)
   824 done
   825 
   826 lemma product_LLimit: "Limit(i) ==> Lset(i) * Lset(i) <= Lset(i)"
   827 by (blast intro: Pair_in_LLimit)
   828 
   829 lemmas Sigma_subset_LLimit = subset_trans [OF Sigma_mono product_LLimit]
   830 
   831 lemma nat_subset_LLimit: "Limit(i) ==> nat \<subseteq> Lset(i)"
   832 by (blast dest: Ord_subset_Lset nat_le_Limit le_imp_subset Limit_is_Ord)
   833 
   834 lemma nat_into_LLimit: "[| n: nat;  Limit(i) |] ==> n : Lset(i)"
   835 by (blast intro: nat_subset_LLimit [THEN subsetD])
   836 
   837 
   838 subsubsection{* Closure under disjoint union *}
   839 
   840 lemmas zero_in_LLimit = Limit_has_0 [THEN ltD, THEN zero_in_Lset, standard]
   841 
   842 lemma one_in_LLimit: "Limit(i) ==> 1 : Lset(i)"
   843 by (blast intro: nat_into_LLimit)
   844 
   845 lemma Inl_in_LLimit:
   846     "[| a: Lset(i); Limit(i) |] ==> Inl(a) : Lset(i)"
   847 apply (unfold Inl_def)
   848 apply (blast intro: zero_in_LLimit Pair_in_LLimit)
   849 done
   850 
   851 lemma Inr_in_LLimit:
   852     "[| b: Lset(i); Limit(i) |] ==> Inr(b) : Lset(i)"
   853 apply (unfold Inr_def)
   854 apply (blast intro: one_in_LLimit Pair_in_LLimit)
   855 done
   856 
   857 lemma sum_LLimit: "Limit(i) ==> Lset(i) + Lset(i) <= Lset(i)"
   858 by (blast intro!: Inl_in_LLimit Inr_in_LLimit)
   859 
   860 lemmas sum_subset_LLimit = subset_trans [OF sum_mono sum_LLimit]
   861 
   862 
   863 text{*The constructible universe and its rank function*}
   864 constdefs
   865   L :: "i=>o" --{*Kunen's definition VI, 1.5, page 167*}
   866     "L(x) == \<exists>i. Ord(i) & x \<in> Lset(i)"
   867   
   868   lrank :: "i=>i" --{*Kunen's definition VI, 1.7*}
   869     "lrank(x) == \<mu>i. x \<in> Lset(succ(i))"
   870 
   871 lemma L_I: "[|x \<in> Lset(i); Ord(i)|] ==> L(x)"
   872 by (simp add: L_def, blast)
   873 
   874 lemma L_D: "L(x) ==> \<exists>i. Ord(i) & x \<in> Lset(i)"
   875 by (simp add: L_def)
   876 
   877 lemma Ord_lrank [simp]: "Ord(lrank(a))"
   878 by (simp add: lrank_def)
   879 
   880 lemma Lset_lrank_lt [rule_format]: "Ord(i) ==> x \<in> Lset(i) --> lrank(x) < i"
   881 apply (erule trans_induct3)
   882   apply simp   
   883  apply (simp only: lrank_def) 
   884  apply (blast intro: Least_le) 
   885 apply (simp_all add: Limit_Lset_eq) 
   886 apply (blast intro: ltI Limit_is_Ord lt_trans) 
   887 done
   888 
   889 text{*Kunen's VI, 1.8, and the proof is much less trivial than the text
   890 would suggest.  For a start it need the previous lemma, proved by induction.*}
   891 lemma Lset_iff_lrank_lt: "Ord(i) ==> x \<in> Lset(i) <-> L(x) & lrank(x) < i"
   892 apply (simp add: L_def, auto) 
   893  apply (blast intro: Lset_lrank_lt) 
   894  apply (unfold lrank_def) 
   895 apply (drule succI1 [THEN Lset_mono_mem, THEN subsetD]) 
   896 apply (drule_tac P="\<lambda>i. x \<in> Lset(succ(i))" in LeastI, assumption) 
   897 apply (blast intro!: le_imp_subset Lset_mono [THEN subsetD]) 
   898 done
   899 
   900 lemma Lset_succ_lrank_iff [simp]: "x \<in> Lset(succ(lrank(x))) <-> L(x)"
   901 by (simp add: Lset_iff_lrank_lt)
   902 
   903 text{*Kunen's VI, 1.9 (a)*}
   904 lemma lrank_of_Ord: "Ord(i) ==> lrank(i) = i"
   905 apply (unfold lrank_def) 
   906 apply (rule Least_equality) 
   907   apply (erule Ord_in_Lset) 
   908  apply assumption
   909 apply (insert notin_Lset [of i]) 
   910 apply (blast intro!: le_imp_subset Lset_mono [THEN subsetD]) 
   911 done
   912 
   913 
   914 lemma Ord_in_L: "Ord(i) ==> L(i)"
   915 by (blast intro: Ord_in_Lset L_I)
   916 
   917 text{*This is lrank(lrank(a)) = lrank(a) *}
   918 declare Ord_lrank [THEN lrank_of_Ord, simp]
   919 
   920 text{*Kunen's VI, 1.10 *}
   921 lemma Lset_in_Lset_succ: "Lset(i) \<in> Lset(succ(i))";
   922 apply (simp add: Lset_succ DPow_def) 
   923 apply (rule_tac x="Nil" in bexI) 
   924  apply (rule_tac x="Equal(0,0)" in bexI) 
   925 apply auto 
   926 done
   927 
   928 lemma lrank_Lset: "Ord(i) ==> lrank(Lset(i)) = i"
   929 apply (unfold lrank_def) 
   930 apply (rule Least_equality) 
   931   apply (rule Lset_in_Lset_succ) 
   932  apply assumption
   933 apply clarify 
   934 apply (subgoal_tac "Lset(succ(ia)) <= Lset(i)")
   935  apply (blast dest: mem_irrefl) 
   936 apply (blast intro!: le_imp_subset Lset_mono) 
   937 done
   938 
   939 text{*Kunen's VI, 1.11 *}
   940 lemma Lset_subset_Vset: "Ord(i) ==> Lset(i) <= Vset(i)";
   941 apply (erule trans_induct)
   942 apply (subst Lset) 
   943 apply (subst Vset) 
   944 apply (rule UN_mono [OF subset_refl]) 
   945 apply (rule subset_trans [OF DPow_subset_Pow]) 
   946 apply (rule Pow_mono, blast) 
   947 done
   948 
   949 text{*Kunen's VI, 1.12 *}
   950 lemma Lset_subset_Vset: "i \<in> nat ==> Lset(i) = Vset(i)";
   951 apply (erule nat_induct)
   952  apply (simp add: Vfrom_0) 
   953 apply (simp add: Lset_succ Vset_succ Finite_Vset Finite_DPow_eq_Pow) 
   954 done
   955 
   956 text{*Every set of constructible sets is included in some @{term Lset}*} 
   957 lemma subset_Lset:
   958      "(\<forall>x\<in>A. L(x)) ==> \<exists>i. Ord(i) & A \<subseteq> Lset(i)"
   959 by (rule_tac x = "\<Union>x\<in>A. succ(lrank(x))" in exI, force)
   960 
   961 lemma subset_LsetE:
   962      "[|\<forall>x\<in>A. L(x);
   963         !!i. [|Ord(i); A \<subseteq> Lset(i)|] ==> P|]
   964       ==> P"
   965 by (blast dest: subset_Lset) 
   966 
   967 subsection{*For L to satisfy the ZF axioms*}
   968 
   969 theorem Union_in_L: "L(X) ==> L(Union(X))"
   970 apply (simp add: L_def, clarify) 
   971 apply (drule Ord_imp_greater_Limit) 
   972 apply (blast intro: lt_LsetI Union_in_LLimit Limit_is_Ord) 
   973 done
   974 
   975 theorem doubleton_in_L: "[| L(a); L(b) |] ==> L({a, b})"
   976 apply (simp add: L_def, clarify) 
   977 apply (drule Ord2_imp_greater_Limit, assumption) 
   978 apply (blast intro: lt_LsetI doubleton_in_LLimit Limit_is_Ord) 
   979 done
   980 
   981 subsubsection{*For L to satisfy Powerset *}
   982 
   983 lemma LPow_env_typing:
   984      "[| y : Lset(i); Ord(i); y \<subseteq> X |] ==> y \<in> (\<Union>y\<in>Pow(X). Lset(succ(lrank(y))))"
   985 by (auto intro: L_I iff: Lset_succ_lrank_iff) 
   986 
   987 lemma LPow_in_Lset:
   988      "[|X \<in> Lset(i); Ord(i)|] ==> \<exists>j. Ord(j) & {y \<in> Pow(X). L(y)} \<in> Lset(j)"
   989 apply (rule_tac x="succ(\<Union>y \<in> Pow(X). succ(lrank(y)))" in exI)
   990 apply simp 
   991 apply (rule LsetI [OF succI1])
   992 apply (simp add: DPow_def) 
   993 apply (intro conjI, clarify) 
   994 apply (rule_tac a="x" in UN_I, simp+)  
   995 txt{*Now to create the formula @{term "y \<subseteq> X"} *}
   996 apply (rule_tac x="Cons(X,Nil)" in bexI) 
   997  apply (rule_tac x="subset_fm(0,1)" in bexI) 
   998   apply typecheck
   999 apply (rule conjI) 
  1000 apply (simp add: succ_Un_distrib [symmetric]) 
  1001 apply (rule equality_iffI) 
  1002 apply (simp add: Transset_UN [OF Transset_Lset] list.Cons [OF LPow_env_typing])
  1003 apply (auto intro: L_I iff: Lset_succ_lrank_iff) 
  1004 done
  1005 
  1006 theorem LPow_in_L: "L(X) ==> L({y \<in> Pow(X). L(y)})"
  1007 by (blast intro: L_I dest: L_D LPow_in_Lset)
  1008 
  1009 end