nLab
substitution

Context

Type theory

natural deduction metalanguage, practical foundations

  1. type formation rule
  2. term introduction rule
  3. term elimination rule
  4. computation rule

type theory (dependent, intensional, observational type theory, homotopy type theory)

syntax object language

computational trinitarianism = propositions as types +programs as proofs +relation type theory/category theory

logiccategory theorytype theory
trueterminal object/(-2)-truncated objecth-level 0-type/unit type
falseinitial objectempty type
proposition(-1)-truncated objecth-proposition, mere proposition
proofgeneralized elementprogram
cut rulecompositionsubstitution
cut elimination for implicationcounit for hom-tensor adjunctionbeta reduction
introduction rule for implicationunit for hom-tensor adjunctioneta conversion
conjunctionproductproduct type
disjunctioncoproduct ((-1)-truncation of)sum type (bracket type of)
implicationinternal homfunction type
negationinternal hom into initial objectfunction type into empty type
universal quantificationdependent productdependent product type
existential quantificationdependent sum ((-1)-truncation of)dependent sum type (bracket type of)
equivalencepath space objectidentity type
equivalence classquotientquotient type
inductioncolimitinductive type, W-type, M-type
higher inductionhigher colimithigher inductive type
completely presented setdiscrete object/0-truncated objecth-level 2-type/preset/h-set
setinternal 0-groupoidBishop set/setoid
universeobject classifiertype of types
modalityclosure operator monadmodal type theory, monad (in computer science)
linear logic(symmetric, closed) monoidal categorylinear type theory/quantum computation
proof netstring diagramquantum circuit
(absence of) contraction rule(absence of) diagonalno-cloning theorem

homotopy levels

semantics

Contents

Idea

Syntactic substitution for variables is one of the basic operations in formal mathematics, such as symbolic logic and type theories?.

Syntactic substitution

Substitution is usually defined as an operation on expressions containing variables. (These expressions may be terms, formulas?, propositions, dependent types, etc.) Suppose that PP an expression in the context of a variable xx, and that tt is an expression which has the same type as xx. Then we denote by

P[t/x] P[t/x]

the result of substituting tt for all occurrences of xx in PP.

For example, if PP is x 2+2xy+3x^2 + 2xy + 3 and tt is (y+z)(y+z), then P[t/x]P[t/x] is (y+z) 2+2(y+z)y+3(y+z)^2 + 2(y+z)y + 3.

Note that in this approach, substitution is an operation on syntax, not an element of syntax itself. In particular, the bracket notation [t/x][t/x] is part of “meta-syntax”, not the syntax in question. That is, the literal string of symbols “P[t/x]P[t/x]” is not itself an expression in the language under consideration, but denotes such an expression, in the same way that “2+22+2” is not literally an integer but denotes the integer 44.

Simultaneous substitution

Substitution for multiple variables does not, in general, commute. That is,

P[t/x][s/y]andP[s/y][t/x]P[t/x][s/y] \qquad\text{and}\qquad P[s/y][t/x]

are not in general the same: the former substitutes ss for occurrences of yy in tt, but not tt for occurrences of xx in ss, while the latter has the opposite behavior. We also write

P[t,s/x,y] P[t,s/x,y]

to denote the simultaneous substitution of tt for xx and ss for yy, in which neither occurrences of xx in ss nor occurrences of yy in tt are substituted for; this is generally not the same as either iterated substitution.

Avoiding variable capture

If the language in question contains variable binders, then there is a subtlety to substitution: if tt contains free variables that are bound in PP, then we cannot simply textually substitute tt for xx and obtain an expression with the desired meaning.

For instance, if PP is y(x+y=1)\exists y (x + y = 1), and tt is the free variable yy, then a literal interpretation of P[t/x]P[t/x] would produce y(y+y=1)\exists y (y + y = 1). But PP is true (universally in its free variables) if the variables have type \mathbb{Z}, while y(y+y=1)\exists y (y + y = 1) is not. The free variable yy in tt has been “captured” by the binder y\exists y in PP.

We say that tt is substitutable for xx in PP if performing a literal textual substitution as above would not result in undesired variable capture. If tt is not substitutable for xx in PP, then we can always replace PP by an α-equivalent expression in which tt is substitutable for xx. Since we often consider formulas only up to α\alpha-equivalence anyway, one usually defines the notation ”P[t/x]P[t/x]” to include an α\alpha-conversion of PP, if necessary, to make tt substitutable for xx.

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 Brujin indices? to represent bound variables.

