2.1.8: Substitution
We define \(\Subst{s}{t}{x}\) , the result of substituting \(t\) for every occurrence of \(x\) in \(s\) , recursively:
- \(\indcase{s}{c}\) \(\Subst{s}{t}{x}\) is just \(s\) .
- \(\indcase{s}{y}\) \(\Subst{s}{t}{x}\) is also just \(s\) , provided \(y\) is a variable and \(y \not\ident x\) .
- \(\indcase{s}{x}\) \(\Subst{s}{t}{x}\) is \(t\) .
- \(\indcase{s}{\Atom{f}{t_1, \dots, t_n}}\) \(\Subst{s}{t}{x}\) is \(\Atom{f}{\Subst{t_1}{t}{x}, \dots, \Subst{t_n}{t}{x}}\) .
A term \(t\) is free for \(x\) in \(A\) if none of the free occurrences of \(x\) in \(A\) occur in the scope of a quantifier that binds a variable in \(t\) .
- \(\Obj v_8\) is free for \(\Obj v_1\) in \(\lexists{\Obj v_3}{}\Atom{\Obj A^2_4}{\Obj v_3,\Obj v_1}\)
- \(\Obj f^2_1(\Obj v_1, \Obj v_2)\) is not free for \(\Obj v_0\) in \(\lforall{\Obj v_2}{}\Atom{\Obj A^2_4}{\Obj v_0,\Obj v_2}\)
If \(A\) is a formula, \(x\) is a variable, and \(t\) is a term free for \(x\) in \(A\) , then \(\Subst{A}{t}{x}\) is the result of substituting \(t\) for all free occurrences of \(x\) in \(A\) .
- \(\indcase{A}{\lfalse}\) \(\Subst{\indfrm}{t}{x}\) is \(\lfalse\) .
- \(\indcase{A}{\Atom{P}{t_1,\dots, t_n}}\) \(\Subst{\indfrm}{t}{x}\) is \(\Atom{P}{\Subst{t_1}{t}{x}, \dots, \Subst{t_n}{t}{x}}\) .
- \(\indcase{A}{\eq[t_1][t_2]}\) \(\Subst{\indfrmp}{t}{x}\) is \(\Subst{t_1}{t}{x} = \Subst{t_2}{t}{x}\) .
- \(\indcase{A}{\lnot B}\) \(\Subst{\indfrmp}{t}{x}\) is \(\lnot \Subst{B}{t}{x}\) .
- \(\indcase{A}{(B \land C)}\) \(\Subst{\indfrmp}{t}{x}\) is \((\Subst{B}{t}{x} \land \Subst{C}{t}{x})\) .
- \(\indcase{A}{(B \lor C)}\) \(\Subst{\indfrmp}{t}{x}\) is \((\Subst{B}{t}{x} \lor \Subst{C}{t}{x})\) .
- \(\indcase{A}{(B \lif C)}\) \(\Subst{\indfrmp}{t}{x}\) is \((\Subst{B}{t}{x} \lif \Subst{C}{t}{x})\) .
- \(\indcase{A}{\lforall{y}{B}}\) \(\Subst{\indfrmp}{t}{x}\) is \(\lforall{y}{\Subst{B}{t}{x}}\) , provided \(y\) is a variable other than \(x\) ; otherwise \(\Subst{\indfrmp}{t}{x}\) is just \(\indfrm\) .
- \(\indcase{A}{\lexists{y}{B}}\) \(\Subst{\indfrmp}{t}{x}\) is \(\lexists{y}{\Subst{B}{t}{x}}\) , provided \(y\) is a variable other than \(x\) ; otherwise \(\Subst{\indfrmp}{t}{x}\) is just \(\indfrm\) .
Note that substitution may be vacuous: If \(x\) does not occur in \(A\) at all, then \(\Subst{A}{t}{x}\) is just \(A\) .
The restriction that \(t\) must be free for \(x\) in \(A\) is necessary to exclude cases like the following. If \(A \ident \lexists{y}{x < y}\) and \(t \ident y\) , then \(\Subst{A}{t}{x}\) would be \(\lexists{y}{y < y}\) . In this case the free variable \(y\) is “captured” by the quantifier \(\lexists{y}{}\) upon substitution, and that is undesirable. For instance, we would like it to be the case that whenever \(\lforall{x}{B}\) holds, so does \(\Subst{B}{t}{x}\) . But consider \(\lforall{x}{\lexists{y}{x < y}}\) (here \(B\) is \(\lexists{y}{x < y}\) ). It is sentence that is true about, e.g., the natural numbers: for every number \(x\) there is a number \(y\) greater than it. If we allowed \(y\) as a possible substitution for \(x\) , we would end up with \(\Subst{B}{y}{x} \ident \lexists{y}{y < y}\) , which is false. We prevent this by requiring that none of the free variables in \(t\) would end up being bound by a quantifier in \(A\) .
We often use the following convention to avoid cumbersume notation: If \(A\) is a formula with a free variable \(x\) , we write \(A(x)\) to indicate this. When it is clear which \(A\) and \(x\) we have in mind, and \(t\) is a term (assumed to be free for \(x\) in \(A(x)\) ), then we write \(A(t)\) as short for \(\Subst{A(x)}{t}{x}\) .