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