open import Cat.Prelude

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

EqualisersπŸ”—

The equaliser of two maps f,g:A→Bf, g : A \to B, when it exists, represents the largest subobject of AA where ff and gg agree. In this sense, the equaliser is the categorical generalisation of a solution set: The solution set of an equation in one variable is largest subset of the domain (i.e. what the variable ranges over) where the left- and right-hand-sides agree.

record is-equaliser {E} (f g : Hom A B) (equ : Hom E A) : Type (β„“ βŠ” β„“β€²) where
  field
    equal     : f ∘ equ ≑ g ∘ equ
    limiting  : βˆ€ {F} {eβ€² : Hom F A} (p : f ∘ eβ€² ≑ g ∘ eβ€²) β†’ Hom F E
    universal : βˆ€ {F} {eβ€² : Hom F A} {p : f ∘ eβ€² ≑ g ∘ eβ€²} β†’ equ ∘ limiting p ≑ eβ€²
    unique
      : βˆ€ {F} {eβ€² : Hom F A} {p : f ∘ eβ€² ≑ g ∘ eβ€²} {lim' : Hom F E}
      β†’ eβ€² ≑ equ ∘ lim'
      β†’ lim' ≑ limiting p

  equal-∘ : f ∘ equ ∘ h ≑ g ∘ equ ∘ h
  equal-∘ {h = h} =
    f ∘ equ ∘ h β‰‘βŸ¨ extendl equal βŸ©β‰‘
    g ∘ equ ∘ h ∎

  uniqueβ‚‚
    : βˆ€ {F} {eβ€² : Hom F A} {p : f ∘ eβ€² ≑ g ∘ eβ€²} {lim' lim'' : Hom F E}
    β†’ eβ€² ≑ equ ∘ lim'
    β†’ eβ€² ≑ equ ∘ lim''
    β†’ lim' ≑ lim''
  uniqueβ‚‚ {p = p} q r = unique {p = p} q βˆ™ sym (unique r)

We can visualise the situation using the commutative diagram below:

There is also a convenient bundling of an equalising arrow together with its domain:

record Equaliser (f g : Hom A B) : Type (β„“ βŠ” β„“β€²) where
  field
    {apex}  : Ob
    equ     : Hom apex A
    has-is-eq : is-equaliser f g equ

  open is-equaliser has-is-eq public

Equalisers are monicπŸ”—

As a small initial application, we prove that equaliser arrows are always monic:

is-equaliser→is-monic
  : βˆ€ {E} (equ : Hom E A)
  β†’ is-equaliser f g equ
  β†’ is-monic equ
is-equaliser→is-monic equ equalises g h p =
  g                β‰‘βŸ¨ unique (sym p) βŸ©β‰‘
  limiting equal-∘ β‰‘Λ˜βŸ¨ unique refl βŸ©β‰‘Λ˜
  h ∎
  where open is-equaliser equalises