author  berghofe 
Thu, 23 May 1996 15:16:12 +0200  
changeset 1762  6e481897a811 
parent 1760  6f41a494f3b1 
child 1776  d7e77cb8ce5c 
permissions  rwrr 
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 higherorder 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 
(*Antisymmetry 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 

1762  140 
AddSIs [equalityI]; 
141 

923  142 
(* Equality rules from ZF set theory  are they appropriate here? *) 
143 
val prems = goal Set.thy "A = B ==> A<=(B::'a set)"; 

144 
by (resolve_tac (prems RL [subst]) 1); 

145 
by (rtac subset_refl 1); 

146 
qed "equalityD1"; 

147 

148 
val prems = goal Set.thy "A = B ==> B<=(A::'a set)"; 

149 
by (resolve_tac (prems RL [subst]) 1); 

150 
by (rtac subset_refl 1); 

151 
qed "equalityD2"; 

152 

153 
val prems = goal Set.thy 

154 
"[ A = B; [ A<=B; B<=(A::'a set) ] ==> P ] ==> P"; 

155 
by (resolve_tac prems 1); 

156 
by (REPEAT (resolve_tac (prems RL [equalityD1,equalityD2]) 1)); 

157 
qed "equalityE"; 

158 

159 
val major::prems = goal Set.thy 

160 
"[ A = B; [ c:A; c:B ] ==> P; [ c~:A; c~:B ] ==> P ] ==> P"; 

161 
by (rtac (major RS equalityE) 1); 

162 
by (REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1)); 

163 
qed "equalityCE"; 

164 

165 
(*Lemma for creating induction formulae  for "pattern matching" on p 

166 
To make the induction hypotheses usable, apply "spec" or "bspec" to 

167 
put universal quantifiers over the free variables in p. *) 

168 
val prems = goal Set.thy 

169 
"[ p:A; !!z. z:A ==> p=z > R ] ==> R"; 

170 
by (rtac mp 1); 

171 
by (REPEAT (resolve_tac (refl::prems) 1)); 

172 
qed "setup_induction"; 

173 

174 

1548  175 
section "Set complement  Compl"; 
923  176 

177 
val prems = goalw Set.thy [Compl_def] 

178 
"[ c:A ==> False ] ==> c : Compl(A)"; 

179 
by (REPEAT (ares_tac (prems @ [CollectI,notI]) 1)); 

180 
qed "ComplI"; 

181 

182 
(*This form, with negated conclusion, works well with the Classical prover. 

183 
Negated assumptions behave like formulae on the right side of the notional 

184 
turnstile...*) 

185 
val major::prems = goalw Set.thy [Compl_def] 

186 
"[ c : Compl(A) ] ==> c~:A"; 

187 
by (rtac (major RS CollectD) 1); 

188 
qed "ComplD"; 

189 

190 
val ComplE = make_elim ComplD; 

191 

1640  192 
qed_goal "Compl_iff" Set.thy "(c : Compl(A)) = (c~:A)" 
1760
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1640
diff
changeset

193 
(fn _ => [ (fast_tac (!claset addSIs [ComplI] addSEs [ComplE]) 1) ]); 
1640  194 

923  195 

1548  196 
section "Binary union  Un"; 
923  197 

198 
val prems = goalw Set.thy [Un_def] "c:A ==> c : A Un B"; 

199 
by (REPEAT (resolve_tac (prems @ [CollectI,disjI1]) 1)); 

200 
qed "UnI1"; 

201 

202 
val prems = goalw Set.thy [Un_def] "c:B ==> c : A Un B"; 

203 
by (REPEAT (resolve_tac (prems @ [CollectI,disjI2]) 1)); 

204 
qed "UnI2"; 

205 

206 
(*Classical introduction rule: no commitment to A vs B*) 

207 
qed_goal "UnCI" Set.thy "(c~:B ==> c:A) ==> c : A Un B" 

208 
(fn prems=> 

209 
[ (rtac classical 1), 

210 
(REPEAT (ares_tac (prems@[UnI1,notI]) 1)), 

211 
(REPEAT (ares_tac (prems@[UnI2,notE]) 1)) ]); 

212 

213 
val major::prems = goalw Set.thy [Un_def] 

214 
"[ c : A Un B; c:A ==> P; c:B ==> P ] ==> P"; 

215 
by (rtac (major RS CollectD RS disjE) 1); 

216 
by (REPEAT (eresolve_tac prems 1)); 

217 
qed "UnE"; 

218 

1640  219 
qed_goal "Un_iff" Set.thy "(c : A Un B) = (c:A  c:B)" 
1760
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1640
diff
changeset

220 
(fn _ => [ (fast_tac (!claset addSIs [UnCI] addSEs [UnE]) 1) ]); 
1640  221 

