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