src/HOL/Complete_Lattice.thy
author haftmann
Sat Jul 16 21:53:50 2011 +0200 (2011-07-16)
changeset 43852 7411fbf0a325
parent 43831 e323be6b02a5
child 43853 020ddc6a9508
permissions -rw-r--r--
tuned notation
haftmann@32139
     1
(*  Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel; Florian Haftmann, TU Muenchen *)
wenzelm@11979
     2
haftmann@32139
     3
header {* Complete lattices, with special focus on sets *}
haftmann@32077
     4
haftmann@32139
     5
theory Complete_Lattice
haftmann@32139
     6
imports Set
haftmann@32139
     7
begin
haftmann@32077
     8
haftmann@32077
     9
notation
haftmann@34007
    10
  less_eq (infix "\<sqsubseteq>" 50) and
haftmann@32077
    11
  less (infix "\<sqsubset>" 50) and
haftmann@34007
    12
  inf (infixl "\<sqinter>" 70) and
haftmann@34007
    13
  sup (infixl "\<squnion>" 65) and
haftmann@32678
    14
  top ("\<top>") and
haftmann@32678
    15
  bot ("\<bottom>")
haftmann@32077
    16
haftmann@32139
    17
haftmann@32879
    18
subsection {* Syntactic infimum and supremum operations *}
haftmann@32879
    19
haftmann@32879
    20
class Inf =
haftmann@32879
    21
  fixes Inf :: "'a set \<Rightarrow> 'a" ("\<Sqinter>_" [900] 900)
haftmann@32879
    22
haftmann@32879
    23
class Sup =
haftmann@32879
    24
  fixes Sup :: "'a set \<Rightarrow> 'a" ("\<Squnion>_" [900] 900)
haftmann@32879
    25
haftmann@32139
    26
subsection {* Abstract complete lattices *}
haftmann@32139
    27
haftmann@34007
    28
class complete_lattice = bounded_lattice + Inf + Sup +
haftmann@32077
    29
  assumes Inf_lower: "x \<in> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> x"
haftmann@32077
    30
     and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A"
haftmann@32077
    31
  assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A"
haftmann@32077
    32
     and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z"
haftmann@32077
    33
begin
haftmann@32077
    34
haftmann@32678
    35
lemma dual_complete_lattice:
haftmann@36635
    36
  "class.complete_lattice Sup Inf (op \<ge>) (op >) (op \<squnion>) (op \<sqinter>) \<top> \<bottom>"
haftmann@36635
    37
  by (auto intro!: class.complete_lattice.intro dual_bounded_lattice)
haftmann@34007
    38
    (unfold_locales, (fact bot_least top_greatest
haftmann@34007
    39
        Sup_upper Sup_least Inf_lower Inf_greatest)+)
haftmann@32678
    40
haftmann@34007
    41
lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<sqsubseteq> a}"
haftmann@32077
    42
  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
haftmann@32077
    43
haftmann@34007
    44
lemma Sup_Inf:  "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<sqsubseteq> b}"
haftmann@32077
    45
  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
haftmann@32077
    46
haftmann@41080
    47
lemma Inf_empty [simp]:
haftmann@34007
    48
  "\<Sqinter>{} = \<top>"
haftmann@34007
    49
  by (auto intro: antisym Inf_greatest)
haftmann@32077
    50
haftmann@41080
    51
lemma Sup_empty [simp]:
haftmann@34007
    52
  "\<Squnion>{} = \<bottom>"
haftmann@34007
    53
  by (auto intro: antisym Sup_least)
haftmann@32077
    54
haftmann@41080
    55
lemma Inf_UNIV [simp]:
haftmann@41080
    56
  "\<Sqinter>UNIV = \<bottom>"
haftmann@41080
    57
  by (simp add: Sup_Inf Sup_empty [symmetric])
haftmann@41080
    58
haftmann@41080
    59
lemma Sup_UNIV [simp]:
haftmann@41080
    60
  "\<Squnion>UNIV = \<top>"
haftmann@41080
    61
  by (simp add: Inf_Sup Inf_empty [symmetric])
haftmann@41080
    62
haftmann@32077
    63
lemma Inf_insert: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A"
haftmann@32077
    64
  by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower)
haftmann@32077
    65
haftmann@32077
    66
lemma Sup_insert: "\<Squnion>insert a A = a \<squnion> \<Squnion>A"
haftmann@32077
    67
  by (auto intro: le_supI le_supI1 le_supI2 antisym Sup_least Sup_upper)
haftmann@32077
    68
haftmann@32077
    69
lemma Inf_singleton [simp]:
haftmann@32077
    70
  "\<Sqinter>{a} = a"
haftmann@32077
    71
  by (auto intro: antisym Inf_lower Inf_greatest)
haftmann@32077
    72
haftmann@32077
    73
lemma Sup_singleton [simp]:
haftmann@32077
    74
  "\<Squnion>{a} = a"
haftmann@32077
    75
  by (auto intro: antisym Sup_upper Sup_least)
haftmann@32077
    76
haftmann@32077
    77
lemma Inf_binary:
haftmann@32077
    78
  "\<Sqinter>{a, b} = a \<sqinter> b"
haftmann@43831
    79
  by (simp add: Inf_insert)
haftmann@32077
    80
haftmann@32077
    81
lemma Sup_binary:
haftmann@32077
    82
  "\<Squnion>{a, b} = a \<squnion> b"
haftmann@43831
    83
  by (simp add: Sup_insert)
haftmann@32077
    84
haftmann@43754
    85
lemma le_Inf_iff: "b \<sqsubseteq> \<Sqinter>A \<longleftrightarrow> (\<forall>a\<in>A. b \<sqsubseteq> a)"
huffman@35629
    86
  by (auto intro: Inf_greatest dest: Inf_lower)
huffman@35629
    87
haftmann@43741
    88
lemma Sup_le_iff: "\<Squnion>A \<sqsubseteq> b \<longleftrightarrow> (\<forall>a\<in>A. a \<sqsubseteq> b)"
haftmann@41082
    89
  by (auto intro: Sup_least dest: Sup_upper)
hoelzl@38705
    90
hoelzl@38705
    91
lemma Inf_mono:
hoelzl@41971
    92
  assumes "\<And>b. b \<in> B \<Longrightarrow> \<exists>a\<in>A. a \<sqsubseteq> b"
haftmann@43741
    93
  shows "\<Sqinter>A \<sqsubseteq> \<Sqinter>B"
hoelzl@38705
    94
proof (rule Inf_greatest)
hoelzl@38705
    95
  fix b assume "b \<in> B"
hoelzl@41971
    96
  with assms obtain a where "a \<in> A" and "a \<sqsubseteq> b" by blast
haftmann@43741
    97
  from `a \<in> A` have "\<Sqinter>A \<sqsubseteq> a" by (rule Inf_lower)
haftmann@43741
    98
  with `a \<sqsubseteq> b` show "\<Sqinter>A \<sqsubseteq> b" by auto
hoelzl@38705
    99
qed
hoelzl@38705
   100
haftmann@41082
   101
lemma Sup_mono:
hoelzl@41971
   102
  assumes "\<And>a. a \<in> A \<Longrightarrow> \<exists>b\<in>B. a \<sqsubseteq> b"
haftmann@43741
   103
  shows "\<Squnion>A \<sqsubseteq> \<Squnion>B"
haftmann@41082
   104
proof (rule Sup_least)
haftmann@41082
   105
  fix a assume "a \<in> A"
hoelzl@41971
   106
  with assms obtain b where "b \<in> B" and "a \<sqsubseteq> b" by blast
haftmann@43741
   107
  from `b \<in> B` have "b \<sqsubseteq> \<Squnion>B" by (rule Sup_upper)
haftmann@43741
   108
  with `a \<sqsubseteq> b` show "a \<sqsubseteq> \<Squnion>B" by auto
haftmann@41082
   109
qed
haftmann@32077
   110
hoelzl@41971
   111
lemma top_le:
haftmann@43741
   112
  "\<top> \<sqsubseteq> x \<Longrightarrow> x = \<top>"
hoelzl@41971
   113
  by (rule antisym) auto
hoelzl@41971
   114
hoelzl@41971
   115
lemma le_bot:
haftmann@43741
   116
  "x \<sqsubseteq> \<bottom> \<Longrightarrow> x = \<bottom>"
hoelzl@41971
   117
  by (rule antisym) auto
hoelzl@41971
   118
haftmann@43831
   119
lemma not_less_bot [simp]: "\<not> (x \<sqsubset> \<bottom>)"
haftmann@43831
   120
  using bot_least [of x] by (auto simp: le_less)
hoelzl@41971
   121
haftmann@43831
   122
lemma not_top_less [simp]: "\<not> (\<top> \<sqsubset> x)"
haftmann@43831
   123
  using top_greatest [of x] by (auto simp: le_less)
hoelzl@41971
   124
haftmann@43741
   125
lemma Sup_upper2: "u \<in> A \<Longrightarrow> v \<sqsubseteq> u \<Longrightarrow> v \<sqsubseteq> \<Squnion>A"
hoelzl@41971
   126
  using Sup_upper[of u A] by auto
hoelzl@41971
   127
haftmann@43741
   128
lemma Inf_lower2: "u \<in> A \<Longrightarrow> u \<sqsubseteq> v \<Longrightarrow> \<Sqinter>A \<sqsubseteq> v"
hoelzl@41971
   129
  using Inf_lower[of u A] by auto
hoelzl@41971
   130
