open import Cat.Diagram.Product
open import Cat.Prelude

open import Data.Bool

open import Order.Diagram.Glb
open import Order.Base
open import Order.Cat

import Order.Reasoning
module Order.Diagram.Meet where
private variable
  o ā„“ : Level

MeetsšŸ”—

As mentioned before, in the binary case, we refer to glbs as meets: The meet of and is, if it exists, the greatest element satisfying and

record is-meet (P : Poset o ā„“) (a b glb : āŒž P āŒŸ) : Type (o āŠ” ā„“) where
  no-eta-equality
  open Poset P
  field
    meetā‰¤l   : glb ā‰¤ a
    meetā‰¤r   : glb ā‰¤ b
    greatest : (lb' : Ob) ā†’ lb' ā‰¤ a ā†’ lb' ā‰¤ b ā†’ lb' ā‰¤ glb

record Meet (P : Poset o ā„“) (a b : āŒž P āŒŸ) : Type (o āŠ” ā„“) where
  no-eta-equality
  field
    glb : āŒž P āŒŸ
    has-meet : is-meet P a b glb
  open is-meet has-meet public

open is-meet

Has-meets : Poset o ā„“ ā†’ Type (o āŠ” ā„“)
Has-meets P = āˆ€ x y ā†’ Meet P x y
unquoteDecl H-Level-is-meet = declare-record-hlevel 1 H-Level-is-meet (quote is-meet)

module _ {P : Poset o ā„“} where
  open Poset P
  open is-glb
  open Glb

A shuffling of terms shows that being a meet is precisely being the greatest lower bound of a family of two elements.

  is-meetā†’is-glb : āˆ€ {a b glb} ā†’ is-meet P a b glb ā†’ is-glb P (if_then a else b) glb
  is-meetā†’is-glb meet .glbā‰¤fam true = meet .meetā‰¤l
  is-meetā†’is-glb meet .glbā‰¤fam false = meet .meetā‰¤r
  is-meetā†’is-glb meet .greatest glb' x = meet .greatest glb' (x true) (x false)

  is-glbā†’is-meet : āˆ€ {F : Bool ā†’ Ob} {glb} ā†’ is-glb P F glb ā†’ is-meet P (F true) (F false) glb
  is-glbā†’is-meet glb .meetā‰¤l = glb .glbā‰¤fam true
  is-glbā†’is-meet glb .meetā‰¤r = glb .glbā‰¤fam false
  is-glbā†’is-meet glb .greatest lb' lb'<a lb'<b = glb .greatest lb' Ī» where
    true  ā†’ lb'<a
    false ā†’ lb'<b
  meet-unique : āˆ€ {a b x y} ā†’ is-meet P a b x ā†’ is-meet P a b y ā†’ x ā‰” y
  meet-unique {a = a} {b} x-meet y-meet = glb-unique
    (is-meetā†’is-glb x-meet)
    (is-meetā†’is-glb y-meet)

  Meet-is-prop : āˆ€ {a b} ā†’ is-prop (Meet P a b)
  Meet-is-prop p q i .Meet.glb =
    meet-unique (Meet.has-meet p) (Meet.has-meet q) i
  Meet-is-prop {a = a} {b = b} p q i .Meet.has-meet =
    is-propā†’pathp
      {B = Ī» i ā†’ is-meet P a b (meet-unique (Meet.has-meet p) (Meet.has-meet q) i)}
      (Ī» i ā†’ hlevel 1)
      (Meet.has-meet p) (Meet.has-meet q) i

  instance
    H-Level-Meet
      : āˆ€ {a b} {n}
      ā†’ H-Level (Meet P a b) (suc n)
    H-Level-Meet = prop-instance Meet-is-prop

  Meetā†’Glb : āˆ€ {a b} ā†’ Meet P a b ā†’ Glb P (if_then a else b)
  Meetā†’Glb meet .Glb.glb = Meet.glb meet
  Meetā†’Glb meet .Glb.has-glb = is-meetā†’is-glb (Meet.has-meet meet)

  Glbā†’Meet : āˆ€ {a b} ā†’ Glb P (if_then a else b) ā†’ Meet P a b
  Glbā†’Meet glb .Meet.glb = Glb.glb glb
  Glbā†’Meet glb .Meet.has-meet = is-glbā†’is-meet (Glb.has-glb glb)

  is-meetā‰ƒis-glb : āˆ€ {a b glb} ā†’ is-equiv (is-meetā†’is-glb {a} {b} {glb})
  is-meetā‰ƒis-glb = biimp-is-equiv! _ is-glbā†’is-meet

  Meetā‰ƒGlb : āˆ€ {a b} ā†’ is-equiv (Meetā†’Glb {a} {b})
  Meetā‰ƒGlb = biimp-is-equiv! _ Glbā†’Meet

An important lemma about meets is that, if then the greatest lower bound of and is just

  leā†’is-meet : āˆ€ {a b} ā†’ a ā‰¤ b ā†’ is-meet P a b a
  leā†’is-meet aā‰¤b .meetā‰¤l = ā‰¤-refl
  leā†’is-meet aā‰¤b .meetā‰¤r = aā‰¤b
  leā†’is-meet aā‰¤b .greatest lb' lb'ā‰¤a _ = lb'ā‰¤a

  le-meet : āˆ€ {a b l} ā†’ a ā‰¤ b ā†’ is-meet P a b l ā†’ a ā‰” l
  le-meet aā‰¤b l = meet-unique (leā†’is-meet aā‰¤b) l

As productsšŸ”—

When passing from posets to categories, meets become products: coming from the other direction, if a category has each a proposition, then products in are simply meets.

  open is-product
  open Product

  is-meetā†’product : āˆ€ {a b glb : Ob} ā†’ is-meet P a b glb ā†’ Product (posetā†’category P) a b
  is-meetā†’product glb .apex = _
  is-meetā†’product glb .Ļ€ā‚ = glb .is-meet.meetā‰¤l
  is-meetā†’product glb .Ļ€ā‚‚ = glb .is-meet.meetā‰¤r
  is-meetā†’product glb .has-is-product .āŸØ_,_āŸ© q<a q<b =
    glb .is-meet.greatest _ q<a q<b
  is-meetā†’product glb .has-is-product .Ļ€ā‚āˆ˜āŸØāŸ© = prop!
  is-meetā†’product glb .has-is-product .Ļ€ā‚‚āˆ˜āŸØāŸ© = prop!
  is-meetā†’product glb .has-is-product .unique _ _ = prop!