As an admissible rule

A general property of type theories (and other formal mathematics) is that substitution is an admissible rule. Roughly, this means that if PP is an expression of some type, then so is the result P[t/x]P[t/x] of substitution (as long as tt and xx 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 we can show that the following substitution rule is admissible:

Γ(t:A)(x:A)PtypeΓP[t/x]type \frac{\Gamma \vdash (t:A) \qquad (x:A) \vdash P \;type}{\Gamma \vdash P[t/x] \;type}

Here “admissibility” means that if there exist derivations of Γ(t:A)\Gamma \vdash (t:A) and (x:A)Ptype(x:A) \vdash P \;type, then there also exists a derivation of ΓP[t/x]type\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.

Explicit substitution

An alternative approach to substitution is to make substitution part of the object language rather than the metalanguage. That is, the notation

P[t/x]P[t/x]

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]P[t/x] to the result of actually substituting tt for xx as in the usual approach.

Categorical semantics

Definition

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 tt into a proposition PP is interpreted by pullback or inverse image of the subobject interpreting PP along the morphism interpreting tt.

  • Recalling that dependent types are interpreted by display maps, substitution of a term tt into a dependent type BB is interpreted by pullback of the display map interpreting BB along the morphism interpreting tt.

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.

Examples

Let 𝒞\mathcal{C} be a suitable ambient category in which we are interpreting logic/type theory.

Suppose XX any YY are types, hence interpreted as objects of 𝒞\mathcal{C}. Then a term of function type f:XYf : X \to Y is interpreted by a morphism, going by the same symbols.

Now a proposition about terms of type YY

y:YP(y) y : Y \vdash P(y)

is interpreted as a object of the slice category 𝒞 /Y\mathcal{C}_{/Y}, specifically as a (-1)-truncated object if it is to be a proposition, hence by a monomorphism

P Y. \array{ P \\ \downarrow \\ Y } \,.

For instance if 𝒞=\mathcal{C} = Set then this is the inclusion of the subset of elements of YY on which PP is true. And generally we may write

P={y:YisInhab(P(y))}. P = \{y : Y | isInhab(P(y)) \} \,.

Now finally the substitution of f(x)f(x) for yy in PP, hence the proposition

P(f()) X \array{ P(f(-)) \\ \downarrow \\ X }

is interpreted as the pullback

P(f()) f *P P X f Y. \array{ P(f(-)) \coloneqq & f^* P &\to& P \\ & \downarrow && \downarrow \\ & X &\stackrel{f}{\to}& Y } \,.

Notice that monomorphisms are preserved by pullback, so that this is indeed again the correct interpretation of a proposition.

Specifically, if XX is the unit type it is interpreted as a terminal object of 𝒞\mathcal{C}, and then the function ff is identified simply with a term y 0f(*)y_0 \coloneqq f(*) . In this case the substitution is evaluation of the proposition at y 0y_0, the resulting monomorphism

P(y 0) P * y 0 Y \array{ P(y_0) &\to& P \\ \downarrow && \downarrow \\ * &\stackrel{y_0}{\to}& Y }

over the terminal object is a truth value: the truth value of PP at y 0y_0.

type theorycategory theory
syntaxsemantics
natural deductionuniversal construction
substitution…………………….pullback
x 2:X 2A(x 2):Typex 1:X 1f(x 1):X 2x 1:X 1A(f(x 1)):Type\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}\, f *A A X 1 f X 2\array{ f^* A &\to& A \\ \downarrow && \downarrow \\ X_1 &\stackrel{f}{\to}& X_2 }

References

The observation that substitution forms an adjoint pair/adjoint triple with quantifiers is due to

  • Bill Lawvere, Adjointness in Foundations, (TAC), Dialectica 23 (1969), 281-296

and further developed in

  • Bill Lawvere, Equality in hyperdoctrines and comprehension schema as an adjoint functor, Proceedings of the AMS Symposium on Pure Mathematics XVII (1970), 1-14.

Revised on November 23, 2012 02:24:08 by Urs Schreiber (82.169.65.155)