src/ZF/Constructible/Relative.thy
author paulson
Mon Jun 24 11:59:21 2002 +0200 (2002-06-24)
changeset 13245 714f7a423a15
parent 13223 45be08fbdcff
child 13247 e3c289f0724b
permissions -rw-r--r--
development and tweaks
paulson@13223
     1
header {*Relativization and Absoluteness*}
paulson@13223
     2
paulson@13223
     3
theory Relative = Main:
paulson@13223
     4
paulson@13223
     5
subsection{* Relativized versions of standard set-theoretic concepts *}
paulson@13223
     6
paulson@13223
     7
constdefs
paulson@13223
     8
  empty :: "[i=>o,i] => o"
paulson@13223
     9
    "empty(M,z) == \<forall>x. M(x) --> x \<notin> z"
paulson@13223
    10
paulson@13223
    11
  subset :: "[i=>o,i,i] => o"
paulson@13223
    12
    "subset(M,A,B) == \<forall>x\<in>A. M(x) --> x \<in> B"
paulson@13223
    13
paulson@13223
    14
  upair :: "[i=>o,i,i,i] => o"
paulson@13223
    15
    "upair(M,a,b,z) == a \<in> z & b \<in> z & (\<forall>x\<in>z. M(x) --> x = a | x = b)"
paulson@13223
    16
paulson@13223
    17
  pair :: "[i=>o,i,i,i] => o"
paulson@13223
    18
    "pair(M,a,b,z) == \<exists>x. M(x) & upair(M,a,a,x) & 
paulson@13223
    19
                          (\<exists>y. M(y) & upair(M,a,b,y) & upair(M,x,y,z))"
paulson@13223
    20
paulson@13245
    21
  union :: "[i=>o,i,i,i] => o"
paulson@13245
    22
    "union(M,a,b,z) == \<forall>x. M(x) --> (x \<in> z <-> x \<in> a | x \<in> b)"
paulson@13245
    23
paulson@13223
    24
  successor :: "[i=>o,i,i] => o"
paulson@13223
    25
    "successor(M,a,z) == \<exists>x. M(x) & upair(M,a,a,x) & union(M,x,a,z)"
paulson@13223
    26
paulson@13223
    27
  powerset :: "[i=>o,i,i] => o"
paulson@13223
    28
    "powerset(M,A,z) == \<forall>x. M(x) --> (x \<in> z <-> subset(M,x,A))"
paulson@13223
    29
paulson@13223
    30
  inter :: "[i=>o,i,i,i] => o"
paulson@13223
    31
    "inter(M,a,b,z) == \<forall>x. M(x) --> (x \<in> z <-> x \<in> a & x \<in> b)"
paulson@13223
    32
paulson@13223
    33
  setdiff :: "[i=>o,i,i,i] => o"
paulson@13223
    34
    "setdiff(M,a,b,z) == \<forall>x. M(x) --> (x \<in> z <-> x \<in> a & x \<notin> b)"
paulson@13223
    35
paulson@13223
    36
  big_union :: "[i=>o,i,i] => o"
paulson@13223
    37
    "big_union(M,A,z) == \<forall>x. M(x) --> (x \<in> z <-> (\<exists>y\<in>A. M(y) & x \<in> y))"
paulson@13223
    38
paulson@13223
    39
  big_inter :: "[i=>o,i,i] => o"
paulson@13223
    40
    "big_inter(M,A,z) == 
paulson@13223
    41
             (A=0 --> z=0) &
paulson@13223
    42
	     (A\<noteq>0 --> (\<forall>x. M(x) --> (x \<in> z <-> (\<forall>y\<in>A. M(y) --> x \<in> y))))"
paulson@13223
    43
paulson@13223
    44
  cartprod :: "[i=>o,i,i,i] => o"
paulson@13223
    45
    "cartprod(M,A,B,z) == 
paulson@13223
    46
	\<forall>u. M(u) --> (u \<in> z <-> (\<exists>x\<in>A. M(x) & (\<exists>y\<in>B. M(y) & pair(M,x,y,u))))"
paulson@13223
    47
paulson@13223
    48
  is_converse :: "[i=>o,i,i] => o"
paulson@13223
    49
    "is_converse(M,r,z) == 
paulson@13223
    50
	\<forall>x. M(x) --> 
paulson@13223
    51
            (x \<in> z <-> 
paulson@13223
    52
             (\<exists>w\<in>r. M(w) & 
paulson@13223
    53
              (\<exists>u v. M(u) & M(v) & pair(M,u,v,w) & pair(M,v,u,x))))"
paulson@13223
    54
paulson@13223
    55
  pre_image :: "[i=>o,i,i,i] => o"
paulson@13223
    56
    "pre_image(M,r,A,z) == 
paulson@13223
    57
	\<forall>x. M(x) --> (x \<in> z <-> (\<exists>w\<in>r. M(w) & (\<exists>y\<in>A. M(y) & pair(M,x,y,w))))"
paulson@13223
    58
paulson@13223
    59
  is_domain :: "[i=>o,i,i] => o"
paulson@13223
    60
    "is_domain(M,r,z) == 
paulson@13223
    61
	\<forall>x. M(x) --> (x \<in> z <-> (\<exists>w\<in>r. M(w) & (\<exists>y. M(y) & pair(M,x,y,w))))"
paulson@13223
    62
paulson@13223
    63
  image :: "[i=>o,i,i,i] => o"
paulson@13223
    64
    "image(M,r,A,z) == 
paulson@13223
    65
        \<forall>y. M(y) --> (y \<in> z <-> (\<exists>w\<in>r. M(w) & (\<exists>x\<in>A. M(x) & pair(M,x,y,w))))"
paulson@13223
    66
paulson@13223
    67
  is_range :: "[i=>o,i,i] => o"
paulson@13223
    68
    --{*the cleaner 
paulson@13223
    69
      @{term "\<exists>r'. M(r') & is_converse(M,r,r') & is_domain(M,r',z)"}
paulson@13223
    70
      unfortunately needs an instance of separation in order to prove 
paulson@13223
    71
        @{term "M(converse(r))"}.*}
paulson@13223
    72
    "is_range(M,r,z) == 
paulson@13223
    73
	\<forall>y. M(y) --> (y \<in> z <-> (\<exists>w\<in>r. M(w) & (\<exists>x. M(x) & pair(M,x,y,w))))"
paulson@13223
    74
paulson@13245
    75
  is_field :: "[i=>o,i,i] => o"
paulson@13245
    76
    "is_field(M,r,z) == 
paulson@13245
    77
	\<exists>dr. M(dr) & is_domain(M,r,dr) & 
paulson@13245
    78
            (\<exists>rr. M(rr) & is_range(M,r,rr) & union(M,dr,rr,z))"
paulson@13245
    79
paulson@13223
    80
  is_relation :: "[i=>o,i] => o"
paulson@13223
    81
    "is_relation(M,r) == 
paulson@13223
    82
        (\<forall>z\<in>r. M(z) --> (\<exists>x y. M(x) & M(y) & pair(M,x,y,z)))"
paulson@13223
    83
paulson@13223
    84
  is_function :: "[i=>o,i] => o"
paulson@13223
    85
    "is_function(M,r) == 
