| author | wenzelm | 
| Tue, 12 Jan 1999 15:17:37 +0100 | |
| changeset 6093 | 87bf8c03b169 | 
| parent 5467 | f864dbcda5f1 | 
| child 6111 | 5347c9a22897 | 
| permissions | -rw-r--r-- | 
| 1461 | 1  | 
(* Title: ZF/ZF.ML  | 
| 0 | 2  | 
ID: $Id$  | 
| 1461 | 3  | 
Author: Lawrence C Paulson and Martin D Coen, CU Computer Laboratory  | 
| 435 | 4  | 
Copyright 1994 University of Cambridge  | 
| 0 | 5  | 
|
6  | 
Basic introduction and elimination rules for Zermelo-Fraenkel Set Theory  | 
|
7  | 
*)  | 
|
8  | 
||
9  | 
open ZF;  | 
|
10  | 
||
| 
825
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
11  | 
(*Useful examples: singletonI RS subst_elem, subst_elem RSN (2,IntI) *)  | 
| 5137 | 12  | 
Goal "[| b:A; a=b |] ==> a:A";  | 
| 
825
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
13  | 
by (etac ssubst 1);  | 
| 
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
14  | 
by (assume_tac 1);  | 
| 
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
15  | 
val subst_elem = result();  | 
| 
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
16  | 
|
| 2469 | 17  | 
|
| 0 | 18  | 
(*** Bounded universal quantifier ***)  | 
19  | 
||
| 775 | 20  | 
qed_goalw "ballI" ZF.thy [Ball_def]  | 
| 0 | 21  | 
"[| !!x. x:A ==> P(x) |] ==> ALL x:A. P(x)"  | 
22  | 
(fn prems=> [ (REPEAT (ares_tac (prems @ [allI,impI]) 1)) ]);  | 
|
23  | 
||
| 775 | 24  | 
qed_goalw "bspec" ZF.thy [Ball_def]  | 
| 0 | 25  | 
"[| ALL x:A. P(x); x: A |] ==> P(x)"  | 
26  | 
(fn major::prems=>  | 
|
27  | 
[ (rtac (major RS spec RS mp) 1),  | 
|
28  | 
(resolve_tac prems 1) ]);  | 
|
29  | 
||
| 775 | 30  | 
qed_goalw "ballE" ZF.thy [Ball_def]  | 
| 37 | 31  | 
"[| ALL x:A. P(x); P(x) ==> Q; x~:A ==> Q |] ==> Q"  | 
| 0 | 32  | 
(fn major::prems=>  | 
33  | 
[ (rtac (major RS allE) 1),  | 
|
34  | 
(REPEAT (eresolve_tac (prems@[asm_rl,impCE]) 1)) ]);  | 
|
35  | 
||
36  | 
(*Used in the datatype package*)  | 
|
| 775 | 37  | 
qed_goal "rev_bspec" ZF.thy  | 
| 0 | 38  | 
"!!x A P. [| x: A; ALL x:A. P(x) |] ==> P(x)"  | 
39  | 
(fn _ =>  | 
|
40  | 
[ REPEAT (ares_tac [bspec] 1) ]);  | 
|
41  | 
||
42  | 
(*Instantiates x first: better for automatic theorem proving?*)  | 
|
| 775 | 43  | 
qed_goal "rev_ballE" ZF.thy  | 
| 37 | 44  | 
"[| ALL x:A. P(x); x~:A ==> Q; P(x) ==> Q |] ==> Q"  | 
| 0 | 45  | 
(fn major::prems=>  | 
46  | 
[ (rtac (major RS ballE) 1),  | 
|
47  | 
(REPEAT (eresolve_tac prems 1)) ]);  | 
|
48  | 
||
| 2469 | 49  | 
AddSIs [ballI];  | 
50  | 
AddEs [rev_ballE];  | 
|
51  | 
||
| 0 | 52  | 
(*Takes assumptions ALL x:A.P(x) and a:A; creates assumption P(a)*)  | 
53  | 
val ball_tac = dtac bspec THEN' assume_tac;  | 
|
54  | 
||
55  | 
(*Trival rewrite rule; (ALL x:A.P)<->P holds only if A is nonempty!*)  | 
|
| 3840 | 56  | 
qed_goal "ball_triv" ZF.thy "(ALL x:A. P) <-> ((EX x. x:A) --> P)"  | 
| 4091 | 57  | 
(fn _=> [ simp_tac (simpset() addsimps [Ball_def]) 1 ]);  | 
| 3425 | 58  | 
Addsimps [ball_triv];  | 
| 0 | 59  | 
|
60  | 
(*Congruence rule for rewriting*)  | 
|
| 775 | 61  | 
qed_goalw "ball_cong" ZF.thy [Ball_def]  | 
| 
6
 
