author | paulson |
Mon, 19 Jul 1999 15:24:35 +0200 | |
changeset 7031 | 972b5f62f476 |
parent 7007 | b46ccfee8e59 |
child 7441 | 20b3e2d2fcb6 |
permissions | -rw-r--r-- |
1465 | 1 |
(* Title: HOL/set |
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 |
||
5316 | 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 |
||
5316 | 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 |
||
32 |
val CollectE = make_elim CollectD; |
|
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] |
923 | 41 |
"[| !!x. x:A ==> P(x) |] ==> ! x:A. P(x)"; |
42 |
by (REPEAT (ares_tac (prems @ [allI,impI]) 1)); |
|
43 |
qed "ballI"; |
|
44 |
||
5316 | 45 |
Goalw [Ball_def] "[| ! x:A. P(x); x:A |] ==> P(x)"; |
46 |
by (Blast_tac 1); |
|
923 | 47 |
qed "bspec"; |
48 |
||
5316 | 49 |
val major::prems = Goalw [Ball_def] |
923 | 50 |
"[| ! x:A. P(x); P(x) ==> Q; x~:A ==> Q |] ==> Q"; |
51 |
by (rtac (major RS spec RS impCE) 1); |
|
52 |
by (REPEAT (eresolve_tac prems 1)); |
|
53 |
qed "ballE"; |
|
54 |
||
55 |
(*Takes assumptions ! x:A.P(x) and a:A; creates assumption P(a)*) |
|
56 |
fun ball_tac i = etac ballE i THEN contr_tac (i+1); |
|
57 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
58 |
AddSIs [ballI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
59 |
AddEs [ballE]; |
5521 | 60 |
(* gives better instantiation for bound: *) |
61 |
claset_ref() := claset() addWrapper ("bspec", fn tac2 => |
|
62 |
(dtac bspec THEN' atac) APPEND' tac2); |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
63 |
|
6006 | 64 |
(*Normally the best argument order: P(x) constrains the choice of x:A*) |
5316 | 65 |
Goalw [Bex_def] "[| P(x); x:A |] ==> ? x:A. P(x)"; |
66 |
by (Blast_tac 1); |
|
923 | 67 |
qed "bexI"; |
68 |
||
6006 | 69 |
(*The best argument order when there is only one x:A*) |
70 |
Goalw [Bex_def] "[| x:A; P(x) |] ==> ? x:A. P(x)"; |
|
71 |
by (Blast_tac 1); |
|
72 |
qed "rev_bexI"; |
|
73 |
||
7031 | 74 |
val prems = Goal |
7007 | 75 |
"[| ! x:A. ~P(x) ==> P(a); a:A |] ==> ? x:A. P(x)"; |
76 |
by (rtac classical 1); |
|
77 |
by (REPEAT (ares_tac (prems@[bexI,ballI,notI,notE]) 1)) ; |
|
78 |
qed "bexCI"; |
|
923 | 79 |
|
5316 | 80 |
val major::prems = Goalw [Bex_def] |
923 | 81 |
"[| ? x:A. P(x); !!x. [| x:A; P(x) |] ==> Q |] ==> Q"; |
82 |
by (rtac (major RS exE) 1); |
|
83 |
by (REPEAT (eresolve_tac (prems @ [asm_rl,conjE]) 1)); |
|
84 |
qed "bexE"; |
|
85 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
86 |
AddIs [bexI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
87 |
AddSEs [bexE]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
88 |
|
3420 | 89 |
(*Trival rewrite rule*) |
5069 | 90 |
Goal "(! x:A. P) = ((? x. x:A) --> P)"; |
4089 | 91 |
by (simp_tac (simpset() addsimps [Ball_def]) 1); |
3420 | 92 |
qed "ball_triv"; |
1816 | 93 |
|
1882 | 94 |
(*Dual form for existentials*) |
5069 | 95 |
Goal "(? x:A. P) = ((? x. x:A) & P)"; |
4089 | 96 |
by (simp_tac (simpset() addsimps [Bex_def]) 1); |
3420 | 97 |
qed "bex_triv"; |
1882 | 98 |
|
3420 | 99 |
Addsimps [ball_triv, bex_triv]; |
923 | 100 |
|
101 |
(** Congruence rules **) |
|
102 |
||
6291 | 103 |
val prems = Goalw [Ball_def] |
923 | 104 |
"[| A=B; !!x. x:B ==> P(x) = Q(x) |] ==> \ |
105 |
\ (! x:A. P(x)) = (! x:B. Q(x))"; |
|
6291 | 106 |
by (asm_simp_tac (simpset() addsimps prems) 1); |
923 | 107 |
qed "ball_cong"; |
108 |
||
6291 | 109 |
val prems = Goalw [Bex_def] |
923 | 110 |
"[| A=B; !!x. x:B ==> P(x) = Q(x) |] ==> \ |
111 |
\ (? x:A. P(x)) = (? x:B. Q(x))"; |
|
6291 | 112 |
by (asm_simp_tac (simpset() addcongs [conj_cong] addsimps prems) 1); |
923 | 113 |
qed "bex_cong"; |
114 |
||
6291 | 115 |
Addcongs [ball_cong,bex_cong]; |
116 |
||
1548 | 117 |
section "Subsets"; |
923 | 118 |
|
5316 | 119 |
val prems = Goalw [subset_def] "(!!x. x:A ==> x:B) ==> A <= B"; |
923 | 120 |
by (REPEAT (ares_tac (prems @ [ballI]) 1)); |
121 |
qed "subsetI"; |
|
122 |
||
5649 | 123 |
(*Map the type ('a set => anything) to just 'a. |
124 |
For overloading constants whose first argument has type "'a set" *) |
|
125 |
fun overload_1st_set s = Blast.overloaded (s, HOLogic.dest_setT o domain_type); |
|
126 |
||
4059 | 127 |
(*While (:) is not, its type must be kept |
128 |
for overloading of = to work.*) |
|
4240
8ba60a4cd380
Renamed "overload" to "overloaded" for sml/nj compatibility
paulson
parents:
4231
diff
changeset
|
129 |
Blast.overloaded ("op :", domain_type); |
5649 | 130 |
|
131 |
overload_1st_set "Ball"; (*need UNION, INTER also?*) |
|
132 |
overload_1st_set "Bex"; |
|
4059 | 133 |
|
4469 | 134 |
(*Image: retain the type of the set being expressed*) |
5336 | 135 |
Blast.overloaded ("op ``", domain_type); |
2881 | 136 |
|
923 | 137 |
(*Rule in Modus Ponens style*) |
5316 | 138 |
Goalw [subset_def] "[| A <= B; c:A |] ==> c:B"; |
139 |
by (Blast_tac 1); |
|
923 | 140 |
qed "subsetD"; |
141 |
||
142 |
(*The same, with reversed premises for use with etac -- cf rev_mp*) |
|
7007 | 143 |
Goal "[| c:A; A <= B |] ==> c:B"; |
144 |
by (REPEAT (ares_tac [subsetD] 1)) ; |
|
145 |
qed "rev_subsetD"; |
|
923 | 146 |
|
1920 | 147 |
(*Converts A<=B to x:A ==> x:B*) |
148 |
fun impOfSubs th = th RSN (2, rev_subsetD); |
|
149 |
||
7007 | 150 |
Goal "[| A <= B; c ~: B |] ==> c ~: A"; |
151 |
by (REPEAT (eresolve_tac [asm_rl, contrapos, subsetD] 1)) ; |
|
152 |
qed "contra_subsetD"; |
|
1841 | 153 |
|
7007 | 154 |
Goal "[| c ~: B; A <= B |] ==> c ~: A"; |
155 |
by (REPEAT (eresolve_tac [asm_rl, contrapos, subsetD] 1)) ; |
|
156 |
qed "rev_contra_subsetD"; |
|
1841 | 157 |
|
923 | 158 |
(*Classical elimination rule*) |
5316 | 159 |
val major::prems = Goalw [subset_def] |
923 | 160 |
"[| A <= B; c~:A ==> P; c:B ==> P |] ==> P"; |
161 |
by (rtac (major RS ballE) 1); |
|
162 |
by (REPEAT (eresolve_tac prems 1)); |
|
163 |
qed "subsetCE"; |
|
164 |
||
165 |
(*Takes assumptions A<=B; c:A and creates the assumption c:B *) |
|
166 |
fun set_mp_tac i = etac subsetCE i THEN mp_tac i; |
|
167 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
168 |
AddSIs [subsetI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
169 |
AddEs [subsetD, subsetCE]; |
923 | 170 |
|
7007 | 171 |
Goal "A <= (A::'a set)"; |
172 |
by (Fast_tac 1); |
|
173 |
qed "subset_refl"; (*Blast_tac would try order_refl and fail*) |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
174 |
|
5316 | 175 |
Goal "[| A<=B; B<=C |] ==> A<=(C::'a set)"; |
2891 | 176 |
by (Blast_tac 1); |
923 | 177 |
qed "subset_trans"; |
178 |
||
179 |
||
1548 | 180 |
section "Equality"; |
923 | 181 |
|
182 |
(*Anti-symmetry of the subset relation*) |
|
5316 | 183 |
Goal "[| A <= B; B <= A |] ==> A = (B::'a set)"; |
5318 | 184 |
by (rtac set_ext 1); |
5316 | 185 |
by (blast_tac (claset() addIs [subsetD]) 1); |
923 | 186 |
qed "subset_antisym"; |
187 |
val equalityI = subset_antisym; |
|
188 |
||
1762 | 189 |
AddSIs [equalityI]; |
190 |
||
923 | 191 |
(* Equality rules from ZF set theory -- are they appropriate here? *) |
5316 | 192 |
Goal "A = B ==> A<=(B::'a set)"; |
193 |
by (etac ssubst 1); |
|
923 | 194 |
by (rtac subset_refl 1); |
195 |
qed "equalityD1"; |
|
196 |
||
5316 | 197 |
Goal "A = B ==> B<=(A::'a set)"; |
198 |
by (etac ssubst 1); |
|
923 | 199 |
by (rtac subset_refl 1); |
200 |
qed "equalityD2"; |
|
201 |
||
5316 | 202 |
val prems = Goal |
923 | 203 |
"[| A = B; [| A<=B; B<=(A::'a set) |] ==> P |] ==> P"; |
204 |
by (resolve_tac prems 1); |
|
205 |
by (REPEAT (resolve_tac (prems RL [equalityD1,equalityD2]) 1)); |
|
206 |
qed "equalityE"; |
|
207 |
||
5316 | 208 |
val major::prems = Goal |
923 | 209 |
"[| A = B; [| c:A; c:B |] ==> P; [| c~:A; c~:B |] ==> P |] ==> P"; |
210 |
by (rtac (major RS equalityE) 1); |
|
211 |
by (REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1)); |
|
212 |
qed "equalityCE"; |
|
213 |
||
214 |
(*Lemma for creating induction formulae -- for "pattern matching" on p |
|
215 |
To make the induction hypotheses usable, apply "spec" or "bspec" to |
|
216 |
put universal quantifiers over the free variables in p. *) |
|
5316 | 217 |
val prems = Goal |
923 | 218 |
"[| p:A; !!z. z:A ==> p=z --> R |] ==> R"; |
219 |
by (rtac mp 1); |
|
220 |
by (REPEAT (resolve_tac (refl::prems) 1)); |
|
221 |
qed "setup_induction"; |
|
222 |
||
223 |
||
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
224 |
section "The universal set -- UNIV"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
225 |
|
7031 | 226 |
Goalw [UNIV_def] "x : UNIV"; |
227 |
by (rtac CollectI 1); |
|
228 |
by (rtac TrueI 1); |
|
229 |
qed "UNIV_I"; |
|
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
230 |
|
4434 | 231 |
Addsimps [UNIV_I]; |
232 |
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
|
233 |
|
7031 | 234 |
Goal "A <= UNIV"; |
235 |
by (rtac subsetI 1); |
|
236 |
by (rtac UNIV_I 1); |
|
237 |
qed "subset_UNIV"; |
|
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
238 |
|
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
239 |
(** 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
|
240 |
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
|
241 |
|
5069 | 242 |
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
|
243 |
by (Simp_tac 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
244 |
qed "ball_UNIV"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
245 |
|
5069 | 246 |
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
|
247 |
by (Simp_tac 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
248 |
qed "bex_UNIV"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
249 |
Addsimps [ball_UNIV, bex_UNIV]; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
250 |
|
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
251 |
|
2858 | 252 |
section "The empty set -- {}"; |
253 |
||
7007 | 254 |
Goalw [empty_def] "(c : {}) = False"; |
255 |
by (Blast_tac 1) ; |
|
256 |
qed "empty_iff"; |
|
2858 | 257 |
|
258 |
Addsimps [empty_iff]; |
|
259 |
||
7007 | 260 |
Goal "a:{} ==> P"; |
261 |
by (Full_simp_tac 1); |
|
262 |
qed "emptyE"; |
|
2858 | 263 |
|
264 |
AddSEs [emptyE]; |
|
265 |
||
7007 | 266 |
Goal "{} <= A"; |
267 |
by (Blast_tac 1) ; |
|
268 |
qed "empty_subsetI"; |
|
2858 | 269 |
|
5256 | 270 |
(*One effect is to delete the ASSUMPTION {} <= A*) |
271 |
AddIffs [empty_subsetI]; |
|
272 |
||
7031 | 273 |
val [prem]= Goal "[| !!y. y:A ==> False |] ==> A={}"; |
7007 | 274 |
by (blast_tac (claset() addIs [prem RS FalseE]) 1) ; |
275 |
qed "equals0I"; |
|
2858 | 276 |
|
5256 | 277 |
(*Use for reasoning about disjointness: A Int B = {} *) |
7007 | 278 |
Goal "A={} ==> a ~: A"; |
279 |
by (Blast_tac 1) ; |
|
280 |
qed "equals0D"; |
|
2858 | 281 |
|
5450
fe9d103464a4
Changed equals0E back to equals0D and gave it the correct destruct form
paulson
parents:
5336
diff
changeset
|
282 |
AddDs [equals0D, sym RS equals0D]; |
5256 | 283 |
|
5069 | 284 |
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
|
285 |
by (Simp_tac 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
286 |
qed "ball_empty"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
287 |
|
5069 | 288 |
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
|
289 |
by (Simp_tac 1); |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
290 |
qed "bex_empty"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
291 |
Addsimps [ball_empty, bex_empty]; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
292 |
|
5069 | 293 |
Goal "UNIV ~= {}"; |
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
294 |
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
|
295 |
qed "UNIV_not_empty"; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
296 |
AddIffs [UNIV_not_empty]; |
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
297 |
|
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
298 |
|
2858 | 299 |
|
300 |
section "The Powerset operator -- Pow"; |
|
301 |
||
7007 | 302 |
Goalw [Pow_def] "(A : Pow(B)) = (A <= B)"; |
303 |
by (Asm_simp_tac 1); |
|
304 |
qed "Pow_iff"; |
|
2858 | 305 |
|
306 |
AddIffs [Pow_iff]; |
|
307 |
||
7031 | 308 |
Goalw [Pow_def] "A <= B ==> A : Pow(B)"; |
7007 | 309 |
by (etac CollectI 1); |
310 |
qed "PowI"; |
|
2858 | 311 |
|
7031 | 312 |
Goalw [Pow_def] "A : Pow(B) ==> A<=B"; |
7007 | 313 |
by (etac CollectD 1); |
314 |
qed "PowD"; |
|
315 |
||
2858 | 316 |
|
317 |
val Pow_bottom = empty_subsetI RS PowI; (* {}: Pow(B) *) |
|
318 |
val Pow_top = subset_refl RS PowI; (* A : Pow(A) *) |
|
319 |
||
320 |
||
5931 | 321 |
section "Set complement"; |
923 | 322 |
|
7031 | 323 |
Goalw [Compl_def] "(c : -A) = (c~:A)"; |
324 |
by (Blast_tac 1); |
|
325 |
qed "Compl_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
326 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
327 |
Addsimps [Compl_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
328 |
|
5490 | 329 |
val prems = Goalw [Compl_def] "[| c:A ==> False |] ==> c : -A"; |
923 | 330 |
by (REPEAT (ares_tac (prems @ [CollectI,notI]) 1)); |
331 |
qed "ComplI"; |
|
332 |
||
333 |
(*This form, with negated conclusion, works well with the Classical prover. |
|
334 |
Negated assumptions behave like formulae on the right side of the notional |
|
335 |
turnstile...*) |
|
5490 | 336 |
Goalw [Compl_def] "c : -A ==> c~:A"; |
5316 | 337 |
by (etac CollectD 1); |
923 | 338 |
qed "ComplD"; |
339 |
||
340 |
val ComplE = make_elim ComplD; |
|
341 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
342 |
AddSIs [ComplI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
343 |
AddSEs [ComplE]; |
1640 | 344 |
|
923 | 345 |
|
1548 | 346 |
section "Binary union -- Un"; |
923 | 347 |
|
7031 | 348 |
Goalw [Un_def] "(c : A Un B) = (c:A | c:B)"; |
349 |
by (Blast_tac 1); |
|
350 |
qed "Un_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
351 |
Addsimps [Un_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
352 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
353 |
Goal "c:A ==> c : A Un B"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
354 |
by (Asm_simp_tac 1); |
923 | 355 |
qed "UnI1"; |
356 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
357 |
Goal "c:B ==> c : A Un B"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
358 |
by (Asm_simp_tac 1); |
923 | 359 |
qed "UnI2"; |
360 |
||
361 |
(*Classical introduction rule: no commitment to A vs B*) |
|
7007 | 362 |
|
7031 | 363 |
val prems = Goal "(c~:B ==> c:A) ==> c : A Un B"; |
7007 | 364 |
by (Simp_tac 1); |
365 |
by (REPEAT (ares_tac (prems@[disjCI]) 1)) ; |
|
366 |
qed "UnCI"; |
|
923 | 367 |
|
5316 | 368 |
val major::prems = Goalw [Un_def] |
923 | 369 |
"[| c : A Un B; c:A ==> P; c:B ==> P |] ==> P"; |
370 |
by (rtac (major RS CollectD RS disjE) 1); |
|
371 |
by (REPEAT (eresolve_tac prems 1)); |
|
372 |
qed "UnE"; |
|
373 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
374 |
AddSIs [UnCI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
375 |
AddSEs [UnE]; |
1640 | 376 |
|
923 | 377 |
|
1548 | 378 |
section "Binary intersection -- Int"; |
923 | 379 |
|
7031 | 380 |
Goalw [Int_def] "(c : A Int B) = (c:A & c:B)"; |
381 |
by (Blast_tac 1); |
|
382 |
qed "Int_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
383 |
Addsimps [Int_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
384 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
385 |
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
|
386 |
by (Asm_simp_tac 1); |
923 | 387 |
qed "IntI"; |
388 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
389 |
Goal "c : A Int B ==> c:A"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
390 |
by (Asm_full_simp_tac 1); |
923 | 391 |
qed "IntD1"; |
392 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
393 |
Goal "c : A Int B ==> c:B"; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
394 |
by (Asm_full_simp_tac 1); |
923 | 395 |
qed "IntD2"; |
396 |
||
5316 | 397 |
val [major,minor] = Goal |
923 | 398 |
"[| c : A Int B; [| c:A; c:B |] ==> P |] ==> P"; |
399 |
by (rtac minor 1); |
|
400 |
by (rtac (major RS IntD1) 1); |
|
401 |
by (rtac (major RS IntD2) 1); |
|
402 |
qed "IntE"; |
|
403 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
404 |
AddSIs [IntI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
405 |
AddSEs [IntE]; |
923 | 406 |
|
1548 | 407 |
section "Set difference"; |
923 | 408 |
|
7031 | 409 |
Goalw [set_diff_def] "(c : A-B) = (c:A & c~:B)"; |
410 |
by (Blast_tac 1); |
|
411 |
qed "Diff_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
412 |
Addsimps [Diff_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
413 |
|
7007 | 414 |
Goal "[| c : A; c ~: B |] ==> c : A - B"; |
415 |
by (Asm_simp_tac 1) ; |
|
416 |
qed "DiffI"; |
|
923 | 417 |
|
7007 | 418 |
Goal "c : A - B ==> c : A"; |
419 |
by (Asm_full_simp_tac 1) ; |
|
420 |
qed "DiffD1"; |
|
923 | 421 |
|
7007 | 422 |
Goal "[| c : A - B; c : B |] ==> P"; |
423 |
by (Asm_full_simp_tac 1) ; |
|
424 |
qed "DiffD2"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
425 |
|
7031 | 426 |
val prems = Goal "[| c : A - B; [| c:A; c~:B |] ==> P |] ==> P"; |
7007 | 427 |
by (resolve_tac prems 1); |
428 |
by (REPEAT (ares_tac (prems RL [DiffD1, DiffD2 RS notI]) 1)) ; |
|
429 |
qed "DiffE"; |
|
923 | 430 |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
431 |
AddSIs [DiffI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
432 |
AddSEs [DiffE]; |
923 | 433 |
|
434 |
||
1548 | 435 |
section "Augmenting a set -- insert"; |
923 | 436 |
|
7031 | 437 |
Goalw [insert_def] "a : insert b A = (a=b | a:A)"; |
438 |
by (Blast_tac 1); |
|
439 |
qed "insert_iff"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
440 |
Addsimps [insert_iff]; |
923 | 441 |
|
7031 | 442 |
Goal "a : insert a B"; |
7007 | 443 |
by (Simp_tac 1); |
444 |
qed "insertI1"; |
|
923 | 445 |
|
7007 | 446 |
Goal "!!a. a : B ==> a : insert b B"; |
447 |
by (Asm_simp_tac 1); |
|
448 |
qed "insertI2"; |
|
449 |
||
450 |
val major::prems = Goalw [insert_def] |
|
451 |
"[| a : insert b A; a=b ==> P; a:A ==> P |] ==> P"; |
|
452 |
by (rtac (major RS UnE) 1); |
|
453 |
by (REPEAT (eresolve_tac (prems @ [CollectE]) 1)); |
|
454 |
qed "insertE"; |
|
923 | 455 |
|
456 |
(*Classical introduction rule*) |
|
7031 | 457 |
val prems = Goal "(a~:B ==> a=b) ==> a: insert b B"; |
7007 | 458 |
by (Simp_tac 1); |
459 |
by (REPEAT (ares_tac (prems@[disjCI]) 1)) ; |
|
460 |
qed "insertCI"; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
461 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
462 |
AddSIs [insertCI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
463 |
AddSEs [insertE]; |
923 | 464 |
|
1548 | 465 |
section "Singletons, using insert"; |
923 | 466 |
|
7007 | 467 |
Goal "a : {a}"; |
468 |
by (rtac insertI1 1) ; |
|
469 |
qed "singletonI"; |
|
923 | 470 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
471 |
Goal "b : {a} ==> b=a"; |
2891 | 472 |
by (Blast_tac 1); |
923 | 473 |
qed "singletonD"; |
474 |
||
1776
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
475 |
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
|
476 |
|
7007 | 477 |
Goal "(b : {a}) = (b=a)"; |
478 |
by (Blast_tac 1); |
|
479 |
qed "singleton_iff"; |
|
923 | 480 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
481 |
Goal "{a}={b} ==> a=b"; |
4089 | 482 |
by (blast_tac (claset() addEs [equalityE]) 1); |
923 | 483 |
qed "singleton_inject"; |
484 |
||
2858 | 485 |
(*Redundant? But unlike insertCI, it proves the subgoal immediately!*) |
486 |
AddSIs [singletonI]; |
|
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
487 |
AddSDs [singleton_inject]; |
3718 | 488 |
AddSEs [singletonE]; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
489 |
|
5069 | 490 |
Goal "{x. x=a} = {a}"; |
4423 | 491 |
by (Blast_tac 1); |
3582 | 492 |
qed "singleton_conv"; |
493 |
Addsimps [singleton_conv]; |
|
1531 | 494 |
|
5600 | 495 |
Goal "{x. a=x} = {a}"; |
6301 | 496 |
by (Blast_tac 1); |
5600 | 497 |
qed "singleton_conv2"; |
498 |
Addsimps [singleton_conv2]; |
|
499 |
||
1531 | 500 |
|
1548 | 501 |
section "Unions of families -- UNION x:A. B(x) is Union(B``A)"; |
923 | 502 |
|
5069 | 503 |
Goalw [UNION_def] "(b: (UN x:A. B(x))) = (EX x:A. b: B(x))"; |
2891 | 504 |
by (Blast_tac 1); |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
505 |
qed "UN_iff"; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
506 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
507 |
Addsimps [UN_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
508 |
|
923 | 509 |
(*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
|
510 |
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
|
511 |
by Auto_tac; |
923 | 512 |
qed "UN_I"; |
513 |
||
5316 | 514 |
val major::prems = Goalw [UNION_def] |
923 | 515 |
"[| b : (UN x:A. B(x)); !!x.[| x:A; b: B(x) |] ==> R |] ==> R"; |
516 |
by (rtac (major RS CollectD RS bexE) 1); |
|
517 |
by (REPEAT (ares_tac prems 1)); |
|
518 |
qed "UN_E"; |
|
519 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
520 |
AddIs [UN_I]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
521 |
AddSEs [UN_E]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
522 |
|
6291 | 523 |
val prems = Goalw [UNION_def] |
923 | 524 |
"[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> \ |
525 |
\ (UN x:A. C(x)) = (UN x:B. D(x))"; |
|
6291 | 526 |
by (asm_simp_tac (simpset() addsimps prems) 1); |
923 | 527 |
qed "UN_cong"; |
528 |
||
529 |
||
1548 | 530 |
section "Intersections of families -- INTER x:A. B(x) is Inter(B``A)"; |
923 | 531 |
|
5069 | 532 |
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
|
533 |
by Auto_tac; |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
534 |
qed "INT_iff"; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
535 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
536 |
Addsimps [INT_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
537 |
|
5316 | 538 |
val prems = Goalw [INTER_def] |
923 | 539 |
"(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))"; |
540 |
by (REPEAT (ares_tac ([CollectI,ballI] @ prems) 1)); |
|
541 |
qed "INT_I"; |
|
542 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
543 |
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
|
544 |
by Auto_tac; |
923 | 545 |
qed "INT_D"; |
546 |
||
547 |
(*"Classical" elimination -- by the Excluded Middle on a:A *) |
|
5316 | 548 |
val major::prems = Goalw [INTER_def] |
923 | 549 |
"[| b : (INT x:A. B(x)); b: B(a) ==> R; a~:A ==> R |] ==> R"; |
550 |
by (rtac (major RS CollectD RS ballE) 1); |
|
551 |
by (REPEAT (eresolve_tac prems 1)); |
|
552 |
qed "INT_E"; |
|
553 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
554 |
AddSIs [INT_I]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
555 |
AddEs [INT_D, INT_E]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
556 |
|
6291 | 557 |
val prems = Goalw [INTER_def] |
923 | 558 |
"[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> \ |
559 |
\ (INT x:A. C(x)) = (INT x:B. D(x))"; |
|
6291 | 560 |
by (asm_simp_tac (simpset() addsimps prems) 1); |
923 | 561 |
qed "INT_cong"; |
562 |
||
563 |
||
1548 | 564 |
section "Union"; |
923 | 565 |
|
5069 | 566 |
Goalw [Union_def] "(A : Union(C)) = (EX X:C. A:X)"; |
2891 | 567 |
by (Blast_tac 1); |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
568 |
qed "Union_iff"; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
569 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
570 |
Addsimps [Union_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
571 |
|
923 | 572 |
(*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
|
573 |
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
|
574 |
by Auto_tac; |
923 | 575 |
qed "UnionI"; |
576 |
||
5316 | 577 |
val major::prems = Goalw [Union_def] |
923 | 578 |
"[| A : Union(C); !!X.[| A:X; X:C |] ==> R |] ==> R"; |
579 |
by (rtac (major RS UN_E) 1); |
|
580 |
by (REPEAT (ares_tac prems 1)); |
|
581 |
qed "UnionE"; |
|
582 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
583 |
AddIs [UnionI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
584 |
AddSEs [UnionE]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
585 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
586 |
|
1548 | 587 |
section "Inter"; |
923 | 588 |
|
5069 | 589 |
Goalw [Inter_def] "(A : Inter(C)) = (ALL X:C. A:X)"; |
2891 | 590 |
by (Blast_tac 1); |
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
591 |
qed "Inter_iff"; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
592 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
593 |
Addsimps [Inter_iff]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
594 |
|
5316 | 595 |
val prems = Goalw [Inter_def] |
923 | 596 |
"[| !!X. X:C ==> A:X |] ==> A : Inter(C)"; |
597 |
by (REPEAT (ares_tac ([INT_I] @ prems) 1)); |
|
598 |
qed "InterI"; |
|
599 |
||
600 |
(*A "destruct" rule -- every X in C contains A as an element, but |
|
601 |
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
|
602 |
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
|
603 |
by Auto_tac; |
923 | 604 |
qed "InterD"; |
605 |
||
606 |
(*"Classical" elimination rule -- does not require proving X:C *) |
|
5316 | 607 |
val major::prems = Goalw [Inter_def] |
2721 | 608 |
"[| A : Inter(C); X~:C ==> R; A:X ==> R |] ==> R"; |
923 | 609 |
by (rtac (major RS INT_E) 1); |
610 |
by (REPEAT (eresolve_tac prems 1)); |
|
611 |
qed "InterE"; |
|
612 |
||
2499
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
613 |
AddSIs [InterI]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
614 |
AddEs [InterD, InterE]; |
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
615 |
|
0bc87b063447
Tidying of proofs. New theorems are enterred immediately into the
paulson
parents:
2031
diff
changeset
|
616 |
|
2912 | 617 |
(*** Image of a set under a function ***) |
618 |
||
619 |
(*Frequently b does not have the syntactic form of f(x).*) |
|
5316 | 620 |
Goalw [image_def] "[| b=f(x); x:A |] ==> b : f``A"; |
621 |
by (Blast_tac 1); |
|
2912 | 622 |
qed "image_eqI"; |
3909 | 623 |
Addsimps [image_eqI]; |
2912 | 624 |
|
625 |
bind_thm ("imageI", refl RS image_eqI); |
|
626 |
||
627 |
(*The eta-expansion gives variable-name preservation.*) |
|
5316 | 628 |
val major::prems = Goalw [image_def] |
3842 | 629 |
"[| b : (%x. f(x))``A; !!x.[| b=f(x); x:A |] ==> P |] ==> P"; |
2912 | 630 |
by (rtac (major RS CollectD RS bexE) 1); |
631 |
by (REPEAT (ares_tac prems 1)); |
|
632 |
qed "imageE"; |
|
633 |
||
634 |
AddIs [image_eqI]; |
|
635 |
AddSEs [imageE]; |
|
636 |
||
5069 | 637 |
Goal "f``(A Un B) = f``A Un f``B"; |
2935 | 638 |
by (Blast_tac 1); |
2912 | 639 |
qed "image_Un"; |
640 |
||
5069 | 641 |
Goal "(z : f``A) = (EX x:A. z = f x)"; |
3960 | 642 |
by (Blast_tac 1); |
643 |
qed "image_iff"; |
|
644 |
||
4523 | 645 |
(*This rewrite rule would confuse users if made default.*) |
5069 | 646 |
Goal "(f``A <= B) = (ALL x:A. f(x): B)"; |
4523 | 647 |
by (Blast_tac 1); |
648 |
qed "image_subset_iff"; |
|
649 |
||
650 |
(*Replaces the three steps subsetI, imageE, hyp_subst_tac, but breaks too |
|
651 |
many existing proofs.*) |
|
5316 | 652 |
val prems = Goal "(!!x. x:A ==> f(x) : B) ==> f``A <= B"; |
4510 | 653 |
by (blast_tac (claset() addIs prems) 1); |
654 |
qed "image_subsetI"; |
|
655 |
||
2912 | 656 |
|
657 |
(*** Range of a function -- just a translation for image! ***) |
|
658 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
659 |
Goal "b=f(x) ==> b : range(f)"; |
2912 | 660 |
by (EVERY1 [etac image_eqI, rtac UNIV_I]); |
661 |
bind_thm ("range_eqI", UNIV_I RSN (2,image_eqI)); |
|
662 |
||
663 |
bind_thm ("rangeI", UNIV_I RS imageI); |
|
664 |
||
5316 | 665 |
val [major,minor] = Goal |
3842 | 666 |
"[| b : range(%x. f(x)); !!x. b=f(x) ==> P |] ==> P"; |
2912 | 667 |
by (rtac (major RS imageE) 1); |
668 |
by (etac minor 1); |
|
669 |
qed "rangeE"; |
|
670 |
||
1776
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
671 |
|
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
672 |
(*** Set reasoning tools ***) |
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
673 |
|
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
674 |
|
3912 | 675 |
(** Rewrite rules for boolean case-splitting: faster than |
4830 | 676 |
addsplits[split_if] |
3912 | 677 |
**) |
678 |
||
4830 | 679 |
bind_thm ("split_if_eq1", read_instantiate [("P", "%x. x = ?b")] split_if); |
680 |
bind_thm ("split_if_eq2", read_instantiate [("P", "%x. ?a = x")] split_if); |
|
3912 | 681 |
|
5237 | 682 |
(*Split ifs on either side of the membership relation. |
683 |
Not for Addsimps -- can cause goals to blow up!*) |
|
4830 | 684 |
bind_thm ("split_if_mem1", |
6394 | 685 |
read_instantiate_sg (Theory.sign_of Set.thy) [("P", "%x. x : ?b")] split_if); |
4830 | 686 |
bind_thm ("split_if_mem2", |
6394 | 687 |
read_instantiate_sg (Theory.sign_of Set.thy) [("P", "%x. ?a : x")] split_if); |
3912 | 688 |
|
4830 | 689 |
val split_ifs = [if_bool_eq_conj, split_if_eq1, split_if_eq2, |
690 |
split_if_mem1, split_if_mem2]; |
|
3912 | 691 |
|
692 |
||
4089 | 693 |
(*Each of these has ALREADY been added to simpset() above.*) |
2024
909153d8318f
Rationalized the rewriting of membership for {} and insert
paulson
parents:
1985
diff
changeset
|
694 |
val mem_simps = [insert_iff, empty_iff, Un_iff, Int_iff, Compl_iff, Diff_iff, |
4159
4aff9b7e5597
UNIV now a constant; UNION1, INTER1 now translations and no longer have
paulson
parents:
4135
diff
changeset
|
695 |
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
|
696 |
|
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
697 |
val mksimps_pairs = ("Ball",[bspec]) :: mksimps_pairs; |
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset
|
698 |
|
6291 | 699 |
simpset_ref() := simpset() setmksimps (mksimps mksimps_pairs); |
3222
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
700 |
|
5256 | 701 |
Addsimps[subset_UNIV, subset_refl]; |
3222
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
702 |
|
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
703 |
|
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
704 |
(*** < ***) |
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
705 |
|
5069 | 706 |
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
|
707 |
by (Blast_tac 1); |
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
708 |
qed "psubsetI"; |
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
709 |
|
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
710 |
Goalw [psubset_def] "A < insert x B ==> (x ~: A) & A<=B | x:A & A-{x}<B"; |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4469
diff
changeset
|
711 |
by Auto_tac; |
3222
726a9b069947
Distributed Psubset stuff to basic set theory files, incl Finite.
nipkow
parents:
2935
diff
changeset
|
712 |
qed "psubset_insertD"; |
4059 | 713 |
|
714 |
bind_thm ("psubset_eq", psubset_def RS meta_eq_to_obj_eq); |
|
6443 | 715 |
|
716 |
bind_thm ("psubset_imp_subset", psubset_eq RS iffD1 RS conjunct1); |
|
717 |
||
718 |
Goal"[| (A::'a set) < B; B <= C |] ==> A < C"; |
|
719 |
by (auto_tac (claset(), simpset() addsimps [psubset_eq])); |
|
720 |
qed "psubset_subset_trans"; |
|
721 |
||
722 |
Goal"[| (A::'a set) <= B; B < C|] ==> A < C"; |
|
723 |
by (auto_tac (claset(), simpset() addsimps [psubset_eq])); |
|
724 |
qed "subset_psubset_trans"; |