Tom de Jong, May 2019.
Refactored January 2020, December 2021.
February 2022: Show that pointed dcpos have semidirected and subsingleton
               suprema.

We define dcpos with a least element, typically denoted by βŠ₯, which are called
pointed dcpos. A map between pointed dcpos is called strict if it preserves
least elements. We show that every isomorphism of dcpos is strict.

Finally, we show that pointed dcpos have semidirected and subsingleton suprema
and that these are preserved by maps that are both strict and Scott continuous.

\begin{code}

{-# OPTIONS --safe --without-K #-}

open import MLTT.Spartan
open import UF.FunExt
open import UF.PropTrunc

module DomainTheory.Basics.Pointed
        (pt : propositional-truncations-exist)
        (fe : Fun-Ext)
        (π“₯ : Universe)
       where

open PropositionalTruncation pt hiding (_∨_)

open import UF.Subsingletons

open import DomainTheory.Basics.Dcpo pt fe π“₯
open import DomainTheory.Basics.Miscelanea pt fe π“₯

module _ {𝓀 𝓣 : Universe} where

 DCPOβŠ₯ : (π“₯ ⁺) βŠ” (𝓀 ⁺) βŠ” (𝓣 ⁺) Μ‡
 DCPOβŠ₯ = Ξ£ 𝓓 κž‰ DCPO {𝓀} {𝓣} , has-least (underlying-order 𝓓)

 _⁻ : DCPOβŠ₯ β†’ DCPO
 _⁻ = pr₁

 βŸͺ_⟫ : DCPOβŠ₯ β†’ 𝓀 Μ‡
 βŸͺ 𝓓 ⟫ = ⟨ 𝓓 ⁻ ⟩

 underlying-orderβŠ₯ : (𝓓 : DCPOβŠ₯) β†’ βŸͺ 𝓓 ⟫ β†’ βŸͺ 𝓓 ⟫ β†’ 𝓣 Μ‡
 underlying-orderβŠ₯ 𝓓 = underlying-order (𝓓 ⁻)

 syntax underlying-orderβŠ₯ 𝓓 x y = x βŠ‘βŸͺ 𝓓 ⟫ y

 βŠ₯ : (𝓓 : DCPOβŠ₯) β†’ ⟨ 𝓓 ⁻ ⟩
 βŠ₯ (𝓓 , x , p) = x

 βŠ₯-is-least : (𝓓 : DCPOβŠ₯) β†’ is-least (underlying-order (𝓓 ⁻)) (βŠ₯ 𝓓)
 βŠ₯-is-least (𝓓 , x , p) = p

 transitivity'' : (𝓓 : DCPOβŠ₯) (x : βŸͺ 𝓓 ⟫) {y z : βŸͺ 𝓓 ⟫}
               β†’ x βŠ‘βŸͺ 𝓓 ⟫ y β†’ y βŠ‘βŸͺ 𝓓 ⟫ z β†’ x βŠ‘βŸͺ 𝓓 ⟫ z
 transitivity'' 𝓓 = transitivity' (𝓓 ⁻)

 reflexivity' : (𝓓 : DCPOβŠ₯) β†’ reflexive (underlying-order (𝓓 ⁻))
 reflexivity' (D , _) = reflexivity D

 syntax transitivity'' 𝓓 x u v = x βŠ‘βŸͺ 𝓓 ⟫[ u ] v
 infixr 0 transitivity''

 syntax reflexivity' 𝓓 x = x ∎βŸͺ 𝓓 ⟫
 infix 1 reflexivity'

is-a-non-trivial-pointed-dcpo : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) β†’ 𝓀 Μ‡
is-a-non-trivial-pointed-dcpo 𝓓 = βˆƒ x κž‰ βŸͺ 𝓓 ⟫ , x β‰  βŠ₯ 𝓓

