src/HOL/Complete_Lattices.thy
author huffman
Fri Mar 30 12:32:35 2012 +0200 (2012-03-30)
changeset 47220 52426c62b5d0
parent 46884 154dc6ec0041
child 49905 a81f95693c68
permissions -rw-r--r--
replace lemmas eval_nat_numeral with a simpler reformulation
haftmann@44103
     1
 (*  Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel; Florian Haftmann, TU Muenchen *)
wenzelm@11979
     2
haftmann@44104
     3
header {* Complete lattices *}
haftmann@32077
     4
haftmann@44860
     5
theory Complete_Lattices
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@46691
    11
  less (infix "\<sqsubset>" 50)
haftmann@32077
    12
haftmann@32139
    13
haftmann@32879
    14
subsection {* Syntactic infimum and supremum operations *}
haftmann@32879
    15
haftmann@32879
    16
class Inf =
haftmann@32879
    17
  fixes Inf :: "'a set \<Rightarrow> 'a" ("\<Sqinter>_" [900] 900)
haftmann@32879
    18
haftmann@32879
    19
class Sup =
haftmann@32879
    20
  fixes Sup :: "'a set \<Rightarrow> 'a" ("\<Squnion>_" [900] 900)
haftmann@32879
    21
haftmann@46691
    22
haftmann@32139
    23
subsection {* Abstract complete lattices *}
haftmann@32139
    24
haftmann@34007
    25
class complete_lattice = bounded_lattice + Inf + Sup +
haftmann@32077
    26
  assumes Inf_lower: "x \<in> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> x"
haftmann@32077
    27
     and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A"
haftmann@32077
    28
  assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A"
haftmann@32077
    29
     and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z"
haftmann@32077
    30
begin
haftmann@32077
    31
haftmann@32678
    32
lemma dual_complete_lattice:
krauss@44845
    33
  "class.complete_lattice Sup Inf sup (op \<ge>) (op >) inf \<top> \<bottom>"
haftmann@36635
    34
  by (auto intro!: class.complete_lattice.intro dual_bounded_lattice)
haftmann@34007
    35
    (unfold_locales, (fact bot_least top_greatest
haftmann@34007
    36
        Sup_upper Sup_least Inf_lower Inf_greatest)+)
haftmann@32678
    37
haftmann@44040
    38
definition INFI :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
haftmann@44040
    39
  INF_def: "INFI A f = \<Sqinter>(f ` A)"
haftmann@44040
    40
haftmann@44040
    41
definition SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
haftmann@44040
    42
  SUP_def: "SUPR A f = \<Squnion>(f ` A)"
haftmann@44040
    43
haftmann@44040
    44
text {*
haftmann@44040
    45
  Note: must use names @{const INFI} and @{const SUPR} here instead of
haftmann@44040
    46
  @{text INF} and @{text SUP} to allow the following syntax coexist
haftmann@44040
    47
  with the plain constant names.
haftmann@44040
    48
*}
haftmann@44040
    49
haftmann@44040
    50
end
haftmann@44040
    51
haftmann@44040
    52
syntax
haftmann@44040
    53
  "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3INF _./ _)" [0, 10] 10)
haftmann@44040
    54
  "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3INF _:_./ _)" [0, 0, 10] 10)
haftmann@44040
    55
  "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3SUP _./ _)" [0, 10] 10)
haftmann@44040
    56
  "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3SUP _:_./ _)" [0, 0, 10] 10)
haftmann@44040
    57
haftmann@44040
    58
syntax (xsymbols)
haftmann@44040
    59
  "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Sqinter>_./ _)" [0, 10] 10)
haftmann@44040
    60
  "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@44040
    61
  "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
haftmann@44040
    62
  "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@44040
    63
haftmann@44040
    64
translations
haftmann@44040
    65
  "INF x y. B"   == "INF x. INF y. B"
haftmann@44040
    66
  "INF x. B"     == "CONST INFI CONST UNIV (%x. B)"
haftmann@44040
    67
  "INF x. B"     == "INF x:CONST UNIV. B"
haftmann@44040
    68
  "INF x:A. B"   == "CONST INFI A (%x. B)"
haftmann@44040
    69
  "SUP x y. B"   == "SUP x. SUP y. B"
haftmann@44040
    70
  "SUP x. B"     == "CONST SUPR CONST UNIV (%x. B)"
haftmann@44040
    71
  "SUP x. B"     == "SUP x:CONST UNIV. B"
haftmann@44040
    72
  "SUP x:A. B"   == "CONST SUPR A (%x. B)"
haftmann@44040
    73
haftmann@44040
    74
print_translation {*
haftmann@44040
    75
  [Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax INFI} @{syntax_const "_INF"},
haftmann@44040
    76
    Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax SUPR} @{syntax_const "_SUP"}]
haftmann@44040
    77
*} -- {* to avoid eta-contraction of body *}
haftmann@44040
    78
haftmann@44040
    79
context complete_lattice
haftmann@44040
    80
begin
haftmann@32077
    81
haftmann@44040
    82
lemma INF_foundation_dual [no_atp]:
haftmann@44040
    83
  "complete_lattice.SUPR Inf = INFI"
huffman@44921
    84
  by (simp add: fun_eq_iff INF_def
huffman@44921
    85
    complete_lattice.SUP_def [OF dual_complete_lattice])
haftmann@44040
    86
haftmann@44040
    87
lemma SUP_foundation_dual [no_atp]:
haftmann@44040
    88
  "complete_lattice.INFI Sup = SUPR"
huffman@44921
    89
  by (simp add: fun_eq_iff SUP_def
huffman@44921
    90
    complete_lattice.INF_def [OF dual_complete_lattice])
haftmann@44040
    91
haftmann@44103
    92
lemma INF_lower: "i \<in> A \<Longrightarrow> (\<Sqinter>i\<in>A. f i) \<sqsubseteq> f i"
haftmann@44040
    93
  by (auto simp add: INF_def intro: Inf_lower)
haftmann@44040
    94
haftmann@44103
    95
lemma INF_greatest: "(\<And>i. i \<in> A \<Longrightarrow> u \<sqsubseteq> f i) \<Longrightarrow> u \<sqsubseteq> (\<Sqinter>i\<in>A. f i)"
haftmann@44103
    96
  by (auto simp add: INF_def intro: Inf_greatest)
haftmann@44103
    97
haftmann@44103
    98
lemma SUP_upper: "i \<in> A \<Longrightarrow> f i \<sqsubseteq> (\<Squnion>i\<in>A. f i)"
haftmann@44040
    99
  by (auto simp add: SUP_def intro: Sup_upper)
haftmann@44040
   100
haftmann@44103
   101
lemma SUP_least: "(\<And>i. i \<in> A \<Longrightarrow> f i \<sqsubseteq> u) \<Longrightarrow> (\<Squnion>i\<in>A. f i) \<sqsubseteq> u"
haftmann@44040
   102
  by (auto simp add: SUP_def intro: Sup_least)
haftmann@44040
   103
haftmann@44040
   104
lemma Inf_lower2: "u \<in> A \<Longrightarrow> u \<sqsubseteq> v \<Longrightarrow> \<Sqinter>A \<sqsubseteq> v"
haftmann@44040
   105
  using Inf_lower [of u A] by auto
haftmann@44040
   106
haftmann@44103
   107
lemma INF_lower2: "i \<in> A \<Longrightarrow> f i \<sqsubseteq> u \<Longrightarrow> (\<Sqinter>i\<in>A. f i) \<sqsubseteq> u"
haftmann@44103
   108
  using INF_lower [of i A f] by auto
haftmann@44040
   109
haftmann@44040
   110
lemma Sup_upper2: "u \<in> A \<Longrightarrow> v \<sqsubseteq> u \<Longrightarrow> v \<sqsubseteq> \<Squnion>A"
haftmann@44040
   111
  using Sup_upper [of u A] by auto
haftmann@44040
   112
haftmann@44103
   113
lemma SUP_upper2: "i \<in> A \<Longrightarrow> u \<sqsubseteq> f i \<Longrightarrow> u \<sqsubseteq> (\<Squnion>i\<in>A. f i)"
haftmann@44103
   114
  using SUP_upper [of i A f] by auto
haftmann@44040
   115
noschinl@44918
   116
lemma le_Inf_iff: "b \<sqsubseteq> \<Sqinter>A \<longleftrightarrow> (\<forall>a\<in>A. b \<sqsubseteq> a)"
haftmann@44040
   117
  by (auto intro: Inf_greatest dest: Inf_lower)
haftmann@44040
   118
noschinl@44918
   119
lemma le_INF_iff: "u \<sqsubseteq> (\<Sqinter>i\<in>A. f i) \<longleftrightarrow> (\<forall>i\<in>A. u \<sqsubseteq> f i)"
haftmann@44040
   120
  by (auto simp add: INF_def le_Inf_iff)
haftmann@44040
   121
noschinl@44918
   122
lemma Sup_le_iff: "\<Squnion>A \<sqsubseteq> b \<longleftrightarrow> (\<forall>a\<in>A. a \<sqsubseteq> b)"
haftmann@44040
   123
  by (auto intro: Sup_least dest: Sup_upper)
haftmann@44040
   124
noschinl@44918
   125
lemma SUP_le_iff: "(\<Squnion>i\<in>A. f i) \<sqsubseteq> u \<longleftrightarrow> (\<forall>i\<in>A. f i \<sqsubseteq> u)"
haftmann@44040
   126
  by (auto simp add: SUP_def Sup_le_iff)
haftmann@32077
   127
haftmann@41080
   128
lemma Inf_empty [simp]:
haftmann@34007
   129
  "\<Sqinter>{} = \<top>"
haftmann@34007
   130
  by (auto intro: antisym Inf_greatest)
haftmann@32077
   131
huffman@44067
   132
lemma INF_empty [simp]: "(\<Sqinter>x\<in>{}. f x) = \<top>"
haftmann@44040
   133
  by (simp add: INF_def)
haftmann@44040
   134
haftmann@41080
   135
lemma Sup_empty [simp]:
haftmann@34007
   136
  "\<Squnion>{} = \<bottom>"
haftmann@34007
   137
  by (auto intro: antisym Sup_least)
haftmann@32077
   138
huffman@44067
   139
lemma SUP_empty [simp]: "(\<Squnion>x\<in>{}. f x) = \<bottom>"
haftmann@44040
   140
  by (simp add: SUP_def)
haftmann@44040
   141
haftmann@41080
   142
lemma Inf_UNIV [simp]:
haftmann@41080
   143
  "\<Sqinter>UNIV = \<bottom>"
haftmann@44040
   144
  by (auto intro!: antisym Inf_lower)
haftmann@41080
   145
haftmann@41080
   146
lemma Sup_UNIV [simp]:
haftmann@41080
   147
  "\<Squnion>UNIV = \<top>"
haftmann@44040
   148
  by (auto intro!: antisym Sup_upper)
haftmann@41080
   149
noschinl@44918
   150
lemma Inf_insert [simp]: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A"
haftmann@32077
   151
  by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower)
haftmann@32077
   152
haftmann@44040
   153
lemma INF_insert: "(\<Sqinter>x\<in>insert a A. f x) = f a \<sqinter> INFI A f"
noschinl@44919
   154
  by (simp add: INF_def)
haftmann@44040
   155
noschinl@44918
   156
