module Cat.Instances.Discrete where

Discrete categories🔗

Given a groupoid we can see as a category with space of objects and path types as When is a set, we call this the discrete category on For technical reasons, we prefer to define this category using the inductive identity type instead of the path type.

Disc : (A : Type )  is-groupoid A  Precategory  
Disc A A-grpd = record where
  Ob          = A
  Hom         = _≡ᵢ_
  Hom-set     = ≡ᵢ-is-hlevel' {n = 2} A-grpd
  id          = reflᵢ
  _∘_ p q     = q ∙ᵢ p
  idr _       = refl
  idl _       = ∙ᵢ-idr _
  assoc p q r = sym (∙ᵢ-assoc r q p)

By construction, this is a univalent groupoid:

Disc-is-category :  {A : Type } {A-grpd}  is-category (Disc A A-grpd)
Disc-is-category .to-path is = Id≃path.to (is .to)
Disc-is-category .to-path-over {a = a} is with is .to in w
... | reflᵢ = ≅-pathp _ _ _ (Id≃path.to (symᵢ w))

Disc-is-groupoid :  {A : Type } {A-grpd}  is-pregroupoid (Disc A A-grpd)
Disc-is-groupoid p = make-invertible _ (symᵢ p) (∙ᵢ-invl p) (∙ᵢ-invr p)

Diagrams in Disc(X)🔗

Because the morphisms in a discrete category are identifications, and functions respect equality, any function on objects out of a discrete category induces a functor.

Disc-diagram
  :  {X : Type } {xh}
   (X  Ob C)
   Functor (Disc X xh) C
Disc-diagram {C = C} f .F₀       = f
Disc-diagram {C = C} f .F₁ reflᵢ = C .id
Disc-diagram {C = C} f .F-id = refl
Disc-diagram {C = C} f .F-∘ reflᵢ reflᵢ = sym (C .idl _)

As a corollary, we can lift any function between underlying types to a functor between discrete categories.

lift-disc
  :  {A : Type } {B : Type ℓ'} {ah bh} (f : A  B)
   Functor (Disc A ah) (Disc B bh)
lift-disc {A = A} f = Disc-diagram f