8ce8c4d13d4d
Installation of new simplifier for ZF.  Deleted all congruence rules not
 
lcp 
parents: 
0 
diff
changeset
 | 
62  | 
"[| A=A'; !!x. x:A' ==> P(x) <-> P'(x) |] ==> Ball(A,P) <-> Ball(A',P')"  | 
| 
 
8ce8c4d13d4d
Installation of new simplifier for ZF.  Deleted all congruence rules not
 
lcp 
parents: 
0 
diff
changeset
 | 
63  | 
(fn prems=> [ (simp_tac (FOL_ss addsimps prems) 1) ]);  | 
| 0 | 64  | 
|
65  | 
(*** Bounded existential quantifier ***)  | 
|
66  | 
||
| 775 | 67  | 
qed_goalw "bexI" ZF.thy [Bex_def]  | 
| 2469 | 68  | 
"!!P. [| P(x); x: A |] ==> EX x:A. P(x)"  | 
| 2877 | 69  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 0 | 70  | 
|
71  | 
(*Not of the general form for such rules; ~EX has become ALL~ *)  | 
|
| 775 | 72  | 
qed_goal "bexCI" ZF.thy  | 
| 3840 | 73  | 
"[| ALL x:A. ~P(x) ==> P(a); a: A |] ==> EX x:A. P(x)"  | 
| 0 | 74  | 
(fn prems=>  | 
75  | 
[ (rtac classical 1),  | 
|
76  | 
(REPEAT (ares_tac (prems@[bexI,ballI,notI,notE]) 1)) ]);  | 
|
77  | 
||
| 775 | 78  | 
qed_goalw "bexE" ZF.thy [Bex_def]  | 
| 0 | 79  | 
"[| EX x:A. P(x); !!x. [| x:A; P(x) |] ==> Q \  | 
80  | 
\ |] ==> Q"  | 
|
81  | 
(fn major::prems=>  | 
|
82  | 
[ (rtac (major RS exE) 1),  | 
|
83  | 
(REPEAT (eresolve_tac (prems @ [asm_rl,conjE]) 1)) ]);  | 
|
84  | 
||
| 2469 | 85  | 
AddIs [bexI];  | 
86  | 
AddSEs [bexE];  | 
|
87  | 
||
| 0 | 88  | 
(*We do not even have (EX x:A. True) <-> True unless A is nonempty!!*)  | 
| 3840 | 89  | 
qed_goal "bex_triv" ZF.thy "(EX x:A. P) <-> ((EX x. x:A) & P)"  | 
| 4091 | 90  | 
(fn _=> [ simp_tac (simpset() addsimps [Bex_def]) 1 ]);  | 
| 3425 | 91  | 
Addsimps [bex_triv];  | 
| 0 | 92  | 
|
| 775 | 93  | 
qed_goalw "bex_cong" ZF.thy [Bex_def]  | 
| 0 | 94  | 
"[| A=A'; !!x. x:A' ==> P(x) <-> P'(x) \  | 
| 
6
 
8ce8c4d13d4d
Installation of new simplifier for ZF.  Deleted all congruence rules not
 
lcp 
parents: 
0 
diff
changeset
 | 
95  | 
\ |] ==> Bex(A,P) <-> Bex(A',P')"  | 
| 
 
8ce8c4d13d4d
Installation of new simplifier for ZF.  Deleted all congruence rules not
 
lcp 
parents: 
0 
diff
changeset
 | 
