module Order.Frame.Free where
Free cocompletionsπ
A frame is, in particular, a meet semilattice. Frame homomorphisms preserve finite meets, so they are also homomorphisms of the underlying meet semilattices. Since equality of homomorphisms is determined by equality of the underlying functions, these remarks assemble into a functor
FrameβͺSLat : β {o β} β Functor (Frames o β) (Meet-slats o β) FrameβͺSLat .Fβ (_ , A) = Frm.meets A FrameβͺSLat .Fβ f .hom = f .hom FrameβͺSLat .Fβ f .witness = has-meet-slat-hom (f .witness) FrameβͺSLat .F-id = trivial! FrameβͺSLat .F-β f g = trivial!
The question this module seeks to answer is: is there a way to freely turn a semilattice into a frame such that the meets in are preserved by the inclusion And if so, how?
Fortunately the answer is positive: otherwise this module would be much longer (and probably rely on silly cardinality arguments). The free frame on a semilattice is the free cocompletion of that semilattice, its poset of lower sets. The lower sets of any poset are a frame, because meets and joins are computed pointwise in the poset of propositions,
Lower-sets-frame : β {o β} β Meet-semilattice o β β Frame (o β β) o Lower-sets-frame (P , L) = Lower-sets P , Lβ-frame where module L = Meet-slat L module Lβ = Order.Reasoning (Lower-sets P) Lβ-frame : is-frame (Lower-sets P) Lβ-frame .is-frame._β©_ a b = Lower-sets-meets P a b .Meet.glb Lβ-frame .is-frame.β©-meets a b = Lower-sets-meets P a b .Meet.has-meet Lβ-frame .is-frame.has-top = Lower-sets-top P Lβ-frame .is-frame.β k = Lower-sets-cocomplete P k .Lub.lub Lβ-frame .is-frame.β-lubs k = Lower-sets-cocomplete P k .Lub.has-lub Lβ-frame .is-frame.β-distribl x f = ext Ξ» arg β biimp (rec! Ξ» xβ€a i fiβ€a β inc (i , xβ€a , fiβ€a)) (rec! Ξ» i xβ€a fiβ€a β xβ€a , inc (i , fiβ€a))
The unit map sends an element of to its down-set, By a decategorification of the similar arguments about the Yoneda embedding, the map preserves finite meets (really, it preserves all glbs that exist in and for a complete lattice the left Kan extension of a map along is always cocontinuous, and left exact whenever is. Since weβre extending semilattice homomorphisms, this means that is a frame homomorphism.
Note the similarity between the construction of free frames outlined in the paragraph above and Diaconescuβs theorem: βA map of frames corresponds to a lex monotone map β is precisely the decategorification of βA geometric morphism is a flat functor β.
make-free-cocompletion : β {β} β (A : Meet-semilattice β β) β Free-object FrameβͺSLat A make-free-cocompletion {β} A = go where
Anwyay, that was a very dense explanation of the universal property. Letβs go through it again, this time commenting on everything as we encounter it. We start by packaging together the extension of a semilattice homomorphism to a frame homomorphism
module A = Meet-slat (A .snd) module Mk (B : Frame β β) (f : Meet-slats.Hom A (Frm.meets (B .snd))) where module Aβ = Frm (Lower-sets-frame A .snd) module B = Frm (B .snd) module f = is-meet-slat-hom (f .witness)
The easy part is an appeal to the existing machinery for free cocompletions: Any monotone map extends to a cocontinuous map because being a frame, is cocomplete.
mkhom : Frames.Hom (Lower-sets-frame A) B mkhom .hom = Lanβ B.β-lubs (f .hom) mkhom .witness .β-β€ g = B.β€-refl' $ Lanβ-cocontinuous B.β-lubs (f .hom) g
The harder part is showing that the cocontinuous extension of a semilattice homomorphism is still a semilattice homomorphism. It preserves the top element, since the cocontinuous extension takes to which is readily calculated to equal
mkhom .witness .top-β€ = B.top B.β€β¨ f.top-β€ β©B.β€ f # A.top B.β€β¨ B.β-inj (A.top , tt) β©B.β€ B.β (Ξ» i β f # fst i) B.β€β
Slightly harder, but still a bit of algebra, is computing that binary meets are preserved as well. The first step follows from the infinite distributive law in and the second from the fact that preserves binary meets.
mkhom .witness .β©-β€ S T = B.β (Ξ» i β f # fst i) B.β© B.β (Ξ» i β f # fst i) B.=β¨ B.β-β©-product (Ξ» i β hom f # fst i) (Ξ» i β hom f # fst i) β©B.= B.β (Ξ» i β f # fst (fst i) B.β© f # fst (snd i)) B.β€β¨ B.ββ€β-over meet-section (Ξ» i β f.β©-β€ _ _) β©B.β€ B.β (Ξ» i β f # fst i) B.β€β where meet-section : β«β S Γ β«β T β β«β (Ξ» x β x β S Γ x β T) meet-section ((x , p) , (y , q)) = x A.β© y , S .pres-β€ A.β©β€l p , T .pres-β€ A.β©β€r q
Itβs also free from the definition of cocompletions that the extended map satisfies
mkcomm : β x β mkhom # (β (A .fst) x) β‘ f # x mkcomm x = (Lanβ-commutes B.β-lubs (f .hom) x)
Now we must define the unit map. Weβve already committed to defining so we have to show that preserves finite meets. This is true because lands in lower sets, so it suffices to show an equivalence between (e.g.) being under and under and being under . But thatβs the definition of
the-unit : (S : Meet-semilattice β β) β Meet-slats.Hom S (Frm.meets (Lower-sets-frame S .snd)) the-unit S = go where module S = Meet-slat (S .snd) module Sβ = Frm (Lower-sets-frame S .snd) go : Meet-slats.Hom S Sβ.meets go .hom = γβ (S .fst) go .witness .is-meet-slat-hom.β©-β€ x y z (p , q) = do zβ€x β p zβ€y β q pure $ S.β©-universal z zβ€x zβ€y go .witness .is-meet-slat-hom.top-β€ x _ = pure S.!
Weβre already 80% done with the adjunction. The final thing to do is to put it all together, bringing in the result about uniqueness of cocontinuous extensions to tie everything up:
go : Free-object FrameβͺSLat A go .free = Lower-sets-frame A go .unit = the-unit A go .fold {B} f = Mk.mkhom B f go .commute {B} {f} = ext (Mk.mkcomm B f) go .unique {B} {f} g wit = ext (p #β_) where open Mk B f gα΅ : Monotone (Lower-sets (A .fst)) (B .fst) gα΅ .hom x = g # x gα΅ .pres-β€ {x} {y} w = g .hom .pres-β€ w p = Lanβ-unique B.β-lubs (f .hom) gα΅ (is-frame-hom.pres-β (g .witness)) (wit #β_)