src/CCL/Set.thy
author wenzelm
Sat May 15 22:15:57 2010 +0200 (2010-05-15)
changeset 36948 d2cdad45fd14
parent 35113 1a0c129bb2e0
child 38499 8f0cd11238a7
permissions -rw-r--r--
renamed Outer_Parse to Parse (in Scala);
wenzelm@17456
     1
header {* Extending FOL by a modified version of HOL set theory *}
wenzelm@17456
     2
wenzelm@17456
     3
theory Set
wenzelm@17456
     4
imports FOL
wenzelm@17456
     5
begin
clasohm@0
     6
wenzelm@3935
     7
global
wenzelm@3935
     8
wenzelm@17456
     9
typedecl 'a set
wenzelm@17456
    10
arities set :: ("term") "term"
clasohm@0
    11
clasohm@0
    12
consts
clasohm@0
    13
  Collect       :: "['a => o] => 'a set"                    (*comprehension*)
clasohm@0
    14
  Compl         :: "('a set) => 'a set"                     (*complement*)
wenzelm@24825
    15
  Int           :: "['a set, 'a set] => 'a set"         (infixl "Int" 70)
wenzelm@24825
    16
  Un            :: "['a set, 'a set] => 'a set"         (infixl "Un" 65)
wenzelm@17456
    17
  Union         :: "(('a set)set) => 'a set"                (*...of a set*)
wenzelm@17456
    18
  Inter         :: "(('a set)set) => 'a set"                (*...of a set*)
wenzelm@17456
    19
  UNION         :: "['a set, 'a => 'b set] => 'b set"       (*general*)
wenzelm@17456
    20
  INTER         :: "['a set, 'a => 'b set] => 'b set"       (*general*)
wenzelm@17456
    21
  Ball          :: "['a set, 'a => o] => o"                 (*bounded quants*)
wenzelm@17456
    22
  Bex           :: "['a set, 'a => o] => o"                 (*bounded quants*)
clasohm@0
    23
  mono          :: "['a set => 'b set] => o"                (*monotonicity*)
wenzelm@24825
    24
  mem           :: "['a, 'a set] => o"                  (infixl ":" 50) (*membership*)
wenzelm@24825
    25
  subset        :: "['a set, 'a set] => o"              (infixl "<=" 50)
clasohm@0
    26
  singleton     :: "'a => 'a set"                       ("{_}")
clasohm@0
    27
  empty         :: "'a set"                             ("{}")
clasohm@0
    28
wenzelm@3935
    29
syntax
wenzelm@35113
    30
  "_Coll"       :: "[idt, o] => 'a set"                 ("(1{_./ _})") (*collection*)
clasohm@0
    31
clasohm@0
    32
  (* Big Intersection / Union *)
clasohm@0
    33
wenzelm@35113
    34
  "_INTER"      :: "[idt, 'a set, 'b set] => 'b set"    ("(INT _:_./ _)" [0, 0, 0] 10)
wenzelm@35113
    35
  "_UNION"      :: "[idt, 'a set, 'b set] => 'b set"    ("(UN _:_./ _)" [0, 0, 0] 10)
clasohm@0
    36
clasohm@0
    37
  (* Bounded Quantifiers *)
clasohm@0
    38
wenzelm@35113
    39
  "_Ball"       :: "[idt, 'a set, o] => o"              ("(ALL _:_./ _)" [0, 0, 0] 10)
wenzelm@35113
    40
  "_Bex"        :: "[idt, 'a set, o] => o"              ("(EX _:_./ _)" [0, 0, 0] 10)
clasohm@0
    41
clasohm@0
    42
translations
wenzelm@35054
    43
  "{x. P}"      == "CONST Collect(%x. P)"
wenzelm@35054
    44
  "INT x:A. B"  == "CONST INTER(A, %x. B)"
wenzelm@35054
    45
  "UN x:A. B"   == "CONST UNION(A, %x. B)"
wenzelm@35054
    46
  "ALL x:A. P"  == "CONST Ball(A, %x. P)"
wenzelm@35054
    47
  "EX x:A. P"   == "CONST Bex(A, %x. P)"
clasohm@0
    48
wenzelm@3935
    49
local
clasohm@0
    50
wenzelm@17456
    51
axioms
wenzelm@17456
    52
  mem_Collect_iff:       "(a : {x. P(x)}) <-> P(a)"
wenzelm@17456
    53
  set_extension:         "A=B <-> (ALL x. x:A <-> x:B)"
clasohm@0
    54