haftmann@32077
   131
definition INFI :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
haftmann@32117
   132
  "INFI A f = \<Sqinter> (f ` A)"
haftmann@32077
   133
haftmann@41082
   134
definition SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
haftmann@41082
   135
  "SUPR A f = \<Squnion> (f ` A)"
haftmann@41082
   136
haftmann@32077
   137
end
haftmann@32077
   138
haftmann@32077
   139
syntax
haftmann@41082
   140
  "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3INF _./ _)" [0, 10] 10)
haftmann@41082
   141
  "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3INF _:_./ _)" [0, 0, 10] 10)
haftmann@41080
   142
  "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3SUP _./ _)" [0, 10] 10)
haftmann@41080
   143
  "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3SUP _:_./ _)" [0, 0, 10] 10)
haftmann@41080
   144
haftmann@41080
   145
syntax (xsymbols)
haftmann@41082
   146
  "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Sqinter>_./ _)" [0, 10] 10)
haftmann@41082
   147
  "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41080
   148
  "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
haftmann@41080
   149
  "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@32077
   150
haftmann@32077
   151
translations
haftmann@41082
   152
  "INF x y. B"   == "INF x. INF y. B"
haftmann@41082
   153
  "INF x. B"     == "CONST INFI CONST UNIV (%x. B)"
haftmann@41082
   154
  "INF x. B"     == "INF x:CONST UNIV. B"
haftmann@41082
   155
  "INF x:A. B"   == "CONST INFI A (%x. B)"
haftmann@32077
   156
  "SUP x y. B"   == "SUP x. SUP y. B"
haftmann@32077
   157
  "SUP x. B"     == "CONST SUPR CONST UNIV (%x. B)"
haftmann@32077
   158
  "SUP x. B"     == "SUP x:CONST UNIV. B"
haftmann@32077
   159
  "SUP x:A. B"   == "CONST SUPR A (%x. B)"
haftmann@32077
   160
wenzelm@35115
   161
print_translation {*
wenzelm@42284
   162
  [Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax INFI} @{syntax_const "_INF"},
wenzelm@42284
   163
    Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax SUPR} @{syntax_const "_SUP"}]
wenzelm@35115
   164
*} -- {* to avoid eta-contraction of body *}
wenzelm@11979
   165
haftmann@32077
   166
context complete_lattice
haftmann@32077
   167
begin
haftmann@32077
   168
hoelzl@41971
   169
lemma SUP_cong: "(\<And>x. x \<in> A \<Longrightarrow> f x = g x) \<Longrightarrow> SUPR A f = SUPR A g"
hoelzl@41971
   170
  by (simp add: SUPR_def cong: image_cong)
hoelzl@41971
   171
hoelzl@41971
   172
lemma INF_cong: "(\<And>x. x \<in> A \<Longrightarrow> f x = g x) \<Longrightarrow> INFI A f = INFI A g"
hoelzl@41971
   173
  by (simp add: INFI_def cong: image_cong)
hoelzl@41971
   174
haftmann@43741
   175
lemma le_SUPI: "i \<in> A \<Longrightarrow> M i \<sqsubseteq> (\<Squnion>i\<in>A. M i)"
haftmann@32077
   176
  by (auto simp add: SUPR_def intro: Sup_upper)
haftmann@32077
   177
haftmann@43741
   178
lemma le_SUPI2: "i \<in> A \<Longrightarrow> u \<sqsubseteq> M i \<Longrightarrow> u \<sqsubseteq> (\<Squnion>i\<in>A. M i)"
hoelzl@41971
   179
  using le_SUPI[of i A M] by auto
hoelzl@41971
   180
haftmann@43741
   181
lemma SUP_leI: "(\<And>i. i \<in> A \<Longrightarrow> M i \<sqsubseteq> u) \<Longrightarrow> (\<Squnion>i\<in>A. M i) \<sqsubseteq> u"
haftmann@32077
   182
  by (auto simp add: SUPR_def intro: Sup_least)
haftmann@32077
   183
haftmann@43741
   184
lemma INF_leI: "i \<in> A \<Longrightarrow> (\<Sqinter>i\<in>A. M i) \<sqsubseteq> M i"
haftmann@32077
   185
  by (auto simp add: INFI_def intro: Inf_lower)
haftmann@32077
   186
haftmann@43741
   187
lemma INF_leI2: "i \<in> A \<Longrightarrow> M i \<sqsubseteq> u \<Longrightarrow> (\<Sqinter>i\<in>A. M i) \<sqsubseteq> u"
hoelzl@41971
   188
  using INF_leI[of i A M] by auto
hoelzl@41971
   189
haftmann@43741
   190
lemma le_INFI: "(\<And>i. i \<in> A \<Longrightarrow> u \<sqsubseteq> M i) \<Longrightarrow> u \<sqsubseteq> (\<Sqinter>i\<in>A. M i)"
haftmann@32077
   191
  by (auto simp add: INFI_def intro: Inf_greatest)
haftmann@32077
   192
haftmann@43753
   193
lemma SUP_le_iff: "(\<Squnion>i\<in>A. M i) \<sqsubseteq> u \<longleftrightarrow> (\<forall>i \<in> A. M i \<sqsubseteq> u)"
huffman@35629
   194
  unfolding SUPR_def by (auto simp add: Sup_le_iff)
huffman@35629
   195
haftmann@43753
   196
lemma le_INF_iff: "u \<sqsubseteq> (\<Sqinter>i\<in>A. M i) \<longleftrightarrow> (\<forall>i \<in> A. u \<sqsubseteq> M i)"
huffman@35629
   197
  unfolding INFI_def by (auto simp add: le_Inf_iff)
huffman@35629
   198
haftmann@43753
   199
lemma INF_const[simp]: "A \<noteq> {} \<Longrightarrow> (\<Sqinter>i\<in>A. M) = M"
haftmann@32077
   200
  by (auto intro: antisym INF_leI le_INFI)
haftmann@32077
   201
haftmann@43753
   202
lemma SUP_const[simp]: "A \<noteq> {} \<Longrightarrow> (\<Squnion>i\<in>A. M) = M"
haftmann@41082
   203
  by (auto intro: antisym SUP_leI le_SUPI)
hoelzl@38705
   204
hoelzl@38705
   205
lemma INF_mono:
haftmann@43753
   206
  "(\<And>m. m \<in> B \<Longrightarrow> \<exists>n\<in>A. f n \<sqsubseteq> g m) \<Longrightarrow> (\<Sqinter>n\<in>A. f n) \<sqsubseteq> (\<Sqinter>n\<in>B. g n)"
hoelzl@38705
   207
  by (force intro!: Inf_mono simp: INFI_def)
hoelzl@38705
   208
haftmann@41082
   209
lemma SUP_mono:
haftmann@43753
   210
  "(\<And>n. n \<in> A \<Longrightarrow> \<exists>m\<in>B. f n \<sqsubseteq> g m) \<Longrightarrow> (\<Squnion>n\<in>A. f n) \<sqsubseteq> (\<Squnion>n\<in>B. g n)"
haftmann@41082
   211
  by (force intro!: Sup_mono simp: SUPR_def)
hoelzl@40872
   212
haftmann@43753
   213
lemma INF_subset:  "A \<subseteq> B \<Longrightarrow> INFI B f \<sqsubseteq> INFI A f"
hoelzl@40872
   214
  by (intro INF_mono) auto
hoelzl@40872
   215
haftmann@43753
   216
lemma SUP_subset:  "A \<subseteq> B \<Longrightarrow> SUPR A f \<sqsubseteq> SUPR B f"
haftmann@41082
   217
  by (intro SUP_mono) auto
hoelzl@40872
   218
haftmann@43753
   219
lemma INF_commute: "(\<Sqinter>i\<in>A. \<Sqinter>j\<in>B. f i j) = (\<Sqinter>j\<in>B. \<Sqinter>i\<in>A. f i j)"
hoelzl@40872
   220
  by (iprover intro: INF_leI le_INFI order_trans antisym)
hoelzl@40872
   221
haftmann@43753
   222
lemma SUP_commute: "(\<Squnion>i\<in>A. \<Squnion>j\<in>B. f i j) = (\<Squnion>j\<in>B. \<Squnion>i\<in>A. f i j)"
haftmann@41082
   223
  by (iprover intro: SUP_leI le_SUPI order_trans antisym)
haftmann@41082
   224
haftmann@32077
   225
end
haftmann@32077
   226
haftmann@41082
   227
lemma Inf_less_iff:
haftmann@41082
   228
  fixes a :: "'a\<Colon>{complete_lattice,linorder}"
haftmann@43753
   229
  shows "\<Sqinter>S \<sqsubset> a \<longleftrightarrow> (\<exists>x\<in>S. x \<sqsubset> a)"
haftmann@43754
   230
  unfolding not_le [symmetric] le_Inf_iff by auto
haftmann@41082
   231
hoelzl@38705
   232
lemma less_Sup_iff:
hoelzl@38705
   233
  fixes a :: "'a\<Colon>{complete_lattice,linorder}"
haftmann@43753
   234
  shows "a \<sqsubset> \<Squnion>S \<longleftrightarrow> (\<exists>x\<in>S. a \<sqsubset> x)"
haftmann@43754
   235
  unfolding not_le [symmetric] Sup_le_iff by auto
hoelzl@38705
   236
haftmann@41082
   237
lemma INF_less_iff:
haftmann@41082
   238
  fixes a :: "'a::{complete_lattice,linorder}"
