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