Asubstitution is asyntactic transformation onformal expressions.Toapply a substitution to anexpression means to consistently replace its variable, or placeholder, symbols with other expressions.[citation needed]
The resulting expression is called asubstitution instance, orinstance for short, of the original expression.
Whereψ andφ representformulas ofpropositional logic,ψ is asubstitution instance ofφif and only ifψ may be obtained fromφ by substituting formulas forpropositional variables inφ, replacing each occurrence of the same variable by an occurrence of the same formula. For example:
is a substitution instance of
That is,ψ can be obtained by replacing P and Q inφ with (R → S) and (T → S) respectively. Similarly:
is a substitution instance of:
sinceψ can be obtained by replacing each A inφ with (A ↔ A).
In somededuction systems for propositional logic, a new expression (aproposition) may be entered on a line of a derivation if it is a substitution instance of a previous line of the derivation.[1][failed verification] This is how new lines are introduced in someaxiomatic systems. In systems that userules of transformation, a rule may include the use of asubstitution instance for the purpose of introducing certain variables into a derivation.
A propositional formula is atautology if it is true under everyvaluation (orinterpretation) of its predicate symbols. If Φ is a tautology, and Θ is a substitution instance of Φ, then Θ is again a tautology. This fact implies the soundness of the deduction rule described in the previous section.
Infirst-order logic, asubstitution is a total mappingσ:V →T fromvariables toterms; many,[2]: 73 [3]: 445 but not all[4]: 250 authors additionally requireσ(x) =x for all but finitely many variablesx. The notation {x1 ↦ t1, …,xk ↦ tk }[note 1]refers to a substitution mapping each variablexi to the corresponding termti, fori=1,…,k, and every other variable to itself; thexi must be pairwise distinct. Most authors additionally require each termti to be syntactically different fromxi, to avoid infinitely many distinct notations for the same substitution.Applying that substitution to a termt is written inpostfix notation ast {x1 ↦ t1, ...,xk ↦ tk }; it means to (simultaneously) replace every occurrence of eachxi int byti.[note 2] The resulttσ of applying a substitutionσ to a termt is called aninstance of that termt.For example, applying the substitution {x ↦ z,z ↦ h(a,y) } to the term
| f( | z | ,a,g( | x | ),y) | yields |
| f( | h(a,y) | ,a,g( | z | ),y) | . |
Thedomaindom(σ) of a substitutionσ is commonly defined as the set of variables actually replaced, i.e.dom(σ) = {x ∈V |xσ ≠x }.A substitution is called aground substitution if it maps all variables of its domain toground, i.e. variable-free, terms.The substitution instancetσ of a ground substitution is a ground term if all oft's variables are inσ's domain, i.e. ifvars(t) ⊆dom(σ).A substitutionσ is called alinear substitution iftσ is alinear term for some (and hence every) linear termt containing precisely the variables ofσ's domain, i.e. withvars(t) =dom(σ).A substitutionσ is called aflat substitution ifxσ is a variable for every variablex.A substitutionσ is called arenaming substitution if it is apermutation on the set of all variables. Like every permutation, a renaming substitution σ always has aninverse substitutionσ−1, such thattσσ−1 =t =tσ−1σ for every termt. However, it is not possible to define an inverse for an arbitrary substitution.
For example, {x ↦ 2,y ↦ 3+4 } is a ground substitution, {x ↦ x1,y ↦ y2+4 } is non-ground and non-flat, but linear,{x ↦ y2,y ↦ y2+4 } is non-linear and non-flat, {x ↦ y2,y ↦ y2 } is flat, but non-linear, {x ↦ x1,y ↦ y2 } is both linear and flat, but not a renaming, since it maps bothy andy2 toy2; each of these substitutions has the set {x,y} as its domain. An example for a renaming substitution is {x ↦ x1,x1 ↦ y,y ↦ y2,y2 ↦ x }, it has the inverse {x ↦ y2,y2 ↦ y,y ↦ x1,x1 ↦ x }. The flat substitution {x ↦ z,y ↦ z } cannot have an inverse, since e.g. (x+y) {x ↦ z,y ↦ z } =z+z, and the latter term cannot be transformed back tox+y, as the information about the origin az stems from is lost. The ground substitution {x ↦ 2 } cannot have an inverse due to a similar loss of origin information e.g. in (x+2) {x ↦ 2 } = 2+2, even if replacing constants by variables was allowed by some fictitious kind of "generalized substitutions".
Two substitutions are consideredequal if they map each variable tosyntactically equal result terms, formally:σ =τ ifxσ =xτ for each variablex ∈V.Thecomposition of two substitutionsσ = {x1 ↦ t1, …,xk ↦ tk } andτ = {y1 ↦ u1, …,yl ↦ ul } is obtained by removing from the substitution {x1 ↦ t1τ, …,xk ↦ tkτ,y1 ↦ u1, …,yl ↦ ul } those pairsyi ↦ ui for whichyi ∈ {x1, …,xk }.The composition ofσ andτ is denoted byστ. Composition is anassociative operation, and is compatible with substitution application, i.e. (ρσ)τ =ρ(στ), and (tσ)τ =t(στ), respectively, for every substitutionsρ,σ,τ, and every termt.Theidentity substitution, which maps every variable to itself, is theneutral element of substitution composition. A substitutionσ is calledidempotent ifσσ =σ, and hencetσσ =tσ for every termt. Whenxi≠ti for alli, the substitution {x1 ↦ t1, …,xk ↦ tk } is idempotent if and only if none of the variablesxi occurs in anytj. Substitution composition is not commutative, that is,στ may be different fromτσ, even ifσ andτ are idempotent.[2]: 73–74 [3]: 445–446
For example, {x ↦ 2,y ↦ 3+4 } is equal to {y ↦ 3+4,x ↦ 2 }, but different from {x ↦ 2,y ↦ 7 }. The substitution {x ↦ y+y } is idempotent, e.g. ((x+y) {x↦y+y}) {x↦y+y} = ((y+y)+y) {x↦y+y} = (y+y)+y, while the substitution {x ↦ x+y } is non-idempotent, e.g. ((x+y) {x↦x+y}) {x↦x+y} = ((x+y)+y) {x↦x+y} = ((x+y)+y)+y. An example for non-commuting substitutions is {x ↦ y } {y ↦ z } = {x ↦ z,y ↦ z }, but {y ↦ z} {x ↦ y} = {x ↦ y,y ↦ z }.
Inmathematics, there are two common uses of substitution:substitution ofvariables forconstants (also calledassignment for that variable), and thesubstitution property ofequality,[5] also calledLeibniz's Law.[6]
Considering mathematics as aformal language, a variable is asymbol from analphabet, usually a letter likex,y, andz, which denotes a range of possiblevalues.[7] If a variable isfree in a givenexpression orformula, then it can be replaced with any of the values in its range.[8] Certain kinds of bound variables can be substituted too. For instance,parameters of an expression (like thecoefficients of apolynomial), or theargument of afunction. Moreover, variables beinguniversally quantified can be replaced with any of the values in its range, and the result will a truestatement. (This is calledUniversal instantiation)
For a non-formalized language, that is, in most mathematical texts outside ofmathematical logic, for an individual expression it is not always possible to identify which variables are free and bound. For example, in, depending on the context, the variable can be free and bound, or vice-versa, but they cannot both be free. Determining which value is assumed to be free depends on context andsemantics.
Thesubstitution property of equality, orLeibniz's Law (though the latter term is usually reserved forphilosophical contexts), generally states that, if two things are equal, then any property of one, must be a property of the other. It can be formally stated inlogical notation as:For every and, and anywell-formed formula (with a free variable x). For example: For allreal numbersa andb, ifa =b, thena ≥ 0 impliesb ≥ 0 (here, isx ≥ 0). This is a property which is most often used inalgebra, especially in solvingsystems of equations, but is applied in nearly every area of math that uses equality. This, taken together with thereflexive property of equality, forms theaxioms of equality in first-order logic.[9]
Substitution is related to, but not identical to,function composition; it is closely related toβ-reduction inlambda calculus. In contrast to these notions, however, the accent in algebra is on the preservation of algebraic structure by the substitution operation, the fact that substitution gives ahomomorphism for the structure at hand (in the case of polynomials, thering structure).[citation needed]
Substitution is a basic operation inalgebra, in particular incomputer algebra.[10][11]
A common case of substitution involvespolynomials, where substitution of a numerical value (or another expression) for the indeterminate of a univariate polynomial amounts to evaluating the polynomial at that value. Indeed, this operation occurs so frequently that the notation for polynomials is often adapted to it; instead of designating a polynomial by a name likeP, as one would do for other mathematical objects, one could define
so that substitution forX can be designated by replacement inside "P(X)", say
or
Substitution can also be applied to other kinds of formal objects built from symbols, for instance elements offree groups. In order for substitution to be defined, one needs an algebraic structure with an appropriateuniversal property, that asserts the existence of unique homomorphisms that send indeterminates to specific values; the substitution then amounts to finding the image of an element under such a homomorphism.
The following is a proof of the substitution property of equality in ZFC (as defined in first-order logic without equality), which is adapted fromIntroduction to Axiomatic Set Theory (1982) by Gaisi Takeuti and Wilson M. Zaring.[12]
Theorem—if, then, for any well-formed formula,.
SeeZermelo–Fraenkel set theory § Formal language for the definition of formulas in ZFC. Thedefinition is recursive, so a proof byinduction is used. In ZFC in first-order logic without equality, "set equality" is defined to mean that two sets have the same elements, written symbolically as "for all z, z is in x if and only if z is in y". Then, the Axiom of Extensionality asserts that if two sets have the same elements, then they belong to the same sets:
Definition—
Axiom—
Let, be metavariables for any variables or sets, such that
Case 1:
Assume, then, by the definition of equality,, thus
Case 2:
Assume, then by the axiom of extensionality,, thus
Let be meta variables for any formulas with the property that. Let, be metavariables for any variables or sets, such that, and let be a metavariable for any variable.
Case 1:
Since, then by symmetry of equality, therefore, by the induction hypothesis, therefore bycontraposition, thus
Case 2:
Since, then and, which implies, thus
Case 3:
Since, assume byway of contradiction that the result is false, that is is true but is false. Byexistential instantiation, let denote the value such that is true. Then is false by asumption, and therefore is false, which contradicts our induction hypothesis, and the result follows.
substitution.