haftmann@43753
   239
  shows "(\<Sqinter>i\<in>A. f i) \<sqsubset> a \<longleftrightarrow> (\<exists>x\<in>A. f x \<sqsubset> a)"
haftmann@41082
   240
  unfolding INFI_def Inf_less_iff by auto
haftmann@32077
   241
hoelzl@40872
   242
lemma less_SUP_iff:
hoelzl@40872
   243
  fixes a :: "'a::{complete_lattice,linorder}"
haftmann@43753
   244
  shows "a \<sqsubset> (\<Squnion>i\<in>A. f i) \<longleftrightarrow> (\<exists>x\<in>A. a \<sqsubset> f x)"
hoelzl@40872
   245
  unfolding SUPR_def less_Sup_iff by auto
hoelzl@40872
   246
haftmann@32139
   247
subsection {* @{typ bool} and @{typ "_ \<Rightarrow> _"} as complete lattice *}
haftmann@32077
   248
haftmann@32077
   249
instantiation bool :: complete_lattice
haftmann@32077
   250
begin
haftmann@32077
   251
haftmann@32077
   252
definition
haftmann@41080
   253
  "\<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x)"
haftmann@32077
   254
haftmann@32077
   255
definition
haftmann@41080
   256
  "\<Squnion>A \<longleftrightarrow> (\<exists>x\<in>A. x)"
haftmann@32077
   257
haftmann@32077
   258
instance proof
haftmann@43852
   259
qed (auto simp add: Inf_bool_def Sup_bool_def)
haftmann@32077
   260
haftmann@32077
   261
end
haftmann@32077
   262
haftmann@41080
   263
lemma INFI_bool_eq [simp]:
haftmann@32120
   264
  "INFI = Ball"
haftmann@32120
   265
proof (rule ext)+
haftmann@32120
   266
  fix A :: "'a set"
haftmann@32120
   267
  fix P :: "'a \<Rightarrow> bool"
haftmann@43753
   268
  show "(\<Sqinter>x\<in>A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P x)"
haftmann@32120
   269
    by (auto simp add: Ball_def INFI_def Inf_bool_def)
haftmann@32120
   270
qed
haftmann@32120
   271
haftmann@41080
   272
lemma SUPR_bool_eq [simp]:
haftmann@32120
   273
  "SUPR = Bex"
haftmann@32120
   274
proof (rule ext)+
haftmann@32120
   275
  fix A :: "'a set"
haftmann@32120
   276
  fix P :: "'a \<Rightarrow> bool"
haftmann@43753
   277
  show "(\<Squnion>x\<in>A. P x) \<longleftrightarrow> (\<exists>x\<in>A. P x)"
haftmann@32120
   278
    by (auto simp add: Bex_def SUPR_def Sup_bool_def)
haftmann@32120
   279
qed
haftmann@32120
   280
haftmann@32077
   281
instantiation "fun" :: (type, complete_lattice) complete_lattice
haftmann@32077
   282
begin
haftmann@32077
   283
haftmann@32077
   284
definition
haftmann@41080
   285
  "\<Sqinter>A = (\<lambda>x. \<Sqinter>{y. \<exists>f\<in>A. y = f x})"
haftmann@41080
   286
haftmann@41080
   287
lemma Inf_apply:
haftmann@41080
   288
  "(\<Sqinter>A) x = \<Sqinter>{y. \<exists>f\<in>A. y = f x}"
haftmann@41080
   289
  by (simp add: Inf_fun_def)
haftmann@32077
   290
haftmann@32077
   291
definition
haftmann@41080
   292
  "\<Squnion>A = (\<lambda>x. \<Squnion>{y. \<exists>f\<in>A. y = f x})"
haftmann@41080
   293
haftmann@41080
   294
lemma Sup_apply:
haftmann@41080
   295
  "(\<Squnion>A) x = \<Squnion>{y. \<exists>f\<in>A. y = f x}"
haftmann@41080
   296
  by (simp add: Sup_fun_def)
haftmann@32077
   297
haftmann@32077
   298
instance proof
haftmann@41080
   299
qed (auto simp add: le_fun_def Inf_apply Sup_apply
haftmann@32077
   300
  intro: Inf_lower Sup_upper Inf_greatest Sup_least)
haftmann@32077
   301
haftmann@32077
   302
end
haftmann@32077
   303
haftmann@41080
   304
lemma INFI_apply:
haftmann@41080
   305
  "(\<Sqinter>y\<in>A. f y) x = (\<Sqinter>y\<in>A. f y x)"
haftmann@41080
   306
  by (auto intro: arg_cong [of _ _ Inf] simp add: INFI_def Inf_apply)
hoelzl@38705
   307
haftmann@41080
   308
lemma SUPR_apply:
haftmann@41080
   309
  "(\<Squnion>y\<in>A. f y) x = (\<Squnion>y\<in>A. f y x)"
haftmann@41080
   310
  by (auto intro: arg_cong [of _ _ Sup] simp add: SUPR_def Sup_apply)
haftmann@32077
   311
haftmann@32077
   312
haftmann@41082
   313
subsection {* Inter *}
haftmann@41082
   314
haftmann@41082
   315
abbreviation Inter :: "'a set set \<Rightarrow> 'a set" where
haftmann@41082
   316
  "Inter S \<equiv> \<Sqinter>S"
haftmann@41082
   317
  
haftmann@41082
   318
notation (xsymbols)
haftmann@41082
   319
  Inter  ("\<Inter>_" [90] 90)
haftmann@41082
   320
haftmann@41082
   321
lemma Inter_eq:
haftmann@41082
   322
  "\<Inter>A = {x. \<forall>B \<in> A. x \<in> B}"
haftmann@41082
   323
proof (rule set_eqI)
haftmann@41082
   324
  fix x
haftmann@41082
   325
  have "(\<forall>Q\<in>{P. \<exists>B\<in>A. P \<longleftrightarrow> x \<in> B}. Q) \<longleftrightarrow> (\<forall>B\<in>A. x \<in> B)"
haftmann@41082
   326
    by auto
haftmann@41082
   327
  then show "x \<in> \<Inter>A \<longleftrightarrow> x \<in> {x. \<forall>B \<in> A. x \<in> B}"
haftmann@41082
   328
    by (simp add: Inf_fun_def Inf_bool_def) (simp add: mem_def)
haftmann@41082
   329
qed
haftmann@41082
   330
haftmann@43741
   331
lemma Inter_iff [simp,no_atp]: "A \<in> \<Inter>C \<longleftrightarrow> (\<forall>X\<in>C. A \<in> X)"
haftmann@41082
   332
  by (unfold Inter_eq) blast
haftmann@41082
   333
haftmann@43741
   334
lemma InterI [intro!]: "(\<And>X. X \<in> C \<Longrightarrow> A \<in> X) \<Longrightarrow> A \<in> \<Inter>C"
haftmann@41082
   335
  by (simp add: Inter_eq)
haftmann@41082
   336
haftmann@41082
   337
text {*
haftmann@41082
   338
  \medskip A ``destruct'' rule -- every @{term X} in @{term C}
haftmann@43741
   339
  contains @{term A} as an element, but @{prop "A \<in> X"} can hold when
haftmann@43741
   340
  @{prop "X \<in> C"} does not!  This rule is analogous to @{text spec}.
haftmann@41082
   341
*}
haftmann@41082
   342
haftmann@43741
   343
lemma InterD [elim, Pure.elim]: "A \<in> \<Inter>C \<Longrightarrow> X \<in> C \<Longrightarrow> A \<in> X"
haftmann@41082
   344
  by auto
haftmann@41082
   345
haftmann@43741
   346
lemma InterE [elim]: "A \<in> \<Inter>C \<Longrightarrow> (X \<notin> C \<Longrightarrow> R) \<Longrightarrow> (A \<in> X \<Longrightarrow> R) \<Longrightarrow> R"
haftmann@41082
   347
  -- {* ``Classical'' elimination rule -- does not require proving
haftmann@43741
   348
    @{prop "X \<in> C"}. *}
haftmann@41082
   349
  by (unfold Inter_eq) blast
haftmann@41082
   350
haftmann@43741
   351
lemma Inter_lower: "B \<in> A \<Longrightarrow> \<Inter>A \<subseteq> B"
haftmann@43740
   352
  by (fact Inf_lower)
haftmann@43740
   353
haftmann@43740
   354
lemma (in complete_lattice) Inf_less_eq:
haftmann@43740
   355
  assumes "\<And>v. v \<in> A \<Longrightarrow> v \<sqsubseteq> u"
haftmann@43740
   356
    and "A \<noteq> {}"
haftmann@43753
   357
  shows "\<Sqinter>A \<sqsubseteq> u"
haftmann@43740
   358
proof -
haftmann@43740
   359
  from `A \<noteq> {}` obtain v where "v \<in> A" by blast
haftmann@43740
   360
  moreover with assms have "v \<sqsubseteq> u" by blast
haftmann@43740
   361
  ultimately show ?thesis by (rule Inf_lower2)
haftmann@43740
   362
qed
haftmann@41082
   363
haftmann@41082
   364
lemma Inter_subset:
haftmann@43755
   365
  "(\<And>X. X \<in> A \<Longrightarrow> X \<subseteq> B) \<Longrightarrow> A \<noteq> {} \<Longrightarrow> \<Inter>A \<subseteq> B"
haftmann@43740
   366
  by (fact Inf_less_eq)
haftmann@41082
   367
haftmann@43755
   368
