module Order.Diagram.Glb where

Greatest lower bounds🔗

A glb (short for greatest lower bound) for a family of elements is, as the name implies, a greatest element among the lower bounds of the Being a lower bound means that we have for all Being the greatest lower bound means that if we’re given some other satisfying (for each then we have

A more common word to use for “greatest lower bound” is “meet”. But since “meet” is a fairly uninformative name, and “glb” (pronounced “glib”) is just plain fun to say, we stick with the non-word for the indexed concept. However, if we’re talking about the glb of a binary family, then we use the word “meet”. The distinction here is entirely artificial, and it’s just because we can’t reuse the identifier is-glb for these two slightly different cases. Summing up: to us, a meet is a glb of two elements.

  record is-glb {ℓᵢ} {I : Type ℓᵢ} (F : I  Ob) (glb : Ob)
          : Type (o    ℓᵢ) where
    no-eta-equality
    field
      glb≤fam  :  i  glb  F i
      greatest : (lb' : Ob)  (∀ i  lb'  F i)  lb'  glb

  record Glb {ℓᵢ} {I : Type ℓᵢ} (F : I  Ob) : Type (o    ℓᵢ) where
    no-eta-equality
    field
      glb : Ob
      has-glb : is-glb F glb
    open is-glb has-glb public
unquoteDecl H-Level-is-glb = declare-record-hlevel 1 H-Level-is-glb (quote is-glb)

module _ {o } {P : Poset o } where
  open Poset P
  open is-glb

  glb-unique
    :  {ℓᵢ} {I : Type ℓᵢ} {F : I  Ob} {x y}
     is-glb P F x  is-glb P F y
     x  y
  glb-unique is is' = ≤-antisym
    (is' .greatest _ (is .glb≤fam))
    (is .greatest _ (is' .glb≤fam))

  Glb-is-prop
    :  {ℓᵢ} {I : Type ℓᵢ} {F : I  Ob}
     is-prop (Glb P F)
  Glb-is-prop p q i .Glb.glb =
    glb-unique (Glb.has-glb p) (Glb.has-glb q) i
  Glb-is-prop {F = F} p q i .Glb.has-glb =
    is-prop→pathp {B = λ i  is-glb P F (glb-unique (Glb.has-glb p) (Glb.has-glb q) i)}
       i  hlevel 1)
      (Glb.has-glb p) (Glb.has-glb q) i

  instance
    H-Level-Glb
      :  {ℓᵢ} {I : Type ℓᵢ} {F : I  Ob} {n}
       H-Level (Glb P F) (suc n)
    H-Level-Glb = prop-instance Glb-is-prop

  lift-is-glb
    :  {ℓᵢ ℓᵢ'} {I : Type ℓᵢ} {F : I  Ob} {glb}
     is-glb P F glb  is-glb P (F  lower { = ℓᵢ'}) glb
  lift-is-glb is .glb≤fam (lift ix) = is .glb≤fam ix
  lift-is-glb is .greatest ub' le = is .greatest ub' (le  lift)

  lift-glb
    :  {ℓᵢ ℓᵢ'} {I : Type ℓᵢ} {F : I  Ob}
     Glb P F  Glb P (F  lower { = ℓᵢ'})
  lift-glb glb .Glb.glb = Glb.glb glb
  lift-glb glb .Glb.has-glb = lift-is-glb (Glb.has-glb glb)

  lower-is-glb
    :  {ℓᵢ ℓᵢ'} {I : Type ℓᵢ} {F : I  Ob} {glb}
     is-glb P (F  lower { = ℓᵢ'}) glb  is-glb P F glb
  lower-is-glb is .glb≤fam ix = is .glb≤fam (lift ix)
  lower-is-glb is .greatest ub' le = is .greatest ub' (le  lower)

  lower-glb
    :  {ℓᵢ ℓᵢ'} {I : Type ℓᵢ} {F : I  Ob}
     Glb P (F  lower { = ℓᵢ'})  Glb P F
  lower-glb glb .Glb.glb = Glb.glb glb
  lower-glb glb .Glb.has-glb = lower-is-glb (Glb.has-glb glb)

As limits🔗

If a poset has all greatest lower bounds of size then it is complete when viewed as a category.

  glbs→complete
    :  { ℓκ}
     (∀ {I : Type } (k : I  Ob)  Glb P k)
     is-complete  ℓκ (poset→category P)
  glbs→complete glbs K = to-limit (to-is-limit lim) where
    open make-is-limit
    module K = Functor K
    open Glb (glbs K.₀)

    lim : make-is-limit K glb
    lim .ψ = glb≤fam
    lim .commutes _ = prop!
    lim .universal eps _ = greatest _ eps
    lim .factors _ _ = prop!
    lim .unique _ _ _ _ = prop!