---
layout: default
title : "Setoid.Homomorphisms.Products module (The Agda Universal Algebra Library)"
date : "2021-09-21"
author: "agda-algebras development team"
---
#### Products of Homomorphisms of Algebras
This is the [Setoid.Homomorphisms.Products][] module of the [Agda Universal Algebra Library][].
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
module Setoid.Homomorphisms.Products where
open import Agda.Primitive using () renaming ( Set to Type )
open import Function using () renaming ( Func to _βΆ_ )
open import Data.Product using ( _,_ )
open import Level using ( Level )
open import Relation.Binary using ( Setoid )
open import Overture using ( projβ ; projβ ; π ; π₯ ; Signature)
open import Setoid.Algebras using ( Algebra ; β¨
; π»[_] )
open import Setoid.Homomorphisms.Basic using ( hom ; IsHom )
open _βΆ_ using ( cong ) renaming ( to to _β¨$β©_ )
open IsHom
private variable Ξ± Ο Ξ² Οα΅ π : Level
```
-->
Suppose we have an algebra `π¨`, a type `I : Type π`, 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.
```agda
module _ {π : Signature π π₯} {π¨ : Algebra {π = π} Ξ± Ο } {I : Type π} (β¬ : I β Algebra Ξ² Οα΅) where
β¨
-hom-co : (β(i : I) β hom π¨ (β¬ i)) β hom π¨ (β¨
β¬)
β¨
-hom-co π½ = h , hhom
where
h : π»[ π¨ ] βΆ π»[ β¨
β¬ ]
h β¨$β© a = Ξ» i β π½ i .projβ β¨$β© a
h .cong xy = Ξ» i β π½ i .projβ .cong xy
hhom : IsHom π¨ (β¨
β¬) h
hhom .compatible = Ξ» i β π½ i .projβ .compatible
```
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.
```agda
module _ {π : Signature π π₯} {I : Type π} (π : I β Algebra {π = π} Ξ± Ο) where
β¨
-hom : (β¬ : I β Algebra Ξ² Οα΅) β (β (i : I) β hom (π i) (β¬ i)) β hom (β¨
π)(β¨
β¬)
β¨
-hom β¬ π½ = F , isHom
where
F : π»[ β¨
π ] βΆ π»[ β¨
β¬ ]
F β¨$β© x = Ξ» i β π½ i .projβ β¨$β© x i
F .cong xy = Ξ» i β π½ i .projβ .cong (xy i)
isHom : IsHom (β¨
π) (β¨
β¬) F
isHom .compatible = Ξ» i β π½ i .projβ .compatible
```
#### Projection out of products
The projection of a product algebra onto its `i`-th factor is a homomorphism.
```agda
β¨
-proj : (i : I) β hom (β¨
π) (π i)
β¨
-proj i = F , isHom
where
F : π»[ β¨
π ] βΆ π»[ π i ]
F β¨$β© x = x i
F .cong xy = xy i
isHom : IsHom (β¨
π) (π i) F
isHom .compatible = Setoid.refl π»[ π i ]
```
We could prove a more general result involving projections onto multiple factors, but
so far the single-factor result has sufficed.