src/HOL/Complete_Lattice.thy
changeset 43873 8a2f339641c1
parent 43872 6b917e5877d2
child 43898 935359fd8210
equal deleted inserted replaced
43872:6b917e5877d2 43873:8a2f339641c1
   347 lemma SUP_bot_conv:
   347 lemma SUP_bot_conv:
   348  "\<bottom> = (\<Squnion>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
   348  "\<bottom> = (\<Squnion>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
   349  "(\<Squnion>x\<in>A. B x) = \<bottom> \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
   349  "(\<Squnion>x\<in>A. B x) = \<bottom> \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
   350   by (auto simp add: SUP_def Sup_bot_conv)
   350   by (auto simp add: SUP_def Sup_bot_conv)
   351 
   351 
   352 lemma (in complete_lattice) INF_UNIV_range:
   352 lemma INF_UNIV_range:
   353   "(\<Sqinter>x. f x) = \<Sqinter>range f"
   353   "(\<Sqinter>x. f x) = \<Sqinter>range f"
   354   by (fact INF_def)
   354   by (fact INF_def)
   355 
   355 
   356 lemma (in complete_lattice) SUP_UNIV_range:
   356 lemma SUP_UNIV_range:
   357   "(\<Squnion>x. f x) = \<Squnion>range f"
   357   "(\<Squnion>x. f x) = \<Squnion>range f"
   358   by (fact SUP_def)
   358   by (fact SUP_def)
   359 
   359 
   360 lemma INF_bool_eq:
   360 lemma INF_UNIV_bool_expand:
   361   "(\<Sqinter>b. A b) = A True \<sqinter> A False"
   361   "(\<Sqinter>b. A b) = A True \<sqinter> A False"
   362   by (simp add: UNIV_bool INF_empty INF_insert inf_commute)
   362   by (simp add: UNIV_bool INF_empty INF_insert inf_commute)
   363 
   363 
   364 lemma SUP_bool_eq:
   364 lemma SUP_UNIV_bool_expand:
   365   "(\<Squnion>b. A b) = A True \<squnion> A False"
   365   "(\<Squnion>b. A b) = A True \<squnion> A False"
   366   by (simp add: UNIV_bool SUP_empty SUP_insert sup_commute)
   366   by (simp add: UNIV_bool SUP_empty SUP_insert sup_commute)
   367 
   367 
   368 lemma INF_anti_mono:
   368 lemma INF_anti_mono:
   369   "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<sqsubseteq> g x) \<Longrightarrow> (\<Sqinter>x\<in>B. f x) \<sqsubseteq> (\<Sqinter>x\<in>B. g x)"
   369   "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<sqsubseteq> g x) \<Longrightarrow> (\<Sqinter>x\<in>B. f x) \<sqsubseteq> (\<Sqinter>x\<in>B. g x)"
   395 lemma less_SUP_iff:
   395 lemma less_SUP_iff:
   396   fixes a :: "'a::{complete_lattice,linorder}"
   396   fixes a :: "'a::{complete_lattice,linorder}"
   397   shows "a \<sqsubset> (\<Squnion>i\<in>A. f i) \<longleftrightarrow> (\<exists>x\<in>A. a \<sqsubset> f x)"
   397   shows "a \<sqsubset> (\<Squnion>i\<in>A. f i) \<longleftrightarrow> (\<exists>x\<in>A. a \<sqsubset> f x)"
   398   unfolding SUP_def less_Sup_iff by auto
   398   unfolding SUP_def less_Sup_iff by auto
   399 
   399 
       
   400 -- "FIXME move"
       
   401 
       
   402 lemma image_ident [simp]: "(%x. x) ` Y = Y"
       
   403   by blast
       
   404 
       
   405 lemma vimage_ident [simp]: "(%x. x) -` Y = Y"
       
   406   by blast
       
   407 
       
   408 class complete_boolean_algebra = boolean_algebra + complete_lattice
       
   409 begin
       
   410 
       
   411 lemma uminus_Inf:
       
   412   "- (\<Sqinter>A) = \<Squnion>(uminus ` A)"
       
   413 proof (rule antisym)
       
   414   show "- \<Sqinter>A \<le> \<Squnion>(uminus ` A)"
       
   415     by (rule compl_le_swap2, rule Inf_greatest, rule compl_le_swap2, rule Sup_upper) simp
       
   416   show "\<Squnion>(uminus ` A) \<le> - \<Sqinter>A"
       
   417     by (rule Sup_least, rule compl_le_swap1, rule Inf_lower) auto
       
   418 qed
       
   419 
       
   420 lemma uminus_Sup:
       
   421   "- (\<Squnion>A) = \<Sqinter>(uminus ` A)"
       
   422 proof -
       
   423   have "\<Squnion>A = - \<Sqinter>(uminus ` A)" by (simp add: image_image uminus_Inf)
       
   424   then show ?thesis by simp
       
   425 qed
       
   426   
       
   427 lemma uminus_INF: "- (\<Sqinter>x\<in>A. B x) = (\<Squnion>x\<in>A. - B x)"
       
   428   by (simp add: INF_def SUP_def uminus_Inf image_image)
       
   429 
       
   430 lemma uminus_SUP: "- (\<Squnion>x\<in>A. B x) = (\<Sqinter>x\<in>A. - B x)"
       
   431   by (simp add: INF_def SUP_def uminus_Sup image_image)
       
   432 
       
   433 end
       
   434 
       
   435 
   400 subsection {* @{typ bool} and @{typ "_ \<Rightarrow> _"} as complete lattice *}
   436 subsection {* @{typ bool} and @{typ "_ \<Rightarrow> _"} as complete lattice *}
   401 
   437 
   402 instantiation bool :: complete_lattice
   438 instantiation bool :: complete_boolean_algebra
   403 begin
   439 begin
   404 
   440 
   405 definition
   441 definition
   406   "\<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x)"
   442   "\<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x)"
   407 
   443 
   411 instance proof
   447 instance proof
   412 qed (auto simp add: Inf_bool_def Sup_bool_def)
   448 qed (auto simp add: Inf_bool_def Sup_bool_def)
   413 
   449 
   414 end
   450 end
   415 
   451 
   416 lemma INFI_bool_eq [simp]:
   452 lemma INF_bool_eq [simp]:
   417   "INFI = Ball"
   453   "INFI = Ball"
   418 proof (rule ext)+
   454 proof (rule ext)+
   419   fix A :: "'a set"
   455   fix A :: "'a set"
   420   fix P :: "'a \<Rightarrow> bool"
   456   fix P :: "'a \<Rightarrow> bool"
   421   show "(\<Sqinter>x\<in>A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P x)"
   457   show "(\<Sqinter>x\<in>A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P x)"
   422     by (auto simp add: Ball_def INF_def Inf_bool_def)
   458     by (auto simp add: Ball_def INF_def Inf_bool_def)
   423 qed
   459 qed
   424 
   460 
   425 lemma SUPR_bool_eq [simp]:
   461 lemma SUP_bool_eq [simp]:
   426   "SUPR = Bex"
   462   "SUPR = Bex"
   427 proof (rule ext)+
   463 proof (rule ext)+
   428   fix A :: "'a set"
   464   fix A :: "'a set"
   429   fix P :: "'a \<Rightarrow> bool"
   465   fix P :: "'a \<Rightarrow> bool"
   430   show "(\<Squnion>x\<in>A. P x) \<longleftrightarrow> (\<exists>x\<in>A. P x)"
   466   show "(\<Squnion>x\<in>A. P x) \<longleftrightarrow> (\<exists>x\<in>A. P x)"
   452 qed (auto simp add: le_fun_def Inf_apply Sup_apply
   488 qed (auto simp add: le_fun_def Inf_apply Sup_apply
   453   intro: Inf_lower Sup_upper Inf_greatest Sup_least)
   489   intro: Inf_lower Sup_upper Inf_greatest Sup_least)
   454 
   490 
   455 end
   491 end
   456 
   492 
   457 lemma INFI_apply:
   493 lemma INF_apply:
   458   "(\<Sqinter>y\<in>A. f y) x = (\<Sqinter>y\<in>A. f y x)"
   494   "(\<Sqinter>y\<in>A. f y) x = (\<Sqinter>y\<in>A. f y x)"
   459   by (auto intro: arg_cong [of _ _ Inf] simp add: INF_def Inf_apply)
   495   by (auto intro: arg_cong [of _ _ Inf] simp add: INF_def Inf_apply)
   460 
   496 
   461 lemma SUPR_apply:
   497 lemma SUP_apply:
   462   "(\<Squnion>y\<in>A. f y) x = (\<Squnion>y\<in>A. f y x)"
   498   "(\<Squnion>y\<in>A. f y) x = (\<Squnion>y\<in>A. f y x)"
   463   by (auto intro: arg_cong [of _ _ Sup] simp add: SUP_def Sup_apply)
   499   by (auto intro: arg_cong [of _ _ Sup] simp add: SUP_def Sup_apply)
       
   500 
       
   501 instance "fun" :: (type, complete_boolean_algebra) complete_boolean_algebra ..
   464 
   502 
   465 
   503 
   466 subsection {* Inter *}
   504 subsection {* Inter *}
   467 
   505 
   468 abbreviation Inter :: "'a set set \<Rightarrow> 'a set" where
   506 abbreviation Inter :: "'a set set \<Rightarrow> 'a set" where
   645  "(UNIV = (\<Inter>x\<in>A. B x)) = (\<forall>x\<in>A. B x = UNIV)"
   683  "(UNIV = (\<Inter>x\<in>A. B x)) = (\<forall>x\<in>A. B x = UNIV)"
   646  "((\<Inter>x\<in>A. B x) = UNIV) = (\<forall>x\<in>A. B x = UNIV)"
   684  "((\<Inter>x\<in>A. B x) = UNIV) = (\<forall>x\<in>A. B x = UNIV)"
   647   by (fact INF_top_conv)+
   685   by (fact INF_top_conv)+
   648 
   686 
   649 lemma INT_bool_eq: "(\<Inter>b. A b) = A True \<inter> A False"
   687 lemma INT_bool_eq: "(\<Inter>b. A b) = A True \<inter> A False"
   650   by (fact INF_bool_eq)
   688   by (fact INF_UNIV_bool_expand)
   651 
   689 
   652 lemma INT_anti_mono:
   690 lemma INT_anti_mono:
   653   "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<subseteq> g x) \<Longrightarrow> (\<Inter>x\<in>B. f x) \<subseteq> (\<Inter>x\<in>B. g x)"
   691   "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> f x \<subseteq> g x) \<Longrightarrow> (\<Inter>x\<in>B. f x) \<subseteq> (\<Inter>x\<in>B. g x)"
   654   -- {* The last inclusion is POSITIVE! *}
   692   -- {* The last inclusion is POSITIVE! *}
   655   by (fact INF_anti_mono)
   693   by (fact INF_anti_mono)
   943   by blast
   981   by blast
   944 
   982 
   945 
   983 
   946 subsection {* Complement *}
   984 subsection {* Complement *}
   947 
   985 
       
   986 lemma Compl_INT [simp]: "- (\<Inter>x\<in>A. B x) = (\<Union>x\<in>A. -B x)"
       
   987   by (fact uminus_INF)
       
   988 
   948 lemma Compl_UN [simp]: "- (\<Union>x\<in>A. B x) = (\<Inter>x\<in>A. -B x)"
   989 lemma Compl_UN [simp]: "- (\<Union>x\<in>A. B x) = (\<Inter>x\<in>A. -B x)"
   949   by blast
   990   by (fact uminus_SUP)
   950 
       
   951 lemma Compl_INT [simp]: "- (\<Inter>x\<in>A. B x) = (\<Union>x\<in>A. -B x)"
       
   952   by blast
       
   953 
   991 
   954 
   992 
   955 subsection {* Miniscoping and maxiscoping *}
   993 subsection {* Miniscoping and maxiscoping *}
   956 
   994 
   957 text {* \medskip Miniscoping: pushing in quantifiers and big Unions
   995 text {* \medskip Miniscoping: pushing in quantifiers and big Unions
  1045 lemmas (in complete_lattice) INFI_def = INF_def
  1083 lemmas (in complete_lattice) INFI_def = INF_def
  1046 lemmas (in complete_lattice) SUPR_def = SUP_def
  1084 lemmas (in complete_lattice) SUPR_def = SUP_def
  1047 lemmas (in complete_lattice) le_SUPI = le_SUP_I
  1085 lemmas (in complete_lattice) le_SUPI = le_SUP_I
  1048 lemmas (in complete_lattice) le_SUPI2 = le_SUP_I2
  1086 lemmas (in complete_lattice) le_SUPI2 = le_SUP_I2
  1049 lemmas (in complete_lattice) le_INFI = le_INF_I
  1087 lemmas (in complete_lattice) le_INFI = le_INF_I
  1050 
  1088 lemmas INFI_apply = INF_apply
       
  1089 lemmas SUPR_apply = SUP_apply
  1051 
  1090 
  1052 text {* Finally *}
  1091 text {* Finally *}
  1053 
  1092 
  1054 no_notation
  1093 no_notation
  1055   less_eq  (infix "\<sqsubseteq>" 50) and
  1094   less_eq  (infix "\<sqsubseteq>" 50) and