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