lemma Sup_insert [simp]: "\<Squnion>insert a A = a \<squnion> \<Squnion>A"
haftmann@32077
   157
  by (auto intro: le_supI le_supI1 le_supI2 antisym Sup_least Sup_upper)
haftmann@32077
   158
haftmann@44040
   159
lemma SUP_insert: "(\<Squnion>x\<in>insert a A. f x) = f a \<squnion> SUPR A f"
noschinl@44919
   160
  by (simp add: SUP_def)
haftmann@44040
   161
noschinl@44918
   162
lemma INF_image [simp]: "(\<Sqinter>x\<in>f`A. g x) = (\<Sqinter>x\<in>A. g (f x))"
huffman@44068
   163
  by (simp add: INF_def image_image)
huffman@44068
   164
noschinl@44918
   165
lemma SUP_image [simp]: "(\<Squnion>x\<in>f`A. g x) = (\<Squnion>x\<in>A. g (f x))"
huffman@44068
   166
  by (simp add: SUP_def image_image)
huffman@44068
   167
haftmann@44040
   168
lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<sqsubseteq> a}"
haftmann@44040
   169
  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
haftmann@44040
   170
haftmann@44040
   171
lemma Sup_Inf:  "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<sqsubseteq> b}"
haftmann@44040
   172
  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
haftmann@44040
   173
haftmann@43899
   174
lemma Inf_superset_mono: "B \<subseteq> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> \<Sqinter>B"
haftmann@43899
   175
  by (auto intro: Inf_greatest Inf_lower)
haftmann@43899
   176
haftmann@43899
   177
lemma Sup_subset_mono: "A \<subseteq> B \<Longrightarrow> \<Squnion>A \<sqsubseteq> \<Squnion>B"
haftmann@43899
   178
  by (auto intro: Sup_least Sup_upper)
haftmann@43899
   179
haftmann@44041
   180
lemma INF_cong:
haftmann@44041
   181
  "A = B \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> C x = D x) \<Longrightarrow> (\<Sqinter>x\<in>A. C x) = (\<Sqinter>x\<in>B. D x)"
haftmann@44041
   182
  by (simp add: INF_def image_def)
haftmann@44041
   183
haftmann@44041
   184
lemma SUP_cong:
haftmann@44041
   185
  "A = B \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> C x = D x) \<Longrightarrow> (\<Squnion>x\<in>A. C x) = (\<Squnion>x\<in>B. D x)"
haftmann@44041
   186
  by (simp add: SUP_def image_def)
haftmann@44041
   187
hoelzl@38705
   188
lemma Inf_mono:
hoelzl@41971
   189
  assumes "\<And>b. b \<in> B \<Longrightarrow> \<exists>a\<in>A. a \<sqsubseteq> b"
haftmann@43741
   190
  shows "\<Sqinter>A \<sqsubseteq> \<Sqinter>B"
hoelzl@38705
   191
proof (rule Inf_greatest)
hoelzl@38705
   192
  fix b assume "b \<in> B"
hoelzl@41971
   193
  with assms obtain a where "a \<in> A" and "a \<sqsubseteq> b" by blast
haftmann@43741
   194
  from `a \<in> A` have "\<Sqinter>A \<sqsubseteq> a" by (rule Inf_lower)
haftmann@43741
   195
  with `a \<sqsubseteq> b` show "\<Sqinter>A \<sqsubseteq> b" by auto
hoelzl@38705
   196
qed
hoelzl@38705
   197
haftmann@44041
   198
lemma INF_mono:
haftmann@44041
   199
  "(\<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)"
noschinl@44918
   200
  unfolding INF_def by (rule Inf_mono) fast
haftmann@44041
   201
haftmann@41082
   202
lemma Sup_mono:
hoelzl@41971
   203
  assumes "\<And>a. a \<in> A \<Longrightarrow> \<exists>b\<in>B. a \<sqsubseteq> b"
haftmann@43741
   204
  shows "\<Squnion>A \<sqsubseteq> \<Squnion>B"
haftmann@41082
   205
proof (rule Sup_least)
haftmann@41082
   206
  fix a assume "a \<in> A"
hoelzl@41971
   207
  with assms obtain b where "b \<in> B" and "a \<sqsubseteq> b" by blast
haftmann@43741
   208
  from `b \<in> B` have "b \<sqsubseteq> \<Squnion>B" by (rule Sup_upper)
haftmann@43741
   209
  with `a \<sqsubseteq> b` show "a \<sqsubseteq> \<Squnion>B" by auto
haftmann@41082
   210
qed
haftmann@32077
   211
haftmann@44041
   212
lemma SUP_mono:
haftmann@44041
   213
  "(\<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)"
noschinl@44918
   214
  unfolding SUP_def by (rule Sup_mono) fast
haftmann@44041
   215
haftmann@44041
   216
lemma INF_superset_mono:
haftmann@44041
   217
  "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> f x \<sqsubseteq> g x) \<Longrightarrow> (\<Sqinter>x\<in>A. f x) \<sqsubseteq> (\<Sqinter>x\<in>B. g x)"
haftmann@44041
   218
  -- {* The last inclusion is POSITIVE! *}
haftmann@44041
   219
  by (blast intro: INF_mono dest: subsetD)
haftmann@44041
   220
haftmann@44041
   221
lemma SUP_subset_mono:
haftmann@44041
   222
  "A \<subseteq> B \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<sqsubseteq> g x) \<Longrightarrow> (\<Squnion>x\<in>A. f x) \<sqsubseteq> (\<Squnion>x\<in>B. g x)"
haftmann@44041
   223
  by (blast intro: SUP_mono dest: subsetD)
haftmann@44041
   224
haftmann@43868
   225
lemma Inf_less_eq:
haftmann@43868
   226
  assumes "\<And>v. v \<in> A \<Longrightarrow> v \<sqsubseteq> u"
haftmann@43868
   227
    and "A \<noteq> {}"
haftmann@43868
   228
  shows "\<Sqinter>A \<sqsubseteq> u"
haftmann@43868
   229
proof -
haftmann@43868
   230
  from `A \<noteq> {}` obtain v where "v \<in> A" by blast
haftmann@43868
   231
  moreover with assms have "v \<sqsubseteq> u" by blast
haftmann@43868
   232
  ultimately show ?thesis by (rule Inf_lower2)
haftmann@43868
   233
qed
haftmann@43868
   234
haftmann@43868
   235
lemma less_eq_Sup:
haftmann@43868
   236
  assumes "\<And>v. v \<in> A \<Longrightarrow> u \<sqsubseteq> v"
haftmann@43868
   237
    and "A \<noteq> {}"
haftmann@43868
   238
  shows "u \<sqsubseteq> \<Squnion>A"
haftmann@43868
   239
proof -
haftmann@43868
   240
  from `A \<noteq> {}` obtain v where "v \<in> A" by blast
haftmann@43868
   241
  moreover with assms have "u \<sqsubseteq> v" by blast
haftmann@43868
   242
  ultimately show ?thesis by (rule Sup_upper2)
haftmann@43868
   243
qed
haftmann@43868
   244
haftmann@43899
   245
lemma less_eq_Inf_inter: "\<Sqinter>A \<squnion> \<Sqinter>B \<sqsubseteq> \<Sqinter>(A \<inter> B)"
haftmann@43868
   246
  by (auto intro: Inf_greatest Inf_lower)
haftmann@43868
   247
haftmann@43899
   248
lemma Sup_inter_less_eq: "\<Squnion>(A \<inter> B) \<sqsubseteq> \<Squnion>A \<sqinter> \<Squnion>B "
haftmann@43868
   249
  by (auto intro: Sup_least Sup_upper)
haftmann@43868
   250
haftmann@43868
   251
lemma Inf_union_distrib: "\<Sqinter>(A \<union> B) = \<Sqinter>A \<sqinter> \<Sqinter>B"
haftmann@43868
   252
  by (rule antisym) (auto intro: Inf_greatest Inf_lower le_infI1 le_infI2)
haftmann@43868
   253
haftmann@44041
   254
lemma INF_union:
haftmann@44041
   255
  "(\<Sqinter>i \<in> A \<union> B. M i) = (\<Sqinter>i \<in> A. M i) \<sqinter> (\<Sqinter>i\<in>B. M i)"
haftmann@44103
   256
  by (auto intro!: antisym INF_mono intro: le_infI1 le_infI2 INF_greatest INF_lower)
haftmann@44041
   257
haftmann@43868
   258
lemma Sup_union_distrib: "\<Squnion>(A \<union> B) = \<Squnion>A \<squnion> \<Squnion>B"
haftmann@43868
   259
  by (rule antisym) (auto intro: Sup_least Sup_upper le_supI1 le_supI2)
haftmann@43868
   260
haftmann@44041
   261
lemma SUP_union:
haftmann@44041
   262
  "(\<Squnion>i \<in> A \<union> B. M i) = (\<Squnion>i \<in> A. M i) \<squnion> (\<Squnion>i\<in>B. M i)"
haftmann@44103
   263
  by (auto intro!: antisym SUP_mono intro: le_supI1 le_supI2 SUP_least SUP_upper)
haftmann@44041
   264
haftmann@44041
   265
lemma INF_inf_distrib: "(\<Sqinter>a\<in>A. f a) \<sqinter> (\<Sqinter>a\<in>A. g a) = (\<Sqinter>a\<in>A. f a \<sqinter> g a)"
haftmann@44103
   266
  by (rule antisym) (rule INF_greatest, auto intro: le_infI1 le_infI2 INF_lower INF_mono)
haftmann@44041
   267
noschinl@44918
   268
lemma SUP_sup_distrib: "(\<Squnion>a\<in>A. f a) \<squnion> (\<Squnion>a\<in>A. g a) = (\<Squnion>a\<in>A. f a \<squnion> g a)" (is "?L = ?R")
noschinl@44918
   269
proof (rule antisym)
noschinl@44918
   270
  show "?L \<le> ?R" by (auto intro: le_supI1 le_supI2 SUP_upper SUP_mono)
noschinl@44918
   271
next
noschinl@44918
   272
  show "?R \<le> ?L" by (rule SUP_least) (auto intro: le_supI1 le_supI2 SUP_upper)
noschinl@44918
   273
qed
haftmann@44041
   274
noschinl@44918
   275
lemma Inf_top_conv [simp, no_atp]:
haftmann@43868
   276
  "\<Sqinter>A = \<top> \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
haftmann@43868
   277
  "\<top> = \<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
haftmann@43868
   278
proof -
haftmann@43868
   279
  show "\<Sqinter>A = \<top> \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
haftmann@43868
   280
  proof
haftmann@43868
   281
    assume "\<forall>x\<in>A. x = \<top>"
haftmann@43868
   282
    then have "A = {} \<or> A = {\<top>}" by auto
noschinl@44919
   283
    then show "\<Sqinter>A = \<top>" by auto
haftmann@43868
   284
  next
haftmann@43868
   285
    assume "\<Sqinter>A = \<top>"
haftmann@43868
   286
    show "\<forall>x\<in>A. x = \<top>"
haftmann@43868
   287
    proof (rule ccontr)
haftmann@43868
   288
      assume "\<not> (\<forall>x\<in>A. x = \<top>)"
haftmann@43868
   289
      then obtain x where "x \<in> A" and "x \<noteq> \<top>" by blast
haftmann@43868
   290
      then obtain B where "A = insert x B" by blast
