6
$\begingroup$

In the simply typed lambda calculus, one can show the following result, known as "preservation under substitution":

  • If $\Gamma \vdash v : \tau_1$ and $(x : \tau_1) \vdash t : \tau_2$, then $\Gamma \vdash [v/x]t : \tau_2 $.

However, the proof of this relies on the property of permutation, that we can rearrange contexts and it will preserve typing of terms.

I'm wondering, can we prove a similar property for dependently typed languages? The problem is that, here, permutation may not hold, since telescopes are used in place of environments, and the types themselves may refer to variables. Moreover, since the types and terms overlap, we have to substitute in $\Gamma$ and $\tau_2$ as well.

Does anyone have a good reference to proving such a preservation property for a dependently typed language? Are there tricks that are used to avoid the permutations?

$\endgroup$

2 Answers 2

8
$\begingroup$

The property, which I would call "typing of substitution" should hold in any type theory, and is not dependent on the exchange property (which I assume is what you mean by permutation)

The key is that you need to generalize the inductive hypothesis to when the variable in t appears in a context. So for a dependent type theory you prove

  • If $\Gamma \vdash t_1 : \tau_1$ and $\Gamma, x : \tau_1, \Delta \vdash t_2 : \tau_2$ then $\Gamma,\Delta[t_1/x] \vdash t_2[t_1/x] : \tau_2[t_1/x]$

For a reference, see Lemma 2.3.2 on page 55 in Advanced Topics in Types and Programming Languages.

$\endgroup$
1
  • 2
    $\begingroup$ Or even better: prove an even more general version corresponding to parallel substitution. $\endgroup$
    – gallais
    Commented Oct 30, 2018 at 8:43
10
$\begingroup$

The most general form of substitution theorems speaks about arbitrary contexts:

  1. Define what it means to have a substitution $\sigma : \Gamma \to \Delta$ from a context $\Gamma$ to a context $\Delta$ (it's a simultaneous substitution giving a term $\Gamma \vdash e : A$ for every $y : A$ appearing in $\Delta$, and in case of type dependencies we have to do it recursively).

  2. Prove that if $\Delta \vdash e : A$ then $\Gamma \vdash e\sigma : A\sigma$.

In such generality there is no reliance on exchange rules and it all works in dependent type theory as well. The case suggested by Max New in his answer is a special case.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.