module Order.Lattice.Distributive {o β„“} {P : Poset o β„“} (l : is-lattice P) where

Distributive latticesπŸ”—

A distributive lattice, as the name implies, is a lattice where the operations of meet and join distribute over each other: that is, for any triple of elements

Rather remarkably, it turns out that either equation implies the other. We provide a pair of parametrised modules which quantifies over one of the equations and proves the other. For convenience, these modules also define distributivity on the right, too; this is a consequence of both meets and joins being commutative operators.

  module from-∩ (∩-distribl : βˆ€ {x y z} β†’ x ∩ (y βˆͺ z) ≑ (x ∩ y) βˆͺ (x ∩ z)) where abstract
    ∩-distribr : βˆ€ {x y z} β†’ (y βˆͺ z) ∩ x ≑ (y ∩ x) βˆͺ (z ∩ x)
    ∩-distribr = ∩-comm Β·Β· ∩-distribl Β·Β· apβ‚‚ _βˆͺ_ ∩-comm ∩-comm

    βˆͺ-distribl : βˆ€ {x y z} β†’ x βˆͺ (y ∩ z) ≑ (x βˆͺ y) ∩ (x βˆͺ z)
    βˆͺ-distribl {x} {y} {z} = sym $
      (x βˆͺ y) ∩ (x βˆͺ z)             β‰‘βŸ¨ ∩-distribl βŸ©β‰‘
      ((x βˆͺ y) ∩ x) βˆͺ ((x βˆͺ y) ∩ z) β‰‘βŸ¨ apβ‚‚ _βˆͺ_ ∩-absorbr refl βŸ©β‰‘
      x βˆͺ ((x βˆͺ y) ∩ z)             β‰‘βŸ¨ apβ‚‚ _βˆͺ_ refl ∩-distribr βŸ©β‰‘
      x βˆͺ (x ∩ z βˆͺ y ∩ z)           β‰‘βŸ¨ βˆͺ-assoc βŸ©β‰‘
      (x βˆͺ x ∩ z) βˆͺ (y ∩ z)         β‰‘βŸ¨ apβ‚‚ _βˆͺ_ βˆͺ-absorbl refl βŸ©β‰‘
      x βˆͺ (y ∩ z)                   ∎

    βˆͺ-distribr : βˆ€ {x y z} β†’ (y ∩ z) βˆͺ x ≑ (y βˆͺ x) ∩ (z βˆͺ x)
    βˆͺ-distribr = βˆͺ-comm Β·Β· βˆͺ-distribl Β·Β· apβ‚‚ _∩_ βˆͺ-comm βˆͺ-comm
The construction assuming that join distributes over meet is formally dual.
  module from-βˆͺ (βˆͺ-distribl : βˆ€ {x y z} β†’ x βˆͺ (y ∩ z) ≑ (x βˆͺ y) ∩ (x βˆͺ z)) where abstract
    βˆͺ-distribr : βˆ€ {x y z} β†’ (y ∩ z) βˆͺ x ≑ (y βˆͺ x) ∩ (z βˆͺ x)
    βˆͺ-distribr = βˆͺ-comm Β·Β· βˆͺ-distribl Β·Β· apβ‚‚ _∩_ βˆͺ-comm βˆͺ-comm

    ∩-distribl : βˆ€ {x y z} β†’ x ∩ (y βˆͺ z) ≑ (x ∩ y) βˆͺ (x ∩ z)
    ∩-distribl {x} {y} {z} = sym $
      (x ∩ y) βˆͺ (x ∩ z)             β‰‘βŸ¨ βˆͺ-distribl βŸ©β‰‘
      ((x ∩ y) βˆͺ x) ∩ ((x ∩ y) βˆͺ z) β‰‘βŸ¨ apβ‚‚ _∩_ βˆͺ-absorbr refl βŸ©β‰‘
      x ∩ ((x ∩ y) βˆͺ z)             β‰‘βŸ¨ apβ‚‚ _∩_ refl βˆͺ-distribr βŸ©β‰‘
      x ∩ (x βˆͺ z) ∩ (y βˆͺ z)         β‰‘βŸ¨ ∩-assoc βŸ©β‰‘
      (x ∩ (x βˆͺ z)) ∩ (y βˆͺ z)       β‰‘βŸ¨ apβ‚‚ _∩_ ∩-absorbl refl βŸ©β‰‘
      x ∩ (y βˆͺ z)                   ∎

    ∩-distribr : βˆ€ {x y z} β†’ (y βˆͺ z) ∩ x ≑ (y ∩ x) βˆͺ (z ∩ x)
    ∩-distribr = ∩-comm Β·Β· ∩-distribl Β·Β· apβ‚‚ _βˆͺ_ ∩-comm ∩-comm

As a further weakening of the preconditions, it turns out that it suffices for distributivity to hold as an inequality, in the direction

since the other direction always holds in a lattice.

distrib-leβ†’βˆ©-distribl
  : (βˆ€ {x y z} β†’ x ∩ (y βˆͺ z) ≀ (x ∩ y) βˆͺ (x ∩ z))
  β†’ βˆ€ {x y z} β†’ x ∩ (y βˆͺ z) ≑ (x ∩ y) βˆͺ (x ∩ z)
distrib-leβ†’βˆ©-distribl ∩-βˆͺ-distrib≀ = ≀-antisym ∩-βˆͺ-distrib≀ βˆͺ-∩-distribl-≀