Tom de Jong & Martin Escardo, 20 May 2019.
Refactored January 2020, December 2021 by Tom de Jong.
Definitions of:
* Directed complete posets (dcpos).
* Scott continuous maps.
See DomainTheory.lagda for an overview of the formalization of the theory of
dcpos.
\begin{code}
{-# OPTIONS --safe --without-K #-}
open import MLTT.Spartan
open import UF.FunExt
open import UF.PropTrunc
open import UF.Sets
open import UF.SubtypeClassifier
module DomainTheory.Basics.Dcpo
(pt : propositional-truncations-exist)
(fe : Fun-Ext)
(π₯ : Universe)
where
open PropositionalTruncation pt
open import UF.Subsingletons
open import UF.Subsingletons-FunExt
open import Naturals.Addition renaming (_+_ to _+'_)
open import Naturals.Order
open import Notation.Order
open import OrderedTypes.Poset fe
module _ {π€ π£ : Universe}
{D : π€ Μ }
(_β_ : D β D β π£ Μ )
where
open PosetAxioms
is-upperbound : {I : π¦ Μ } (u : D) (Ξ± : I β D) β π¦ β π£ Μ
is-upperbound u Ξ± = (i : domain Ξ±) β Ξ± i β u
is-lowerbound-of-upperbounds : {I : π¦ Μ } (u : D) (Ξ± : I β D) β π¦ β π€ β π£ Μ
is-lowerbound-of-upperbounds u Ξ± = (v : D) β is-upperbound v Ξ± β u β v
is-sup : {I : π¦ Μ } β D β (I β D) β π€ β π¦ β π£ Μ
is-sup s Ξ± = (is-upperbound s Ξ±) Γ (is-lowerbound-of-upperbounds s Ξ±)
sup-is-upperbound : {I : π¦ Μ } {s : D} {Ξ± : I β D}
β is-sup s Ξ±
β is-upperbound s Ξ±
sup-is-upperbound i = prβ i
sup-is-lowerbound-of-upperbounds : {I : π¦ Μ } {s : D} {Ξ± : I β D}
β is-sup s Ξ±
β (u : D)
β is-upperbound u Ξ± β s β u
sup-is-lowerbound-of-upperbounds i = prβ i
has-sup : {I : π¦ Μ } β (I β D) β π€ β π¦ β π£ Μ
has-sup Ξ± = Ξ£ s κ D , is-sup s Ξ±
the-sup : {I : π¦ Μ } {Ξ± : I β D} β has-sup Ξ± β D
the-sup (s , i) = s
sup-property : {I : π¦ Μ } {Ξ± : I β D} (h : has-sup Ξ±) β is-sup (the-sup h) Ξ±
sup-property (s , i) = i
is-inhabited : (X : π¦ Μ ) β π¦ Μ
is-inhabited = β₯_β₯
is-semidirected : {I : π¦ Μ } β (I β D) β π¦ β π£ Μ
is-semidirected {π¦} {I} Ξ± = (i j : I) β β k κ I , (Ξ± i β Ξ± k) Γ (Ξ± j β Ξ± k)
is-directed : {I : π¦ Μ } β (I β D) β π¦ β π£ Μ
is-directed {π¦} {I} Ξ± = is-inhabited I Γ is-semidirected Ξ±
inhabited-if-directed : {I : π¦ Μ } (Ξ± : I β D) β is-directed Ξ± β β₯ I β₯
inhabited-if-directed Ξ± = prβ
semidirected-if-directed : {I : π¦ Μ } (Ξ± : I β D) β is-directed Ξ±
β (i j : I) β β k κ I , (Ξ± i β Ξ± k) Γ (Ξ± j β Ξ± k)
semidirected-if-directed Ξ± = prβ
being-inhabited-is-prop : {I : π¦ Μ } β is-prop (is-inhabited I)
being-inhabited-is-prop = β₯β₯-is-prop
being-semidirected-is-prop : {I : π¦ Μ } (Ξ± : I β D) β is-prop (is-semidirected Ξ±)
being-semidirected-is-prop Ξ± = Ξ β-is-prop fe (Ξ» i j β β₯β₯-is-prop)
being-directed-is-prop : {I : π¦ Μ } (Ξ± : I β D) β is-prop (is-directed Ξ±)
being-directed-is-prop Ξ± =
Γ-is-prop being-inhabited-is-prop (being-semidirected-is-prop Ξ±)
is-directed-complete : π€ β (π₯ βΊ) β π£ Μ
is-directed-complete = (I : π₯ Μ ) (Ξ± : I β D) β is-directed Ξ± β has-sup Ξ±
is-sup-is-prop : poset-axioms _β_
β {I : π¦ Μ } (d : D) (Ξ± : I β D)
β is-prop (is-sup d Ξ±)
is-sup-is-prop (s , p , r , t , a) {I} d Ξ± = Ξ³
where
Ξ³ : is-prop (is-sup d Ξ±)
Ξ³ = Γ-is-prop (Ξ -is-prop fe (Ξ» i β p (Ξ± i) d))
(Ξ β-is-prop fe (Ξ» x l β p d x))
sups-are-unique : poset-axioms _β_
β {I : π¦ Μ } (Ξ± : I β D) {x y : D}
β is-sup x Ξ± β is-sup y Ξ± β x οΌ y
sups-are-unique (s , p , r , t , a) {I} Ξ± {x} {y} x-is-sup y-is-sup =
a x y
(sup-is-lowerbound-of-upperbounds x-is-sup y (sup-is-upperbound y-is-sup))
(sup-is-lowerbound-of-upperbounds y-is-sup x (sup-is-upperbound x-is-sup))
having-sup-is-prop : poset-axioms _β_
β {I : π¦ Μ } (Ξ± : I β D)
β is-prop (has-sup Ξ±)
having-sup-is-prop ax {I} Ξ± Ο Ο =
to-subtype-οΌ (Ξ» x β is-sup-is-prop ax x Ξ±)
(sups-are-unique ax Ξ± (prβ Ο) (prβ Ο))
dcpo-axioms : π€ β (π₯ βΊ) β π£ Μ
dcpo-axioms = poset-axioms _β_ Γ is-directed-complete
being-directed-complete-is-prop : dcpo-axioms β is-prop is-directed-complete
being-directed-complete-is-prop a =
Ξ β-is-prop fe (Ξ» I Ξ± Ξ΄ β having-sup-is-prop (prβ a) Ξ±)
dcpo-axioms-is-prop : is-prop dcpo-axioms
dcpo-axioms-is-prop = prop-criterion Ξ³
where
Ξ³ : dcpo-axioms β is-prop dcpo-axioms
Ξ³ a = Γ-is-prop (poset-axioms-is-prop _β_)
(being-directed-complete-is-prop a)
\end{code}
Since we will also consider dcpos with a least element later, we make the
following definitions.
\begin{code}
is-least : D β π€ β π£ Μ
is-least x = β (y : D) β x β y
has-least : π€ β π£ Μ
has-least = Ξ£ x κ D , is-least x
\end{code}
Added 23 June 2024.
\begin{code}
is-Ο-chain : (β β D) β π£ Μ
is-Ο-chain Ξ± = (n : β) β Ξ± n β Ξ± (succ n)
is-Ο-complete : π€ β π£ Μ
is-Ο-complete = (Ξ± : β β D) β is-Ο-chain Ξ± β has-sup Ξ±
module _
(β-refl : is-reflexive _β_)
(β-trans : is-transitive _β_)
(Ξ± : β β D)
where
Ο-chains-increase : is-Ο-chain Ξ±
β (n m : β) β n β€ m β Ξ± n β Ξ± m
Ο-chains-increase c n 0 l =
transportβ»ΒΉ (Ξ» - β Ξ± - β Ξ± 0) (unique-least n l) (β-refl (Ξ± 0))
Ο-chains-increase c n (succ m) l = I (β€-split n m l)
where
I : n β€ m + (n οΌ succ m) β Ξ± n β Ξ± (succ m)
I (inl k) = β-trans (Ξ± n) (Ξ± m) (Ξ± (succ m)) (Ο-chains-increase c n m k) (c m)
I (inr refl) = β-refl (Ξ± (succ m))
Ο-chains-are-directed : is-Ο-chain Ξ± β is-directed Ξ±
Ο-chains-are-directed c = β£ 0 β£ , I
where
I : is-semidirected Ξ±
I n m = β£ n +' m , II , III β£
where
II : Ξ± n β Ξ± (n +' m)
II = Ο-chains-increase c n (n +' m)
(cosubtraction n (n +' m) (m , (addition-commutativity m n)))
III : Ξ± m β Ξ± (n +' m)
III = Ο-chains-increase c m (n +' m)
(cosubtraction m (n +' m) (n , refl))
\end{code}
End of addition.
We have now developed enough material to define dcpos and we introduce some
convenient projections.
\begin{code}
module _ {π€ π£ : Universe} where
open PosetAxioms
DCPO-structure : π€ Μ β π€ β (π₯ βΊ) β (π£ βΊ) Μ
DCPO-structure D = Ξ£ _β_ κ (D β D β π£ Μ ), (dcpo-axioms {π€} {π£} _β_)
DCPO : (π€ βΊ) β (π₯ βΊ) β (π£ βΊ) Μ
DCPO = Ξ£ D κ π€ Μ , DCPO-structure D
β¨_β© : DCPO β π€ Μ
β¨ D , _β_ , d β© = D
underlying-order : (π : DCPO) β β¨ π β© β β¨ π β© β π£ Μ
underlying-order (D , _β_ , d) = _β_
syntax underlying-order π x y = x ββ¨ π β© y
axioms-of-dcpo : (π : DCPO) β dcpo-axioms (underlying-order π)
axioms-of-dcpo (D , _β_ , d) = d
poset-axioms-of-dcpo : (π : DCPO) β poset-axioms (underlying-order π)
poset-axioms-of-dcpo (D , _β_ , d) = prβ d
sethood : (π : DCPO) β is-set β¨ π β©
sethood (D , _β_ , (s , p , r , t , a) , c ) = s
prop-valuedness : (π : DCPO) β is-prop-valued (underlying-order π )
prop-valuedness (D , _β_ , (s , p , r , t , a) , c ) = p
reflexivity : (π : DCPO) β is-reflexive (underlying-order π)
reflexivity (D , _β_ , (s , p , r , t , a) , c ) = r
transitivity : (π : DCPO) β is-transitive (underlying-order π)
transitivity (D , _β_ , (s , p , r , t , a) , c ) = t
antisymmetry : (π : DCPO) β is-antisymmetric (underlying-order π)
antisymmetry (D , _β_ , (s , p , r , t , a) , c ) = a
\end{code}
Added by Ayberk Tosun on 2024-04-19.
To work with the combinators in `UF.Logic`, it is convenient to have a version
of equality on domain elements that is packaged up with the proof that it is
a proposition.
\begin{code}
dcpo-equalityβ : (π : DCPO) β β¨ π β© β β¨ π β© β Ξ© π€
dcpo-equalityβ π x y = (x οΌ y) , sethood π
syntax dcpo-equalityβ π x y = x οΌβ[ π ] y
infix 2 dcpo-equalityβ
\end{code}
We introduce pretty syntax for chain reasoning with inequalities.
(Cf. οΌβ¨_β© and β in Id.lagda, ββ¨_β© and β in UF.Equiv.lagda)
For example, given (a b c d : β¨ π β©) and
u : a ββ¨ π β© b
v : b ββ¨ π β© c
w : c ββ¨ π β© d
this will allow us to write
z : a ββ¨ π β© d
z = a ββ¨ π β©[ u ]
b ββ¨ π β©[ v ]
c ββ¨ π β©[ w ]
d ββ¨ π β©
rather than the hard(er) to read
z : a ββ¨ π β© d
z = transitivity π a c d z' w
where
z' : a ββ¨ π β© c
z' = transitivity π a b c u v
\begin{code}
transitivity' : (π : DCPO) (x : β¨ π β©) {y z : β¨ π β©}
β x ββ¨ π β© y β y ββ¨ π β© z β x ββ¨ π β© z
transitivity' π x {y} {z} u v = transitivity π x y z u v
syntax transitivity' π x u v = x ββ¨ π β©[ u ] v
infixr 0 transitivity'
syntax reflexivity π x = x ββ¨ π β©
infix 1 reflexivity
has-bottom : DCPO β π€ β π£ Μ
has-bottom π = has-least (underlying-order π)
\end{code}
Next, we introduce β-notation for the supremum of a directed family in a dcpo.
\begin{code}
directed-completeness : (π : DCPO) β is-directed-complete (underlying-order π)
directed-completeness (D , _β_ , a) = prβ a
is-Semidirected : (π : DCPO) {I : π¦ Μ } (Ξ± : I β β¨ π β©) β π¦ β π£ Μ
is-Semidirected π Ξ± = is-semidirected (underlying-order π) Ξ±
is-Directed : (π : DCPO) {I : π¦ Μ } (Ξ± : I β β¨ π β©) β π¦ β π£ Μ
is-Directed π Ξ± = is-directed (underlying-order π) Ξ±
inhabited-if-Directed : (π : DCPO) {I : π¦ Μ } (Ξ± : I β β¨ π β©)
β is-Directed π Ξ±
β β₯ I β₯
inhabited-if-Directed π Ξ± = prβ
semidirected-if-Directed : (π : DCPO) {I : π¦ Μ } (Ξ± : I β β¨ π β©)
β is-Directed π Ξ±
β is-Semidirected π Ξ±
semidirected-if-Directed π Ξ± = prβ
Ο-chains-are-Directed : (π : DCPO) (Ξ± : β β β¨ π β©)
β is-Ο-chain (underlying-order π) Ξ±
β is-Directed π Ξ±
Ο-chains-are-Directed π Ξ± =
Ο-chains-are-directed (underlying-order π) (reflexivity π) (transitivity π) Ξ±
β : (π : DCPO) {I : π₯ Μ } {Ξ± : I β β¨ π β©} β is-Directed π Ξ± β β¨ π β©
β π {I} {Ξ±} Ξ΄ = prβ (directed-completeness π I Ξ± Ξ΄)
β-is-sup : (π : DCPO) {I : π₯ Μ } {Ξ± : I β β¨ π β©} (Ξ΄ : is-Directed π Ξ±)
β is-sup (underlying-order π) (β π Ξ΄) Ξ±
β-is-sup π {I} {Ξ±} Ξ΄ = prβ (directed-completeness π I Ξ± Ξ΄)
β-is-upperbound : (π : DCPO) {I : π₯ Μ } {Ξ± : I β β¨ π β©} (Ξ΄ : is-Directed π Ξ±)
β is-upperbound (underlying-order π) (β π Ξ΄) Ξ±
β-is-upperbound π Ξ΄ = prβ (β-is-sup π Ξ΄)
β-is-lowerbound-of-upperbounds : (π : DCPO) {I : π₯ Μ } {Ξ± : I β β¨ π β©}
(Ξ΄ : is-Directed π Ξ±)
β is-lowerbound-of-upperbounds
(underlying-order π) (β π Ξ΄) Ξ±
β-is-lowerbound-of-upperbounds π Ξ΄ = prβ (β-is-sup π Ξ΄)
\end{code}
Finally, we define (strict) continuous maps between (pointed) dcpos.
\begin{code}
is-continuous : (π : DCPO {π€} {π£}) (π : DCPO {π€'} {π£'})
β (β¨ π β© β β¨ π β©)
β π₯ βΊ β π€ β π£ β π€' β π£' Μ
is-continuous π π f = (I : π₯ Μ ) (Ξ± : I β β¨ π β©) (Ξ΄ : is-Directed π Ξ±)
β is-sup (underlying-order π) (f (β π Ξ΄)) (f β Ξ±)
being-continuous-is-prop : (π : DCPO {π€} {π£}) (π : DCPO {π€'} {π£'})
(f : β¨ π β© β β¨ π β©)
β is-prop (is-continuous π π f)
being-continuous-is-prop π π f =
Ξ β-is-prop fe (Ξ» I Ξ± Ξ΄ β is-sup-is-prop (underlying-order π)
(prβ (axioms-of-dcpo π))
(f (β π Ξ΄)) (f β Ξ±))
DCPO[_,_] : DCPO {π€} {π£} β DCPO {π€'} {π£'} β π₯ βΊ β π€ β π£ β π€' β π£' Μ
DCPO[ π , π ] = Ξ£ f κ (β¨ π β© β β¨ π β©) , is-continuous π π f
underlying-function : (π : DCPO {π€} {π£}) (π : DCPO {π€'} {π£'})
β DCPO[ π , π ] β β¨ π β© β β¨ π β©
underlying-function π π (f , _) = f
syntax underlying-function π π f = [ π , π ]β¨ f β©
continuity-of-function : (π : DCPO {π€} {π£}) (π : DCPO {π€'} {π£'}) (f : DCPO[ π , π ])
β is-continuous π π [ π , π ]β¨ f β©
continuity-of-function π π (_ , c) = c
\end{code}