wenzelm@17456
    55
defs
wenzelm@17456
    56
  Ball_def:      "Ball(A, P)  == ALL x. x:A --> P(x)"
wenzelm@17456
    57
  Bex_def:       "Bex(A, P)   == EX x. x:A & P(x)"
wenzelm@17456
    58
  mono_def:      "mono(f)     == (ALL A B. A <= B --> f(A) <= f(B))"
wenzelm@17456
    59
  subset_def:    "A <= B      == ALL x:A. x:B"
wenzelm@17456
    60
  singleton_def: "{a}         == {x. x=a}"
wenzelm@17456
    61
  empty_def:     "{}          == {x. False}"
wenzelm@17456
    62
  Un_def:        "A Un B      == {x. x:A | x:B}"
wenzelm@17456
    63
  Int_def:       "A Int B     == {x. x:A & x:B}"
wenzelm@17456
    64
  Compl_def:     "Compl(A)    == {x. ~x:A}"
wenzelm@17456
    65
  INTER_def:     "INTER(A, B) == {y. ALL x:A. y: B(x)}"
wenzelm@17456
    66
  UNION_def:     "UNION(A, B) == {y. EX x:A. y: B(x)}"
wenzelm@17456
    67
  Inter_def:     "Inter(S)    == (INT x:S. x)"
wenzelm@17456
    68
  Union_def:     "Union(S)    == (UN x:S. x)"
wenzelm@17456
    69
wenzelm@20140
    70
wenzelm@20140
    71
lemma CollectI: "[| P(a) |] ==> a : {x. P(x)}"
wenzelm@20140
    72
  apply (rule mem_Collect_iff [THEN iffD2])
wenzelm@20140
    73
  apply assumption
wenzelm@20140
    74
  done
wenzelm@20140
    75
wenzelm@20140
    76
lemma CollectD: "[| a : {x. P(x)} |] ==> P(a)"
wenzelm@20140
    77
  apply (erule mem_Collect_iff [THEN iffD1])
wenzelm@20140
    78
  done
wenzelm@20140
    79
wenzelm@20140
    80
lemmas CollectE = CollectD [elim_format]
wenzelm@20140
    81
wenzelm@20140
    82
lemma set_ext: "[| !!x. x:A <-> x:B |] ==> A = B"
wenzelm@20140
    83
  apply (rule set_extension [THEN iffD2])
wenzelm@20140
    84
  apply simp
wenzelm@20140
    85
  done
wenzelm@20140
    86
wenzelm@20140
    87
wenzelm@20140
    88
subsection {* Bounded quantifiers *}
wenzelm@20140
    89
wenzelm@20140
    90
lemma ballI: "[| !!x. x:A ==> P(x) |] ==> ALL x:A. P(x)"
wenzelm@20140
    91
  by (simp add: Ball_def)
wenzelm@20140
    92
wenzelm@20140
    93
lemma bspec: "[| ALL x:A. P(x);  x:A |] ==> P(x)"
wenzelm@20140
    94
  by (simp add: Ball_def)
wenzelm@20140
    95
wenzelm@20140
    96
lemma ballE: "[| ALL x:A. P(x);  P(x) ==> Q;  ~ x:A ==> Q |] ==> Q"
wenzelm@20140
    97
  unfolding Ball_def by blast
wenzelm@20140
    98
wenzelm@20140
    99
lemma bexI: "[| P(x);  x:A |] ==> EX x:A. P(x)"
wenzelm@20140
   100
  unfolding Bex_def by blast
wenzelm@20140
   101
wenzelm@20140
   102
lemma bexCI: "[| EX x:A. ~P(x) ==> P(a);  a:A |] ==> EX x:A. P(x)"
wenzelm@20140
   103
  unfolding Bex_def by blast
wenzelm@20140
   104
wenzelm@20140
   105
lemma bexE: "[| EX x:A. P(x);  !!x. [| x:A; P(x) |] ==> Q  |] ==> Q"
wenzelm@20140
   106
  unfolding Bex_def by blast
wenzelm@20140
   107
wenzelm@20140
   108
(*Trival rewrite rule;   (! x:A.P)=P holds only if A is nonempty!*)
wenzelm@20140
   109
lemma ball_rew: "(ALL x:A. True) <-> True"
wenzelm@20140
   110
  by (blast intro: ballI)
wenzelm@20140
   111
wenzelm@20140
   112
wenzelm@20140
   113
subsection {* Congruence rules *}
wenzelm@20140
   114
wenzelm@20140
   115
