module Cat.Diagram.Equaliser.Kernel {o β„“} (C : Precategory o β„“) where

KernelsπŸ”—

In a category with equalisers and a zero object 00, a kernel of a morphism f:aβ†’bf : a \to b is an equaliser of ff and the zero morphism 0:aβ†’b0 : a \to b, hence a subobject ker(f)β†ͺa\mathrm{ker}(f) \hookrightarrow a of the domain of ff.

module _ (βˆ… : Zero) where
  open Zero βˆ…

  is-kernel : βˆ€ {a b ker} (f : Hom a b) (k : Hom ker a) β†’ Type _
  is-kernel f = is-equaliser f zero→

  kernels-are-subobjects
    : βˆ€ {a b ker} {f : Hom a b} (k : Hom ker a)
    β†’ is-kernel f k β†’ is-monic k
  kernels-are-subobjects = is-equaliser→is-monic

  record Kernel {a b} (f : Hom a b) : Type (o βŠ” β„“) where
    field
      {ker} : Ob
      kernel : Hom ker a
      has-is-kernel : is-kernel f kernel
    open is-equaliser has-is-kernel public

Lemma: Let C\mathcal{C} be a category with equalisers and a zero object. In C\mathcal{C}, the kernel of a kernel is zero. First, note that if a category has a choice of zero object and a choice of equaliser for any pair of morphisms, then it has canonically-defined choices of kernels:

module Canonical-kernels
  (zero : Zero) (eqs : βˆ€ {a b} (f g : Hom a b) β†’ Equaliser f g) where
  open Zero zero
  open Kernel

  Ker : βˆ€ {a b} (f : Hom a b) β†’ Kernel zero f
  Ker f .ker           = _
  Ker f .kernel        = eqs f zero→ .Equaliser.equ
  Ker f .has-is-kernel = eqs _ _ .Equaliser.has-is-eq

We now show that the maps !:ker⁑ker⁑fβ†’βˆ…! : \ker\ker f \to \emptyset and Β‘:βˆ…β†’ker⁑ker⁑fΒ‘ : \emptyset \to \ker\ker f are inverses. In one direction the composite is in βˆ…β†’βˆ…\emptyset \to \emptyset, so it is trivially unique. In the other direction, we have maps ker⁑ker⁑fβ†’ker⁑ker⁑f\ker\ker f \to \ker\ker f, which, since ker⁑\ker is a limit, are uniquely determined if they are cone homomorphisms.

  Ker-of-kerβ‰ƒβˆ… : βˆ€ {a b} (f : Hom a b) β†’ Ker (Ker f .kernel) .ker β‰… βˆ…
  Ker-of-kerβ‰ƒβˆ… f = make-iso ! Β‘ (!-uniqueβ‚‚ _ _) p where
    module Kf = Kernel (Ker f)
    module KKf = Kernel (Ker (Ker f .kernel))

The calculation is straightforward enough: The hardest part is showing that ker⁑f∘ker⁑ker⁑f=0\ker f \circ \ker \ker f = 0 (here we are talking about the inclusion maps, not the objects) β€” but recall that ker⁑ker⁑f\ker \ker f equalises ker⁑f\ker f and 00, so we have

ker⁑f∘ker⁑ker⁑f=0∘ker⁑ker⁑f=0 \ker f \circ \ker \ker f = 0 \circ \ker \ker f = 0

    p : Β‘ ∘ ! ≑ id
    p = KKf.uniqueβ‚‚ (zero-comm _ _) (zero-∘l _)
          (Kf.uniqueβ‚‚ (extendl (zero-comm _ _))
                      (pulll KKf.equal βˆ™ idr _)
                      (zero-comm _ _))