src/HOL/Set.thy
author haftmann
Sat Mar 07 15:20:32 2009 +0100 (2009-03-07)
changeset 30352 047f183c43b0
parent 30304 d8e4cd2ac2a1
child 30531 ab3d61baf66a
permissions -rw-r--r--
restructured theory Set.thy
clasohm@923
     1
(*  Title:      HOL/Set.thy
wenzelm@12257
     2
    Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel
clasohm@923
     3
*)
clasohm@923
     4
wenzelm@11979
     5
header {* Set theory for higher-order logic *}
wenzelm@11979
     6
nipkow@15131
     7
theory Set
haftmann@30304
     8
imports Lattices
nipkow@15131
     9
begin
wenzelm@11979
    10
haftmann@30352
    11
subsection {* Basic operations *}
haftmann@30352
    12
haftmann@30352
    13
subsubsection {* Comprehension and membership *}
haftmann@30352
    14
wenzelm@11979
    15
text {* A set in HOL is simply a predicate. *}
clasohm@923
    16
wenzelm@3947
    17
global
wenzelm@3947
    18
berghofe@26800
    19
types 'a set = "'a => bool"
wenzelm@3820
    20
clasohm@923
    21
consts
haftmann@30352
    22
  Collect :: "('a \<Rightarrow> bool) \<Rightarrow> 'a set"
haftmann@30352
    23
  "op :" :: "'a => 'a set => bool"
haftmann@30304
    24
haftmann@30304
    25
local
wenzelm@19656
    26
haftmann@30352
    27
syntax
haftmann@30352
    28
  "@Coll"       :: "pttrn => bool => 'a set"              ("(1{_./ _})")
haftmann@30352
    29
haftmann@30352
    30
translations
haftmann@30352
    31
  "{x. P}"      == "Collect (%x. P)"
haftmann@30352
    32
wenzelm@21210
    33
notation
wenzelm@21404
    34
  "op :"  ("op :") and
wenzelm@19656
    35
  "op :"  ("(_/ : _)" [50, 51] 50)
wenzelm@11979
    36
wenzelm@19656
    37
abbreviation
wenzelm@21404
    38
  "not_mem x A == ~ (x : A)" -- "non-membership"
wenzelm@19656
    39
wenzelm@21210
    40
notation
wenzelm@21404
    41
  not_mem  ("op ~:") and
wenzelm@19656
    42
  not_mem  ("(_/ ~: _)" [50, 51] 50)
wenzelm@19656
    43
wenzelm@21210
    44
notation (xsymbols)
wenzelm@21404
    45
  "op :"  ("op \<in>") and
wenzelm@21404
    46
  "op :"  ("(_/ \<in> _)" [50, 51] 50) and
wenzelm@21404
    47
  not_mem  ("op \<notin>") and
haftmann@30304
    48
  not_mem  ("(_/ \<notin> _)" [50, 51] 50)
wenzelm@19656
    49
wenzelm@21210
    50
notation (HTML output)
wenzelm@21404
    51
  "op :"  ("op \<in>") and
wenzelm@21404
    52
  "op :"  ("(_/ \<in> _)" [50, 51] 50) and
wenzelm@21404
    53
  not_mem  ("op \<notin>") and
wenzelm@19656
    54
  not_mem  ("(_/ \<notin> _)" [50, 51] 50)
wenzelm@19656
    55
haftmann@30352
    56
defs
haftmann@30352
    57
  Collect_def [code]: "Collect P \<equiv> P"
haftmann@30352
    58
  mem_def [code]: "x \<in> S \<equiv> S x"
haftmann@30352
    59
haftmann@30352
    60
text {* Relating predicates and sets *}
haftmann@30352
    61
haftmann@30352
    62
lemma mem_Collect_eq [iff]: "(a : {x. P(x)}) = P(a)"
haftmann@30352
    63
  by (simp add: Collect_def mem_def)
haftmann@30352
    64
haftmann@30352
    65
lemma Collect_mem_eq [simp]: "{x. x:A} = A"
haftmann@30352
    66
  by (simp add: Collect_def mem_def)
haftmann@30352
    67
haftmann@30352
    68
lemma CollectI: "P(a) ==> a : {x. P(x)}"
haftmann@30352
    69
  by simp
haftmann@30352
    70
haftmann@30352
    71
lemma CollectD: "a : {x. P(x)} ==> P(a)"
haftmann@30352
    72
  by simp
haftmann@30352
    73
haftmann@30352
    74
lemma Collect_cong: "(!!x. P x = Q x) ==> {x. P(x)} = {x. Q(x)}"
haftmann@30352
    75
  by simp
haftmann@30352
    76
haftmann@30352
    77
lemmas CollectE = CollectD [elim_format]
haftmann@30352
    78
haftmann@30352
    79
lemma set_ext: assumes prem: "(!!x. (x:A) = (x:B))" shows "A = B"
haftmann@30352
    80
  apply (rule prem [THEN ext, THEN arg_cong, THEN box_equals])
haftmann@30352
    81
   apply (rule Collect_mem_eq)
haftmann@30352
    82
  apply (rule Collect_mem_eq)
haftmann@30352
    83
  done
haftmann@30352
    84
haftmann@30352
    85
(* Due to Brian Huffman *)
haftmann@30352
    86
lemma expand_set_eq: "(A = B) = (ALL x. (x:A) = (x:B))"
haftmann@30352
    87
by(auto intro:set_ext)
haftmann@30352
    88
haftmann@30352
    89
lemma equalityCE [elim]:
haftmann@30352
    90
    "A = B ==> (c \<in> A ==> c \<in> B ==> P) ==> (c \<notin> A ==> c \<notin> B ==> P) ==> P"
haftmann@30352
    91
  by blast
haftmann@30352
    92
haftmann@30352
    93
lemma eqset_imp_iff: "A = B ==> (x : A) = (x : B)"
haftmann@30352
    94
  by simp
haftmann@30352
    95
haftmann@30352
    96
lemma eqelem_imp_iff: "x = y ==> (x : A) = (y : A)"
haftmann@30352
    97
  by simp
haftmann@30352
    98
haftmann@30352
    99
haftmann@30352
   100
subsubsection {* Subset relation, empty and universal set *}
wenzelm@2261
   101
haftmann@21333
   102
abbreviation
wenzelm@21404
   103
  subset :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" where
haftmann@21819
   104
  "subset \<equiv> less"
wenzelm@21404
   105
wenzelm@21404
   106
abbreviation
wenzelm@21404
   107
  subset_eq :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" where
haftmann@21819
   108
  "subset_eq \<equiv> less_eq"
haftmann@21333
   109
haftmann@21333
   110
notation (output)
wenzelm@21404
   111
  subset  ("op <") and
wenzelm@21404
   112
  subset  ("(_/ < _)" [50, 51] 50) and
wenzelm@21404
   113
  subset_eq  ("op <=") and
haftmann@21333
   114
  subset_eq  ("(_/ <= _)" [50, 51] 50)
haftmann@21333
   115
haftmann@21333
   116
notation (xsymbols)
wenzelm@21404
   117
  subset  ("op \<subset>") and
wenzelm@21404
   118
  subset  ("(_/ \<subset> _)" [50, 51] 50) and
wenzelm@21404
   119
  subset_eq  ("op \<subseteq>") and
haftmann@21333
   120
  subset_eq  ("(_/ \<subseteq> _)" [50, 51] 50)
haftmann@21333
   121
haftmann@21333
   122
notation (HTML output)
wenzelm@21404
   123
  subset  ("op \<subset>") and
wenzelm@21404
   124
  subset  ("(_/ \<subset> _)" [50, 51] 50) and
wenzelm@21404
   125
  subset_eq  ("op \<subseteq>") and
haftmann@21333
   126
  subset_eq  ("(_/ \<subseteq> _)" [50, 51] 50)
haftmann@21333
   127
haftmann@21333
   128
abbreviation (input)
haftmann@21819
   129
  supset :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" where
haftmann@21819
   130
  "supset \<equiv> greater"
wenzelm@21404
   131
wenzelm@21404
   132
abbreviation (input)
haftmann@21819
   133
  supset_eq :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" where
haftmann@21819
   134
  "supset_eq \<equiv> greater_eq"
haftmann@21819
   135
haftmann@21819
   136
notation (xsymbols)
haftmann@21819
   137
  supset  ("op \<supset>") and
haftmann@21819
   138
  supset  ("(_/ \<supset> _)" [50, 51] 50) and
haftmann@21819
   139
  supset_eq  ("op \<supseteq>") and
haftmann@21819
   140
  supset_eq  ("(_/ \<supseteq> _)" [50, 51] 50)
haftmann@21333
   141
haftmann@30352
   142
definition empty :: "'a set" ("{}") where
haftmann@30352
   143
  "empty \<equiv> {x. False}"
haftmann@30352
   144
haftmann@30352
   145
definition UNIV :: "'a set" where
haftmann@30352
   146
  "UNIV \<equiv> {x. True}"
haftmann@30352
   147
 
haftmann@30352
   148
lemma subsetI [atp,intro!]: "(!!x. x:A ==> x:B) ==> A \<subseteq> B"
haftmann@30352
   149
  by (auto simp add: mem_def intro: predicate1I)
haftmann@30352
   150
haftmann@30352
   151
text {*
haftmann@30352
   152
  \medskip Map the type @{text "'a set => anything"} to just @{typ
haftmann@30352
   153
  'a}; for overloading constants whose first argument has type @{typ
haftmann@30352
   154
  "'a set"}.
haftmann@30352
   155
*}
haftmann@30352
   156
haftmann@30352
   157
lemma subsetD [elim]: "A \<subseteq> B ==> c \<in> A ==> c \<in> B"
haftmann@30352
   158
  -- {* Rule in Modus Ponens style. *}
haftmann@30352
   159
  by (unfold mem_def) blast
haftmann@30352
   160
haftmann@30352
   161
declare subsetD [intro?] -- FIXME
haftmann@30352
   162
haftmann@30352
   163
lemma rev_subsetD: "c \<in> A ==> A \<subseteq> B ==> c \<in> B"
haftmann@30352
   164
  -- {* The same, with reversed premises for use with @{text erule} --
haftmann@30352
   165
      cf @{text rev_mp}. *}
haftmann@30352
   166
  by (rule subsetD)
haftmann@30352
   167
haftmann@30352
   168
declare rev_subsetD [intro?] -- FIXME
haftmann@30352
   169
haftmann@30352
   170
text {*
haftmann@30352
   171
  \medskip Converts @{prop "A \<subseteq> B"} to @{prop "x \<in> A ==> x \<in> B"}.
haftmann@30352
   172
*}
haftmann@30352
   173
haftmann@30352
   174
ML {*
haftmann@30352
   175
  fun impOfSubs th = th RSN (2, @{thm rev_subsetD})
haftmann@30352
   176
*}
haftmann@30352
   177
haftmann@30352
   178
lemma subsetCE [elim]: "A \<subseteq>  B ==> (c \<notin> A ==> P) ==> (c \<in> B ==> P) ==> P"
haftmann@30352
   179
  -- {* Classical elimination rule. *}
haftmann@30352
   180
  by (unfold mem_def) blast
haftmann@30352
   181
haftmann@30352
   182
text {*
haftmann@30352
   183
  \medskip Takes assumptions @{prop "A \<subseteq> B"}; @{prop "c \<in> A"} and
haftmann@30352
   184
  creates the assumption @{prop "c \<in> B"}.
haftmann@30352
   185
*}
haftmann@30352
   186
haftmann@30352
   187
ML {*
haftmann@30352
   188
  fun set_mp_tac i = etac @{thm subsetCE} i THEN mp_tac i
haftmann@30352
   189
*}
haftmann@30352
   190
haftmann@30352
   191
lemma contra_subsetD: "A \<subseteq> B ==> c \<notin> B ==> c \<notin> A"
haftmann@30352
   192
  by blast
haftmann@30352
   193
haftmann@30352
   194
lemma subset_refl [simp,atp]: "A \<subseteq> A"
haftmann@30352
   195
  by fast
haftmann@30352
   196
haftmann@30352
   197
lemma subset_trans: "A \<subseteq> B ==> B \<subseteq> C ==> A \<subseteq> C"
haftmann@30352
   198
  by blast
haftmann@30352
   199
haftmann@30352
   200
lemma subset_antisym [intro!]: "A \<subseteq> B ==> B \<subseteq> A ==> A = B"
haftmann@30352
   201
  -- {* Anti-symmetry of the subset relation. *}
haftmann@30352
   202
  by (iprover intro: set_ext subsetD)
haftmann@30352
   203
haftmann@30352
   204
text {*
haftmann@30352
   205
  \medskip Equality rules from ZF set theory -- are they appropriate
haftmann@30352
   206
  here?
haftmann@30352
   207
*}
haftmann@30352
   208
haftmann@30352
   209
lemma equalityD1: "A = B ==> A \<subseteq> B"
haftmann@30352
   210
  by (simp add: subset_refl)
haftmann@30352
   211
haftmann@30352
   212
lemma equalityD2: "A = B ==> B \<subseteq> A"
haftmann@30352
   213
  by (simp add: subset_refl)
haftmann@30352
   214
haftmann@30352
   215
