module Cat.Instances.Discrete where
private variable
: Level
β β' : Type β
X : Precategory β β'
C
open Precategory
open Functor
open _=>_
Discrete categoriesπ
Given a groupoid we can build the category with space of objects and a single morphism whenever
: (A : Type β) β is-groupoid A β Precategory β β
Disc .Ob = A
Disc A A-grpd .Hom = _β‘_
Disc A A-grpd .Hom-set = A-grpd
Disc A A-grpd .id = refl
Disc A A-grpd ._β_ p q = q β p
Disc A A-grpd .idr _ = β-idl _
Disc A A-grpd .idl _ = β-idr _
Disc A A-grpd .assoc _ _ _ = sym (β-assoc _ _ _)
Disc A A-grpd
: Set β β Precategory β β
Disc' = Disc β£ A β£ h where abstract
Disc' A : is-groupoid β£ A β£
h = is-hlevel-suc 2 (A .is-tr) h
Clearly this is a univalent groupoid:
: β {A : Type β} {A-grpd} β is-category (Disc A A-grpd)
Disc-is-category .to-path is = is .to
Disc-is-category .to-path-over is = β
-pathp _ _ _ Ξ» i j β is .to (i β§ j)
Disc-is-category
: β {A : Type β} {A-grpd} β is-pregroupoid (Disc A A-grpd)
Disc-is-groupoid = make-invertible _ (sym p) (β-invl p) (β-invr p) Disc-is-groupoid p
We can lift any function between the underlying types to a functor between discrete categories. This is because every function automatically respects equality in a functorial way.
lift-disc: β {A : Set β} {B : Set β'}
β (β£ A β£ β β£ B β£)
β Functor (Disc' A) (Disc' B)
.Fβ = f
lift-disc f .Fβ = ap f
lift-disc f .F-id = refl
lift-disc f .F-β p q = ap-β f q p lift-disc f
: β {β'} β Type β β Precategory β β'
Codisc' .Ob = x
Codisc' x .Hom _ _ = Lift _ β€
Codisc' x .Hom-set _ _ = is-propβis-set (Ξ» _ _ i β lift tt)
Codisc' x .id = lift tt
Codisc' x ._β_ _ _ = lift tt
Codisc' x .idr _ = refl
Codisc' x .idl _ = refl
Codisc' x .assoc _ _ _ = refl Codisc' x
Diagrams in Disc(X)π
If
is a discrete type
, then it is in particular in
Set
, and we
can make diagrams of shape
in some category
using the decidable equality on
We note that the decidable equality is redundant information:
The construction Disc'
above
extends into a left
adjoint to the Ob
functor.
Disc-diagram: β {X : Set β} β¦ _ : Discrete β£ X β£ β¦
β (β£ X β£ β Ob C)
β Functor (Disc' X) C
{C = C} {X = X} β¦ d β¦ f = F where
Disc-diagram module C = Precategory C
: β£ X β£ β β£ X β£ β Type _
P = C.Hom (f x) (f y)
P x y
: β {x y : β£ X β£} β x β‘ y β Dec (x β‘α΅’ y) β P x y
go {x} {.x} p (yes reflα΅’) = C.id
go {x} {y} p (no Β¬p) = absurd (Β¬p (Idβpath.from p)) go
The object part of the functor is the provided and the decidable equality is used to prove that respects equality. This is why itβs redundant: automatically respects equality, because itβs a function! However, by using the decision procedure, we get better computational behaviour: Very often, will be and substitution along is easy to deal with.
: Functor _ _
F .Fβ = f
F .Fβ {x} {y} p = go p (x β‘α΅’? y) F
Proving that our our is functorial involves a bunch of tedious computations with equalities and a whole waterfall of absurd cases:
.F-id {x} = refl
F .F-β {x} {y} {z} f g =
F (Ξ» y g β β {z} (f : y β‘ z) β go (g β f) (x β‘α΅’? z) β‘ go f (y β‘α΅’? z) C.β go g (x β‘α΅’? y))
J (Ξ» f β J (Ξ» z f β go (refl β f) (x β‘α΅’? z) β‘ go f (x β‘α΅’? z) C.β C.id) (sym (C.idr _)) f)
g f
Disc-adjunct: β {iss : is-groupoid X}
β (X β Ob C)
β Functor (Disc X iss) C
{C = C} F .Fβ = F
Disc-adjunct {C = C} F .Fβ p = subst (C .Hom (F _) β F) p (C .id)
Disc-adjunct {C = C} F .F-id = transport-refl _
Disc-adjunct {C = C} {iss = iss} F .F-β {x} {y} {z} f g = path where
Disc-adjunct import Cat.Reasoning C as C
= Disc-adjunct {C = C} {iss} F .Fβ
go abstract
: go (g β f) β‘ C ._β_ (go f) (go g)
path =
path (Ξ» y z f β β {x} (g : x β‘ y) β go (g β f) β‘ go f C.β go g)
J' (Ξ» x g β subst-β (C .Hom (F _) β F) _ _ _
_
Β·Β· transport-refl .introl (transport-refl _))
Β·Β· C{x} g
f
Disc-into: β {β} (X : Set β)
β (F : C .Ob β β£ X β£)
β (Fβ : β {x y} β C .Hom x y β F x β‘ F y)
β Functor C (Disc' X)
.Fβ = F
Disc-into X F Fβ .Fβ = Fβ
Disc-into X F Fβ .F-id = X .is-tr _ _ _ _
Disc-into X F Fβ .F-β _ _ = X .is-tr _ _ _ _ Disc-into X F Fβ
Disc-natural: β {X : Set β}
β {F G : Functor (Disc' X) C}
β (β x β C .Hom (F .Fβ x) (G .Fβ x))
β F => G
.Ξ· = fam
Disc-natural fam {C = C} {F = F} {G = G} fam .is-natural x y f =
Disc-natural (Ξ» y p β fam y C.β F .Fβ p β‘ G .Fβ p C.β fam x)
J (C.elimr (F .F-id) β C.introl (G .F-id))
fwhere module C = Cat.Reasoning C
Disc-naturalβ: β {X : Type β} {Y : Type β'}
β {issx : is-groupoid X} {issy : is-groupoid Y}
β {F G : Functor (Disc X issx ΓαΆ Disc Y issy) C}
β ((x : X Γ Y) β C .Hom (F .Fβ x) (G .Fβ x))
β F => G
.Ξ· = fam
Disc-naturalβ fam {C = C} {F = F} {G = G} fam .is-natural x y (p , q) =
Disc-naturalβ (Ξ» y' p' β fam y' C.β F .Fβ (ap fst p' , ap snd p')
J .Fβ (ap fst p' , ap snd p') C.β fam x)
β‘ G (C.elimr (F .F-id) β C.introl (G .F-id))
(Ξ£-pathp p q)
where module C = Cat.Reasoning C