open import Cat.Prelude

open import Data.Sum

open import Order.Semilattice.Join
open import Order.Semilattice.Meet
open import Order.Diagram.Bottom
open import Order.Diagram.Join
open import Order.Diagram.Meet
open import Order.Diagram.Glb
open import Order.Diagram.Lub
open import Order.Diagram.Top
open import Order.Base

module Order.Instances.Props where


# Propositionsπ

In the posetal world, what plays the role of the category of sets is the poset of propositions β our relations take values in propositions, much like the category of sets is where the functor takes values.

Unlike βtheβ category of sets, which is actually a bunch of categories (depending on the universe level of the types weβre considering), there is a single poset of propositions β this is the principle of propositional resizing, which we assume throughout.

Props : Poset lzero lzero
Props .Poset._β€_ P Q = β£ P β£ β β£ Q β£
Props .Poset.β€-thin = hlevel 1
Props .Poset.β€-refl x = x
Props .Poset.β€-trans g f x = f (g x)


The poset of propositions a top and bottom element, as well as all meets and joins.

Props-has-top : Top Props
Props-has-top .Top.has-top _ _ = tt

Props-has-bot : Bottom Props
Props-has-bot .Bottom.has-bottom _ ()

Props-has-joins : β P Q β is-join Props P Q (P β¨Ξ© Q)
Props-has-joins P Q .is-join.lβ€join = pure β inl
Props-has-joins P Q .is-join.rβ€join = pure β inr
Props-has-joins P Q .is-join.least R l r = rec! [ l , r ]

Props-has-meets : β P Q β is-meet Props P Q (P β§Ξ© Q)
Props-has-meets P Q .is-meet.meetβ€l = fst
Props-has-meets P Q .is-meet.meetβ€r = snd
Props-has-meets P Q .is-meet.greatest R l r x = l x , r x

module _ {β} {I : Type β} (Ps : I β Ξ©) where
Props-has-glbs : is-glb Props Ps (βΞ© I Ps)
Props-has-glbs .is-glb.glbβ€fam i = rec! (_\$ i)
Props-has-glbs .is-glb.greatest R k x = inc (Ξ» i β k i x)

Props-has-lubs : is-lub Props Ps (βΞ© I Ps)
Props-has-lubs .is-lub.famβ€lub i pi = inc (i , pi)
Props-has-lubs .is-lub.least R k = rec! k

open is-meet-semilattice
open is-join-semilattice

Props-is-meet-slat : is-meet-semilattice Props