text {*
haftmann@30352
   216
  \medskip Be careful when adding this to the claset as @{text
haftmann@30352
   217
  subset_empty} is in the simpset: @{prop "A = {}"} goes to @{prop "{}
haftmann@30352
   218
  \<subseteq> A"} and @{prop "A \<subseteq> {}"} and then back to @{prop "A = {}"}!
haftmann@30352
   219
*}
haftmann@30352
   220
haftmann@30352
   221
lemma equalityE: "A = B ==> (A \<subseteq> B ==> B \<subseteq> A ==> P) ==> P"
haftmann@30352
   222
  by (simp add: subset_refl)
haftmann@30352
   223
haftmann@30352
   224
lemma empty_iff [simp]: "(c : {}) = False"
haftmann@30352
   225
  by (simp add: empty_def)
haftmann@30352
   226
haftmann@30352
   227
lemma emptyE [elim!]: "a : {} ==> P"
haftmann@30352
   228
  by simp
haftmann@30352
   229
haftmann@30352
   230
lemma empty_subsetI [iff]: "{} \<subseteq> A"
haftmann@30352
   231
    -- {* One effect is to delete the ASSUMPTION @{prop "{} \<subseteq> A"} *}
haftmann@30352
   232
  by blast
haftmann@30352
   233
haftmann@30352
   234
lemma bot_set_eq: "bot = {}"
haftmann@30352
   235
  by (iprover intro!: subset_antisym empty_subsetI bot_least)
haftmann@30352
   236
haftmann@30352
   237
lemma equals0I: "(!!y. y \<in> A ==> False) ==> A = {}"
haftmann@30352
   238
  by blast
haftmann@30352
   239
haftmann@30352
   240
lemma equals0D: "A = {} ==> a \<notin> A"
haftmann@30352
   241
    -- {* Use for reasoning about disjointness *}
haftmann@30352
   242
  by blast
haftmann@30352
   243
haftmann@30352
   244
lemma UNIV_I [simp]: "x : UNIV"
haftmann@30352
   245
  by (simp add: UNIV_def)
haftmann@30352
   246
haftmann@30352
   247
declare UNIV_I [intro]  -- {* unsafe makes it less likely to cause problems *}
haftmann@30352
   248
haftmann@30352
   249
lemma UNIV_witness [intro?]: "EX x. x : UNIV"
haftmann@30352
   250
  by simp
haftmann@30352
   251
haftmann@30352
   252
lemma subset_UNIV [simp]: "A \<subseteq> UNIV"
haftmann@30352
   253
  by (rule subsetI) (rule UNIV_I)
haftmann@30352
   254
haftmann@30352
   255
lemma top_set_eq: "top = UNIV"
haftmann@30352
   256
  by (iprover intro!: subset_antisym subset_UNIV top_greatest)
haftmann@30352
   257
haftmann@30352
   258
lemma UNIV_eq_I: "(\<And>x. x \<in> A) \<Longrightarrow> UNIV = A"
haftmann@30352
   259
  by auto
haftmann@30352
   260
haftmann@30352
   261
lemma UNIV_not_empty [iff]: "UNIV ~= {}"
haftmann@30352
   262
  by blast
haftmann@30352
   263
haftmann@30352
   264
lemma psubsetI [intro!,noatp]: "A \<subseteq> B ==> A \<noteq> B ==> A \<subset> B"
haftmann@30352
   265
  by (unfold less_le) blast
haftmann@30352
   266
haftmann@30352
   267
lemma psubsetE [elim!,noatp]: 
haftmann@30352
   268
    "[|A \<subset> B;  [|A \<subseteq> B; ~ (B\<subseteq>A)|] ==> R|] ==> R"
haftmann@30352
   269
  by (unfold less_le) blast
haftmann@30352
   270
haftmann@30352
   271
lemma psubset_eq: "(A \<subset> B) = (A \<subseteq> B & A \<noteq> B)"
haftmann@30352
   272
  by (simp only: less_le)
haftmann@30352
   273
haftmann@30352
   274
lemma psubset_imp_subset: "A \<subset> B ==> A \<subseteq> B"
haftmann@30352
   275
  by (simp add: psubset_eq)
haftmann@30352
   276
haftmann@30352
   277
lemma psubset_trans: "[| A \<subset> B; B \<subset> C |] ==> A \<subset> C"
haftmann@30352
   278
apply (unfold less_le)
haftmann@30352
   279
apply (auto dest: subset_antisym)
haftmann@30352
   280
done
haftmann@30352
   281
haftmann@30352
   282
lemma psubsetD: "[| A \<subset> B; c \<in> A |] ==> c \<in> B"
haftmann@30352
   283
apply (unfold less_le)
haftmann@30352
   284
apply (auto dest: subsetD)
haftmann@30352
   285
done
haftmann@30352
   286
haftmann@30352
   287
lemma psubset_subset_trans: "A \<subset> B ==> B \<subseteq> C ==> A \<subset> C"
haftmann@30352
   288
  by (auto simp add: psubset_eq)
haftmann@30352
   289
haftmann@30352
   290
lemma subset_psubset_trans: "A \<subseteq> B ==> B \<subset> C ==> A \<subset> C"
haftmann@30352
   291
  by (auto simp add: psubset_eq)
haftmann@30352
   292
haftmann@30352
   293
lemma Collect_empty_eq [simp]: "(Collect P = {}) = (\<forall>x. \<not> P x)"
haftmann@30352
   294
by blast
haftmann@30352
   295
haftmann@30352
   296
lemma empty_Collect_eq [simp]: "({} = Collect P) = (\<forall>x. \<not> P x)"
haftmann@30352
   297
by blast
haftmann@30352
   298
haftmann@30352
   299
subsubsection {* Intersection and union *}
haftmann@30352
   300
haftmann@30352
   301
definition Int :: "'a set \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "Int" 70) where
haftmann@30352
   302
  "A Int B \<equiv> {x. x \<in> A \<and> x \<in> B}"
haftmann@30352
   303
haftmann@30352
   304
definition Un :: "'a set \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "Un" 65) where
haftmann@30352
   305
  "A Un B \<equiv> {x. x \<in> A \<or> x \<in> B}"
haftmann@30352
   306
haftmann@30352
   307
notation (xsymbols)
haftmann@30352
   308
  "Int"  (infixl "\<inter>" 70) and
haftmann@30352
   309
  "Un"  (infixl "\<union>" 65)
haftmann@30352
   310
haftmann@30352
   311
notation (HTML output)
haftmann@30352
   312
  "Int"  (infixl "\<inter>" 70) and
haftmann@30352
   313
  "Un"  (infixl "\<union>" 65)
haftmann@30352
   314
haftmann@30352
   315
lemma Int_iff [simp]: "(c : A Int B) = (c:A & c:B)"
haftmann@30352
   316
  by (unfold Int_def) blast
haftmann@30352
   317
haftmann@30352
   318
lemma IntI [intro!]: "c:A ==> c:B ==> c : A Int B"
haftmann@30352
   319
  by simp
haftmann@30352
   320
haftmann@30352
   321
lemma IntD1: "c : A Int B ==> c:A"
haftmann@30352
   322
  by simp
haftmann@30352
   323
haftmann@30352
   324
lemma IntD2: "c : A Int B ==> c:B"
haftmann@30352
   325
  by simp
haftmann@30352
   326
haftmann@30352
   327
lemma IntE [elim!]: "c : A Int B ==> (c:A ==> c:B ==> P) ==> P"
haftmann@30352
   328
  by simp
haftmann@30352
   329
haftmann@30352
   330
lemma Un_iff [simp]: "(c : A Un B) = (c:A | c:B)"
haftmann@30352
   331
  by (unfold Un_def) blast
haftmann@30352
   332
haftmann@30352
   333
lemma UnI1 [elim?]: "c:A ==> c : A Un B"
haftmann@30352
   334
  by simp
haftmann@30352
   335
haftmann@30352
   336
lemma UnI2 [elim?]: "c:B ==> c : A Un B"
haftmann@30352
   337
  by simp
haftmann@30352
   338
haftmann@30352
   339
text {*
haftmann@30352
   340
  \medskip Classical introduction rule: no commitment to @{prop A} vs
haftmann@30352
   341
  @{prop B}.
haftmann@30352
   342
*}
haftmann@30352
   343
haftmann@30352
   344
lemma UnCI [intro!]: "(c~:B ==> c:A) ==> c : A Un B"
haftmann@30352
   345
  by auto
haftmann@30352
   346
haftmann@30352
   347
lemma UnE [elim!]: "c : A Un B ==> (c:A ==> P) ==> (c:B ==> P) ==> P"
haftmann@30352
   348
  by (unfold Un_def) blast
haftmann@30352
   349
haftmann@30352
   350
lemma Int_lower1: "A \<inter> B \<subseteq> A"
haftmann@30352
   351
  by blast
haftmann@30352
   352
haftmann@30352
   353
lemma Int_lower2: "A \<inter> B \<subseteq> B"
haftmann@30352
   354
  by blast
haftmann@30352
   355
haftmann@30352
   356
lemma Int_greatest: "C \<subseteq> A ==> C \<subseteq> B ==> C \<subseteq> A \<inter> B"
haftmann@30352
   357
  by blast
haftmann@30352
   358
haftmann@30352
   359
lemma inf_set_eq: "inf A B = A \<inter> B"
haftmann@30352
   360
  apply (rule subset_antisym)
haftmann@30352
   361
  apply (rule Int_greatest)
haftmann@30352
   362
  apply (rule inf_le1)
haftmann@30352
   363
  apply (rule inf_le2)
haftmann@30352
   364
  apply (rule inf_greatest)
haftmann@30352
   365
  apply (rule Int_lower1)
haftmann@30352
   366
  apply (rule Int_lower2)
haftmann@30352
   367
  done
haftmann@30352
   368
haftmann@30352
   369
lemma Un_upper1: "A \<subseteq> A \<union> B"
haftmann@30352
   370
  by blast
haftmann@30352
   371
haftmann@30352
   372
lemma Un_upper2: "B \<subseteq> A \<union> B"
haftmann@30352
   373
  by blast
haftmann@30352
   374
haftmann@30352
   375
lemma Un_least: "A \<subseteq> C ==> B \<subseteq> C ==> A \<union> B \<subseteq> C"
haftmann@30352
   376
  by blast
haftmann@30352
   377
haftmann@30352
   378
lemma sup_set_eq: "sup A B = A \<union> B"
haftmann@30352
   379
  apply (rule subset_antisym)
haftmann@30352
   380
  apply (rule sup_least)
haftmann@30352
   381
  apply (rule Un_upper1)
haftmann@30352
   382
  apply (rule Un_upper2)
haftmann@30352
   383
  apply (rule Un_least)
haftmann@30352
   384
  apply (rule sup_ge1)
haftmann@30352
   385
  apply (rule sup_ge2)
haftmann@30352
   386
  done
haftmann@30352
   387
haftmann@30352
   388
lemma Collect_conj_eq: "{x. P x & Q x} = {x. P x} \<inter> {x. Q x}"
haftmann@30352
   389
  by blast
haftmann@30352
   390
haftmann@30352
   391
lemma Collect_disj_eq: "{x. P x | Q x} = {x. P x} \<union> {x. Q x}"
haftmann@30352
   392
  by blast
haftmann@30352
   393
haftmann@30352
   394
lemma subset_empty [simp]: "(A \<subseteq> {}) = (A = {})"
haftmann@30352
   395
  by blast
haftmann@30352
   396
haftmann@30352
   397
lemma not_psubset_empty [iff]: "\<not> (A \<subset> {})"
haftmann@30352
   398
  by (unfold less_le) blast
haftmann@30352
   399
haftmann@30352
   400
lemma Collect_const [simp]: "{s. P} = (if P then UNIV else {})"
haftmann@30352
   401
  -- {* supersedes @{text "Collect_False_empty"} *}
haftmann@30352
   402
  by auto
haftmann@30352
   403
haftmann@30352
   404
haftmann@30352
   405
subsubsection {* Complement and set difference *}
haftmann@30352
   406
haftmann@30352
   407
instantiation bool :: minus
haftmann@30352
   408
begin
haftmann@30352
   409
haftmann@30352
   410
definition
haftmann@30352
   411
  bool_diff_def: "A - B \<longleftrightarrow> A \<and> \<not> B"
haftmann@30352
   412
haftmann@30352
   413
instance ..
haftmann@30352
   414
haftmann@30352
   415
end
haftmann@30352
   416
haftmann@30352
   417
instantiation "fun" :: (type, minus) minus
haftmann@30352
   418
begin
haftmann@30352
   419
haftmann@30352
   420
definition
haftmann@30352
   421
  fun_diff_def: "A - B = (\<lambda>x. A x - B x)"
haftmann@30352
   422
haftmann@30352
   423
instance ..
haftmann@30352
   424
haftmann@30352
   425
end
haftmann@30352
   426
haftmann@30352
   427
instantiation bool :: uminus
haftmann@30352
   428
begin
haftmann@30352
   429
haftmann@30352
   430
definition
haftmann@30352
   431
  bool_Compl_def: "- A \<longleftrightarrow> \<not> A"
haftmann@30352
   432
haftmann@30352
   433
instance ..
haftmann@30352
   434
haftmann@30352
   435
end
haftmann@30352
   436
haftmann@30352
   437
instantiation "fun" :: (type, uminus) uminus
haftmann@30352
   438
begin
haftmann@30352
   439
haftmann@30352
   440
definition
haftmann@30352
   441
  fun_Compl_def: "- A = (\<lambda>x. - A x)"
haftmann@30352
   442
haftmann@30352
   443
instance ..
haftmann@30352
   444
haftmann@30352
   445
end
haftmann@30352
   446
haftmann@30352
   447
lemma Compl_iff [simp]: "(c \<in> -A) = (c \<notin> A)"
haftmann@30352
   448
  by (simp add: mem_def fun_Compl_def bool_Compl_def)
haftmann@30352
   449
haftmann@30352
   450
lemma ComplI [intro!]: "(c \<in> A ==> False) ==> c \<in> -A"
haftmann@30352
   451
  by (unfold mem_def fun_Compl_def bool_Compl_def) blast
haftmann@30352
   452
haftmann@30352
   453
text {*
haftmann@30352
   454
  \medskip This form, with negated conclusion, works well with the
haftmann@30352
   455
  Classical prover.  Negated assumptions behave like formulae on the
haftmann@30352
   456
  right side of the notional turnstile ... *}
haftmann@30352
   457
haftmann@30352
   458
lemma ComplD [dest!]: "c : -A ==> c~:A"
haftmann@30352
   459
  by (simp add: mem_def fun_Compl_def bool_Compl_def)
haftmann@30352
   460
haftmann@30352
   461
lemmas ComplE = ComplD [elim_format]
haftmann@30352
   462
haftmann@30352
   463
lemma Compl_eq: "- A = {x. ~ x : A}" by blast
haftmann@30352
   464
haftmann@30352
   465
lemma Diff_iff [simp]: "(c : A - B) = (c:A & c~:B)"
haftmann@30352
   466
  by (simp add: mem_def fun_diff_def bool_diff_def)
haftmann@30352
   467
haftmann@30352
   468
lemma DiffI [intro!]: "c : A ==> c ~: B ==> c : A - B"
haftmann@30352
   469
  by simp
haftmann@30352
   470
haftmann@30352
   471
lemma DiffD1: "c : A - B ==> c : A"
haftmann@30352
   472
  by simp
haftmann@30352
   473
haftmann@30352
   474
lemma DiffD2: "c : A - B ==> c : B ==> P"
haftmann@30352
   475
  by simp
haftmann@30352
   476
haftmann@30352
   477
lemma DiffE [elim!]: "c : A - B ==> (c:A ==> c~:B ==> P) ==> P"
haftmann@30352
   478
  by simp
haftmann@30352
   479
haftmann@30352
   480
lemma set_diff_eq: "A - B = {x. x : A & ~ x : B}" by blast
haftmann@30352
   481
haftmann@30352
   482
lemma Compl_eq_Diff_UNIV: "-A = (UNIV - A)"
haftmann@30352
   483
by blast
haftmann@30352
   484
haftmann@30352
   485
lemma psubset_imp_ex_mem: "A \<subset> B ==> \<exists>b. b \<in> (B - A)"
haftmann@30352
   486
  by (unfold less_le) blast
haftmann@30352
   487
haftmann@30352
   488
lemma Diff_subset: "A - B \<subseteq> A"
haftmann@30352
   489
  by blast
haftmann@30352
   490
haftmann@30352
   491
lemma Diff_subset_conv: "(A - B \<subseteq> C) = (A \<subseteq> B \<union> C)"
haftmann@30352
   492
by blast
haftmann@30352
   493
haftmann@30352
   494
lemma Collect_imp_eq: "{x. P x --> Q x} = -{x. P x} \<union> {x. Q x}"
haftmann@30352
   495
  by blast
haftmann@30352
   496
haftmann@30352
   497
lemma Collect_neg_eq: "{x. \<not> P x} = - {x. P x}"
haftmann@30352
   498
  by blast
haftmann@30352
   499
haftmann@30352
   500
haftmann@30352
   501
subsubsection {* Set enumerations *}
haftmann@30352
   502
haftmann@30352
   503
global
haftmann@30352
   504
haftmann@30352
   505
consts
haftmann@30352
   506
  insert        :: "'a => 'a set => 'a set"
haftmann@30352
   507
haftmann@30352
   508
local
haftmann@30352
   509
haftmann@30352
   510
defs
haftmann@30352
   511
  insert_def:   "insert a B == {x. x=a} Un B"
haftmann@30352
   512
haftmann@30352
   513
syntax
haftmann@30352
   514
  "@Finset"     :: "args => 'a set"                       ("{(_)}")
haftmann@30352
   515
haftmann@30352
   516
translations
haftmann@30352
   517
  "{x, xs}"     == "insert x {xs}"
haftmann@30352
   518
  "{x}"         == "insert x {}"
haftmann@30352
   519
haftmann@30352
   520
lemma insert_iff [simp]: "(a : insert b A) = (a = b | a:A)"
haftmann@30352
   521
  by (unfold insert_def) blast
haftmann@30352
   522
haftmann@30352
   523
lemma insertI1: "a : insert a B"
haftmann@30352
   524
  by simp
haftmann@30352
   525
haftmann@30352
   526
lemma insertI2: "a : B ==> a : insert b B"
haftmann@30352
   527
  by simp
haftmann@30352
   528
haftmann@30352
   529
lemma insertE [elim!]: "a : insert b A ==> (a = b ==> P) ==> (a:A ==> P) ==> P"
haftmann@30352
   530
  by (unfold insert_def) blast
haftmann@30352
   531
haftmann@30352
   532
lemma insertCI [intro!]: "(a~:B ==> a = b) ==> a: insert b B"
haftmann@30352
   533
  -- {* Classical introduction rule. *}
haftmann@30352
   534
  by auto
haftmann@30352
   535
haftmann@30352
   536
lemma subset_insert_iff: "(A \<subseteq> insert x B) = (if x:A then A - {x} \<subseteq> B else A \<subseteq> B)"
haftmann@30352
   537
  by auto
haftmann@30352
   538
haftmann@30352
   539
lemma set_insert:
haftmann@30352
   540
  assumes "x \<in> A"
haftmann@30352
   541
  obtains B where "A = insert x B" and "x \<notin> B"
haftmann@30352
   542
proof
haftmann@30352
   543
  from assms show "A = insert x (A - {x})" by blast
haftmann@30352
   544
next
haftmann@30352
   545
  show "x \<notin> A - {x}" by blast
haftmann@30352
   546
qed
haftmann@30352
   547
haftmann@30352
   548
lemma insert_ident: "x ~: A ==> x ~: B ==> (insert x A = insert x B) = (A = B)"
haftmann@30352
   549
by auto
haftmann@30352
   550
haftmann@30352
   551
lemma insert_is_Un: "insert a A = {a} Un A"
haftmann@30352
   552
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a {}"} *}
haftmann@30352
   553
  by blast
haftmann@30352
   554
haftmann@30352
   555
lemma insert_not_empty [simp]: "insert a A \<noteq> {}"
haftmann@30352
   556
  by blast
haftmann@30352
   557
haftmann@30352
   558
lemmas empty_not_insert = insert_not_empty [symmetric, standard]
haftmann@30352
   559
declare empty_not_insert [simp]
haftmann@30352
   560
haftmann@30352
   561
lemma insert_absorb: "a \<in> A ==> insert a A = A"
haftmann@30352
   562
  -- {* @{text "[simp]"} causes recursive calls when there are nested inserts *}
haftmann@30352
   563
  -- {* with \emph{quadratic} running time *}
haftmann@30352
   564
  by blast
haftmann@30352
   565
haftmann@30352
   566
lemma insert_absorb2 [simp]: "insert x (insert x A) = insert x A"
haftmann@30352
   567
  by blast
haftmann@30352
   568
haftmann@30352
   569
lemma insert_commute: "insert x (insert y A) = insert y (insert x A)"
haftmann@30352
   570
  by blast
haftmann@30352
   571
haftmann@30352
   572
lemma insert_subset [simp]: "(insert x A \<subseteq> B) = (x \<in> B & A \<subseteq> B)"
haftmann@30352
   573
  by blast
haftmann@30352
   574
haftmann@30352
   575
lemma mk_disjoint_insert: "a \<in> A ==> \<exists>B. A = insert a B & a \<notin> B"
haftmann@30352
   576
  -- {* use new @{text B} rather than @{text "A - {a}"} to avoid infinite unfolding *}
haftmann@30352
   577
  apply (rule_tac x = "A - {a}" in exI, blast)
haftmann@30352
   578
  done
haftmann@30352
   579
haftmann@30352
   580
lemma insert_Collect: "insert a (Collect P) = {u. u \<noteq> a --> P u}"
haftmann@30352
   581
  by auto
haftmann@30352
   582
haftmann@30352
   583
lemma insert_inter_insert[simp]: "insert a A \<inter> insert a B = insert a (A \<inter> B)"
haftmann@30352
   584
  by blast
haftmann@30352
   585
haftmann@30352
   586
lemma insert_disjoint [simp,noatp]:
haftmann@30352
   587
 "(insert a A \<inter> B = {}) = (a \<notin> B \<and> A \<inter> B = {})"
haftmann@30352
   588
 "({} = insert a A \<inter> B) = (a \<notin> B \<and> {} = A \<inter> B)"
haftmann@30352
   589
  by auto
haftmann@30352
   590
haftmann@30352
   591
lemma disjoint_insert [simp,noatp]:
haftmann@30352
   592
 "(B \<inter> insert a A = {}) = (a \<notin> B \<and> B \<inter> A = {})"
haftmann@30352
   593
 "({} = A \<inter> insert b B) = (b \<notin> A \<and> {} = A \<inter> B)"
haftmann@30352
   594
  by auto
haftmann@30352
   595
haftmann@30352
   596
text {* Singletons, using insert *}
haftmann@30352
   597
haftmann@30352
   598
lemma singletonI [intro!,noatp]: "a : {a}"
haftmann@30352
   599
    -- {* Redundant? But unlike @{text insertCI}, it proves the subgoal immediately! *}
haftmann@30352
   600
  by (rule insertI1)
haftmann@30352
   601
haftmann@30352
   602
lemma singletonD [dest!,noatp]: "b : {a} ==> b = a"
haftmann@30352
   603
  by blast
haftmann@30352
   604
haftmann@30352
   605
lemmas singletonE = singletonD [elim_format]
haftmann@30352
   606
haftmann@30352
   607
lemma singleton_iff: "(b : {a}) = (b = a)"
haftmann@30352
   608
  by blast
haftmann@30352
   609
haftmann@30352
   610
lemma singleton_inject [dest!]: "{a} = {b} ==> a = b"
haftmann@30352
   611
  by blast
haftmann@30352
   612
haftmann@30352
   613
lemma singleton_insert_inj_eq [iff,noatp]:
haftmann@30352
   614
     "({b} = insert a A) = (a = b & A \<subseteq> {b})"
haftmann@30352
   615
  by blast
haftmann@30352
   616
haftmann@30352
   617
lemma singleton_insert_inj_eq' [iff,noatp]:
haftmann@30352
   618
     "(insert a A = {b}) = (a = b & A \<subseteq> {b})"
haftmann@30352
   619
  by blast
haftmann@30352
   620
haftmann@30352
   621
lemma subset_singletonD: "A \<subseteq> {x} ==> A = {} | A = {x}"
haftmann@30352
   622
  by fast
haftmann@30352
   623
haftmann@30352
   624
lemma singleton_conv [simp]: "{x. x = a} = {a}"
haftmann@30352
   625
  by blast
haftmann@30352
   626
haftmann@30352
   627
lemma singleton_conv2 [simp]: "{x. a = x} = {a}"
haftmann@30352
   628
  by blast
haftmann@30352
   629
haftmann@30352
   630
lemma diff_single_insert: "A - {x} \<subseteq> B ==> x \<in> A ==> A \<subseteq> insert x B"
haftmann@30352
   631
  by blast
haftmann@30352
   632
haftmann@30352
   633
lemma doubleton_eq_iff: "({a,b} = {c,d}) = (a=c & b=d | a=d & b=c)"
haftmann@30352
   634
  by (blast elim: equalityE)
haftmann@30352
   635
haftmann@30352
   636
lemma psubset_insert_iff:
haftmann@30352
   637
  "(A \<subset> insert x B) = (if x \<in> B then A \<subset> B else if x \<in> A then A - {x} \<subset> B else A \<subseteq> B)"
haftmann@30352
   638
  by (auto simp add: less_le subset_insert_iff)
haftmann@30352
   639
haftmann@30352
   640
lemma subset_insertI: "B \<subseteq> insert a B"
haftmann@30352
   641
  by (rule subsetI) (erule insertI2)
haftmann@30352
   642
haftmann@30352
   643
lemma subset_insertI2: "A \<subseteq> B \<Longrightarrow> A \<subseteq> insert b B"
haftmann@30352
   644
  by blast
haftmann@30352
   645
haftmann@30352
   646
lemma subset_insert: "x \<notin> A ==> (A \<subseteq> insert x B) = (A \<subseteq> B)"
haftmann@30352
   647
  by blast
haftmann@30352
   648
haftmann@30352
   649
haftmann@30352
   650
subsubsection {* Bounded quantifiers and operators *}
haftmann@30352
   651
haftmann@30352
   652
global
haftmann@30352
   653
haftmann@30352
   654
consts
haftmann@30352
   655
  Ball          :: "'a set => ('a => bool) => bool"      -- "bounded universal quantifiers"
haftmann@30352
   656
  Bex           :: "'a set => ('a => bool) => bool"      -- "bounded existential quantifiers"
haftmann@30352
   657
  Bex1          :: "'a set => ('a => bool) => bool"      -- "bounded unique existential quantifiers"
haftmann@30352
   658
haftmann@30352
   659
local
haftmann@30352
   660
haftmann@30352
   661
defs
haftmann@30352
   662
  Ball_def:     "Ball A P       == ALL x. x:A --> P(x)"
haftmann@30352
   663
  Bex_def:      "Bex A P        == EX x. x:A & P(x)"
haftmann@30352
   664
  Bex1_def:     "Bex1 A P       == EX! x. x:A & P(x)"
haftmann@30352
   665
haftmann@30352
   666
syntax
haftmann@30352
   667
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3ALL _:_./ _)" [0, 0, 10] 10)
haftmann@30352
   668
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3EX _:_./ _)" [0, 0, 10] 10)
haftmann@30352
   669
  "_Bex1"       :: "pttrn => 'a set => bool => bool"      ("(3EX! _:_./ _)" [0, 0, 10] 10)
haftmann@30352
   670
  "_Bleast"     :: "id => 'a set => bool => 'a"           ("(3LEAST _:_./ _)" [0, 0, 10] 10)
haftmann@30352
   671
haftmann@30352
   672
syntax (HOL)
haftmann@30352
   673
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3! _:_./ _)" [0, 0, 10] 10)
haftmann@30352
   674
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3? _:_./ _)" [0, 0, 10] 10)
haftmann@30352
   675
  "_Bex1"       :: "pttrn => 'a set => bool => bool"      ("(3?! _:_./ _)" [0, 0, 10] 10)
haftmann@30352
   676
haftmann@30352
   677
syntax (xsymbols)
haftmann@30352
   678
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3\<forall>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30352
   679
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3\<exists>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30352
   680
  "_Bex1"       :: "pttrn => 'a set => bool => bool"      ("(3\<exists>!_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30352
   681
  "_Bleast"     :: "id => 'a set => bool => 'a"           ("(3LEAST_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30352
   682
haftmann@30352
   683
syntax (HTML output)
haftmann@30352
   684
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3\<forall>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30352
   685
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3\<exists>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30352
   686
  "_Bex1"       :: "pttrn => 'a set => bool => bool"      ("(3\<exists>!_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30352
   687
haftmann@30352
   688
translations
haftmann@30352
   689
  "ALL x:A. P"  == "Ball A (%x. P)"
haftmann@30352
   690
  "EX x:A. P"   == "Bex A (%x. P)"
haftmann@30352
   691
  "EX! x:A. P"  == "Bex1 A (%x. P)"
haftmann@30352
   692
  "LEAST x:A. P" => "LEAST x. x:A & P"
nipkow@14804
   693
wenzelm@19656
   694
syntax (output)
nipkow@14804
   695
  "_setlessAll" :: "[idt, 'a, bool] => bool"  ("(3ALL _<_./ _)"  [0, 0, 10] 10)
nipkow@14804
   696
  "_setlessEx"  :: "[idt, 'a, bool] => bool"  ("(3EX _<_./ _)"  [0, 0, 10] 10)
nipkow@14804
   697
  "_setleAll"   :: "[idt, 'a, bool] => bool"  ("(3ALL _<=_./ _)" [0, 0, 10] 10)
nipkow@14804
   698
  "_setleEx"    :: "[idt, 'a, bool] => bool"  ("(3EX _<=_./ _)" [0, 0, 10] 10)
webertj@20217
   699
  "_setleEx1"   :: "[idt, 'a, bool] => bool"  ("(3EX! _<=_./ _)" [0, 0, 10] 10)
nipkow@14804
   700
nipkow@14804
   701
syntax (xsymbols)
nipkow@14804
   702
  "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subset>_./ _)"  [0, 0, 10] 10)
nipkow@14804
   703
  "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subset>_./ _)"  [0, 0, 10] 10)
nipkow@14804
   704
  "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subseteq>_./ _)" [0, 0, 10] 10)
