Tom de Jong, early January 2022.

Inspired by the paper "Continuous categories and exponentiable toposes" by Peter
Johnstone and AndrΓ© Joyal, we discuss the notions

(1) structural continuity of a dcpo;
(2) continuity of a dcpo;
(3) pseudocontinuity of a dcpo.

(1) and (2) are defined in Continuity.lagda and (3) is defined and examined here.
The notions (1)-(3) have the following shapes:

(1)   Ξ  (x : D) β†’   Ξ£ I : π“₯ Μ‡ , Ξ£ Ξ± : I β†’ D , Ξ± is-directed Γ— ... Γ— ...
(2) βˆ₯ Ξ  (x : D) β†’   Ξ£ I : π“₯ Μ‡ , Ξ£ Ξ± : I β†’ D , Ξ± is-directed Γ— ... Γ— ... βˆ₯
(3)   Ξ  (x : D) β†’ βˆ₯ Ξ£ I : π“₯ Μ‡ , Ξ£ Ξ± : I β†’ D , Ξ± is-directed Γ— ... Γ— ... βˆ₯

So (2) and (3) are propositions, but (1) isn't. We illustrate (1)-(3) by
discussion them in terms of left adjoints. In these discussions, the
Ind-completion, as defined in IndCompletion.lagda plays an important role.

We show that (1) for a dcpo D is equivalent to asserting that the map
∐ : Ind(D) β†’ D (which takes a directed family to its supremum) has a specified
left adjoint.

It follows directly that (2) is equivalent to asking that ∐-map has an
*unspecified* left adjoint.

Because Ind is a preorder and not a poset, the type expressing that ∐-map has a
specified left adjoint is not a proposition, as the supposed left adjoint can
map elements of D to bicofinal (but nonequal) directed families.

We could take the poset reflection Ind(D)/β‰ˆ of Ind(D) and ask that the map
∐-map/ : Ind(D)/β‰ˆ β†’ D induced by ∐ : Ind(D) β†’ D has a left adjoint to obtain a
type that is a proposition. We show that this amounts precisely to
pseudocontinuity.

\begin{code}

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

open import MLTT.Spartan hiding (J)
open import UF.FunExt
open import UF.PropTrunc

module DomainTheory.BasesAndContinuity.ContinuityDiscussion
        (pt : propositional-truncations-exist)
        (fe : Fun-Ext)
        (π“₯ : Universe) -- where the index types for directed completeness live
       where

open PropositionalTruncation pt

open import UF.Base hiding (_β‰ˆ_)
open import UF.Equiv
open import UF.EquivalenceExamples
open import UF.Hedberg
open import UF.ImageAndSurjection pt
open import UF.Subsingletons
open import UF.Subsingletons-FunExt

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

open import DomainTheory.BasesAndContinuity.Continuity pt fe π“₯
open import DomainTheory.BasesAndContinuity.IndCompletion pt fe π“₯

\end{code}

Because we'll want to apply some standard equivalences later on, we first show
that our record-based definition of structural continuity is equivalent to one
using Ξ£-types.

\begin{code}

structurally-continuous-Ξ£ : (𝓓 : DCPO {𝓀} {𝓣}) β†’ π“₯ ⁺ βŠ” 𝓀 βŠ” 𝓣 Μ‡
structurally-continuous-Ξ£ 𝓓 =
   (x : ⟨ 𝓓 ⟩)
 β†’ Ξ£ I κž‰ π“₯ Μ‡ , Ξ£ Ξ± κž‰ (I β†’ ⟨ 𝓓 ⟩) , (is-way-upperbound 𝓓 x Ξ±)
                                 Γ— (Ξ£ Ξ΄ κž‰ is-Directed 𝓓 Ξ± , ∐ 𝓓 Ξ΄ = x)


structurally-continuous-to-Ξ£ : (𝓓 : DCPO {𝓀} {𝓣})
                              β†’ structurally-continuous 𝓓
                              β†’ structurally-continuous-Ξ£ 𝓓
