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