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