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