module Order.DCPO where
Directed-complete partial ordersđ
Let be a partial order. A family of elements is a semi-directed family if for every there merely exists some such and A semidirected family is a directed family when is merely inhabited.
module _ {o â} (P : Poset o â) where open Order.Reasoning P is-semidirected-family : â {Ix : Type o} â (Ix â Ob) â Type _ is-semidirected-family {Ix = Ix} f = â i j â â[ k â Ix ] (f i †f k Ă f j †f k) record is-directed-family {Ix : Type o} (f : Ix â Ob) : Type (o â â) where no-eta-equality field elt : â„ Ix â„ semidirected : is-semidirected-family f
Note that any family whose indexing type is a proposition is automatically semi-directed:
prop-indexedâsemidirected : â {Ix : Type o} â (s : Ix â Ob) â is-prop Ix â is-semidirected-family s prop-indexedâsemidirected s prop i j = inc (i , â€-refl , â€-refl' (ap s (prop j i)))
The poset is a directed-complete partial order, or DCPO, if it has least upper bounds of all directed families.
record is-dcpo : Type (lsuc o â â) where no-eta-equality field directed-lubs : â {Ix : Type o} (f : Ix â Ob) â is-directed-family f â Lub P f module â {Ix : Type o} (f : Ix â Ob) (dir : is-directed-family f) = Lub (directed-lubs f dir) open â using () renaming (lub to â; famâ€lub to famâ€â; least to â-least) public
Since least upper bounds are unique when they exist, being a DCPO is a property of a poset, and not structure on that poset.
Scott-continuous functionsđ
Let and be a pair of posets. A monotone map is called Scott-continuous when it preserves all directed lubs.
module _ {P Q : Poset o â} where private module P = Poset P module Q = Poset Q open is-directed-family open Total-hom
is-scott-continuous : (f : Posets.Hom P Q) â Type _ is-scott-continuous f = â {Ix} (s : Ix â P.Ob) (fam : is-directed-family P s) â â x â is-lub P s x â is-lub Q (f .hom â s) (f .hom x) is-scott-continuous-is-prop : â (f : Posets.Hom P Q) â is-prop (is-scott-continuous f) is-scott-continuous-is-prop _ = hlevel 1
If is a DCPO, then any function which preserves directed lubs is automatically a monotone map, and, consequently, Scott-continuous.
To see this, suppose weâre given with The family that sends to and to is directed: is inhabited, and is a least upper bound for arbitrary values of the family. Since preserves lubs, we have
opaque dcpo+scottâmonotone : is-dcpo P â (f : P.Ob â Q.Ob) â (â {Ix} (s : Ix â Poset.Ob P) (fam : is-directed-family P s) â â x â is-lub P s x â is-lub Q (f â s) (f x)) â â {x y} â x P.†y â f x Q.†f y dcpo+scottâmonotone is-dcpo f scott {x} {y} p = fs-lub .is-lub.famâ€lub (lift true) where s : Lift o Bool â P.Ob s (lift b) = if b then x else y sxâ€sfalse : â b â s b P.†s (lift false) sxâ€sfalse (lift true) = p sxâ€sfalse (lift false) = P.â€-refl s-directed : is-directed-family P s s-directed .elt = inc (lift true) s-directed .semidirected i j = inc (lift false , sxâ€sfalse _ , sxâ€sfalse _) s-lub : is-lub P s y s-lub .is-lub.famâ€lub = sxâ€sfalse s-lub .is-lub.least z lt = lt (lift false) fs-lub : is-lub Q (f â s) (f y) fs-lub = scott s s-directed y s-lub
Moreover, if is an arbitrary monotone map, and is a directed family, then is still a directed family.
monotoneâdirected : â {Ix : Type o} â {s : Ix â P.Ob} â (f : Posets.Hom P Q) â is-directed-family P s â is-directed-family Q (f .hom â s) monotoneâdirected f dir .elt = dir .elt monotoneâdirected f dir .is-directed-family.semidirected i j = â„-â„-map (ÎŁ-mapâ (Ă-map (f .pres-â€) (f .pres-â€))) (dir .semidirected i j)
The identity function is Scott-continuous.
scott-id : â {P : Poset o â} â is-scott-continuous (Posets.id {x = P}) scott-id s fam x lub = lub
Scott-continuous functions are closed under composition.
scott-â : â {P Q R : Poset o â} â (f : Posets.Hom Q R) (g : Posets.Hom P Q) â is-scott-continuous f â is-scott-continuous g â is-scott-continuous (f Posets.â g) scott-â f g f-scott g-scott s dir x lub = f-scott (g .hom â s) (monotoneâdirected g dir) (g .hom x) (g-scott s dir x lub)
The category of DCPOsđ
DCPOs form a subcategory of the category of posets. Furthermore, since being a DCPO is a property, identity of DCPOs is determined by identity of their underlying posets: thus, the category of DCPOs is univalent.
DCPOs-subcat : â (o â : Level) â Subcat (Posets o â) (lsuc o â â) (lsuc o â â) DCPOs-subcat o â .Subcat.is-ob = is-dcpo DCPOs-subcat o â .Subcat.is-hom f _ _ = is-scott-continuous f DCPOs-subcat o â .Subcat.is-hom-prop f _ _ = is-scott-continuous-is-prop f DCPOs-subcat o â .Subcat.is-hom-id _ = scott-id DCPOs-subcat o â .Subcat.is-hom-â {f = f} {g = g} = scott-â f g DCPOs : â (o â : Level) â Precategory (lsuc (o â â)) (lsuc o â â) DCPOs o â = Subcategory (DCPOs-subcat o â) DCPOs-is-category : â {o â} â is-category (DCPOs o â) DCPOs-is-category = subcat-is-category Posets-is-category (λ _ â hlevel 1)
module DCPOs {o â : Level} = Cat.Reasoning (DCPOs o â) DCPO : (o â : Level) â Type _ DCPO o â = DCPOs.Ob {o} {â} DCPOsâȘPosets : â {o â} â Functor (DCPOs o â) (Posets o â) DCPOsâȘPosets = Forget-subcat DCPOsâȘSets : â {o â} â Functor (DCPOs o â) (Sets o) DCPOsâȘSets = PosetsâȘSets Fâ DCPOsâȘPosets
Reasoning with DCPOsđ
The following pair of modules re-exports facts about the underlying posets (resp. monotone maps) of DCPOs (resp. Scott-continuous functions). They also prove a plethora of small lemmas that are useful in formalisation but not for informal reading.
These proofs are all quite straightforward, so we omit them.
module DCPO {o â} (D : DCPO o â) where poset : Poset o â poset = D .fst open Order.Reasoning poset public set : Set o set = el â D â Ob-is-set has-dcpo : is-dcpo poset has-dcpo = D .snd open is-dcpo has-dcpo public â-pointwise : â {Ix} {s s' : Ix â Ob} â {fam : is-directed-family poset s} {fam' : is-directed-family poset s'} â (â ix â s ix †s' ix) â â s fam †â s' fam' â-pointwise p = â.least _ _ (â _ _) λ ix â â€-trans (p ix) (â.famâ€lub _ _ ix) module Scott {o â} {D E : DCPO o â} (f : DCPOs.Hom D E) where private module D = DCPO D module E = DCPO E mono : Posets.Hom D.poset E.poset mono = Subcat-hom.hom f monotone : â {x y} â x D.†y â f # x E.†f # y monotone = mono .pres-†opaque pres-directed-lub : â {Ix} (s : Ix â D.Ob) â is-directed-family D.poset s â â x â is-lub (D .fst) s x â is-lub (E .fst) (apply f â s) (f # x) pres-directed-lub = Subcat-hom.witness f directed : â {Ix} {s : Ix â D.Ob} â is-directed-family D.poset s â is-directed-family E.poset (apply f â s) directed dir = monotoneâdirected (Subcat-hom.hom f) dir pres-â : â {Ix} (s : Ix â D.Ob) â (dir : is-directed-family D.poset s) â f # (D.â s dir) ⥠E.â (apply f â s) (directed dir) pres-â s dir = E.â€-antisym (is-lub.least (pres-directed-lub s dir (D.â s dir) (D.â.has-lub s dir)) (E.â (apply f â s) (directed dir)) (E.â.famâ€lub (apply f â s) (directed dir))) (E.â.least (apply f â s) (directed dir) (apply f (D.â s dir)) λ i â monotone (D.â.famâ€lub s dir i))
module _ {o â} {D E : DCPO o â} where private module D = DCPO D module E = DCPO E open is-directed-family open Total-hom
We also provide a couple methods for constructing Scott-continuous maps. First, we note that if a function is monotonic and commutes with some chosen assignment of least upper bounds, then it is Scott-continuous.
to-scott : (f : D.Ob â E.Ob) â (â {x y} â x D.†y â f x E.†f y) â (â {Ix} (s : Ix â D.Ob) â (dir : is-directed-family D.poset s) â is-lub E.poset (f â s) (f (D.â s dir))) â DCPOs.Hom D E to-scott f monotone pres-â = sub-hom fá” pres-lub where fá” : Monotone D.poset E.poset fá” .hom = f fá” .pres-†= monotone pres-lub : â {Ix} (s : Ix â D.Ob) â (dir : is-directed-family D.poset s) â â x â is-lub D.poset s x â is-lub E.poset (f â s) (f x) pres-lub s dir x x-lub .is-lub.famâ€lub i = monotone (is-lub.famâ€lub x-lub i) pres-lub s dir x x-lub .is-lub.least y le = f x E.â€âš monotone (is-lub.least x-lub _ (D.â.famâ€lub s dir)) â©E.†f (D.â s dir) E.=âš lub-unique (pres-â s dir) (E.â.has-lub (f â s) (monotoneâdirected fá” dir)) â©E.= E.â (f â s) _ E.â€âš E.â.least _ _ y le â©E.†y E.â€â
Furthermore, if preserves arbitrary least upper bounds, then it is monotone, and thus Scott-continuous.
to-scott-directed : (f : D.Ob â E.Ob) â (â {Ix} (s : Ix â D.Ob) â (dir : is-directed-family D.poset s) â â x â is-lub D.poset s x â is-lub E.poset (f â s) (f x)) â DCPOs.Hom D E to-scott-directed f pres .Subcat-hom.hom .hom = f to-scott-directed f pres .Subcat-hom.hom .pres-†= dcpo+scottâmonotone D.has-dcpo f pres to-scott-directed f pres .Subcat-hom.witness = pres