src/HOL/equalities.ML
author nipkow
Fri May 17 16:08:06 1996 +0200 (1996-05-17)
changeset 1748 88650ba93c10
parent 1660 8cb42cd97579
child 1754 852093aeb0ab
permissions -rw-r--r--
Added if_image_distrib.
     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 qed_goal "ball_image" Set.thy "(!y:F``S. P y) = (!x:S. P (F x))"
    85  (fn _ => [fast_tac set_cs 1]);
    86 
    87 goalw Set.thy [image_def]
    88 "(%x. if P x then f x else g x) `` S			\
    89 \ = (f `` ({x.x:S & P x})) Un (g `` ({x.x:S & ~(P x)}))";
    90 by(split_tac [expand_if] 1);
    91 by(fast_tac eq_cs 1);
    92 qed "if_image_distrib";
    93 Addsimps[if_image_distrib];
    94 
    95 
    96 section "range";
    97 
    98 qed_goal "ball_range" Set.thy "(!y:range f. P y) = (!x. P (f x))"
    99  (fn _ => [fast_tac set_cs 1]);
   100 
   101 qed_goalw "image_range" Set.thy [image_def, range_def]
   102  "f``range g = range (%x. f (g x))" (fn _ => [
   103 	rtac Collect_cong 1,
   104 	fast_tac set_cs 1]);
   105 
   106 section "Int";
   107 
   108 goal Set.thy "A Int A = A";
   109 by (fast_tac eq_cs 1);
   110 qed "Int_absorb";
   111 Addsimps[Int_absorb];
   112 
   113 goal Set.thy "A Int B  =  B Int A";
   114 by (fast_tac eq_cs 1);
   115 qed "Int_commute";
   116 
   117 goal Set.thy "(A Int B) Int C  =  A Int (B Int C)";
   118 by (fast_tac eq_cs 1);
   119 qed "Int_assoc";
   120 
   121 goal Set.thy "{} Int B = {}";
   122 by (fast_tac eq_cs 1);
   123 qed "Int_empty_left";
   124 Addsimps[Int_empty_left];
   125 
   126 goal Set.thy "A Int {} = {}";
   127 by (fast_tac eq_cs 1);
   128 qed "Int_empty_right";
   129 Addsimps[Int_empty_right];
   130 
   131 goal Set.thy "UNIV Int B = B";
   132 by (fast_tac eq_cs 1);
   133 qed "Int_UNIV_left";
   134 Addsimps[Int_UNIV_left];
   135 
   136 goal Set.thy "A Int UNIV = A";
   137 by (fast_tac eq_cs 1);
   138 qed "Int_UNIV_right";
   139 Addsimps[Int_UNIV_right];
   140 
   141 goal Set.thy "A Int (B Un C)  =  (A Int B) Un (A Int C)";
   142 by (fast_tac eq_cs 1);
   143 qed "Int_Un_distrib";
   144 
   145 goal Set.thy "(B Un C) Int A =  (B Int A) Un (C Int A)";
   146 by (fast_tac eq_cs 1);
   147 qed "Int_Un_distrib2";
   148 
   149 goal Set.thy "(A<=B) = (A Int B = A)";
   150 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   151 qed "subset_Int_eq";
   152 
   153 goal Set.thy "(A Int B = UNIV) = (A = UNIV & B = UNIV)";
   154 by (fast_tac (eq_cs addEs [equalityCE]) 1);
   155 qed "Int_UNIV";
   156 Addsimps[Int_UNIV];
   157 
   158 section "Un";
   159 
   160 goal Set.thy "A Un A = A";
   161 by (fast_tac eq_cs 1);
   162 qed "Un_absorb";
   163 Addsimps[Un_absorb];
   164 
   165 goal Set.thy "A Un B  =  B Un A";
   166 by (fast_tac eq_cs 1);
   167 qed "Un_commute";
   168 
   169 goal Set.thy "(A Un B) Un C  =  A Un (B Un C)";
   170 by (fast_tac eq_cs 1);
   171 qed "Un_assoc";
   172 
   173 goal Set.thy "{} Un B = B";
   174 by (fast_tac eq_cs 1);
   175 qed "Un_empty_left";
   176 Addsimps[Un_empty_left];
   177 
   178 goal Set.thy "A Un {} = A";
   179 by (fast_tac eq_cs 1);
   180 qed "Un_empty_right";
   181 Addsimps[Un_empty_right];
   182 
   183 goal Set.thy "UNIV Un B = UNIV";
   184 by (fast_tac eq_cs 1);
   185 qed "Un_UNIV_left";
   186 Addsimps[Un_UNIV_left];
   187 
   188 goal Set.thy "A Un UNIV = UNIV";
   189 by (fast_tac eq_cs 1);
   190 qed "Un_UNIV_right";
   191 Addsimps[Un_UNIV_right];
   192 
   193 goal Set.thy "insert a B Un C = insert a (B Un C)";
   194 by (fast_tac eq_cs 1);
   195 qed "Un_insert_left";
   196 
   197 goal Set.thy "(A Int B) Un C  =  (A Un C) Int (B Un C)";
   198 by (fast_tac eq_cs 1);
   199 qed "Un_Int_distrib";
   200 
   201 goal Set.thy
   202  "(A Int B) Un (B Int C) Un (C Int A) = (A Un B) Int (B Un C) Int (C Un A)";
   203 by (fast_tac eq_cs 1);
   204 qed "Un_Int_crazy";
   205 
   206 goal Set.thy "(A<=B) = (A Un B = B)";
   207 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   208 qed "subset_Un_eq";
   209 
   210 goal Set.thy "(A <= insert b C) = (A <= C | b:A & A-{b} <= C)";
   211 by (fast_tac eq_cs 1);
   212 qed "subset_insert_iff";
   213 
   214 goal Set.thy "(A Un B = {}) = (A = {} & B = {})";
   215 by (fast_tac (eq_cs addEs [equalityCE]) 1);
   216 qed "Un_empty";
   217 Addsimps[Un_empty];
   218 
   219 section "Compl";
   220 
   221 goal Set.thy "A Int Compl(A) = {}";
   222 by (fast_tac eq_cs 1);
   223 qed "Compl_disjoint";
   224 Addsimps[Compl_disjoint];
   225 
   226 goal Set.thy "A Un Compl(A) = UNIV";
   227 by (fast_tac eq_cs 1);
   228 qed "Compl_partition";
   229 
   230 goal Set.thy "Compl(Compl(A)) = A";
   231 by (fast_tac eq_cs 1);
   232 qed "double_complement";
   233 Addsimps[double_complement];
   234 
   235 goal Set.thy "Compl(A Un B) = Compl(A) Int Compl(B)";
   236 by (fast_tac eq_cs 1);
   237 qed "Compl_Un";
   238 
   239 goal Set.thy "Compl(A Int B) = Compl(A) Un Compl(B)";
   240 by (fast_tac eq_cs 1);
   241 qed "Compl_Int";
   242 
   243 goal Set.thy "Compl(UN x:A. B(x)) = (INT x:A. Compl(B(x)))";
   244 by (fast_tac eq_cs 1);
   245 qed "Compl_UN";
   246 
   247 goal Set.thy "Compl(INT x:A. B(x)) = (UN x:A. Compl(B(x)))";
   248 by (fast_tac eq_cs 1);
   249 qed "Compl_INT";
   250 
   251 (*Halmos, Naive Set Theory, page 16.*)
   252 
   253 goal Set.thy "((A Int B) Un C = A Int (B Un C)) = (C<=A)";
   254 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   255 qed "Un_Int_assoc_eq";
   256 
   257 
   258 section "Union";
   259 
   260 goal Set.thy "Union({}) = {}";
   261 by (fast_tac eq_cs 1);
   262 qed "Union_empty";
   263 Addsimps[Union_empty];
   264 
   265 goal Set.thy "Union(UNIV) = UNIV";
   266 by (fast_tac eq_cs 1);
   267 qed "Union_UNIV";
   268 Addsimps[Union_UNIV];
   269 
   270 goal Set.thy "Union(insert a B) = a Un Union(B)";
   271 by (fast_tac eq_cs 1);
   272 qed "Union_insert";
   273 Addsimps[Union_insert];
   274 
   275 goal Set.thy "Union(A Un B) = Union(A) Un Union(B)";
   276 by (fast_tac eq_cs 1);
   277 qed "Union_Un_distrib";
   278 Addsimps[Union_Un_distrib];
   279 
   280 goal Set.thy "Union(A Int B) <= Union(A) Int Union(B)";
   281 by (fast_tac set_cs 1);
   282 qed "Union_Int_subset";
   283 
   284 val prems = goal Set.thy
   285    "(Union(C) Int A = {}) = (! B:C. B Int A = {})";
   286 by (fast_tac (eq_cs addSEs [equalityE]) 1);
   287 qed "Union_disjoint";
   288 
   289 section "Inter";
   290 
   291 goal Set.thy "Inter({}) = UNIV";
   292 by (fast_tac eq_cs 1);
   293 qed "Inter_empty";
   294 Addsimps[Inter_empty];
   295 
   296 goal Set.thy "Inter(UNIV) = {}";
   297 by (fast_tac eq_cs 1);
   298 qed "Inter_UNIV";
   299 Addsimps[Inter_UNIV];
   300 
   301 goal Set.thy "Inter(insert a B) = a Int Inter(B)";
   302 by (fast_tac eq_cs 1);
   303 qed "Inter_insert";
   304 Addsimps[Inter_insert];
   305 
   306 goal Set.thy "Inter(A) Un Inter(B) <= Inter(A Int B)";
   307 by (fast_tac set_cs 1);
   308 qed "Inter_Un_subset";
   309 
   310 goal Set.thy "Inter(A Un B) = Inter(A) Int Inter(B)";
   311 by (best_tac eq_cs 1);
   312 qed "Inter_Un_distrib";
   313 
   314 section "UN and INT";
   315 
   316 (*Basic identities*)
   317 
   318 goal Set.thy "(UN x:{}. B x) = {}";
   319 by (fast_tac eq_cs 1);
   320 qed "UN_empty";
   321 Addsimps[UN_empty];
   322 
   323 goal Set.thy "(UN x:UNIV. B x) = (UN x. B x)";
   324 by (fast_tac eq_cs 1);
   325 qed "UN_UNIV";
   326 Addsimps[UN_UNIV];
   327 
   328 goal Set.thy "(INT x:{}. B x) = UNIV";
   329 by (fast_tac eq_cs 1);
   330 qed "INT_empty";
   331 Addsimps[INT_empty];
   332 
   333 goal Set.thy "(INT x:UNIV. B x) = (INT x. B x)";
   334 by (fast_tac eq_cs 1);
   335 qed "INT_UNIV";
   336 Addsimps[INT_UNIV];
   337 
   338 goal Set.thy "(UN x:insert a A. B x) = B a Un UNION A B";
   339 by (fast_tac eq_cs 1);
   340 qed "UN_insert";
   341 Addsimps[UN_insert];
   342 
   343 goal Set.thy "(INT x:insert a A. B x) = B a Int INTER A B";
   344 by (fast_tac eq_cs 1);
   345 qed "INT_insert";
   346 Addsimps[INT_insert];
   347 
   348 goal Set.thy "Union(range(f)) = (UN x.f(x))";
   349 by (fast_tac eq_cs 1);
   350 qed "Union_range_eq";
   351 
   352 goal Set.thy "Inter(range(f)) = (INT x.f(x))";
   353 by (fast_tac eq_cs 1);
   354 qed "Inter_range_eq";
   355 
   356 goal Set.thy "Union(B``A) = (UN x:A. B(x))";
   357 by (fast_tac eq_cs 1);
   358 qed "Union_image_eq";
   359 
   360 goal Set.thy "Inter(B``A) = (INT x:A. B(x))";
   361 by (fast_tac eq_cs 1);
   362 qed "Inter_image_eq";
   363 
   364 goal Set.thy "!!A. a: A ==> (UN y:A. c) = c";
   365 by (fast_tac eq_cs 1);
   366 qed "UN_constant";
   367 
   368 goal Set.thy "!!A. a: A ==> (INT y:A. c) = c";
   369 by (fast_tac eq_cs 1);
   370 qed "INT_constant";
   371 
   372 goal Set.thy "(UN x.B) = B";
   373 by (fast_tac eq_cs 1);
   374 qed "UN1_constant";
   375 Addsimps[UN1_constant];
   376 
   377 goal Set.thy "(INT x.B) = B";
   378 by (fast_tac eq_cs 1);
   379 qed "INT1_constant";
   380 Addsimps[INT1_constant];
   381 
   382 goal Set.thy "(UN x:A. B(x)) = Union({Y. ? x:A. Y=B(x)})";
   383 by (fast_tac eq_cs 1);
   384 qed "UN_eq";
   385 
   386 (*Look: it has an EXISTENTIAL quantifier*)
   387 goal Set.thy "(INT x:A. B(x)) = Inter({Y. ? x:A. Y=B(x)})";
   388 by (fast_tac eq_cs 1);
   389 qed "INT_eq";
   390 
   391 (*Distributive laws...*)
   392 
   393 goal Set.thy "A Int Union(B) = (UN C:B. A Int C)";
   394 by (fast_tac eq_cs 1);
   395 qed "Int_Union";
   396 
   397 (* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: 
   398    Union of a family of unions **)
   399 goal Set.thy "(UN x:C. A(x) Un B(x)) = Union(A``C)  Un  Union(B``C)";
   400 by (fast_tac eq_cs 1);
   401 qed "Un_Union_image";
   402 
   403 (*Equivalent version*)
   404 goal Set.thy "(UN i:I. A(i) Un B(i)) = (UN i:I. A(i))  Un  (UN i:I. B(i))";
   405 by (fast_tac eq_cs 1);
   406 qed "UN_Un_distrib";
   407 
   408 goal Set.thy "A Un Inter(B) = (INT C:B. A Un C)";
   409 by (fast_tac eq_cs 1);
   410 qed "Un_Inter";
   411 
   412 goal Set.thy "(INT x:C. A(x) Int B(x)) = Inter(A``C) Int Inter(B``C)";
   413 by (best_tac eq_cs 1);
   414 qed "Int_Inter_image";
   415 
   416 (*Equivalent version*)
   417 goal Set.thy "(INT i:I. A(i) Int B(i)) = (INT i:I. A(i)) Int (INT i:I. B(i))";
   418 by (fast_tac eq_cs 1);
   419 qed "INT_Int_distrib";
   420 
   421 (*Halmos, Naive Set Theory, page 35.*)
   422 goal Set.thy "B Int (UN i:I. A(i)) = (UN i:I. B Int A(i))";
   423 by (fast_tac eq_cs 1);
   424 qed "Int_UN_distrib";
   425 
   426 goal Set.thy "B Un (INT i:I. A(i)) = (INT i:I. B Un A(i))";
   427 by (fast_tac eq_cs 1);
   428 qed "Un_INT_distrib";
   429 
   430 goal Set.thy
   431     "(UN i:I. A(i)) Int (UN j:J. B(j)) = (UN i:I. UN j:J. A(i) Int B(j))";
   432 by (fast_tac eq_cs 1);
   433 qed "Int_UN_distrib2";
   434 
   435 goal Set.thy
   436     "(INT i:I. A(i)) Un (INT j:J. B(j)) = (INT i:I. INT j:J. A(i) Un B(j))";
   437 by (fast_tac eq_cs 1);
   438 qed "Un_INT_distrib2";
   439 
   440 section "-";
   441 
   442 goal Set.thy "A-A = {}";
   443 by (fast_tac eq_cs 1);
   444 qed "Diff_cancel";
   445 Addsimps[Diff_cancel];
   446 
   447 goal Set.thy "{}-A = {}";
   448 by (fast_tac eq_cs 1);
   449 qed "empty_Diff";
   450 Addsimps[empty_Diff];
   451 
   452 goal Set.thy "A-{} = A";
   453 by (fast_tac eq_cs 1);
   454 qed "Diff_empty";
   455 Addsimps[Diff_empty];
   456 
   457 goal Set.thy "A-UNIV = {}";
   458 by (fast_tac eq_cs 1);
   459 qed "Diff_UNIV";
   460 Addsimps[Diff_UNIV];
   461 
   462 goal Set.thy "!!x. x~:A ==> A - insert x B = A-B";
   463 by (fast_tac eq_cs 1);
   464 qed "Diff_insert0";
   465 Addsimps [Diff_insert0];
   466 
   467 (*NOT SUITABLE FOR REWRITING since {a} == insert a 0*)
   468 goal Set.thy "A - insert a B = A - B - {a}";
   469 by (fast_tac eq_cs 1);
   470 qed "Diff_insert";
   471 
   472 (*NOT SUITABLE FOR REWRITING since {a} == insert a 0*)
   473 goal Set.thy "A - insert a B = A - {a} - B";
   474 by (fast_tac eq_cs 1);
   475 qed "Diff_insert2";
   476 
   477 goal Set.thy "insert x A - B = (if x:B then A-B else insert x (A-B))";
   478 by (simp_tac (!simpset setloop split_tac[expand_if]) 1);
   479 by (fast_tac eq_cs 1);
   480 qed "insert_Diff_if";
   481 
   482 goal Set.thy "!!x. x:B ==> insert x A - B = A-B";
   483 by (fast_tac eq_cs 1);
   484 qed "insert_Diff1";
   485 Addsimps [insert_Diff1];
   486 
   487 val prems = goal Set.thy "a:A ==> insert a (A-{a}) = A";
   488 by (fast_tac (eq_cs addSIs prems) 1);
   489 qed "insert_Diff";
   490 
   491 goal Set.thy "A Int (B-A) = {}";
   492 by (fast_tac eq_cs 1);
   493 qed "Diff_disjoint";
   494 Addsimps[Diff_disjoint];
   495 
   496 goal Set.thy "!!A. A<=B ==> A Un (B-A) = B";
   497 by (fast_tac eq_cs 1);
   498 qed "Diff_partition";
   499 
   500 goal Set.thy "!!A. [| A<=B; B<= C |] ==> (B - (C - A)) = (A :: 'a set)";
   501 by (fast_tac eq_cs 1);
   502 qed "double_diff";
   503 
   504 goal Set.thy "A - (B Un C) = (A-B) Int (A-C)";
   505 by (fast_tac eq_cs 1);
   506 qed "Diff_Un";
   507 
   508 goal Set.thy "A - (B Int C) = (A-B) Un (A-C)";
   509 by (fast_tac eq_cs 1);
   510 qed "Diff_Int";
   511 
   512 Addsimps[subset_UNIV, empty_subsetI, subset_refl];