Setoid.Algebras.Products¶
Products of Setoid Algebras¶
This is the Setoid.Algebras.Products module of the Agda Universal Algebra Library.
The product of an indexed family of algebras is formed coordinatewise: its carrier is the dependent function type over the index, its equality is pointwise, and each operation symbol is interpreted by applying the corresponding operation in every factor.
This module defines that product, β¨
; the binary product
_Γᴬ_ of two algebras, whose carrier is the type of pairs; the
machinery for taking the product of a class of algebras rather than of an
indexed family; and the one nontrivial fact about products proved here, which is
the following:
The coordinate projections out of a product are surjective when the index type has decidable equality and every factor is nonempty.
Products are one of the three closure operations H, S, P whose composite V
defines a variety, so this module is used throughout Setoid.Varieties.Closure
and in the proof of Birkhoff's theorem in Setoid.Varieties.HSP.
Homomorphisms into and out of a product are in Setoid.Homomorphisms.Products,
and β¨
β
of Setoid.Homomorphisms.Isomorphisms shows that
products of isomorphic families are isomorphic.
β¨
π is the product of the family π : I β Algebra Ξ± Ο. Its
carrier is the dependent product β i β π[ π i ] of the carriers of the factors;
two elements are equal exactly when they agree in every coordinate; and the
interpretation of an operation symbol f is the tuple of interpretations of f
in the factors, (f ^ β¨
π) a i = (f ^ π i) (flip a i).
The types involved in the expression (f ^ β¨
π) a i = (f ^ π i) (flip a i) are
the following:
I : Type ΞΉ
π : I β Algebra Ξ± Ο
a : ArityOf π f β (i : I) β π[ π i ]
f : OperationSymbolsOf π
The effect of flip a i is to partially apply a to its second argument, i,
which results in a map from ArityOf π f to π[ π i ] and is exactly the right
shaped argument "tuple" to pass to f ^ π i.
Reflexivity, symmetry and transitivity are inherited coordinatewise, and so is the
congruence proof for Interp.
β¨ : {I : Type ΞΉ }(π : I β Algebra {π = π} Ξ± Ο) β Algebra {π = π} (Ξ± β ΞΉ) (Ο β ΞΉ) Domain (β¨ π) = record { Carrier = β i β π[ π i ] ; _β_ = Ξ» a b β β i β π»[ π i ] ._β_ (a i) (b i) ; isEquivalence = record { refl = Ξ» i β reflE (isEqv π»[ π i ]) ; sym = Ξ» x i β symE (isEqv π»[ π i ])(x i) ; trans = Ξ» x y i β transE (isEqv π»[ π i ])(x i)(y i) } } Interp (β¨ π) β¨$β© (f , a) = Ξ» i β (f ^ π i) (flip a i) cong (Interp (β¨ π)) (refl , f=g) = Ξ» i β cong (Interp (π i)) (refl , flip f=g i)
Note that both levels of the resulting algebra absorb the level ΞΉ of the index
type, since the carrier is a function out of I and the equality is an
I-indexed conjunction. A product therefore sits at the join of its factors'
levels with the level of its index. Correspondingly, the operator
P of Setoid.Varieties.Closure, defining the class of products
of a class, states membership up to isomorphism, π© β
β¨
π, which leaves π© with
its own pair of levels.
Binary products¶
π¨ Γᴬ π© is the binary product of two algebras: its carrier is
the type π[ π¨ ] Γ π[ π© ] of pairs, two pairs are equal when they agree in both
coordinates (the standard library's Γ-setoid), and an operation
symbol acts coordinatewise. It is the product A Γ B of the textbooks, the one
in which a direct decomposition π¨ β
π© Γ πͺ is stated (McKenzie, McNulty, and
Taylor, Algebras, Lattices, Varieties I, Definition 4.37 and Β§5.1); see
Setoid.Decompositions.
The indexed product β¨
over a two-element index type would serve
mathematically, but it asks both factors to live at the same universe levels,
while the pair carrier lets them differ; the coordinates are also projected with
projβ and projβ rather than by evaluation at an
index. Its projections and the pairing of two homomorphisms are in
Setoid.Homomorphisms.Products.
_Γᴬ_ : Algebra {π = π} Ξ± Ο β Algebra {π = π} Ξ² Οα΅ β Algebra {π = π} (Ξ± β Ξ²) (Ο β Οα΅) Domain (π¨ Γᴬ π©) = Γ-setoid π»[ π¨ ] π»[ π© ] Interp (π¨ Γᴬ π©) β¨$β© (f , a) = (f ^ π¨) (projβ β a) , (f ^ π©) (projβ β a) cong (Interp (π¨ Γᴬ π©)) (refl , aβb) = cong (Interp π¨) (refl , projβ β aβb) , cong (Interp π©) (refl , projβ β aβb) infixr 2 _Γᴬ_
Products of classes of Algebras¶
A class of algebras is given as a predicate π¦ : Pred (Algebra Ξ± Ο) _, not as an
indexed family, so β¨
cannot be applied to it directly; and the
dependent product over the predicate is not what we want either, since β π¨ β π¨ β π¦
asserts that every algebra belongs to π¦.
The remedy is to take the class itself as the index:
βis the type of pairs(π¨ , p)withp : π¨ β π¦,πsends such a pair to its first component, andclass-productisβ¨ π, the product of all the members ofπ¦.
Given a proof, p : π¨ β π¦, that π¨ belongs to π¦, we view the pair (π¨ , p) β β
as an index over the class, and π (π¨ , p) (which is simply π¨) as the
projection of the product β¨
π onto the (π¨ , p)-th component.
module _ {π : Signature π π₯} {π¦ : Pred (Algebra {π = π} Ξ± Ο) (ov {π = π} Ξ±)} where β : Type (ov {π = π} (Ξ± β Ο)) β = Ξ£[ π¨ β (Algebra {π = π} Ξ± Ο) ] π¨ β π¦ π : β β Algebra {π = π} Ξ± Ο π (π¨ , _) = π¨ class-product : Algebra (ov {π = π} (Ξ± β Ο)) (ov {π = π} (Ξ± β Ο)) class-product = β¨ π
One subtlety of indexing by proofs rather than by algebras is that an algebra
carrying two membership proofs contributes two identical factors; the result is a
product of members of π¦ regardless. A variant that indexes by an environment as
well appears as ββΊ, πβΊ and β in Setoid.Varieties.HSP.
Surjectivity of coordinate projections¶
Suppose I is an index type and π : I β Algebra Ξ± Ο is an indexed collection of algebras.
Let β¨
π be the product algebra defined in the first section of this module.
Given i : I, consider the projection of β¨
π onto the i-th coordinate.
This projection ought to be a surjective map from β¨
π onto π i, but this is
not so if I is an arbitrary type. Indeed, we need an equality on I, the
equality must be decidable, and each factor of the product must be nonempty.
In the Setoid.Functions.Surjective module we showed how to define a decidable index type in Agda. Here we use this to prove that the projection of a product of algebras over such an index type is surjective.
module _ {I : Type ΞΉ} -- index type {_β_ : Decidable{A = I} _β‘_} -- with decidable equality {π : I β Algebra {π = π} Ξ± Ο} -- indexed collection of algebras {πI : β i β π[ π i ] } -- each of which is nonempty where ProjAlgIsOnto : β{i} β Ξ£[ h β (π[ β¨ π ] β π[ π i ]) ] onto h ProjAlgIsOnto {i} = (proj _β_ πI i) , projIsOnto _β_ πI