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