noschinl@44919
   291
      with `\<Sqinter>A = \<top>` `x \<noteq> \<top>` show False by simp
haftmann@43868
   292
    qed
haftmann@43868
   293
  qed
haftmann@43868
   294
  then show "\<top> = \<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)" by auto
haftmann@43868
   295
qed
haftmann@43868
   296
noschinl@44918
   297
lemma INF_top_conv [simp]:
haftmann@44041
   298
 "(\<Sqinter>x\<in>A. B x) = \<top> \<longleftrightarrow> (\<forall>x\<in>A. B x = \<top>)"
haftmann@44041
   299
 "\<top> = (\<Sqinter>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = \<top>)"
noschinl@44919
   300
  by (auto simp add: INF_def)
haftmann@44041
   301
noschinl@44918
   302
lemma Sup_bot_conv [simp, no_atp]:
haftmann@43868
   303
  "\<Squnion>A = \<bottom> \<longleftrightarrow> (\<forall>x\<in>A. x = \<bottom>)" (is ?P)
haftmann@43868
   304
  "\<bottom> = \<Squnion>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<bottom>)" (is ?Q)
huffman@44920
   305
  using dual_complete_lattice
huffman@44920
   306
  by (rule complete_lattice.Inf_top_conv)+
haftmann@43868
   307
noschinl@44918
   308
lemma SUP_bot_conv [simp]:
haftmann@44041
   309
 "(\<Squnion>x\<in>A. B x) = \<bottom> \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
haftmann@44041
   310
 "\<bottom> = (\<Squnion>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
noschinl@44919
   311
  by (auto simp add: SUP_def)
haftmann@44041
   312
haftmann@43865
   313
lemma INF_const [simp]: "A \<noteq> {} \<Longrightarrow> (\<Sqinter>i\<in>A. f) = f"
haftmann@44103
   314
  by (auto intro: antisym INF_lower INF_greatest)
haftmann@32077
   315
haftmann@43870
   316
lemma SUP_const [simp]: "A \<noteq> {} \<Longrightarrow> (\<Squnion>i\<in>A. f) = f"
haftmann@44103
   317
  by (auto intro: antisym SUP_upper SUP_least)
haftmann@43870
   318
noschinl@44918
   319
lemma INF_top [simp]: "(\<Sqinter>x\<in>A. \<top>) = \<top>"
huffman@44921
   320
  by (cases "A = {}") simp_all
haftmann@43900
   321
noschinl@44918
   322
lemma SUP_bot [simp]: "(\<Squnion>x\<in>A. \<bottom>) = \<bottom>"
huffman@44921
   323
  by (cases "A = {}") simp_all
haftmann@43900
   324
haftmann@43865
   325
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)"
haftmann@44103
   326
  by (iprover intro: INF_lower INF_greatest order_trans antisym)
haftmann@43865
   327
haftmann@43870
   328
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@44103
   329
  by (iprover intro: SUP_upper SUP_least order_trans antisym)
haftmann@43870
   330
haftmann@43871
   331
lemma INF_absorb:
haftmann@43868
   332
  assumes "k \<in> I"
haftmann@43868
   333
  shows "A k \<sqinter> (\<Sqinter>i\<in>I. A i) = (\<Sqinter>i\<in>I. A i)"
haftmann@43868
   334
proof -
haftmann@43868
   335
  from assms obtain J where "I = insert k J" by blast
haftmann@43868
   336
  then show ?thesis by (simp add: INF_insert)
haftmann@43868
   337
qed
haftmann@43868
   338
haftmann@43871
   339
lemma SUP_absorb:
haftmann@43871
   340
  assumes "k \<in> I"
haftmann@43871
   341
  shows "A k \<squnion> (\<Squnion>i\<in>I. A i) = (\<Squnion>i\<in>I. A i)"
haftmann@43871
   342
proof -
haftmann@43871
   343
  from assms obtain J where "I = insert k J" by blast
haftmann@43871
   344
  then show ?thesis by (simp add: SUP_insert)
haftmann@43871
   345
qed
haftmann@43871
   346
haftmann@43871
   347
lemma INF_constant:
haftmann@43868
   348
  "(\<Sqinter>y\<in>A. c) = (if A = {} then \<top> else c)"
huffman@44921
   349
  by simp
haftmann@43868
   350
haftmann@43871
   351
lemma SUP_constant:
haftmann@43871
   352
  "(\<Squnion>y\<in>A. c) = (if A = {} then \<bottom> else c)"
huffman@44921
   353
  by simp
haftmann@43871
   354
haftmann@43943
   355
lemma less_INF_D:
haftmann@43943
   356
  assumes "y < (\<Sqinter>i\<in>A. f i)" "i \<in> A" shows "y < f i"
haftmann@43943
   357
proof -
haftmann@43943
   358
  note `y < (\<Sqinter>i\<in>A. f i)`
haftmann@43943
   359
  also have "(\<Sqinter>i\<in>A. f i) \<le> f i" using `i \<in> A`
haftmann@44103
   360
    by (rule INF_lower)
haftmann@43943
   361
  finally show "y < f i" .
haftmann@43943
   362
qed
haftmann@43943
   363
haftmann@43943
   364
lemma SUP_lessD:
haftmann@43943
   365
  assumes "(\<Squnion>i\<in>A. f i) < y" "i \<in> A" shows "f i < y"
haftmann@43943
   366
proof -
haftmann@43943
   367
  have "f i \<le> (\<Squnion>i\<in>A. f i)" using `i \<in> A`
haftmann@44103
   368
    by (rule SUP_upper)
haftmann@43943
   369
  also note `(\<Squnion>i\<in>A. f i) < y`
haftmann@43943
   370
  finally show "f i < y" .
haftmann@43943
   371
qed
haftmann@43943
   372
haftmann@43873
   373
lemma INF_UNIV_bool_expand:
haftmann@43868
   374
  "(\<Sqinter>b. A b) = A True \<sqinter> A False"
huffman@44921
   375
  by (simp add: UNIV_bool INF_insert inf_commute)
haftmann@43868
   376
haftmann@43873
   377
lemma SUP_UNIV_bool_expand:
haftmann@43871
   378
  "(\<Squnion>b. A b) = A True \<squnion> A False"
huffman@44921
   379
  by (simp add: UNIV_bool SUP_insert sup_commute)
haftmann@43871
   380
haftmann@32077
   381
end
haftmann@32077
   382
haftmann@44024
   383
class complete_distrib_lattice = complete_lattice +
haftmann@44039
   384
  assumes sup_Inf: "a \<squnion> \<Sqinter>B = (\<Sqinter>b\<in>B. a \<squnion> b)"
haftmann@44024
   385
  assumes inf_Sup: "a \<sqinter> \<Squnion>B = (\<Squnion>b\<in>B. a \<sqinter> b)"
haftmann@44024
   386
begin
haftmann@44024
   387
haftmann@44039
   388
lemma sup_INF:
haftmann@44039
   389
  "a \<squnion> (\<Sqinter>b\<in>B. f b) = (\<Sqinter>b\<in>B. a \<squnion> f b)"
haftmann@44039
   390
  by (simp add: INF_def sup_Inf image_image)
haftmann@44039
   391
haftmann@44039
   392
lemma inf_SUP:
haftmann@44039
   393
  "a \<sqinter> (\<Squnion>b\<in>B. f b) = (\<Squnion>b\<in>B. a \<sqinter> f b)"
haftmann@44039
   394
  by (simp add: SUP_def inf_Sup image_image)
haftmann@44039
   395
haftmann@44032
   396
lemma dual_complete_distrib_lattice:
krauss@44845
   397
  "class.complete_distrib_lattice Sup Inf sup (op \<ge>) (op >) inf \<top> \<bottom>"
haftmann@44024
   398
  apply (rule class.complete_distrib_lattice.intro)
haftmann@44024
   399
  apply (fact dual_complete_lattice)
haftmann@44024
   400
  apply (rule class.complete_distrib_lattice_axioms.intro)
haftmann@44032
   401
  apply (simp_all only: INF_foundation_dual SUP_foundation_dual inf_Sup sup_Inf)
haftmann@44032
   402
  done
haftmann@44024
   403
haftmann@44322
   404
subclass distrib_lattice proof
haftmann@44024
   405
  fix a b c
haftmann@44024
   406
  from sup_Inf have "a \<squnion> \<Sqinter>{b, c} = (\<Sqinter>d\<in>{b, c}. a \<squnion> d)" .
noschinl@44919
   407
  then show "a \<squnion> b \<sqinter> c = (a \<squnion> b) \<sqinter> (a \<squnion> c)" by (simp add: INF_def)
haftmann@44024
   408
qed
haftmann@44024
   409
haftmann@44039
   410
lemma Inf_sup:
haftmann@44039
   411
  "\<Sqinter>B \<squnion> a = (\<Sqinter>b\<in>B. b \<squnion> a)"
haftmann@44039
   412
  by (simp add: sup_Inf sup_commute)
haftmann@44039
   413
haftmann@44039
   414
lemma Sup_inf:
haftmann@44039
   415
  "\<Squnion>B \<sqinter> a = (\<Squnion>b\<in>B. b \<sqinter> a)"
haftmann@44039
   416
  by (simp add: inf_Sup inf_commute)
haftmann@44039
   417
haftmann@44039
   418
lemma INF_sup: 
haftmann@44039
   419
  "(\<Sqinter>b\<in>B. f b) \<squnion> a = (\<Sqinter>b\<in>B. f b \<squnion> a)"
haftmann@44039
   420
  by (simp add: sup_INF sup_commute)
haftmann@44039
   421
haftmann@44039
   422
lemma SUP_inf:
haftmann@44039
   423
  "(\<Squnion>b\<in>B. f b) \<sqinter> a = (\<Squnion>b\<in>B. f b \<sqinter> a)"
haftmann@44039
   424
  by (simp add: inf_SUP inf_commute)
haftmann@44039
   425
haftmann@44039
   426
lemma Inf_sup_eq_top_iff:
haftmann@44039
   427
  "(\<Sqinter>B \<squnion> a = \<top>) \<longleftrightarrow> (\<forall>b\<in>B. b \<squnion> a = \<top>)"
haftmann@44039
   428
  by (simp only: Inf_sup INF_top_conv)
haftmann@44039
   429
haftmann@44039
   430
lemma Sup_inf_eq_bot_iff:
haftmann@44039
   431
  "(\<Squnion>B \<sqinter> a = \<bottom>) \<longleftrightarrow> (\<forall>b\<in>B. b \<sqinter> a = \<bottom>)"
haftmann@44039
   432
  by (simp only: Sup_inf SUP_bot_conv)
haftmann@44039
   433
haftmann@44039
   434
lemma INF_sup_distrib2:
haftmann@44039
   435
  "(\<Sqinter>a\<in>A. f a) \<squnion> (\<Sqinter>b\<in>B. g b) = (\<Sqinter>a\<in>A. \<Sqinter>b\<in>B. f a \<squnion> g b)"
haftmann@44039
   436
  by (subst INF_commute) (simp add: sup_INF INF_sup)
haftmann@44039
   437
haftmann@44039
   438
lemma SUP_inf_distrib2:
haftmann@44039
   439
  "(\<Squnion>a\<in>A. f a) \<sqinter> (\<Squnion>b\<in>B. g b) = (\<Squnion>a\<in>A. \<Squnion>b\<in>B. f a \<sqinter> g b)"
