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