nipkow@14804
   705
  "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subseteq>_./ _)" [0, 0, 10] 10)
webertj@20217
   706
  "_setleEx1"   :: "[idt, 'a, bool] => bool"   ("(3\<exists>!_\<subseteq>_./ _)" [0, 0, 10] 10)
nipkow@14804
   707
wenzelm@19656
   708
syntax (HOL output)
nipkow@14804
   709
  "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
nipkow@14804
   710
  "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
nipkow@14804
   711
  "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
nipkow@14804
   712
  "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
webertj@20217
   713
  "_setleEx1"   :: "[idt, 'a, bool] => bool"   ("(3?! _<=_./ _)" [0, 0, 10] 10)
nipkow@14804
   714
nipkow@14804
   715
syntax (HTML output)
nipkow@14804
   716
  "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subset>_./ _)"  [0, 0, 10] 10)
nipkow@14804
   717
  "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subset>_./ _)"  [0, 0, 10] 10)
nipkow@14804
   718
  "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subseteq>_./ _)" [0, 0, 10] 10)
nipkow@14804
   719
  "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subseteq>_./ _)" [0, 0, 10] 10)
webertj@20217
   720
  "_setleEx1"   :: "[idt, 'a, bool] => bool"   ("(3\<exists>!_\<subseteq>_./ _)" [0, 0, 10] 10)
nipkow@14804
   721
nipkow@14804
   722
translations
haftmann@30352
   723
  "\<forall>A\<subset>B. P"   =>  "ALL A. A \<subset> B --> P"
haftmann@30352
   724
  "\<exists>A\<subset>B. P"   =>  "EX A. A \<subset> B & P"
haftmann@30352
   725
  "\<forall>A\<subseteq>B. P"   =>  "ALL A. A \<subseteq> B --> P"
haftmann@30352
   726
  "\<exists>A\<subseteq>B. P"   =>  "EX A. A \<subseteq> B & P"
haftmann@30352
   727
  "\<exists>!A\<subseteq>B. P"  =>  "EX! A. A \<subseteq> B & P"
nipkow@14804
   728
nipkow@14804
   729
