-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Knaster-Tarski for categories (#436)
# Description This PR proves a Knaster-Tarski theorem for categories, and uses it to prove the usual Knaster-Tarski theorem for suplattices. ## Checklist Before submitting a merge request, please check the items below: - [x] I've read [the contributing guidelines](https://github.com/plt-amy/1lab/blob/main/CONTRIBUTING.md). - [x] The imports of new modules have been sorted with `support/sort-imports.hs` (or `nix run --experimental-features nix-command -f . sort-imports`). - [x] All new code blocks have "agda" as their language. If your change affects many files without adding substantial content, and you don't want your name to appear on those pages (for example, treewide refactorings or reformattings), start the commit message and PR title with `chore:`.
- Loading branch information
Showing
9 changed files
with
362 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
--- | ||
description: | | ||
The Knaster-Tarski theorem for categories. | ||
--- | ||
<!-- | ||
```agda | ||
open import Cat.Functor.Algebra.Limits | ||
open import Cat.Diagram.Initial.Weak | ||
open import Cat.Diagram.Limit.Base | ||
open import Cat.Diagram.Initial | ||
open import Cat.Displayed.Total | ||
open import Cat.Functor.Algebra | ||
open import Cat.Prelude | ||
|
||
open import Order.Diagram.Fixpoint | ||
open import Order.Diagram.Glb | ||
open import Order.Base | ||
open import Order.Cat | ||
|
||
import Cat.Reasoning | ||
``` | ||
--> | ||
```agda | ||
module Cat.Functor.Algebra.KnasterTarski where | ||
``` | ||
|
||
# The Knaster-Tarski fixpoint theorem {defines="knaster-tarski"} | ||
|
||
The **Knaster-Tarski theorem** gives a recipe for constructing [[initial]] | ||
[[F-algebras]] in [[complete categories]]. | ||
|
||
The big idea is that if a category $\cC$ is complete, then we can construct | ||
an initial algebra of a functor $F$ by taking a limit $\rm{Fix}$ over the forgetful | ||
functor $\pi : \FAlg{F} \to \cC$ from the category of $F$-algebras: | ||
the universal property of such a limit let us construct an algebra | ||
$F(\rm{Fix}) \to \rm{Fix}$, and the projections out of $\rm{Fix}$ let | ||
us establish that $\rm{Fix}$ is the initial algebra. | ||
|
||
Unfortunately, this limit is a bit too ambitious. If we examine the universe | ||
levels involved, we will quickly notice that this argument requires $\cC$ | ||
to admit limits indexed by the \emph{objects} of $\cC$, which in the presence | ||
of excluded middle means that $\cC$ must be a preorder. | ||
|
||
This problem of overly ambitious limits is similar to the one encountered | ||
in the naïve [[adjoint functor theorem]], so we can use a similar technique | ||
to repair our proof. In particular, we will impose a variant of the | ||
**solution set condition** on the category of $F$-algebras that ensures | ||
that the limit we end up computing is determined by a small amount of data, | ||
which lets us relax our large-completeness requirement. | ||
|
||
More precisely, we will require that the category of $F$-algebras has a | ||
small [[weakly initial family]] of algebras. This means that we need: | ||
|
||
- A family $\alpha_i : F(A_i) \to A_i$ of $F$ algebras indexed by a | ||
small set $I$, such that; | ||
- For every $F$-algebra $\beta : F(B) \to B$, there (merely) exists an $i : I$ | ||
along with a $F$-algebra morphism $A_i \to B$. | ||
|
||
<!-- | ||
```agda | ||
module _ | ||
{o ℓ} {C : Precategory o ℓ} | ||
(F : Functor C C) | ||
where | ||
open Cat.Reasoning C | ||
open Functor F | ||
open Total-hom | ||
``` | ||
--> | ||
|
||
Once we have a solution set, the theorem pops open like a walnut submerged | ||
in water: | ||
|
||
* First, $\cC$ is small-complete, so the category of $F$-algebras must also | ||
be small-complete, as [[limits of algebras]] are computed by limits | ||
in $\cC$. | ||
* In particular, the category of $F$-algebras has all small [[equalisers]], | ||
so we can upgrade our weakly initial family to an [[initial object]]. | ||
|
||
```agda | ||
solution-set→initial-algebra | ||
: ∀ {κ} {Idx : Type κ} ⦃ _ : ∀ {n} → H-Level Idx (2 + n) ⦄ | ||
→ (Aᵢ : Idx → FAlg.Ob F) | ||
→ is-complete κ (ℓ ⊔ κ) C | ||
→ is-weak-initial-fam (FAlg F) Aᵢ | ||
→ Initial (FAlg F) | ||
solution-set→initial-algebra Aᵢ complete soln-set = | ||
is-complete-weak-initial→initial (FAlg F) | ||
Aᵢ | ||
(FAlg-is-complete complete F) | ||
soln-set | ||
``` | ||
|
||
We can obtain the more familiar form of the Knaster-Tarski theorem by | ||
applying [[Lambek's lemma]] to the resulting initial algebra. | ||
|
||
```agda | ||
solution-set→fixpoint | ||
: ∀ {κ} {Idx : Type κ} ⦃ _ : ∀ {n} → H-Level Idx (2 + n) ⦄ | ||
→ (Aᵢ : Idx → FAlg.Ob F) | ||
→ is-complete κ (ℓ ⊔ κ) C | ||
→ is-weak-initial-fam (FAlg F) Aᵢ | ||
→ Σ[ Fix ∈ Ob ] (F₀ Fix ≅ Fix) | ||
solution-set→fixpoint Aᵢ complete soln-set = | ||
bot .fst , invertible→iso (bot .snd) (lambek F (bot .snd) has⊥) | ||
where open Initial (solution-set→initial-algebra Aᵢ complete soln-set) | ||
``` | ||
|
||
## Knaster-Tarski for sup-lattices | ||
|
||
<!-- | ||
```agda | ||
module _ | ||
{o ℓ} (P : Poset o ℓ) | ||
(f : Monotone P P) | ||
where | ||
open Poset P | ||
open Total-hom | ||
``` | ||
--> | ||
|
||
The "traditional" Knaster-Tarski theorem states that every [[monotone endomap|monotone-map]] | ||
on a [[poset]] $P$ with all [[greatest lower bounds]] has a [[least fixpoint]]. | ||
In the presence of [[propositional resizing]], this theorem follows as a corollary of | ||
our previous theorem. | ||
|
||
```agda | ||
complete→least-fixpoint | ||
: (∀ {I : Type o} → (k : I → Ob) → Glb P k) | ||
→ Least-fixpoint P f | ||
complete→least-fixpoint glbs = least-fixpoint where | ||
``` | ||
|
||
<!-- | ||
```agda | ||
open Cat.Reasoning (poset→category P) using (_≅_; to; from) | ||
open is-least-fixpoint | ||
open Least-fixpoint | ||
``` | ||
--> | ||
|
||
The key is that resizing lets us prove the solution set condition with | ||
respect to the size of the underlying set of $P$, as we can resize away | ||
the proofs that $f x \leq x$. | ||
|
||
```agda | ||
Idx : Type o | ||
Idx = Σ[ x ∈ Ob ] (□ (f # x ≤ x)) | ||
|
||
soln : Idx → Σ[ x ∈ Ob ] (f # x ≤ x) | ||
soln (x , lt) = x , (□-out! lt) | ||
|
||
is-soln-set : is-weak-initial-fam (FAlg (monotone→functor f)) soln | ||
is-soln-set (x , lt) = inc ((x , inc lt) , total-hom ≤-refl prop!) | ||
``` | ||
|
||
Moreover, $P$ has all [[greatest lower bounds]], so it is `complete as a | ||
category`{.Agda ident=glbs→complete}. This lets us invoke the general | ||
Knaster-Tarski theorem to get an initial $f$-algebra. | ||
|
||
```agda | ||
initial : Initial (FAlg (monotone→functor f)) | ||
initial = | ||
solution-set→initial-algebra (monotone→functor f) | ||
soln | ||
(glbs→complete glbs) | ||
is-soln-set | ||
``` | ||
|
||
Finally, we can inline the proof of [[Lambek's lemma]] to show that this | ||
initial algebra gives the least fixpoint of $f$! | ||
|
||
```agda | ||
open Initial initial | ||
|
||
least-fixpoint : Least-fixpoint P f | ||
least-fixpoint .fixpoint = | ||
bot .fst | ||
least-fixpoint .has-least-fixpoint .fixed = | ||
≤-antisym | ||
(bot .snd) | ||
(¡ {x = f .hom (bot .fst) , f .pres-≤ (bot .snd)} .hom) | ||
least-fixpoint .has-least-fixpoint .least x fx=x = | ||
¡ {x = x , ≤-refl' fx=x} .hom | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
description: | | ||
Limits in categories of F-algebras. | ||
--- | ||
<!-- | ||
```agda | ||
open import Cat.Diagram.Limit.Base | ||
open import Cat.Displayed.Total | ||
open import Cat.Functor.Algebra | ||
open import Cat.Prelude | ||
|
||
import Cat.Functor.Reasoning | ||
import Cat.Reasoning | ||
``` | ||
--> | ||
```agda | ||
module Cat.Functor.Algebra.Limits where | ||
``` | ||
|
||
# Limits in categories of algebras {defines="limits-of-algebras"} | ||
|
||
This short note details the construction of [[limits]] in categories of | ||
[[F-algebras]] from limits in the underlying category. | ||
|
||
<!-- [TODO: Reed M, 17/10/2024] | ||
This should really be about creation of limits/display, but I don't want to deal | ||
with that at the moment! | ||
--> | ||
|
||
<!-- | ||
```agda | ||
module _ | ||
{o ℓ oj ℓj} {C : Precategory o ℓ} | ||
(F : Functor C C) | ||
{J : Precategory oj ℓj} (K : Functor J (FAlg F)) | ||
where | ||
open Cat.Reasoning C | ||
private | ||
module J = Cat.Reasoning J | ||
module F = Cat.Functor.Reasoning F | ||
module K = Cat.Functor.Reasoning K | ||
open Total-hom | ||
``` | ||
--> | ||
|
||
Let $F : \cC \to \cC$ be an endofunctor, and $K : \cJ \to \FAlg{F}$ be a | ||
diagram of $F$-algebras. If $\cC$ has a limit $L$ of $\pi \circ K$, then | ||
$F(L)$ is the limit of $K$ in $\FAlg{F}$. | ||
|
||
|
||
```agda | ||
Forget-algebra-lift-limit : Limit (πᶠ (F-Algebras F) F∘ K) → Limit K | ||
Forget-algebra-lift-limit L = to-limit (to-is-limit L') where | ||
module L = Limit L | ||
open make-is-limit | ||
``` | ||
|
||
As noted earlier, the underlying object of the limit is $F(L)$. The algebra | ||
$F(L) \to L$ is constructed via the universal property of $L$: to | ||
give a map $F(L) \to L$, it suffices to give maps $F(L) \to K(j)$ for | ||
every $j : \cJ$, which we can construct by composing the projection | ||
$F(\psi_{j}) : F(L) \to F(K(j))$ with the algebra $F(K(j)) \to K(j)$. | ||
|
||
```agda | ||
apex : FAlg.Ob F | ||
apex .fst = L.apex | ||
apex .snd = L.universal (λ j → K.₀ j .snd ∘ F.₁ (L.ψ j)) comm where abstract | ||
comm | ||
: ∀ {i j : J.Ob} (f : J.Hom i j) | ||
→ K.₁ f .hom ∘ K.₀ i .snd ∘ F.₁ (L.ψ i) ≡ K.₀ j .snd ∘ F.₁ (L.ψ j) | ||
comm {i} {j} f = | ||
K.₁ f .hom ∘ K.₀ i .snd ∘ F.₁ (L.ψ i) ≡⟨ pulll (K.₁ f .preserves) ⟩ | ||
(K.₀ j .snd ∘ F.₁ (K.₁ f .hom)) ∘ F.₁ (L.ψ i) ≡⟨ F.pullr (L.commutes f) ⟩ | ||
K.₀ j .snd ∘ F.₁ (L.ψ j) ∎ | ||
``` | ||
|
||
A short series of calculations shows that the projections and universal map | ||
associated to $L$ are $F$-algebra homomorphisms. | ||
|
||
```agda | ||
L' : make-is-limit K apex | ||
L' .ψ j .hom = L.ψ j | ||
L' .ψ j .preserves = L.factors _ _ | ||
L' .universal eps p .hom = | ||
L.universal (λ j → eps j .hom) (λ f → ap hom (p f)) | ||
L' .universal eps p .preserves = | ||
L.unique₂ (λ j → K.F₀ j .snd ∘ F.₁ (eps j .hom)) | ||
(λ f → pulll (K.₁ f .preserves) ∙ F.pullr (ap hom (p f))) | ||
(λ j → pulll (L.factors _ _) ∙ eps j .preserves) | ||
(λ j → pulll (L.factors _ _) ∙ F.pullr (L.factors _ _)) | ||
``` | ||
|
||
Finally, equality of morphisms of $F$-algebras is given by equality on | ||
the underlying morphisms, so all of the relevant diagrams in $\FAlg{F}$ | ||
commute. | ||
|
||
```agda | ||
L' .commutes f = | ||
total-hom-path (F-Algebras F) (L.commutes f) prop! | ||
L' .factors eps p = | ||
total-hom-path (F-Algebras F) (L.factors _ _) prop! | ||
L' .unique eps p other q = | ||
total-hom-path (F-Algebras F) (L.unique _ _ _ λ j → ap hom (q j)) prop! | ||
``` | ||
|
||
<!-- | ||
```agda | ||
module _ | ||
{o ℓ oκ ℓκ} {C : Precategory o ℓ} | ||
(complete : is-complete oκ ℓκ C) | ||
where | ||
``` | ||
--> | ||
|
||
This gives us the following useful corollary: if $\cC$ is $\kappa$-complete, | ||
then $\FAlg{F}$ is also $\kappa$ complete. | ||
|
||
```agda | ||
FAlg-is-complete : (F : Functor C C) → is-complete oκ ℓκ (FAlg F) | ||
FAlg-is-complete F K = Forget-algebra-lift-limit F K (complete (πᶠ (F-Algebras F) F∘ K)) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.