---
layout: default
file: "src/Setoid/Categories/Algebra.lagda.md"
title: "Setoid.Categories.Algebra module"
date: "2026-06-08"
author: "the agda-algebras development team"
---
### The category of `π`-algebras
This is the [Setoid.Categories.Algebra][] module of the [Agda Universal Algebra Library][].
`Alg π Ξ± Ο` assembles the `π`-algebras at levels `(Ξ± , Ο)` into a
[`Category`][Setoid.Categories.Category]: objects are `Algebra Ξ± Ο`, homs are the
setoid homomorphisms `hom` of [Setoid.Homomorphisms][], identity and composition are
`πΎπΉ` and `β-hom`, and the hom-equality `_β_` is **pointwise** β two homomorphisms are
equal when their underlying maps agree on every element, in the codomain's setoid
equality. This pointwise hom-setoid is exactly what `_β‘_` cannot provide under
`--safe`, and is why the `Category` record carries `_β_` as a field.
The `assoc` and identity laws hold by the codomain's `refl` (the underlying maps are
definitionally equal β `β-hom` is function composition, `πΎπΉ` the identity map);
`β-resp-β` is the one law with content, combining the codomain's `trans` with a hom's
`cong`.
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
open import Overture using ( π ; π₯ ; Signature )
module Setoid.Categories.Algebra {π : Signature π π₯} where
open import Agda.Primitive using () renaming ( Set to Type )
open import Data.Product using ( projβ )
open import Function using ( Func )
open import Level using ( Level ; _β_ ) renaming ( suc to lsuc )
open import Relation.Binary using ( Setoid ; IsEquivalence )
open import Setoid.Algebras.Basic {π = π} using ( Algebra ; π[_] ; π»[_] )
open import Setoid.Homomorphisms.Basic using ( hom ; πΎπΉ )
open import Setoid.Homomorphisms.Properties using ( β-hom )
open import Setoid.Categories.Category using ( Category )
open Func using (cong) renaming ( to to _β¨$β©_ )
private variable Ξ± Ο : Level
```
-->
#### Pointwise equality of homomorphisms
```agda
_β_ : {π¨ π© : Algebra Ξ± Ο} β hom π¨ π© β hom π¨ π© β Type (Ξ± β Ο)
_β_ {π¨ = π¨} {π©} f g = β (x : π[ π¨ ]) β Setoid._β_ π»[ π© ] (projβ f β¨$β© x) (projβ g β¨$β© x)
β-equiv : {π¨ π© : Algebra Ξ± Ο} β IsEquivalence (_β_ {π¨ = π¨} {π©})
β-equiv {π© = π©} = record
{ refl = Ξ» _ β Setoid.refl π»[ π© ]
; sym = Ξ» fβg x β Setoid.sym π»[ π© ] (fβg x)
; trans = Ξ» fβg gβh x β Setoid.trans π»[ π© ] (fβg x) (gβh x)
}
```
#### The category
```agda
Alg : (Ξ± Ο : Level) β Category (π β π₯ β lsuc (Ξ± β Ο)) (π β π₯ β Ξ± β Ο) (Ξ± β Ο)
Alg Ξ± Ο = record
{ Obj = Algebra Ξ± Ο
; Hom = hom
; _β_ = _β_
; id = πΎπΉ
; _β_ = Ξ» g f β β-hom f g
; β-equiv = β-equiv
; assoc = Ξ» {_} {_} {_} {π«} _ β Setoid.refl π»[ π« ]
; identityΛ‘ = Ξ» {_} {π©} _ β Setoid.refl π»[ π© ]
; identityΚ³ = Ξ» {_} {π©} _ β Setoid.refl π»[ π© ]
; β-resp-β = Ξ» {_} {_} {πͺ} {_} {g} {h} fβg hβi x β
Setoid.trans π»[ πͺ ] (fβg (projβ h β¨$β© x)) (cong (projβ g) (hβi x))
}
```