src/ZF/Constructible/Relative.thy
author paulson
Thu Jul 25 18:29:04 2002 +0200 (2002-07-25)
changeset 13423 7ec771711c09
parent 13418 7c0ba9dba978
child 13428 99e52e78eb65
permissions -rw-r--r--
More lemmas, working towards relativization of "satisfies"
paulson@13223
     1
header {*Relativization and Absoluteness*}
paulson@13223
     2
paulson@13223
     3
theory Relative = Main:
paulson@13223
     4
paulson@13423
     5
(*????????????????for IFOL.thy????????????????*)
paulson@13423
     6
lemma eq_commute: "a=b <-> b=a"
paulson@13423
     7
by blast 
paulson@13423
     8
paulson@13223
     9
subsection{* Relativized versions of standard set-theoretic concepts *}
paulson@13223
    10
paulson@13223
    11
constdefs
paulson@13223
    12
  empty :: "[i=>o,i] => o"
paulson@13254
    13
    "empty(M,z) == \<forall>x[M]. x \<notin> z"
paulson@13223
    14
paulson@13223
    15
  subset :: "[i=>o,i,i] => o"
paulson@13298
    16
    "subset(M,A,B) == \<forall>x[M]. x\<in>A --> x \<in> B"
paulson@13223
    17
paulson@13223
    18
  upair :: "[i=>o,i,i,i] => o"
paulson@13298
    19
    "upair(M,a,b,z) == a \<in> z & b \<in> z & (\<forall>x[M]. x\<in>z --> x = a | x = b)"
paulson@13223
    20
paulson@13223
    21
  pair :: "[i=>o,i,i,i] => o"
paulson@13254
    22
    "pair(M,a,b,z) == \<exists>x[M]. upair(M,a,a,x) & 
paulson@13254
    23
                          (\<exists>y[M]. upair(M,a,b,y) & upair(M,x,y,z))"
paulson@13223
    24
paulson@13306
    25
paulson@13245
    26
  union :: "[i=>o,i,i,i] => o"
paulson@13254
    27
    "union(M,a,b,z) == \<forall>x[M]. x \<in> z <-> x \<in> a | x \<in> b"
paulson@13245
    28
paulson@13306
    29
  is_cons :: "[i=>o,i,i,i] => o"
paulson@13306
    30
    "is_cons(M,a,b,z) == \<exists>x[M]. upair(M,a,a,x) & union(M,x,b,z)"
paulson@13306
    31
paulson@13223
    32
  successor :: "[i=>o,i,i] => o"
paulson@13306
    33
    "successor(M,a,z) == is_cons(M,a,a,z)"
paulson@13223
    34
paulson@13363
    35
  number1 :: "[i=>o,i] => o"
paulson@13363
    36
    "number1(M,a) == (\<exists>x[M]. empty(M,x) & successor(M,x,a))"
paulson@13363
    37
paulson@13363
    38
  number2 :: "[i=>o,i] => o"
paulson@13363
    39
    "number2(M,a) == (\<exists>x[M]. number1(M,x) & successor(M,x,a))"
paulson@13363
    40
paulson@13363
    41
  number3 :: "[i=>o,i] => o"
paulson@13363
    42
    "number3(M,a) == (\<exists>x[M]. number2(M,x) & successor(M,x,a))"
paulson@13363
    43
paulson@13223
    44
  powerset :: "[i=>o,i,i] => o"
paulson@13254
    45
    "powerset(M,A,z) == \<forall>x[M]. x \<in> z <-> subset(M,x,A)"
paulson@13223
    46
paulson@13223
    47
  inter :: "[i=>o,i,i,i] => o"
paulson@13254
    48
    "inter(M,a,b,z) == \<forall>x[M]. x \<in> z <-> x \<in> a & x \<in> b"
paulson@13223
    49
paulson@13223
    50
  setdiff :: "[i=>o,i,i,i] => o"
paulson@13254
    51
    "setdiff(M,a,b,z) == \<forall>x[M]. x \<in> z <-> x \<in> a & x \<notin> b"
paulson@13223
    52
paulson@13223
    53
  big_union :: "[i=>o,i,i] => o"
paulson@13298
    54
    "big_union(M,A,z) == \<forall>x[M]. x \<in> z <-> (\<exists>y[M]. y\<in>A & x \<in> y)"
paulson@13223
    55
paulson@13223
    56
  big_inter :: "[i=>o,i,i] => o"
paulson@13223
    57
    "big_inter(M,A,z) == 
paulson@13223
    58
             (A=0 --> z=0) &
paulson@13298
    59
	     (A\<noteq>0 --> (\<forall>x[M]. x \<in> z <-> (\<forall>y[M]. y\<in>A --> x \<in> y)))"
paulson@13223
    60
paulson@13223
    61
  cartprod :: "[i=>o,i,i,i] => o"
paulson@13223
    62
    "cartprod(M,A,B,z) == 
paulson@13298
    63
	\<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
    64
paulson@13350
    65
  is_sum :: "[i=>o,i,i,i] => o"
paulson@13350
    66
    "is_sum(M,A,B,Z) == 
paulson@13350
    67
       \<exists>A0[M]. \<exists>n1[M]. \<exists>s1[M]. \<exists>B1[M]. 
paulson@13350
    68
       number1(M,n1) & cartprod(M,n1,A,A0) & upair(M,n1,n1,s1) &
paulson@13350
    69
       cartprod(M,s1,B,B1) & union(M,A0,B1,Z)"
paulson@13350
    70
paulson@13397
    71
  is_Inl :: "[i=>o,i,i] => o"
paulson@13397
    72
    "is_Inl(M,a,z) == \<exists>zero[M]. empty(M,zero) & pair(M,zero,a,z)"
paulson@13397
    73
paulson@13397
    74
  is_Inr :: "[i=>o,i,i] => o"
paulson@13397
    75
    "is_Inr(M,a,z) == \<exists>n1[M]. number1(M,n1) & pair(M,n1,a,z)"
paulson@13397
    76
paulson@13223
    77
  is_converse :: "[i=>o,i,i] => o"
paulson@13223
    78
    "is_converse(M,r,z) == 
paulson@13299
    79
	\<forall>x[M]. x \<in> z <-> 
paulson@13299
    80
             (\<exists>w[M]. w\<in>r & (\<exists>u[M]. \<exists>v[M]. pair(M,u,v,w) & pair(M,v,u,x)))"
paulson@13223
    81
paulson@13223
    82
  pre_image :: "[i=>o,i,i,i] => o"
paulson@13223
    83
    "pre_image(M,r,A,z) == 
paulson@13299
    84
	\<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
    85
paulson@13223
    86
  is_domain :: "[i=>o,i,i] => o"
paulson@13223
    87
    "is_domain(M,r,z) == 
paulson@13299
    88
	\<forall>x[M]. (x \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>y[M]. pair(M,x,y,w))))"
paulson@13223
    89
paulson@13223
    90
  image :: "[i=>o,i,i,i] => o"
paulson@13223
    91
    "image(M,r,A,z) == 
paulson@13299
    92
        \<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
    93
paulson@13223
    94
  is_range :: "[i=>o,i,i] => o"
paulson@13223
    95
    --{*the cleaner 
paulson@13299
    96
      @{term "\<exists>r'[M]. is_converse(M,r,r') & is_domain(M,r',z)"}
paulson@13223
    97
      unfortunately needs an instance of separation in order to prove 
paulson@13223
    98
        @{term "M(converse(r))"}.*}
paulson@13223
    99
    "is_range(M,r,z) == 
paulson@13299
   100
	\<forall>y[M]. (y \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>x[M]. pair(M,x,y,w))))"
paulson@13223
   101
paulson@13245
   102
  is_field :: "[i=>o,i,i] => o"
paulson@13245
   103
    "is_field(M,r,z) == 
paulson@13298
   104
	\<exists>dr[M]. is_domain(M,r,dr) & 
paulson@13298
   105
            (\<exists>rr[M]. is_range(M,r,rr) & union(M,dr,rr,z))"
paulson@13245
   106
paulson@13223
   107
  is_relation :: "[i=>o,i] => o"
paulson@13223
   108
    "is_relation(M,r) == 
paulson@13298
   109
        (\<forall>z[M]. z\<in>r --> (\<exists>x[M]. \<exists>y[M]. pair(M,x,y,z)))"
paulson@13223
   110
paulson@13223
   111
  is_function :: "[i=>o,i] => o"
paulson@13223
   112
    "is_function(M,r) == 
paulson@13299
   113
	\<forall>x[M]. \<forall>y[M]. \<forall>y'[M]. \<forall>p[M]. \<forall>p'[M]. 
paulson@13299
   114
           pair(M,x,y,p) --> pair(M,x,y',p') --> p\<in>r --> p'\<in>r --> y=y'"
paulson@13223
   115
paulson@13223
   116
  fun_apply :: "[i=>o,i,i,i] => o"
paulson@13223
   117
    "fun_apply(M,f,x,y) == 
paulson@13352
   118
        (\<exists>xs[M]. \<exists>fxs[M]. 
paulson@13352
   119
         upair(M,x,x,xs) & image(M,f,xs,fxs) & big_union(M,fxs,y))"
paulson@13223
   120
paulson@13223
   121
  typed_function :: "[i=>o,i,i,i] => o"
paulson@13223
   122
    "typed_function(M,A,B,r) == 
paulson@13223
   123
        is_function(M,r) & is_relation(M,r) & is_domain(M,r,A) &
paulson@13306
   124
        (\<forall>u[M]. u\<in>r --> (\<forall>x[M]. \<forall>y[M]. pair(M,x,y,u) --> y\<in>B))"
paulson@13223
   125
paulson@13268
   126
  is_funspace :: "[i=>o,i,i,i] => o"
paulson@13268
   127
    "is_funspace(M,A,B,F) == 
paulson@13268
   128
        \<forall>f[M]. f \<in> F <-> typed_function(M,A,B,f)"
paulson@13268
   129
paulson@13245
   130
  composition :: "[i=>o,i,i,i] => o"
paulson@13245
   131
    "composition(M,r,s,t) == 
paulson@13306
   132
        \<forall>p[M]. p \<in> t <-> 
paulson@13323
   133
               (\<exists>x[M]. \<exists>y[M]. \<exists>z[M]. \<exists>xy[M]. \<exists>yz[M]. 
paulson@13323
   134
                pair(M,x,z,p) & pair(M,x,y,xy) & pair(M,y,z,yz) & 
paulson@13323
   135
                xy \<in> s & yz \<in> r)"
paulson@13245
   136
paulson@13223
   137
  injection :: "[i=>o,i,i,i] => o"
paulson@13223
   138
    "injection(M,A,B,f) == 
paulson@13223
   139
	typed_function(M,A,B,f) &
paulson@13306
   140
        (\<forall>x[M]. \<forall>x'[M]. \<forall>y[M]. \<forall>p[M]. \<forall>p'[M]. 
paulson@13306
   141
          pair(M,x,y,p) --> pair(M,x',y,p') --> p\<in>f --> p'\<in>f --> x=x')"
paulson@13223
   142
paulson@13223
   143
  surjection :: "[i=>o,i,i,i] => o"
paulson@13223
   144
    "surjection(M,A,B,f) == 
paulson@13223
   145
        typed_function(M,A,B,f) &
paulson@13299
   146
        (\<forall>y[M]. y\<in>B --> (\<exists>x[M]. x\<in>A & fun_apply(M,f,x,y)))"
paulson@13223
   147
paulson@13223
   148
  bijection :: "[i=>o,i,i,i] => o"
paulson@13223
   149
    "bijection(M,A,B,f) == injection(M,A,B,f) & surjection(M,A,B,f)"
paulson@13223
   150
paulson@13223
   151
  restriction :: "[i=>o,i,i,i] => o"
paulson@13223
   152
    "restriction(M,r,A,z) == 
paulson@13306
   153
	\<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
   154
paulson@13223
   155
  transitive_set :: "[i=>o,i] => o"
paulson@13299
   156
    "transitive_set(M,a) == \<forall>x[M]. x\<in>a --> subset(M,x,a)"
paulson@13223
   157
paulson@13223
   158
  ordinal :: "[i=>o,i] => o"
paulson@13223
   159
     --{*an ordinal is a transitive set of transitive sets*}
paulson@13299
   160
    "ordinal(M,a) == transitive_set(M,a) & (\<forall>x[M]. x\<in>a --> transitive_set(M,x))"
paulson@13223
   161
paulson@13223
   162
  limit_ordinal :: "[i=>o,i] => o"
paulson@13223
   163
    --{*a limit ordinal is a non-empty, successor-closed ordinal*}
paulson@13223
   164
    "limit_ordinal(M,a) == 
paulson@13223
   165
	ordinal(M,a) & ~ empty(M,a) & 
paulson@13299
   166
        (\<forall>x[M]. x\<in>a --> (\<exists>y[M]. y\<in>a & successor(M,x,y)))"
paulson@13223
   167
paulson@13223
   168
  successor_ordinal :: "[i=>o,i] => o"
paulson@13223
   169
    --{*a successor ordinal is any ordinal that is neither empty nor limit*}
paulson@13223
   170
    "successor_ordinal(M,a) == 
paulson@13223
   171
	ordinal(M,a) & ~ empty(M,a) & ~ limit_ordinal(M,a)"
paulson@13223
   172
paulson@13223
   173
  finite_ordinal :: "[i=>o,i] => o"
paulson@13223
   174
    --{*an ordinal is finite if neither it nor any of its elements are limit*}
