src/HOL/equalities.ML
changeset 1548 afe750876848
parent 1531 e5eb247ad13c
child 1553 4eb4a9c7d736
equal deleted inserted replaced
1547:9ee49b349bb4 1548:afe750876848
     8 
     8 
     9 writeln"File HOL/equalities";
     9 writeln"File HOL/equalities";
    10 
    10 
    11 val eq_cs = set_cs addSIs [equalityI];
    11 val eq_cs = set_cs addSIs [equalityI];
    12 
    12 
       
    13 section "{}";
       
    14 
    13 goal Set.thy "{x.False} = {}";
    15 goal Set.thy "{x.False} = {}";
    14 by(fast_tac eq_cs 1);
    16 by(fast_tac eq_cs 1);
    15 qed "Collect_False_empty";
    17 qed "Collect_False_empty";
    16 Addsimps [Collect_False_empty];
    18 Addsimps [Collect_False_empty];
    17 
    19 
    18 goal Set.thy "(A <= {}) = (A = {})";
    20 goal Set.thy "(A <= {}) = (A = {})";
    19 by(fast_tac eq_cs 1);
    21 by(fast_tac eq_cs 1);
    20 qed "subset_empty";
    22 qed "subset_empty";
    21 Addsimps [subset_empty];
    23 Addsimps [subset_empty];
    22 
    24 
    23 (** The membership relation, : **)
    25 section ":";
    24 
    26 
    25 goal Set.thy "x ~: {}";
    27 goal Set.thy "x ~: {}";
    26 by(fast_tac set_cs 1);
    28 by(fast_tac set_cs 1);
    27 qed "in_empty";
    29 qed "in_empty";
    28 Addsimps[in_empty];
    30 Addsimps[in_empty];
    30 goal Set.thy "x : insert y A = (x=y | x:A)";
    32 goal Set.thy "x : insert y A = (x=y | x:A)";
    31 by(fast_tac set_cs 1);
    33 by(fast_tac set_cs 1);
    32 qed "in_insert";
    34 qed "in_insert";
    33 Addsimps[in_insert];
    35 Addsimps[in_insert];
    34 
    36 
    35 (** insert **)
    37 section "insert";
    36 
    38 
    37 (*NOT SUITABLE FOR REWRITING since {a} == insert a {}*)
    39 (*NOT SUITABLE FOR REWRITING since {a} == insert a {}*)
    38 goal Set.thy "insert a A = {a} Un A";
    40 goal Set.thy "insert a A = {a} Un A";
    39 by(fast_tac eq_cs 1);
    41 by(fast_tac eq_cs 1);
    40 qed "insert_is_Un";
    42 qed "insert_is_Un";
    65 goal Set.thy "!!a. a:A ==> ? B. A = insert a B & a ~: B";
    67 goal Set.thy "!!a. a:A ==> ? B. A = insert a B & a ~: B";
    66 by(res_inst_tac [("x","A-{a}")] exI 1);
    68 by(res_inst_tac [("x","A-{a}")] exI 1);
    67 by(fast_tac eq_cs 1);
    69 by(fast_tac eq_cs 1);
    68 qed "mk_disjoint_insert";
    70 qed "mk_disjoint_insert";
    69 
    71 
    70 (** Image **)
    72 section "''";
    71 
    73 
    72 goal Set.thy "f``{} = {}";
    74 goal Set.thy "f``{} = {}";
    73 by (fast_tac eq_cs 1);
    75 by (fast_tac eq_cs 1);
    74 qed "image_empty";
    76 qed "image_empty";
    75 Addsimps[image_empty];
    77 Addsimps[image_empty];
    77 goal Set.thy "f``insert a B = insert (f a) (f``B)";
    79 goal Set.thy "f``insert a B = insert (f a) (f``B)";
    78 by (fast_tac eq_cs 1);
    80 by (fast_tac eq_cs 1);
    79 qed "image_insert";
    81 qed "image_insert";
    80 Addsimps[image_insert];
    82 Addsimps[image_insert];
    81 
    83 
    82 (** Binary Intersection **)
    84 section "Int";
    83 
    85 
    84 goal Set.thy "A Int A = A";
    86 goal Set.thy "A Int A = A";
    85 by (fast_tac eq_cs 1);
    87 by (fast_tac eq_cs 1);
    86 qed "Int_absorb";
    88 qed "Int_absorb";
    87 Addsimps[Int_absorb];
    89 Addsimps[Int_absorb];
   125 goal Set.thy "(A Int B = UNIV) = (A = UNIV & B = UNIV)";
   127 goal Set.thy "(A Int B = UNIV) = (A = UNIV & B = UNIV)";
   126 by (fast_tac (eq_cs addEs [equalityCE]) 1);
   128 by (fast_tac (eq_cs addEs [equalityCE]) 1);
   127 qed "Int_UNIV";
   129 qed "Int_UNIV";
   128 Addsimps[Int_UNIV];
   130 Addsimps[Int_UNIV];
   129 
   131 
   130 (** Binary Union **)
   132 section "Un";
   131 
   133 
   132 goal Set.thy "A Un A = A";
   134 goal Set.thy "A Un A = A";
   133 by (fast_tac eq_cs 1);
   135 by (fast_tac eq_cs 1);
   134 qed "Un_absorb";
   136 qed "Un_absorb";
   135 Addsimps[Un_absorb];
   137 Addsimps[Un_absorb];
   186 goal Set.thy "(A Un B = {}) = (A = {} & B = {})";
   188 goal Set.thy "(A Un B = {}) = (A = {} & B = {})";
   187 by (fast_tac (eq_cs addEs [equalityCE]) 1);
   189 by (fast_tac (eq_cs addEs [equalityCE]) 1);
   188 qed "Un_empty";
   190 qed "Un_empty";
   189 Addsimps[Un_empty];
   191 Addsimps[Un_empty];
   190 
   192 
   191 (** Simple properties of Compl -- complement of a set **)
   193 section "Compl";
   192 
   194 
   193 goal Set.thy "A Int Compl(A) = {}";
   195 goal Set.thy "A Int Compl(A) = {}";
   194 by (fast_tac eq_cs 1);
   196 by (fast_tac eq_cs 1);
   195 qed "Compl_disjoint";
   197 qed "Compl_disjoint";
   196 Addsimps[Compl_disjoint];
   198 Addsimps[Compl_disjoint];
   225 goal Set.thy "((A Int B) Un C = A Int (B Un C)) = (C<=A)";
   227 goal Set.thy "((A Int B) Un C = A Int (B Un C)) = (C<=A)";
   226 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   228 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   227 qed "Un_Int_assoc_eq";
   229 qed "Un_Int_assoc_eq";
   228 
   230 
   229 
   231 
   230 (** Big Union and Intersection **)
   232 section "Union";
   231 
   233 
   232 goal Set.thy "Union({}) = {}";
   234 goal Set.thy "Union({}) = {}";
   233 by (fast_tac eq_cs 1);
   235 by (fast_tac eq_cs 1);
   234 qed "Union_empty";
   236 qed "Union_empty";
   235 Addsimps[Union_empty];
   237 Addsimps[Union_empty];
   256 val prems = goal Set.thy
   258 val prems = goal Set.thy
   257    "(Union(C) Int A = {}) = (! B:C. B Int A = {})";
   259    "(Union(C) Int A = {}) = (! B:C. B Int A = {})";
   258 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   260 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   259 qed "Union_disjoint";
   261 qed "Union_disjoint";
   260 
   262 
       
   263 section "Inter";
       
   264 
   261 goal Set.thy "Inter({}) = UNIV";
   265 goal Set.thy "Inter({}) = UNIV";
   262 by (fast_tac eq_cs 1);
   266 by (fast_tac eq_cs 1);
   263 qed "Inter_empty";
   267 qed "Inter_empty";
   264 Addsimps[Inter_empty];
   268 Addsimps[Inter_empty];
   265 
   269 
   282 
   286 
   283 goal Set.thy "Inter(A Un B) = Inter(A) Int Inter(B)";
   287 goal Set.thy "Inter(A Un B) = Inter(A) Int Inter(B)";
   284 by (best_tac eq_cs 1);
   288 by (best_tac eq_cs 1);
   285 qed "Inter_Un_distrib";
   289 qed "Inter_Un_distrib";
   286 
   290 
   287 (** Unions and Intersections of Families **)
   291 section "UN and INT";
   288 
   292 
   289 (*Basic identities*)
   293 (*Basic identities*)
   290 
   294 
   291 goal Set.thy "(UN x:{}. B x) = {}";
   295 goal Set.thy "(UN x:{}. B x) = {}";
   292 by (fast_tac eq_cs 1);
   296 by (fast_tac eq_cs 1);
   408 goal Set.thy
   412 goal Set.thy
   409     "(INT i:I. A(i)) Un (INT j:J. B(j)) = (INT i:I. INT j:J. A(i) Un B(j))";
   413     "(INT i:I. A(i)) Un (INT j:J. B(j)) = (INT i:I. INT j:J. A(i) Un B(j))";
   410 by (fast_tac eq_cs 1);
   414 by (fast_tac eq_cs 1);
   411 qed "Un_INT_distrib2";
   415 qed "Un_INT_distrib2";
   412 
   416 
   413 (** Simple properties of Diff -- set difference **)
   417 section "-";
   414 
   418 
   415 goal Set.thy "A-A = {}";
   419 goal Set.thy "A-A = {}";
   416 by (fast_tac eq_cs 1);
   420 by (fast_tac eq_cs 1);
   417 qed "Diff_cancel";
   421 qed "Diff_cancel";
   418 Addsimps[Diff_cancel];
   422 Addsimps[Diff_cancel];
   480 
   484 
   481 goal Set.thy "A - (B Int C) = (A-B) Un (A-C)";
   485 goal Set.thy "A - (B Int C) = (A-B) Un (A-C)";
   482 by (fast_tac eq_cs 1);
   486 by (fast_tac eq_cs 1);
   483 qed "Diff_Int";
   487 qed "Diff_Int";
   484 
   488 
   485 (* Congruence rule for set comprehension *)
       
   486 val prems = goal Set.thy
       
   487   "[| !!x. P x = Q x; !!x. Q x ==> f x = g x |] ==> \
       
   488 \  {f x |x. P x} = {g x|x. Q x}";
       
   489 by(simp_tac (!simpset addsimps prems) 1);
       
   490 br set_ext 1;
       
   491 br iffI 1;
       
   492 by(fast_tac (eq_cs addss (!simpset addsimps prems)) 1);
       
   493 be CollectE 1;
       
   494 be exE 1;
       
   495 by(Asm_simp_tac 1);
       
   496 be conjE 1;
       
   497 by(rtac exI 1 THEN rtac conjI 1 THEN atac 2);
       
   498 by(asm_simp_tac (!simpset addsimps prems) 1);
       
   499 qed "Collect_cong1";
       
   500 
       
   501 Addsimps[subset_UNIV, empty_subsetI, subset_refl];
   489 Addsimps[subset_UNIV, empty_subsetI, subset_refl];