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