print_translation {*
nipkow@14804
   730
let
wenzelm@22377
   731
  val Type (set_type, _) = @{typ "'a set"};
wenzelm@22377
   732
  val All_binder = Syntax.binder_name @{const_syntax "All"};
wenzelm@22377
   733
  val Ex_binder = Syntax.binder_name @{const_syntax "Ex"};
wenzelm@22377
   734
  val impl = @{const_syntax "op -->"};
wenzelm@22377
   735
  val conj = @{const_syntax "op &"};
wenzelm@22377
   736
  val sbset = @{const_syntax "subset"};
wenzelm@22377
   737
  val sbset_eq = @{const_syntax "subset_eq"};
haftmann@21819
   738
haftmann@21819
   739
  val trans =
haftmann@21819
   740
   [((All_binder, impl, sbset), "_setlessAll"),
haftmann@21819
   741
    ((All_binder, impl, sbset_eq), "_setleAll"),
haftmann@21819
   742
    ((Ex_binder, conj, sbset), "_setlessEx"),
haftmann@21819
   743
    ((Ex_binder, conj, sbset_eq), "_setleEx")];
haftmann@21819
   744
haftmann@21819
   745
  fun mk v v' c n P =
haftmann@21819
   746
    if v = v' andalso not (Term.exists_subterm (fn Free (x, _) => x = v | _ => false) n)
haftmann@21819
   747
    then Syntax.const c $ Syntax.mark_bound v' $ n $ P else raise Match;
haftmann@21819
   748
haftmann@21819
   749
  fun tr' q = (q,
haftmann@21819
   750
    fn [Const ("_bound", _) $ Free (v, Type (T, _)), Const (c, _) $ (Const (d, _) $ (Const ("_bound", _) $ Free (v', _)) $ n) $ P] =>
haftmann@21819
   751
         if T = (set_type) then case AList.lookup (op =) trans (q, c, d)
haftmann@21819
   752
          of NONE => raise Match
haftmann@21819
   753
           | SOME l => mk v v' l n P
haftmann@21819
   754
         else raise Match
haftmann@21819
   755
     | _ => raise Match);
nipkow@14804
   756
in
haftmann@21819
   757
  [tr' All_binder, tr' Ex_binder]
nipkow@14804
   758
end
nipkow@14804
   759
*}
nipkow@14804
   760
wenzelm@11979
   761
text {*
wenzelm@11979
   762
  \medskip Translate between @{text "{e | x1...xn. P}"} and @{text
wenzelm@11979
   763
  "{u. EX x1..xn. u = e & P}"}; @{text "{y. EX x1..xn. y = e & P}"} is
wenzelm@11979
   764
  only translated if @{text "[0..n] subset bvs(e)"}.
wenzelm@11979
   765
*}
wenzelm@11979
   766
haftmann@30352
   767
syntax
haftmann@30352
   768
  "@SetCompr"   :: "'a => idts => bool => 'a set"         ("(1{_ |/_./ _})")
haftmann@30352
   769
  "@Collect"    :: "idt => 'a set => bool => 'a set"      ("(1{_ :/ _./ _})")
haftmann@30352
   770
haftmann@30352
   771
syntax (xsymbols)
haftmann@30352
   772
  "@Collect"    :: "idt => 'a set => bool => 'a set"      ("(1{_ \<in>/ _./ _})")
haftmann@30352
   773
haftmann@30352
   774
translations
haftmann@30352
   775
  "{x:A. P}"    => "{x. x:A & P}"
haftmann@30352
   776
wenzelm@11979
   777
parse_translation {*
wenzelm@11979
   778
  let
wenzelm@11979
   779
    val ex_tr = snd (mk_binder_tr ("EX ", "Ex"));
wenzelm@3947
   780
wenzelm@11979
   781
    fun nvars (Const ("_idts", _) $ _ $ idts) = nvars idts + 1
wenzelm@11979
   782
      | nvars _ = 1;
wenzelm@11979
   783
wenzelm@11979
   784
    fun setcompr_tr [e, idts, b] =
wenzelm@11979
   785
      let
wenzelm@11979
   786
        val eq = Syntax.const "op =" $ Bound (nvars idts) $ e;
wenzelm@11979
   787
        val P = Syntax.const "op &" $ eq $ b;
wenzelm@11979
   788
        val exP = ex_tr [idts, P];
wenzelm@17784
   789
      in Syntax.const "Collect" $ Term.absdummy (dummyT, exP) end;
wenzelm@11979
   790
wenzelm@11979
   791
  in [("@SetCompr", setcompr_tr)] end;
wenzelm@11979
   792
*}
clasohm@923
   793
nipkow@13763
   794
print_translation {*
nipkow@13763
   795
let
nipkow@13763
   796
  val ex_tr' = snd (mk_binder_tr' ("Ex", "DUMMY"));
nipkow@13763
   797
nipkow@13763
   798
  fun setcompr_tr' [Abs (abs as (_, _, P))] =
nipkow@13763
   799
    let
nipkow@13763
   800
      fun check (Const ("Ex", _) $ Abs (_, _, P), n) = check (P, n + 1)
nipkow@13763
   801
        | check (Const ("op &", _) $ (Const ("op =", _) $ Bound m $ e) $ P, n) =
nipkow@13763
   802
            n > 0 andalso m = n andalso not (loose_bvar1 (P, n)) andalso
nipkow@13763
   803
            ((0 upto (n - 1)) subset add_loose_bnos (e, 0, []))
nipkow@13764
   804
        | check _ = false
clasohm@923
   805
wenzelm@11979
   806
        fun tr' (_ $ abs) =
wenzelm@11979
   807
          let val _ $ idts $ (_ $ (_ $ _ $ e) $ Q) = ex_tr' [abs]
wenzelm@11979
   808
          in Syntax.const "@SetCompr" $ e $ idts $ Q end;
nipkow@13763
   809
    in if check (P, 0) then tr' P
nipkow@15535
   810
       else let val (x as _ $ Free(xN,_), t) = atomic_abs_tr' abs
nipkow@15535
   811
                val M = Syntax.const "@Coll" $ x $ t
nipkow@15535
   812
            in case t of
nipkow@15535
   813
                 Const("op &",_)
nipkow@15535
   814
                   $ (Const("op :",_) $ (Const("_bound",_) $ Free(yN,_)) $ A)
nipkow@15535
   815
                   $ P =>
nipkow@15535
   816
                   if xN=yN then Syntax.const "@Collect" $ x $ A $ P else M
nipkow@15535
   817
               | _ => M
nipkow@15535
   818
            end
nipkow@13763
   819
    end;
wenzelm@11979
   820
  in [("Collect", setcompr_tr')] end;
wenzelm@11979
   821
*}
wenzelm@11979
   822
wenzelm@11979
   823
lemma ballI [intro!]: "(!!x. x:A ==> P x) ==> ALL x:A. P x"
wenzelm@11979
   824
  by (simp add: Ball_def)
wenzelm@11979
   825
wenzelm@11979
   826
lemmas strip = impI allI ballI
wenzelm@11979
   827
wenzelm@11979
   828
lemma bspec [dest?]: "ALL x:A. P x ==> x:A ==> P x"
wenzelm@11979
   829
  by (simp add: Ball_def)
wenzelm@11979
   830
wenzelm@11979
   831
lemma ballE [elim]: "ALL x:A. P x ==> (P x ==> Q) ==> (x ~: A ==> Q) ==> Q"
wenzelm@11979
   832
  by (unfold Ball_def) blast
wenzelm@22139
   833
wenzelm@22139
   834
ML {* bind_thm ("rev_ballE", permute_prems 1 1 @{thm ballE}) *}
wenzelm@11979
   835
wenzelm@11979
   836
text {*
wenzelm@11979
   837
  \medskip This tactic takes assumptions @{prop "ALL x:A. P x"} and
wenzelm@11979
   838
  @{prop "a:A"}; creates assumption @{prop "P a"}.
wenzelm@11979
   839
*}
wenzelm@11979
   840
wenzelm@11979
   841
ML {*
wenzelm@22139
   842
  fun ball_tac i = etac @{thm ballE} i THEN contr_tac (i + 1)
wenzelm@11979
   843
*}
wenzelm@11979
   844
wenzelm@11979
   845
text {*
wenzelm@11979
   846
  Gives better instantiation for bound:
wenzelm@11979
   847
*}
wenzelm@11979
   848
wenzelm@26339
   849
declaration {* fn _ =>
wenzelm@26339
   850
  Classical.map_cs (fn cs => cs addbefore ("bspec", datac @{thm bspec} 1))
wenzelm@11979
   851
*}
wenzelm@11979
   852
wenzelm@11979
   853
lemma bexI [intro]: "P x ==> x:A ==> EX x:A. P x"
wenzelm@11979
   854
  -- {* Normally the best argument order: @{prop "P x"} constrains the
wenzelm@11979
   855
    choice of @{prop "x:A"}. *}
wenzelm@11979
   856
  by (unfold Bex_def) blast
wenzelm@11979
   857
wenzelm@13113
   858
lemma rev_bexI [intro?]: "x:A ==> P x ==> EX x:A. P x"
wenzelm@11979
   859
  -- {* The best argument order when there is only one @{prop "x:A"}. *}
wenzelm@11979
   860
  by (unfold Bex_def) blast
wenzelm@11979
   861
wenzelm@11979
   862
lemma bexCI: "(ALL x:A. ~P x ==> P a) ==> a:A ==> EX x:A. P x"
wenzelm@11979
   863
  by (unfold Bex_def) blast
wenzelm@11979
   864
wenzelm@11979
   865
lemma bexE [elim!]: "EX x:A. P x ==> (!!x. x:A ==> P x ==> Q) ==> Q"
wenzelm@11979
   866
  by (unfold Bex_def) blast
wenzelm@11979
   867
wenzelm@11979
   868
lemma ball_triv [simp]: "(ALL x:A. P) = ((EX x. x:A) --> P)"
wenzelm@11979
   869
  -- {* Trival rewrite rule. *}
wenzelm@11979
   870
  by (simp add: Ball_def)
wenzelm@11979
   871
wenzelm@11979
   872
lemma bex_triv [simp]: "(EX x:A. P) = ((EX x. x:A) & P)"
wenzelm@11979
   873
  -- {* Dual form for existentials. *}
wenzelm@11979
   874
  by (simp add: Bex_def)
wenzelm@11979
   875
wenzelm@11979
   876
lemma bex_triv_one_point1 [simp]: "(EX x:A. x = a) = (a:A)"
wenzelm@11979
   877
  by blast
wenzelm@11979
   878
wenzelm@11979
   879
lemma bex_triv_one_point2 [simp]: "(EX x:A. a = x) = (a:A)"
wenzelm@11979
   880
  by blast
wenzelm@11979
   881
wenzelm@11979
   882
lemma bex_one_point1 [simp]: "(EX x:A. x = a & P x) = (a:A & P a)"
wenzelm@11979
   883
  by blast
wenzelm@11979
   884
wenzelm@11979
   885
lemma bex_one_point2 [simp]: "(EX x:A. a = x & P x) = (a:A & P a)"
wenzelm@11979
   886
  by blast
wenzelm@11979
   887
wenzelm@11979
   888
lemma ball_one_point1 [simp]: "(ALL x:A. x = a --> P x) = (a:A --> P a)"
wenzelm@11979
   889
  by blast
wenzelm@11979
   890
wenzelm@11979
   891
lemma ball_one_point2 [simp]: "(ALL x:A. a = x --> P x) = (a:A --> P a)"
wenzelm@11979
   892
  by blast
wenzelm@11979
   893
wenzelm@26480
   894
ML {*
wenzelm@13462
   895
  local
wenzelm@22139
   896
    val unfold_bex_tac = unfold_tac @{thms "Bex_def"};
wenzelm@18328
   897
    fun prove_bex_tac ss = unfold_bex_tac ss THEN Quantifier1.prove_one_point_ex_tac;
wenzelm@11979
   898
    val rearrange_bex = Quantifier1.rearrange_bex prove_bex_tac;
wenzelm@11979
   899
wenzelm@22139
   900
    val unfold_ball_tac = unfold_tac @{thms "Ball_def"};
wenzelm@18328
   901
    fun prove_ball_tac ss = unfold_ball_tac ss THEN Quantifier1.prove_one_point_all_tac;
wenzelm@11979
   902
    val rearrange_ball = Quantifier1.rearrange_ball prove_ball_tac;
wenzelm@11979
   903
  in
wenzelm@18328
   904
    val defBEX_regroup = Simplifier.simproc (the_context ())
wenzelm@13462
   905
      "defined BEX" ["EX x:A. P x & Q x"] rearrange_bex;
wenzelm@18328
   906
    val defBALL_regroup = Simplifier.simproc (the_context ())
wenzelm@13462
   907
      "defined BALL" ["ALL x:A. P x --> Q x"] rearrange_ball;
wenzelm@11979
   908
  end;
wenzelm@13462
   909
wenzelm@13462
   910
  Addsimprocs [defBALL_regroup, defBEX_regroup];
wenzelm@11979
   911
*}
wenzelm@11979
   912
haftmann@30352
   913
text {*
haftmann@30352
   914
  \medskip Eta-contracting these four rules (to remove @{text P})
haftmann@30352
   915
  causes them to be ignored because of their interaction with
haftmann@30352
   916
  congruence rules.
haftmann@30352
   917
*}
haftmann@30352
   918
haftmann@30352
   919
lemma ball_UNIV [simp]: "Ball UNIV P = All P"
haftmann@30352
   920
  by (simp add: Ball_def)
haftmann@30352
   921
haftmann@30352
   922
lemma bex_UNIV [simp]: "Bex UNIV P = Ex P"
haftmann@30352
   923
  by (simp add: Bex_def)
haftmann@30352
   924
haftmann@30352
   925
lemma ball_empty [simp]: "Ball {} P = True"
haftmann@30352
   926
  by (simp add: Ball_def)
haftmann@30352
   927
haftmann@30352
   928
lemma bex_empty [simp]: "Bex {} P = False"
haftmann@30352
   929
  by (simp add: Bex_def)
haftmann@30352
   930
haftmann@30352
   931
text {* Congruence rules *}
wenzelm@11979
   932
berghofe@16636
   933
lemma ball_cong:
wenzelm@11979
   934
  "A = B ==> (!!x. x:B ==> P x = Q x) ==>
wenzelm@11979
   935
    (ALL x:A. P x) = (ALL x:B. Q x)"
wenzelm@11979
   936
  by (simp add: Ball_def)
wenzelm@11979
   937
berghofe@16636
   938
lemma strong_ball_cong [cong]:
berghofe@16636
   939
  "A = B ==> (!!x. x:B =simp=> P x = Q x) ==>
berghofe@16636
   940
    (ALL x:A. P x) = (ALL x:B. Q x)"
berghofe@16636
   941
  by (simp add: simp_implies_def Ball_def)
berghofe@16636
   942
berghofe@16636
   943
lemma bex_cong:
wenzelm@11979
   944
  "A = B ==> (!!x. x:B ==> P x = Q x) ==>
wenzelm@11979
   945
    (EX x:A. P x) = (EX x:B. Q x)"
wenzelm@11979
   946
  by (simp add: Bex_def cong: conj_cong)
regensbu@1273
   947
berghofe@16636
   948
lemma strong_bex_cong [cong]:
berghofe@16636
   949
  "A = B ==> (!!x. x:B =simp=> P x = Q x) ==>
berghofe@16636
   950
    (EX x:A. P x) = (EX x:B. Q x)"
berghofe@16636
   951
  by (simp add: simp_implies_def Bex_def cong: conj_cong)
berghofe@16636
   952
berghofe@26800
   953
lemma subset_eq: "A \<le> B = (\<forall>x\<in>A. x \<in> B)" by blast
wenzelm@11979
   954
haftmann@30352
   955
lemma atomize_ball:
haftmann@30352
   956
    "(!!x. x \<in> A ==> P x) == Trueprop (\<forall>x\<in>A. P x)"
haftmann@30352
   957
  by (simp only: Ball_def atomize_all atomize_imp)
haftmann@30352
   958
haftmann@30352
   959
lemmas [symmetric, rulify] = atomize_ball
haftmann@30352
   960
  and [symmetric, defn] = atomize_ball
haftmann@30352
   961
haftmann@30352
   962
haftmann@30352
   963
subsubsection {* Image of a set under a function. *}
haftmann@30352
   964
wenzelm@11979
   965
text {*
haftmann@30352
   966
  Frequently @{term b} does not have the syntactic form of @{term "f x"}.
wenzelm@11979
   967
*}
wenzelm@11979
   968
haftmann@30352
   969
global
haftmann@30352
   970
haftmann@30352
   971
consts
haftmann@30352
   972
  image         :: "('a => 'b) => 'a set => 'b set"      (infixr "`" 90)
haftmann@30352
   973
haftmann@30352
   974
local
haftmann@30352
   975
haftmann@30352
   976
defs
haftmann@30352
   977
  image_def [noatp]:    "f`A == {y. EX x:A. y = f(x)}"
haftmann@30352
   978
haftmann@30352
   979
lemma image_eqI [simp, intro]: "b = f x ==> x:A ==> b : f`A"
haftmann@30352
   980
  by (unfold image_def) blast
haftmann@30352
   981
haftmann@30352
   982
lemma imageI: "x : A ==> f x : f ` A"
haftmann@30352
   983
  by (rule image_eqI) (rule refl)
haftmann@30352
   984
haftmann@30352
   985
lemma rev_image_eqI: "x:A ==> b = f x ==> b : f`A"
haftmann@30352
   986
  -- {* This version's more effective when we already have the
haftmann@30352
   987
    required @{term x}. *}
haftmann@30352
   988
  by (unfold image_def) blast
haftmann@30352
   989
haftmann@30352
   990
lemma imageE [elim!]:
haftmann@30352
   991
  "b : (%x. f x)`A ==> (!!x. b = f x ==> x:A ==> P) ==> P"
haftmann@30352
   992
  -- {* The eta-expansion gives variable-name preservation. *}
haftmann@30352
   993
  by (unfold image_def) blast
haftmann@30352
   994
haftmann@30352
   995
lemma image_Un: "f`(A Un B) = f`A Un f`B"
wenzelm@11979
   996
  by blast
wenzelm@11979
   997
haftmann@30352
   998
lemma image_iff: "(z : f`A) = (EX x:A. z = f x)"
haftmann@30352
   999
  by blast
haftmann@30352
  1000
haftmann@30352
  1001
lemma image_subset_iff: "(f`A \<subseteq> B) = (\<forall>x\<in>A. f x \<in> B)"
haftmann@30352
  1002
  -- {* This rewrite rule would confuse users if made default. *}
wenzelm@11979
  1003
  by blast
clasohm@923
  1004
haftmann@30352
  1005
lemma subset_image_iff: "(B \<subseteq> f`A) = (EX AA. AA \<subseteq> A & B = f`AA)"
haftmann@30352
  1006
  apply safe
haftmann@30352
  1007
   prefer 2 apply fast
haftmann@30352
  1008
  apply (rule_tac x = "{a. a : A & f a : B}" in exI, fast)
paulson@13865
  1009
  done
paulson@13865
  1010
haftmann@30352
  1011
lemma image_subsetI: "(!!x. x \<in> A ==> f x \<in> B) ==> f`A \<subseteq> B"
haftmann@30352
  1012
  -- {* Replaces the three steps @{text subsetI}, @{text imageE},
haftmann@30352
  1013
    @{text hypsubst}, but breaks too many existing proofs. *}
haftmann@30352
  1014
  by blast
haftmann@30352
  1015
haftmann@30352
  1016
lemma image_empty [simp]: "f`{} = {}"
haftmann@30352
  1017
  by blast
haftmann@30352
  1018
haftmann@30352
  1019
lemma image_insert [simp]: "f ` insert a B = insert (f a) (f`B)"
haftmann@30352
  1020
  by blast
haftmann@30352
  1021
haftmann@30352
  1022
lemma image_constant: "x \<in> A ==> (\<lambda>x. c) ` A = {c}"
haftmann@30352
  1023
  by auto
haftmann@30352
  1024
haftmann@30352
  1025
lemma image_constant_conv: "(%x. c) ` A = (if A = {} then {} else {c})"
haftmann@30352
  1026
by auto
haftmann@30352
  1027
haftmann@30352
  1028
lemma image_image: "f ` (g ` A) = (\<lambda>x. f (g x)) ` A"
haftmann@30352
  1029
  by blast
haftmann@30352
  1030
haftmann@30352
  1031
lemma insert_image [simp]: "x \<in> A ==> insert (f x) (f`A) = f`A"
haftmann@30352
  1032
  by blast
haftmann@30352
  1033
haftmann@30352
  1034
lemma image_is_empty [iff]: "(f`A = {}) = (A = {})"
haftmann@30352
  1035
  by blast
haftmann@30352
  1036
haftmann@30352
  1037
haftmann@30352
  1038
lemma image_Collect [noatp]: "f ` {x. P x} = {f x | x. P x}"
haftmann@30352
  1039
  -- {* NOT suitable as a default simprule: the RHS isn't simpler than the LHS,
haftmann@30352
  1040
      with its implicit quantifier and conjunction.  Also image enjoys better
haftmann@30352
  1041
      equational properties than does the RHS. *}
haftmann@30352
  1042
  by blast
haftmann@30352
  1043
haftmann@30352
  1044
lemma if_image_distrib [simp]:
haftmann@30352
  1045
  "(\<lambda>x. if P x then f x else g x) ` S
haftmann@30352
  1046
    = (f ` (S \<inter> {x. P x})) \<union> (g ` (S \<inter> {x. \<not> P x}))"
haftmann@30352
  1047
  by (auto simp add: image_def)
haftmann@30352
  1048
haftmann@30352
  1049
lemma image_cong: "M = N ==> (!!x. x \<in> N ==> f x = g x) ==> f`M = g`N"
haftmann@30352
  1050
  by (simp add: image_def)
haftmann@30352
  1051
haftmann@30352
  1052
haftmann@30352
  1053
subsection {* Set reasoning tools *}
wenzelm@11979
  1054
wenzelm@11979
  1055
text {*
haftmann@30352
  1056
  Rewrite rules for boolean case-splitting: faster than @{text
haftmann@30352
  1057
  "split_if [split]"}.
wenzelm@11979
  1058
*}
wenzelm@11979
  1059
haftmann@30352
  1060
lemma split_if_eq1: "((if Q then x else y) = b) = ((Q --> x = b) & (~ Q --> y = b))"
haftmann@30352
  1061
  by (rule split_if)
haftmann@30352
  1062
haftmann@30352
  1063
lemma split_if_eq2: "(a = (if Q then x else y)) = ((Q --> a = x) & (~ Q --> a = y))"
haftmann@30352
  1064
  by (rule split_if)
wenzelm@2388
  1065
wenzelm@11979
  1066
text {*
haftmann@30352
  1067
  Split ifs on either side of the membership relation.  Not for @{text
haftmann@30352
  1068
  "[simp]"} -- can cause goals to blow up!
haftmann@30352
  1069
*}
haftmann@30352
  1070
haftmann@30352
  1071
lemma split_if_mem1: "((if Q then x else y) : b) = ((Q --> x : b) & (~ Q --> y : b))"
haftmann@30352
  1072
  by (rule split_if)
haftmann@30352
  1073
haftmann@30352
  1074
lemma split_if_mem2: "(a : (if Q then x else y)) = ((Q --> a : x) & (~ Q --> a : y))"
haftmann@30352
  1075
  by (rule split_if [where P="%S. a : S"])
haftmann@30352
  1076
haftmann@30352
  1077
lemmas split_ifs = if_bool_eq_conj split_if_eq1 split_if_eq2 split_if_mem1 split_if_mem2
haftmann@30352
  1078
haftmann@30352
  1079
(*Would like to add these, but the existing code only searches for the
haftmann@30352
  1080
  outer-level constant, which in this case is just "op :"; we instead need
haftmann@30352
  1081
  to use term-nets to associate patterns with rules.  Also, if a rule fails to
haftmann@30352
  1082
  apply, then the formula should be kept.
haftmann@30352
  1083
  [("HOL.uminus", Compl_iff RS iffD1), ("HOL.minus", [Diff_iff RS iffD1]),
haftmann@30352
  1084
   ("Int", [IntD1,IntD2]),
haftmann@30352
  1085
   ("Collect", [CollectD]), ("Inter", [InterD]), ("INTER", [INT_D])]
haftmann@30352
  1086
 *)
haftmann@30352
  1087
haftmann@30352
  1088
ML {*
haftmann@30352
  1089
  val mksimps_pairs = [(@{const_name Ball}, @{thms bspec})] @ mksimps_pairs;
haftmann@30352
  1090
*}
haftmann@30352
  1091
declaration {* fn _ =>
haftmann@30352
  1092
  Simplifier.map_ss (fn ss => ss setmksimps (mksimps mksimps_pairs))
wenzelm@11979
  1093
*}
wenzelm@11979
  1094
haftmann@30352
  1095
text {* Transitivity rules for calculational reasoning *}
haftmann@30352
  1096
haftmann@30352
  1097
lemma set_rev_mp: "x:A ==> A \<subseteq> B ==> x:B"
haftmann@30352
  1098
  by (rule subsetD)
haftmann@30352
  1099
haftmann@30352
  1100
lemma set_mp: "A \<subseteq> B ==> x:A ==> x:B"
haftmann@30352
  1101
  by (rule subsetD)
haftmann@30352
  1102
haftmann@30352
  1103
lemmas basic_trans_rules [trans] =
haftmann@30352
  1104
  order_trans_rules set_rev_mp set_mp
haftmann@30352
  1105
haftmann@30352
  1106
haftmann@30352
  1107
subsection {* Complete lattices *}
haftmann@30352
  1108
haftmann@30352
  1109
notation
haftmann@30352
  1110
  less_eq  (infix "\<sqsubseteq>" 50) and
haftmann@30352
  1111
  less (infix "\<sqsubset>" 50) and
haftmann@30352
  1112
  inf  (infixl "\<sqinter>" 70) and
haftmann@30352
  1113
  sup  (infixl "\<squnion>" 65)
haftmann@30352
  1114
haftmann@30352
  1115
class complete_lattice = lattice + bot + top +
haftmann@30352
  1116
  fixes Inf :: "'a set \<Rightarrow> 'a" ("\<Sqinter>_" [900] 900)
haftmann@30352
  1117
    and Sup :: "'a set \<Rightarrow> 'a" ("\<Squnion>_" [900] 900)
haftmann@30352
  1118
  assumes Inf_lower: "x \<in> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> x"
haftmann@30352
  1119
    and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A"
haftmann@30352
  1120
  assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A"
haftmann@30352
  1121
    and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z"
haftmann@30352
  1122
begin
haftmann@30352
  1123
haftmann@30352
  1124
lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<le> a}"
haftmann@30352
  1125
  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
haftmann@30352
  1126
haftmann@30352
  1127
lemma Sup_Inf:  "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<le> b}"
haftmann@30352
  1128
  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
haftmann@30352
  1129
haftmann@30352
  1130
lemma Inf_Univ: "\<Sqinter>UNIV = \<Squnion>{}"
haftmann@30352
  1131
  unfolding Sup_Inf by auto
haftmann@30352
  1132
haftmann@30352
  1133
lemma Sup_Univ: "\<Squnion>UNIV = \<Sqinter>{}"
haftmann@30352
  1134
  unfolding Inf_Sup by auto
haftmann@30352
  1135
haftmann@30352
  1136
lemma Inf_insert: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A"
haftmann@30352
  1137
  by (auto intro: antisym Inf_greatest Inf_lower)
haftmann@30352
  1138
haftmann@30352
  1139
lemma Sup_insert: "\<Squnion>insert a A = a \<squnion> \<Squnion>A"
haftmann@30352
  1140
  by (auto intro: antisym Sup_least Sup_upper)
haftmann@30352
  1141
haftmann@30352
  1142
lemma Inf_singleton [simp]:
haftmann@30352
  1143
  "\<Sqinter>{a} = a"
haftmann@30352
  1144
  by (auto intro: antisym Inf_lower Inf_greatest)
haftmann@30352
  1145
haftmann@30352
  1146
lemma Sup_singleton [simp]:
haftmann@30352
  1147
  "\<Squnion>{a} = a"
haftmann@30352
  1148
  by (auto intro: antisym Sup_upper Sup_least)
haftmann@30352
  1149
haftmann@30352
  1150
lemma Inf_insert_simp:
haftmann@30352
  1151
  "\<Sqinter>insert a A = (if A = {} then a else a \<sqinter> \<Sqinter>A)"
haftmann@30352
  1152
  by (cases "A = {}") (simp_all, simp add: Inf_insert)
haftmann@30352
  1153
haftmann@30352
  1154
lemma Sup_insert_simp:
haftmann@30352
  1155
  "\<Squnion>insert a A = (if A = {} then a else a \<squnion> \<Squnion>A)"
haftmann@30352
  1156
  by (cases "A = {}") (simp_all, simp add: Sup_insert)
haftmann@30352
  1157
haftmann@30352
  1158
lemma Inf_binary:
haftmann@30352
  1159
  "\<Sqinter>{a, b} = a \<sqinter> b"
haftmann@30352
  1160
  by (simp add: Inf_insert_simp)
haftmann@30352
  1161
haftmann@30352
  1162
lemma Sup_binary:
haftmann@30352
  1163
  "\<Squnion>{a, b} = a \<squnion> b"
haftmann@30352
  1164
  by (simp add: Sup_insert_simp)
haftmann@30352
  1165
haftmann@30352
  1166
lemma bot_def:
haftmann@30352
  1167
  "bot = \<Squnion>{}"
haftmann@30352
  1168
  by (auto intro: antisym Sup_least)
haftmann@30352
  1169
haftmann@30352
  1170
lemma top_def:
haftmann@30352
  1171
  "top = \<Sqinter>{}"
haftmann@30352
  1172
  by (auto intro: antisym Inf_greatest)
haftmann@30352
  1173
haftmann@30352
  1174
lemma sup_bot [simp]:
haftmann@30352
  1175
  "x \<squnion> bot = x"
haftmann@30352
  1176
  using bot_least [of x] by (simp add: le_iff_sup sup_commute)
haftmann@30352
  1177
haftmann@30352
  1178
lemma inf_top [simp]:
haftmann@30352
  1179
  "x \<sqinter> top = x"
haftmann@30352
  1180
  using top_greatest [of x] by (simp add: le_iff_inf inf_commute)
haftmann@30352
  1181
haftmann@30352
  1182
definition SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
haftmann@30352
  1183
  "SUPR A f == \<Squnion> (f ` A)"
haftmann@30352
  1184
haftmann@30352
  1185
definition INFI :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
haftmann@30352
  1186
  "INFI A f == \<Sqinter> (f ` A)"
haftmann@30352
  1187
haftmann@30352
  1188
end
haftmann@30352
  1189
haftmann@30352
  1190
syntax
haftmann@30352
  1191
  "_SUP1"     :: "pttrns => 'b => 'b"           ("(3SUP _./ _)" [0, 10] 10)
haftmann@30352
  1192
  "_SUP"      :: "pttrn => 'a set => 'b => 'b"  ("(3SUP _:_./ _)" [0, 10] 10)
haftmann@30352
  1193
  "_INF1"     :: "pttrns => 'b => 'b"           ("(3INF _./ _)" [0, 10] 10)
haftmann@30352
  1194
  "_INF"      :: "pttrn => 'a set => 'b => 'b"  ("(3INF _:_./ _)" [0, 10] 10)
haftmann@30352
  1195
haftmann@30352
  1196
translations
haftmann@30352
  1197
  "SUP x y. B"   == "SUP x. SUP y. B"
haftmann@30352
  1198
  "SUP x. B"     == "CONST SUPR CONST UNIV (%x. B)"
haftmann@30352
  1199
  "SUP x. B"     == "SUP x:CONST UNIV. B"
haftmann@30352
  1200
  "SUP x:A. B"   == "CONST SUPR A (%x. B)"
haftmann@30352
  1201
  "INF x y. B"   == "INF x. INF y. B"
haftmann@30352
  1202
  "INF x. B"     == "CONST INFI CONST UNIV (%x. B)"
haftmann@30352
  1203
  "INF x. B"     == "INF x:CONST UNIV. B"
haftmann@30352
  1204
  "INF x:A. B"   == "CONST INFI A (%x. B)"
haftmann@30352
  1205
haftmann@30352
  1206
(* To avoid eta-contraction of body: *)
haftmann@30352
  1207
print_translation {*
haftmann@30352
  1208
let
haftmann@30352
  1209
  fun btr' syn (A :: Abs abs :: ts) =
haftmann@30352
  1210
    let val (x,t) = atomic_abs_tr' abs
haftmann@30352
  1211
    in list_comb (Syntax.const syn $ x $ A $ t, ts) end
haftmann@30352
  1212
  val const_syntax_name = Sign.const_syntax_name @{theory} o fst o dest_Const
haftmann@30352
  1213
in
haftmann@30352
  1214
[(const_syntax_name @{term SUPR}, btr' "_SUP"),(const_syntax_name @{term "INFI"}, btr' "_INF")]
haftmann@30352
  1215
end
haftmann@30352
  1216
*}
haftmann@30352
  1217
haftmann@30352
  1218
context complete_lattice
haftmann@30352
  1219
begin
haftmann@30352
  1220
haftmann@30352
  1221
lemma le_SUPI: "i : A \<Longrightarrow> M i \<le> (SUP i:A. M i)"
haftmann@30352
  1222
  by (auto simp add: SUPR_def intro: Sup_upper)
haftmann@30352
  1223
haftmann@30352
  1224
lemma SUP_leI: "(\<And>i. i : A \<Longrightarrow> M i \<le> u) \<Longrightarrow> (SUP i:A. M i) \<le> u"
haftmann@30352
  1225
  by (auto simp add: SUPR_def intro: Sup_least)
haftmann@30352
  1226
haftmann@30352
  1227
lemma INF_leI: "i : A \<Longrightarrow> (INF i:A. M i) \<le> M i"
haftmann@30352
  1228
  by (auto simp add: INFI_def intro: Inf_lower)
haftmann@30352
  1229
haftmann@30352
  1230
lemma le_INFI: "(\<And>i. i : A \<Longrightarrow> u \<le> M i) \<Longrightarrow> u \<le> (INF i:A. M i)"
haftmann@30352
  1231
  by (auto simp add: INFI_def intro: Inf_greatest)
haftmann@30352
  1232
haftmann@30352
  1233
lemma SUP_const[simp]: "A \<noteq> {} \<Longrightarrow> (SUP i:A. M) = M"
haftmann@30352
  1234
  by (auto intro: antisym SUP_leI le_SUPI)
haftmann@30352
  1235
haftmann@30352
  1236
lemma INF_const[simp]: "A \<noteq> {} \<Longrightarrow> (INF i:A. M) = M"
haftmann@30352
  1237
  by (auto intro: antisym INF_leI le_INFI)
haftmann@30352
  1238
haftmann@30352
  1239
end
haftmann@30352
  1240
haftmann@30352
  1241
subsubsection {* Bool as complete lattice *}
haftmann@30352
  1242
haftmann@30352
  1243
instantiation bool :: complete_lattice
haftmann@30352
  1244
begin
haftmann@30352
  1245
haftmann@30352
  1246
definition
haftmann@30352
  1247
  Inf_bool_def: "\<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x)"
haftmann@30352
  1248
haftmann@30352
  1249
definition
haftmann@30352
  1250
  Sup_bool_def: "\<Squnion>A \<longleftrightarrow> (\<exists>x\<in>A. x)"
haftmann@30352
  1251
haftmann@30352
  1252
instance
haftmann@30352
  1253
  by intro_classes (auto simp add: Inf_bool_def Sup_bool_def le_bool_def)
haftmann@30352
  1254
haftmann@30352
  1255
end
haftmann@30352
  1256
haftmann@30352
  1257
lemma Inf_empty_bool [simp]:
haftmann@30352
  1258
  "\<Sqinter>{}"
haftmann@30352
  1259
  unfolding Inf_bool_def by auto
haftmann@30352
  1260
haftmann@30352
  1261
lemma not_Sup_empty_bool [simp]:
haftmann@30352
  1262
  "\<not> Sup {}"
haftmann@30352
  1263
  unfolding Sup_bool_def by auto
haftmann@30352
  1264
haftmann@30352
  1265
haftmann@30352
  1266
subsubsection {* Fun as complete lattice *}
haftmann@30352
  1267
haftmann@30352
  1268
instantiation "fun" :: (type, complete_lattice) complete_lattice
haftmann@30352
  1269
begin
haftmann@30352
  1270
haftmann@30352
  1271
definition
haftmann@30352
  1272
  Inf_fun_def [code del]: "\<Sqinter>A = (\<lambda>x. \<Sqinter>{y. \<exists>f\<in>A. y = f x})"
haftmann@30352
  1273
haftmann@30352
  1274
definition
haftmann@30352
  1275
  Sup_fun_def [code del]: "\<Squnion>A = (\<lambda>x. \<Squnion>{y. \<exists>f\<in>A. y = f x})"
haftmann@30352
  1276
haftmann@30352
  1277
instance
haftmann@30352
  1278
  by intro_classes
haftmann@30352
  1279
    (auto simp add: Inf_fun_def Sup_fun_def le_fun_def
haftmann@30352
  1280
      intro: Inf_lower Sup_upper Inf_greatest Sup_least)
haftmann@30352
  1281
haftmann@30352
  1282
end
haftmann@30352
  1283
haftmann@30352
  1284
lemma Inf_empty_fun:
haftmann@30352
  1285
  "\<Sqinter>{} = (\<lambda>_. \<Sqinter>{})"
haftmann@30352
  1286
  by rule (auto simp add: Inf_fun_def)
haftmann@30352
  1287
haftmann@30352
  1288
lemma Sup_empty_fun:
haftmann@30352
  1289
  "\<Squnion>{} = (\<lambda>_. \<Squnion>{})"
haftmann@30352
  1290
  by rule (auto simp add: Sup_fun_def)
haftmann@30352
  1291
haftmann@30352
  1292
no_notation
haftmann@30352
  1293
  less_eq  (infix "\<sqsubseteq>" 50) and
haftmann@30352
  1294
  less (infix "\<sqsubset>" 50) and
haftmann@30352
  1295
  inf  (infixl "\<sqinter>" 70) and
haftmann@30352
  1296
  sup  (infixl "\<squnion>" 65) and
haftmann@30352
  1297
  Inf  ("\<Sqinter>_" [900] 900) and
haftmann@30352
  1298
  Sup  ("\<Squnion>_" [900] 900)
haftmann@30352
  1299
haftmann@30352
  1300
haftmann@30352
  1301
subsection {* Further operations *}
haftmann@30352
  1302
haftmann@30352
  1303
subsubsection {* Big families as specialisation of lattice operations *}
haftmann@30352
  1304
haftmann@30352
  1305
definition INTER :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
haftmann@30352
  1306
  "INTER A B \<equiv> {y. \<forall>x\<in>A. y \<in> B x}"
haftmann@30352
  1307
haftmann@30352
  1308
definition UNION :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
haftmann@30352
  1309
  "UNION A B \<equiv> {y. \<exists>x\<in>A. y \<in> B x}"
haftmann@30352
  1310
haftmann@30352
  1311
definition Inter :: "'a set set \<Rightarrow> 'a set" where
haftmann@30352
  1312
  "Inter S \<equiv> INTER S (\<lambda>x. x)"
haftmann@30352
  1313
haftmann@30352
  1314
definition Union :: "'a set set \<Rightarrow> 'a set" where
haftmann@30352
  1315
  "Union S \<equiv> UNION S (\<lambda>x. x)"
haftmann@30352
  1316
haftmann@30352
  1317
notation (xsymbols)
haftmann@30352
  1318
  Inter  ("\<Inter>_" [90] 90) and
haftmann@30352
  1319
  Union  ("\<Union>_" [90] 90)
haftmann@30352
  1320
haftmann@30352
  1321
syntax
haftmann@30352
  1322
  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3INT _./ _)" [0, 10] 10)
haftmann@30352
  1323
  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3UN _./ _)" [0, 10] 10)
haftmann@30352
  1324
  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3INT _:_./ _)" [0, 10] 10)