=-to-βŠ₯-criterion : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {x : βŸͺ 𝓓 ⟫} β†’ x βŠ‘βŸͺ 𝓓 ⟫ βŠ₯ 𝓓 β†’ x = βŠ₯ 𝓓
=-to-βŠ₯-criterion 𝓓 {x} x-below-βŠ₯ =
 antisymmetry (𝓓 ⁻) x (βŠ₯ 𝓓) x-below-βŠ₯ (βŠ₯-is-least 𝓓 x)

DCPOβŠ₯[_,_] : DCPOβŠ₯ {𝓀} {𝓣} β†’ DCPOβŠ₯ {𝓀'} {𝓣'} β†’ (π“₯ ⁺) βŠ” 𝓀 βŠ” 𝓣 βŠ” 𝓀' βŠ” 𝓣' Μ‡
DCPOβŠ₯[ 𝓓 , 𝓔 ] = DCPO[ 𝓓 ⁻ , 𝓔 ⁻ ]

is-strict : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
          β†’ (βŸͺ 𝓓 ⟫ β†’ βŸͺ 𝓔 ⟫)
          β†’ 𝓀' Μ‡
is-strict 𝓓 𝓔 f = f (βŠ₯ 𝓓) = βŠ₯ 𝓔

∘-is-strict : {𝓀'' 𝓣'' : Universe}
              (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
              (𝓔' : DCPOβŠ₯ {𝓀''} {𝓣''})
              (f : βŸͺ 𝓓 ⟫ β†’ βŸͺ 𝓔 ⟫) (g : βŸͺ 𝓔 ⟫ β†’ βŸͺ 𝓔' ⟫)
            β†’ is-strict 𝓓 𝓔 f
            β†’ is-strict 𝓔 𝓔' g
            β†’ is-strict 𝓓 𝓔' (g ∘ f)
∘-is-strict 𝓓 𝓔 𝓔' f g sf sg = ap g sf βˆ™ sg

being-strict-is-prop : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
                       (f : βŸͺ 𝓓 ⟫ β†’ βŸͺ 𝓔 ⟫)
                     β†’ is-prop (is-strict 𝓓 𝓔 f)
being-strict-is-prop 𝓓 𝓔 f = sethood (𝓔 ⁻)

strictness-criterion : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
                       (f : βŸͺ 𝓓 ⟫ β†’ βŸͺ 𝓔 ⟫)
                     β†’ f (βŠ₯ 𝓓) βŠ‘βŸͺ 𝓔 ⟫ βŠ₯ 𝓔
                     β†’ is-strict 𝓓 𝓔 f
strictness-criterion 𝓓 𝓔 f crit =
 antisymmetry (𝓔 ⁻) (f (βŠ₯ 𝓓)) (βŠ₯ 𝓔) crit (βŠ₯-is-least 𝓔 (f (βŠ₯ 𝓓)))

\end{code}

Defining isomorphisms of pointed dcpos and showing that every isomorphism of
dcpos is automatically strict.

\begin{code}

_β‰ƒα΅ˆαΆœα΅–α΅’βŠ₯_ : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'}) β†’ π“₯ ⁺ βŠ” 𝓀 βŠ” 𝓣 βŠ” 𝓀' βŠ” 𝓣' Μ‡
𝓓 β‰ƒα΅ˆαΆœα΅–α΅’βŠ₯ 𝓔 = Ξ£ f κž‰ (⟨ 𝓓 ⁻ ⟩ β†’ ⟨ 𝓔 ⁻ ⟩) , Ξ£ g κž‰ (⟨ 𝓔 ⁻ ⟩ β†’ ⟨ 𝓓 ⁻ ⟩) ,
                ((d : ⟨ 𝓓 ⁻ ⟩) β†’ g (f d) = d)
               Γ— ((e : ⟨ 𝓔 ⁻ ⟩) β†’ f (g e) = e)
               Γ— is-continuous (𝓓 ⁻) (𝓔 ⁻) f
               Γ— is-continuous (𝓔 ⁻) (𝓓 ⁻) g
               Γ— is-strict 𝓓 𝓔 f
               Γ— is-strict 𝓔 𝓓 g

β‰ƒα΅ˆαΆœα΅–α΅’βŠ₯-to-β‰ƒα΅ˆαΆœα΅–α΅’ : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
                β†’ 𝓓 β‰ƒα΅ˆαΆœα΅–α΅’βŠ₯ 𝓔 β†’ (𝓓 ⁻) β‰ƒα΅ˆαΆœα΅–α΅’ (𝓔 ⁻)
β‰ƒα΅ˆαΆœα΅–α΅’βŠ₯-to-β‰ƒα΅ˆαΆœα΅–α΅’ 𝓓 𝓔 (f , g , s , r , cf , cg , sf , sg) =
 f , g , s , r , cf , cg

β‰ƒα΅ˆαΆœα΅–α΅’-to-β‰ƒα΅ˆαΆœα΅–α΅’βŠ₯ : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
                β†’ (𝓓 ⁻) β‰ƒα΅ˆαΆœα΅–α΅’ (𝓔 ⁻) β†’ 𝓓 β‰ƒα΅ˆαΆœα΅–α΅’βŠ₯ 𝓔
β‰ƒα΅ˆαΆœα΅–α΅’-to-β‰ƒα΅ˆαΆœα΅–α΅’βŠ₯ 𝓓 𝓔 (f , g , gf , fg , cf , cg) =
 f , g , gf , fg , cf , cg , sf , sg
  where
   sf : is-strict 𝓓 𝓔 f
   sf = antisymmetry (𝓔 ⁻) (f (βŠ₯ 𝓓)) (βŠ₯ 𝓔) Ξ³ (βŠ₯-is-least 𝓔 (f (βŠ₯ 𝓓)))
    where
     Ξ³ = f (βŠ₯ 𝓓)     βŠ‘βŸ¨ 𝓔 ⁻ ⟩[ l₁ ]
         f (g (βŠ₯ 𝓔)) βŠ‘βŸ¨ 𝓔 ⁻ ⟩[ lβ‚‚ ]
         βŠ₯ 𝓔         ∎⟨ 𝓔 ⁻ ⟩
      where
       l₁ = monotone-if-continuous (𝓓 ⁻) (𝓔 ⁻) (f , cf) (βŠ₯ 𝓓) (g (βŠ₯ 𝓔))
             (βŠ₯-is-least 𝓓 (g (βŠ₯ 𝓔)))
       lβ‚‚ = =-to-βŠ‘ (𝓔 ⁻) (fg (βŠ₯ 𝓔))
   sg : is-strict 𝓔 𝓓 g
   sg = antisymmetry (𝓓 ⁻) (g (βŠ₯ 𝓔)) (βŠ₯ 𝓓) Ξ³ (βŠ₯-is-least 𝓓 (g (βŠ₯ 𝓔)))
    where
     Ξ³ = g (βŠ₯ 𝓔)     βŠ‘βŸ¨ 𝓓 ⁻ ⟩[ l₁ ]
         g (f (βŠ₯ 𝓓)) βŠ‘βŸ¨ 𝓓 ⁻ ⟩[ lβ‚‚ ]
         βŠ₯ 𝓓         ∎⟨ 𝓓 ⁻ ⟩
      where
       l₁ = monotone-if-continuous (𝓔 ⁻) (𝓓 ⁻) (g , cg) (βŠ₯ 𝓔) (f (βŠ₯ 𝓓))
             (βŠ₯-is-least 𝓔 (f (βŠ₯ 𝓓)))
       lβ‚‚ = =-to-βŠ‘ (𝓓 ⁻) (gf (βŠ₯ 𝓓))

\end{code}

Pointed dcpos have semidirected & subsingleton suprema and these are preserved
by maps that are both strict and continuous.

This is used to prove (in DomainTheroy.Lifting.LiftingSet.lagda) that the
lifting yields the free pointed dcpo on a set.

\begin{code}

add-βŠ₯ : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } (Ξ± : I β†’ βŸͺ 𝓓 ⟫)
      β†’ (πŸ™{π“₯} + I) β†’ βŸͺ 𝓓 ⟫
add-βŠ₯ 𝓓 Ξ± (inl ⋆) = βŠ₯ 𝓓
add-βŠ₯ 𝓓 Ξ± (inr i) = Ξ± i

add-βŠ₯-is-directed : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } {Ξ± : I β†’ βŸͺ 𝓓 ⟫}
                  β†’ is-semidirected (underlying-order (𝓓 ⁻)) Ξ±
                  β†’ is-Directed (𝓓 ⁻) (add-βŠ₯ 𝓓 Ξ±)
add-βŠ₯-is-directed 𝓓 {I} {Ξ±} Οƒ = ∣ inl ⋆ ∣ , Ξ΄
 where
  Ξ΄ : is-semidirected (underlying-order (𝓓 ⁻)) (add-βŠ₯ 𝓓 Ξ±)
  Ξ΄ (inl ⋆) a       = ∣ a , βŠ₯-is-least 𝓓 (add-βŠ₯ 𝓓 Ξ± a) ,
                            reflexivity (𝓓 ⁻) (add-βŠ₯ 𝓓 Ξ± a) ∣
  Ξ΄ (inr i) (inl ⋆) = ∣ (inr i) , reflexivity (𝓓 ⁻) (Ξ± i)
                                , βŠ₯-is-least 𝓓 (Ξ± i)        ∣
  Ξ΄ (inr i) (inr j) = βˆ₯βˆ₯-functor (Ξ» (k , u , v) β†’ (inr k , u , v)) (Οƒ i j)

adding-βŠ₯-preserves-sup : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ }
                         (Ξ± : I β†’ βŸͺ 𝓓 ⟫) (x : βŸͺ 𝓓 ⟫)
                       β†’ is-sup (underlying-order (𝓓 ⁻)) x Ξ±
                       β†’ is-sup (underlying-order (𝓓 ⁻)) x (add-βŠ₯ 𝓓 Ξ±)
