In
first-order logic, a
substitution is a total mapping from
variables to
terms; many, authors additionally require
σ(
x) =
x for all but finitely many variables
x. The notation refers to a substitution mapping each variable
xi to the corresponding term
ti, for
i=1,…,
k, and every other variable to itself; the
xi must be pairwise distinct. Most authors additionally require each term
ti to be syntactically different from
xi, to avoid infinitely many distinct notations for the same substitution.
Applying that substitution to a term
t is written in
postfix notation as
t ; it means to (simultaneously) replace every occurrence of each
xi in
t by
ti. The result
tσ of applying a substitution
σ to a term
t is called an
instance of that term
t. For example, applying the substitution to the term : The
domain dom(
σ) of a substitution
σ is commonly defined as the set of variables actually replaced, i.e.
dom(
σ) = . A substitution is called a
ground substitution if it maps all variables of its domain to
ground, i.e. variable-free, terms. The substitution instance
tσ of a ground substitution is a ground term if all of
ts variables are in
σs domain, i.e. if
vars(
t) ⊆
dom(
σ). A substitution
σ is called a
linear substitution if
tσ is a
linear term for some (and hence every) linear term
t containing precisely the variables of
σs domain, i.e. with
vars(
t) =
dom(
σ). A substitution
σ is called a
flat substitution if
xσ is a variable for every variable
x. A substitution
σ is called a
renaming substitution if it is a
permutation on the set of all variables. Like every permutation, a renaming substitution σ always has an
inverse substitution
σ−1, such that
tσσ−1 =
t =
tσ−1
σ for every term
t. However, it is not possible to define an inverse for an arbitrary substitution. For example, is a ground substitution, is non-ground and non-flat, but linear, is non-linear and non-flat, is flat, but non-linear, is both linear and flat, but not a renaming, since it maps both
y and
y2 to
y2; each of these substitutions has the set as its domain. An example for a renaming substitution is , it has the inverse . The flat substitution cannot have an inverse, since e.g. (
x+
y) =
z+
z, and the latter term cannot be transformed back to
x+
y, as the information about the origin a
z stems from is lost. The ground substitution cannot have an inverse due to a similar loss of origin information e.g. in (
x+2) = 2+2, even if replacing constants by variables was allowed by some fictitious kind of "generalized substitutions". Two substitutions are considered
equal if they map each variable to
syntactically equal result terms, formally:
σ =
τ if
xσ =
xτ for each variable
x ∈
V. The
composition of two substitutions
σ = and
τ = is obtained by removing from the substitution those pairs
yi ↦
ui for which
yi ∈ . The composition of
σ and
τ is denoted by
στ. Composition is an
associative operation, and is compatible with substitution application, i.e. (
ρσ)
τ =
ρ(
στ), and (
tσ)
τ =
t(
στ), respectively, for every substitutions
ρ,
σ,
τ, and every term
t. The
identity substitution, which maps every variable to itself, is the
neutral element of substitution composition. A substitution
σ is called
idempotent if
σσ =
σ, and hence
tσσ =
tσ for every term
t. When
xi≠
ti for all
i, the substitution is idempotent if and only if none of the variables
xi occurs in any
tj. Substitution composition is not commutative, that is,
στ may be different from
τσ, even if
σ and
τ are idempotent. For example, is equal to , but different from . The substitution is idempotent, e.g. ((
x+
y) ) = ((
y+
y)+
y) = (
y+
y)+
y, while the substitution is non-idempotent, e.g. ((
x+
y) ) = ((
x+
y)+
y) = ((
x+
y)+
y)+
y. An example for non-commuting substitutions is = , but = . ==Mathematics==