module Order.Diagram.Meet.Reasoning
  {o β„“} {P : Poset o β„“} {_∩_ : ⌞ P ⌟ β†’ ⌞ P ⌟ β†’ ⌞ P ⌟}
  (∩-meets : βˆ€ x y β†’ is-meet P x y (x ∩ y))
  where

Reasoning about meetsπŸ”—

This module provides syntax and reasoning combinators for working with partial orders that have all meets.

meets : βˆ€ x y β†’ Meet P x y
meets x y .glb      = x ∩ y
meets x y .has-meet = ∩-meets x y

module meets {x} {y} = Meet (meets x y)
open meets renaming
  ( meet≀l to βˆ©β‰€l
  ; meet≀r to βˆ©β‰€r
  ; greatest to ∩-universal)
  public

The meet operation is idempotent and commutative.

abstract
  ∩-idem : βˆ€ {x} β†’ x ∩ x ≑ x
  ∩-idem = ≀-antisym βˆ©β‰€l (∩-universal _ ≀-refl ≀-refl)

  ∩-comm : βˆ€ {x y} β†’ x ∩ y ≑ y ∩ x
  ∩-comm =
    ≀-antisym
      (∩-universal _ βˆ©β‰€r βˆ©β‰€l)
      (∩-universal _ βˆ©β‰€r βˆ©β‰€l)

Furthermore, it is associative, and thus forms a semigroup.

  ∩-assoc : βˆ€ {x y z} β†’ x ∩ (y ∩ z) ≑ (x ∩ y) ∩ z
  ∩-assoc =
    ≀-antisym
      (∩-universal _
        (∩-universal _ βˆ©β‰€l (≀-trans βˆ©β‰€r βˆ©β‰€l))
        (≀-trans βˆ©β‰€r βˆ©β‰€r))
      (∩-universal _
        (≀-trans βˆ©β‰€l βˆ©β‰€l)
        (∩-universal _ (≀-trans βˆ©β‰€l βˆ©β‰€r) βˆ©β‰€r))

  ∩-is-semigroup : is-semigroup _∩_
  ∩-is-semigroup .has-is-magma .has-is-set = Ob-is-set
  ∩-is-semigroup .associative = ∩-assoc

Additionally, it respects the ordering on in each variable.

  βˆ©β‰€βˆ©
    : βˆ€ {x y x' y'}
    β†’ x ≀ x'
    β†’ y ≀ y'
    β†’ (x ∩ y) ≀ (x' ∩ y')
  βˆ©β‰€βˆ© p q = ∩-universal _ (≀-trans βˆ©β‰€l p) (≀-trans βˆ©β‰€r q)

Finally, we note that the meet operation determines the order on as witnessed by the following equivalence.

  βˆ©β†’order : βˆ€ {x y} β†’ x ∩ y ≑ x β†’ x ≀ y
  βˆ©β†’order {x} {y} p =
    x       =˘⟨ p ⟩=˘
    (x ∩ y) β‰€βŸ¨ βˆ©β‰€r βŸ©β‰€
    y       β‰€βˆŽ

  orderβ†’βˆ© : βˆ€ {x y} β†’ x ≀ y β†’ x ∩ y ≑ x
  orderβ†’βˆ© {x} {y} p = ≀-antisym βˆ©β‰€l (∩-universal _ ≀-refl p)

  βˆ©β‰ƒorder : βˆ€ {x y} β†’ (x ∩ y ≑ x) ≃ (x ≀ y)
  βˆ©β‰ƒorder = prop-ext! βˆ©β†’order orderβ†’βˆ©