adding-βŠ₯-preserves-sup 𝓓 {I} Ξ± x x-is-sup = x-is-ub , x-is-lb-of-ubs
 where
  x-is-ub : (i : πŸ™ + I) β†’ add-βŠ₯ 𝓓 Ξ± i βŠ‘βŸͺ 𝓓 ⟫ x
  x-is-ub (inl ⋆) = βŠ₯-is-least 𝓓 x
  x-is-ub (inr i) = sup-is-upperbound (underlying-order (𝓓 ⁻)) x-is-sup i
  x-is-lb-of-ubs : is-lowerbound-of-upperbounds (underlying-order (𝓓 ⁻))
                    x (add-βŠ₯ 𝓓 Ξ±)
  x-is-lb-of-ubs y y-is-ub = sup-is-lowerbound-of-upperbounds
                              (underlying-order (𝓓 ⁻)) x-is-sup y
                              (Ξ» i β†’ y-is-ub (inr i))

adding-βŠ₯-reflects-sup : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ }
                        (Ξ± : I β†’ βŸͺ 𝓓 ⟫) (x : βŸͺ 𝓓 ⟫)
                      β†’ is-sup (underlying-order (𝓓 ⁻)) x (add-βŠ₯ 𝓓 Ξ±)
                      β†’ is-sup (underlying-order (𝓓 ⁻)) x Ξ±
