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)

Disc-is-univalent-groupoid : ∀ {A : Type ℓ} {A-grpd} → is-univalent-groupoid (Disc A A-grpd)
Disc-is-univalent-groupoid = Id-identity-system

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