lemma Inter_greatest: "(\<And>X. X \<in> A \<Longrightarrow> C \<subseteq> X) \<Longrightarrow> C \<subseteq> Inter A"
haftmann@43740
   369
  by (fact Inf_greatest)
haftmann@41082
   370
haftmann@41082
   371
lemma Int_eq_Inter: "A \<inter> B = \<Inter>{A, B}"
haftmann@43739
   372
  by (fact Inf_binary [symmetric])
haftmann@41082
   373
haftmann@41082
   374
lemma Inter_empty [simp]: "\<Inter>{} = UNIV"
haftmann@41082
   375
  by (fact Inf_empty)
haftmann@41082
   376
haftmann@41082
   377
lemma Inter_UNIV [simp]: "\<Inter>UNIV = {}"
haftmann@43739
   378
  by (fact Inf_UNIV)
haftmann@41082
   379
haftmann@41082
   380
lemma Inter_insert [simp]: "\<Inter>(insert a B) = a \<inter> \<Inter>B"
haftmann@43739
   381
  by (fact Inf_insert)
haftmann@41082
   382
haftmann@43741
   383
lemma (in complete_lattice) Inf_inter_less: "\<Sqinter>A \<squnion> \<Sqinter>B \<sqsubseteq> \<Sqinter>(A \<inter> B)"
haftmann@43741
   384
  by (auto intro: Inf_greatest Inf_lower)
haftmann@43741
   385
haftmann@41082
   386
lemma Inter_Un_subset: "\<Inter>A \<union> \<Inter>B \<subseteq> \<Inter>(A \<inter> B)"
haftmann@43741
   387
  by (fact Inf_inter_less)
haftmann@43741
   388
haftmann@43756
   389
lemma (in complete_lattice) Inf_union_distrib: "\<Sqinter>(A \<union> B) = \<Sqinter>A \<sqinter> \<Sqinter>B"
haftmann@43756
   390
  by (rule antisym) (auto intro: Inf_greatest Inf_lower le_infI1 le_infI2)
haftmann@41082
   391
haftmann@41082
   392
lemma Inter_Un_distrib: "\<Inter>(A \<union> B) = \<Inter>A \<inter> \<Inter>B"
haftmann@43756
   393
  by (fact Inf_union_distrib)
haftmann@43756
   394
haftmann@43801
   395
lemma (in complete_lattice) Inf_top_conv [no_atp]:
haftmann@43801
   396
  "\<Sqinter>A = \<top> \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
haftmann@43801
   397
  "\<top> = \<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
haftmann@43801
   398
proof -
haftmann@43801
   399
  show "\<Sqinter>A = \<top> \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
haftmann@43801
   400
  proof
haftmann@43801
   401
    assume "\<forall>x\<in>A. x = \<top>"
haftmann@43801
   402
    then have "A = {} \<or> A = {\<top>}" by auto
haftmann@43801
   403
    then show "\<Sqinter>A = \<top>" by auto
haftmann@43801
   404
  next
haftmann@43801
   405
    assume "\<Sqinter>A = \<top>"
haftmann@43801
   406
    show "\<forall>x\<in>A. x = \<top>"
haftmann@43801
   407
    proof (rule ccontr)
haftmann@43801
   408
      assume "\<not> (\<forall>x\<in>A. x = \<top>)"
haftmann@43801
   409
      then obtain x where "x \<in> A" and "x \<noteq> \<top>" by blast
haftmann@43801
   410
      then obtain B where "A = insert x B" by blast
haftmann@43801
   411
      with `\<Sqinter>A = \<top>` `x \<noteq> \<top>` show False by (simp add: Inf_insert)
haftmann@43801
   412
    qed
haftmann@43801
   413
  qed
haftmann@43801
   414
  then show "\<top> = \<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)" by auto
haftmann@43801
   415
qed
haftmann@41082
   416
haftmann@41082
   417
lemma Inter_UNIV_conv [simp,no_atp]:
haftmann@43741
   418
  "\<Inter>A = UNIV \<longleftrightarrow> (\<forall>x\<in>A. x = UNIV)"
haftmann@43741
   419
  "UNIV = \<Inter>A \<longleftrightarrow> (\<forall>x\<in>A. x = UNIV)"
haftmann@43801
   420
  by (fact Inf_top_conv)+
haftmann@41082
   421
haftmann@43756
   422
lemma (in complete_lattice) Inf_anti_mono: "B \<subseteq> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> \<Sqinter>B"
haftmann@43756
   423
  by (auto intro: Inf_greatest Inf_lower)
haftmann@43756
   424
haftmann@43741
   425
lemma Inter_anti_mono: "B \<subseteq> A \<Longrightarrow> \<Inter>A \<subseteq> \<Inter>B"
haftmann@43756
   426
  by (fact Inf_anti_mono)
haftmann@41082
   427
haftmann@41082
   428
haftmann@41082
   429
subsection {* Intersections of families *}
haftmann@41082
   430
haftmann@41082
   431
abbreviation INTER :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
haftmann@41082
   432
  "INTER \<equiv> INFI"
haftmann@41082
   433
haftmann@41082
   434
syntax
haftmann@41082
   435
  "_INTER1"     :: "pttrns => 'b set => 'b set"           ("(3INT _./ _)" [0, 10] 10)
haftmann@41082
   436
  "_INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3INT _:_./ _)" [0, 0, 10] 10)
haftmann@41082
   437
haftmann@41082
   438
syntax (xsymbols)
haftmann@41082
   439
  "_INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>_./ _)" [0, 10] 10)
haftmann@41082
   440
  "_INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41082
   441
haftmann@41082
   442
syntax (latex output)
haftmann@41082
   443
  "_INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
haftmann@41082
   444
  "_INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 0, 10] 10)
haftmann@41082
   445
haftmann@41082
   446
translations
haftmann@41082
   447
  "INT x y. B"  == "INT x. INT y. B"
haftmann@41082
   448
  "INT x. B"    == "CONST INTER CONST UNIV (%x. B)"
haftmann@41082
   449
  "INT x. B"    == "INT x:CONST UNIV. B"
haftmann@41082
   450
  "INT x:A. B"  == "CONST INTER A (%x. B)"
haftmann@41082
   451
haftmann@41082
   452
print_translation {*
wenzelm@42284
   453
  [Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax INTER} @{syntax_const "_INTER"}]
haftmann@41082
   454
*} -- {* to avoid eta-contraction of body *}
haftmann@41082
   455
haftmann@41082
   456
lemma INTER_eq_Inter_image:
haftmann@41082
   457
  "(\<Inter>x\<in>A. B x) = \<Inter>(B`A)"
haftmann@41082
   458
  by (fact INFI_def)
haftmann@41082
   459
  
haftmann@41082
   460
lemma Inter_def:
haftmann@41082
   461
  "\<Inter>S = (\<Inter>x\<in>S. x)"
haftmann@41082
   462
  by (simp add: INTER_eq_Inter_image image_def)
haftmann@41082
   463
haftmann@41082
   464
lemma INTER_def:
haftmann@41082
   465
  "(\<Inter>x\<in>A. B x) = {y. \<forall>x\<in>A. y \<in> B x}"
haftmann@41082
   466
  by (auto simp add: INTER_eq_Inter_image Inter_eq)
haftmann@41082
   467
haftmann@41082
   468
lemma Inter_image_eq [simp]:
haftmann@41082
   469
  "\<Inter>(B`A) = (\<Inter>x\<in>A. B x)"
haftmann@43801
   470
  by (rule sym) (fact INFI_def)
haftmann@41082
   471
haftmann@43817
   472
lemma INT_iff [simp]: "b \<in> (\<Inter>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. b \<in> B x)"
haftmann@41082
   473
  by (unfold INTER_def) blast
haftmann@41082
   474
haftmann@43817
   475
lemma INT_I [intro!]: "(\<And>x. x \<in> A \<Longrightarrow> b \<in> B x) \<Longrightarrow> b \<in> (\<Inter>x\<in>A. B x)"
haftmann@41082
   476
  by (unfold INTER_def) blast
haftmann@41082
   477
haftmann@43852
   478
lemma INT_D [elim, Pure.elim]: "b \<in> (\<Inter>x\<in>A. B x) \<Longrightarrow> a \<in> A \<Longrightarrow> b \<in> B a"
haftmann@41082
   479
  by auto
haftmann@41082
   480
haftmann@43852
   481
lemma INT_E [elim]: "b \<in> (\<Inter>x\<in>A. B x) \<Longrightarrow> (b \<in> B a \<Longrightarrow> R) \<Longrightarrow> (a \<notin> A \<Longrightarrow> R) \<Longrightarrow> R"
haftmann@43852
   482
  -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a\<in>A"}. *}
haftmann@41082
   483
  by (unfold INTER_def) blast
haftmann@41082
   484
haftmann@41082
   485
lemma INT_cong [cong]:
haftmann@43852
   486
    "A = B \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> C x = D x) \<Longrightarrow> (\<Inter>x\<in>A. C x) = (\<Inter>x\<in>B. D x)"
haftmann@41082
   487
  by (simp add: INTER_def)
haftmann@41082
   488
haftmann@41082
   489
lemma Collect_ball_eq: "{x. \<forall>y\<in>A. P x y} = (\<Inter>y\<in>A. {x. P x y})"
haftmann@41082
   490
  by blast
haftmann@41082
   491
haftmann@41082
   492
lemma Collect_all_eq: "{x. \<forall>y. P x y} = (\<Inter>y. {x. P x y})"
haftmann@41082
   493
  by blast