haftmann@44039
   440
  by (subst SUP_commute) (simp add: inf_SUP SUP_inf)
haftmann@44039
   441
haftmann@44024
   442
end
haftmann@44024
   443
haftmann@44032
   444
class complete_boolean_algebra = boolean_algebra + complete_distrib_lattice
haftmann@43873
   445
begin
haftmann@43873
   446
haftmann@43943
   447
lemma dual_complete_boolean_algebra:
krauss@44845
   448
  "class.complete_boolean_algebra Sup Inf sup (op \<ge>) (op >) inf \<top> \<bottom> (\<lambda>x y. x \<squnion> - y) uminus"
haftmann@44032
   449
  by (rule class.complete_boolean_algebra.intro, rule dual_complete_distrib_lattice, rule dual_boolean_algebra)
haftmann@43943
   450
haftmann@43873
   451
lemma uminus_Inf:
haftmann@43873
   452
  "- (\<Sqinter>A) = \<Squnion>(uminus ` A)"
haftmann@43873
   453
proof (rule antisym)
haftmann@43873
   454
  show "- \<Sqinter>A \<le> \<Squnion>(uminus ` A)"
haftmann@43873
   455
    by (rule compl_le_swap2, rule Inf_greatest, rule compl_le_swap2, rule Sup_upper) simp
haftmann@43873
   456
  show "\<Squnion>(uminus ` A) \<le> - \<Sqinter>A"
haftmann@43873
   457
    by (rule Sup_least, rule compl_le_swap1, rule Inf_lower) auto
haftmann@43873
   458
qed
haftmann@43873
   459
haftmann@44041
   460
lemma uminus_INF: "- (\<Sqinter>x\<in>A. B x) = (\<Squnion>x\<in>A. - B x)"
haftmann@44041
   461
  by (simp add: INF_def SUP_def uminus_Inf image_image)
haftmann@44041
   462
haftmann@43873
   463
lemma uminus_Sup:
haftmann@43873
   464
  "- (\<Squnion>A) = \<Sqinter>(uminus ` A)"
haftmann@43873
   465
proof -
haftmann@43873
   466
  have "\<Squnion>A = - \<Sqinter>(uminus ` A)" by (simp add: image_image uminus_Inf)
haftmann@43873
   467
  then show ?thesis by simp
haftmann@43873
   468
qed
haftmann@43873
   469
  
haftmann@43873
   470
lemma uminus_SUP: "- (\<Squnion>x\<in>A. B x) = (\<Sqinter>x\<in>A. - B x)"
haftmann@43873
   471
  by (simp add: INF_def SUP_def uminus_Sup image_image)
haftmann@43873
   472
haftmann@43873
   473
end
haftmann@43873
   474
haftmann@43940
   475
class complete_linorder = linorder + complete_lattice
haftmann@43940
   476
begin
haftmann@43940
   477
haftmann@43943
   478
lemma dual_complete_linorder:
krauss@44845
   479
  "class.complete_linorder Sup Inf sup (op \<ge>) (op >) inf \<top> \<bottom>"
haftmann@43943
   480
  by (rule class.complete_linorder.intro, rule dual_complete_lattice, rule dual_linorder)
haftmann@43943
   481
noschinl@44918
   482
lemma Inf_less_iff:
haftmann@43940
   483
  "\<Sqinter>S \<sqsubset> a \<longleftrightarrow> (\<exists>x\<in>S. x \<sqsubset> a)"
haftmann@43940
   484
  unfolding not_le [symmetric] le_Inf_iff by auto
haftmann@43940
   485
noschinl@44918
   486
lemma INF_less_iff:
haftmann@44041
   487
  "(\<Sqinter>i\<in>A. f i) \<sqsubset> a \<longleftrightarrow> (\<exists>x\<in>A. f x \<sqsubset> a)"
haftmann@44041
   488
  unfolding INF_def Inf_less_iff by auto
haftmann@44041
   489
noschinl@44918
   490
lemma less_Sup_iff:
haftmann@43940
   491
  "a \<sqsubset> \<Squnion>S \<longleftrightarrow> (\<exists>x\<in>S. a \<sqsubset> x)"
haftmann@43940
   492
  unfolding not_le [symmetric] Sup_le_iff by auto
haftmann@43940
   493
noschinl@44918
   494
lemma less_SUP_iff:
haftmann@43940
   495
  "a \<sqsubset> (\<Squnion>i\<in>A. f i) \<longleftrightarrow> (\<exists>x\<in>A. a \<sqsubset> f x)"
haftmann@43940
   496
  unfolding SUP_def less_Sup_iff by auto
haftmann@43940
   497
noschinl@44918
   498
lemma Sup_eq_top_iff [simp]:
haftmann@43943
   499
  "\<Squnion>A = \<top> \<longleftrightarrow> (\<forall>x<\<top>. \<exists>i\<in>A. x < i)"
haftmann@43943
   500
proof
haftmann@43943
   501
  assume *: "\<Squnion>A = \<top>"
haftmann@43943
   502
  show "(\<forall>x<\<top>. \<exists>i\<in>A. x < i)" unfolding * [symmetric]
haftmann@43943
   503
  proof (intro allI impI)
haftmann@43943
   504
    fix x assume "x < \<Squnion>A" then show "\<exists>i\<in>A. x < i"
haftmann@43943
   505
      unfolding less_Sup_iff by auto
haftmann@43943
   506
  qed
haftmann@43943
   507
next
haftmann@43943
   508
  assume *: "\<forall>x<\<top>. \<exists>i\<in>A. x < i"
haftmann@43943
   509
  show "\<Squnion>A = \<top>"
haftmann@43943
   510
  proof (rule ccontr)
haftmann@43943
   511
    assume "\<Squnion>A \<noteq> \<top>"
haftmann@43943
   512
    with top_greatest [of "\<Squnion>A"]
haftmann@43943
   513
    have "\<Squnion>A < \<top>" unfolding le_less by auto
haftmann@43943
   514
    then have "\<Squnion>A < \<Squnion>A"
haftmann@43943
   515
      using * unfolding less_Sup_iff by auto
haftmann@43943
   516
    then show False by auto
haftmann@43943
   517
  qed
haftmann@43943
   518
qed
haftmann@43943
   519
noschinl@44918
   520
lemma SUP_eq_top_iff [simp]:
haftmann@44041
   521
  "(\<Squnion>i\<in>A. f i) = \<top> \<longleftrightarrow> (\<forall>x<\<top>. \<exists>i\<in>A. x < f i)"
noschinl@44919
   522
  unfolding SUP_def by auto
haftmann@44041
   523
noschinl@44918
   524
lemma Inf_eq_bot_iff [simp]:
haftmann@43943
   525
  "\<Sqinter>A = \<bottom> \<longleftrightarrow> (\<forall>x>\<bottom>. \<exists>i\<in>A. i < x)"
huffman@44920
   526
  using dual_complete_linorder
huffman@44920
   527
  by (rule complete_linorder.Sup_eq_top_iff)
haftmann@43943
   528
noschinl@44918
   529
lemma INF_eq_bot_iff [simp]:
haftmann@43967
   530
  "(\<Sqinter>i\<in>A. f i) = \<bottom> \<longleftrightarrow> (\<forall>x>\<bottom>. \<exists>i\<in>A. f i < x)"
noschinl@44919
   531
  unfolding INF_def by auto
haftmann@43967
   532
haftmann@43940
   533
end
haftmann@43940
   534
haftmann@43873
   535
haftmann@46631
   536
subsection {* Complete lattice on @{typ bool} *}
haftmann@32077
   537
haftmann@44024
   538
instantiation bool :: complete_lattice
haftmann@32077
   539
begin
haftmann@32077
   540
haftmann@32077
   541
definition
haftmann@46154
   542
  [simp, code]: "\<Sqinter>A \<longleftrightarrow> False \<notin> A"
haftmann@32077
   543
haftmann@32077
   544
definition
haftmann@46154
   545
  [simp, code]: "\<Squnion>A \<longleftrightarrow> True \<in> A"
haftmann@32077
   546
haftmann@32077
   547
instance proof
haftmann@44322
   548
qed (auto intro: bool_induct)
haftmann@32077
   549
haftmann@32077
   550
end
haftmann@32077
   551
haftmann@43873
   552
lemma INF_bool_eq [simp]:
haftmann@32120
   553
  "INFI = Ball"
haftmann@32120
   554
proof (rule ext)+
haftmann@32120
   555
  fix A :: "'a set"
haftmann@32120
   556
  fix P :: "'a \<Rightarrow> bool"
haftmann@43753
   557
  show "(\<Sqinter>x\<in>A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P x)"
haftmann@44322
   558
    by (auto simp add: INF_def)
haftmann@32120
   559
qed
haftmann@32120
   560
haftmann@43873
   561
lemma SUP_bool_eq [simp]:
haftmann@32120
   562
  "SUPR = Bex"
haftmann@32120
   563
proof (rule ext)+
haftmann@32120
   564
  fix A :: "'a set"
haftmann@32120
   565
  fix P :: "'a \<Rightarrow> bool"
haftmann@43753
   566
  show "(\<Squnion>x\<in>A. P x) \<longleftrightarrow> (\<exists>x\<in>A. P x)"
haftmann@44322
   567
    by (auto simp add: SUP_def)
haftmann@32120
   568
qed
haftmann@32120
   569
haftmann@44032
   570
instance bool :: complete_boolean_algebra proof
haftmann@44322
   571
qed (auto intro: bool_induct)
haftmann@44024
   572
haftmann@46631
   573
haftmann@46631
   574
subsection {* Complete lattice on @{typ "_ \<Rightarrow> _"} *}
haftmann@46631
   575
haftmann@32077
   576
instantiation "fun" :: (type, complete_lattice) complete_lattice
haftmann@32077
   577
begin
haftmann@32077
   578
haftmann@32077
   579
definition
haftmann@44024
   580
  "\<Sqinter>A = (\<lambda>x. \<Sqinter>f\<in>A. f x)"
haftmann@41080
   581
noschinl@46882
   582
lemma Inf_apply [simp, code]:
haftmann@44024
   583
  "(\<Sqinter>A) x = (\<Sqinter>f\<in>A. f x)"
haftmann@41080
   584
  by (simp add: Inf_fun_def)
haftmann@32077
   585
haftmann@32077
   586
definition
haftmann@44024
   587
  "\<Squnion>A = (\<lambda>x. \<Squnion>f\<in>A. f x)"
haftmann@41080
   588
noschinl@46882
   589
lemma Sup_apply [simp, code]:
haftmann@44024
   590
  "(\<Squnion>A) x = (\<Squnion>f\<in>A. f x)"
haftmann@41080
   591
  by (simp add: Sup_fun_def)
haftmann@32077
   592
haftmann@32077
   593
instance proof
noschinl@46884
   594
qed (auto simp add: le_fun_def intro: INF_lower INF_greatest SUP_upper SUP_least)
haftmann@32077
   595
haftmann@32077
   596
end
haftmann@32077
   597
noschinl@46882
   598
lemma INF_apply [simp]:
haftmann@41080
   599
  "(\<Sqinter>y\<in>A. f y) x = (\<Sqinter>y\<in>A. f y x)"
noschinl@46884
   600
  by (auto intro: arg_cong [of _ _ Inf] simp add: INF_def)
hoelzl@38705
   601
noschinl@46882
   602
