src/HOL/Lattices.thy
changeset 52152 b561cdce6c4c
parent 51593 d40aec502416
child 52729 412c9e0381a1
equal deleted inserted replaced
52151:de43876e77bf 52152:b561cdce6c4c
    47 lemma orderE:
    47 lemma orderE:
    48   assumes "a \<preceq> b"
    48   assumes "a \<preceq> b"
    49   obtains "a = a * b"
    49   obtains "a = a * b"
    50   using assms by (unfold order_iff)
    50   using assms by (unfold order_iff)
    51 
    51 
    52 end
    52 sublocale ordering less_eq less
    53 
       
    54 sublocale semilattice_order < ordering less_eq less
       
    55 proof
    53 proof
    56   fix a b
    54   fix a b
    57   show "a \<prec> b \<longleftrightarrow> a \<preceq> b \<and> a \<noteq> b"
    55   show "a \<prec> b \<longleftrightarrow> a \<preceq> b \<and> a \<noteq> b"
    58     by (fact semilattice_strict_iff_order)
    56     by (fact semilattice_strict_iff_order)
    59 next
    57 next
    77     by (simp add: assoc)
    75     by (simp add: assoc)
    78   with `a = a * b` [symmetric] have "a = a * c" by simp
    76   with `a = a * b` [symmetric] have "a = a * c" by simp
    79   then show "a \<preceq> c" by (rule orderI)
    77   then show "a \<preceq> c" by (rule orderI)
    80 qed
    78 qed
    81 
    79 
    82 context semilattice_order
       
    83 begin
       
    84 
       
    85 lemma cobounded1 [simp]:
    80 lemma cobounded1 [simp]:
    86   "a * b \<preceq> a"
    81   "a * b \<preceq> a"
    87   by (simp add: order_iff commute)  
    82   by (simp add: order_iff commute)  
    88 
    83 
    89 lemma cobounded2 [simp]:
    84 lemma cobounded2 [simp]:
   130   by (rule antisym) (auto simp add: refl bounded_iff)
   125   by (rule antisym) (auto simp add: refl bounded_iff)
   131 
   126 
   132 end
   127 end
   133 
   128 
   134 locale semilattice_neutr_order = semilattice_neutr + semilattice_order
   129 locale semilattice_neutr_order = semilattice_neutr + semilattice_order
   135 
   130 begin
   136 sublocale semilattice_neutr_order < ordering_top less_eq less 1
   131 
       
   132 sublocale ordering_top less_eq less 1
   137   by default (simp add: order_iff)
   133   by default (simp add: order_iff)
       
   134 
       
   135 end
   138 
   136 
   139 notation times (infixl "*" 70)
   137 notation times (infixl "*" 70)
   140 notation Groups.one ("1")
   138 notation Groups.one ("1")
   141 
   139 
   142 
   140 
   253 end
   251 end
   254 
   252 
   255 
   253 
   256 subsubsection {* Equational laws *}
   254 subsubsection {* Equational laws *}
   257 
   255 
   258 sublocale semilattice_inf < inf!: semilattice inf
   256 context semilattice_inf
       
   257 begin
       
   258 
       
   259 sublocale inf!: semilattice inf
   259 proof
   260 proof
   260   fix a b c
   261   fix a b c
   261   show "(a \<sqinter> b) \<sqinter> c = a \<sqinter> (b \<sqinter> c)"
   262   show "(a \<sqinter> b) \<sqinter> c = a \<sqinter> (b \<sqinter> c)"
   262     by (rule antisym) (auto intro: le_infI1 le_infI2)
   263     by (rule antisym) (auto intro: le_infI1 le_infI2)
   263   show "a \<sqinter> b = b \<sqinter> a"
   264   show "a \<sqinter> b = b \<sqinter> a"
   264     by (rule antisym) auto
   265     by (rule antisym) auto
   265   show "a \<sqinter> a = a"
   266   show "a \<sqinter> a = a"
   266     by (rule antisym) auto
   267     by (rule antisym) auto
   267 qed
   268 qed
   268 
   269 
   269 sublocale semilattice_sup < sup!: semilattice sup
   270 sublocale inf!: semilattice_order inf less_eq less
       
   271   by default (auto simp add: le_iff_inf less_le)
       
   272 
       
   273 lemma inf_assoc: "(x \<sqinter> y) \<sqinter> z = x \<sqinter> (y \<sqinter> z)"
       
   274   by (fact inf.assoc)
       
   275 
       
   276 lemma inf_commute: "(x \<sqinter> y) = (y \<sqinter> x)"
       
   277   by (fact inf.commute)
       
   278 
       
   279 lemma inf_left_commute: "x \<sqinter> (y \<sqinter> z) = y \<sqinter> (x \<sqinter> z)"
       
   280   by (fact inf.left_commute)
       
   281 
       
   282 lemma inf_idem: "x \<sqinter> x = x"
       
   283   by (fact inf.idem) (* already simp *)
       
   284 
       
   285 lemma inf_left_idem: "x \<sqinter> (x \<sqinter> y) = x \<sqinter> y"
       
   286   by (fact inf.left_idem) (* already simp *)
       
   287 
       
   288 lemma inf_right_idem: "(x \<sqinter> y) \<sqinter> y = x \<sqinter> y"
       
   289   by (fact inf.right_idem) (* already simp *)
       
   290 
       
   291 lemma inf_absorb1: "x \<sqsubseteq> y \<Longrightarrow> x \<sqinter> y = x"
       
   292   by (rule antisym) auto
       
   293 
       
   294 lemma inf_absorb2: "y \<sqsubseteq> x \<Longrightarrow> x \<sqinter> y = y"
       
   295   by (rule antisym) auto
       
   296  
       
   297 lemmas inf_aci = inf_commute inf_assoc inf_left_commute inf_left_idem
       
   298 
       
   299 end
       
   300 
       
   301 context semilattice_sup
       
   302 begin
       
   303 
       
   304 sublocale sup!: semilattice sup
   270 proof
   305 proof
   271   fix a b c
   306   fix a b c
   272   show "(a \<squnion> b) \<squnion> c = a \<squnion> (b \<squnion> c)"
   307   show "(a \<squnion> b) \<squnion> c = a \<squnion> (b \<squnion> c)"
   273     by (rule antisym) (auto intro: le_supI1 le_supI2)
   308     by (rule antisym) (auto intro: le_supI1 le_supI2)
   274   show "a \<squnion> b = b \<squnion> a"
   309   show "a \<squnion> b = b \<squnion> a"
   275     by (rule antisym) auto
   310     by (rule antisym) auto
   276   show "a \<squnion> a = a"
   311   show "a \<squnion> a = a"
   277     by (rule antisym) auto
   312     by (rule antisym) auto
   278 qed
   313 qed
   279 
   314 
   280 sublocale semilattice_inf < inf!: semilattice_order inf less_eq less
   315 sublocale sup!: semilattice_order sup greater_eq greater
   281   by default (auto simp add: le_iff_inf less_le)
       
   282 
       
   283 sublocale semilattice_sup < sup!: semilattice_order sup greater_eq greater
       
   284   by default (auto simp add: le_iff_sup sup.commute less_le)
   316   by default (auto simp add: le_iff_sup sup.commute less_le)
   285 
       
   286 context semilattice_inf
       
   287 begin
       
   288 
       
   289 lemma inf_assoc: "(x \<sqinter> y) \<sqinter> z = x \<sqinter> (y \<sqinter> z)"
       
   290   by (fact inf.assoc)
       
   291 
       
   292 lemma inf_commute: "(x \<sqinter> y) = (y \<sqinter> x)"
       
   293   by (fact inf.commute)
       
   294 
       
   295 lemma inf_left_commute: "x \<sqinter> (y \<sqinter> z) = y \<sqinter> (x \<sqinter> z)"
       
   296   by (fact inf.left_commute)
       
   297 
       
   298 lemma inf_idem: "x \<sqinter> x = x"
       
   299   by (fact inf.idem) (* already simp *)
       
   300 
       
   301 lemma inf_left_idem: "x \<sqinter> (x \<sqinter> y) = x \<sqinter> y"
       
   302   by (fact inf.left_idem) (* already simp *)
       
   303 
       
   304 lemma inf_right_idem: "(x \<sqinter> y) \<sqinter> y = x \<sqinter> y"
       
   305   by (fact inf.right_idem) (* already simp *)
       
   306 
       
   307 lemma inf_absorb1: "x \<sqsubseteq> y \<Longrightarrow> x \<sqinter> y = x"
       
   308   by (rule antisym) auto
       
   309 
       
   310 lemma inf_absorb2: "y \<sqsubseteq> x \<Longrightarrow> x \<sqinter> y = y"
       
   311   by (rule antisym) auto
       
   312  
       
   313 lemmas inf_aci = inf_commute inf_assoc inf_left_commute inf_left_idem
       
   314 
       
   315 end
       
   316 
       
   317 context semilattice_sup
       
   318 begin
       
   319 
   317 
   320 lemma sup_assoc: "(x \<squnion> y) \<squnion> z = x \<squnion> (y \<squnion> z)"
   318 lemma sup_assoc: "(x \<squnion> y) \<squnion> z = x \<squnion> (y \<squnion> z)"
   321   by (fact sup.assoc)
   319   by (fact sup.assoc)
   322 
   320 
   323 lemma sup_commute: "(x \<squnion> y) = (y \<squnion> x)"
   321 lemma sup_commute: "(x \<squnion> y) = (y \<squnion> x)"
   467 
   465 
   468 
   466 
   469 subsection {* Bounded lattices and boolean algebras *}
   467 subsection {* Bounded lattices and boolean algebras *}
   470 
   468 
   471 class bounded_semilattice_inf_top = semilattice_inf + top
   469 class bounded_semilattice_inf_top = semilattice_inf + top
   472 
   470 begin
   473 sublocale bounded_semilattice_inf_top < inf_top!: semilattice_neutr inf top
   471 
       
   472 sublocale inf_top!: semilattice_neutr inf top
   474   + inf_top!: semilattice_neutr_order inf top less_eq less
   473   + inf_top!: semilattice_neutr_order inf top less_eq less
   475 proof
   474 proof
   476   fix x
   475   fix x
   477   show "x \<sqinter> \<top> = x"
   476   show "x \<sqinter> \<top> = x"
   478     by (rule inf_absorb1) simp
   477     by (rule inf_absorb1) simp
   479 qed
   478 qed
   480 
   479 
       
   480 end
       
   481 
   481 class bounded_semilattice_sup_bot = semilattice_sup + bot
   482 class bounded_semilattice_sup_bot = semilattice_sup + bot
   482 
   483 begin
   483 sublocale bounded_semilattice_sup_bot < sup_bot!: semilattice_neutr sup bot
   484 
       
   485 sublocale sup_bot!: semilattice_neutr sup bot
   484   + sup_bot!: semilattice_neutr_order sup bot greater_eq greater
   486   + sup_bot!: semilattice_neutr_order sup bot greater_eq greater
   485 proof
   487 proof
   486   fix x
   488   fix x
   487   show "x \<squnion> \<bottom> = x"
   489   show "x \<squnion> \<bottom> = x"
   488     by (rule sup_absorb1) simp
   490     by (rule sup_absorb1) simp
   489 qed
   491 qed
       
   492 
       
   493 end
   490 
   494 
   491 class bounded_lattice_bot = lattice + bot
   495 class bounded_lattice_bot = lattice + bot
   492 begin
   496 begin
   493 
   497 
   494 subclass bounded_semilattice_sup_bot ..
   498 subclass bounded_semilattice_sup_bot ..