module Order.DCPO.Free where
private variable o o' â : Level A B C : Type â open is-directed-family open Lub open Functor open _=>_ open _âŁ_
Free DCPOsđ
The discrete poset on a set is a DCPO. To see this, note that every semi-directed family in a discrete poset is constant. Furthermore, is directed, so it is merely inhabited.
Disc-is-dcpo : â {â} {A : Set â} â is-dcpo (Disc A) Disc-is-dcpo {A = A} .is-dcpo.directed-lubs {Ix = Ix} f dir = const-inhabited-famâlub disc-fam-const (dir .elt) where disc-fam-const : â i j â f i ⥠f j disc-fam-const i j = case dir .semidirected i j of λ k p q â p â sym q Disc-dcpo : (A : Set â) â DCPO â â Disc-dcpo A = Disc A , Disc-is-dcpo
This extends to a functor from to the category of DCPOs.
Free-DCPO : â {â} â Functor (Sets â) (DCPOs â â) Free-DCPO .Fâ = Disc-dcpo Free-DCPO .Fâ f = to-scott-directed f λ s dir x x-lub â const-inhabited-famâis-lub (λ ix â ap f (disc-is-lubâconst x-lub ix)) (dir .elt) Free-DCPO .F-id = trivial! Free-DCPO .F-â _ _ = trivial!
Furthermore, this functor is left adjoint to the forgetful functor to
Free-DCPOâŁForget-DCPO : â {â} â Free-DCPO {â} ⣠DCPOsâȘSets Free-DCPOâŁForget-DCPO .unit .η _ x = x Free-DCPOâŁForget-DCPO .unit .is-natural _ _ _ = refl Free-DCPOâŁForget-DCPO .counit .η D = to-scott-directed (λ x â x) λ s dir x x-lub â λ where .is-lub.famâ€lub i â â€-refl' (disc-is-lubâconst x-lub i) .is-lub.least y le â â„-â„-rec â€-thin (λ i â x =Ëâš disc-is-lubâconst x-lub i â©=Ë s i â€âš le i â©â€ y â€â) (dir .elt) where open DCPO D Free-DCPOâŁForget-DCPO .counit .is-natural x y f = trivial! Free-DCPOâŁForget-DCPO .zig = trivial! Free-DCPOâŁForget-DCPO .zag = refl
Free pointed DCPOsđ
The purpose of this section is to establish that the free pointed DCPO on a set is given by its partial elements We have already constructed the order we will use, the information ordering, and established some of its basic order-theoretic properties, so that we immediately get a poset of partial elements:
Parts : (A : Set â) â Poset â â Parts A .Poset.Ob = ⯠⣠A ⣠Parts A .Poset._â€_ = _â_ Parts A .Poset.â€-thin = hlevel 1 Parts A .Poset.â€-refl = â-refl Parts A .Poset.â€-trans = â-trans Parts A .Poset.â€-antisym = â-antisym
Unfortunately, the hardest two parts of the construction remain:
We must show that has least upper bounds for all semidirected families, i.e., that it is actually a DCPO;
We must show that this construction is actually free, meaning that every map to a pointed DCPO extends uniquely to a strictly Scott-continuous
We will proceed in this order.
Directed joins of partial elementsđ
â-lub : {Ix : Type â} ⊠_ : H-Level A 2 ⊠(s : Ix â ⯠A) â (semi : â i j â â[ k â Ix ] (s i â s k Ă s j â s k)) â ⯠A
Suppose that is a semidirected family of partial elements â which, recall, means that for each we can merely find satisfying and We decree that the join is defined whenever there exists such that is defined.
â-lub {Ix = Ix} s dir .def = elΩ (ÎŁ[ i â Ix ] â s i â)
Next, we need to construct an element of under the assumption that there exists such an The obvious move is to use the value itself. However, we only merely have such an and weâre not mapping into a proposition â weâre mapping into a set. But thatâs not a major impediment: weâre allowed to make this choice, as long as we show that the function is constant.
â-lub {Ix = Ix} s dir .elt = âĄ-rec-set (hlevel 2) (λ (ix , def) â s ix .elt def) (λ p q i â is-const p q i .elt $ is-propâpathp (λ i â is-const p q i .def .is-tr) (p .snd) (q .snd) i) where abstract
So imagine that we have two indices with and both defined. We must show that Since is semidirected, and weâre showing a proposition, we may assume that there is some satisfying and We then compute:
is-const : â (p q : ÎŁ[ i â Ix ] â s i â) â s (p .fst) ⥠s (q .fst) is-const (i , si) (j , sj) = â„-â„-out! do (k , p , q) â dir i j pure $ part-ext (λ _ â sj) (λ _ â si) λ si sj â s i .elt _ âĄËâš p .refines si â©âĄË s k .elt _ âĄâš âŻ-indep (s k) â©âĄ s k .elt _ âĄâš q .refines sj â©âĄ s j .elt _ â
After having constructed the element, weâre still left with proving that this is actually a least upper bound. This turns out to be pretty straightforward, so we present the solution without further comments:
module _ {Ix : Type â} ⊠set : H-Level A 2 ⊠{s : Ix â ⯠A} {dir : â i j â â[ k â Ix ] (s i â s k Ă s j â s k)} where
â-lub-le : â i â s i â â-lub s dir â-lub-le i .implies si = inc (i , si) â-lub-le i .refines si = refl â-lub-least : â x â (â i â s i â x) â â-lub s dir â x â-lub-least x le .implies = rec! λ i si â le i .implies si â-lub-least x le .refines = elim! λ i si â le i .refines si
Parts-is-dcpo : â {A : Set â} â is-dcpo (Parts A) Parts-is-dcpo {A = A} .directed-lubs s dir .lub = â-lub s (dir .semidirected) Parts-is-dcpo {A = A} .directed-lubs s dir .has-lub .famâ€lub = â-lub-le Parts-is-dcpo {A = A} .directed-lubs s dir .has-lub .least = â-lub-least Parts-dcpo : (A : Set â) â DCPO â â Parts-dcpo A = Parts A , Parts-is-dcpo
Furthermore, itâs a pointed DCPO, since we additionally have a bottom element.
Parts-is-pointed-dcpo : â {A : Set â} â is-pointed-dcpo (Parts-dcpo A) Parts-is-pointed-dcpo .bot = never Parts-is-pointed-dcpo .has-bottom _ = never-â Parts-pointed-dcpo : â (A : Set â) â Pointed-dcpo â â Parts-pointed-dcpo A = Parts-dcpo A , Parts-is-pointed-dcpo
Finally, we note that the functorial action of the partiality monad preserves these directed joins. Since itâs valued in strict Scott-continuous maps, this action extends to a proper functor from the category to the category of pointed dcpos.
part-map-lub : {Ix : Type â} {A : Set o} {B : Set o'} {s : Ix â ⯠⣠A âŁ} â {dir : â i j â â[ k â Ix ] (s i â s k Ă s j â s k)} â (f : ⣠A ⣠â ⣠B âŁ) â is-lub (Parts B) (part-map f â s) (part-map f (â-lub s dir)) part-map-lub f .famâ€lub i = part-map-â (â-lub-le i) part-map-lub f .least y le .implies = rec! λ i si â le i .implies si part-map-lub {B = B} f .least y le .refines = elim! λ i si â le i .refines si Free-Pointed-dcpo : Functor (Sets â) (Pointed-DCPOs â â) Free-Pointed-dcpo .Fâ A = Parts-pointed-dcpo A Free-Pointed-dcpo .Fâ {x = A} f = to-strict-scott-bottom (part-map f) (part-map-â) (λ _ _ â part-map-lub {A = A} f) (λ _ â part-map-never) Free-Pointed-dcpo .F-id = ext (part-map-id $_) Free-Pointed-dcpo .F-â f g = ext (part-map-â f g $_)
The universal propertyđ
It remains to show that this functor is actually a left adjoint. We have
already constructed the adjunction unit: it is the map always
which embeds
into
We turn to defining the counit. Since every pointed dcpo admits joins
indexed by propositions,
given a
we can define
to be the join
part-counit : ⯠Ob â Ob part-counit x = â-prop (x .elt â lower) def-prop where abstract def-prop : is-prop (Lift o â x â) def-prop = hlevel 1
We can characterise the behaviour of this definition as though it were defined by cases: if is defined, then this simply yields its value. And if is undefined, then this is the bottom element.
part-counit-elt : (x : ⯠Ob) (p : â x â) â part-counit x ⥠x .elt p part-counit-elt x p = â€-antisym (â-prop-least _ _ _ λ (lift p') â â€-refl' (âŻ-indep x)) (â-prop-le _ _ (lift p)) part-counit-ÂŹelt : (x : ⯠Ob) â (â x â â â„) â part-counit x ⥠bottom part-counit-ÂŹelt x ÂŹdef = â€-antisym (â-prop-least _ _ _ (λ p â absurd (ÂŹdef (lower p)))) (bottomâ€x _)
The following three properties are fundamental: the counit
- preserves the information order; and
- preserves directed joins; and
- preserves the bottom element.
part-counit-â : â {x y} â x â y â part-counit x †part-counit y part-counit-lub : â {Ix} s (sdir : is-semidirected-family (Parts set) {Ix} s) â is-lub poset (part-counit â s) (part-counit (â-lub s sdir)) part-counit-never : â x â part-counit never †x
The proofs here are simply calculations. We leave them for the curious reader.
part-counit-â {x = x} {y = y} p = â-prop-least _ _ (part-counit y) λ (lift i) â x .elt i =Ëâš p .refines i â©=Ë y .elt (p .implies i) â€âš â-prop-le _ _ (lift (p .implies i)) â©â€ â-prop (y .elt â lower) _ â€â part-counit-lub s sdir .is-lub.famâ€lub i = â-prop-least _ _ _ λ (lift p) â â-prop-le _ _ (lift (inc (i , p))) part-counit-lub {Ix = Ix} s sdir .is-lub.least y le = â-prop-least _ _ _ $ λ (lift p) â âĄ-elim (λ p â â€-thin {x = â-lub s sdir .elt p}) (λ (i , si) â s i .elt si â€âš â-prop-le _ _ (lift si) â©â€ â-prop _ _ â€âš le i â©â€ y â€â) p part-counit-never x = â-prop-least _ _ x (λ ())
We can tie this all together to obtain the desired adjunction.
Free-Pointed-dcpoâŁForget-Pointed-dcpo : â {â} â Free-Pointed-dcpo {â} ⣠Pointed-DCPOsâȘSets Free-Pointed-dcpoâŁForget-Pointed-dcpo .unit .η A x = always x Free-Pointed-dcpoâŁForget-Pointed-dcpo .unit .is-natural x y f = ext λ _ â sym (always-natural f) Free-Pointed-dcpoâŁForget-Pointed-dcpo .counit .η D = to-strict-scott-bottom (part-counit D) (part-counit-â D) (λ s dir â part-counit-lub D s (dir .semidirected)) (part-counit-never D) Free-Pointed-dcpoâŁForget-Pointed-dcpo .counit .is-natural D E f = ext λ x â sym $ Strict-scott.pres-â-prop f _ _ _ Free-Pointed-dcpoâŁForget-Pointed-dcpo .zig {A} = ext λ x â part-ext (A?.â-prop-least _ _ x (λ p â always-â (lower p , refl)) .implies) (λ p â A?.â-prop-le _ _ (lift p) .implies tt) (λ p q â sym (A?.â-prop-least _ _ x (λ p â always-â (lower p , refl)) .refines p) â âŻ-indep x) where module A? = Pointed-dcpo (Parts-pointed-dcpo A) Free-Pointed-dcpoâŁForget-Pointed-dcpo .zag {B} = ext λ x â sym $ lub-of-const-fam (λ _ _ â refl) (B.â-prop-lub _ _ ) (lift tt) where module B = Pointed-dcpo B