lemma SUP_apply [simp]:
haftmann@41080
   603
  "(\<Squnion>y\<in>A. f y) x = (\<Squnion>y\<in>A. f y x)"
noschinl@46884
   604
  by (auto intro: arg_cong [of _ _ Sup] simp add: SUP_def)
haftmann@32077
   605
haftmann@44024
   606
instance "fun" :: (type, complete_distrib_lattice) complete_distrib_lattice proof
noschinl@46884
   607
qed (auto simp add: INF_def SUP_def inf_Sup sup_Inf image_image)
haftmann@44024
   608
haftmann@43873
   609
instance "fun" :: (type, complete_boolean_algebra) complete_boolean_algebra ..
haftmann@43873
   610
haftmann@46631
   611
haftmann@46631
   612
subsection {* Complete lattice on unary and binary predicates *}
haftmann@46631
   613
haftmann@46631
   614
lemma INF1_iff: "(\<Sqinter>x\<in>A. B x) b = (\<forall>x\<in>A. B x b)"
noschinl@46884
   615
  by simp
haftmann@46631
   616
haftmann@46631
   617
lemma INF2_iff: "(\<Sqinter>x\<in>A. B x) b c = (\<forall>x\<in>A. B x b c)"
noschinl@46884
   618
  by simp
haftmann@46631
   619
haftmann@46631
   620
lemma INF1_I: "(\<And>x. x \<in> A \<Longrightarrow> B x b) \<Longrightarrow> (\<Sqinter>x\<in>A. B x) b"
noschinl@46884
   621
  by auto
haftmann@46631
   622
haftmann@46631
   623
lemma INF2_I: "(\<And>x. x \<in> A \<Longrightarrow> B x b c) \<Longrightarrow> (\<Sqinter>x\<in>A. B x) b c"
noschinl@46884
   624
  by auto
haftmann@46631
   625
haftmann@46631
   626
lemma INF1_D: "(\<Sqinter>x\<in>A. B x) b \<Longrightarrow> a \<in> A \<Longrightarrow> B a b"
noschinl@46884
   627
  by auto
haftmann@46631
   628
haftmann@46631
   629
lemma INF2_D: "(\<Sqinter>x\<in>A. B x) b c \<Longrightarrow> a \<in> A \<Longrightarrow> B a b c"
noschinl@46884
   630
  by auto
haftmann@46631
   631
haftmann@46631
   632
lemma INF1_E: "(\<Sqinter>x\<in>A. B x) b \<Longrightarrow> (B a b \<Longrightarrow> R) \<Longrightarrow> (a \<notin> A \<Longrightarrow> R) \<Longrightarrow> R"
noschinl@46884
   633
  by auto
haftmann@46631
   634
haftmann@46631
   635
lemma INF2_E: "(\<Sqinter>x\<in>A. B x) b c \<Longrightarrow> (B a b c \<Longrightarrow> R) \<Longrightarrow> (a \<notin> A \<Longrightarrow> R) \<Longrightarrow> R"
noschinl@46884
   636
  by auto
haftmann@46631
   637
haftmann@46631
   638
lemma SUP1_iff: "(\<Squnion>x\<in>A. B x) b = (\<exists>x\<in>A. B x b)"
noschinl@46884
   639
  by simp
haftmann@46631
   640
haftmann@46631
   641
lemma SUP2_iff: "(\<Squnion>x\<in>A. B x) b c = (\<exists>x\<in>A. B x b c)"
noschinl@46884
   642
  by simp
haftmann@46631
   643
haftmann@46631
   644
lemma SUP1_I: "a \<in> A \<Longrightarrow> B a b \<Longrightarrow> (\<Squnion>x\<in>A. B x) b"
noschinl@46884
   645
  by auto
haftmann@46631
   646
haftmann@46631
   647
lemma SUP2_I: "a \<in> A \<Longrightarrow> B a b c \<Longrightarrow> (\<Squnion>x\<in>A. B x) b c"
noschinl@46884
   648
  by auto
haftmann@46631
   649
haftmann@46631
   650
lemma SUP1_E: "(\<Squnion>x\<in>A. B x) b \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> B x b \<Longrightarrow> R) \<Longrightarrow> R"
noschinl@46884
   651
  by auto
haftmann@46631
   652
haftmann@46631
   653
lemma SUP2_E: "(\<Squnion>x\<in>A. B x) b c \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> B x b c \<Longrightarrow> R) \<Longrightarrow> R"
noschinl@46884
   654
  by auto
haftmann@46631
   655
haftmann@46631
   656
haftmann@46631
   657
subsection {* Complete lattice on @{typ "_ set"} *}
haftmann@46631
   658
haftmann@45960
   659
instantiation "set" :: (type) complete_lattice
haftmann@45960
   660
begin
haftmann@45960
   661
haftmann@45960
   662
definition
haftmann@45960
   663
  "\<Sqinter>A = {x. \<Sqinter>((\<lambda>B. x \<in> B) ` A)}"
haftmann@45960
   664
haftmann@45960
   665
definition
haftmann@45960
   666
  "\<Squnion>A = {x. \<Squnion>((\<lambda>B. x \<in> B) ` A)}"
haftmann@45960
   667
haftmann@45960
   668
instance proof
haftmann@45960
   669
qed (auto simp add: less_eq_set_def Inf_set_def Sup_set_def Inf_bool_def Sup_bool_def le_fun_def)
haftmann@45960
   670
haftmann@45960
   671
end
haftmann@45960
   672
haftmann@45960
   673
instance "set" :: (type) complete_boolean_algebra
haftmann@45960
   674
proof
haftmann@45960
   675
qed (auto simp add: INF_def SUP_def Inf_set_def Sup_set_def image_def)
haftmann@45960
   676
  
haftmann@32077
   677
haftmann@46631
   678
subsubsection {* Inter *}
haftmann@41082
   679
haftmann@41082
   680
abbreviation Inter :: "'a set set \<Rightarrow> 'a set" where
haftmann@41082
   681
  "Inter S \<equiv> \<Sqinter>S"
haftmann@41082
   682
  
haftmann@41082
   683
notation (xsymbols)
haftmann@41082
   684
  Inter  ("\<Inter>_" [90] 90)
haftmann@41082
   685
haftmann@41082
   686
lemma Inter_eq:
haftmann@41082
   687
  "\<Inter>A = {x. \<forall>B \<in> A. x \<in> B}"
haftmann@41082
   688
proof (rule set_eqI)
haftmann@41082
   689
  fix x
haftmann@41082
   690
  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
   691
    by auto
haftmann@41082
   692
  then show "x \<in> \<Inter>A \<longleftrightarrow> x \<in> {x. \<forall>B \<in> A. x \<in> B}"
haftmann@45960
   693
    by (simp add: Inf_set_def image_def)
haftmann@41082
   694
qed
haftmann@41082
   695
haftmann@43741
   696
lemma Inter_iff [simp,no_atp]: "A \<in> \<Inter>C \<longleftrightarrow> (\<forall>X\<in>C. A \<in> X)"
haftmann@41082
   697
  by (unfold Inter_eq) blast
haftmann@41082
   698
haftmann@43741
   699
lemma InterI [intro!]: "(\<And>X. X \<in> C \<Longrightarrow> A \<in> X) \<Longrightarrow> A \<in> \<Inter>C"
haftmann@41082
   700
  by (simp add: Inter_eq)
haftmann@41082
   701
haftmann@41082
   702
text {*
haftmann@41082
   703
  \medskip A ``destruct'' rule -- every @{term X} in @{term C}
haftmann@43741
   704
  contains @{term A} as an element, but @{prop "A \<in> X"} can hold when
haftmann@43741
   705
  @{prop "X \<in> C"} does not!  This rule is analogous to @{text spec}.
haftmann@41082
   706
*}
haftmann@41082
   707
haftmann@43741
   708
lemma InterD [elim, Pure.elim]: "A \<in> \<Inter>C \<Longrightarrow> X \<in> C \<Longrightarrow> A \<in> X"
haftmann@41082
   709
  by auto
haftmann@41082
   710
haftmann@43741
   711
lemma InterE [elim]: "A \<in> \<Inter>C \<Longrightarrow> (X \<notin> C \<Longrightarrow> R) \<Longrightarrow> (A \<in> X \<Longrightarrow> R) \<Longrightarrow> R"
haftmann@41082
   712
  -- {* ``Classical'' elimination rule -- does not require proving
haftmann@43741
   713
    @{prop "X \<in> C"}. *}
haftmann@41082
   714
  by (unfold Inter_eq) blast
haftmann@41082
   715
haftmann@43741
   716
lemma Inter_lower: "B \<in> A \<Longrightarrow> \<Inter>A \<subseteq> B"
haftmann@43740
   717
  by (fact Inf_lower)
haftmann@43740
   718
haftmann@41082
   719
lemma Inter_subset:
haftmann@43755
   720
  "(\<And>X. X \<in> A \<Longrightarrow> X \<subseteq> B) \<Longrightarrow> A \<noteq> {} \<Longrightarrow> \<Inter>A \<subseteq> B"
haftmann@43740
   721
  by (fact Inf_less_eq)
haftmann@41082
   722
haftmann@43755
   723
lemma Inter_greatest: "(\<And>X. X \<in> A \<Longrightarrow> C \<subseteq> X) \<Longrightarrow> C \<subseteq> Inter A"
haftmann@43740
   724
  by (fact Inf_greatest)
haftmann@41082
   725
huffman@44067
   726
lemma Inter_empty: "\<Inter>{} = UNIV"
huffman@44067
   727
  by (fact Inf_empty) (* already simp *)
haftmann@41082
   728
huffman@44067
   729
lemma Inter_UNIV: "\<Inter>UNIV = {}"
huffman@44067
   730
  by (fact Inf_UNIV) (* already simp *)
haftmann@41082
   731
huffman@44920
   732
lemma Inter_insert: "\<Inter>(insert a B) = a \<inter> \<Inter>B"
huffman@44920
   733
  by (fact Inf_insert) (* already simp *)
haftmann@41082
   734
haftmann@41082
   735
lemma Inter_Un_subset: "\<Inter>A \<union> \<Inter>B \<subseteq> \<Inter>(A \<inter> B)"
haftmann@43899
   736
  by (fact less_eq_Inf_inter)
haftmann@41082
   737
haftmann@41082
   738
lemma Inter_Un_distrib: "\<Inter>(A \<union> B) = \<Inter>A \<inter> \<Inter>B"
haftmann@43756
   739
  by (fact Inf_union_distrib)
haftmann@43756
   740
haftmann@43868
   741
lemma Inter_UNIV_conv [simp, no_atp]:
haftmann@43741
   742
  "\<Inter>A = UNIV \<longleftrightarrow> (\<forall>x\<in>A. x = UNIV)"
haftmann@43741
   743
  "UNIV = \<Inter>A \<longleftrightarrow> (\<forall>x\<in>A. x = UNIV)"
haftmann@43801
   744
  by (fact Inf_top_conv)+
haftmann@41082
   745
haftmann@43741
   746
lemma Inter_anti_mono: "B \<subseteq> A \<Longrightarrow> \<Inter>A \<subseteq> \<Inter>B"
haftmann@43899
   747
  by (fact Inf_superset_mono)
haftmann@41082
   748
haftmann@41082
   749
haftmann@46631
   750
subsubsection {* Intersections of families *}
haftmann@41082
   751
