---
layout: default
file: "src/Overture/Terms/Interpretation.lagda.md"
title: "Overture.Terms.Interpretation module"
date: "2026-06-15"
author: "the agda-algebras development team"
---
### Theory interpretations: sending operation symbols to derived terms
This is the [Overture.Terms.Interpretation][] module of the [Agda Universal Algebra Library][].
A signature morphism `Ο : SigMorphism πβ πβ` ([Overture.Signatures.Morphisms][])
relabels each operation symbol of `πβ` to an operation symbol of `πβ`.
A *theory interpretation* generalizes this one decisive step: it sends each
operation symbol `o` of `πβ` to a *term* of `πβ` β a *derived operation* of `πβ`, an
`πβ`-term in the argument positions `ArityOf πβ o` of `o`.
This is the term-valued generalization of a signature morphism, and it is exactly the
data with which universal algebra defines one variety's operations inside another
(GarciaβTaylor's "definitions"[^1]): a Maltsev term, a majority term, or a
near-unanimity term is such an assignment of one fresh symbol to a derived term.
signature morphism Ο : o β¦ ΞΉ Ο o (one symbol)
interpretation I : o β¦ (an πβ-term over ArityOf πβ o) (a derived operation)
Like the signature-morphism translation `Ο βΆ_` ([Overture.Terms.Translation][]), an
interpretation acts on whole terms: `I β¦ t` rewrites an `πβ`-term `t` into an
`πβ`-term over the same variables. The leaf clause fixes variables; the node clause
is where the generalization lives β where `Ο βΆ_` *relabels* the node `node f ts` to
`node (ΞΉ Ο f) β¦`, the interpretation *substitutes* the translated subterms into the
chosen derived term `I f`.
Substitution into a term β grafting one tree onto the leaves of another β is the
operation we call `graft`{.AgdaFunction} below; it is the term monad's bind, stated
at heterogeneous variable levels (the positions `ArityOf πβ f` live at level `π₯`, the
term's variables at an arbitrary level `Ο`), which the level-homogeneous
`Sub`{.AgdaFunction} / `_[_]`{.AgdaFunction} of [Setoid.Terms.Basic][] cannot
express.
Everything here presupposes only the signatures β no setoid, no equality on any
carrier β so it lives in `Overture/`, exactly as `Term`{.AgdaDatatype} and `Ο βΆ_` do.
The laws of `_β¦_`{.AgdaFunction} (congruence, functoriality, the substitution square)
compare functions on positions and so require the equality-of-terms relation `_β_`;
they are proved in [Setoid.Terms.Interpretation][]. The *equation-preserving* half
of a theory interpretation β that it carries one theory's laws into another's β needs
satisfaction and lives in [Setoid.Varieties.Interpretation][], the analogue of
[Setoid.Varieties.Invariance][] for `reduct`.
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
module Overture.Terms.Interpretation where
open import Agda.Primitive using () renaming ( Set to Type )
open import Level using ( Level ; suc ; _β_ )
open import Function using ( _β_ )
open import Overture.Signatures using ( π ; π₯ ; Signature
; OperationSymbolsOf ; ArityOf )
open import Overture.Signatures.Morphisms using ( SigMorphism ; ΞΉ ; ΞΊ )
open import Overture.Terms.Basic using ( Term ; β ; node )
private variable
Ο ΞΎ : Level
X : Type Ο
Y : Type ΞΎ
π πβ πβ πβ : Signature π π₯
```
-->
#### Interpretations
An `Interpretation πβ πβ` assigns to each operation symbol `o` in `πβ` an `πβ`-term
over argument positions `ArityOf πβ o`. Reading position `i : ArityOf πβ o` as the
variable "the `i`-th argument of `o`", the assigned term `I o` is the recipe for
computing `o` from its arguments using only `πβ`-operations.
```agda
Interpretation : (πβ πβ : Signature π π₯) β Type (π β suc π₯)
Interpretation πβ πβ = (o : OperationSymbolsOf πβ) β Term {π = πβ} (ArityOf πβ o)
```
#### Grafting: substitution at heterogeneous levels
Given a term `t` and a map `Ο : Y β Term {π = π} X`, the application `graft t Ο`
replaces each leaf `β y` of the term `t` by the term `Ο y`, recursing through nodes
(the term monad's bind). This is `_[_]`{.AgdaFunction} of [Setoid.Terms.Basic][],
but stated for variable types `Y` and `X` at independent universe levels, which is
what the interpretation action below needs: it grafts an `πβ`-term over the positions
`ArityOf πβ f` (level `π₯`) into one over the term's own variables.
```agda
graft : Term {π = π} Y β (Y β Term {π = π} X) β Term {π = π} X
graft (β y) Ο = Ο y
graft (node f ts) Ο = node f (Ξ» i β graft (ts i) Ο)
```
#### The interpretation action on terms
Given an `πβ`-`πβ`-interpretation `I`, and an `πβ`-term `t`, `I β¦ t` translates `t`
to an `πβ`-term over the same variables.[^2]
Variables are fixed points (`I β¦ β x` is `β x`, definitionally), so environments
transfer across the action unchanged. At a node, the subterms are translated and then
grafted into the chosen derived term `I f`.
```agda
infix 15 _β¦_
_β¦_ : Interpretation πβ πβ β Term {π = πβ} X β Term {π = πβ} X
I β¦ β x = β x
I β¦ node f ts = graft (I f) (Ξ» i β I β¦ ts i)
```
#### Identity, composition, and the embedding of signature morphisms
Interpretations are the morphisms of a category whose objects are signatures β the
*clone category* of algebraic theories. The identity interpretation sends each symbol
to itself, applied to its own argument variables; composition runs an interpretation's
derived terms through a second interpretation. (That these satisfy the category laws β
`I β¦_` is functorial in `I` β is the content of `β¦-id`{.AgdaFunction} and
`β¦-β`{.AgdaFunction} in [Setoid.Terms.Interpretation][].)
```agda
idα΄΅ : Interpretation π π
idα΄΅ o = node o β
infixr 9 _βα΄΅_
_βα΄΅_ : Interpretation πβ πβ β Interpretation πβ πβ β Interpretation πβ πβ
(J βα΄΅ I) o = J β¦ I o
```
Every signature morphism is an interpretation: send `o` to the single-application
derived term `node (ΞΉ Ο o) (Ξ» j β β (ΞΊ Ο o j))` β apply the relabelled symbol `ΞΉ Ο o`
to its arguments, reindexed back through `ΞΊ Ο o`. This is the inclusion of `Sig`
([Overture.Signatures.Morphisms][]) into the clone category, and `β¦-β¨β©`{.AgdaFunction}
([Setoid.Terms.Interpretation][]) checks that the embedded interpretation acts on terms
exactly as `Ο βΆ_` does, so theory interpretations strictly generalize signature
morphisms.
```agda
β¨_β©α΄΅ : SigMorphism πβ πβ β Interpretation πβ πβ
β¨ Ο β©α΄΅ o = node (ΞΉ Ο o) (β β (ΞΊ Ο o))
```
--------------------------------------
[^1]: W. D. Neumann; O. C. GarcΓa and W. Taylor, *The Lattice of Interpretability Types of Varieties*, Mem. Amer. Math. Soc. **50** (1984), no. 305.
[^2]: **Unicode tip**. Type `\st` and select `β¦` to get the four-pointed star; it is the `_βΆ_` of [Overture.Terms.Translation][] "thickened", since `_β¦_` generalizes `_βΆ_` from one application to an arbitrary derived term.