96  | 
(fn prems=> [ (simp_tac (FOL_ss addsimps prems addcongs [conj_cong]) 1) ]);  | 
| 0 | 97  | 
|
| 2469 | 98  | 
Addcongs [ball_cong, bex_cong];  | 
99  | 
||
100  | 
||
| 0 | 101  | 
(*** Rules for subsets ***)  | 
102  | 
||
| 775 | 103  | 
qed_goalw "subsetI" ZF.thy [subset_def]  | 
| 3840 | 104  | 
"(!!x. x:A ==> x:B) ==> A <= B"  | 
| 0 | 105  | 
(fn prems=> [ (REPEAT (ares_tac (prems @ [ballI]) 1)) ]);  | 
106  | 
||
107  | 
(*Rule in Modus Ponens style [was called subsetE] *)  | 
|
| 775 | 108  | 
qed_goalw "subsetD" ZF.thy [subset_def] "[| A <= B; c:A |] ==> c:B"  | 
| 0 | 109  | 
(fn major::prems=>  | 
110  | 
[ (rtac (major RS bspec) 1),  | 
|
111  | 
(resolve_tac prems 1) ]);  | 
|
112  | 
||
113  | 
(*Classical elimination rule*)  | 
|
| 775 | 114  | 
qed_goalw "subsetCE" ZF.thy [subset_def]  | 
| 37 | 115  | 
"[| A <= B; c~:A ==> P; c:B ==> P |] ==> P"  | 
| 0 | 116  | 
(fn major::prems=>  | 
117  | 
[ (rtac (major RS ballE) 1),  | 
|
118  | 
(REPEAT (eresolve_tac prems 1)) ]);  | 
|
119  | 
||
| 2469 | 120  | 
AddSIs [subsetI];  | 
121  | 
AddEs [subsetCE, subsetD];  | 
|
122  | 
||
123  | 
||
| 0 | 124  | 
(*Takes assumptions A<=B; c:A and creates the assumption c:B *)  | 
125  | 
val set_mp_tac = dtac subsetD THEN' assume_tac;  | 
|
126  | 
||
127  | 
(*Sometimes useful with premises in this order*)  | 
|
| 775 | 128  | 
qed_goal "rev_subsetD" ZF.thy "!!A B c. [| c:A; A<=B |] ==> c:B"  | 
| 2877 | 129  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 0 | 130  | 
|
| 1889 | 131  | 
qed_goal "contra_subsetD" ZF.thy "!!c. [| A <= B; c ~: B |] ==> c ~: A"  | 
| 2877 | 132  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 1889 | 133  | 
|
134  | 
qed_goal "rev_contra_subsetD" ZF.thy "!!c. [| c ~: B; A <= B |] ==> c ~: A"  | 
|
| 2877 | 135  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 1889 | 136  | 
|
| 775 | 137  | 
qed_goal "subset_refl" ZF.thy "A <= A"  | 
| 2877 | 138  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 0 | 139  | 
|
| 2469 | 140  | 
Addsimps [subset_refl];  | 
141  | 
||
142  | 
qed_goal "subset_trans" ZF.thy "!!A B C. [| A<=B; B<=C |] ==> A<=C"  | 
|
| 2877 | 143  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 0 | 144  | 
|
| 435 | 145  | 
(*Useful for proving A<=B by rewriting in some cases*)  | 
| 775 | 146  | 
qed_goalw "subset_iff" ZF.thy [subset_def,Ball_def]  | 
| 435 | 147  | 
"A<=B <-> (ALL x. x:A --> x:B)"  | 
148  | 
(fn _=> [ (rtac iff_refl 1) ]);  | 
|
149  | 
||
| 0 | 150  | 
|
151  | 
(*** Rules for equality ***)  | 
|
152  | 
||
153  | 
(*Anti-symmetry of the subset relation*)  | 
|
| 775 | 154  | 
qed_goal "equalityI" ZF.thy "[| A <= B; B <= A |] ==> A = B"  | 
| 0 | 155  | 
(fn prems=> [ (REPEAT (resolve_tac (prems@[conjI, extension RS iffD2]) 1)) ]);  | 
156  | 
||
| 2493 | 157  | 
AddIs [equalityI];  | 
158  | 
||
| 775 | 159  | 
qed_goal "equality_iffI" ZF.thy "(!!x. x:A <-> x:B) ==> A = B"  | 
| 0 | 160  | 
(fn [prem] =>  | 
161  | 
[ (rtac equalityI 1),  | 
|
162  | 
(REPEAT (ares_tac [subsetI, prem RS iffD1, prem RS iffD2] 1)) ]);  | 
|
163  | 
||
| 2469 | 164  | 
bind_thm ("equalityD1", extension RS iffD1 RS conjunct1);
 | 
165  | 
bind_thm ("equalityD2", extension RS iffD1 RS conjunct2);
 | 
|
| 0 | 166  | 
|
| 775 | 167  | 
qed_goal "equalityE" ZF.thy  | 
| 0 | 168  | 
"[| A = B; [| A<=B; B<=A |] ==> P |] ==> P"  | 
169  | 
(fn prems=>  | 
|
170  | 
[ (DEPTH_SOLVE (resolve_tac (prems@[equalityD1,equalityD2]) 1)) ]);  | 
|
171  | 
||
| 775 | 172  | 
qed_goal "equalityCE" ZF.thy  | 
| 37 | 173  | 
"[| A = B; [| c:A; c:B |] ==> P; [| c~:A; c~:B |] ==> P |] ==> P"  | 
| 0 | 174  | 
(fn major::prems=>  | 
175  | 
[ (rtac (major RS equalityE) 1),  | 
|
176  | 
(REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1)) ]);  | 
|
177  | 
||
178  | 
(*Lemma for creating induction formulae -- for "pattern matching" on p  | 
|
179  | 
To make the induction hypotheses usable, apply "spec" or "bspec" to  | 
|
180  | 
put universal quantifiers over the free variables in p.  | 
|
181  | 
Would it be better to do subgoal_tac "ALL z. p = f(z) --> R(z)" ??*)  | 
|
| 775 | 182  | 
qed_goal "setup_induction" ZF.thy  | 
| 0 | 183  | 
"[| p: A; !!z. z: A ==> p=z --> R |] ==> R"  | 
184  | 
(fn prems=>  | 
|
185  | 
[ (rtac mp 1),  | 
|
186  | 
(REPEAT (resolve_tac (refl::prems) 1)) ]);  | 
|
187  | 
||
188  | 
||
189  | 
(*** Rules for Replace -- the derived form of replacement ***)  | 
|
190  | 
||
| 775 | 191  | 
qed_goalw "Replace_iff" ZF.thy [Replace_def]  | 
| 0 | 192  | 
    "b : {y. x:A, P(x,y)}  <->  (EX x:A. P(x,b) & (ALL y. P(x,y) --> y=b))"
 | 
