src/HOL/Lattices.thy
changeset 32568 89518a3074e1
parent 32512 d14762642cdd
child 32642 026e7c6a6d08
equal deleted inserted replaced
32561:fdbfa0e35e78 32568:89518a3074e1
    10 
    10 
    11 subsection {* Lattices *}
    11 subsection {* Lattices *}
    12 
    12 
    13 notation
    13 notation
    14   less_eq  (infix "\<sqsubseteq>" 50) and
    14   less_eq  (infix "\<sqsubseteq>" 50) and
    15   less  (infix "\<sqsubset>" 50)
    15   less  (infix "\<sqsubset>" 50) and
       
    16   top ("\<top>") and
       
    17   bot ("\<bottom>")
    16 
    18 
    17 class lower_semilattice = order +
    19 class lower_semilattice = order +
    18   fixes inf :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<sqinter>" 70)
    20   fixes inf :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<sqinter>" 70)
    19   assumes inf_le1 [simp]: "x \<sqinter> y \<sqsubseteq> x"
    21   assumes inf_le1 [simp]: "x \<sqinter> y \<sqsubseteq> x"
    20   and inf_le2 [simp]: "x \<sqinter> y \<sqsubseteq> y"
    22   and inf_le2 [simp]: "x \<sqinter> y \<sqsubseteq> y"
   218   finally show ?thesis .
   220   finally show ?thesis .
   219 qed
   221 qed
   220 
   222 
   221 end
   223 end
   222 
   224 
       
   225 subsubsection {* Strict order *}
       
   226 
       
   227 context lower_semilattice
       
   228 begin
       
   229 
       
   230 lemma less_infI1:
       
   231   "a \<sqsubset> x \<Longrightarrow> a \<sqinter> b \<sqsubset> x"
       
   232   by (auto simp add: less_le intro: le_infI1)
       
   233 
       
   234 lemma less_infI2:
       
   235   "b \<sqsubset> x \<Longrightarrow> a \<sqinter> b \<sqsubset> x"
       
   236   by (auto simp add: less_le intro: le_infI2)
       
   237 
       
   238 end
       
   239 
       
   240 context upper_semilattice
       
   241 begin
       
   242 
       
   243 lemma less_supI1:
       
   244   "x < a \<Longrightarrow> x < a \<squnion> b"
       
   245 proof -
       
   246   interpret dual: lower_semilattice "op \<ge>" "op >" sup
       
   247     by (fact dual_semilattice)
       
   248   assume "x < a"
       
   249   then show "x < a \<squnion> b"
       
   250     by (fact dual.less_infI1)
       
   251 qed
       
   252 
       
   253 lemma less_supI2:
       
   254   "x < b \<Longrightarrow> x < a \<squnion> b"
       
   255 proof -
       
   256   interpret dual: lower_semilattice "op \<ge>" "op >" sup
       
   257     by (fact dual_semilattice)
       
   258   assume "x < b"
       
   259   then show "x < a \<squnion> b"
       
   260     by (fact dual.less_infI2)
       
   261 qed
       
   262 
       
   263 end
       
   264 
   223 
   265 
   224 subsection {* Distributive lattices *}
   266 subsection {* Distributive lattices *}
   225 
   267 
   226 class distrib_lattice = lattice +
   268 class distrib_lattice = lattice +
   227   assumes sup_inf_distrib1: "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"
   269   assumes sup_inf_distrib1: "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"
   303   by (rule sup_absorb2) simp
   345   by (rule sup_absorb2) simp
   304 
   346 
   305 lemma sup_bot_right [simp]:
   347 lemma sup_bot_right [simp]:
   306   "x \<squnion> bot = x"
   348   "x \<squnion> bot = x"
   307   by (rule sup_absorb1) simp
   349   by (rule sup_absorb1) simp
       
   350 
       
   351 lemma inf_eq_top_eq1:
       
   352   assumes "A \<sqinter> B = \<top>"
       
   353   shows "A = \<top>"
       
   354 proof (cases "B = \<top>")
       
   355   case True with assms show ?thesis by simp
       
   356 next
       
   357   case False with top_greatest have "B < \<top>" by (auto intro: neq_le_trans)
       
   358   then have "A \<sqinter> B < \<top>" by (rule less_infI2)
       
   359   with assms show ?thesis by simp
       
   360 qed
       
   361 
       
   362 lemma inf_eq_top_eq2:
       
   363   assumes "A \<sqinter> B = \<top>"
       
   364   shows "B = \<top>"
       
   365   by (rule inf_eq_top_eq1, unfold inf_commute [of B]) (fact assms)
       
   366 
       
   367 lemma sup_eq_bot_eq1:
       
   368   assumes "A \<squnion> B = \<bottom>"
       
   369   shows "A = \<bottom>"
       
   370 proof -
       
   371   interpret dual: boolean_algebra "\<lambda>x y. x \<squnion> - y" uminus "op \<ge>" "op >" "op \<squnion>" "op \<sqinter>" top bot
       
   372     by (rule dual_boolean_algebra)
       
   373   from dual.inf_eq_top_eq1 assms show ?thesis .
       
   374 qed
       
   375 
       
   376 lemma sup_eq_bot_eq2:
       
   377   assumes "A \<squnion> B = \<bottom>"
       
   378   shows "B = \<bottom>"
       
   379 proof -
       
   380   interpret dual: boolean_algebra "\<lambda>x y. x \<squnion> - y" uminus "op \<ge>" "op >" "op \<squnion>" "op \<sqinter>" top bot
       
   381     by (rule dual_boolean_algebra)
       
   382   from dual.inf_eq_top_eq2 assms show ?thesis .
       
   383 qed
   308 
   384 
   309 lemma compl_unique:
   385 lemma compl_unique:
   310   assumes "x \<sqinter> y = bot"
   386   assumes "x \<sqinter> y = bot"
   311     and "x \<squnion> y = top"
   387     and "x \<squnion> y = top"
   312   shows "- x = y"
   388   shows "- x = y"
   515 
   591 
   516 no_notation
   592 no_notation
   517   less_eq  (infix "\<sqsubseteq>" 50) and
   593   less_eq  (infix "\<sqsubseteq>" 50) and
   518   less (infix "\<sqsubset>" 50) and
   594   less (infix "\<sqsubset>" 50) and
   519   inf  (infixl "\<sqinter>" 70) and
   595   inf  (infixl "\<sqinter>" 70) and
   520   sup  (infixl "\<squnion>" 65)
   596   sup  (infixl "\<squnion>" 65) and
   521 
   597   top ("\<top>") and
   522 end
   598   bot ("\<bottom>")
       
   599 
       
   600 end