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