Lecture 8: The Simply-Typed Lambda Calculus & The Substitution Lemma
October 1
The Simply-Typed Lambda Calculus
- Review and finish progress & preservation for the new additions to the languages (lambda abstraction and application)
- The patterns for progress proofs - induction over the typing derivation.
Like we've said, there are three kinds of cases.
- Case 1: The term is already a value, so we know the term is not stuck (it steps or is a value!)
- Case 2: The term always takes a step. Look at the principal subterm(s) (the principal subterms of e1 + e2 are e1 and e2, the principal subterms of eA eB are eA and eB, but the principal subterm of if e then eT else eF is just e). The induction hypothesis says that these aren't stuck.
- If any of the principal subterms take a step, then the whole term takes a step
- If all of the principal subterms are values, then by using some canonical forms lemmas, we should be able to show that the whole term takes a step.
- SPOILER ALERT Case 3: The term make take a step or be a value. Look at the principal subterms - if the principal subterm(s) take(s) a step, the whole term does. If the principal subterm(s) is a value (are values), the whole term is a value. This will probably first come up when we discuss having paris to the language.
- The patterns for preservation proofs - induction over the evaluation relation.
In all compatibility cases,
- Use inversion to get that the subterms are typed correctly
- Use the induction hypothesis to get that the new subterm is typed correctly
- Use the rules to get that the new term is typed correctly
In the "significant" or "reduction" cases, like n1 + n2 -> n1 + n2 or λx:t'.e1 -> [e2/x]e1, more cleverness is needed. By the way, in these cases, the left hand side is called a redex (short for "reducible expression," plural redices or redexes) and the right side is called a contractum.
In the case where the redex is an application, part of this cleverness is the substitution lemma, which says that if e' : t1 and x:t1 |- e : t2, then [e'/x]e : t2.
The Substitution Lemma
We need to prove a stronger lemma: If Γ |- e : t2 and Γ includes x : t1, and e2 : t1, then...
Before we claw our eyes out from notation...
If Γ, x:t1 |- e : t2 and e' : t1 then Γ |- [e'/x]e : t2 - proved by induction on the derivation of Γ, x:t1 |- e : t2.
This is how we prove that substitution was defined correctly. If we screw up defining substitution, then the substitution lemma is the part of the language that breaks down.
We also needed to use weakening to prove
substitution; namely, that if e' : t1 then Γ |- e' : t1. This follows naturally from the way we treat Γ - it's just a set of assumptions, and so we can add more, we don't have to use those assumptions if we don't want to.
$LastChangedDate: 2008-11-10 11:52:21 -0500 (Mon, 10 Nov 2008) $
$Author: rjsimmon $
$Rev: 1029 $