adding-βŠ₯-reflects-sup 𝓓 {I} Ξ± x x-is-sup = x-is-ub , x-is-lb-of-ubs
 where
  x-is-ub : (i : I) β†’ Ξ± i βŠ‘βŸͺ 𝓓 ⟫ x
  x-is-ub i = sup-is-upperbound (underlying-order (𝓓 ⁻)) x-is-sup (inr i)
  x-is-lb-of-ubs : is-lowerbound-of-upperbounds (underlying-order (𝓓 ⁻)) x Ξ±
  x-is-lb-of-ubs y y-is-ub = sup-is-lowerbound-of-upperbounds
                              (underlying-order (𝓓 ⁻)) x-is-sup y
                              h
   where
    h : is-upperbound (underlying-order (𝓓 ⁻)) y (add-βŠ₯ 𝓓 Ξ±)
    h (inl ⋆) = βŠ₯-is-least 𝓓 y
    h (inr i) = y-is-ub i

semidirected-complete-if-pointed : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } {Ξ± : I β†’ βŸͺ 𝓓 ⟫}
                                 β†’ is-semidirected (underlying-order (𝓓 ⁻)) Ξ±
                                 β†’ has-sup (underlying-order (𝓓 ⁻)) Ξ±
semidirected-complete-if-pointed 𝓓 {I} {Ξ±} Οƒ = x , x-is-sup
 where
  Ξ΄ : is-Directed (𝓓 ⁻) (add-βŠ₯ 𝓓 Ξ±)
  Ξ΄ = add-βŠ₯-is-directed 𝓓 Οƒ
  x : βŸͺ 𝓓 ⟫
  x = ∐ (𝓓 ⁻) Ξ΄
  x-is-sup : is-sup (underlying-order (𝓓 ⁻)) x Ξ±
  x-is-sup = adding-βŠ₯-reflects-sup 𝓓 Ξ± x (∐-is-sup (𝓓 ⁻) Ξ΄)