haftmann@41082
   494
haftmann@43817
   495
lemma INT_lower: "a \<in> A \<Longrightarrow> (\<Inter>x\<in>A. B x) \<subseteq> B a"
haftmann@41082
   496
  by (fact INF_leI)
haftmann@41082
   497
haftmann@43817
   498
lemma INT_greatest: "(\<And>x. x \<in> A \<Longrightarrow> C \<subseteq> B x) \<Longrightarrow> C \<subseteq> (\<Inter>x\<in>A. B x)"
haftmann@41082
   499
  by (fact le_INFI)
haftmann@41082
   500
haftmann@41082
   501
lemma INT_empty [simp]: "(\<Inter>x\<in>{}. B x) = UNIV"
haftmann@41082
   502
  by blast
haftmann@41082
   503
haftmann@43817
   504
lemma INT_absorb: "k \<in> I \<Longrightarrow> A k \<inter> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. A i)"
haftmann@41082
   505
  by blast
haftmann@41082
   506
haftmann@41082
   507
lemma INT_subset_iff: "(B \<subseteq> (\<Inter>i\<in>I. A i)) = (\<forall>i\<in>I. B \<subseteq> A i)"
haftmann@41082
   508
  by (fact le_INF_iff)
haftmann@41082
   509
haftmann@41082
   510
lemma INT_insert [simp]: "(\<Inter>x \<in> insert a A. B x) = B a \<inter> INTER A B"
haftmann@41082
   511
  by blast
haftmann@41082
   512
haftmann@41082
   513
lemma INT_Un: "(\<Inter>i \<in> A \<union> B. M i) = (\<Inter>i \<in> A. M i) \<inter> (\<Inter>i\<in>B. M i)"
haftmann@41082
   514
  by blast
haftmann@41082
   515
haftmann@41082
   516
lemma INT_insert_distrib:
haftmann@43817
   517
    "u \<in> A \<Longrightarrow> (\<Inter>x\<in>A. insert a (B x)) = insert a (\<Inter>x\<in>A. B x)"
haftmann@41082
   518
  by blast
haftmann@41082
   519
haftmann@41082
   520
lemma INT_constant [simp]: "(\<Inter>y\<in>A. c) = (if A = {} then UNIV else c)"
haftmann@41082
   521
  by auto
haftmann@41082
   522
haftmann@41082
   523
lemma INT_eq: "(\<Inter>x\<in>A. B x) = \<Inter>({Y. \<exists>x\<in>A. Y = B x})"
haftmann@41082
   524
  -- {* Look: it has an \emph{existential} quantifier *}
haftmann@41082
   525
  by blast
haftmann@41082
   526
haftmann@41082
   527
lemma INTER_UNIV_conv[simp]:
haftmann@43817
   528
 "(UNIV = (\<Inter>x\<in>A. B x)) = (\<forall>x\<in>A. B x = UNIV)"
haftmann@43817
   529
 "((\<Inter>x\<in>A. B x) = UNIV) = (\<forall>x\<in>A. B x = UNIV)"
haftmann@41082
   530
by blast+
haftmann@41082
   531
haftmann@43817
   532
lemma INT_bool_eq: "(\<Inter>b. A b) = (A True \<inter> A False)"
haftmann@41082
   533
  by (auto intro: bool_induct)
haftmann@41082
   534
haftmann@41082
   535
lemma Pow_INT_eq: "Pow (\<Inter>x\<in>A. B x) = (\<Inter>x\<in>A. Pow (B x))"
haftmann@41082
   536
  by blast
haftmann@41082
   537
haftmann@41082
   538
lemma INT_anti_mono:
haftmann@43817
   539
  "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<subseteq> g x) \<Longrightarrow>
haftmann@41082
   540
    (\<Inter>x\<in>A. f x) \<subseteq> (\<Inter>x\<in>A. g x)"
haftmann@41082
   541
  -- {* The last inclusion is POSITIVE! *}
haftmann@41082
   542
  by (blast dest: subsetD)
haftmann@41082
   543
haftmann@43817
   544
lemma vimage_INT: "f -` (\<Inter>x\<in>A. B x) = (\<Inter>x\<in>A. f -` B x)"
haftmann@41082
   545
  by blast
haftmann@41082
   546
haftmann@41082
   547
haftmann@32139
   548
subsection {* Union *}
haftmann@32115
   549
haftmann@32587
   550
abbreviation Union :: "'a set set \<Rightarrow> 'a set" where
haftmann@32587
   551
  "Union S \<equiv> \<Squnion>S"
haftmann@32115
   552
haftmann@32115
   553
notation (xsymbols)
haftmann@32115
   554
  Union  ("\<Union>_" [90] 90)
haftmann@32115
   555
haftmann@32135
   556
lemma Union_eq:
haftmann@32135
   557
  "\<Union>A = {x. \<exists>B \<in> A. x \<in> B}"
nipkow@39302
   558
proof (rule set_eqI)
haftmann@32115
   559
  fix x
haftmann@32135
   560
  have "(\<exists>Q\<in>{P. \<exists>B\<in>A. P \<longleftrightarrow> x \<in> B}. Q) \<longleftrightarrow> (\<exists>B\<in>A. x \<in> B)"
haftmann@32115
   561
    by auto
haftmann@32135
   562
  then show "x \<in> \<Union>A \<longleftrightarrow> x \<in> {x. \<exists>B\<in>A. x \<in> B}"
haftmann@32587
   563
    by (simp add: Sup_fun_def Sup_bool_def) (simp add: mem_def)
haftmann@32115
   564
qed
haftmann@32115
   565
blanchet@35828
   566
lemma Union_iff [simp, no_atp]:
haftmann@32115
   567
  "A \<in> \<Union>C \<longleftrightarrow> (\<exists>X\<in>C. A\<in>X)"
haftmann@32115
   568
  by (unfold Union_eq) blast
haftmann@32115
   569
haftmann@32115
   570
lemma UnionI [intro]:
haftmann@32115
   571
  "X \<in> C \<Longrightarrow> A \<in> X \<Longrightarrow> A \<in> \<Union>C"
haftmann@32115
   572
  -- {* The order of the premises presupposes that @{term C} is rigid;
haftmann@32115
   573
    @{term A} may be flexible. *}
haftmann@32115
   574
  by auto
haftmann@32115
   575
haftmann@32115
   576
lemma UnionE [elim!]:
haftmann@43817
   577
  "A \<in> \<Union>C \<Longrightarrow> (\<And>X. A \<in> X \<Longrightarrow> X \<in> C \<Longrightarrow> R) \<Longrightarrow> R"
haftmann@32115
   578
  by auto
haftmann@32115
   579
haftmann@43817
   580
lemma Union_upper: "B \<in> A \<Longrightarrow> B \<subseteq> \<Union>A"
haftmann@32135
   581
  by (iprover intro: subsetI UnionI)
haftmann@32135
   582
haftmann@43817
   583
lemma Union_least: "(\<And>X. X \<in> A \<Longrightarrow> X \<subseteq> C) \<Longrightarrow> \<Union>A \<subseteq> C"
haftmann@32135
   584
  by (iprover intro: subsetI elim: UnionE dest: subsetD)
haftmann@32135
   585
haftmann@32135
   586
lemma Un_eq_Union: "A \<union> B = \<Union>{A, B}"
haftmann@32135
   587
  by blast
haftmann@32135
   588
haftmann@43817
   589
lemma Union_empty [simp]: "\<Union>{} = {}"
haftmann@32135
   590
  by blast
haftmann@32135
   591
haftmann@43817
   592
lemma Union_UNIV [simp]: "\<Union>UNIV = UNIV"
haftmann@32135
   593
  by blast
haftmann@32135
   594
haftmann@43817
   595
lemma Union_insert [simp]: "\<Union>insert a B = a \<union> \<Union>B"
haftmann@32135
   596
  by blast
haftmann@32135
   597
haftmann@43817
   598
lemma Union_Un_distrib [simp]: "\<Union>(A \<union> B) = \<Union>A \<union> \<Union>B"
haftmann@32135
   599
  by blast
haftmann@32135
   600
haftmann@32135
   601
lemma Union_Int_subset: "\<Union>(A \<inter> B) \<subseteq> \<Union>A \<inter> \<Union>B"
haftmann@32135
   602
  by blast
haftmann@32135
   603
haftmann@43817
   604
lemma Union_empty_conv [simp,no_atp]: "(\<Union>A = {}) \<longleftrightarrow> (\<forall>x\<in>A. x = {})"
haftmann@32135
   605
  by blast
haftmann@32135
   606
haftmann@43817
   607
lemma empty_Union_conv [simp,no_atp]: "({} = \<Union>A) \<longleftrightarrow> (\<forall>x\<in>A. x = {})"
haftmann@32135
   608
  by blast
haftmann@32135
   609
haftmann@43817
   610
lemma Union_disjoint: "(\<Union>C \<inter> A = {}) \<longleftrightarrow> (\<forall>B\<in>C. B \<inter> A = {})"
haftmann@32135
   611
  by blast
haftmann@32135
   612
haftmann@32135
   613
lemma subset_Pow_Union: "A \<subseteq> Pow (\<Union>A)"
haftmann@32135
   614
  by blast
haftmann@32135
   615
haftmann@32135
   616
lemma Union_Pow_eq [simp]: "\<Union>(Pow A) = A"
haftmann@32135
   617
  by blast
haftmann@32135
   618
haftmann@43817
   619