lemma ball_cong:
wenzelm@20140
   116
  "[| A=A';  !!x. x:A' ==> P(x) <-> P'(x) |] ==>
wenzelm@20140
   117
    (ALL x:A. P(x)) <-> (ALL x:A'. P'(x))"
wenzelm@20140
   118
  by (blast intro: ballI elim: ballE)
wenzelm@20140
   119
wenzelm@20140
   120
lemma bex_cong:
wenzelm@20140
   121
  "[| A=A';  !!x. x:A' ==> P(x) <-> P'(x) |] ==>
wenzelm@20140
   122
    (EX x:A. P(x)) <-> (EX x:A'. P'(x))"
wenzelm@20140
   123
  by (blast intro: bexI elim: bexE)
wenzelm@20140
   124
wenzelm@20140
   125
wenzelm@20140
   126
subsection {* Rules for subsets *}
wenzelm@20140
   127
wenzelm@20140
   128
lemma subsetI: "(!!x. x:A ==> x:B) ==> A <= B"
wenzelm@20140
   129
  unfolding subset_def by (blast intro: ballI)
wenzelm@20140
   130
wenzelm@20140
   131
(*Rule in Modus Ponens style*)
wenzelm@20140
   132
lemma subsetD: "[| A <= B;  c:A |] ==> c:B"
wenzelm@20140
   133
  unfolding subset_def by (blast elim: ballE)
wenzelm@20140
   134
wenzelm@20140
   135
(*Classical elimination rule*)
wenzelm@20140
   136
lemma subsetCE: "[| A <= B;  ~(c:A) ==> P;  c:B ==> P |] ==> P"
wenzelm@20140
   137
  by (blast dest: subsetD)
wenzelm@20140
   138
wenzelm@20140
   139
lemma subset_refl: "A <= A"
wenzelm@20140
   140
  by (blast intro: subsetI)
wenzelm@20140
   141
wenzelm@20140
   142
lemma subset_trans: "[| A<=B;  B<=C |] ==> A<=C"
wenzelm@20140
   143
  by (blast intro: subsetI dest: subsetD)
wenzelm@20140
   144
wenzelm@20140
   145
wenzelm@20140
   146
subsection {* Rules for equality *}
wenzelm@20140
   147
wenzelm@20140
   148
(*Anti-symmetry of the subset relation*)
wenzelm@20140
   149
lemma subset_antisym: "[| A <= B;  B <= A |] ==> A = B"
wenzelm@20140
   150
  by (blast intro: set_ext dest: subsetD)
wenzelm@20140
   151
wenzelm@20140
   152
lemmas equalityI = subset_antisym
wenzelm@20140
   153
wenzelm@20140
   154
(* Equality rules from ZF set theory -- are they appropriate here? *)
wenzelm@20140
   155
lemma equalityD1: "A = B ==> A<=B"
wenzelm@20140
   156
  and equalityD2: "A = B ==> B<=A"
wenzelm@20140
   157
  by (simp_all add: subset_refl)
wenzelm@20140
   158
wenzelm@20140
   159
lemma equalityE: "[| A = B;  [| A<=B; B<=A |] ==> P |]  ==>  P"
wenzelm@20140
   160
  by (simp add: subset_refl)
wenzelm@20140
   161
wenzelm@20140
   162
lemma equalityCE:
wenzelm@20140
   163
    "[| A = B;  [| c:A; c:B |] ==> P;  [| ~ c:A; ~ c:B |] ==> P |]  ==>  P"
wenzelm@20140
   164
  by (blast elim: equalityE subsetCE)
wenzelm@20140
   165
wenzelm@20140
   166
lemma trivial_set: "{x. x:A} = A"
wenzelm@20140
   167
  by (blast intro: equalityI subsetI CollectI dest: CollectD)
wenzelm@20140
   168
wenzelm@20140
   169
wenzelm@20140
   170
subsection {* Rules for binary union *}
wenzelm@20140
   171
wenzelm@20140
   172
lemma UnI1: "c:A ==> c : A Un B"
wenzelm@20140
   173
  and UnI2: "c:B ==> c : A Un B"
wenzelm@20140
   174
  unfolding Un_def by (blast intro: CollectI)+
wenzelm@20140
   175
wenzelm@20140
   176
(*Classical introduction rule: no commitment to A vs B*)
wenzelm@20140
   177
lemma UnCI: "(~c:B ==> c:A) ==> c : A Un B"
wenzelm@20140
   178
  by (blast intro: UnI1 UnI2)
wenzelm@20140
   179
