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