Skip to content

Setoid.Categories.Algebra

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:

  • objects inhabit Algebra Ξ± ρ,
  • homs are the setoid homomorphisms hom of Setoid.Homomorphisms,
  • identity and composition are the 𝒾𝒹 and βŠ™-hom of Setoid.Homomorphisms
  • the hom-equality _≋_ is defined in this module and is pointwise equality: two homomorphisms are equal when their underlying maps agree on every element, in the codomain's setoid equality.

Pointwise hom-setoid equality is exactly what _≑_ cannot provide under --safe, and is why the Category record carries _β‰ˆ_ as a field.

The associative 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.

{-# OPTIONS --cubical-compatible --exact-split --safe #-}

module Setoid.Categories.Algebra where

open import Agda.Primitive using () renaming ( Set to Type )

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

-- Imports from the Agda Universal Algebra Library ----------------------------
open import Overture                         using ( π“ž ; π“₯ ; Signature ; 𝑆 )
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

_≋_ : {𝑆 : Signature π“ž π“₯}{𝑨 𝑩 : Algebra {𝑆 = 𝑆} Ξ± ρ} β†’ hom 𝑨 𝑩 β†’ hom 𝑨 𝑩 β†’ Type (Ξ± βŠ” ρ)
_≋_ {𝑨 = 𝑨} {𝑩} f g = βˆ€ (x : π•Œ[ 𝑨 ]) β†’ Setoid._β‰ˆ_ 𝔻[ 𝑩 ] (proj₁ f ⟨$⟩ x) (proj₁ g ⟨$⟩ x)

≋-equiv : {𝑆 : Signature π“ž π“₯}{𝑨 𝑩 : 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

Alg Ξ± ρ is the category of 𝑆-algebras at a fixed pair of levels: objects are algebras, morphisms are homomorphisms, and two morphisms are identified when they agree pointwise up to the codomain's equality (_≋_, defined above).

Everything the Category record asks for is already at hand. The identity is 𝒾𝒹 and composition is βŠ™-hom with its arguments flipped, since βŠ™-hom takes them in diagrammatic order while a category's _∘_ does not. Associativity and both unit laws hold on the nose under _≋_, so each is discharged by reflexivity of the codomain's equality; only ∘-resp-β‰ˆ needs an argument, and that argument is congruence of the underlying setoid functions.

Alg : {𝑆 : Signature π“ž π“₯}(Ξ± ρ : 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))
  }