923  222 

1548  223 
section "Binary intersection  Int"; 
923  224 

225 
val prems = goalw Set.thy [Int_def] 

226 
"[ c:A; c:B ] ==> c : A Int B"; 

227 
by (REPEAT (resolve_tac (prems @ [CollectI,conjI]) 1)); 

228 
qed "IntI"; 

229 

230 
val [major] = goalw Set.thy [Int_def] "c : A Int B ==> c:A"; 

231 
by (rtac (major RS CollectD RS conjunct1) 1); 

232 
qed "IntD1"; 

233 

234 
val [major] = goalw Set.thy [Int_def] "c : A Int B ==> c:B"; 

235 
by (rtac (major RS CollectD RS conjunct2) 1); 

236 
qed "IntD2"; 

237 

238 
val [major,minor] = goal Set.thy 

239 
"[ c : A Int B; [ c:A; c:B ] ==> P ] ==> P"; 

240 
by (rtac minor 1); 

241 
by (rtac (major RS IntD1) 1); 

242 
by (rtac (major RS IntD2) 1); 

243 
qed "IntE"; 

244 

1640  245 
qed_goal "Int_iff" Set.thy "(c : A Int B) = (c:A & c:B)" 
1760
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1640
diff
changeset

246 
(fn _ => [ (fast_tac (!claset addSIs [IntI] addSEs [IntE]) 1) ]); 
1640  247 

923  248 

1548  249 
section "Set difference"; 
923  250 

251 
qed_goalw "DiffI" Set.thy [set_diff_def] 

252 
"[ c : A; c ~: B ] ==> c : A  B" 

253 
(fn prems=> [ (REPEAT (resolve_tac (prems @ [CollectI,conjI]) 1)) ]); 

254 

255 
qed_goalw "DiffD1" Set.thy [set_diff_def] 

256 
"c : A  B ==> c : A" 

257 
(fn [major]=> [ (rtac (major RS CollectD RS conjunct1) 1) ]); 

258 

259 
qed_goalw "DiffD2" Set.thy [set_diff_def] 

260 
"[ c : A  B; c : B ] ==> P" 

261 
(fn [major,minor]=> 

262 
[rtac (minor RS (major RS CollectD RS conjunct2 RS notE)) 1]); 

263 

264 
qed_goal "DiffE" Set.thy 

265 
"[ c : A  B; [ c:A; c~:B ] ==> P ] ==> P" 

266 
(fn prems=> 

267 
[ (resolve_tac prems 1), 

268 
(REPEAT (ares_tac (prems RL [DiffD1, DiffD2 RS notI]) 1)) ]); 

269 

270 
qed_goal "Diff_iff" Set.thy "(c : AB) = (c:A & c~:B)" 

1760
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1640
diff
changeset

271 
(fn _ => [ (fast_tac (!claset addSIs [DiffI] addSEs [DiffE]) 1) ]); 
923  272 

1548  273 
section "The empty set  {}"; 
923  274 

275 
qed_goalw "emptyE" Set.thy [empty_def] "a:{} ==> P" 

276 
(fn [prem] => [rtac (prem RS CollectD RS FalseE) 1]); 

277 

278 
qed_goal "empty_subsetI" Set.thy "{} <= A" 

279 
(fn _ => [ (REPEAT (ares_tac [equalityI,subsetI,emptyE] 1)) ]); 

280 

281 
qed_goal "equals0I" Set.thy "[ !!y. y:A ==> False ] ==> A={}" 

282 
(fn prems=> 

283 
[ (REPEAT (ares_tac (prems@[empty_subsetI,subsetI,equalityI]) 1 

284 
ORELSE eresolve_tac (prems RL [FalseE]) 1)) ]); 

285 

286 
qed_goal "equals0D" Set.thy "[ A={}; a:A ] ==> P" 

287 
(fn [major,minor]=> 

288 
[ (rtac (minor RS (major RS equalityD1 RS subsetD RS emptyE)) 1) ]); 

289 

1640  290 
qed_goal "empty_iff" Set.thy "(c : {}) = False" 
1760
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1640
diff
changeset

291 
(fn _ => [ (fast_tac (!claset addSEs [emptyE]) 1) ]); 
1640  292 

923  293 

1548  294 
section "Augmenting a set  insert"; 
923  295 

296 
qed_goalw "insertI1" Set.thy [insert_def] "a : insert a B" 

297 
(fn _ => [rtac (CollectI RS UnI1) 1, rtac refl 1]); 

298 

299 
qed_goalw "insertI2" Set.thy [insert_def] "a : B ==> a : insert b B" 

300 
(fn [prem]=> [ (rtac (prem RS UnI2) 1) ]); 