193  | 
(fn _=>  | 
|
194  | 
[ (rtac (replacement RS iff_trans) 1),  | 
|
195  | 
(REPEAT (ares_tac [refl,bex_cong,iffI,ballI,allI,conjI,impI,ex1I] 1  | 
|
196  | 
ORELSE eresolve_tac [conjE, spec RS mp, ex1_functional] 1)) ]);  | 
|
197  | 
||
198  | 
(*Introduction; there must be a unique y such that P(x,y), namely y=b. *)  | 
|
| 775 | 199  | 
qed_goal "ReplaceI" ZF.thy  | 
| 485 | 200  | 
"[| P(x,b); x: A; !!y. P(x,y) ==> y=b |] ==> \  | 
| 0 | 201  | 
\    b : {y. x:A, P(x,y)}"
 | 
202  | 
(fn prems=>  | 
|
203  | 
[ (rtac (Replace_iff RS iffD2) 1),  | 
|
204  | 
(REPEAT (ares_tac (prems@[bexI,conjI,allI,impI]) 1)) ]);  | 
|
205  | 
||
206  | 
(*Elimination; may asssume there is a unique y such that P(x,y), namely y=b. *)  | 
|
| 775 | 207  | 
qed_goal "ReplaceE" ZF.thy  | 
| 0 | 208  | 
    "[| b : {y. x:A, P(x,y)};  \
 | 
209  | 
\ !!x. [| x: A; P(x,b); ALL y. P(x,y)-->y=b |] ==> R \  | 
|
210  | 
\ |] ==> R"  | 
|
211  | 
(fn prems=>  | 
|
212  | 
[ (rtac (Replace_iff RS iffD1 RS bexE) 1),  | 
|
213  | 
(etac conjE 2),  | 
|
214  | 
(REPEAT (ares_tac prems 1)) ]);  | 
|
215  | 
||
| 485 | 216  | 
(*As above but without the (generally useless) 3rd assumption*)  | 
| 775 | 217  | 
qed_goal "ReplaceE2" ZF.thy  | 
| 485 | 218  | 
    "[| b : {y. x:A, P(x,y)};  \
 | 
219  | 
\ !!x. [| x: A; P(x,b) |] ==> R \  | 
|
220  | 
\ |] ==> R"  | 
|
221  | 
(fn major::prems=>  | 
|
222  | 
[ (rtac (major RS ReplaceE) 1),  | 
|
223  | 
(REPEAT (ares_tac prems 1)) ]);  | 
|
224  | 
||
| 2469 | 225  | 
AddIs [ReplaceI];  | 
226  | 
AddSEs [ReplaceE2];  | 
|
227  | 
||
| 775 | 228  | 
qed_goal "Replace_cong" ZF.thy  | 
| 0 | 229  | 
"[| A=B; !!x y. x:B ==> P(x,y) <-> Q(x,y) |] ==> \  | 
| 
6
 
8ce8c4d13d4d
Installation of new simplifier for ZF.  Deleted all congruence rules not
 
lcp 
parents: 
0 
diff
changeset
 | 
230  | 
\ Replace(A,P) = Replace(B,Q)"  | 
| 0 | 231  | 
(fn prems=>  | 
232  | 
let val substprems = prems RL [subst, ssubst]  | 
|
233  | 
and iffprems = prems RL [iffD1,iffD2]  | 
|
234  | 
in [ (rtac equalityI 1),  | 
|
| 1461 | 235  | 
(REPEAT (eresolve_tac (substprems@[asm_rl, ReplaceE, spec RS mp]) 1  | 
236  | 
ORELSE resolve_tac [subsetI, ReplaceI] 1  | 
|
237  | 
ORELSE (resolve_tac iffprems 1 THEN assume_tac 2))) ]  | 
|
| 0 | 238  | 
end);  | 
239  | 
||
| 2469 | 240  | 
Addcongs [Replace_cong];  | 
241  | 
||
| 0 | 242  | 
(*** Rules for RepFun ***)  | 
243  | 
||
| 775 | 244  | 
qed_goalw "RepFunI" ZF.thy [RepFun_def]  | 
| 0 | 245  | 
    "!!a A. a : A ==> f(a) : {f(x). x:A}"
 | 
