src/HOL/equalities.ML
author clasohm
Wed Mar 13 11:55:25 1996 +0100 (1996-03-13 ago)
changeset 1574 5a63ab90ee8a
parent 1564 822575c737bd
child 1618 372880456b5b
permissions -rw-r--r--
modified primrec so it can be used in MiniML/Type.thy
     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 goal Set.thy "Inter(A) Un Inter(B) <= Inter(A Int B)";
   281 by (fast_tac set_cs 1);
   282 qed "Inter_Un_subset";
   283 
   284 goal Set.thy "Inter(A Un B) = Inter(A) Int Inter(B)";
   285 by (best_tac eq_cs 1);
   286 qed "Inter_Un_distrib";
   287 
   288 section "UN and INT";
   289 
   290 (*Basic identities*)
   291 
   292 goal Set.thy "(UN x:{}. B x) = {}";
   293 by (fast_tac eq_cs 1);
   294 qed "UN_empty";
   295 Addsimps[UN_empty];
   296 
   297 goal Set.thy "(UN x:UNIV. B x) = (UN x. B x)";
   298 by (fast_tac eq_cs 1);
   299 qed "UN_UNIV";
   300 Addsimps[UN_UNIV];
   301 
   302 goal Set.thy "(INT x:{}. B x) = UNIV";
   303 by (fast_tac eq_cs 1);
   304 qed "INT_empty";
   305 Addsimps[INT_empty];
   306 
   307 goal Set.thy "(INT x:UNIV. B x) = (INT x. B x)";
   308 by (fast_tac eq_cs 1);
   309 qed "INT_UNIV";
   310 Addsimps[INT_UNIV];
   311 
   312 goal Set.thy "(UN x:insert a A. B x) = B a Un UNION A B";
   313 by (fast_tac eq_cs 1);
   314 qed "UN_insert";
   315 Addsimps[UN_insert];
   316 
   317 goal Set.thy "(INT x:insert a A. B x) = B a Int INTER A B";
   318 by (fast_tac eq_cs 1);
   319 qed "INT_insert";
   320 Addsimps[INT_insert];
   321 
   322 goal Set.thy "Union(range(f)) = (UN x.f(x))";
   323 by (fast_tac eq_cs 1);
   324 qed "Union_range_eq";
   325 
   326 goal Set.thy "Inter(range(f)) = (INT x.f(x))";
   327 by (fast_tac eq_cs 1);
   328 qed "Inter_range_eq";
   329 
   330 goal Set.thy "Union(B``A) = (UN x:A. B(x))";
   331 by (fast_tac eq_cs 1);
   332 qed "Union_image_eq";
   333 
   334 goal Set.thy "Inter(B``A) = (INT x:A. B(x))";
   335 by (fast_tac eq_cs 1);
   336 qed "Inter_image_eq";
   337 
   338 goal Set.thy "!!A. a: A ==> (UN y:A. c) = c";
   339 by (fast_tac eq_cs 1);
   340 qed "UN_constant";
   341 
   342 goal Set.thy "!!A. a: A ==> (INT y:A. c) = c";
   343 by (fast_tac eq_cs 1);
   344 qed "INT_constant";
   345 
   346 goal Set.thy "(UN x.B) = B";
   347 by (fast_tac eq_cs 1);
   348 qed "UN1_constant";
   349 Addsimps[UN1_constant];
   350 
   351 goal Set.thy "(INT x.B) = B";
   352 by (fast_tac eq_cs 1);
   353 qed "INT1_constant";
   354 Addsimps[INT1_constant];
   355 
   356 goal Set.thy "(UN x:A. B(x)) = Union({Y. ? x:A. Y=B(x)})";
   357 by (fast_tac eq_cs 1);
   358 qed "UN_eq";
   359 
   360 (*Look: it has an EXISTENTIAL quantifier*)
   361 goal Set.thy "(INT x:A. B(x)) = Inter({Y. ? x:A. Y=B(x)})";
   362 by (fast_tac eq_cs 1);
   363 qed "INT_eq";
   364 
   365 (*Distributive laws...*)
   366 
   367 goal Set.thy "A Int Union(B) = (UN C:B. A Int C)";
   368 by (fast_tac eq_cs 1);
   369 qed "Int_Union";
   370 
   371 (* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: 
   372    Union of a family of unions **)
   373 goal Set.thy "(UN x:C. A(x) Un B(x)) = Union(A``C)  Un  Union(B``C)";
   374 by (fast_tac eq_cs 1);
   375 qed "Un_Union_image";
   376 
   377 (*Equivalent version*)
   378 goal Set.thy "(UN i:I. A(i) Un B(i)) = (UN i:I. A(i))  Un  (UN i:I. B(i))";
   379 by (fast_tac eq_cs 1);
   380 qed "UN_Un_distrib";
   381 
   382 goal Set.thy "A Un Inter(B) = (INT C:B. A Un C)";
   383 by (fast_tac eq_cs 1);
   384 qed "Un_Inter";
   385 
   386 goal Set.thy "(INT x:C. A(x) Int B(x)) = Inter(A``C) Int Inter(B``C)";
   387 by (best_tac eq_cs 1);
   388 qed "Int_Inter_image";
   389 
   390 (*Equivalent version*)
   391 goal Set.thy "(INT i:I. A(i) Int B(i)) = (INT i:I. A(i)) Int (INT i:I. B(i))";
   392 by (fast_tac eq_cs 1);
   393 qed "INT_Int_distrib";
   394 
   395 (*Halmos, Naive Set Theory, page 35.*)
   396 goal Set.thy "B Int (UN i:I. A(i)) = (UN i:I. B Int A(i))";
   397 by (fast_tac eq_cs 1);
   398 qed "Int_UN_distrib";
   399 
   400 goal Set.thy "B Un (INT i:I. A(i)) = (INT i:I. B Un A(i))";
   401 by (fast_tac eq_cs 1);
   402 qed "Un_INT_distrib";
   403 
   404 goal Set.thy
   405     "(UN i:I. A(i)) Int (UN j:J. B(j)) = (UN i:I. UN j:J. A(i) Int B(j))";
   406 by (fast_tac eq_cs 1);
   407 qed "Int_UN_distrib2";
   408 
   409 goal Set.thy
   410     "(INT i:I. A(i)) Un (INT j:J. B(j)) = (INT i:I. INT j:J. A(i) Un B(j))";
   411 by (fast_tac eq_cs 1);
   412 qed "Un_INT_distrib2";
   413 
   414 section "-";
   415 
   416 goal Set.thy "A-A = {}";
   417 by (fast_tac eq_cs 1);
   418 qed "Diff_cancel";
   419 Addsimps[Diff_cancel];
   420 
   421 goal Set.thy "{}-A = {}";
   422 by (fast_tac eq_cs 1);
   423 qed "empty_Diff";
   424 Addsimps[empty_Diff];
   425 
   426 goal Set.thy "A-{} = A";
   427 by (fast_tac eq_cs 1);
   428 qed "Diff_empty";
   429 Addsimps[Diff_empty];
   430 
   431 goal Set.thy "A-UNIV = {}";
   432 by (fast_tac eq_cs 1);
   433 qed "Diff_UNIV";
   434 Addsimps[Diff_UNIV];
   435 
   436 goal Set.thy "!!x. x~:A ==> A - insert x B = A-B";
   437 by (fast_tac eq_cs 1);
   438 qed "Diff_insert0";
   439 Addsimps [Diff_insert0];
   440 
   441 (*NOT SUITABLE FOR REWRITING since {a} == insert a 0*)
   442 goal Set.thy "A - insert a B = A - B - {a}";
   443 by (fast_tac eq_cs 1);
   444 qed "Diff_insert";
   445 
   446 (*NOT SUITABLE FOR REWRITING since {a} == insert a 0*)
   447 goal Set.thy "A - insert a B = A - {a} - B";
   448 by (fast_tac eq_cs 1);
   449 qed "Diff_insert2";
   450 
   451 goal Set.thy "insert x A - B = (if x:B then A-B else insert x (A-B))";
   452 by (simp_tac (!simpset setloop split_tac[expand_if]) 1);
   453 by (fast_tac eq_cs 1);
   454 qed "insert_Diff_if";
   455 
   456 goal Set.thy "!!x. x:B ==> insert x A - B = A-B";
   457 by (fast_tac eq_cs 1);
   458 qed "insert_Diff1";
   459 Addsimps [insert_Diff1];
   460 
   461 val prems = goal Set.thy "a:A ==> insert a (A-{a}) = A";
   462 by (fast_tac (eq_cs addSIs prems) 1);
   463 qed "insert_Diff";
   464 
   465 goal Set.thy "A Int (B-A) = {}";
   466 by (fast_tac eq_cs 1);
   467 qed "Diff_disjoint";
   468 Addsimps[Diff_disjoint];
   469 
   470 goal Set.thy "!!A. A<=B ==> A Un (B-A) = B";
   471 by (fast_tac eq_cs 1);
   472 qed "Diff_partition";
   473 
   474 goal Set.thy "!!A. [| A<=B; B<= C |] ==> (B - (C - A)) = (A :: 'a set)";
   475 by (fast_tac eq_cs 1);
   476 qed "double_diff";
   477 
   478 goal Set.thy "A - (B Un C) = (A-B) Int (A-C)";
   479 by (fast_tac eq_cs 1);
   480 qed "Diff_Un";
   481 
   482 goal Set.thy "A - (B Int C) = (A-B) Un (A-C)";
   483 by (fast_tac eq_cs 1);
   484 qed "Diff_Int";
   485 
   486 Addsimps[subset_UNIV, empty_subsetI, subset_refl];