haftmann@30352
  1325
  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3UN _:_./ _)" [0, 10] 10)
haftmann@30352
  1326
haftmann@30352
  1327
syntax (xsymbols)
haftmann@30352
  1328
  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>_./ _)" [0, 10] 10)
haftmann@30352
  1329
  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>_./ _)" [0, 10] 10)
haftmann@30352
  1330
  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>_\<in>_./ _)" [0, 10] 10)
haftmann@30352
  1331
  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>_\<in>_./ _)" [0, 10] 10)
haftmann@30352
  1332
haftmann@30352
  1333
syntax (latex output)
haftmann@30352
  1334
  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
haftmann@30352
  1335
  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
haftmann@30352
  1336
  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 10] 10)
haftmann@30352
  1337
  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 10] 10)
haftmann@30352
  1338
haftmann@30352
  1339
translations
haftmann@30352
  1340
  "INT x y. B"  == "INT x. INT y. B"
haftmann@30352
  1341
  "INT x. B"    == "CONST INTER CONST UNIV (%x. B)"
haftmann@30352
  1342
  "INT x. B"    == "INT x:CONST UNIV. B"
haftmann@30352
  1343
  "INT x:A. B"  == "CONST INTER A (%x. B)"
haftmann@30352
  1344
  "UN x y. B"   == "UN x. UN y. B"
haftmann@30352
  1345
  "UN x. B"     == "CONST UNION CONST UNIV (%x. B)"
haftmann@30352
  1346
  "UN x. B"     == "UN x:CONST UNIV. B"
haftmann@30352
  1347
  "UN x:A. B"   == "CONST UNION A (%x. B)"
clasohm@923
  1348
wenzelm@11979
  1349
text {*
haftmann@30352
  1350
  Note the difference between ordinary xsymbol syntax of indexed
haftmann@30352
  1351
  unions and intersections (e.g.\ @{text"\<Union>a\<^isub>1\<in>A\<^isub>1. B"})
haftmann@30352
  1352
  and their \LaTeX\ rendition: @{term"\<Union>a\<^isub>1\<in>A\<^isub>1. B"}. The
haftmann@30352
  1353
  former does not make the index expression a subscript of the
haftmann@30352
  1354
  union/intersection symbol because this leads to problems with nested
haftmann@30352
  1355
  subscripts in Proof General.
wenzelm@11979
  1356
*}
wenzelm@11979
  1357
haftmann@30352
  1358
(* To avoid eta-contraction of body: *)
haftmann@30352
  1359
(*FIXME  integrate with / factor out from similar situations*)
haftmann@30352
  1360
print_translation {*
haftmann@30352
  1361
let
haftmann@30352
  1362
  fun btr' syn [A, Abs abs] =
haftmann@30352
  1363
    let val (x, t) = atomic_abs_tr' abs
haftmann@30352
  1364
    in Syntax.const syn $ x $ A $ t end
haftmann@30352
  1365
in
haftmann@30352
  1366
[(@{const_syntax Ball}, btr' "_Ball"), (@{const_syntax Bex}, btr' "_Bex"),
haftmann@30352
  1367
 (@{const_syntax UNION}, btr' "@UNION"),(@{const_syntax INTER}, btr' "@INTER")]
haftmann@30352
  1368
end
haftmann@30352
  1369
*}
wenzelm@11979
  1370
wenzelm@11979
  1371
subsubsection {* Unions of families *}
wenzelm@11979
  1372
wenzelm@11979
  1373
text {*
wenzelm@11979
  1374
  @{term [source] "UN x:A. B x"} is @{term "Union (B`A)"}.
wenzelm@11979
  1375
*}
wenzelm@11979
  1376
paulson@24286
  1377
declare UNION_def [noatp]
paulson@24286
  1378
wenzelm@11979
  1379
lemma UN_iff [simp]: "(b: (UN x:A. B x)) = (EX x:A. b: B x)"
wenzelm@11979
  1380
  by (unfold UNION_def) blast
wenzelm@11979
  1381
wenzelm@11979
  1382
lemma UN_I [intro]: "a:A ==> b: B a ==> b: (UN x:A. B x)"
wenzelm@11979
  1383
  -- {* The order of the premises presupposes that @{term A} is rigid;
wenzelm@11979
  1384
    @{term b} may be flexible. *}
wenzelm@11979
  1385
  by auto
wenzelm@11979
  1386
wenzelm@11979
  1387
lemma UN_E [elim!]: "b : (UN x:A. B x) ==> (!!x. x:A ==> b: B x ==> R) ==> R"
wenzelm@11979
  1388
  by (unfold UNION_def) blast
clasohm@923
  1389
wenzelm@11979
  1390
lemma UN_cong [cong]:
wenzelm@11979
  1391
    "A = B ==> (!!x. x:B ==> C x = D x) ==> (UN x:A. C x) = (UN x:B. D x)"
wenzelm@11979
  1392
  by (simp add: UNION_def)
wenzelm@11979
  1393
berghofe@29691
  1394
lemma strong_UN_cong:
berghofe@29691
  1395
    "A = B ==> (!!x. x:B =simp=> C x = D x) ==> (UN x:A. C x) = (UN x:B. D x)"
berghofe@29691
  1396
  by (simp add: UNION_def simp_implies_def)
berghofe@29691
  1397
haftmann@30352
  1398
lemma image_eq_UN: "f`A = (UN x:A. {f x})"
haftmann@30352
  1399
  by blast
haftmann@30352
  1400
wenzelm@11979
  1401
wenzelm@11979
  1402
subsubsection {* Intersections of families *}
wenzelm@11979
  1403
wenzelm@11979
  1404
text {* @{term [source] "INT x:A. B x"} is @{term "Inter (B`A)"}. *}
wenzelm@11979
  1405
wenzelm@11979
  1406
lemma INT_iff [simp]: "(b: (INT x:A. B x)) = (ALL x:A. b: B x)"
wenzelm@11979
  1407
  by (unfold INTER_def) blast
clasohm@923
  1408
wenzelm@11979
  1409
lemma INT_I [intro!]: "(!!x. x:A ==> b: B x) ==> b : (INT x:A. B x)"
wenzelm@11979
  1410
  by (unfold INTER_def) blast
wenzelm@11979
  1411
wenzelm@11979
  1412
lemma INT_D [elim]: "b : (INT x:A. B x) ==> a:A ==> b: B a"
wenzelm@11979
  1413
  by auto
wenzelm@11979
  1414
wenzelm@11979
  1415
lemma INT_E [elim]: "b : (INT x:A. B x) ==> (b: B a ==> R) ==> (a~:A ==> R) ==> R"
wenzelm@11979
  1416
  -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a:A"}. *}
wenzelm@11979
  1417
  by (unfold INTER_def) blast
wenzelm@11979
  1418
wenzelm@11979
  1419
lemma INT_cong [cong]:
wenzelm@11979
  1420
    "A = B ==> (!!x. x:B ==> C x = D x) ==> (INT x:A. C x) = (INT x:B. D x)"
wenzelm@11979
  1421
  by (simp add: INTER_def)
wenzelm@7238
  1422
clasohm@923
  1423
wenzelm@11979
  1424
subsubsection {* Union *}
wenzelm@11979
  1425
paulson@24286
  1426
lemma Union_iff [simp,noatp]: "(A : Union C) = (EX X:C. A:X)"
wenzelm@11979
  1427
  by (unfold Union_def) blast
wenzelm@11979
  1428
wenzelm@11979
  1429
lemma UnionI [intro]: "X:C ==> A:X ==> A : Union C"
wenzelm@11979
  1430
  -- {* The order of the premises presupposes that @{term C} is rigid;
wenzelm@11979
  1431
    @{term A} may be flexible. *}
wenzelm@11979
  1432
  by auto
wenzelm@11979
  1433
wenzelm@11979
  1434
lemma UnionE [elim!]: "A : Union C ==> (!!X. A:X ==> X:C ==> R) ==> R"
wenzelm@11979
  1435
  by (unfold Union_def) blast
wenzelm@11979
  1436
wenzelm@11979
  1437
wenzelm@11979
  1438
subsubsection {* Inter *}
wenzelm@11979
  1439
paulson@24286
  1440
lemma Inter_iff [simp,noatp]: "(A : Inter C) = (ALL X:C. A:X)"
wenzelm@11979
  1441
  by (unfold Inter_def) blast
wenzelm@11979
  1442
wenzelm@11979
  1443
lemma InterI [intro!]: "(!!X. X:C ==> A:X) ==> A : Inter C"
wenzelm@11979
  1444
  by (simp add: Inter_def)
wenzelm@11979
  1445
wenzelm@11979
  1446
text {*
wenzelm@11979
  1447
  \medskip A ``destruct'' rule -- every @{term X} in @{term C}
wenzelm@11979
  1448
  contains @{term A} as an element, but @{prop "A:X"} can hold when
wenzelm@11979
  1449
  @{prop "X:C"} does not!  This rule is analogous to @{text spec}.
wenzelm@11979
  1450
*}
wenzelm@11979
  1451
wenzelm@11979
  1452
lemma InterD [elim]: "A : Inter C ==> X:C ==> A:X"
wenzelm@11979
  1453
  by auto
wenzelm@11979
  1454
wenzelm@11979
  1455
lemma InterE [elim]: "A : Inter C ==> (X~:C ==> R) ==> (A:X ==> R) ==> R"
wenzelm@11979
  1456
  -- {* ``Classical'' elimination rule -- does not require proving
wenzelm@11979
  1457
    @{prop "X:C"}. *}
wenzelm@11979
  1458
  by (unfold Inter_def) blast
wenzelm@11979
  1459
wenzelm@12897
  1460
wenzelm@12897
  1461
wenzelm@12897
  1462
text {* \medskip Big Union -- least upper bound of a set. *}
wenzelm@12897
  1463
wenzelm@12897
  1464
lemma Union_upper: "B \<in> A ==> B \<subseteq> Union A"
nipkow@17589
  1465
  by (iprover intro: subsetI UnionI)
wenzelm@12897
  1466
wenzelm@12897
  1467
lemma Union_least: "(!!X. X \<in> A ==> X \<subseteq> C) ==> Union A \<subseteq> C"
nipkow@17589
  1468
  by (iprover intro: subsetI elim: UnionE dest: subsetD)
wenzelm@12897
  1469
haftmann@30352
  1470
lemma Sup_set_eq: "Sup S = \<Union>S"
haftmann@30352
  1471
  apply (rule subset_antisym)
haftmann@30352
  1472
  apply (rule Sup_least)
haftmann@30352
  1473
  apply (erule Union_upper)
haftmann@30352
  1474
  apply (rule Union_least)
haftmann@30352
  1475
  apply (erule Sup_upper)
haftmann@30352
  1476
  done
haftmann@30352
  1477
wenzelm@12897
  1478
wenzelm@12897
  1479
text {* \medskip General union. *}
wenzelm@12897
  1480
wenzelm@12897
  1481
lemma UN_upper: "a \<in> A ==> B a \<subseteq> (\<Union>x\<in>A. B x)"
wenzelm@12897
  1482
  by blast
wenzelm@12897
  1483
wenzelm@12897
  1484
lemma UN_least: "(!!x. x \<in> A ==> B x \<subseteq> C) ==> (\<Union>x\<in>A. B x) \<subseteq> C"
nipkow@17589
  1485
  by (iprover intro: subsetI elim: UN_E dest: subsetD)
wenzelm@12897
  1486
wenzelm@12897
  1487
wenzelm@12897
  1488
text {* \medskip Big Intersection -- greatest lower bound of a set. *}
wenzelm@12897
  1489
wenzelm@12897
  1490
lemma Inter_lower: "B \<in> A ==> Inter A \<subseteq> B"
wenzelm@12897
  1491
  by blast
wenzelm@12897
  1492
ballarin@14551
  1493
lemma Inter_subset:
ballarin@14551
  1494
  "[| !!X. X \<in> A ==> X \<subseteq> B; A ~= {} |] ==> \<Inter>A \<subseteq> B"
ballarin@14551
  1495
  by blast
ballarin@14551
  1496
wenzelm@12897
  1497
lemma Inter_greatest: "(!!X. X \<in> A ==> C \<subseteq> X) ==> C \<subseteq> Inter A"
nipkow@17589
  1498
  by (iprover intro: InterI subsetI dest: subsetD)
wenzelm@12897
  1499
haftmann@30352
  1500
lemma Inf_set_eq: "Inf S = \<Inter>S"
haftmann@30352
  1501
  apply (rule subset_antisym)
haftmann@30352
  1502
  apply (rule Inter_greatest)
haftmann@30352
  1503
  apply (erule Inf_lower)
haftmann@30352
  1504
  apply (rule Inf_greatest)
haftmann@30352
  1505
  apply (erule Inter_lower)
haftmann@30352
  1506
  done
haftmann@30352
  1507
wenzelm@12897
  1508
lemma INT_lower: "a \<in> A ==> (\<Inter>x\<in>A. B x) \<subseteq> B a"
wenzelm@12897
  1509
  by blast
wenzelm@12897
  1510
wenzelm@12897
  1511
lemma INT_greatest: "(!!x. x \<in> A ==> C \<subseteq> B x) ==> C \<subseteq> (\<Inter>x\<in>A. B x)"
nipkow@17589
  1512
  by (iprover intro: INT_I subsetI dest: subsetD)
wenzelm@12897
  1513
haftmann@30352
  1514
lemma UN_insert_distrib: "u \<in> A ==> (\<Union>x\<in>A. insert a (B x)) = insert a (\<Union>x\<in>A. B x)"
wenzelm@12897
  1515
  by blast
wenzelm@12897
  1516
wenzelm@12897
  1517
lemma Collect_all_eq: "{x. \<forall>y. P x y} = (\<Inter>y. {x. P x y})"
wenzelm@12897
  1518
  by blast
wenzelm@12897
  1519
wenzelm@12897
  1520
lemma Collect_ball_eq: "{x. \<forall>y\<in>A. P x y} = (\<Inter>y\<in>A. {x. P x y})"
wenzelm@12897
  1521
  by blast
wenzelm@12897
  1522
paulson@24286
  1523
lemma Collect_ex_eq [noatp]: "{x. \<exists>y. P x y} = (\<Union>y. {x. P x y})"
wenzelm@12897
  1524
  by blast
wenzelm@12897
  1525
paulson@24286
  1526
lemma Collect_bex_eq [noatp]: "{x. \<exists>y\<in>A. P x y} = (\<Union>y\<in>A. {x. P x y})"
wenzelm@12897
  1527
  by blast
wenzelm@12897
  1528
wenzelm@12897
  1529
haftmann@30352
  1530
subsubsection {* The Powerset operator -- Pow *}
haftmann@30352
  1531
haftmann@30352
  1532
global
haftmann@30352
  1533
haftmann@30352
  1534
consts
haftmann@30352
  1535
  Pow           :: "'a set => 'a set set"
haftmann@30352
  1536
haftmann@30352
  1537
local
haftmann@30352
  1538
haftmann@30352
  1539
defs
haftmann@30352
  1540
  Pow_def:      "Pow A          == {B. B <= A}"
haftmann@30352
  1541
haftmann@30352
  1542
lemma Pow_iff [iff]: "(A \<in> Pow B) = (A \<subseteq> B)"
haftmann@30352
  1543
  by (simp add: Pow_def)
haftmann@30352
  1544
haftmann@30352
  1545
lemma PowI: "A \<subseteq> B ==> A \<in> Pow B"
haftmann@30352
  1546
  by (simp add: Pow_def)
haftmann@30352
  1547
haftmann@30352
  1548
lemma PowD: "A \<in> Pow B ==> A \<subseteq> B"
haftmann@30352
  1549
  by (simp add: Pow_def)
haftmann@30352
  1550
haftmann@30352
  1551
lemma Pow_bottom: "{} \<in> Pow B"
haftmann@30352
  1552
  by simp
haftmann@30352
  1553
haftmann@30352
  1554
lemma Pow_top: "A \<in> Pow A"
haftmann@30352
  1555
  by (simp add: subset_refl)
haftmann@30352
  1556
haftmann@30352
  1557
haftmann@30352
  1558
haftmann@30352
  1559
subsubsection {* Getting the Contents of a Singleton Set *}
haftmann@30352
  1560
haftmann@30352
  1561
definition contents :: "'a set \<Rightarrow> 'a" where
haftmann@30352
  1562
  [code del]: "contents X = (THE x. X = {x})"
haftmann@30352
  1563
haftmann@30352
  1564
lemma contents_eq [simp]: "contents {x} = x"
haftmann@30352
  1565
  by (simp add: contents_def)
haftmann@30352
  1566
haftmann@30352
  1567
haftmann@30352
  1568
subsubsection {* Range of a function -- just a translation for image! *}
haftmann@30352
  1569
haftmann@30352
  1570
abbreviation
haftmann@30352
  1571
  range :: "('a => 'b) => 'b set" where -- "of function"
haftmann@30352
  1572
  "range f == f ` UNIV"
haftmann@30352
  1573
haftmann@30352
  1574
lemma range_eqI: "b = f x ==> b \<in> range f"
haftmann@30352
  1575
  by simp
haftmann@30352
  1576
haftmann@30352
  1577
lemma rangeI: "f x \<in> range f"
haftmann@30352
  1578
  by simp
haftmann@30352
  1579
haftmann@30352
  1580
lemma rangeE [elim?]: "b \<in> range (\<lambda>x. f x) ==> (!!x. b = f x ==> P) ==> P"
mehta@14742
  1581
  by blast
nipkow@14302
  1582
paulson@24286
  1583
lemma full_SetCompr_eq [noatp]: "{u. \<exists>x. u = f x} = range f"
wenzelm@12897
  1584
  by auto
wenzelm@12897
  1585
huffman@27418
  1586
lemma range_composition: "range (\<lambda>x. f (g x)) = f`range g"
paulson@14208
  1587
by (subst image_image, simp)
wenzelm@12897
  1588
wenzelm@12897
  1589
haftmann@30352
  1590
subsection {* Further rules and properties *}
haftmann@30352
  1591
wenzelm@12897
  1592
text {* \medskip @{text Int} *}
wenzelm@12897
  1593
wenzelm@12897
  1594
lemma Int_absorb [simp]: "A \<inter> A = A"
wenzelm@12897
  1595
  by blast
wenzelm@12897
  1596
wenzelm@12897
  1597
lemma Int_left_absorb: "A \<inter> (A \<inter> B) = A \<inter> B"
wenzelm@12897
  1598
  by blast
wenzelm@12897
  1599
wenzelm@12897
  1600
lemma Int_commute: "A \<inter> B = B \<inter> A"
wenzelm@12897
  1601
  by blast
wenzelm@12897
  1602
wenzelm@12897
  1603
lemma Int_left_commute: "A \<inter> (B \<inter> C) = B \<inter> (A \<inter> C)"
wenzelm@12897
  1604
  by blast
wenzelm@12897
  1605
wenzelm@12897
  1606
lemma Int_assoc: "(A \<inter> B) \<inter> C = A \<inter> (B \<inter> C)"
wenzelm@12897
  1607
  by blast
wenzelm@12897
  1608
wenzelm@12897
  1609
lemmas Int_ac = Int_assoc Int_left_absorb Int_commute Int_left_commute
wenzelm@12897
  1610
  -- {* Intersection is an AC-operator *}
wenzelm@12897
  1611
wenzelm@12897
  1612
lemma Int_absorb1: "B \<subseteq> A ==> A \<inter> B = B"
wenzelm@12897
  1613
  by blast
wenzelm@12897
  1614
wenzelm@12897
  1615
lemma Int_absorb2: "A \<subseteq> B ==> A \<inter> B = A"
wenzelm@12897
  1616
  by blast
wenzelm@12897
  1617
wenzelm@12897
  1618
lemma Int_empty_left [simp]: "{} \<inter> B = {}"
wenzelm@12897
  1619
  by blast
wenzelm@12897
  1620
wenzelm@12897
  1621
lemma Int_empty_right [simp]: "A \<inter> {} = {}"
wenzelm@12897
  1622
  by blast
wenzelm@12897
  1623
wenzelm@12897
  1624
lemma disjoint_eq_subset_Compl: "(A \<inter> B = {}) = (A \<subseteq> -B)"
wenzelm@12897
  1625
  by blast
wenzelm@12897
  1626
wenzelm@12897
  1627
lemma disjoint_iff_not_equal: "(A \<inter> B = {}) = (\<forall>x\<in>A. \<forall>y\<in>B. x \<noteq> y)"
wenzelm@12897
  1628
  by blast
wenzelm@12897
  1629
wenzelm@12897
  1630
lemma Int_UNIV_left [simp]: "UNIV \<inter> B = B"
wenzelm@12897
  1631
  by blast
wenzelm@12897
  1632
wenzelm@12897
  1633
lemma Int_UNIV_right [simp]: "A \<inter> UNIV = A"
wenzelm@12897
  1634
  by blast
wenzelm@12897
  1635
wenzelm@12897
  1636
lemma Int_eq_Inter: "A \<inter> B = \<Inter>{A, B}"
wenzelm@12897
  1637
  by blast
wenzelm@12897
  1638
wenzelm@12897
  1639
lemma Int_Un_distrib: "A \<inter> (B \<union> C) = (A \<inter> B) \<union> (A \<inter> C)"
wenzelm@12897
  1640
  by blast
