author | wenzelm |
Tue, 24 Jan 2006 00:43:31 +0100 | |
changeset 18768 | 6e97b57cdcba |
parent 18413 | 50c0c118e96d |
permissions | -rw-r--r-- |
17456 | 1 |
(* Title: Set/Set.ML |
0 | 2 |
ID: $Id$ |
3 |
*) |
|
4 |
||
17456 | 5 |
val [prem] = goal (the_context ()) "[| P(a) |] ==> a : {x. P(x)}"; |
0 | 6 |
by (rtac (mem_Collect_iff RS iffD2) 1); |
7 |
by (rtac prem 1); |
|
757 | 8 |
qed "CollectI"; |
0 | 9 |
|
17456 | 10 |
val prems = goal (the_context ()) "[| a : {x. P(x)} |] ==> P(a)"; |
0 | 11 |
by (resolve_tac (prems RL [mem_Collect_iff RS iffD1]) 1); |
757 | 12 |
qed "CollectD"; |
0 | 13 |
|
8
c3d2c6dcf3f0
Installation of new simplfier. Previously appeared to set up the old
lcp
parents:
0
diff
changeset
|
14 |
val CollectE = make_elim CollectD; |
c3d2c6dcf3f0
Installation of new simplfier. Previously appeared to set up the old
lcp
parents:
0
diff
changeset
|
15 |
|
17456 | 16 |
val [prem] = goal (the_context ()) "[| !!x. x:A <-> x:B |] ==> A = B"; |
0 | 17 |
by (rtac (set_extension RS iffD2) 1); |
18 |
by (rtac (prem RS allI) 1); |
|
757 | 19 |
qed "set_ext"; |
0 | 20 |
|
21 |
(*** Bounded quantifiers ***) |
|
22 |
||
17456 | 23 |
val prems = goalw (the_context ()) [Ball_def] |
0 | 24 |
"[| !!x. x:A ==> P(x) |] ==> ALL x:A. P(x)"; |
25 |
by (REPEAT (ares_tac (prems @ [allI,impI]) 1)); |
|
757 | 26 |
qed "ballI"; |
0 | 27 |
|
17456 | 28 |
val [major,minor] = goalw (the_context ()) [Ball_def] |
0 | 29 |
"[| ALL x:A. P(x); x:A |] ==> P(x)"; |
30 |
by (rtac (minor RS (major RS spec RS mp)) 1); |
|
757 | 31 |
qed "bspec"; |
0 | 32 |
|
17456 | 33 |
val major::prems = goalw (the_context ()) [Ball_def] |
0 | 34 |
"[| ALL x:A. P(x); P(x) ==> Q; ~ x:A ==> Q |] ==> Q"; |
35 |
by (rtac (major RS spec RS impCE) 1); |
|
36 |
by (REPEAT (eresolve_tac prems 1)); |
|
757 | 37 |
qed "ballE"; |
0 | 38 |
|
39 |
(*Takes assumptions ALL x:A.P(x) and a:A; creates assumption P(a)*) |
|
40 |
fun ball_tac i = etac ballE i THEN contr_tac (i+1); |
|
41 |
||
17456 | 42 |
val prems = goalw (the_context ()) [Bex_def] |
0 | 43 |
"[| P(x); x:A |] ==> EX x:A. P(x)"; |
44 |
by (REPEAT (ares_tac (prems @ [exI,conjI]) 1)); |
|
757 | 45 |
qed "bexI"; |
0 | 46 |
|
17456 | 47 |
qed_goal "bexCI" (the_context ()) |
3837 | 48 |
"[| EX x:A. ~P(x) ==> P(a); a:A |] ==> EX x:A. P(x)" |
0 | 49 |
(fn prems=> |
50 |
[ (rtac classical 1), |
|
51 |
(REPEAT (ares_tac (prems@[bexI,ballI,notI,notE]) 1)) ]); |
|
52 |
||
17456 | 53 |
val major::prems = goalw (the_context ()) [Bex_def] |
0 | 54 |
"[| EX x:A. P(x); !!x. [| x:A; P(x) |] ==> Q |] ==> Q"; |
55 |
by (rtac (major RS exE) 1); |
|
56 |
by (REPEAT (eresolve_tac (prems @ [asm_rl,conjE]) 1)); |
|
757 | 57 |
qed "bexE"; |
0 | 58 |
|
59 |
(*Trival rewrite rule; (! x:A.P)=P holds only if A is nonempty!*) |
|
17456 | 60 |
val prems = goal (the_context ()) |
0 | 61 |
"(ALL x:A. True) <-> True"; |
62 |
by (REPEAT (ares_tac [TrueI,ballI,iffI] 1)); |
|
757 | 63 |
qed "ball_rew"; |
0 | 64 |
|
65 |
(** Congruence rules **) |
|
66 |
||
17456 | 67 |
val prems = goal (the_context ()) |
0 | 68 |
"[| A=A'; !!x. x:A' ==> P(x) <-> P'(x) |] ==> \ |
69 |
\ (ALL x:A. P(x)) <-> (ALL x:A'. P'(x))"; |
|
70 |
by (resolve_tac (prems RL [ssubst,iffD2]) 1); |
|
71 |
by (REPEAT (ares_tac [ballI,iffI] 1 |
|
72 |
ORELSE eresolve_tac ([make_elim bspec, mp] @ (prems RL [iffE])) 1)); |
|
757 | 73 |
qed "ball_cong"; |
0 | 74 |
|
17456 | 75 |
val prems = goal (the_context ()) |
0 | 76 |
"[| A=A'; !!x. x:A' ==> P(x) <-> P'(x) |] ==> \ |
77 |
\ (EX x:A. P(x)) <-> (EX x:A'. P'(x))"; |
|
78 |
by (resolve_tac (prems RL [ssubst,iffD2]) 1); |
|
79 |
by (REPEAT (etac bexE 1 |
|
80 |
ORELSE ares_tac ([bexI,iffI] @ (prems RL [iffD1,iffD2])) 1)); |
|
757 | 81 |
qed "bex_cong"; |
0 | 82 |
|
83 |
(*** Rules for subsets ***) |
|
84 |
||
17456 | 85 |
val prems = goalw (the_context ()) [subset_def] "(!!x. x:A ==> x:B) ==> A <= B"; |
0 | 86 |
by (REPEAT (ares_tac (prems @ [ballI]) 1)); |
757 | 87 |
qed "subsetI"; |
0 | 88 |
|
89 |
(*Rule in Modus Ponens style*) |
|
17456 | 90 |
val major::prems = goalw (the_context ()) [subset_def] "[| A <= B; c:A |] ==> c:B"; |
0 | 91 |
by (rtac (major RS bspec) 1); |
92 |
by (resolve_tac prems 1); |
|
757 | 93 |
qed "subsetD"; |
0 | 94 |
|
95 |
(*Classical elimination rule*) |
|
17456 | 96 |
val major::prems = goalw (the_context ()) [subset_def] |
0 | 97 |
"[| A <= B; ~(c:A) ==> P; c:B ==> P |] ==> P"; |
98 |
by (rtac (major RS ballE) 1); |
|
99 |
by (REPEAT (eresolve_tac prems 1)); |
|
757 | 100 |
qed "subsetCE"; |
0 | 101 |
|
102 |
(*Takes assumptions A<=B; c:A and creates the assumption c:B *) |
|
103 |
fun set_mp_tac i = etac subsetCE i THEN mp_tac i; |
|
104 |
||
17456 | 105 |
qed_goal "subset_refl" (the_context ()) "A <= A" |
0 | 106 |
(fn _=> [ (REPEAT (ares_tac [subsetI] 1)) ]); |
107 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5062
diff
changeset
|
108 |
Goal "[| A<=B; B<=C |] ==> A<=C"; |
642
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
8
diff
changeset
|
109 |
by (rtac subsetI 1); |
0 | 110 |
by (REPEAT (eresolve_tac [asm_rl, subsetD] 1)); |
757 | 111 |
qed "subset_trans"; |
0 | 112 |
|
113 |
||
114 |
(*** Rules for equality ***) |
|
115 |
||
116 |
(*Anti-symmetry of the subset relation*) |
|
17456 | 117 |
val prems = goal (the_context ()) "[| A <= B; B <= A |] ==> A = B"; |
0 | 118 |
by (rtac (iffI RS set_ext) 1); |
119 |
by (REPEAT (ares_tac (prems RL [subsetD]) 1)); |
|
757 | 120 |
qed "subset_antisym"; |
0 | 121 |
val equalityI = subset_antisym; |
122 |
||
123 |
(* Equality rules from ZF set theory -- are they appropriate here? *) |
|
17456 | 124 |
val prems = goal (the_context ()) "A = B ==> A<=B"; |
0 | 125 |
by (resolve_tac (prems RL [subst]) 1); |
126 |
by (rtac subset_refl 1); |
|
757 | 127 |
qed "equalityD1"; |
0 | 128 |
|
17456 | 129 |
val prems = goal (the_context ()) "A = B ==> B<=A"; |
0 | 130 |
by (resolve_tac (prems RL [subst]) 1); |
131 |
by (rtac subset_refl 1); |
|
757 | 132 |
qed "equalityD2"; |
0 | 133 |
|
17456 | 134 |
val prems = goal (the_context ()) |
0 | 135 |
"[| A = B; [| A<=B; B<=A |] ==> P |] ==> P"; |
136 |
by (resolve_tac prems 1); |
|
137 |
by (REPEAT (resolve_tac (prems RL [equalityD1,equalityD2]) 1)); |
|
757 | 138 |
qed "equalityE"; |
0 | 139 |
|
17456 | 140 |
val major::prems = goal (the_context ()) |
0 | 141 |
"[| A = B; [| c:A; c:B |] ==> P; [| ~ c:A; ~ c:B |] ==> P |] ==> P"; |
142 |
by (rtac (major RS equalityE) 1); |
|
143 |
by (REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1)); |
|
757 | 144 |
qed "equalityCE"; |
0 | 145 |
|
5062 | 146 |
Goal "{x. x:A} = A"; |
642
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
8
diff
changeset
|
147 |
by (REPEAT (ares_tac [equalityI,subsetI,CollectI] 1 ORELSE etac CollectD 1)); |
757 | 148 |
qed "trivial_set"; |
0 | 149 |
|
150 |
(*** Rules for binary union -- Un ***) |
|
151 |
||
17456 | 152 |
val prems = goalw (the_context ()) [Un_def] "c:A ==> c : A Un B"; |
0 | 153 |
by (REPEAT (resolve_tac (prems @ [CollectI,disjI1]) 1)); |
757 | 154 |
qed "UnI1"; |
0 | 155 |
|
17456 | 156 |
val prems = goalw (the_context ()) [Un_def] "c:B ==> c : A Un B"; |
0 | 157 |
by (REPEAT (resolve_tac (prems @ [CollectI,disjI2]) 1)); |
757 | 158 |
qed "UnI2"; |
0 | 159 |
|
160 |
(*Classical introduction rule: no commitment to A vs B*) |
|
17456 | 161 |
qed_goal "UnCI" (the_context ()) "(~c:B ==> c:A) ==> c : A Un B" |
0 | 162 |
(fn prems=> |
163 |
[ (rtac classical 1), |
|
164 |
(REPEAT (ares_tac (prems@[UnI1,notI]) 1)), |
|
165 |
(REPEAT (ares_tac (prems@[UnI2,notE]) 1)) ]); |
|
166 |
||
17456 | 167 |
val major::prems = goalw (the_context ()) [Un_def] |
0 | 168 |
"[| c : A Un B; c:A ==> P; c:B ==> P |] ==> P"; |
169 |
by (rtac (major RS CollectD RS disjE) 1); |
|
170 |
by (REPEAT (eresolve_tac prems 1)); |
|
757 | 171 |
qed "UnE"; |
0 | 172 |
|
173 |
||
174 |
(*** Rules for small intersection -- Int ***) |
|
175 |
||
17456 | 176 |
val prems = goalw (the_context ()) [Int_def] |
0 | 177 |
"[| c:A; c:B |] ==> c : A Int B"; |
178 |
by (REPEAT (resolve_tac (prems @ [CollectI,conjI]) 1)); |
|
757 | 179 |
qed "IntI"; |
0 | 180 |
|
17456 | 181 |
val [major] = goalw (the_context ()) [Int_def] "c : A Int B ==> c:A"; |
0 | 182 |
by (rtac (major RS CollectD RS conjunct1) 1); |
757 | 183 |
qed "IntD1"; |
0 | 184 |
|
17456 | 185 |
val [major] = goalw (the_context ()) [Int_def] "c : A Int B ==> c:B"; |
0 | 186 |
by (rtac (major RS CollectD RS conjunct2) 1); |
757 | 187 |
qed "IntD2"; |
0 | 188 |
|
17456 | 189 |
val [major,minor] = goal (the_context ()) |
0 | 190 |
"[| c : A Int B; [| c:A; c:B |] ==> P |] ==> P"; |
191 |
by (rtac minor 1); |
|
192 |
by (rtac (major RS IntD1) 1); |
|
193 |
by (rtac (major RS IntD2) 1); |
|
757 | 194 |
qed "IntE"; |
0 | 195 |
|
196 |
||
197 |
(*** Rules for set complement -- Compl ***) |
|
198 |
||
17456 | 199 |
val prems = goalw (the_context ()) [Compl_def] |
0 | 200 |
"[| c:A ==> False |] ==> c : Compl(A)"; |
201 |
by (REPEAT (ares_tac (prems @ [CollectI,notI]) 1)); |
|
757 | 202 |
qed "ComplI"; |
0 | 203 |
|
204 |
(*This form, with negated conclusion, works well with the Classical prover. |
|
205 |
Negated assumptions behave like formulae on the right side of the notional |
|
206 |
turnstile...*) |
|
17456 | 207 |
val major::prems = goalw (the_context ()) [Compl_def] |
0 | 208 |
"[| c : Compl(A) |] ==> ~c:A"; |
209 |
by (rtac (major RS CollectD) 1); |
|
757 | 210 |
qed "ComplD"; |
0 | 211 |
|
212 |
val ComplE = make_elim ComplD; |
|
213 |
||
214 |
||
215 |
(*** Empty sets ***) |
|
216 |
||
5062 | 217 |
Goalw [empty_def] "{x. False} = {}"; |
642
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
8
diff
changeset
|
218 |
by (rtac refl 1); |
757 | 219 |
qed "empty_eq"; |
0 | 220 |
|
17456 | 221 |
val [prem] = goalw (the_context ()) [empty_def] "a : {} ==> P"; |
0 | 222 |
by (rtac (prem RS CollectD RS FalseE) 1); |
757 | 223 |
qed "emptyD"; |
0 | 224 |
|
225 |
val emptyE = make_elim emptyD; |
|
226 |
||
17456 | 227 |
val [prem] = goal (the_context ()) "~ A={} ==> (EX x. x:A)"; |
18371 | 228 |
by (rtac (prem RS Cla.swap) 1); |
642
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents:
8
diff
changeset
|
229 |
by (rtac equalityI 1); |
0 | 230 |
by (ALLGOALS (fast_tac (FOL_cs addSIs [subsetI] addSEs [emptyD]))); |
757 | 231 |
qed "not_emptyD"; |
0 | 232 |
|
233 |
(*** Singleton sets ***) |
|
234 |
||
5062 | 235 |
Goalw [singleton_def] "a : {a}"; |
0 | 236 |
by (rtac CollectI 1); |
237 |
by (rtac refl 1); |
|
757 | 238 |
qed "singletonI"; |
0 | 239 |
|
17456 | 240 |
val [major] = goalw (the_context ()) [singleton_def] "b : {a} ==> b=a"; |
0 | 241 |
by (rtac (major RS CollectD) 1); |
757 | 242 |
qed "singletonD"; |
0 | 243 |
|
244 |
val singletonE = make_elim singletonD; |
|
245 |
||
246 |
(*** Unions of families ***) |
|
247 |
||
248 |
(*The order of the premises presupposes that A is rigid; b may be flexible*) |
|
17456 | 249 |
val prems = goalw (the_context ()) [UNION_def] |
0 | 250 |
"[| a:A; b: B(a) |] ==> b: (UN x:A. B(x))"; |
251 |
by (REPEAT (resolve_tac (prems @ [bexI,CollectI]) 1)); |
|
757 | 252 |
qed "UN_I"; |
0 | 253 |
|
17456 | 254 |
val major::prems = goalw (the_context ()) [UNION_def] |
0 | 255 |
"[| b : (UN x:A. B(x)); !!x.[| x:A; b: B(x) |] ==> R |] ==> R"; |
256 |
by (rtac (major RS CollectD RS bexE) 1); |
|
257 |
by (REPEAT (ares_tac prems 1)); |
|
757 | 258 |
qed "UN_E"; |
0 | 259 |
|
17456 | 260 |
val prems = goal (the_context ()) |
0 | 261 |
"[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> \ |
262 |
\ (UN x:A. C(x)) = (UN x:B. D(x))"; |
|
263 |
by (REPEAT (etac UN_E 1 |
|
17456 | 264 |
ORELSE ares_tac ([UN_I,equalityI,subsetI] @ |
1459 | 265 |
(prems RL [equalityD1,equalityD2] RL [subsetD])) 1)); |
757 | 266 |
qed "UN_cong"; |
0 | 267 |
|
268 |
(*** Intersections of families -- INTER x:A. B(x) is Inter(B)``A ) *) |
|
269 |
||
17456 | 270 |
val prems = goalw (the_context ()) [INTER_def] |
0 | 271 |
"(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))"; |
272 |
by (REPEAT (ares_tac ([CollectI,ballI] @ prems) 1)); |
|
757 | 273 |
qed "INT_I"; |
0 | 274 |
|
17456 | 275 |
val major::prems = goalw (the_context ()) [INTER_def] |
0 | 276 |
"[| b : (INT x:A. B(x)); a:A |] ==> b: B(a)"; |
277 |
by (rtac (major RS CollectD RS bspec) 1); |
|
278 |
by (resolve_tac prems 1); |
|
757 | 279 |
qed "INT_D"; |
0 | 280 |
|
281 |
(*"Classical" elimination rule -- does not require proving X:C *) |
|
17456 | 282 |
val major::prems = goalw (the_context ()) [INTER_def] |
0 | 283 |
"[| b : (INT x:A. B(x)); b: B(a) ==> R; ~ a:A ==> R |] ==> R"; |
284 |
by (rtac (major RS CollectD RS ballE) 1); |
|
285 |
by (REPEAT (eresolve_tac prems 1)); |
|
757 | 286 |
qed "INT_E"; |
0 | 287 |
|
17456 | 288 |
val prems = goal (the_context ()) |
0 | 289 |
"[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> \ |
290 |
\ (INT x:A. C(x)) = (INT x:B. D(x))"; |
|
291 |
by (REPEAT_FIRST (resolve_tac [INT_I,equalityI,subsetI])); |
|
292 |
by (REPEAT (dtac INT_D 1 |
|
293 |
ORELSE ares_tac (prems RL [equalityD1,equalityD2] RL [subsetD]) 1)); |
|
757 | 294 |
qed "INT_cong"; |
0 | 295 |
|
296 |
(*** Rules for Unions ***) |
|
297 |
||
298 |
(*The order of the premises presupposes that C is rigid; A may be flexible*) |
|
17456 | 299 |
val prems = goalw (the_context ()) [Union_def] |
0 | 300 |
"[| X:C; A:X |] ==> A : Union(C)"; |
301 |
by (REPEAT (resolve_tac (prems @ [UN_I]) 1)); |
|
757 | 302 |
qed "UnionI"; |
0 | 303 |
|
17456 | 304 |
val major::prems = goalw (the_context ()) [Union_def] |
0 | 305 |
"[| A : Union(C); !!X.[| A:X; X:C |] ==> R |] ==> R"; |
306 |
by (rtac (major RS UN_E) 1); |
|
307 |
by (REPEAT (ares_tac prems 1)); |
|
757 | 308 |
qed "UnionE"; |
0 | 309 |
|
310 |
(*** Rules for Inter ***) |
|
311 |
||
17456 | 312 |
val prems = goalw (the_context ()) [Inter_def] |
0 | 313 |
"[| !!X. X:C ==> A:X |] ==> A : Inter(C)"; |
314 |
by (REPEAT (ares_tac ([INT_I] @ prems) 1)); |
|
757 | 315 |
qed "InterI"; |
0 | 316 |
|
317 |
(*A "destruct" rule -- every X in C contains A as an element, but |
|
318 |
A:X can hold when X:C does not! This rule is analogous to "spec". *) |
|
17456 | 319 |
val major::prems = goalw (the_context ()) [Inter_def] |
0 | 320 |
"[| A : Inter(C); X:C |] ==> A:X"; |
321 |
by (rtac (major RS INT_D) 1); |
|
322 |
by (resolve_tac prems 1); |
|
757 | 323 |
qed "InterD"; |
0 | 324 |
|
325 |
(*"Classical" elimination rule -- does not require proving X:C *) |
|
17456 | 326 |
val major::prems = goalw (the_context ()) [Inter_def] |
0 | 327 |
"[| A : Inter(C); A:X ==> R; ~ X:C ==> R |] ==> R"; |
328 |
by (rtac (major RS INT_E) 1); |
|
329 |
by (REPEAT (eresolve_tac prems 1)); |
|
757 | 330 |
qed "InterE"; |