src/ZF/Constructible/Relative.thy
author paulson
Fri Jul 05 18:33:50 2002 +0200 (2002-07-05)
changeset 13306 6eebcddee32b
parent 13299 3a932abf97e8
child 13316 d16629fd0f95
permissions -rw-r--r--
more internalized formulas and separation proofs
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@13223
    52
  is_converse :: "[i=>o,i,i] => o"
paulson@13223
    53
    "is_converse(M,r,z) == 
paulson@13299
    54
	\<forall>x[M]. x \<in> z <-> 
paulson@13299
    55
             (\<exists>w[M]. w\<in>r & (\<exists>u[M]. \<exists>v[M]. pair(M,u,v,w) & pair(M,v,u,x)))"
paulson@13223
    56
paulson@13223
    57
  pre_image :: "[i=>o,i,i,i] => o"
paulson@13223
    58
    "pre_image(M,r,A,z) == 
paulson@13299
    59
	\<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
    60
paulson@13223
    61
  is_domain :: "[i=>o,i,i] => o"
paulson@13223
    62
    "is_domain(M,r,z) == 
paulson@13299
    63
	\<forall>x[M]. (x \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>y[M]. pair(M,x,y,w))))"
paulson@13223
    64
paulson@13223
    65
  image :: "[i=>o,i,i,i] => o"
paulson@13223
    66
    "image(M,r,A,z) == 
paulson@13299
    67
        \<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
    68
paulson@13223
    69
  is_range :: "[i=>o,i,i] => o"
paulson@13223
    70
    --{*the cleaner 
paulson@13299
    71
      @{term "\<exists>r'[M]. is_converse(M,r,r') & is_domain(M,r',z)"}
paulson@13223
    72
      unfortunately needs an instance of separation in order to prove 
paulson@13223
    73
        @{term "M(converse(r))"}.*}
paulson@13223
    74
    "is_range(M,r,z) == 
paulson@13299
    75
	\<forall>y[M]. (y \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>x[M]. pair(M,x,y,w))))"
paulson@13223
    76
paulson@13245
    77
  is_field :: "[i=>o,i,i] => o"
paulson@13245
    78
    "is_field(M,r,z) == 
paulson@13298
    79
	\<exists>dr[M]. is_domain(M,r,dr) & 
paulson@13298
    80
            (\<exists>rr[M]. is_range(M,r,rr) & union(M,dr,rr,z))"
paulson@13245
    81
paulson@13223
    82
  is_relation :: "[i=>o,i] => o"
paulson@13223
    83
    "is_relation(M,r) == 
paulson@13298
    84
        (\<forall>z[M]. z\<in>r --> (\<exists>x[M]. \<exists>y[M]. pair(M,x,y,z)))"
paulson@13223
    85
paulson@13223
    86
  is_function :: "[i=>o,i] => o"
paulson@13223
    87
    "is_function(M,r) == 
paulson@13299
    88
	\<forall>x[M]. \<forall>y[M]. \<forall>y'[M]. \<forall>p[M]. \<forall>p'[M]. 
paulson@13299
    89
           pair(M,x,y,p) --> pair(M,x,y',p') --> p\<in>r --> p'\<in>r --> y=y'"
paulson@13223
    90
paulson@13223
    91
  fun_apply :: "[i=>o,i,i,i] => o"
paulson@13223
    92
    "fun_apply(M,f,x,y) == 
paulson@13299
    93
	(\<forall>y'[M]. (\<exists>u[M]. u\<in>f & pair(M,x,y',u)) <-> y=y')"
paulson@13223
    94
paulson@13223
    95
  typed_function :: "[i=>o,i,i,i] => o"
paulson@13223
    96
    "typed_function(M,A,B,r) == 
paulson@13223
    97
        is_function(M,r) & is_relation(M,r) & is_domain(M,r,A) &
paulson@13306
    98
        (\<forall>u[M]. u\<in>r --> (\<forall>x[M]. \<forall>y[M]. pair(M,x,y,u) --> y\<in>B))"
paulson@13223
    99
paulson@13268
   100
  is_funspace :: "[i=>o,i,i,i] => o"
paulson@13268
   101
    "is_funspace(M,A,B,F) == 
paulson@13268
   102
        \<forall>f[M]. f \<in> F <-> typed_function(M,A,B,f)"
paulson@13268
   103
paulson@13245
   104
  composition :: "[i=>o,i,i,i] => o"
paulson@13245
   105
    "composition(M,r,s,t) == 
paulson@13306
   106
        \<forall>p[M]. p \<in> t <-> 
paulson@13306
   107
               (\<exists>x[M]. \<exists>y[M]. \<exists>z[M]. pair(M,x,z,p) & \<langle>x,y\<rangle> \<in> s & \<langle>y,z\<rangle> \<in> r)"
paulson@13245
   108
paulson@13245
   109
paulson@13223
   110
  injection :: "[i=>o,i,i,i] => o"
paulson@13223
   111
    "injection(M,A,B,f) == 
paulson@13223
   112
	typed_function(M,A,B,f) &
paulson@13306
   113
        (\<forall>x[M]. \<forall>x'[M]. \<forall>y[M]. \<forall>p[M]. \<forall>p'[M]. 
paulson@13306
   114
          pair(M,x,y,p) --> pair(M,x',y,p') --> p\<in>f --> p'\<in>f --> x=x')"
paulson@13223
   115
paulson@13223
   116
  surjection :: "[i=>o,i,i,i] => o"
paulson@13223
   117
    "surjection(M,A,B,f) == 
paulson@13223
   118
        typed_function(M,A,B,f) &
paulson@13299
   119
        (\<forall>y[M]. y\<in>B --> (\<exists>x[M]. x\<in>A & fun_apply(M,f,x,y)))"
paulson@13223
   120
paulson@13223
   121
  bijection :: "[i=>o,i,i,i] => o"
paulson@13223
   122
    "bijection(M,A,B,f) == injection(M,A,B,f) & surjection(M,A,B,f)"
paulson@13223
   123
paulson@13223
   124
  restriction :: "[i=>o,i,i,i] => o"
paulson@13223
   125
    "restriction(M,r,A,z) == 
paulson@13306
   126
	\<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
   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@13306
   366
        (\<forall>x[M]. x\<in>A --> (\<forall>y[M]. y\<in>A -->
paulson@13306
   367
          (\<forall>p[M]. \<forall>fx[M]. \<forall>fy[M]. \<forall>q[M].
paulson@13223
   368
            pair(M,x,y,p) --> fun_apply(M,f,x,fx) --> fun_apply(M,f,y,fy) --> 
paulson@13306
   369
            pair(M,fx,fy,q) --> (p\<in>r <-> q\<in>s))))"
paulson@13223
   370
paulson@13223
   371
  pred_set :: "[i=>o,i,i,i,i] => o"
paulson@13223
   372
    "pred_set(M,A,x,r,B) == 
paulson@13299
   373
	\<forall>y[M]. y \<in> B <-> (\<exists>p[M]. p\<in>r & y \<in> A & pair(M,y,x,p))"
paulson@13223
   374
paulson@13223
   375
  membership :: "[i=>o,i,i] => o" --{*membership relation*}
paulson@13223
   376
    "membership(M,A,r) == 