pointed-if-semidirected-complete : (𝓓 : DCPO {𝓀} {𝓣})
                                 β†’ ({I : π“₯ Μ‡ } {Ξ± : I β†’ ⟨ 𝓓 ⟩}
                                       β†’ is-semidirected (underlying-order 𝓓) Ξ±
                                       β†’ has-sup (underlying-order 𝓓) Ξ±)
                                 β†’ has-least (underlying-order 𝓓)
pointed-if-semidirected-complete 𝓓 c = x , x-is-least
 where
  Ξ± : 𝟘 β†’ ⟨ 𝓓 ⟩
  α = 𝟘-elim
  Οƒ : is-semidirected (underlying-order 𝓓) Ξ±
  Οƒ = 𝟘-induction
  x : ⟨ 𝓓 ⟩
  x = the-sup (underlying-order 𝓓) (c Οƒ)
  x-is-least : is-least (underlying-order 𝓓) x
  x-is-least y =
   sup-is-lowerbound-of-upperbounds
    (underlying-order 𝓓)
    (sup-property (underlying-order 𝓓) (c Οƒ))
    y 𝟘-induction

∐˒ᡈ : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } {Ξ± : I β†’ βŸͺ 𝓓 ⟫}
    β†’ is-semidirected (underlying-order (𝓓 ⁻)) Ξ± β†’ βŸͺ 𝓓 ⟫
∐˒ᡈ 𝓓 {I} {Ξ±} Οƒ = pr₁ (semidirected-complete-if-pointed 𝓓 Οƒ)

∐˒ᡈ-in-terms-of-∐ : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } {Ξ± : I β†’ βŸͺ 𝓓 ⟫}
                    (Οƒ : is-semidirected (underlying-order (𝓓 ⁻)) Ξ±)
                  β†’ ∐˒ᡈ 𝓓 Οƒ = ∐ (𝓓 ⁻) (add-βŠ₯-is-directed 𝓓 Οƒ)
∐˒ᡈ-in-terms-of-∐ 𝓓 {I} {Ξ±} Οƒ = refl

