Ian Ray, started: 2023-09-12 - updated: 2024-02-05.
A Sup Lattice L is a set with a partial order โค that has suprema of 'small'
types. We will use three universe parameters: ๐ค for the carrier, ๐ฆ for the
order values and ๐ฅ for the families which have suprema.
\begin{code}
{-# OPTIONS --safe --without-K --exact-split #-}
open import MLTT.Spartan
open import UF.Equiv
open import UF.FunExt
open import UF.HedbergApplications
open import UF.Logic
open import UF.Powerset-MultiUniverse
open import UF.PropTrunc
open import UF.Retracts
open import UF.Sets
open import UF.SubtypeClassifier
open import UF.Size
module OrderedTypes.SupLattice
(pt : propositional-truncations-exist)
(fe : Fun-Ext)
where
open import Locales.Frame pt fe hiding (โจ_โฉ ; join-of)
open import Slice.Family
open import UF.ImageAndSurjection pt
open AllCombinators pt fe
open PropositionalTruncation pt
\end{code}
We commence by defining sup lattices.
\begin{code}
module _ (๐ค ๐ฃ ๐ฅ : Universe) where
sup-lattice-data : ๐ค ฬ โ ๐ค โ ๐ฃ โบ โ ๐ฅ โบ ฬ
sup-lattice-data A = (A โ A โ ฮฉ ๐ฃ) ร (Fam ๐ฅ A โ A)
is-sup-lattice : {A : ๐ค ฬ } โ sup-lattice-data A โ ๐ค โ ๐ฃ โ ๐ฅ โบ ฬ
is-sup-lattice {A} (_โค_ , โ_) = is-partial-order A _โค_ ร suprema
where
open Joins _โค_
suprema : ๐ค โ ๐ฃ โ ๐ฅ โบ ฬ
suprema = (U : Fam ๐ฅ A) โ ((โ U) is-lub-of U) holds
sup-lattice-structure : ๐ค ฬ โ ๐ค โ ๐ฅ โบ โ ๐ฃ โบ ฬ
sup-lattice-structure A = ฮฃ d ๊ (sup-lattice-data A) , is-sup-lattice d
Sup-Lattice : (๐ค โ ๐ฃ โ ๐ฅ) โบ ฬ
Sup-Lattice = ฮฃ A ๊ ๐ค ฬ , sup-lattice-structure A
\end{code}
Now we give some naming conventions which will be useful.
\begin{code}
โจ_โฉ : Sup-Lattice ๐ค ๐ฃ ๐ฅ โ ๐ค ฬ
โจ A , rest โฉ = A
order-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ) โ (โจ L โฉ โ โจ L โฉ โ ฮฉ ๐ฃ)
order-of (A , (_โค_ , โ_) , rest) = _โค_
syntax order-of L x y = x โคโจ L โฉ y
join-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ) โ Fam ๐ฅ โจ L โฉ โ โจ L โฉ
join-of (A , (_โค_ , โ_) , rest) = โ_
syntax join-of L U = โโจ L โฉ U
partial-orderedness-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
โ is-partial-order โจ L โฉ (order-of L)
partial-orderedness-of (A , (_โค_ , โ_) , order , is-lub-of) = order
reflexivity-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ) โ is-reflexive (order-of L) holds
reflexivity-of L = prโ (prโ (partial-orderedness-of L))
antisymmetry-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ) โ is-antisymmetric (order-of L)
antisymmetry-of L = prโ (partial-orderedness-of L)
transitivity-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ) โ is-transitive (order-of L) holds
transitivity-of L = prโ (prโ (partial-orderedness-of L))
join-is-lub-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
โ (U : Fam ๐ฅ โจ L โฉ)
โ ((order-of L) Joins.is-lub-of join-of L U) U holds
join-is-lub-of (A , (_โค_ , โ_) , order , suprema) = suprema
join-is-upper-bound-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
โ (U : Fam ๐ฅ โจ L โฉ)
โ ((order-of L) Joins.is-an-upper-bound-of
join-of L U) U holds
join-is-upper-bound-of L U = prโ (join-is-lub-of L U)
join-is-least-upper-bound-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
โ (U : Fam ๐ฅ โจ L โฉ)
โ ((u' , _) : Joins.upper-bound (order-of L) U)
โ (order-of L (join-of L U) u') holds
join-is-least-upper-bound-of L U = prโ (join-is-lub-of L U)
sethood-of : (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ) โ is-set โจ L โฉ
sethood-of L =
type-with-prop-valued-refl-antisym-rel-is-set
(ฮป x โ ฮป y โ order-of L x y holds)
(ฮป x โ ฮป y โ holds-is-prop (order-of L x y))
(ฮป x โ reflexivity-of L x)
(ฮป x โ ฮป y โ antisymmetry-of L)
\end{code}
We now define monotone endomaps on a sup-lattice and specify monotone endomaps
as a special case.
\begin{code}
module _ where
is-monotone : {๐ค ๐ค' ๐ฃ ๐ฃ' ๐ฅ ๐ฅ' : Universe}
โ (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ) (M : Sup-Lattice ๐ค' ๐ฃ' ๐ฅ')
โ (f : โจ L โฉ โ โจ M โฉ)
โ ๐ค โ ๐ฃ โ ๐ฃ' ฬ
is-monotone L M f = (x y : โจ L โฉ)
โ (x โคโจ L โฉ y) holds
โ (f x โคโจ M โฉ f y) holds
is-monotone-endomap : {๐ค ๐ฃ ๐ฅ : Universe}
โ (L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
โ (f : โจ L โฉ โ โจ L โฉ)
โ ๐ค โ ๐ฃ ฬ
is-monotone-endomap L f = is-monotone L L f
\end{code}
We now show that when one subset contains another the join of their total
spaces are ordered as expected.
\begin{code}
module _
{๐ค ๐ฃ ๐ฅ : Universe}
(L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
{A : ๐ฅ ฬ }
(m : A โ โจ L โฉ)
where
open Joins (order-of L)
joins-preserve-containment : {P : ๐ {๐ฅ} A} {Q : ๐ {๐ฅ} A}
โ P โ Q
โ ((โโจ L โฉ ใ m , P ใ)
โคโจ L โฉ (โโจ L โฉ ใ m , Q ใ)) holds
joins-preserve-containment {P} {Q} C =
(join-is-least-upper-bound-of L ใ m , P ใ)
(โโจ L โฉ ใ m , Q ใ ,
(ฮป (b , b-in-P) โ (join-is-upper-bound-of L ใ m , Q ใ)
(b , C b b-in-P)))
\end{code}
We now show if a type is small and has a map to the carrier then it has a join.
\begin{code}
module _
{๐ค ๐ฃ ๐ฅ ๐ฆ : Universe}
(L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
{T : ๐ฆ ฬ }
(m : T โ โจ L โฉ)
(T-is-small : T is ๐ฅ small)
where
private
T' : ๐ฅ ฬ
T' = (resized T) T-is-small
T'-โ-T : T' โ T
T'-โ-T = resizing-condition T-is-small
T'-to-T : T' โ T
T'-to-T = โ T'-โ-T โ
T'-to-T-is-equiv : is-equiv T'-to-T
T'-to-T-is-equiv = โ T'-โ-T โ-is-equiv
T-to-T' : T โ T'
T-to-T' = โ T'-โ-T โโปยน
T'-to-T-has-section : has-section T'-to-T
T'-to-T-has-section = equivs-have-sections T'-to-T T'-to-T-is-equiv
T'-to-T-is-section : is-section T'-to-T
T'-to-T-is-section = equivs-are-sections T'-to-T T'-to-T-is-equiv
section-T'-to-T : T'-to-T โ T-to-T' โผ id
section-T'-to-T = section-equation T'-to-T T'-to-T-has-section
retraction-T'-to-T : T-to-T' โ T'-to-T โผ id
retraction-T'-to-T = inverses-are-retractions' T'-โ-T
T'-inclusion : T' โ โจ L โฉ
T'-inclusion = m โ T'-to-T
s : โจ L โฉ
s = โโจ L โฉ (T' , T'-inclusion)
open Joins (order-of L)
sup-of-small-fam-is-lub : (s is-lub-of (T , m)) holds
sup-of-small-fam-is-lub = (I , III)
where
I : (s is-an-upper-bound-of (T , m)) holds
I t = II
where
II : (m t โคโจ L โฉ s) holds
II = transport (ฮป - โ (m - โคโจ L โฉ s) holds)
(section-T'-to-T t)
(join-is-upper-bound-of L (T' , T'-inclusion) (T-to-T' t))
III : ((u , _) : upper-bound (T , m)) โ (s โคโจ L โฉ u) holds
III (u , is-upbnd-T) = IV
where
IV : (s โคโจ L โฉ u) holds
IV = join-is-least-upper-bound-of
L (T' , T'-inclusion) (u , ฮป i โ is-upbnd-T (T'-to-T i))
\end{code}
We now show that reindexing families along a surjection preserves the supremum.
\begin{code}
module _
{๐ค ๐ฃ ๐ฅ ๐ฆ ๐ฆ' : Universe}
(L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
{T : ๐ฆ ฬ }
{T' : ๐ฆ' ฬ }
(e : T' โ T)
(m : T โ โจ L โฉ)
where
open Joins (order-of L)
reindexing-along-surj-๏ผ-sup : (s s' : โจ L โฉ)
โ (s is-lub-of (T , m)) holds
โ (s' is-lub-of (T' , m โ โ e โ)) holds
โ s ๏ผ s'
reindexing-along-surj-๏ผ-sup
s s' (is-upbnd , is-least-upbnd) (is-upbnd' , is-least-upbnd') =
antisymmetry-of L I IV
where
I : (s โคโจ L โฉ s') holds
I = is-least-upbnd (s' , ฮป t โ III t (โโ-is-surjection e t))
where
II : (t : T)
โ ฮฃ t' ๊ T' , โ e โ t' ๏ผ t
โ (m t โคโจ L โฉ s') holds
II t (t' , path) =
transport (ฮป z โ (m z โคโจ L โฉ s') holds) path (is-upbnd' t')
III : (t : T)
โ (ฦ t' ๊ T' , โ e โ t' ๏ผ t) holds
โ (m t โคโจ L โฉ s') holds
III t = โฅโฅ-rec (holds-is-prop (m t โคโจ L โฉ s')) (II t)
IV : (s' โคโจ L โฉ s) holds
IV = is-least-upbnd' (s , ฮป t' โ is-upbnd (โ e โ t'))
\end{code}
We can also show that reindexing along an equivalence preserves the supremum.
This follows from the previous result as any equivalence can be demoted to a
surjection.
\begin{code}
module _
{๐ค ๐ฃ ๐ฅ ๐ฆ ๐ฆ' : Universe}
(L : Sup-Lattice ๐ค ๐ฃ ๐ฅ)
{T : ๐ฆ ฬ }
{T' : ๐ฆ' ฬ }
(e : T' โ T)
(m : T โ โจ L โฉ)
where
open Joins (order-of L)
reindexing-along-equiv-๏ผ-sup : (s s' : โจ L โฉ)
โ (s is-lub-of (T , m)) holds
โ (s' is-lub-of (T' , m โ โ e โ )) holds
โ s ๏ผ s'
reindexing-along-equiv-๏ผ-sup =
reindexing-along-surj-๏ผ-sup
L (โ e โ , equivs-are-surjections โ e โ-is-equiv) m
\end{code}