src/ZF/Constructible/DPow_absolute.thy
author wenzelm
Mon Dec 04 22:54:31 2017 +0100 (21 months ago)
changeset 67131 85d10959c2e4
parent 61798 27f3c10b0b50
child 67443 3abf6a722518
permissions -rw-r--r--
tuned signature;
paulson@13503
     1
(*  Title:      ZF/Constructible/DPow_absolute.thy
paulson@13503
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@13503
     3
*)
paulson@13503
     4
wenzelm@60770
     5
section \<open>Absoluteness for the Definable Powerset Function\<close>
paulson@13503
     6
paulson@13503
     7
haftmann@16417
     8
theory DPow_absolute imports Satisfies_absolute begin
paulson@13503
     9
paulson@13503
    10
wenzelm@60770
    11
subsection\<open>Preliminary Internalizations\<close>
paulson@13503
    12
wenzelm@60770
    13
subsubsection\<open>The Operator @{term is_formula_rec}\<close>
paulson@13503
    14
wenzelm@60770
    15
text\<open>The three arguments of @{term p} are always 2, 1, 0.  It is buried
wenzelm@60770
    16
   within 11 quantifiers!!\<close>
paulson@13503
    17
paulson@13503
    18
(* is_formula_rec :: "[i=>o, [i,i,i]=>o, i, i] => o"
paulson@13503
    19
   "is_formula_rec(M,MH,p,z)  ==
paulson@13503
    20
      \<exists>dp[M]. \<exists>i[M]. \<exists>f[M]. finite_ordinal(M,dp) & is_depth(M,p,dp) & 
paulson@13503
    21
       2       1      0
paulson@13503
    22
             successor(M,dp,i) & fun_apply(M,f,p,z) & is_transrec(M,MH,i,f)"
paulson@13503
    23
*)
paulson@13503
    24
wenzelm@21404
    25
definition
wenzelm@21404
    26
  formula_rec_fm :: "[i, i, i]=>i" where
paulson@13503
    27
 "formula_rec_fm(mh,p,z) == 
