src/HOL/Complete_Lattice.thy
changeset 32139 e271a64f03ff
parent 32135 f645b51e8e54
child 32436 10cd49e0c067
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Complete_Lattice.thy	Wed Jul 22 18:02:10 2009 +0200
     1.3 @@ -0,0 +1,794 @@
     1.4 +(*  Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel; Florian Haftmann, TU Muenchen *)
     1.5 +
     1.6 +header {* Complete lattices, with special focus on sets *}
     1.7 +
     1.8 +theory Complete_Lattice
     1.9 +imports Set
    1.10 +begin
    1.11 +
    1.12 +notation
    1.13 +  less_eq  (infix "\<sqsubseteq>" 50) and
    1.14 +  less (infix "\<sqsubset>" 50) and
    1.15 +  inf  (infixl "\<sqinter>" 70) and
    1.16 +  sup  (infixl "\<squnion>" 65)
    1.17 +
    1.18 +
    1.19 +subsection {* Abstract complete lattices *}
    1.20 +
    1.21 +class complete_lattice = lattice + bot + top +
    1.22 +  fixes Inf :: "'a set \<Rightarrow> 'a" ("\<Sqinter>_" [900] 900)
    1.23 +    and Sup :: "'a set \<Rightarrow> 'a" ("\<Squnion>_" [900] 900)
    1.24 +  assumes Inf_lower: "x \<in> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> x"
    1.25 +     and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A"
    1.26 +  assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A"
    1.27 +     and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z"
    1.28 +begin
    1.29 +
    1.30 +lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<le> a}"
    1.31 +  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
    1.32 +
    1.33 +lemma Sup_Inf:  "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<le> b}"
    1.34 +  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
    1.35 +
    1.36 +lemma Inf_Univ: "\<Sqinter>UNIV = \<Squnion>{}"
    1.37 +  unfolding Sup_Inf by auto
    1.38 +
    1.39 +lemma Sup_Univ: "\<Squnion>UNIV = \<Sqinter>{}"
    1.40 +  unfolding Inf_Sup by auto
    1.41 +
    1.42 +lemma Inf_insert: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A"
    1.43 +  by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower)
    1.44 +
    1.45 +lemma Sup_insert: "\<Squnion>insert a A = a \<squnion> \<Squnion>A"
    1.46 +  by (auto intro: le_supI le_supI1 le_supI2 antisym Sup_least Sup_upper)
    1.47 +
    1.48 +lemma Inf_singleton [simp]:
    1.49 +  "\<Sqinter>{a} = a"
    1.50 +  by (auto intro: antisym Inf_lower Inf_greatest)
    1.51 +
    1.52 +lemma Sup_singleton [simp]:
    1.53 +  "\<Squnion>{a} = a"
    1.54 +  by (auto intro: antisym Sup_upper Sup_least)
    1.55 +
    1.56 +lemma Inf_insert_simp:
    1.57 +  "\<Sqinter>insert a A = (if A = {} then a else a \<sqinter> \<Sqinter>A)"
    1.58 +  by (cases "A = {}") (simp_all, simp add: Inf_insert)
    1.59 +
    1.60 +lemma Sup_insert_simp:
    1.61 +  "\<Squnion>insert a A = (if A = {} then a else a \<squnion> \<Squnion>A)"
    1.62 +  by (cases "A = {}") (simp_all, simp add: Sup_insert)
    1.63 +
    1.64 +lemma Inf_binary:
    1.65 +  "\<Sqinter>{a, b} = a \<sqinter> b"
    1.66 +  by (auto simp add: Inf_insert_simp)
    1.67 +
    1.68 +lemma Sup_binary:
    1.69 +  "\<Squnion>{a, b} = a \<squnion> b"
    1.70 +  by (auto simp add: Sup_insert_simp)
    1.71 +
    1.72 +lemma bot_def:
    1.73 +  "bot = \<Squnion>{}"
    1.74 +  by (auto intro: antisym Sup_least)
    1.75 +
    1.76 +lemma top_def:
    1.77 +  "top = \<Sqinter>{}"
    1.78 +  by (auto intro: antisym Inf_greatest)
    1.79 +
    1.80 +lemma sup_bot [simp]:
    1.81 +  "x \<squnion> bot = x"
    1.82 +  using bot_least [of x] by (simp add: le_iff_sup sup_commute)
    1.83 +
    1.84 +lemma inf_top [simp]:
    1.85 +  "x \<sqinter> top = x"
    1.86 +  using top_greatest [of x] by (simp add: le_iff_inf inf_commute)
    1.87 +
    1.88 +definition SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
    1.89 +  "SUPR A f = \<Squnion> (f ` A)"
    1.90 +
    1.91 +definition INFI :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
    1.92 +  "INFI A f = \<Sqinter> (f ` A)"
    1.93 +
    1.94 +end
    1.95 +
    1.96 +syntax
    1.97 +  "_SUP1"     :: "pttrns => 'b => 'b"           ("(3SUP _./ _)" [0, 10] 10)
    1.98 +  "_SUP"      :: "pttrn => 'a set => 'b => 'b"  ("(3SUP _:_./ _)" [0, 10] 10)
    1.99 +  "_INF1"     :: "pttrns => 'b => 'b"           ("(3INF _./ _)" [0, 10] 10)
   1.100 +  "_INF"      :: "pttrn => 'a set => 'b => 'b"  ("(3INF _:_./ _)" [0, 10] 10)
   1.101 +
   1.102 +translations
   1.103 +  "SUP x y. B"   == "SUP x. SUP y. B"
   1.104 +  "SUP x. B"     == "CONST SUPR CONST UNIV (%x. B)"
   1.105 +  "SUP x. B"     == "SUP x:CONST UNIV. B"
   1.106 +  "SUP x:A. B"   == "CONST SUPR A (%x. B)"
   1.107 +  "INF x y. B"   == "INF x. INF y. B"
   1.108 +  "INF x. B"     == "CONST INFI CONST UNIV (%x. B)"
   1.109 +  "INF x. B"     == "INF x:CONST UNIV. B"
   1.110 +  "INF x:A. B"   == "CONST INFI A (%x. B)"
   1.111 +
   1.112 +print_translation {* [
   1.113 +Syntax.preserve_binder_abs2_tr' @{const_syntax SUPR} "_SUP",
   1.114 +Syntax.preserve_binder_abs2_tr' @{const_syntax INFI} "_INF"
   1.115 +] *} -- {* to avoid eta-contraction of body *}
   1.116 +
   1.117 +context complete_lattice
   1.118 +begin
   1.119 +
   1.120 +lemma le_SUPI: "i : A \<Longrightarrow> M i \<le> (SUP i:A. M i)"
   1.121 +  by (auto simp add: SUPR_def intro: Sup_upper)
   1.122 +
   1.123 +lemma SUP_leI: "(\<And>i. i : A \<Longrightarrow> M i \<le> u) \<Longrightarrow> (SUP i:A. M i) \<le> u"
   1.124 +  by (auto simp add: SUPR_def intro: Sup_least)
   1.125 +
   1.126 +lemma INF_leI: "i : A \<Longrightarrow> (INF i:A. M i) \<le> M i"
   1.127 +  by (auto simp add: INFI_def intro: Inf_lower)
   1.128 +
   1.129 +lemma le_INFI: "(\<And>i. i : A \<Longrightarrow> u \<le> M i) \<Longrightarrow> u \<le> (INF i:A. M i)"
   1.130 +  by (auto simp add: INFI_def intro: Inf_greatest)
   1.131 +
   1.132 +lemma SUP_const[simp]: "A \<noteq> {} \<Longrightarrow> (SUP i:A. M) = M"
   1.133 +  by (auto intro: antisym SUP_leI le_SUPI)
   1.134 +
   1.135 +lemma INF_const[simp]: "A \<noteq> {} \<Longrightarrow> (INF i:A. M) = M"
   1.136 +  by (auto intro: antisym INF_leI le_INFI)
   1.137 +
   1.138 +end
   1.139 +
   1.140 +
   1.141 +subsection {* @{typ bool} and @{typ "_ \<Rightarrow> _"} as complete lattice *}
   1.142 +
   1.143 +instantiation bool :: complete_lattice
   1.144 +begin
   1.145 +
   1.146 +definition
   1.147 +  Inf_bool_def: "\<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x)"
   1.148 +
   1.149 +definition
   1.150 +  Sup_bool_def: "\<Squnion>A \<longleftrightarrow> (\<exists>x\<in>A. x)"
   1.151 +
   1.152 +instance proof
   1.153 +qed (auto simp add: Inf_bool_def Sup_bool_def le_bool_def)
   1.154 +
   1.155 +end
   1.156 +
   1.157 +lemma Inf_empty_bool [simp]:
   1.158 +  "\<Sqinter>{}"
   1.159 +  unfolding Inf_bool_def by auto
   1.160 +
   1.161 +lemma not_Sup_empty_bool [simp]:
   1.162 +  "\<not> \<Squnion>{}"
   1.163 +  unfolding Sup_bool_def by auto
   1.164 +
   1.165 +lemma INFI_bool_eq:
   1.166 +  "INFI = Ball"
   1.167 +proof (rule ext)+
   1.168 +  fix A :: "'a set"
   1.169 +  fix P :: "'a \<Rightarrow> bool"
   1.170 +  show "(INF x:A. P x) \<longleftrightarrow> (\<forall>x \<in> A. P x)"
   1.171 +    by (auto simp add: Ball_def INFI_def Inf_bool_def)
   1.172 +qed
   1.173 +
   1.174 +lemma SUPR_bool_eq:
   1.175 +  "SUPR = Bex"
   1.176 +proof (rule ext)+
   1.177 +  fix A :: "'a set"
   1.178 +  fix P :: "'a \<Rightarrow> bool"
   1.179 +  show "(SUP x:A. P x) \<longleftrightarrow> (\<exists>x \<in> A. P x)"
   1.180 +    by (auto simp add: Bex_def SUPR_def Sup_bool_def)
   1.181 +qed
   1.182 +
   1.183 +instantiation "fun" :: (type, complete_lattice) complete_lattice
   1.184 +begin
   1.185 +
   1.186 +definition
   1.187 +  Inf_fun_def [code del]: "\<Sqinter>A = (\<lambda>x. \<Sqinter>{y. \<exists>f\<in>A. y = f x})"
   1.188 +
   1.189 +definition
   1.190 +  Sup_fun_def [code del]: "\<Squnion>A = (\<lambda>x. \<Squnion>{y. \<exists>f\<in>A. y = f x})"
   1.191 +
   1.192 +instance proof
   1.193 +qed (auto simp add: Inf_fun_def Sup_fun_def le_fun_def
   1.194 +  intro: Inf_lower Sup_upper Inf_greatest Sup_least)
   1.195 +
   1.196 +end
   1.197 +
   1.198 +lemma Inf_empty_fun:
   1.199 +  "\<Sqinter>{} = (\<lambda>_. \<Sqinter>{})"
   1.200 +  by (simp add: Inf_fun_def)
   1.201 +
   1.202 +lemma Sup_empty_fun:
   1.203 +  "\<Squnion>{} = (\<lambda>_. \<Squnion>{})"
   1.204 +  by (simp add: Sup_fun_def)
   1.205 +
   1.206 +
   1.207 +subsection {* Union *}
   1.208 +
   1.209 +definition Union :: "'a set set \<Rightarrow> 'a set" where
   1.210 +  Sup_set_eq [symmetric]: "Union S = \<Squnion>S"
   1.211 +
   1.212 +notation (xsymbols)
   1.213 +  Union  ("\<Union>_" [90] 90)
   1.214 +
   1.215 +lemma Union_eq:
   1.216 +  "\<Union>A = {x. \<exists>B \<in> A. x \<in> B}"
   1.217 +proof (rule set_ext)
   1.218 +  fix x
   1.219 +  have "(\<exists>Q\<in>{P. \<exists>B\<in>A. P \<longleftrightarrow> x \<in> B}. Q) \<longleftrightarrow> (\<exists>B\<in>A. x \<in> B)"
   1.220 +    by auto
   1.221 +  then show "x \<in> \<Union>A \<longleftrightarrow> x \<in> {x. \<exists>B\<in>A. x \<in> B}"
   1.222 +    by (simp add: Sup_set_eq [symmetric] Sup_fun_def Sup_bool_def) (simp add: mem_def)
   1.223 +qed
   1.224 +
   1.225 +lemma Union_iff [simp, noatp]:
   1.226 +  "A \<in> \<Union>C \<longleftrightarrow> (\<exists>X\<in>C. A\<in>X)"
   1.227 +  by (unfold Union_eq) blast
   1.228 +
   1.229 +lemma UnionI [intro]:
   1.230 +  "X \<in> C \<Longrightarrow> A \<in> X \<Longrightarrow> A \<in> \<Union>C"
   1.231 +  -- {* The order of the premises presupposes that @{term C} is rigid;
   1.232 +    @{term A} may be flexible. *}
   1.233 +  by auto
   1.234 +
   1.235 +lemma UnionE [elim!]:
   1.236 +  "A \<in> \<Union>C \<Longrightarrow> (\<And>X. A\<in>X \<Longrightarrow> X\<in>C \<Longrightarrow> R) \<Longrightarrow> R"
   1.237 +  by auto
   1.238 +
   1.239 +lemma Union_upper: "B \<in> A ==> B \<subseteq> Union A"
   1.240 +  by (iprover intro: subsetI UnionI)
   1.241 +
   1.242 +lemma Union_least: "(!!X. X \<in> A ==> X \<subseteq> C) ==> Union A \<subseteq> C"
   1.243 +  by (iprover intro: subsetI elim: UnionE dest: subsetD)
   1.244 +
   1.245 +lemma Un_eq_Union: "A \<union> B = \<Union>{A, B}"
   1.246 +  by blast
   1.247 +
   1.248 +lemma Union_empty [simp]: "Union({}) = {}"
   1.249 +  by blast
   1.250 +
   1.251 +lemma Union_UNIV [simp]: "Union UNIV = UNIV"
   1.252 +  by blast
   1.253 +
   1.254 +lemma Union_insert [simp]: "Union (insert a B) = a \<union> \<Union>B"
   1.255 +  by blast
   1.256 +
   1.257 +lemma Union_Un_distrib [simp]: "\<Union>(A Un B) = \<Union>A \<union> \<Union>B"
   1.258 +  by blast
   1.259 +
   1.260 +lemma Union_Int_subset: "\<Union>(A \<inter> B) \<subseteq> \<Union>A \<inter> \<Union>B"
   1.261 +  by blast
   1.262 +
   1.263 +lemma Union_empty_conv [simp,noatp]: "(\<Union>A = {}) = (\<forall>x\<in>A. x = {})"
   1.264 +  by blast
   1.265 +
   1.266 +lemma empty_Union_conv [simp,noatp]: "({} = \<Union>A) = (\<forall>x\<in>A. x = {})"
   1.267 +  by blast
   1.268 +
   1.269 +lemma Union_disjoint: "(\<Union>C \<inter> A = {}) = (\<forall>B\<in>C. B \<inter> A = {})"
   1.270 +  by blast
   1.271 +
   1.272 +lemma subset_Pow_Union: "A \<subseteq> Pow (\<Union>A)"
   1.273 +  by blast
   1.274 +
   1.275 +lemma Union_Pow_eq [simp]: "\<Union>(Pow A) = A"
   1.276 +  by blast
   1.277 +
   1.278 +lemma Union_mono: "A \<subseteq> B ==> \<Union>A \<subseteq> \<Union>B"
   1.279 +  by blast
   1.280 +
   1.281 +
   1.282 +subsection {* Unions of families *}
   1.283 +
   1.284 +definition UNION :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
   1.285 +  SUPR_set_eq [symmetric]: "UNION S f = (SUP x:S. f x)"
   1.286 +
   1.287 +syntax
   1.288 +  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3UN _./ _)" [0, 10] 10)
   1.289 +  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3UN _:_./ _)" [0, 10] 10)
   1.290 +
   1.291 +syntax (xsymbols)
   1.292 +  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>_./ _)" [0, 10] 10)
   1.293 +  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>_\<in>_./ _)" [0, 10] 10)
   1.294 +
   1.295 +syntax (latex output)
   1.296 +  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
   1.297 +  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 10] 10)
   1.298 +
   1.299 +translations
   1.300 +  "UN x y. B"   == "UN x. UN y. B"
   1.301 +  "UN x. B"     == "CONST UNION CONST UNIV (%x. B)"
   1.302 +  "UN x. B"     == "UN x:CONST UNIV. B"
   1.303 +  "UN x:A. B"   == "CONST UNION A (%x. B)"
   1.304 +
   1.305 +text {*
   1.306 +  Note the difference between ordinary xsymbol syntax of indexed
   1.307 +  unions and intersections (e.g.\ @{text"\<Union>a\<^isub>1\<in>A\<^isub>1. B"})
   1.308 +  and their \LaTeX\ rendition: @{term"\<Union>a\<^isub>1\<in>A\<^isub>1. B"}. The
   1.309 +  former does not make the index expression a subscript of the
   1.310 +  union/intersection symbol because this leads to problems with nested
   1.311 +  subscripts in Proof General.
   1.312 +*}
   1.313 +
   1.314 +print_translation {* [
   1.315 +Syntax.preserve_binder_abs2_tr' @{const_syntax UNION} "@UNION"
   1.316 +] *} -- {* to avoid eta-contraction of body *}
   1.317 +
   1.318 +lemma UNION_eq_Union_image:
   1.319 +  "(\<Union>x\<in>A. B x) = \<Union>(B`A)"
   1.320 +  by (simp add: SUPR_def SUPR_set_eq [symmetric] Sup_set_eq)
   1.321 +
   1.322 +lemma Union_def:
   1.323 +  "\<Union>S = (\<Union>x\<in>S. x)"
   1.324 +  by (simp add: UNION_eq_Union_image image_def)
   1.325 +
   1.326 +lemma UNION_def [noatp]:
   1.327 +  "(\<Union>x\<in>A. B x) = {y. \<exists>x\<in>A. y \<in> B x}"
   1.328 +  by (auto simp add: UNION_eq_Union_image Union_eq)
   1.329 +  
   1.330 +lemma Union_image_eq [simp]:
   1.331 +  "\<Union>(B`A) = (\<Union>x\<in>A. B x)"
   1.332 +  by (rule sym) (fact UNION_eq_Union_image)
   1.333 +  
   1.334 +lemma UN_iff [simp]: "(b: (UN x:A. B x)) = (EX x:A. b: B x)"
   1.335 +  by (unfold UNION_def) blast
   1.336 +
   1.337 +lemma UN_I [intro]: "a:A ==> b: B a ==> b: (UN x:A. B x)"
   1.338 +  -- {* The order of the premises presupposes that @{term A} is rigid;
   1.339 +    @{term b} may be flexible. *}
   1.340 +  by auto
   1.341 +
   1.342 +lemma UN_E [elim!]: "b : (UN x:A. B x) ==> (!!x. x:A ==> b: B x ==> R) ==> R"
   1.343 +  by (unfold UNION_def) blast
   1.344 +
   1.345 +lemma UN_cong [cong]:
   1.346 +    "A = B ==> (!!x. x:B ==> C x = D x) ==> (UN x:A. C x) = (UN x:B. D x)"
   1.347 +  by (simp add: UNION_def)
   1.348 +
   1.349 +lemma strong_UN_cong:
   1.350 +    "A = B ==> (!!x. x:B =simp=> C x = D x) ==> (UN x:A. C x) = (UN x:B. D x)"
   1.351 +  by (simp add: UNION_def simp_implies_def)
   1.352 +
   1.353 +lemma image_eq_UN: "f`A = (UN x:A. {f x})"
   1.354 +  by blast
   1.355 +
   1.356 +lemma UN_upper: "a \<in> A ==> B a \<subseteq> (\<Union>x\<in>A. B x)"
   1.357 +  by blast
   1.358 +
   1.359 +lemma UN_least: "(!!x. x \<in> A ==> B x \<subseteq> C) ==> (\<Union>x\<in>A. B x) \<subseteq> C"
   1.360 +  by (iprover intro: subsetI elim: UN_E dest: subsetD)
   1.361 +
   1.362 +lemma Collect_bex_eq [noatp]: "{x. \<exists>y\<in>A. P x y} = (\<Union>y\<in>A. {x. P x y})"
   1.363 +  by blast
   1.364 +
   1.365 +lemma UN_insert_distrib: "u \<in> A ==> (\<Union>x\<in>A. insert a (B x)) = insert a (\<Union>x\<in>A. B x)"
   1.366 +  by blast
   1.367 +
   1.368 +lemma UN_empty [simp,noatp]: "(\<Union>x\<in>{}. B x) = {}"
   1.369 +  by blast
   1.370 +
   1.371 +lemma UN_empty2 [simp]: "(\<Union>x\<in>A. {}) = {}"
   1.372 +  by blast
   1.373 +
   1.374 +lemma UN_singleton [simp]: "(\<Union>x\<in>A. {x}) = A"
   1.375 +  by blast
   1.376 +
   1.377 +lemma UN_absorb: "k \<in> I ==> A k \<union> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. A i)"
   1.378 +  by auto
   1.379 +
   1.380 +lemma UN_insert [simp]: "(\<Union>x\<in>insert a A. B x) = B a \<union> UNION A B"
   1.381 +  by blast
   1.382 +
   1.383 +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)"
   1.384 +  by blast
   1.385 +
   1.386 +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)"
   1.387 +  by blast
   1.388 +
   1.389 +lemma UN_subset_iff: "((\<Union>i\<in>I. A i) \<subseteq> B) = (\<forall>i\<in>I. A i \<subseteq> B)"
   1.390 +  by blast
   1.391 +
   1.392 +lemma image_Union: "f ` \<Union>S = (\<Union>x\<in>S. f ` x)"
   1.393 +  by blast
   1.394 +
   1.395 +lemma UN_constant [simp]: "(\<Union>y\<in>A. c) = (if A = {} then {} else c)"
   1.396 +  by auto
   1.397 +
   1.398 +lemma UN_eq: "(\<Union>x\<in>A. B x) = \<Union>({Y. \<exists>x\<in>A. Y = B x})"
   1.399 +  by blast
   1.400 +
   1.401 +lemma UNION_empty_conv[simp]:
   1.402 +  "({} = (UN x:A. B x)) = (\<forall>x\<in>A. B x = {})"
   1.403 +  "((UN x:A. B x) = {}) = (\<forall>x\<in>A. B x = {})"
   1.404 +by blast+
   1.405 +
   1.406 +lemma Collect_ex_eq [noatp]: "{x. \<exists>y. P x y} = (\<Union>y. {x. P x y})"
   1.407 +  by blast
   1.408 +
   1.409 +lemma ball_UN: "(\<forall>z \<in> UNION A B. P z) = (\<forall>x\<in>A. \<forall>z \<in> B x. P z)"
   1.410 +  by blast
   1.411 +
   1.412 +lemma bex_UN: "(\<exists>z \<in> UNION A B. P z) = (\<exists>x\<in>A. \<exists>z\<in>B x. P z)"
   1.413 +  by blast
   1.414 +
   1.415 +lemma Un_eq_UN: "A \<union> B = (\<Union>b. if b then A else B)"
   1.416 +  by (auto simp add: split_if_mem2)
   1.417 +
   1.418 +lemma UN_bool_eq: "(\<Union>b::bool. A b) = (A True \<union> A False)"
   1.419 +  by (auto intro: bool_contrapos)
   1.420 +
   1.421 +lemma UN_Pow_subset: "(\<Union>x\<in>A. Pow (B x)) \<subseteq> Pow (\<Union>x\<in>A. B x)"
   1.422 +  by blast
   1.423 +
   1.424 +lemma UN_mono:
   1.425 +  "A \<subseteq> B ==> (!!x. x \<in> A ==> f x \<subseteq> g x) ==>
   1.426 +    (\<Union>x\<in>A. f x) \<subseteq> (\<Union>x\<in>B. g x)"
   1.427 +  by (blast dest: subsetD)
   1.428 +
   1.429 +lemma vimage_Union: "f -` (Union A) = (UN X:A. f -` X)"
   1.430 +  by blast
   1.431 +
   1.432 +lemma vimage_UN: "f-`(UN x:A. B x) = (UN x:A. f -` B x)"
   1.433 +  by blast
   1.434 +
   1.435 +lemma vimage_eq_UN: "f-`B = (UN y: B. f-`{y})"
   1.436 +  -- {* NOT suitable for rewriting *}
   1.437 +  by blast
   1.438 +
   1.439 +lemma image_UN: "(f ` (UNION A B)) = (UN x:A.(f ` (B x)))"
   1.440 +by blast
   1.441 +
   1.442 +
   1.443 +subsection {* Inter *}
   1.444 +
   1.445 +definition Inter :: "'a set set \<Rightarrow> 'a set" where
   1.446 +  Inf_set_eq [symmetric]: "Inter S = \<Sqinter>S"
   1.447 +  
   1.448 +notation (xsymbols)
   1.449 +  Inter  ("\<Inter>_" [90] 90)
   1.450 +
   1.451 +lemma Inter_eq [code del]:
   1.452 +  "\<Inter>A = {x. \<forall>B \<in> A. x \<in> B}"
   1.453 +proof (rule set_ext)
   1.454 +  fix x
   1.455 +  have "(\<forall>Q\<in>{P. \<exists>B\<in>A. P \<longleftrightarrow> x \<in> B}. Q) \<longleftrightarrow> (\<forall>B\<in>A. x \<in> B)"
   1.456 +    by auto
   1.457 +  then show "x \<in> \<Inter>A \<longleftrightarrow> x \<in> {x. \<forall>B \<in> A. x \<in> B}"
   1.458 +    by (simp add: Inf_fun_def Inf_bool_def Inf_set_eq [symmetric]) (simp add: mem_def)
   1.459 +qed
   1.460 +
   1.461 +lemma Inter_iff [simp,noatp]: "(A : Inter C) = (ALL X:C. A:X)"
   1.462 +  by (unfold Inter_eq) blast
   1.463 +
   1.464 +lemma InterI [intro!]: "(!!X. X:C ==> A:X) ==> A : Inter C"
   1.465 +  by (simp add: Inter_eq)
   1.466 +
   1.467 +text {*
   1.468 +  \medskip A ``destruct'' rule -- every @{term X} in @{term C}
   1.469 +  contains @{term A} as an element, but @{prop "A:X"} can hold when
   1.470 +  @{prop "X:C"} does not!  This rule is analogous to @{text spec}.
   1.471 +*}
   1.472 +
   1.473 +lemma InterD [elim]: "A : Inter C ==> X:C ==> A:X"
   1.474 +  by auto
   1.475 +
   1.476 +lemma InterE [elim]: "A : Inter C ==> (X~:C ==> R) ==> (A:X ==> R) ==> R"
   1.477 +  -- {* ``Classical'' elimination rule -- does not require proving
   1.478 +    @{prop "X:C"}. *}
   1.479 +  by (unfold Inter_eq) blast
   1.480 +
   1.481 +lemma Inter_lower: "B \<in> A ==> Inter A \<subseteq> B"
   1.482 +  by blast
   1.483 +
   1.484 +lemma Inter_subset:
   1.485 +  "[| !!X. X \<in> A ==> X \<subseteq> B; A ~= {} |] ==> \<Inter>A \<subseteq> B"
   1.486 +  by blast
   1.487 +
   1.488 +lemma Inter_greatest: "(!!X. X \<in> A ==> C \<subseteq> X) ==> C \<subseteq> Inter A"
   1.489 +  by (iprover intro: InterI subsetI dest: subsetD)
   1.490 +
   1.491 +lemma Int_eq_Inter: "A \<inter> B = \<Inter>{A, B}"
   1.492 +  by blast
   1.493 +
   1.494 +lemma Inter_empty [simp]: "\<Inter>{} = UNIV"
   1.495 +  by blast
   1.496 +
   1.497 +lemma Inter_UNIV [simp]: "\<Inter>UNIV = {}"
   1.498 +  by blast
   1.499 +
   1.500 +lemma Inter_insert [simp]: "\<Inter>(insert a B) = a \<inter> \<Inter>B"
   1.501 +  by blast
   1.502 +
   1.503 +lemma Inter_Un_subset: "\<Inter>A \<union> \<Inter>B \<subseteq> \<Inter>(A \<inter> B)"
   1.504 +  by blast
   1.505 +
   1.506 +lemma Inter_Un_distrib: "\<Inter>(A \<union> B) = \<Inter>A \<inter> \<Inter>B"
   1.507 +  by blast
   1.508 +
   1.509 +lemma Inter_UNIV_conv [simp,noatp]:
   1.510 +  "(\<Inter>A = UNIV) = (\<forall>x\<in>A. x = UNIV)"
   1.511 +  "(UNIV = \<Inter>A) = (\<forall>x\<in>A. x = UNIV)"
   1.512 +  by blast+
   1.513 +
   1.514 +lemma Inter_anti_mono: "B \<subseteq> A ==> \<Inter>A \<subseteq> \<Inter>B"
   1.515 +  by blast
   1.516 +
   1.517 +
   1.518 +subsection {* Intersections of families *}
   1.519 +
   1.520 +definition INTER :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
   1.521 +  INFI_set_eq [symmetric]: "INTER S f = (INF x:S. f x)"
   1.522 +
   1.523 +syntax
   1.524 +  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3INT _./ _)" [0, 10] 10)
   1.525 +  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3INT _:_./ _)" [0, 10] 10)
   1.526 +
   1.527 +syntax (xsymbols)
   1.528 +  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>_./ _)" [0, 10] 10)
   1.529 +  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>_\<in>_./ _)" [0, 10] 10)
   1.530 +
   1.531 +syntax (latex output)
   1.532 +  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
   1.533 +  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 10] 10)
   1.534 +
   1.535 +translations
   1.536 +  "INT x y. B"  == "INT x. INT y. B"
   1.537 +  "INT x. B"    == "CONST INTER CONST UNIV (%x. B)"
   1.538 +  "INT x. B"    == "INT x:CONST UNIV. B"
   1.539 +  "INT x:A. B"  == "CONST INTER A (%x. B)"
   1.540 +
   1.541 +print_translation {* [
   1.542 +Syntax.preserve_binder_abs2_tr' @{const_syntax INTER} "@INTER"
   1.543 +] *} -- {* to avoid eta-contraction of body *}
   1.544 +
   1.545 +lemma INTER_eq_Inter_image:
   1.546 +  "(\<Inter>x\<in>A. B x) = \<Inter>(B`A)"
   1.547 +  by (simp add: INFI_def INFI_set_eq [symmetric] Inf_set_eq)
   1.548 +  
   1.549 +lemma Inter_def:
   1.550 +  "\<Inter>S = (\<Inter>x\<in>S. x)"
   1.551 +  by (simp add: INTER_eq_Inter_image image_def)
   1.552 +
   1.553 +lemma INTER_def:
   1.554 +  "(\<Inter>x\<in>A. B x) = {y. \<forall>x\<in>A. y \<in> B x}"
   1.555 +  by (auto simp add: INTER_eq_Inter_image Inter_eq)
   1.556 +
   1.557 +lemma Inter_image_eq [simp]:
   1.558 +  "\<Inter>(B`A) = (\<Inter>x\<in>A. B x)"
   1.559 +  by (rule sym) (fact INTER_eq_Inter_image)
   1.560 +
   1.561 +lemma INT_iff [simp]: "(b: (INT x:A. B x)) = (ALL x:A. b: B x)"
   1.562 +  by (unfold INTER_def) blast
   1.563 +
   1.564 +lemma INT_I [intro!]: "(!!x. x:A ==> b: B x) ==> b : (INT x:A. B x)"
   1.565 +  by (unfold INTER_def) blast
   1.566 +
   1.567 +lemma INT_D [elim]: "b : (INT x:A. B x) ==> a:A ==> b: B a"
   1.568 +  by auto
   1.569 +
   1.570 +lemma INT_E [elim]: "b : (INT x:A. B x) ==> (b: B a ==> R) ==> (a~:A ==> R) ==> R"
   1.571 +  -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a:A"}. *}
   1.572 +  by (unfold INTER_def) blast
   1.573 +
   1.574 +lemma INT_cong [cong]:
   1.575 +    "A = B ==> (!!x. x:B ==> C x = D x) ==> (INT x:A. C x) = (INT x:B. D x)"
   1.576 +  by (simp add: INTER_def)
   1.577 +
   1.578 +lemma Collect_ball_eq: "{x. \<forall>y\<in>A. P x y} = (\<Inter>y\<in>A. {x. P x y})"
   1.579 +  by blast
   1.580 +
   1.581 +lemma Collect_all_eq: "{x. \<forall>y. P x y} = (\<Inter>y. {x. P x y})"
   1.582 +  by blast
   1.583 +
   1.584 +lemma INT_lower: "a \<in> A ==> (\<Inter>x\<in>A. B x) \<subseteq> B a"
   1.585 +  by blast
   1.586 +
   1.587 +lemma INT_greatest: "(!!x. x \<in> A ==> C \<subseteq> B x) ==> C \<subseteq> (\<Inter>x\<in>A. B x)"
   1.588 +  by (iprover intro: INT_I subsetI dest: subsetD)
   1.589 +
   1.590 +lemma INT_empty [simp]: "(\<Inter>x\<in>{}. B x) = UNIV"
   1.591 +  by blast
   1.592 +
   1.593 +lemma INT_absorb: "k \<in> I ==> A k \<inter> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. A i)"
   1.594 +  by blast
   1.595 +
   1.596 +lemma INT_subset_iff: "(B \<subseteq> (\<Inter>i\<in>I. A i)) = (\<forall>i\<in>I. B \<subseteq> A i)"
   1.597 +  by blast
   1.598 +
   1.599 +lemma INT_insert [simp]: "(\<Inter>x \<in> insert a A. B x) = B a \<inter> INTER A B"
   1.600 +  by blast
   1.601 +
   1.602 +lemma INT_Un: "(\<Inter>i \<in> A \<union> B. M i) = (\<Inter>i \<in> A. M i) \<inter> (\<Inter>i\<in>B. M i)"
   1.603 +  by blast
   1.604 +
   1.605 +lemma INT_insert_distrib:
   1.606 +    "u \<in> A ==> (\<Inter>x\<in>A. insert a (B x)) = insert a (\<Inter>x\<in>A. B x)"
   1.607 +  by blast
   1.608 +
   1.609 +lemma INT_constant [simp]: "(\<Inter>y\<in>A. c) = (if A = {} then UNIV else c)"
   1.610 +  by auto
   1.611 +
   1.612 +lemma INT_eq: "(\<Inter>x\<in>A. B x) = \<Inter>({Y. \<exists>x\<in>A. Y = B x})"
   1.613 +  -- {* Look: it has an \emph{existential} quantifier *}
   1.614 +  by blast
   1.615 +
   1.616 +lemma INTER_UNIV_conv[simp]:
   1.617 + "(UNIV = (INT x:A. B x)) = (\<forall>x\<in>A. B x = UNIV)"
   1.618 + "((INT x:A. B x) = UNIV) = (\<forall>x\<in>A. B x = UNIV)"
   1.619 +by blast+
   1.620 +
   1.621 +lemma INT_bool_eq: "(\<Inter>b::bool. A b) = (A True \<inter> A False)"
   1.622 +  by (auto intro: bool_induct)
   1.623 +
   1.624 +lemma Pow_INT_eq: "Pow (\<Inter>x\<in>A. B x) = (\<Inter>x\<in>A. Pow (B x))"
   1.625 +  by blast
   1.626 +
   1.627 +lemma INT_anti_mono:
   1.628 +  "B \<subseteq> A ==> (!!x. x \<in> A ==> f x \<subseteq> g x) ==>
   1.629 +    (\<Inter>x\<in>A. f x) \<subseteq> (\<Inter>x\<in>A. g x)"
   1.630 +  -- {* The last inclusion is POSITIVE! *}
   1.631 +  by (blast dest: subsetD)
   1.632 +
   1.633 +lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)"
   1.634 +  by blast
   1.635 +
   1.636 +
   1.637 +subsection {* Distributive laws *}
   1.638 +
   1.639 +lemma Int_Union: "A \<inter> \<Union>B = (\<Union>C\<in>B. A \<inter> C)"
   1.640 +  by blast
   1.641 +
   1.642 +lemma Int_Union2: "\<Union>B \<inter> A = (\<Union>C\<in>B. C \<inter> A)"
   1.643 +  by blast
   1.644 +
   1.645 +lemma Un_Union_image: "(\<Union>x\<in>C. A x \<union> B x) = \<Union>(A`C) \<union> \<Union>(B`C)"
   1.646 +  -- {* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: *}
   1.647 +  -- {* Union of a family of unions *}
   1.648 +  by blast
   1.649 +
   1.650 +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)"
   1.651 +  -- {* Equivalent version *}
   1.652 +  by blast
   1.653 +
   1.654 +lemma Un_Inter: "A \<union> \<Inter>B = (\<Inter>C\<in>B. A \<union> C)"
   1.655 +  by blast
   1.656 +
   1.657 +lemma Int_Inter_image: "(\<Inter>x\<in>C. A x \<inter> B x) = \<Inter>(A`C) \<inter> \<Inter>(B`C)"
   1.658 +  by blast
   1.659 +
   1.660 +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)"
   1.661 +  -- {* Equivalent version *}
   1.662 +  by blast
   1.663 +
   1.664 +lemma Int_UN_distrib: "B \<inter> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. B \<inter> A i)"
   1.665 +  -- {* Halmos, Naive Set Theory, page 35. *}
   1.666 +  by blast
   1.667 +
   1.668 +lemma Un_INT_distrib: "B \<union> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. B \<union> A i)"
   1.669 +  by blast
   1.670 +
   1.671 +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)"
   1.672 +  by blast
   1.673 +
   1.674 +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)"
   1.675 +  by blast
   1.676 +
   1.677 +
   1.678 +subsection {* Complement *}
   1.679 +
   1.680 +lemma Compl_UN [simp]: "-(\<Union>x\<in>A. B x) = (\<Inter>x\<in>A. -B x)"
   1.681 +  by blast
   1.682 +
   1.683 +lemma Compl_INT [simp]: "-(\<Inter>x\<in>A. B x) = (\<Union>x\<in>A. -B x)"
   1.684 +  by blast
   1.685 +
   1.686 +
   1.687 +subsection {* Miniscoping and maxiscoping *}
   1.688 +
   1.689 +text {* \medskip Miniscoping: pushing in quantifiers and big Unions
   1.690 +           and Intersections. *}
   1.691 +
   1.692 +lemma UN_simps [simp]:
   1.693 +  "!!a B C. (UN x:C. insert a (B x)) = (if C={} then {} else insert a (UN x:C. B x))"
   1.694 +  "!!A B C. (UN x:C. A x Un B)   = ((if C={} then {} else (UN x:C. A x) Un B))"
   1.695 +  "!!A B C. (UN x:C. A Un B x)   = ((if C={} then {} else A Un (UN x:C. B x)))"
   1.696 +  "!!A B C. (UN x:C. A x Int B)  = ((UN x:C. A x) Int B)"
   1.697 +  "!!A B C. (UN x:C. A Int B x)  = (A Int (UN x:C. B x))"
   1.698 +  "!!A B C. (UN x:C. A x - B)    = ((UN x:C. A x) - B)"
   1.699 +  "!!A B C. (UN x:C. A - B x)    = (A - (INT x:C. B x))"
   1.700 +  "!!A B. (UN x: Union A. B x) = (UN y:A. UN x:y. B x)"
   1.701 +  "!!A B C. (UN z: UNION A B. C z) = (UN  x:A. UN z: B(x). C z)"
   1.702 +  "!!A B f. (UN x:f`A. B x)     = (UN a:A. B (f a))"
   1.703 +  by auto
   1.704 +
   1.705 +lemma INT_simps [simp]:
   1.706 +  "!!A B C. (INT x:C. A x Int B) = (if C={} then UNIV else (INT x:C. A x) Int B)"
   1.707 +  "!!A B C. (INT x:C. A Int B x) = (if C={} then UNIV else A Int (INT x:C. B x))"
   1.708 +  "!!A B C. (INT x:C. A x - B)   = (if C={} then UNIV else (INT x:C. A x) - B)"
   1.709 +  "!!A B C. (INT x:C. A - B x)   = (if C={} then UNIV else A - (UN x:C. B x))"
   1.710 +  "!!a B C. (INT x:C. insert a (B x)) = insert a (INT x:C. B x)"
   1.711 +  "!!A B C. (INT x:C. A x Un B)  = ((INT x:C. A x) Un B)"
   1.712 +  "!!A B C. (INT x:C. A Un B x)  = (A Un (INT x:C. B x))"
   1.713 +  "!!A B. (INT x: Union A. B x) = (INT y:A. INT x:y. B x)"
   1.714 +  "!!A B C. (INT z: UNION A B. C z) = (INT x:A. INT z: B(x). C z)"
   1.715 +  "!!A B f. (INT x:f`A. B x)    = (INT a:A. B (f a))"
   1.716 +  by auto
   1.717 +
   1.718 +lemma ball_simps [simp,noatp]:
   1.719 +  "!!A P Q. (ALL x:A. P x | Q) = ((ALL x:A. P x) | Q)"
   1.720 +  "!!A P Q. (ALL x:A. P | Q x) = (P | (ALL x:A. Q x))"
   1.721 +  "!!A P Q. (ALL x:A. P --> Q x) = (P --> (ALL x:A. Q x))"
   1.722 +  "!!A P Q. (ALL x:A. P x --> Q) = ((EX x:A. P x) --> Q)"
   1.723 +  "!!P. (ALL x:{}. P x) = True"
   1.724 +  "!!P. (ALL x:UNIV. P x) = (ALL x. P x)"
   1.725 +  "!!a B P. (ALL x:insert a B. P x) = (P a & (ALL x:B. P x))"
   1.726 +  "!!A P. (ALL x:Union A. P x) = (ALL y:A. ALL x:y. P x)"
   1.727 +  "!!A B P. (ALL x: UNION A B. P x) = (ALL a:A. ALL x: B a. P x)"
   1.728 +  "!!P Q. (ALL x:Collect Q. P x) = (ALL x. Q x --> P x)"
   1.729 +  "!!A P f. (ALL x:f`A. P x) = (ALL x:A. P (f x))"
   1.730 +  "!!A P. (~(ALL x:A. P x)) = (EX x:A. ~P x)"
   1.731 +  by auto
   1.732 +
   1.733 +lemma bex_simps [simp,noatp]:
   1.734 +  "!!A P Q. (EX x:A. P x & Q) = ((EX x:A. P x) & Q)"
   1.735 +  "!!A P Q. (EX x:A. P & Q x) = (P & (EX x:A. Q x))"
   1.736 +  "!!P. (EX x:{}. P x) = False"
   1.737 +  "!!P. (EX x:UNIV. P x) = (EX x. P x)"
   1.738 +  "!!a B P. (EX x:insert a B. P x) = (P(a) | (EX x:B. P x))"
   1.739 +  "!!A P. (EX x:Union A. P x) = (EX y:A. EX x:y. P x)"
   1.740 +  "!!A B P. (EX x: UNION A B. P x) = (EX a:A. EX x:B a. P x)"
   1.741 +  "!!P Q. (EX x:Collect Q. P x) = (EX x. Q x & P x)"
   1.742 +  "!!A P f. (EX x:f`A. P x) = (EX x:A. P (f x))"
   1.743 +  "!!A P. (~(EX x:A. P x)) = (ALL x:A. ~P x)"
   1.744 +  by auto
   1.745 +
   1.746 +lemma ball_conj_distrib:
   1.747 +  "(ALL x:A. P x & Q x) = ((ALL x:A. P x) & (ALL x:A. Q x))"
   1.748 +  by blast
   1.749 +
   1.750 +lemma bex_disj_distrib:
   1.751 +  "(EX x:A. P x | Q x) = ((EX x:A. P x) | (EX x:A. Q x))"
   1.752 +  by blast
   1.753 +
   1.754 +
   1.755 +text {* \medskip Maxiscoping: pulling out big Unions and Intersections. *}
   1.756 +
   1.757 +lemma UN_extend_simps:
   1.758 +  "!!a B C. insert a (UN x:C. B x) = (if C={} then {a} else (UN x:C. insert a (B x)))"
   1.759 +  "!!A B C. (UN x:C. A x) Un B    = (if C={} then B else (UN x:C. A x Un B))"
   1.760 +  "!!A B C. A Un (UN x:C. B x)   = (if C={} then A else (UN x:C. A Un B x))"
   1.761 +  "!!A B C. ((UN x:C. A x) Int B) = (UN x:C. A x Int B)"
   1.762 +  "!!A B C. (A Int (UN x:C. B x)) = (UN x:C. A Int B x)"
   1.763 +  "!!A B C. ((UN x:C. A x) - B) = (UN x:C. A x - B)"
   1.764 +  "!!A B C. (A - (INT x:C. B x)) = (UN x:C. A - B x)"
   1.765 +  "!!A B. (UN y:A. UN x:y. B x) = (UN x: Union A. B x)"
   1.766 +  "!!A B C. (UN  x:A. UN z: B(x). C z) = (UN z: UNION A B. C z)"
   1.767 +  "!!A B f. (UN a:A. B (f a)) = (UN x:f`A. B x)"
   1.768 +  by auto
   1.769 +
   1.770 +lemma INT_extend_simps:
   1.771 +  "!!A B C. (INT x:C. A x) Int B = (if C={} then B else (INT x:C. A x Int B))"
   1.772 +  "!!A B C. A Int (INT x:C. B x) = (if C={} then A else (INT x:C. A Int B x))"
   1.773 +  "!!A B C. (INT x:C. A x) - B   = (if C={} then UNIV-B else (INT x:C. A x - B))"
   1.774 +  "!!A B C. A - (UN x:C. B x)   = (if C={} then A else (INT x:C. A - B x))"
   1.775 +  "!!a B C. insert a (INT x:C. B x) = (INT x:C. insert a (B x))"
   1.776 +  "!!A B C. ((INT x:C. A x) Un B)  = (INT x:C. A x Un B)"
   1.777 +  "!!A B C. A Un (INT x:C. B x)  = (INT x:C. A Un B x)"
   1.778 +  "!!A B. (INT y:A. INT x:y. B x) = (INT x: Union A. B x)"
   1.779 +  "!!A B C. (INT x:A. INT z: B(x). C z) = (INT z: UNION A B. C z)"
   1.780 +  "!!A B f. (INT a:A. B (f a))    = (INT x:f`A. B x)"
   1.781 +  by auto
   1.782 +
   1.783 +
   1.784 +no_notation
   1.785 +  less_eq  (infix "\<sqsubseteq>" 50) and
   1.786 +  less (infix "\<sqsubset>" 50) and
   1.787 +  inf  (infixl "\<sqinter>" 70) and
   1.788 +  sup  (infixl "\<squnion>" 65) and
   1.789 +  Inf  ("\<Sqinter>_" [900] 900) and
   1.790 +  Sup  ("\<Squnion>_" [900] 900)
   1.791 +
   1.792 +lemmas mem_simps =
   1.793 +  insert_iff empty_iff Un_iff Int_iff Compl_iff Diff_iff
   1.794 +  mem_Collect_eq UN_iff Union_iff INT_iff Inter_iff
   1.795 +  -- {* Each of these has ALREADY been added @{text "[simp]"} above. *}
   1.796 +
   1.797 +end