paulson@13306
   377
	\<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
   378
paulson@13223
   379
paulson@13223
   380
subsection{*Absoluteness for a transitive class model*}
paulson@13223
   381
paulson@13223
   382
text{*The class M is assumed to be transitive and to satisfy some
paulson@13223
   383
      relativized ZF axioms*}
paulson@13290
   384
locale M_triv_axioms =
paulson@13223
   385
  fixes M
paulson@13223
   386
  assumes transM:           "[| y\<in>x; M(x) |] ==> M(y)"
paulson@13223
   387
      and nonempty [simp]:  "M(0)"
paulson@13223
   388
      and upair_ax:	    "upair_ax(M)"
paulson@13223
   389
      and Union_ax:	    "Union_ax(M)"
paulson@13223
   390
      and power_ax:         "power_ax(M)"
paulson@13223
   391
      and replacement:      "replacement(M,P)"
paulson@13268
   392
      and M_nat [iff]:      "M(nat)"           (*i.e. the axiom of infinity*)
paulson@13290
   393
paulson@13290
   394
lemma (in M_triv_axioms) ball_abs [simp]: 
paulson@13290
   395
     "M(A) ==> (\<forall>x\<in>A. M(x) --> P(x)) <-> (\<forall>x\<in>A. P(x))" 
paulson@13290
   396
by (blast intro: transM) 
paulson@13290
   397
paulson@13290
   398
lemma (in M_triv_axioms) rall_abs [simp]: 
paulson@13290
   399
     "M(A) ==> (\<forall>x[M]. x\<in>A --> P(x)) <-> (\<forall>x\<in>A. P(x))" 
paulson@13290
   400
by (blast intro: transM) 
paulson@13290
   401
paulson@13290
   402
lemma (in M_triv_axioms) bex_abs [simp]: 
paulson@13290
   403
     "M(A) ==> (\<exists>x\<in>A. M(x) & P(x)) <-> (\<exists>x\<in>A. P(x))" 
paulson@13290
   404
by (blast intro: transM) 
paulson@13290
   405
paulson@13290
   406
lemma (in M_triv_axioms) rex_abs [simp]: 
paulson@13290
   407
     "M(A) ==> (\<exists>x[M]. x\<in>A & P(x)) <-> (\<exists>x\<in>A. P(x))" 
paulson@13290
   408
by (blast intro: transM) 
paulson@13290
   409
paulson@13290
   410
lemma (in M_triv_axioms) ball_iff_equiv: 
paulson@13299
   411
     "M(A) ==> (\<forall>x[M]. (x\<in>A <-> P(x))) <-> 
paulson@13290
   412
               (\<forall>x\<in>A. P(x)) & (\<forall>x. P(x) --> M(x) --> x\<in>A)" 
paulson@13290
   413
by (blast intro: transM)
paulson@13290
   414
paulson@13290
   415
text{*Simplifies proofs of equalities when there's an iff-equality
paulson@13290
   416
      available for rewriting, universally quantified over M. *}
paulson@13290
   417
lemma (in M_triv_axioms) M_equalityI: 
paulson@13290
   418
     "[| !!x. M(x) ==> x\<in>A <-> x\<in>B; M(A); M(B) |] ==> A=B"
paulson@13290
   419
by (blast intro!: equalityI dest: transM) 
paulson@13290
   420
paulson@13290
   421
lemma (in M_triv_axioms) empty_abs [simp]: 
paulson@13290
   422
     "M(z) ==> empty(M,z) <-> z=0"
paulson@13290
   423
apply (simp add: empty_def)
paulson@13290
   424
apply (blast intro: transM) 
paulson@13290
   425
done
paulson@13290
   426
paulson@13290
   427
lemma (in M_triv_axioms) subset_abs [simp]: 
paulson@13290
   428
     "M(A) ==> subset(M,A,B) <-> A \<subseteq> B"
paulson@13290
   429
apply (simp add: subset_def) 
paulson@13290
   430
apply (blast intro: transM) 
paulson@13290
   431
done
paulson@13290
   432
paulson@13290
   433
lemma (in M_triv_axioms) upair_abs [simp]: 
paulson@13290
   434
     "M(z) ==> upair(M,a,b,z) <-> z={a,b}"
paulson@13290
   435
apply (simp add: upair_def) 
paulson@13290
   436
apply (blast intro: transM) 
paulson@13290
   437
done
paulson@13290
   438
paulson@13290
   439
lemma (in M_triv_axioms) upair_in_M_iff [iff]:
paulson@13290
   440
     "M({a,b}) <-> M(a) & M(b)"
paulson@13290
   441
apply (insert upair_ax, simp add: upair_ax_def) 
paulson@13290
   442
apply (blast intro: transM) 
paulson@13290
   443
done
paulson@13290
   444
paulson@13290
   445
lemma (in M_triv_axioms) singleton_in_M_iff [iff]:
paulson@13290
   446
     "M({a}) <-> M(a)"
paulson@13290
   447
by (insert upair_in_M_iff [of a a], simp) 
paulson@13290
   448
paulson@13290
   449
lemma (in M_triv_axioms) pair_abs [simp]: 
paulson@13290
   450
     "M(z) ==> pair(M,a,b,z) <-> z=<a,b>"
paulson@13290
   451
apply (simp add: pair_def ZF.Pair_def)
paulson@13290
   452
apply (blast intro: transM) 
paulson@13290
   453
done
paulson@13290
   454
paulson@13290
   455
lemma (in M_triv_axioms) pair_in_M_iff [iff]:
paulson@13290
   456
     "M(<a,b>) <-> M(a) & M(b)"
paulson@13290
   457
by (simp add: ZF.Pair_def)
paulson@13290
   458
paulson@13290
   459
lemma (in M_triv_axioms) pair_components_in_M:
paulson@13290
   460
     "[| <x,y> \<in> A; M(A) |] ==> M(x) & M(y)"
paulson@13290
   461
apply (simp add: Pair_def)
paulson@13290
   462
apply (blast dest: transM) 
paulson@13290
   463
done
paulson@13290
   464
paulson@13290
   465
lemma (in M_triv_axioms) cartprod_abs [simp]: 
paulson@13290
   466
     "[| M(A); M(B); M(z) |] ==> cartprod(M,A,B,z) <-> z = A*B"
paulson@13290
   467
apply (simp add: cartprod_def)
paulson@13290
   468
apply (rule iffI) 
paulson@13290
   469
 apply (blast intro!: equalityI intro: transM dest!: rspec) 
paulson@13290
   470
apply (blast dest: transM) 
paulson@13290
   471
done
paulson@13290
   472
paulson@13290
   473
lemma (in M_triv_axioms) union_abs [simp]: 
paulson@13290
   474
     "[| M(a); M(b); M(z) |] ==> union(M,a,b,z) <-> z = a Un b"
paulson@13290
   475
apply (simp add: union_def) 
paulson@13290
   476
apply (blast intro: transM) 
paulson@13290
   477
done
paulson@13290
   478
paulson@13290
   479
lemma (in M_triv_axioms) inter_abs [simp]: 
paulson@13290
   480
     "[| M(a); M(b); M(z) |] ==> inter(M,a,b,z) <-> z = a Int b"
paulson@13290
   481