wenzelm@20140
   180
lemma UnE: "[| c : A Un B;  c:A ==> P;  c:B ==> P |] ==> P"
wenzelm@20140
   181
  unfolding Un_def by (blast dest: CollectD)
wenzelm@20140
   182
wenzelm@20140
   183
wenzelm@20140
   184
subsection {* Rules for small intersection *}
wenzelm@20140
   185
wenzelm@20140
   186
lemma IntI: "[| c:A;  c:B |] ==> c : A Int B"
wenzelm@20140
   187
  unfolding Int_def by (blast intro: CollectI)
wenzelm@20140
   188
wenzelm@20140
   189
lemma IntD1: "c : A Int B ==> c:A"
wenzelm@20140
   190
  and IntD2: "c : A Int B ==> c:B"
wenzelm@20140
   191
  unfolding Int_def by (blast dest: CollectD)+
wenzelm@20140
   192
wenzelm@20140
   193
lemma IntE: "[| c : A Int B;  [| c:A; c:B |] ==> P |] ==> P"
wenzelm@20140
   194
  by (blast dest: IntD1 IntD2)
wenzelm@20140
   195
wenzelm@20140
   196
wenzelm@20140
   197
subsection {* Rules for set complement *}
wenzelm@20140
   198
wenzelm@20140
   199
lemma ComplI: "[| c:A ==> False |] ==> c : Compl(A)"
wenzelm@20140
   200
  unfolding Compl_def by (blast intro: CollectI)
wenzelm@20140
   201
wenzelm@20140
   202
(*This form, with negated conclusion, works well with the Classical prover.
wenzelm@20140
   203
  Negated assumptions behave like formulae on the right side of the notional
wenzelm@20140
   204
  turnstile...*)
wenzelm@20140
   205
lemma ComplD: "[| c : Compl(A) |] ==> ~c:A"
wenzelm@20140
   206
  unfolding Compl_def by (blast dest: CollectD)
wenzelm@20140
   207
wenzelm@20140
   208
lemmas ComplE = ComplD [elim_format]
wenzelm@20140
   209
wenzelm@20140
   210
wenzelm@20140
   211
subsection {* Empty sets *}
wenzelm@20140
   212
wenzelm@20140
   213
lemma empty_eq: "{x. False} = {}"
wenzelm@20140
   214
  by (simp add: empty_def)
wenzelm@20140
   215
wenzelm@20140
   216
lemma emptyD: "a : {} ==> P"
wenzelm@20140
   217
  unfolding empty_def by (blast dest: CollectD)
wenzelm@20140
   218
wenzelm@20140
   219
lemmas emptyE = emptyD [elim_format]
wenzelm@20140
   220
wenzelm@20140
   221
lemma not_emptyD:
wenzelm@20140
   222
  assumes "~ A={}"
wenzelm@20140
   223
  shows "EX x. x:A"
wenzelm@20140
   224
proof -
wenzelm@20140
   225
  have "\<not> (EX x. x:A) \<Longrightarrow> A = {}"
wenzelm@20140
   226
    by (rule equalityI) (blast intro!: subsetI elim!: emptyD)+
wenzelm@20140
   227
  with prems show ?thesis by blast
wenzelm@20140
   228
qed
wenzelm@20140
   229
wenzelm@20140
   230
wenzelm@20140
   231
subsection {* Singleton sets *}
wenzelm@20140
   232
wenzelm@20140
   233
lemma singletonI: "a : {a}"
wenzelm@20140
   234
  unfolding singleton_def by (blast intro: CollectI)
wenzelm@20140
   235
wenzelm@20140
   236
lemma singletonD: "b : {a} ==> b=a"
wenzelm@20140
   237
  unfolding singleton_def by (blast dest: CollectD)
wenzelm@20140
   238
wenzelm@20140
   239
lemmas singletonE = singletonD [elim_format]
wenzelm@20140
   240
wenzelm@20140
   241
wenzelm@20140
   242
subsection {* Unions of families *}
wenzelm@20140
   243
wenzelm@20140
   244
(*The order of the premises presupposes that A is rigid; b may be flexible*)
wenzelm@20140
   245
lemma UN_I: "[| a:A;  b: B(a) |] ==> b: (UN x:A. B(x))"
wenzelm@20140
   246
  unfolding UNION_def by (blast intro: bexI CollectI)
wenzelm@20140
   247
wenzelm@20140
   248
