src/HOL/Lattices.thy
changeset 41080 294956ff285b
parent 41075 4bed56dc95fb
child 41082 9ff94e7cc3b3
equal deleted inserted replaced
41079:a0d9258e2091 41080:294956ff285b
   585 
   585 
   586 instantiation bool :: boolean_algebra
   586 instantiation bool :: boolean_algebra
   587 begin
   587 begin
   588 
   588 
   589 definition
   589 definition
   590   bool_Compl_def: "uminus = Not"
   590   bool_Compl_def [simp]: "uminus = Not"
   591 
   591 
   592 definition
   592 definition
   593   bool_diff_def: "A - B \<longleftrightarrow> A \<and> \<not> B"
   593   bool_diff_def [simp]: "A - B \<longleftrightarrow> A \<and> \<not> B"
   594 
   594 
   595 definition
   595 definition
   596   inf_bool_def: "P \<sqinter> Q \<longleftrightarrow> P \<and> Q"
   596   [simp]: "P \<sqinter> Q \<longleftrightarrow> P \<and> Q"
   597 
   597 
   598 definition
   598 definition
   599   sup_bool_def: "P \<squnion> Q \<longleftrightarrow> P \<or> Q"
   599   [simp]: "P \<squnion> Q \<longleftrightarrow> P \<or> Q"
   600 
   600 
   601 instance proof
   601 instance proof
   602 qed (simp_all add: inf_bool_def sup_bool_def le_bool_def
   602 qed auto
   603   bot_bool_def top_bool_def bool_Compl_def bool_diff_def, auto)
       
   604 
   603 
   605 end
   604 end
   606 
   605 
   607 lemma sup_boolI1:
   606 lemma sup_boolI1:
   608   "P \<Longrightarrow> P \<squnion> Q"
   607   "P \<Longrightarrow> P \<squnion> Q"
   609   by (simp add: sup_bool_def)
   608   by simp
   610 
   609 
   611 lemma sup_boolI2:
   610 lemma sup_boolI2:
   612   "Q \<Longrightarrow> P \<squnion> Q"
   611   "Q \<Longrightarrow> P \<squnion> Q"
   613   by (simp add: sup_bool_def)
   612   by simp
   614 
   613 
   615 lemma sup_boolE:
   614 lemma sup_boolE:
   616   "P \<squnion> Q \<Longrightarrow> (P \<Longrightarrow> R) \<Longrightarrow> (Q \<Longrightarrow> R) \<Longrightarrow> R"
   615   "P \<squnion> Q \<Longrightarrow> (P \<Longrightarrow> R) \<Longrightarrow> (Q \<Longrightarrow> R) \<Longrightarrow> R"
   617   by (auto simp add: sup_bool_def)
   616   by auto
   618 
   617 
   619 
   618 
   620 subsection {* Fun as lattice *}
   619 subsection {* Fun as lattice *}
   621 
   620 
   622 instantiation "fun" :: (type, lattice) lattice
   621 instantiation "fun" :: (type, lattice) lattice
   623 begin
   622 begin
   624 
   623 
   625 definition
   624 definition
   626   inf_fun_def: "f \<sqinter> g = (\<lambda>x. f x \<sqinter> g x)"
   625   "f \<sqinter> g = (\<lambda>x. f x \<sqinter> g x)"
   627 
   626 
   628 definition
   627 lemma inf_apply:
   629   sup_fun_def: "f \<squnion> g = (\<lambda>x. f x \<squnion> g x)"
   628   "(f \<sqinter> g) x = f x \<sqinter> g x"
       
   629   by (simp add: inf_fun_def)
       
   630 
       
   631 definition
       
   632   "f \<squnion> g = (\<lambda>x. f x \<squnion> g x)"
       
   633 
       
   634 lemma sup_apply:
       
   635   "(f \<squnion> g) x = f x \<squnion> g x"
       
   636   by (simp add: sup_fun_def)
   630 
   637 
   631 instance proof
   638 instance proof
   632 qed (simp_all add: le_fun_def inf_fun_def sup_fun_def)
   639 qed (simp_all add: le_fun_def inf_apply sup_apply)
   633 
   640 
   634 end
   641 end
   635 
   642 
   636 instance "fun" :: (type, distrib_lattice) distrib_lattice
   643 instance "fun" :: (type, distrib_lattice) distrib_lattice proof
   637 proof
   644 qed (rule ext, simp add: sup_inf_distrib1 inf_apply sup_apply)
   638 qed (simp_all add: inf_fun_def sup_fun_def sup_inf_distrib1)
       
   639 
   645 
   640 instance "fun" :: (type, bounded_lattice) bounded_lattice ..
   646 instance "fun" :: (type, bounded_lattice) bounded_lattice ..
   641 
   647 
   642 instantiation "fun" :: (type, uminus) uminus
   648 instantiation "fun" :: (type, uminus) uminus
   643 begin
   649 begin
   644 
   650 
   645 definition
   651 definition
   646   fun_Compl_def: "- A = (\<lambda>x. - A x)"
   652   fun_Compl_def: "- A = (\<lambda>x. - A x)"
   647 
   653 
       
   654 lemma uminus_apply:
       
   655   "(- A) x = - (A x)"
       
   656   by (simp add: fun_Compl_def)
       
   657 
   648 instance ..
   658 instance ..
   649 
   659 
   650 end
   660 end
   651 
   661 
   652 instantiation "fun" :: (type, minus) minus
   662 instantiation "fun" :: (type, minus) minus
   653 begin
   663 begin
   654 
   664 
   655 definition
   665 definition
   656   fun_diff_def: "A - B = (\<lambda>x. A x - B x)"
   666   fun_diff_def: "A - B = (\<lambda>x. A x - B x)"
   657 
   667 
       
   668 lemma minus_apply:
       
   669   "(A - B) x = A x - B x"
       
   670   by (simp add: fun_diff_def)
       
   671 
   658 instance ..
   672 instance ..
   659 
   673 
   660 end
   674 end
   661 
   675 
   662 instance "fun" :: (type, boolean_algebra) boolean_algebra
   676 instance "fun" :: (type, boolean_algebra) boolean_algebra proof
   663 proof
   677 qed (rule ext, simp_all add: inf_apply sup_apply bot_apply top_apply uminus_apply minus_apply inf_compl_bot sup_compl_top diff_eq)+
   664 qed (simp_all add: inf_fun_def sup_fun_def bot_fun_def top_fun_def fun_Compl_def fun_diff_def
       
   665   inf_compl_bot sup_compl_top diff_eq)
       
   666 
       
   667 
   678 
   668 no_notation
   679 no_notation
   669   less_eq  (infix "\<sqsubseteq>" 50) and
   680   less_eq  (infix "\<sqsubseteq>" 50) and
   670   less (infix "\<sqsubset>" 50) and
   681   less (infix "\<sqsubset>" 50) and
   671   inf  (infixl "\<sqinter>" 70) and
   682   inf  (infixl "\<sqinter>" 70) and