structurally-continuous-to-Ξ£ 𝓓 C x =
   index-of-approximating-family x
 , approximating-family x
 , approximating-family-is-way-below x
 , approximating-family-is-directed x
 , approximating-family-∐-= x
 where
  open structurally-continuous C

structurally-continuous-from-Ξ£ : (𝓓 : DCPO {𝓀} {𝓣})
                                β†’ structurally-continuous-Ξ£ 𝓓
                                β†’ structurally-continuous 𝓓
structurally-continuous-from-Ξ£ 𝓓 C' =
 record
  { index-of-approximating-family     = Ξ» x β†’ pr₁ (C' x)
  ; approximating-family              = Ξ» x β†’ pr₁ (prβ‚‚ (C' x))
  ; approximating-family-is-directed  = Ξ» x β†’ pr₁ (prβ‚‚ (prβ‚‚ (prβ‚‚ (C' x))))
  ; approximating-family-is-way-below = Ξ» x β†’ pr₁ (prβ‚‚ (prβ‚‚ (C' x)))
  ; approximating-family-∐-=          = Ξ» x β†’ prβ‚‚ (prβ‚‚ (prβ‚‚ (prβ‚‚ (C' x))))
  }

structurally-continuous-≃ : (𝓓 : DCPO {𝓀} {𝓣})
                          β†’ structurally-continuous 𝓓
                          ≃ structurally-continuous-Ξ£ 𝓓
structurally-continuous-≃ 𝓓 = qinveq (structurally-continuous-to-Ξ£ 𝓓)
                                    ((structurally-continuous-from-Ξ£ 𝓓) ,
                                     ((Ξ» x β†’ refl) , (Ξ» x β†’ refl)))

\end{code}

In "Continuous categories and exponentiable toposes", Peter Johnstone and AndrΓ©
Joyal show in Lemma 2.1 that a dcpo D is continuous if and only if the map
∐ : Ind(D) β†’ D that takes a directed family in the Ind-completion of D to its
supremum has a (specified) left adjoint.

We show that the type expressing that the ∐-map has a left adjoint is equivalent
to the type expressing structural continuity of D.

The proof below is fairly short, but only because we already characterized when
∐-map has a left adjoint in IndCompletion.lagda.

\begin{code}

module _
        (𝓓 : DCPO {𝓀} {𝓣})
       where

 open Ind-completion 𝓓

 structurally-continuous-if-specified-left-adjoint :
    ∐-map-has-specified-left-adjoint
  β†’ structurally-continuous 𝓓
 structurally-continuous-if-specified-left-adjoint (L , L-left-adjoint) =
  record
   { index-of-approximating-family     = Ξ» x β†’ pr₁ (L x)
   ; approximating-family              = Ξ» x β†’ pr₁ (prβ‚‚ (L x))
   ; approximating-family-is-directed  = Ξ» x β†’ prβ‚‚ (prβ‚‚ (L x))
   ; approximating-family-is-way-below = Ξ» x β†’ prβ‚‚ (L-is-approximating x)
   ; approximating-family-∐-=          = Ξ» x β†’ pr₁ (L-is-approximating x)
   }
   where
    L-is-approximating : is-approximating L
    L-is-approximating = ⌜ left-adjoint-to-∐-map-characterization L ⌝⁻¹ L-left-adjoint

 specified-left-adjoint-if-structurally-continuous :
    structurally-continuous 𝓓
  β†’ ∐-map-has-specified-left-adjoint
 specified-left-adjoint-if-structurally-continuous C = L , L-is-left-adjoint
  where
   open structurally-continuous C
   L : ⟨ 𝓓 ⟩ β†’ Ind
   L x = index-of-approximating-family x
       , approximating-family x
       , approximating-family-is-directed x
   L-is-left-adjoint : left-adjoint-to-∐-map L
   L-is-left-adjoint x Οƒ@(I , Ξ± , Ξ΄) = β¦…1⦆ , β¦…2⦆
    where
     β¦…1⦆ : L x ≲ (I , Ξ± , Ξ΄) β†’ x βŠ‘βŸ¨ 𝓓 ⟩ ∐ 𝓓 Ξ΄
     β¦…1⦆ Lx-cofinal-in-Ξ± = transport (Ξ» - β†’ - βŠ‘βŸ¨ 𝓓 ⟩ ∐ 𝓓 Ξ΄)
                           (approximating-family-∐-= x)
                           (≲-to-βŠ‘-of-∐ (approximating-family-is-directed x)
                                        Ξ΄ Lx-cofinal-in-Ξ±)
     β¦…2⦆ : x βŠ‘βŸ¨ 𝓓 ⟩ ∐ 𝓓 Ξ΄ β†’ L x ≲ (I , Ξ± , Ξ΄)
     β¦…2⦆ x-below-∐α j = approximating-family-is-way-below x j I Ξ± Ξ΄ x-below-∐α

 specified-left-adjoint-structurally-continuous-≃ :
  ∐-map-has-specified-left-adjoint ≃ structurally-continuous 𝓓
 specified-left-adjoint-structurally-continuous-≃ = qinveq f (g , Οƒ , Ο„)
  where
   f = structurally-continuous-if-specified-left-adjoint
   g = specified-left-adjoint-if-structurally-continuous
   Οƒ : g ∘ f ∼ id
   Οƒ (L , L-left-adjoint) =
    to-subtype-= being-left-adjoint-to-∐-map-is-prop refl
   Ο„ : f ∘ g ∼ id
   Ο„ C = f (g C)         =⟨ refl ⟩
         Ο• (ψ (f (g C))) =⟨ h    ⟩
         Ο• (ψ C)         =⟨ refl ⟩
         C               ∎
    where
     Ο• : structurally-continuous-Ξ£ 𝓓 β†’ structurally-continuous 𝓓
     Ο• = structurally-continuous-from-Ξ£ 𝓓
     ψ : structurally-continuous 𝓓 β†’ structurally-continuous-Ξ£ 𝓓
     ψ = structurally-continuous-to-Ξ£ 𝓓
     h = ap Ο• (dfunext fe
          (Ξ» x β†’ to-Ξ£-= (refl , (to-Ξ£-= (refl ,
                  (to-Γ—-= refl  (to-Ξ£-= (refl , (sethood 𝓓 _ _)))))))))

\end{code}

It follows immediately that a dcpo is continuous if and only if ∐-map has an
unspecified left adjoint.

\begin{code}


module _
        (𝓓 : DCPO {𝓀} {𝓣})
       where

 open Ind-completion 𝓓

 ∐-map-has-unspecified-left-adjoint : π“₯ ⁺ βŠ” 𝓀 βŠ” 𝓣 Μ‡
 ∐-map-has-unspecified-left-adjoint = βˆ₯ ∐-map-has-specified-left-adjoint βˆ₯

 is-continuous-dcpo-iff-∐-map-has-unspecified-left-adjoint :
   ∐-map-has-unspecified-left-adjoint ≃ is-continuous-dcpo 𝓓
 is-continuous-dcpo-iff-∐-map-has-unspecified-left-adjoint =
  βˆ₯βˆ₯-cong pt (specified-left-adjoint-structurally-continuous-≃ 𝓓)

\end{code}

Finall, we consider pseudocontinuity. It is similar to structural continuity,
but instead of asking that for every x : D, we have a specified directed family
approximating x, we merely ask there exists an unspecified directed family
approximating x.

On first sight, pseudocontinuity is arguably how one would expect us to define
contuinity of a dcpo while ensuring the notion is property as opposed to
structure. It is however weaker than continuity (as defined in
Continuity.lagda) and structural continuity. More importantly, with
pseudocontinuity we would need some instances of the axiom of choice when
proving the interpolation properties for the way-below relation, at least when
trying to mimick the proof in Continuity.lagda.

\begin{code}

is-pseudocontinuous-dcpo : (𝓓 : DCPO {𝓀} {𝓣}) β†’ π“₯ ⁺ βŠ” 𝓀 βŠ” 𝓣 Μ‡
is-pseudocontinuous-dcpo 𝓓 =
   (x : ⟨ 𝓓 ⟩)
 β†’ βˆ₯ Ξ£ I κž‰ π“₯ Μ‡ , Ξ£ Ξ± κž‰ (I β†’ ⟨ 𝓓 ⟩) , (is-way-upperbound 𝓓 x Ξ±)
                                   Γ— (Ξ£ Ξ΄ κž‰ is-Directed 𝓓 Ξ± , ∐ 𝓓 Ξ΄ = x) βˆ₯

being-pseudocontinuous-dcpo-is-prop : (𝓓 : DCPO {𝓀} {𝓣})
                                    β†’ is-prop (is-pseudocontinuous-dcpo 𝓓)
being-pseudocontinuous-dcpo-is-prop 𝓓 = Ξ -is-prop fe (Ξ» x β†’ βˆ₯βˆ₯-is-prop)

continuous-dcpo-hierarchy₁ : (𝓓 : DCPO {𝓀} {𝓣})
                           β†’ structurally-continuous 𝓓
                           β†’ is-continuous-dcpo 𝓓
continuous-dcpo-hierarchy₁ 𝓓 = ∣_∣

continuous-dcpo-hierarchyβ‚‚ : (𝓓 : DCPO {𝓀} {𝓣})
                           β†’ is-continuous-dcpo 𝓓
                           β†’ is-pseudocontinuous-dcpo 𝓓
continuous-dcpo-hierarchyβ‚‚ 𝓓 c x =
 βˆ₯βˆ₯-functor (Ξ» C β†’ structurally-continuous-to-Ξ£ 𝓓 C x) c

\end{code}

Of course, one way to obtain a propositional-valued definition of continuity is
to ensure that we're asking for left adjoints between posets. That is, we take
the poset reflection Ind/β‰ˆ of Ind and ask that ∐-map/ : Ind/β‰ˆ β†’ D has a left
adjoint.

We show that this is exactly the same as pseudocontinuity. This also illustrates
the discussion above on the need for the axiom of choice, as it boils down to
choosing representatives of equivalence classes.

\begin{code}

module _
        (pe : Prop-Ext)
        (𝓓 : DCPO {𝓀} {𝓣})
       where

 open import Quotient.Type
 open import Quotient.Large pt fe pe
 open general-set-quotients-exist large-set-quotients

 open Ind-completion 𝓓
 open Ind-completion-poset-reflection pe 𝓓

 βŠ‘-∐-map/-lemma : {x : ⟨ 𝓓 ⟩} {Οƒ : Ind}
               β†’ (x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map Οƒ) ↔ (x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map/ (Ξ· Οƒ))
 βŠ‘-∐-map/-lemma {x} {Οƒ} = transport (Ξ» - β†’ x βŠ‘βŸ¨ 𝓓 ⟩ -) ((∐-map/-triangle Οƒ) ⁻¹)
                       , transport (Ξ» - β†’ x βŠ‘βŸ¨ 𝓓 ⟩ -) (∐-map/-triangle Οƒ)

 specified-left-adjoint-if-pseudocontinuous : is-pseudocontinuous-dcpo 𝓓
                                            β†’ ∐-map/-has-specified-left-adjoint
 specified-left-adjoint-if-pseudocontinuous pc = L , L-is-ladj
  where
   module construction (x : ⟨ 𝓓 ⟩) where
    str-cont : π“₯ ⁺ βŠ” 𝓀 βŠ” 𝓣 Μ‡
    str-cont = (Ξ£ I κž‰ π“₯ Μ‡ , Ξ£ Ξ± κž‰ (I β†’ ⟨ 𝓓 ⟩)
                          , is-way-upperbound 𝓓 x Ξ±
                          Γ— (Ξ£ Ξ΄ κž‰ is-Directed 𝓓 Ξ± , ∐ 𝓓 Ξ΄ = x))
    ΞΊ : str-cont β†’ Ind
    ΞΊ (I , Ξ± , _ , (Ξ΄ , _)) = I , Ξ± , Ξ΄
    ΞΊ-gives-approximating-family : (Οƒ : str-cont) β†’ ΞΊ Οƒ approximates x
    κ-gives-approximating-family (I , α , α-wb-x , (δ , ∐α-is-x)) =
     ∐α-is-x , α-wb-x

    ladj : (Οƒ : str-cont) (Ο„ : Ind) β†’ (ΞΊ Οƒ ≲ Ο„) ↔ (x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map Ο„)
    ladj Οƒ Ο„ = left-adjunct-to-if-approximates
                (ΞΊ Οƒ) x (ΞΊ-gives-approximating-family Οƒ) Ο„

    ΞΊ/ : str-cont β†’ Ind/β‰ˆ
    κ/ = η ∘ κ
    ΞΊ/-wconstant : wconstant ΞΊ/
    ΞΊ/-wconstant Οƒ@(I , Ξ± , Ξ±-way-below-x , (Ξ΄ , x-sup-of-Ξ±))
                 Ο„@(J , Ξ² , Ξ²-way-below-x , (Ξ΅ , x-sup-of-Ξ²)) =
     ≀-is-antisymmetric (ΞΊ/ Οƒ) (ΞΊ/ Ο„)
      (Ξ·-preserves-order (Ξ» i β†’ Ξ±-way-below-x i J Ξ² Ξ΅ (=-to-βŠ’ 𝓓 x-sup-of-Ξ²)))
      (Ξ·-preserves-order (Ξ» j β†’ Ξ²-way-below-x j I Ξ± Ξ΄ (=-to-βŠ’ 𝓓 x-sup-of-Ξ±)))

    Ο‰ : Ξ£ Ο• κž‰ (βˆ₯ str-cont βˆ₯ β†’ Ind/β‰ˆ) , ΞΊ/ ∼ Ο• ∘ ∣_∣
    Ο‰ = wconstant-map-to-set-factors-through-truncation-of-domain
         Ind/β‰ˆ-is-set ΞΊ/ ΞΊ/-wconstant

   L : ⟨ 𝓓 ⟩ β†’ Ind/β‰ˆ
   L x = pr₁ Ο‰ (pc x)
    where
     open construction x

   L-is-ladj : left-adjoint-to-∐-map/ L
   L-is-ladj x = βˆ₯βˆ₯-rec (Ξ -is-prop fe adj-condition-is-prop) lemma (pc x)
    where
     open construction x
     adj-condition-is-prop : (Ο„' : Ind/β‰ˆ)
                           β†’ is-prop ((L x ≀ Ο„') ↔ (x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map/ Ο„'))
     adj-condition-is-prop Ο„' =
      (Γ—-is-prop (Ξ -is-prop fe (Ξ» _ β†’ prop-valuedness 𝓓 x (∐-map/ Ο„')))
                 (Ξ -is-prop fe (Ξ» _ β†’ ≀-is-prop-valued (L x) Ο„')))
     lemma : (Οƒ : str-cont) (Ο„' : Ind/β‰ˆ) β†’ ((L x ≀ Ο„') ↔ (x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map/ Ο„'))
     lemma Οƒ = /-induction ≋ adj-condition-is-prop L-is-ladj'
      where
       L-is-ladj' : (Ο„ : Ind)
                  β†’ (L x ≀ Ξ· Ο„) ↔ (x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map/ (Ξ· Ο„))
       L-is-ladj' Ο„ = ↔-trans β¦…1⦆ β¦…2⦆
        where
         β¦…2⦆ : (ΞΊ Οƒ ≲ Ο„) ↔ (x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map/ (Ξ· Ο„))
         β¦…2⦆ = ↔-trans (ladj Οƒ Ο„) (βŠ‘-∐-map/-lemma)
         β¦…1⦆ : (L x ≀ Ξ· Ο„) ↔ (ΞΊ Οƒ ≲ Ο„)
         β¦…1⦆ = ↔-trans s (↔-sym Ξ·-↔-order)
          where
           s : (L x ≀ Ξ· Ο„) ↔ (Ξ· (ΞΊ Οƒ) ≀ Ξ· Ο„)
           s = transport (_≀ Ξ· Ο„) e , transport (_≀ Ξ· Ο„) (e ⁻¹)
            where
             e : L x = Ξ· (ΞΊ Οƒ)
             e = L x          =⟨ refl                                 ⟩
                 pr₁ Ο‰ (pc x) =⟨ ap (pr₁ Ο‰) (βˆ₯βˆ₯-is-prop (pc x) ∣ Οƒ ∣) ⟩
                 pr₁ Ο‰ ∣ Οƒ ∣  =⟨ (prβ‚‚ Ο‰ Οƒ) ⁻¹                         ⟩
                 Ξ· (ΞΊ Οƒ)      ∎

 pseudocontinuous-if-specified-left-adjoint : ∐-map/-has-specified-left-adjoint
                                            β†’ is-pseudocontinuous-dcpo 𝓓
 pseudocontinuous-if-specified-left-adjoint (L , L-is-left-adjoint) x =
  βˆ₯βˆ₯-functor lemma (Ξ·-is-surjection (L x))
   where
    lemma : (Ξ£ Οƒ κž‰ Ind , Ξ· Οƒ = L x)
          β†’ Ξ£ I κž‰ π“₯ Μ‡ , Ξ£ Ξ± κž‰ (I β†’ ⟨ 𝓓 ⟩) , is-way-upperbound 𝓓 x Ξ±
                                          Γ— (Ξ£ Ξ΄ κž‰ is-Directed 𝓓 Ξ± , ∐ 𝓓 Ξ΄ = x)
    lemma (Οƒ@(I , Ξ± , Ξ΄) , e) = I , Ξ± , prβ‚‚ approx , (Ξ΄ , pr₁ approx)
     where
      ladj : (Ο„ : Ind) β†’ (Οƒ ≲ Ο„) ↔ (x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map Ο„)
      ladj Ο„ = ↔-trans (↔-trans Ξ·-↔-order ladj') (↔-sym βŠ‘-∐-map/-lemma)
       where
        ladj' : (Ξ· Οƒ ≀ Ξ· Ο„) ↔ xΒ βŠ‘βŸ¨ 𝓓 ⟩ ∐-map/ (Ξ· Ο„)
        ladj' = transport (Ξ» - β†’ (- ≀ Ξ· Ο„) ↔ x βŠ‘βŸ¨ 𝓓 ⟩ ∐-map/ (Ξ· Ο„)) (e ⁻¹)
                 (L-is-left-adjoint x (Ξ· Ο„))
      approx : (∐ 𝓓 Ξ΄ = x) Γ— is-way-upperbound 𝓓 x Ξ±
      approx = approximates-if-left-adjunct-to Οƒ x ladj

 specified-left-adjoint-pseudo-continuous-≃ : ∐-map/-has-specified-left-adjoint
                                            ≃ is-pseudocontinuous-dcpo 𝓓
 specified-left-adjoint-pseudo-continuous-≃ =
  logically-equivalent-props-are-equivalent
    ∐-map/-having-left-adjoint-is-prop
    (being-pseudocontinuous-dcpo-is-prop 𝓓)
    pseudocontinuous-if-specified-left-adjoint
    specified-left-adjoint-if-pseudocontinuous

\end{code}