---
layout: default
title : "Setoid.Homomorphisms.Kernels module (Agda Universal Algebra Library)"
date : "2021-09-13"
author: "agda-algebras development team"
---
#### Kernels of Homomorphisms
This is the [Setoid.Homomorphisms.Kernels][] module of the [Agda Universal Algebra Library][].
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
module Setoid.Homomorphisms.Kernels where
open import Data.Product using ( _,_ ; projβ ; projβ )
open import Function renaming ( Func to _βΆ_ ) using ( _β_ ; id )
open import Level using ( Level )
open import Relation.Binary using ( Setoid )
open import Relation.Binary.PropositionalEquality using (refl)
open import Overture using ( kerRel ; kerRelOfEquiv ; π ; π₯ ; Signature)
open import Setoid.Functions using ( Image_β_ )
open import Setoid.Algebras using ( Algebra ; _^_ ; π»[_] )
open import Setoid.Congruences using ( _β£β_ ; Con ; mkcon ; _β±_ ; IsCongruence )
open import Setoid.Homomorphisms.Basic using ( hom ; IsHom ; epi ; IsEpi ; epiβhom ; πΎπΉ )
private variable Ξ± Ξ² Οα΅ Οα΅ β : Level
open _βΆ_ using ( cong ) renaming ( to to _β¨$β©_ )
```
-->
```agda
module _ {π : Signature π π₯} {π¨ : Algebra {π = π} Ξ± Οα΅}{π© : Algebra Ξ² Οα΅} ((hmap , hhom) : hom π¨ π©) where
open Algebra π© using ( Interp ) renaming ( Domain to B )
open Setoid B using ( _β_ ; sym ; trans ; isEquivalence )
private h = _β¨$β©_ hmap
```
`HomKerComp` asserts that the kernel of a homomorphism is compatible with the basic operations.
That is, if each `(u i, v i)` belongs to the kernel, then so does the pair `((f ^ π¨) u , (f ^ π¨) v)`.
```agda
HomKerComp : π¨ β£β kerRel _β_ h
HomKerComp f {u}{v} kuv = Goal
where
fhuv : (f ^ π©)(h β u) β (f ^ π©)(h β v)
fhuv = cong Interp (refl , kuv)
lem1 : h ((f ^ π¨) u) β (f ^ π©)(h β u)
lem1 = IsHom.compatible hhom
lem2 : (f ^ π©) (h β v) β h ((f ^ π¨) v)
lem2 = sym (IsHom.compatible hhom)
Goal : h ((f ^ π¨) u) β h ((f ^ π¨) v)
Goal = trans lem1 (trans fhuv lem2)
```
The kernel of a homomorphism is a congruence of the domain, which we construct as follows.
```agda
kercon : Con π¨ Οα΅
kercon = kerRel _β_ h ,
mkcon (Ξ» x β cong hmap x)(kerRelOfEquiv isEquivalence h)(HomKerComp)
```
Now that we have a congruence, we can construct the quotient relative to the kernel.
```agda
kerquo : Algebra Ξ± Οα΅
kerquo = π¨ β± kercon
ker[_β_]_ : {π : Signature π π₯} (π¨ : Algebra {π = π} Ξ± Οα΅) (π© : Algebra Ξ² Οα΅) β hom π¨ π© β Algebra _ _
ker[ π¨ β π© ] h = kerquo h
```
#### The canonical projection
Given an algebra `π¨` and a congruence `ΞΈ`, the *canonical projection* is a map from `π¨` onto `π¨ β± ΞΈ` that is constructed, and proved epimorphic, as follows.
```agda
module _ {π : Signature π π₯} {π¨ : Algebra {π = π} Ξ± Οα΅}{π© : Algebra Ξ² Οα΅} (h : hom π¨ π©) where
open IsCongruence
Οepi : (ΞΈ : Con π¨ β) β epi π¨ (π¨ β± ΞΈ)
Οepi ΞΈ = p , pepi
where
open Setoid π»[ π¨ β± ΞΈ ] using () renaming ( sym to βsym ; refl to βrefl )
open IsHom {π¨ = (π¨ β± ΞΈ)} using ( compatible )
open IsEpi
p : π»[ π¨ ] βΆ π»[ π¨ β± ΞΈ ]
p β¨$β© x = x
p .cong = reflexive (ΞΈ .projβ)
pepi : IsEpi π¨ (π¨ β± ΞΈ) p
pepi .isHom .compatible = βsym (πΎπΉ .projβ .compatible)
pepi .isSurjective {y} = Image_β_.eq y βrefl
```
In may happen that we don't care about the surjectivity of `Οepi`, in which
case would might prefer to work with the *homomorphic reduct* of `Οepi`.
This is obtained by applying `epi-to-hom`, like so.
```agda
Οhom : (ΞΈ : Con π¨ β) β hom π¨ (π¨ β± ΞΈ)
Οhom ΞΈ = epiβhom π¨ (π¨ β± ΞΈ) (Οepi ΞΈ)
```
We combine the foregoing to define a function that takes π-algebras `π¨` and `π©`,
and a homomorphism `h : hom π¨ π©` and returns the canonical epimorphism from `π¨`
onto `π¨ [ π© ]/ker h`. (Recall, the latter is the special notation we defined
above for the quotient of `π¨` modulo the kernel of `h`.)
```agda
Οker : epi π¨ (ker[ π¨ β π© ] h)
Οker = Οepi (kercon h)
```
The kernel of the canonical projection of `π¨` onto `π¨ / ΞΈ` is equal to `ΞΈ`,
but since equality of inhabitants of certain types (like `Congruence` or `Rel`)
can be a tricky business, we settle for proving the containment `π¨ / ΞΈ β ΞΈ`.
Of the two containments, this is the easier one to prove; luckily it is also
the one we need later.
```agda
ker-in-con : {ΞΈ : Con π¨ β} β β {x}{y} β kercon (Οhom ΞΈ) .projβ x y β ΞΈ .projβ x y
ker-in-con = id
```