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