Setoid.Terms.Operations¶
Term Operations for Setoid Algebras¶
This section presents the Setoid.Terms.Operations module of the Agda Universal Algebra Library.
Here we define term operations which are simply terms interpreted in a particular algebra, and we prove some compatibility properties of term operations.
It turns out that the intepretation of a term is the same as the free-lift
(modulo argument order and assuming function extensionality).
module _ {π¨ : Algebra Ξ± Οα΅} where open Algebra π¨ using ( Interp ) renaming (Domain to A ) open Setoid A using ( _β_ ; refl ) renaming ( Carrier to β£Aβ£ ) open Environment π¨ using ( β¦_β§ ) free-lift-interp : (Ξ· : X β β£Aβ£)(p : Term X) β β¦ p β§ β¨$β© Ξ· β (free-lift{π¨ = π¨} Ξ·) p free-lift-interp Ξ· (β x) = refl free-lift-interp Ξ· (node f t) = cong Interp (β‘.refl , (free-lift-interp Ξ·) β t) module _ {X : Type Ο} where open Algebra (π» X) using ( Interp ) renaming (Domain to TX ) open Setoid TX using ( _β_ ; refl ) open Environment (π» X) using ( β¦_β§ ; ββEqual ) open SetoidReasoning TX term-interp : (f : OperationSymbolsOf π){s t : ArityOf π f β Term X} β (β i β s i β t i) β β Ξ· β β¦ node f s β§ β¨$β© Ξ· β β¦ node f t β§ β¨$β© Ξ· term-interp f {s}{t} st Ξ· = cong Interp (β‘.refl , Ξ» i β ββEqual (s i) (t i) (st i) Ξ· ) term-agreement : (p : Term X) β p β β¦ p β§ β¨$β© β term-agreement (β x) = refl term-agreement (node f t) = cong Interp (β‘.refl , (Ξ» i β term-agreement (t i)))
Interpretation of terms in product algebras¶
module _ {X : Type Ο }{I : Type ΞΉ}(π : I β Algebra Ξ± Οα΅) where open Algebra (β¨ π) using (Interp) renaming ( Domain to β¨ A ) open Setoid β¨ A using ( _β_ ; refl ) open Environment (β¨ π) using () renaming ( β¦_β§ to β¦_β§β ) open Environment using ( β¦_β§ ; ββEqual ) interp-prod : (p : Term X) β β Ο β β¦ p β§β β¨$β© Ο β Ξ» i β (β¦ π i β§ p) β¨$β© Ξ» x β (Ο x) i interp-prod (β x) = Ξ» Ο i β ββEqual (π i) (β x) (β x) β-isRefl Ξ» x' β (Ο x) i interp-prod (node f t) = Ξ» Ο i β cong Interp (β‘.refl , (Ξ» j k β interp-prod (t j) Ο k)) i
Compatibility of terms¶
We now prove two important facts about term operations. The first of these, which is used very often in the sequel, asserts that every term commutes with every homomorphism.
module _ {π¨ : Algebra Ξ± Οα΅}{π© : Algebra Ξ² Οα΅}(hh : hom π¨ π©) where open Algebra π¨ using () renaming (Domain to A ) open Setoid A using () renaming ( Carrier to β£Aβ£ ) open Algebra π© using () renaming (Domain to B ; Interp to Interpβ ) open Setoid B using ( _β_ ; refl ) open Environment π¨ using () renaming ( β¦_β§ to β¦_β§β ) open Environment π© using () renaming ( β¦_β§ to β¦_β§β ) open SetoidReasoning B open IsHom private h : A βΆ B h = projβ hh comm-hom-term : (t : Term X) (a : X β β£Aβ£) β h β¨$β© (β¦ t β§β β¨$β© a) β β¦ t β§β β¨$β© Ξ» i β h β¨$β© a i comm-hom-term (β x) a = refl comm-hom-term (node f t) a = goal where goal : h β¨$β© (β¦ node f t β§β β¨$β© a) β β¦ node f t β§β β¨$β© Ξ» i β h β¨$β© a i goal = begin h β¨$β© (β¦ node f t β§β β¨$β© a) ββ¨ compatible (projβ hh) β© (f ^ π©)(Ξ» i β h β¨$β© (β¦ t i β§β β¨$β© a)) ββ¨ cong Interpβ (β‘.refl , Ξ» i β comm-hom-term (t i) a) β© (f ^ π©)(Ξ» i β β¦ t i β§β β¨$β© Ξ» j β h β¨$β© a j) ββ¨ refl β© β¦ node f t β§β β¨$β© (Ξ» j β h β¨$β© a j) β
Substitution¶
A substitution from Y to X is simply a function from Y to X, and the
application of a substitution is represented as follows.
_[_]s : {Ο : Level}{X Y : Type Ο} β Term Y β (Y β X) β Term X (β y) [ Ο ]s = β (Ο y) (node f t) [ Ο ]s = node f Ξ» i β t i [ Ο ]s
Alternatively, we may want a substitution that replaces each variable symbol in Y,
not with an element of X, but with a term from Term X.
-- Substerm X Y, an inhabitant of which replaces each variable symbol in Y with a term from Term X. Substerm : (X Y : Type Ο) β Type (ov Ο) Substerm X Y = (y : Y) β Term X -- Application of a Substerm. _[_]t : {X Y : Type Ο } β Term Y β Substerm X Y β Term X (β y) [ Ο ]t = Ο y (node f t) [ Ο ]t = node f Ξ» z β (t z) [ Ο ]t