moved complete_lattice &c. into separate theory
authorhaftmann
Wed Jul 22 18:02:10 2009 +0200 (2009-07-22)
changeset 32139e271a64f03ff
parent 32136 672dfd59ff03
child 32140 228905e02350
moved complete_lattice &c. into separate theory
src/HOL/Complete_Lattice.thy
src/HOL/Fun.thy
src/HOL/HoareParallel/OG_Hoare.thy
src/HOL/IsaMakefile
src/HOL/Library/Executable_Set.thy
src/HOL/Library/Fset.thy
src/HOL/Library/Lattice_Syntax.thy
src/HOL/Set.thy
src/HOL/UNITY/Comp/Alloc.thy
src/HOL/UNITY/ProgressSets.thy
     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
     2.1 --- a/src/HOL/Fun.thy	Wed Jul 22 14:21:52 2009 +0200
     2.2 +++ b/src/HOL/Fun.thy	Wed Jul 22 18:02:10 2009 +0200
     2.3 @@ -6,7 +6,7 @@
     2.4  header {* Notions about functions *}
     2.5  
     2.6  theory Fun
     2.7 -imports Set
     2.8 +imports Complete_Lattice
     2.9  begin
    2.10  
    2.11  text{*As a simplification rule, it replaces all function equalities by
     3.1 --- a/src/HOL/HoareParallel/OG_Hoare.thy	Wed Jul 22 14:21:52 2009 +0200
     3.2 +++ b/src/HOL/HoareParallel/OG_Hoare.thy	Wed Jul 22 18:02:10 2009 +0200
     3.3 @@ -441,7 +441,7 @@
     3.4        apply clarify
     3.5        apply(frule Parallel_length_post_PStar)
     3.6        apply clarify
     3.7 -      apply(drule_tac j=xa in Parallel_Strong_Soundness)
     3.8 +      apply(drule_tac j=xb in Parallel_Strong_Soundness)
     3.9           apply clarify
    3.10          apply simp
    3.11         apply force
     4.1 --- a/src/HOL/IsaMakefile	Wed Jul 22 14:21:52 2009 +0200
     4.2 +++ b/src/HOL/IsaMakefile	Wed Jul 22 18:02:10 2009 +0200
     4.3 @@ -117,6 +117,7 @@
     4.4  	@$(ISABELLE_TOOL) usedir -b -f base.ML -d false -g false $(OUT)/Pure HOL-Base
     4.5  
     4.6  PLAIN_DEPENDENCIES = $(BASE_DEPENDENCIES)\
     4.7 +  Complete_Lattice.thy \
     4.8    Datatype.thy \
     4.9    Divides.thy \
    4.10    Extraction.thy \
     5.1 --- a/src/HOL/Library/Executable_Set.thy	Wed Jul 22 14:21:52 2009 +0200
     5.2 +++ b/src/HOL/Library/Executable_Set.thy	Wed Jul 22 18:02:10 2009 +0200
     5.3 @@ -75,8 +75,8 @@
     5.4    "op \<union>"              ("{*Fset.union*}")
     5.5    "op \<inter>"              ("{*Fset.inter*}")
     5.6    "op - \<Colon> 'a set \<Rightarrow> 'a set \<Rightarrow> 'a set" ("{*flip Fset.subtract*}")
     5.7 -  "Set.Union"         ("{*Fset.Union*}")
     5.8 -  "Set.Inter"         ("{*Fset.Inter*}")
     5.9 +  "Complete_Lattice.Union" ("{*Fset.Union*}")
    5.10 +  "Complete_Lattice.Inter" ("{*Fset.Inter*}")
    5.11    card                ("{*Fset.card*}")
    5.12    fold                ("{*foldl o flip*}")
    5.13  
     6.1 --- a/src/HOL/Library/Fset.thy	Wed Jul 22 14:21:52 2009 +0200
     6.2 +++ b/src/HOL/Library/Fset.thy	Wed Jul 22 18:02:10 2009 +0200
     6.3 @@ -160,7 +160,7 @@
     6.4  qed
     6.5  
     6.6  definition Inter :: "'a fset fset \<Rightarrow> 'a fset" where
     6.7 -  [simp]: "Inter A = Fset (Set.Inter (member ` member A))"
     6.8 +  [simp]: "Inter A = Fset (Complete_Lattice.Inter (member ` member A))"
     6.9  
    6.10  lemma Inter_inter [code]:
    6.11    "Inter (Set (A # As)) = foldl inter A As"
    6.12 @@ -174,7 +174,7 @@
    6.13  qed
    6.14  
    6.15  definition Union :: "'a fset fset \<Rightarrow> 'a fset" where
    6.16 -  [simp]: "Union A = Fset (Set.Union (member ` member A))"
    6.17 +  [simp]: "Union A = Fset (Complete_Lattice.Union (member ` member A))"
    6.18  
    6.19  lemma Union_union [code]:
    6.20    "Union (Set As) = foldl union empty As"
     7.1 --- a/src/HOL/Library/Lattice_Syntax.thy	Wed Jul 22 14:21:52 2009 +0200
     7.2 +++ b/src/HOL/Library/Lattice_Syntax.thy	Wed Jul 22 18:02:10 2009 +0200
     7.3 @@ -4,16 +4,16 @@
     7.4  
     7.5  (*<*)
     7.6  theory Lattice_Syntax
     7.7 -imports Set
     7.8 +imports Complete_Lattice
     7.9  begin
    7.10  
    7.11  notation
    7.12 +  top ("\<top>") and
    7.13 +  bot ("\<bottom>") and
    7.14    inf  (infixl "\<sqinter>" 70) and
    7.15    sup  (infixl "\<squnion>" 65) and
    7.16    Inf  ("\<Sqinter>_" [900] 900) and
    7.17 -  Sup  ("\<Squnion>_" [900] 900) and
    7.18 -  top ("\<top>") and
    7.19 -  bot ("\<bottom>")
    7.20 +  Sup  ("\<Squnion>_" [900] 900)
    7.21  
    7.22  end
    7.23  (*>*)
    7.24 \ No newline at end of file
     8.1 --- a/src/HOL/Set.thy	Wed Jul 22 14:21:52 2009 +0200
     8.2 +++ b/src/HOL/Set.thy	Wed Jul 22 18:02:10 2009 +0200
     8.3 @@ -1,6 +1,4 @@
     8.4 -(*  Title:      HOL/Set.thy
     8.5 -    Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel
     8.6 -*)
     8.7 +(*  Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel *)
     8.8  
     8.9  header {* Set theory for higher-order logic *}
    8.10  
    8.11 @@ -1733,789 +1731,4 @@
    8.12  val vimage_Un = @{thm vimage_Un}
    8.13  *}
    8.14  
    8.15 -
    8.16 -subsection {* Complete lattices *}
    8.17 -
    8.18 -notation
    8.19 -  less_eq  (infix "\<sqsubseteq>" 50) and
    8.20 -  less (infix "\<sqsubset>" 50) and
    8.21 -  inf  (infixl "\<sqinter>" 70) and
    8.22 -  sup  (infixl "\<squnion>" 65)
    8.23 -
    8.24 -class complete_lattice = lattice + bot + top +
    8.25 -  fixes Inf :: "'a set \<Rightarrow> 'a" ("\<Sqinter>_" [900] 900)
    8.26 -    and Sup :: "'a set \<Rightarrow> 'a" ("\<Squnion>_" [900] 900)
    8.27 -  assumes Inf_lower: "x \<in> A \<Longrightarrow> \<Sqinter>A \<sqsubseteq> x"
    8.28 -     and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A"
    8.29 -  assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A"
    8.30 -     and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z"
    8.31 -begin
    8.32 -
    8.33 -lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<le> a}"
    8.34 -  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
    8.35 -
    8.36 -lemma Sup_Inf:  "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<le> b}"
    8.37 -  by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
    8.38 -
    8.39 -lemma Inf_Univ: "\<Sqinter>UNIV = \<Squnion>{}"
    8.40 -  unfolding Sup_Inf by auto
    8.41 -
    8.42 -lemma Sup_Univ: "\<Squnion>UNIV = \<Sqinter>{}"
    8.43 -  unfolding Inf_Sup by auto
    8.44 -
    8.45 -lemma Inf_insert: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A"
    8.46 -  by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower)
    8.47 -
    8.48 -lemma Sup_insert: "\<Squnion>insert a A = a \<squnion> \<Squnion>A"
    8.49 -  by (auto intro: le_supI le_supI1 le_supI2 antisym Sup_least Sup_upper)
    8.50 -
    8.51 -lemma Inf_singleton [simp]:
    8.52 -  "\<Sqinter>{a} = a"
    8.53 -  by (auto intro: antisym Inf_lower Inf_greatest)
    8.54 -
    8.55 -lemma Sup_singleton [simp]:
    8.56 -  "\<Squnion>{a} = a"
    8.57 -  by (auto intro: antisym Sup_upper Sup_least)
    8.58 -
    8.59 -lemma Inf_insert_simp:
    8.60 -  "\<Sqinter>insert a A = (if A = {} then a else a \<sqinter> \<Sqinter>A)"
    8.61 -  by (cases "A = {}") (simp_all, simp add: Inf_insert)
    8.62 -
    8.63 -lemma Sup_insert_simp:
    8.64 -  "\<Squnion>insert a A = (if A = {} then a else a \<squnion> \<Squnion>A)"
    8.65 -  by (cases "A = {}") (simp_all, simp add: Sup_insert)
    8.66 -
    8.67 -lemma Inf_binary:
    8.68 -  "\<Sqinter>{a, b} = a \<sqinter> b"
    8.69 -  by (auto simp add: Inf_insert_simp)
    8.70 -
    8.71 -lemma Sup_binary:
    8.72 -  "\<Squnion>{a, b} = a \<squnion> b"
    8.73 -  by (auto simp add: Sup_insert_simp)
    8.74 -
    8.75 -lemma bot_def:
    8.76 -  "bot = \<Squnion>{}"
    8.77 -  by (auto intro: antisym Sup_least)
    8.78 -
    8.79 -lemma top_def:
    8.80 -  "top = \<Sqinter>{}"
    8.81 -  by (auto intro: antisym Inf_greatest)
    8.82 -
    8.83 -lemma sup_bot [simp]:
    8.84 -  "x \<squnion> bot = x"
    8.85 -  using bot_least [of x] by (simp add: le_iff_sup sup_commute)
    8.86 -
    8.87 -lemma inf_top [simp]:
    8.88 -  "x \<sqinter> top = x"
    8.89 -  using top_greatest [of x] by (simp add: le_iff_inf inf_commute)
    8.90 -
    8.91 -definition SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
    8.92 -  "SUPR A f = \<Squnion> (f ` A)"
    8.93 -
    8.94 -definition INFI :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a" where
    8.95 -  "INFI A f = \<Sqinter> (f ` A)"
    8.96 -
    8.97  end
    8.98 -
    8.99 -syntax
   8.100 -  "_SUP1"     :: "pttrns => 'b => 'b"           ("(3SUP _./ _)" [0, 10] 10)
   8.101 -  "_SUP"      :: "pttrn => 'a set => 'b => 'b"  ("(3SUP _:_./ _)" [0, 10] 10)
   8.102 -  "_INF1"     :: "pttrns => 'b => 'b"           ("(3INF _./ _)" [0, 10] 10)
   8.103 -  "_INF"      :: "pttrn => 'a set => 'b => 'b"  ("(3INF _:_./ _)" [0, 10] 10)
   8.104 -
   8.105 -translations
   8.106 -  "SUP x y. B"   == "SUP x. SUP y. B"
   8.107 -  "SUP x. B"     == "CONST SUPR CONST UNIV (%x. B)"
   8.108 -  "SUP x. B"     == "SUP x:CONST UNIV. B"
   8.109 -  "SUP x:A. B"   == "CONST SUPR A (%x. B)"
   8.110 -  "INF x y. B"   == "INF x. INF y. B"
   8.111 -  "INF x. B"     == "CONST INFI CONST UNIV (%x. B)"
   8.112 -  "INF x. B"     == "INF x:CONST UNIV. B"
   8.113 -  "INF x:A. B"   == "CONST INFI A (%x. B)"
   8.114 -
   8.115 -print_translation {* [
   8.116 -Syntax.preserve_binder_abs2_tr' @{const_syntax SUPR} "_SUP",
   8.117 -Syntax.preserve_binder_abs2_tr' @{const_syntax INFI} "_INF"
   8.118 -] *} -- {* to avoid eta-contraction of body *}
   8.119 -
   8.120 -context complete_lattice
   8.121 -begin
   8.122 -
   8.123 -lemma le_SUPI: "i : A \<Longrightarrow> M i \<le> (SUP i:A. M i)"
   8.124 -  by (auto simp add: SUPR_def intro: Sup_upper)
   8.125 -
   8.126 -lemma SUP_leI: "(\<And>i. i : A \<Longrightarrow> M i \<le> u) \<Longrightarrow> (SUP i:A. M i) \<le> u"
   8.127 -  by (auto simp add: SUPR_def intro: Sup_least)
   8.128 -
   8.129 -lemma INF_leI: "i : A \<Longrightarrow> (INF i:A. M i) \<le> M i"
   8.130 -  by (auto simp add: INFI_def intro: Inf_lower)
   8.131 -
   8.132 -lemma le_INFI: "(\<And>i. i : A \<Longrightarrow> u \<le> M i) \<Longrightarrow> u \<le> (INF i:A. M i)"
   8.133 -  by (auto simp add: INFI_def intro: Inf_greatest)
   8.134 -
   8.135 -lemma SUP_const[simp]: "A \<noteq> {} \<Longrightarrow> (SUP i:A. M) = M"
   8.136 -  by (auto intro: antisym SUP_leI le_SUPI)
   8.137 -
   8.138 -lemma INF_const[simp]: "A \<noteq> {} \<Longrightarrow> (INF i:A. M) = M"
   8.139 -  by (auto intro: antisym INF_leI le_INFI)
   8.140 -
   8.141 -end
   8.142 -
   8.143 -
   8.144 -subsubsection {* @{typ bool} and @{typ "_ \<Rightarrow> _"} as complete lattice *}
   8.145 -
   8.146 -instantiation bool :: complete_lattice
   8.147 -begin
   8.148 -
   8.149 -definition
   8.150 -  Inf_bool_def: "\<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x)"
   8.151 -
   8.152 -definition
   8.153 -  Sup_bool_def: "\<Squnion>A \<longleftrightarrow> (\<exists>x\<in>A. x)"
   8.154 -
   8.155 -instance proof
   8.156 -qed (auto simp add: Inf_bool_def Sup_bool_def le_bool_def)
   8.157 -
   8.158 -end
   8.159 -
   8.160 -lemma Inf_empty_bool [simp]:
   8.161 -  "\<Sqinter>{}"
   8.162 -  unfolding Inf_bool_def by auto
   8.163 -
   8.164 -lemma not_Sup_empty_bool [simp]:
   8.165 -  "\<not> \<Squnion>{}"
   8.166 -  unfolding Sup_bool_def by auto
   8.167 -
   8.168 -lemma INFI_bool_eq:
   8.169 -  "INFI = Ball"
   8.170 -proof (rule ext)+
   8.171 -  fix A :: "'a set"
   8.172 -  fix P :: "'a \<Rightarrow> bool"
   8.173 -  show "(INF x:A. P x) \<longleftrightarrow> (\<forall>x \<in> A. P x)"
   8.174 -    by (auto simp add: Ball_def INFI_def Inf_bool_def)
   8.175 -qed
   8.176 -
   8.177 -lemma SUPR_bool_eq:
   8.178 -  "SUPR = Bex"
   8.179 -proof (rule ext)+
   8.180 -  fix A :: "'a set"
   8.181 -  fix P :: "'a \<Rightarrow> bool"
   8.182 -  show "(SUP x:A. P x) \<longleftrightarrow> (\<exists>x \<in> A. P x)"
   8.183 -    by (auto simp add: Bex_def SUPR_def Sup_bool_def)
   8.184 -qed
   8.185 -
   8.186 -instantiation "fun" :: (type, complete_lattice) complete_lattice
   8.187 -begin
   8.188 -
   8.189 -definition
   8.190 -  Inf_fun_def [code del]: "\<Sqinter>A = (\<lambda>x. \<Sqinter>{y. \<exists>f\<in>A. y = f x})"
   8.191 -
   8.192 -definition
   8.193 -  Sup_fun_def [code del]: "\<Squnion>A = (\<lambda>x. \<Squnion>{y. \<exists>f\<in>A. y = f x})"
   8.194 -
   8.195 -instance proof
   8.196 -qed (auto simp add: Inf_fun_def Sup_fun_def le_fun_def
   8.197 -  intro: Inf_lower Sup_upper Inf_greatest Sup_least)
   8.198 -
   8.199 -end
   8.200 -
   8.201 -lemma Inf_empty_fun:
   8.202 -  "\<Sqinter>{} = (\<lambda>_. \<Sqinter>{})"
   8.203 -  by (simp add: Inf_fun_def)
   8.204 -
   8.205 -lemma Sup_empty_fun:
   8.206 -  "\<Squnion>{} = (\<lambda>_. \<Squnion>{})"
   8.207 -  by (simp add: Sup_fun_def)
   8.208 -
   8.209 -
   8.210 -subsubsection {* Union *}
   8.211 -
   8.212 -definition Union :: "'a set set \<Rightarrow> 'a set" where
   8.213 -  Sup_set_eq [symmetric]: "Union S = \<Squnion>S"
   8.214 -
   8.215 -notation (xsymbols)
   8.216 -  Union  ("\<Union>_" [90] 90)
   8.217 -
   8.218 -lemma Union_eq:
   8.219 -  "\<Union>A = {x. \<exists>B \<in> A. x \<in> B}"
   8.220 -proof (rule set_ext)
   8.221 -  fix x
   8.222 -  have "(\<exists>Q\<in>{P. \<exists>B\<in>A. P \<longleftrightarrow> x \<in> B}. Q) \<longleftrightarrow> (\<exists>B\<in>A. x \<in> B)"
   8.223 -    by auto
   8.224 -  then show "x \<in> \<Union>A \<longleftrightarrow> x \<in> {x. \<exists>B\<in>A. x \<in> B}"
   8.225 -    by (simp add: Sup_set_eq [symmetric] Sup_fun_def Sup_bool_def) (simp add: mem_def)
   8.226 -qed
   8.227 -
   8.228 -lemma Union_iff [simp, noatp]:
   8.229 -  "A \<in> \<Union>C \<longleftrightarrow> (\<exists>X\<in>C. A\<in>X)"
   8.230 -  by (unfold Union_eq) blast
   8.231 -
   8.232 -lemma UnionI [intro]:
   8.233 -  "X \<in> C \<Longrightarrow> A \<in> X \<Longrightarrow> A \<in> \<Union>C"
   8.234 -  -- {* The order of the premises presupposes that @{term C} is rigid;
   8.235 -    @{term A} may be flexible. *}
   8.236 -  by auto
   8.237 -
   8.238 -lemma UnionE [elim!]:
   8.239 -  "A \<in> \<Union>C \<Longrightarrow> (\<And>X. A\<in>X \<Longrightarrow> X\<in>C \<Longrightarrow> R) \<Longrightarrow> R"
   8.240 -  by auto
   8.241 -
   8.242 -lemma Union_upper: "B \<in> A ==> B \<subseteq> Union A"
   8.243 -  by (iprover intro: subsetI UnionI)
   8.244 -
   8.245 -lemma Union_least: "(!!X. X \<in> A ==> X \<subseteq> C) ==> Union A \<subseteq> C"
   8.246 -  by (iprover intro: subsetI elim: UnionE dest: subsetD)
   8.247 -
   8.248 -lemma Un_eq_Union: "A \<union> B = \<Union>{A, B}"
   8.249 -  by blast
   8.250 -
   8.251 -lemma Union_empty [simp]: "Union({}) = {}"
   8.252 -  by blast
   8.253 -
   8.254 -lemma Union_UNIV [simp]: "Union UNIV = UNIV"
   8.255 -  by blast
   8.256 -
   8.257 -lemma Union_insert [simp]: "Union (insert a B) = a \<union> \<Union>B"
   8.258 -  by blast
   8.259 -
   8.260 -lemma Union_Un_distrib [simp]: "\<Union>(A Un B) = \<Union>A \<union> \<Union>B"
   8.261 -  by blast
   8.262 -
   8.263 -lemma Union_Int_subset: "\<Union>(A \<inter> B) \<subseteq> \<Union>A \<inter> \<Union>B"
   8.264 -  by blast
   8.265 -
   8.266 -lemma Union_empty_conv [simp,noatp]: "(\<Union>A = {}) = (\<forall>x\<in>A. x = {})"
   8.267 -  by blast
   8.268 -
   8.269 -lemma empty_Union_conv [simp,noatp]: "({} = \<Union>A) = (\<forall>x\<in>A. x = {})"
   8.270 -  by blast
   8.271 -
   8.272 -lemma Union_disjoint: "(\<Union>C \<inter> A = {}) = (\<forall>B\<in>C. B \<inter> A = {})"
   8.273 -  by blast
   8.274 -
   8.275 -lemma subset_Pow_Union: "A \<subseteq> Pow (\<Union>A)"
   8.276 -  by blast
   8.277 -
   8.278 -lemma Union_Pow_eq [simp]: "\<Union>(Pow A) = A"
   8.279 -  by blast
   8.280 -
   8.281 -lemma Union_mono: "A \<subseteq> B ==> \<Union>A \<subseteq> \<Union>B"
   8.282 -  by blast
   8.283 -
   8.284 -
   8.285 -subsubsection {* Unions of families *}
   8.286 -
   8.287 -definition UNION :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
   8.288 -  SUPR_set_eq [symmetric]: "UNION S f = (SUP x:S. f x)"
   8.289 -
   8.290 -syntax
   8.291 -  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3UN _./ _)" [0, 10] 10)
   8.292 -  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3UN _:_./ _)" [0, 10] 10)
   8.293 -
   8.294 -syntax (xsymbols)
   8.295 -  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>_./ _)" [0, 10] 10)
   8.296 -  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>_\<in>_./ _)" [0, 10] 10)
   8.297 -
   8.298 -syntax (latex output)
   8.299 -  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
   8.300 -  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 10] 10)
   8.301 -
   8.302 -translations
   8.303 -  "UN x y. B"   == "UN x. UN y. B"
   8.304 -  "UN x. B"     == "CONST UNION CONST UNIV (%x. B)"
   8.305 -  "UN x. B"     == "UN x:CONST UNIV. B"
   8.306 -  "UN x:A. B"   == "CONST UNION A (%x. B)"
   8.307 -
   8.308 -text {*
   8.309 -  Note the difference between ordinary xsymbol syntax of indexed
   8.310 -  unions and intersections (e.g.\ @{text"\<Union>a\<^isub>1\<in>A\<^isub>1. B"})
   8.311 -  and their \LaTeX\ rendition: @{term"\<Union>a\<^isub>1\<in>A\<^isub>1. B"}. The
   8.312 -  former does not make the index expression a subscript of the
   8.313 -  union/intersection symbol because this leads to problems with nested
   8.314 -  subscripts in Proof General.
   8.315 -*}
   8.316 -
   8.317 -print_translation {* [
   8.318 -Syntax.preserve_binder_abs2_tr' @{const_syntax UNION} "@UNION"
   8.319 -] *} -- {* to avoid eta-contraction of body *}
   8.320 -
   8.321 -lemma UNION_eq_Union_image:
   8.322 -  "(\<Union>x\<in>A. B x) = \<Union>(B`A)"
   8.323 -  by (simp add: SUPR_def SUPR_set_eq [symmetric] Sup_set_eq)
   8.324 -
   8.325 -lemma Union_def:
   8.326 -  "\<Union>S = (\<Union>x\<in>S. x)"
   8.327 -  by (simp add: UNION_eq_Union_image image_def)
   8.328 -
   8.329 -lemma UNION_def [noatp]:
   8.330 -  "(\<Union>x\<in>A. B x) = {y. \<exists>x\<in>A. y \<in> B x}"
   8.331 -  by (auto simp add: UNION_eq_Union_image Union_eq)
   8.332 -  
   8.333 -lemma Union_image_eq [simp]:
   8.334 -  "\<Union>(B`A) = (\<Union>x\<in>A. B x)"
   8.335 -  by (rule sym) (fact UNION_eq_Union_image)
   8.336 -  
   8.337 -lemma UN_iff [simp]: "(b: (UN x:A. B x)) = (EX x:A. b: B x)"
   8.338 -  by (unfold UNION_def) blast
   8.339 -
   8.340 -lemma UN_I [intro]: "a:A ==> b: B a ==> b: (UN x:A. B x)"
   8.341 -  -- {* The order of the premises presupposes that @{term A} is rigid;
   8.342 -    @{term b} may be flexible. *}
   8.343 -  by auto
   8.344 -
   8.345 -lemma UN_E [elim!]: "b : (UN x:A. B x) ==> (!!x. x:A ==> b: B x ==> R) ==> R"
   8.346 -  by (unfold UNION_def) blast
   8.347 -
   8.348 -lemma UN_cong [cong]:
   8.349 -    "A = B ==> (!!x. x:B ==> C x = D x) ==> (UN x:A. C x) = (UN x:B. D x)"
   8.350 -  by (simp add: UNION_def)
   8.351 -
   8.352 -lemma strong_UN_cong:
   8.353 -    "A = B ==> (!!x. x:B =simp=> C x = D x) ==> (UN x:A. C x) = (UN x:B. D x)"
   8.354 -  by (simp add: UNION_def simp_implies_def)
   8.355 -
   8.356 -lemma image_eq_UN: "f`A = (UN x:A. {f x})"
   8.357 -  by blast
   8.358 -
   8.359 -lemma UN_upper: "a \<in> A ==> B a \<subseteq> (\<Union>x\<in>A. B x)"
   8.360 -  by blast
   8.361 -
   8.362 -lemma UN_least: "(!!x. x \<in> A ==> B x \<subseteq> C) ==> (\<Union>x\<in>A. B x) \<subseteq> C"
   8.363 -  by (iprover intro: subsetI elim: UN_E dest: subsetD)
   8.364 -
   8.365 -lemma Collect_bex_eq [noatp]: "{x. \<exists>y\<in>A. P x y} = (\<Union>y\<in>A. {x. P x y})"
   8.366 -  by blast
   8.367 -
   8.368 -lemma UN_insert_distrib: "u \<in> A ==> (\<Union>x\<in>A. insert a (B x)) = insert a (\<Union>x\<in>A. B x)"
   8.369 -  by blast
   8.370 -
   8.371 -lemma UN_empty [simp,noatp]: "(\<Union>x\<in>{}. B x) = {}"
   8.372 -  by blast
   8.373 -
   8.374 -lemma UN_empty2 [simp]: "(\<Union>x\<in>A. {}) = {}"
   8.375 -  by blast
   8.376 -
   8.377 -lemma UN_singleton [simp]: "(\<Union>x\<in>A. {x}) = A"
   8.378 -  by blast
   8.379 -
   8.380 -lemma UN_absorb: "k \<in> I ==> A k \<union> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. A i)"
   8.381 -  by auto
   8.382 -
   8.383 -lemma UN_insert [simp]: "(\<Union>x\<in>insert a A. B x) = B a \<union> UNION A B"
   8.384 -  by blast
   8.385 -
   8.386 -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)"
   8.387 -  by blast
   8.388 -
   8.389 -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)"
   8.390 -  by blast
   8.391 -
   8.392 -lemma UN_subset_iff: "((\<Union>i\<in>I. A i) \<subseteq> B) = (\<forall>i\<in>I. A i \<subseteq> B)"
   8.393 -  by blast
   8.394 -
   8.395 -lemma image_Union: "f ` \<Union>S = (\<Union>x\<in>S. f ` x)"
   8.396 -  by blast
   8.397 -
   8.398 -lemma UN_constant [simp]: "(\<Union>y\<in>A. c) = (if A = {} then {} else c)"
   8.399 -  by auto
   8.400 -
   8.401 -lemma UN_eq: "(\<Union>x\<in>A. B x) = \<Union>({Y. \<exists>x\<in>A. Y = B x})"
   8.402 -  by blast
   8.403 -
   8.404 -lemma UNION_empty_conv[simp]:
   8.405 -  "({} = (UN x:A. B x)) = (\<forall>x\<in>A. B x = {})"
   8.406 -  "((UN x:A. B x) = {}) = (\<forall>x\<in>A. B x = {})"
   8.407 -by blast+
   8.408 -
   8.409 -lemma Collect_ex_eq [noatp]: "{x. \<exists>y. P x y} = (\<Union>y. {x. P x y})"
   8.410 -  by blast
   8.411 -
   8.412 -lemma ball_UN: "(\<forall>z \<in> UNION A B. P z) = (\<forall>x\<in>A. \<forall>z \<in> B x. P z)"
   8.413 -  by blast
   8.414 -
   8.415 -lemma bex_UN: "(\<exists>z \<in> UNION A B. P z) = (\<exists>x\<in>A. \<exists>z\<in>B x. P z)"
   8.416 -  by blast
   8.417 -
   8.418 -lemma Un_eq_UN: "A \<union> B = (\<Union>b. if b then A else B)"
   8.419 -  by (auto simp add: split_if_mem2)
   8.420 -
   8.421 -lemma UN_bool_eq: "(\<Union>b::bool. A b) = (A True \<union> A False)"
   8.422 -  by (auto intro: bool_contrapos)
   8.423 -
   8.424 -lemma UN_Pow_subset: "(\<Union>x\<in>A. Pow (B x)) \<subseteq> Pow (\<Union>x\<in>A. B x)"
   8.425 -  by blast
   8.426 -
   8.427 -lemma UN_mono:
   8.428 -  "A \<subseteq> B ==> (!!x. x \<in> A ==> f x \<subseteq> g x) ==>
   8.429 -    (\<Union>x\<in>A. f x) \<subseteq> (\<Union>x\<in>B. g x)"
   8.430 -  by (blast dest: subsetD)
   8.431 -
   8.432 -lemma vimage_Union: "f -` (Union A) = (UN X:A. f -` X)"
   8.433 -  by blast
   8.434 -
   8.435 -lemma vimage_UN: "f-`(UN x:A. B x) = (UN x:A. f -` B x)"
   8.436 -  by blast
   8.437 -
   8.438 -lemma vimage_eq_UN: "f-`B = (UN y: B. f-`{y})"
   8.439 -  -- {* NOT suitable for rewriting *}
   8.440 -  by blast
   8.441 -
   8.442 -lemma image_UN: "(f ` (UNION A B)) = (UN x:A.(f ` (B x)))"
   8.443 -by blast
   8.444 -
   8.445 -
   8.446 -subsubsection {* Inter *}
   8.447 -
   8.448 -definition Inter :: "'a set set \<Rightarrow> 'a set" where
   8.449 -  Inf_set_eq [symmetric]: "Inter S = \<Sqinter>S"
   8.450 -  
   8.451 -notation (xsymbols)
   8.452 -  Inter  ("\<Inter>_" [90] 90)
   8.453 -
   8.454 -lemma Inter_eq [code del]:
   8.455 -  "\<Inter>A = {x. \<forall>B \<in> A. x \<in> B}"
   8.456 -proof (rule set_ext)
   8.457 -  fix x
   8.458 -  have "(\<forall>Q\<in>{P. \<exists>B\<in>A. P \<longleftrightarrow> x \<in> B}. Q) \<longleftrightarrow> (\<forall>B\<in>A. x \<in> B)"
   8.459 -    by auto
   8.460 -  then show "x \<in> \<Inter>A \<longleftrightarrow> x \<in> {x. \<forall>B \<in> A. x \<in> B}"
   8.461 -    by (simp add: Inf_fun_def Inf_bool_def Inf_set_eq [symmetric]) (simp add: mem_def)
   8.462 -qed
   8.463 -
   8.464 -lemma Inter_iff [simp,noatp]: "(A : Inter C) = (ALL X:C. A:X)"
   8.465 -  by (unfold Inter_eq) blast
   8.466 -
   8.467 -lemma InterI [intro!]: "(!!X. X:C ==> A:X) ==> A : Inter C"
   8.468 -  by (simp add: Inter_eq)
   8.469 -
   8.470 -text {*
   8.471 -  \medskip A ``destruct'' rule -- every @{term X} in @{term C}
   8.472 -  contains @{term A} as an element, but @{prop "A:X"} can hold when
   8.473 -  @{prop "X:C"} does not!  This rule is analogous to @{text spec}.
   8.474 -*}
   8.475 -
   8.476 -lemma InterD [elim]: "A : Inter C ==> X:C ==> A:X"
   8.477 -  by auto
   8.478 -
   8.479 -lemma InterE [elim]: "A : Inter C ==> (X~:C ==> R) ==> (A:X ==> R) ==> R"
   8.480 -  -- {* ``Classical'' elimination rule -- does not require proving
   8.481 -    @{prop "X:C"}. *}
   8.482 -  by (unfold Inter_eq) blast
   8.483 -
   8.484 -lemma Inter_lower: "B \<in> A ==> Inter A \<subseteq> B"
   8.485 -  by blast
   8.486 -
   8.487 -lemma Inter_subset:
   8.488 -  "[| !!X. X \<in> A ==> X \<subseteq> B; A ~= {} |] ==> \<Inter>A \<subseteq> B"
   8.489 -  by blast
   8.490 -
   8.491 -lemma Inter_greatest: "(!!X. X \<in> A ==> C \<subseteq> X) ==> C \<subseteq> Inter A"
   8.492 -  by (iprover intro: InterI subsetI dest: subsetD)
   8.493 -
   8.494 -lemma Int_eq_Inter: "A \<inter> B = \<Inter>{A, B}"
   8.495 -  by blast
   8.496 -
   8.497 -lemma Inter_empty [simp]: "\<Inter>{} = UNIV"
   8.498 -  by blast
   8.499 -
   8.500 -lemma Inter_UNIV [simp]: "\<Inter>UNIV = {}"
   8.501 -  by blast
   8.502 -
   8.503 -lemma Inter_insert [simp]: "\<Inter>(insert a B) = a \<inter> \<Inter>B"
   8.504 -  by blast
   8.505 -
   8.506 -lemma Inter_Un_subset: "\<Inter>A \<union> \<Inter>B \<subseteq> \<Inter>(A \<inter> B)"
   8.507 -  by blast
   8.508 -
   8.509 -lemma Inter_Un_distrib: "\<Inter>(A \<union> B) = \<Inter>A \<inter> \<Inter>B"
   8.510 -  by blast
   8.511 -
   8.512 -lemma Inter_UNIV_conv [simp,noatp]:
   8.513 -  "(\<Inter>A = UNIV) = (\<forall>x\<in>A. x = UNIV)"
   8.514 -  "(UNIV = \<Inter>A) = (\<forall>x\<in>A. x = UNIV)"
   8.515 -  by blast+
   8.516 -
   8.517 -lemma Inter_anti_mono: "B \<subseteq> A ==> \<Inter>A \<subseteq> \<Inter>B"
   8.518 -  by blast
   8.519 -
   8.520 -
   8.521 -subsubsection {* Intersections of families *}
   8.522 -
   8.523 -definition INTER :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> 'b set" where
   8.524 -  INFI_set_eq [symmetric]: "INTER S f = (INF x:S. f x)"
   8.525 -
   8.526 -syntax
   8.527 -  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3INT _./ _)" [0, 10] 10)
   8.528 -  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3INT _:_./ _)" [0, 10] 10)
   8.529 -
   8.530 -syntax (xsymbols)
   8.531 -  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>_./ _)" [0, 10] 10)
   8.532 -  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>_\<in>_./ _)" [0, 10] 10)
   8.533 -
   8.534 -syntax (latex output)
   8.535 -  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>(00\<^bsub>_\<^esub>)/ _)" [0, 10] 10)
   8.536 -  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>(00\<^bsub>_\<in>_\<^esub>)/ _)" [0, 10] 10)
   8.537 -
   8.538 -translations
   8.539 -  "INT x y. B"  == "INT x. INT y. B"
   8.540 -  "INT x. B"    == "CONST INTER CONST UNIV (%x. B)"
   8.541 -  "INT x. B"    == "INT x:CONST UNIV. B"
   8.542 -  "INT x:A. B"  == "CONST INTER A (%x. B)"
   8.543 -
   8.544 -print_translation {* [
   8.545 -Syntax.preserve_binder_abs2_tr' @{const_syntax INTER} "@INTER"
   8.546 -] *} -- {* to avoid eta-contraction of body *}
   8.547 -
   8.548 -lemma INTER_eq_Inter_image:
   8.549 -  "(\<Inter>x\<in>A. B x) = \<Inter>(B`A)"
   8.550 -  by (simp add: INFI_def INFI_set_eq [symmetric] Inf_set_eq)
   8.551 -  
   8.552 -lemma Inter_def:
   8.553 -  "\<Inter>S = (\<Inter>x\<in>S. x)"
   8.554 -  by (simp add: INTER_eq_Inter_image image_def)
   8.555 -
   8.556 -lemma INTER_def:
   8.557 -  "(\<Inter>x\<in>A. B x) = {y. \<forall>x\<in>A. y \<in> B x}"
   8.558 -  by (auto simp add: INTER_eq_Inter_image Inter_eq)
   8.559 -
   8.560 -lemma Inter_image_eq [simp]:
   8.561 -  "\<Inter>(B`A) = (\<Inter>x\<in>A. B x)"
   8.562 -  by (rule sym) (fact INTER_eq_Inter_image)
   8.563 -
   8.564 -lemma INT_iff [simp]: "(b: (INT x:A. B x)) = (ALL x:A. b: B x)"
   8.565 -  by (unfold INTER_def) blast
   8.566 -
   8.567 -lemma INT_I [intro!]: "(!!x. x:A ==> b: B x) ==> b : (INT x:A. B x)"
   8.568 -  by (unfold INTER_def) blast
   8.569 -
   8.570 -lemma INT_D [elim]: "b : (INT x:A. B x) ==> a:A ==> b: B a"
   8.571 -  by auto
   8.572 -
   8.573 -lemma INT_E [elim]: "b : (INT x:A. B x) ==> (b: B a ==> R) ==> (a~:A ==> R) ==> R"
   8.574 -  -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a:A"}. *}
   8.575 -  by (unfold INTER_def) blast
   8.576 -
   8.577 -lemma INT_cong [cong]:
   8.578 -    "A = B ==> (!!x. x:B ==> C x = D x) ==> (INT x:A. C x) = (INT x:B. D x)"
   8.579 -  by (simp add: INTER_def)
   8.580 -
   8.581 -lemma Collect_ball_eq: "{x. \<forall>y\<in>A. P x y} = (\<Inter>y\<in>A. {x. P x y})"
   8.582 -  by blast
   8.583 -
   8.584 -lemma Collect_all_eq: "{x. \<forall>y. P x y} = (\<Inter>y. {x. P x y})"
   8.585 -  by blast
   8.586 -
   8.587 -lemma INT_lower: "a \<in> A ==> (\<Inter>x\<in>A. B x) \<subseteq> B a"
   8.588 -  by blast
   8.589 -
   8.590 -lemma INT_greatest: "(!!x. x \<in> A ==> C \<subseteq> B x) ==> C \<subseteq> (\<Inter>x\<in>A. B x)"
   8.591 -  by (iprover intro: INT_I subsetI dest: subsetD)
   8.592 -
   8.593 -lemma INT_empty [simp]: "(\<Inter>x\<in>{}. B x) = UNIV"
   8.594 -  by blast
   8.595 -
   8.596 -lemma INT_absorb: "k \<in> I ==> A k \<inter> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. A i)"
   8.597 -  by blast
   8.598 -
   8.599 -lemma INT_subset_iff: "(B \<subseteq> (\<Inter>i\<in>I. A i)) = (\<forall>i\<in>I. B \<subseteq> A i)"
   8.600 -  by blast
   8.601 -
   8.602 -lemma INT_insert [simp]: "(\<Inter>x \<in> insert a A. B x) = B a \<inter> INTER A B"
   8.603 -  by blast
   8.604 -
   8.605 -lemma INT_Un: "(\<Inter>i \<in> A \<union> B. M i) = (\<Inter>i \<in> A. M i) \<inter> (\<Inter>i\<in>B. M i)"
   8.606 -  by blast
   8.607 -
   8.608 -lemma INT_insert_distrib:
   8.609 -    "u \<in> A ==> (\<Inter>x\<in>A. insert a (B x)) = insert a (\<Inter>x\<in>A. B x)"
   8.610 -  by blast
   8.611 -
   8.612 -lemma INT_constant [simp]: "(\<Inter>y\<in>A. c) = (if A = {} then UNIV else c)"
   8.613 -  by auto
   8.614 -
   8.615 -lemma INT_eq: "(\<Inter>x\<in>A. B x) = \<Inter>({Y. \<exists>x\<in>A. Y = B x})"
   8.616 -  -- {* Look: it has an \emph{existential} quantifier *}
   8.617 -  by blast
   8.618 -
   8.619 -lemma INTER_UNIV_conv[simp]:
   8.620 - "(UNIV = (INT x:A. B x)) = (\<forall>x\<in>A. B x = UNIV)"
   8.621 - "((INT x:A. B x) = UNIV) = (\<forall>x\<in>A. B x = UNIV)"
   8.622 -by blast+
   8.623 -
   8.624 -lemma INT_bool_eq: "(\<Inter>b::bool. A b) = (A True \<inter> A False)"
   8.625 -  by (auto intro: bool_induct)
   8.626 -
   8.627 -lemma Pow_INT_eq: "Pow (\<Inter>x\<in>A. B x) = (\<Inter>x\<in>A. Pow (B x))"
   8.628 -  by blast
   8.629 -
   8.630 -lemma INT_anti_mono:
   8.631 -  "B \<subseteq> A ==> (!!x. x \<in> A ==> f x \<subseteq> g x) ==>
   8.632 -    (\<Inter>x\<in>A. f x) \<subseteq> (\<Inter>x\<in>A. g x)"
   8.633 -  -- {* The last inclusion is POSITIVE! *}
   8.634 -  by (blast dest: subsetD)
   8.635 -
   8.636 -lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)"
   8.637 -  by blast
   8.638 -
   8.639 -
   8.640 -subsubsection {* Distributive laws *}
   8.641 -
   8.642 -lemma Int_Union: "A \<inter> \<Union>B = (\<Union>C\<in>B. A \<inter> C)"
   8.643 -  by blast
   8.644 -
   8.645 -lemma Int_Union2: "\<Union>B \<inter> A = (\<Union>C\<in>B. C \<inter> A)"
   8.646 -  by blast
   8.647 -
   8.648 -lemma Un_Union_image: "(\<Union>x\<in>C. A x \<union> B x) = \<Union>(A`C) \<union> \<Union>(B`C)"
   8.649 -  -- {* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: *}
   8.650 -  -- {* Union of a family of unions *}
   8.651 -  by blast
   8.652 -
   8.653 -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)"
   8.654 -  -- {* Equivalent version *}
   8.655 -  by blast
   8.656 -
   8.657 -lemma Un_Inter: "A \<union> \<Inter>B = (\<Inter>C\<in>B. A \<union> C)"
   8.658 -  by blast
   8.659 -
   8.660 -lemma Int_Inter_image: "(\<Inter>x\<in>C. A x \<inter> B x) = \<Inter>(A`C) \<inter> \<Inter>(B`C)"
   8.661 -  by blast
   8.662 -
   8.663 -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)"
   8.664 -  -- {* Equivalent version *}
   8.665 -  by blast
   8.666 -
   8.667 -lemma Int_UN_distrib: "B \<inter> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. B \<inter> A i)"
   8.668 -  -- {* Halmos, Naive Set Theory, page 35. *}
   8.669 -  by blast
   8.670 -
   8.671 -lemma Un_INT_distrib: "B \<union> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. B \<union> A i)"
   8.672 -  by blast
   8.673 -
   8.674 -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)"
   8.675 -  by blast
   8.676 -
   8.677 -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)"
   8.678 -  by blast
   8.679 -
   8.680 -
   8.681 -subsubsection {* Complement *}
   8.682 -
   8.683 -lemma Compl_UN [simp]: "-(\<Union>x\<in>A. B x) = (\<Inter>x\<in>A. -B x)"
   8.684 -  by blast
   8.685 -
   8.686 -lemma Compl_INT [simp]: "-(\<Inter>x\<in>A. B x) = (\<Union>x\<in>A. -B x)"
   8.687 -  by blast
   8.688 -
   8.689 -
   8.690 -subsubsection {* Miniscoping and maxiscoping *}
   8.691 -
   8.692 -text {* \medskip Miniscoping: pushing in quantifiers and big Unions
   8.693 -           and Intersections. *}
   8.694 -
   8.695 -lemma UN_simps [simp]:
   8.696 -  "!!a B C. (UN x:C. insert a (B x)) = (if C={} then {} else insert a (UN x:C. B x))"
   8.697 -  "!!A B C. (UN x:C. A x Un B)   = ((if C={} then {} else (UN x:C. A x) Un B))"
   8.698 -  "!!A B C. (UN x:C. A Un B x)   = ((if C={} then {} else A Un (UN x:C. B x)))"
   8.699 -  "!!A B C. (UN x:C. A x Int B)  = ((UN x:C. A x) Int B)"
   8.700 -  "!!A B C. (UN x:C. A Int B x)  = (A Int (UN x:C. B x))"
   8.701 -  "!!A B C. (UN x:C. A x - B)    = ((UN x:C. A x) - B)"
   8.702 -  "!!A B C. (UN x:C. A - B x)    = (A - (INT x:C. B x))"
   8.703 -  "!!A B. (UN x: Union A. B x) = (UN y:A. UN x:y. B x)"
   8.704 -  "!!A B C. (UN z: UNION A B. C z) = (UN  x:A. UN z: B(x). C z)"
   8.705 -  "!!A B f. (UN x:f`A. B x)     = (UN a:A. B (f a))"
   8.706 -  by auto
   8.707 -
   8.708 -lemma INT_simps [simp]:
   8.709 -  "!!A B C. (INT x:C. A x Int B) = (if C={} then UNIV else (INT x:C. A x) Int B)"
   8.710 -  "!!A B C. (INT x:C. A Int B x) = (if C={} then UNIV else A Int (INT x:C. B x))"
   8.711 -  "!!A B C. (INT x:C. A x - B)   = (if C={} then UNIV else (INT x:C. A x) - B)"
   8.712 -  "!!A B C. (INT x:C. A - B x)   = (if C={} then UNIV else A - (UN x:C. B x))"
   8.713 -  "!!a B C. (INT x:C. insert a (B x)) = insert a (INT x:C. B x)"
   8.714 -  "!!A B C. (INT x:C. A x Un B)  = ((INT x:C. A x) Un B)"
   8.715 -  "!!A B C. (INT x:C. A Un B x)  = (A Un (INT x:C. B x))"
   8.716 -  "!!A B. (INT x: Union A. B x) = (INT y:A. INT x:y. B x)"
   8.717 -  "!!A B C. (INT z: UNION A B. C z) = (INT x:A. INT z: B(x). C z)"
   8.718 -  "!!A B f. (INT x:f`A. B x)    = (INT a:A. B (f a))"
   8.719 -  by auto
   8.720 -
   8.721 -lemma ball_simps [simp,noatp]:
   8.722 -  "!!A P Q. (ALL x:A. P x | Q) = ((ALL x:A. P x) | Q)"
   8.723 -  "!!A P Q. (ALL x:A. P | Q x) = (P | (ALL x:A. Q x))"
   8.724 -  "!!A P Q. (ALL x:A. P --> Q x) = (P --> (ALL x:A. Q x))"
   8.725 -  "!!A P Q. (ALL x:A. P x --> Q) = ((EX x:A. P x) --> Q)"
   8.726 -  "!!P. (ALL x:{}. P x) = True"
   8.727 -  "!!P. (ALL x:UNIV. P x) = (ALL x. P x)"
   8.728 -  "!!a B P. (ALL x:insert a B. P x) = (P a & (ALL x:B. P x))"
   8.729 -  "!!A P. (ALL x:Union A. P x) = (ALL y:A. ALL x:y. P x)"
   8.730 -  "!!A B P. (ALL x: UNION A B. P x) = (ALL a:A. ALL x: B a. P x)"
   8.731 -  "!!P Q. (ALL x:Collect Q. P x) = (ALL x. Q x --> P x)"
   8.732 -  "!!A P f. (ALL x:f`A. P x) = (ALL x:A. P (f x))"
   8.733 -  "!!A P. (~(ALL x:A. P x)) = (EX x:A. ~P x)"
   8.734 -  by auto
   8.735 -
   8.736 -lemma bex_simps [simp,noatp]:
   8.737 -  "!!A P Q. (EX x:A. P x & Q) = ((EX x:A. P x) & Q)"
   8.738 -  "!!A P Q. (EX x:A. P & Q x) = (P & (EX x:A. Q x))"
   8.739 -  "!!P. (EX x:{}. P x) = False"
   8.740 -  "!!P. (EX x:UNIV. P x) = (EX x. P x)"
   8.741 -  "!!a B P. (EX x:insert a B. P x) = (P(a) | (EX x:B. P x))"
   8.742 -  "!!A P. (EX x:Union A. P x) = (EX y:A. EX x:y. P x)"
   8.743 -  "!!A B P. (EX x: UNION A B. P x) = (EX a:A. EX x:B a. P x)"
   8.744 -  "!!P Q. (EX x:Collect Q. P x) = (EX x. Q x & P x)"
   8.745 -  "!!A P f. (EX x:f`A. P x) = (EX x:A. P (f x))"
   8.746 -  "!!A P. (~(EX x:A. P x)) = (ALL x:A. ~P x)"
   8.747 -  by auto
   8.748 -
   8.749 -lemma ball_conj_distrib:
   8.750 -  "(ALL x:A. P x & Q x) = ((ALL x:A. P x) & (ALL x:A. Q x))"
   8.751 -  by blast
   8.752 -
   8.753 -lemma bex_disj_distrib:
   8.754 -  "(EX x:A. P x | Q x) = ((EX x:A. P x) | (EX x:A. Q x))"
   8.755 -  by blast
   8.756 -
   8.757 -
   8.758 -text {* \medskip Maxiscoping: pulling out big Unions and Intersections. *}
   8.759 -
   8.760 -lemma UN_extend_simps:
   8.761 -  "!!a B C. insert a (UN x:C. B x) = (if C={} then {a} else (UN x:C. insert a (B x)))"
   8.762 -  "!!A B C. (UN x:C. A x) Un B    = (if C={} then B else (UN x:C. A x Un B))"
   8.763 -  "!!A B C. A Un (UN x:C. B x)   = (if C={} then A else (UN x:C. A Un B x))"
   8.764 -  "!!A B C. ((UN x:C. A x) Int B) = (UN x:C. A x Int B)"
   8.765 -  "!!A B C. (A Int (UN x:C. B x)) = (UN x:C. A Int B x)"
   8.766 -  "!!A B C. ((UN x:C. A x) - B) = (UN x:C. A x - B)"
   8.767 -  "!!A B C. (A - (INT x:C. B x)) = (UN x:C. A - B x)"
   8.768 -  "!!A B. (UN y:A. UN x:y. B x) = (UN x: Union A. B x)"
   8.769 -  "!!A B C. (UN  x:A. UN z: B(x). C z) = (UN z: UNION A B. C z)"
   8.770 -  "!!A B f. (UN a:A. B (f a)) = (UN x:f`A. B x)"
   8.771 -  by auto
   8.772 -
   8.773 -lemma INT_extend_simps:
   8.774 -  "!!A B C. (INT x:C. A x) Int B = (if C={} then B else (INT x:C. A x Int B))"
   8.775 -  "!!A B C. A Int (INT x:C. B x) = (if C={} then A else (INT x:C. A Int B x))"
   8.776 -  "!!A B C. (INT x:C. A x) - B   = (if C={} then UNIV-B else (INT x:C. A x - B))"
   8.777 -  "!!A B C. A - (UN x:C. B x)   = (if C={} then A else (INT x:C. A - B x))"
   8.778 -  "!!a B C. insert a (INT x:C. B x) = (INT x:C. insert a (B x))"
   8.779 -  "!!A B C. ((INT x:C. A x) Un B)  = (INT x:C. A x Un B)"
   8.780 -  "!!A B C. A Un (INT x:C. B x)  = (INT x:C. A Un B x)"
   8.781 -  "!!A B. (INT y:A. INT x:y. B x) = (INT x: Union A. B x)"
   8.782 -  "!!A B C. (INT x:A. INT z: B(x). C z) = (INT z: UNION A B. C z)"
   8.783 -  "!!A B f. (INT a:A. B (f a))    = (INT x:f`A. B x)"
   8.784 -  by auto
   8.785 -
   8.786 -
   8.787 -no_notation
   8.788 -  less_eq  (infix "\<sqsubseteq>" 50) and
   8.789 -  less (infix "\<sqsubset>" 50) and
   8.790 -  inf  (infixl "\<sqinter>" 70) and
   8.791 -  sup  (infixl "\<squnion>" 65) and
   8.792 -  Inf  ("\<Sqinter>_" [900] 900) and
   8.793 -  Sup  ("\<Squnion>_" [900] 900)
   8.794 -
   8.795 -lemmas mem_simps =
   8.796 -  insert_iff empty_iff Un_iff Int_iff Compl_iff Diff_iff
   8.797 -  mem_Collect_eq UN_iff Union_iff INT_iff Inter_iff
   8.798 -  -- {* Each of these has ALREADY been added @{text "[simp]"} above. *}
   8.799 -
   8.800 -end
     9.1 --- a/src/HOL/UNITY/Comp/Alloc.thy	Wed Jul 22 14:21:52 2009 +0200
     9.2 +++ b/src/HOL/UNITY/Comp/Alloc.thy	Wed Jul 22 18:02:10 2009 +0200
     9.3 @@ -1021,7 +1021,7 @@
     9.4                     LeadsTo {s. h pfixLe (sub i o allocGiv) s})"
     9.5    apply (simp only: o_apply sub_def)
     9.6    apply (insert Alloc_Progress [THEN rename_guarantees_sysOfAlloc_I])
     9.7 -  apply (simp add: o_def del: Set.INT_iff);
     9.8 +  apply (simp add: o_def del: INT_iff)
     9.9    apply (erule component_guaranteesD)
    9.10    apply (auto simp add:
    9.11      System_Increasing_allocRel [simplified sub_apply o_def]
    10.1 --- a/src/HOL/UNITY/ProgressSets.thy	Wed Jul 22 14:21:52 2009 +0200
    10.2 +++ b/src/HOL/UNITY/ProgressSets.thy	Wed Jul 22 18:02:10 2009 +0200
    10.3 @@ -44,7 +44,7 @@
    10.4  
    10.5  lemma UN_in_lattice:
    10.6       "[|lattice L; !!i. i\<in>I ==> r i \<in> L|] ==> (\<Union>i\<in>I. r i) \<in> L"
    10.7 -apply (simp add: Set.UN_eq) 
    10.8 +apply (simp add: UN_eq) 
    10.9  apply (blast intro: Union_in_lattice) 
   10.10  done
   10.11