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 |
|
|
6 |
For set.thy. Set theory for higher-order logic. A set is simply a predicate.
|
|
7 |
*)
|
|
8 |
|
|
9 |
open Set;
|
|
10 |
|
1548
|
11 |
section "Relating predicates and sets";
|
|
12 |
|
|
13 |
val [prem] = goal Set.thy "P(a) ==> a : {x.P(x)}";
|
923
|
14 |
by (rtac (mem_Collect_eq RS ssubst) 1);
|
|
15 |
by (rtac prem 1);
|
|
16 |
qed "CollectI";
|
|
17 |
|
|
18 |
val prems = goal Set.thy "[| a : {x.P(x)} |] ==> P(a)";
|
|
19 |
by (resolve_tac (prems RL [mem_Collect_eq RS subst]) 1);
|
|
20 |
qed "CollectD";
|
|
21 |
|
|
22 |
val [prem] = goal Set.thy "[| !!x. (x:A) = (x:B) |] ==> A = B";
|
|
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 |
|
|
28 |
val [prem] = goal Set.thy "[| !!x. P(x)=Q(x) |] ==> {x. P(x)} = {x. Q(x)}";
|
|
29 |
by (rtac (prem RS ext RS arg_cong) 1);
|
|
30 |
qed "Collect_cong";
|
|
31 |
|
|
32 |
val CollectE = make_elim CollectD;
|
|
33 |
|
1548
|
34 |
section "Bounded quantifiers";
|
923
|
35 |
|
|
36 |
val prems = goalw Set.thy [Ball_def]
|
|
37 |
"[| !!x. x:A ==> P(x) |] ==> ! x:A. P(x)";
|
|
38 |
by (REPEAT (ares_tac (prems @ [allI,impI]) 1));
|
|
39 |
qed "ballI";
|
|
40 |
|
|
41 |
val [major,minor] = goalw Set.thy [Ball_def]
|
|
42 |
"[| ! x:A. P(x); x:A |] ==> P(x)";
|
|
43 |
by (rtac (minor RS (major RS spec RS mp)) 1);
|
|
44 |
qed "bspec";
|
|
45 |
|
|
46 |
val major::prems = goalw Set.thy [Ball_def]
|
|
47 |
"[| ! x:A. P(x); P(x) ==> Q; x~:A ==> Q |] ==> Q";
|
|
48 |
by (rtac (major RS spec RS impCE) 1);
|
|
49 |
by (REPEAT (eresolve_tac prems 1));
|
|
50 |
qed "ballE";
|
|
51 |
|
|
52 |
(*Takes assumptions ! x:A.P(x) and a:A; creates assumption P(a)*)
|
|
53 |
fun ball_tac i = etac ballE i THEN contr_tac (i+1);
|
|
54 |
|
|
55 |
val prems = goalw Set.thy [Bex_def]
|
|
56 |
"[| P(x); x:A |] ==> ? x:A. P(x)";
|
|
57 |
by (REPEAT (ares_tac (prems @ [exI,conjI]) 1));
|
|
58 |
qed "bexI";
|
|
59 |
|
|
60 |
qed_goal "bexCI" Set.thy
|
|
61 |
"[| ! x:A. ~P(x) ==> P(a); a:A |] ==> ? x:A.P(x)"
|
|
62 |
(fn prems=>
|
|
63 |
[ (rtac classical 1),
|
|
64 |
(REPEAT (ares_tac (prems@[bexI,ballI,notI,notE]) 1)) ]);
|
|
65 |
|
|
66 |
val major::prems = goalw Set.thy [Bex_def]
|
|
67 |
"[| ? x:A. P(x); !!x. [| x:A; P(x) |] ==> Q |] ==> Q";
|
|
68 |
by (rtac (major RS exE) 1);
|
|
69 |
by (REPEAT (eresolve_tac (prems @ [asm_rl,conjE]) 1));
|
|
70 |
qed "bexE";
|
|
71 |
|
|
72 |
(*Trival rewrite rule; (! x:A.P)=P holds only if A is nonempty!*)
|
1618
|
73 |
goal Set.thy "(! x:A. True) = True";
|
923
|
74 |
by (REPEAT (ares_tac [TrueI,ballI,iffI] 1));
|
|
75 |
qed "ball_rew";
|
1618
|
76 |
Addsimps [ball_rew];
|
923
|
77 |
|
|
78 |
(** Congruence rules **)
|
|
79 |
|
|
80 |
val prems = goal Set.thy
|
|
81 |
"[| A=B; !!x. x:B ==> P(x) = Q(x) |] ==> \
|
|
82 |
\ (! x:A. P(x)) = (! x:B. Q(x))";
|
|
83 |
by (resolve_tac (prems RL [ssubst]) 1);
|
|
84 |
by (REPEAT (ares_tac [ballI,iffI] 1
|
|
85 |
ORELSE eresolve_tac ([make_elim bspec, mp] @ (prems RL [iffE])) 1));
|
|
86 |
qed "ball_cong";
|
|
87 |
|
|
88 |
val prems = goal Set.thy
|
|
89 |
"[| A=B; !!x. x:B ==> P(x) = Q(x) |] ==> \
|
|
90 |
\ (? x:A. P(x)) = (? x:B. Q(x))";
|
|
91 |
by (resolve_tac (prems RL [ssubst]) 1);
|
|
92 |
by (REPEAT (etac bexE 1
|
|
93 |
ORELSE ares_tac ([bexI,iffI] @ (prems RL [iffD1,iffD2])) 1));
|
|
94 |
qed "bex_cong";
|
|
95 |
|
1548
|
96 |
section "Subsets";
|
923
|
97 |
|
|
98 |
val prems = goalw Set.thy [subset_def] "(!!x.x:A ==> x:B) ==> A <= B";
|
|
99 |
by (REPEAT (ares_tac (prems @ [ballI]) 1));
|
|
100 |
qed "subsetI";
|
|
101 |
|
|
102 |
(*Rule in Modus Ponens style*)
|
|
103 |
val major::prems = goalw Set.thy [subset_def] "[| A <= B; c:A |] ==> c:B";
|
|
104 |
by (rtac (major RS bspec) 1);
|
|
105 |
by (resolve_tac prems 1);
|
|
106 |
qed "subsetD";
|
|
107 |
|
|
108 |
(*The same, with reversed premises for use with etac -- cf rev_mp*)
|
|
109 |
qed_goal "rev_subsetD" Set.thy "[| c:A; A <= B |] ==> c:B"
|
|
110 |
(fn prems=> [ (REPEAT (resolve_tac (prems@[subsetD]) 1)) ]);
|
|
111 |
|
|
112 |
(*Classical elimination rule*)
|
|
113 |
val major::prems = goalw Set.thy [subset_def]
|
|
114 |
"[| A <= B; c~:A ==> P; c:B ==> P |] ==> P";
|
|
115 |
by (rtac (major RS ballE) 1);
|
|
116 |
by (REPEAT (eresolve_tac prems 1));
|
|
117 |
qed "subsetCE";
|
|
118 |
|
|
119 |
(*Takes assumptions A<=B; c:A and creates the assumption c:B *)
|
|
120 |
fun set_mp_tac i = etac subsetCE i THEN mp_tac i;
|
|
121 |
|
|
122 |
qed_goal "subset_refl" Set.thy "A <= (A::'a set)"
|
|
123 |
(fn _=> [ (REPEAT (ares_tac [subsetI] 1)) ]);
|
|
124 |
|
|
125 |
val prems = goal Set.thy "[| A<=B; B<=C |] ==> A<=(C::'a set)";
|
|
126 |
by (cut_facts_tac prems 1);
|
|
127 |
by (REPEAT (ares_tac [subsetI] 1 ORELSE set_mp_tac 1));
|
|
128 |
qed "subset_trans";
|
|
129 |
|
|
130 |
|
1548
|
131 |
section "Equality";
|
923
|
132 |
|
|
133 |
(*Anti-symmetry of the subset relation*)
|
|
134 |
val prems = goal Set.thy "[| A <= B; B <= A |] ==> A = (B::'a set)";
|
|
135 |
by (rtac (iffI RS set_ext) 1);
|
|
136 |
by (REPEAT (ares_tac (prems RL [subsetD]) 1));
|
|
137 |
qed "subset_antisym";
|
|
138 |
val equalityI = subset_antisym;
|
|
139 |
|
|
140 |
(* Equality rules from ZF set theory -- are they appropriate here? *)
|
|
141 |
val prems = goal Set.thy "A = B ==> A<=(B::'a set)";
|
|
142 |
by (resolve_tac (prems RL [subst]) 1);
|
|
143 |
by (rtac subset_refl 1);
|
|
144 |
qed "equalityD1";
|
|
145 |
|
|
146 |
val prems = goal Set.thy "A = B ==> B<=(A::'a set)";
|
|
147 |
by (resolve_tac (prems RL [subst]) 1);
|
|
148 |
by (rtac subset_refl 1);
|
|
149 |
qed "equalityD2";
|
|
150 |
|
|
151 |
val prems = goal Set.thy
|
|
152 |
"[| A = B; [| A<=B; B<=(A::'a set) |] ==> P |] ==> P";
|
|
153 |
by (resolve_tac prems 1);
|
|
154 |
by (REPEAT (resolve_tac (prems RL [equalityD1,equalityD2]) 1));
|
|
155 |
qed "equalityE";
|
|
156 |
|
|
157 |
val major::prems = goal Set.thy
|
|
158 |
"[| A = B; [| c:A; c:B |] ==> P; [| c~:A; c~:B |] ==> P |] ==> P";
|
|
159 |
by (rtac (major RS equalityE) 1);
|
|
160 |
by (REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1));
|
|
161 |
qed "equalityCE";
|
|
162 |
|
|
163 |
(*Lemma for creating induction formulae -- for "pattern matching" on p
|
|
164 |
To make the induction hypotheses usable, apply "spec" or "bspec" to
|
|
165 |
put universal quantifiers over the free variables in p. *)
|
|
166 |
val prems = goal Set.thy
|
|
167 |
"[| p:A; !!z. z:A ==> p=z --> R |] ==> R";
|
|
168 |
by (rtac mp 1);
|
|
169 |
by (REPEAT (resolve_tac (refl::prems) 1));
|
|
170 |
qed "setup_induction";
|
|
171 |
|
|
172 |
|
1548
|
173 |
section "Set complement -- Compl";
|
923
|
174 |
|
|
175 |
val prems = goalw Set.thy [Compl_def]
|
|
176 |
"[| c:A ==> False |] ==> c : Compl(A)";
|
|
177 |
by (REPEAT (ares_tac (prems @ [CollectI,notI]) 1));
|
|
178 |
qed "ComplI";
|
|
179 |
|
|
180 |
(*This form, with negated conclusion, works well with the Classical prover.
|
|
181 |
Negated assumptions behave like formulae on the right side of the notional
|
|
182 |
turnstile...*)
|
|
183 |
val major::prems = goalw Set.thy [Compl_def]
|
|
184 |
"[| c : Compl(A) |] ==> c~:A";
|
|
185 |
by (rtac (major RS CollectD) 1);
|
|
186 |
qed "ComplD";
|
|
187 |
|
|
188 |
val ComplE = make_elim ComplD;
|
|
189 |
|
1640
|
190 |
qed_goal "Compl_iff" Set.thy "(c : Compl(A)) = (c~:A)"
|
|
191 |
(fn _ => [ (fast_tac (HOL_cs addSIs [ComplI] addSEs [ComplE]) 1) ]);
|
|
192 |
|
923
|
193 |
|
1548
|
194 |
section "Binary union -- Un";
|
923
|
195 |
|
|
196 |
val prems = goalw Set.thy [Un_def] "c:A ==> c : A Un B";
|
|
197 |
by (REPEAT (resolve_tac (prems @ [CollectI,disjI1]) 1));
|
|
198 |
qed "UnI1";
|
|
199 |
|
|
200 |
val prems = goalw Set.thy [Un_def] "c:B ==> c : A Un B";
|
|
201 |
by (REPEAT (resolve_tac (prems @ [CollectI,disjI2]) 1));
|
|
202 |
qed "UnI2";
|
|
203 |
|
|
204 |
(*Classical introduction rule: no commitment to A vs B*)
|
|
205 |
qed_goal "UnCI" Set.thy "(c~:B ==> c:A) ==> c : A Un B"
|
|
206 |
(fn prems=>
|
|
207 |
[ (rtac classical 1),
|
|
208 |
(REPEAT (ares_tac (prems@[UnI1,notI]) 1)),
|
|
209 |
(REPEAT (ares_tac (prems@[UnI2,notE]) 1)) ]);
|
|
210 |
|
|
211 |
val major::prems = goalw Set.thy [Un_def]
|
|
212 |
"[| c : A Un B; c:A ==> P; c:B ==> P |] ==> P";
|
|
213 |
by (rtac (major RS CollectD RS disjE) 1);
|
|
214 |
by (REPEAT (eresolve_tac prems 1));
|
|
215 |
qed "UnE";
|
|
216 |
|
1640
|
217 |
qed_goal "Un_iff" Set.thy "(c : A Un B) = (c:A | c:B)"
|
|
218 |
(fn _ => [ (fast_tac (HOL_cs addSIs [UnCI] addSEs [UnE]) 1) ]);
|
|
219 |
|
923
|
220 |
|
1548
|
221 |
section "Binary intersection -- Int";
|
923
|
222 |
|
|
223 |
val prems = goalw Set.thy [Int_def]
|
|
224 |
"[| c:A; c:B |] ==> c : A Int B";
|
|
225 |
by (REPEAT (resolve_tac (prems @ [CollectI,conjI]) 1));
|
|
226 |
qed "IntI";
|
|
227 |
|
|
228 |
val [major] = goalw Set.thy [Int_def] "c : A Int B ==> c:A";
|
|
229 |
by (rtac (major RS CollectD RS conjunct1) 1);
|
|
230 |
qed "IntD1";
|
|
231 |
|
|
232 |
val [major] = goalw Set.thy [Int_def] "c : A Int B ==> c:B";
|
|
233 |
by (rtac (major RS CollectD RS conjunct2) 1);
|
|
234 |
qed "IntD2";
|
|
235 |
|
|
236 |
val [major,minor] = goal Set.thy
|
|
237 |
"[| c : A Int B; [| c:A; c:B |] ==> P |] ==> P";
|
|
238 |
by (rtac minor 1);
|
|
239 |
by (rtac (major RS IntD1) 1);
|
|
240 |
by (rtac (major RS IntD2) 1);
|
|
241 |
qed "IntE";
|
|
242 |
|
1640
|
243 |
qed_goal "Int_iff" Set.thy "(c : A Int B) = (c:A & c:B)"
|
|
244 |
(fn _ => [ (fast_tac (HOL_cs addSIs [IntI] addSEs [IntE]) 1) ]);
|
|
245 |
|
923
|
246 |
|
1548
|
247 |
section "Set difference";
|
923
|
248 |
|
|
249 |
qed_goalw "DiffI" Set.thy [set_diff_def]
|
|
250 |
"[| c : A; c ~: B |] ==> c : A - B"
|
|
251 |
(fn prems=> [ (REPEAT (resolve_tac (prems @ [CollectI,conjI]) 1)) ]);
|
|
252 |
|
|
253 |
qed_goalw "DiffD1" Set.thy [set_diff_def]
|
|
254 |
"c : A - B ==> c : A"
|
|
255 |
(fn [major]=> [ (rtac (major RS CollectD RS conjunct1) 1) ]);
|
|
256 |
|
|
257 |
qed_goalw "DiffD2" Set.thy [set_diff_def]
|
|
258 |
"[| c : A - B; c : B |] ==> P"
|
|
259 |
(fn [major,minor]=>
|
|
260 |
[rtac (minor RS (major RS CollectD RS conjunct2 RS notE)) 1]);
|
|
261 |
|
|
262 |
qed_goal "DiffE" Set.thy
|
|
263 |
"[| c : A - B; [| c:A; c~:B |] ==> P |] ==> P"
|
|
264 |
(fn prems=>
|
|
265 |
[ (resolve_tac prems 1),
|
|
266 |
(REPEAT (ares_tac (prems RL [DiffD1, DiffD2 RS notI]) 1)) ]);
|
|
267 |
|
|
268 |
qed_goal "Diff_iff" Set.thy "(c : A-B) = (c:A & c~:B)"
|
|
269 |
(fn _ => [ (fast_tac (HOL_cs addSIs [DiffI] addSEs [DiffE]) 1) ]);
|
|
270 |
|
1548
|
271 |
section "The empty set -- {}";
|
923
|
272 |
|
|
273 |
qed_goalw "emptyE" Set.thy [empty_def] "a:{} ==> P"
|
|
274 |
(fn [prem] => [rtac (prem RS CollectD RS FalseE) 1]);
|
|
275 |
|
|
276 |
qed_goal "empty_subsetI" Set.thy "{} <= A"
|
|
277 |
(fn _ => [ (REPEAT (ares_tac [equalityI,subsetI,emptyE] 1)) ]);
|
|
278 |
|
|
279 |
qed_goal "equals0I" Set.thy "[| !!y. y:A ==> False |] ==> A={}"
|
|
280 |
(fn prems=>
|
|
281 |
[ (REPEAT (ares_tac (prems@[empty_subsetI,subsetI,equalityI]) 1
|
|
282 |
ORELSE eresolve_tac (prems RL [FalseE]) 1)) ]);
|
|
283 |
|
|
284 |
qed_goal "equals0D" Set.thy "[| A={}; a:A |] ==> P"
|
|
285 |
(fn [major,minor]=>
|
|
286 |
[ (rtac (minor RS (major RS equalityD1 RS subsetD RS emptyE)) 1) ]);
|
|
287 |
|
1640
|
288 |
qed_goal "empty_iff" Set.thy "(c : {}) = False"
|
|
289 |
(fn _ => [ (fast_tac (HOL_cs addSEs [emptyE]) 1) ]);
|
|
290 |
|
923
|
291 |
|
1548
|
292 |
section "Augmenting a set -- insert";
|
923
|
293 |
|
|
294 |
qed_goalw "insertI1" Set.thy [insert_def] "a : insert a B"
|
|
295 |
(fn _ => [rtac (CollectI RS UnI1) 1, rtac refl 1]);
|
|
296 |
|
|
297 |
qed_goalw "insertI2" Set.thy [insert_def] "a : B ==> a : insert b B"
|
|
298 |
(fn [prem]=> [ (rtac (prem RS UnI2) 1) ]);
|
|
299 |
|
|
300 |
qed_goalw "insertE" Set.thy [insert_def]
|
|
301 |
"[| a : insert b A; a=b ==> P; a:A ==> P |] ==> P"
|
|
302 |
(fn major::prems=>
|
|
303 |
[ (rtac (major RS UnE) 1),
|
|
304 |
(REPEAT (eresolve_tac (prems @ [CollectE]) 1)) ]);
|
|
305 |
|
|
306 |
qed_goal "insert_iff" Set.thy "a : insert b A = (a=b | a:A)"
|
|
307 |
(fn _ => [fast_tac (HOL_cs addIs [insertI1,insertI2] addSEs [insertE]) 1]);
|
|
308 |
|
|
309 |
(*Classical introduction rule*)
|
|
310 |
qed_goal "insertCI" Set.thy "(a~:B ==> a=b) ==> a: insert b B"
|
|
311 |
(fn [prem]=>
|
|
312 |
[ (rtac (disjCI RS (insert_iff RS iffD2)) 1),
|
|
313 |
(etac prem 1) ]);
|
|
314 |
|
1548
|
315 |
section "Singletons, using insert";
|
923
|
316 |
|
|
317 |
qed_goal "singletonI" Set.thy "a : {a}"
|
|
318 |
(fn _=> [ (rtac insertI1 1) ]);
|
|
319 |
|
|
320 |
qed_goal "singletonE" Set.thy "[| a: {b}; a=b ==> P |] ==> P"
|
|
321 |
(fn major::prems=>
|
|
322 |
[ (rtac (major RS insertE) 1),
|
|
323 |
(REPEAT (eresolve_tac (prems @ [emptyE]) 1)) ]);
|
|
324 |
|
|
325 |
goalw Set.thy [insert_def] "!!a. b : {a} ==> b=a";
|
1552
|
326 |
by (fast_tac (HOL_cs addSEs [emptyE,CollectE,UnE]) 1);
|
923
|
327 |
qed "singletonD";
|
|
328 |
|
|
329 |
val singletonE = make_elim singletonD;
|
|
330 |
|
|
331 |
val [major] = goal Set.thy "{a}={b} ==> a=b";
|
|
332 |
by (rtac (major RS equalityD1 RS subsetD RS singletonD) 1);
|
|
333 |
by (rtac singletonI 1);
|
|
334 |
qed "singleton_inject";
|
|
335 |
|
1531
|
336 |
|
1548
|
337 |
section "The universal set -- UNIV";
|
1531
|
338 |
|
|
339 |
qed_goal "subset_UNIV" Set.thy "A <= UNIV"
|
|
340 |
(fn _ => [rtac subsetI 1, rtac ComplI 1, etac emptyE 1]);
|
|
341 |
|
|
342 |
|
1548
|
343 |
section "Unions of families -- UNION x:A. B(x) is Union(B``A)";
|
923
|
344 |
|
|
345 |
(*The order of the premises presupposes that A is rigid; b may be flexible*)
|
|
346 |
val prems = goalw Set.thy [UNION_def]
|
|
347 |
"[| a:A; b: B(a) |] ==> b: (UN x:A. B(x))";
|
|
348 |
by (REPEAT (resolve_tac (prems @ [bexI,CollectI]) 1));
|
|
349 |
qed "UN_I";
|
|
350 |
|
|
351 |
val major::prems = goalw Set.thy [UNION_def]
|
|
352 |
"[| b : (UN x:A. B(x)); !!x.[| x:A; b: B(x) |] ==> R |] ==> R";
|
|
353 |
by (rtac (major RS CollectD RS bexE) 1);
|
|
354 |
by (REPEAT (ares_tac prems 1));
|
|
355 |
qed "UN_E";
|
|
356 |
|
|
357 |
val prems = goal Set.thy
|
|
358 |
"[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> \
|
|
359 |
\ (UN x:A. C(x)) = (UN x:B. D(x))";
|
|
360 |
by (REPEAT (etac UN_E 1
|
|
361 |
ORELSE ares_tac ([UN_I,equalityI,subsetI] @
|
1465
|
362 |
(prems RL [equalityD1,equalityD2] RL [subsetD])) 1));
|
923
|
363 |
qed "UN_cong";
|
|
364 |
|
|
365 |
|
1548
|
366 |
section "Intersections of families -- INTER x:A. B(x) is Inter(B``A)";
|
923
|
367 |
|
|
368 |
val prems = goalw Set.thy [INTER_def]
|
|
369 |
"(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))";
|
|
370 |
by (REPEAT (ares_tac ([CollectI,ballI] @ prems) 1));
|
|
371 |
qed "INT_I";
|
|
372 |
|
|
373 |
val major::prems = goalw Set.thy [INTER_def]
|
|
374 |
"[| b : (INT x:A. B(x)); a:A |] ==> b: B(a)";
|
|
375 |
by (rtac (major RS CollectD RS bspec) 1);
|
|
376 |
by (resolve_tac prems 1);
|
|
377 |
qed "INT_D";
|
|
378 |
|
|
379 |
(*"Classical" elimination -- by the Excluded Middle on a:A *)
|
|
380 |
val major::prems = goalw Set.thy [INTER_def]
|
|
381 |
"[| b : (INT x:A. B(x)); b: B(a) ==> R; a~:A ==> R |] ==> R";
|
|
382 |
by (rtac (major RS CollectD RS ballE) 1);
|
|
383 |
by (REPEAT (eresolve_tac prems 1));
|
|
384 |
qed "INT_E";
|
|
385 |
|
|
386 |
val prems = goal Set.thy
|
|
387 |
"[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> \
|
|
388 |
\ (INT x:A. C(x)) = (INT x:B. D(x))";
|
|
389 |
by (REPEAT_FIRST (resolve_tac [INT_I,equalityI,subsetI]));
|
|
390 |
by (REPEAT (dtac INT_D 1
|
|
391 |
ORELSE ares_tac (prems RL [equalityD1,equalityD2] RL [subsetD]) 1));
|
|
392 |
qed "INT_cong";
|
|
393 |
|
|
394 |
|
1548
|
395 |
section "Unions over a type; UNION1(B) = Union(range(B))";
|
923
|
396 |
|
|
397 |
(*The order of the premises presupposes that A is rigid; b may be flexible*)
|
|
398 |
val prems = goalw Set.thy [UNION1_def]
|
|
399 |
"b: B(x) ==> b: (UN x. B(x))";
|
|
400 |
by (REPEAT (resolve_tac (prems @ [TrueI, CollectI RS UN_I]) 1));
|
|
401 |
qed "UN1_I";
|
|
402 |
|
|
403 |
val major::prems = goalw Set.thy [UNION1_def]
|
|
404 |
"[| b : (UN x. B(x)); !!x. b: B(x) ==> R |] ==> R";
|
|
405 |
by (rtac (major RS UN_E) 1);
|
|
406 |
by (REPEAT (ares_tac prems 1));
|
|
407 |
qed "UN1_E";
|
|
408 |
|
|
409 |
|
1548
|
410 |
section "Intersections over a type; INTER1(B) = Inter(range(B))";
|
923
|
411 |
|
|
412 |
val prems = goalw Set.thy [INTER1_def]
|
|
413 |
"(!!x. b: B(x)) ==> b : (INT x. B(x))";
|
|
414 |
by (REPEAT (ares_tac (INT_I::prems) 1));
|
|
415 |
qed "INT1_I";
|
|
416 |
|
|
417 |
val [major] = goalw Set.thy [INTER1_def]
|
|
418 |
"b : (INT x. B(x)) ==> b: B(a)";
|
|
419 |
by (rtac (TrueI RS (CollectI RS (major RS INT_D))) 1);
|
|
420 |
qed "INT1_D";
|
|
421 |
|
1548
|
422 |
section "Union";
|
923
|
423 |
|
|
424 |
(*The order of the premises presupposes that C is rigid; A may be flexible*)
|
|
425 |
val prems = goalw Set.thy [Union_def]
|
|
426 |
"[| X:C; A:X |] ==> A : Union(C)";
|
|
427 |
by (REPEAT (resolve_tac (prems @ [UN_I]) 1));
|
|
428 |
qed "UnionI";
|
|
429 |
|
|
430 |
val major::prems = goalw Set.thy [Union_def]
|
|
431 |
"[| A : Union(C); !!X.[| A:X; X:C |] ==> R |] ==> R";
|
|
432 |
by (rtac (major RS UN_E) 1);
|
|
433 |
by (REPEAT (ares_tac prems 1));
|
|
434 |
qed "UnionE";
|
|
435 |
|
1548
|
436 |
section "Inter";
|
923
|
437 |
|
|
438 |
val prems = goalw Set.thy [Inter_def]
|
|
439 |
"[| !!X. X:C ==> A:X |] ==> A : Inter(C)";
|
|
440 |
by (REPEAT (ares_tac ([INT_I] @ prems) 1));
|
|
441 |
qed "InterI";
|
|
442 |
|
|
443 |
(*A "destruct" rule -- every X in C contains A as an element, but
|
|
444 |
A:X can hold when X:C does not! This rule is analogous to "spec". *)
|
|
445 |
val major::prems = goalw Set.thy [Inter_def]
|
|
446 |
"[| A : Inter(C); X:C |] ==> A:X";
|
|
447 |
by (rtac (major RS INT_D) 1);
|
|
448 |
by (resolve_tac prems 1);
|
|
449 |
qed "InterD";
|
|
450 |
|
|
451 |
(*"Classical" elimination rule -- does not require proving X:C *)
|
|
452 |
val major::prems = goalw Set.thy [Inter_def]
|
|
453 |
"[| A : Inter(C); A:X ==> R; X~:C ==> R |] ==> R";
|
|
454 |
by (rtac (major RS INT_E) 1);
|
|
455 |
by (REPEAT (eresolve_tac prems 1));
|
|
456 |
qed "InterE";
|
|
457 |
|
1548
|
458 |
section "The Powerset operator -- Pow";
|
923
|
459 |
|
|
460 |
qed_goalw "PowI" Set.thy [Pow_def] "!!A B. A <= B ==> A : Pow(B)"
|
|
461 |
(fn _ => [ (etac CollectI 1) ]);
|
|
462 |
|
|
463 |
qed_goalw "PowD" Set.thy [Pow_def] "!!A B. A : Pow(B) ==> A<=B"
|
|
464 |
(fn _=> [ (etac CollectD 1) ]);
|
|
465 |
|
|
466 |
val Pow_bottom = empty_subsetI RS PowI; (* {}: Pow(B) *)
|
|
467 |
val Pow_top = subset_refl RS PowI; (* A : Pow(A) *)
|