apply (simp add: inter_def) 
paulson@13290
   482
apply (blast intro: transM) 
paulson@13290
   483
done
paulson@13290
   484
paulson@13290
   485
lemma (in M_triv_axioms) setdiff_abs [simp]: 
paulson@13290
   486
     "[| M(a); M(b); M(z) |] ==> setdiff(M,a,b,z) <-> z = a-b"
paulson@13290
   487
apply (simp add: setdiff_def) 
paulson@13290
   488
apply (blast intro: transM) 
paulson@13290
   489
done
paulson@13290
   490
paulson@13290
   491
lemma (in M_triv_axioms) Union_abs [simp]: 
paulson@13290
   492
     "[| M(A); M(z) |] ==> big_union(M,A,z) <-> z = Union(A)"
paulson@13290
   493
apply (simp add: big_union_def) 
paulson@13290
   494
apply (blast intro!: equalityI dest: transM) 
paulson@13290
   495
done
paulson@13290
   496
paulson@13290
   497
lemma (in M_triv_axioms) Union_closed [intro,simp]:
paulson@13290
   498
     "M(A) ==> M(Union(A))"
paulson@13290
   499
by (insert Union_ax, simp add: Union_ax_def) 
paulson@13290
   500
paulson@13290
   501
lemma (in M_triv_axioms) Un_closed [intro,simp]:
paulson@13290
   502
     "[| M(A); M(B) |] ==> M(A Un B)"
paulson@13290
   503
by (simp only: Un_eq_Union, blast) 
paulson@13290
   504
paulson@13290
   505
lemma (in M_triv_axioms) cons_closed [intro,simp]:
paulson@13290
   506
     "[| M(a); M(A) |] ==> M(cons(a,A))"
paulson@13290
   507
by (subst cons_eq [symmetric], blast) 
paulson@13290
   508
paulson@13306
   509
lemma (in M_triv_axioms) cons_abs [simp]: 
paulson@13306
   510
     "[| M(b); M(z) |] ==> is_cons(M,a,b,z) <-> z = cons(a,b)"
paulson@13306
   511
by (simp add: is_cons_def, blast intro: transM)  
paulson@13306
   512
paulson@13290
   513
lemma (in M_triv_axioms) successor_abs [simp]: 
paulson@13306
   514
     "[| M(a); M(z) |] ==> successor(M,a,z) <-> z = succ(a)"
paulson@13290
   515
by (simp add: successor_def, blast)  
paulson@13290
   516
paulson@13290
   517
lemma (in M_triv_axioms) succ_in_M_iff [iff]:
paulson@13290
   518
     "M(succ(a)) <-> M(a)"
paulson@13290
   519
apply (simp add: succ_def) 
paulson@13290
   520
apply (blast intro: transM) 
paulson@13290
   521
done
paulson@13290
   522
paulson@13290
   523
lemma (in M_triv_axioms) separation_closed [intro,simp]:
paulson@13290
   524
     "[| separation(M,P); M(A) |] ==> M(Collect(A,P))"
paulson@13290
   525
apply (insert separation, simp add: separation_def) 
paulson@13290
   526
apply (drule rspec, assumption, clarify) 
paulson@13290
   527
apply (subgoal_tac "y = Collect(A,P)", blast)
paulson@13290
   528
apply (blast dest: transM) 
paulson@13290
   529
done
paulson@13290
   530
paulson@13290
   531
text{*Probably the premise and conclusion are equivalent*}
paulson@13306
   532
lemma (in M_triv_axioms) strong_replacementI [OF rallI]:
paulson@13306
   533
    "[| \<forall>A[M]. separation(M, %u. \<exists>x[M]. x\<in>A & P(x,u)) |]
paulson@13290
   534
     ==> strong_replacement(M,P)"
paulson@13290
   535
apply (simp add: strong_replacement_def, clarify) 
paulson@13290
   536
apply (frule replacementD [OF replacement], assumption, clarify) 
paulson@13299
   537
apply (drule_tac x=A in rspec, clarify)  
paulson@13290
   538
apply (drule_tac z=Y in separationD, assumption, clarify) 
paulson@13299
   539
apply (rule_tac x=y in rexI) 
paulson@13299
   540
apply (blast dest: transM)+
paulson@13290
   541
done
paulson@13290
   542
paulson@13290
   543
paulson@13290
   544
(*The last premise expresses that P takes M to M*)
paulson@13290
   545
lemma (in M_triv_axioms) strong_replacement_closed [intro,simp]:
paulson@13290
   546
     "[| strong_replacement(M,P); M(A); univalent(M,A,P); 
paulson@13290
   547
       !!x y. [| x\<in>A; P(x,y); M(x) |] ==> M(y) |] ==> M(Replace(A,P))"
paulson@13290
   548
apply (simp add: strong_replacement_def) 
paulson@13299
   549
apply (drule rspec, auto) 
paulson@13290
   550
apply (subgoal_tac "Replace(A,P) = Y")
paulson@13290
   551
 apply simp 
paulson@13290
   552
apply (rule equality_iffI) 
paulson@13290
   553
apply (simp add: Replace_iff, safe)
paulson@13290
   554
 apply (blast dest: transM) 
paulson@13290
   555
apply (frule transM, assumption) 
paulson@13290
   556
 apply (simp add: univalent_def)
paulson@13299
   557
 apply (drule rspec [THEN iffD1], assumption, assumption)
paulson@13290
   558
 apply (blast dest: transM) 
paulson@13290
   559
done
paulson@13290
   560
paulson@13290
   561
(*The first premise can't simply be assumed as a schema.
paulson@13290
   562
  It is essential to take care when asserting instances of Replacement.
paulson@13290
   563
  Let K be a nonconstructible subset of nat and define
paulson@13290
   564
  f(x) = x if x:K and f(x)=0 otherwise.  Then RepFun(nat,f) = cons(0,K), a 
paulson@13290
   565
  nonconstructible set.  So we cannot assume that M(X) implies M(RepFun(X,f))
paulson@13290
   566
  even for f : M -> M.
paulson@13290
   567
*)
paulson@13290
   568
lemma (in M_triv_axioms) RepFun_closed [intro,simp]:
paulson@13290
   569
     "[| strong_replacement(M, \<lambda>x y. y = f(x)); M(A); \<forall>x\<in>A. M(f(x)) |]
paulson@13290
   570
      ==> M(RepFun(A,f))"
paulson@13290
   571
apply (simp add: RepFun_def) 
paulson@13290
   572
apply (rule strong_replacement_closed) 
paulson@13290
   573
apply (auto dest: transM  simp add: univalent_def) 
paulson@13290
   574
done
paulson@13290
   575
paulson@13290
   576
lemma (in M_triv_axioms) lam_closed [intro,simp]:
paulson@13290
   577
     "[| strong_replacement(M, \<lambda>x y. y = <x,b(x)>); M(A); \<forall>x\<in>A. M(b(x)) |]
paulson@13290
   578
      ==> M(\<lambda>x\<in>A. b(x))"
paulson@13290
   579
by (simp add: lam_def, blast dest: transM) 
paulson@13290
   580
paulson@13290
   581
lemma (in M_triv_axioms) image_abs [simp]: 
paulson@13290
   582
     "[| M(r); M(A); M(z) |] ==> image(M,r,A,z) <-> z = r``A"