246  | 
(fn _ => [ (REPEAT (ares_tac [ReplaceI,refl] 1)) ]);  | 
|
247  | 
||
| 120 | 248  | 
(*Useful for coinduction proofs*)  | 
| 775 | 249  | 
qed_goal "RepFun_eqI" ZF.thy  | 
| 0 | 250  | 
    "!!b a f. [| b=f(a);  a : A |] ==> b : {f(x). x:A}"
 | 
251  | 
(fn _ => [ etac ssubst 1, etac RepFunI 1 ]);  | 
|
252  | 
||
| 775 | 253  | 
qed_goalw "RepFunE" ZF.thy [RepFun_def]  | 
| 0 | 254  | 
    "[| b : {f(x). x:A};  \
 | 
255  | 
\ !!x.[| x:A; b=f(x) |] ==> P |] ==> \  | 
|
256  | 
\ P"  | 
|
257  | 
(fn major::prems=>  | 
|
258  | 
[ (rtac (major RS ReplaceE) 1),  | 
|
259  | 
(REPEAT (ares_tac prems 1)) ]);  | 
|
260  | 
||
| 2716 | 261  | 
AddIs [RepFun_eqI];  | 
| 2469 | 262  | 
AddSEs [RepFunE];  | 
263  | 
||
| 775 | 264  | 
qed_goalw "RepFun_cong" ZF.thy [RepFun_def]  | 
| 
6
 
8ce8c4d13d4d
Installation of new simplifier for ZF.  Deleted all congruence rules not
 
lcp 
parents: 
0 
diff
changeset
 | 
265  | 
"[| A=B; !!x. x:B ==> f(x)=g(x) |] ==> RepFun(A,f) = RepFun(B,g)"  | 
| 4091 | 266  | 
(fn prems=> [ (simp_tac (simpset() addsimps prems) 1) ]);  | 
| 2469 | 267  | 
|
268  | 
Addcongs [RepFun_cong];  | 
|
| 0 | 269  | 
|
| 775 | 270  | 
qed_goalw "RepFun_iff" ZF.thy [Bex_def]  | 
| 485 | 271  | 
    "b : {f(x). x:A} <-> (EX x:A. b=f(x))"
 | 
| 2877 | 272  | 
(fn _ => [Blast_tac 1]);  | 
| 485 | 273  | 
|
| 5067 | 274  | 
Goal "{x. x:A} = A";
 | 
| 2877 | 275  | 
by (Blast_tac 1);  | 
| 2469 | 276  | 
qed "triv_RepFun";  | 
277  | 
||
278  | 
Addsimps [RepFun_iff, triv_RepFun];  | 
|
| 0 | 279  | 
|
280  | 
(*** Rules for Collect -- forming a subset by separation ***)  | 
|
281  | 
||
282  | 
(*Separation is derivable from Replacement*)  | 
|
| 775 | 283  | 
qed_goalw "separation" ZF.thy [Collect_def]  | 
| 0 | 284  | 
    "a : {x:A. P(x)} <-> a:A & P(a)"
 | 
| 2877 | 285  | 
(fn _=> [Blast_tac 1]);  | 
| 2469 | 286  | 
|
287  | 
Addsimps [separation];  | 
|
| 0 | 288  | 
|
| 775 | 289  | 
qed_goal "CollectI" ZF.thy  | 
| 2469 | 290  | 
    "!!P. [| a:A;  P(a) |] ==> a : {x:A. P(x)}"
 | 
291  | 
(fn _=> [ Asm_simp_tac 1 ]);  | 
|
| 0 | 292  | 
|
| 775 | 293  | 
qed_goal "CollectE" ZF.thy  | 
| 0 | 294  | 
    "[| a : {x:A. P(x)};  [| a:A; P(a) |] ==> R |] ==> R"
 | 
295  | 
(fn prems=>  | 
|
296  | 
[ (rtac (separation RS iffD1 RS conjE) 1),  | 
|
297  | 
(REPEAT (ares_tac prems 1)) ]);  | 
|
298  | 
||
| 2469 | 299  | 
qed_goal "CollectD1" ZF.thy "!!P. a : {x:A. P(x)} ==> a:A"
 | 
300  | 
(fn _=> [ (etac CollectE 1), (assume_tac 1) ]);  | 
|
| 0 | 301  | 
|
| 2469 | 302  | 
qed_goal "CollectD2" ZF.thy "!!P. a : {x:A. P(x)} ==> P(a)"
 | 
