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