paulson@13290
   583
apply (simp add: image_def)
paulson@13290
   584
apply (rule iffI) 
paulson@13290
   585
 apply (blast intro!: equalityI dest: transM, blast) 
paulson@13290
   586
done
paulson@13290
   587
paulson@13290
   588
text{*What about @{text Pow_abs}?  Powerset is NOT absolute!
paulson@13290
   589
      This result is one direction of absoluteness.*}
paulson@13290
   590
paulson@13290
   591
lemma (in M_triv_axioms) powerset_Pow: 
paulson@13290
   592
     "powerset(M, x, Pow(x))"
paulson@13290
   593
by (simp add: powerset_def)
paulson@13290
   594
paulson@13290
   595
text{*But we can't prove that the powerset in @{text M} includes the
paulson@13290
   596
      real powerset.*}
paulson@13290
   597
lemma (in M_triv_axioms) powerset_imp_subset_Pow: 
paulson@13290
   598
     "[| powerset(M,x,y); M(y) |] ==> y <= Pow(x)"
paulson@13290
   599
apply (simp add: powerset_def) 
paulson@13290
   600
apply (blast dest: transM) 
paulson@13290
   601
done
paulson@13290
   602
paulson@13290
   603
lemma (in M_triv_axioms) nat_into_M [intro]:
paulson@13290
   604
     "n \<in> nat ==> M(n)"
paulson@13290
   605
by (induct n rule: nat_induct, simp_all)
paulson@13290
   606
paulson@13290
   607
lemma (in M_triv_axioms) nat_case_closed:
paulson@13290
   608
  "[|M(k); M(a); \<forall>m[M]. M(b(m))|] ==> M(nat_case(a,b,k))"
paulson@13290
   609
apply (case_tac "k=0", simp) 
paulson@13290
   610
apply (case_tac "\<exists>m. k = succ(m)", force)
paulson@13290
   611
apply (simp add: nat_case_def) 
paulson@13290
   612
done
paulson@13290
   613
paulson@13290
   614
lemma (in M_triv_axioms) Inl_in_M_iff [iff]:
paulson@13290
   615
     "M(Inl(a)) <-> M(a)"
paulson@13290
   616
by (simp add: Inl_def) 
paulson@13290
   617
paulson@13290
   618
lemma (in M_triv_axioms) Inr_in_M_iff [iff]:
paulson@13290
   619
     "M(Inr(a)) <-> M(a)"
paulson@13290
   620
by (simp add: Inr_def)
paulson@13290
   621
paulson@13290
   622
paulson@13290
   623
subsection{*Absoluteness for ordinals*}
paulson@13290
   624
text{*These results constitute Theorem IV 5.1 of Kunen (page 126).*}
paulson@13290
   625
paulson@13290
   626
lemma (in M_triv_axioms) lt_closed:
paulson@13290
   627
     "[| j<i; M(i) |] ==> M(j)" 
paulson@13290
   628
by (blast dest: ltD intro: transM) 
paulson@13290
   629
paulson@13290
   630
lemma (in M_triv_axioms) transitive_set_abs [simp]: 
paulson@13290
   631
     "M(a) ==> transitive_set(M,a) <-> Transset(a)"
paulson@13290
   632
by (simp add: transitive_set_def Transset_def)
paulson@13290
   633
paulson@13290
   634
lemma (in M_triv_axioms) ordinal_abs [simp]: 
paulson@13290
   635
     "M(a) ==> ordinal(M,a) <-> Ord(a)"
paulson@13290
   636
by (simp add: ordinal_def Ord_def)
paulson@13290
   637
paulson@13290
   638
lemma (in M_triv_axioms) limit_ordinal_abs [simp]: 
paulson@13290
   639
     "M(a) ==> limit_ordinal(M,a) <-> Limit(a)"
paulson@13290
   640
apply (simp add: limit_ordinal_def Ord_0_lt_iff Limit_def) 
paulson@13290
   641
apply (simp add: lt_def, blast) 
paulson@13290
   642
done
paulson@13290
   643
paulson@13290
   644
lemma (in M_triv_axioms) successor_ordinal_abs [simp]: 
paulson@13299
   645
     "M(a) ==> successor_ordinal(M,a) <-> Ord(a) & (\<exists>b[M]. a = succ(b))"
paulson@13290
   646
apply (simp add: successor_ordinal_def, safe)
paulson@13290
   647
apply (drule Ord_cases_disj, auto) 
paulson@13290
   648
done
paulson@13290
   649
paulson@13290
   650
lemma finite_Ord_is_nat:
paulson@13290
   651
      "[| Ord(a); ~ Limit(a); \<forall>x\<in>a. ~ Limit(x) |] ==> a \<in> nat"
paulson@13290
   652
by (induct a rule: trans_induct3, simp_all)
paulson@13290
   653
paulson@13290
   654
lemma naturals_not_limit: "a \<in> nat ==> ~ Limit(a)"
paulson@13290
   655
by (induct a rule: nat_induct, auto)
paulson@13290
   656
paulson@13290
   657
lemma (in M_triv_axioms) finite_ordinal_abs [simp]: 
paulson@13290
   658
     "M(a) ==> finite_ordinal(M,a) <-> a \<in> nat"
paulson@13290
   659
apply (simp add: finite_ordinal_def)
paulson@13290
   660
apply (blast intro: finite_Ord_is_nat intro: nat_into_Ord 
paulson@13290
   661
             dest: Ord_trans naturals_not_limit)
paulson@13290
   662
done
paulson@13290
   663
paulson@13290
   664
lemma Limit_non_Limit_implies_nat:
paulson@13290
   665
     "[| Limit(a); \<forall>x\<in>a. ~ Limit(x) |] ==> a = nat"
paulson@13290
   666
apply (rule le_anti_sym) 
paulson@13290
   667
apply (rule all_lt_imp_le, blast, blast intro: Limit_is_Ord)  
paulson@13290
   668
 apply (simp add: lt_def)  
paulson@13290
   669
 apply (blast intro: Ord_in_Ord Ord_trans finite_Ord_is_nat) 
paulson@13290
   670
apply (erule nat_le_Limit)
paulson@13290
   671
done
paulson@13290
   672
paulson@13290
   673
lemma (in M_triv_axioms) omega_abs [simp]: 
paulson@13290
   674
     "M(a) ==> omega(M,a) <-> a = nat"
paulson@13290
   675
apply (simp add: omega_def) 
paulson@13290
   676
apply (blast intro: Limit_non_Limit_implies_nat dest: naturals_not_limit)
paulson@13290
   677
done
paulson@13290
   678
paulson@13290
   679
lemma (in M_triv_axioms) number1_abs [simp]: 
paulson@13290
   680
     "M(a) ==> number1(M,a) <-> a = 1"
paulson@13290
   681
by (simp add: number1_def) 
paulson@13290
   682
paulson@13290
   683
lemma (in M_triv_axioms) number1_abs [simp]: 
paulson@13290
   684
     "M(a) ==> number2(M,a) <-> a = succ(1)"
paulson@13290
   685
by (simp add: number2_def) 
paulson@13290
   686
paulson@13290
   687
