This section describes the Homomorphisms.Basic module of the Agda Universal Algebra Library.
{-# OPTIONS --without-K --exact-split --safe #-} open import Algebras.Signatures using (Signature; π; π₯) module Homomorphisms.Basic {π : Signature π π₯} where open import Algebras.Congruences{π = π} public open import MGS-MLTT using (_β‘β¨_β©_; _β; id) public
If π¨
and π©
are π
-algebras, then a homomorphism from π¨
to π©
is a function β : β£ π¨ β£ β β£ π© β£
from the domain of π¨
to the domain of π©
that is compatible (or commutes) with all of the basic operations of the signature; that is, for all operation symbols π : β£ π β£
and tuples π : β₯ π β₯ π β β£ π¨ β£
of π¨
, the following holds:1
h ((π Μ π¨) π) β‘ (π Μ π©) (h β π)
.
To formalize this concept, we first define a type representing the assertion that a function h : β£ π¨ β£ β β£ π© β£
commutes with a single basic operation π
. With Agdaβs extremely flexible syntax the defining equation above can be expressed unadulterated.
module _ {π€ π¦ : Universe}(π¨ : Algebra π€ π)(π© : Algebra π¦ π) where compatible-op-map : β£ π β£ β (β£ π¨ β£ β β£ π© β£) β π€ β π₯ β π¦ Μ compatible-op-map π h = β π β h ((π Μ π¨) π) β‘ (π Μ π©) (h β π)
Agda infers from the shorthand β π
that π
has type β₯ π β₯ π β β£ π¨ β£
since it must be a tuple on β£ π¨ β£
of βlengthβ β₯ π β₯ π
(the arity of π
).
We now define the type hom π¨ π©
of homomorphisms from π¨
to π©
by first defining the type is-homomorphism
which represents the property of being a homomorphism.
is-homomorphism : (β£ π¨ β£ β β£ π© β£) β π β π₯ β π€ β π¦ Μ is-homomorphism g = β π β compatible-op-map π g hom : π β π₯ β π€ β π¦ Μ hom = Ξ£ g κ (β£ π¨ β£ β β£ π© β£ ) , is-homomorphism g
Letβs look at a few examples of homomorphisms. These examples are actually quite special in that the function in question commutes with the basic operations of all algebras and so, no matter the algebras involved, is always a homomorphism (trivially). We begin with the identity map, which is proved to be (the underlying map of) a homomorphism as follows.
module _ {π€ : Universe} where πΎπΉ : (A : Algebra π€ π) β hom A A πΎπΉ _ = id , Ξ» π π β refl
Next, lift
and lower
, defined in the Overture.Lifts module, are (the maps of) homomorphisms. Again, the proofs are trivial.
open Lift ππΎπ»π : {π¦ : Universe}{π¨ : Algebra π€ π} β hom π¨ (Lift-alg π¨ π¦) ππΎπ»π = lift , Ξ» π π β refl πβ΄πβ―π : {π¦ : Universe}{π¨ : Algebra π€ π} β hom (Lift-alg π¨ π¦) π¨ πβ΄πβ―π = lower , Ξ» π π β refl
A monomorphism is an injective homomorphism and an epimorphism is a surjective homomorphism. These are represented in the UALib by the following types.
module _ {π€ π¦ : Universe} where is-monomorphism : (π¨ : Algebra π€ π)(π© : Algebra π¦ π) β (β£ π¨ β£ β β£ π© β£) β π β π₯ β π€ β π¦ Μ is-monomorphism π¨ π© g = is-homomorphism π¨ π© g Γ Monic g mon : Algebra π€ π β Algebra π¦ π β π β π₯ β π€ β π¦ Μ mon π¨ π© = Ξ£ g κ (β£ π¨ β£ β β£ π© β£) , is-monomorphism π¨ π© g is-epimorphism : (π¨ : Algebra π€ π)(π© : Algebra π¦ π) β (β£ π¨ β£ β β£ π© β£) β π β π₯ β π€ β π¦ Μ is-epimorphism π¨ π© g = is-homomorphism π¨ π© g Γ Epic g epi : Algebra π€ π β Algebra π¦ π β π β π₯ β π€ β π¦ Μ epi π¨ π© = Ξ£ g κ (β£ π¨ β£ β β£ π© β£) , is-epimorphism π¨ π© g
It will be convenient to have a function that takes an inhabitant of mon
(or epi
) and extracts the homomorphism part, or hom reduct (that is, the pair consisting of the map and a proof that the map is a homomorphism).
mon-to-hom : (π¨ : Algebra π€ π){π© : Algebra π¦ π} β mon π¨ π© β hom π¨ π© mon-to-hom π¨ Ο = β£ Ο β£ , fst β₯ Ο β₯ epi-to-hom : {π¨ : Algebra π€ π}(π© : Algebra π¦ π) β epi π¨ π© β hom π¨ π© epi-to-hom _ Ο = β£ Ο β£ , fst β₯ Ο β₯
The kernel of a homomorphism is a congruence relation and conversely for every congruence relation ΞΈ, there exists a homomorphism with kernel ΞΈ (namely, that canonical projection onto the quotient modulo ΞΈ).
module _ {π€ π¦ : Universe}{π¨ : Algebra π€ π} where homker-compatible : dfunext π₯ π¦ β (π© : Algebra π¦ π)(h : hom π¨ π©) β compatible π¨ (ker β£ h β£) homker-compatible fe π© h f {u}{v} Kerhab = β£ h β£ ((f Μ π¨) u) β‘β¨ β₯ h β₯ f u β© (f Μ π©)(β£ h β£ β u) β‘β¨ ap (f Μ π©)(fe Ξ» x β Kerhab x) β© (f Μ π©)(β£ h β£ β v) β‘β¨ (β₯ h β₯ f v)β»ΒΉ β© β£ h β£ ((f Μ π¨) v) β
It is convenient to define a function that takes a homomorphism and constructs a congruence from its kernel. We call this function kercon
.
kercon : (π© : Algebra π¦ π){fe : dfunext π₯ π¦} β hom π¨ π© β Con{π¦} π¨ kercon π© {fe} h = ker β£ h β£ , mkcon (ker-IsEquivalence β£ h β£)(homker-compatible fe π© h)
With this congruence we construct the corresponding quotient, along with some syntactic sugar to denote it.
kerquo : dfunext π₯ π¦ β {π© : Algebra π¦ π} β hom π¨ π© β Algebra (π€ β π¦ βΊ) π kerquo fe {π©} h = π¨ β± (kercon π© {fe} h) _[_]/ker_βΎ_ : (π¨ : Algebra π€ π)(π© : Algebra π¦ π) β hom π¨ π© β dfunext π₯ π¦ β Algebra (π€ β π¦ βΊ) π π¨ [ π© ]/ker h βΎ fe = kerquo fe {π©} h infix 60 _[_]/ker_βΎ_
Thus, given h : hom π¨ π©
, we can construct the quotient of π¨
modulo the kernel of h
, and the syntax for this quotient in the UALib is π¨ [ π© ]/ker h βΎ fe
.
Given an algebra π¨
and a congruence ΞΈ
, the canonical projection is a map from π¨
onto π¨ β± ΞΈ
that is constructed, and proved epimorphic, as follows.
module _ {π€ π¦ : Universe}{π¨ : Algebra π€ π} where Οepi : (ΞΈ : Con{π¦} π¨) β epi π¨ (π¨ β± ΞΈ) Οepi ΞΈ = (Ξ» a β βͺ a β«) , (Ξ» _ _ β refl) , cΟ-is-epic where cΟ-is-epic : Epic (Ξ» a β βͺ a β«) cΟ-is-epic (C , (a , refl)) = Image_β_.im a
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.
Οhom : (ΞΈ : Con{π¦} π¨) β hom π¨ (π¨ β± ΞΈ) Οhom ΞΈ = epi-to-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
.)
Οker : (π© : Algebra π¦ π){fe : dfunext π₯ π¦}(h : hom π¨ π©) β epi π¨ (π¨ [ π© ]/ker h βΎ fe) Οker π© {fe} h = Οepi (kercon π© {fe} 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.
open IsCongruence ker-in-con : {fe : dfunext π₯ (π€ β π¦ βΊ)}(ΞΈ : Con{π¦} π¨) β β {x}{y} β β£ kercon (π¨ β± ΞΈ){fe} (Οhom ΞΈ) β£ x y β β£ ΞΈ β£ x y ker-in-con ΞΈ hyp = /-β‘ ΞΈ hyp
Suppose we have an algebra π¨
, a type I : π Μ
, and a family β¬ : I β Algebra π¦ π
of algebras. We sometimes refer to the inhabitants of I
as indices, and call β¬
an indexed family of algebras.
If in addition we have a family π½ : (i : I) β hom π¨ (β¬ i)
of homomorphisms, then we can construct a homomorphism from π¨
to the product β¨
β¬
in the natural way.
module _ {π π¦ : Universe}{I : π Μ}(β¬ : I β Algebra π¦ π) where β¨ -hom-co : dfunext π π¦ β {π€ : Universe}(π¨ : Algebra π€ π) β Ξ i κ I , hom π¨ (β¬ i) β hom π¨ (β¨ β¬) β¨ -hom-co fe π¨ π½ = (Ξ» a i β β£ π½ i β£ a) , (Ξ» π πΆ β fe Ξ» i β β₯ π½ i β₯ π πΆ)
The family π½
of homomorphisms inhabits the dependent type Ξ i κ I , hom π¨ (β¬ i)
. The syntax we use to represent this type is available to us because of the way -Ξ
is defined in the Type Topology library. We like this syntax because it is very close to the notation one finds in the standard type theory literature. However,
we could equally well have used one of the following alternatives, which may be closer to βstandard Agdaβ syntax:
Ξ Ξ» i β hom π¨ (β¬ i)
Β or Β (i : I) β hom π¨ (β¬ i)
Β or Β β i β hom π¨ (β¬ i)
.
The foregoing generalizes easily to the case in which the domain is also a product of a family of algebras. That is, if we are given π : I β Algebra π€ π and β¬ : I β Algebra π¦ π
(two families of π
-algebras), and π½ : Ξ i κ I , hom (π i)(β¬ i)
(a family of homomorphisms), then we can construct a homomorphism from β¨
π
to β¨
β¬
in the following natural way.
β¨ -hom : dfunext π π¦ β {π€ : Universe}(π : I β Algebra π€ π) β Ξ i κ I , hom (π i)(β¬ i) β hom (β¨ π)(β¨ β¬) β¨ -hom fe π π½ = (Ξ» x i β β£ π½ i β£ (x i)) , (Ξ» π πΆ β fe Ξ» i β β₯ π½ i β₯ π (Ξ» x β πΆ x i))
Later we will need a proof of the fact that projecting out of a product algebra onto one of its factors is a homomorphism.
β¨ -projection-hom : Ξ i κ I , hom (β¨ β¬) (β¬ i) β¨ -projection-hom = Ξ» x β (Ξ» z β z x) , Ξ» _ _ β refl
We could prove a more general result involving projections onto multiple factors, but so far the single-factor result has sufficed.
1
Recall, h β π
is the tuple whose i-th component is h (π i)
.
Instead of βhomomorphism,β we sometimes use the nickname βhomβ to refer to such a map.