paulson@13223
   175
    "finite_ordinal(M,a) == 
paulson@13223
   176
	ordinal(M,a) & ~ limit_ordinal(M,a) & 
paulson@13299
   177
        (\<forall>x[M]. x\<in>a --> ~ limit_ordinal(M,x))"
paulson@13223
   178
paulson@13223
   179
  omega :: "[i=>o,i] => o"
paulson@13223
   180
    --{*omega is a limit ordinal none of whose elements are limit*}
paulson@13299
   181
    "omega(M,a) == limit_ordinal(M,a) & (\<forall>x[M]. x\<in>a --> ~ limit_ordinal(M,x))"
paulson@13223
   182
paulson@13350
   183
  is_quasinat :: "[i=>o,i] => o"
paulson@13350
   184
    "is_quasinat(M,z) == empty(M,z) | (\<exists>m[M]. successor(M,m,z))"
paulson@13350
   185
paulson@13350
   186
  is_nat_case :: "[i=>o, i, [i,i]=>o, i, i] => o"
paulson@13350
   187
    "is_nat_case(M, a, is_b, k, z) == 
paulson@13350
   188
       (empty(M,k) --> z=a) &
paulson@13350
   189
       (\<forall>m[M]. successor(M,m,k) --> is_b(m,z)) &
paulson@13363
   190
       (is_quasinat(M,k) | empty(M,z))"
paulson@13350
   191
paulson@13353
   192
  relativize1 :: "[i=>o, [i,i]=>o, i=>i] => o"
paulson@13353
   193
    "relativize1(M,is_f,f) == \<forall>x[M]. \<forall>y[M]. is_f(x,y) <-> y = f(x)"
paulson@13353
   194
paulson@13423
   195
  Relativize1 :: "[i=>o, i, [i,i]=>o, i=>i] => o"
paulson@13423
   196
    --{*as above, but typed*}
paulson@13423
   197
    "Relativize1(M,A,is_f,f) == 
paulson@13423
   198
        \<forall>x[M]. \<forall>y[M]. x\<in>A --> is_f(x,y) <-> y = f(x)"
paulson@13423
   199
paulson@13353
   200
  relativize2 :: "[i=>o, [i,i,i]=>o, [i,i]=>i] => o"
paulson@13353
   201
    "relativize2(M,is_f,f) == \<forall>x[M]. \<forall>y[M]. \<forall>z[M]. is_f(x,y,z) <-> z = f(x,y)"
paulson@13353
   202
paulson@13423
   203
  Relativize2 :: "[i=>o, i, i, [i,i,i]=>o, [i,i]=>i] => o"
paulson@13423
   204
    "Relativize2(M,A,B,is_f,f) ==
paulson@13423
   205
        \<forall>x[M]. \<forall>y[M]. \<forall>z[M]. x\<in>A --> y\<in>B --> is_f(x,y,z) <-> z = f(x,y)"
paulson@13423
   206
paulson@13353
   207
  relativize3 :: "[i=>o, [i,i,i,i]=>o, [i,i,i]=>i] => o"
paulson@13353
   208
    "relativize3(M,is_f,f) == 
paulson@13353
   209
       \<forall>x[M]. \<forall>y[M]. \<forall>z[M]. \<forall>u[M]. is_f(x,y,z,u) <-> u = f(x,y,z)"
paulson@13353
   210
paulson@13423
   211
  Relativize3 :: "[i=>o, i, i, i, [i,i,i,i]=>o, [i,i,i]=>i] => o"
paulson@13423
   212
    "Relativize3(M,A,B,C,is_f,f) == 
paulson@13423
   213
       \<forall>x[M]. \<forall>y[M]. \<forall>z[M]. \<forall>u[M]. 
paulson@13423
   214
         x\<in>A --> y\<in>B --> z\<in>C --> is_f(x,y,z,u) <-> u = f(x,y,z)"
paulson@13423
   215
paulson@13423
   216
  relativize4 :: "[i=>o, [i,i,i,i,i]=>o, [i,i,i,i]=>i] => o"
paulson@13423
   217
    "relativize4(M,is_f,f) == 
paulson@13423
   218
       \<forall>u[M]. \<forall>x[M]. \<forall>y[M]. \<forall>z[M]. \<forall>a[M]. is_f(u,x,y,z,a) <-> a = f(u,x,y,z)"
paulson@13423
   219
paulson@13423
   220
paulson@13423
   221
text{*Useful when absoluteness reasoning has replaced the predicates by terms*}
paulson@13423
   222
lemma triv_Relativize1:
paulson@13423
   223
     "Relativize1(M, A, \<lambda>x y. y = f(x), f)"
paulson@13423
   224
by (simp add: Relativize1_def) 
paulson@13423
   225
paulson@13423
   226
lemma triv_Relativize2:
paulson@13423
   227
     "Relativize2(M, A, B, \<lambda>x y a. a = f(x,y), f)"
paulson@13423
   228
by (simp add: Relativize2_def) 
paulson@13423
   229
paulson@13223
   230
paulson@13223
   231
subsection {*The relativized ZF axioms*}
paulson@13223
   232
constdefs
paulson@13223
   233
paulson@13223
   234
  extensionality :: "(i=>o) => o"
paulson@13223
   235
    "extensionality(M) == 
paulson@13290
   236
	\<forall>x[M]. \<forall>y[M]. (\<forall>z[M]. z \<in> x <-> z \<in> y) --> x=y"
paulson@13223
   237
paulson@13223
   238
  separation :: "[i=>o, i=>o] => o"
