Overture.Terms.Basic¶
Terms over a signature¶
A Term X is a finite tree whose leaves are drawn from a type X of variable
symbols and whose internal nodes are labelled by operation symbols of the signature
š. Equivalently, Term is the W-type for the polynomial functor associated to
š, freely adjoined a copy of X at the leaves.
This definition presupposes only the signature: no propositional equality on a
carrier, no setoid equivalence, no path type. It is therefore foundational rather
than setoid-specific, which is why it lives in Overture/ rather than under
Setoid/, Classical/, or Cubical/. The Setoid term algebra š» X (which equips
Term X with an inductive equivalence-of-terms relation _ā_) is built on top of
this definition in Setoid.Terms.Basic; the planned Cubical analog will sit
similarly.1
The level shorthand ov¶
Throughout the library we package the universe levels of operation symbols (š),
arities (š„), and a separate "carrier-or-variable" level (Ļ) into a single
shorthand ov Ļ = š ā š„ ā suc Ļ. The suc is unavoidable because Term X mixes
leaves of type X : Type Ļ with operation symbols of type Type š, so the resulting
tree type sits one universe up.
This shorthand currently appears with the same definition in
Legacy.Base.Algebras.Basic and Setoid.Algebras.Basic; the three definitions are
definitionally equal.2
ov : Level ā Level ov Ļ = š ā š„ ā suc Ļ
The type of terms¶
Fix a signature š and let X denote an arbitrary collection of variable symbols,
assumed disjoint from the operation symbols of š
(i.e. X ā© OperationSymbolsOf š = ā
).
By a word in the language of š, we mean a nonempty finite sequence of members of
X āŖ OperationSymbolsOf š; we denote concatenation of such sequences by simple
juxtaposition.
Let Sā denote the set of nullary operation symbols of š. We define the sets šā
of words over X āŖ OperationSymbolsOf š by induction on n
(cf. Bergman (2012) Def. 4.19):
šā := X āŖ Sā and šāāā := šā āŖ šÆā
- where
šÆāis the collection of allf tsuch thatf : OperationSymbolsOf šand `t - ArityOf š f ā šā
(recallArityOf š fis the arity off). The collection of *terms* in the signaturešoverXis thenTerm X := āā šā. By an š-*term* we mean a term in the language ofš`.
The definition of Term X is recursive, indicating that an inductive type suffices
to represent the notion in type theory. Such a representation is given by the
inductive type below, which encodes each term as a tree with an operation symbol at
each node and a variable symbol (the generator) at each leaf.
data Term (X : Type Ļ) : Type (ov Ļ) where ā : X ā Term X -- ā is for "generator" node : (f : OperationSymbolsOf š)(t : ArityOf š f ā Term X) ā Term X open Term public
Notation. The type X represents an arbitrary collection of variable symbols;
ov Ļ is the universe-level shorthand defined above.
The bare-types term algebra š» : (X : Type Ļ) ā Algebra (ov Ļ), which equips Term
X with node as its interpretation, is not relocated here: it depends on the
foundation-specific Algebra type, which differs between the bare-types tree
(Legacy.Base.Algebras.Algebra) and the canonical Setoid tree
(Setoid.Algebras.Basic.Algebra). The legacy š» continues to live in
Legacy.Base.Terms.Basic; the Setoid term algebra continues to live in
Setoid.Terms.Basic.
-
This module is a Category-A relocation under #303 (M2-6). See
src/Legacy/Base/DEPRECATED.mdfor the full inventory. ↩ -
Hoisting
ovtoOverture.Signaturesand removing the duplicates is a small candidate cleanup tracked separately from #303. ↩