301 

302 
qed_goalw "insertE" Set.thy [insert_def] 

303 
"[ a : insert b A; a=b ==> P; a:A ==> P ] ==> P" 

304 
(fn major::prems=> 

305 
[ (rtac (major RS UnE) 1), 

306 
(REPEAT (eresolve_tac (prems @ [CollectE]) 1)) ]); 

307 

308 
qed_goal "insert_iff" Set.thy "a : insert b A = (a=b  a:A)" 

1760
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1640
diff
changeset

309 
(fn _ => [fast_tac (!claset addIs [insertI1,insertI2] addSEs [insertE]) 1]); 
923  310 

311 
(*Classical introduction rule*) 

312 
qed_goal "insertCI" Set.thy "(a~:B ==> a=b) ==> a: insert b B" 

313 
(fn [prem]=> 

314 
[ (rtac (disjCI RS (insert_iff RS iffD2)) 1), 

315 
(etac prem 1) ]); 

316 

1548  317 
section "Singletons, using insert"; 
923  318 

319 
qed_goal "singletonI" Set.thy "a : {a}" 

320 
(fn _=> [ (rtac insertI1 1) ]); 

321 

322 
qed_goal "singletonE" Set.thy "[ a: {b}; a=b ==> P ] ==> P" 

323 
(fn major::prems=> 

324 
[ (rtac (major RS insertE) 1), 

325 
(REPEAT (eresolve_tac (prems @ [emptyE]) 1)) ]); 

326 

327 
goalw Set.thy [insert_def] "!!a. b : {a} ==> b=a"; 

1760
6f41a494f3b1
Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents:
1640
diff
changeset

328 
by (fast_tac (!claset addSEs [emptyE,CollectE,UnE]) 1); 
923  329 
qed "singletonD"; 
330 

331 
val singletonE = make_elim singletonD; 

332 

333 
val [major] = goal Set.thy "{a}={b} ==> a=b"; 

334 
by (rtac (major RS equalityD1 RS subsetD RS singletonD) 1); 

335 
by (rtac singletonI 1); 

336 
qed "singleton_inject"; 

337 

1531  338 

1548  339 
section "The universal set  UNIV"; 
1531  340 

341 
qed_goal "subset_UNIV" Set.thy "A <= UNIV" 

342 
(fn _ => [rtac subsetI 1, rtac ComplI 1, etac emptyE 1]); 

343 

344 

1548  345 
section "Unions of families  UNION x:A. B(x) is Union(B``A)"; 
923  346 

347 
(*The order of the premises presupposes that A is rigid; b may be flexible*) 

348 
val prems = goalw Set.thy [UNION_def] 

349 
"[ a:A; b: B(a) ] ==> b: (UN x:A. B(x))"; 

350 
by (REPEAT (resolve_tac (prems @ [bexI,CollectI]) 1)); 

351 
qed "UN_I"; 

352 

353 
val major::prems = goalw Set.thy [UNION_def] 

354 
"[ b : (UN x:A. B(x)); !!x.[ x:A; b: B(x) ] ==> R ] ==> R"; 

355 
by (rtac (major RS CollectD RS bexE) 1); 

356 
by (REPEAT (ares_tac prems 1)); 

357 
qed "UN_E"; 

358 

359 
val prems = goal Set.thy 

360 
"[ A=B; !!x. x:B ==> C(x) = D(x) ] ==> \ 

361 
\ (UN x:A. C(x)) = (UN x:B. D(x))"; 

362 
by (REPEAT (etac UN_E 1 

363 
ORELSE ares_tac ([UN_I,equalityI,subsetI] @ 

1465  364 
(prems RL [equalityD1,equalityD2] RL [subsetD])) 1)); 
923  365 
qed "UN_cong"; 
366 

367 

1548  368 
section "Intersections of families  INTER x:A. B(x) is Inter(B``A)"; 
923  369 

370 
val prems = goalw Set.thy [INTER_def] 

371 
"(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))"; 

372 
by (REPEAT (ares_tac ([CollectI,ballI] @ prems) 1)); 

373 
qed "INT_I"; 

374 

375 
val major::prems = goalw Set.thy [INTER_def] 

376 
"[ b : (INT x:A. B(x)); a:A ] ==> b: B(a)"; 

377 
by (rtac (major RS CollectD RS bspec) 1); 

378 
by (resolve_tac prems 1); 

379 
qed "INT_D"; 

380 

381 
(*"Classical" elimination  by the Excluded Middle on a:A *) 

382 
val major::prems = goalw Set.thy [INTER_def] 

383 
"[ b : (INT x:A. B(x)); b: B(a) ==> R; a~:A ==> R ] ==> R"; 

