src/HOL/Lattices.thy
changeset 26794 354c3844dfde
parent 26233 3751b3dbb67c
child 27682 25aceefd4786
equal deleted inserted replaced
26793:e36a92ff543e 26794:354c3844dfde
     4 *)
     4 *)
     5 
     5 
     6 header {* Abstract lattices *}
     6 header {* Abstract lattices *}
     7 
     7 
     8 theory Lattices
     8 theory Lattices
     9 imports Orderings
     9 imports Fun
    10 begin
    10 begin
    11 
    11 
    12 subsection{* Lattices *}
    12 subsection{* Lattices *}
    13 
    13 
    14 notation
    14 notation
   504 
   504 
   505 lemma bot_bool_eq: "bot = False"
   505 lemma bot_bool_eq: "bot = False"
   506   by (iprover intro!: order_antisym le_boolI bot_least)
   506   by (iprover intro!: order_antisym le_boolI bot_least)
   507 
   507 
   508 
   508 
   509 subsection {* Set as lattice *}
       
   510 
       
   511 instantiation set :: (type) distrib_lattice
       
   512 begin
       
   513 
       
   514 definition
       
   515   inf_set_eq [code func del]: "A \<sqinter> B = A \<inter> B"
       
   516 
       
   517 definition
       
   518   sup_set_eq [code func del]: "A \<squnion> B = A \<union> B"
       
   519 
       
   520 instance
       
   521   by intro_classes (auto simp add: inf_set_eq sup_set_eq)
       
   522 
       
   523 end
       
   524 
       
   525 lemma mono_Int: "mono f \<Longrightarrow> f (A \<inter> B) \<subseteq> f A \<inter> f B"
       
   526   apply (fold inf_set_eq sup_set_eq)
       
   527   apply (erule mono_inf)
       
   528   done
       
   529 
       
   530 lemma mono_Un: "mono f \<Longrightarrow> f A \<union> f B \<subseteq> f (A \<union> B)"
       
   531   apply (fold inf_set_eq sup_set_eq)
       
   532   apply (erule mono_sup)
       
   533   done
       
   534 
       
   535 instantiation set :: (type) complete_lattice
       
   536 begin
       
   537 
       
   538 definition
       
   539   Inf_set_def [code func del]: "\<Sqinter>S \<equiv> \<Inter>S"
       
   540 
       
   541 definition
       
   542   Sup_set_def [code func del]: "\<Squnion>S \<equiv> \<Union>S"
       
   543 
       
   544 instance
       
   545   by intro_classes (auto simp add: Inf_set_def Sup_set_def)
       
   546 
       
   547 end
       
   548 
       
   549 lemma top_set_eq: "top = UNIV"
       
   550   by (iprover intro!: subset_antisym subset_UNIV top_greatest)
       
   551 
       
   552 lemma bot_set_eq: "bot = {}"
       
   553   by (iprover intro!: subset_antisym empty_subsetI bot_least)
       
   554 
       
   555 
       
   556 subsection {* Fun as lattice *}
   509 subsection {* Fun as lattice *}
   557 
   510 
   558 instantiation "fun" :: (type, lattice) lattice
   511 instantiation "fun" :: (type, lattice) lattice
   559 begin
   512 begin
   560 
   513 
   608 
   561 
   609 lemma bot_fun_eq: "bot = (\<lambda>x. bot)"
   562 lemma bot_fun_eq: "bot = (\<lambda>x. bot)"
   610   by (iprover intro!: order_antisym le_funI bot_least)
   563   by (iprover intro!: order_antisym le_funI bot_least)
   611 
   564 
   612 
   565 
       
   566 subsection {* Set as lattice *}
       
   567 
       
   568 lemma inf_set_eq: "A \<sqinter> B = A \<inter> B"
       
   569   apply (rule subset_antisym)
       
   570   apply (rule Int_greatest)
       
   571   apply (rule inf_le1)
       
   572   apply (rule inf_le2)
       
   573   apply (rule inf_greatest)
       
   574   apply (rule Int_lower1)
       
   575   apply (rule Int_lower2)
       
   576   done
       
   577 
       
   578 lemma sup_set_eq: "A \<squnion> B = A \<union> B"
       
   579   apply (rule subset_antisym)
       
   580   apply (rule sup_least)
       
   581   apply (rule Un_upper1)
       
   582   apply (rule Un_upper2)
       
   583   apply (rule Un_least)
       
   584   apply (rule sup_ge1)
       
   585   apply (rule sup_ge2)
       
   586   done
       
   587 
       
   588 lemma mono_Int: "mono f \<Longrightarrow> f (A \<inter> B) \<subseteq> f A \<inter> f B"
       
   589   apply (fold inf_set_eq sup_set_eq)
       
   590   apply (erule mono_inf)
       
   591   done
       
   592 
       
   593 lemma mono_Un: "mono f \<Longrightarrow> f A \<union> f B \<subseteq> f (A \<union> B)"
       
   594   apply (fold inf_set_eq sup_set_eq)
       
   595   apply (erule mono_sup)
       
   596   done
       
   597 
       
   598 lemma Inf_set_eq: "\<Sqinter>S = \<Inter>S"
       
   599   apply (rule subset_antisym)
       
   600   apply (rule Inter_greatest)
       
   601   apply (erule Inf_lower)
       
   602   apply (rule Inf_greatest)
       
   603   apply (erule Inter_lower)
       
   604   done
       
   605 
       
   606 lemma Sup_set_eq: "\<Squnion>S = \<Union>S"
       
   607   apply (rule subset_antisym)
       
   608   apply (rule Sup_least)
       
   609   apply (erule Union_upper)
       
   610   apply (rule Union_least)
       
   611   apply (erule Sup_upper)
       
   612   done
       
   613   
       
   614 lemma top_set_eq: "top = UNIV"
       
   615   by (iprover intro!: subset_antisym subset_UNIV top_greatest)
       
   616 
       
   617 lemma bot_set_eq: "bot = {}"
       
   618   by (iprover intro!: subset_antisym empty_subsetI bot_least)
       
   619 
       
   620 
   613 text {* redundant bindings *}
   621 text {* redundant bindings *}
   614 
   622 
   615 lemmas inf_aci = inf_ACI
   623 lemmas inf_aci = inf_ACI
   616 lemmas sup_aci = sup_ACI
   624 lemmas sup_aci = sup_ACI
   617 
   625