module Cat.Diagram.Congruence {o β} {C : Precategory o β} (fc : Finitely-complete C) where
Congruencesπ
The idea of congruence is the categorical rephrasing of the idea of equivalence relation. Recall that an equivalence relation on a set is a family of propositions satisfying reflexivity ( for all transitivity ( and symmetry ( Knowing that classifies embeddings, we can equivalently talk about an equivalence relation as being just some set, equipped with a monomorphism
We must now identify what properties of the mono identify as being the total space of an equivalence relation. Let us work in the category of sets for the moment. Suppose is a relation on and is the monomorphism representing it. Letβs identify the properties of which correspond to the properties of weβre interested in:
module _ {β} {A : Set β} {R : β£ A β£ Γ β£ A β£ β Type β} {rp : β x β is-prop (R x)} where private domain : Type β domain = subtype-classifier.from (Ξ» x β R x , rp x) .fst m : domain β£ (β£ A β£ Γ β£ A β£) m = subtype-classifier.from (Ξ» x β R x , rp x) .snd pβ pβ : domain β β£ A β£ pβ = fst β fst m pβ = snd β fst m
Reflexivity. is reflexive if, and only if, the morphisms have a common left inverse
R-reflβcommon-inverse : (β x β R (x , x)) β Ξ£[ rrefl β (β£ A β£ β domain) ] ( (pβ β rrefl β‘ (Ξ» x β x)) Γ (pβ β rrefl β‘ (Ξ» x β x))) R-reflβcommon-inverse ref = (Ξ» x β (x , x) , ref x) , refl , refl common-inverseβR-refl : (rrefl : β£ A β£ β domain) β (pβ β rrefl β‘ (Ξ» x β x)) β (pβ β rrefl β‘ (Ξ» x β x)) β β x β R (x , x) common-inverseβR-refl inv p q x = subst R (Ξ» i β p i x , q i x) (inv x .snd)
Symmetry. There is a map which swaps and
R-symβswap : (β {x y} β R (x , y) β R (y , x)) β Ξ£[ s β (domain β domain) ] ((pβ β s β‘ pβ) Γ (pβ β s β‘ pβ)) R-symβswap sym .fst ((x , y) , p) = (y , x) , sym p R-symβswap sym .snd = refl , refl swapβR-sym : (s : domain β domain) β (pβ β s β‘ pβ) β (pβ β s β‘ pβ) β β {x y} β R (x , y) β R (y , x) swapβR-sym s p q {x} {y} rel = subst R (Ξ£-pathp (happly p _) (happly q _)) (s (_ , rel) .snd)
Transitivity. This oneβs a doozy. Since has finite limits, we have an object of βcomposable pairsβ of namely the pullback under the cospan
Transitivity, then, means that the two projection maps β which take a βcomposable pairβ to the βfirst mapβs sourceβ and βsecond mapβs targetβ, respectively β factor through somehow, i.e.Β we have a fitting in the diagram below
s-t-factorβR-transitive : (t : (Ξ£[ m1 β domain ] Ξ£[ m2 β domain ] (m1 .fst .snd β‘ m2 .fst .fst)) β domain) β ( Ξ» { (((x , _) , _) , ((_ , y) , _) , _) β x , y } ) β‘ m .fst β t -- ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- this atrocity is "(pβqβ,pβqβ)" in the diagram β β {x y z} β R (x , y) β R (y , z) β R (x , z) s-t-factorβR-transitive compose preserves s t = subst R (sym (happly preserves _)) (composite .snd) where composite = compose ((_ , s) , (_ , t) , refl)
Generallyπ
Above, we have calculated the properties of a monomorphism which identify as an equivalence relation on the object Note that, since the definition relies on both products and pullbacks, we go ahead and assume the category is finitely complete.
open Cat.Reasoning C open Pullback open Product private module fc = Finitely-complete fc private _β_ : Ob β Ob β Ob A β B = fc.products A B .apex
record is-congruence {A R} (m : Hom R (A β A)) : Type (o β β) where no-eta-equality
Hereβs the data of a congruence. Get ready, because thereβs a lot of it:
private module AΓA = Product (fc.products A A) relβ : Hom R A relβ = AΓA.Οβ β m relβ : Hom R A relβ = AΓA.Οβ β m private module RΓR = Pullback (fc.pullbacks relβ relβ) private module AΓAΓA = Pullback (fc.pullbacks relβ relβ)
field has-is-monic : is-monic m -- Reflexivity: has-refl : Hom A R refl-pβ : relβ β has-refl β‘ id refl-pβ : relβ β has-refl β‘ id -- Symmetry: has-sym : Hom R R sym-pβ : relβ β has-sym β‘ relβ sym-pβ : relβ β has-sym β‘ relβ -- Transitivity has-trans : Hom RΓR.apex R source-target : Hom RΓR.apex AΓA.apex source-target = AΓA.β¨ relβ β RΓR.pβ , relβ β RΓR.pβ β©AΓA. field trans-factors : source-target β‘ m β has-trans
trans-pβ : relβ β has-trans β‘ relβ β AΓAΓA.pβ trans-pβ = pullr (sym trans-factors) β AΓA.Οβββ¨β© trans-pβ : relβ β has-trans β‘ relβ β AΓAΓA.pβ trans-pβ = pullr (sym trans-factors) β AΓA.Οβββ¨β© unpair-trans : β {X} {pβ' pβ' : Hom X R} β (sq : relβ β pβ' β‘ relβ β pβ') β m β has-trans β RΓR.universal sq β‘ AΓA.β¨ relβ β pβ' , relβ β pβ' β©AΓA. unpair-trans sq = pulll (sym trans-factors) Β·Β· AΓA.β¨β©β _ Β·Β· apβ AΓA.β¨_,_β© (pullr RΓR.pββuniversal) (pullr RΓR.pββuniversal)
record Congruence-on A : Type (o β β) where no-eta-equality field {domain} : Ob inclusion : Hom domain (A β A) has-is-cong : is-congruence inclusion open is-congruence has-is-cong public
The diagonalπ
The first example of a congruence we will see is the βdiagonalβ morphism corresponding to the βtrivial relationβ.
diagonal : β {A} β Hom A (A β A) diagonal {A} = fc.products A A .β¨_,_β© id id
That the diagonal morphism is monic follows from the following calculation, where we use that
diagonal-is-monic : β {A} β is-monic (diagonal {A}) diagonal-is-monic {A} g h p = g β‘β¨ introl AΓA.Οβββ¨β© β©β‘ (AΓA.Οβ β diagonal) β g β‘β¨ extendr p β©β‘ (AΓA.Οβ β diagonal) β h β‘β¨ eliml AΓA.Οβββ¨β© β©β‘ h β where module AΓA = Product (fc.products A A)
We now calculate that it is a congruence, using the properties of products and pullbacks. The reflexivity map is given by the identity, and so is the symmetry map; For the transitivity map, we arbitrarily pick the first projection from the pullback of βcomposable pairsβ; The second projection wouldβve worked just as well.
diagonal-congruence : β {A} β is-congruence diagonal diagonal-congruence {A} = cong where module AΓA = Product (fc.products A A) module Pb = Pullback (fc.pullbacks (AΓA.Οβ β diagonal) (AΓA.Οβ β diagonal)) open is-congruence cong : is-congruence _ cong .has-is-monic = diagonal-is-monic cong .has-refl = id cong .refl-pβ = eliml AΓA.Οβββ¨β© cong .refl-pβ = eliml AΓA.Οβββ¨β© cong .has-sym = id cong .sym-pβ = eliml AΓA.Οβββ¨β© β sym AΓA.Οβββ¨β© cong .sym-pβ = eliml AΓA.Οβββ¨β© β sym AΓA.Οβββ¨β© cong .has-trans = Pb.pβ cong .trans-factors = AΓA.uniqueβ (AΓA.Οβββ¨β© β eliml AΓA.Οβββ¨β©) (AΓA.Οβββ¨β© β eliml AΓA.Οβββ¨β©) (assoc _ _ _ β Pb.square β eliml AΓA.Οβββ¨β©) (cancell AΓA.Οβββ¨β©)
Effective congruencesπ
A second example in the same vein as the diagonal is, for any morphism its kernel pair, i.e.Β the pullback of Calculating in this is the equivalence relation generated by β it is the subobject of consisting of those βvalues which maps to the same thingβ.
module _ {a b} (f : Hom a b) where private module Kp = Pullback (fc.pullbacks f f) module aΓa = Product (fc.products a a) kernel-pair : Hom Kp.apex aΓa.apex kernel-pair = aΓa.β¨ Kp.pβ , Kp.pβ β©aΓa. private module rel = Pullback (fc.pullbacks (aΓa.Οβ β kernel-pair) (aΓa.Οβ β kernel-pair)) kernel-pair-is-monic : is-monic kernel-pair kernel-pair-is-monic g h p = Kp.uniqueβ {p = extendl Kp.square} refl refl (sym (pulll aΓa.Οβββ¨β©) β apβ _β_ refl (sym p) β pulll aΓa.Οβββ¨β©) (sym (pulll aΓa.Οβββ¨β©) β apβ _β_ refl (sym p) β pulll aΓa.Οβββ¨β©)
We build the congruence in parts.
open is-congruence kernel-pair-is-congruence : is-congruence kernel-pair kernel-pair-is-congruence = cg where cg : is-congruence _ cg .has-is-monic = kernel-pair-is-monic
For the reflexivity map, we take the unique map which is characterised by This expresses, diagrammatically, that
cg .has-refl = Kp.universal {pβ' = id} {pβ' = id} refl cg .refl-pβ = ap (_β Kp.universal refl) aΓa.Οβββ¨β© β Kp.pββuniversal cg .refl-pβ = ap (_β Kp.universal refl) aΓa.Οβββ¨β© β Kp.pββuniversal
Symmetry is witnessed by the map which swaps the components. This oneβs pretty simple.
cg .has-sym = Kp.universal {pβ' = Kp.pβ} {pβ' = Kp.pβ} (sym Kp.square) cg .sym-pβ = ap (_β Kp.universal (sym Kp.square)) aΓa.Οβββ¨β© β sym (aΓa.Οβββ¨β© β sym Kp.pββuniversal) cg .sym-pβ = ap (_β Kp.universal (sym Kp.square)) aΓa.Οβββ¨β© β sym (aΓa.Οβββ¨β© β sym Kp.pββuniversal)
Understanding the transitivity map is left as an exercise to the reader.
cg .has-trans = Kp.universal {pβ' = Kp.pβ β rel.pβ} {pβ' = Kp.pβ β rel.pβ} path where abstract path : f β Kp.pβ β rel.pβ β‘ f β Kp.pβ β rel.pβ path = f β Kp.pβ β rel.pβ β‘β¨ extendl (Kp.square β ap (f β_) (sym aΓa.Οβββ¨β©)) β©β‘ f β (aΓa.Οβ β kernel-pair) β rel.pβ β‘β¨ ap (f β_) (sym rel.square) β©β‘ f β (aΓa.Οβ β kernel-pair) β rel.pβ β‘β¨ extendl (ap (f β_) aΓa.Οβββ¨β© β Kp.square) β©β‘ f β Kp.pβ β rel.pβ β cg .trans-factors = sym ( kernel-pair β Kp.universal _ β‘β¨ aΓa.β¨β©β _ β©β‘ aΓa.β¨ Kp.pβ β Kp.universal _ , Kp.pβ β Kp.universal _ β©aΓa. β‘β¨ apβ aΓa.β¨_,_β© (Kp.pββuniversal β apβ _β_ (sym aΓa.Οβββ¨β©) refl) (Kp.pββuniversal β apβ _β_ (sym aΓa.Οβββ¨β©) refl) β©β‘ aΓa.β¨ (aΓa.Οβ β kernel-pair) β rel.pβ , (aΓa.Οβ β kernel-pair) β rel.pβ β©aΓa. β) Kernel-pair : Congruence-on a Kernel-pair .Congruence-on.domain = _ Kernel-pair .Congruence-on.inclusion = kernel-pair Kernel-pair .Congruence-on.has-is-cong = kernel-pair-is-congruence
Quotient objectsπ
Let be a congruence on If has a coequaliser for the composites then we call the quotient map, and we call the quotient of
is-quotient-of : β {A A/R} (R : Congruence-on A) β Hom A A/R β Type _ is-quotient-of R = is-coequaliser C R.relβ R.relβ where module R = Congruence-on R
Since coequalises the two projections, by definition, we have Calculating in the category of sets where equality of morphisms is computed pointwise, we can say that βthe images of elements under the quotient map are equalβ. By definition, the quotient for a congruence is a regular epimorphism.
open is-regular-epi quotient-regular-epi : β {A A/R} {R : Congruence-on A} {f : Hom A A/R} β is-quotient-of R f β is-regular-epi C f quotient-regular-epi quot .r = _ quotient-regular-epi quot .arrβ = _ quotient-regular-epi quot .arrβ = _ quotient-regular-epi quot .has-is-coeq = quot
If has a quotient and is additionally the pullback of along itself, then is called an effective congruence, and is an effective coequaliser. Since, as mentioned above, the kernel pair of a morphism is βthe congruence of equal imagesβ, this says that an effective quotient identifies exactly those objects related by and no more.
record is-effective-congruence {A} (R : Congruence-on A) : Type (o β β) where private module R = Congruence-on R field {A/R} : Ob quotient : Hom A A/R has-quotient : is-quotient-of R quotient has-kernel-pair : is-kernel-pair C R.relβ R.relβ quotient
If is the coequaliser of its kernel pair β that is, it is an effective epimorphism β then it is an effective congruence, and vice-versa.
kernel-pair-is-effective : β {a b} {f : Hom a b} β is-quotient-of (Kernel-pair f) f β is-effective-congruence (Kernel-pair f) kernel-pair-is-effective {a = a} {b} {f} quot = epi where open is-effective-congruence hiding (A/R) module aΓa = Product (fc.products a a) module pb = Pullback (fc.pullbacks f f) open is-coequaliser epi : is-effective-congruence _ epi .is-effective-congruence.A/R = b epi .quotient = f epi .has-quotient = quot epi .has-kernel-pair = transport (Ξ» i β is-pullback C (aΓa.Οβββ¨β© {p1 = pb.pβ} {p2 = pb.pβ} (~ i)) f (aΓa.Οβββ¨β© {p1 = pb.pβ} {p2 = pb.pβ} (~ i)) f) pb.has-is-pb kp-effective-congruenceβeffective-epi : β {a b} {f : Hom a b} β (eff : is-effective-congruence (Kernel-pair f)) β is-effective-epi C (eff .is-effective-congruence.quotient) kp-effective-congruenceβeffective-epi {f = f} cong = epi where module cong = is-effective-congruence cong open is-effective-epi epi : is-effective-epi C _ epi .kernel = Kernel-pair _ .Congruence-on.domain epi .pβ = _ epi .pβ = _ epi .has-kernel-pair = cong.has-kernel-pair epi .has-is-coeq = cong.has-quotient