384 
by (rtac (major RS CollectD RS ballE) 1); 

385 
by (REPEAT (eresolve_tac prems 1)); 

386 
qed "INT_E"; 

387 

388 
val prems = goal Set.thy 

389 
"[ A=B; !!x. x:B ==> C(x) = D(x) ] ==> \ 

390 
\ (INT x:A. C(x)) = (INT x:B. D(x))"; 

391 
by (REPEAT_FIRST (resolve_tac [INT_I,equalityI,subsetI])); 

392 
by (REPEAT (dtac INT_D 1 

393 
ORELSE ares_tac (prems RL [equalityD1,equalityD2] RL [subsetD]) 1)); 

394 
qed "INT_cong"; 

395 

396 

1548  397 
section "Unions over a type; UNION1(B) = Union(range(B))"; 
923  398 

399 
(*The order of the premises presupposes that A is rigid; b may be flexible*) 

400 
val prems = goalw Set.thy [UNION1_def] 

401 
"b: B(x) ==> b: (UN x. B(x))"; 

402 
by (REPEAT (resolve_tac (prems @ [TrueI, CollectI RS UN_I]) 1)); 

403 
qed "UN1_I"; 

404 

405 
val major::prems = goalw Set.thy [UNION1_def] 

406 
"[ b : (UN x. B(x)); !!x. b: B(x) ==> R ] ==> R"; 

407 
by (rtac (major RS UN_E) 1); 

408 
by (REPEAT (ares_tac prems 1)); 

409 
qed "UN1_E"; 

410 

411 

1548  412 
section "Intersections over a type; INTER1(B) = Inter(range(B))"; 
923  413 

414 
val prems = goalw Set.thy [INTER1_def] 

415 
"(!!x. b: B(x)) ==> b : (INT x. B(x))"; 

416 
by (REPEAT (ares_tac (INT_I::prems) 1)); 

417 
qed "INT1_I"; 

418 

419 
val [major] = goalw Set.thy [INTER1_def] 

420 
"b : (INT x. B(x)) ==> b: B(a)"; 

421 
by (rtac (TrueI RS (CollectI RS (major RS INT_D))) 1); 

422 
qed "INT1_D"; 

423 

1548  424 
section "Union"; 
923  425 

426 
(*The order of the premises presupposes that C is rigid; A may be flexible*) 

427 
val prems = goalw Set.thy [Union_def] 

428 
"[ X:C; A:X ] ==> A : Union(C)"; 

429 
by (REPEAT (resolve_tac (prems @ [UN_I]) 1)); 

430 
qed "UnionI"; 

431 

432 
val major::prems = goalw Set.thy [Union_def] 

433 
"[ A : Union(C); !!X.[ A:X; X:C ] ==> R ] ==> R"; 

434 
by (rtac (major RS UN_E) 1); 

435 
by (REPEAT (ares_tac prems 1)); 

436 
qed "UnionE"; 

437 

1548  438 
section "Inter"; 
923  439 

440 
val prems = goalw Set.thy [Inter_def] 

441 
"[ !!X. X:C ==> A:X ] ==> A : Inter(C)"; 

442 
by (REPEAT (ares_tac ([INT_I] @ prems) 1)); 

443 
qed "InterI"; 

444 

445 
(*A "destruct" rule  every X in C contains A as an element, but 

446 
A:X can hold when X:C does not! This rule is analogous to "spec". *) 

447 
val major::prems = goalw Set.thy [Inter_def] 

448 
"[ A : Inter(C); X:C ] ==> A:X"; 

449 
by (rtac (major RS INT_D) 1); 

450 
by (resolve_tac prems 1); 

451 
qed "InterD"; 

452 

453 
(*"Classical" elimination rule  does not require proving X:C *) 

454 
val major::prems = goalw Set.thy [Inter_def] 

455 
"[ A : Inter(C); A:X ==> R; X~:C ==> R ] ==> R"; 

456 
by (rtac (major RS INT_E) 1); 

457 
by (REPEAT (eresolve_tac prems 1)); 

458 
qed "InterE"; 

459 

1548  460 
section "The Powerset operator  Pow"; 
923  461 

462 
qed_goalw "PowI" Set.thy [Pow_def] "!!A B. A <= B ==> A : Pow(B)" 

463 
(fn _ => [ (etac CollectI 1) ]); 

464 

465 
qed_goalw "PowD" Set.thy [Pow_def] "!!A B. A : Pow(B) ==> A<=B" 

466 
(fn _=> [ (etac CollectD 1) ]); 

467 

468 
val Pow_bottom = empty_subsetI RS PowI; (* {}: Pow(B) *) 

469 
val Pow_top = subset_refl RS PowI; (* A : Pow(A) *) 