author | nipkow |
Thu, 29 Mar 2001 13:59:54 +0200 | |
changeset 11232 | 558a4feebb04 |
parent 11227 | d9bda7cbdf56 |
child 11290 | c6a4100d1cd0 |
permissions | -rw-r--r-- |
9422 | 1 |
(* Title: HOL/Set.ML |
923 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
923 | 4 |
Copyright 1991 University of Cambridge |
5 |
||
1985
84cf16192e03
Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
1937
diff
changeset
|
6 |
Set theory for higher-order logic. A set is simply a predicate. |
923 | 7 |
*) |
8 |
||
1548 | 9 |
section "Relating predicates and sets"; |
10 |
||
3469
61d927bd57ec
Now Collect_mem_eq is a default simprule (how could it have ever been omitted?
paulson
parents:
3420
diff
changeset
|
11 |
Addsimps [Collect_mem_eq]; |
61d927bd57ec
Now Collect_mem_eq is a default simprule (how could it have ever been omitted?
paulson
parents:
3420
diff
changeset
|
12 |
AddIffs [mem_Collect_eq]; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
13 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
14 |
Goal "P(a) ==> a : {x. P(x)}"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
15 |
by (Asm_simp_tac 1); |
923 | 16 |
qed "CollectI"; |
17 |
||
5316 | 18 |
Goal "a : {x. P(x)} ==> P(a)"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
19 |
by (Asm_full_simp_tac 1); |
923 | 20 |
qed "CollectD"; |
21 |
||
9687
772ac061bd76
moved congruence rules UN_cong, INT_cong from UNTIY/Union to Set.ML
paulson
parents:
9422
diff
changeset
|
22 |
val [prem] = Goal "(!!x. (x:A) = (x:B)) ==> A = B"; |
923 | 23 |
by (rtac (prem RS ext RS arg_cong RS box_equals) 1); |
24 |
by (rtac Collect_mem_eq 1); |
|
25 |
by (rtac Collect_mem_eq 1); |
|
26 |
qed "set_ext"; |
|
27 |
||
9687
772ac061bd76
moved congruence rules UN_cong, INT_cong from UNTIY/Union to Set.ML
paulson
parents:
9422
diff
changeset
|
28 |
val [prem] = Goal "(!!x. P(x)=Q(x)) ==> {x. P(x)} = {x. Q(x)}"; |
923 | 29 |
by (rtac (prem RS ext RS arg_cong) 1); |
30 |
qed "Collect_cong"; |
|
31 |
||
9108 | 32 |
bind_thm ("CollectE", make_elim CollectD); |
923 | 33 |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
34 |
AddSIs [CollectI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
35 |
AddSEs [CollectE]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
36 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
37 |
|
1548 | 38 |
section "Bounded quantifiers"; |
923 | 39 |
|
5316 | 40 |
val prems = Goalw [Ball_def] |
9041 | 41 |
"[| !!x. x:A ==> P(x) |] ==> ALL x:A. P(x)"; |
923 | 42 |
by (REPEAT (ares_tac (prems @ [allI,impI]) 1)); |
43 |
qed "ballI"; |
|
44 |
||
8839 | 45 |
bind_thms ("strip", [impI, allI, ballI]); |
46 |
||
9041 | 47 |
Goalw [Ball_def] "[| ALL x:A. P(x); x:A |] ==> P(x)"; |
5316 | 48 |
by (Blast_tac 1); |
923 | 49 |
qed "bspec"; |
50 |
||
5316 | 51 |
val major::prems = Goalw [Ball_def] |
9041 | 52 |
"[| ALL x:A. P(x); P(x) ==> Q; x~:A ==> Q |] ==> Q"; |
923 | 53 |
by (rtac (major RS spec RS impCE) 1); |
54 |
by (REPEAT (eresolve_tac prems 1)); |
|
55 |
qed "ballE"; |
|
56 |
||
9041 | 57 |
(*Takes assumptions ALL x:A.P(x) and a:A; creates assumption P(a)*) |
923 | 58 |
fun ball_tac i = etac ballE i THEN contr_tac (i+1); |
59 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
60 |
AddSIs [ballI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
61 |
AddEs [ballE]; |
7441 | 62 |
AddXDs [bspec]; |
5521 | 63 |
(* gives better instantiation for bound: *) |
11166 | 64 |
claset_ref() := claset() addbefore ("bspec", datac bspec 1); |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
65 |
|
6006 | 66 |
(*Normally the best argument order: P(x) constrains the choice of x:A*) |
9041 | 67 |
Goalw [Bex_def] "[| P(x); x:A |] ==> EX x:A. P(x)"; |
5316 | 68 |
by (Blast_tac 1); |
923 | 69 |
qed "bexI"; |
70 |
||
6006 | 71 |
(*The best argument order when there is only one x:A*) |
9041 | 72 |
Goalw [Bex_def] "[| x:A; P(x) |] ==> EX x:A. P(x)"; |
6006 | 73 |
by (Blast_tac 1); |
74 |
qed "rev_bexI"; |
|
75 |
||
7031 | 76 |
val prems = Goal |
9041 | 77 |
"[| ALL x:A. ~P(x) ==> P(a); a:A |] ==> EX x:A. P(x)"; |
7007 | 78 |
by (rtac classical 1); |
79 |
by (REPEAT (ares_tac (prems@[bexI,ballI,notI,notE]) 1)) ; |
|
80 |
qed "bexCI"; |
|
923 | 81 |
|
5316 | 82 |
val major::prems = Goalw [Bex_def] |
9041 | 83 |
"[| EX x:A. P(x); !!x. [| x:A; P(x) |] ==> Q |] ==> Q"; |
923 | 84 |
by (rtac (major RS exE) 1); |
85 |
by (REPEAT (eresolve_tac (prems @ [asm_rl,conjE]) 1)); |
|
86 |
qed "bexE"; |
|
87 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
88 |
AddIs [bexI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
89 |
AddSEs [bexE]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
90 |
|
3420 | 91 |
(*Trival rewrite rule*) |
9041 | 92 |
Goal "(ALL x:A. P) = ((EX x. x:A) --> P)"; |
4089 | 93 |
by (simp_tac (simpset() addsimps [Ball_def]) 1); |
3420 | 94 |
qed "ball_triv"; |
1816 | 95 |
|
1882 | 96 |
(*Dual form for existentials*) |
9041 | 97 |
Goal "(EX x:A. P) = ((EX x. x:A) & P)"; |
4089 | 98 |
by (simp_tac (simpset() addsimps [Bex_def]) 1); |
3420 | 99 |
qed "bex_triv"; |
1882 | 100 |
|
3420 | 101 |
Addsimps [ball_triv, bex_triv]; |
923 | 102 |
|
11232 | 103 |
(* Blast cannot prove these (yet?). |
104 |
Move somewhere else? |
|
105 |
Goal "(ALL x:A. x=a) = (A = {a})"; |
|
106 |
by(Blast_tac 1); |
|
107 |
qed "ball_triv_one_point1"; |
|
108 |
||
109 |
Goal "(ALL x:A. a=x) = (A = {a})"; |
|
110 |
by(Blast_tac 1); |
|
111 |
qed "ball_triv_one_point2"; |
|
112 |
*) |
|
113 |
||
11223
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
114 |
Goal "(EX x:A. x=a) = (a:A)"; |
11220 | 115 |
by(Blast_tac 1); |
11223
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
116 |
qed "bex_triv_one_point1"; |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
117 |
|
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
118 |
Goal "(EX x:A. a=x) = (a:A)"; |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
119 |
by(Blast_tac 1); |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
120 |
qed "bex_triv_one_point2"; |
11220 | 121 |
|
122 |
Goal "(EX x:A. x=a & P x) = (a:A & P a)"; |
|
123 |
by(Blast_tac 1); |
|
11223
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
124 |
qed "bex_one_point1"; |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
125 |
|
11232 | 126 |
Goal "(EX x:A. a=x & P x) = (a:A & P a)"; |
127 |
by(Blast_tac 1); |
|
128 |
qed "bex_one_point2"; |
|
129 |
||
11223
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
130 |
Goal "(ALL x:A. x=a --> P x) = (a:A --> P a)"; |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
131 |
by(Blast_tac 1); |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
132 |
qed "ball_one_point1"; |
11220 | 133 |
|
11223
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
134 |
Goal "(ALL x:A. a=x --> P x) = (a:A --> P a)"; |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
135 |
by(Blast_tac 1); |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
136 |
qed "ball_one_point2"; |
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
137 |
|
11232 | 138 |
Addsimps [bex_triv_one_point1,bex_triv_one_point2, |
139 |
bex_one_point1,bex_one_point2, |
|
11223
fef9da0ee890
I forgot a few bases cases for the 1-point rules...
nipkow
parents:
11220
diff
changeset
|
140 |
ball_one_point1,ball_one_point2]; |
11220 | 141 |
|
142 |
let |
|
143 |
val ex_pattern = Thm.read_cterm (Theory.sign_of (the_context ())) |
|
144 |
("EX x:A. P(x) & Q(x)",HOLogic.boolT) |
|
145 |
||
146 |
val prove_bex_tac = rewrite_goals_tac [Bex_def] THEN |
|
147 |
Quantifier1.prove_one_point_ex_tac; |
|
148 |
||
149 |
val rearrange_bex = Quantifier1.rearrange_bex prove_bex_tac; |
|
150 |
||
151 |
val all_pattern = Thm.read_cterm (Theory.sign_of (the_context ())) |
|
11232 | 152 |
("ALL x:A. P(x) --> Q(x)",HOLogic.boolT) |
11220 | 153 |
|
11232 | 154 |
val prove_ball_tac = rewrite_goals_tac [Ball_def] THEN |
11220 | 155 |
Quantifier1.prove_one_point_all_tac; |
156 |
||
157 |
val rearrange_ball = Quantifier1.rearrange_ball prove_ball_tac; |
|
158 |
||
159 |
val defBEX_regroup = mk_simproc "defined BEX" [ex_pattern] rearrange_bex; |
|
160 |
val defBALL_regroup = mk_simproc "defined BALL" [all_pattern] rearrange_ball; |
|
161 |
in |
|
162 |
||
163 |
Addsimprocs [defBALL_regroup,defBEX_regroup] |
|
164 |
||
165 |
end; |
|
166 |
||
923 | 167 |
(** Congruence rules **) |
168 |
||
6291 | 169 |
val prems = Goalw [Ball_def] |
923 | 170 |
"[| A=B; !!x. x:B ==> P(x) = Q(x) |] ==> \ |
9041 | 171 |
\ (ALL x:A. P(x)) = (ALL x:B. Q(x))"; |
6291 | 172 |
by (asm_simp_tac (simpset() addsimps prems) 1); |
923 | 173 |
qed "ball_cong"; |
174 |
||
6291 | 175 |
val prems = Goalw [Bex_def] |
923 | 176 |
"[| A=B; !!x. x:B ==> P(x) = Q(x) |] ==> \ |
9041 | 177 |
\ (EX x:A. P(x)) = (EX x:B. Q(x))"; |
6291 | 178 |
by (asm_simp_tac (simpset() addcongs [conj_cong] addsimps prems) 1); |
923 | 179 |
qed "bex_cong"; |
180 |
||
6291 | 181 |
Addcongs [ball_cong,bex_cong]; |
182 |
||
1548 | 183 |
section "Subsets"; |
923 | 184 |
|
5316 | 185 |
val prems = Goalw [subset_def] "(!!x. x:A ==> x:B) ==> A <= B"; |
923 | 186 |
by (REPEAT (ares_tac (prems @ [ballI]) 1)); |
187 |
qed "subsetI"; |
|
188 |
||
5649 | 189 |
(*Map the type ('a set => anything) to just 'a. |
190 |
For overloading constants whose first argument has type "'a set" *) |
|
191 |
fun overload_1st_set s = Blast.overloaded (s, HOLogic.dest_setT o domain_type); |
|
192 |
||
4059 | 193 |
(*While (:) is not, its type must be kept |
194 |
for overloading of = to work.*) |
|
4240
8ba60a4cd380
Renamed "overload" to "overloaded" for sml/nj compatibility
paulson
parents:
4231
diff
changeset
|
195 |
Blast.overloaded ("op :", domain_type); |
5649 | 196 |
|
197 |
overload_1st_set "Ball"; (*need UNION, INTER also?*) |
|
198 |
overload_1st_set "Bex"; |
|
4059 | 199 |
|
4469 | 200 |
(*Image: retain the type of the set being expressed*) |
8005 | 201 |
Blast.overloaded ("image", domain_type); |
2881 | 202 |
|
923 | 203 |
(*Rule in Modus Ponens style*) |
5316 | 204 |
Goalw [subset_def] "[| A <= B; c:A |] ==> c:B"; |
205 |
by (Blast_tac 1); |
|
923 | 206 |
qed "subsetD"; |
7658 | 207 |
AddXIs [subsetD]; |
923 | 208 |
|
209 |
(*The same, with reversed premises for use with etac -- cf rev_mp*) |
|
7007 | 210 |
Goal "[| c:A; A <= B |] ==> c:B"; |
211 |
by (REPEAT (ares_tac [subsetD] 1)) ; |
|
212 |
qed "rev_subsetD"; |
|
7658 | 213 |
AddXIs [rev_subsetD]; |
923 | 214 |
|
1920 | 215 |
(*Converts A<=B to x:A ==> x:B*) |
216 |
fun impOfSubs th = th RSN (2, rev_subsetD); |
|
217 |
||
923 | 218 |
(*Classical elimination rule*) |
5316 | 219 |
val major::prems = Goalw [subset_def] |
923 | 220 |
"[| A <= B; c~:A ==> P; c:B ==> P |] ==> P"; |
221 |
by (rtac (major RS ballE) 1); |
|
222 |
by (REPEAT (eresolve_tac prems 1)); |
|
223 |
qed "subsetCE"; |
|
224 |
||
225 |
(*Takes assumptions A<=B; c:A and creates the assumption c:B *) |
|
226 |
fun set_mp_tac i = etac subsetCE i THEN mp_tac i; |
|
227 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
228 |
AddSIs [subsetI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
229 |
AddEs [subsetD, subsetCE]; |
923 | 230 |
|
10233 | 231 |
Goal "[| A <= B; c ~: B |] ==> c ~: A"; |
232 |
by (Blast_tac 1); |
|
233 |
qed "contra_subsetD"; |
|
234 |
||
7007 | 235 |
Goal "A <= (A::'a set)"; |
236 |
by (Fast_tac 1); |
|
10233 | 237 |
qed "subset_refl"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
238 |
|
5316 | 239 |
Goal "[| A<=B; B<=C |] ==> A<=(C::'a set)"; |
2891 | 240 |
by (Blast_tac 1); |
923 | 241 |
qed "subset_trans"; |
242 |
||
243 |
||
1548 | 244 |
section "Equality"; |
923 | 245 |
|
246 |
(*Anti-symmetry of the subset relation*) |
|
5316 | 247 |
Goal "[| A <= B; B <= A |] ==> A = (B::'a set)"; |
5318 | 248 |
by (rtac set_ext 1); |
5316 | 249 |
by (blast_tac (claset() addIs [subsetD]) 1); |
923 | 250 |
qed "subset_antisym"; |
9108 | 251 |
bind_thm ("equalityI", subset_antisym); |
923 | 252 |
|
1762 | 253 |
AddSIs [equalityI]; |
254 |
||
923 | 255 |
(* Equality rules from ZF set theory -- are they appropriate here? *) |
5316 | 256 |
Goal "A = B ==> A<=(B::'a set)"; |
257 |
by (etac ssubst 1); |
|
923 | 258 |
by (rtac subset_refl 1); |
259 |
qed "equalityD1"; |
|
260 |
||
5316 | 261 |
Goal "A = B ==> B<=(A::'a set)"; |
262 |
by (etac ssubst 1); |
|
923 | 263 |
by (rtac subset_refl 1); |
264 |
qed "equalityD2"; |
|
265 |
||
9338 | 266 |
(*Be careful when adding this to the claset as subset_empty is in the simpset: |
267 |
A={} goes to {}<=A and A<={} and then back to A={} !*) |
|
5316 | 268 |
val prems = Goal |
923 | 269 |
"[| A = B; [| A<=B; B<=(A::'a set) |] ==> P |] ==> P"; |
270 |
by (resolve_tac prems 1); |
|
271 |
by (REPEAT (resolve_tac (prems RL [equalityD1,equalityD2]) 1)); |
|
272 |
qed "equalityE"; |
|
273 |
||
5316 | 274 |
val major::prems = Goal |
923 | 275 |
"[| A = B; [| c:A; c:B |] ==> P; [| c~:A; c~:B |] ==> P |] ==> P"; |
276 |
by (rtac (major RS equalityE) 1); |
|
277 |
by (REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1)); |
|
278 |
qed "equalityCE"; |
|
279 |
||
9186
7b2f4e6538b4
now uses equalityCE, which usually is more efficent than equalityE
paulson
parents:
9161
diff
changeset
|
280 |
AddEs [equalityCE]; |
7b2f4e6538b4
now uses equalityCE, which usually is more efficent than equalityE
paulson
parents:
9161
diff
changeset
|
281 |
|
923 | 282 |
(*Lemma for creating induction formulae -- for "pattern matching" on p |
283 |
To make the induction hypotheses usable, apply "spec" or "bspec" to |
|
284 |
put universal quantifiers over the free variables in p. *) |
|
5316 | 285 |
val prems = Goal |
923 | 286 |
"[| p:A; !!z. z:A ==> p=z --> R |] ==> R"; |
287 |
by (rtac mp 1); |
|
288 |
by (REPEAT (resolve_tac (refl::prems) 1)); |
|
289 |
qed "setup_induction"; |
|
290 |
||
8053 | 291 |
Goal "A = B ==> (x : A) = (x : B)"; |
292 |
by (Asm_simp_tac 1); |
|
293 |
qed "eqset_imp_iff"; |
|
294 |
||
923 | 295 |
|
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
296 |
section "The universal set -- UNIV"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
297 |
|
7031 | 298 |
Goalw [UNIV_def] "x : UNIV"; |
299 |
by (rtac CollectI 1); |
|
300 |
by (rtac TrueI 1); |
|
301 |
qed "UNIV_I"; |
|
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
302 |
|
4434 | 303 |
Addsimps [UNIV_I]; |
304 |
AddIs [UNIV_I]; (*unsafe makes it less likely to cause problems*) |
|
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
305 |
|
10482 | 306 |
Goal "EX x. x : UNIV"; |
307 |
by (Simp_tac 1); |
|
308 |
qed "UNIV_witness"; |
|
309 |
AddXIs [UNIV_witness]; |
|
310 |
||
7031 | 311 |
Goal "A <= UNIV"; |
312 |
by (rtac subsetI 1); |
|
313 |
by (rtac UNIV_I 1); |
|
314 |
qed "subset_UNIV"; |
|
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
315 |
|
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
316 |
(** Eta-contracting these two rules (to remove P) causes them to be ignored |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
317 |
because of their interaction with congruence rules. **) |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
318 |
|
5069 | 319 |
Goalw [Ball_def] "Ball UNIV P = All P"; |
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
320 |
by (Simp_tac 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
321 |
qed "ball_UNIV"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
322 |
|
5069 | 323 |
Goalw [Bex_def] "Bex UNIV P = Ex P"; |
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
324 |
by (Simp_tac 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
325 |
qed "bex_UNIV"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
326 |
Addsimps [ball_UNIV, bex_UNIV]; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
327 |
|
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
328 |
|
2858 | 329 |
section "The empty set -- {}"; |
330 |
||
7007 | 331 |
Goalw [empty_def] "(c : {}) = False"; |
332 |
by (Blast_tac 1) ; |
|
333 |
qed "empty_iff"; |
|
2858 | 334 |
|
335 |
Addsimps [empty_iff]; |
|
336 |
||
7007 | 337 |
Goal "a:{} ==> P"; |
338 |
by (Full_simp_tac 1); |
|
339 |
qed "emptyE"; |
|
2858 | 340 |
|
341 |
AddSEs [emptyE]; |
|
342 |
||
7007 | 343 |
Goal "{} <= A"; |
344 |
by (Blast_tac 1) ; |
|
345 |
qed "empty_subsetI"; |
|
2858 | 346 |
|
5256 | 347 |
(*One effect is to delete the ASSUMPTION {} <= A*) |
348 |
AddIffs [empty_subsetI]; |
|
349 |
||
7031 | 350 |
val [prem]= Goal "[| !!y. y:A ==> False |] ==> A={}"; |
7007 | 351 |
by (blast_tac (claset() addIs [prem RS FalseE]) 1) ; |
352 |
qed "equals0I"; |
|
2858 | 353 |
|
5256 | 354 |
(*Use for reasoning about disjointness: A Int B = {} *) |
7007 | 355 |
Goal "A={} ==> a ~: A"; |
356 |
by (Blast_tac 1) ; |
|
357 |
qed "equals0D"; |
|
2858 | 358 |
|
5069 | 359 |
Goalw [Ball_def] "Ball {} P = True"; |
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
360 |
by (Simp_tac 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
361 |
qed "ball_empty"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
362 |
|
5069 | 363 |
Goalw [Bex_def] "Bex {} P = False"; |
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
364 |
by (Simp_tac 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
365 |
qed "bex_empty"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
366 |
Addsimps [ball_empty, bex_empty]; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
367 |
|
5069 | 368 |
Goal "UNIV ~= {}"; |
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
369 |
by (blast_tac (claset() addEs [equalityE]) 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
370 |
qed "UNIV_not_empty"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
371 |
AddIffs [UNIV_not_empty]; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
372 |
|
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
373 |
|
2858 | 374 |
|
375 |
section "The Powerset operator -- Pow"; |
|
376 |
||
7007 | 377 |
Goalw [Pow_def] "(A : Pow(B)) = (A <= B)"; |
378 |
by (Asm_simp_tac 1); |
|
379 |
qed "Pow_iff"; |
|
2858 | 380 |
|
381 |
AddIffs [Pow_iff]; |
|
382 |
||
7031 | 383 |
Goalw [Pow_def] "A <= B ==> A : Pow(B)"; |
7007 | 384 |
by (etac CollectI 1); |
385 |
qed "PowI"; |
|
2858 | 386 |
|
7031 | 387 |
Goalw [Pow_def] "A : Pow(B) ==> A<=B"; |
7007 | 388 |
by (etac CollectD 1); |
389 |
qed "PowD"; |
|
390 |
||
2858 | 391 |
|
9108 | 392 |
bind_thm ("Pow_bottom", empty_subsetI RS PowI); (* {}: Pow(B) *) |
393 |
bind_thm ("Pow_top", subset_refl RS PowI); (* A : Pow(A) *) |
|
2858 | 394 |
|
395 |
||
5931 | 396 |
section "Set complement"; |
923 | 397 |
|
7031 | 398 |
Goalw [Compl_def] "(c : -A) = (c~:A)"; |
399 |
by (Blast_tac 1); |
|
400 |
qed "Compl_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
401 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
402 |
Addsimps [Compl_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
403 |
|
5490 | 404 |
val prems = Goalw [Compl_def] "[| c:A ==> False |] ==> c : -A"; |
923 | 405 |
by (REPEAT (ares_tac (prems @ [CollectI,notI]) 1)); |
406 |
qed "ComplI"; |
|
407 |
||
408 |
(*This form, with negated conclusion, works well with the Classical prover. |
|
409 |
Negated assumptions behave like formulae on the right side of the notional |
|
410 |
turnstile...*) |
|
5490 | 411 |
Goalw [Compl_def] "c : -A ==> c~:A"; |
5316 | 412 |
by (etac CollectD 1); |
923 | 413 |
qed "ComplD"; |
414 |
||
9108 | 415 |
bind_thm ("ComplE", make_elim ComplD); |
923 | 416 |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
417 |
AddSIs [ComplI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
418 |
AddSEs [ComplE]; |
1640 | 419 |
|
923 | 420 |
|
1548 | 421 |
section "Binary union -- Un"; |
923 | 422 |
|
7031 | 423 |
Goalw [Un_def] "(c : A Un B) = (c:A | c:B)"; |
424 |
by (Blast_tac 1); |
|
425 |
qed "Un_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
426 |
Addsimps [Un_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
427 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
428 |
Goal "c:A ==> c : A Un B"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
429 |
by (Asm_simp_tac 1); |
923 | 430 |
qed "UnI1"; |
431 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
432 |
Goal "c:B ==> c : A Un B"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
433 |
by (Asm_simp_tac 1); |
923 | 434 |
qed "UnI2"; |
435 |
||
9378 | 436 |
AddXIs [UnI1, UnI2]; |
437 |
||
438 |
||
923 | 439 |
(*Classical introduction rule: no commitment to A vs B*) |
7007 | 440 |
|
7031 | 441 |
val prems = Goal "(c~:B ==> c:A) ==> c : A Un B"; |
7007 | 442 |
by (Simp_tac 1); |
443 |
by (REPEAT (ares_tac (prems@[disjCI]) 1)) ; |
|
444 |
qed "UnCI"; |
|
923 | 445 |
|
5316 | 446 |
val major::prems = Goalw [Un_def] |
923 | 447 |
"[| c : A Un B; c:A ==> P; c:B ==> P |] ==> P"; |
448 |
by (rtac (major RS CollectD RS disjE) 1); |
|
449 |
by (REPEAT (eresolve_tac prems 1)); |
|
450 |
qed "UnE"; |
|
451 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
452 |
AddSIs [UnCI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
453 |
AddSEs [UnE]; |
1640 | 454 |
|
923 | 455 |
|
1548 | 456 |
section "Binary intersection -- Int"; |
923 | 457 |
|
7031 | 458 |
Goalw [Int_def] "(c : A Int B) = (c:A & c:B)"; |
459 |
by (Blast_tac 1); |
|
460 |
qed "Int_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
461 |
Addsimps [Int_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
462 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
463 |
Goal "[| c:A; c:B |] ==> c : A Int B"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
464 |
by (Asm_simp_tac 1); |
923 | 465 |
qed "IntI"; |
466 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
467 |
Goal "c : A Int B ==> c:A"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
468 |
by (Asm_full_simp_tac 1); |
923 | 469 |
qed "IntD1"; |
470 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
471 |
Goal "c : A Int B ==> c:B"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
472 |
by (Asm_full_simp_tac 1); |
923 | 473 |
qed "IntD2"; |
474 |
||
5316 | 475 |
val [major,minor] = Goal |
923 | 476 |
"[| c : A Int B; [| c:A; c:B |] ==> P |] ==> P"; |
477 |
by (rtac minor 1); |
|
478 |
by (rtac (major RS IntD1) 1); |
|
479 |
by (rtac (major RS IntD2) 1); |
|
480 |
qed "IntE"; |
|
481 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
482 |
AddSIs [IntI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
483 |
AddSEs [IntE]; |
923 | 484 |
|
1548 | 485 |
section "Set difference"; |
923 | 486 |
|
7031 | 487 |
Goalw [set_diff_def] "(c : A-B) = (c:A & c~:B)"; |
488 |
by (Blast_tac 1); |
|
489 |
qed "Diff_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
490 |
Addsimps [Diff_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
491 |
|
7007 | 492 |
Goal "[| c : A; c ~: B |] ==> c : A - B"; |
493 |
by (Asm_simp_tac 1) ; |
|
494 |
qed "DiffI"; |
|
923 | 495 |
|
7007 | 496 |
Goal "c : A - B ==> c : A"; |
497 |
by (Asm_full_simp_tac 1) ; |
|
498 |
qed "DiffD1"; |
|
923 | 499 |
|
7007 | 500 |
Goal "[| c : A - B; c : B |] ==> P"; |
501 |
by (Asm_full_simp_tac 1) ; |
|
502 |
qed "DiffD2"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
503 |
|
7031 | 504 |
val prems = Goal "[| c : A - B; [| c:A; c~:B |] ==> P |] ==> P"; |
7007 | 505 |
by (resolve_tac prems 1); |
506 |
by (REPEAT (ares_tac (prems RL [DiffD1, DiffD2 RS notI]) 1)) ; |
|
507 |
qed "DiffE"; |
|
923 | 508 |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
509 |
AddSIs [DiffI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
510 |
AddSEs [DiffE]; |
923 | 511 |
|
512 |
||
1548 | 513 |
section "Augmenting a set -- insert"; |
923 | 514 |
|
7031 | 515 |
Goalw [insert_def] "a : insert b A = (a=b | a:A)"; |
516 |
by (Blast_tac 1); |
|
517 |
qed "insert_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
518 |
Addsimps [insert_iff]; |
923 | 519 |
|
7031 | 520 |
Goal "a : insert a B"; |
7007 | 521 |
by (Simp_tac 1); |
522 |
qed "insertI1"; |
|
923 | 523 |
|
7007 | 524 |
Goal "!!a. a : B ==> a : insert b B"; |
525 |
by (Asm_simp_tac 1); |
|
526 |
qed "insertI2"; |
|
527 |
||
528 |
val major::prems = Goalw [insert_def] |
|
529 |
"[| a : insert b A; a=b ==> P; a:A ==> P |] ==> P"; |
|
530 |
by (rtac (major RS UnE) 1); |
|
531 |
by (REPEAT (eresolve_tac (prems @ [CollectE]) 1)); |
|
532 |
qed "insertE"; |
|
923 | 533 |
|
534 |
(*Classical introduction rule*) |
|
7031 | 535 |
val prems = Goal "(a~:B ==> a=b) ==> a: insert b B"; |
7007 | 536 |
by (Simp_tac 1); |
537 |
by (REPEAT (ares_tac (prems@[disjCI]) 1)) ; |
|
538 |
qed "insertCI"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
539 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
540 |
AddSIs [insertCI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
541 |
AddSEs [insertE]; |
923 | 542 |
|
9088
453996655ac2
replaced the useless [p]subset_insertD by [p]subset_insert_iff
paulson
parents:
9075
diff
changeset
|
543 |
Goal "(A <= insert x B) = (if x:A then A-{x} <= B else A<=B)"; |
453996655ac2
replaced the useless [p]subset_insertD by [p]subset_insert_iff
paulson
parents:
9075
diff
changeset
|
544 |
by Auto_tac; |
453996655ac2
replaced the useless [p]subset_insertD by [p]subset_insert_iff
paulson
parents:
9075
diff
changeset
|
545 |
qed "subset_insert_iff"; |
7496
93ae11d887ff
added theorems subset_insertD, singleton_insert_inj_eq, subset_singletonD
oheimb
parents:
7441
diff
changeset
|
546 |
|
1548 | 547 |
section "Singletons, using insert"; |
923 | 548 |
|
7007 | 549 |
Goal "a : {a}"; |
550 |
by (rtac insertI1 1) ; |
|
551 |
qed "singletonI"; |
|
923 | 552 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
553 |
Goal "b : {a} ==> b=a"; |
2891 | 554 |
by (Blast_tac 1); |
923 | 555 |
qed "singletonD"; |
556 |
||
1776
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
557 |
bind_thm ("singletonE", make_elim singletonD); |
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
558 |
|
7007 | 559 |
Goal "(b : {a}) = (b=a)"; |
560 |
by (Blast_tac 1); |
|
561 |
qed "singleton_iff"; |
|
923 | 562 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
563 |
Goal "{a}={b} ==> a=b"; |
4089 | 564 |
by (blast_tac (claset() addEs [equalityE]) 1); |
923 | 565 |
qed "singleton_inject"; |
566 |
||
2858 | 567 |
(*Redundant? But unlike insertCI, it proves the subgoal immediately!*) |
568 |
AddSIs [singletonI]; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
569 |
AddSDs [singleton_inject]; |
3718 | 570 |
AddSEs [singletonE]; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
571 |
|
7969 | 572 |
Goal "{b} = insert a A = (a = b & A <= {b})"; |
8326
0e329578b0ef
tidied the proofs of singleton_insert_inj_eq, singleton_insert_inj_eq' and
paulson
parents:
8053
diff
changeset
|
573 |
by (blast_tac (claset() addSEs [equalityE]) 1); |
7496
93ae11d887ff
added theorems subset_insertD, singleton_insert_inj_eq, subset_singletonD
oheimb
parents:
7441
diff
changeset
|
574 |
qed "singleton_insert_inj_eq"; |
93ae11d887ff
added theorems subset_insertD, singleton_insert_inj_eq, subset_singletonD
oheimb
parents:
7441
diff
changeset
|
575 |
|
8326
0e329578b0ef
tidied the proofs of singleton_insert_inj_eq, singleton_insert_inj_eq' and
paulson
parents:
8053
diff
changeset
|
576 |
Goal "(insert a A = {b}) = (a = b & A <= {b})"; |
0e329578b0ef
tidied the proofs of singleton_insert_inj_eq, singleton_insert_inj_eq' and
paulson
parents:
8053
diff
changeset
|
577 |
by (blast_tac (claset() addSEs [equalityE]) 1); |
7969 | 578 |
qed "singleton_insert_inj_eq'"; |
579 |
||
8326
0e329578b0ef
tidied the proofs of singleton_insert_inj_eq, singleton_insert_inj_eq' and
paulson
parents:
8053
diff
changeset
|
580 |
AddIffs [singleton_insert_inj_eq, singleton_insert_inj_eq']; |
0e329578b0ef
tidied the proofs of singleton_insert_inj_eq, singleton_insert_inj_eq' and
paulson
parents:
8053
diff
changeset
|
581 |
|
7496
93ae11d887ff
added theorems subset_insertD, singleton_insert_inj_eq, subset_singletonD
oheimb
parents:
7441
diff
changeset
|
582 |
Goal "A <= {x} ==> A={} | A = {x}"; |
93ae11d887ff
added theorems subset_insertD, singleton_insert_inj_eq, subset_singletonD
oheimb
parents:
7441
diff
changeset
|
583 |
by (Fast_tac 1); |
93ae11d887ff
added theorems subset_insertD, singleton_insert_inj_eq, subset_singletonD
oheimb
parents:
7441
diff
changeset
|
584 |
qed "subset_singletonD"; |
93ae11d887ff
added theorems subset_insertD, singleton_insert_inj_eq, subset_singletonD
oheimb
parents:
7441
diff
changeset
|
585 |
|
5069 | 586 |
Goal "{x. x=a} = {a}"; |
4423 | 587 |
by (Blast_tac 1); |
3582 | 588 |
qed "singleton_conv"; |
589 |
Addsimps [singleton_conv]; |
|
1531 | 590 |
|
5600 | 591 |
Goal "{x. a=x} = {a}"; |
6301 | 592 |
by (Blast_tac 1); |
5600 | 593 |
qed "singleton_conv2"; |
594 |
Addsimps [singleton_conv2]; |
|
595 |
||
11007 | 596 |
Goal "[| A - {x} <= B; x : A |] ==> A <= insert x B"; |
597 |
by(Blast_tac 1); |
|
598 |
qed "diff_single_insert"; |
|
599 |
||
1531 | 600 |
|
10832 | 601 |
section "Unions of families -- UNION x:A. B(x) is Union(B`A)"; |
923 | 602 |
|
5069 | 603 |
Goalw [UNION_def] "(b: (UN x:A. B(x))) = (EX x:A. b: B(x))"; |
2891 | 604 |
by (Blast_tac 1); |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
605 |
qed "UN_iff"; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
606 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
607 |
Addsimps [UN_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
608 |
|
923 | 609 |
(*The order of the premises presupposes that A is rigid; b may be flexible*) |
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
610 |
Goal "[| a:A; b: B(a) |] ==> b: (UN x:A. B(x))"; |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4469
diff
changeset
|
611 |
by Auto_tac; |
923 | 612 |
qed "UN_I"; |
613 |
||
5316 | 614 |
val major::prems = Goalw [UNION_def] |
923 | 615 |
"[| b : (UN x:A. B(x)); !!x.[| x:A; b: B(x) |] ==> R |] ==> R"; |
616 |
by (rtac (major RS CollectD RS bexE) 1); |
|
617 |
by (REPEAT (ares_tac prems 1)); |
|
618 |
qed "UN_E"; |
|
619 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
620 |
AddIs [UN_I]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
621 |
AddSEs [UN_E]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
622 |
|
6291 | 623 |
val prems = Goalw [UNION_def] |
923 | 624 |
"[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> \ |
625 |
\ (UN x:A. C(x)) = (UN x:B. D(x))"; |
|
6291 | 626 |
by (asm_simp_tac (simpset() addsimps prems) 1); |
923 | 627 |
qed "UN_cong"; |
9687
772ac061bd76
moved congruence rules UN_cong, INT_cong from UNTIY/Union to Set.ML
paulson
parents:
9422
diff
changeset
|
628 |
Addcongs [UN_cong]; |
923 | 629 |
|
630 |
||
10832 | 631 |
section "Intersections of families -- INTER x:A. B(x) is Inter(B`A)"; |
923 | 632 |
|
5069 | 633 |
Goalw [INTER_def] "(b: (INT x:A. B(x))) = (ALL x:A. b: B(x))"; |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4469
diff
changeset
|
634 |
by Auto_tac; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
635 |
qed "INT_iff"; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
636 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
637 |
Addsimps [INT_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
638 |
|
5316 | 639 |
val prems = Goalw [INTER_def] |
923 | 640 |
"(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))"; |
641 |
by (REPEAT (ares_tac ([CollectI,ballI] @ prems) 1)); |
|
642 |
qed "INT_I"; |
|
643 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
644 |
Goal "[| b : (INT x:A. B(x)); a:A |] ==> b: B(a)"; |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4469
diff
changeset
|
645 |
by Auto_tac; |
923 | 646 |
qed "INT_D"; |
647 |
||
648 |
(*"Classical" elimination -- by the Excluded Middle on a:A *) |
|
5316 | 649 |
val major::prems = Goalw [INTER_def] |
923 | 650 |
"[| b : (INT x:A. B(x)); b: B(a) ==> R; a~:A ==> R |] ==> R"; |
651 |
by (rtac (major RS CollectD RS ballE) 1); |
|
652 |
by (REPEAT (eresolve_tac prems 1)); |
|
653 |
qed "INT_E"; |
|
654 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
655 |
AddSIs [INT_I]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
656 |
AddEs [INT_D, INT_E]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
657 |
|
6291 | 658 |
val prems = Goalw [INTER_def] |
923 | 659 |
"[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> \ |
660 |
\ (INT x:A. C(x)) = (INT x:B. D(x))"; |
|
6291 | 661 |
by (asm_simp_tac (simpset() addsimps prems) 1); |
923 | 662 |
qed "INT_cong"; |
9687
772ac061bd76
moved congruence rules UN_cong, INT_cong from UNTIY/Union to Set.ML
paulson
parents:
9422
diff
changeset
|
663 |
Addcongs [INT_cong]; |
923 | 664 |
|
665 |
||
1548 | 666 |
section "Union"; |
923 | 667 |
|
5069 | 668 |
Goalw [Union_def] "(A : Union(C)) = (EX X:C. A:X)"; |
2891 | 669 |
by (Blast_tac 1); |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
670 |
qed "Union_iff"; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
671 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
672 |
Addsimps [Union_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
673 |
|
923 | 674 |
(*The order of the premises presupposes that C is rigid; A may be flexible*) |
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
675 |
Goal "[| X:C; A:X |] ==> A : Union(C)"; |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4469
diff
changeset
|
676 |
by Auto_tac; |
923 | 677 |
qed "UnionI"; |
678 |
||
5316 | 679 |
val major::prems = Goalw [Union_def] |
923 | 680 |
"[| A : Union(C); !!X.[| A:X; X:C |] ==> R |] ==> R"; |
681 |
by (rtac (major RS UN_E) 1); |
|
682 |
by (REPEAT (ares_tac prems 1)); |
|
683 |
qed "UnionE"; |
|
684 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
685 |
AddIs [UnionI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
686 |
AddSEs [UnionE]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
687 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
688 |
|
1548 | 689 |
section "Inter"; |
923 | 690 |
|
5069 | 691 |
Goalw [Inter_def] "(A : Inter(C)) = (ALL X:C. A:X)"; |
2891 | 692 |
by (Blast_tac 1); |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
693 |
qed "Inter_iff"; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
694 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
695 |
Addsimps [Inter_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
696 |
|
5316 | 697 |
val prems = Goalw [Inter_def] |
923 | 698 |
"[| !!X. X:C ==> A:X |] ==> A : Inter(C)"; |
699 |
by (REPEAT (ares_tac ([INT_I] @ prems) 1)); |
|
700 |
qed "InterI"; |
|
701 |
||
702 |
(*A "destruct" rule -- every X in C contains A as an element, but |
|
703 |
A:X can hold when X:C does not! This rule is analogous to "spec". *) |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
704 |
Goal "[| A : Inter(C); X:C |] ==> A:X"; |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4469
diff
changeset
|
705 |
by Auto_tac; |
923 | 706 |
qed "InterD"; |
707 |
||
708 |
(*"Classical" elimination rule -- does not require proving X:C *) |
|
5316 | 709 |
val major::prems = Goalw [Inter_def] |
2721 | 710 |
"[| A : Inter(C); X~:C ==> R; A:X ==> R |] ==> R"; |
923 | 711 |
by (rtac (major RS INT_E) 1); |
712 |
by (REPEAT (eresolve_tac prems 1)); |
|
713 |
qed "InterE"; |
|
714 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
715 |
AddSIs [InterI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
716 |
AddEs [InterD, InterE]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
717 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
718 |
|
2912 | 719 |
(*** Image of a set under a function ***) |
720 |
||
721 |
(*Frequently b does not have the syntactic form of f(x).*) |
|
10832 | 722 |
Goalw [image_def] "[| b=f(x); x:A |] ==> b : f`A"; |
5316 | 723 |
by (Blast_tac 1); |
2912 | 724 |
qed "image_eqI"; |
3909 | 725 |
Addsimps [image_eqI]; |
2912 | 726 |
|
727 |
bind_thm ("imageI", refl RS image_eqI); |
|
728 |
||
8025 | 729 |
(*This version's more effective when we already have the required x*) |
10832 | 730 |
Goalw [image_def] "[| x:A; b=f(x) |] ==> b : f`A"; |
8025 | 731 |
by (Blast_tac 1); |
732 |
qed "rev_image_eqI"; |
|
733 |
||
2912 | 734 |
(*The eta-expansion gives variable-name preservation.*) |
5316 | 735 |
val major::prems = Goalw [image_def] |
10832 | 736 |
"[| b : (%x. f(x))`A; !!x.[| b=f(x); x:A |] ==> P |] ==> P"; |
2912 | 737 |
by (rtac (major RS CollectD RS bexE) 1); |
738 |
by (REPEAT (ares_tac prems 1)); |
|
739 |
qed "imageE"; |
|
740 |
||
741 |
AddIs [image_eqI]; |
|
742 |
AddSEs [imageE]; |
|
743 |
||
10832 | 744 |
Goal "f`(A Un B) = f`A Un f`B"; |
2935 | 745 |
by (Blast_tac 1); |
2912 | 746 |
qed "image_Un"; |
747 |
||
10832 | 748 |
Goal "(z : f`A) = (EX x:A. z = f x)"; |
3960 | 749 |
by (Blast_tac 1); |
750 |
qed "image_iff"; |
|
751 |
||
4523 | 752 |
(*This rewrite rule would confuse users if made default.*) |
10832 | 753 |
Goal "(f`A <= B) = (ALL x:A. f(x): B)"; |
4523 | 754 |
by (Blast_tac 1); |
755 |
qed "image_subset_iff"; |
|
756 |
||
11007 | 757 |
Goal "B <= f ` A = (? AA. AA <= A & B = f ` AA)"; |
758 |
by Safe_tac; |
|
759 |
by (Fast_tac 2); |
|
760 |
by (res_inst_tac [("x","{a. a : A & f a : B}")] exI 1); |
|
761 |
by (Fast_tac 1); |
|
762 |
qed "subset_image_iff"; |
|
763 |
||
4523 | 764 |
(*Replaces the three steps subsetI, imageE, hyp_subst_tac, but breaks too |
765 |
many existing proofs.*) |
|
10832 | 766 |
val prems = Goal "(!!x. x:A ==> f(x) : B) ==> f`A <= B"; |
4510 | 767 |
by (blast_tac (claset() addIs prems) 1); |
768 |
qed "image_subsetI"; |
|
769 |
||
2912 | 770 |
(*** Range of a function -- just a translation for image! ***) |
771 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
772 |
Goal "b=f(x) ==> b : range(f)"; |
2912 | 773 |
by (EVERY1 [etac image_eqI, rtac UNIV_I]); |
774 |
bind_thm ("range_eqI", UNIV_I RSN (2,image_eqI)); |
|
775 |
||
776 |
bind_thm ("rangeI", UNIV_I RS imageI); |
|
777 |
||
5316 | 778 |
val [major,minor] = Goal |
3842 | 779 |
"[| b : range(%x. f(x)); !!x. b=f(x) ==> P |] ==> P"; |
2912 | 780 |
by (rtac (major RS imageE) 1); |
781 |
by (etac minor 1); |
|
782 |
qed "rangeE"; |
|
10482 | 783 |
AddXEs [rangeE]; |
2912 | 784 |
|
1776
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
785 |
|
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
786 |
(*** Set reasoning tools ***) |
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
787 |
|
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
788 |
|
3912 | 789 |
(** Rewrite rules for boolean case-splitting: faster than |
4830 | 790 |
addsplits[split_if] |
3912 | 791 |
**) |
792 |
||
4830 | 793 |
bind_thm ("split_if_eq1", read_instantiate [("P", "%x. x = ?b")] split_if); |
794 |
bind_thm ("split_if_eq2", read_instantiate [("P", "%x. ?a = x")] split_if); |
|
3912 | 795 |
|
5237 | 796 |
(*Split ifs on either side of the membership relation. |
797 |
Not for Addsimps -- can cause goals to blow up!*) |
|
9969 | 798 |
bind_thm ("split_if_mem1", inst "P" "%x. x : ?b" split_if); |
799 |
bind_thm ("split_if_mem2", inst "P" "%x. ?a : x" split_if); |
|
3912 | 800 |
|
9108 | 801 |
bind_thms ("split_ifs", [if_bool_eq_conj, split_if_eq1, split_if_eq2, |
9969 | 802 |
split_if_mem1, split_if_mem2]); |
3912 | 803 |
|
804 |
||
4089 | 805 |
(*Each of these has ALREADY been added to simpset() above.*) |
9108 | 806 |
bind_thms ("mem_simps", [insert_iff, empty_iff, Un_iff, Int_iff, Compl_iff, Diff_iff, |
807 |
mem_Collect_eq, UN_iff, Union_iff, INT_iff, Inter_iff]); |
|
1776
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
808 |
|
9041 | 809 |
(*Would like to add these, but the existing code only searches for the |
810 |
outer-level constant, which in this case is just "op :"; we instead need |
|
811 |
to use term-nets to associate patterns with rules. Also, if a rule fails to |
|
812 |
apply, then the formula should be kept. |
|
813 |
[("uminus", Compl_iff RS iffD1), ("op -", [Diff_iff RS iffD1]), |
|
814 |
("op Int", [IntD1,IntD2]), |
|
815 |
("Collect", [CollectD]), ("Inter", [InterD]), ("INTER", [INT_D])] |
|
816 |
*) |
|
817 |
val mksimps_pairs = |
|
818 |
[("Ball",[bspec])] @ mksimps_pairs; |
|
1776
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
819 |
|
6291 | 820 |
simpset_ref() := simpset() setmksimps (mksimps mksimps_pairs); |
3222
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
821 |
|
5256 | 822 |
Addsimps[subset_UNIV, subset_refl]; |
3222
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
823 |
|
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
824 |
|
8001 | 825 |
(*** The 'proper subset' relation (<) ***) |
3222
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
826 |
|
5069 | 827 |
Goalw [psubset_def] "!!A::'a set. [| A <= B; A ~= B |] ==> A<B"; |
3222
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
828 |
by (Blast_tac 1); |
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
829 |
qed "psubsetI"; |
8913 | 830 |
AddSIs [psubsetI]; |
3222
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
831 |
|
9088
453996655ac2
replaced the useless [p]subset_insertD by [p]subset_insert_iff
paulson
parents:
9075
diff
changeset
|
832 |
Goalw [psubset_def] |
453996655ac2
replaced the useless [p]subset_insertD by [p]subset_insert_iff
paulson
parents:
9075
diff
changeset
|
833 |
"(A < insert x B) = (if x:B then A<B else if x:A then A-{x} < B else A<=B)"; |
453996655ac2
replaced the useless [p]subset_insertD by [p]subset_insert_iff
paulson
parents:
9075
diff
changeset
|
834 |
by (asm_simp_tac (simpset() addsimps [subset_insert_iff]) 1); |
453996655ac2
replaced the useless [p]subset_insertD by [p]subset_insert_iff
paulson
parents:
9075
diff
changeset
|
835 |
by (Blast_tac 1); |
453996655ac2
replaced the useless [p]subset_insertD by [p]subset_insert_iff
paulson
parents:
9075
diff
changeset
|
836 |
qed "psubset_insert_iff"; |
4059 | 837 |
|
838 |
bind_thm ("psubset_eq", psubset_def RS meta_eq_to_obj_eq); |
|
6443 | 839 |
|
840 |
bind_thm ("psubset_imp_subset", psubset_eq RS iffD1 RS conjunct1); |
|
841 |
||
842 |
Goal"[| (A::'a set) < B; B <= C |] ==> A < C"; |
|
843 |
by (auto_tac (claset(), simpset() addsimps [psubset_eq])); |
|
844 |
qed "psubset_subset_trans"; |
|
845 |
||
846 |
Goal"[| (A::'a set) <= B; B < C|] ==> A < C"; |
|
847 |
by (auto_tac (claset(), simpset() addsimps [psubset_eq])); |
|
848 |
qed "subset_psubset_trans"; |
|
7717
e7ecfa617443
Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents:
7658
diff
changeset
|
849 |
|
8001 | 850 |
Goalw [psubset_def] "A < B ==> EX b. b : (B - A)"; |
851 |
by (Blast_tac 1); |
|
852 |
qed "psubset_imp_ex_mem"; |
|
853 |
||
7717
e7ecfa617443
Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents:
7658
diff
changeset
|
854 |
|
9892 | 855 |
(* rulify setup *) |
856 |
||
857 |
Goal "(!!x. x:A ==> P x) == Trueprop (ALL x:A. P x)"; |
|
858 |
by (simp_tac (simpset () addsimps (Ball_def :: thms "atomize")) 1); |
|
859 |
qed "ball_eq"; |
|
7717
e7ecfa617443
Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents:
7658
diff
changeset
|
860 |
|
e7ecfa617443
Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents:
7658
diff
changeset
|
861 |
local |
9892 | 862 |
val ss = HOL_basic_ss addsimps |
863 |
(Drule.norm_hhf_eq :: map Thm.symmetric (ball_eq :: thms "atomize")); |
|
7717
e7ecfa617443
Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents:
7658
diff
changeset
|
864 |
in |
e7ecfa617443
Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents:
7658
diff
changeset
|
865 |
|
9892 | 866 |
structure Rulify = RulifyFun |
867 |
(val make_meta = Simplifier.simplify ss |
|
868 |
val full_make_meta = Simplifier.full_simplify ss); |
|
869 |
||
870 |
structure BasicRulify: BASIC_RULIFY = Rulify; |
|
871 |
open BasicRulify; |
|
7717
e7ecfa617443
Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents:
7658
diff
changeset
|
872 |
|
e7ecfa617443
Added attribute rulify_prems (useful for modifying premises of introduction
berghofe
parents:
7658
diff
changeset
|
873 |
end; |