lemma (in M_triv_axioms) number3_abs [simp]: 
paulson@13290
   688
     "M(a) ==> number3(M,a) <-> a = succ(succ(1))"
paulson@13290
   689
by (simp add: number3_def) 
paulson@13290
   690
paulson@13290
   691
text{*Kunen continued to 20...*}
paulson@13290
   692
paulson@13290
   693
(*Could not get this to work.  The \<lambda>x\<in>nat is essential because everything 
paulson@13290
   694
  but the recursion variable must stay unchanged.  But then the recursion
paulson@13290
   695
  equations only hold for x\<in>nat (or in some other set) and not for the 
paulson@13290
   696
  whole of the class M.
paulson@13290
   697
  consts
paulson@13290
   698
    natnumber_aux :: "[i=>o,i] => i"
paulson@13290
   699
paulson@13290
   700
  primrec
paulson@13290
   701
      "natnumber_aux(M,0) = (\<lambda>x\<in>nat. if empty(M,x) then 1 else 0)"
paulson@13290
   702
      "natnumber_aux(M,succ(n)) = 
paulson@13299
   703
	   (\<lambda>x\<in>nat. if (\<exists>y[M]. natnumber_aux(M,n)`y=1 & successor(M,y,x)) 
paulson@13290
   704
		     then 1 else 0)"
paulson@13290
   705
paulson@13290
   706
  constdefs
paulson@13290
   707
    natnumber :: "[i=>o,i,i] => o"
paulson@13290
   708
      "natnumber(M,n,x) == natnumber_aux(M,n)`x = 1"
paulson@13290
   709
paulson@13290
   710
  lemma (in M_triv_axioms) [simp]: 
paulson@13290
   711
       "natnumber(M,0,x) == x=0"
paulson@13290
   712
*)
paulson@13290
   713
paulson@13290
   714
subsection{*Some instances of separation and strong replacement*}
paulson@13290
   715
paulson@13290
   716
locale M_axioms = M_triv_axioms +
paulson@13290
   717
assumes Inter_separation:
paulson@13268
   718
     "M(A) ==> separation(M, \<lambda>x. \<forall>y[M]. y\<in>A --> x\<in>y)"
paulson@13223
   719
  and cartprod_separation:
paulson@13223
   720
     "[| M(A); M(B) |] 
paulson@13298
   721
      ==> separation(M, \<lambda>z. \<exists>x[M]. x\<in>A & (\<exists>y[M]. y\<in>B & pair(M,x,y,z)))"
paulson@13223
   722
  and image_separation:
paulson@13223
   723
     "[| M(A); M(r) |] 
paulson@13268
   724
      ==> separation(M, \<lambda>y. \<exists>p[M]. p\<in>r & (\<exists>x[M]. x\<in>A & pair(M,x,y,p)))"
paulson@13223
   725
  and converse_separation:
paulson@13298
   726
     "M(r) ==> separation(M, 
paulson@13298
   727
         \<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
   728
  and restrict_separation:
paulson@13268
   729
     "M(A) ==> separation(M, \<lambda>z. \<exists>x[M]. x\<in>A & (\<exists>y[M]. pair(M,x,y,z)))"
paulson@13223
   730
  and comp_separation:
paulson@13223
   731
     "[| M(r); M(s) |]
paulson@13268
   732
      ==> separation(M, \<lambda>xz. \<exists>x[M]. \<exists>y[M]. \<exists>z[M]. \<exists>xy[M]. \<exists>yz[M]. 
paulson@13268
   733
		  pair(M,x,z,xz) & pair(M,x,y,xy) & pair(M,y,z,yz) & 
paulson@13268
   734
                  xy\<in>s & yz\<in>r)"
paulson@13223
   735
  and pred_separation:
paulson@13298
   736
     "[| M(r); M(x) |] ==> separation(M, \<lambda>y. \<exists>p[M]. p\<in>r & pair(M,y,x,p))"
paulson@13223
   737
  and Memrel_separation:
paulson@13298
   738
     "separation(M, \<lambda>z. \<exists>x[M]. \<exists>y[M]. pair(M,x,y,z) & x \<in> y)"
paulson@13268
   739
  and funspace_succ_replacement:
paulson@13268
   740
     "M(n) ==> 
paulson@13306
   741
      strong_replacement(M, \<lambda>p z. \<exists>f[M]. \<exists>b[M]. \<exists>nb[M]. \<exists>cnbf[M]. 
paulson@13306
   742
                pair(M,f,b,p) & pair(M,n,b,nb) & is_cons(M,nb,f,cnbf) &
paulson@13306
   743
                upair(M,cnbf,cnbf,z))"
paulson@13223
   744
  and well_ord_iso_separation:
paulson@13223
   745
     "[| M(A); M(f); M(r) |] 
paulson@13299
   746
      ==> separation (M, \<lambda>x. x\<in>A --> (\<exists>y[M]. (\<exists>p[M]. 
paulson@13245
   747
		     fun_apply(M,f,x,y) & pair(M,y,x,p) & p \<in> r)))"
paulson@13306
   748
  and obase_separation:
paulson@13306
   749
     --{*part of the order type formalization*}
paulson@13306
   750
     "[| M(A); M(r) |] 
paulson@13306
   751
      ==> separation(M, \<lambda>a. \<exists>x[M]. \<exists>g[M]. \<exists>mx[M]. \<exists>par[M]. 
paulson@13306
   752
	     ordinal(M,x) & membership(M,x,mx) & pred_set(M,A,a,r,par) &
paulson@13306
   753
	     order_isomorphism(M,par,r,x,mx,g))"
paulson@13223
   754
  and obase_equals_separation:
paulson@13223
   755
     "[| M(A); M(r) |] 
paulson@13223
   756
      ==> separation
paulson@13306
   757
      (M, \<lambda>x. x\<in>A --> ~(\<exists>y[M]. \<exists>g[M]. 
paulson@13306
   758
	      ordinal(M,y) & (\<exists>my[M]. \<exists>pxr[M]. 
paulson@13223
   759
	      membership(M,y,my) & pred_set(M,A,x,r,pxr) &
paulson@13306
   760
	      order_isomorphism(M,pxr,r,y,my,g))))"
paulson@13306
   761
  and omap_replacement:
paulson@13306
   762
     "[| M(A); M(r) |] 
paulson@13306
   763
      ==> strong_replacement(M,
paulson@13306
   764
             \<lambda>a z. \<exists>x[M]. \<exists>g[M]. \<exists>mx[M]. \<exists>par[M]. 
paulson@13306
   765
	     ordinal(M,x) & pair(M,a,x,z) & membership(M,x,mx) & 
paulson@13306
   766
	     pred_set(M,A,a,r,par) & order_isomorphism(M,par,r,x,mx,g))"
paulson@13223
   767
  and is_recfun_separation:
paulson@13223
   768
     --{*for well-founded recursion.  NEEDS RELATIVIZATION*}
paulson@13223
   769
     "[| M(A); M(f); M(g); M(a); M(b) |] 
paulson@13251
   770
     ==> separation(M, \<lambda>x. \<langle>x,a\<rangle> \<in> r & \<langle>x,b\<rangle> \<in> r & f`x \<noteq> g`x)"
paulson@13223
   771
paulson@13223
   772
lemma (in M_axioms) cartprod_iff_lemma:
paulson@13254
   773
     "[| M(C);  \<forall>u[M]. u \<in> C <-> (\<exists>x\<in>A. \<exists>y\<in>B. u = {{x}, {x,y}}); 
paulson@13254
   774
         powerset(M, A \<union> B, p1); powerset(M, p1, p2);  M(p2) |]
paulson@13223
   775
       ==> C = {u \<in> p2 . \<exists>x\<in>A. \<exists>y\<in>B. u = {{x}, {x,y}}}"
paulson@13223
   776
apply (simp add: powerset_def) 
paulson@13254
   777
apply (rule equalityI, clarify, simp)
paulson@13254
   778
 apply (frule transM, assumption) 
paulson@13223
   779
 apply (frule transM, assumption, simp) 
paulson@13223
   780
 apply blast 
paulson@13223
   781
apply clarify
paulson@13223
   782
apply (frule transM, assumption, force) 
paulson@13223
   783
done
paulson@13223
   784
paulson@13223
   785
lemma (in M_axioms) cartprod_iff:
paulson@13223
   786
     "[| M(A); M(B); M(C) |] 
paulson@13223
   787
      ==> cartprod(M,A,B,C) <-> 
paulson@13223
   788
          (\<exists>p1 p2. M(p1) & M(p2) & powerset(M,A Un B,p1) & powerset(M,p1,p2) &
paulson@13223
   789
                   C = {z \<in> p2. \<exists>x\<in>A. \<exists>y\<in>B. z = <x,y>})"
paulson@13223
   790
apply (simp add: Pair_def cartprod_def, safe)
paulson@13223
   791
defer 1 
paulson@13223
   792
  apply (simp add: powerset_def) 
paulson@13223
   793
 apply blast 
paulson@13223
   794
txt{*Final, difficult case: the left-to-right direction of the theorem.*}
paulson@13223
   795
apply (insert power_ax, simp add: power_ax_def) 
paulson@13299
   796
apply (frule_tac x="A Un B" and P="\<lambda>x. rex(M,?Q(x))" in rspec) 
paulson@13299
   797
apply (blast, clarify) 
paulson@13299
   798
apply (drule_tac x=z and P="\<lambda>x. rex(M,?Q(x))" in rspec)
paulson@13299
   799
apply assumption
paulson@13223
   800
apply (blast intro: cartprod_iff_lemma) 
paulson@13223
   801
done
paulson@13223
   802
paulson@13223
   803
lemma (in M_axioms) cartprod_closed_lemma:
paulson@13299
   804
     "[| M(A); M(B) |] ==> \<exists>C[M]. cartprod(M,A,B,C)"
paulson@13223
   805
apply (simp del: cartprod_abs add: cartprod_iff)
paulson@13223
   806
apply (insert power_ax, simp add: power_ax_def) 
paulson@13299
   807
apply (frule_tac x="A Un B" and P="\<lambda>x. rex(M,?Q(x))" in rspec) 
paulson@13299
   808
apply (blast, clarify) 
paulson@13299
   809
apply (drule_tac x=z and P="\<lambda>x. rex(M,?Q(x))" in rspec) 
paulson@13299
   810
apply (blast, clarify)
paulson@13299
   811
apply (intro rexI exI conjI) 
paulson@13299
   812
prefer 5 apply (rule refl) 
paulson@13299
   813
prefer 3 apply assumption
paulson@13299
   814
prefer 3 apply assumption
paulson@13245
   815
apply (insert cartprod_separation [of A B], auto)
paulson@13223
   816
done
paulson@13223
   817
paulson@13223
   818
text{*All the lemmas above are necessary because Powerset is not absolute.
paulson@13223
   819
      I should have used Replacement instead!*}
paulson@13245
   820
lemma (in M_axioms) cartprod_closed [intro,simp]: 
paulson@13223
   821
     "[| M(A); M(B) |] ==> M(A*B)"
paulson@13223
   822
by (frule cartprod_closed_lemma, assumption, force)
paulson@13223
   823
paulson@13268
   824
lemma (in M_axioms) sum_closed [intro,simp]: 
paulson@13268
   825
     "[| M(A); M(B) |] ==> M(A+B)"
paulson@13268
   826
by (simp add: sum_def)
paulson@13268
   827
paulson@13290
   828
paulson@13290
   829
subsubsection {*converse of a relation*}
paulson@13290
   830
paulson@13290
   831
lemma (in M_axioms) M_converse_iff:
paulson@13290
   832
     "M(r) ==> 
paulson@13290
   833
      converse(r) = 
paulson@13290
   834
      {z \<in> Union(Union(r)) * Union(Union(r)). 
paulson@13290
   835
       \<exists>p\<in>r. \<exists>x[M]. \<exists>y[M]. p = \<langle>x,y\<rangle> & z = \<langle>y,x\<rangle>}"
paulson@13290
   836
apply (rule equalityI)
paulson@13290
   837
 prefer 2 apply (blast dest: transM, clarify, simp) 
paulson@13290
   838
apply (simp add: Pair_def) 
paulson@13290
   839
apply (blast dest: transM) 
paulson@13290
   840
done
paulson@13290
   841
paulson@13290
   842
lemma (in M_axioms) converse_closed [intro,simp]: 
paulson@13290
   843
     "M(r) ==> M(converse(r))"
paulson@13290
   844
apply (simp add: M_converse_iff)
paulson@13290
   845
apply (insert converse_separation [of r], simp)
paulson@13290
   846
done
paulson@13290
   847
paulson@13290
   848
lemma (in M_axioms) converse_abs [simp]: 
paulson@13290
   849
     "[| M(r); M(z) |] ==> is_converse(M,r,z) <-> z = converse(r)"
paulson@13290
   850
apply (simp add: is_converse_def)
paulson@13290
   851
apply (rule iffI)
paulson@13290
   852
 prefer 2 apply blast 
paulson@13290
   853
apply (rule M_equalityI)
paulson@13290
   854
  apply simp
paulson@13290
   855
  apply (blast dest: transM)+
paulson@13290
   856
done
paulson@13290
   857
paulson@13290
   858
paulson@13290
   859
subsubsection {*image, preimage, domain, range*}
paulson@13290
   860
paulson@13245
   861
lemma (in M_axioms) image_closed [intro,simp]: 
paulson@13223
   862
     "[| M(A); M(r) |] ==> M(r``A)"
paulson@13223
   863
apply (simp add: image_iff_Collect)
paulson@13245
   864
apply (insert image_separation [of A r], simp) 
paulson@13223
   865
done
paulson@13223
   866
paulson@13223
   867
lemma (in M_axioms) vimage_abs [simp]: 
paulson@13223
   868
     "[| M(r); M(A); M(z) |] ==> pre_image(M,r,A,z) <-> z = r-``A"
paulson@13223
   869
apply (simp add: pre_image_def)
paulson@13223
   870
apply (rule iffI) 
paulson@13223
   871
 apply (blast intro!: equalityI dest: transM, blast) 
paulson@13223
   872
done
paulson@13223
   873
paulson@13245
   874
lemma (in M_axioms) vimage_closed [intro,simp]: 
paulson@13223
   875
     "[| M(A); M(r) |] ==> M(r-``A)"
paulson@13290
   876
by (simp add: vimage_def)
paulson@13290
   877
paulson@13290
   878
paulson@13290
   879
subsubsection{*Domain, range and field*}
paulson@13223
   880
paulson@13223
   881
lemma (in M_axioms) domain_abs [simp]: 
paulson@13223
   882
     "[| M(r); M(z) |] ==> is_domain(M,r,z) <-> z = domain(r)"
paulson@13223
   883
apply (simp add: is_domain_def) 
paulson@13223
   884
apply (blast intro!: equalityI dest: transM) 
paulson@13223
   885
done
paulson@13223
   886
paulson@13245
   887
lemma (in M_axioms) domain_closed [intro,simp]: 
paulson@13223
   888
     "M(r) ==> M(domain(r))"
paulson@13223
   889
apply (simp add: domain_eq_vimage)
paulson@13223
   890
done
paulson@13223
   891
paulson@13223
   892
lemma (in M_axioms) range_abs [simp]: 
paulson@13223
   893
     "[| M(r); M(z) |] ==> is_range(M,r,z) <-> z = range(r)"
paulson@13223
   894
apply (simp add: is_range_def)
paulson@13223
   895
apply (blast intro!: equalityI dest: transM)
paulson@13223
   896
done
paulson@13223
   897
paulson@13245
   898
lemma (in M_axioms) range_closed [intro,simp]: 
paulson@13223
   899
     "M(r) ==> M(range(r))"
paulson@13223
   900
apply (simp add: range_eq_image)
paulson@13223
   901
done
paulson@13223
   902
paulson@13245
   903
lemma (in M_axioms) field_abs [simp]: 
paulson@13245
   904
     "[| M(r); M(z) |] ==> is_field(M,r,z) <-> z = field(r)"
paulson@13245
   905
by (simp add: domain_closed range_closed is_field_def field_def)
paulson@13245
   906
paulson@13245
   907
lemma (in M_axioms) field_closed [intro,simp]: 
paulson@13245
   908
     "M(r) ==> M(field(r))"
paulson@13245
   909
by (simp add: domain_closed range_closed Un_closed field_def) 
paulson@13245
   910
paulson@13245
   911
paulson@13290
   912
subsubsection{*Relations, functions and application*}
paulson@13254
   913
paulson@13223
   914
lemma (in M_axioms) relation_abs [simp]: 
paulson@13223
   915
     "M(r) ==> is_relation(M,r) <-> relation(r)"
paulson@13223
   916
apply (simp add: is_relation_def relation_def) 
paulson@13223
   917
apply (blast dest!: bspec dest: pair_components_in_M)+
paulson@13223
   918
done
paulson@13223
   919
paulson@13223
   920
lemma (in M_axioms) function_abs [simp]: 
paulson@13223
   921
     "M(r) ==> is_function(M,r) <-> function(r)"
paulson@13223
   922
apply (simp add: is_function_def function_def, safe) 
paulson@13223
   923
   apply (frule transM, assumption) 
paulson@13223
   924
  apply (blast dest: pair_components_in_M)+
paulson@13223
   925
done
paulson@13223
   926
paulson@13245
   927
lemma (in M_axioms) apply_closed [intro,simp]: 
paulson@13223
   928
     "[|M(f); M(a)|] ==> M(f`a)"
paulson@13290
   929
by (simp add: apply_def)
paulson@13223
   930
paulson@13223
   931
lemma (in M_axioms) apply_abs: 
paulson@13223
   932
     "[| function(f); M(f); M(y) |] 
paulson@13223
   933
      ==> fun_apply(M,f,x,y) <-> x \<in> domain(f) & f`x = y"
paulson@13223
   934
apply (simp add: fun_apply_def)
paulson@13223
   935
apply (blast intro: function_apply_equality function_apply_Pair) 
paulson@13223
   936
done
paulson@13223
   937
paulson@13223
   938
lemma (in M_axioms) typed_apply_abs: 
paulson@13223
   939
     "[| f \<in> A -> B; M(f); M(y) |] 
paulson@13223
   940
      ==> fun_apply(M,f,x,y) <-> x \<in> A & f`x = y"
paulson@13223
   941
by (simp add: apply_abs fun_is_function domain_of_fun) 
paulson@13223
   942
paulson@13223
   943
lemma (in M_axioms) typed_function_abs [simp]: 
paulson@13223
   944
     "[| M(A); M(f) |] ==> typed_function(M,A,B,f) <-> f \<in> A -> B"
paulson@13223
   945
apply (auto simp add: typed_function_def relation_def Pi_iff) 
paulson@13223
   946
apply (blast dest: pair_components_in_M)+
paulson@13223
   947
done
paulson@13223
   948
paulson@13223
   949
lemma (in M_axioms) injection_abs [simp]: 
paulson@13223
   950
     "[| M(A); M(f) |] ==> injection(M,A,B,f) <-> f \<in> inj(A,B)"
paulson@13223
   951
apply (simp add: injection_def apply_iff inj_def apply_closed)
paulson@13247
   952
apply (blast dest: transM [of _ A]) 
paulson@13223
   953
done
paulson@13223
   954
paulson@13223
   955
lemma (in M_axioms) surjection_abs [simp]: 
paulson@13223
   956
     "[| M(A); M(B); M(f) |] ==> surjection(M,A,B,f) <-> f \<in> surj(A,B)"
paulson@13223
   957
by (simp add: typed_apply_abs surjection_def surj_def)
paulson@13223
   958
paulson@13223
   959
lemma (in M_axioms) bijection_abs [simp]: 
paulson@13223
   960
     "[| M(A); M(B); M(f) |] ==> bijection(M,A,B,f) <-> f \<in> bij(A,B)"
paulson@13223
   961
by (simp add: bijection_def bij_def)
paulson@13223
   962
paulson@13223
   963
paulson@13290
   964
subsubsection{*Composition of relations*}
paulson@13223
   965
paulson@13223
   966
lemma (in M_axioms) M_comp_iff:
paulson@13223
   967
     "[| M(r); M(s) |] 
paulson@13223
   968
      ==> r O s = 
paulson@13223
   969
          {xz \<in> domain(s) * range(r).  
paulson@13268
   970
            \<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
   971
apply (simp add: comp_def)
paulson@13223
   972
apply (rule equalityI) 
paulson@13247
   973
 apply clarify 
paulson@13247
   974
 apply simp 
paulson@13223
   975
 apply  (blast dest:  transM)+
paulson@13223
   976
done
paulson@13223
   977
paulson@13245
   978
lemma (in M_axioms) comp_closed [intro,simp]: 
paulson@13223
   979
     "[| M(r); M(s) |] ==> M(r O s)"
paulson@13223
   980
apply (simp add: M_comp_iff)
paulson@13245
   981
apply (insert comp_separation [of r s], simp) 
paulson@13245
   982
done
paulson@13245
   983
paulson@13245
   984
lemma (in M_axioms) composition_abs [simp]: 
paulson@13245
   985
     "[| M(r); M(s); M(t) |] 
paulson@13245
   986
      ==> composition(M,r,s,t) <-> t = r O s"
paulson@13247
   987
apply safe
paulson@13245
   988
 txt{*Proving @{term "composition(M, r, s, r O s)"}*}
paulson@13245
   989
 prefer 2 
paulson@13245
   990
 apply (simp add: composition_def comp_def)
paulson@13245
   991
 apply (blast dest: transM) 
paulson@13245
   992
txt{*Opposite implication*}
paulson@13245
   993
apply (rule M_equalityI)
paulson@13245
   994
  apply (simp add: composition_def comp_def)
paulson@13245
   995
  apply (blast del: allE dest: transM)+
paulson@13223
   996
done
paulson@13223
   997
paulson@13290
   998
text{*no longer needed*}
paulson@13290
   999
lemma (in M_axioms) restriction_is_function: 
paulson@13290
  1000
     "[| restriction(M,f,A,z); function(f); M(f); M(A); M(z) |] 
paulson@13290
  1001
      ==> function(z)"
paulson@13290
  1002
apply (rotate_tac 1)
paulson@13290
  1003
apply (simp add: restriction_def ball_iff_equiv) 
paulson@13290
  1004
apply (unfold function_def, blast) 
paulson@13269
  1005
done
paulson@13269
  1006
paulson@13290
  1007
lemma (in M_axioms) restriction_abs [simp]: 
paulson@13290
  1008
     "[| M(f); M(A); M(z) |] 
paulson@13290
  1009
      ==> restriction(M,f,A,z) <-> z = restrict(f,A)"
paulson@13290
  1010
apply (simp add: ball_iff_equiv restriction_def restrict_def)
paulson@13290
  1011
apply (blast intro!: equalityI dest: transM) 
paulson@13290
  1012
done
paulson@13290
  1013
paulson@13223
  1014
paulson@13290
  1015
lemma (in M_axioms) M_restrict_iff:
paulson@13290
  1016
     "M(r) ==> restrict(r,A) = {z \<in> r . \<exists>x\<in>A. \<exists>y[M]. z = \<langle>x, y\<rangle>}"
paulson@13290
  1017
by (simp add: restrict_def, blast dest: transM)
paulson@13290
  1018
paulson@13290
  1019
lemma (in M_axioms) restrict_closed [intro,simp]: 
paulson@13290
  1020
     "[| M(A); M(r) |] ==> M(restrict(r,A))"
paulson@13290
  1021
apply (simp add: M_restrict_iff)
paulson@13290
  1022
apply (insert restrict_separation [of A], simp) 
paulson@13290
  1023
done
paulson@13223
  1024
paulson@13223
  1025
lemma (in M_axioms) Inter_abs [simp]: 
paulson@13223
  1026
     "[| M(A); M(z) |] ==> big_inter(M,A,z) <-> z = Inter(A)"
paulson@13223
  1027
apply (simp add: big_inter_def Inter_def) 
paulson@13223
  1028
apply (blast intro!: equalityI dest: transM) 
paulson@13223
  1029
done
paulson@13223
  1030
paulson@13245
  1031
lemma (in M_axioms) Inter_closed [intro,simp]:
paulson@13223
  1032
     "M(A) ==> M(Inter(A))"
paulson@13245
  1033
by (insert Inter_separation, simp add: Inter_def)
paulson@13223
  1034
paulson@13245
  1035
lemma (in M_axioms) Int_closed [intro,simp]:
paulson@13223
  1036
     "[| M(A); M(B) |] ==> M(A Int B)"
paulson@13223
  1037
apply (subgoal_tac "M({A,B})")
paulson@13247
  1038
apply (frule Inter_closed, force+) 
paulson@13223
  1039
done
paulson@13223
  1040
paulson@13290
  1041
subsubsection{*Functions and function space*}
paulson@13268
  1042
paulson@13245
  1043
text{*M contains all finite functions*}
paulson@13245
  1044
lemma (in M_axioms) finite_fun_closed_lemma [rule_format]: 
paulson@13245
  1045
     "[| n \<in> nat; M(A) |] ==> \<forall>f \<in> n -> A. M(f)"
paulson@13245
  1046
apply (induct_tac n, simp)
paulson@13245
  1047
apply (rule ballI)  
paulson@13245
  1048
apply (simp add: succ_def) 
paulson@13245
  1049
apply (frule fun_cons_restrict_eq)
paulson@13245
  1050
apply (erule ssubst) 
paulson@13245
  1051
apply (subgoal_tac "M(f`x) & restrict(f,x) \<in> x -> A") 
paulson@13245
  1052
 apply (simp add: cons_closed nat_into_M apply_closed) 
paulson@13245
  1053
apply (blast intro: apply_funtype transM restrict_type2) 
paulson@13245
  1054
done
paulson@13245
  1055
paulson@13245
  1056
lemma (in M_axioms) finite_fun_closed [rule_format]: 
paulson@13245
  1057
     "[| f \<in> n -> A; n \<in> nat; M(A) |] ==> M(f)"
paulson@13245
  1058
by (blast intro: finite_fun_closed_lemma) 
paulson@13245
  1059
paulson@13268
  1060
text{*The assumption @{term "M(A->B)"} is unusual, but essential: in 
paulson@13268
  1061
all but trivial cases, A->B cannot be expected to belong to @{term M}.*}
paulson@13268
  1062
lemma (in M_axioms) is_funspace_abs [simp]:
paulson@13268
  1063
     "[|M(A); M(B); M(F); M(A->B)|] ==> is_funspace(M,A,B,F) <-> F = A->B";
paulson@13268
  1064
apply (simp add: is_funspace_def)
paulson@13268
  1065
apply (rule iffI)
paulson@13268
  1066
 prefer 2 apply blast 
paulson@13268
  1067
apply (rule M_equalityI)
paulson@13268
  1068
  apply simp_all
paulson@13268
  1069
done
paulson@13268
  1070
paulson@13268
  1071
lemma (in M_axioms) succ_fun_eq2:
paulson@13268
  1072
     "[|M(B); M(n->B)|] ==>
paulson@13268
  1073
      succ(n) -> B = 
paulson@13268
  1074
      \<Union>{z. p \<in> (n->B)*B, \<exists>f[M]. \<exists>b[M]. p = <f,b> & z = {cons(<n,b>, f)}}"
paulson@13268
  1075
apply (simp add: succ_fun_eq)
paulson@13268
  1076
apply (blast dest: transM)  
paulson@13268
  1077
done
paulson@13268
  1078
paulson@13268
  1079
lemma (in M_axioms) funspace_succ:
paulson@13268
  1080
     "[|M(n); M(B); M(n->B) |] ==> M(succ(n) -> B)"
paulson@13306
  1081
apply (insert funspace_succ_replacement [of n], simp) 
paulson@13268
  1082
apply (force simp add: succ_fun_eq2 univalent_def) 
paulson@13268
  1083
done
paulson@13268
  1084
paulson@13268
  1085
text{*@{term M} contains all finite function spaces.  Needed to prove the
paulson@13268
  1086
absoluteness of transitive closure.*}
paulson@13268
  1087
lemma (in M_axioms) finite_funspace_closed [intro,simp]:
paulson@13268
  1088
     "[|n\<in>nat; M(B)|] ==> M(n->B)"
paulson@13268
  1089
apply (induct_tac n, simp)
paulson@13268
  1090
apply (simp add: funspace_succ nat_into_M) 
paulson@13268
  1091
done
paulson@13268
  1092
paulson@13223
  1093
end