lemma UN_E: "[| b : (UN x:A. B(x));  !!x.[| x:A;  b: B(x) |] ==> R |] ==> R"
wenzelm@20140
   249
  unfolding UNION_def by (blast dest: CollectD elim: bexE)
wenzelm@20140
   250
wenzelm@20140
   251
lemma UN_cong:
wenzelm@20140
   252
  "[| A=B;  !!x. x:B ==> C(x) = D(x) |] ==>
wenzelm@20140
   253
    (UN x:A. C(x)) = (UN x:B. D(x))"
wenzelm@20140
   254
  by (simp add: UNION_def cong: bex_cong)
wenzelm@20140
   255
wenzelm@20140
   256
wenzelm@20140
   257
subsection {* Intersections of families *}
wenzelm@20140
   258
wenzelm@20140
   259
lemma INT_I: "(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))"
wenzelm@20140
   260
  unfolding INTER_def by (blast intro: CollectI ballI)
wenzelm@20140
   261
wenzelm@20140
   262
lemma INT_D: "[| b : (INT x:A. B(x));  a:A |] ==> b: B(a)"
wenzelm@20140
   263
  unfolding INTER_def by (blast dest: CollectD bspec)
wenzelm@20140
   264
wenzelm@20140
   265
(*"Classical" elimination rule -- does not require proving X:C *)
wenzelm@20140
   266
lemma INT_E: "[| b : (INT x:A. B(x));  b: B(a) ==> R;  ~ a:A ==> R |] ==> R"
wenzelm@20140
   267
  unfolding INTER_def by (blast dest: CollectD bspec)
wenzelm@20140
   268
wenzelm@20140
   269
lemma INT_cong:
wenzelm@20140
   270
  "[| A=B;  !!x. x:B ==> C(x) = D(x) |] ==>
wenzelm@20140
   271
    (INT x:A. C(x)) = (INT x:B. D(x))"
wenzelm@20140
   272
  by (simp add: INTER_def cong: ball_cong)
wenzelm@20140
   273
wenzelm@20140
   274
wenzelm@20140
   275
subsection {* Rules for Unions *}
wenzelm@20140
   276
wenzelm@20140
   277
(*The order of the premises presupposes that C is rigid; A may be flexible*)
wenzelm@20140
   278
lemma UnionI: "[| X:C;  A:X |] ==> A : Union(C)"
wenzelm@20140
   279
  unfolding Union_def by (blast intro: UN_I)
wenzelm@20140
   280
wenzelm@20140
   281
lemma UnionE: "[| A : Union(C);  !!X.[| A:X;  X:C |] ==> R |] ==> R"
wenzelm@20140
   282
  unfolding Union_def by (blast elim: UN_E)
wenzelm@20140
   283
wenzelm@20140
   284
wenzelm@20140
   285
subsection {* Rules for Inter *}
wenzelm@20140
   286
wenzelm@20140
   287
lemma InterI: "[| !!X. X:C ==> A:X |] ==> A : Inter(C)"
wenzelm@20140
   288
  unfolding Inter_def by (blast intro: INT_I)
wenzelm@20140
   289
wenzelm@20140
   290
(*A "destruct" rule -- every X in C contains A as an element, but
wenzelm@20140
   291
  A:X can hold when X:C does not!  This rule is analogous to "spec". *)
wenzelm@20140
   292
lemma InterD: "[| A : Inter(C);  X:C |] ==> A:X"
wenzelm@20140
   293
  unfolding Inter_def by (blast dest: INT_D)
wenzelm@20140
   294
wenzelm@20140
   295
(*"Classical" elimination rule -- does not require proving X:C *)
wenzelm@20140
   296
lemma InterE: "[| A : Inter(C);  A:X ==> R;  ~ X:C ==> R |] ==> R"
wenzelm@20140
   297
  unfolding Inter_def by (blast elim: INT_E)
wenzelm@20140
   298
wenzelm@20140
   299
wenzelm@20140
   300
section {* Derived rules involving subsets; Union and Intersection as lattice operations *}
wenzelm@20140
   301
wenzelm@20140
   302
subsection {* Big Union -- least upper bound of a set *}
wenzelm@20140
   303
wenzelm@20140
   304
lemma Union_upper: "B:A ==> B <= Union(A)"
wenzelm@20140
   305
  by (blast intro: subsetI UnionI)
wenzelm@20140
   306
wenzelm@20140
   307
lemma Union_least: "[| !!X. X:A ==> X<=C |] ==> Union(A) <= C"
wenzelm@20140
   308
  by (blast intro: subsetI dest: subsetD elim: UnionE)