preserves-semidirected-sups-if-continuous-and-strict :
   (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
   (f : βŸͺ 𝓓 ⟫ β†’ βŸͺ 𝓔 ⟫)
 β†’ is-continuous (𝓓 ⁻) (𝓔 ⁻) f
 β†’ is-strict 𝓓 𝓔 f
 β†’ {I : π“₯ Μ‡ } {Ξ± : I β†’ βŸͺ 𝓓 ⟫}
 β†’ (Οƒ : is-semidirected (underlying-order (𝓓 ⁻)) Ξ±)
 β†’ is-sup (underlying-order (𝓔 ⁻)) (f (∐˒ᡈ 𝓓 Οƒ)) (f ∘ Ξ±)
preserves-semidirected-sups-if-continuous-and-strict 𝓓 𝓔 f con str {I} {Ξ±} Οƒ =
 ub , lb-of-ubs
 where
  Ξ΄ : is-Directed (𝓓 ⁻) (add-βŠ₯ 𝓓 Ξ±)
  Ξ΄ = add-βŠ₯-is-directed 𝓓 Οƒ
  claim₁ : is-sup (underlying-order (𝓔 ⁻)) (f (∐ (𝓓 ⁻) Ξ΄))
            (f ∘ add-βŠ₯ 𝓓 Ξ±)
  claim₁ = con (πŸ™ + I) (add-βŠ₯ 𝓓 Ξ±) (add-βŠ₯-is-directed 𝓓 Οƒ)
  claimβ‚‚ : is-sup (underlying-order (𝓔 ⁻)) (f (∐˒ᡈ 𝓓 Οƒ))
            (f ∘ add-βŠ₯ 𝓓 Ξ±)
  claimβ‚‚ = transport⁻¹
            (Ξ» - β†’ is-sup (underlying-order (𝓔 ⁻)) (f -) (f ∘ (add-βŠ₯ 𝓓 Ξ±)))
            (∐˒ᡈ-in-terms-of-∐ 𝓓 Οƒ) claim₁
  ub : (i : I) β†’ f (Ξ± i) βŠ‘βŸͺ 𝓔 ⟫ f (∐˒ᡈ 𝓓 Οƒ)
  ub i = sup-is-upperbound (underlying-order (𝓔 ⁻)) claimβ‚‚ (inr i)
  lb-of-ubs : is-lowerbound-of-upperbounds (underlying-order (𝓔 ⁻)) (f (∐˒ᡈ 𝓓 Οƒ))
                (f ∘ α)
  lb-of-ubs y y-is-ub = sup-is-lowerbound-of-upperbounds (underlying-order (𝓔 ⁻))
                         claimβ‚‚ y h
   where
    h : is-upperbound (underlying-order (𝓔 ⁻)) y (f ∘ add-βŠ₯ 𝓓 Ξ±)
    h (inl ⋆) = f (βŠ₯ 𝓓) βŠ‘βŸͺ 𝓔 ⟫[ =-to-βŠ‘ (𝓔 ⁻) str ]
                βŠ₯ 𝓔     βŠ‘βŸͺ 𝓔 ⟫[ βŠ₯-is-least 𝓔 y ]
                y       ∎βŸͺ 𝓔 ⟫
    h (inr i) = y-is-ub i

subsingleton-indexed-is-semidirected : (𝓓 : DCPO {𝓀} {𝓣})
                                       {I : π“₯ Μ‡ } (Ξ± : I β†’ ⟨ 𝓓 ⟩)
                                     β†’ is-prop I
                                     β†’ is-semidirected (underlying-order 𝓓) Ξ±
subsingleton-indexed-is-semidirected 𝓓 Ξ± ρ i j = ∣ i , r , r' ∣
  where
   r : Ξ± i βŠ‘βŸ¨ 𝓓 ⟩ Ξ± i
   r = reflexivity 𝓓 (Ξ± i)
   r' : Ξ± j βŠ‘βŸ¨ 𝓓 ⟩ Ξ± i
   r' = transport (Ξ» k β†’ Ξ± k βŠ‘βŸ¨ 𝓓 ⟩ Ξ± i) (ρ i j) r

subsingleton-complete-if-pointed : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } (Ξ± : I β†’ βŸͺ 𝓓 ⟫)
                                 β†’ is-prop I
                                 β†’ has-sup (underlying-order (𝓓 ⁻)) Ξ±
