author  oheimb 
Fri, 31 May 1996 19:12:00 +0200  
changeset 1776  d7e77cb8ce5c 
parent 1762  6e481897a811 
child 1816  b03dba9116d4 
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 
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

323 
by (fast_tac (!claset addSEs [emptyE,CollectE,UnE]) 1); 
923  324 
qed "singletonD"; 
325 

1776
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

326 
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

327 

d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

328 
qed_goal "singleton_iff" thy "(b : {a}) = (b=a)" (fn _ => [ 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

329 
rtac iffI 1, 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

330 
etac singletonD 1, 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

331 
hyp_subst_tac 1, 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

332 
rtac singletonI 1]); 
923  333 

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

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

336 
by (rtac singletonI 1); 

337 
qed "singleton_inject"; 

338 

1531  339 

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

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

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

344 

345 

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

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

349 
val prems = goalw Set.thy [UNION_def] 

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

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

352 
qed "UN_I"; 

353 

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

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

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

357 
by (REPEAT (ares_tac prems 1)); 

358 
qed "UN_E"; 

359 

360 
val prems = goal Set.thy 

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

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

363 
by (REPEAT (etac UN_E 1 

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

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

368 

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

371 
val prems = goalw Set.thy [INTER_def] 

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

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

374 
qed "INT_I"; 

375 

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

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

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

379 
by (resolve_tac prems 1); 

380 
qed "INT_D"; 

381 

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

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

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

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

386 
by (REPEAT (eresolve_tac prems 1)); 

387 
qed "INT_E"; 

388 

389 
val prems = goal Set.thy 

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

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

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

393 
by (REPEAT (dtac INT_D 1 

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

395 
qed "INT_cong"; 

396 

397 

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

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

401 
val prems = goalw Set.thy [UNION1_def] 

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

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

404 
qed "UN1_I"; 

405 

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

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

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

409 
by (REPEAT (ares_tac prems 1)); 

410 
qed "UN1_E"; 

411 

412 

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

415 
val prems = goalw Set.thy [INTER1_def] 

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

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

418 
qed "INT1_I"; 

419 

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

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

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

423 
qed "INT1_D"; 

424 

1548  425 
section "Union"; 
923  426 

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

428 
val prems = goalw Set.thy [Union_def] 

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

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

431 
qed "UnionI"; 

432 

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

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

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

436 
by (REPEAT (ares_tac prems 1)); 

437 
qed "UnionE"; 

438 

1548  439 
section "Inter"; 
923  440 

441 
val prems = goalw Set.thy [Inter_def] 

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

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

444 
qed "InterI"; 

445 

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

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

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

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

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

451 
by (resolve_tac prems 1); 

452 
qed "InterD"; 

453 

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

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

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

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

458 
by (REPEAT (eresolve_tac prems 1)); 

459 
qed "InterE"; 

460 

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

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

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

465 

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

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

468 

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

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

1776
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

471 

d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

472 

d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

473 

d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

474 
(*** Set reasoning tools ***) 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

475 

d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

476 

d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

477 
val mem_simps = [ Un_iff, Int_iff, Compl_iff, Diff_iff, singleton_iff, 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

478 
mem_Collect_eq]; 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

479 

d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

480 
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

481 

d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

482 
simpset := !simpset addsimps mem_simps 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

483 
addcongs [ball_cong,bex_cong] 
d7e77cb8ce5c
moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents:
1762
diff
changeset

484 
setmksimps (mksimps mksimps_pairs); 