wenzelm@20140
   309
wenzelm@20140
   310
wenzelm@20140
   311
subsection {* Big Intersection -- greatest lower bound of a set *}
wenzelm@20140
   312
wenzelm@20140
   313
lemma Inter_lower: "B:A ==> Inter(A) <= B"
wenzelm@20140
   314
  by (blast intro: subsetI dest: InterD)
wenzelm@20140
   315
wenzelm@20140
   316
lemma Inter_greatest: "[| !!X. X:A ==> C<=X |] ==> C <= Inter(A)"
wenzelm@20140
   317
  by (blast intro: subsetI InterI dest: subsetD)
wenzelm@20140
   318
wenzelm@20140
   319
wenzelm@20140
   320
subsection {* Finite Union -- the least upper bound of 2 sets *}
wenzelm@20140
   321
wenzelm@20140
   322
lemma Un_upper1: "A <= A Un B"
wenzelm@20140
   323
  by (blast intro: subsetI UnI1)
wenzelm@20140
   324
wenzelm@20140
   325
lemma Un_upper2: "B <= A Un B"
wenzelm@20140
   326
  by (blast intro: subsetI UnI2)
wenzelm@20140
   327
wenzelm@20140
   328
lemma Un_least: "[| A<=C;  B<=C |] ==> A Un B <= C"
wenzelm@20140
   329
  by (blast intro: subsetI elim: UnE dest: subsetD)
wenzelm@20140
   330
wenzelm@20140
   331
wenzelm@20140
   332
subsection {* Finite Intersection -- the greatest lower bound of 2 sets *}
wenzelm@20140
   333
wenzelm@20140
   334
lemma Int_lower1: "A Int B <= A"
wenzelm@20140
   335
  by (blast intro: subsetI elim: IntE)
wenzelm@20140
   336
wenzelm@20140
   337
lemma Int_lower2: "A Int B <= B"
wenzelm@20140
   338
  by (blast intro: subsetI elim: IntE)
wenzelm@20140
   339
wenzelm@20140
   340
lemma Int_greatest: "[| C<=A;  C<=B |] ==> C <= A Int B"
wenzelm@20140
   341
  by (blast intro: subsetI IntI dest: subsetD)
wenzelm@20140
   342
wenzelm@20140
   343
wenzelm@20140
   344
subsection {* Monotonicity *}
wenzelm@20140
   345
wenzelm@20140
   346
lemma monoI: "[| !!A B. A <= B ==> f(A) <= f(B) |] ==> mono(f)"
wenzelm@20140
   347
  unfolding mono_def by blast
wenzelm@20140
   348
wenzelm@20140
   349
lemma monoD: "[| mono(f);  A <= B |] ==> f(A) <= f(B)"
wenzelm@20140
   350
  unfolding mono_def by blast
wenzelm@20140
   351
wenzelm@20140
   352
lemma mono_Un: "mono(f) ==> f(A) Un f(B) <= f(A Un B)"
wenzelm@20140
   353
  by (blast intro: Un_least dest: monoD intro: Un_upper1 Un_upper2)
wenzelm@20140
   354
wenzelm@20140
   355
lemma mono_Int: "mono(f) ==> f(A Int B) <= f(A) Int f(B)"
wenzelm@20140
   356
  by (blast intro: Int_greatest dest: monoD intro: Int_lower1 Int_lower2)
wenzelm@20140
   357
wenzelm@20140
   358
wenzelm@20140
   359
subsection {* Automated reasoning setup *}
wenzelm@20140
   360
wenzelm@20140
   361
lemmas [intro!] = ballI subsetI InterI INT_I CollectI ComplI IntI UnCI singletonI
wenzelm@20140
   362
  and [intro] = bexI UnionI UN_I
wenzelm@20140
   363
  and [elim!] = bexE UnionE UN_E CollectE ComplE IntE UnE emptyE singletonE
wenzelm@20140
   364
  and [elim] = ballE InterD InterE INT_D INT_E subsetD subsetCE
wenzelm@20140
   365
wenzelm@20140
   366
lemma mem_rews:
wenzelm@20140
   367
  "(a : A Un B)   <->  (a:A | a:B)"
wenzelm@20140
   368
  "(a : A Int B)  <->  (a:A & a:B)"
wenzelm@20140
   369
  "(a : Compl(B)) <->  (~a:B)"
wenzelm@20140
   370
  "(a : {b})      <->  (a=b)"
wenzelm@20140
   371
  "(a : {})       <->   False"