303  | 
(fn _=> [ (etac CollectE 1), (assume_tac 1) ]);  | 
|
| 0 | 304  | 
|
| 775 | 305  | 
qed_goalw "Collect_cong" ZF.thy [Collect_def]  | 
| 
6
 
8ce8c4d13d4d
Installation of new simplifier for ZF.  Deleted all congruence rules not
 
lcp 
parents: 
0 
diff
changeset
 | 
306  | 
"[| A=B; !!x. x:B ==> P(x) <-> Q(x) |] ==> Collect(A,P) = Collect(B,Q)"  | 
| 4091 | 307  | 
(fn prems=> [ (simp_tac (simpset() addsimps prems) 1) ]);  | 
| 2469 | 308  | 
|
309  | 
AddSIs [CollectI];  | 
|
310  | 
AddSEs [CollectE];  | 
|
311  | 
Addcongs [Collect_cong];  | 
|
| 0 | 312  | 
|
313  | 
(*** Rules for Unions ***)  | 
|
314  | 
||
| 2469 | 315  | 
Addsimps [Union_iff];  | 
316  | 
||
| 0 | 317  | 
(*The order of the premises presupposes that C is rigid; A may be flexible*)  | 
| 2469 | 318  | 
qed_goal "UnionI" ZF.thy "!!C. [| B: C; A: B |] ==> A: Union(C)"  | 
| 2877 | 319  | 
(fn _=> [ Simp_tac 1, Blast_tac 1 ]);  | 
| 0 | 320  | 
|
| 775 | 321  | 
qed_goal "UnionE" ZF.thy  | 
| 0 | 322  | 
"[| A : Union(C); !!B.[| A: B; B: C |] ==> R |] ==> R"  | 
323  | 
(fn prems=>  | 
|
| 485 | 324  | 
[ (resolve_tac [Union_iff RS iffD1 RS bexE] 1),  | 
| 0 | 325  | 
(REPEAT (ares_tac prems 1)) ]);  | 
326  | 
||
327  | 
(*** Rules for Unions of families ***)  | 
|
328  | 
(* UN x:A. B(x) abbreviates Union({B(x). x:A}) *)
 | 
|
329  | 
||
| 775 | 330  | 
qed_goalw "UN_iff" ZF.thy [Bex_def]  | 
| 485 | 331  | 
"b : (UN x:A. B(x)) <-> (EX x:A. b : B(x))"  | 
| 2877 | 332  | 
(fn _=> [ Simp_tac 1, Blast_tac 1 ]);  | 
| 2469 | 333  | 
|
334  | 
Addsimps [UN_iff];  | 
|
| 485 | 335  | 
|
| 0 | 336  | 
(*The order of the premises presupposes that A is rigid; b may be flexible*)  | 
| 2469 | 337  | 
qed_goal "UN_I" ZF.thy "!!A B. [| a: A; b: B(a) |] ==> b: (UN x:A. B(x))"  | 
| 2877 | 338  | 
(fn _=> [ Simp_tac 1, Blast_tac 1 ]);  | 
| 0 | 339  | 
|
| 775 | 340  | 
qed_goal "UN_E" ZF.thy  | 
| 0 | 341  | 
"[| b : (UN x:A. B(x)); !!x.[| x: A; b: B(x) |] ==> R |] ==> R"  | 
342  | 
(fn major::prems=>  | 
|
343  | 
[ (rtac (major RS UnionE) 1),  | 
|
344  | 
(REPEAT (eresolve_tac (prems@[asm_rl, RepFunE, subst]) 1)) ]);  | 
|
345  | 
||
| 775 | 346  | 
qed_goal "UN_cong" ZF.thy  | 
| 3840 | 347  | 
"[| A=B; !!x. x:B ==> C(x)=D(x) |] ==> (UN x:A. C(x)) = (UN x:B. D(x))"  | 
| 4091 | 348  | 
(fn prems=> [ (simp_tac (simpset() addsimps prems) 1) ]);  | 
| 2469 | 349  | 
|
350  | 
(*No "Addcongs [UN_cong]" because UN is a combination of constants*)  | 
|
351  | 
||
352  | 
(* UN_E appears before UnionE so that it is tried first, to avoid expensive  | 
|
353  | 
calls to hyp_subst_tac. Cannot include UN_I as it is unsafe: would enlarge  | 
|
354  | 
the search space.*)  | 
|
355  | 
AddIs [UnionI];  | 
|
356  | 
AddSEs [UN_E];  | 
|
357  | 
AddSEs [UnionE];  | 
|
358  | 
||
359  | 
||
360  | 
(*** Rules for Inter ***)  | 
|
361  | 
||
362  | 
(*Not obviously useful towards proving InterI, InterD, InterE*)  | 
|
363  | 
qed_goalw "Inter_iff" ZF.thy [Inter_def,Ball_def]  | 
|
364  | 
"A : Inter(C) <-> (ALL x:C. A: x) & (EX x. x:C)"  | 
|
| 2877 | 365  | 
(fn _=> [ Simp_tac 1, Blast_tac 1 ]);  | 
| 435 | 366  | 
|
| 2469 | 367  | 
(* Intersection is well-behaved only if the family is non-empty! *)  | 
| 
2815
 
