src/HOL/equalities.ML
author paulson
Wed Mar 06 13:57:07 1996 +0100 (1996-03-06 ago)
changeset 1553 4eb4a9c7d736
parent 1548 afe750876848
child 1564 822575c737bd
permissions -rw-r--r--
Ran expandshort
     1 (*  Title:      HOL/equalities
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1994  University of Cambridge
     5 
     6 Equalities involving union, intersection, inclusion, etc.
     7 *)
     8 
     9 writeln"File HOL/equalities";
    10 
    11 val eq_cs = set_cs addSIs [equalityI];
    12 
    13 section "{}";
    14 
    15 goal Set.thy "{x.False} = {}";
    16 by (fast_tac eq_cs 1);
    17 qed "Collect_False_empty";
    18 Addsimps [Collect_False_empty];
    19 
    20 goal Set.thy "(A <= {}) = (A = {})";
    21 by (fast_tac eq_cs 1);
    22 qed "subset_empty";
    23 Addsimps [subset_empty];
    24 
    25 section ":";
    26 
    27 goal Set.thy "x ~: {}";
    28 by (fast_tac set_cs 1);
    29 qed "in_empty";
    30 Addsimps[in_empty];
    31 
    32 goal Set.thy "x : insert y A = (x=y | x:A)";
    33 by (fast_tac set_cs 1);
    34 qed "in_insert";
    35 Addsimps[in_insert];
    36 
    37 section "insert";
    38 
    39 (*NOT SUITABLE FOR REWRITING since {a} == insert a {}*)
    40 goal Set.thy "insert a A = {a} Un A";
    41 by (fast_tac eq_cs 1);
    42 qed "insert_is_Un";
    43 
    44 goal Set.thy "insert a A ~= {}";
    45 by (fast_tac (set_cs addEs [equalityCE]) 1);
    46 qed"insert_not_empty";
    47 Addsimps[insert_not_empty];
    48 
    49 bind_thm("empty_not_insert",insert_not_empty RS not_sym);
    50 Addsimps[empty_not_insert];
    51 
    52 goal Set.thy "!!a. a:A ==> insert a A = A";
    53 by (fast_tac eq_cs 1);
    54 qed "insert_absorb";
    55 
    56 goal Set.thy "insert x (insert x A) = insert x A";
    57 by (fast_tac eq_cs 1);
    58 qed "insert_absorb2";
    59 Addsimps [insert_absorb2];
    60 
    61 goal Set.thy "(insert x A <= B) = (x:B & A <= B)";
    62 by (fast_tac set_cs 1);
    63 qed "insert_subset";
    64 Addsimps[insert_subset];
    65 
    66 (* use new B rather than (A-{a}) to avoid infinite unfolding *)
    67 goal Set.thy "!!a. a:A ==> ? B. A = insert a B & a ~: B";
    68 by (res_inst_tac [("x","A-{a}")] exI 1);
    69 by (fast_tac eq_cs 1);
    70 qed "mk_disjoint_insert";
    71 
    72 section "''";
    73 
    74 goal Set.thy "f``{} = {}";
    75 by (fast_tac eq_cs 1);
    76 qed "image_empty";
    77 Addsimps[image_empty];
    78 
    79 goal Set.thy "f``insert a B = insert (f a) (f``B)";
    80 by (fast_tac eq_cs 1);
    81 qed "image_insert";
    82 Addsimps[image_insert];
    83 
    84 section "Int";
    85 
    86 goal Set.thy "A Int A = A";
    87 by (fast_tac eq_cs 1);
    88 qed "Int_absorb";
    89 Addsimps[Int_absorb];
    90 
    91 goal Set.thy "A Int B  =  B Int A";
    92 by (fast_tac eq_cs 1);
    93 qed "Int_commute";
    94 
    95 goal Set.thy "(A Int B) Int C  =  A Int (B Int C)";
    96 by (fast_tac eq_cs 1);
    97 qed "Int_assoc";
    98 
    99 goal Set.thy "{} Int B = {}";
   100 by (fast_tac eq_cs 1);
   101 qed "Int_empty_left";
   102 Addsimps[Int_empty_left];
   103 
   104 goal Set.thy "A Int {} = {}";
   105 by (fast_tac eq_cs 1);
   106 qed "Int_empty_right";
   107 Addsimps[Int_empty_right];
   108 
   109 goal Set.thy "UNIV Int B = B";
   110 by (fast_tac eq_cs 1);
   111 qed "Int_UNIV_left";
   112 Addsimps[Int_UNIV_left];
   113 
   114 goal Set.thy "A Int UNIV = A";
   115 by (fast_tac eq_cs 1);
   116 qed "Int_UNIV_right";
   117 Addsimps[Int_UNIV_right];
   118 
   119 goal Set.thy "A Int (B Un C)  =  (A Int B) Un (A Int C)";
   120 by (fast_tac eq_cs 1);
   121 qed "Int_Un_distrib";
   122 
   123 goal Set.thy "(A<=B) = (A Int B = A)";
   124 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   125 qed "subset_Int_eq";
   126 
   127 goal Set.thy "(A Int B = UNIV) = (A = UNIV & B = UNIV)";
   128 by (fast_tac (eq_cs addEs [equalityCE]) 1);
   129 qed "Int_UNIV";
   130 Addsimps[Int_UNIV];
   131 
   132 section "Un";
   133 
   134 goal Set.thy "A Un A = A";
   135 by (fast_tac eq_cs 1);
   136 qed "Un_absorb";
   137 Addsimps[Un_absorb];
   138 
   139 goal Set.thy "A Un B  =  B Un A";
   140 by (fast_tac eq_cs 1);
   141 qed "Un_commute";
   142 
   143 goal Set.thy "(A Un B) Un C  =  A Un (B Un C)";
   144 by (fast_tac eq_cs 1);
   145 qed "Un_assoc";
   146 
   147 goal Set.thy "{} Un B = B";
   148 by (fast_tac eq_cs 1);
   149 qed "Un_empty_left";
   150 Addsimps[Un_empty_left];
   151 
   152 goal Set.thy "A Un {} = A";
   153 by (fast_tac eq_cs 1);
   154 qed "Un_empty_right";
   155 Addsimps[Un_empty_right];
   156 
   157 goal Set.thy "UNIV Un B = UNIV";
   158 by (fast_tac eq_cs 1);
   159 qed "Un_UNIV_left";
   160 Addsimps[Un_UNIV_left];
   161 
   162 goal Set.thy "A Un UNIV = UNIV";
   163 by (fast_tac eq_cs 1);
   164 qed "Un_UNIV_right";
   165 Addsimps[Un_UNIV_right];
   166 
   167 goal Set.thy "insert a B Un C = insert a (B Un C)";
   168 by (fast_tac eq_cs 1);
   169 qed "Un_insert_left";
   170 
   171 goal Set.thy "(A Int B) Un C  =  (A Un C) Int (B Un C)";
   172 by (fast_tac eq_cs 1);
   173 qed "Un_Int_distrib";
   174 
   175 goal Set.thy
   176  "(A Int B) Un (B Int C) Un (C Int A) = (A Un B) Int (B Un C) Int (C Un A)";
   177 by (fast_tac eq_cs 1);
   178 qed "Un_Int_crazy";
   179 
   180 goal Set.thy "(A<=B) = (A Un B = B)";
   181 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   182 qed "subset_Un_eq";
   183 
   184 goal Set.thy "(A <= insert b C) = (A <= C | b:A & A-{b} <= C)";
   185 by (fast_tac eq_cs 1);
   186 qed "subset_insert_iff";
   187 
   188 goal Set.thy "(A Un B = {}) = (A = {} & B = {})";
   189 by (fast_tac (eq_cs addEs [equalityCE]) 1);
   190 qed "Un_empty";
   191 Addsimps[Un_empty];
   192 
   193 section "Compl";
   194 
   195 goal Set.thy "A Int Compl(A) = {}";
   196 by (fast_tac eq_cs 1);
   197 qed "Compl_disjoint";
   198 Addsimps[Compl_disjoint];
   199 
   200 goal Set.thy "A Un Compl(A) = UNIV";
   201 by (fast_tac eq_cs 1);
   202 qed "Compl_partition";
   203 
   204 goal Set.thy "Compl(Compl(A)) = A";
   205 by (fast_tac eq_cs 1);
   206 qed "double_complement";
   207 Addsimps[double_complement];
   208 
   209 goal Set.thy "Compl(A Un B) = Compl(A) Int Compl(B)";
   210 by (fast_tac eq_cs 1);
   211 qed "Compl_Un";
   212 
   213 goal Set.thy "Compl(A Int B) = Compl(A) Un Compl(B)";
   214 by (fast_tac eq_cs 1);
   215 qed "Compl_Int";
   216 
   217 goal Set.thy "Compl(UN x:A. B(x)) = (INT x:A. Compl(B(x)))";
   218 by (fast_tac eq_cs 1);
   219 qed "Compl_UN";
   220 
   221 goal Set.thy "Compl(INT x:A. B(x)) = (UN x:A. Compl(B(x)))";
   222 by (fast_tac eq_cs 1);
   223 qed "Compl_INT";
   224 
   225 (*Halmos, Naive Set Theory, page 16.*)
   226 
   227 goal Set.thy "((A Int B) Un C = A Int (B Un C)) = (C<=A)";
   228 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   229 qed "Un_Int_assoc_eq";
   230 
   231 
   232 section "Union";
   233 
   234 goal Set.thy "Union({}) = {}";
   235 by (fast_tac eq_cs 1);
   236 qed "Union_empty";
   237 Addsimps[Union_empty];
   238 
   239 goal Set.thy "Union(UNIV) = UNIV";
   240 by (fast_tac eq_cs 1);
   241 qed "Union_UNIV";
   242 Addsimps[Union_UNIV];
   243 
   244 goal Set.thy "Union(insert a B) = a Un Union(B)";
   245 by (fast_tac eq_cs 1);
   246 qed "Union_insert";
   247 Addsimps[Union_insert];
   248 
   249 goal Set.thy "Union(A Un B) = Union(A) Un Union(B)";
   250 by (fast_tac eq_cs 1);
   251 qed "Union_Un_distrib";
   252 Addsimps[Union_Un_distrib];
   253 
   254 goal Set.thy "Union(A Int B) <= Union(A) Int Union(B)";
   255 by (fast_tac set_cs 1);
   256 qed "Union_Int_subset";
   257 
   258 val prems = goal Set.thy
   259    "(Union(C) Int A = {}) = (! B:C. B Int A = {})";
   260 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   261 qed "Union_disjoint";
   262 
   263 section "Inter";
   264 
   265 goal Set.thy "Inter({}) = UNIV";
   266 by (fast_tac eq_cs 1);
   267 qed "Inter_empty";
   268 Addsimps[Inter_empty];
   269 
   270 goal Set.thy "Inter(UNIV) = {}";
   271 by (fast_tac eq_cs 1);
   272 qed "Inter_UNIV";
   273 Addsimps[Inter_UNIV];
   274 
   275 goal Set.thy "Inter(insert a B) = a Int Inter(B)";
   276 by (fast_tac eq_cs 1);
   277 qed "Inter_insert";
   278 Addsimps[Inter_insert];
   279 
   280 (* Why does fast_tac fail???
   281 goal Set.thy "Inter(A Int B) = Inter(A) Int Inter(B)";
   282 by (fast_tac eq_cs 1);
   283 qed "Inter_Int_distrib";
   284 Addsimps[Inter_Int_distrib];
   285 *)
   286 
   287 goal Set.thy "Inter(A Un B) = Inter(A) Int Inter(B)";
   288 by (best_tac eq_cs 1);
   289 qed "Inter_Un_distrib";
   290 
   291 section "UN and INT";
   292 
   293 (*Basic identities*)
   294 
   295 goal Set.thy "(UN x:{}. B x) = {}";
   296 by (fast_tac eq_cs 1);
   297 qed "UN_empty";
   298 Addsimps[UN_empty];
   299 
   300 goal Set.thy "(UN x:UNIV. B x) = (UN x. B x)";
   301 by (fast_tac eq_cs 1);
   302 qed "UN_UNIV";
   303 Addsimps[UN_UNIV];
   304 
   305 goal Set.thy "(INT x:{}. B x) = UNIV";
   306 by (fast_tac eq_cs 1);
   307 qed "INT_empty";
   308 Addsimps[INT_empty];
   309 
   310 goal Set.thy "(INT x:UNIV. B x) = (INT x. B x)";
   311 by (fast_tac eq_cs 1);
   312 qed "INT_UNIV";
   313 Addsimps[INT_UNIV];
   314 
   315 goal Set.thy "(UN x:insert a A. B x) = B a Un UNION A B";
   316 by (fast_tac eq_cs 1);
   317 qed "UN_insert";
   318 Addsimps[UN_insert];
   319 
   320 goal Set.thy "(INT x:insert a A. B x) = B a Int INTER A B";
   321 by (fast_tac eq_cs 1);
   322 qed "INT_insert";
   323 Addsimps[INT_insert];
   324 
   325 goal Set.thy "Union(range(f)) = (UN x.f(x))";
   326 by (fast_tac eq_cs 1);
   327 qed "Union_range_eq";
   328 
   329 goal Set.thy "Inter(range(f)) = (INT x.f(x))";
   330 by (fast_tac eq_cs 1);
   331 qed "Inter_range_eq";
   332 
   333 goal Set.thy "Union(B``A) = (UN x:A. B(x))";
   334 by (fast_tac eq_cs 1);
   335 qed "Union_image_eq";
   336 
   337 goal Set.thy "Inter(B``A) = (INT x:A. B(x))";
   338 by (fast_tac eq_cs 1);
   339 qed "Inter_image_eq";
   340 
   341 goal Set.thy "!!A. a: A ==> (UN y:A. c) = c";
   342 by (fast_tac eq_cs 1);
   343 qed "UN_constant";
   344 
   345 goal Set.thy "!!A. a: A ==> (INT y:A. c) = c";
   346 by (fast_tac eq_cs 1);
   347 qed "INT_constant";
   348 
   349 goal Set.thy "(UN x.B) = B";
   350 by (fast_tac eq_cs 1);
   351 qed "UN1_constant";
   352 Addsimps[UN1_constant];
   353 
   354 goal Set.thy "(INT x.B) = B";
   355 by (fast_tac eq_cs 1);
   356 qed "INT1_constant";
   357 Addsimps[INT1_constant];
   358 
   359 goal Set.thy "(UN x:A. B(x)) = Union({Y. ? x:A. Y=B(x)})";
   360 by (fast_tac eq_cs 1);
   361 qed "UN_eq";
   362 
   363 (*Look: it has an EXISTENTIAL quantifier*)
   364 goal Set.thy "(INT x:A. B(x)) = Inter({Y. ? x:A. Y=B(x)})";
   365 by (fast_tac eq_cs 1);
   366 qed "INT_eq";
   367 
   368 (*Distributive laws...*)
   369 
   370 goal Set.thy "A Int Union(B) = (UN C:B. A Int C)";
   371 by (fast_tac eq_cs 1);
   372 qed "Int_Union";
   373 
   374 (* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: 
   375    Union of a family of unions **)
   376 goal Set.thy "(UN x:C. A(x) Un B(x)) = Union(A``C)  Un  Union(B``C)";
   377 by (fast_tac eq_cs 1);
   378 qed "Un_Union_image";
   379 
   380 (*Equivalent version*)
   381 goal Set.thy "(UN i:I. A(i) Un B(i)) = (UN i:I. A(i))  Un  (UN i:I. B(i))";
   382 by (fast_tac eq_cs 1);
   383 qed "UN_Un_distrib";
   384 
   385 goal Set.thy "A Un Inter(B) = (INT C:B. A Un C)";
   386 by (fast_tac eq_cs 1);
   387 qed "Un_Inter";
   388 
   389 goal Set.thy "(INT x:C. A(x) Int B(x)) = Inter(A``C) Int Inter(B``C)";
   390 by (best_tac eq_cs 1);
   391 qed "Int_Inter_image";
   392 
   393 (*Equivalent version*)
   394 goal Set.thy "(INT i:I. A(i) Int B(i)) = (INT i:I. A(i)) Int (INT i:I. B(i))";
   395 by (fast_tac eq_cs 1);
   396 qed "INT_Int_distrib";
   397 
   398 (*Halmos, Naive Set Theory, page 35.*)
   399 goal Set.thy "B Int (UN i:I. A(i)) = (UN i:I. B Int A(i))";
   400 by (fast_tac eq_cs 1);
   401 qed "Int_UN_distrib";
   402 
   403 goal Set.thy "B Un (INT i:I. A(i)) = (INT i:I. B Un A(i))";
   404 by (fast_tac eq_cs 1);
   405 qed "Un_INT_distrib";
   406 
   407 goal Set.thy
   408     "(UN i:I. A(i)) Int (UN j:J. B(j)) = (UN i:I. UN j:J. A(i) Int B(j))";
   409 by (fast_tac eq_cs 1);
   410 qed "Int_UN_distrib2";
   411 
   412 goal Set.thy
   413     "(INT i:I. A(i)) Un (INT j:J. B(j)) = (INT i:I. INT j:J. A(i) Un B(j))";
   414 by (fast_tac eq_cs 1);
   415 qed "Un_INT_distrib2";
   416 
   417 section "-";
   418 
   419 goal Set.thy "A-A = {}";
   420 by (fast_tac eq_cs 1);
   421 qed "Diff_cancel";
   422 Addsimps[Diff_cancel];
   423 
   424 goal Set.thy "{}-A = {}";
   425 by (fast_tac eq_cs 1);
   426 qed "empty_Diff";
   427 Addsimps[empty_Diff];
   428 
   429 goal Set.thy "A-{} = A";
   430 by (fast_tac eq_cs 1);
   431 qed "Diff_empty";
   432 Addsimps[Diff_empty];
   433 
   434 goal Set.thy "A-UNIV = {}";
   435 by (fast_tac eq_cs 1);
   436 qed "Diff_UNIV";
   437 Addsimps[Diff_UNIV];
   438 
   439 goal Set.thy "!!x. x~:A ==> A - insert x B = A-B";
   440 by (fast_tac eq_cs 1);
   441 qed "Diff_insert0";
   442 Addsimps [Diff_insert0];
   443 
   444 (*NOT SUITABLE FOR REWRITING since {a} == insert a 0*)
   445 goal Set.thy "A - insert a B = A - B - {a}";
   446 by (fast_tac eq_cs 1);
   447 qed "Diff_insert";
   448 
   449 (*NOT SUITABLE FOR REWRITING since {a} == insert a 0*)
   450 goal Set.thy "A - insert a B = A - {a} - B";
   451 by (fast_tac eq_cs 1);
   452 qed "Diff_insert2";
   453 
   454 goal Set.thy "insert x A - B = (if x:B then A-B else insert x (A-B))";
   455 by (simp_tac (!simpset setloop split_tac[expand_if]) 1);
   456 by (fast_tac eq_cs 1);
   457 qed "insert_Diff_if";
   458 
   459 goal Set.thy "!!x. x:B ==> insert x A - B = A-B";
   460 by (fast_tac eq_cs 1);
   461 qed "insert_Diff1";
   462 Addsimps [insert_Diff1];
   463 
   464 val prems = goal Set.thy "a:A ==> insert a (A-{a}) = A";
   465 by (fast_tac (eq_cs addSIs prems) 1);
   466 qed "insert_Diff";
   467 
   468 goal Set.thy "A Int (B-A) = {}";
   469 by (fast_tac eq_cs 1);
   470 qed "Diff_disjoint";
   471 Addsimps[Diff_disjoint];
   472 
   473 goal Set.thy "!!A. A<=B ==> A Un (B-A) = B";
   474 by (fast_tac eq_cs 1);
   475 qed "Diff_partition";
   476 
   477 goal Set.thy "!!A. [| A<=B; B<= C |] ==> (B - (C - A)) = (A :: 'a set)";
   478 by (fast_tac eq_cs 1);
   479 qed "double_diff";
   480 
   481 goal Set.thy "A - (B Un C) = (A-B) Int (A-C)";
   482 by (fast_tac eq_cs 1);
   483 qed "Diff_Un";
   484 
   485 goal Set.thy "A - (B Int C) = (A-B) Un (A-C)";
   486 by (fast_tac eq_cs 1);
   487 qed "Diff_Int";
   488 
   489 Addsimps[subset_UNIV, empty_subsetI, subset_refl];