# HG changeset patch # User nipkow # Date 1107971369 -3600 # Node ID 8c1910887be3d65cce0ede74857eaf2130a811ae # Parent 9de204d7b699a6b5bbc323dfb16d4f8e91a38c9b New diff -r 9de204d7b699 -r 8c1910887be3 src/HOL/Lattice_Locales.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Lattice_Locales.thy Wed Feb 09 18:49:29 2005 +0100 @@ -0,0 +1,156 @@ +(* Title: HOL/Lattices.thy + ID: $Id$ + Author: Tobias Nipkow +*) + +header {* Lattices via Locales *} + +theory Lattice_Locales +imports Set +begin + +subsection{* Lattices *} + +text{* This theory of lattice locales only defines binary sup and inf +operations. The extension to finite sets is done in theory @{text +Finite_Set}. In the longer term it may be better to define arbitrary +sups and infs via @{text THE}. *} + +locale partial_order = + fixes below :: "'a \ 'a \ bool" (infixl "\" 50) + assumes refl[iff]: "x \ x" + and trans: "x \ y \ y \ z \ x \ z" + and antisym: "x \ y \ y \ x \ x = y" + +locale lower_semilattice = partial_order + + fixes inf :: "'a \ 'a \ 'a" (infixl "\" 70) + assumes inf_le1: "x \ y \ x" and inf_le2: "x \ y \ y" + and inf_least: "x \ y \ x \ z \ x \ y \ z" + +locale upper_semilattice = partial_order + + fixes sup :: "'a \ 'a \ 'a" (infixl "\" 65) + assumes sup_ge1: "x \ x \ y" and sup_ge2: "y \ x \ y" + and sup_greatest: "y \ x \ z \ x \ y \ z \ x" + +locale lattice = lower_semilattice + upper_semilattice + +lemma (in lower_semilattice) inf_commute: "(x \ y) = (y \ x)" +by(blast intro: antisym inf_le1 inf_le2 inf_least) + +lemma (in upper_semilattice) sup_commute: "(x \ y) = (y \ x)" +by(blast intro: antisym sup_ge1 sup_ge2 sup_greatest) + +lemma (in lower_semilattice) inf_assoc: "(x \ y) \ z = x \ (y \ z)" +by(blast intro: antisym inf_le1 inf_le2 inf_least trans del:refl) + +lemma (in upper_semilattice) sup_assoc: "(x \ y) \ z = x \ (y \ z)" +by(blast intro!: antisym sup_ge1 sup_ge2 intro: sup_greatest trans del:refl) + +lemma (in lower_semilattice) inf_idem[simp]: "x \ x = x" +by(blast intro: antisym inf_le1 inf_le2 inf_least refl) + +lemma (in upper_semilattice) sup_idem[simp]: "x \ x = x" +by(blast intro: antisym sup_ge1 sup_ge2 sup_greatest refl) + +lemma (in lattice) inf_sup_absorb: "x \ (x \ y) = x" +by(blast intro: antisym inf_le1 inf_least sup_ge1) + +lemma (in lattice) sup_inf_absorb: "x \ (x \ y) = x" +by(blast intro: antisym sup_ge1 sup_greatest inf_le1) + +lemma (in lower_semilattice) inf_absorb: "x \ y \ x \ y = x" +by(blast intro: antisym inf_le1 inf_least refl) + +lemma (in upper_semilattice) sup_absorb: "x \ y \ x \ y = y" +by(blast intro: antisym sup_ge2 sup_greatest refl) + +text{* Towards distributivity: if you have one of them, you have them all. *} + +lemma (in lattice) distrib_imp1: +assumes D: "!!x y z. x \ (y \ z) = (x \ y) \ (x \ z)" +shows "x \ (y \ z) = (x \ y) \ (x \ z)" +proof- + have "x \ (y \ z) = (x \ (x \ z)) \ (y \ z)" by(simp add:sup_inf_absorb) + also have "\ = x \ (z \ (x \ y))" by(simp add:D inf_commute sup_assoc) + also have "\ = ((x \ y) \ x) \ ((x \ y) \ z)" + by(simp add:inf_sup_absorb inf_commute) + also have "\ = (x \ y) \ (x \ z)" by(simp add:D) + finally show ?thesis . +qed + +lemma (in lattice) distrib_imp2: +assumes D: "!!x y z. x \ (y \ z) = (x \ y) \ (x \ z)" +shows "x \ (y \ z) = (x \ y) \ (x \ z)" +proof- + have "x \ (y \ z) = (x \ (x \ z)) \ (y \ z)" by(simp add:inf_sup_absorb) + also have "\ = x \ (z \ (x \ y))" by(simp add:D sup_commute inf_assoc) + also have "\ = ((x \ y) \ x) \ ((x \ y) \ z)" + by(simp add:sup_inf_absorb sup_commute) + also have "\ = (x \ y) \ (x \ z)" by(simp add:D) + finally show ?thesis . +qed + +text{* A package of rewrite rules for deciding equivalence wrt ACI: *} + +lemma (in lower_semilattice) inf_left_commute: "x \ (y \ z) = y \ (x \ z)" +proof - + have "x \ (y \ z) = (y \ z) \ x" by (simp only: inf_commute) + also have "... = y \ (z \ x)" by (simp only: inf_assoc) + also have "z \ x = x \ z" by (simp only: inf_commute) + finally show ?thesis . +qed + +lemma (in upper_semilattice) sup_left_commute: "x \ (y \ z) = y \ (x \ z)" +proof - + have "x \ (y \ z) = (y \ z) \ x" by (simp only: sup_commute) + also have "... = y \ (z \ x)" by (simp only: sup_assoc) + also have "z \ x = x \ z" by (simp only: sup_commute) + finally show ?thesis . +qed + +lemma (in lower_semilattice) inf_left_idem: "x \ (x \ y) = x \ y" +proof - + have "x \ (x \ y) = (x \ x) \ y" by(simp only:inf_assoc) + also have "\ = x \ y" by(simp) + finally show ?thesis . +qed + +lemma (in upper_semilattice) sup_left_idem: "x \ (x \ y) = x \ y" +proof - + have "x \ (x \ y) = (x \ x) \ y" by(simp only:sup_assoc) + also have "\ = x \ y" by(simp) + finally show ?thesis . +qed + + +lemmas (in lower_semilattice) inf_ACI = + inf_commute inf_assoc inf_left_commute inf_left_idem + +lemmas (in upper_semilattice) sup_ACI = + sup_commute sup_assoc sup_left_commute sup_left_idem + +lemmas (in lattice) ACI = inf_ACI sup_ACI + + +subsection{* Distributive lattices *} + +locale distrib_lattice = lattice + + assumes sup_inf_distrib1: "x \ (y \ z) = (x \ y) \ (x \ z)" + +lemma (in distrib_lattice) sup_inf_distrib2: + "(y \ z) \ x = (y \ x) \ (z \ x)" +by(simp add:ACI sup_inf_distrib1) + +lemma (in distrib_lattice) inf_sup_distrib1: + "x \ (y \ z) = (x \ y) \ (x \ z)" +by(rule distrib_imp2[OF sup_inf_distrib1]) + +lemma (in distrib_lattice) inf_sup_distrib2: + "(y \ z) \ x = (y \ x) \ (z \ x)" +by(simp add:ACI inf_sup_distrib1) + +lemmas (in distrib_lattice) distrib = + sup_inf_distrib1 sup_inf_distrib2 inf_sup_distrib1 inf_sup_distrib2 + + +end