lemma Union_mono: "A \<subseteq> B \<Longrightarrow> \<Union>A \<subseteq> \<Union>B"
haftmann@32135
   620
  by blast
haftmann@32135
   621
haftmann@32115
   622
haftmann@32139
   623
subsection {* Unions of families *}
haftmann@32077
   624
haftmann@32606
   625
abbreviation UNION :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
haftmann@32606
   626
  "UNION \<equiv> SUPR"
haftmann@32077
   627
haftmann@32077
   628
syntax
wenzelm@35115
   629
  "_UNION1"     :: "pttrns => 'b set => 'b set"           ("(3UN _./ _)" [0, 10] 10)
huffman@36364
   630
  "_UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3UN _:_./ _)" [0, 0, 10] 10)
haftmann@32077
   631
haftmann@32077
   632
syntax (xsymbols)
wenzelm@35115
   633
  "_UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>_./ _)" [0, 10] 10)
huffman@36364
   634
  "_UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@32077
   635
haftmann@32077
   636
syntax (latex output)
wenzelm@35115
   637
  "_UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
huffman@36364
   638
  "_UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 0, 10] 10)
haftmann@32077
   639
haftmann@32077
   640
translations
haftmann@32077
   641
  "UN x y. B"   == "UN x. UN y. B"
haftmann@32077
   642
  "UN x. B"     == "CONST UNION CONST UNIV (%x. B)"
haftmann@32077
   643
  "UN x. B"     == "UN x:CONST UNIV. B"
haftmann@32077
   644
  "UN x:A. B"   == "CONST UNION A (%x. B)"
haftmann@32077
   645
haftmann@32077
   646
text {*
haftmann@32077
   647
  Note the difference between ordinary xsymbol syntax of indexed
haftmann@32077
   648
  unions and intersections (e.g.\ @{text"\<Union>a\<^isub>1\<in>A\<^isub>1. B"})
haftmann@32077
   649
  and their \LaTeX\ rendition: @{term"\<Union>a\<^isub>1\<in>A\<^isub>1. B"}. The
haftmann@32077
   650
  former does not make the index expression a subscript of the
haftmann@32077
   651
  union/intersection symbol because this leads to problems with nested
haftmann@32077
   652
  subscripts in Proof General.
haftmann@32077
   653
*}
haftmann@32077
   654
wenzelm@35115
   655
print_translation {*
wenzelm@42284
   656
  [Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax UNION} @{syntax_const "_UNION"}]
wenzelm@35115
   657
*} -- {* to avoid eta-contraction of body *}
haftmann@32077
   658
haftmann@32135
   659
lemma UNION_eq_Union_image:
haftmann@43817
   660
  "(\<Union>x\<in>A. B x) = \<Union>(B ` A)"
haftmann@32606
   661
  by (fact SUPR_def)
haftmann@32115
   662
haftmann@32115
   663
lemma Union_def:
haftmann@32117
   664
  "\<Union>S = (\<Union>x\<in>S. x)"
haftmann@32115
   665
  by (simp add: UNION_eq_Union_image image_def)
haftmann@32115
   666
blanchet@35828
   667
lemma UNION_def [no_atp]:
haftmann@32135
   668
  "(\<Union>x\<in>A. B x) = {y. \<exists>x\<in>A. y \<in> B x}"
haftmann@32117
   669
  by (auto simp add: UNION_eq_Union_image Union_eq)
haftmann@32115
   670
  
haftmann@32115
   671
lemma Union_image_eq [simp]:
haftmann@43817
   672
  "\<Union>(B ` A) = (\<Union>x\<in>A. B x)"
haftmann@32115
   673
  by (rule sym) (fact UNION_eq_Union_image)
haftmann@32115
   674
  
haftmann@43852
   675
lemma UN_iff [simp]: "(b \<in> (\<Union>x\<in>A. B x)) = (\<exists>x\<in>A. b \<in> B x)"
wenzelm@11979
   676
  by (unfold UNION_def) blast
wenzelm@11979
   677
haftmann@43852
   678
lemma UN_I [intro]: "a \<in> A \<Longrightarrow> b \<in> B a \<Longrightarrow> b \<in> (\<Union>x\<in>A. B x)"
wenzelm@11979
   679
  -- {* The order of the premises presupposes that @{term A} is rigid;
wenzelm@11979
   680
    @{term b} may be flexible. *}
wenzelm@11979
   681
  by auto
wenzelm@11979
   682
haftmann@43852
   683
lemma UN_E [elim!]: "b \<in> (\<Union>x\<in>A. B x) \<Longrightarrow> (\<And>x. x\<in>A \<Longrightarrow> b \<in> B x \<Longrightarrow> R) \<Longrightarrow> R"
wenzelm@11979
   684
  by (unfold UNION_def) blast
clasohm@923
   685
wenzelm@11979
   686
lemma UN_cong [cong]:
haftmann@43852
   687
    "A = B \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> C x = D x) \<Longrightarrow> (\<Union>x\<in>A. C x) = (\<Union>x\<in>B. D x)"
wenzelm@11979
   688
  by (simp add: UNION_def)
wenzelm@11979
   689
berghofe@29691
   690
lemma strong_UN_cong:
haftmann@43852
   691
    "A = B \<Longrightarrow> (\<And>x. x \<in> B =simp=> C x = D x) \<Longrightarrow> (\<Union>x\<in>A. C x) = (\<Union>x\<in>B. D x)"
berghofe@29691
   692
  by (simp add: UNION_def simp_implies_def)
berghofe@29691
   693
haftmann@43817
   694
lemma image_eq_UN: "f ` A = (\<Union>x\<in>A. {f x})"
haftmann@32077
   695
  by blast
haftmann@32077
   696
haftmann@43817
   697
lemma UN_upper: "a \<in> A \<Longrightarrow> B a \<subseteq> (\<Union>x\<in>A. B x)"
haftmann@32606
   698
  by (fact le_SUPI)
haftmann@32135
   699
haftmann@43817
   700
lemma UN_least: "(\<And>x. x \<in> A \<Longrightarrow> B x \<subseteq> C) \<Longrightarrow> (\<Union>x\<in>A. B x) \<subseteq> C"
haftmann@32135
   701
  by (iprover intro: subsetI elim: UN_E dest: subsetD)
haftmann@32135
   702
blanchet@35828
   703
lemma Collect_bex_eq [no_atp]: "{x. \<exists>y\<in>A. P x y} = (\<Union>y\<in>A. {x. P x y})"
haftmann@32135
   704
  by blast
haftmann@32135
   705
haftmann@43817
   706
lemma UN_insert_distrib: "u \<in> A \<Longrightarrow> (\<Union>x\<in>A. insert a (B x)) = insert a (\<Union>x\<in>A. B x)"
haftmann@32135
   707
  by blast
haftmann@32135
   708
blanchet@35828
   709
lemma UN_empty [simp,no_atp]: "(\<Union>x\<in>{}. B x) = {}"
haftmann@32135
   710
  by blast
haftmann@32135
   711
haftmann@32135
   712
lemma UN_empty2 [simp]: "(\<Union>x\<in>A. {}) = {}"
haftmann@32135
   713
  by blast
haftmann@32135
   714
haftmann@32135
   715
lemma UN_singleton [simp]: "(\<Union>x\<in>A. {x}) = A"
haftmann@32135
   716
  by blast
haftmann@32135
   717
haftmann@43817
   718
lemma UN_absorb: "k \<in> I \<Longrightarrow> A k \<union> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. A i)"
haftmann@32135
   719
  by auto
haftmann@32135
   720
haftmann@32135
   721
lemma UN_insert [simp]: "(\<Union>x\<in>insert a A. B x) = B a \<union> UNION A B"
haftmann@32135
   722
  by blast
haftmann@32135
   723
haftmann@32135
   724
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)"
haftmann@32135
   725
  by blast
haftmann@32135
   726
haftmann@32135
   727
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)"
haftmann@32135
   728
  by blast
haftmann@32135
   729
haftmann@32135
   730
lemma UN_subset_iff: "((\<Union>i\<in>I. A i) \<subseteq> B) = (\<forall>i\<in>I. A i \<subseteq> B)"
huffman@35629
   731
  by (fact SUP_le_iff)
haftmann@32135
   732
haftmann@32135
   733
lemma image_Union: "f ` \<Union>S = (\<Union>x\<in>S. f ` x)"
haftmann@32135
   734
  by blast
haftmann@32135
   735
haftmann@32135
   736
lemma UN_constant [simp]: "(\<Union>y\<in>A. c) = (if A = {} then {} else c)"
haftmann@32135
   737
  by auto
haftmann@32135
   738
haftmann@32135
   739
lemma UN_eq: "(\<Union>x\<in>A. B x) = \<Union>({Y. \<exists>x\<in>A. Y = B x})"
haftmann@32135
   740
  by blast
haftmann@32135
   741
haftmann@32135
   742
lemma UNION_empty_conv[simp]:
haftmann@43817
   743
  "{} = (\<Union>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = {})"
haftmann@43817
   744
  "(\<Union>x\<in>A. B x) = {} \<longleftrightarrow> (\<forall>x\<in>A. B x = {})"
haftmann@32135
   745
by blast+
haftmann@32135
   746
blanchet@35828
   747
lemma Collect_ex_eq [no_atp]: "{x. \<exists>y. P x y} = (\<Union>y. {x. P x y})"
haftmann@32135
   748
  by blast
haftmann@32135
   749
haftmann@32135
   750
