module Order.Instances.Lower where

Lower sets🔗

Imagine you have a poset which does not have all joins, and you want to freely (co)complete it into a poset which does, along a monotone map (which additionally preserves meets). To be clear, by a “free cocompletion” we mean that is the smallest cocomplete poset generated by in that any monotone map into a cocomplete poset can be extended uniquely to a cocontinuous monotone map

Lower-sets :  {ℓₒ ℓᵣ}  Poset ℓₒ ℓᵣ  Poset (ℓₒ  ℓᵣ) ℓₒ
Lower-sets P = Poset[ (P ^opp) , Props ]

Lower-set :  {ℓₒ ℓᵣ} (P : Poset ℓₒ ℓᵣ)  Type _
Lower-set P =  Lower-sets P 

Note the similarity between this construction and the Yoneda embedding: Indeed, if we take the perspective that a poset is a “” (as opposed to a “”), then the lower sets of are precisely the presheaves on

module _ {ℓₒ ℓᵣ} (P : Poset ℓₒ ℓᵣ) where
  private module P = Pr P

   :  P   Lower-set P
   a .hom b = elΩ (b P.≤ a)
   a .pres-≤ y<x x<a = P.≤-trans y<x <$> x<a

  よₚ : Monotone P (Lower-sets P)
  よₚ .hom = 
  よₚ .pres-≤ x≤y a a≤x =  P.≤-trans a≤x (pure x≤y) 

(Co)completeness🔗

Let us first show that the poset of lower sets is cocomplete (and complete), in that it admits all meets and joins. The meet of a family of lower sets is given by the product of the underlying propositions. Because propositional resizing, we can create meets of families indexed by arbitrarily large types:

  Lower-sets-complete
    :  {ℓ'} {I : Type ℓ'} (F : I  Lower-set P)  Glb (Lower-sets P) F
  Lower-sets-complete F .Glb.glb .hom i = elΩ (∀ j  i  F j)
  Lower-sets-complete F .Glb.glb .pres-≤ j≤i =
    □-map λ x∈Fj j  F j .pres-≤ j≤i (x∈Fj j)
  Lower-sets-complete F .Glb.has-glb .is-glb.glb≤fam i x x∈Fj = □-out! x∈Fj i
  Lower-sets-complete F .Glb.has-glb .is-glb.greatest lb' lb'≤Fi x y∈lb' =
    inc  j  lb'≤Fi j x y∈lb')

The same thing happens for joins, which are given by an existential quantifier. Note that we directly resize a sigma, because our resizing operator automatically propositionally truncates.

  Lower-sets-cocomplete
    :  {ℓ'} {I : Type ℓ'} (F : I  Lower-set P)  Lub (Lower-sets P) F
  Lower-sets-cocomplete {I = I} F .Lub.lub .hom i =
    elΩ (Σ[ j  I ] i  F j)
  Lower-sets-cocomplete F .Lub.lub .pres-≤ j≤i =
    □-map λ { (i , x∈Fi)  i , F i .pres-≤ j≤i x∈Fi }
  Lower-sets-cocomplete F .Lub.has-lub .is-lub.fam≤lub i x x∈Fi =
    inc (i , x∈Fi)
  Lower-sets-cocomplete F .Lub.has-lub .is-lub.least lb' lb'≤Fi x =
    rec! λ i x∈Fi  lb'≤Fi i x x∈Fi