wenzelm@12897
  1641
wenzelm@12897
  1642
lemma Int_Un_distrib2: "(B \<union> C) \<inter> A = (B \<inter> A) \<union> (C \<inter> A)"
wenzelm@12897
  1643
  by blast
wenzelm@12897
  1644
paulson@24286
  1645
lemma Int_UNIV [simp,noatp]: "(A \<inter> B = UNIV) = (A = UNIV & B = UNIV)"
wenzelm@12897
  1646
  by blast
wenzelm@12897
  1647
paulson@15102
  1648
lemma Int_subset_iff [simp]: "(C \<subseteq> A \<inter> B) = (C \<subseteq> A & C \<subseteq> B)"
wenzelm@12897
  1649
  by blast
wenzelm@12897
  1650
wenzelm@12897
  1651
lemma Int_Collect: "(x \<in> A \<inter> {x. P x}) = (x \<in> A & P x)"
wenzelm@12897
  1652
  by blast
wenzelm@12897
  1653
wenzelm@12897
  1654
wenzelm@12897
  1655
text {* \medskip @{text Un}. *}
wenzelm@12897
  1656
wenzelm@12897
  1657
lemma Un_absorb [simp]: "A \<union> A = A"
wenzelm@12897
  1658
  by blast
wenzelm@12897
  1659
wenzelm@12897
  1660
lemma Un_left_absorb: "A \<union> (A \<union> B) = A \<union> B"
wenzelm@12897
  1661
  by blast
wenzelm@12897
  1662
wenzelm@12897
  1663
lemma Un_commute: "A \<union> B = B \<union> A"
wenzelm@12897
  1664
  by blast
wenzelm@12897
  1665
wenzelm@12897
  1666
lemma Un_left_commute: "A \<union> (B \<union> C) = B \<union> (A \<union> C)"
wenzelm@12897
  1667
  by blast
wenzelm@12897
  1668
wenzelm@12897
  1669
lemma Un_assoc: "(A \<union> B) \<union> C = A \<union> (B \<union> C)"
wenzelm@12897
  1670
  by blast
wenzelm@12897
  1671
wenzelm@12897
  1672
lemmas Un_ac = Un_assoc Un_left_absorb Un_commute Un_left_commute
wenzelm@12897
  1673
  -- {* Union is an AC-operator *}
wenzelm@12897
  1674
wenzelm@12897
  1675
lemma Un_absorb1: "A \<subseteq> B ==> A \<union> B = B"
wenzelm@12897
  1676
  by blast
wenzelm@12897
  1677
wenzelm@12897
  1678
lemma Un_absorb2: "B \<subseteq> A ==> A \<union> B = A"
wenzelm@12897
  1679
  by blast
wenzelm@12897
  1680
wenzelm@12897
  1681
lemma Un_empty_left [simp]: "{} \<union> B = B"
wenzelm@12897
  1682
  by blast
wenzelm@12897
  1683
wenzelm@12897
  1684
lemma Un_empty_right [simp]: "A \<union> {} = A"
wenzelm@12897
  1685
  by blast
wenzelm@12897
  1686
wenzelm@12897
  1687
lemma Un_UNIV_left [simp]: "UNIV \<union> B = UNIV"
wenzelm@12897
  1688
  by blast
wenzelm@12897
  1689
wenzelm@12897
  1690
lemma Un_UNIV_right [simp]: "A \<union> UNIV = UNIV"
wenzelm@12897
  1691
  by blast
wenzelm@12897
  1692
wenzelm@12897
  1693
lemma Un_eq_Union: "A \<union> B = \<Union>{A, B}"
wenzelm@12897
  1694
  by blast
wenzelm@12897
  1695
wenzelm@12897
  1696
lemma Un_insert_left [simp]: "(insert a B) \<union> C = insert a (B \<union> C)"
wenzelm@12897
  1697
  by blast
wenzelm@12897
  1698
wenzelm@12897
  1699
lemma Un_insert_right [simp]: "A \<union> (insert a B) = insert a (A \<union> B)"
wenzelm@12897
  1700
  by blast
wenzelm@12897
  1701
wenzelm@12897
  1702
lemma Int_insert_left:
wenzelm@12897
  1703
    "(insert a B) Int C = (if a \<in> C then insert a (B \<inter> C) else B \<inter> C)"
wenzelm@12897
  1704
  by auto
wenzelm@12897
  1705
wenzelm@12897
  1706
lemma Int_insert_right:
wenzelm@12897
  1707
    "A \<inter> (insert a B) = (if a \<in> A then insert a (A \<inter> B) else A \<inter> B)"
wenzelm@12897
  1708
  by auto
wenzelm@12897
  1709
wenzelm@12897
  1710
lemma Un_Int_distrib: "A \<union> (B \<inter> C) = (A \<union> B) \<inter> (A \<union> C)"
wenzelm@12897
  1711
  by blast
wenzelm@12897
  1712
wenzelm@12897
  1713
lemma Un_Int_distrib2: "(B \<inter> C) \<union> A = (B \<union> A) \<inter> (C \<union> A)"
wenzelm@12897
  1714
  by blast
wenzelm@12897
  1715
wenzelm@12897
  1716
lemma Un_Int_crazy:
wenzelm@12897
  1717
    "(A \<inter> B) \<union> (B \<inter> C) \<union> (C \<inter> A) = (A \<union> B) \<inter> (B \<union> C) \<inter> (C \<union> A)"
wenzelm@12897
  1718
  by blast
wenzelm@12897
  1719
wenzelm@12897
  1720
lemma subset_Un_eq: "(A \<subseteq> B) = (A \<union> B = B)"
wenzelm@12897
  1721
  by blast
wenzelm@12897
  1722
wenzelm@12897
  1723
lemma Un_empty [iff]: "(A \<union> B = {}) = (A = {} & B = {})"
wenzelm@12897
  1724
  by blast
paulson@15102
  1725
paulson@15102
  1726
lemma Un_subset_iff [simp]: "(A \<union> B \<subseteq> C) = (A \<subseteq> C & B \<subseteq> C)"
wenzelm@12897
  1727
  by blast
wenzelm@12897
  1728
wenzelm@12897
  1729
lemma Un_Diff_Int: "(A - B) \<union> (A \<inter> B) = A"
wenzelm@12897
  1730
  by blast
wenzelm@12897
  1731
paulson@22172
  1732
lemma Diff_Int2: "A \<inter> C - B \<inter> C = A \<inter> C - B"
paulson@22172
  1733
  by blast
paulson@22172
  1734
wenzelm@12897
  1735
wenzelm@12897
  1736
text {* \medskip Set complement *}
wenzelm@12897
  1737
wenzelm@12897
  1738
lemma Compl_disjoint [simp]: "A \<inter> -A = {}"
wenzelm@12897
  1739
  by blast
wenzelm@12897
  1740
wenzelm@12897
  1741
lemma Compl_disjoint2 [simp]: "-A \<inter> A = {}"
wenzelm@12897
  1742
  by blast
wenzelm@12897
  1743
paulson@13818
  1744
lemma Compl_partition: "A \<union> -A = UNIV"
paulson@13818
  1745
  by blast
paulson@13818
  1746
paulson@13818
  1747
lemma Compl_partition2: "-A \<union> A = UNIV"
wenzelm@12897
  1748
  by blast
wenzelm@12897
  1749
wenzelm@12897
  1750
lemma double_complement [simp]: "- (-A) = (A::'a set)"
wenzelm@12897
  1751
  by blast
wenzelm@12897
  1752
wenzelm@12897
  1753
lemma Compl_Un [simp]: "-(A \<union> B) = (-A) \<inter> (-B)"
wenzelm@12897
  1754
  by blast
wenzelm@12897
  1755
wenzelm@12897
  1756
lemma Compl_Int [simp]: "-(A \<inter> B) = (-A) \<union> (-B)"
wenzelm@12897
  1757
  by blast
wenzelm@12897
  1758
wenzelm@12897
  1759
lemma Compl_UN [simp]: "-(\<Union>x\<in>A. B x) = (\<Inter>x\<in>A. -B x)"
wenzelm@12897
  1760
  by blast
wenzelm@12897
  1761
wenzelm@12897
  1762
lemma Compl_INT [simp]: "-(\<Inter>x\<in>A. B x) = (\<Union>x\<in>A. -B x)"
wenzelm@12897
  1763
  by blast
wenzelm@12897
  1764
wenzelm@12897
  1765
lemma subset_Compl_self_eq: "(A \<subseteq> -A) = (A = {})"
wenzelm@12897
  1766
  by blast
wenzelm@12897
  1767
wenzelm@12897
  1768
lemma Un_Int_assoc_eq: "((A \<inter> B) \<union> C = A \<inter> (B \<union> C)) = (C \<subseteq> A)"
wenzelm@12897
  1769
  -- {* Halmos, Naive Set Theory, page 16. *}
wenzelm@12897
  1770
  by blast
wenzelm@12897
  1771
wenzelm@12897
  1772
lemma Compl_UNIV_eq [simp]: "-UNIV = {}"
wenzelm@12897
  1773
  by blast
wenzelm@12897
  1774
wenzelm@12897
  1775
lemma Compl_empty_eq [simp]: "-{} = UNIV"
wenzelm@12897
  1776
  by blast
wenzelm@12897
  1777
wenzelm@12897
  1778
lemma Compl_subset_Compl_iff [iff]: "(-A \<subseteq> -B) = (B \<subseteq> A)"
wenzelm@12897
  1779
  by blast
wenzelm@12897
  1780
wenzelm@12897
  1781
lemma Compl_eq_Compl_iff [iff]: "(-A = -B) = (A = (B::'a set))"
wenzelm@12897
  1782
  by blast
wenzelm@12897
  1783
wenzelm@12897
  1784
wenzelm@12897
  1785
text {* \medskip @{text Union}. *}
wenzelm@12897
  1786
wenzelm@12897
  1787
lemma Union_empty [simp]: "Union({}) = {}"
wenzelm@12897
  1788
  by blast
wenzelm@12897
  1789
wenzelm@12897
  1790
lemma Union_UNIV [simp]: "Union UNIV = UNIV"
wenzelm@12897
  1791
  by blast
wenzelm@12897
  1792
wenzelm@12897
  1793
lemma Union_insert [simp]: "Union (insert a B) = a \<union> \<Union>B"
wenzelm@12897
  1794
  by blast
wenzelm@12897
  1795
wenzelm@12897
  1796
lemma Union_Un_distrib [simp]: "\<Union>(A Un B) = \<Union>A \<union> \<Union>B"
wenzelm@12897
  1797
  by blast
wenzelm@12897
  1798
wenzelm@12897
  1799
lemma Union_Int_subset: "\<Union>(A \<inter> B) \<subseteq> \<Union>A \<inter> \<Union>B"
wenzelm@12897
  1800
  by blast
wenzelm@12897
  1801
paulson@24286
  1802
lemma Union_empty_conv [simp,noatp]: "(\<Union>A = {}) = (\<forall>x\<in>A. x = {})"
nipkow@13653
  1803
  by blast
nipkow@13653
  1804
paulson@24286
  1805
lemma empty_Union_conv [simp,noatp]: "({} = \<Union>A) = (\<forall>x\<in>A. x = {})"
nipkow@13653
  1806
  by blast
wenzelm@12897
  1807
wenzelm@12897
  1808
lemma Union_disjoint: "(\<Union>C \<inter> A = {}) = (\<forall>B\<in>C. B \<inter> A = {})"
wenzelm@12897
  1809
  by blast
wenzelm@12897
  1810
wenzelm@12897
  1811
wenzelm@12897
  1812
text {* \medskip @{text Inter}. *}
wenzelm@12897
  1813
wenzelm@12897
  1814
lemma Inter_empty [simp]: "\<Inter>{} = UNIV"
wenzelm@12897
  1815
  by blast
wenzelm@12897
  1816
wenzelm@12897
  1817
lemma Inter_UNIV [simp]: "\<Inter>UNIV = {}"
wenzelm@12897
  1818
  by blast
wenzelm@12897
  1819
wenzelm@12897
  1820
lemma Inter_insert [simp]: "\<Inter>(insert a B) = a \<inter> \<Inter>B"
wenzelm@12897
  1821
  by blast
wenzelm@12897
  1822
wenzelm@12897
  1823
lemma Inter_Un_subset: "\<Inter>A \<union> \<Inter>B \<subseteq> \<Inter>(A \<inter> B)"
wenzelm@12897
  1824
  by blast
wenzelm@12897
  1825
wenzelm@12897
  1826
lemma Inter_Un_distrib: "\<Inter>(A \<union> B) = \<Inter>A \<inter> \<Inter>B"
wenzelm@12897
  1827
  by blast
wenzelm@12897
  1828
paulson@24286
  1829
lemma Inter_UNIV_conv [simp,noatp]:
nipkow@13653
  1830
  "(\<Inter>A = UNIV) = (\<forall>x\<in>A. x = UNIV)"
nipkow@13653
  1831
  "(UNIV = \<Inter>A) = (\<forall>x\<in>A. x = UNIV)"
paulson@14208
  1832
  by blast+
nipkow@13653
  1833
wenzelm@12897
  1834
wenzelm@12897
  1835
text {*
wenzelm@12897
  1836
  \medskip @{text UN} and @{text INT}.
wenzelm@12897
  1837
wenzelm@12897
  1838
  Basic identities: *}
wenzelm@12897
  1839
paulson@24286
  1840
lemma UN_empty [simp,noatp]: "(\<Union>x\<in>{}. B x) = {}"
wenzelm@12897
  1841
  by blast
wenzelm@12897
  1842
wenzelm@12897
  1843
lemma UN_empty2 [simp]: "(\<Union>x\<in>A. {}) = {}"
wenzelm@12897
  1844
  by blast
wenzelm@12897
  1845
wenzelm@12897
  1846
lemma UN_singleton [simp]: "(\<Union>x\<in>A. {x}) = A"
wenzelm@12897
  1847
  by blast
wenzelm@12897
  1848
wenzelm@12897
  1849
lemma UN_absorb: "k \<in> I ==> A k \<union> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. A i)"
paulson@15102
  1850
  by auto
wenzelm@12897
  1851
wenzelm@12897
  1852
lemma INT_empty [simp]: "(\<Inter>x\<in>{}. B x) = UNIV"
wenzelm@12897
  1853
  by blast
wenzelm@12897
  1854
wenzelm@12897
  1855
lemma INT_absorb: "k \<in> I ==> A k \<inter> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. A i)"
wenzelm@12897
  1856
  by blast
wenzelm@12897
  1857
wenzelm@12897
  1858
lemma UN_insert [simp]: "(\<Union>x\<in>insert a A. B x) = B a \<union> UNION A B"
wenzelm@12897
  1859
  by blast
wenzelm@12897
  1860
nipkow@24331
  1861
lemma UN_Un[simp]: "(\<Union>i \<in> A \<union> B. M i) = (\<Union>i\<in>A. M i) \<union> (\<Union>i\<in>B. M i)"
wenzelm@12897
  1862
  by blast
wenzelm@12897
  1863
wenzelm@12897
  1864
lemma UN_UN_flatten: "(\<Union>x \<in> (\<Union>y\<in>A. B y). C x) = (\<Union>y\<in>A. \<Union>x\<in>B y. C x)"
wenzelm@12897
  1865
  by blast
wenzelm@12897
  1866
wenzelm@12897
  1867
lemma UN_subset_iff: "((\<Union>i\<in>I. A i) \<subseteq> B) = (\<forall>i\<in>I. A i \<subseteq> B)"
wenzelm@12897
  1868
  by blast
wenzelm@12897
  1869
wenzelm@12897
  1870
lemma INT_subset_iff: "(B \<subseteq> (\<Inter>i\<in>I. A i)) = (\<forall>i\<in>I. B \<subseteq> A i)"
wenzelm@12897
  1871
  by blast
wenzelm@12897
  1872
wenzelm@12897
  1873
lemma INT_insert [simp]: "(\<Inter>x \<in> insert a A. B x) = B a \<inter> INTER A B"
wenzelm@12897
  1874
  by blast
wenzelm@12897
  1875
wenzelm@12897
  1876
lemma INT_Un: "(\<Inter>i \<in> A \<union> B. M i) = (\<Inter>i \<in> A. M i) \<inter> (\<Inter>i\<in>B. M i)"
wenzelm@12897
  1877
  by blast
wenzelm@12897
  1878
wenzelm@12897
  1879
lemma INT_insert_distrib:
wenzelm@12897
  1880
    "u \<in> A ==> (\<Inter>x\<in>A. insert a (B x)) = insert a (\<Inter>x\<in>A. B x)"
wenzelm@12897
  1881
  by blast
wenzelm@12897
  1882
wenzelm@12897
  1883
lemma Union_image_eq [simp]: "\<Union>(B`A) = (\<Union>x\<in>A. B x)"
wenzelm@12897
  1884
  by blast
wenzelm@12897
  1885
wenzelm@12897
  1886
lemma image_Union: "f ` \<Union>S = (\<Union>x\<in>S. f ` x)"
wenzelm@12897
  1887
  by blast
wenzelm@12897
  1888
wenzelm@12897
  1889
lemma Inter_image_eq [simp]: "\<Inter>(B`A) = (\<Inter>x\<in>A. B x)"
wenzelm@12897
  1890
  by blast
wenzelm@12897
  1891
wenzelm@12897
  1892
lemma UN_constant [simp]: "(\<Union>y\<in>A. c) = (if A = {} then {} else c)"
wenzelm@12897
  1893
  by auto
wenzelm@12897
  1894
wenzelm@12897
  1895
lemma INT_constant [simp]: "(\<Inter>y\<in>A. c) = (if A = {} then UNIV else c)"
wenzelm@12897
  1896
  by auto
wenzelm@12897
  1897
wenzelm@12897
  1898
lemma UN_eq: "(\<Union>x\<in>A. B x) = \<Union>({Y. \<exists>x\<in>A. Y = B x})"
wenzelm@12897
  1899
  by blast
wenzelm@12897
  1900
wenzelm@12897
  1901
lemma INT_eq: "(\<Inter>x\<in>A. B x) = \<Inter>({Y. \<exists>x\<in>A. Y = B x})"
wenzelm@12897
  1902
  -- {* Look: it has an \emph{existential} quantifier *}
wenzelm@12897
  1903
  by blast
wenzelm@12897
  1904
paulson@18447
  1905
lemma UNION_empty_conv[simp]:
nipkow@13653
  1906
  "({} = (UN x:A. B x)) = (\<forall>x\<in>A. B x = {})"
nipkow@13653
  1907
  "((UN x:A. B x) = {}) = (\<forall>x\<in>A. B x = {})"
nipkow@13653
  1908
by blast+
nipkow@13653
  1909
paulson@18447
  1910
lemma INTER_UNIV_conv[simp]:
nipkow@13653
  1911
 "(UNIV = (INT x:A. B x)) = (\<forall>x\<in>A. B x = UNIV)"
nipkow@13653
  1912
 "((INT x:A. B x) = UNIV) = (\<forall>x\<in>A. B x = UNIV)"
nipkow@13653
  1913
by blast+
wenzelm@12897
  1914
wenzelm@12897
  1915
wenzelm@12897
  1916
text {* \medskip Distributive laws: *}
wenzelm@12897
  1917
wenzelm@12897
  1918
lemma Int_Union: "A \<inter> \<Union>B = (\<Union>C\<in>B. A \<inter> C)"
wenzelm@12897
  1919
  by blast
wenzelm@12897
  1920
wenzelm@12897
  1921
lemma Int_Union2: "\<Union>B \<inter> A = (\<Union>C\<in>B. C \<inter> A)"
wenzelm@12897
  1922
  by blast
wenzelm@12897
  1923
wenzelm@12897
  1924
lemma Un_Union_image: "(\<Union>x\<in>C. A x \<union> B x) = \<Union>(A`C) \<union> \<Union>(B`C)"
wenzelm@12897
  1925
  -- {* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: *}
wenzelm@12897
  1926
  -- {* Union of a family of unions *}
wenzelm@12897
  1927
  by blast
wenzelm@12897
  1928
wenzelm@12897
  1929
lemma UN_Un_distrib: "(\<Union>i\<in>I. A i \<union> B i) = (\<Union>i\<in>I. A i) \<union> (\<Union>i\<in>I. B i)"
wenzelm@12897
  1930
  -- {* Equivalent version *}
wenzelm@12897
  1931
  by blast
wenzelm@12897
  1932
wenzelm@12897
  1933
lemma Un_Inter: "A \<union> \<Inter>B = (\<Inter>C\<in>B. A \<union> C)"
wenzelm@12897
  1934
  by blast
wenzelm@12897
  1935
wenzelm@12897
  1936
lemma Int_Inter_image: "(\<Inter>x\<in>C. A x \<inter> B x) = \<Inter>(A`C) \<inter> \<Inter>(B`C)"
wenzelm@12897
  1937
  by blast
wenzelm@12897
  1938
wenzelm@12897
  1939
lemma INT_Int_distrib: "(\<Inter>i\<in>I. A i \<inter> B i) = (\<Inter>i\<in>I. A i) \<inter> (\<Inter>i\<in>I. B i)"
wenzelm@12897
  1940
  -- {* Equivalent version *}
wenzelm@12897
  1941
  by blast
wenzelm@12897
  1942
wenzelm@12897
  1943
lemma Int_UN_distrib: "B \<inter> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. B \<inter> A i)"
wenzelm@12897
  1944
  -- {* Halmos, Naive Set Theory, page 35. *}