paulson@13223
    86
	(\<forall>x y y' p p'. M(x) --> M(y) --> M(y') --> M(p) --> M(p') --> 
paulson@13223
    87
                      pair(M,x,y,p) --> pair(M,x,y',p') --> p\<in>r --> p'\<in>r --> 
paulson@13223
    88
                      y=y')"
paulson@13223
    89
paulson@13223
    90
  fun_apply :: "[i=>o,i,i,i] => o"
paulson@13223
    91
    "fun_apply(M,f,x,y) == 
paulson@13223
    92
	(\<forall>y'. M(y') --> ((\<exists>u\<in>f. M(u) & pair(M,x,y',u)) <-> y=y'))"
paulson@13223
    93
paulson@13223
    94
  typed_function :: "[i=>o,i,i,i] => o"
paulson@13223
    95
    "typed_function(M,A,B,r) == 
paulson@13223
    96
        is_function(M,r) & is_relation(M,r) & is_domain(M,r,A) &
paulson@13223
    97
        (\<forall>u\<in>r. M(u) --> (\<forall>x y. M(x) & M(y) & pair(M,x,y,u) --> y\<in>B))"
paulson@13223
    98
paulson@13245
    99
  composition :: "[i=>o,i,i,i] => o"
paulson@13245
   100
    "composition(M,r,s,t) == 
paulson@13245
   101
        \<forall>p. M(p) --> (p \<in> t <-> 
paulson@13245
   102
                      (\<exists>x. M(x) & (\<exists>y. M(y) & (\<exists>z. M(z) & 
paulson@13245
   103
                           p = \<langle>x,z\<rangle> & \<langle>x,y\<rangle> \<in> s & \<langle>y,z\<rangle> \<in> r))))"
paulson@13245
   104
paulson@13245
   105
paulson@13223
   106
  injection :: "[i=>o,i,i,i] => o"
paulson@13223
   107
    "injection(M,A,B,f) == 
paulson@13223
   108
	typed_function(M,A,B,f) &
paulson@13223
   109
        (\<forall>x x' y p p'. M(x) --> M(x') --> M(y) --> M(p) --> M(p') --> 
paulson@13223
   110
                      pair(M,x,y,p) --> pair(M,x',y,p') --> p\<in>f --> p'\<in>f --> 
paulson@13223
   111
                      x=x')"
paulson@13223
   112
paulson@13223
   113
  surjection :: "[i=>o,i,i,i] => o"
paulson@13223
   114
    "surjection(M,A,B,f) == 
paulson@13223
   115
        typed_function(M,A,B,f) &
paulson@13223
   116
        (\<forall>y\<in>B. M(y) --> (\<exists>x\<in>A. M(x) & fun_apply(M,f,x,y)))"
paulson@13223
   117
paulson@13223
   118
  bijection :: "[i=>o,i,i,i] => o"
paulson@13223
   119
    "bijection(M,A,B,f) == injection(M,A,B,f) & surjection(M,A,B,f)"
paulson@13223
   120
paulson@13223
   121
  restriction :: "[i=>o,i,i,i] => o"
paulson@13223
   122
    "restriction(M,r,A,z) == 
paulson@13223
   123
	\<forall>x. M(x) --> 
paulson@13223
   124
            (x \<in> z <-> 
paulson@13223
   125
             (x \<in> r & (\<exists>u\<in>A. M(u) & (\<exists>v. M(v) & pair(M,u,v,x)))))"
paulson@13223
   126
paulson@13223
   127
  transitive_set :: "[i=>o,i] => o"
paulson@13223
   128
    "transitive_set(M,a) == \<forall>x\<in>a. M(x) --> subset(M,x,a)"
paulson@13223
   129
paulson@13223
   130
  ordinal :: "[i=>o,i] => o"
paulson@13223
   131
     --{*an ordinal is a transitive set of transitive sets*}
paulson@13223
   132
    "ordinal(M,a) == transitive_set(M,a) & (\<forall>x\<in>a. M(x) --> transitive_set(M,x))"
paulson@13223
   133
paulson@13223
   134
  limit_ordinal :: "[i=>o,i] => o"
paulson@13223
   135
    --{*a limit ordinal is a non-empty, successor-closed ordinal*}
paulson@13223
   136
    "limit_ordinal(M,a) == 
paulson@13223
   137
	ordinal(M,a) & ~ empty(M,a) & 
paulson@13223
   138
        (\<forall>x\<in>a. M(x) --> (\<exists>y\<in>a. M(y) & successor(M,x,y)))"
paulson@13223
   139
paulson@13223
   140
  successor_ordinal :: "[i=>o,i] => o"
paulson@13223
   141
    --{*a successor ordinal is any ordinal that is neither empty nor limit*}
paulson@13223
   142
    "successor_ordinal(M,a) == 
paulson@13223
   143
	ordinal(M,a) & ~ empty(M,a) & ~ limit_ordinal(M,a)"
paulson@13223
   144
paulson@13223
   145
  finite_ordinal :: "[i=>o,i] => o"
paulson@13223
   146
    --{*an ordinal is finite if neither it nor any of its elements are limit*}
paulson@13223
   147
    "finite_ordinal(M,a) == 
paulson@13223
   148
	ordinal(M,a) & ~ limit_ordinal(M,a) & 
paulson@13223
   149
        (\<forall>x\<in>a. M(x) --> ~ limit_ordinal(M,x))"
paulson@13223
   150
paulson@13223
   151
  omega :: "[i=>o,i] => o"
paulson@13223
   152
    --{*omega is a limit ordinal none of whose elements are limit*}
paulson@13223
   153
    "omega(M,a) == limit_ordinal(M,a) & (\<forall>x\<in>a. M(x) --> ~ limit_ordinal(M,x))"
paulson@13223
   154
paulson@13223
   155
  number1 :: "[i=>o,i] => o"
paulson@13223
   156
    "number1(M,a) == (\<exists>x. M(x) & empty(M,x) & successor(M,x,a))"
paulson@13223
   157
paulson@13223
   158
  number2 :: "[i=>o,i] => o"
paulson@13223
   159
    "number2(M,a) == (\<exists>x. M(x) & number1(M,x) & successor(M,x,a))"
paulson@13223
   160
paulson@13223
   161
  number3 :: "[i=>o,i] => o"
paulson@13223
   162
    "number3(M,a) == (\<exists>x. M(x) & number2(M,x) & successor(M,x,a))"
paulson@13223
   163
paulson@13223
   164
paulson@13223
   165
subsection {*The relativized ZF axioms*}
paulson@13223
   166
constdefs
paulson@13223
   167
paulson@13223
   168
  extensionality :: "(i=>o) => o"
paulson@13223
   169
    "extensionality(M) == 
paulson@13223
   170
	\<forall>x y. M(x) --> M(y) --> (\<forall>z. M(z) --> (z \<in> x <-> z \<in> y)) --> x=y"
paulson@13223
   171
paulson@13223
   172
  separation :: "[i=>o, i=>o] => o"
paulson@13223
   173
    --{*Big problem: the formula @{text P} should only involve parameters
paulson@13223
   174
        belonging to @{text M}.  Don't see how to enforce that.*}
paulson@13223
   175
    "separation(M,P) == 
paulson@13223
   176
	\<forall>z. M(z) --> (\<exists>y. M(y) & (\<forall>x. M(x) --> (x \<in> y <-> x \<in> z & P(x))))"
paulson@13223
   177
paulson@13223
   178
  upair_ax :: "(i=>o) => o"
paulson@13223
   179
    "upair_ax(M) == \<forall>x y. M(x) --> M(y) --> (\<exists>z. M(z) & upair(M,x,y,z))"
paulson@13223
   180
paulson@13223
   181
  Union_ax :: "(i=>o) => o"
paulson@13223
   182
    "Union_ax(M) == \<forall>x. M(x) --> (\<exists>z. M(z) & big_union(M,x,z))"
paulson@13223
   183
paulson@13223
   184
  power_ax :: "(i=>o) => o"
paulson@13223
   185
    "power_ax(M) == \<forall>x. M(x) --> (\<exists>z. M(z) & powerset(M,x,z))"
paulson@13223
   186
paulson@13223
   187
  univalent :: "[i=>o, i, [i,i]=>o] => o"
paulson@13223
   188
    "univalent(M,A,P) == 
paulson@13223
   189
	(\<forall>x\<in>A. M(x) --> (\<forall>y z. M(y) --> M(z) --> P(x,y) & P(x,z) --> y=z))"
paulson@13223
   190
paulson@13223
   191
  replacement :: "[i=>o, [i,i]=>o] => o"
paulson@13223
   192
    "replacement(M,P) == 
paulson@13223
   193
      \<forall>A. M(A) --> univalent(M,A,P) -->
paulson@13223
   194
      (\<exists>Y. M(Y) & (\<forall>b. M(b) --> ((\<exists>x\<in>A. M(x) & P(x,b)) --> b \<in> Y)))"
paulson@13223
   195
paulson@13223
   196
  strong_replacement :: "[i=>o, [i,i]=>o] => o"
paulson@13223
   197
    "strong_replacement(M,P) == 
paulson@13223
   198
      \<forall>A. M(A) --> univalent(M,A,P) -->
paulson@13223
   199
      (\<exists>Y. M(Y) & (\<forall>b. M(b) --> (b \<in> Y <-> (\<exists>x\<in>A. M(x) & P(x,b)))))"
paulson@13223
   200
paulson@13223
   201
  foundation_ax :: "(i=>o) => o"
paulson@13223
   202
    "foundation_ax(M) == 
paulson@13223
   203
	\<forall>x. M(x) --> (\<exists>y\<in>x. M(y))
paulson@13223
   204
                 --> (\<exists>y\<in>x. M(y) & ~(\<exists>z\<in>x. M(z) & z \<in> y))"
paulson@13223
   205
paulson@13223
   206
paulson@13223
   207
subsection{*A trivial consistency proof for $V_\omega$ *}
paulson@13223
   208
paulson@13223
   209
text{*We prove that $V_\omega$ 
paulson@13223
   210
      (or @{text univ} in Isabelle) satisfies some ZF axioms.
paulson@13223
   211
     Kunen, Theorem IV 3.13, page 123.*}
paulson@13223
   212
paulson@13223
   213
lemma univ0_downwards_mem: "[| y \<in> x; x \<in> univ(0) |] ==> y \<in> univ(0)"
paulson@13223
   214
apply (insert Transset_univ [OF Transset_0])  
paulson@13223
   215
apply (simp add: Transset_def, blast) 
paulson@13223
   216
done
paulson@13223
   217
paulson@13223
   218
lemma univ0_Ball_abs [simp]: 
paulson@13223
   219
     "A \<in> univ(0) ==> (\<forall>x\<in>A. x \<in> univ(0) --> P(x)) <-> (\<forall>x\<in>A. P(x))" 
paulson@13223
   220
by (blast intro: univ0_downwards_mem) 
paulson@13223
   221
paulson@13223
   222
lemma univ0_Bex_abs [simp]: 
paulson@13223
   223
     "A \<in> univ(0) ==> (\<exists>x\<in>A. x \<in> univ(0) & P(x)) <-> (\<exists>x\<in>A. P(x))" 
paulson@13223
   224
by (blast intro: univ0_downwards_mem) 
paulson@13223
   225
paulson@13223
   226
text{*Congruence rule for separation: can assume the variable is in @{text M}*}
paulson@13223
   227
lemma [cong]:
paulson@13223
   228
     "(!!x. M(x) ==> P(x) <-> P'(x)) ==> separation(M,P) <-> separation(M,P')"
paulson@13223
   229
by (simp add: separation_def) 
paulson@13223
   230
paulson@13223
   231
text{*Congruence rules for replacement*}
paulson@13223
   232
lemma [cong]:
paulson@13223
   233
     "[| A=A'; !!x y. [| x\<in>A; M(x); M(y) |] ==> P(x,y) <-> P'(x,y) |] 
paulson@13223
   234
      ==> univalent(M,A,P) <-> univalent(M,A',P')"
paulson@13223
   235
by (simp add: univalent_def) 
paulson@13223
   236
paulson@13223
   237
lemma [cong]:
paulson@13223
   238
     "[| !!x y. [| M(x); M(y) |] ==> P(x,y) <-> P'(x,y) |] 
paulson@13223
   239
      ==> strong_replacement(M,P) <-> strong_replacement(M,P')" 
paulson@13223
   240
by (simp add: strong_replacement_def) 
paulson@13223
   241
paulson@13223
   242
text{*The extensionality axiom*}
paulson@13223
   243
lemma "extensionality(\<lambda>x. x \<in> univ(0))"
paulson@13223
   244
apply (simp add: extensionality_def)
paulson@13223
   245
apply (blast intro: univ0_downwards_mem) 
paulson@13223
   246
done
paulson@13223
   247
paulson@13223
   248
text{*The separation axiom requires some lemmas*}
paulson@13223
   249
lemma Collect_in_Vfrom:
paulson@13223
   250
     "[| X \<in> Vfrom(A,j);  Transset(A) |] ==> Collect(X,P) \<in> Vfrom(A, succ(j))"
paulson@13223
   251
apply (drule Transset_Vfrom)
paulson@13223
   252
apply (rule subset_mem_Vfrom)
paulson@13223
   253
apply (unfold Transset_def, blast)
paulson@13223
   254
done
paulson@13223
   255
paulson@13223
   256
lemma Collect_in_VLimit:
paulson@13223
   257
     "[| X \<in> Vfrom(A,i);  Limit(i);  Transset(A) |] 
paulson@13223
   258
      ==> Collect(X,P) \<in> Vfrom(A,i)"
paulson@13223
   259
apply (rule Limit_VfromE, assumption+)
paulson@13223
   260
apply (blast intro: Limit_has_succ VfromI Collect_in_Vfrom)
paulson@13223
   261
done
paulson@13223
   262
paulson@13223
   263
lemma Collect_in_univ:
paulson@13223
   264
     "[| X \<in> univ(A);  Transset(A) |] ==> Collect(X,P) \<in> univ(A)"
paulson@13223
   265
by (simp add: univ_def Collect_in_VLimit Limit_nat)
paulson@13223
   266
paulson@13223
   267
lemma "separation(\<lambda>x. x \<in> univ(0), P)"
paulson@13223
   268
apply (simp add: separation_def)
paulson@13223
   269
apply (blast intro: Collect_in_univ Transset_0) 
paulson@13223
   270
done
paulson@13223
   271
paulson@13223
   272
text{*Unordered pairing axiom*}
paulson@13223
   273
lemma "upair_ax(\<lambda>x. x \<in> univ(0))"
paulson@13223
   274
apply (simp add: upair_ax_def upair_def)  
paulson@13223
   275
apply (blast intro: doubleton_in_univ) 
paulson@13223
   276
done
paulson@13223
   277
paulson@13223
   278
text{*Union axiom*}
paulson@13223
   279
lemma "Union_ax(\<lambda>x. x \<in> univ(0))"  
paulson@13223
   280
apply (simp add: Union_ax_def big_union_def)  
paulson@13223
   281
apply (blast intro: Union_in_univ Transset_0 univ0_downwards_mem) 
paulson@13223
   282
done
paulson@13223
   283
paulson@13223
   284
text{*Powerset axiom*}
paulson@13223
   285
paulson@13223
   286
lemma Pow_in_univ:
paulson@13223
   287
     "[| X \<in> univ(A);  Transset(A) |] ==> Pow(X) \<in> univ(A)"
paulson@13223
   288
apply (simp add: univ_def Pow_in_VLimit Limit_nat)
paulson@13223
   289
done
paulson@13223
   290
paulson@13223
   291
lemma "power_ax(\<lambda>x. x \<in> univ(0))"  
paulson@13223
   292
apply (simp add: power_ax_def powerset_def subset_def)  
paulson@13223
   293
apply (blast intro: Pow_in_univ Transset_0 univ0_downwards_mem) 
paulson@13223
   294
done
paulson@13223
   295
paulson@13223
   296
text{*Foundation axiom*}
paulson@13223
   297
lemma "foundation_ax(\<lambda>x. x \<in> univ(0))"  
paulson@13223
   298
apply (simp add: foundation_ax_def, clarify)
paulson@13223
   299
apply (cut_tac A=x in foundation, blast) 
paulson@13223
   300
done
paulson@13223
   301
paulson@13223
   302
lemma "replacement(\<lambda>x. x \<in> univ(0), P)"  
paulson@13223
   303
apply (simp add: replacement_def, clarify) 
paulson@13223
   304
oops
paulson@13223
   305
text{*no idea: maybe prove by induction on the rank of A?*}
paulson@13223
   306
paulson@13223
   307
text{*Still missing: Replacement, Choice*}
paulson@13223
   308
paulson@13223
   309
subsection{*lemmas needed to reduce some set constructions to instances
paulson@13223
   310
      of Separation*}
paulson@13223
   311
paulson@13223
   312
lemma image_iff_Collect: "r `` A = {y \<in> Union(Union(r)). \<exists>p\<in>r. \<exists>x\<in>A. p=<x,y>}"
paulson@13223
   313
apply (rule equalityI, auto) 
paulson@13223
   314
apply (simp add: Pair_def, blast) 
paulson@13223
   315
done
paulson@13223
   316
paulson@13223
   317
lemma vimage_iff_Collect:
paulson@13223
   318
     "r -`` A = {x \<in> Union(Union(r)). \<exists>p\<in>r. \<exists>y\<in>A. p=<x,y>}"
paulson@13223
   319
apply (rule equalityI, auto) 
paulson@13223
   320
apply (simp add: Pair_def, blast) 
paulson@13223
   321
done
paulson@13223
   322
paulson@13223
   323
text{*These two lemmas lets us prove @{text domain_closed} and 
paulson@13223
   324
      @{text range_closed} without new instances of separation*}
paulson@13223
   325
paulson@13223
   326
lemma domain_eq_vimage: "domain(r) = r -`` Union(Union(r))"
paulson@13223
   327
apply (rule equalityI, auto)
paulson@13223
   328
apply (rule vimageI, assumption)
paulson@13223
   329
apply (simp add: Pair_def, blast) 
paulson@13223
   330
done
paulson@13223
   331
paulson@13223
   332
lemma range_eq_image: "range(r) = r `` Union(Union(r))"
paulson@13223
   333
apply (rule equalityI, auto)
paulson@13223
   334
apply (rule imageI, assumption)
paulson@13223
   335
apply (simp add: Pair_def, blast) 
paulson@13223
   336
done
paulson@13223
   337
paulson@13223
   338
lemma replacementD:
paulson@13223
   339
    "[| replacement(M,P); M(A);  univalent(M,A,P) |]
paulson@13223
   340
     ==> \<exists>Y. M(Y) & (\<forall>b. M(b) --> ((\<exists>x\<in>A. M(x) & P(x,b)) --> b \<in> Y))"
paulson@13223
   341
by (simp add: replacement_def) 
paulson@13223
   342
paulson@13223
   343
lemma strong_replacementD:
paulson@13223
   344
    "[| strong_replacement(M,P); M(A);  univalent(M,A,P) |]
paulson@13223
   345
     ==> \<exists>Y. M(Y) & (\<forall>b. M(b) --> (b \<in> Y <-> (\<exists>x\<in>A. M(x) & P(x,b))))"
paulson@13223
   346
by (simp add: strong_replacement_def) 
paulson@13223
   347
paulson@13223
   348
lemma separationD:
paulson@13223
   349
    "[| separation(M,P); M(z) |]
paulson@13223
   350
     ==> \<exists>y. M(y) & (\<forall>x. M(x) --> (x \<in> y <-> x \<in> z & P(x)))"
paulson@13223
   351
by (simp add: separation_def) 
paulson@13223
   352
paulson@13223
   353
paulson@13223
   354
text{*More constants, for order types*}
paulson@13223
   355
constdefs
paulson@13223
   356
paulson@13223
   357
  order_isomorphism :: "[i=>o,i,i,i,i,i] => o"
paulson@13223
   358
    "order_isomorphism(M,A,r,B,s,f) == 
paulson@13223
   359
        bijection(M,A,B,f) & 
paulson@13223
   360
        (\<forall>x\<in>A. \<forall>y\<in>A. \<forall>p fx fy q. 
paulson@13223
   361
            M(x) --> M(y) --> M(p) --> M(fx) --> M(fy) --> M(q) --> 
paulson@13223
   362
            pair(M,x,y,p) --> fun_apply(M,f,x,fx) --> fun_apply(M,f,y,fy) --> 
paulson@13223
   363
            pair(M,fx,fy,q) --> (p\<in>r <-> q\<in>s))"
paulson@13223
   364
paulson@13223
   365
paulson@13223
   366
  pred_set :: "[i=>o,i,i,i,i] => o"
paulson@13223
   367
    "pred_set(M,A,x,r,B) == 
paulson@13223
   368
	\<forall>y. M(y) --> (y \<in> B <-> (\<exists>p\<in>r. M(p) & y \<in> A & pair(M,y,x,p)))"
paulson@13223
   369
paulson@13223
   370
  membership :: "[i=>o,i,i] => o" --{*membership relation*}
paulson@13223
   371
    "membership(M,A,r) == 
paulson@13223
   372
	\<forall>p. M(p) --> 
paulson@13223
   373
             (p \<in> r <-> (\<exists>x\<in>A. \<exists>y\<in>A. M(x) & M(y) & x\<in>y & pair(M,x,y,p)))"
paulson@13223
   374
paulson@13223
   375
paulson@13223
   376
subsection{*Absoluteness for a transitive class model*}
paulson@13223
   377
paulson@13223
   378
text{*The class M is assumed to be transitive and to satisfy some
paulson@13223
   379
      relativized ZF axioms*}
paulson@13223
   380
locale M_axioms =
paulson@13223
   381
  fixes M
paulson@13223
   382
  assumes transM:           "[| y\<in>x; M(x) |] ==> M(y)"
paulson@13223
   383
      and nonempty [simp]:  "M(0)"
paulson@13223
   384
      and upair_ax:	    "upair_ax(M)"
paulson@13223
   385
      and Union_ax:	    "Union_ax(M)"
paulson@13223
   386
      and power_ax:         "power_ax(M)"
paulson@13223
   387
      and replacement:      "replacement(M,P)"
paulson@13245
   388
      and M_nat:            "M(nat)"   (*i.e. the axiom of infinity*)
paulson@13223
   389
  and Inter_separation:
paulson@13223
   390
     "M(A) ==> separation(M, \<lambda>x. \<forall>y\<in>A. M(y) --> x\<in>y)"
paulson@13223
   391
  and cartprod_separation:
paulson@13223
   392
     "[| M(A); M(B) |] 
paulson@13223
   393
      ==> separation(M, \<lambda>z. \<exists>x\<in>A. \<exists>y\<in>B. M(x) & M(y) & pair(M,x,y,z))"
paulson@13223
   394
  and image_separation:
paulson@13223
   395
     "[| M(A); M(r) |] 
paulson@13223
   396
      ==> separation(M, \<lambda>y. \<exists>p\<in>r. M(p) & (\<exists>x\<in>A. M(x) & pair(M,x,y,p)))"
paulson@13223
   397
  and vimage_separation:
paulson@13223
   398
     "[| M(A); M(r) |] 
paulson@13223
   399
      ==> separation(M, \<lambda>x. \<exists>p\<in>r. M(p) & (\<exists>y\<in>A. M(x) & pair(M,x,y,p)))"
paulson@13223
   400
  and converse_separation:
paulson@13223
   401
     "M(r) ==> separation(M, \<lambda>z. \<exists>p\<in>r. M(p) & (\<exists>x y. M(x) & M(y) & 
paulson@13223
   402
				     pair(M,x,y,p) & pair(M,y,x,z)))"
paulson@13223
   403
  and restrict_separation:
paulson@13223
   404
     "M(A) 
paulson@13223
   405
      ==> separation(M, \<lambda>z. \<exists>x\<in>A. M(x) & (\<exists>y. M(y) & pair(M,x,y,z)))"
paulson@13223
   406
  and comp_separation:
paulson@13223
   407
     "[| M(r); M(s) |]
paulson@13223
   408
      ==> separation(M, \<lambda>xz. \<exists>x y z. M(x) & M(y) & M(z) &
paulson@13223
   409
			   (\<exists>xy\<in>s. \<exists>yz\<in>r. M(xy) & M(yz) & 
paulson@13223
   410
		  pair(M,x,z,xz) & pair(M,x,y,xy) & pair(M,y,z,yz)))"
paulson@13223
   411
  and pred_separation:
paulson@13223
   412
     "[| M(r); M(x) |] ==> separation(M, \<lambda>y. \<exists>p\<in>r. M(p) & pair(M,y,x,p))"
paulson@13223
   413
  and Memrel_separation:
paulson@13245
   414
     "separation(M, \<lambda>z. \<exists>x y. M(x) & M(y) & pair(M,x,y,z) & x \<in> y)"
paulson@13223
   415
  and obase_separation:
paulson@13223
   416
     --{*part of the order type formalization*}
paulson@13223
   417
     "[| M(A); M(r) |] 
paulson@13223
   418
      ==> separation(M, \<lambda>a. \<exists>x g mx par. M(x) & M(g) & M(mx) & M(par) & 
paulson@13223
   419
	     ordinal(M,x) & membership(M,x,mx) & pred_set(M,A,a,r,par) &
paulson@13223
   420
	     order_isomorphism(M,par,r,x,mx,g))"
paulson@13223
   421
  and well_ord_iso_separation:
paulson@13223
   422
     "[| M(A); M(f); M(r) |] 
paulson@13245
   423
      ==> separation (M, \<lambda>x. x\<in>A --> (\<exists>y. M(y) & (\<exists>p. M(p) & 
paulson@13245
   424
		     fun_apply(M,f,x,y) & pair(M,y,x,p) & p \<in> r)))"
paulson@13223
   425
  and obase_equals_separation:
paulson@13223
   426
     "[| M(A); M(r) |] 
paulson@13223
   427
      ==> separation
paulson@13223
   428
      (M, \<lambda>x. x\<in>A --> ~(\<exists>y. M(y) & (\<exists>g. M(g) &
paulson@13223
   429
	      ordinal(M,y) & (\<exists>my pxr. M(my) & M(pxr) &
paulson@13223
   430
	      membership(M,y,my) & pred_set(M,A,x,r,pxr) &
paulson@13223
   431
	      order_isomorphism(M,pxr,r,y,my,g)))))"
paulson@13223
   432
  and is_recfun_separation:
paulson@13223
   433
     --{*for well-founded recursion.  NEEDS RELATIVIZATION*}
paulson@13223
   434
     "[| M(A); M(f); M(g); M(a); M(b) |] 
paulson@13245
   435
     ==> separation(M, \<lambda>x. x \<in> A --> \<langle>x,a\<rangle> \<in> r & \<langle>x,b\<rangle> \<in> r & f`x \<noteq> g`x)"
paulson@13223
   436
  and omap_replacement:
paulson@13223
   437
     "[| M(A); M(r) |] 
paulson@13223
   438
      ==> strong_replacement(M,
paulson@13223
   439
             \<lambda>a z. \<exists>x g mx par. M(x) & M(g) & M(mx) & M(par) &
paulson@13223
   440
	     ordinal(M,x) & pair(M,a,x,z) & membership(M,x,mx) & 
paulson@13223
   441
	     pred_set(M,A,a,r,par) & order_isomorphism(M,par,r,x,mx,g))"
paulson@13223
   442
paulson@13223
   443
lemma (in M_axioms) Ball_abs [simp]: 
paulson@13223
   444
     "M(A) ==> (\<forall>x\<in>A. M(x) --> P(x)) <-> (\<forall>x\<in>A. P(x))" 
paulson@13223
   445
by (blast intro: transM) 
paulson@13223
   446
paulson@13223
   447
lemma (in M_axioms) Bex_abs [simp]: 
paulson@13223
   448
     "M(A) ==> (\<exists>x\<in>A. M(x) & P(x)) <-> (\<exists>x\<in>A. P(x))" 
paulson@13223
   449
by (blast intro: transM) 
paulson@13223
   450
paulson@13223
   451
lemma (in M_axioms) Ball_iff_equiv: 
paulson@13223
   452
     "M(A) ==> (\<forall>x. M(x) --> (x\<in>A <-> P(x))) <-> 
paulson@13223
   453
               (\<forall>x\<in>A. P(x)) & (\<forall>x. P(x) --> M(x) --> x\<in>A)" 
paulson@13223
   454
by (blast intro: transM)
paulson@13223
   455
paulson@13245
   456
text{*Simplifies proofs of equalities when there's an iff-equality
paulson@13245
   457
      available for rewriting, universally quantified over M. *}
paulson@13245
   458
lemma (in M_axioms) M_equalityI: 
paulson@13245
   459
     "[| !!x. M(x) ==> x\<in>A <-> x\<in>B; M(A); M(B) |] ==> A=B"
paulson@13245
   460
by (blast intro!: equalityI dest: transM) 
paulson@13245
   461
paulson@13223
   462
lemma (in M_axioms) empty_abs [simp]: 
paulson@13223
   463
     "M(z) ==> empty(M,z) <-> z=0"
paulson@13223
   464
apply (simp add: empty_def)
paulson@13223
   465
apply (blast intro: transM) 
paulson@13223
   466
done
paulson@13223
   467
paulson@13223
   468
lemma (in M_axioms) subset_abs [simp]: 
paulson@13223
   469
     "M(A) ==> subset(M,A,B) <-> A \<subseteq> B"
paulson@13223
   470
apply (simp add: subset_def) 
paulson@13223
   471
apply (blast intro: transM) 
paulson@13223
   472
done
paulson@13223
   473
paulson@13223
   474
lemma (in M_axioms) upair_abs [simp]: 
paulson@13223
   475
     "M(z) ==> upair(M,a,b,z) <-> z={a,b}"
paulson@13223
   476
apply (simp add: upair_def) 
paulson@13223
   477
apply (blast intro: transM) 
paulson@13223
   478
done
paulson@13223
   479
paulson@13223
   480
lemma (in M_axioms) upair_in_M_iff [iff]:
paulson@13223
   481
     "M({a,b}) <-> M(a) & M(b)"
paulson@13223
   482
apply (insert upair_ax, simp add: upair_ax_def) 
paulson@13223
   483
apply (blast intro: transM) 
paulson@13223
   484
done
paulson@13223
   485
paulson@13223
   486
lemma (in M_axioms) singleton_in_M_iff [iff]:
paulson@13223
   487
     "M({a}) <-> M(a)"
paulson@13223
   488
by (insert upair_in_M_iff [of a a], simp) 
paulson@13223
   489
paulson@13223
   490
lemma (in M_axioms) pair_abs [simp]: 
paulson@13223
   491
     "M(z) ==> pair(M,a,b,z) <-> z=<a,b>"
paulson@13223
   492
apply (simp add: pair_def ZF.Pair_def)
paulson@13223
   493
apply (blast intro: transM) 
paulson@13223
   494
done
paulson@13223
   495
paulson@13223
   496
lemma (in M_axioms) pair_in_M_iff [iff]:
paulson@13223
   497
     "M(<a,b>) <-> M(a) & M(b)"
paulson@13223
   498
by (simp add: ZF.Pair_def)
paulson@13223
   499
paulson@13223
   500
lemma (in M_axioms) pair_components_in_M:
paulson@13223
   501
     "[| <x,y> \<in> A; M(A) |] ==> M(x) & M(y)"
paulson@13223
   502
apply (simp add: Pair_def)
paulson@13223
   503
apply (blast dest: transM) 
paulson@13223
   504
done
paulson@13223
   505
paulson@13223
   506
lemma (in M_axioms) cartprod_abs [simp]: 
paulson@13223
   507
     "[| M(A); M(B); M(z) |] ==> cartprod(M,A,B,z) <-> z = A*B"
paulson@13223
   508
apply (simp add: cartprod_def)
paulson@13223
   509
apply (rule iffI) 
paulson@13223
   510
apply (blast intro!: equalityI intro: transM dest!: spec) 
paulson@13223
   511
apply (blast dest: transM) 
paulson@13223
   512
done
paulson@13223
   513
paulson@13223
   514
lemma (in M_axioms) union_abs [simp]: 
paulson@13223
   515
     "[| M(a); M(b); M(z) |] ==> union(M,a,b,z) <-> z = a Un b"
paulson@13223
   516
apply (simp add: union_def) 
paulson@13223
   517
apply (blast intro: transM) 
paulson@13223
   518
done
paulson@13223
   519
paulson@13223
   520
lemma (in M_axioms) inter_abs [simp]: 
paulson@13223
   521
     "[| M(a); M(b); M(z) |] ==> inter(M,a,b,z) <-> z = a Int b"
paulson@13223
   522
apply (simp add: inter_def) 
paulson@13223
   523
apply (blast intro: transM) 
paulson@13223
   524
done
paulson@13223
   525
paulson@13223
   526
lemma (in M_axioms) setdiff_abs [simp]: 
paulson@13223
   527
     "[| M(a); M(b); M(z) |] ==> setdiff(M,a,b,z) <-> z = a-b"
paulson@13223
   528
apply (simp add: setdiff_def) 
paulson@13223
   529
apply (blast intro: transM) 
paulson@13223
   530
done
paulson@13223
   531
paulson@13223
   532
lemma (in M_axioms) Union_abs [simp]: 
paulson@13223
   533
     "[| M(A); M(z) |] ==> big_union(M,A,z) <-> z = Union(A)"
paulson@13223
   534
apply (simp add: big_union_def) 
paulson@13223
   535
apply (blast intro!: equalityI dest: transM) 
paulson@13223
   536
done
paulson@13223
   537
paulson@13245
   538
lemma (in M_axioms) Union_closed [intro,simp]:
paulson@13223
   539
     "M(A) ==> M(Union(A))"
paulson@13223
   540
by (insert Union_ax, simp add: Union_ax_def) 
paulson@13223
   541
paulson@13245
   542
lemma (in M_axioms) Un_closed [intro,simp]:
paulson@13223
   543
     "[| M(A); M(B) |] ==> M(A Un B)"
paulson@13223
   544
by (simp only: Un_eq_Union, blast) 
paulson@13223
   545
paulson@13245
   546
lemma (in M_axioms) cons_closed [intro,simp]:
paulson@13223
   547
     "[| M(a); M(A) |] ==> M(cons(a,A))"
paulson@13223
   548
by (subst cons_eq [symmetric], blast) 
paulson@13223
   549
paulson@13223
   550
lemma (in M_axioms) successor_abs [simp]: 
paulson@13223
   551
     "[| M(a); M(z) |] ==> successor(M,a,z) <-> z=succ(a)"
paulson@13223
   552
by (simp add: successor_def, blast)  
paulson@13223
   553
paulson@13223
   554
lemma (in M_axioms) succ_in_M_iff [iff]:
paulson@13223
   555
     "M(succ(a)) <-> M(a)"
paulson@13223
   556
apply (simp add: succ_def) 
paulson@13223
   557
apply (blast intro: transM) 
paulson@13223
   558
done
paulson@13223
   559
paulson@13245
   560
lemma (in M_axioms) separation_closed [intro,simp]:
paulson@13223
   561
     "[| separation(M,P); M(A) |] ==> M(Collect(A,P))"
paulson@13223
   562
apply (insert separation, simp add: separation_def) 
paulson@13223
   563
apply (drule spec [THEN mp], assumption, clarify) 
paulson@13223
   564
apply (subgoal_tac "y = Collect(A,P)", blast)
paulson@13223
   565
apply (blast dest: transM) 
paulson@13223
   566
done
paulson@13223
   567
paulson@13223
   568
text{*Probably the premise and conclusion are equivalent*}
paulson@13223
   569
lemma (in M_axioms) strong_replacementI [rule_format]:
paulson@13223
   570
    "[| \<forall>A. M(A) --> separation(M, %u. \<exists>x\<in>A. P(x,u)) |]
paulson@13223
   571
     ==> strong_replacement(M,P)"
paulson@13223
   572
apply (simp add: strong_replacement_def) 
paulson@13223
   573
apply (clarify ); 
paulson@13223
   574
apply (frule replacementD [OF replacement]) 
paulson@13223
   575
apply assumption
paulson@13223
   576
apply (clarify ); 
paulson@13223
   577
apply (drule_tac x=A in spec)
paulson@13223
   578
apply (clarify );  
paulson@13223
   579
apply (drule_tac z=Y in separationD) 
paulson@13223
   580
apply assumption; 
paulson@13223
   581
apply (clarify ); 
paulson@13223
   582
apply (blast dest: transM) 
paulson@13223
   583
done
paulson@13223
   584
paulson@13223
   585
paulson@13223
   586
(*The last premise expresses that P takes M to M*)
paulson@13245
   587
lemma (in M_axioms) strong_replacement_closed [intro,simp]:
paulson@13223
   588
     "[| strong_replacement(M,P); M(A); univalent(M,A,P); 
paulson@13223
   589
       !!x y. [| P(x,y); M(x) |] ==> M(y) |] ==> M(Replace(A,P))"
paulson@13223
   590
apply (simp add: strong_replacement_def) 
paulson@13223
   591
apply (drule spec [THEN mp], auto) 
paulson@13223
   592
apply (subgoal_tac "Replace(A,P) = Y")
paulson@13223
   593
 apply (simp add: ); 
paulson@13223
   594
apply (rule equality_iffI) 
paulson@13223
   595
apply (simp add: Replace_iff) 
paulson@13223
   596
apply safe;
paulson@13223
   597
 apply (blast dest: transM) 
paulson@13223
   598
apply (frule transM, assumption) 
paulson@13223
   599
 apply (simp add: univalent_def);
paulson@13223
   600
 apply (drule spec [THEN mp, THEN iffD1], assumption, assumption)
paulson@13223
   601
 apply (blast dest: transM) 
paulson@13223
   602
done
paulson@13223
   603
paulson@13223
   604
(*The first premise can't simply be assumed as a schema.
paulson@13223
   605
  It is essential to take care when asserting instances of Replacement.
paulson@13223
   606
  Let K be a nonconstructible subset of nat and define
paulson@13223
   607
  f(x) = x if x:K and f(x)=0 otherwise.  Then RepFun(nat,f) = cons(0,K), a 
paulson@13223
   608
  nonconstructible set.  So we cannot assume that M(X) implies M(RepFun(X,f))
paulson@13223
   609
  even for f : M -> M.
paulson@13223
   610
*)
paulson@13245
   611
lemma (in M_axioms) RepFun_closed [intro,simp]:
paulson@13223
   612
     "[| strong_replacement(M, \<lambda>x y. y = f(x)); M(A); \<forall>x. M(x) --> M(f(x)) |]
paulson@13223
   613
      ==> M(RepFun(A,f))"
paulson@13223
   614
apply (simp add: RepFun_def) 
paulson@13223
   615
apply (rule strong_replacement_closed) 
paulson@13223
   616
apply (auto dest: transM  simp add: univalent_def) 
paulson@13223
   617
done
paulson@13223
   618
paulson@13223
   619
lemma (in M_axioms) converse_abs [simp]: 
paulson@13223
   620
     "[| M(r); M(z) |] ==> is_converse(M,r,z) <-> z = converse(r)"
paulson@13223
   621
apply (simp add: is_converse_def)
paulson@13223
   622
apply (rule iffI)
paulson@13223
   623
 apply (rule equalityI) 
paulson@13223
   624
  apply (blast dest: transM) 
paulson@13223
   625
 apply (clarify, frule transM, assumption, simp, blast) 
paulson@13223
   626
done
paulson@13223
   627
paulson@13223
   628
lemma (in M_axioms) image_abs [simp]: 
paulson@13223
   629
     "[| M(r); M(A); M(z) |] ==> image(M,r,A,z) <-> z = r``A"
paulson@13223
   630
apply (simp add: image_def)
paulson@13223
   631
apply (rule iffI) 
paulson@13223
   632
 apply (blast intro!: equalityI dest: transM, blast) 
paulson@13223
   633
done
paulson@13223
   634
paulson@13223
   635
text{*What about @{text Pow_abs}?  Powerset is NOT absolute!
paulson@13223
   636
      This result is one direction of absoluteness.*}
paulson@13223
   637
paulson@13223
   638
lemma (in M_axioms) powerset_Pow: 
paulson@13223
   639
     "powerset(M, x, Pow(x))"
paulson@13223
   640
by (simp add: powerset_def)
paulson@13223
   641
paulson@13223
   642
text{*But we can't prove that the powerset in @{text M} includes the
paulson@13223
   643
      real powerset.*}
paulson@13223
   644
lemma (in M_axioms) powerset_imp_subset_Pow: 
paulson@13223
   645
     "[| powerset(M,x,y); M(y) |] ==> y <= Pow(x)"
paulson@13223
   646
apply (simp add: powerset_def) 
paulson@13223
   647
apply (blast dest: transM) 
paulson@13223
   648
done
paulson@13223
   649
paulson@13223
   650
lemma (in M_axioms) cartprod_iff_lemma:
paulson@13223
   651
     "[| M(C); \<forall>u. M(u) --> u \<in> C <-> (\<exists>x\<in>A. \<exists>y\<in>B. u = {{x}, {x,y}}); 
paulson@13223
   652
       powerset(M, A \<union> B, p1); powerset(M, p1, p2); M(p2) |]
paulson@13223
   653
       ==> C = {u \<in> p2 . \<exists>x\<in>A. \<exists>y\<in>B. u = {{x}, {x,y}}}"
paulson@13223
   654
apply (simp add: powerset_def) 
paulson@13223
   655
apply (rule equalityI, clarify, simp) 
paulson@13223
   656
 apply (frule transM, assumption, simp) 
paulson@13223
   657
 apply blast 
paulson@13223
   658
apply clarify
paulson@13223
   659
apply (frule transM, assumption, force) 
paulson@13223
   660
done
paulson@13223
   661
paulson@13223
   662
lemma (in M_axioms) cartprod_iff:
paulson@13223
   663
     "[| M(A); M(B); M(C) |] 
paulson@13223
   664
      ==> cartprod(M,A,B,C) <-> 
paulson@13223
   665
          (\<exists>p1 p2. M(p1) & M(p2) & powerset(M,A Un B,p1) & powerset(M,p1,p2) &
paulson@13223
   666
                   C = {z \<in> p2. \<exists>x\<in>A. \<exists>y\<in>B. z = <x,y>})"
paulson@13223
   667
apply (simp add: Pair_def cartprod_def, safe)
paulson@13223
   668
defer 1 
paulson@13223
   669
  apply (simp add: powerset_def) 
paulson@13223
   670
 apply blast 
paulson@13223
   671
txt{*Final, difficult case: the left-to-right direction of the theorem.*}
paulson@13223
   672
apply (insert power_ax, simp add: power_ax_def) 
paulson@13223
   673
apply (frule_tac x="A Un B" and P="\<lambda>x. M(x) --> Ex(?Q(x))" in spec) 
paulson@13223
   674
apply (erule impE, blast, clarify) 
paulson@13223
   675
apply (drule_tac x=z and P="\<lambda>x. M(x) --> Ex(?Q(x))" in spec) 
paulson@13223
   676
apply (blast intro: cartprod_iff_lemma) 
paulson@13223
   677
done
paulson@13223
   678
paulson@13223
   679
lemma (in M_axioms) cartprod_closed_lemma:
paulson@13223
   680
     "[| M(A); M(B) |] ==> \<exists>C. M(C) & cartprod(M,A,B,C)"
paulson@13223
   681
apply (simp del: cartprod_abs add: cartprod_iff)
paulson@13223
   682
apply (insert power_ax, simp add: power_ax_def) 
paulson@13223
   683
apply (frule_tac x="A Un B" and P="\<lambda>x. M(x) --> Ex(?Q(x))" in spec) 
paulson@13223
   684
apply (erule impE, blast, clarify) 
paulson@13223
   685
apply (drule_tac x=z and P="\<lambda>x. M(x) --> Ex(?Q(x))" in spec) 
paulson@13223
   686
apply (erule impE, blast, clarify)
paulson@13223
   687
apply (intro exI conjI) 
paulson@13223
   688
prefer 6 apply (rule refl) 
paulson@13223
   689
prefer 4 apply assumption
paulson@13223
   690
prefer 4 apply assumption
paulson@13245
   691
apply (insert cartprod_separation [of A B], auto)
paulson@13223
   692
done
paulson@13223
   693
paulson@13223
   694
paulson@13223
   695
text{*All the lemmas above are necessary because Powerset is not absolute.
paulson@13223
   696
      I should have used Replacement instead!*}
paulson@13245
   697
lemma (in M_axioms) cartprod_closed [intro,simp]: 
paulson@13223
   698
     "[| M(A); M(B) |] ==> M(A*B)"
paulson@13223
   699
by (frule cartprod_closed_lemma, assumption, force)
paulson@13223
   700
paulson@13245
   701
lemma (in M_axioms) image_closed [intro,simp]: 
paulson@13223
   702
     "[| M(A); M(r) |] ==> M(r``A)"
paulson@13223
   703
apply (simp add: image_iff_Collect)
paulson@13245
   704
apply (insert image_separation [of A r], simp) 
paulson@13223
   705
done
paulson@13223
   706
paulson@13223
   707
lemma (in M_axioms) vimage_abs [simp]: 
paulson@13223
   708
     "[| M(r); M(A); M(z) |] ==> pre_image(M,r,A,z) <-> z = r-``A"
paulson@13223
   709
apply (simp add: pre_image_def)
paulson@13223
   710
apply (rule iffI) 
paulson@13223
   711
 apply (blast intro!: equalityI dest: transM, blast) 
paulson@13223
   712
done
paulson@13223
   713
paulson@13245
   714
lemma (in M_axioms) vimage_closed [intro,simp]: 
paulson@13223
   715
     "[| M(A); M(r) |] ==> M(r-``A)"
paulson@13223
   716
apply (simp add: vimage_iff_Collect)
paulson@13245
   717
apply (insert vimage_separation [of A r], simp) 
paulson@13223
   718
done
paulson@13223
   719
paulson@13223
   720
lemma (in M_axioms) domain_abs [simp]: 
paulson@13223
   721
     "[| M(r); M(z) |] ==> is_domain(M,r,z) <-> z = domain(r)"
paulson@13223
   722
apply (simp add: is_domain_def) 
paulson@13223
   723
apply (blast intro!: equalityI dest: transM) 
paulson@13223
   724
done
paulson@13223
   725
paulson@13245
   726
lemma (in M_axioms) domain_closed [intro,simp]: 
paulson@13223
   727
     "M(r) ==> M(domain(r))"
paulson@13223
   728
apply (simp add: domain_eq_vimage)
paulson@13223
   729
done
paulson@13223
   730
paulson@13223
   731
lemma (in M_axioms) range_abs [simp]: 
paulson@13223
   732
     "[| M(r); M(z) |] ==> is_range(M,r,z) <-> z = range(r)"
paulson@13223
   733
apply (simp add: is_range_def)
paulson@13223
   734
apply (blast intro!: equalityI dest: transM)
paulson@13223
   735
done
paulson@13223
   736
paulson@13245
   737
lemma (in M_axioms) range_closed [intro,simp]: 
paulson@13223
   738
     "M(r) ==> M(range(r))"
paulson@13223
   739
apply (simp add: range_eq_image)
paulson@13223
   740
done
paulson@13223
   741
paulson@13245
   742
lemma (in M_axioms) field_abs [simp]: 
paulson@13245
   743
     "[| M(r); M(z) |] ==> is_field(M,r,z) <-> z = field(r)"
paulson@13245
   744
by (simp add: domain_closed range_closed is_field_def field_def)
paulson@13245
   745
paulson@13245
   746
lemma (in M_axioms) field_closed [intro,simp]: 
paulson@13245
   747
     "M(r) ==> M(field(r))"
paulson@13245
   748
by (simp add: domain_closed range_closed Un_closed field_def) 
paulson@13245
   749
paulson@13245
   750
paulson@13223
   751
lemma (in M_axioms) M_converse_iff:
paulson@13223
   752
     "M(r) ==> 
paulson@13223
   753
      converse(r) = 
paulson@13223
   754
      {z \<in> range(r) * domain(r). 
paulson@13245
   755
        \<exists>p\<in>r. \<exists>x. M(x) & (\<exists>y. M(y) & p = \<langle>x,y\<rangle> & z = \<langle>y,x\<rangle>)}"
paulson@13223
   756
by (blast dest: transM)
paulson@13223
   757
paulson@13245
   758
lemma (in M_axioms) converse_closed [intro,simp]: 
paulson@13223
   759
     "M(r) ==> M(converse(r))"
paulson@13223
   760
apply (simp add: M_converse_iff)
paulson@13245
   761
apply (insert converse_separation [of r], simp)
paulson@13223
   762
done
paulson@13223
   763
paulson@13223
   764
lemma (in M_axioms) relation_abs [simp]: 
paulson@13223
   765
     "M(r) ==> is_relation(M,r) <-> relation(r)"
paulson@13223
   766
apply (simp add: is_relation_def relation_def) 
paulson@13223
   767
apply (blast dest!: bspec dest: pair_components_in_M)+
paulson@13223
   768
done
paulson@13223
   769
paulson@13223
   770
lemma (in M_axioms) function_abs [simp]: 
paulson@13223
   771
     "M(r) ==> is_function(M,r) <-> function(r)"
paulson@13223
   772
apply (simp add: is_function_def function_def, safe) 
paulson@13223
   773
   apply (frule transM, assumption) 
paulson@13223
   774
  apply (blast dest: pair_components_in_M)+
paulson@13223
   775
done
paulson@13223
   776
paulson@13245
   777
lemma (in M_axioms) apply_closed [intro,simp]: 
paulson@13223
   778
     "[|M(f); M(a)|] ==> M(f`a)"
paulson@13245
   779
apply (simp add: apply_def)
paulson@13223
   780
done
paulson@13223
   781
paulson@13223
   782
lemma (in M_axioms) apply_abs: 
paulson@13223
   783
     "[| function(f); M(f); M(y) |] 
paulson@13223
   784
      ==> fun_apply(M,f,x,y) <-> x \<in> domain(f) & f`x = y"
paulson@13223
   785
apply (simp add: fun_apply_def)
paulson@13223
   786
apply (blast intro: function_apply_equality function_apply_Pair) 
paulson@13223
   787
done
paulson@13223
   788
paulson@13223
   789
lemma (in M_axioms) typed_apply_abs: 
paulson@13223
   790
     "[| f \<in> A -> B; M(f); M(y) |] 
paulson@13223
   791
      ==> fun_apply(M,f,x,y) <-> x \<in> A & f`x = y"
paulson@13223
   792
by (simp add: apply_abs fun_is_function domain_of_fun) 
paulson@13223
   793
paulson@13223
   794
lemma (in M_axioms) typed_function_abs [simp]: 
paulson@13223
   795
     "[| M(A); M(f) |] ==> typed_function(M,A,B,f) <-> f \<in> A -> B"
paulson@13223
   796
apply (auto simp add: typed_function_def relation_def Pi_iff) 
paulson@13223
   797
apply (blast dest: pair_components_in_M)+
paulson@13223
   798
done
paulson@13223
   799
paulson@13223
   800
lemma (in M_axioms) injection_abs [simp]: 
paulson@13223
   801
     "[| M(A); M(f) |] ==> injection(M,A,B,f) <-> f \<in> inj(A,B)"
paulson@13223
   802
apply (simp add: injection_def apply_iff inj_def apply_closed)
paulson@13223
   803
apply (blast dest: transM [of _ A]); 
paulson@13223
   804
done
paulson@13223
   805
paulson@13223
   806
lemma (in M_axioms) surjection_abs [simp]: 
paulson@13223
   807
     "[| M(A); M(B); M(f) |] ==> surjection(M,A,B,f) <-> f \<in> surj(A,B)"
paulson@13223
   808
by (simp add: typed_apply_abs surjection_def surj_def)
paulson@13223
   809
paulson@13223
   810
lemma (in M_axioms) bijection_abs [simp]: 
paulson@13223
   811
     "[| M(A); M(B); M(f) |] ==> bijection(M,A,B,f) <-> f \<in> bij(A,B)"
paulson@13223
   812
by (simp add: bijection_def bij_def)
paulson@13223
   813
paulson@13223
   814
text{*no longer needed*}
paulson@13223
   815
lemma (in M_axioms) restriction_is_function: 
paulson@13223
   816
     "[| restriction(M,f,A,z); function(f); M(f); M(A); M(z) |] 
paulson@13223
   817
      ==> function(z)"
paulson@13223
   818
apply (rotate_tac 1)
paulson@13223
   819
apply (simp add: restriction_def Ball_iff_equiv) 
paulson@13223
   820
apply (unfold function_def, blast) 
paulson@13223
   821
done
paulson@13223
   822
paulson@13223
   823
lemma (in M_axioms) restriction_abs [simp]: 
paulson@13223
   824
     "[| M(f); M(A); M(z) |] 
paulson@13223
   825
      ==> restriction(M,f,A,z) <-> z = restrict(f,A)"
paulson@13223
   826
apply (simp add: Ball_iff_equiv restriction_def restrict_def)
paulson@13223
   827
apply (blast intro!: equalityI dest: transM) 
paulson@13223
   828
done
paulson@13223
   829
paulson@13223
   830
paulson@13223
   831
lemma (in M_axioms) M_restrict_iff:
paulson@13223
   832
     "M(r) ==> restrict(r,A) = {z \<in> r . \<exists>x\<in>A. \<exists>y. M(y) & z = \<langle>x, y\<rangle>}"
paulson@13223
   833
by (simp add: restrict_def, blast dest: transM)
paulson@13223
   834
paulson@13245
   835
lemma (in M_axioms) restrict_closed [intro,simp]: 
paulson@13223
   836
     "[| M(A); M(r) |] ==> M(restrict(r,A))"
paulson@13223
   837
apply (simp add: M_restrict_iff)
paulson@13245
   838
apply (insert restrict_separation [of A], simp) 
paulson@13223
   839
done
paulson@13223
   840
paulson@13223
   841
lemma (in M_axioms) M_comp_iff:
paulson@13223
   842
     "[| M(r); M(s) |] 
paulson@13223
   843
      ==> r O s = 
paulson@13223
   844
          {xz \<in> domain(s) * range(r).  
paulson@13245
   845
            \<exists>x. M(x) & (\<exists>y. M(y) & (\<exists>z. M(z) & 
paulson@13245
   846
                xz = \<langle>x,z\<rangle> & \<langle>x,y\<rangle> \<in> s & \<langle>y,z\<rangle> \<in> r))}"
paulson@13223
   847
apply (simp add: comp_def)
paulson@13223
   848
apply (rule equalityI) 
paulson@13223
   849
 apply (clarify ); 
paulson@13223
   850
 apply (simp add: ); 
paulson@13223
   851
 apply  (blast dest:  transM)+
paulson@13223
   852
done
paulson@13223
   853
paulson@13245
   854
lemma (in M_axioms) comp_closed [intro,simp]: 
paulson@13223
   855
     "[| M(r); M(s) |] ==> M(r O s)"
paulson@13223
   856
apply (simp add: M_comp_iff)
paulson@13245
   857
apply (insert comp_separation [of r s], simp) 
paulson@13245
   858
done
paulson@13245
   859
paulson@13245
   860
lemma (in M_axioms) composition_abs [simp]: 
paulson@13245
   861
     "[| M(r); M(s); M(t) |] 
paulson@13245
   862
      ==> composition(M,r,s,t) <-> t = r O s"
paulson@13245
   863
apply safe;
paulson@13245
   864
 txt{*Proving @{term "composition(M, r, s, r O s)"}*}
paulson@13245
   865
 prefer 2 
paulson@13245
   866
 apply (simp add: composition_def comp_def)
paulson@13245
   867
 apply (blast dest: transM) 
paulson@13245
   868
txt{*Opposite implication*}
paulson@13245
   869
apply (rule M_equalityI)
paulson@13245
   870
  apply (simp add: composition_def comp_def)
paulson@13245
   871
  apply (blast del: allE dest: transM)+
paulson@13223
   872
done
paulson@13223
   873
paulson@13223
   874
lemma (in M_axioms) nat_into_M [intro]:
paulson@13223
   875
     "n \<in> nat ==> M(n)"
paulson@13223
   876
by (induct n rule: nat_induct, simp_all)
paulson@13223
   877
paulson@13223
   878
lemma (in M_axioms) Inl_in_M_iff [iff]:
paulson@13223
   879
     "M(Inl(a)) <-> M(a)"
paulson@13223
   880
by (simp add: Inl_def) 
paulson@13223
   881
paulson@13223
   882
lemma (in M_axioms) Inr_in_M_iff [iff]:
paulson@13223
   883
     "M(Inr(a)) <-> M(a)"
paulson@13223
   884
by (simp add: Inr_def) 
paulson@13223
   885
paulson@13223
   886
lemma (in M_axioms) Inter_abs [simp]: 
paulson@13223
   887
     "[| M(A); M(z) |] ==> big_inter(M,A,z) <-> z = Inter(A)"
paulson@13223
   888
apply (simp add: big_inter_def Inter_def) 
paulson@13223
   889
apply (blast intro!: equalityI dest: transM) 
paulson@13223
   890
done
paulson@13223
   891
paulson@13245
   892
lemma (in M_axioms) Inter_closed [intro,simp]:
paulson@13223
   893
     "M(A) ==> M(Inter(A))"
paulson@13245
   894
by (insert Inter_separation, simp add: Inter_def)
paulson@13223
   895
paulson@13245
   896
lemma (in M_axioms) Int_closed [intro,simp]:
paulson@13223
   897
     "[| M(A); M(B) |] ==> M(A Int B)"
paulson@13223
   898
apply (subgoal_tac "M({A,B})")
paulson@13223
   899
apply (frule Inter_closed, force+); 
paulson@13223
   900
done
paulson@13223
   901
paulson@13245
   902
text{*M contains all finite functions*}
paulson@13245
   903
lemma (in M_axioms) finite_fun_closed_lemma [rule_format]: 
paulson@13245
   904
     "[| n \<in> nat; M(A) |] ==> \<forall>f \<in> n -> A. M(f)"
paulson@13245
   905
apply (induct_tac n, simp)
paulson@13245
   906
apply (rule ballI)  
paulson@13245
   907
apply (simp add: succ_def) 
paulson@13245
   908
apply (frule fun_cons_restrict_eq)
paulson@13245
   909
apply (erule ssubst) 
paulson@13245
   910
apply (subgoal_tac "M(f`x) & restrict(f,x) \<in> x -> A") 
paulson@13245
   911
 apply (simp add: cons_closed nat_into_M apply_closed) 
paulson@13245
   912
apply (blast intro: apply_funtype transM restrict_type2) 
paulson@13245
   913
done
paulson@13245
   914
paulson@13245
   915
lemma (in M_axioms) finite_fun_closed [rule_format]: 
paulson@13245
   916
     "[| f \<in> n -> A; n \<in> nat; M(A) |] ==> M(f)"
paulson@13245
   917
by (blast intro: finite_fun_closed_lemma) 
paulson@13245
   918
paulson@13245
   919
paulson@13223
   920
subsection{*Absoluteness for ordinals*}
paulson@13223
   921
text{*These results constitute Theorem IV 5.1 of Kunen (page 126).*}
paulson@13223
   922
paulson@13223
   923
lemma (in M_axioms) lt_closed:
paulson@13223
   924
     "[| j<i; M(i) |] ==> M(j)" 
paulson@13223
   925
by (blast dest: ltD intro: transM) 
paulson@13223
   926
paulson@13223
   927
lemma (in M_axioms) transitive_set_abs [simp]: 
paulson@13223
   928
     "M(a) ==> transitive_set(M,a) <-> Transset(a)"
paulson@13223
   929
by (simp add: transitive_set_def Transset_def)
paulson@13223
   930
paulson@13223
   931
lemma (in M_axioms) ordinal_abs [simp]: 
paulson@13223
   932
     "M(a) ==> ordinal(M,a) <-> Ord(a)"
paulson@13223
   933
by (simp add: ordinal_def Ord_def)
paulson@13223
   934
paulson@13223
   935
lemma (in M_axioms) limit_ordinal_abs [simp]: 
paulson@13223
   936
     "M(a) ==> limit_ordinal(M,a) <-> Limit(a)"
paulson@13223
   937
apply (simp add: limit_ordinal_def Ord_0_lt_iff Limit_def) 
paulson@13223
   938
apply (simp add: lt_def, blast) 
paulson@13223
   939
done
paulson@13223
   940
paulson@13223
   941
lemma (in M_axioms) successor_ordinal_abs [simp]: 
paulson@13223
   942
     "M(a) ==> successor_ordinal(M,a) <-> Ord(a) & (\<exists>b. M(b) & a = succ(b))"
paulson@13223
   943
apply (simp add: successor_ordinal_def, safe)
paulson@13223
   944
apply (drule Ord_cases_disj, auto) 
paulson@13223
   945
done
paulson@13223
   946
paulson@13223
   947
lemma finite_Ord_is_nat:
paulson@13223
   948
      "[| Ord(a); ~ Limit(a); \<forall>x\<in>a. ~ Limit(x) |] ==> a \<in> nat"
paulson@13223
   949
by (induct a rule: trans_induct3, simp_all)
paulson@13223
   950
paulson@13223
   951
lemma naturals_not_limit: "a \<in> nat ==> ~ Limit(a)"
paulson@13223
   952
by (induct a rule: nat_induct, auto)
paulson@13223
   953
paulson@13223
   954
lemma (in M_axioms) finite_ordinal_abs [simp]: 
paulson@13223
   955
     "M(a) ==> finite_ordinal(M,a) <-> a \<in> nat"
paulson@13223
   956
apply (simp add: finite_ordinal_def)
paulson@13223
   957
apply (blast intro: finite_Ord_is_nat intro: nat_into_Ord 
paulson@13223
   958
             dest: Ord_trans naturals_not_limit)
paulson@13223
   959
done
paulson@13223
   960
paulson@13223
   961
lemma Limit_non_Limit_implies_nat: "[| Limit(a); \<forall>x\<in>a. ~ Limit(x) |] ==> a = nat"
paulson@13223
   962
apply (rule le_anti_sym) 
paulson@13223
   963
apply (rule all_lt_imp_le, blast, blast intro: Limit_is_Ord)  
paulson@13223
   964
 apply (simp add: lt_def)  
paulson@13223
   965
 apply (blast intro: Ord_in_Ord Ord_trans finite_Ord_is_nat) 
paulson@13223
   966
apply (erule nat_le_Limit)
paulson@13223
   967
done
paulson@13223
   968
paulson@13223
   969
lemma (in M_axioms) omega_abs [simp]: 
paulson@13223
   970
     "M(a) ==> omega(M,a) <-> a = nat"
paulson@13223
   971
apply (simp add: omega_def) 
paulson@13223
   972
apply (blast intro: Limit_non_Limit_implies_nat dest: naturals_not_limit)
paulson@13223
   973
done
paulson@13223
   974
paulson@13223
   975
lemma (in M_axioms) number1_abs [simp]: 
paulson@13223
   976
     "M(a) ==> number1(M,a) <-> a = 1"
paulson@13223
   977
by (simp add: number1_def) 
paulson@13223
   978
paulson@13223
   979
lemma (in M_axioms) number1_abs [simp]: 
paulson@13223
   980
     "M(a) ==> number2(M,a) <-> a = succ(1)"
paulson@13223
   981
by (simp add: number2_def) 
paulson@13223
   982
paulson@13223
   983
lemma (in M_axioms) number3_abs [simp]: 
paulson@13223
   984
     "M(a) ==> number3(M,a) <-> a = succ(succ(1))"
paulson@13223
   985
by (simp add: number3_def) 
paulson@13223
   986
paulson@13223
   987
text{*Kunen continued to 20...*}
paulson@13223
   988
paulson@13223
   989
(*Could not get this to work.  The \<lambda>x\<in>nat is essential because everything 
paulson@13223
   990
  but the recursion variable must stay unchanged.  But then the recursion
paulson@13223
   991
  equations only hold for x\<in>nat (or in some other set) and not for the 
paulson@13223
   992
  whole of the class M.
paulson@13223
   993
  consts
paulson@13223
   994
    natnumber_aux :: "[i=>o,i] => i"
paulson@13223
   995
paulson@13223
   996
  primrec
paulson@13223
   997
      "natnumber_aux(M,0) = (\<lambda>x\<in>nat. if empty(M,x) then 1 else 0)"
paulson@13223
   998
      "natnumber_aux(M,succ(n)) = 
paulson@13223
   999
	   (\<lambda>x\<in>nat. if (\<exists>y. M(y) & natnumber_aux(M,n)`y=1 & successor(M,y,x)) 
paulson@13223
  1000
		     then 1 else 0)"
paulson@13223
  1001
paulson@13223
  1002
  constdefs
paulson@13223
  1003
    natnumber :: "[i=>o,i,i] => o"
paulson@13223
  1004
      "natnumber(M,n,x) == natnumber_aux(M,n)`x = 1"
paulson@13223
  1005
paulson@13223
  1006
  lemma (in M_axioms) [simp]: 
paulson@13223
  1007
       "natnumber(M,0,x) == x=0"
paulson@13223
  1008
*)
paulson@13223
  1009
paulson@13223
  1010
paulson@13223
  1011
end