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