natural deduction metalanguage, practical foundations
type theory (dependent, intensional, observational type theory, homotopy type theory)
computational trinitarianism =
propositions as types +programs as proofs +relation type theory/category theory
Syntactic substitution of/for variables is one of the basic operations in formal mathematics, such as in formal logic and type theories, where it is part of the structural rules.
Substitution is usually defined as an operation on expressions (such strings of letters from an alphabet and representing terms, formulas, propositions, dependent types, etc.) containing variables.
Suppose that $P$ is an expression in the context of a variable $x \,\colon\, X$ of type, and that $t \colon X$ is an expression which has the same type as $x$. Then one denotes by
the result of substituting $t$ for all occurrences of $x$ in $P$.
For example, if $P$ is $x^2 + 2x y + 3$ and $t$ is $(y+z)$, then $P[t/x]$ is $(y+z)^2 + 2(y+z)y + 3$.
(substitution is a meta-operation on syntax) In this approach, substitution is an operation on syntax, not an element of syntax itself. In particular, the bracket notation $[t/x]$ is part of “meta-syntax”, not the syntax in question.
That is, the literal string of symbols “$P[t/x]$” is not itself an expression in the language under consideration, but denotes such an expression, in the same way that “$2+2$” is not literally an integer but denotes the numeral “$4$”.
Substitution for multiple variables does not, in general, commute. That is, the expressions
are not in general the same: The former substitutes $s$ for occurrences of $y$ in $t$, but not $t$ for occurrences of $x$ in $s$, while the latter has the opposite behavior. We also write
to denote the simultaneous substitution of $t$ for $x$ and $s$ for $y$, in which neither occurrences of $x$ in $s$ nor occurrences of $y$ in $t$ are substituted for; this is generally not the same as either iterated substitution.
If the language in question contains variable binders, then there is a subtlety to substitution: if $t$ contains free variables that are bound in $P$, then we cannot simply textually substitute $t$ for $x$ and obtain an expression with the desired meaning.
For instance, if $P$ is $\exists y (x + y = 1)$, and $t$ is the free variable $y$, then a literal interpretation of $P[t/x]$ would produce $\exists y (y + y = 1)$. But $P$ is true (universally in its free variables) if the variables have type $\mathbb{Z}$, while $\exists y (y + y = 1)$ is not. The free variable $y$ in $t$ has been “captured” by the binder $\exists y$ in $P$.
We say that $t$ is substitutable for $x$ in $P$ if performing a literal textual substitution as above would not result in undesired variable capture. If $t$ is not substitutable for $x$ in $P$, then we can always replace $P$ by an alpha-equivalent expression in which $t$ is substitutable for $x$. Since we often consider formulas only up to $\alpha$-equivalence anyway, one usually defines the notation “$P[t/x]$” to include an $\alpha$-conversion of $P$, if necessary, to make $t$ substitutable for $x$.
In computer implementations of type theories, however, the issue of variable binding and capture is one of the trickiest things to get right. Performing $\alpha$-conversions is difficult and tedious, and other solutions exist, such as using de Bruijn indices to represent bound variables.
A general property of type theories (and other formal mathematics) is that substitution is an admissible rule.
Roughly, this means that if $P$ is an expression of some type, then so is the result $P[t/x]$ of substitution (as long as $t$ and $x$ have the same type). This is generally not a rule “put into” the theory, but rather a property one proves about the theory; type theorists say that substitution is an admissible rule rather than a derivable rule?.
For instance, in the language of dependent type theory the following substitution rule (one of the structural rules) is an admissible rule:
Here “admissibility” means that if there exist derivations of $\Gamma \vdash (t:A)$ and $(x:A) \vdash P \;type$, then there also exists a derivation of $\Gamma \vdash P[t/x] \;type$. By contrast, saying that this is a derivable rule would mean that it can occur itself as part of a derivation, rather than being a meta-statement about derivations.
The substition rule is closely related to the cut rule, and admissibility of such rules is generally proven by cut elimination.
(alternative typesetting of substitution rule)
In view of Remark we may re-express the substitution rule (1) by using actual syntactic substitutions instead of the meta-instruction “[t/x]” to perform these, if only we make explicit the variable dependency of all terms, say by a subscript:
An alternative approach to substitution is to make substitution part of the object language rather than the metalanguage. That is, the notation
is now actually itself a string of the language under consideration. One then needs reduction or equality rules describing the relationship of this string $P[t/x]$ to the result of actually substituting $t$ for $x$ as in the usual approach. See explicit substitution for more details.
In the categorical semantics of type theory:
Recalling that terms are interpreted by morphisms, substitution of a term into another term is interpreted by composition of the relevant morphisms.
Recalling that propositions are interpreted by subobjects, substitution of a term $t$ into a proposition $P$ is interpreted by pullback or inverse image of the subobject interpreting $P$ along the morphism interpreting $t$.
Recalling that dependent types are interpreted by display maps, substitution of a term $t$ into a dependent type $B$ is interpreted by pullback of the display map interpreting $B$ along the morphism interpreting $t$.
Or else, since dependent types are also given by classifying morphisms into a type of types, substitution corresponds to composition of these classifying morphisms with the given morphism.
In the third case, there is a coherence issue: syntactic substitution in the usual approach is strictly associative, whereas pullback in a category is not. One way to deal with this is by using explicit substitution as described above. Another way is to strictify the category before modeling type theory; see categorical model of dependent types. For literature see (Curien-Garner-Hofmann, Lumsdaine-Warren 13).
Let $\mathcal{C}$ be a suitable ambient category in which we are interpreting logic/type theory.
Suppose $X$ and $Y$ are types, hence interpreted as objects of $\mathcal{C}$. Then a term of function type $f : X \to Y$ is interpreted by a morphism, going by the same symbols.
Now a proposition about terms of type $Y$
is interpreted as an object of the slice category $\mathcal{C}_{/Y}$, specifically as a (-1)-truncated object if it is to be a proposition, hence by a monomorphism
For instance if $\mathcal{C} =$ Set then this is the inclusion of the subset of elements of $Y$ on which $P$ is true. And generally we may write
Now finally the substitution of $f(x)$ for $y$ in $P$, hence the proposition
is interpreted as the pullback
Notice that monomorphisms are preserved by pullback, so that this is indeed again the correct interpretation of a proposition.
Specifically, if $X$ is the unit type it is interpreted as a terminal object of $\mathcal{C}$, and then the function $f$ is identified simply with a term $y_0 \coloneqq f(*)$. In this case the substitution is evaluation of the proposition at $y_0$, the resulting monomorphism
over the terminal object is a truth value: the truth value of $P$ at $y_0$.
type theory | category theory | |
---|---|---|
syntax | semantics | |
natural deduction | universal construction | |
substitution……………………. | pullback of display maps | |
$\frac{ x_2 \colon X_2\; \vdash\; A(x_2) \colon Type \;\;\;\; x_1 \colon X_1\; \vdash \; f(x_1)\colon X_2}{ x_1 \colon X_1 \;\vdash A(f(x_1)) \colon Type}$ | $\,$ $\array{ f^* A &\to& A \\ \downarrow && \downarrow \\ X_1 &\stackrel{f}{\to}& X_2 }$ |
Discussion of the substitution rule in intuitionistic dependent type theory:
Bart Jacobs, p. 123 in: Categorical Logic and Type Theory, Studies in Logic and the Foundations of Mathematics 141, Elsevier (1998) [ISBN:978-0-444-50170-7, pdf]
(emphasis on the categorical model of dependent types)
Univalent Foundations Project, p. 423 of: Homotopy Type Theory – Univalent Foundations of Mathematics (2013) [web, pdf]
(in the context of homotopy type theory)
Egbert Rijke, p. 4 of: Dependent type theory [pdf], Lecture 1 in: Introduction to Homotopy Type Theory, lecture notes, CMU (2018) [pdf, pdf, webpage]
(in the context of homotopy type theory)
The observation that substitution forms an adjoint pair/adjoint triple with quantifiers is due to
and further developed in
comprehension schema as an adjoint functor_, Proceedings of the AMS Symposium on Pure Mathematics XVII (1970), 1-14.
Exposition of the interpretation of substitution as pullback:
The coherence issue involved in making this precise is discussed in
Pierre-Louis Curien, Richard Garner, Martin Hofmann, Revisiting the categorical interpretation of dependent type theory (pdf)
Peter LeFanu Lumsdaine, Michael Warren, An overlooked coherence construction for dependent type theory, CT2013 (pdf)
Last revised on August 15, 2023 at 19:34:17. See the history of this page for a list of all contributions to it.