lemma ball_UN: "(\<forall>z \<in> UNION A B. P z) = (\<forall>x\<in>A. \<forall>z \<in> B x. P z)"
haftmann@32135
   751
  by blast
haftmann@32135
   752
haftmann@32135
   753
lemma bex_UN: "(\<exists>z \<in> UNION A B. P z) = (\<exists>x\<in>A. \<exists>z\<in>B x. P z)"
haftmann@32135
   754
  by blast
haftmann@32135
   755
haftmann@32135
   756
lemma Un_eq_UN: "A \<union> B = (\<Union>b. if b then A else B)"
haftmann@32135
   757
  by (auto simp add: split_if_mem2)
haftmann@32135
   758
haftmann@43817
   759
lemma UN_bool_eq: "(\<Union>b. A b) = (A True \<union> A False)"
haftmann@32135
   760
  by (auto intro: bool_contrapos)
haftmann@32135
   761
haftmann@32135
   762
lemma UN_Pow_subset: "(\<Union>x\<in>A. Pow (B x)) \<subseteq> Pow (\<Union>x\<in>A. B x)"
haftmann@32135
   763
  by blast
haftmann@32135
   764
haftmann@32135
   765
lemma UN_mono:
haftmann@43817
   766
  "A \<subseteq> B \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<subseteq> g x) \<Longrightarrow>
haftmann@32135
   767
    (\<Union>x\<in>A. f x) \<subseteq> (\<Union>x\<in>B. g x)"
haftmann@32135
   768
  by (blast dest: subsetD)
haftmann@32135
   769
haftmann@43817
   770
lemma vimage_Union: "f -` (\<Union>A) = (\<Union>X\<in>A. f -` X)"
haftmann@32135
   771
  by blast
haftmann@32135
   772
haftmann@43817
   773
lemma vimage_UN: "f -` (\<Union>x\<in>A. B x) = (\<Union>x\<in>A. f -` B x)"
haftmann@32135
   774
  by blast
haftmann@32135
   775
haftmann@43817
   776
lemma vimage_eq_UN: "f -` B = (\<Union>y\<in>B. f -` {y})"
haftmann@32135
   777
  -- {* NOT suitable for rewriting *}
haftmann@32135
   778
  by blast
haftmann@32135
   779
haftmann@43817
   780
lemma image_UN: "f ` UNION A B = (\<Union>x\<in>A. f ` B x)"
haftmann@43817
   781
  by blast
haftmann@32135
   782
wenzelm@11979
   783
haftmann@32139
   784
subsection {* Distributive laws *}
wenzelm@12897
   785
wenzelm@12897
   786
lemma Int_Union: "A \<inter> \<Union>B = (\<Union>C\<in>B. A \<inter> C)"
wenzelm@12897
   787
  by blast
wenzelm@12897
   788
wenzelm@12897
   789
lemma Int_Union2: "\<Union>B \<inter> A = (\<Union>C\<in>B. C \<inter> A)"
wenzelm@12897
   790
  by blast
wenzelm@12897
   791
haftmann@43817
   792
lemma Un_Union_image: "(\<Union>x\<in>C. A x \<union> B x) = \<Union>(A ` C) \<union> \<Union>(B ` C)"
wenzelm@12897
   793
  -- {* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: *}
wenzelm@12897
   794
  -- {* Union of a family of unions *}
wenzelm@12897
   795
  by blast
wenzelm@12897
   796
wenzelm@12897
   797
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
   798
  -- {* Equivalent version *}
wenzelm@12897
   799
  by blast
wenzelm@12897
   800
wenzelm@12897
   801
lemma Un_Inter: "A \<union> \<Inter>B = (\<Inter>C\<in>B. A \<union> C)"
wenzelm@12897
   802
  by blast
wenzelm@12897
   803
haftmann@43817
   804
lemma Int_Inter_image: "(\<Inter>x\<in>C. A x \<inter> B x) = \<Inter>(A ` C) \<inter> \<Inter>(B ` C)"
wenzelm@12897
   805
  by blast
wenzelm@12897
   806
wenzelm@12897
   807
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
   808
  -- {* Equivalent version *}
wenzelm@12897
   809
  by blast
wenzelm@12897
   810
wenzelm@12897
   811
lemma Int_UN_distrib: "B \<inter> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. B \<inter> A i)"
wenzelm@12897
   812
  -- {* Halmos, Naive Set Theory, page 35. *}
wenzelm@12897
   813
  by blast
wenzelm@12897
   814
wenzelm@12897
   815
lemma Un_INT_distrib: "B \<union> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. B \<union> A i)"
wenzelm@12897
   816
  by blast
wenzelm@12897
   817
wenzelm@12897
   818
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
   819
  by blast
wenzelm@12897
   820
wenzelm@12897
   821
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
   822
  by blast
wenzelm@12897
   823
wenzelm@12897
   824
haftmann@32139
   825
subsection {* Complement *}
haftmann@32135
   826
haftmann@43817
   827
lemma Compl_UN [simp]: "- (\<Union>x\<in>A. B x) = (\<Inter>x\<in>A. -B x)"
wenzelm@12897
   828
  by blast
wenzelm@12897
   829
haftmann@43817
   830
lemma Compl_INT [simp]: "- (\<Inter>x\<in>A. B x) = (\<Union>x\<in>A. -B x)"
wenzelm@12897
   831
  by blast
wenzelm@12897
   832
wenzelm@12897
   833
haftmann@32139
   834
subsection {* Miniscoping and maxiscoping *}
wenzelm@12897
   835
paulson@13860
   836
text {* \medskip Miniscoping: pushing in quantifiers and big Unions
paulson@13860
   837
           and Intersections. *}
wenzelm@12897
   838
wenzelm@12897
   839
lemma UN_simps [simp]:
haftmann@43817
   840
  "\<And>a B C. (\<Union>x\<in>C. insert a (B x)) = (if C={} then {} else insert a (\<Union>x\<in>C. B x))"
haftmann@43852
   841
  "\<And>A B C. (\<Union>x\<in>C. A x \<union>  B) = ((if C={} then {} else (\<Union>x\<in>C. A x) \<union> B))"
haftmann@43852
   842
  "\<And>A B C. (\<Union>x\<in>C. A \<union> B x) = ((if C={} then {} else A \<union> (\<Union>x\<in>C. B x)))"
haftmann@43852
   843
  "\<And>A B C. (\<Union>x\<in>C. A x \<inter> B) = ((\<Union>x\<in>C. A x) \<inter>B)"
haftmann@43852
   844
  "\<And>A B C. (\<Union>x\<in>C. A \<inter> B x) = (A \<inter>(\<Union>x\<in>C. B x))"
haftmann@43852
   845
  "\<And>A B C. (\<Union>x\<in>C. A x - B) = ((\<Union>x\<in>C. A x) - B)"
haftmann@43852
   846
  "\<And>A B C. (\<Union>x\<in>C. A - B x) = (A - (\<Inter>x\<in>C. B x))"
haftmann@43852
   847
  "\<And>A B. (\<Union>x\<in>\<Union>A. B x) = (\<Union>y\<in>A. \<Union>x\<in>y. B x)"
haftmann@43852
   848
  "\<And>A B C. (\<Union>z\<in>UNION A B. C z) = (\<Union>x\<in>A. \<Union>z\<in>B x. C z)"
haftmann@43831
   849
  "\<And>A B f. (\<Union>x\<in>f`A. B x) = (\<Union>a\<in>A. B (f a))"
wenzelm@12897
   850
  by auto
wenzelm@12897
   851
wenzelm@12897
   852
lemma INT_simps [simp]:
haftmann@43831
   853
  "\<And>A B C. (\<Inter>x\<in>C. A x \<inter> B) = (if C={} then UNIV else (\<Inter>x\<in>C. A x) \<inter>B)"
haftmann@43831
   854
  "\<And>A B C. (\<Inter>x\<in>C. A \<inter> B x) = (if C={} then UNIV else A \<inter>(\<Inter>x\<in>C. B x))"
haftmann@43852
   855
  "\<And>A B C. (\<Inter>x\<in>C. A x - B) = (if C={} then UNIV else (\<Inter>x\<in>C. A x) - B)"
haftmann@43852
   856
  "\<And>A B C. (\<Inter>x\<in>C. A - B x) = (if C={} then UNIV else A - (\<Union>x\<in>C. B x))"
haftmann@43817
   857
  "\<And>a B C. (\<Inter>x\<in>C. insert a (B x)) = insert a (\<Inter>x\<in>C. B x)"
haftmann@43852
   858
  "\<And>A B C. (\<Inter>x\<in>C. A x \<union> B) = ((\<Inter>x\<in>C. A x) \<union> B)"
haftmann@43852
   859
  "\<And>A B C. (\<Inter>x\<in>C. A \<union> B x) = (A \<union> (\<Inter>x\<in>C. B x))"
haftmann@43852
   860
  "\<And>A B. (\<Inter>x\<in>\<Union>A. B x) = (\<Inter>y\<in>A. \<Inter>x\<in>y. B x)"
haftmann@43852
   861
  "\<And>A B C. (\<Inter>z\<in>UNION A B. C z) = (\<Inter>x\<in>A. \<Inter>z\<in>B x. C z)"
haftmann@43852
   862
  "\<And>A B f. (\<Inter>x\<in>f`A. B x) = (\<Inter>a\<in>A. B (f a))"
wenzelm@12897
   863
  by auto
wenzelm@12897
   864
blanchet@35828
   865