subsingleton-complete-if-pointed 𝓓 Ξ± ρ =
 semidirected-complete-if-pointed 𝓓 Οƒ
  where
   Οƒ : is-semidirected (underlying-order (𝓓 ⁻)) Ξ±
   Οƒ = subsingleton-indexed-is-semidirected (𝓓 ⁻) Ξ± ρ

∐˒˒ : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } (Ξ± : I β†’ βŸͺ 𝓓 ⟫)
    β†’ is-prop I β†’ βŸͺ 𝓓 ⟫
∐˒˒ 𝓓 {I} Ξ± ρ = pr₁ (subsingleton-complete-if-pointed 𝓓 Ξ± ρ)

∐˒˒-in-terms-of-∐˒ᡈ : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } {Ξ± : I β†’ βŸͺ 𝓓 ⟫}
                      (ρ : is-prop I)
                    β†’ ∐˒˒ 𝓓 Ξ± ρ
                    = ∐˒ᡈ 𝓓
                       (subsingleton-indexed-is-semidirected (𝓓 ⁻) Ξ± ρ)
∐˒˒-in-terms-of-∐˒ᡈ 𝓓 {I} {Ξ±} Οƒ = refl

preserves-subsingleton-sups-if-continuous-and-strict :
   (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
   (f : βŸͺ 𝓓 ⟫ β†’ βŸͺ 𝓔 ⟫)
 β†’ is-continuous (𝓓 ⁻) (𝓔 ⁻) f
 β†’ is-strict 𝓓 𝓔 f
 β†’ {I : π“₯ Μ‡ } (Ξ± : I β†’ βŸͺ 𝓓 ⟫)
 β†’ (ρ : is-prop I)
 β†’ is-sup (underlying-order (𝓔 ⁻)) (f (∐˒˒ 𝓓 Ξ± ρ)) (f ∘ Ξ±)
preserves-subsingleton-sups-if-continuous-and-strict 𝓓 𝓔 f con str Ξ± ρ =
 preserves-semidirected-sups-if-continuous-and-strict 𝓓 𝓔 f con str
  (subsingleton-indexed-is-semidirected (𝓓 ⁻) Ξ± ρ)

∐˒˒-is-upperbound : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } (Ξ± : I β†’ βŸͺ 𝓓 ⟫)
                    (ρ : is-prop I)
                  β†’ is-upperbound
                     (underlying-order (𝓓 ⁻)) (∐˒˒ 𝓓 Ξ± ρ) Ξ±
∐˒˒-is-upperbound 𝓓 {I} Ξ± ρ i = ∐-is-upperbound (𝓓 ⁻) Ξ΄ (inr i)
 where
  Ξ΄ : is-Directed (𝓓 ⁻) (add-βŠ₯ 𝓓 Ξ±)
  Ξ΄ = add-βŠ₯-is-directed 𝓓 (subsingleton-indexed-is-semidirected (𝓓 ⁻) Ξ± ρ)

∐˒˒-is-lowerbound-of-upperbounds : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } (Ξ± : I β†’ βŸͺ 𝓓 ⟫)
                                   (ρ : is-prop I)
                                 β†’ is-lowerbound-of-upperbounds
                                    (underlying-order (𝓓 ⁻)) (∐˒˒ 𝓓 Ξ± ρ) Ξ±
