cwfs/src/Fams.lagda.md

63 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

2022-10-06 00:05:15 +02:00
```
open import Cat.Prelude
2022-10-06 19:43:55 +02:00
module Fams where
2022-10-06 00:05:15 +02:00
```
2022-10-06 20:39:10 +02:00
# The category of families of sets
This file defines the category $\mathcal Fam$ of families of sets.
2022-10-06 00:05:15 +02:00
Given a universe level there is a category $\mathcal Fam$ of the families of sets of that level.
```
module _ where
open Precategory
Fams : (o : _) → Precategory (lsuc o) o
```
2022-10-06 19:43:55 +02:00
2022-10-06 00:05:15 +02:00
Objects in $\mathcal Fam$ are pairs $B = (B^0,B^1)$ where $B^0$ is a set and $B^1$ is a family of sets indexed over $B^0$.
```
Fams o .Ob = Σ[ B ∈ Set o ] ( B → Set o)
```
2022-10-06 19:43:55 +02:00
A morphism between objects $B$ and $C$ in $\mathcal Fam$ is a pair of functions $(f^0,f^1)$ where $f^0$ is a function $f^0 : B^0 \to C^0$ and $f^1$ is a family of functions $b : B^0 \mapsto f^1 : B^1(b) \to C^1(f^0(b))$.
2022-10-06 19:43:55 +02:00
```
Fams o .Hom B C =
Σ[ f ∈ ( B .fst C .fst ) ]
((b : B .fst ) → B .snd b C .snd (f b) )
```
The identity is given by a pair of identity functions.
2022-10-06 00:05:15 +02:00
```
2022-10-06 19:43:55 +02:00
Fams o .id .fst x = x
Fams o .id .snd b x = x
```
Composition follows from regular function composition for $(f \circ g)^0$, and function composition with a translation of $b : B^0$ for $(f \circ g)^1$
2022-10-06 00:05:15 +02:00
```
2022-10-06 19:43:55 +02:00
(Fams o ∘ (f⁰ , f¹)) (g⁰ , g¹) .fst x = f⁰ (g⁰ x)
(Fams o ∘ (f⁰ , f¹)) (g⁰ , g¹) .snd b x = f¹ (g⁰ b) (g¹ b x)
2022-10-06 00:05:15 +02:00
```
2022-10-06 19:43:55 +02:00
2022-10-06 20:39:10 +02:00
Since composition is defined using regular function composition it computes nicely.
2022-10-06 19:43:55 +02:00
```
Fams o .idr f = refl
Fams o .idl f = refl
Fams o .assoc f g h = refl
```
Since homs are functions between families of sets, they form a set.
```
Fams o .Hom-set B C = Σ-is-hlevel 2 p⁰ p¹
where
p⁰ : is-set ( B .fst C .fst )
p⁰ f g p q i j x = C .fst .is-tr (f x) (g x) (happly p x)
(happly q x) i j
p¹ : (f⁰ : B .fst C .fst )
→ is-set ((b : B .fst ) → B .snd b C .snd (f⁰ b) )
p¹ h f g p q i j b x = C .snd (h b) .is-tr (f b x)
(g b x)
(λ k → p k b x)
(λ k → q k b x) i j
```