Tom de Jong, 9 January 2026

The extended partial Dedekind reals as a pointed dcpo.

\begin{code}

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

open import MLTT.Spartan

open import UF.FunExt
open import UF.PropTrunc
open import UF.Subsingletons

module DomainTheory.Examples.ExtendedPartialDedekindReals
        (pt : propositional-truncations-exist)
        (fe : Fun-Ext)
        (pe : Prop-Ext)
       where

 open PropositionalTruncation pt

 open import DomainTheory.Basics.Dcpo pt fe ๐“คโ‚€
 open import DomainTheory.Basics.Pointed pt fe ๐“คโ‚€
 open import OrderedTypes.Poset fe
 open PosetAxioms

 open import Notation.Order using (_<_ ; _โ‰ฎ_)
 open import Rationals.Order
 open import Rationals.Type

 open import UF.Base
 open import UF.Powerset
 open import UF.Powerset-MultiUniverse hiding (๐“Ÿ)
 open unions-of-small-families pt ๐“คโ‚€ ๐“คโ‚€ โ„š

 open import Various.DedekindNonAxiomatic pt fe pe

 extended-partial-Dedekind-reals : ๐“คโ‚ ฬ‡
 extended-partial-Dedekind-reals = ๐“กโˆž

 private
  L U : ๐“กโˆž โ†’ ๐“Ÿ โ„š
  L x = prโ‚ (prโ‚ x)
  U x = prโ‚‚ (prโ‚ x)

  L-is-lower : (x : ๐“กโˆž) โ†’ is-lower (L x)
  L-is-lower x = prโ‚ (prโ‚ (prโ‚‚ x))

  L-is-upper-open : (x : ๐“กโˆž) โ†’ is-upper-open (L x)
  L-is-upper-open x = prโ‚‚ (prโ‚ (prโ‚‚ x))

  U-is-upper : (x : ๐“กโˆž) โ†’ is-upper (U x)
  U-is-upper x = prโ‚ (prโ‚ (prโ‚‚ (prโ‚‚ x)))

  U-is-lower-open : (x : ๐“กโˆž) โ†’ is-lower-open (U x)
  U-is-lower-open x = prโ‚‚ (prโ‚ (prโ‚‚ (prโ‚‚ x)))

  orderedness : (x : ๐“กโˆž) โ†’ are-ordered (L x) (U x)
  orderedness x = prโ‚‚ (prโ‚‚ (prโ‚‚ x))

  _โŠ‘_ : ๐“กโˆž โ†’ ๐“กโˆž โ†’ ๐“คโ‚€ ฬ‡
  x โŠ‘ y = (L x โІ L y) ร— (U x โІ U y)

  L-inclusion : (x y : ๐“กโˆž) โ†’ x โŠ‘ y โ†’ L x โІ L y
  L-inclusion x y = prโ‚

  U-inclusion : (x y : ๐“กโˆž) โ†’ x โŠ‘ y โ†’ U x โІ U y
  U-inclusion x y = prโ‚‚

  โŠ‘-is-prop : (x y : ๐“กโˆž) โ†’ is-prop (x โŠ‘ y)
  โŠ‘-is-prop x y = ร—-is-prop (โІ-is-prop fe (L x) (L y))
                            (โІ-is-prop fe (U x) (U y))

  โŠ‘-refl : is-reflexive _โŠ‘_
  โŠ‘-refl x = (โІ-refl (L x) , โІ-refl (U x))

  โŠ‘-trans : is-transitive _โŠ‘_
  โŠ‘-trans x y z (uโ‚ , uโ‚‚) (vโ‚ , vโ‚‚) =
   (โІ-trans (L x) (L y) (L z) uโ‚ vโ‚) ,
    โІ-trans (U x) (U y) (U z) uโ‚‚ vโ‚‚

  โŠ‘-antisym : is-antisymmetric _โŠ‘_
  โŠ‘-antisym x y (uโ‚ , uโ‚‚) (vโ‚ , vโ‚‚) =
   to-subtype-๏ผ
    (ฮป (L , U) โ†’ ร—โ‚ƒ-is-prop
                  (ร—-is-prop (being-lower-is-prop L)
                             (being-upper-open-is-prop L))
                  (ร—-is-prop (being-upper-is-prop U)
                             (being-lower-open-is-prop U))
                  (being-ordered-is-prop L U))
    (to-ร—-๏ผ (subset-extensionality pe fe uโ‚ vโ‚)
             (subset-extensionality pe fe uโ‚‚ vโ‚‚))

  directed-join : {I : ๐“คโ‚€ ฬ‡ } (x : I โ†’ ๐“กโˆž) โ†’ is-directed _โŠ‘_ x โ†’ ๐“กโˆž
  directed-join {I} x ฮด =
   (Lโˆž , Uโˆž) , (Lโˆž-is-lower , Lโˆž-is-upper-open) ,
               (Uโˆž-is-upper , Uโˆž-is-lower-open) ,
               Lโˆž-Uโˆž-are-ordered
   where
    Lโˆž : ๐“Ÿ โ„š
    Lโˆž = โ‹ƒ (L โˆ˜ x)
    Uโˆž : ๐“Ÿ โ„š
    Uโˆž = โ‹ƒ (U โˆ˜ x)
    Lโˆž-is-lower : is-lower Lโˆž
    Lโˆž-is-lower q q-in-union p p-below-q =
     โˆฅโˆฅ-rec (โˆˆ-is-prop Lโˆž p) h q-in-union
      where
       h : (ฮฃ i ๊ž‰ I , q โˆˆ L (x i)) โ†’ p โˆˆ Lโˆž
       h (i , m) = โˆฃ i , L-is-lower (x i) q m p p-below-q โˆฃ
    Lโˆž-is-upper-open : is-upper-open Lโˆž
    Lโˆž-is-upper-open p = โˆฅโˆฅ-rec โˆƒ-is-prop h
     where
      h : (ฮฃ i ๊ž‰ I , p โˆˆ L (x i)) โ†’ โˆƒ p' ๊ž‰ โ„š , p < p' ร— p' โˆˆ Lโˆž
      h (i , m) = โˆฅโˆฅ-functor (ฮป (p' , l , n) โ†’ p' , l , โˆฃ i , n โˆฃ)
                             (L-is-upper-open (x i) p m)
    Uโˆž-is-upper : is-upper Uโˆž
    Uโˆž-is-upper q q-in-union p q-below-p =
     โˆฅโˆฅ-rec (โˆˆ-is-prop Uโˆž p) h q-in-union
      where
       h : (ฮฃ i ๊ž‰ I , q โˆˆ U (x i)) โ†’ p โˆˆ Uโˆž
       h (i , m) = โˆฃ i , U-is-upper (x i) q m p q-below-p โˆฃ
    Uโˆž-is-lower-open : is-lower-open Uโˆž
    Uโˆž-is-lower-open p = โˆฅโˆฅ-rec โˆƒ-is-prop h
     where
      h : (ฮฃ i ๊ž‰ I , p โˆˆ U (x i)) โ†’ โˆƒ p' ๊ž‰ โ„š , p' < p ร— p' โˆˆ Uโˆž
      h (i , m) = โˆฅโˆฅ-functor (ฮป (p' , l , n) โ†’ p' , l , โˆฃ i , n โˆฃ)
                             (U-is-lower-open (x i) p m)
    Lโˆž-Uโˆž-are-ordered : are-ordered Lโˆž Uโˆž
    Lโˆž-Uโˆž-are-ordered p q p-in-Lโˆž q-in-Uโˆž =
     โˆฅโˆฅ-recโ‚‚ (โ„š<-is-prop p q) h p-in-Lโˆž q-in-Uโˆž
      where
       h : ฮฃ i ๊ž‰ I , p โˆˆ L (x i)
         โ†’ ฮฃ j ๊ž‰ I , q โˆˆ U (x j)
         โ†’ p < q
       h (i , m) (j , n) =
        โˆฅโˆฅ-rec (โ„š<-is-prop p q) h' (semidirected-if-directed _โŠ‘_ x ฮด i j)
         where
          h' : ฮฃ k ๊ž‰ I , (x i โŠ‘ x k) ร— (x j โŠ‘ x k)
             โ†’ p < q
          h' (k , inclโ‚ , inclโ‚‚) =
           orderedness (x k) p q (L-inclusion (x i) (x k) inclโ‚ p m)
                                 (U-inclusion (x j) (x k) inclโ‚‚ q n)

  directed-join-is-upper-bound : {I : ๐“คโ‚€ ฬ‡ } (x : I โ†’ ๐“กโˆž) (ฮด : is-directed _โŠ‘_ x)
                                โ†’ is-upperbound _โŠ‘_ (directed-join x ฮด) x
  directed-join-is-upper-bound x ฮด i =
   โ‹ƒ-is-upperbound (L โˆ˜ x) i , โ‹ƒ-is-upperbound (U โˆ˜ x) i

  directed-join-is-lower-bound-of-upper-bounds
   : {I : ๐“คโ‚€ ฬ‡ } (x : I โ†’ ๐“กโˆž) (ฮด : is-directed _โŠ‘_ x)
   โ†’ is-lowerbound-of-upperbounds _โŠ‘_ (directed-join x ฮด) x
  directed-join-is-lower-bound-of-upper-bounds x ฮด y y-is-ub =
   โ‹ƒ-is-lowerbound-of-upperbounds
    (L โˆ˜ x) (L y) (ฮป i โ†’ L-inclusion (x i) y (y-is-ub i)) ,
   โ‹ƒ-is-lowerbound-of-upperbounds
    (U โˆ˜ x) (U y) (ฮป i โ†’ U-inclusion (x i) y (y-is-ub i))

 ๐“กโˆž-DCPO : DCPO {๐“คโ‚} {๐“คโ‚€}
 ๐“กโˆž-DCPO = ๐“กโˆž , _โŠ‘_ ,
           (๐“กโˆž-is-set , โŠ‘-is-prop , โŠ‘-refl , โŠ‘-trans , โŠ‘-antisym) ,
           (ฮป I x ฮด โ†’ directed-join x ฮด ,
                      directed-join-is-upper-bound x ฮด ,
                      directed-join-is-lower-bound-of-upper-bounds x ฮด)

 ๐“กโˆž-DCPOโŠฅ : DCPOโŠฅ {๐“คโ‚} {๐“คโ‚€}
 ๐“กโˆž-DCPOโŠฅ = ๐“กโˆž-DCPO , (โŠฅ๐“กโˆž , (ฮป x โ†’ (ฮป _ โ†’ ๐Ÿ˜-elim) , (ฮป _ โ†’ ๐Ÿ˜-elim)))

\end{code}