∐˒˒-is-lowerbound-of-upperbounds 𝓓 {I} Ξ± ρ y y-is-ub =
 ∐-is-lowerbound-of-upperbounds (𝓓 ⁻) Ξ΄ y h
  where
   Ξ΄ : is-Directed (𝓓 ⁻) (add-βŠ₯ 𝓓 Ξ±)
   Ξ΄ = add-βŠ₯-is-directed 𝓓 (subsingleton-indexed-is-semidirected (𝓓 ⁻) Ξ± ρ)
   h : (i : πŸ™ + I) β†’ add-βŠ₯ 𝓓 Ξ± i βŠ‘βŸͺ 𝓓 ⟫ y
   h (inl ⋆) = βŠ₯-is-least 𝓓 y
   h (inr i) = y-is-ub i

∐˒˒-is-sup : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } (Ξ± : I β†’ βŸͺ 𝓓 ⟫) (ρ : is-prop I)
           β†’ is-sup (underlying-order (𝓓 ⁻)) (∐˒˒ 𝓓 Ξ± ρ) Ξ±
∐˒˒-is-sup 𝓓 Ξ± ρ = ∐˒˒-is-upperbound 𝓓 Ξ± ρ
                 , ∐˒˒-is-lowerbound-of-upperbounds 𝓓 Ξ± ρ

∐˒˒-=-if-continuous-and-strict : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) (𝓔 : DCPOβŠ₯ {𝓀'} {𝓣'})
                                 (f : βŸͺ 𝓓 ⟫ β†’ βŸͺ 𝓔 ⟫)
                               β†’ is-continuous (𝓓 ⁻) (𝓔 ⁻) f
                               β†’ is-strict 𝓓 𝓔 f
                               β†’ {I : π“₯ Μ‡ } (Ξ± : I β†’ βŸͺ 𝓓 ⟫)
                               β†’ (ρ : is-prop I)
                               β†’ f (∐˒˒ 𝓓 Ξ± ρ) = ∐˒˒ 𝓔 (f ∘ Ξ±) ρ
∐˒˒-=-if-continuous-and-strict 𝓓 𝓔 f con str Ξ± ρ =
 sups-are-unique
  (underlying-order (𝓔 ⁻))
  (pr₁ (axioms-of-dcpo (𝓔 ⁻))) (f ∘ Ξ±)
  (preserves-subsingleton-sups-if-continuous-and-strict 𝓓 𝓔 f con str Ξ± ρ)
  (∐˒˒-is-sup 𝓔 (f ∘ Ξ±) ρ)

∐˒˒-family-= : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ } {Ξ± Ξ² : I β†’ βŸͺ 𝓓 ⟫} (ρ : is-prop I)
             β†’ Ξ± = Ξ²
             β†’ ∐˒˒ 𝓓 Ξ± ρ = ∐˒˒ 𝓓 Ξ² ρ
∐˒˒-family-= 𝓓 ρ refl = refl

∐˒˒-=-if-domain-holds : (𝓓 : DCPOβŠ₯ {𝓀} {𝓣}) {I : π“₯ Μ‡ }
                         {Ξ± : I β†’ βŸͺ 𝓓 ⟫} (ρ : is-prop I)
                       β†’ (i : I) β†’ ∐˒˒ 𝓓 Ξ± ρ = Ξ± i
∐˒˒-=-if-domain-holds 𝓓 {I} {Ξ±} ρ i =
 antisymmetry (𝓓 ⁻) (∐˒˒ 𝓓 Ξ± ρ) (Ξ± i)
  (∐˒˒-is-lowerbound-of-upperbounds 𝓓 Ξ± ρ (Ξ± i) l)
  (∐˒˒-is-upperbound 𝓓 Ξ± ρ i)
   where
    l : (j : I) β†’ Ξ± j βŠ‘βŸͺ 𝓓 ⟫ Ξ± i
    l j = transport (Ξ» - β†’ Ξ± - βŠ‘βŸͺ 𝓓 ⟫ Ξ± i) (ρ i j) (reflexivity (𝓓 ⁻) (Ξ± i))

\end{code}