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