wenzelm@12897
  1945
  by blast
wenzelm@12897
  1946
wenzelm@12897
  1947
lemma Un_INT_distrib: "B \<union> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. B \<union> A i)"
wenzelm@12897
  1948
  by blast
wenzelm@12897
  1949
wenzelm@12897
  1950
lemma Int_UN_distrib2: "(\<Union>i\<in>I. A i) \<inter> (\<Union>j\<in>J. B j) = (\<Union>i\<in>I. \<Union>j\<in>J. A i \<inter> B j)"
wenzelm@12897
  1951
  by blast
wenzelm@12897
  1952
wenzelm@12897
  1953
lemma Un_INT_distrib2: "(\<Inter>i\<in>I. A i) \<union> (\<Inter>j\<in>J. B j) = (\<Inter>i\<in>I. \<Inter>j\<in>J. A i \<union> B j)"
wenzelm@12897
  1954
  by blast
wenzelm@12897
  1955
wenzelm@12897
  1956
wenzelm@12897
  1957
text {* \medskip Bounded quantifiers.
wenzelm@12897
  1958
wenzelm@12897
  1959
  The following are not added to the default simpset because
wenzelm@12897
  1960
  (a) they duplicate the body and (b) there are no similar rules for @{text Int}. *}
wenzelm@12897
  1961
wenzelm@12897
  1962
lemma ball_Un: "(\<forall>x \<in> A \<union> B. P x) = ((\<forall>x\<in>A. P x) & (\<forall>x\<in>B. P x))"
wenzelm@12897
  1963
  by blast
wenzelm@12897
  1964
wenzelm@12897
  1965
lemma bex_Un: "(\<exists>x \<in> A \<union> B. P x) = ((\<exists>x\<in>A. P x) | (\<exists>x\<in>B. P x))"
wenzelm@12897
  1966
  by blast
wenzelm@12897
  1967
wenzelm@12897
  1968
lemma ball_UN: "(\<forall>z \<in> UNION A B. P z) = (\<forall>x\<in>A. \<forall>z \<in> B x. P z)"
wenzelm@12897
  1969
  by blast
wenzelm@12897
  1970
wenzelm@12897
  1971
lemma bex_UN: "(\<exists>z \<in> UNION A B. P z) = (\<exists>x\<in>A. \<exists>z\<in>B x. P z)"
wenzelm@12897
  1972
  by blast
wenzelm@12897
  1973
wenzelm@12897
  1974
wenzelm@12897
  1975
text {* \medskip Set difference. *}
wenzelm@12897
  1976
wenzelm@12897
  1977
lemma Diff_eq: "A - B = A \<inter> (-B)"
wenzelm@12897
  1978
  by blast
wenzelm@12897
  1979
paulson@24286
  1980
lemma Diff_eq_empty_iff [simp,noatp]: "(A - B = {}) = (A \<subseteq> B)"
wenzelm@12897
  1981
  by blast
wenzelm@12897
  1982
wenzelm@12897
  1983
lemma Diff_cancel [simp]: "A - A = {}"
wenzelm@12897
  1984
  by blast
wenzelm@12897
  1985
nipkow@14302
  1986
lemma Diff_idemp [simp]: "(A - B) - B = A - (B::'a set)"
nipkow@14302
  1987
by blast
nipkow@14302
  1988
wenzelm@12897
  1989
lemma Diff_triv: "A \<inter> B = {} ==> A - B = A"
wenzelm@12897
  1990
  by (blast elim: equalityE)
wenzelm@12897
  1991
wenzelm@12897
  1992
lemma empty_Diff [simp]: "{} - A = {}"
wenzelm@12897
  1993
  by blast
wenzelm@12897
  1994
wenzelm@12897
  1995
lemma Diff_empty [simp]: "A - {} = A"
wenzelm@12897
  1996
  by blast
wenzelm@12897
  1997
wenzelm@12897
  1998
lemma Diff_UNIV [simp]: "A - UNIV = {}"
wenzelm@12897
  1999
  by blast
wenzelm@12897
  2000
paulson@24286
  2001
lemma Diff_insert0 [simp,noatp]: "x \<notin> A ==> A - insert x B = A - B"
wenzelm@12897
  2002
  by blast
wenzelm@12897
  2003
wenzelm@12897
  2004
lemma Diff_insert: "A - insert a B = A - B - {a}"
wenzelm@12897
  2005
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a 0"} *}
wenzelm@12897
  2006
  by blast
wenzelm@12897
  2007
wenzelm@12897
  2008
lemma Diff_insert2: "A - insert a B = A - {a} - B"
wenzelm@12897
  2009
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a 0"} *}
wenzelm@12897
  2010
  by blast
wenzelm@12897
  2011
wenzelm@12897
  2012
lemma insert_Diff_if: "insert x A - B = (if x \<in> B then A - B else insert x (A - B))"
wenzelm@12897
  2013
  by auto
wenzelm@12897
  2014
wenzelm@12897
  2015
lemma insert_Diff1 [simp]: "x \<in> B ==> insert x A - B = A - B"
wenzelm@12897
  2016
  by blast
wenzelm@12897
  2017
nipkow@14302
  2018
lemma insert_Diff_single[simp]: "insert a (A - {a}) = insert a A"
nipkow@14302
  2019
by blast
nipkow@14302
  2020
wenzelm@12897
  2021
lemma insert_Diff: "a \<in> A ==> insert a (A - {a}) = A"
wenzelm@12897
  2022
  by blast
wenzelm@12897
  2023
wenzelm@12897
  2024
lemma Diff_insert_absorb: "x \<notin> A ==> (insert x A) - {x} = A"
wenzelm@12897
  2025
  by auto
wenzelm@12897
  2026
wenzelm@12897
  2027
lemma Diff_disjoint [simp]: "A \<inter> (B - A) = {}"
wenzelm@12897
  2028
  by blast
wenzelm@12897
  2029
wenzelm@12897
  2030
lemma Diff_partition: "A \<subseteq> B ==> A \<union> (B - A) = B"
wenzelm@12897
  2031
  by blast
wenzelm@12897
  2032
wenzelm@12897
  2033
lemma double_diff: "A \<subseteq> B ==> B \<subseteq> C ==> B - (C - A) = A"
wenzelm@12897
  2034
  by blast
wenzelm@12897
  2035
wenzelm@12897
  2036
lemma Un_Diff_cancel [simp]: "A \<union> (B - A) = A \<union> B"
wenzelm@12897
  2037
  by blast
wenzelm@12897
  2038
wenzelm@12897
  2039
lemma Un_Diff_cancel2 [simp]: "(B - A) \<union> A = B \<union> A"
wenzelm@12897
  2040
  by blast
wenzelm@12897
  2041
wenzelm@12897
  2042
lemma Diff_Un: "A - (B \<union> C) = (A - B) \<inter> (A - C)"
wenzelm@12897
  2043
  by blast
wenzelm@12897
  2044
wenzelm@12897
  2045
lemma Diff_Int: "A - (B \<inter> C) = (A - B) \<union> (A - C)"
wenzelm@12897
  2046
  by blast
wenzelm@12897
  2047
wenzelm@12897
  2048
lemma Un_Diff: "(A \<union> B) - C = (A - C) \<union> (B - C)"
wenzelm@12897
  2049
  by blast
wenzelm@12897
  2050
wenzelm@12897
  2051
lemma Int_Diff: "(A \<inter> B) - C = A \<inter> (B - C)"
wenzelm@12897
  2052
  by blast
wenzelm@12897
  2053
wenzelm@12897
  2054
lemma Diff_Int_distrib: "C \<inter> (A - B) = (C \<inter> A) - (C \<inter> B)"
wenzelm@12897
  2055
  by blast
wenzelm@12897
  2056
wenzelm@12897
  2057
lemma Diff_Int_distrib2: "(A - B) \<inter> C = (A \<inter> C) - (B \<inter> C)"
wenzelm@12897
  2058
  by blast
wenzelm@12897
  2059
wenzelm@12897
  2060
lemma Diff_Compl [simp]: "A - (- B) = A \<inter> B"
wenzelm@12897
  2061
  by auto
wenzelm@12897
  2062
wenzelm@12897
  2063
lemma Compl_Diff_eq [simp]: "- (A - B) = -A \<union> B"
wenzelm@12897
  2064
  by blast
wenzelm@12897
  2065
wenzelm@12897
  2066
wenzelm@12897
  2067
text {* \medskip Quantification over type @{typ bool}. *}
wenzelm@12897
  2068
wenzelm@12897
  2069
lemma bool_induct: "P True \<Longrightarrow> P False \<Longrightarrow> P x"
haftmann@21549
  2070
  by (cases x) auto
haftmann@21549
  2071
haftmann@21549
  2072
lemma all_bool_eq: "(\<forall>b. P b) \<longleftrightarrow> P True \<and> P False"
haftmann@21549
  2073
  by (auto intro: bool_induct)
haftmann@21549
  2074
haftmann@21549
  2075
lemma bool_contrapos: "P x \<Longrightarrow> \<not> P False \<Longrightarrow> P True"
haftmann@21549
  2076
  by (cases x) auto
haftmann@21549
  2077
haftmann@21549
  2078
lemma ex_bool_eq: "(\<exists>b. P b) \<longleftrightarrow> P True \<or> P False"
haftmann@21549
  2079
  by (auto intro: bool_contrapos)
wenzelm@12897
  2080
wenzelm@12897
  2081
lemma Un_eq_UN: "A \<union> B = (\<Union>b. if b then A else B)"
wenzelm@12897
  2082
  by (auto simp add: split_if_mem2)
wenzelm@12897
  2083
wenzelm@12897
  2084
lemma UN_bool_eq: "(\<Union>b::bool. A b) = (A True \<union> A False)"
haftmann@21549
  2085
  by (auto intro: bool_contrapos)
wenzelm@12897
  2086
wenzelm@12897
  2087
lemma INT_bool_eq: "(\<Inter>b::bool. A b) = (A True \<inter> A False)"
haftmann@21549
  2088
  by (auto intro: bool_induct)
wenzelm@12897
  2089
wenzelm@12897
  2090
text {* \medskip @{text Pow} *}
wenzelm@12897
  2091
wenzelm@12897
  2092
lemma Pow_empty [simp]: "Pow {} = {{}}"
wenzelm@12897
  2093
  by (auto simp add: Pow_def)
wenzelm@12897
  2094
wenzelm@12897
  2095
lemma Pow_insert: "Pow (insert a A) = Pow A \<union> (insert a ` Pow A)"
wenzelm@12897
  2096
  by (blast intro: image_eqI [where ?x = "u - {a}", standard])
wenzelm@12897
  2097
wenzelm@12897
  2098
lemma Pow_Compl: "Pow (- A) = {-B | B. A \<in> Pow B}"
wenzelm@12897
  2099
  by (blast intro: exI [where ?x = "- u", standard])
wenzelm@12897
  2100
wenzelm@12897
  2101
lemma Pow_UNIV [simp]: "Pow UNIV = UNIV"
wenzelm@12897
  2102
  by blast
wenzelm@12897
  2103
wenzelm@12897
  2104
lemma Un_Pow_subset: "Pow A \<union> Pow B \<subseteq> Pow (A \<union> B)"
wenzelm@12897
  2105
  by blast
wenzelm@12897
  2106
wenzelm@12897
  2107
lemma UN_Pow_subset: "(\<Union>x\<in>A. Pow (B x)) \<subseteq> Pow (\<Union>x\<in>A. B x)"
wenzelm@12897
  2108
  by blast
wenzelm@12897
  2109
wenzelm@12897
  2110
lemma subset_Pow_Union: "A \<subseteq> Pow (\<Union>A)"
wenzelm@12897
  2111
  by blast
wenzelm@12897
  2112
wenzelm@12897
  2113
lemma Union_Pow_eq [simp]: "\<Union>(Pow A) = A"
wenzelm@12897
  2114
  by blast
wenzelm@12897
  2115
wenzelm@12897
  2116
lemma Pow_Int_eq [simp]: "Pow (A \<inter> B) = Pow A \<inter> Pow B"
wenzelm@12897
  2117
  by blast
wenzelm@12897
  2118
wenzelm@12897
  2119
lemma Pow_INT_eq: "Pow (\<Inter>x\<in>A. B x) = (\<Inter>x\<in>A. Pow (B x))"
wenzelm@12897
  2120
  by blast
wenzelm@12897
  2121
wenzelm@12897
  2122
wenzelm@12897
  2123
text {* \medskip Miscellany. *}
wenzelm@12897
  2124
wenzelm@12897
  2125
lemma set_eq_subset: "(A = B) = (A \<subseteq> B & B \<subseteq> A)"
wenzelm@12897
  2126
  by blast
wenzelm@12897
  2127
wenzelm@12897
  2128
lemma subset_iff: "(A \<subseteq> B) = (\<forall>t. t \<in> A --> t \<in> B)"
wenzelm@12897
  2129
  by blast
wenzelm@12897
  2130
wenzelm@12897
  2131
lemma subset_iff_psubset_eq: "(A \<subseteq> B) = ((A \<subset> B) | (A = B))"
berghofe@26800
  2132
  by (unfold less_le) blast
wenzelm@12897
  2133
paulson@18447
  2134
lemma all_not_in_conv [simp]: "(\<forall>x. x \<notin> A) = (A = {})"
wenzelm@12897
  2135
  by blast
wenzelm@12897
  2136
paulson@13831
  2137
lemma ex_in_conv: "(\<exists>x. x \<in> A) = (A \<noteq> {})"
paulson@13831
  2138
  by blast
paulson@13831
  2139
wenzelm@12897
  2140
lemma distinct_lemma: "f x \<noteq> f y ==> x \<noteq> y"
nipkow@17589
  2141
  by iprover
wenzelm@12897
  2142
wenzelm@12897
  2143
paulson@13860
  2144
text {* \medskip Miniscoping: pushing in quantifiers and big Unions
paulson@13860
  2145
           and Intersections. *}
wenzelm@12897
  2146
wenzelm@12897
  2147
lemma UN_simps [simp]:
wenzelm@12897
  2148
  "!!a B C. (UN x:C. insert a (B x)) = (if C={} then {} else insert a (UN x:C. B x))"
wenzelm@12897
  2149
  "!!A B C. (UN x:C. A x Un B)   = ((if C={} then {} else (UN x:C. A x) Un B))"
wenzelm@12897
  2150
  "!!A B C. (UN x:C. A Un B x)   = ((if C={} then {} else A Un (UN x:C. B x)))"
wenzelm@12897
  2151
  "!!A B C. (UN x:C. A x Int B)  = ((UN x:C. A x) Int B)"
wenzelm@12897
  2152
  "!!A B C. (UN x:C. A Int B x)  = (A Int (UN x:C. B x))"
wenzelm@12897
  2153
  "!!A B C. (UN x:C. A x - B)    = ((UN x:C. A x) - B)"
wenzelm@12897
  2154
  "!!A B C. (UN x:C. A - B x)    = (A - (INT x:C. B x))"
wenzelm@12897
  2155
  "!!A B. (UN x: Union A. B x) = (UN y:A. UN x:y. B x)"
wenzelm@12897
  2156
  "!!A B C. (UN z: UNION A B. C z) = (UN  x:A. UN z: B(x). C z)"
wenzelm@12897
  2157
  "!!A B f. (UN x:f`A. B x)     = (UN a:A. B (f a))"
wenzelm@12897
  2158
  by auto
wenzelm@12897
  2159
wenzelm@12897
  2160
lemma INT_simps [simp]:
wenzelm@12897
  2161
  "!!A B C. (INT x:C. A x Int B) = (if C={} then UNIV else (INT x:C. A x) Int B)"
wenzelm@12897
  2162
  "!!A B C. (INT x:C. A Int B x) = (if C={} then UNIV else A Int (INT x:C. B x))"
wenzelm@12897
  2163
  "!!A B C. (INT x:C. A x - B)   = (if C={} then UNIV else (INT x:C. A x) - B)"
wenzelm@12897
  2164
  "!!A B C. (INT x:C. A - B x)   = (if C={} then UNIV else A - (UN x:C. B x))"
wenzelm@12897
  2165
  "!!a B C. (INT x:C. insert a (B x)) = insert a (INT x:C. B x)"
wenzelm@12897
  2166
  "!!A B C. (INT x:C. A x Un B)  = ((INT x:C. A x) Un B)"
wenzelm@12897
  2167
  "!!A B C. (INT x:C. A Un B x)  = (A Un (INT x:C. B x))"
wenzelm@12897
  2168
  "!!A B. (INT x: Union A. B x) = (INT y:A. INT x:y. B x)"
wenzelm@12897
  2169
  "!!A B C. (INT z: UNION A B. C z) = (INT x:A. INT z: B(x). C z)"
wenzelm@12897
  2170
  "!!A B f. (INT x:f`A. B x)    = (INT a:A. B (f a))"
wenzelm@12897
  2171
  by auto
wenzelm@12897
  2172
paulson@24286
  2173
lemma ball_simps [simp,noatp]:
wenzelm@12897
  2174
  "!!A P Q. (ALL x:A. P x | Q) = ((ALL x:A. P x) | Q)"
wenzelm@12897
  2175
  "!!A P Q. (ALL x:A. P | Q x) = (P | (ALL x:A. Q x))"
wenzelm@12897
  2176
  "!!A P Q. (ALL x:A. P --> Q x) = (P --> (ALL x:A. Q x))"
wenzelm@12897
  2177
  "!!A P Q. (ALL x:A. P x --> Q) = ((EX x:A. P x) --> Q)"
wenzelm@12897
  2178
  "!!P. (ALL x:{}. P x) = True"
wenzelm@12897
  2179
  "!!P. (ALL x:UNIV. P x) = (ALL x. P x)"
wenzelm@12897
  2180
  "!!a B P. (ALL x:insert a B. P x) = (P a & (ALL x:B. P x))"
wenzelm@12897
  2181
  "!!A P. (ALL x:Union A. P x) = (ALL y:A. ALL x:y. P x)"
wenzelm@12897
  2182
  "!!A B P. (ALL x: UNION A B. P x) = (ALL a:A. ALL x: B a. P x)"
wenzelm@12897
  2183
  "!!P Q. (ALL x:Collect Q. P x) = (ALL x. Q x --> P x)"
wenzelm@12897
  2184
  "!!A P f. (ALL x:f`A. P x) = (ALL x:A. P (f x))"
wenzelm@12897
  2185
  "!!A P. (~(ALL x:A. P x)) = (EX x:A. ~P x)"
wenzelm@12897
  2186
  by auto
wenzelm@12897
  2187
paulson@24286
  2188
lemma bex_simps [simp,noatp]:
wenzelm@12897
  2189
  "!!A P Q. (EX x:A. P x & Q) = ((EX x:A. P x) & Q)"
wenzelm@12897
  2190
  "!!A P Q. (EX x:A. P & Q x) = (P & (EX x:A. Q x))"
wenzelm@12897
  2191
  "!!P. (EX x:{}. P x) = False"
wenzelm@12897
  2192
  "!!P. (EX x:UNIV. P x) = (EX x. P x)"
wenzelm@12897
  2193
  "!!a B P. (EX x:insert a B. P x) = (P(a) | (EX x:B. P x))"
wenzelm@12897
  2194
  "!!A P. (EX x:Union A. P x) = (EX y:A. EX x:y. P x)"
wenzelm@12897
  2195
  "!!A B P. (EX x: UNION A B. P x) = (EX a:A. EX x:B a. P x)"
wenzelm@12897
  2196
  "!!P Q. (EX x:Collect Q. P x) = (EX x. Q x & P x)"
wenzelm@12897
  2197
  "!!A P f. (EX x:f`A. P x) = (EX x:A. P (f x))"
wenzelm@12897
  2198
  "!!A P. (~(EX x:A. P x)) = (ALL x:A. ~P x)"
wenzelm@12897
  2199
  by auto
wenzelm@12897
  2200
wenzelm@12897
  2201
lemma ball_conj_distrib:
wenzelm@12897
  2202
  "(ALL x:A. P x & Q x) = ((ALL x:A. P x) & (ALL x:A. Q x))"
wenzelm@12897
  2203
  by blast
wenzelm@12897
  2204
wenzelm@12897
  2205
lemma bex_disj_distrib:
wenzelm@12897
  2206
  "(EX x:A. P x | Q x) = ((EX x:A. P x) | (EX x:A. Q x))"
wenzelm@12897
  2207
  by blast
wenzelm@12897
  2208
wenzelm@12897
  2209
paulson@13860
  2210
text {* \medskip Maxiscoping: pulling out big Unions and Intersections. *}
paulson@13860
  2211
paulson@13860
  2212
lemma UN_extend_simps:
paulson@13860
  2213
  "!!a B C. insert a (UN x:C. B x) = (if C={} then {a} else (UN x:C. insert a (B x)))"
paulson@13860
  2214
  "!!A B C. (UN x:C. A x) Un B    = (if C={} then B else (UN x:C. A x Un B))"
paulson@13860
  2215
  "!!A B C. A Un (UN x:C. B x)   = (if C={} then A else (UN x:C. A Un B x))"
paulson@13860
  2216
  "!!A B C. ((UN x:C. A x) Int B) = (UN x:C. A x Int B)"
paulson@13860
  2217
  "!!A B C. (A Int (UN x:C. B x)) = (UN x:C. A Int B x)"
paulson@13860
  2218
  "!!A B C. ((UN x:C. A x) - B) = (UN x:C. A x - B)"