c05fa3ce5439
Improved intersection rule InterI: now truly safe, since the unsafeness is
 
paulson 
parents: 
2716 
diff
changeset
 | 
368  | 
qed_goal "InterI" ZF.thy  | 
| 
 
c05fa3ce5439
Improved intersection rule InterI: now truly safe, since the unsafeness is
 
paulson 
parents: 
2716 
diff
changeset
 | 
369  | 
"[| !!x. x: C ==> A: x; EX c. c:C |] ==> A : Inter(C)"  | 
| 4091 | 370  | 
(fn prems=> [ (simp_tac (simpset() addsimps [Inter_iff]) 1),  | 
371  | 
blast_tac (claset() addIs prems) 1 ]);  | 
|
| 2469 | 372  | 
|
373  | 
(*A "destruct" rule -- every B in C contains A as an element, but  | 
|
374  | 
A:B can hold when B:C does not! This rule is analogous to "spec". *)  | 
|
375  | 
qed_goalw "InterD" ZF.thy [Inter_def]  | 
|
376  | 
"!!C. [| A : Inter(C); B : C |] ==> A : B"  | 
|
| 2877 | 377  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 2469 | 378  | 
|
379  | 
(*"Classical" elimination rule -- does not require exhibiting B:C *)  | 
|
380  | 
qed_goalw "InterE" ZF.thy [Inter_def]  | 
|
| 2716 | 381  | 
"[| A : Inter(C); B~:C ==> R; A:B ==> R |] ==> R"  | 
| 2469 | 382  | 
(fn major::prems=>  | 
383  | 
[ (rtac (major RS CollectD2 RS ballE) 1),  | 
|
384  | 
(REPEAT (eresolve_tac prems 1)) ]);  | 
|
385  | 
||
386  | 
AddSIs [InterI];  | 
|
| 2716 | 387  | 
AddEs [InterD, InterE];  | 
| 0 | 388  | 
|
389  | 
(*** Rules for Intersections of families ***)  | 
|
390  | 
(* INT x:A. B(x) abbreviates Inter({B(x). x:A}) *)
 | 
|
391  | 
||
| 2469 | 392  | 
qed_goalw "INT_iff" ZF.thy [Inter_def]  | 
| 485 | 393  | 
"b : (INT x:A. B(x)) <-> (ALL x:A. b : B(x)) & (EX x. x:A)"  | 
| 2469 | 394  | 
(fn _=> [ Simp_tac 1, Best_tac 1 ]);  | 
| 485 | 395  | 
|
| 775 | 396  | 
qed_goal "INT_I" ZF.thy  | 
| 0 | 397  | 
"[| !!x. x: A ==> b: B(x); a: A |] ==> b: (INT x:A. B(x))"  | 
| 4091 | 398  | 
(fn prems=> [ blast_tac (claset() addIs prems) 1 ]);  | 
| 0 | 399  | 
|
| 775 | 400  | 
qed_goal "INT_E" ZF.thy  | 
| 0 | 401  | 
"[| b : (INT x:A. B(x)); a: A |] ==> b : B(a)"  | 
402  | 
(fn [major,minor]=>  | 
|
403  | 
[ (rtac (major RS InterD) 1),  | 
|
404  | 
(rtac (minor RS RepFunI) 1) ]);  | 
|
405  | 
||
| 775 | 406  | 
qed_goal "INT_cong" ZF.thy  | 
| 3840 | 407  | 
"[| A=B; !!x. x:B ==> C(x)=D(x) |] ==> (INT x:A. C(x)) = (INT x:B. D(x))"  | 
| 4091 | 408  | 
(fn prems=> [ (simp_tac (simpset() addsimps prems) 1) ]);  | 
| 2469 | 409  | 
|
410  | 
(*No "Addcongs [INT_cong]" because INT is a combination of constants*)  | 
|
| 435 | 411  | 
|
| 0 | 412  | 
|
413  | 
(*** Rules for Powersets ***)  | 
|
414  | 
||
| 775 | 415  | 
qed_goal "PowI" ZF.thy "A <= B ==> A : Pow(B)"  | 
| 485 | 416  | 
(fn [prem]=> [ (rtac (prem RS (Pow_iff RS iffD2)) 1) ]);  | 
| 0 | 417  | 
|
| 775 | 418  | 
qed_goal "PowD" ZF.thy "A : Pow(B) ==> A<=B"  | 
| 485 | 419  | 
(fn [major]=> [ (rtac (major RS (Pow_iff RS iffD1)) 1) ]);  | 
| 0 | 420  | 
|
| 2469 | 421  | 
AddSIs [PowI];  | 
422  | 
AddSDs [PowD];  | 
|
423  | 
||
| 0 | 424  | 
|
425  | 
(*** Rules for the empty set ***)  | 
|
426  | 
||
427  | 
(*The set {x:0.False} is empty; by foundation it equals 0 
 | 
|
428  | 
See Suppes, page 21.*)  | 
|
| 2469 | 429  | 
qed_goal "not_mem_empty" ZF.thy "a ~: 0"  | 
430  | 
(fn _=>  | 
|
431  | 
[ (cut_facts_tac [foundation] 1),  | 
|
| 4091 | 432  | 
(best_tac (claset() addDs [equalityD2]) 1) ]);  | 
| 2469 | 433  | 
|
434  | 
bind_thm ("emptyE", not_mem_empty RS notE);
 | 