haftmann@41082
   752
abbreviation INTER :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
haftmann@41082
   753
  "INTER \<equiv> INFI"
haftmann@41082
   754
haftmann@43872
   755
text {*
haftmann@43872
   756
  Note: must use name @{const INTER} here instead of @{text INT}
haftmann@43872
   757
  to allow the following syntax coexist with the plain constant name.
haftmann@43872
   758
*}
haftmann@43872
   759
haftmann@41082
   760
syntax
haftmann@41082
   761
  "_INTER1"     :: "pttrns => 'b set => 'b set"           ("(3INT _./ _)" [0, 10] 10)
haftmann@41082
   762
  "_INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3INT _:_./ _)" [0, 0, 10] 10)
haftmann@41082
   763
haftmann@41082
   764
syntax (xsymbols)
haftmann@41082
   765
  "_INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>_./ _)" [0, 10] 10)
haftmann@41082
   766
  "_INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41082
   767
haftmann@41082
   768
syntax (latex output)
haftmann@41082
   769
  "_INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
haftmann@41082
   770
  "_INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 0, 10] 10)
haftmann@41082
   771
haftmann@41082
   772
translations
haftmann@41082
   773
  "INT x y. B"  == "INT x. INT y. B"
haftmann@41082
   774
  "INT x. B"    == "CONST INTER CONST UNIV (%x. B)"
haftmann@41082
   775
  "INT x. B"    == "INT x:CONST UNIV. B"
haftmann@41082
   776
  "INT x:A. B"  == "CONST INTER A (%x. B)"
haftmann@41082
   777
haftmann@41082
   778
print_translation {*
wenzelm@42284
   779
  [Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax INTER} @{syntax_const "_INTER"}]
haftmann@41082
   780
*} -- {* to avoid eta-contraction of body *}
haftmann@41082
   781
haftmann@44085
   782
lemma INTER_eq:
haftmann@41082
   783
  "(\<Inter>x\<in>A. B x) = {y. \<forall>x\<in>A. y \<in> B x}"
haftmann@44085
   784
  by (auto simp add: INF_def)
haftmann@41082
   785
haftmann@41082
   786
lemma Inter_image_eq [simp]:
haftmann@41082
   787
  "\<Inter>(B`A) = (\<Inter>x\<in>A. B x)"
haftmann@43872
   788
  by (rule sym) (fact INF_def)
haftmann@41082
   789
haftmann@43817
   790
lemma INT_iff [simp]: "b \<in> (\<Inter>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. b \<in> B x)"
haftmann@44085
   791
  by (auto simp add: INF_def image_def)
haftmann@41082
   792
haftmann@43817
   793
lemma INT_I [intro!]: "(\<And>x. x \<in> A \<Longrightarrow> b \<in> B x) \<Longrightarrow> b \<in> (\<Inter>x\<in>A. B x)"
haftmann@44085
   794
  by (auto simp add: INF_def image_def)
haftmann@41082
   795
haftmann@43852
   796
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
   797
  by auto
haftmann@41082
   798
haftmann@43852
   799
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
   800
  -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a\<in>A"}. *}
haftmann@44085
   801
  by (auto simp add: INF_def image_def)
haftmann@41082
   802
haftmann@41082
   803
lemma INT_cong [cong]:
haftmann@43854
   804
  "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@43865
   805
  by (fact INF_cong)
haftmann@41082
   806
haftmann@41082
   807
lemma Collect_ball_eq: "{x. \<forall>y\<in>A. P x y} = (\<Inter>y\<in>A. {x. P x y})"
haftmann@41082
   808
  by blast
haftmann@41082
   809
haftmann@41082
   810
lemma Collect_all_eq: "{x. \<forall>y. P x y} = (\<Inter>y. {x. P x y})"
haftmann@41082
   811
  by blast
haftmann@41082
   812
haftmann@43817
   813
lemma INT_lower: "a \<in> A \<Longrightarrow> (\<Inter>x\<in>A. B x) \<subseteq> B a"
haftmann@44103
   814
  by (fact INF_lower)
haftmann@41082
   815
haftmann@43817
   816
lemma INT_greatest: "(\<And>x. x \<in> A \<Longrightarrow> C \<subseteq> B x) \<Longrightarrow> C \<subseteq> (\<Inter>x\<in>A. B x)"
haftmann@44103
   817
  by (fact INF_greatest)
haftmann@41082
   818
huffman@44067
   819
lemma INT_empty: "(\<Inter>x\<in>{}. B x) = UNIV"
haftmann@44085
   820
  by (fact INF_empty)
haftmann@43854
   821
haftmann@43817
   822
lemma INT_absorb: "k \<in> I \<Longrightarrow> A k \<inter> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. A i)"
haftmann@43872
   823
  by (fact INF_absorb)
haftmann@41082
   824
haftmann@43854
   825
lemma INT_subset_iff: "B \<subseteq> (\<Inter>i\<in>I. A i) \<longleftrightarrow> (\<forall>i\<in>I. B \<subseteq> A i)"
haftmann@41082
   826
  by (fact le_INF_iff)
haftmann@41082
   827
haftmann@41082
   828
lemma INT_insert [simp]: "(\<Inter>x \<in> insert a A. B x) = B a \<inter> INTER A B"
haftmann@43865
   829
  by (fact INF_insert)
haftmann@43865
   830
haftmann@43865
   831
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@43865
   832
  by (fact INF_union)
haftmann@43865
   833
haftmann@43865
   834
lemma INT_insert_distrib:
haftmann@43865
   835
  "u \<in> A \<Longrightarrow> (\<Inter>x\<in>A. insert a (B x)) = insert a (\<Inter>x\<in>A. B x)"
haftmann@43865
   836
  by blast
haftmann@43854
   837
haftmann@41082
   838
lemma INT_constant [simp]: "(\<Inter>y\<in>A. c) = (if A = {} then UNIV else c)"
haftmann@43865
   839
  by (fact INF_constant)
haftmann@43865
   840
huffman@44920
   841
lemma INTER_UNIV_conv:
haftmann@43817
   842
 "(UNIV = (\<Inter>x\<in>A. B x)) = (\<forall>x\<in>A. B x = UNIV)"
haftmann@43817
   843
 "((\<Inter>x\<in>A. B x) = UNIV) = (\<forall>x\<in>A. B x = UNIV)"
huffman@44920
   844
  by (fact INF_top_conv)+ (* already simp *)
haftmann@43865
   845
haftmann@43865
   846
lemma INT_bool_eq: "(\<Inter>b. A b) = A True \<inter> A False"
haftmann@43873
   847
  by (fact INF_UNIV_bool_expand)
haftmann@43865
   848
haftmann@43865
   849
lemma INT_anti_mono:
haftmann@43900
   850
  "A \<subseteq> B \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<subseteq> g x) \<Longrightarrow> (\<Inter>x\<in>B. f x) \<subseteq> (\<Inter>x\<in>A. g x)"
haftmann@43865
   851
  -- {* The last inclusion is POSITIVE! *}
haftmann@43940
   852
  by (fact INF_superset_mono)
haftmann@41082
   853
haftmann@41082
   854
lemma Pow_INT_eq: "Pow (\<Inter>x\<in>A. B x) = (\<Inter>x\<in>A. Pow (B x))"
haftmann@41082
   855
  by blast
haftmann@41082
   856
haftmann@43817
   857
lemma vimage_INT: "f -` (\<Inter>x\<in>A. B x) = (\<Inter>x\<in>A. f -` B x)"
haftmann@41082
   858
  by blast
haftmann@41082
   859
haftmann@41082
   860
haftmann@46631
   861
subsubsection {* Union *}
haftmann@32115
   862
haftmann@32587
   863
abbreviation Union :: "'a set set \<Rightarrow> 'a set" where
haftmann@32587
   864
  "Union S \<equiv> \<Squnion>S"
haftmann@32115
   865
haftmann@32115
   866
notation (xsymbols)
haftmann@32115
   867
  Union  ("\<Union>_" [90] 90)
haftmann@32115
   868
haftmann@32135
   869
lemma Union_eq:
haftmann@32135
   870
  "\<Union>A = {x. \<exists>B \<in> A. x \<in> B}"
nipkow@39302
   871
proof (rule set_eqI)
haftmann@32115
   872
  fix x
haftmann@32135
   873
  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
   874
    by auto
haftmann@32135
   875
  then show "x \<in> \<Union>A \<longleftrightarrow> x \<in> {x. \<exists>B\<in>A. x \<in> B}"
haftmann@45960
   876
    by (simp add: Sup_set_def image_def)
haftmann@32115
   877
qed
haftmann@32115
   878
blanchet@35828
   879
lemma Union_iff [simp, no_atp]:
haftmann@32115
   880
  "A \<in> \<Union>C \<longleftrightarrow> (\<exists>X\<in>C. A\<in>X)"
haftmann@32115
   881
  by (unfold Union_eq) blast
haftmann@32115
   882
haftmann@32115
   883
lemma UnionI [intro]:
haftmann@32115
   884
  "X \<in> C \<Longrightarrow> A \<in> X \<Longrightarrow> A \<in> \<Union>C"
haftmann@32115
   885
  -- {* The order of the premises presupposes that @{term C} is rigid;
haftmann@32115
   886
    @{term A} may be flexible. *}
haftmann@32115
   887
  by auto
haftmann@32115
   888
haftmann@32115
   889
lemma UnionE [elim!]:
haftmann@43817
   890
  "A \<in> \<Union>C \<Longrightarrow> (\<And>X. A \<in> X \<Longrightarrow> X \<in> C \<Longrightarrow> R) \<Longrightarrow> R"
haftmann@32115
   891
  by auto
haftmann@32115
   892
haftmann@43817
   893
lemma Union_upper: "B \<in> A \<Longrightarrow> B \<subseteq> \<Union>A"
haftmann@43901
   894
  by (fact Sup_upper)
haftmann@32135
   895
haftmann@43817
   896
lemma Union_least: "(\<And>X. X \<in> A \<Longrightarrow> X \<subseteq> C) \<Longrightarrow> \<Union>A \<subseteq> C"
haftmann@43901
   897
  by (fact Sup_least)
haftmann@32135
   898
huffman@44920
   899
lemma Union_empty: "\<Union>{} = {}"
huffman@44920
   900
  by (fact Sup_empty) (* already simp *)
haftmann@32135
   901
huffman@44920
   902
lemma Union_UNIV: "\<Union>UNIV = UNIV"
huffman@44920
   903
  by (fact Sup_UNIV) (* already simp *)
haftmann@32135
   904
huffman@44920
   905
lemma Union_insert: "\<Union>insert a B = a \<union> \<Union>B"
huffman@44920
   906
  by (fact Sup_insert) (* already simp *)
haftmann@32135
   907
haftmann@43817
   908
lemma Union_Un_distrib [simp]: "\<Union>(A \<union> B) = \<Union>A \<union> \<Union>B"
haftmann@43901
   909
  by (fact Sup_union_distrib)
haftmann@32135
   910
haftmann@32135
   911
lemma Union_Int_subset: "\<Union>(A \<inter> B) \<subseteq> \<Union>A \<inter> \<Union>B"
haftmann@43901
   912
  by (fact Sup_inter_less_eq)
haftmann@32135
   913
huffman@44920
   914
