Setoid.Varieties.Preservation¶
Equation preservation for setoid algebras¶
This is the Setoid.Varieties.Preservation module of the Agda Universal Algebra Library.
This module proves that the classes Hπ¦,
Sπ¦, Pπ¦, and
Vπ¦ all satisfy the same identities.
Closure properties¶
The types defined above represent operators with useful closure properties. We now prove a handful of such properties that we need later.
module _ {Ξ± Οα΅ β : Level}{π¦ : Pred(Algebra {π = π} Ξ± Οα΅) (Ξ± β Οα΅ β ov {π = π} β)} where private a = Ξ± β Οα΅ oaβ = ov {π = π} (a β β) SβSP : β{ΞΉ} β S β π¦ β S {Ξ² = Ξ±}{Οα΅} (a β β β ΞΉ) (P {Ξ² = Ξ±}{Οα΅} β ΞΉ π¦) SβSP {ΞΉ} (π¨ , (kA , Bβ€A )) = π¨ , (pA , Bβ€A) where pA : π¨ β P β ΞΉ π¦ pA = β€ , (Ξ» _ β π¨) , (Ξ» _ β kA) , β β¨ βΊ-refl PβSP : β{ΞΉ} β P β ΞΉ π¦ β S (a β β β ΞΉ) (P {Ξ² = Ξ±}{Οα΅}β ΞΉ π¦) PβSP {ΞΉ} x = S-expa{β = a β β β ΞΉ} x PβHSP : β{ΞΉ} β P {Ξ² = Ξ±}{Οα΅} β ΞΉ π¦ β H (a β β β ΞΉ) (S (a β β β ΞΉ) (P β ΞΉ π¦)) PβHSP {ΞΉ} x = H-expa{β = a β β β ΞΉ} (S-expa{β = a β β β ΞΉ} x) PβV : β{ΞΉ} β P β ΞΉ π¦ β V β ΞΉ π¦ PβV = PβHSP SPβV : β{ΞΉ} β S{Ξ² = Ξ±}{Οα΅ = Οα΅} (a β β β ΞΉ) (P {Ξ² = Ξ±}{Οα΅} β ΞΉ π¦) β V β ΞΉ π¦ SPβV {ΞΉ} x = H-expa{β = a β β β ΞΉ} x
Finally, we are in a position to prove that a product of subalgebras of algebras in a class π¦ is a subalgebra of a product of algebras in π¦.
PSβSP : P (a β β) oaβ (S{Ξ² = Ξ±}{Οα΅} β π¦) β S oaβ (P β oaβ π¦) PSβSP {π©} (I , ( π , sA , Bβ β¨ A )) = Goal where β¬ : I β Algebra {π = π} Ξ± Οα΅ β¬ i = sA i .projβ kB : (i : I) β β¬ i β π¦ kB i = sA i .projβ .projβ β¨ Aβ€β¨ B : β¨ π β€ β¨ β¬ β¨ Aβ€β¨ B = β¨ -β€ Ξ» i β projβ (projβ (sA i)) Goal : π© β S{Ξ² = oaβ}{oaβ}oaβ (P {Ξ² = oaβ}{oaβ} β oaβ π¦) Goal = β¨ β¬ , (I , (β¬ , (kB , β -refl))) , (β -trans-β€ Bβ β¨ A β¨ Aβ€β¨ B)
H preserves identities¶
First we prove that the closure operator H is compatible with identities that hold in the given class.
module _ {Ξ± Οα΅ β Ο : Level} {π¦ : Pred(Algebra {π = π} Ξ± Οα΅) (Ξ± β Οα΅ β ov {π = π} β)} {X : Type Ο} {p q : Term {π = π} X} where H-id1 : π¦ β« (p βΜ q) β H {Ξ² = Ξ±}{Οα΅}β π¦ β« (p βΜ q) H-id1 Ο .β«-proof π© (π¨ , kA , BimgA) = β§-H-invar{p = p}{q} (Ο .β«-proof π¨ kA) BimgA
The converse of the foregoing result is almost too obvious to bother with. Nonetheless, we formalize it for completeness.
H-id2 : H β π¦ β« (p βΜ q) β π¦ β« (p βΜ q) H-id2 Hpq .β«-proof π¨ kA = Hpq .β«-proof π¨ (π¨ , (kA , IdHomImage))
S preserves identities¶
Identities are inherited by subalgebras, so a class and its subalgebra closure
satisfy the same equations. S-id1 is the substantive direction
and is immediate from β§-S-invar of
Setoid.Varieties.Properties: an identity true in π¨ is true in anything
embedded in π¨. S-id2 is the converse, and holds for the same
reason H-id2 above does, namely that S is
expansive: π¦ β S β π¦ by β€-reflexive, so an identity holding
throughout the closure holds in particular on π¦.
S-id1 : π¦ β« (p βΜ q) β (S {Ξ² = Ξ±}{Οα΅} β π¦) β« (p βΜ q) S-id1 Ο .β«-proof π© (π¨ , kA , Bβ€A) = β§-S-invar{p = p}{q} (Ο .β«-proof π¨ kA) Bβ€A S-id2 : S β π¦ β« (p βΜ q) β π¦ β« (p βΜ q) S-id2 Spq .β«-proof π¨ kA = Spq .β«-proof π¨ (π¨ , (kA , β€-reflexive))
P preserves identities¶
The same for products, with one extra step. P-id1 combines
β§-P-invar, that a product of models is a model, with
β§-I-invar, that satisfaction transports across an isomorphism.
The second is needed because membership in P β ΞΉ π¦ holds only up to
isomorphism: an inhabitant supplies a family π together with a proof
π¨ β
β¨
π, not an equality. P-id2 is once more the
expansiveness converse, this time by way of P-expa.
P-id1 : β{ΞΉ} β π¦ β« (p βΜ q) β P {Ξ² = Ξ±}{Οα΅}β ΞΉ π¦ β« (p βΜ q) P-id1 Ο .β«-proof π¨ (I , π , kA , Aβ β¨ A) = β§-I-invar π¨ p q IH (β -sym Aβ β¨ A) where ih : β i β π i β§ (p βΜ q) ih i = Ο .β«-proof (π i) (kA i) IH : β¨ π β§ (p βΜ q) IH = β§-P-invar {p = p}{q} π ih P-id2 : β{ΞΉ} β P β ΞΉ π¦ β« (p βΜ q) β π¦ β« (p βΜ q) P-id2{ΞΉ} PKpq .β«-proof π¨ kA = PKpq .β«-proof π¨ (P-expa {β = β}{ΞΉ} kA)
V preserves identities¶
Finally, we prove the analogous preservation lemmas for the closure operator V.
module _ {Ξ± Οα΅ β ΞΉ Ο : Level} {π¦ : Pred(Algebra {π = π} Ξ± Οα΅) (Ξ± β Οα΅ β ov {π = π} β)} {X : Type Ο} {p q : Term {π = π} X} where private aβΞΉ = Ξ± β Οα΅ β β β ΞΉ V-id1 : π¦ β« (p βΜ q) β V β ΞΉ π¦ β« (p βΜ q) V-id1 Ο .β«-proof π© (π¨ , (β¨ A , pβ¨ A , Aβ€β¨ A) , BimgA) = H-id1{β = aβΞΉ}{π¦ = S aβΞΉ (P {Ξ² = Ξ±}{Οα΅}β ΞΉ π¦)} spKβ§pq .β«-proof π© (π¨ , (spA , BimgA)) where spA : π¨ β S aβΞΉ (P {Ξ² = Ξ±}{Οα΅}β ΞΉ π¦) spA = β¨ A , (pβ¨ A , Aβ€β¨ A) spKβ§pq : S aβΞΉ (P β ΞΉ π¦) β« (p βΜ q) spKβ§pq = S-id1{β = aβΞΉ} (P-id1{β = β} {π¦ = π¦} Ο) V-id2 : V β ΞΉ π¦ β« (p βΜ q) β π¦ β« (p βΜ q) V-id2 Vpq .β«-proof π¨ kA = Vpq .β«-proof π¨ (V-expa β ΞΉ kA) Lift-id1 : β{Ξ² Οα΅} β π¦ β« (p βΜ q) β Level-closure{Ξ±}{Οα΅}{Ξ²}{Οα΅} β π¦ β« (p βΜ q) Lift-id1 pKq .β«-proof π¨ (π© , kB , Bβ A) Ο = Goal where open Environment π¨ open Setoid (Domain π¨) using (_β_) Goal : β¦ p β§ β¨$β© Ο β β¦ q β§ β¨$β© Ο Goal = β§-I-invar π¨ p q (pKq .β«-proof π© kB) Bβ A Ο
Class identities¶
From V-id1 it follows that if π¦ is a class of structures, then the set of identities
modeled by all structures in π¦ is equivalent to the set of identities modeled by all
structures in V π¦. In other terms, Th (V π¦) is precisely the set of identities
modeled by π¦. We formalize this observation as follows.
classIds-β-VIds : π¦ β« (p βΜ q) β (p , q) β Th (V β ΞΉ π¦) classIds-β-VIds pKq = V-id1 pKq VIds-β-classIds : (p , q) β Th (V β ΞΉ π¦) β π¦ β« (p βΜ q) VIds-β-classIds Thpq = V-id2 Thpq