|
435  | 
||
436  | 
Addsimps [not_mem_empty];  | 
|
437  | 
AddSEs [emptyE];  | 
|
| 0 | 438  | 
|
| 775 | 439  | 
qed_goal "empty_subsetI" ZF.thy "0 <= A"  | 
| 2877 | 440  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 2469 | 441  | 
|
442  | 
Addsimps [empty_subsetI];  | 
|
| 0 | 443  | 
|
| 775 | 444  | 
qed_goal "equals0I" ZF.thy "[| !!y. y:A ==> False |] ==> A=0"  | 
| 4091 | 445  | 
(fn prems=> [ blast_tac (claset() addDs prems) 1 ]);  | 
| 0 | 446  | 
|
| 5467 | 447  | 
qed_goal "equals0D" ZF.thy "!!P. A=0 ==> a ~: A"  | 
448  | 
(fn _=> [ Blast_tac 1 ]);  | 
|
| 0 | 449  | 
|
| 5467 | 450  | 
AddDs [equals0D, sym RS equals0D];  | 
| 
5265
 
9d1d4c43c76d
Disjointness reasoning by  AddEs [equals0E, sym RS equals0E]
 
paulson 
parents: 
5242 
diff
changeset
 | 
451  | 
|
| 
825
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
452  | 
qed_goal "not_emptyI" ZF.thy "!!A a. a:A ==> A ~= 0"  | 
| 2877 | 453  | 
(fn _=> [ Blast_tac 1 ]);  | 
| 
825
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
454  | 
|
| 
868
 
452f1e6ae3bc
Deleted semicolon at the end of the qed_goal line, which was preventing
 
lcp 
parents: 
854 
diff
changeset
 | 
455  | 
qed_goal "not_emptyE" ZF.thy "[| A ~= 0; !!x. x:A ==> R |] ==> R"  | 
| 
825
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
456  | 
(fn [major,minor]=>  | 
| 
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
457  | 
[ rtac ([major, equals0I] MRS swap) 1,  | 
| 
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
458  | 
swap_res_tac [minor] 1,  | 
| 
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
459  | 
assume_tac 1 ]);  | 
| 
 
76d9575950f2
Added Krzysztof's theorems subst_elem, not_emptyI, not_emptyE
 
lcp 
parents: 
775 
diff
changeset
 | 
460  | 
|
| 0 | 461  | 
|
| 748 | 462  | 
(*** Cantor's Theorem: There is no surjection from a set to its powerset. ***)  | 
463  | 
||
464  | 
val cantor_cs = FOL_cs (*precisely the rules needed for the proof*)  | 
|
465  | 
addSIs [ballI, CollectI, PowI, subsetI] addIs [bexI]  | 
|
466  | 
addSEs [CollectE, equalityCE];  | 
|
467  | 
||
468  | 
(*The search is undirected; similar proof attempts may fail.  | 
|
469  | 
b represents ANY map, such as (lam x:A.b(x)): A->Pow(A). *)  | 
|
| 775 | 470  | 
qed_goal "cantor" ZF.thy "EX S: Pow(A). ALL x:A. b(x) ~= S"  | 
| 2877 | 471  | 
(fn _ => [best_tac cantor_cs 1]);  | 
| 748 | 472  | 
|
| 516 | 473  | 
(*Lemma for the inductive definition in Zorn.thy*)  | 
| 775 | 474  | 
qed_goal "Union_in_Pow" ZF.thy  | 
| 516 | 475  | 
"!!Y. Y : Pow(Pow(A)) ==> Union(Y) : Pow(A)"  | 
| 2877 | 476  | 
(fn _ => [Blast_tac 1]);  | 
| 
1902
 
e349b91cf197
Added function for storing default claset in theory.
 
berghofe 
parents: 
1889 
diff
changeset
 | 
477  |