src/HOL/Set.ML
changeset 2891 d8f254ad1ab9
parent 2881 62ecde1015ae
child 2912 3fac3e8d5d3e
equal deleted inserted replaced
2890:f27002fc531d 2891:d8f254ad1ab9
   149 
   149 
   150 AddSIs [subsetI];
   150 AddSIs [subsetI];
   151 AddEs  [subsetD, subsetCE];
   151 AddEs  [subsetD, subsetCE];
   152 
   152 
   153 qed_goal "subset_refl" Set.thy "A <= (A::'a set)"
   153 qed_goal "subset_refl" Set.thy "A <= (A::'a set)"
   154  (fn _=> [Fast_tac 1]);
   154  (fn _=> [Blast_tac 1]);
   155 
   155 
   156 val prems = goal Set.thy "!!B. [| A<=B;  B<=C |] ==> A<=(C::'a set)";
   156 val prems = goal Set.thy "!!B. [| A<=B;  B<=C |] ==> A<=(C::'a set)";
   157 by (Fast_tac 1);
   157 by (Blast_tac 1);
   158 qed "subset_trans";
   158 qed "subset_trans";
   159 
   159 
   160 
   160 
   161 section "Equality";
   161 section "Equality";
   162 
   162 
   204 
   204 
   205 
   205 
   206 section "The empty set -- {}";
   206 section "The empty set -- {}";
   207 
   207 
   208 qed_goalw "empty_iff" Set.thy [empty_def] "(c : {}) = False"
   208 qed_goalw "empty_iff" Set.thy [empty_def] "(c : {}) = False"
   209  (fn _ => [ (Fast_tac 1) ]);
   209  (fn _ => [ (Blast_tac 1) ]);
   210 
   210 
   211 Addsimps [empty_iff];
   211 Addsimps [empty_iff];
   212 
   212 
   213 qed_goal "emptyE" Set.thy "!!a. a:{} ==> P"
   213 qed_goal "emptyE" Set.thy "!!a. a:{} ==> P"
   214  (fn _ => [Full_simp_tac 1]);
   214  (fn _ => [Full_simp_tac 1]);
   215 
   215 
   216 AddSEs [emptyE];
   216 AddSEs [emptyE];
   217 
   217 
   218 qed_goal "empty_subsetI" Set.thy "{} <= A"
   218 qed_goal "empty_subsetI" Set.thy "{} <= A"
   219  (fn _ => [ (Fast_tac 1) ]);
   219  (fn _ => [ (Blast_tac 1) ]);
   220 
   220 
   221 qed_goal "equals0I" Set.thy "[| !!y. y:A ==> False |] ==> A={}"
   221 qed_goal "equals0I" Set.thy "[| !!y. y:A ==> False |] ==> A={}"
   222  (fn [prem]=>
   222  (fn [prem]=>
   223   [ (fast_tac (!claset addIs [prem RS FalseE]) 1) ]);
   223   [ (fast_tac (!claset addIs [prem RS FalseE]) 1) ]);
   224 
   224 
   225 qed_goal "equals0D" Set.thy "!!a. [| A={};  a:A |] ==> P"
   225 qed_goal "equals0D" Set.thy "!!a. [| A={};  a:A |] ==> P"
   226  (fn _ => [ (Fast_tac 1) ]);
   226  (fn _ => [ (Blast_tac 1) ]);
   227 
   227 
   228 goal Set.thy "Ball {} P = True";
   228 goal Set.thy "Ball {} P = True";
   229 by (simp_tac (HOL_ss addsimps [mem_Collect_eq, Ball_def, empty_def]) 1);
   229 by (simp_tac (HOL_ss addsimps [mem_Collect_eq, Ball_def, empty_def]) 1);
   230 qed "ball_empty";
   230 qed "ball_empty";
   231 
   231 
   233 by (simp_tac (HOL_ss addsimps [mem_Collect_eq, Bex_def, empty_def]) 1);
   233 by (simp_tac (HOL_ss addsimps [mem_Collect_eq, Bex_def, empty_def]) 1);
   234 qed "bex_empty";
   234 qed "bex_empty";
   235 Addsimps [ball_empty, bex_empty];
   235 Addsimps [ball_empty, bex_empty];
   236 
   236 
   237 goalw Set.thy [Ball_def] "(!x:A.False) = (A = {})";
   237 goalw Set.thy [Ball_def] "(!x:A.False) = (A = {})";
   238 by(Fast_tac 1);
   238 by(Blast_tac 1);
   239 qed "ball_False";
   239 qed "ball_False";
   240 Addsimps [ball_False];
   240 Addsimps [ball_False];
   241 
   241 
   242 (* The dual is probably not helpful:
   242 (* The dual is probably not helpful:
   243 goal Set.thy "(? x:A.True) = (A ~= {})";
   243 goal Set.thy "(? x:A.True) = (A ~= {})";
   244 by(Fast_tac 1);
   244 by(Blast_tac 1);
   245 qed "bex_True";
   245 qed "bex_True";
   246 Addsimps [bex_True];
   246 Addsimps [bex_True];
   247 *)
   247 *)
   248 
   248 
   249 
   249 
   265 
   265 
   266 
   266 
   267 section "Set complement -- Compl";
   267 section "Set complement -- Compl";
   268 
   268 
   269 qed_goalw "Compl_iff" Set.thy [Compl_def] "(c : Compl(A)) = (c~:A)"
   269 qed_goalw "Compl_iff" Set.thy [Compl_def] "(c : Compl(A)) = (c~:A)"
   270  (fn _ => [ (Fast_tac 1) ]);
   270  (fn _ => [ (Blast_tac 1) ]);
   271 
   271 
   272 Addsimps [Compl_iff];
   272 Addsimps [Compl_iff];
   273 
   273 
   274 val prems = goalw Set.thy [Compl_def]
   274 val prems = goalw Set.thy [Compl_def]
   275     "[| c:A ==> False |] ==> c : Compl(A)";
   275     "[| c:A ==> False |] ==> c : Compl(A)";
   291 
   291 
   292 
   292 
   293 section "Binary union -- Un";
   293 section "Binary union -- Un";
   294 
   294 
   295 qed_goalw "Un_iff" Set.thy [Un_def] "(c : A Un B) = (c:A | c:B)"
   295 qed_goalw "Un_iff" Set.thy [Un_def] "(c : A Un B) = (c:A | c:B)"
   296  (fn _ => [ Fast_tac 1 ]);
   296  (fn _ => [ Blast_tac 1 ]);
   297 
   297 
   298 Addsimps [Un_iff];
   298 Addsimps [Un_iff];
   299 
   299 
   300 goal Set.thy "!!c. c:A ==> c : A Un B";
   300 goal Set.thy "!!c. c:A ==> c : A Un B";
   301 by (Asm_simp_tac 1);
   301 by (Asm_simp_tac 1);
   322 
   322 
   323 
   323 
   324 section "Binary intersection -- Int";
   324 section "Binary intersection -- Int";
   325 
   325 
   326 qed_goalw "Int_iff" Set.thy [Int_def] "(c : A Int B) = (c:A & c:B)"
   326 qed_goalw "Int_iff" Set.thy [Int_def] "(c : A Int B) = (c:A & c:B)"
   327  (fn _ => [ (Fast_tac 1) ]);
   327  (fn _ => [ (Blast_tac 1) ]);
   328 
   328 
   329 Addsimps [Int_iff];
   329 Addsimps [Int_iff];
   330 
   330 
   331 goal Set.thy "!!c. [| c:A;  c:B |] ==> c : A Int B";
   331 goal Set.thy "!!c. [| c:A;  c:B |] ==> c : A Int B";
   332 by (Asm_simp_tac 1);
   332 by (Asm_simp_tac 1);
   351 AddSEs [IntE];
   351 AddSEs [IntE];
   352 
   352 
   353 section "Set difference";
   353 section "Set difference";
   354 
   354 
   355 qed_goalw "Diff_iff" Set.thy [set_diff_def] "(c : A-B) = (c:A & c~:B)"
   355 qed_goalw "Diff_iff" Set.thy [set_diff_def] "(c : A-B) = (c:A & c~:B)"
   356  (fn _ => [ (Fast_tac 1) ]);
   356  (fn _ => [ (Blast_tac 1) ]);
   357 
   357 
   358 Addsimps [Diff_iff];
   358 Addsimps [Diff_iff];
   359 
   359 
   360 qed_goal "DiffI" Set.thy "!!c. [| c : A;  c ~: B |] ==> c : A - B"
   360 qed_goal "DiffI" Set.thy "!!c. [| c : A;  c ~: B |] ==> c : A - B"
   361  (fn _=> [ Asm_simp_tac 1 ]);
   361  (fn _=> [ Asm_simp_tac 1 ]);
   376 
   376 
   377 
   377 
   378 section "Augmenting a set -- insert";
   378 section "Augmenting a set -- insert";
   379 
   379 
   380 qed_goalw "insert_iff" Set.thy [insert_def] "a : insert b A = (a=b | a:A)"
   380 qed_goalw "insert_iff" Set.thy [insert_def] "a : insert b A = (a=b | a:A)"
   381  (fn _ => [Fast_tac 1]);
   381  (fn _ => [Blast_tac 1]);
   382 
   382 
   383 Addsimps [insert_iff];
   383 Addsimps [insert_iff];
   384 
   384 
   385 qed_goal "insertI1" Set.thy "a : insert a B"
   385 qed_goal "insertI1" Set.thy "a : insert a B"
   386  (fn _ => [Simp_tac 1]);
   386  (fn _ => [Simp_tac 1]);
   407 
   407 
   408 qed_goal "singletonI" Set.thy "a : {a}"
   408 qed_goal "singletonI" Set.thy "a : {a}"
   409  (fn _=> [ (rtac insertI1 1) ]);
   409  (fn _=> [ (rtac insertI1 1) ]);
   410 
   410 
   411 goal Set.thy "!!a. b : {a} ==> b=a";
   411 goal Set.thy "!!a. b : {a} ==> b=a";
   412 by (Fast_tac 1);
   412 by (Blast_tac 1);
   413 qed "singletonD";
   413 qed "singletonD";
   414 
   414 
   415 bind_thm ("singletonE", make_elim singletonD);
   415 bind_thm ("singletonE", make_elim singletonD);
   416 
   416 
   417 qed_goal "singleton_iff" thy "(b : {a}) = (b=a)" 
   417 qed_goal "singleton_iff" thy "(b : {a}) = (b=a)" 
   418 (fn _ => [Fast_tac 1]);
   418 (fn _ => [Blast_tac 1]);
   419 
   419 
   420 goal Set.thy "!!a b. {a}={b} ==> a=b";
   420 goal Set.thy "!!a b. {a}={b} ==> a=b";
   421 by (fast_tac (!claset addEs [equalityE]) 1);
   421 by (fast_tac (!claset addEs [equalityE]) 1);
   422 qed "singleton_inject";
   422 qed "singleton_inject";
   423 
   423 
   437 
   437 
   438 
   438 
   439 section "Unions of families -- UNION x:A. B(x) is Union(B``A)";
   439 section "Unions of families -- UNION x:A. B(x) is Union(B``A)";
   440 
   440 
   441 goalw Set.thy [UNION_def] "(b: (UN x:A. B(x))) = (EX x:A. b: B(x))";
   441 goalw Set.thy [UNION_def] "(b: (UN x:A. B(x))) = (EX x:A. b: B(x))";
   442 by (Fast_tac 1);
   442 by (Blast_tac 1);
   443 qed "UN_iff";
   443 qed "UN_iff";
   444 
   444 
   445 Addsimps [UN_iff];
   445 Addsimps [UN_iff];
   446 
   446 
   447 (*The order of the premises presupposes that A is rigid; b may be flexible*)
   447 (*The order of the premises presupposes that A is rigid; b may be flexible*)
   505 
   505 
   506 section "Unions over a type; UNION1(B) = Union(range(B))";
   506 section "Unions over a type; UNION1(B) = Union(range(B))";
   507 
   507 
   508 goalw Set.thy [UNION1_def] "(b: (UN x. B(x))) = (EX x. b: B(x))";
   508 goalw Set.thy [UNION1_def] "(b: (UN x. B(x))) = (EX x. b: B(x))";
   509 by (Simp_tac 1);
   509 by (Simp_tac 1);
   510 by (Fast_tac 1);
   510 by (Blast_tac 1);
   511 qed "UN1_iff";
   511 qed "UN1_iff";
   512 
   512 
   513 Addsimps [UN1_iff];
   513 Addsimps [UN1_iff];
   514 
   514 
   515 (*The order of the premises presupposes that A is rigid; b may be flexible*)
   515 (*The order of the premises presupposes that A is rigid; b may be flexible*)
   529 
   529 
   530 section "Intersections over a type; INTER1(B) = Inter(range(B))";
   530 section "Intersections over a type; INTER1(B) = Inter(range(B))";
   531 
   531 
   532 goalw Set.thy [INTER1_def] "(b: (INT x. B(x))) = (ALL x. b: B(x))";
   532 goalw Set.thy [INTER1_def] "(b: (INT x. B(x))) = (ALL x. b: B(x))";
   533 by (Simp_tac 1);
   533 by (Simp_tac 1);
   534 by (Fast_tac 1);
   534 by (Blast_tac 1);
   535 qed "INT1_iff";
   535 qed "INT1_iff";
   536 
   536 
   537 Addsimps [INT1_iff];
   537 Addsimps [INT1_iff];
   538 
   538 
   539 val prems = goalw Set.thy [INTER1_def]
   539 val prems = goalw Set.thy [INTER1_def]
   550 
   550 
   551 
   551 
   552 section "Union";
   552 section "Union";
   553 
   553 
   554 goalw Set.thy [Union_def] "(A : Union(C)) = (EX X:C. A:X)";
   554 goalw Set.thy [Union_def] "(A : Union(C)) = (EX X:C. A:X)";
   555 by (Fast_tac 1);
   555 by (Blast_tac 1);
   556 qed "Union_iff";
   556 qed "Union_iff";
   557 
   557 
   558 Addsimps [Union_iff];
   558 Addsimps [Union_iff];
   559 
   559 
   560 (*The order of the premises presupposes that C is rigid; A may be flexible*)
   560 (*The order of the premises presupposes that C is rigid; A may be flexible*)
   573 
   573 
   574 
   574 
   575 section "Inter";
   575 section "Inter";
   576 
   576 
   577 goalw Set.thy [Inter_def] "(A : Inter(C)) = (ALL X:C. A:X)";
   577 goalw Set.thy [Inter_def] "(A : Inter(C)) = (ALL X:C. A:X)";
   578 by (Fast_tac 1);
   578 by (Blast_tac 1);
   579 qed "Inter_iff";
   579 qed "Inter_iff";
   580 
   580 
   581 Addsimps [Inter_iff];
   581 Addsimps [Inter_iff];
   582 
   582 
   583 val prems = goalw Set.thy [Inter_def]
   583 val prems = goalw Set.thy [Inter_def]