wenzelm@20140
   372
  "(a : {x. P(x)}) <->  P(a)"
wenzelm@20140
   373
  by blast+
wenzelm@20140
   374
wenzelm@20140
   375
lemmas [simp] = trivial_set empty_eq mem_rews
wenzelm@20140
   376
  and [cong] = ball_cong bex_cong INT_cong UN_cong
wenzelm@20140
   377
wenzelm@20140
   378
wenzelm@20140
   379
section {* Equalities involving union, intersection, inclusion, etc. *}
wenzelm@20140
   380
wenzelm@20140
   381
subsection {* Binary Intersection *}
wenzelm@20140
   382
wenzelm@20140
   383
lemma Int_absorb: "A Int A = A"
wenzelm@20140
   384
  by (blast intro: equalityI)
wenzelm@20140
   385
wenzelm@20140
   386
lemma Int_commute: "A Int B  =  B Int A"
wenzelm@20140
   387
  by (blast intro: equalityI)
wenzelm@20140
   388
wenzelm@20140
   389
lemma Int_assoc: "(A Int B) Int C  =  A Int (B Int C)"
wenzelm@20140
   390
  by (blast intro: equalityI)
wenzelm@20140
   391
wenzelm@20140
   392
lemma Int_Un_distrib: "(A Un B) Int C  =  (A Int C) Un (B Int C)"
wenzelm@20140
   393
  by (blast intro: equalityI)
wenzelm@20140
   394
wenzelm@20140
   395
lemma subset_Int_eq: "(A<=B) <-> (A Int B = A)"
wenzelm@20140
   396
  by (blast intro: equalityI elim: equalityE)
wenzelm@20140
   397
wenzelm@20140
   398
wenzelm@20140
   399
subsection {* Binary Union *}
wenzelm@20140
   400
wenzelm@20140
   401
lemma Un_absorb: "A Un A = A"
wenzelm@20140
   402
  by (blast intro: equalityI)
wenzelm@20140
   403
wenzelm@20140
   404
lemma Un_commute: "A Un B  =  B Un A"
wenzelm@20140
   405
  by (blast intro: equalityI)
wenzelm@20140
   406
wenzelm@20140
   407
lemma Un_assoc: "(A Un B) Un C  =  A Un (B Un C)"
wenzelm@20140
   408
  by (blast intro: equalityI)
wenzelm@20140
   409
wenzelm@20140
   410
lemma Un_Int_distrib: "(A Int B) Un C  =  (A Un C) Int (B Un C)"
wenzelm@20140
   411
  by (blast intro: equalityI)
wenzelm@20140
   412
wenzelm@20140
   413
lemma Un_Int_crazy:
wenzelm@20140
   414
    "(A Int B) Un (B Int C) Un (C Int A) = (A Un B) Int (B Un C) Int (C Un A)"
wenzelm@20140
   415
  by (blast intro: equalityI)
wenzelm@20140
   416
wenzelm@20140
   417
lemma subset_Un_eq: "(A<=B) <-> (A Un B = B)"
wenzelm@20140
   418
  by (blast intro: equalityI elim: equalityE)
wenzelm@20140
   419
wenzelm@20140
   420
wenzelm@20140
   421
subsection {* Simple properties of @{text "Compl"} -- complement of a set *}
wenzelm@20140
   422
wenzelm@20140
   423
lemma Compl_disjoint: "A Int Compl(A) = {x. False}"
wenzelm@20140
   424
  by (blast intro: equalityI)
wenzelm@20140
   425
wenzelm@20140
   426
lemma Compl_partition: "A Un Compl(A) = {x. True}"
wenzelm@20140
   427
  by (blast intro: equalityI)
wenzelm@20140
   428
wenzelm@20140
   429
lemma double_complement: "Compl(Compl(A)) = A"
wenzelm@20140
   430
  by (blast intro: equalityI)
wenzelm@20140
   431
wenzelm@20140
   432
lemma Compl_Un: "Compl(A Un B) = Compl(A) Int Compl(B)"
wenzelm@20140
   433
  by (blast intro: equalityI)
wenzelm@20140
   434
wenzelm@20140
   435
lemma Compl_Int: "Compl(A Int B) = Compl(A) Un Compl(B)"
wenzelm@20140
   436
  by (blast intro: equalityI)
wenzelm@20140
   437
wenzelm@20140
   438
lemma Compl_UN: "Compl(UN x:A. B(x)) = (INT x:A. Compl(B(x)))"
wenzelm@20140
   439
  by (blast intro: equalityI)
