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