Setoid.Congruences.Finite¶
Finitely enumerable congruence lattices¶
This is the Setoid.Congruences.Finite module of the Agda Universal Algebra Library.
Setoid.Algebras.Finite defines the finiteness interface for a setoid algebra:
decidable β and a finite surjective enumeration of the carrier. This module
supplies the finiteness interface for congruences, that is, decidable
congruences (DecCon) and the record type
FiniteCongruences π¨.
FiniteCongruences π¨ packages a finite list cons of decidable
congruences of π¨ along with a proof that this list is complete in the sense that
every congruence of π¨ is, up to mutual containment β, one of those in cons.
This provides a searchable congruence lattice that finite-algebra theorems run their algorithms over; its first consumer is the finite Birkhoff theorem of Setoid.Subalgebras.Subdirect.Finite.
Why carrier finiteness does not suffice¶
Crucially, the data packaged here is strictly stronger than a
FiniteAlgebra witness, which is why the two interfaces are separate
records. Carrier-finiteness along with decidable setoid equality do not, by
themselves, admit a complete congruence enumeration constructively.
Indeed, a congruence is a Type-valued relation π[ π¨ ] β π[ π¨ ] β Type β, and an
arbitrary such relation on a finite carrier need not be decidable; e.g., on a bare
set of two elements, the relation that collapses the two points iff P holds is a
congruence for any proposition P, and it is β-equal to a decidable congruence
only iff P is decidable.
Thus, a complete enumeration of congruences-up-to-β is strictly stronger than
decidable equality on a finite set; it is exactly the classical content of "finite
algebra" for congruence-lattice purposes. Classically every finite algebra furnishes
these data; constructively they must be supplied, and this record is the interface
through which they are.
The two interfaces are logically independent in the other direction as well: an
infinite algebra can perfectly well have a finitely enumerable congruence lattice
(consider an algebra that is constructively simple, with decidable equality β its
complete list is the diagonal and the total congruence), so
FiniteCongruences does not presuppose a finite carrier.
There is, however, one overlap, recorded as β-dec below:
completeness forces the listed representative of the diagonal to decide setoid
equality, so the _β_ field of FiniteAlgebra is derivable
from a FiniteCongruences witness.
Decidable congruences and the working level¶
A decidable congruence is a congruence whose membership relation is decidable.
The working congruence level is the absorbing level clv Ξ± Ο = π β π₯ β Ξ± β Ο, at
which the generated (principal) congruences used downstream (e.g. for the monolith
in the finite Birkhoff construction) stay put β the same level discipline as in
Setoid.Congruences.CompleteLattice.
-- The absorbing congruence level at which the enumeration below is carried out. clv : (Ξ± Ο : Level) β Level clv Ξ± Ο = π β π₯ β Ξ± β Ο -- A congruence together with a decision procedure for its membership. DecCon : (π¨ : Algebra Ξ± Ο)(β : Level) β Type (clv Ξ± Ο β lsuc β) DecCon π¨ β = Ξ£[ (_ΞΈ_ , _) β Con π¨ β ] β x y β Dec (x ΞΈ y) -- The underlying relation of a decidable congruence. ConRel : {π¨ : Algebra Ξ± Ο}{β : Level} β DecCon π¨ β β BinaryRel π[ π¨ ] β ConRel ((ΞΈ , _) , _) = ΞΈ
The congruence-side finiteness interface¶
The record bundles a finite list cons of decidable congruences and a
proof complete that the list exhausts the congruence lattice up to
β. The witness* helpers project, for any congruence, its listed
representative together with the membership and β-equality proofs.
record FiniteCongruences (π¨ : Algebra Ξ± Ο) : Type (lsuc (clv Ξ± Ο)) where field -- a finite list of decidable congruences of π¨ ... cons : List (DecCon π¨ (clv Ξ± Ο)) -- ... exhausting the congruence lattice of π¨, up to β complete : (Ο : Con π¨ (clv Ξ± Ο)) β Ξ£[ d β DecCon π¨ (clv Ξ± Ο) ] (d β cons) Γ (Ο β projβ d) witness : (Ο : Con π¨ (clv Ξ± Ο)) β DecCon π¨ (clv Ξ± Ο) witness = projβ β complete witnessβ : (Ο : Con π¨ (clv Ξ± Ο)) β witness Ο β cons witnessβ = projβ β projβ β complete witnessβ : (Ο : Con π¨ (clv Ξ± Ο)) β Ο β projβ (witness Ο) witnessβ = projβ β projβ β complete
As promised, a FiniteCongruences witness decides setoid equality:
the diagonal congruence π[ π¨ ] has a listed representative whose decidable
membership coincides, up to the two containments of β, with β.
module _ {π¨ : Algebra Ξ± Ο} (πͺ : FiniteCongruences π¨) where open FiniteCongruences πͺ open Setoid π»[ π¨ ] using ( _β_ ) private -- The diagonal congruence at the working level. Ξ : Con π¨ (clv Ξ± Ο) Ξ = π[ π¨ ] {clv Ξ± Ο} -- Setoid equality is decidable whenever the congruence lattice is -- finitely enumerable: ask the diagonal's listed representative. β-dec : (x y : π[ π¨ ]) β Dec (x β y) β-dec x y with projβ (witness Ξ) x y ... | yes dxy = yes (lower (projβ (witnessβ Ξ) dxy)) ... | no Β¬dxy = no Ξ» xβy β Β¬dxy (projβ (witnessβ Ξ) (lift xβy))
Non-vacuity: the one-element algebra¶
The one-element algebra π of Setoid.Algebras.Finite has, up to
β, exactly one congruence β the all-relation, which on a one-point carrier is
also the diagonal β so its complete list is a singleton.
-- The sole decidable congruence of π: the all-relation (= the diagonal on a point). π-Ξ : DecCon π (clv 0β 0β) π-Ξ = ((Ξ» _ _ β Lift (clv 0β 0β) β€) , mkcon (Ξ» _ β lift tt) (record { refl = lift tt ; sym = Ξ» _ β lift tt ; trans = Ξ» _ _ β lift tt }) (Ξ» _ _ β lift tt)) , (Ξ» _ _ β yes (lift tt)) -- The congruence lattice of π is finitely enumerable. open FiniteCongruences π-FiniteCongruences : FiniteCongruences π π-FiniteCongruences .cons = π-Ξ β· [] π-FiniteCongruences .complete ( _ , Οcon ) = π-Ξ , here refl , (Ξ» _ β lift tt) , Ξ» x β reflexive Οcon tt