lemma Union_empty_conv [no_atp]: "(\<Union>A = {}) \<longleftrightarrow> (\<forall>x\<in>A. x = {})"
huffman@44920
   915
  by (fact Sup_bot_conv) (* already simp *)
haftmann@32135
   916
huffman@44920
   917
lemma empty_Union_conv [no_atp]: "({} = \<Union>A) \<longleftrightarrow> (\<forall>x\<in>A. x = {})"
huffman@44920
   918
  by (fact Sup_bot_conv) (* already simp *)
haftmann@32135
   919
haftmann@32135
   920
lemma subset_Pow_Union: "A \<subseteq> Pow (\<Union>A)"
haftmann@32135
   921
  by blast
haftmann@32135
   922
haftmann@32135
   923
lemma Union_Pow_eq [simp]: "\<Union>(Pow A) = A"
haftmann@32135
   924
  by blast
haftmann@32135
   925
haftmann@43817
   926
lemma Union_mono: "A \<subseteq> B \<Longrightarrow> \<Union>A \<subseteq> \<Union>B"
haftmann@43901
   927
  by (fact Sup_subset_mono)
haftmann@32135
   928
haftmann@32115
   929
haftmann@46631
   930
subsubsection {* Unions of families *}
haftmann@32077
   931
haftmann@32606
   932
abbreviation UNION :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
haftmann@32606
   933
  "UNION \<equiv> SUPR"
haftmann@32077
   934
haftmann@43872
   935
text {*
haftmann@43872
   936
  Note: must use name @{const UNION} here instead of @{text UN}
haftmann@43872
   937
  to allow the following syntax coexist with the plain constant name.
haftmann@43872
   938
*}
haftmann@43872
   939
haftmann@32077
   940
syntax
wenzelm@35115
   941
  "_UNION1"     :: "pttrns => 'b set => 'b set"           ("(3UN _./ _)" [0, 10] 10)
huffman@36364
   942
  "_UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3UN _:_./ _)" [0, 0, 10] 10)
haftmann@32077
   943
haftmann@32077
   944
syntax (xsymbols)
wenzelm@35115
   945
  "_UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>_./ _)" [0, 10] 10)
huffman@36364
   946
  "_UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@32077
   947
haftmann@32077
   948
syntax (latex output)
wenzelm@35115
   949
  "_UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
huffman@36364
   950
  "_UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 0, 10] 10)
haftmann@32077
   951
haftmann@32077
   952
translations
haftmann@32077
   953
  "UN x y. B"   == "UN x. UN y. B"
haftmann@32077
   954
  "UN x. B"     == "CONST UNION CONST UNIV (%x. B)"
haftmann@32077
   955
  "UN x. B"     == "UN x:CONST UNIV. B"
haftmann@32077
   956
  "UN x:A. B"   == "CONST UNION A (%x. B)"
haftmann@32077
   957
haftmann@32077
   958
text {*
haftmann@32077
   959
  Note the difference between ordinary xsymbol syntax of indexed
haftmann@32077
   960
  unions and intersections (e.g.\ @{text"\<Union>a\<^isub>1\<in>A\<^isub>1. B"})
haftmann@32077
   961
  and their \LaTeX\ rendition: @{term"\<Union>a\<^isub>1\<in>A\<^isub>1. B"}. The
haftmann@32077
   962
  former does not make the index expression a subscript of the
haftmann@32077
   963
  union/intersection symbol because this leads to problems with nested
haftmann@32077
   964
  subscripts in Proof General.
haftmann@32077
   965
*}
haftmann@32077
   966
wenzelm@35115
   967
print_translation {*
wenzelm@42284
   968
  [Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax UNION} @{syntax_const "_UNION"}]
wenzelm@35115
   969
*} -- {* to avoid eta-contraction of body *}
haftmann@32077
   970
haftmann@44085
   971
lemma UNION_eq [no_atp]:
haftmann@32135
   972
  "(\<Union>x\<in>A. B x) = {y. \<exists>x\<in>A. y \<in> B x}"
haftmann@44085
   973
  by (auto simp add: SUP_def)
huffman@44920
   974
haftmann@45960
   975
lemma bind_UNION [code]:
haftmann@45960
   976
  "Set.bind A f = UNION A f"
haftmann@45960
   977
  by (simp add: bind_def UNION_eq)
haftmann@45960
   978
haftmann@46036
   979
lemma member_bind [simp]:
haftmann@46036
   980
  "x \<in> Set.bind P f \<longleftrightarrow> x \<in> UNION P f "
haftmann@46036
   981
  by (simp add: bind_UNION)
haftmann@46036
   982
haftmann@32115
   983
lemma Union_image_eq [simp]:
haftmann@43817
   984
  "\<Union>(B ` A) = (\<Union>x\<in>A. B x)"
huffman@44920
   985
  by (rule sym) (fact SUP_def)
huffman@44920
   986
haftmann@46036
   987
lemma UN_iff [simp]: "b \<in> (\<Union>x\<in>A. B x) \<longleftrightarrow> (\<exists>x\<in>A. b \<in> B x)"
haftmann@44085
   988
  by (auto simp add: SUP_def image_def)
wenzelm@11979
   989
haftmann@43852
   990
lemma UN_I [intro]: "a \<in> A \<Longrightarrow> b \<in> B a \<Longrightarrow> b \<in> (\<Union>x\<in>A. B x)"
wenzelm@11979
   991
  -- {* The order of the premises presupposes that @{term A} is rigid;
wenzelm@11979
   992
    @{term b} may be flexible. *}
wenzelm@11979
   993
  by auto
wenzelm@11979
   994
haftmann@43852
   995
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"
haftmann@44085
   996
  by (auto simp add: SUP_def image_def)
clasohm@923
   997
wenzelm@11979
   998
lemma UN_cong [cong]:
haftmann@43900
   999
  "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)"
haftmann@43900
  1000
  by (fact SUP_cong)
wenzelm@11979
  1001
berghofe@29691
  1002
lemma strong_UN_cong:
haftmann@43900
  1003
  "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)"
haftmann@43900
  1004
  by (unfold simp_implies_def) (fact UN_cong)
berghofe@29691
  1005
haftmann@43817
  1006
lemma image_eq_UN: "f ` A = (\<Union>x\<in>A. {f x})"
haftmann@32077
  1007
  by blast
haftmann@32077
  1008
haftmann@43817
  1009
lemma UN_upper: "a \<in> A \<Longrightarrow> B a \<subseteq> (\<Union>x\<in>A. B x)"
haftmann@44103
  1010
  by (fact SUP_upper)
haftmann@32135
  1011
haftmann@43817
  1012
lemma UN_least: "(\<And>x. x \<in> A \<Longrightarrow> B x \<subseteq> C) \<Longrightarrow> (\<Union>x\<in>A. B x) \<subseteq> C"
haftmann@44103
  1013
  by (fact SUP_least)
haftmann@32135
  1014
blanchet@35828
  1015
lemma Collect_bex_eq [no_atp]: "{x. \<exists>y\<in>A. P x y} = (\<Union>y\<in>A. {x. P x y})"
haftmann@32135
  1016
  by blast
haftmann@32135
  1017
haftmann@43817
  1018
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
  1019
  by blast
haftmann@32135
  1020
huffman@44067
  1021
lemma UN_empty [no_atp]: "(\<Union>x\<in>{}. B x) = {}"
haftmann@44085
  1022
  by (fact SUP_empty)
haftmann@32135
  1023
huffman@44920
  1024
lemma UN_empty2: "(\<Union>x\<in>A. {}) = {}"
huffman@44920
  1025
  by (fact SUP_bot) (* already simp *)
haftmann@32135
  1026
haftmann@43817
  1027
lemma UN_absorb: "k \<in> I \<Longrightarrow> A k \<union> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. A i)"
haftmann@43900
  1028
  by (fact SUP_absorb)
haftmann@32135
  1029
haftmann@32135
  1030
lemma UN_insert [simp]: "(\<Union>x\<in>insert a A. B x) = B a \<union> UNION A B"
haftmann@43900
  1031
  by (fact SUP_insert)
haftmann@32135
  1032
haftmann@44085
  1033
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@43900
  1034
  by (fact SUP_union)
haftmann@32135
  1035
haftmann@43967
  1036
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
  1037
  by blast
haftmann@32135
  1038
haftmann@32135
  1039
lemma UN_subset_iff: "((\<Union>i\<in>I. A i) \<subseteq> B) = (\<forall>i\<in>I. A i \<subseteq> B)"
huffman@35629
  1040
  by (fact SUP_le_iff)
haftmann@32135
  1041
haftmann@32135
  1042
lemma UN_constant [simp]: "(\<Union>y\<in>A. c) = (if A = {} then {} else c)"
haftmann@43900
  1043
  by (fact SUP_constant)
haftmann@32135
  1044
haftmann@43944
  1045
lemma image_Union: "f ` \<Union>S = (\<Union>x\<in>S. f ` x)"
haftmann@32135
  1046
  by blast
haftmann@32135
  1047
huffman@44920
  1048
lemma UNION_empty_conv:
haftmann@43817
  1049
  "{} = (\<Union>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = {})"
haftmann@43817
  1050
  "(\<Union>x\<in>A. B x) = {} \<longleftrightarrow> (\<forall>x\<in>A. B x = {})"
huffman@44920
  1051
  by (fact SUP_bot_conv)+ (* already simp *)
haftmann@32135
  1052
blanchet@35828
  1053
lemma Collect_ex_eq [no_atp]: "{x. \<exists>y. P x y} = (\<Union>y. {x. P x y})"
haftmann@32135
  1054
  by blast
haftmann@32135
  1055
haftmann@43900
  1056
lemma ball_UN: "(\<forall>z \<in> UNION A B. P z) \<longleftrightarrow> (\<forall>x\<in>A. \<forall>z \<in> B x. P z)"
haftmann@32135
  1057
  by blast
haftmann@32135
  1058
haftmann@43900
  1059
lemma bex_UN: "(\<exists>z \<in> UNION A B. P z) \<longleftrightarrow> (\<exists>x\<in>A. \<exists>z\<in>B x. P z)"
haftmann@32135
  1060
  by blast
haftmann@32135
  1061
haftmann@32135
  1062
lemma Un_eq_UN: "A \<union> B = (\<Union>b. if b then A else B)"
haftmann@32135
  1063
  by (auto simp add: split_if_mem2)
haftmann@32135
  1064
haftmann@43817
  1065
lemma UN_bool_eq: "(\<Union>b. A b) = (A True \<union> A False)"
haftmann@43900
  1066
  by (fact SUP_UNIV_bool_expand)
haftmann@32135
  1067
haftmann@32135
  1068
lemma UN_Pow_subset: "(\<Union>x\<in>A. Pow (B x)) \<subseteq> Pow (\<Union>x\<in>A. B x)"
haftmann@32135
  1069
  by blast
haftmann@32135
  1070
haftmann@32135
  1071
lemma UN_mono:
haftmann@43817
  1072
  "A \<subseteq> B \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<subseteq> g x) \<Longrightarrow>
haftmann@32135
  1073
    (\<Union>x\<in>A. f x) \<subseteq> (\<Union>x\<in>B. g x)"
haftmann@43940
  1074
  by (fact SUP_subset_mono)
haftmann@32135
  1075
haftmann@43817
  1076
lemma vimage_Union: "f -` (\<Union>A) = (\<Union>X\<in>A. f -` X)"
haftmann@32135
  1077
  by blast
