In universal algebra and mathematical logic, a term algebra is a freely generated algebraic structure over a given signature.[1] [2] For example, in a signature consisting of a single binary operation, the term algebra over a set X of variables is exactly the free magma generated by X. Other synonyms for the notion include absolutely free algebra and anarchic algebra.[3]
From a category theory perspective, a term algebra is the initial object for the category of all X-generated algebras of the same signature, and this object, unique up to isomorphism, is called an initial algebra; it generates by homomorphic projection all algebras in the category.[4] [5]
A similar notion is that of a Herbrand universe in logic, usually used under this name in logic programming,[6] which is (absolutely freely) defined starting from the set of constants and function symbols in a set of clauses. That is, the Herbrand universe consists of all ground terms: terms that have no variables in them.
An atomic formula or atom is commonly defined as a predicate applied to a tuple of terms; a ground atom is then a predicate in which only ground terms appear. The Herbrand base is the set of all ground atoms that can be formed from predicate symbols in the original set of clauses and terms in its Herbrand universe.[7] [8] These two concepts are named after Jacques Herbrand.
Term algebras also play a role in the semantics of abstract data types, where an abstract data type declaration provides the signature of a multi-sorted algebraic structure and the term algebra is a concrete model of the abstract declaration.
A type
\tau
n
\taun
\tau
n
Let
\tau
X
X
\tau
T(X)
\tau
X
X
\tau
T(X)
X\cup\tau0\subseteqT(X)
X
T(X)
\tau0
n\geq1
f\in\taun
t1,...,tn\inT(X)
f(t1,...,tn)\inT(X)
n
t1,...,tn
n
f
The term algebra
l{T}(X)
\tau
X
\tau
l{T}(X)
l{T}(X)
T(X)
f
\tau0
fl{T(X)}
f
n\geq1
f
\tau
t1,...,tn
fl{T(X)}(t1,...,tn)
f(t1,...,tn)
A term algebra is called absolutely free because for any algebra
l{A}
\tau
g:X\tol{A}
g
g\ast:l{T}(X)\tol{A}
t\inl{T}(X)
g\ast(t)\inl{A}
t\inl{T}(X)
t\inX
g\ast(t)=g(t)
t=f\in\tau0
g\ast(t)=fl{A}
t=f(t1,...,tn)
f\in\taun
n\geq1
g\ast(t)=fl{A}(g
\ast(t | |
1), |
...,
\ast(t | |
g | |
n)) |
As an example type inspired from integer arithmetic can be defined by
\tau0=\{0,1\}
\tau1=\{\}
\tau2=\{+,*\}
\taui=\{\}
i>2
The best-known algebra of type
\tau
0
1
+
*
l{A}nat
For the example variable set
X=\{x,y\}
l{T}(X)
\tau
X
First, the set
T(X)
\tau
X
{\color{red}x}\inT(X)
x\inX
{\color{red}1}\inT(X)
1\in\tau0
{\color{red}+x1}\inT(X)
+
{\color{red}*+x1x}\inT(X)
*
T(X)
{\color{red}*+x1x}
(x+1)*x
x+(1*x)
{\color{red}+x*1x}
To give some counter-examples, we have e.g.
{\color{red}z}\not\inT(X)
z
{\color{red}3}\not\inT(X)
{\color{red}+1}\not\inT(X)
+
{\color{red}1}
Now that the term set
T(X)
l{T}(X)
\tau
X
T(X)
+l{T(X)}
p
q
{\color{red}+}pq
*l{T(X)}
p
q
{\color{red}*}pq
*l{T(X)}({\color{red}+x1},{\color{red}x})
{\color{red}*+x1x}
+l{T(X)}
*l{T(X)}
As an example for unique extendability of a homomorphism consider
g:X\tol{A}nat
g(x)=7
g(y)=3
g
T(X)
l{A}nat
\begin{array}{lll} &g*({\color{red}+x1})\\ =&g*({\color{red}x})+g*({\color{red}1})&sinceg*isahomomorphism\\ =&g({\color{red}x})+g*({\color{red}1})&sinceg*coincidesonXwithg\\ =&7+g*({\color{red}1})&bydefinitionofg\\ =&7+1&sinceg*isahomomorphism\\ =&8&accordingtothewell-knownarithmeticalrulesinl{A}nat\\ \end{array}
g*({\color{red}*+x1x})=...=8*g({\color{red}x})=...=56
See main article: Herbrand interpretation and Herbrand structure. The signature σ of a language is a triple <O, F, P> consisting of the alphabet of constants O, function symbols F, and predicates P. The Herbrand base[10] of a signature σ consists of all ground atoms of σ: of all formulas of the form R(t1, ..., tn), where t1, ..., tn are terms containing no variables (i.e. elements of the Herbrand universe) and R is an n-ary relation symbol (i.e. predicate). In the case of logic with equality, it also contains all equations of the form t1 = t2, where t1 and t2 contain no variables.
Term algebras can be shown decidable using quantifier elimination. The complexity of the decision problem is in NONELEMENTARY because binary constructors are injective and thus pairing functions.[11]