paulson@13223
   239
    --{*Big problem: the formula @{text P} should only involve parameters
paulson@13223
   240
        belonging to @{text M}.  Don't see how to enforce that.*}
paulson@13223
   241
    "separation(M,P) == 
paulson@13290
   242
	\<forall>z[M]. \<exists>y[M]. \<forall>x[M]. x \<in> y <-> x \<in> z & P(x)"
paulson@13223
   243
paulson@13223
   244
  upair_ax :: "(i=>o) => o"
paulson@13299
   245
    "upair_ax(M) == \<forall>x y. M(x) --> M(y) --> (\<exists>z[M]. upair(M,x,y,z))"
paulson@13223
   246
paulson@13223
   247
  Union_ax :: "(i=>o) => o"
paulson@13299
   248
    "Union_ax(M) == \<forall>x[M]. (\<exists>z[M]. big_union(M,x,z))"
paulson@13223
   249
paulson@13223
   250
  power_ax :: "(i=>o) => o"
paulson@13299
   251
    "power_ax(M) == \<forall>x[M]. (\<exists>z[M]. powerset(M,x,z))"
paulson@13223
   252
paulson@13223
   253
  univalent :: "[i=>o, i, [i,i]=>o] => o"
paulson@13223
   254
    "univalent(M,A,P) == 
paulson@13299
   255
	(\<forall>x[M]. x\<in>A --> (\<forall>y z. M(y) --> M(z) --> P(x,y) & P(x,z) --> y=z))"
paulson@13223
   256
paulson@13223
   257
  replacement :: "[i=>o, [i,i]=>o] => o"
paulson@13223
   258
    "replacement(M,P) == 
paulson@13299
   259
      \<forall>A[M]. univalent(M,A,P) -->
paulson@13299
   260
      (\<exists>Y[M]. (\<forall>b[M]. ((\<exists>x[M]. x\<in>A & P(x,b)) --> b \<in> Y)))"
paulson@13223
   261
paulson@13223
   262
  strong_replacement :: "[i=>o, [i,i]=>o] => o"
paulson@13223
   263
    "strong_replacement(M,P) == 
paulson@13299
   264
      \<forall>A[M]. univalent(M,A,P) -->
paulson@13299
   265
      (\<exists>Y[M]. (\<forall>b[M]. (b \<in> Y <-> (\<exists>x[M]. x\<in>A & P(x,b)))))"
paulson@13223
   266
paulson@13223
   267
  foundation_ax :: "(i=>o) => o"
paulson@13223
   268
    "foundation_ax(M) == 
paulson@13299
   269
	\<forall>x[M]. (\<exists>y\<in>x. M(y))
paulson@13299
   270
                 --> (\<exists>y[M]. y\<in>x & ~(\<exists>z[M]. z\<in>x & z \<in> y))"
paulson@13223
   271
paulson@13223
   272
paulson@13223
   273
subsection{*A trivial consistency proof for $V_\omega$ *}
paulson@13223
   274
paulson@13223
   275
text{*We prove that $V_\omega$ 
paulson@13223
   276
      (or @{text univ} in Isabelle) satisfies some ZF axioms.
paulson@13223
   277
     Kunen, Theorem IV 3.13, page 123.*}
paulson@13223
   278
paulson@13223
   279
lemma univ0_downwards_mem: "[| y \<in> x; x \<in> univ(0) |] ==> y \<in> univ(0)"
paulson@13223
   280
apply (insert Transset_univ [OF Transset_0])  
paulson@13223
   281
apply (simp add: Transset_def, blast) 
paulson@13223
   282
done
paulson@13223
   283
paulson@13223
   284
lemma univ0_Ball_abs [simp]: 
paulson@13223
   285
     "A \<in> univ(0) ==> (\<forall>x\<in>A. x \<in> univ(0) --> P(x)) <-> (\<forall>x\<in>A. P(x))" 
paulson@13223
   286
by (blast intro: univ0_downwards_mem) 
paulson@13223
   287
paulson@13223
   288
lemma univ0_Bex_abs [simp]: 
paulson@13223
   289
     "A \<in> univ(0) ==> (\<exists>x\<in>A. x \<in> univ(0) & P(x)) <-> (\<exists>x\<in>A. P(x))" 
paulson@13223
   290
by (blast intro: univ0_downwards_mem) 
paulson@13223
   291
paulson@13223
   292
text{*Congruence rule for separation: can assume the variable is in @{text M}*}
paulson@13254
   293
lemma separation_cong [cong]:
paulson@13339
   294
     "(!!x. M(x) ==> P(x) <-> P'(x)) 
paulson@13339
   295
      ==> separation(M, %x. P(x)) <-> separation(M, %x. P'(x))"
paulson@13223
   296
by (simp add: separation_def) 
paulson@13223
   297
paulson@13223
   298
text{*Congruence rules for replacement*}
paulson@13254
   299
lemma univalent_cong [cong]:
paulson@13223
   300
     "[| A=A'; !!x y. [| x\<in>A; M(x); M(y) |] ==> P(x,y) <-> P'(x,y) |] 
paulson@13339
   301
      ==> univalent(M, A, %x y. P(x,y)) <-> univalent(M, A', %x y. P'(x,y))"
paulson@13223
   302
by (simp add: univalent_def) 
paulson@13223
   303
paulson@13254
   304
lemma strong_replacement_cong [cong]:
paulson@13223
   305
     "[| !!x y. [| M(x); M(y) |] ==> P(x,y) <-> P'(x,y) |] 
paulson@13339
   306
      ==> strong_replacement(M, %x y. P(x,y)) <-> 
paulson@13339
   307
          strong_replacement(M, %x y. P'(x,y))" 
paulson@13223
   308
by (simp add: strong_replacement_def) 
paulson@13223
   309
paulson@13223
   310
text{*The extensionality axiom*}
paulson@13223
   311
lemma "extensionality(\<lambda>x. x \<in> univ(0))"
paulson@13223
   312
apply (simp add: extensionality_def)
paulson@13223
   313
apply (blast intro: univ0_downwards_mem) 
paulson@13223
   314
done
paulson@13223
   315
paulson@13223
   316
text{*The separation axiom requires some lemmas*}
paulson@13223
   317
lemma Collect_in_Vfrom:
paulson@13223
   318
     "[| X \<in> Vfrom(A,j);  Transset(A) |] ==> Collect(X,P) \<in> Vfrom(A, succ(j))"
paulson@13223
   319
apply (drule Transset_Vfrom)
paulson@13223
   320
apply (rule subset_mem_Vfrom)
paulson@13223
   321
apply (unfold Transset_def, blast)
paulson@13223
   322
done
paulson@13223
   323
paulson@13223
   324
lemma Collect_in_VLimit:
paulson@13223
   325
     "[| X \<in> Vfrom(A,i);  Limit(i);  Transset(A) |] 
paulson@13223
   326
      ==> Collect(X,P) \<in> Vfrom(A,i)"
paulson@13223
   327
apply (rule Limit_VfromE, assumption+)
paulson@13223
   328
apply (blast intro: Limit_has_succ VfromI Collect_in_Vfrom)
paulson@13223
   329
done
paulson@13223
   330
paulson@13223
   331
lemma Collect_in_univ:
paulson@13223
   332
     "[| X \<in> univ(A);  Transset(A) |] ==> Collect(X,P) \<in> univ(A)"
paulson@13223
   333
by (simp add: univ_def Collect_in_VLimit Limit_nat)
paulson@13223
   334
paulson@13223
   335
lemma "separation(\<lambda>x. x \<in> univ(0), P)"
paulson@13290
   336
apply (simp add: separation_def, clarify) 
paulson@13339
   337
apply (rule_tac x = "Collect(z,P)" in bexI) 
paulson@13290
   338
apply (blast intro: Collect_in_univ Transset_0)+
paulson@13223
   339
done
paulson@13223
   340
paulson@13223
   341
text{*Unordered pairing axiom*}
paulson@13223
   342
lemma "upair_ax(\<lambda>x. x \<in> univ(0))"
paulson@13223
   343
apply (simp add: upair_ax_def upair_def)  
paulson@13223
   344
apply (blast intro: doubleton_in_univ) 
paulson@13223
   345
done
paulson@13223
   346
paulson@13223
   347
text{*Union axiom*}
paulson@13223
   348
lemma "Union_ax(\<lambda>x. x \<in> univ(0))"  
paulson@13299
   349
apply (simp add: Union_ax_def big_union_def, clarify) 
paulson@13299
   350
apply (rule_tac x="\<Union>x" in bexI)  
paulson@13299
   351
 apply (blast intro: univ0_downwards_mem)
paulson@13299
   352
apply (blast intro: Union_in_univ Transset_0) 
paulson@13223
   353
done
paulson@13223
   354
paulson@13223
   355
text{*Powerset axiom*}
paulson@13223
   356
paulson@13223
   357
lemma Pow_in_univ:
paulson@13223
   358
     "[| X \<in> univ(A);  Transset(A) |] ==> Pow(X) \<in> univ(A)"
paulson@13223
   359
apply (simp add: univ_def Pow_in_VLimit Limit_nat)
paulson@13223
   360
done
paulson@13223
   361
paulson@13223
   362
lemma "power_ax(\<lambda>x. x \<in> univ(0))"  
paulson@13299
   363
apply (simp add: power_ax_def powerset_def subset_def, clarify) 
paulson@13299
   364
apply (rule_tac x="Pow(x)" in bexI)
paulson@13299
   365
 apply (blast intro: univ0_downwards_mem)
paulson@13299
   366
apply (blast intro: Pow_in_univ Transset_0) 
paulson@13223
   367
done
paulson@13223
   368
paulson@13223
   369
text{*Foundation axiom*}
paulson@13223
   370
lemma "foundation_ax(\<lambda>x. x \<in> univ(0))"  
paulson@13223
   371
apply (simp add: foundation_ax_def, clarify)
paulson@13299
   372
apply (cut_tac A=x in foundation) 
paulson@13299
   373
apply (blast intro: univ0_downwards_mem)
paulson@13223
   374
done
paulson@13223
   375
paulson@13223
   376
lemma "replacement(\<lambda>x. x \<in> univ(0), P)"  
paulson@13223
   377
apply (simp add: replacement_def, clarify) 
paulson@13223
   378
oops
paulson@13223
   379
text{*no idea: maybe prove by induction on the rank of A?*}
paulson@13223
   380
paulson@13223
   381
text{*Still missing: Replacement, Choice*}
paulson@13223
   382
paulson@13223
   383
subsection{*lemmas needed to reduce some set constructions to instances
paulson@13223
   384
      of Separation*}
paulson@13223
   385
paulson@13223
   386
lemma image_iff_Collect: "r `` A = {y \<in> Union(Union(r)). \<exists>p\<in>r. \<exists>x\<in>A. p=<x,y>}"
paulson@13223
   387
apply (rule equalityI, auto) 
paulson@13223
   388
apply (simp add: Pair_def, blast) 
paulson@13223
   389
done
paulson@13223
   390
paulson@13223
   391
lemma vimage_iff_Collect:
paulson@13223
   392
     "r -`` A = {x \<in> Union(Union(r)). \<exists>p\<in>r. \<exists>y\<in>A. p=<x,y>}"
paulson@13223
   393
apply (rule equalityI, auto) 
paulson@13223
   394
apply (simp add: Pair_def, blast) 
paulson@13223
   395
done
paulson@13223
   396
paulson@13223
   397
text{*These two lemmas lets us prove @{text domain_closed} and 
paulson@13223
   398
      @{text range_closed} without new instances of separation*}
paulson@13223
   399
paulson@13223
   400
lemma domain_eq_vimage: "domain(r) = r -`` Union(Union(r))"
paulson@13223
   401
apply (rule equalityI, auto)
paulson@13223
   402
apply (rule vimageI, assumption)
paulson@13223
   403
apply (simp add: Pair_def, blast) 
paulson@13223
   404
done
paulson@13223
   405
paulson@13223
   406
lemma range_eq_image: "range(r) = r `` Union(Union(r))"
paulson@13223
   407
apply (rule equalityI, auto)
paulson@13223
   408
apply (rule imageI, assumption)
paulson@13223
   409
apply (simp add: Pair_def, blast) 
paulson@13223
   410
done
paulson@13223
   411
paulson@13223
   412
lemma replacementD:
paulson@13223
   413
    "[| replacement(M,P); M(A);  univalent(M,A,P) |]
paulson@13299
   414
     ==> \<exists>Y[M]. (\<forall>b[M]. ((\<exists>x[M]. x\<in>A & P(x,b)) --> b \<in> Y))"
paulson@13223
   415
by (simp add: replacement_def) 
paulson@13223
   416
paulson@13223
   417
lemma strong_replacementD:
paulson@13223
   418
    "[| strong_replacement(M,P); M(A);  univalent(M,A,P) |]
paulson@13299
   419
     ==> \<exists>Y[M]. (\<forall>b[M]. (b \<in> Y <-> (\<exists>x[M]. x\<in>A & P(x,b))))"
paulson@13223
   420
by (simp add: strong_replacement_def) 
paulson@13223
   421
paulson@13223
   422
lemma separationD:
paulson@13290
   423
    "[| separation(M,P); M(z) |] ==> \<exists>y[M]. \<forall>x[M]. x \<in> y <-> x \<in> z & P(x)"
paulson@13223
   424
by (simp add: separation_def) 
paulson@13223
   425
paulson@13223
   426
paulson@13223
   427
text{*More constants, for order types*}
paulson@13223
   428
constdefs
paulson@13223
   429
paulson@13223
   430
  order_isomorphism :: "[i=>o,i,i,i,i,i] => o"
paulson@13223
   431
    "order_isomorphism(M,A,r,B,s,f) == 
paulson@13223
   432
        bijection(M,A,B,f) & 
paulson@13306
   433
        (\<forall>x[M]. x\<in>A --> (\<forall>y[M]. y\<in>A -->
paulson@13306
   434
          (\<forall>p[M]. \<forall>fx[M]. \<forall>fy[M]. \<forall>q[M].
paulson@13223
   435
            pair(M,x,y,p) --> fun_apply(M,f,x,fx) --> fun_apply(M,f,y,fy) --> 
paulson@13306
   436
            pair(M,fx,fy,q) --> (p\<in>r <-> q\<in>s))))"
paulson@13223
   437
paulson@13223
   438
  pred_set :: "[i=>o,i,i,i,i] => o"
paulson@13223
   439
    "pred_set(M,A,x,r,B) == 
paulson@13299
   440
	\<forall>y[M]. y \<in> B <-> (\<exists>p[M]. p\<in>r & y \<in> A & pair(M,y,x,p))"
paulson@13223
   441
paulson@13223
   442
  membership :: "[i=>o,i,i] => o" --{*membership relation*}
paulson@13223
   443
    "membership(M,A,r) == 
paulson@13306
   444
	\<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
   445
paulson@13223
   446
paulson@13418
   447
subsection{*Introducing a Transitive Class Model*}
paulson@13223
   448
paulson@13223
   449
text{*The class M is assumed to be transitive and to satisfy some
paulson@13223
   450
      relativized ZF axioms*}
wenzelm@13382
   451
locale (open) M_triv_axioms =
paulson@13223
   452
  fixes M
paulson@13223
   453
  assumes transM:           "[| y\<in>x; M(x) |] ==> M(y)"
paulson@13223
   454
      and nonempty [simp]:  "M(0)"
paulson@13223
   455
      and upair_ax:	    "upair_ax(M)"
paulson@13223
   456
      and Union_ax:	    "Union_ax(M)"
paulson@13223
   457
      and power_ax:         "power_ax(M)"
paulson@13223
   458
      and replacement:      "replacement(M,P)"
paulson@13268
   459
      and M_nat [iff]:      "M(nat)"           (*i.e. the axiom of infinity*)
paulson@13290
   460
paulson@13290
   461
lemma (in M_triv_axioms) rall_abs [simp]: 
paulson@13290
   462
     "M(A) ==> (\<forall>x[M]. x\<in>A --> P(x)) <-> (\<forall>x\<in>A. P(x))" 
paulson@13290
   463
by (blast intro: transM) 
paulson@13290
   464
paulson@13290
   465
lemma (in M_triv_axioms) rex_abs [simp]: 
paulson@13290
   466
     "M(A) ==> (\<exists>x[M]. x\<in>A & P(x)) <-> (\<exists>x\<in>A. P(x))" 
paulson@13290
   467
by (blast intro: transM) 
paulson@13290
   468
paulson@13290
   469
lemma (in M_triv_axioms) ball_iff_equiv: 
paulson@13299
   470
     "M(A) ==> (\<forall>x[M]. (x\<in>A <-> P(x))) <-> 
paulson@13290
   471
               (\<forall>x\<in>A. P(x)) & (\<forall>x. P(x) --> M(x) --> x\<in>A)" 
paulson@13290
   472
by (blast intro: transM)
paulson@13290
   473
paulson@13290
   474
text{*Simplifies proofs of equalities when there's an iff-equality
paulson@13290
   475
      available for rewriting, universally quantified over M. *}
paulson@13290
   476
lemma (in M_triv_axioms) M_equalityI: 
paulson@13290
   477
     "[| !!x. M(x) ==> x\<in>A <-> x\<in>B; M(A); M(B) |] ==> A=B"
paulson@13290
   478
by (blast intro!: equalityI dest: transM) 
paulson@13290
   479
paulson@13418
   480
paulson@13418
   481
subsubsection{*Trivial Absoluteness Proofs: Empty Set, Pairs, etc.*}
paulson@13418
   482
paulson@13290
   483
lemma (in M_triv_axioms) empty_abs [simp]: 
paulson@13290
   484
     "M(z) ==> empty(M,z) <-> z=0"
paulson@13290
   485
apply (simp add: empty_def)
paulson@13290
   486
apply (blast intro: transM) 
paulson@13290
   487
done
paulson@13290
   488
paulson@13290
   489
lemma (in M_triv_axioms) subset_abs [simp]: 
paulson@13290
   490
     "M(A) ==> subset(M,A,B) <-> A \<subseteq> B"
paulson@13290
   491
apply (simp add: subset_def) 
paulson@13290
   492
apply (blast intro: transM) 
paulson@13290
   493
done
paulson@13290
   494
paulson@13290
   495
lemma (in M_triv_axioms) upair_abs [simp]: 
paulson@13290
   496
     "M(z) ==> upair(M,a,b,z) <-> z={a,b}"
paulson@13290
   497
apply (simp add: upair_def) 
paulson@13290
   498
apply (blast intro: transM) 
paulson@13290
   499
done
paulson@13290
   500
paulson@13290
   501
lemma (in M_triv_axioms) upair_in_M_iff [iff]:
paulson@13290
   502
     "M({a,b}) <-> M(a) & M(b)"
paulson@13290
   503
apply (insert upair_ax, simp add: upair_ax_def) 
paulson@13290
   504
apply (blast intro: transM) 
paulson@13290
   505
done
paulson@13290
   506
paulson@13290
   507
lemma (in M_triv_axioms) singleton_in_M_iff [iff]:
paulson@13290
   508
     "M({a}) <-> M(a)"
paulson@13290
   509
by (insert upair_in_M_iff [of a a], simp) 
paulson@13290
   510
paulson@13290
   511
lemma (in M_triv_axioms) pair_abs [simp]: 
paulson@13290
   512
     "M(z) ==> pair(M,a,b,z) <-> z=<a,b>"
paulson@13290
   513
apply (simp add: pair_def ZF.Pair_def)
paulson@13290
   514
apply (blast intro: transM) 
paulson@13290
   515
done
paulson@13290
   516
paulson@13290
   517
lemma (in M_triv_axioms) pair_in_M_iff [iff]:
paulson@13290
   518
     "M(<a,b>) <-> M(a) & M(b)"
paulson@13290
   519
by (simp add: ZF.Pair_def)
paulson@13290
   520
paulson@13290
   521
lemma (in M_triv_axioms) pair_components_in_M:
paulson@13290
   522
     "[| <x,y> \<in> A; M(A) |] ==> M(x) & M(y)"
paulson@13290
   523
apply (simp add: Pair_def)
paulson@13290
   524
apply (blast dest: transM) 
paulson@13290
   525
done
paulson@13290
   526
paulson@13290
   527
lemma (in M_triv_axioms) cartprod_abs [simp]: 
paulson@13290
   528
     "[| M(A); M(B); M(z) |] ==> cartprod(M,A,B,z) <-> z = A*B"
paulson@13290
   529
apply (simp add: cartprod_def)
paulson@13290
   530
apply (rule iffI) 
paulson@13290
   531
 apply (blast intro!: equalityI intro: transM dest!: rspec) 
paulson@13290
   532
apply (blast dest: transM) 
paulson@13290
   533
done
paulson@13290
   534
paulson@13418
   535
subsubsection{*Absoluteness for Unions and Intersections*}
paulson@13418
   536
paulson@13290
   537
lemma (in M_triv_axioms) union_abs [simp]: 
paulson@13290
   538
     "[| M(a); M(b); M(z) |] ==> union(M,a,b,z) <-> z = a Un b"
paulson@13290
   539
apply (simp add: union_def) 
paulson@13290
   540
apply (blast intro: transM) 
paulson@13290
   541
done
paulson@13290
   542
paulson@13290
   543
lemma (in M_triv_axioms) inter_abs [simp]: 
paulson@13290
   544
     "[| M(a); M(b); M(z) |] ==> inter(M,a,b,z) <-> z = a Int b"
paulson@13290
   545
apply (simp add: inter_def) 
paulson@13290
   546
apply (blast intro: transM) 
paulson@13290
   547
done
paulson@13290
   548
paulson@13290
   549
lemma (in M_triv_axioms) setdiff_abs [simp]: 
paulson@13290
   550
     "[| M(a); M(b); M(z) |] ==> setdiff(M,a,b,z) <-> z = a-b"
paulson@13290
   551
apply (simp add: setdiff_def) 
paulson@13290
   552
apply (blast intro: transM) 
paulson@13290
   553
done
paulson@13290
   554
paulson@13290
   555
lemma (in M_triv_axioms) Union_abs [simp]: 
paulson@13290
   556
     "[| M(A); M(z) |] ==> big_union(M,A,z) <-> z = Union(A)"
paulson@13290
   557
apply (simp add: big_union_def) 
paulson@13290
   558
apply (blast intro!: equalityI dest: transM) 
paulson@13290
   559
done
paulson@13290
   560
paulson@13290
   561
lemma (in M_triv_axioms) Union_closed [intro,simp]:
paulson@13290
   562
     "M(A) ==> M(Union(A))"
paulson@13290
   563
by (insert Union_ax, simp add: Union_ax_def) 
paulson@13290
   564
paulson@13290
   565
lemma (in M_triv_axioms) Un_closed [intro,simp]:
paulson@13290
   566
     "[| M(A); M(B) |] ==> M(A Un B)"
paulson@13290
   567
by (simp only: Un_eq_Union, blast) 
paulson@13290
   568
paulson@13290
   569
lemma (in M_triv_axioms) cons_closed [intro,simp]:
paulson@13290
   570
     "[| M(a); M(A) |] ==> M(cons(a,A))"
paulson@13290
   571
by (subst cons_eq [symmetric], blast) 
paulson@13290
   572
paulson@13306
   573
lemma (in M_triv_axioms) cons_abs [simp]: 
paulson@13306
   574
     "[| M(b); M(z) |] ==> is_cons(M,a,b,z) <-> z = cons(a,b)"
paulson@13306
   575
by (simp add: is_cons_def, blast intro: transM)  
paulson@13306
   576
paulson@13290
   577
lemma (in M_triv_axioms) successor_abs [simp]: 
paulson@13306
   578
     "[| M(a); M(z) |] ==> successor(M,a,z) <-> z = succ(a)"
paulson@13290
   579
by (simp add: successor_def, blast)  
paulson@13290
   580
paulson@13290
   581
lemma (in M_triv_axioms) succ_in_M_iff [iff]:
paulson@13290
   582
     "M(succ(a)) <-> M(a)"
paulson@13290
   583
apply (simp add: succ_def) 
paulson@13290
   584
apply (blast intro: transM) 
paulson@13290
   585
done
paulson@13290
   586
paulson@13418
   587
subsubsection{*Absoluteness for Separation and Replacement*}
paulson@13418
   588
paulson@13290
   589
lemma (in M_triv_axioms) separation_closed [intro,simp]:
paulson@13290
   590
     "[| separation(M,P); M(A) |] ==> M(Collect(A,P))"
paulson@13290
   591
apply (insert separation, simp add: separation_def) 
paulson@13290
   592
apply (drule rspec, assumption, clarify) 
paulson@13290
   593
apply (subgoal_tac "y = Collect(A,P)", blast)
paulson@13290
   594
apply (blast dest: transM) 
paulson@13290
   595
done
paulson@13290
   596
paulson@13290
   597
text{*Probably the premise and conclusion are equivalent*}
paulson@13348
   598
lemma (in M_triv_axioms) strong_replacementI [rule_format]:
paulson@13306
   599
    "[| \<forall>A[M]. separation(M, %u. \<exists>x[M]. x\<in>A & P(x,u)) |]
paulson@13290
   600
     ==> strong_replacement(M,P)"
paulson@13290
   601
apply (simp add: strong_replacement_def, clarify) 
paulson@13290
   602
apply (frule replacementD [OF replacement], assumption, clarify) 
paulson@13299
   603
apply (drule_tac x=A in rspec, clarify)  
paulson@13290
   604
apply (drule_tac z=Y in separationD, assumption, clarify) 
paulson@13299
   605
apply (rule_tac x=y in rexI) 
paulson@13299
   606
apply (blast dest: transM)+
paulson@13290
   607
done
paulson@13290
   608
paulson@13290
   609
paulson@13290
   610
(*The last premise expresses that P takes M to M*)
paulson@13290
   611
lemma (in M_triv_axioms) strong_replacement_closed [intro,simp]:
paulson@13290
   612
     "[| strong_replacement(M,P); M(A); univalent(M,A,P); 
paulson@13290
   613
       !!x y. [| x\<in>A; P(x,y); M(x) |] ==> M(y) |] ==> M(Replace(A,P))"
paulson@13290
   614
apply (simp add: strong_replacement_def) 
paulson@13299
   615
apply (drule rspec, auto) 
paulson@13290
   616
apply (subgoal_tac "Replace(A,P) = Y")
paulson@13290
   617
 apply simp 
paulson@13290
   618
apply (rule equality_iffI) 
paulson@13290
   619
apply (simp add: Replace_iff, safe)
paulson@13290
   620
 apply (blast dest: transM) 
paulson@13290
   621
apply (frule transM, assumption) 
paulson@13290
   622
 apply (simp add: univalent_def)
paulson@13299
   623
 apply (drule rspec [THEN iffD1], assumption, assumption)
paulson@13290
   624
 apply (blast dest: transM) 
paulson@13290
   625
done
paulson@13290
   626
paulson@13290
   627
(*The first premise can't simply be assumed as a schema.
paulson@13290
   628
  It is essential to take care when asserting instances of Replacement.
paulson@13290
   629
  Let K be a nonconstructible subset of nat and define
paulson@13290
   630
  f(x) = x if x:K and f(x)=0 otherwise.  Then RepFun(nat,f) = cons(0,K), a 
paulson@13290
   631
  nonconstructible set.  So we cannot assume that M(X) implies M(RepFun(X,f))
paulson@13290
   632
  even for f : M -> M.
paulson@13290
   633
*)
paulson@13353
   634
lemma (in M_triv_axioms) RepFun_closed:
paulson@13290
   635
     "[| strong_replacement(M, \<lambda>x y. y = f(x)); M(A); \<forall>x\<in>A. M(f(x)) |]
paulson@13290
   636
      ==> M(RepFun(A,f))"
paulson@13290
   637
apply (simp add: RepFun_def) 
paulson@13290
   638
apply (rule strong_replacement_closed) 
paulson@13290
   639
apply (auto dest: transM  simp add: univalent_def) 
paulson@13290
   640
done
paulson@13290
   641
paulson@13353
   642
lemma Replace_conj_eq: "{y . x \<in> A, x\<in>A & y=f(x)} = {y . x\<in>A, y=f(x)}"
paulson@13353
   643
by simp
paulson@13353
   644
paulson@13353
   645
text{*Better than @{text RepFun_closed} when having the formula @{term "x\<in>A"}
paulson@13353
   646
      makes relativization easier.*}
paulson@13353
   647
lemma (in M_triv_axioms) RepFun_closed2:
paulson@13353
   648
     "[| strong_replacement(M, \<lambda>x y. x\<in>A & y = f(x)); M(A); \<forall>x\<in>A. M(f(x)) |]
paulson@13353
   649
      ==> M(RepFun(A, %x. f(x)))"
paulson@13353
   650
apply (simp add: RepFun_def)
paulson@13353
   651
apply (frule strong_replacement_closed, assumption)
paulson@13353
   652
apply (auto dest: transM  simp add: Replace_conj_eq univalent_def) 
paulson@13353
   653
done
paulson@13353
   654
paulson@13418
   655
subsubsection {*Absoluteness for @{term Lambda}*}
paulson@13418
   656
paulson@13418
   657
constdefs
paulson@13418
   658
 is_lambda :: "[i=>o, i, [i,i]=>o, i] => o"
paulson@13418
   659
    "is_lambda(M, A, is_b, z) == 
paulson@13418
   660
       \<forall>p[M]. p \<in> z <->
paulson@13418
   661
        (\<exists>u[M]. \<exists>v[M]. u\<in>A & pair(M,u,v,p) & is_b(u,v))"
paulson@13418
   662
paulson@13418
   663
lemma (in M_triv_axioms) lam_closed:
paulson@13290
   664
     "[| strong_replacement(M, \<lambda>x y. y = <x,b(x)>); M(A); \<forall>x\<in>A. M(b(x)) |]
paulson@13290
   665
      ==> M(\<lambda>x\<in>A. b(x))"
paulson@13353
   666
by (simp add: lam_def, blast intro: RepFun_closed dest: transM) 
paulson@13290
   667
paulson@13418
   668
text{*Better than @{text lam_closed}: has the formula @{term "x\<in>A"}*}
paulson@13418
   669
lemma (in M_triv_axioms) lam_closed2:
paulson@13418
   670
  "[|strong_replacement(M, \<lambda>x y. x\<in>A & y = \<langle>x, b(x)\<rangle>);
paulson@13418
   671
     M(A); \<forall>m[M]. m\<in>A --> M(b(m))|] ==> M(Lambda(A,b))"
paulson@13418
   672
apply (simp add: lam_def)
paulson@13418
   673
apply (blast intro: RepFun_closed2 dest: transM)  
paulson@13418
   674
done
paulson@13418
   675
paulson@13418
   676
lemma (in M_triv_axioms) lambda_abs2 [simp]: 
paulson@13418
   677
     "[| strong_replacement(M, \<lambda>x y. x\<in>A & y = \<langle>x, b(x)\<rangle>);
paulson@13423
   678
         Relativize1(M,A,is_b,b); M(A); \<forall>m[M]. m\<in>A --> M(b(m)); M(z) |] 
