src/HOL/Set.ML
changeset 2031 03a843f0f447
parent 2024 909153d8318f
child 2499 0bc87b063447
equal deleted inserted replaced
2030:474b3f208789 2031:03a843f0f447
     9 open Set;
     9 open Set;
    10 
    10 
    11 section "Relating predicates and sets";
    11 section "Relating predicates and sets";
    12 
    12 
    13 val [prem] = goal Set.thy "P(a) ==> a : {x.P(x)}";
    13 val [prem] = goal Set.thy "P(a) ==> a : {x.P(x)}";
    14 by (rtac (mem_Collect_eq RS ssubst) 1);
    14 by (stac mem_Collect_eq 1);
    15 by (rtac prem 1);
    15 by (rtac prem 1);
    16 qed "CollectI";
    16 qed "CollectI";
    17 
    17 
    18 val prems = goal Set.thy "[| a : {x.P(x)} |] ==> P(a)";
    18 val prems = goal Set.thy "[| a : {x.P(x)} |] ==> P(a)";
    19 by (resolve_tac (prems RL [mem_Collect_eq  RS subst]) 1);
    19 by (resolve_tac (prems RL [mem_Collect_eq  RS subst]) 1);
   348 qed "singletonD";
   348 qed "singletonD";
   349 
   349 
   350 bind_thm ("singletonE", make_elim singletonD);
   350 bind_thm ("singletonE", make_elim singletonD);
   351 
   351 
   352 qed_goal "singleton_iff" thy "(b : {a}) = (b=a)" (fn _ => [
   352 qed_goal "singleton_iff" thy "(b : {a}) = (b=a)" (fn _ => [
   353 	rtac iffI 1,
   353         rtac iffI 1,
   354 	etac singletonD 1,
   354         etac singletonD 1,
   355 	hyp_subst_tac 1,
   355         hyp_subst_tac 1,
   356 	rtac singletonI 1]);
   356         rtac singletonI 1]);
   357 
   357 
   358 val [major] = goal Set.thy "{a}={b} ==> a=b";
   358 val [major] = goal Set.thy "{a}={b} ==> a=b";
   359 by (rtac (major RS equalityD1 RS subsetD RS singletonD) 1);
   359 by (rtac (major RS equalityD1 RS subsetD RS singletonD) 1);
   360 by (rtac singletonI 1);
   360 by (rtac singletonI 1);
   361 qed "singleton_inject";
   361 qed "singleton_inject";
   500 
   500 
   501 (*** Set reasoning tools ***)
   501 (*** Set reasoning tools ***)
   502 
   502 
   503 
   503 
   504 val mem_simps = [insert_iff, empty_iff, Un_iff, Int_iff, Compl_iff, Diff_iff, 
   504 val mem_simps = [insert_iff, empty_iff, Un_iff, Int_iff, Compl_iff, Diff_iff, 
   505 		 mem_Collect_eq];
   505                  mem_Collect_eq];
   506 
   506 
   507 (*Not for Addsimps -- it can cause goals to blow up!*)
   507 (*Not for Addsimps -- it can cause goals to blow up!*)
   508 goal Set.thy "(a : (if Q then x else y)) = ((Q --> a:x) & (~Q --> a : y))";
   508 goal Set.thy "(a : (if Q then x else y)) = ((Q --> a:x) & (~Q --> a : y))";
   509 by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
   509 by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
   510 qed "mem_if";
   510 qed "mem_if";