Overture.Terms.Translation¶
Translating terms along a signature morphism¶
This is the Overture.Terms.Translation module of the Agda Universal Algebra Library.
A signature morphism Ο : SigMorphism πβ πβ (Overture.Signatures.Morphisms)
relabels operation symbols (ΞΉ Ο, covariantly) and reindexes argument positions
(ΞΊ Ο, contravariantly). This module extends that relabelling from single symbols
to whole terms: the translation Ο βΆ t rewrites an πβ-term t into an
πβ-term over the same variables, leaf by leaf and node by node.
The definition is exactly the structural recursion one would guess, and it is worth
reading the node clause slowly because the contravariance of ΞΊ is where all the
content lives. A node node f ts of an πβ-term carries one subterm ts i for
each position i : ArityOf πβ f. Its translation is a node labelled ΞΉ Ο f, which
must carry one subterm for each position j : ArityOf πβ (ΞΉ Ο f) β a position of
the target symbol. The position map ΞΊ Ο f converts such a j back into a
source position ΞΊ Ο f j, and the translated subterm at j is the translation of
ts (ΞΊ Ο f j):
πβ-term: node f ts with subterms ts i , i : ArityOf πβ f
β
β Ο βΆ_
β
πβ-term: node (ΞΉ Ο f) tsβ² with subterms tsβ² j = Ο βΆ ts (ΞΊ Ο f j) , j : ArityOf πβ (ΞΉ Ο f)
In the typical case of a signature inclusion β ΞΉ injective, each ΞΊ Ο f the
identity, as in Sig-Magma βͺ Sig-Monoid β the translation simply re-reads a magma
term such as (x β y) β z as the same expression in the monoid signature. That
"same expression, richer signature" reading is what makes the translation the
syntactic half of the reduct: reduct Ο moves algebras from πβ to πβ
(Setoid.Algebras.Reduct), Ο βΆ_ moves terms from πβ to πβ, and the
two are adjoint in the logical sense that satisfaction is invariant β
reduct Ο π¨ β§ s β t iff π¨ β§ Ο βΆ s β Ο βΆ t (Setoid.Varieties.Invariance).
In the vocabulary of M4-5b, Ο βΆ_ is the unique extension of the natural
transformation β¦ Ο β§ : β¨ πβ β© βΉ β¨ πβ β© from single applications to free
P_{πβ}-algebras; in monad vocabulary it is a morphism of term monads, a fact
recorded (up to _β_) in Setoid.Terms.Translation.
Like Term itself, the translation presupposes only the signatures β no setoid, no
equality on any carrier β so it lives in Overture/. Its laws (functoriality in
Ο, congruence, and the substitution square) require the equality-of-terms relation
_β_ and are therefore stated in Setoid.Terms.Translation, mirroring the
Overture.Terms / Setoid.Terms.Basic split. M4-5f will generalize precisely this
definition: a theory interpretation sends operation symbols to derived operations
(terms) rather than to symbols, and its action on terms replaces the node clause's
relabelling by substitution into the chosen derived term.
The translation¶
The two signatures are instantiated by module application; Termβ X and
Termβ X are the term types over the same variable type X.1
module _ {πβ πβ : Signature π π₯} where open Terms {π = πβ} using () renaming (β to ββ; node to nodeβ; Term to Termβ) open Terms {π = πβ} using () renaming (β to ββ; node to nodeβ; Term to Termβ) infix 15 _βΆ_ _βΆ_ : SigMorphism πβ πβ β Termβ X β Termβ X Ο βΆ ββ x = ββ x Ο βΆ nodeβ f ts = nodeβ (ΞΉ Ο f) (Ξ» j β Ο βΆ ts (ΞΊ Ο f j))
Variables are fixed points of the translation (Ο βΆ β x is β x, definitionally),
which is what lets environments transfer across it unchanged: interpreting Ο βΆ t
needs values for exactly the variables that interpreting t needs. The
reduct-invariance theorem leans on this directly.
-
Unicode tip. Type
\stand selectβΆto get the star. ↩