haftmann@32135
  1078
haftmann@43817
  1079
lemma vimage_UN: "f -` (\<Union>x\<in>A. B x) = (\<Union>x\<in>A. f -` B x)"
haftmann@32135
  1080
  by blast
haftmann@32135
  1081
haftmann@43817
  1082
lemma vimage_eq_UN: "f -` B = (\<Union>y\<in>B. f -` {y})"
haftmann@32135
  1083
  -- {* NOT suitable for rewriting *}
haftmann@32135
  1084
  by blast
haftmann@32135
  1085
haftmann@43817
  1086
lemma image_UN: "f ` UNION A B = (\<Union>x\<in>A. f ` B x)"
haftmann@43817
  1087
  by blast
haftmann@32135
  1088
haftmann@45013
  1089
lemma UN_singleton [simp]: "(\<Union>x\<in>A. {x}) = A"
haftmann@45013
  1090
  by blast
haftmann@45013
  1091
wenzelm@11979
  1092
haftmann@46631
  1093
subsubsection {* Distributive laws *}
wenzelm@12897
  1094
wenzelm@12897
  1095
lemma Int_Union: "A \<inter> \<Union>B = (\<Union>C\<in>B. A \<inter> C)"
haftmann@44032
  1096
  by (fact inf_Sup)
wenzelm@12897
  1097
haftmann@44039
  1098
lemma Un_Inter: "A \<union> \<Inter>B = (\<Inter>C\<in>B. A \<union> C)"
haftmann@44039
  1099
  by (fact sup_Inf)
haftmann@44039
  1100
wenzelm@12897
  1101
lemma Int_Union2: "\<Union>B \<inter> A = (\<Union>C\<in>B. C \<inter> A)"
haftmann@44039
  1102
  by (fact Sup_inf)
haftmann@44039
  1103
haftmann@44039
  1104
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)"
haftmann@44039
  1105
  by (rule sym) (rule INF_inf_distrib)
haftmann@44039
  1106
haftmann@44039
  1107
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)"
haftmann@44039
  1108
  by (rule sym) (rule SUP_sup_distrib)
haftmann@44039
  1109
haftmann@44039
  1110
lemma Int_Inter_image: "(\<Inter>x\<in>C. A x \<inter> B x) = \<Inter>(A ` C) \<inter> \<Inter>(B ` C)"
haftmann@44039
  1111
  by (simp only: INT_Int_distrib INF_def)
wenzelm@12897
  1112
haftmann@43817
  1113
lemma Un_Union_image: "(\<Union>x\<in>C. A x \<union> B x) = \<Union>(A ` C) \<union> \<Union>(B ` C)"
wenzelm@12897
  1114
  -- {* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: *}
wenzelm@12897
  1115
  -- {* Union of a family of unions *}
haftmann@44039
  1116
  by (simp only: UN_Un_distrib SUP_def)
wenzelm@12897
  1117
haftmann@44039
  1118
lemma Un_INT_distrib: "B \<union> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. B \<union> A i)"
haftmann@44039
  1119
  by (fact sup_INF)
wenzelm@12897
  1120
wenzelm@12897
  1121
lemma Int_UN_distrib: "B \<inter> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. B \<inter> A i)"
wenzelm@12897
  1122
  -- {* Halmos, Naive Set Theory, page 35. *}
haftmann@44039
  1123
  by (fact inf_SUP)
wenzelm@12897
  1124
wenzelm@12897
  1125
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)"
haftmann@44039
  1126
  by (fact SUP_inf_distrib2)
wenzelm@12897
  1127
wenzelm@12897
  1128
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)"
haftmann@44039
  1129
  by (fact INF_sup_distrib2)
haftmann@44039
  1130
haftmann@44039
  1131
lemma Union_disjoint: "(\<Union>C \<inter> A = {}) \<longleftrightarrow> (\<forall>B\<in>C. B \<inter> A = {})"
haftmann@44039
  1132
  by (fact Sup_inf_eq_bot_iff)
wenzelm@12897
  1133
wenzelm@12897
  1134
haftmann@46631
  1135
subsubsection {* Complement *}
haftmann@32135
  1136
haftmann@43873
  1137
lemma Compl_INT [simp]: "- (\<Inter>x\<in>A. B x) = (\<Union>x\<in>A. -B x)"
haftmann@43873
  1138
  by (fact uminus_INF)
wenzelm@12897
  1139
haftmann@43873
  1140
lemma Compl_UN [simp]: "- (\<Union>x\<in>A. B x) = (\<Inter>x\<in>A. -B x)"
haftmann@43873
  1141
  by (fact uminus_SUP)
wenzelm@12897
  1142
wenzelm@12897
  1143
haftmann@46631
  1144
subsubsection {* Miniscoping and maxiscoping *}
wenzelm@12897
  1145
paulson@13860
  1146
text {* \medskip Miniscoping: pushing in quantifiers and big Unions
paulson@13860
  1147
           and Intersections. *}
wenzelm@12897
  1148
wenzelm@12897
  1149
lemma UN_simps [simp]:
haftmann@43817
  1150
  "\<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@44032
  1151
  "\<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
  1152
  "\<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@44032
  1153
  "\<And>A B C. (\<Union>x\<in>C. A x \<inter> B) = ((\<Union>x\<in>C. A x) \<inter> B)"
haftmann@43852
  1154
  "\<And>A B C. (\<Union>x\<in>C. A \<inter> B x) = (A \<inter>(\<Union>x\<in>C. B x))"
haftmann@43852
  1155
  "\<And>A B C. (\<Union>x\<in>C. A x - B) = ((\<Union>x\<in>C. A x) - B)"
haftmann@43852
  1156
  "\<And>A B C. (\<Union>x\<in>C. A - B x) = (A - (\<Inter>x\<in>C. B x))"
haftmann@43852
  1157
  "\<And>A B. (\<Union>x\<in>\<Union>A. B x) = (\<Union>y\<in>A. \<Union>x\<in>y. B x)"
haftmann@43852
  1158
  "\<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
  1159
  "\<And>A B f. (\<Union>x\<in>f`A. B x) = (\<Union>a\<in>A. B (f a))"
wenzelm@12897
  1160
  by auto
wenzelm@12897
  1161
wenzelm@12897
  1162
lemma INT_simps [simp]:
haftmann@44032
  1163
  "\<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
  1164
  "\<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
  1165
  "\<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
  1166
  "\<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
  1167
  "\<And>a B C. (\<Inter>x\<in>C. insert a (B x)) = insert a (\<Inter>x\<in>C. B x)"
haftmann@43852
  1168
  "\<And>A B C. (\<Inter>x\<in>C. A x \<union> B) = ((\<Inter>x\<in>C. A x) \<union> B)"
haftmann@43852
  1169
  "\<And>A B C. (\<Inter>x\<in>C. A \<union> B x) = (A \<union> (\<Inter>x\<in>C. B x))"
haftmann@43852
  1170
  "\<And>A B. (\<Inter>x\<in>\<Union>A. B x) = (\<Inter>y\<in>A. \<Inter>x\<in>y. B x)"
haftmann@43852
  1171
  "\<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
  1172
  "\<And>A B f. (\<Inter>x\<in>f`A. B x) = (\<Inter>a\<in>A. B (f a))"
wenzelm@12897
  1173
  by auto
wenzelm@12897
  1174
haftmann@43967
  1175
lemma UN_ball_bex_simps [simp, no_atp]:
haftmann@43852
  1176
  "\<And>A P. (\<forall>x\<in>\<Union>A. P x) \<longleftrightarrow> (\<forall>y\<in>A. \<forall>x\<in>y. P x)"
haftmann@43967
  1177
  "\<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
  1178
  "\<And>A P. (\<exists>x\<in>\<Union>A. P x) \<longleftrightarrow> (\<exists>y\<in>A. \<exists>x\<in>y. P x)"
haftmann@43852
  1179
  "\<And>A B P. (\<exists>x\<in>UNION A B. P x) \<longleftrightarrow> (\<exists>a\<in>A. \<exists>x\<in>B a. P x)"
wenzelm@12897
  1180
  by auto
wenzelm@12897
  1181
haftmann@43943
  1182
paulson@13860
  1183
text {* \medskip Maxiscoping: pulling out big Unions and Intersections. *}
paulson@13860
  1184
paulson@13860
  1185
lemma UN_extend_simps:
haftmann@43817
  1186
  "\<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@44032
  1187
  "\<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
  1188
  "\<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
  1189
  "\<And>A B C. ((\<Union>x\<in>C. A x) \<inter> B) = (\<Union>x\<in>C. A x \<inter> B)"
haftmann@43852
  1190
  "\<And>A B C. (A \<inter> (\<Union>x\<in>C. B x)) = (\<Union>x\<in>C. A \<inter> B x)"
haftmann@43817
  1191
  "\<And>A B C. ((\<Union>x\<in>C. A x) - B) = (\<Union>x\<in>C. A x - B)"
haftmann@43817
  1192
  "\<And>A B C. (A - (\<Inter>x\<in>C. B x)) = (\<Union>x\<in>C. A - B x)"
haftmann@43852
  1193
  "\<And>A B. (\<Union>y\<in>A. \<Union>x\<in>y. B x) = (\<Union>x\<in>\<Union>A. B x)"
haftmann@43852
  1194
  "\<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
  1195
  "\<And>A B f. (\<Union>a\<in>A. B (f a)) = (\<Union>x\<in>f`A. B x)"
paulson@13860
  1196
  by auto
paulson@13860
  1197
paulson@13860
  1198
lemma INT_extend_simps:
haftmann@43852
  1199
  "\<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
  1200
  "\<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
  1201
  "\<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
  1202
  "\<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
  1203
  "\<And>a B C. insert a (\<Inter>x\<in>C. B x) = (\<Inter>x\<in>C. insert a (B x))"
haftmann@43852
  1204
  "\<And>A B C. ((\<Inter>x\<in>C. A x) \<union> B) = (\<Inter>x\<in>C. A x \<union> B)"
haftmann@43852
  1205
  "\<And>A B C. A \<union> (\<Inter>x\<in>C. B x) = (\<Inter>x\<in>C. A \<union> B x)"
haftmann@43852
  1206
  "\<And>A B. (\<Inter>y\<in>A. \<Inter>x\<in>y. B x) = (\<Inter>x\<in>\<Union>A. B x)"
haftmann@43852
  1207
  "\<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
  1208
  "\<And>A B f. (\<Inter>a\<in>A. B (f a)) = (\<Inter>x\<in>f`A. B x)"
paulson@13860
  1209
  by auto
paulson@13860
  1210
haftmann@43872
  1211
text {* Finally *}
haftmann@43872
  1212
haftmann@32135
  1213
no_notation
haftmann@46691
  1214
  less_eq (infix "\<sqsubseteq>" 50) and
haftmann@46691
  1215
  less (infix "\<sqsubset>" 50)
haftmann@32135
  1216
haftmann@30596
  1217
lemmas mem_simps =
haftmann@30596
  1218
  insert_iff empty_iff Un_iff Int_iff Compl_iff Diff_iff
haftmann@30596
  1219
  mem_Collect_eq UN_iff Union_iff INT_iff Inter_iff
haftmann@30596
  1220
  -- {* Each of these has ALREADY been added @{text "[simp]"} above. *}
wenzelm@21669
  1221
wenzelm@11979
  1222
end