lemma ball_simps [simp,no_atp]:
haftmann@43852
   866
  "\<And>A P Q. (\<forall>x\<in>A. P x \<or> Q) \<longleftrightarrow> ((\<forall>x\<in>A. P x) \<or> Q)"
haftmann@43852
   867
  "\<And>A P Q. (\<forall>x\<in>A. P \<or> Q x) \<longleftrightarrow> (P \<or> (\<forall>x\<in>A. Q x))"
haftmann@43852
   868
  "\<And>A P Q. (\<forall>x\<in>A. P \<longrightarrow> Q x) \<longleftrightarrow> (P \<longrightarrow> (\<forall>x\<in>A. Q x))"
haftmann@43852
   869
  "\<And>A P Q. (\<forall>x\<in>A. P x \<longrightarrow> Q) \<longleftrightarrow> ((\<exists>x\<in>A. P x) \<longrightarrow> Q)"
haftmann@43852
   870
  "\<And>P. (\<forall>x\<in>{}. P x) \<longleftrightarrow> True"
haftmann@43852
   871
  "\<And>P. (\<forall>x\<in>UNIV. P x) \<longleftrightarrow> (\<forall>x. P x)"
haftmann@43852
   872
  "\<And>a B P. (\<forall>x\<in>insert a B. P x) \<longleftrightarrow> (P a \<and> (\<forall>x\<in>B. P x))"
haftmann@43852
   873
  "\<And>A P. (\<forall>x\<in>\<Union>A. P x) \<longleftrightarrow> (\<forall>y\<in>A. \<forall>x\<in>y. P x)"
haftmann@43852
   874
  "\<And>A B P. (\<forall>x\<in> UNION A B. P x) = (\<forall>a\<in>A. \<forall>x\<in> B a. P x)"
haftmann@43852
   875
  "\<And>P Q. (\<forall>x\<in>Collect Q. P x) \<longleftrightarrow> (\<forall>x. Q x \<longrightarrow> P x)"
haftmann@43852
   876
  "\<And>A P f. (\<forall>x\<in>f`A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P (f x))"
haftmann@43852
   877
  "\<And>A P. (\<not> (\<forall>x\<in>A. P x)) \<longleftrightarrow> (\<exists>x\<in>A. \<not> P x)"
wenzelm@12897
   878
  by auto
wenzelm@12897
   879
blanchet@35828
   880
lemma bex_simps [simp,no_atp]:
haftmann@43852
   881
  "\<And>A P Q. (\<exists>x\<in>A. P x \<and> Q) \<longleftrightarrow> ((\<exists>x\<in>A. P x) \<and> Q)"
haftmann@43852
   882
  "\<And>A P Q. (\<exists>x\<in>A. P \<and> Q x) \<longleftrightarrow> (P \<and> (\<exists>x\<in>A. Q x))"
haftmann@43852
   883
  "\<And>P. (\<exists>x\<in>{}. P x) \<longleftrightarrow> False"
haftmann@43852
   884
  "\<And>P. (\<exists>x\<in>UNIV. P x) \<longleftrightarrow> (\<exists>x. P x)"
haftmann@43852
   885
  "\<And>a B P. (\<exists>x\<in>insert a B. P x) \<longleftrightarrow> (P a | (\<exists>x\<in>B. P x))"
haftmann@43852
   886
  "\<And>A P. (\<exists>x\<in>\<Union>A. P x) \<longleftrightarrow> (\<exists>y\<in>A. \<exists>x\<in>y. P x)"
haftmann@43852
   887
  "\<And>A B P. (\<exists>x\<in>UNION A B. P x) \<longleftrightarrow> (\<exists>a\<in>A. \<exists>x\<in>B a. P x)"
haftmann@43852
   888
  "\<And>P Q. (\<exists>x\<in>Collect Q. P x) \<longleftrightarrow> (\<exists>x. Q x \<and> P x)"
haftmann@43852
   889
  "\<And>A P f. (\<exists>x\<in>f`A. P x) \<longleftrightarrow> (\<exists>x\<in>A. P (f x))"
haftmann@43852
   890
  "\<And>A P. (\<not>(\<exists>x\<in>A. P x)) \<longleftrightarrow> (\<forall>x\<in>A. \<not> P x)"
wenzelm@12897
   891
  by auto
wenzelm@12897
   892
paulson@13860
   893
text {* \medskip Maxiscoping: pulling out big Unions and Intersections. *}
paulson@13860
   894
paulson@13860
   895
lemma UN_extend_simps:
haftmann@43817
   896
  "\<And>a B C. insert a (\<Union>x\<in>C. B x) = (if C={} then {a} else (\<Union>x\<in>C. insert a (B x)))"
haftmann@43852
   897
  "\<And>A B C. (\<Union>x\<in>C. A x) \<union>  B  = (if C={} then B else (\<Union>x\<in>C. A x \<union>  B))"
haftmann@43852
   898
  "\<And>A B C. A \<union> (\<Union>x\<in>C. B x) = (if C={} then A else (\<Union>x\<in>C. A \<union> B x))"
haftmann@43852
   899
  "\<And>A B C. ((\<Union>x\<in>C. A x) \<inter> B) = (\<Union>x\<in>C. A x \<inter> B)"
haftmann@43852
   900
  "\<And>A B C. (A \<inter> (\<Union>x\<in>C. B x)) = (\<Union>x\<in>C. A \<inter> B x)"
haftmann@43817
   901
  "\<And>A B C. ((\<Union>x\<in>C. A x) - B) = (\<Union>x\<in>C. A x - B)"
haftmann@43817
   902
  "\<And>A B C. (A - (\<Inter>x\<in>C. B x)) = (\<Union>x\<in>C. A - B x)"
haftmann@43852
   903
  "\<And>A B. (\<Union>y\<in>A. \<Union>x\<in>y. B x) = (\<Union>x\<in>\<Union>A. B x)"
haftmann@43852
   904
  "\<And>A B C. (\<Union>x\<in>A. \<Union>z\<in>B x. C z) = (\<Union>z\<in>UNION A B. C z)"
haftmann@43831
   905
  "\<And>A B f. (\<Union>a\<in>A. B (f a)) = (\<Union>x\<in>f`A. B x)"
paulson@13860
   906
  by auto
paulson@13860
   907
paulson@13860
   908
lemma INT_extend_simps:
haftmann@43852
   909
  "\<And>A B C. (\<Inter>x\<in>C. A x) \<inter> B = (if C={} then B else (\<Inter>x\<in>C. A x \<inter> B))"
haftmann@43852
   910
  "\<And>A B C. A \<inter> (\<Inter>x\<in>C. B x) = (if C={} then A else (\<Inter>x\<in>C. A \<inter> B x))"
haftmann@43852
   911
  "\<And>A B C. (\<Inter>x\<in>C. A x) - B = (if C={} then UNIV - B else (\<Inter>x\<in>C. A x - B))"
haftmann@43852
   912
  "\<And>A B C. A - (\<Union>x\<in>C. B x) = (if C={} then A else (\<Inter>x\<in>C. A - B x))"
haftmann@43817
   913
  "\<And>a B C. insert a (\<Inter>x\<in>C. B x) = (\<Inter>x\<in>C. insert a (B x))"
haftmann@43852
   914
  "\<And>A B C. ((\<Inter>x\<in>C. A x) \<union> B) = (\<Inter>x\<in>C. A x \<union> B)"
haftmann@43852
   915
  "\<And>A B C. A \<union> (\<Inter>x\<in>C. B x) = (\<Inter>x\<in>C. A \<union> B x)"
haftmann@43852
   916
  "\<And>A B. (\<Inter>y\<in>A. \<Inter>x\<in>y. B x) = (\<Inter>x\<in>\<Union>A. B x)"
haftmann@43852
   917
  "\<And>A B C. (\<Inter>x\<in>A. \<Inter>z\<in>B x. C z) = (\<Inter>z\<in>UNION A B. C z)"
haftmann@43852
   918
  "\<And>A B f. (\<Inter>a\<in>A. B (f a)) = (\<Inter>x\<in>f`A. B x)"
paulson@13860
   919
  by auto
paulson@13860
   920
paulson@13860
   921
haftmann@32135
   922
no_notation
haftmann@32135
   923
  less_eq  (infix "\<sqsubseteq>" 50) and
haftmann@32135
   924
  less (infix "\<sqsubset>" 50) and
haftmann@41082
   925
  bot ("\<bottom>") and
haftmann@41082
   926
  top ("\<top>") and
haftmann@32135
   927
  inf  (infixl "\<sqinter>" 70) and
haftmann@32135
   928
  sup  (infixl "\<squnion>" 65) and
haftmann@32135
   929
  Inf  ("\<Sqinter>_" [900] 900) and
haftmann@41082
   930
  Sup  ("\<Squnion>_" [900] 900)
haftmann@32135
   931
haftmann@41080
   932
no_syntax (xsymbols)
haftmann@41082
   933
  "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Sqinter>_./ _)" [0, 10] 10)
haftmann@41082
   934
  "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41080
   935
  "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
haftmann@41080
   936
  "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41080
   937
haftmann@30596
   938
lemmas mem_simps =
haftmann@30596
   939
  insert_iff empty_iff Un_iff Int_iff Compl_iff Diff_iff
haftmann@30596
   940
  mem_Collect_eq UN_iff Union_iff INT_iff Inter_iff
haftmann@30596
   941
  -- {* Each of these has ALREADY been added @{text "[simp]"} above. *}
wenzelm@21669
   942
wenzelm@11979
   943
end