module Order.Diagram.Lub where

Least upper bounds🔗

A lub (short for least upper bound) for a family of elements is, as the name implies, a least elemnet among the upper boudns of the Being an upper bound means that we have for all Being the least upper bound means that if we’re given some other satisfying (for each then we have

The same observation about the naming of glbs vs meets applies to lubs, with the binary name being join.

  record is-lub
    {ℓᵢ} {I : Type ℓᵢ} (F : I → Ob) (lub : Ob)
    : Type (o ⊔ ℓ ⊔ ℓᵢ)
    where
    no-eta-equality
    field
      fam≤lub : ∀ i → F i ≤ lub
      least   : (ub' : Ob) → (∀ i → F i ≤ ub') → lub ≤ ub'

  record Lub {ℓᵢ} {I : Type ℓᵢ} (F : I → Ob) : Type (o ⊔ ℓ ⊔ ℓᵢ) where
    no-eta-equality
    field
      lub : Ob
      has-lub : is-lub F lub
    open is-lub has-lub public

Let be a family. If there is some such that for all then is the least upper bound of

  fam-bound→is-lub
    : ∀ {ℓᵢ} {I : Type ℓᵢ} {F : I → Ob}
    → (i : I) → (∀ j → F j ≤ F i)
    → is-lub P F (F i)
  fam-bound→is-lub i ge .fam≤lub = ge
  fam-bound→is-lub i ge .least y le = le i

If is the least upper bound of a constant family, then must be equal to every member of the family.

  lub-of-const-fam
    : ∀ {ℓᵢ} {I : Type ℓᵢ} {F : I → Ob} {x}
    → (∀ i j → F i ≡ F j)
    → is-lub P F x
    → ∀ i → F i ≡ x
  lub-of-const-fam {F = F} is-const x-lub i =
    ≤-antisym
      (fam≤lub x-lub i)
      (least x-lub (F i) λ j → ≤-refl' (sym (is-const i j)))

Furthermore, if is a constant family and is merely inhabited, then has a least upper bound.

  const-inhabited-fam→is-lub
    : ∀ {ℓᵢ} {I : Type ℓᵢ} {F : I → Ob} {x}
    → (∀ i → F i ≡ x)
    → ∥ I ∥
    → is-lub P F x
  const-inhabited-fam→is-lub {I = I} {F = F} {x = x} is-const =
    rec! mk-is-lub where
      mk-is-lub : I → is-lub P F x
      mk-is-lub i .is-lub.fam≤lub j = ≤-refl' (is-const j)
      mk-is-lub i .is-lub.least y le =
        x   =˘⟨ is-const i ⟩
        F i ≤⟨ le i ⟩
        y ≤∎

  const-inhabited-fam→lub
    : ∀ {ℓᵢ} {I : Type ℓᵢ} {F : I → Ob}
    → (∀ i j → F i ≡ F j)
    → ∥ I ∥
    → Lub P F
  const-inhabited-fam→lub {I = I} {F = F} is-const =
    rec! mk-lub where
      mk-lub : I → Lub P F
      mk-lub i .Lub.lub = F i
      mk-lub i .Lub.has-lub =
        const-inhabited-fam→is-lub (λ j → is-const j i) (inc i)