paulson@13503
    28
    Exists(Exists(Exists(
paulson@13503
    29
      And(finite_ordinal_fm(2),
paulson@13503
    30
       And(depth_fm(p#+3,2),
paulson@13503
    31
        And(succ_fm(2,1), 
paulson@13503
    32
          And(fun_apply_fm(0,p#+3,z#+3), is_transrec_fm(mh,1,0))))))))"
paulson@13503
    33
paulson@13503
    34
lemma is_formula_rec_type [TC]:
paulson@13503
    35
     "[| p \<in> formula; x \<in> nat; z \<in> nat |] 
paulson@13503
    36
      ==> formula_rec_fm(p,x,z) \<in> formula"
paulson@13503
    37
by (simp add: formula_rec_fm_def) 
paulson@13503
    38
paulson@13503
    39
lemma sats_formula_rec_fm:
paulson@13503
    40
  assumes MH_iff_sats: 
paulson@13503
    41
      "!!a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10. 
paulson@13503
    42
        [|a0\<in>A; a1\<in>A; a2\<in>A; a3\<in>A; a4\<in>A; a5\<in>A; a6\<in>A; a7\<in>A; a8\<in>A; a9\<in>A; a10\<in>A|]
paulson@46823
    43
        ==> MH(a2, a1, a0) \<longleftrightarrow> 
paulson@13503
    44
            sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,
paulson@13503
    45
                          Cons(a4,Cons(a5,Cons(a6,Cons(a7,
paulson@13503
    46
                                  Cons(a8,Cons(a9,Cons(a10,env))))))))))))"
paulson@13503
    47
  shows 
paulson@13503
    48
      "[|x \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@46823
    49
       ==> sats(A, formula_rec_fm(p,x,z), env) \<longleftrightarrow> 
paulson@13807
    50
           is_formula_rec(##A, MH, nth(x,env), nth(z,env))"
paulson@13503
    51
by (simp add: formula_rec_fm_def sats_is_transrec_fm is_formula_rec_def 
paulson@13503
    52
              MH_iff_sats [THEN iff_sym])
paulson@13503
    53
paulson@13503
    54
lemma formula_rec_iff_sats:
paulson@13503
    55
  assumes MH_iff_sats: 
paulson@13503
    56
      "!!a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10. 
paulson@13503
    57
        [|a0\<in>A; a1\<in>A; a2\<in>A; a3\<in>A; a4\<in>A; a5\<in>A; a6\<in>A; a7\<in>A; a8\<in>A; a9\<in>A; a10\<in>A|]
paulson@46823
    58
        ==> MH(a2, a1, a0) \<longleftrightarrow> 
paulson@13503
    59
            sats(A, p, Cons(a0,Cons(a1,Cons(a2,Cons(a3,
paulson@13503
    60
                          Cons(a4,Cons(a5,Cons(a6,Cons(a7,
paulson@13503
    61
                                  Cons(a8,Cons(a9,Cons(a10,env))))))))))))"
paulson@13503
    62
  shows
paulson@13503
    63
  "[|nth(i,env) = x; nth(k,env) = z; 
paulson@13503
    64
      i \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@46823
    65
   ==> is_formula_rec(##A, MH, x, z) \<longleftrightarrow> sats(A, formula_rec_fm(p,i,k), env)" 
paulson@13503
    66
by (simp add: sats_formula_rec_fm [OF MH_iff_sats])
paulson@13503
    67
paulson@13503
    68
theorem formula_rec_reflection:
paulson@13503
    69
  assumes MH_reflection:
paulson@13503
    70
    "!!f' f g h. REFLECTS[\<lambda>x. MH(L, f'(x), f(x), g(x), h(x)), 
paulson@13807
    71
                     \<lambda>i x. MH(##Lset(i), f'(x), f(x), g(x), h(x))]"
paulson@13503
    72
  shows "REFLECTS[\<lambda>x. is_formula_rec(L, MH(L,x), f(x), h(x)), 
paulson@13807
    73
               \<lambda>i x. is_formula_rec(##Lset(i), MH(##Lset(i),x), f(x), h(x))]"
paulson@13655
    74
apply (simp (no_asm_use) only: is_formula_rec_def)
paulson@13503
    75
apply (intro FOL_reflections function_reflections fun_plus_reflections
paulson@13503
    76
             depth_reflection is_transrec_reflection MH_reflection)
paulson@13503
    77
done
paulson@13503
    78
paulson@13503
    79
wenzelm@60770
    80
subsubsection\<open>The Operator @{term is_satisfies}\<close>
paulson@13503
    81
paulson@13503
    82
(* is_satisfies(M,A,p,z) == is_formula_rec (M, satisfies_MH(M,A), p, z) *)
wenzelm@21404
    83
definition
wenzelm@21404
    84
  satisfies_fm :: "[i,i,i]=>i" where
paulson@13503
    85
    "satisfies_fm(x) == formula_rec_fm (satisfies_MH_fm(x#+5#+6, 2, 1, 0))"
paulson@13503
    86
paulson@13503
    87
lemma is_satisfies_type [TC]:
paulson@13503
    88
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> satisfies_fm(x,y,z) \<in> formula"
paulson@13503
    89
by (simp add: satisfies_fm_def)
paulson@13503
    90
paulson@13503
    91
lemma sats_satisfies_fm [simp]:
paulson@13503
    92
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@46823
    93
    ==> sats(A, satisfies_fm(x,y,z), env) \<longleftrightarrow>
paulson@13807
    94
        is_satisfies(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13503
    95
by (simp add: satisfies_fm_def is_satisfies_def sats_satisfies_MH_fm
paulson@13503
    96
              sats_formula_rec_fm)
paulson@13503
    97
paulson@13503
    98
lemma satisfies_iff_sats:
paulson@13503
    99
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13503
   100
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@46823
   101
       ==> is_satisfies(##A, x, y, z) \<longleftrightarrow> sats(A, satisfies_fm(i,j,k), env)"
paulson@13503
   102
by (simp add: sats_satisfies_fm)
paulson@13503
   103
paulson@13503
   104
theorem satisfies_reflection:
paulson@13503
   105
     "REFLECTS[\<lambda>x. is_satisfies(L,f(x),g(x),h(x)),
paulson@13807
   106
               \<lambda>i x. is_satisfies(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
   107
apply (simp only: is_satisfies_def)
paulson@13503
   108
apply (intro formula_rec_reflection satisfies_MH_reflection)
paulson@13503
   109
done
paulson@13503
   110
paulson@13503
   111
wenzelm@60770
   112
subsection \<open>Relativization of the Operator @{term DPow'}\<close>
paulson@13503
   113
paulson@13503
   114
lemma DPow'_eq: 
paulson@13692
   115
  "DPow'(A) = {z . ep \<in> list(A) * formula, 
paulson@13692
   116
                    \<exists>env \<in> list(A). \<exists>p \<in> formula. 
paulson@13692
   117
                       ep = <env,p> & z = {x\<in>A. sats(A, p, Cons(x,env))}}"
paulson@13692
   118
by (simp add: DPow'_def, blast) 
paulson@13503
   119
paulson@13503
   120
wenzelm@60770
   121
text\<open>Relativize the use of @{term sats} within @{term DPow'}
wenzelm@60770
   122
(the comprehension).\<close>
wenzelm@21233
   123
definition
wenzelm@21404
   124
  is_DPow_sats :: "[i=>o,i,i,i,i] => o" where
paulson@13692
   125
   "is_DPow_sats(M,A,env,p,x) ==
paulson@13503
   126
      \<forall>n1[M]. \<forall>e[M]. \<forall>sp[M]. 
paulson@46823
   127
             is_satisfies(M,A,p,sp) \<longrightarrow> is_Cons(M,x,env,e) \<longrightarrow> 
paulson@46823
   128
             fun_apply(M, sp, e, n1) \<longrightarrow> number1(M, n1)"
paulson@13503
   129
paulson@13692
   130
lemma (in M_satisfies) DPow_sats_abs:
paulson@13503
   131
    "[| M(A); env \<in> list(A); p \<in> formula; M(x) |]
paulson@46823
   132
    ==> is_DPow_sats(M,A,env,p,x) \<longleftrightarrow> sats(A, p, Cons(x,env))"
paulson@13503
   133
apply (subgoal_tac "M(env)") 
paulson@13692
   134
 apply (simp add: is_DPow_sats_def satisfies_closed satisfies_abs) 
paulson@13503
   135
apply (blast dest: transM) 
paulson@13503
   136
done
paulson@13503
   137
paulson@13692
   138
lemma (in M_satisfies) Collect_DPow_sats_abs:
paulson@13503
   139
    "[| M(A); env \<in> list(A); p \<in> formula |]
paulson@13692
   140
    ==> Collect(A, is_DPow_sats(M,A,env,p)) = 
paulson@13503
   141
        {x \<in> A. sats(A, p, Cons(x,env))}"
paulson@13692
   142
by (simp add: DPow_sats_abs transM [of _ A])
paulson@13503
   143
paulson@13503
   144
wenzelm@60770
   145
subsubsection\<open>The Operator @{term is_DPow_sats}, Internalized\<close>
paulson@13503
   146
paulson@13692
   147
(* is_DPow_sats(M,A,env,p,x) ==
paulson@13503
   148
      \<forall>n1[M]. \<forall>e[M]. \<forall>sp[M]. 
paulson@46823
   149
             is_satisfies(M,A,p,sp) \<longrightarrow> is_Cons(M,x,env,e) \<longrightarrow> 
paulson@46823
   150
             fun_apply(M, sp, e, n1) \<longrightarrow> number1(M, n1) *)
paulson@13503
   151
wenzelm@21404
   152
definition
wenzelm@21404
   153
  DPow_sats_fm :: "[i,i,i,i]=>i" where
wenzelm@21404
   154
  "DPow_sats_fm(A,env,p,x) ==
paulson@13503
   155
   Forall(Forall(Forall(
paulson@13503
   156
     Implies(satisfies_fm(A#+3,p#+3,0), 
paulson@13503
   157
       Implies(Cons_fm(x#+3,env#+3,1), 
paulson@13503
   158
         Implies(fun_apply_fm(0,1,2), number1_fm(2)))))))"
paulson@13503
   159
paulson@13692
   160
lemma is_DPow_sats_type [TC]:
paulson@13503
   161
     "[| A \<in> nat; x \<in> nat; y \<in> nat; z \<in> nat |]
paulson@13692
   162
      ==> DPow_sats_fm(A,x,y,z) \<in> formula"
paulson@13692
   163
by (simp add: DPow_sats_fm_def)
paulson@13503
   164
paulson@13692
   165
lemma sats_DPow_sats_fm [simp]:
paulson@13503
   166
   "[| u \<in> nat; x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@46823
   167
    ==> sats(A, DPow_sats_fm(u,x,y,z), env) \<longleftrightarrow>
paulson@13807
   168
        is_DPow_sats(##A, nth(u,env), nth(x,env), nth(y,env), nth(z,env))"
paulson@13692
   169
by (simp add: DPow_sats_fm_def is_DPow_sats_def)
paulson@13503
   170
paulson@13692
   171
lemma DPow_sats_iff_sats:
paulson@13503
   172
  "[| nth(u,env) = nu; nth(x,env) = nx; nth(y,env) = ny; nth(z,env) = nz;
paulson@13503
   173
      u \<in> nat; x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@46823
   174
   ==> is_DPow_sats(##A,nu,nx,ny,nz) \<longleftrightarrow>
paulson@13692
   175
       sats(A, DPow_sats_fm(u,x,y,z), env)"
paulson@13503
   176
by simp
paulson@13503
   177
paulson@13692
   178
theorem DPow_sats_reflection:
paulson@13692
   179
     "REFLECTS[\<lambda>x. is_DPow_sats(L,f(x),g(x),h(x),g'(x)),
paulson@13807
   180
               \<lambda>i x. is_DPow_sats(##Lset(i),f(x),g(x),h(x),g'(x))]"
paulson@13692
   181
apply (unfold is_DPow_sats_def) 
paulson@13503
   182
apply (intro FOL_reflections function_reflections extra_reflections
paulson@13503
   183
             satisfies_reflection)
paulson@13503
   184
done
paulson@13503
   185
paulson@13503
   186
wenzelm@60770
   187
subsection\<open>A Locale for Relativizing the Operator @{term DPow'}\<close>
paulson@13503
   188
paulson@13503
   189
locale M_DPow = M_satisfies +
paulson@13503
   190
 assumes sep:
paulson@13503
   191
   "[| M(A); env \<in> list(A); p \<in> formula |]
paulson@13692
   192
    ==> separation(M, \<lambda>x. is_DPow_sats(M,A,env,p,x))"
paulson@13503
   193
 and rep: 
paulson@13503
   194
    "M(A)
paulson@13503
   195
    ==> strong_replacement (M, 
paulson@13503
   196
         \<lambda>ep z. \<exists>env[M]. \<exists>p[M]. mem_formula(M,p) & mem_list(M,A,env) &
paulson@13503
   197
                  pair(M,env,p,ep) & 
paulson@13692
   198
                  is_Collect(M, A, \<lambda>x. is_DPow_sats(M,A,env,p,x), z))"
paulson@13503
   199
paulson@13503
   200
lemma (in M_DPow) sep':
paulson@13503
   201
   "[| M(A); env \<in> list(A); p \<in> formula |]
paulson@13503
   202
    ==> separation(M, \<lambda>x. sats(A, p, Cons(x,env)))"
paulson@13692
   203
by (insert sep [of A env p], simp add: DPow_sats_abs)
paulson@13503
   204
paulson@13503
   205
lemma (in M_DPow) rep':
paulson@13503
   206
   "M(A)
paulson@13503
   207
    ==> strong_replacement (M, 
paulson@13503
   208
         \<lambda>ep z. \<exists>env\<in>list(A). \<exists>p\<in>formula.
paulson@13504
   209
                  ep = <env,p> & z = {x \<in> A . sats(A, p, Cons(x, env))})" 
paulson@13692
   210
by (insert rep [of A], simp add: Collect_DPow_sats_abs) 
paulson@13503
   211
paulson@13503
   212
paulson@13503
   213
lemma univalent_pair_eq:
paulson@13503
   214
     "univalent (M, A, \<lambda>xy z. \<exists>x\<in>B. \<exists>y\<in>C. xy = \<langle>x,y\<rangle> \<and> z = f(x,y))"
paulson@13503
   215
by (simp add: univalent_def, blast) 
paulson@13503
   216
paulson@13503
   217
lemma (in M_DPow) DPow'_closed: "M(A) ==> M(DPow'(A))"
paulson@13503
   218
apply (simp add: DPow'_eq)
paulson@13503
   219
apply (fast intro: rep' sep' univalent_pair_eq)  
paulson@13503
   220
done
paulson@13503
   221
wenzelm@60770
   222
text\<open>Relativization of the Operator @{term DPow'}\<close>
wenzelm@21233
   223
definition 
wenzelm@21404
   224
  is_DPow' :: "[i=>o,i,i] => o" where
paulson@13503
   225
    "is_DPow'(M,A,Z) == 
paulson@46823
   226
       \<forall>X[M]. X \<in> Z \<longleftrightarrow> 
paulson@13503
   227
         subset(M,X,A) & 
paulson@13503
   228
           (\<exists>env[M]. \<exists>p[M]. mem_formula(M,p) & mem_list(M,A,env) &
paulson@13692
   229
                    is_Collect(M, A, is_DPow_sats(M,A,env,p), X))"
paulson@13503
   230
paulson@13503
   231
lemma (in M_DPow) DPow'_abs:
paulson@46823
   232
    "[|M(A); M(Z)|] ==> is_DPow'(M,A,Z) \<longleftrightarrow> Z = DPow'(A)"
paulson@13503
   233
apply (rule iffI)
paulson@13692
   234
 prefer 2 apply (simp add: is_DPow'_def DPow'_def Collect_DPow_sats_abs) 
paulson@13503
   235
apply (rule M_equalityI) 
paulson@13692
   236
apply (simp add: is_DPow'_def DPow'_def Collect_DPow_sats_abs, assumption)
paulson@13503
   237
apply (erule DPow'_closed)
paulson@13503
   238
done
paulson@13503
   239
paulson@13503
   240
wenzelm@61798
   241
subsection\<open>Instantiating the Locale \<open>M_DPow\<close>\<close>
paulson@13503
   242
wenzelm@60770
   243
subsubsection\<open>The Instance of Separation\<close>
paulson@13503
   244
paulson@13503
   245
lemma DPow_separation:
paulson@13503
   246
    "[| L(A); env \<in> list(A); p \<in> formula |]
paulson@13692
   247
     ==> separation(L, \<lambda>x. is_DPow_sats(L,A,env,p,x))"
paulson@13692
   248
apply (rule gen_separation_multi [OF DPow_sats_reflection, of "{A,env,p}"], 
paulson@13687
   249
       auto intro: transL)
paulson@13687
   250
apply (rule_tac env="[A,env,p]" in DPow_LsetI)
paulson@13692
   251
apply (rule DPow_sats_iff_sats sep_rules | simp)+
paulson@13503
   252
done
paulson@13503
   253
paulson@13503
   254
paulson@13503
   255
wenzelm@60770
   256
subsubsection\<open>The Instance of Replacement\<close>
paulson@13503
   257
paulson@13503
   258
lemma DPow_replacement_Reflects:
paulson@13503
   259
 "REFLECTS [\<lambda>x. \<exists>u[L]. u \<in> B &
paulson@13503
   260
             (\<exists>env[L]. \<exists>p[L].
paulson@13503
   261
               mem_formula(L,p) & mem_list(L,A,env) & pair(L,env,p,u) &
paulson@13692
   262
               is_Collect (L, A, is_DPow_sats(L,A,env,p), x)),
paulson@13503
   263
    \<lambda>i x. \<exists>u \<in> Lset(i). u \<in> B &
paulson@13503
   264
             (\<exists>env \<in> Lset(i). \<exists>p \<in> Lset(i).
paulson@13807
   265
               mem_formula(##Lset(i),p) & mem_list(##Lset(i),A,env) & 
paulson@13807
   266
               pair(##Lset(i),env,p,u) &
paulson@13807
   267
               is_Collect (##Lset(i), A, is_DPow_sats(##Lset(i),A,env,p), x))]"
paulson@13503
   268
apply (unfold is_Collect_def) 
paulson@13503
   269
apply (intro FOL_reflections function_reflections mem_formula_reflection
paulson@13692
   270
          mem_list_reflection DPow_sats_reflection)
paulson@13503
   271
done
paulson@13503
   272
paulson@13503
   273
lemma DPow_replacement:
paulson@13503
   274
    "L(A)
paulson@13503
   275
    ==> strong_replacement (L, 
paulson@13503
   276
         \<lambda>ep z. \<exists>env[L]. \<exists>p[L]. mem_formula(L,p) & mem_list(L,A,env) &
paulson@13503
   277
                  pair(L,env,p,ep) & 
paulson@13692
   278
                  is_Collect(L, A, \<lambda>x. is_DPow_sats(L,A,env,p,x), z))"
paulson@13503
   279
apply (rule strong_replacementI)
paulson@13687
   280
apply (rule_tac u="{A,B}" 
paulson@13687
   281
         in gen_separation_multi [OF DPow_replacement_Reflects], 
paulson@13687
   282
       auto)
paulson@13566
   283
apply (unfold is_Collect_def) 
paulson@13687
   284
apply (rule_tac env="[A,B]" in DPow_LsetI)
paulson@13503
   285
apply (rule sep_rules mem_formula_iff_sats mem_list_iff_sats 
paulson@13692
   286
            DPow_sats_iff_sats | simp)+
paulson@13503
   287
done
paulson@13503
   288
paulson@13503
   289
wenzelm@60770
   290
subsubsection\<open>Actually Instantiating the Locale\<close>
paulson@13503
   291
paulson@13503
   292
lemma M_DPow_axioms_L: "M_DPow_axioms(L)"
paulson@13503
   293
  apply (rule M_DPow_axioms.intro)
paulson@13503
   294
   apply (assumption | rule DPow_separation DPow_replacement)+
paulson@13503
   295
  done
paulson@13503
   296
paulson@13503
   297
theorem M_DPow_L: "PROP M_DPow(L)"
paulson@13503
   298
  apply (rule M_DPow.intro)
ballarin@19931
   299
   apply (rule M_satisfies_L)
paulson@13503
   300
  apply (rule M_DPow_axioms_L)
paulson@13503
   301
  done
paulson@13503
   302
paulson@13503
   303
lemmas DPow'_closed [intro, simp] = M_DPow.DPow'_closed [OF M_DPow_L]
paulson@13503
   304
  and DPow'_abs [intro, simp] = M_DPow.DPow'_abs [OF M_DPow_L]
paulson@13503
   305
paulson@13505
   306
wenzelm@60770
   307
subsubsection\<open>The Operator @{term is_Collect}\<close>
paulson@13505
   308
wenzelm@60770
   309
text\<open>The formula @{term is_P} has one free variable, 0, and it is
wenzelm@60770
   310
enclosed within a single quantifier.\<close>
paulson@13505
   311
paulson@13505
   312
(* is_Collect :: "[i=>o,i,i=>o,i] => o"
paulson@46823
   313
    "is_Collect(M,A,P,z) == \<forall>x[M]. x \<in> z \<longleftrightarrow> x \<in> A & P(x)" *)
paulson@13505
   314
wenzelm@21404
   315
definition
wenzelm@21404
   316
  Collect_fm :: "[i, i, i]=>i" where
paulson@13505
   317
 "Collect_fm(A,is_P,z) == 
paulson@13505
   318
        Forall(Iff(Member(0,succ(z)),
paulson@13505
   319
                   And(Member(0,succ(A)), is_P)))"
paulson@13505
   320
paulson@13505
   321
lemma is_Collect_type [TC]:
paulson@13505
   322
     "[| is_P \<in> formula; x \<in> nat; y \<in> nat |] 
paulson@13505
   323
      ==> Collect_fm(x,is_P,y) \<in> formula"
paulson@13505
   324
by (simp add: Collect_fm_def)
paulson@13505
   325
paulson@13505
   326
lemma sats_Collect_fm:
paulson@13505
   327
  assumes is_P_iff_sats: 
paulson@46823
   328
      "!!a. a \<in> A ==> is_P(a) \<longleftrightarrow> sats(A, p, Cons(a, env))"
paulson@13505
   329
  shows 
paulson@13505
   330
      "[|x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@46823
   331
       ==> sats(A, Collect_fm(x,p,y), env) \<longleftrightarrow>
paulson@13807
   332
           is_Collect(##A, nth(x,env), is_P, nth(y,env))"
paulson@13505
   333
by (simp add: Collect_fm_def is_Collect_def is_P_iff_sats [THEN iff_sym])
paulson@13505
   334
paulson@13505
   335
lemma Collect_iff_sats:
paulson@13505
   336
  assumes is_P_iff_sats: 
paulson@46823
   337
      "!!a. a \<in> A ==> is_P(a) \<longleftrightarrow> sats(A, p, Cons(a, env))"
paulson@13505
   338
  shows 
paulson@13505
   339
  "[| nth(i,env) = x; nth(j,env) = y;
paulson@13505
   340
      i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@46823
   341
   ==> is_Collect(##A, x, is_P, y) \<longleftrightarrow> sats(A, Collect_fm(i,p,j), env)"
paulson@13505
   342
by (simp add: sats_Collect_fm [OF is_P_iff_sats])
paulson@13505
   343
paulson@13505
   344
wenzelm@60770
   345
text\<open>The second argument of @{term is_P} gives it direct access to @{term x},
wenzelm@60770
   346
  which is essential for handling free variable references.\<close>
paulson@13505
   347
theorem Collect_reflection:
paulson@13505
   348
  assumes is_P_reflection:
paulson@13505
   349
    "!!h f g. REFLECTS[\<lambda>x. is_P(L, f(x), g(x)),
paulson@13807
   350
                     \<lambda>i x. is_P(##Lset(i), f(x), g(x))]"
paulson@13505
   351
  shows "REFLECTS[\<lambda>x. is_Collect(L, f(x), is_P(L,x), g(x)),
paulson@13807
   352
               \<lambda>i x. is_Collect(##Lset(i), f(x), is_P(##Lset(i), x), g(x))]"
paulson@13655
   353
apply (simp (no_asm_use) only: is_Collect_def)
paulson@13505
   354
apply (intro FOL_reflections is_P_reflection)
paulson@13505
   355
done
paulson@13505
   356
paulson@13505
   357
wenzelm@60770
   358
subsubsection\<open>The Operator @{term is_Replace}\<close>
paulson@13505
   359
wenzelm@60770
   360
text\<open>BEWARE!  The formula @{term is_P} has free variables 0, 1
wenzelm@60770
   361
 and not the usual 1, 0!  It is enclosed within two quantifiers.\<close>
paulson@13505
   362
paulson@13505
   363
(*  is_Replace :: "[i=>o,i,[i,i]=>o,i] => o"
paulson@46823
   364
    "is_Replace(M,A,P,z) == \<forall>u[M]. u \<in> z \<longleftrightarrow> (\<exists>x[M]. x\<in>A & P(x,u))" *)
paulson@13505
   365
wenzelm@21404
   366
definition
wenzelm@21404
   367
  Replace_fm :: "[i, i, i]=>i" where
wenzelm@21404
   368
  "Replace_fm(A,is_P,z) == 
paulson@13505
   369
        Forall(Iff(Member(0,succ(z)),
paulson@13505
   370
                   Exists(And(Member(0,A#+2), is_P))))"
paulson@13505
   371
paulson@13505
   372
lemma is_Replace_type [TC]:
paulson@13505
   373
     "[| is_P \<in> formula; x \<in> nat; y \<in> nat |] 
paulson@13505
   374
      ==> Replace_fm(x,is_P,y) \<in> formula"
paulson@13505
   375
by (simp add: Replace_fm_def)
paulson@13505
   376
paulson@13505
   377
lemma sats_Replace_fm:
paulson@13505
   378
  assumes is_P_iff_sats: 
paulson@13505
   379
      "!!a b. [|a \<in> A; b \<in> A|] 
paulson@46823
   380
              ==> is_P(a,b) \<longleftrightarrow> sats(A, p, Cons(a,Cons(b,env)))"
paulson@13505
   381
  shows 
paulson@13505
   382
      "[|x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@46823
   383
       ==> sats(A, Replace_fm(x,p,y), env) \<longleftrightarrow>
paulson@13807
   384
           is_Replace(##A, nth(x,env), is_P, nth(y,env))"
paulson@13505
   385
by (simp add: Replace_fm_def is_Replace_def is_P_iff_sats [THEN iff_sym])
paulson@13505
   386
paulson@13505
   387
lemma Replace_iff_sats:
paulson@13505
   388
  assumes is_P_iff_sats: 
paulson@13505
   389
      "!!a b. [|a \<in> A; b \<in> A|] 
paulson@46823
   390
              ==> is_P(a,b) \<longleftrightarrow> sats(A, p, Cons(a,Cons(b,env)))"
paulson@13505
   391
  shows 
paulson@13505
   392
  "[| nth(i,env) = x; nth(j,env) = y;
paulson@13505
   393
      i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@46823
   394
   ==> is_Replace(##A, x, is_P, y) \<longleftrightarrow> sats(A, Replace_fm(i,p,j), env)"
paulson@13505
   395
by (simp add: sats_Replace_fm [OF is_P_iff_sats])
paulson@13505
   396
paulson@13505
   397
wenzelm@60770
   398
text\<open>The second argument of @{term is_P} gives it direct access to @{term x},
wenzelm@60770
   399
  which is essential for handling free variable references.\<close>
paulson@13505
   400
theorem Replace_reflection:
paulson@13505
   401
  assumes is_P_reflection:
paulson@13505
   402
    "!!h f g. REFLECTS[\<lambda>x. is_P(L, f(x), g(x), h(x)),
paulson@13807
   403
                     \<lambda>i x. is_P(##Lset(i), f(x), g(x), h(x))]"
paulson@13505
   404
  shows "REFLECTS[\<lambda>x. is_Replace(L, f(x), is_P(L,x), g(x)),
paulson@13807
   405
               \<lambda>i x. is_Replace(##Lset(i), f(x), is_P(##Lset(i), x), g(x))]"
paulson@13655
   406
apply (simp (no_asm_use) only: is_Replace_def)
paulson@13505
   407
apply (intro FOL_reflections is_P_reflection)
paulson@13505
   408
done
paulson@13505
   409
paulson@13505
   410
paulson@13505
   411
wenzelm@60770
   412
subsubsection\<open>The Operator @{term is_DPow'}, Internalized\<close>
paulson@13505
   413
paulson@13505
   414
(*  "is_DPow'(M,A,Z) == 
paulson@46823
   415
       \<forall>X[M]. X \<in> Z \<longleftrightarrow> 
paulson@13505
   416
         subset(M,X,A) & 
paulson@13505
   417
           (\<exists>env[M]. \<exists>p[M]. mem_formula(M,p) & mem_list(M,A,env) &
paulson@13692
   418
                    is_Collect(M, A, is_DPow_sats(M,A,env,p), X))" *)
paulson@13505
   419
wenzelm@21404
   420
definition
wenzelm@21404
   421
  DPow'_fm :: "[i,i]=>i" where
paulson@13505
   422
    "DPow'_fm(A,Z) == 
paulson@13505
   423
      Forall(
paulson@13505
   424
       Iff(Member(0,succ(Z)),
paulson@13505
   425
        And(subset_fm(0,succ(A)),
paulson@13505
   426
         Exists(Exists(
paulson@13505
   427
          And(mem_formula_fm(0),
paulson@13505
   428
           And(mem_list_fm(A#+3,1),
paulson@13505
   429
            Collect_fm(A#+3, 
paulson@13692
   430
                       DPow_sats_fm(A#+4, 2, 1, 0), 2))))))))"
paulson@13505
   431
paulson@13505
   432
lemma is_DPow'_type [TC]:
paulson@13505
   433
     "[| x \<in> nat; y \<in> nat |] ==> DPow'_fm(x,y) \<in> formula"
paulson@13505
   434
by (simp add: DPow'_fm_def)
paulson@13505
   435
paulson@13505
   436
lemma sats_DPow'_fm [simp]:
paulson@13505
   437
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@46823
   438
    ==> sats(A, DPow'_fm(x,y), env) \<longleftrightarrow>
paulson@13807
   439
        is_DPow'(##A, nth(x,env), nth(y,env))"
paulson@13505
   440
by (simp add: DPow'_fm_def is_DPow'_def sats_subset_fm' sats_Collect_fm)
paulson@13505
   441
paulson@13505
   442
lemma DPow'_iff_sats:
paulson@13505
   443
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13505
   444
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@46823
   445
       ==> is_DPow'(##A, x, y) \<longleftrightarrow> sats(A, DPow'_fm(i,j), env)"
paulson@13505
   446
by (simp add: sats_DPow'_fm)
paulson@13505
   447
paulson@13505
   448
theorem DPow'_reflection:
paulson@13505
   449
     "REFLECTS[\<lambda>x. is_DPow'(L,f(x),g(x)),
paulson@13807
   450
               \<lambda>i x. is_DPow'(##Lset(i),f(x),g(x))]"
paulson@13655
   451
apply (simp only: is_DPow'_def)
paulson@13505
   452
apply (intro FOL_reflections function_reflections mem_formula_reflection
paulson@13692
   453
             mem_list_reflection Collect_reflection DPow_sats_reflection)
paulson@13505
   454
done
paulson@13505
   455
paulson@13505
   456
wenzelm@60770
   457
subsection\<open>A Locale for Relativizing the Operator @{term Lset}\<close>
paulson@13505
   458
wenzelm@21233
   459
definition
wenzelm@21404
   460
  transrec_body :: "[i=>o,i,i,i,i] => o" where
paulson@13505
   461
    "transrec_body(M,g,x) ==
paulson@13505
   462
      \<lambda>y z. \<exists>gy[M]. y \<in> x & fun_apply(M,g,y,gy) & is_DPow'(M,gy,z)"
paulson@13505
   463
paulson@13505
   464
lemma (in M_DPow) transrec_body_abs:
paulson@13505
   465
     "[|M(x); M(g); M(z)|]
paulson@46823
   466
    ==> transrec_body(M,g,x,y,z) \<longleftrightarrow> y \<in> x & z = DPow'(g`y)"
paulson@13505
   467
by (simp add: transrec_body_def DPow'_abs transM [of _ x])
paulson@13505
   468
paulson@13505
   469
locale M_Lset = M_DPow +
paulson@13505
   470
 assumes strong_rep:
paulson@13505
   471
   "[|M(x); M(g)|] ==> strong_replacement(M, \<lambda>y z. transrec_body(M,g,x,y,z))"
paulson@13505
   472
 and transrec_rep: 
paulson@13505
   473
    "M(i) ==> transrec_replacement(M, \<lambda>x f u. 
paulson@13505
   474
              \<exists>r[M]. is_Replace(M, x, transrec_body(M,f,x), r) & 
paulson@13505
   475
                     big_union(M, r, u), i)"
paulson@13505
   476
paulson@13505
   477
paulson@13505
   478
lemma (in M_Lset) strong_rep':
paulson@13505
   479
   "[|M(x); M(g)|]
paulson@13505
   480
    ==> strong_replacement(M, \<lambda>y z. y \<in> x & z = DPow'(g`y))"
paulson@13505
   481
by (insert strong_rep [of x g], simp add: transrec_body_abs)
paulson@13505
   482
paulson@13505
   483
lemma (in M_Lset) DPow_apply_closed:
paulson@13505
   484
   "[|M(f); M(x); y\<in>x|] ==> M(DPow'(f`y))"
paulson@13505
   485
by (blast intro: DPow'_closed dest: transM) 
paulson@13505
   486
paulson@13505
   487
lemma (in M_Lset) RepFun_DPow_apply_closed:
paulson@13505
   488
   "[|M(f); M(x)|] ==> M({DPow'(f`y). y\<in>x})"
paulson@13505
   489
by (blast intro: DPow_apply_closed RepFun_closed2 strong_rep') 
paulson@13505
   490
paulson@13505
   491
lemma (in M_Lset) RepFun_DPow_abs:
paulson@13505
   492
     "[|M(x); M(f); M(r) |]
paulson@46823
   493
      ==> is_Replace(M, x, \<lambda>y z. transrec_body(M,f,x,y,z), r) \<longleftrightarrow>
paulson@13505
   494
          r =  {DPow'(f`y). y\<in>x}"
paulson@13505
   495
apply (simp add: transrec_body_abs RepFun_def) 
paulson@13505
   496
apply (rule iff_trans) 
paulson@13505
   497
apply (rule Replace_abs) 
paulson@13505
   498
apply (simp_all add: DPow_apply_closed strong_rep') 
paulson@13505
   499
done
paulson@13505
   500
paulson@13505
   501
lemma (in M_Lset) transrec_rep':
paulson@13505
   502
   "M(i) ==> transrec_replacement(M, \<lambda>x f u. u = (\<Union>y\<in>x. DPow'(f ` y)), i)"
paulson@13505
   503
apply (insert transrec_rep [of i]) 
paulson@13505
   504
apply (simp add: RepFun_DPow_apply_closed RepFun_DPow_abs 
paulson@13505
   505
       transrec_replacement_def) 
paulson@13505
   506
done
paulson@13505
   507
paulson@13505
   508
wenzelm@60770
   509
text\<open>Relativization of the Operator @{term Lset}\<close>
paulson@13692
   510
wenzelm@21233
   511
definition
wenzelm@21404
   512
  is_Lset :: "[i=>o, i, i] => o" where
wenzelm@61798
   513
   \<comment>\<open>We can use the term language below because @{term is_Lset} will
paulson@13692
   514
       not have to be internalized: it isn't used in any instance of
wenzelm@60770
   515
       separation.\<close>
paulson@13505
   516
   "is_Lset(M,a,z) == is_transrec(M, %x f u. u = (\<Union>y\<in>x. DPow'(f`y)), a, z)"
paulson@13505
   517
paulson@13505
   518
lemma (in M_Lset) Lset_abs:
paulson@13505
   519
  "[|Ord(i);  M(i);  M(z)|] 
paulson@46823
   520
   ==> is_Lset(M,i,z) \<longleftrightarrow> z = Lset(i)"
paulson@13505
   521
apply (simp add: is_Lset_def Lset_eq_transrec_DPow') 
paulson@13505
   522
apply (rule transrec_abs)  
paulson@13634
   523
apply (simp_all add: transrec_rep' relation2_def RepFun_DPow_apply_closed)
paulson@13505
   524
done
paulson@13505
   525
paulson@13505
   526
lemma (in M_Lset) Lset_closed:
paulson@13505
   527
  "[|Ord(i);  M(i)|] ==> M(Lset(i))"
paulson@13505
   528
apply (simp add: Lset_eq_transrec_DPow') 
paulson@13505
   529
apply (rule transrec_closed [OF transrec_rep']) 
paulson@13634
   530
apply (simp_all add: relation2_def RepFun_DPow_apply_closed)
paulson@13505
   531
done
paulson@13505
   532
paulson@13505
   533
wenzelm@61798
   534
subsection\<open>Instantiating the Locale \<open>M_Lset\<close>\<close>
paulson@13505
   535
wenzelm@60770
   536
subsubsection\<open>The First Instance of Replacement\<close>
paulson@13505
   537
paulson@13505
   538
lemma strong_rep_Reflects:
paulson@13505
   539
 "REFLECTS [\<lambda>u. \<exists>v[L]. v \<in> B & (\<exists>gy[L].
paulson@13505
   540
                          v \<in> x & fun_apply(L,g,v,gy) & is_DPow'(L,gy,u)),
paulson@13505
   541
   \<lambda>i u. \<exists>v \<in> Lset(i). v \<in> B & (\<exists>gy \<in> Lset(i).
paulson@13807
   542
            v \<in> x & fun_apply(##Lset(i),g,v,gy) & is_DPow'(##Lset(i),gy,u))]"
paulson@13505
   543
by (intro FOL_reflections function_reflections DPow'_reflection)
paulson@13505
   544
paulson@13505
   545
lemma strong_rep:
paulson@13505
   546
   "[|L(x); L(g)|] ==> strong_replacement(L, \<lambda>y z. transrec_body(L,g,x,y,z))"
paulson@13505
   547
apply (unfold transrec_body_def)  
paulson@13505
   548
apply (rule strong_replacementI) 
paulson@13687
   549
apply (rule_tac u="{x,g,B}" 
paulson@13687
   550
         in gen_separation_multi [OF strong_rep_Reflects], auto)
paulson@13687
   551
apply (rule_tac env="[x,g,B]" in DPow_LsetI)
paulson@13505
   552
apply (rule sep_rules DPow'_iff_sats | simp)+
paulson@13505
   553
done
paulson@13505
   554
paulson@13505
   555
wenzelm@60770
   556
subsubsection\<open>The Second Instance of Replacement\<close>
paulson@13505
   557
paulson@13505
   558
lemma transrec_rep_Reflects:
paulson@13505
   559
 "REFLECTS [\<lambda>x. \<exists>v[L]. v \<in> B &
paulson@13505
   560
              (\<exists>y[L]. pair(L,v,y,x) &
paulson@13505
   561
             is_wfrec (L, \<lambda>x f u. \<exists>r[L].
paulson@13505
   562
                is_Replace (L, x, \<lambda>y z. 
paulson@13505
   563
                     \<exists>gy[L]. y \<in> x & fun_apply(L,f,y,gy) & 
paulson@13505
   564
                      is_DPow'(L,gy,z), r) & big_union(L,r,u), mr, v, y)),
paulson@13505
   565
    \<lambda>i x. \<exists>v \<in> Lset(i). v \<in> B &
paulson@13807
   566
              (\<exists>y \<in> Lset(i). pair(##Lset(i),v,y,x) &
paulson@13807
   567
             is_wfrec (##Lset(i), \<lambda>x f u. \<exists>r \<in> Lset(i).
paulson@13807
   568
                is_Replace (##Lset(i), x, \<lambda>y z. 
paulson@13807
   569
                     \<exists>gy \<in> Lset(i). y \<in> x & fun_apply(##Lset(i),f,y,gy) & 
paulson@13807
   570
                      is_DPow'(##Lset(i),gy,z), r) & 
paulson@13807
   571
                      big_union(##Lset(i),r,u), mr, v, y))]" 
paulson@13655
   572
apply (simp only: rex_setclass_is_bex [symmetric])
wenzelm@61798
   573
  \<comment>\<open>Convert \<open>\<exists>y\<in>Lset(i)\<close> to \<open>\<exists>y[##Lset(i)]\<close> within the body
wenzelm@60770
   574
       of the @{term is_wfrec} application.\<close>
paulson@13505
   575
apply (intro FOL_reflections function_reflections 
paulson@13505
   576
          is_wfrec_reflection Replace_reflection DPow'_reflection) 
paulson@13505
   577
done
paulson@13505
   578
paulson@13505
   579
paulson@13505
   580
lemma transrec_rep: 
paulson@13505
   581
    "[|L(j)|]
paulson@13505
   582
    ==> transrec_replacement(L, \<lambda>x f u. 
paulson@13505
   583
              \<exists>r[L]. is_Replace(L, x, transrec_body(L,f,x), r) & 
paulson@13505
   584
                     big_union(L, r, u), j)"
paulson@13505
   585
apply (rule transrec_replacementI, assumption)
paulson@13566
   586
apply (unfold transrec_body_def)  
paulson@13505
   587
apply (rule strong_replacementI)
paulson@13566
   588
apply (rule_tac u="{j,B,Memrel(eclose({j}))}" 
paulson@13687
   589
         in gen_separation_multi [OF transrec_rep_Reflects], auto)
paulson@13687
   590
apply (rule_tac env="[j,B,Memrel(eclose({j}))]" in DPow_LsetI)
paulson@13505
   591
apply (rule sep_rules is_wfrec_iff_sats Replace_iff_sats DPow'_iff_sats | 
paulson@13505
   592
       simp)+
paulson@13505
   593
done
paulson@13505
   594
paulson@13505
   595
wenzelm@61798
   596
subsubsection\<open>Actually Instantiating \<open>M_Lset\<close>\<close>
paulson@13505
   597
paulson@13505
   598
lemma M_Lset_axioms_L: "M_Lset_axioms(L)"
paulson@13505
   599
  apply (rule M_Lset_axioms.intro)
paulson@13505
   600
       apply (assumption | rule strong_rep transrec_rep)+
paulson@13505
   601
  done
paulson@13505
   602
paulson@13505
   603
theorem M_Lset_L: "PROP M_Lset(L)"
ballarin@19931
   604
  apply (rule M_Lset.intro) 
ballarin@19931
   605
   apply (rule M_DPow_L)
ballarin@19931
   606
  apply (rule M_Lset_axioms_L) 
ballarin@19931
   607
  done
paulson@13505
   608
wenzelm@60770
   609
text\<open>Finally: the point of the whole theory!\<close>
paulson@13505
   610
lemmas Lset_closed = M_Lset.Lset_closed [OF M_Lset_L]
paulson@13505
   611
   and Lset_abs = M_Lset.Lset_abs [OF M_Lset_L]
paulson@13505
   612
paulson@13505
   613
wenzelm@60770
   614
subsection\<open>The Notion of Constructible Set\<close>
paulson@13505
   615
wenzelm@21233
   616
definition
wenzelm@21404
   617
  constructible :: "[i=>o,i] => o" where
paulson@13505
   618
    "constructible(M,x) ==
paulson@13505
   619
       \<exists>i[M]. \<exists>Li[M]. ordinal(M,i) & is_Lset(M,i,Li) & x \<in> Li"
paulson@13505
   620
paulson@13505
   621
theorem V_equals_L_in_L:
paulson@47072
   622
  "L(x) \<longleftrightarrow> constructible(L,x)"
paulson@47072
   623
apply (simp add: constructible_def Lset_abs Lset_closed)
paulson@13505
   624
apply (simp add: L_def)
paulson@13505
   625
apply (blast intro: Ord_in_L) 
paulson@13505
   626
done
paulson@13505
   627
paulson@13503
   628
end