Skip to content

Setoid.Homomorphisms.Products

Products of Homomorphisms of Algebras

This is the Setoid.Homomorphisms.Products module of the Agda Universal Algebra Library.

This module defines some of the homomorphisms associated with a product.

  • β¨…-hom-co is the induced map into a product: a family of homomorphisms out of a single algebra 𝑨, one for each index, assembles into a single homomorphism from 𝑨 to the product;
  • β¨…-hom takes a family of homomorphisms π’œ i β†’ ℬ i to their product, β¨… π’œ β†’ β¨… ℬ;
  • β¨…-proj is the coordinate projection β¨… π’œ β†’ π’œ i;
  • Γ—-proj₁, Γ—-projβ‚‚, and Γ—-hom-co are the same constructions for the binary product _×ᴬ_: the two projections, and the pairing of two homomorphisms out of 𝑨.

All three are defined coordinatewise, and their compatibility proofs are inherited coordinatewise from the factors, because that is how β¨… of Setoid.Algebras.Products interprets the operations in the first place.1

{-# OPTIONS --without-K --exact-split --safe #-}

module Setoid.Homomorphisms.Products where

-- Imports from Agda and the Agda Standard Library --------------------------
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 )

-- Imports from the Agda Universal Algebras Library ----------------------
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.

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

If we are given π’œ : I β†’ Algebra Ξ± 𝑆 and ℬ : I β†’ Algebra Ξ² 𝑆 (two families of 𝑆-algebras), then a family 𝒽 of homomorphisms inhabits the dependent type βˆ€ (i : I) β†’ hom (π’œ i) (ℬ i), from which we construct a homomorphism from β¨… π’œ to β¨… ℬ in the following natural way.

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.

  β¨…-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.

Homomorphisms of binary products

The two projections out of a binary product 𝑩 ×ᴬ π‘ͺ are homomorphisms, Γ—-proj₁ onto 𝑩 and Γ—-projβ‚‚ onto π‘ͺ; the setoid equality of the product is the conjunction of the two coordinate equalities, so each projection respects it by taking one conjunct.

module _ {𝑆 : Signature π“ž π“₯} {𝑩 : Algebra {𝑆 = 𝑆} Ξ² ρᡇ} {π‘ͺ : Algebra {𝑆 = 𝑆} Ξ³ ρᢜ} where
  -- The first projection 𝑩 Γ— π‘ͺ β†’ 𝑩.
  Γ—-proj₁ : hom (𝑩 ×ᴬ π‘ͺ) 𝑩
  Γ—-proj₁ = F , isHom
    where
    F : 𝔻[ 𝑩 ×ᴬ π‘ͺ ] ⟢ 𝔻[ 𝑩 ]
    F ⟨$⟩ x = proj₁ x
    F .cong xy = proj₁ xy

    isHom : IsHom (𝑩 ×ᴬ π‘ͺ) 𝑩 F
    isHom .compatible = Setoid.refl 𝔻[ 𝑩 ]

  -- The second projection 𝑩 Γ— π‘ͺ β†’ π‘ͺ.
  Γ—-projβ‚‚ : hom (𝑩 ×ᴬ π‘ͺ) π‘ͺ
  Γ—-projβ‚‚ = F , isHom
    where
    F : 𝔻[ 𝑩 ×ᴬ π‘ͺ ] ⟢ 𝔻[ π‘ͺ ]
    F ⟨$⟩ x = projβ‚‚ x
    F .cong xy = projβ‚‚ xy

    isHom : IsHom (𝑩 ×ᴬ π‘ͺ) π‘ͺ F
    isHom .compatible = Setoid.refl 𝔻[ π‘ͺ ]

Two homomorphisms g : 𝑨 β†’ 𝑩 and h : 𝑨 β†’ π‘ͺ out of one algebra pair to the homomorphism Γ—-hom-co g h : 𝑨 β†’ 𝑩 ×ᴬ π‘ͺ, a ↦ (g a , h a); it is the binary case of β¨…-hom-co, and composing it with either projection gives back g or h on the nose.

module _ {𝑆 : Signature π“ž π“₯} {𝑨 : Algebra {𝑆 = 𝑆} Ξ± ρ}
         {𝑩 : Algebra {𝑆 = 𝑆} Ξ² ρᡇ} {π‘ͺ : Algebra {𝑆 = 𝑆} Ξ³ ρᢜ} where
  -- The pairing a ↦ (g a , h a) of two homomorphisms out of 𝑨.
  Γ—-hom-co : hom 𝑨 𝑩 β†’ hom 𝑨 π‘ͺ β†’ hom 𝑨 (𝑩 ×ᴬ π‘ͺ)
  Γ—-hom-co g h = F , isHom
    where
    F : 𝔻[ 𝑨 ] ⟢ 𝔻[ 𝑩 ×ᴬ π‘ͺ ]
    F ⟨$⟩ a = g .proj₁ ⟨$⟩ a , h .proj₁ ⟨$⟩ a
    F .cong xy = g .proj₁ .cong xy , h .proj₁ .cong xy

    isHom : IsHom 𝑨 (𝑩 ×ᴬ π‘ͺ) F
    isHom .compatible = g .projβ‚‚ .compatible , h .projβ‚‚ .compatible


  1. β¨…-hom-co does real work later: the proof of Birkhoff's theorem in Setoid.Varieties.HSP uses it to build the homomorphism homβ„­ from the term algebra into the product β„­ that the whole argument turns on. ↩