paulson@13418
   679
      ==> is_lambda(M,A,is_b,z) <-> z = Lambda(A,b)"
paulson@13423
   680
apply (simp add: Relativize1_def is_lambda_def)
paulson@13418
   681
apply (rule iffI)
paulson@13418
   682
 prefer 2 apply (simp add: lam_def) 
paulson@13418
   683
apply (rule M_equalityI)
paulson@13418
   684
  apply (simp add: lam_def) 
paulson@13418
   685
 apply (simp add: lam_closed2)+
paulson@13418
   686
done
paulson@13418
   687
paulson@13423
   688
lemma is_lambda_cong [cong]:
paulson@13423
   689
     "[| A=A';  z=z'; 
paulson@13423
   690
         !!x y. [| x\<in>A; M(x); M(y) |] ==> is_b(x,y) <-> is_b'(x,y) |] 
paulson@13423
   691
      ==> is_lambda(M, A, %x y. is_b(x,y), z) <-> 
paulson@13423
   692
          is_lambda(M, A', %x y. is_b'(x,y), z')" 
paulson@13423
   693
by (simp add: is_lambda_def) 
paulson@13423
   694
paulson@13290
   695
lemma (in M_triv_axioms) image_abs [simp]: 
paulson@13290
   696
     "[| M(r); M(A); M(z) |] ==> image(M,r,A,z) <-> z = r``A"
paulson@13290
   697
apply (simp add: image_def)
paulson@13290
   698
apply (rule iffI) 
paulson@13290
   699
 apply (blast intro!: equalityI dest: transM, blast) 
paulson@13290
   700
done
paulson@13290
   701
paulson@13290
   702
text{*What about @{text Pow_abs}?  Powerset is NOT absolute!
paulson@13290
   703
      This result is one direction of absoluteness.*}
paulson@13290
   704
paulson@13290
   705
lemma (in M_triv_axioms) powerset_Pow: 
paulson@13290
   706
     "powerset(M, x, Pow(x))"
paulson@13290
   707
by (simp add: powerset_def)
paulson@13290
   708
paulson@13290
   709
text{*But we can't prove that the powerset in @{text M} includes the
paulson@13290
   710
      real powerset.*}
paulson@13290
   711
lemma (in M_triv_axioms) powerset_imp_subset_Pow: 
paulson@13290
   712
     "[| powerset(M,x,y); M(y) |] ==> y <= Pow(x)"
paulson@13290
   713
apply (simp add: powerset_def) 
paulson@13290
   714
apply (blast dest: transM) 
paulson@13290
   715
done
paulson@13290
   716
paulson@13418
   717
subsubsection{*Absoluteness for the Natural Numbers*}
paulson@13418
   718
paulson@13290
   719
lemma (in M_triv_axioms) nat_into_M [intro]:
paulson@13290
   720
     "n \<in> nat ==> M(n)"
paulson@13290
   721
by (induct n rule: nat_induct, simp_all)
paulson@13290
   722
paulson@13350
   723
lemma (in M_triv_axioms) nat_case_closed [intro,simp]:
paulson@13290
   724
  "[|M(k); M(a); \<forall>m[M]. M(b(m))|] ==> M(nat_case(a,b,k))"
paulson@13290
   725
apply (case_tac "k=0", simp) 
paulson@13290
   726
apply (case_tac "\<exists>m. k = succ(m)", force)
paulson@13290
   727
apply (simp add: nat_case_def) 
paulson@13290
   728
done
paulson@13290
   729
paulson@13350
   730
lemma (in M_triv_axioms) quasinat_abs [simp]: 
paulson@13350
   731
     "M(z) ==> is_quasinat(M,z) <-> quasinat(z)"
paulson@13350
   732
by (auto simp add: is_quasinat_def quasinat_def)
paulson@13350
   733
paulson@13350
   734
lemma (in M_triv_axioms) nat_case_abs [simp]: 
paulson@13353
   735
     "[| relativize1(M,is_b,b); M(k); M(z) |] 
paulson@13353
   736
      ==> is_nat_case(M,a,is_b,k,z) <-> z = nat_case(a,b,k)"
paulson@13350
   737
apply (case_tac "quasinat(k)") 
paulson@13350
   738
 prefer 2 
paulson@13350
   739
 apply (simp add: is_nat_case_def non_nat_case) 
paulson@13350
   740
 apply (force simp add: quasinat_def) 
paulson@13350
   741
apply (simp add: quasinat_def is_nat_case_def)
paulson@13350
   742
apply (elim disjE exE) 
paulson@13353
   743
 apply (simp_all add: relativize1_def) 
paulson@13350
   744
done
paulson@13350
   745
paulson@13363
   746
(*NOT for the simplifier.  The assumption M(z') is apparently necessary, but 
paulson@13363
   747
  causes the error "Failed congruence proof!"  It may be better to replace
paulson@13363
   748
  is_nat_case by nat_case before attempting congruence reasoning.*)
paulson@13363
   749
lemma (in M_triv_axioms) is_nat_case_cong:
paulson@13352
   750
     "[| a = a'; k = k';  z = z';  M(z');
paulson@13352
   751
       !!x y. [| M(x); M(y) |] ==> is_b(x,y) <-> is_b'(x,y) |]
paulson@13352
   752
      ==> is_nat_case(M, a, is_b, k, z) <-> is_nat_case(M, a', is_b', k', z')"
paulson@13352
   753
by (simp add: is_nat_case_def) 
paulson@13352
   754
paulson@13290
   755
lemma (in M_triv_axioms) Inl_in_M_iff [iff]:
paulson@13290
   756
     "M(Inl(a)) <-> M(a)"
paulson@13290
   757
by (simp add: Inl_def) 
paulson@13290
   758
paulson@13290
   759
lemma (in M_triv_axioms) Inr_in_M_iff [iff]:
paulson@13290
   760
     "M(Inr(a)) <-> M(a)"
paulson@13290
   761
by (simp add: Inr_def)
paulson@13290
   762
paulson@13290
   763
paulson@13418
   764
subsection{*Absoluteness for Ordinals*}
paulson@13290
   765
text{*These results constitute Theorem IV 5.1 of Kunen (page 126).*}
paulson@13290
   766
paulson@13290
   767
lemma (in M_triv_axioms) lt_closed:
paulson@13290
   768
     "[| j<i; M(i) |] ==> M(j)" 
paulson@13290
   769
by (blast dest: ltD intro: transM) 
paulson@13290
   770
paulson@13290
   771
lemma (in M_triv_axioms) transitive_set_abs [simp]: 
paulson@13290
   772
     "M(a) ==> transitive_set(M,a) <-> Transset(a)"
paulson@13290
   773
by (simp add: transitive_set_def Transset_def)
paulson@13290
   774
paulson@13290
   775
lemma (in M_triv_axioms) ordinal_abs [simp]: 
paulson@13290
   776
     "M(a) ==> ordinal(M,a) <-> Ord(a)"
paulson@13290
   777
by (simp add: ordinal_def Ord_def)
paulson@13290
   778
paulson@13290
   779
lemma (in M_triv_axioms) limit_ordinal_abs [simp]: 
paulson@13290
   780
     "M(a) ==> limit_ordinal(M,a) <-> Limit(a)"
paulson@13290
   781
apply (simp add: limit_ordinal_def Ord_0_lt_iff Limit_def) 
paulson@13290
   782
apply (simp add: lt_def, blast) 
paulson@13290
   783
done
paulson@13290
   784
paulson@13290
   785
lemma (in M_triv_axioms) successor_ordinal_abs [simp]: 
paulson@13299
   786
     "M(a) ==> successor_ordinal(M,a) <-> Ord(a) & (\<exists>b[M]. a = succ(b))"
paulson@13290
   787
apply (simp add: successor_ordinal_def, safe)
paulson@13290
   788
apply (drule Ord_cases_disj, auto) 
paulson@13290
   789
done
paulson@13290
   790
paulson@13290
   791
lemma finite_Ord_is_nat:
paulson@13290
   792
      "[| Ord(a); ~ Limit(a); \<forall>x\<in>a. ~ Limit(x) |] ==> a \<in> nat"
paulson@13290
   793
by (induct a rule: trans_induct3, simp_all)
paulson@13290
   794
paulson@13290
   795
lemma naturals_not_limit: "a \<in> nat ==> ~ Limit(a)"
paulson@13290
   796
by (induct a rule: nat_induct, auto)
paulson@13290
   797
paulson@13290
   798
lemma (in M_triv_axioms) finite_ordinal_abs [simp]: 
paulson@13290
   799
     "M(a) ==> finite_ordinal(M,a) <-> a \<in> nat"
paulson@13290
   800
apply (simp add: finite_ordinal_def)
paulson@13290
   801
apply (blast intro: finite_Ord_is_nat intro: nat_into_Ord 
paulson@13290
   802
             dest: Ord_trans naturals_not_limit)
paulson@13290
   803
done
paulson@13290
   804
paulson@13290
   805
lemma Limit_non_Limit_implies_nat:
paulson@13290
   806
     "[| Limit(a); \<forall>x\<in>a. ~ Limit(x) |] ==> a = nat"
paulson@13290
   807
apply (rule le_anti_sym) 
paulson@13290
   808
apply (rule all_lt_imp_le, blast, blast intro: Limit_is_Ord)  
paulson@13290
   809
 apply (simp add: lt_def)  
paulson@13290
   810
 apply (blast intro: Ord_in_Ord Ord_trans finite_Ord_is_nat) 
paulson@13290
   811
apply (erule nat_le_Limit)
paulson@13290
   812
done
paulson@13290
   813
paulson@13290
   814
lemma (in M_triv_axioms) omega_abs [simp]: 
paulson@13290
   815
     "M(a) ==> omega(M,a) <-> a = nat"
paulson@13290
   816
apply (simp add: omega_def) 
paulson@13290
   817
apply (blast intro: Limit_non_Limit_implies_nat dest: naturals_not_limit)
paulson@13290
   818
done
paulson@13290
   819
paulson@13290
   820
lemma (in M_triv_axioms) number1_abs [simp]: 
paulson@13290
   821
     "M(a) ==> number1(M,a) <-> a = 1"
paulson@13290
   822
by (simp add: number1_def) 
paulson@13290
   823
paulson@13290
   824
lemma (in M_triv_axioms) number1_abs [simp]: 
paulson@13290
   825
     "M(a) ==> number2(M,a) <-> a = succ(1)"
paulson@13290
   826
by (simp add: number2_def) 
paulson@13290
   827
paulson@13290
   828
lemma (in M_triv_axioms) number3_abs [simp]: 
paulson@13290
   829
     "M(a) ==> number3(M,a) <-> a = succ(succ(1))"
paulson@13290
   830
by (simp add: number3_def) 
paulson@13290
   831
paulson@13290
   832
text{*Kunen continued to 20...*}
paulson@13290
   833
paulson@13290
   834
(*Could not get this to work.  The \<lambda>x\<in>nat is essential because everything 
paulson@13290
   835
  but the recursion variable must stay unchanged.  But then the recursion
paulson@13290
   836
  equations only hold for x\<in>nat (or in some other set) and not for the 
paulson@13290
   837
  whole of the class M.
paulson@13290
   838
  consts
paulson@13290
   839
    natnumber_aux :: "[i=>o,i] => i"
paulson@13290
   840
paulson@13290
   841
  primrec
paulson@13290
   842
      "natnumber_aux(M,0) = (\<lambda>x\<in>nat. if empty(M,x) then 1 else 0)"
paulson@13290
   843
      "natnumber_aux(M,succ(n)) = 
paulson@13299
   844
	   (\<lambda>x\<in>nat. if (\<exists>y[M]. natnumber_aux(M,n)`y=1 & successor(M,y,x)) 
paulson@13290
   845
		     then 1 else 0)"
paulson@13290
   846
paulson@13290
   847
  constdefs
paulson@13290
   848
    natnumber :: "[i=>o,i,i] => o"
paulson@13290
   849
      "natnumber(M,n,x) == natnumber_aux(M,n)`x = 1"
paulson@13290
   850
paulson@13290
   851
  lemma (in M_triv_axioms) [simp]: 
paulson@13290
   852
       "natnumber(M,0,x) == x=0"
paulson@13290
   853
*)
paulson@13290
   854
paulson@13290
   855
subsection{*Some instances of separation and strong replacement*}
paulson@13290
   856
wenzelm@13382
   857
locale (open) M_axioms = M_triv_axioms +
paulson@13290
   858
assumes Inter_separation:
paulson@13268
   859
     "M(A) ==> separation(M, \<lambda>x. \<forall>y[M]. y\<in>A --> x\<in>y)"
paulson@13223
   860
  and cartprod_separation:
paulson@13223
   861
     "[| M(A); M(B) |] 
paulson@13298
   862
      ==> separation(M, \<lambda>z. \<exists>x[M]. x\<in>A & (\<exists>y[M]. y\<in>B & pair(M,x,y,z)))"
paulson@13223
   863
  and image_separation:
paulson@13223
   864
     "[| M(A); M(r) |] 
paulson@13268
   865
      ==> separation(M, \<lambda>y. \<exists>p[M]. p\<in>r & (\<exists>x[M]. x\<in>A & pair(M,x,y,p)))"
paulson@13223
   866
  and converse_separation:
paulson@13298
   867
     "M(r) ==> separation(M, 
paulson@13298
   868
         \<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
   869
  and restrict_separation:
paulson@13268
   870
     "M(A) ==> separation(M, \<lambda>z. \<exists>x[M]. x\<in>A & (\<exists>y[M]. pair(M,x,y,z)))"
paulson@13223
   871
  and comp_separation:
paulson@13223
   872
     "[| M(r); M(s) |]
paulson@13268
   873
      ==> separation(M, \<lambda>xz. \<exists>x[M]. \<exists>y[M]. \<exists>z[M]. \<exists>xy[M]. \<exists>yz[M]. 
paulson@13268
   874
		  pair(M,x,z,xz) & pair(M,x,y,xy) & pair(M,y,z,yz) & 
paulson@13268
   875
                  xy\<in>s & yz\<in>r)"
paulson@13223
   876
  and pred_separation:
paulson@13298
   877
     "[| M(r); M(x) |] ==> separation(M, \<lambda>y. \<exists>p[M]. p\<in>r & pair(M,y,x,p))"
paulson@13223
   878
  and Memrel_separation:
paulson@13298
   879
     "separation(M, \<lambda>z. \<exists>x[M]. \<exists>y[M]. pair(M,x,y,z) & x \<in> y)"
paulson@13268
   880
  and funspace_succ_replacement:
paulson@13268
   881
     "M(n) ==> 
paulson@13306
   882
      strong_replacement(M, \<lambda>p z. \<exists>f[M]. \<exists>b[M]. \<exists>nb[M]. \<exists>cnbf[M]. 
paulson@13306
   883
                pair(M,f,b,p) & pair(M,n,b,nb) & is_cons(M,nb,f,cnbf) &
paulson@13306
   884
                upair(M,cnbf,cnbf,z))"
paulson@13223
   885
  and well_ord_iso_separation:
paulson@13223
   886
     "[| M(A); M(f); M(r) |] 
paulson@13299
   887
      ==> separation (M, \<lambda>x. x\<in>A --> (\<exists>y[M]. (\<exists>p[M]. 
paulson@13245
   888
		     fun_apply(M,f,x,y) & pair(M,y,x,p) & p \<in> r)))"
paulson@13306
   889
  and obase_separation:
paulson@13306
   890
     --{*part of the order type formalization*}
paulson@13306
   891
     "[| M(A); M(r) |] 
paulson@13306
   892
      ==> separation(M, \<lambda>a. \<exists>x[M]. \<exists>g[M]. \<exists>mx[M]. \<exists>par[M]. 
paulson@13306
   893
	     ordinal(M,x) & membership(M,x,mx) & pred_set(M,A,a,r,par) &
paulson@13306
   894
	     order_isomorphism(M,par,r,x,mx,g))"
paulson@13223
   895
  and obase_equals_separation:
paulson@13223
   896
     "[| M(A); M(r) |] 
paulson@13316
   897
      ==> separation (M, \<lambda>x. x\<in>A --> ~(\<exists>y[M]. \<exists>g[M]. 
paulson@13316
   898
			      ordinal(M,y) & (\<exists>my[M]. \<exists>pxr[M]. 
paulson@13316
   899
			      membership(M,y,my) & pred_set(M,A,x,r,pxr) &
paulson@13316
   900
			      order_isomorphism(M,pxr,r,y,my,g))))"
paulson@13306
   901
  and omap_replacement:
paulson@13306
   902
     "[| M(A); M(r) |] 
paulson@13306
   903
      ==> strong_replacement(M,
paulson@13306
   904
             \<lambda>a z. \<exists>x[M]. \<exists>g[M]. \<exists>mx[M]. \<exists>par[M]. 
paulson@13306
   905
	     ordinal(M,x) & pair(M,a,x,z) & membership(M,x,mx) & 
paulson@13306
   906
	     pred_set(M,A,a,r,par) & order_isomorphism(M,par,r,x,mx,g))"
paulson@13223
   907
  and is_recfun_separation:
paulson@13319
   908
     --{*for well-founded recursion*}
paulson@13319
   909
     "[| M(r); M(f); M(g); M(a); M(b) |] 
paulson@13319
   910
     ==> separation(M, 
paulson@13319
   911
            \<lambda>x. \<exists>xa[M]. \<exists>xb[M]. 
paulson@13319
   912
                pair(M,x,a,xa) & xa \<in> r & pair(M,x,b,xb) & xb \<in> r & 
paulson@13319
   913
                (\<exists>fx[M]. \<exists>gx[M]. fun_apply(M,f,x,fx) & fun_apply(M,g,x,gx) & 
paulson@13319
   914
                                   fx \<noteq> gx))"
paulson@13223
   915
paulson@13223
   916
lemma (in M_axioms) cartprod_iff_lemma:
paulson@13254
   917
     "[| M(C);  \<forall>u[M]. u \<in> C <-> (\<exists>x\<in>A. \<exists>y\<in>B. u = {{x}, {x,y}}); 
paulson@13254
   918
         powerset(M, A \<union> B, p1); powerset(M, p1, p2);  M(p2) |]
paulson@13223
   919
       ==> C = {u \<in> p2 . \<exists>x\<in>A. \<exists>y\<in>B. u = {{x}, {x,y}}}"
paulson@13223
   920
apply (simp add: powerset_def) 
paulson@13254
   921
apply (rule equalityI, clarify, simp)
paulson@13254
   922
 apply (frule transM, assumption) 
paulson@13223
   923
 apply (frule transM, assumption, simp) 
paulson@13223
   924
 apply blast 
paulson@13223
   925
apply clarify
paulson@13223
   926
apply (frule transM, assumption, force) 
paulson@13223
   927
done
paulson@13223
   928
paulson@13223
   929
lemma (in M_axioms) cartprod_iff:
paulson@13223
   930
     "[| M(A); M(B); M(C) |] 
paulson@13223
   931
      ==> cartprod(M,A,B,C) <-> 
paulson@13223
   932
          (\<exists>p1 p2. M(p1) & M(p2) & powerset(M,A Un B,p1) & powerset(M,p1,p2) &
paulson@13223
   933
                   C = {z \<in> p2. \<exists>x\<in>A. \<exists>y\<in>B. z = <x,y>})"
paulson@13223
   934
apply (simp add: Pair_def cartprod_def, safe)
paulson@13223
   935
defer 1 
paulson@13223
   936
  apply (simp add: powerset_def) 
paulson@13223
   937
 apply blast 
paulson@13223
   938
txt{*Final, difficult case: the left-to-right direction of the theorem.*}
paulson@13223
   939
apply (insert power_ax, simp add: power_ax_def) 
paulson@13299
   940
apply (frule_tac x="A Un B" and P="\<lambda>x. rex(M,?Q(x))" in rspec) 
paulson@13299
   941
apply (blast, clarify) 
paulson@13299
   942
apply (drule_tac x=z and P="\<lambda>x. rex(M,?Q(x))" in rspec)
paulson@13299
   943
apply assumption
paulson@13223
   944
apply (blast intro: cartprod_iff_lemma) 
paulson@13223
   945
done
paulson@13223
   946
paulson@13223
   947
lemma (in M_axioms) cartprod_closed_lemma:
paulson@13299
   948
     "[| M(A); M(B) |] ==> \<exists>C[M]. cartprod(M,A,B,C)"
paulson@13223
   949
apply (simp del: cartprod_abs add: cartprod_iff)
paulson@13223
   950
apply (insert power_ax, simp add: power_ax_def) 
paulson@13299
   951
apply (frule_tac x="A Un B" and P="\<lambda>x. rex(M,?Q(x))" in rspec) 
paulson@13299
   952
apply (blast, clarify) 
paulson@13299
   953
apply (drule_tac x=z and P="\<lambda>x. rex(M,?Q(x))" in rspec) 
paulson@13299
   954
apply (blast, clarify)
paulson@13299
   955
apply (intro rexI exI conjI) 
paulson@13299
   956
prefer 5 apply (rule refl) 
paulson@13299
   957
prefer 3 apply assumption
paulson@13299
   958
prefer 3 apply assumption
paulson@13245
   959
apply (insert cartprod_separation [of A B], auto)
paulson@13223
   960
done
paulson@13223
   961
paulson@13223
   962
text{*All the lemmas above are necessary because Powerset is not absolute.
paulson@13223
   963
      I should have used Replacement instead!*}
paulson@13245
   964
lemma (in M_axioms) cartprod_closed [intro,simp]: 
paulson@13223
   965
     "[| M(A); M(B) |] ==> M(A*B)"
paulson@13223
   966
by (frule cartprod_closed_lemma, assumption, force)
paulson@13223
   967
paulson@13268
   968
lemma (in M_axioms) sum_closed [intro,simp]: 
paulson@13268
   969
     "[| M(A); M(B) |] ==> M(A+B)"
paulson@13268
   970
by (simp add: sum_def)
paulson@13268
   971
paulson@13350
   972
lemma (in M_axioms) sum_abs [simp]:
paulson@13350
   973
     "[| M(A); M(B); M(Z) |] ==> is_sum(M,A,B,Z) <-> (Z = A+B)"
paulson@13350
   974
by (simp add: is_sum_def sum_def singleton_0 nat_into_M)
paulson@13350
   975
paulson@13397
   976
lemma (in M_triv_axioms) Inl_in_M_iff [iff]:
paulson@13397
   977
     "M(Inl(a)) <-> M(a)"
paulson@13397
   978
by (simp add: Inl_def) 
paulson@13397
   979
paulson@13397
   980
lemma (in M_triv_axioms) Inl_abs [simp]:
paulson@13397
   981
     "M(Z) ==> is_Inl(M,a,Z) <-> (Z = Inl(a))"
paulson@13397
   982
by (simp add: is_Inl_def Inl_def)
paulson@13397
   983
paulson@13397
   984
lemma (in M_triv_axioms) Inr_in_M_iff [iff]:
paulson@13397
   985
     "M(Inr(a)) <-> M(a)"
paulson@13397
   986
by (simp add: Inr_def) 
paulson@13397
   987
paulson@13397
   988
lemma (in M_triv_axioms) Inr_abs [simp]:
paulson@13397
   989
     "M(Z) ==> is_Inr(M,a,Z) <-> (Z = Inr(a))"
paulson@13397
   990
by (simp add: is_Inr_def Inr_def)
paulson@13397
   991
paulson@13290
   992
paulson@13290
   993
subsubsection {*converse of a relation*}
paulson@13290
   994
paulson@13290
   995
lemma (in M_axioms) M_converse_iff:
paulson@13290
   996
     "M(r) ==> 
paulson@13290
   997
      converse(r) = 
paulson@13290
   998
      {z \<in> Union(Union(r)) * Union(Union(r)). 
paulson@13290
   999
       \<exists>p\<in>r. \<exists>x[M]. \<exists>y[M]. p = \<langle>x,y\<rangle> & z = \<langle>y,x\<rangle>}"
paulson@13290
  1000
apply (rule equalityI)
paulson@13290
  1001
 prefer 2 apply (blast dest: transM, clarify, simp) 
paulson@13290
  1002
apply (simp add: Pair_def) 
paulson@13290
  1003
apply (blast dest: transM) 
paulson@13290
  1004
done
paulson@13290
  1005
paulson@13290
  1006
lemma (in M_axioms) converse_closed [intro,simp]: 
paulson@13290
  1007
     "M(r) ==> M(converse(r))"
paulson@13290
  1008
apply (simp add: M_converse_iff)
paulson@13290
  1009
apply (insert converse_separation [of r], simp)
paulson@13290
  1010
done
paulson@13290
  1011
paulson@13290
  1012
lemma (in M_axioms) converse_abs [simp]: 
paulson@13290
  1013
     "[| M(r); M(z) |] ==> is_converse(M,r,z) <-> z = converse(r)"
paulson@13290
  1014
apply (simp add: is_converse_def)
paulson@13290
  1015
apply (rule iffI)
paulson@13290
  1016
 prefer 2 apply blast 
paulson@13290
  1017
apply (rule M_equalityI)
paulson@13290
  1018
  apply simp
paulson@13290
  1019
  apply (blast dest: transM)+
paulson@13290
  1020
done
paulson@13290
  1021
paulson@13290
  1022
paulson@13290
  1023
subsubsection {*image, preimage, domain, range*}
paulson@13290
  1024
paulson@13245
  1025
lemma (in M_axioms) image_closed [intro,simp]: 
paulson@13223
  1026
     "[| M(A); M(r) |] ==> M(r``A)"
paulson@13223
  1027
apply (simp add: image_iff_Collect)
paulson@13245
  1028
apply (insert image_separation [of A r], simp) 
paulson@13223
  1029
done
paulson@13223
  1030
paulson@13223
  1031
lemma (in M_axioms) vimage_abs [simp]: 
paulson@13223
  1032
     "[| M(r); M(A); M(z) |] ==> pre_image(M,r,A,z) <-> z = r-``A"
paulson@13223
  1033
apply (simp add: pre_image_def)
paulson@13223
  1034
apply (rule iffI) 
paulson@13223
  1035
 apply (blast intro!: equalityI dest: transM, blast) 
paulson@13223
  1036
done
paulson@13223
  1037
paulson@13245
  1038
lemma (in M_axioms) vimage_closed [intro,simp]: 
paulson@13223
  1039
     "[| M(A); M(r) |] ==> M(r-``A)"
paulson@13290
  1040
by (simp add: vimage_def)
paulson@13290
  1041
paulson@13290
  1042
paulson@13290
  1043
subsubsection{*Domain, range and field*}
paulson@13223
  1044
paulson@13223
  1045
lemma (in M_axioms) domain_abs [simp]: 
paulson@13223
  1046
     "[| M(r); M(z) |] ==> is_domain(M,r,z) <-> z = domain(r)"
paulson@13223
  1047
apply (simp add: is_domain_def) 
paulson@13223
  1048
apply (blast intro!: equalityI dest: transM) 
paulson@13223
  1049
done
paulson@13223
  1050
paulson@13245
  1051
lemma (in M_axioms) domain_closed [intro,simp]: 
paulson@13223
  1052
     "M(r) ==> M(domain(r))"
paulson@13223
  1053
apply (simp add: domain_eq_vimage)
paulson@13223
  1054
done
paulson@13223
  1055
paulson@13223
  1056
lemma (in M_axioms) range_abs [simp]: 
paulson@13223
  1057
     "[| M(r); M(z) |] ==> is_range(M,r,z) <-> z = range(r)"
paulson@13223
  1058
apply (simp add: is_range_def)
paulson@13223
  1059
apply (blast intro!: equalityI dest: transM)
paulson@13223
  1060
done
paulson@13223
  1061
paulson@13245
  1062
lemma (in M_axioms) range_closed [intro,simp]: 
paulson@13223
  1063
     "M(r) ==> M(range(r))"
paulson@13223
  1064
apply (simp add: range_eq_image)
paulson@13223
  1065
done
paulson@13223
  1066
paulson@13245
  1067
lemma (in M_axioms) field_abs [simp]: 
paulson@13245
  1068
     "[| M(r); M(z) |] ==> is_field(M,r,z) <-> z = field(r)"
paulson@13245
  1069
by (simp add: domain_closed range_closed is_field_def field_def)
paulson@13245
  1070
paulson@13245
  1071
lemma (in M_axioms) field_closed [intro,simp]: 
paulson@13245
  1072
     "M(r) ==> M(field(r))"
paulson@13245
  1073
by (simp add: domain_closed range_closed Un_closed field_def) 
paulson@13245
  1074
paulson@13245
  1075
paulson@13290
  1076
subsubsection{*Relations, functions and application*}
paulson@13254
  1077
paulson@13223
  1078
lemma (in M_axioms) relation_abs [simp]: 
paulson@13223
  1079
     "M(r) ==> is_relation(M,r) <-> relation(r)"
paulson@13223
  1080
apply (simp add: is_relation_def relation_def) 
paulson@13223
  1081
apply (blast dest!: bspec dest: pair_components_in_M)+
paulson@13223
  1082
done
paulson@13223
  1083
paulson@13223
  1084
lemma (in M_axioms) function_abs [simp]: 
paulson@13223
  1085
     "M(r) ==> is_function(M,r) <-> function(r)"
paulson@13223
  1086
apply (simp add: is_function_def function_def, safe) 
paulson@13223
  1087
   apply (frule transM, assumption) 
paulson@13223
  1088
  apply (blast dest: pair_components_in_M)+
paulson@13223
  1089
done
paulson@13223
  1090
paulson@13245
  1091
lemma (in M_axioms) apply_closed [intro,simp]: 
paulson@13223
  1092
     "[|M(f); M(a)|] ==> M(f`a)"
paulson@13290
  1093
by (simp add: apply_def)
paulson@13223
  1094
paulson@13352
  1095
lemma (in M_axioms) apply_abs [simp]: 
paulson@13352
  1096
     "[| M(f); M(x); M(y) |] ==> fun_apply(M,f,x,y) <-> f`x = y"
paulson@13353
  1097
apply (simp add: fun_apply_def apply_def, blast) 
paulson@13223
  1098
done
paulson@13223
  1099
paulson@13223
  1100
lemma (in M_axioms) typed_function_abs [simp]: 
paulson@13223
  1101
     "[| M(A); M(f) |] ==> typed_function(M,A,B,f) <-> f \<in> A -> B"
paulson@13223
  1102
apply (auto simp add: typed_function_def relation_def Pi_iff) 
paulson@13223
  1103
apply (blast dest: pair_components_in_M)+
paulson@13223
  1104
done
paulson@13223
  1105
paulson@13223
  1106
lemma (in M_axioms) injection_abs [simp]: 
paulson@13223
  1107
     "[| M(A); M(f) |] ==> injection(M,A,B,f) <-> f \<in> inj(A,B)"
paulson@13223
  1108
apply (simp add: injection_def apply_iff inj_def apply_closed)
paulson@13247
  1109
apply (blast dest: transM [of _ A]) 
paulson@13223
  1110
done
paulson@13223
  1111
paulson@13223
  1112
lemma (in M_axioms) surjection_abs [simp]: 
paulson@13223
  1113
     "[| M(A); M(B); M(f) |] ==> surjection(M,A,B,f) <-> f \<in> surj(A,B)"
paulson@13352
  1114
by (simp add: surjection_def surj_def)
paulson@13223
  1115
paulson@13223
  1116
lemma (in M_axioms) bijection_abs [simp]: 
paulson@13223
  1117
     "[| M(A); M(B); M(f) |] ==> bijection(M,A,B,f) <-> f \<in> bij(A,B)"
paulson@13223
  1118
by (simp add: bijection_def bij_def)
paulson@13223
  1119
paulson@13223
  1120
paulson@13290
  1121
subsubsection{*Composition of relations*}
paulson@13223
  1122
paulson@13223
  1123
lemma (in M_axioms) M_comp_iff:
paulson@13223
  1124
     "[| M(r); M(s) |] 
paulson@13223
  1125
      ==> r O s = 
paulson@13223
  1126
          {xz \<in> domain(s) * range(r).  
paulson@13268
  1127
            \<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
  1128
apply (simp add: comp_def)
paulson@13223
  1129
apply (rule equalityI) 
paulson@13247
  1130
 apply clarify 
paulson@13247
  1131
 apply simp 
paulson@13223
  1132
 apply  (blast dest:  transM)+
paulson@13223
  1133
done
paulson@13223
  1134
paulson@13245
  1135
lemma (in M_axioms) comp_closed [intro,simp]: 
paulson@13223
  1136
     "[| M(r); M(s) |] ==> M(r O s)"
paulson@13223
  1137
apply (simp add: M_comp_iff)
paulson@13245
  1138
apply (insert comp_separation [of r s], simp) 
paulson@13245
  1139
done
paulson@13245
  1140
paulson@13245
  1141
lemma (in M_axioms) composition_abs [simp]: 
paulson@13245
  1142
     "[| M(r); M(s); M(t) |] 
paulson@13245
  1143
      ==> composition(M,r,s,t) <-> t = r O s"
paulson@13247
  1144
apply safe
paulson@13245
  1145
 txt{*Proving @{term "composition(M, r, s, r O s)"}*}
paulson@13245
  1146
 prefer 2 
paulson@13245
  1147
 apply (simp add: composition_def comp_def)
paulson@13245
  1148
 apply (blast dest: transM) 
paulson@13245
  1149
txt{*Opposite implication*}
paulson@13245
  1150
apply (rule M_equalityI)
paulson@13245
  1151
  apply (simp add: composition_def comp_def)
paulson@13245
  1152
  apply (blast del: allE dest: transM)+
paulson@13223
  1153
done
paulson@13223
  1154
paulson@13290
  1155
text{*no longer needed*}
paulson@13290
  1156
lemma (in M_axioms) restriction_is_function: 
paulson@13290
  1157
     "[| restriction(M,f,A,z); function(f); M(f); M(A); M(z) |] 
paulson@13290
  1158
      ==> function(z)"
paulson@13290
  1159
apply (rotate_tac 1)
paulson@13290
  1160
apply (simp add: restriction_def ball_iff_equiv) 
paulson@13290
  1161
apply (unfold function_def, blast) 
paulson@13269
  1162
done
paulson@13269
  1163
paulson@13290
  1164
lemma (in M_axioms) restriction_abs [simp]: 
paulson@13290
  1165
     "[| M(f); M(A); M(z) |] 
paulson@13290
  1166
      ==> restriction(M,f,A,z) <-> z = restrict(f,A)"
paulson@13290
  1167
apply (simp add: ball_iff_equiv restriction_def restrict_def)
paulson@13290
  1168
apply (blast intro!: equalityI dest: transM) 
paulson@13290
  1169
done
paulson@13290
  1170
paulson@13223
  1171
paulson@13290
  1172
lemma (in M_axioms) M_restrict_iff:
paulson@13290
  1173
     "M(r) ==> restrict(r,A) = {z \<in> r . \<exists>x\<in>A. \<exists>y[M]. z = \<langle>x, y\<rangle>}"
paulson@13290
  1174
by (simp add: restrict_def, blast dest: transM)
paulson@13290
  1175
paulson@13290
  1176
lemma (in M_axioms) restrict_closed [intro,simp]: 
paulson@13290
  1177
     "[| M(A); M(r) |] ==> M(restrict(r,A))"
paulson@13290
  1178
apply (simp add: M_restrict_iff)
paulson@13290
  1179
apply (insert restrict_separation [of A], simp) 
paulson@13290
  1180
done
paulson@13223
  1181
paulson@13223
  1182
lemma (in M_axioms) Inter_abs [simp]: 
paulson@13223
  1183
     "[| M(A); M(z) |] ==> big_inter(M,A,z) <-> z = Inter(A)"
paulson@13223
  1184
apply (simp add: big_inter_def Inter_def) 
paulson@13223
  1185
apply (blast intro!: equalityI dest: transM) 
paulson@13223
  1186
done
paulson@13223
  1187
paulson@13245
  1188
lemma (in M_axioms) Inter_closed [intro,simp]:
paulson@13223
  1189
     "M(A) ==> M(Inter(A))"
paulson@13245
  1190
by (insert Inter_separation, simp add: Inter_def)
paulson@13223
  1191
paulson@13245
  1192
lemma (in M_axioms) Int_closed [intro,simp]:
paulson@13223
  1193
     "[| M(A); M(B) |] ==> M(A Int B)"
paulson@13223
  1194
apply (subgoal_tac "M({A,B})")
paulson@13247
  1195
apply (frule Inter_closed, force+) 
paulson@13223
  1196
done
paulson@13223
  1197
paulson@13290
  1198
subsubsection{*Functions and function space*}
paulson@13268
  1199
paulson@13245
  1200
text{*M contains all finite functions*}
paulson@13245
  1201
lemma (in M_axioms) finite_fun_closed_lemma [rule_format]: 
paulson@13245
  1202
     "[| n \<in> nat; M(A) |] ==> \<forall>f \<in> n -> A. M(f)"
paulson@13245
  1203
apply (induct_tac n, simp)
paulson@13245
  1204
apply (rule ballI)  
paulson@13245
  1205
apply (simp add: succ_def) 
paulson@13245
  1206
apply (frule fun_cons_restrict_eq)
paulson@13245
  1207
apply (erule ssubst) 
paulson@13245
  1208
apply (subgoal_tac "M(f`x) & restrict(f,x) \<in> x -> A") 
paulson@13245
  1209
 apply (simp add: cons_closed nat_into_M apply_closed) 
paulson@13245
  1210
apply (blast intro: apply_funtype transM restrict_type2) 
paulson@13245
  1211
done
paulson@13245
  1212
paulson@13245
  1213
lemma (in M_axioms) finite_fun_closed [rule_format]: 
paulson@13245
  1214
     "[| f \<in> n -> A; n \<in> nat; M(A) |] ==> M(f)"
paulson@13245
  1215
by (blast intro: finite_fun_closed_lemma) 
paulson@13245
  1216
paulson@13268
  1217
text{*The assumption @{term "M(A->B)"} is unusual, but essential: in 
paulson@13268
  1218
all but trivial cases, A->B cannot be expected to belong to @{term M}.*}
paulson@13268
  1219
lemma (in M_axioms) is_funspace_abs [simp]:
paulson@13268
  1220
     "[|M(A); M(B); M(F); M(A->B)|] ==> is_funspace(M,A,B,F) <-> F = A->B";
paulson@13268
  1221
apply (simp add: is_funspace_def)
paulson@13268
  1222
apply (rule iffI)
paulson@13268
  1223
 prefer 2 apply blast 
paulson@13268
  1224
apply (rule M_equalityI)
paulson@13268
  1225
  apply simp_all
paulson@13268
  1226
done
paulson@13268
  1227
paulson@13268
  1228
lemma (in M_axioms) succ_fun_eq2:
paulson@13268
  1229
     "[|M(B); M(n->B)|] ==>
paulson@13268
  1230
      succ(n) -> B = 
paulson@13268
  1231
      \<Union>{z. p \<in> (n->B)*B, \<exists>f[M]. \<exists>b[M]. p = <f,b> & z = {cons(<n,b>, f)}}"
paulson@13268
  1232
apply (simp add: succ_fun_eq)
paulson@13268
  1233
apply (blast dest: transM)  
paulson@13268
  1234
done
paulson@13268
  1235
paulson@13268
  1236
lemma (in M_axioms) funspace_succ:
paulson@13268
  1237
     "[|M(n); M(B); M(n->B) |] ==> M(succ(n) -> B)"
paulson@13306
  1238
apply (insert funspace_succ_replacement [of n], simp) 
paulson@13268
  1239
apply (force simp add: succ_fun_eq2 univalent_def) 
paulson@13268
  1240
done
paulson@13268
  1241
paulson@13268
  1242
text{*@{term M} contains all finite function spaces.  Needed to prove the
paulson@13268
  1243
absoluteness of transitive closure.*}
paulson@13268
  1244
lemma (in M_axioms) finite_funspace_closed [intro,simp]:
paulson@13268
  1245
     "[|n\<in>nat; M(B)|] ==> M(n->B)"
paulson@13268
  1246
apply (induct_tac n, simp)
paulson@13268
  1247
apply (simp add: funspace_succ nat_into_M) 
paulson@13268
  1248
done
paulson@13268
  1249
paulson@13350
  1250
paulson@13423
  1251
subsection{*Relativization and Absoluteness for Boolean Operators*}
paulson@13423
  1252
paulson@13423
  1253
constdefs
paulson@13423
  1254
  is_bool_of_o :: "[i=>o, o, i] => o"
paulson@13423
  1255
   "is_bool_of_o(M,P,z) == (P & number1(M,z)) | (~P & empty(M,z))"
paulson@13423
  1256
paulson@13423
  1257
  is_not :: "[i=>o, i, i] => o"
paulson@13423
  1258
   "is_not(M,a,z) == (number1(M,a)  & empty(M,z)) | 
paulson@13423
  1259
                     (~number1(M,a) & number1(M,z))"
paulson@13423
  1260
paulson@13423
  1261
  is_and :: "[i=>o, i, i, i] => o"
paulson@13423
  1262
   "is_and(M,a,b,z) == (number1(M,a)  & z=b) | 
paulson@13423
  1263
                       (~number1(M,a) & empty(M,z))"
paulson@13423
  1264
paulson@13423
  1265
  is_or :: "[i=>o, i, i, i] => o"
paulson@13423
  1266
   "is_or(M,a,b,z) == (number1(M,a)  & number1(M,z)) | 
paulson@13423
  1267
                      (~number1(M,a) & z=b)"
paulson@13423
  1268
paulson@13423
  1269
lemma (in M_triv_axioms) bool_of_o_abs [simp]: 
paulson@13423
  1270
     "M(z) ==> is_bool_of_o(M,P,z) <-> z = bool_of_o(P)" 
paulson@13423
  1271
by (simp add: is_bool_of_o_def bool_of_o_def) 
paulson@13423
  1272
paulson@13423
  1273
paulson@13423
  1274
lemma (in M_triv_axioms) not_abs [simp]: 
paulson@13423
  1275
     "[| M(a); M(z)|] ==> is_not(M,a,z) <-> z = not(a)"
paulson@13423
  1276
by (simp add: Bool.not_def cond_def is_not_def) 
paulson@13423
  1277
paulson@13423
  1278
lemma (in M_triv_axioms) and_abs [simp]: 
paulson@13423
  1279
     "[| M(a); M(b); M(z)|] ==> is_and(M,a,b,z) <-> z = a and b"
paulson@13423
  1280
by (simp add: Bool.and_def cond_def is_and_def) 
paulson@13423
  1281
paulson@13423
  1282
lemma (in M_triv_axioms) or_abs [simp]: 
paulson@13423
  1283
     "[| M(a); M(b); M(z)|] ==> is_or(M,a,b,z) <-> z = a or b"
paulson@13423
  1284
by (simp add: Bool.or_def cond_def is_or_def)
paulson@13423
  1285
paulson@13423
  1286
paulson@13423
  1287
lemma (in M_triv_axioms) bool_of_o_closed [intro,simp]:
paulson@13423
  1288
     "M(bool_of_o(P))"
paulson@13423
  1289
by (simp add: bool_of_o_def) 
paulson@13423
  1290
paulson@13423
  1291
lemma (in M_triv_axioms) and_closed [intro,simp]:
paulson@13423
  1292
     "[| M(p); M(q) |] ==> M(p and q)"
paulson@13423
  1293
by (simp add: and_def cond_def) 
paulson@13423
  1294
paulson@13423
  1295
lemma (in M_triv_axioms) or_closed [intro,simp]:
paulson@13423
  1296
     "[| M(p); M(q) |] ==> M(p or q)"
paulson@13423
  1297
by (simp add: or_def cond_def) 
paulson@13423
  1298
paulson@13423
  1299
lemma (in M_triv_axioms) not_closed [intro,simp]:
paulson@13423
  1300
     "M(p) ==> M(not(p))"
paulson@13423
  1301
by (simp add: Bool.not_def cond_def) 
paulson@13423
  1302
paulson@13423
  1303
paulson@13397
  1304
subsection{*Relativization and Absoluteness for List Operators*}
paulson@13397
  1305
paulson@13397
  1306
constdefs
paulson@13397
  1307
paulson@13397
  1308
  is_Nil :: "[i=>o, i] => o"
paulson@13397
  1309
     --{* because @{term "[] \<equiv> Inl(0)"}*}
paulson@13397
  1310
    "is_Nil(M,xs) == \<exists>zero[M]. empty(M,zero) & is_Inl(M,zero,xs)"
paulson@13397
  1311
paulson@13397
  1312
  is_Cons :: "[i=>o,i,i,i] => o"
paulson@13397
  1313
     --{* because @{term "Cons(a, l) \<equiv> Inr(\<langle>a,l\<rangle>)"}*}
paulson@13397
  1314
    "is_Cons(M,a,l,Z) == \<exists>p[M]. pair(M,a,l,p) & is_Inr(M,p,Z)"
paulson@13397
  1315
paulson@13397
  1316
paulson@13397
  1317
lemma (in M_triv_axioms) Nil_in_M [intro,simp]: "M(Nil)"
paulson@13397
  1318
by (simp add: Nil_def)
paulson@13397
  1319
paulson@13397
  1320
lemma (in M_triv_axioms) Nil_abs [simp]: "M(Z) ==> is_Nil(M,Z) <-> (Z = Nil)"
paulson@13397
  1321
by (simp add: is_Nil_def Nil_def)
paulson@13397
  1322
paulson@13397
  1323
lemma (in M_triv_axioms) Cons_in_M_iff [iff]: "M(Cons(a,l)) <-> M(a) & M(l)"
paulson@13397
  1324
by (simp add: Cons_def) 
paulson@13397
  1325
paulson@13397
  1326
lemma (in M_triv_axioms) Cons_abs [simp]:
paulson@13397
  1327
     "[|M(a); M(l); M(Z)|] ==> is_Cons(M,a,l,Z) <-> (Z = Cons(a,l))"
paulson@13397
  1328
by (simp add: is_Cons_def Cons_def)
paulson@13397
  1329
paulson@13397
  1330
paulson@13397
  1331
constdefs
paulson@13397
  1332
paulson@13397
  1333
  quasilist :: "i => o"
paulson@13397
  1334
    "quasilist(xs) == xs=Nil | (\<exists>x l. xs = Cons(x,l))"
paulson@13397
  1335
paulson@13397
  1336
  is_quasilist :: "[i=>o,i] => o"
paulson@13397
  1337
    "is_quasilist(M,z) == is_Nil(M,z) | (\<exists>x[M]. \<exists>l[M]. is_Cons(M,x,l,z))"
paulson@13397
  1338
paulson@13397
  1339
  list_case' :: "[i, [i,i]=>i, i] => i"
paulson@13397
  1340
    --{*A version of @{term list_case} that's always defined.*}
paulson@13397
  1341
    "list_case'(a,b,xs) == 
paulson@13397
  1342
       if quasilist(xs) then list_case(a,b,xs) else 0"  
paulson@13397
  1343
paulson@13397
  1344
  is_list_case :: "[i=>o, i, [i,i,i]=>o, i, i] => o"
paulson@13397
  1345
    --{*Returns 0 for non-lists*}
paulson@13397
  1346
    "is_list_case(M, a, is_b, xs, z) == 
paulson@13397
  1347
       (is_Nil(M,xs) --> z=a) &
paulson@13397
  1348
       (\<forall>x[M]. \<forall>l[M]. is_Cons(M,x,l,xs) --> is_b(x,l,z)) &
paulson@13397
  1349
       (is_quasilist(M,xs) | empty(M,z))"
paulson@13397
  1350
paulson@13397
  1351
  hd' :: "i => i"
paulson@13397
  1352
    --{*A version of @{term hd} that's always defined.*}
paulson@13397
  1353
    "hd'(xs) == if quasilist(xs) then hd(xs) else 0"  
paulson@13397
  1354
paulson@13397
  1355
  tl' :: "i => i"
paulson@13397
  1356
    --{*A version of @{term tl} that's always defined.*}
paulson@13397
  1357
    "tl'(xs) == if quasilist(xs) then tl(xs) else 0"  
paulson@13397
  1358
paulson@13397
  1359
  is_hd :: "[i=>o,i,i] => o"
paulson@13397
  1360
     --{* @{term "hd([]) = 0"} no constraints if not a list.
paulson@13397
  1361
          Avoiding implication prevents the simplifier's looping.*}
paulson@13397
  1362
    "is_hd(M,xs,H) == 
paulson@13397
  1363
       (is_Nil(M,xs) --> empty(M,H)) &
paulson@13397
  1364
       (\<forall>x[M]. \<forall>l[M]. ~ is_Cons(M,x,l,xs) | H=x) &
paulson@13397
  1365
       (is_quasilist(M,xs) | empty(M,H))"
paulson@13397
  1366
paulson@13397
  1367
  is_tl :: "[i=>o,i,i] => o"
paulson@13397
  1368
     --{* @{term "tl([]) = []"}; see comments about @{term is_hd}*}
paulson@13397
  1369
    "is_tl(M,xs,T) == 
paulson@13397
  1370
       (is_Nil(M,xs) --> T=xs) &
paulson@13397
  1371
       (\<forall>x[M]. \<forall>l[M]. ~ is_Cons(M,x,l,xs) | T=l) &
paulson@13397
  1372
       (is_quasilist(M,xs) | empty(M,T))"
paulson@13397
  1373
paulson@13397
  1374
subsubsection{*@{term quasilist}: For Case-Splitting with @{term list_case'}*}
paulson@13397
  1375
paulson@13397
  1376
lemma [iff]: "quasilist(Nil)"
paulson@13397
  1377
by (simp add: quasilist_def)
paulson@13397
  1378
paulson@13397
  1379
lemma [iff]: "quasilist(Cons(x,l))"
paulson@13397
  1380
by (simp add: quasilist_def)
paulson@13397
  1381
paulson@13397
  1382
lemma list_imp_quasilist: "l \<in> list(A) ==> quasilist(l)"
paulson@13397
  1383
by (erule list.cases, simp_all)
paulson@13397
  1384
paulson@13397
  1385
subsubsection{*@{term list_case'}, the Modified Version of @{term list_case}*}
paulson@13397
  1386
paulson@13397
  1387
lemma list_case'_Nil [simp]: "list_case'(a,b,Nil) = a"
paulson@13397
  1388
by (simp add: list_case'_def quasilist_def)
paulson@13397
  1389
paulson@13397
  1390
lemma list_case'_Cons [simp]: "list_case'(a,b,Cons(x,l)) = b(x,l)"
paulson@13397
  1391
by (simp add: list_case'_def quasilist_def)
paulson@13397
  1392
paulson@13397
  1393
lemma non_list_case: "~ quasilist(x) ==> list_case'(a,b,x) = 0" 
paulson@13397
  1394
by (simp add: quasilist_def list_case'_def) 
paulson@13397
  1395
paulson@13397
  1396
lemma list_case'_eq_list_case [simp]:
paulson@13397
  1397
     "xs \<in> list(A) ==>list_case'(a,b,xs) = list_case(a,b,xs)"
paulson@13397
  1398
by (erule list.cases, simp_all)
paulson@13397
  1399
paulson@13397
  1400
lemma (in M_axioms) list_case'_closed [intro,simp]:
paulson@13397
  1401
  "[|M(k); M(a); \<forall>x[M]. \<forall>y[M]. M(b(x,y))|] ==> M(list_case'(a,b,k))"
paulson@13397
  1402
apply (case_tac "quasilist(k)") 
paulson@13397
  1403
 apply (simp add: quasilist_def, force) 
paulson@13397
  1404
apply (simp add: non_list_case) 
paulson@13397
  1405
done
paulson@13397
  1406
paulson@13397
  1407
lemma (in M_triv_axioms) quasilist_abs [simp]: 
paulson@13397
  1408
     "M(z) ==> is_quasilist(M,z) <-> quasilist(z)"
paulson@13397
  1409
by (auto simp add: is_quasilist_def quasilist_def)
paulson@13397
  1410
paulson@13397
  1411
lemma (in M_triv_axioms) list_case_abs [simp]: 
paulson@13397
  1412
     "[| relativize2(M,is_b,b); M(k); M(z) |] 
paulson@13397
  1413
      ==> is_list_case(M,a,is_b,k,z) <-> z = list_case'(a,b,k)"
paulson@13397
  1414
apply (case_tac "quasilist(k)") 
paulson@13397
  1415
 prefer 2 
paulson@13397
  1416
 apply (simp add: is_list_case_def non_list_case) 
paulson@13397
  1417
 apply (force simp add: quasilist_def) 
paulson@13397
  1418
apply (simp add: quasilist_def is_list_case_def)
paulson@13397
  1419
apply (elim disjE exE) 
paulson@13397
  1420
 apply (simp_all add: relativize2_def) 
paulson@13397
  1421
done
paulson@13397
  1422
paulson@13397
  1423
paulson@13397
  1424
subsubsection{*The Modified Operators @{term hd'} and @{term tl'}*}
paulson@13397
  1425
paulson@13397
  1426
lemma (in M_triv_axioms) is_hd_Nil: "is_hd(M,[],Z) <-> empty(M,Z)"
paulson@13397
  1427
by (simp add: is_hd_def )
paulson@13397
  1428
paulson@13397
  1429
lemma (in M_triv_axioms) is_hd_Cons:
paulson@13397
  1430
     "[|M(a); M(l)|] ==> is_hd(M,Cons(a,l),Z) <-> Z = a"
paulson@13397
  1431
by (force simp add: is_hd_def ) 
paulson@13397
  1432
paulson@13397
  1433
lemma (in M_triv_axioms) hd_abs [simp]:
paulson@13397
  1434
     "[|M(x); M(y)|] ==> is_hd(M,x,y) <-> y = hd'(x)"
paulson@13397
  1435
apply (simp add: hd'_def)
paulson@13397
  1436
apply (intro impI conjI)
paulson@13397
  1437
 prefer 2 apply (force simp add: is_hd_def) 
paulson@13397
  1438
apply (simp add: quasilist_def is_hd_def )
paulson@13397
  1439
apply (elim disjE exE, auto)
paulson@13397
  1440
done 
paulson@13397
  1441
paulson@13397
  1442
lemma (in M_triv_axioms) is_tl_Nil: "is_tl(M,[],Z) <-> Z = []"
paulson@13397
  1443
by (simp add: is_tl_def )
paulson@13397
  1444
paulson@13397
  1445
lemma (in M_triv_axioms) is_tl_Cons:
paulson@13397
  1446
     "[|M(a); M(l)|] ==> is_tl(M,Cons(a,l),Z) <-> Z = l"
paulson@13397
  1447
by (force simp add: is_tl_def ) 
paulson@13397
  1448
paulson@13397
  1449
lemma (in M_triv_axioms) tl_abs [simp]:
paulson@13397
  1450
     "[|M(x); M(y)|] ==> is_tl(M,x,y) <-> y = tl'(x)"
paulson@13397
  1451
apply (simp add: tl'_def)
paulson@13397
  1452
apply (intro impI conjI)
paulson@13397
  1453
 prefer 2 apply (force simp add: is_tl_def) 
paulson@13397
  1454
apply (simp add: quasilist_def is_tl_def )
paulson@13397
  1455
apply (elim disjE exE, auto)
paulson@13397
  1456
done 
paulson@13397
  1457
paulson@13397
  1458
lemma (in M_triv_axioms) relativize1_tl: "relativize1(M, is_tl(M), tl')"  
paulson@13397
  1459
by (simp add: relativize1_def)
paulson@13397
  1460
paulson@13397
  1461
lemma hd'_Nil: "hd'([]) = 0"
paulson@13397
  1462
by (simp add: hd'_def)
paulson@13397
  1463
paulson@13397
  1464
lemma hd'_Cons: "hd'(Cons(a,l)) = a"
paulson@13397
  1465
by (simp add: hd'_def)
paulson@13397
  1466
paulson@13397
  1467
lemma tl'_Nil: "tl'([]) = []"
paulson@13397
  1468
by (simp add: tl'_def)
paulson@13397
  1469
paulson@13397
  1470
lemma tl'_Cons: "tl'(Cons(a,l)) = l"
paulson@13397
  1471
by (simp add: tl'_def)
paulson@13397
  1472
paulson@13397
  1473
lemma iterates_tl_Nil: "n \<in> nat ==> tl'^n ([]) = []"
paulson@13397
  1474
apply (induct_tac n) 
paulson@13397
  1475
apply (simp_all add: tl'_Nil) 
paulson@13397
  1476
done
paulson@13397
  1477
paulson@13397
  1478
lemma (in M_axioms) tl'_closed: "M(x) ==> M(tl'(x))"
paulson@13397
  1479
apply (simp add: tl'_def)
paulson@13397
  1480
apply (force simp add: quasilist_def)
paulson@13397
  1481
done
paulson@13397
  1482
paulson@13397
  1483
paulson@13223
  1484
end