wenzelm@20140
   440
wenzelm@20140
   441
lemma Compl_INT: "Compl(INT x:A. B(x)) = (UN x:A. Compl(B(x)))"
wenzelm@20140
   442
  by (blast intro: equalityI)
wenzelm@20140
   443
wenzelm@20140
   444
(*Halmos, Naive Set Theory, page 16.*)
wenzelm@20140
   445
lemma Un_Int_assoc_eq: "((A Int B) Un C = A Int (B Un C)) <-> (C<=A)"
wenzelm@20140
   446
  by (blast intro: equalityI elim: equalityE)
wenzelm@20140
   447
wenzelm@20140
   448
wenzelm@20140
   449
subsection {* Big Union and Intersection *}
wenzelm@20140
   450
wenzelm@20140
   451
lemma Union_Un_distrib: "Union(A Un B) = Union(A) Un Union(B)"
wenzelm@20140
   452
  by (blast intro: equalityI)
wenzelm@20140
   453
wenzelm@20140
   454
lemma Union_disjoint:
wenzelm@20140
   455
    "(Union(C) Int A = {x. False}) <-> (ALL B:C. B Int A = {x. False})"
wenzelm@20140
   456
  by (blast intro: equalityI elim: equalityE)
wenzelm@20140
   457
wenzelm@20140
   458
lemma Inter_Un_distrib: "Inter(A Un B) = Inter(A) Int Inter(B)"
wenzelm@20140
   459
  by (blast intro: equalityI)
wenzelm@20140
   460
wenzelm@20140
   461
wenzelm@20140
   462
subsection {* Unions and Intersections of Families *}
wenzelm@20140
   463
wenzelm@20140
   464
lemma UN_eq: "(UN x:A. B(x)) = Union({Y. EX x:A. Y=B(x)})"
wenzelm@20140
   465
  by (blast intro: equalityI)
wenzelm@20140
   466
wenzelm@20140
   467
(*Look: it has an EXISTENTIAL quantifier*)
wenzelm@20140
   468
lemma INT_eq: "(INT x:A. B(x)) = Inter({Y. EX x:A. Y=B(x)})"
wenzelm@20140
   469
  by (blast intro: equalityI)
wenzelm@20140
   470
wenzelm@20140
   471
lemma Int_Union_image: "A Int Union(B) = (UN C:B. A Int C)"
wenzelm@20140
   472
  by (blast intro: equalityI)
wenzelm@20140
   473
wenzelm@20140
   474
lemma Un_Inter_image: "A Un Inter(B) = (INT C:B. A Un C)"
wenzelm@20140
   475
  by (blast intro: equalityI)
wenzelm@20140
   476
wenzelm@20140
   477
wenzelm@20140
   478
section {* Monotonicity of various operations *}
wenzelm@20140
   479
wenzelm@20140
   480
lemma Union_mono: "A<=B ==> Union(A) <= Union(B)"
wenzelm@20140
   481
  by blast
wenzelm@20140
   482
wenzelm@20140
   483
lemma Inter_anti_mono: "[| B<=A |] ==> Inter(A) <= Inter(B)"
wenzelm@20140
   484
  by blast
wenzelm@20140
   485
wenzelm@20140
   486
lemma UN_mono:
wenzelm@20140
   487
  "[| A<=B;  !!x. x:A ==> f(x)<=g(x) |] ==>  
wenzelm@20140
   488
    (UN x:A. f(x)) <= (UN x:B. g(x))"
wenzelm@20140
   489
  by blast
wenzelm@20140
   490
wenzelm@20140
   491
lemma INT_anti_mono:
wenzelm@20140
   492
  "[| B<=A;  !!x. x:A ==> f(x)<=g(x) |] ==>  
wenzelm@20140
   493
    (INT x:A. f(x)) <= (INT x:A. g(x))"
wenzelm@20140
   494
  by blast
wenzelm@20140
   495
wenzelm@20140
   496
lemma Un_mono: "[| A<=C;  B<=D |] ==> A Un B <= C Un D"
wenzelm@20140
   497
  by blast
wenzelm@20140
   498
wenzelm@20140
   499
lemma Int_mono: "[| A<=C;  B<=D |] ==> A Int B <= C Int D"
wenzelm@20140
   500
  by blast
wenzelm@20140
   501
wenzelm@20140
   502
lemma Compl_anti_mono: "[| A<=B |] ==> Compl(B) <= Compl(A)"
wenzelm@20140
   503
  by blast
clasohm@0
   504
clasohm@0
   505
end