paulson@13860
  2219
  "!!A B C. (A - (INT x:C. B x)) = (UN x:C. A - B x)"
paulson@13860
  2220
  "!!A B. (UN y:A. UN x:y. B x) = (UN x: Union A. B x)"
paulson@13860
  2221
  "!!A B C. (UN  x:A. UN z: B(x). C z) = (UN z: UNION A B. C z)"
paulson@13860
  2222
  "!!A B f. (UN a:A. B (f a)) = (UN x:f`A. B x)"
paulson@13860
  2223
  by auto
paulson@13860
  2224
paulson@13860
  2225
lemma INT_extend_simps:
paulson@13860
  2226
  "!!A B C. (INT x:C. A x) Int B = (if C={} then B else (INT x:C. A x Int B))"
paulson@13860
  2227
  "!!A B C. A Int (INT x:C. B x) = (if C={} then A else (INT x:C. A Int B x))"
paulson@13860
  2228
  "!!A B C. (INT x:C. A x) - B   = (if C={} then UNIV-B else (INT x:C. A x - B))"
paulson@13860
  2229
  "!!A B C. A - (UN x:C. B x)   = (if C={} then A else (INT x:C. A - B x))"
paulson@13860
  2230
  "!!a B C. insert a (INT x:C. B x) = (INT x:C. insert a (B x))"
paulson@13860
  2231
  "!!A B C. ((INT x:C. A x) Un B)  = (INT x:C. A x Un B)"
paulson@13860
  2232
  "!!A B C. A Un (INT x:C. B x)  = (INT x:C. A Un B x)"
paulson@13860
  2233
  "!!A B. (INT y:A. INT x:y. B x) = (INT x: Union A. B x)"
paulson@13860
  2234
  "!!A B C. (INT x:A. INT z: B(x). C z) = (INT z: UNION A B. C z)"
paulson@13860
  2235
  "!!A B f. (INT a:A. B (f a))    = (INT x:f`A. B x)"
paulson@13860
  2236
  by auto
paulson@13860
  2237
paulson@13860
  2238
wenzelm@12897
  2239
subsubsection {* Monotonicity of various operations *}
wenzelm@12897
  2240
wenzelm@12897
  2241
lemma image_mono: "A \<subseteq> B ==> f`A \<subseteq> f`B"
wenzelm@12897
  2242
  by blast
wenzelm@12897
  2243
wenzelm@12897
  2244
lemma Pow_mono: "A \<subseteq> B ==> Pow A \<subseteq> Pow B"
wenzelm@12897
  2245
  by blast
wenzelm@12897
  2246
wenzelm@12897
  2247
lemma Union_mono: "A \<subseteq> B ==> \<Union>A \<subseteq> \<Union>B"
wenzelm@12897
  2248
  by blast
wenzelm@12897
  2249
wenzelm@12897
  2250
lemma Inter_anti_mono: "B \<subseteq> A ==> \<Inter>A \<subseteq> \<Inter>B"
wenzelm@12897
  2251
  by blast
wenzelm@12897
  2252
wenzelm@12897
  2253
lemma UN_mono:
wenzelm@12897
  2254
  "A \<subseteq> B ==> (!!x. x \<in> A ==> f x \<subseteq> g x) ==>
wenzelm@12897
  2255
    (\<Union>x\<in>A. f x) \<subseteq> (\<Union>x\<in>B. g x)"
wenzelm@12897
  2256
  by (blast dest: subsetD)
wenzelm@12897
  2257
wenzelm@12897
  2258
lemma INT_anti_mono:
wenzelm@12897
  2259
  "B \<subseteq> A ==> (!!x. x \<in> A ==> f x \<subseteq> g x) ==>
wenzelm@12897
  2260
    (\<Inter>x\<in>A. f x) \<subseteq> (\<Inter>x\<in>A. g x)"
wenzelm@12897
  2261
  -- {* The last inclusion is POSITIVE! *}
wenzelm@12897
  2262
  by (blast dest: subsetD)
wenzelm@12897
  2263
wenzelm@12897
  2264
lemma insert_mono: "C \<subseteq> D ==> insert a C \<subseteq> insert a D"
wenzelm@12897
  2265
  by blast
wenzelm@12897
  2266
wenzelm@12897
  2267
lemma Un_mono: "A \<subseteq> C ==> B \<subseteq> D ==> A \<union> B \<subseteq> C \<union> D"
wenzelm@12897
  2268
  by blast
wenzelm@12897
  2269
wenzelm@12897
  2270
lemma Int_mono: "A \<subseteq> C ==> B \<subseteq> D ==> A \<inter> B \<subseteq> C \<inter> D"
wenzelm@12897
  2271
  by blast
wenzelm@12897
  2272
wenzelm@12897
  2273
lemma Diff_mono: "A \<subseteq> C ==> D \<subseteq> B ==> A - B \<subseteq> C - D"
wenzelm@12897
  2274
  by blast
wenzelm@12897
  2275
wenzelm@12897
  2276
lemma Compl_anti_mono: "A \<subseteq> B ==> -B \<subseteq> -A"
wenzelm@12897
  2277
  by blast
wenzelm@12897
  2278
haftmann@30352
  2279
lemma mono_Int: "mono f \<Longrightarrow> f (A \<inter> B) \<subseteq> f A \<inter> f B"
haftmann@30352
  2280
  apply (fold inf_set_eq sup_set_eq)
haftmann@30352
  2281
  apply (erule mono_inf)
haftmann@30352
  2282
  done
haftmann@30352
  2283
haftmann@30352
  2284
lemma mono_Un: "mono f \<Longrightarrow> f A \<union> f B \<subseteq> f (A \<union> B)"
haftmann@30352
  2285
  apply (fold inf_set_eq sup_set_eq)
haftmann@30352
  2286
  apply (erule mono_sup)
haftmann@30352
  2287
  done
haftmann@30352
  2288
wenzelm@12897
  2289
text {* \medskip Monotonicity of implications. *}
wenzelm@12897
  2290
wenzelm@12897
  2291
lemma in_mono: "A \<subseteq> B ==> x \<in> A --> x \<in> B"
wenzelm@12897
  2292
  apply (rule impI)
paulson@14208
  2293
  apply (erule subsetD, assumption)
wenzelm@12897
  2294
  done
wenzelm@12897
  2295
wenzelm@12897
  2296
lemma conj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 & P2) --> (Q1 & Q2)"
nipkow@17589
  2297
  by iprover
wenzelm@12897
  2298
wenzelm@12897
  2299
lemma disj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 | P2) --> (Q1 | Q2)"
nipkow@17589
  2300
  by iprover
wenzelm@12897
  2301
wenzelm@12897
  2302
lemma imp_mono: "Q1 --> P1 ==> P2 --> Q2 ==> (P1 --> P2) --> (Q1 --> Q2)"
nipkow@17589
  2303
  by iprover
wenzelm@12897
  2304
wenzelm@12897
  2305
lemma imp_refl: "P --> P" ..
wenzelm@12897
  2306
wenzelm@12897
  2307
lemma ex_mono: "(!!x. P x --> Q x) ==> (EX x. P x) --> (EX x. Q x)"
nipkow@17589
  2308
  by iprover
wenzelm@12897
  2309
wenzelm@12897
  2310
lemma all_mono: "(!!x. P x --> Q x) ==> (ALL x. P x) --> (ALL x. Q x)"
nipkow@17589
  2311
  by iprover
wenzelm@12897
  2312
wenzelm@12897
  2313
lemma Collect_mono: "(!!x. P x --> Q x) ==> Collect P \<subseteq> Collect Q"
wenzelm@12897
  2314
  by blast
wenzelm@12897
  2315
wenzelm@12897
  2316
lemma Int_Collect_mono:
wenzelm@12897
  2317
    "A \<subseteq> B ==> (!!x. x \<in> A ==> P x --> Q x) ==> A \<inter> Collect P \<subseteq> B \<inter> Collect Q"
wenzelm@12897
  2318
  by blast
wenzelm@12897
  2319
wenzelm@12897
  2320
lemmas basic_monos =
wenzelm@12897
  2321
  subset_refl imp_refl disj_mono conj_mono
wenzelm@12897
  2322
  ex_mono Collect_mono in_mono
wenzelm@12897
  2323
wenzelm@12897
  2324
lemma eq_to_mono: "a = b ==> c = d ==> b --> d ==> a --> c"
nipkow@17589
  2325
  by iprover
wenzelm@12897
  2326
wenzelm@12897
  2327
lemma eq_to_mono2: "a = b ==> c = d ==> ~ b --> ~ d ==> ~ a --> ~ c"
nipkow@17589
  2328
  by iprover
wenzelm@11979
  2329
wenzelm@12020
  2330
haftmann@30352
  2331
subsubsection {* Inverse image of a function *}
wenzelm@12257
  2332
wenzelm@12257
  2333
constdefs
wenzelm@12257
  2334
  vimage :: "('a => 'b) => 'b set => 'a set"    (infixr "-`" 90)
haftmann@28562
  2335
  [code del]: "f -` B == {x. f x : B}"
wenzelm@12257
  2336
wenzelm@12257
  2337
lemma vimage_eq [simp]: "(a : f -` B) = (f a : B)"
wenzelm@12257
  2338
  by (unfold vimage_def) blast
wenzelm@12257
  2339
wenzelm@12257
  2340
lemma vimage_singleton_eq: "(a : f -` {b}) = (f a = b)"
wenzelm@12257
  2341
  by simp
wenzelm@12257
  2342
wenzelm@12257
  2343
lemma vimageI [intro]: "f a = b ==> b:B ==> a : f -` B"
wenzelm@12257
  2344
  by (unfold vimage_def) blast
wenzelm@12257
  2345
wenzelm@12257
  2346
lemma vimageI2: "f a : A ==> a : f -` A"
wenzelm@12257
  2347
  by (unfold vimage_def) fast
wenzelm@12257
  2348
wenzelm@12257
  2349
lemma vimageE [elim!]: "a: f -` B ==> (!!x. f a = x ==> x:B ==> P) ==> P"
wenzelm@12257
  2350
  by (unfold vimage_def) blast
wenzelm@12257
  2351
wenzelm@12257
  2352
lemma vimageD: "a : f -` A ==> f a : A"
wenzelm@12257
  2353
  by (unfold vimage_def) fast
wenzelm@12257
  2354
wenzelm@12257
  2355
lemma vimage_empty [simp]: "f -` {} = {}"
wenzelm@12257
  2356
  by blast
wenzelm@12257
  2357
wenzelm@12257
  2358
lemma vimage_Compl: "f -` (-A) = -(f -` A)"
wenzelm@12257
  2359
  by blast
wenzelm@12257
  2360
wenzelm@12257
  2361
lemma vimage_Un [simp]: "f -` (A Un B) = (f -` A) Un (f -` B)"
wenzelm@12257
  2362
  by blast
wenzelm@12257
  2363
wenzelm@12257
  2364
lemma vimage_Int [simp]: "f -` (A Int B) = (f -` A) Int (f -` B)"
wenzelm@12257
  2365
  by fast
wenzelm@12257
  2366
wenzelm@12257
  2367
lemma vimage_Union: "f -` (Union A) = (UN X:A. f -` X)"
wenzelm@12257
  2368
  by blast
wenzelm@12257
  2369
wenzelm@12257
  2370
lemma vimage_UN: "f-`(UN x:A. B x) = (UN x:A. f -` B x)"
wenzelm@12257
  2371
  by blast
wenzelm@12257
  2372
wenzelm@12257
  2373
lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)"
wenzelm@12257
  2374
  by blast
wenzelm@12257
  2375
wenzelm@12257
  2376
lemma vimage_Collect_eq [simp]: "f -` Collect P = {y. P (f y)}"
wenzelm@12257
  2377
  by blast
wenzelm@12257
  2378
wenzelm@12257
  2379
lemma vimage_Collect: "(!!x. P (f x) = Q x) ==> f -` (Collect P) = Collect Q"
wenzelm@12257
  2380
  by blast
wenzelm@12257
  2381
wenzelm@12257
  2382
lemma vimage_insert: "f-`(insert a B) = (f-`{a}) Un (f-`B)"
wenzelm@12257
  2383
  -- {* NOT suitable for rewriting because of the recurrence of @{term "{a}"}. *}
wenzelm@12257
  2384
  by blast
wenzelm@12257
  2385
wenzelm@12257
  2386
lemma vimage_Diff: "f -` (A - B) = (f -` A) - (f -` B)"
wenzelm@12257
  2387
  by blast
wenzelm@12257
  2388
wenzelm@12257
  2389
lemma vimage_UNIV [simp]: "f -` UNIV = UNIV"
wenzelm@12257
  2390
  by blast
wenzelm@12257
  2391
wenzelm@12257
  2392
lemma vimage_eq_UN: "f-`B = (UN y: B. f-`{y})"
wenzelm@12257
  2393
  -- {* NOT suitable for rewriting *}
wenzelm@12257
  2394
  by blast
wenzelm@12257
  2395
wenzelm@12897
  2396
lemma vimage_mono: "A \<subseteq> B ==> f -` A \<subseteq> f -` B"
wenzelm@12257
  2397
  -- {* monotonicity *}
wenzelm@12257
  2398
  by blast
wenzelm@12257
  2399
haftmann@26150
  2400
lemma vimage_image_eq [noatp]: "f -` (f ` A) = {y. EX x:A. f x = f y}"
haftmann@26150
  2401
by (blast intro: sym)
haftmann@26150
  2402
haftmann@26150
  2403
lemma image_vimage_subset: "f ` (f -` A) <= A"
haftmann@26150
  2404
by blast
haftmann@26150
  2405
haftmann@26150
  2406
lemma image_vimage_eq [simp]: "f ` (f -` A) = A Int range f"
haftmann@26150
  2407
by blast
haftmann@26150
  2408
haftmann@26150
  2409
lemma image_Int_subset: "f`(A Int B) <= f`A Int f`B"
haftmann@26150
  2410
by blast
haftmann@26150
  2411
haftmann@26150
  2412
lemma image_diff_subset: "f`A - f`B <= f`(A - B)"
haftmann@26150
  2413
by blast
haftmann@26150
  2414
haftmann@26150
  2415
lemma image_UN: "(f ` (UNION A B)) = (UN x:A.(f ` (B x)))"
haftmann@26150
  2416
by blast
haftmann@26150
  2417
wenzelm@12257
  2418
haftmann@30352
  2419
subsubsection {* Least value operator *}
berghofe@26800
  2420
berghofe@26800
  2421
lemma Least_mono:
berghofe@26800
  2422
  "mono (f::'a::order => 'b::order) ==> EX x:S. ALL y:S. x <= y
berghofe@26800
  2423
    ==> (LEAST y. y : f ` S) = f (LEAST x. x : S)"
berghofe@26800
  2424
    -- {* Courtesy of Stephan Merz *}
berghofe@26800
  2425
  apply clarify
berghofe@26800
  2426
  apply (erule_tac P = "%x. x : S" in LeastI2_order, fast)
berghofe@26800
  2427
  apply (rule LeastI2_order)
berghofe@26800
  2428
  apply (auto elim: monoD intro!: order_antisym)
berghofe@26800
  2429
  done
berghofe@26800
  2430
haftmann@24420
  2431
haftmann@30352
  2432
subsubsection {* Rudimentary code generation *}
haftmann@27824
  2433
haftmann@28562
  2434
lemma empty_code [code]: "{} x \<longleftrightarrow> False"
haftmann@27824
  2435
  unfolding empty_def Collect_def ..
haftmann@27824
  2436
haftmann@28562
  2437
lemma UNIV_code [code]: "UNIV x \<longleftrightarrow> True"
haftmann@27824
  2438
  unfolding UNIV_def Collect_def ..
haftmann@27824
  2439
haftmann@28562
  2440
lemma insert_code [code]: "insert y A x \<longleftrightarrow> y = x \<or> A x"
haftmann@27824
  2441
  unfolding insert_def Collect_def mem_def Un_def by auto
haftmann@27824
  2442
haftmann@28562
  2443
lemma inter_code [code]: "(A \<inter> B) x \<longleftrightarrow> A x \<and> B x"
haftmann@27824
  2444
  unfolding Int_def Collect_def mem_def ..
haftmann@27824
  2445
haftmann@28562
  2446
lemma union_code [code]: "(A \<union> B) x \<longleftrightarrow> A x \<or> B x"
haftmann@27824
  2447
  unfolding Un_def Collect_def mem_def ..
haftmann@27824
  2448
haftmann@28562
  2449
lemma vimage_code [code]: "(f -` A) x = A (f x)"
haftmann@27824
  2450
  unfolding vimage_def Collect_def mem_def ..
haftmann@27824
  2451
haftmann@27824
  2452
haftmann@30352
  2453
subsection {* Misc theorem and ML bindings *}
haftmann@30352
  2454
haftmann@30352
  2455
lemmas equalityI = subset_antisym
haftmann@30352
  2456
lemmas mem_simps =
haftmann@30352
  2457
  insert_iff empty_iff Un_iff Int_iff Compl_iff Diff_iff
haftmann@30352
  2458
  mem_Collect_eq UN_iff Union_iff INT_iff Inter_iff
haftmann@30352
  2459
  -- {* Each of these has ALREADY been added @{text "[simp]"} above. *}
wenzelm@21669
  2460
wenzelm@21669
  2461
ML {*
wenzelm@22139
  2462
val Ball_def = @{thm Ball_def}
wenzelm@22139
  2463
val Bex_def = @{thm Bex_def}
wenzelm@22139
  2464
val CollectD = @{thm CollectD}
wenzelm@22139
  2465
val CollectE = @{thm CollectE}
wenzelm@22139
  2466
val CollectI = @{thm CollectI}
wenzelm@22139
  2467
val Collect_conj_eq = @{thm Collect_conj_eq}
wenzelm@22139
  2468
val Collect_mem_eq = @{thm Collect_mem_eq}
wenzelm@22139
  2469
val IntD1 = @{thm IntD1}
wenzelm@22139
  2470
val IntD2 = @{thm IntD2}
wenzelm@22139
  2471
val IntE = @{thm IntE}
wenzelm@22139
  2472
val IntI = @{thm IntI}
wenzelm@22139
  2473
val Int_Collect = @{thm Int_Collect}
wenzelm@22139
  2474
val UNIV_I = @{thm UNIV_I}
wenzelm@22139
  2475
val UNIV_witness = @{thm UNIV_witness}
wenzelm@22139
  2476
val UnE = @{thm UnE}
wenzelm@22139
  2477
val UnI1 = @{thm UnI1}
wenzelm@22139
  2478
val UnI2 = @{thm UnI2}
wenzelm@22139
  2479
val ballE = @{thm ballE}
wenzelm@22139
  2480
val ballI = @{thm ballI}
wenzelm@22139
  2481
val bexCI = @{thm bexCI}
wenzelm@22139
  2482
val bexE = @{thm bexE}
wenzelm@22139
  2483
val bexI = @{thm bexI}
wenzelm@22139
  2484
val bex_triv = @{thm bex_triv}
wenzelm@22139
  2485
val bspec = @{thm bspec}
wenzelm@22139
  2486
val contra_subsetD = @{thm contra_subsetD}
wenzelm@22139
  2487
val distinct_lemma = @{thm distinct_lemma}
wenzelm@22139
  2488
val eq_to_mono = @{thm eq_to_mono}
wenzelm@22139
  2489
val eq_to_mono2 = @{thm eq_to_mono2}
wenzelm@22139
  2490
val equalityCE = @{thm equalityCE}
wenzelm@22139
  2491
val equalityD1 = @{thm equalityD1}
wenzelm@22139
  2492
val equalityD2 = @{thm equalityD2}
wenzelm@22139
  2493
val equalityE = @{thm equalityE}
wenzelm@22139
  2494
val equalityI = @{thm equalityI}
wenzelm@22139
  2495
val imageE = @{thm imageE}
wenzelm@22139
  2496
val imageI = @{thm imageI}
wenzelm@22139
  2497
val image_Un = @{thm image_Un}
wenzelm@22139
  2498
val image_insert = @{thm image_insert}
wenzelm@22139
  2499
val insert_commute = @{thm insert_commute}
wenzelm@22139
  2500
val insert_iff = @{thm insert_iff}
wenzelm@22139
  2501
val mem_Collect_eq = @{thm mem_Collect_eq}
wenzelm@22139
  2502
val rangeE = @{thm rangeE}
wenzelm@22139
  2503
val rangeI = @{thm rangeI}
wenzelm@22139
  2504
val range_eqI = @{thm range_eqI}
wenzelm@22139
  2505
val subsetCE = @{thm subsetCE}
wenzelm@22139
  2506
val subsetD = @{thm subsetD}
wenzelm@22139
  2507
val subsetI = @{thm subsetI}
wenzelm@22139
  2508
val subset_refl = @{thm subset_refl}
wenzelm@22139
  2509
val subset_trans = @{thm subset_trans}
wenzelm@22139
  2510
val vimageD = @{thm vimageD}
wenzelm@22139
  2511
val vimageE = @{thm vimageE}
wenzelm@22139
  2512
val vimageI = @{thm vimageI}
wenzelm@22139
  2513
val vimageI2 = @{thm vimageI2}
wenzelm@22139
  2514
val vimage_Collect = @{thm vimage_Collect}
wenzelm@22139
  2515
val vimage_Int = @{thm vimage_Int}
wenzelm@22139
  2516
val vimage_Un = @{thm vimage_Un}
wenzelm@21669
  2517
*}
wenzelm@21669
  2518
wenzelm@11979
  2519
end