Step 6.5: Proofs for Types | Language Workshop

Complexity Medium

Table of Contents

Motivation

Progress, Preservation and Type Safety

There’s a well-known slogan for typed languages: “well-typed programs don’t go wrong”! This notion is called type safety, and is an important property to prove to make sure that programs that start with no type errors stay with no type errors when they’re evaluated. It can come about from two properties of type systems: progress and preservation.

Progress

Progress says that, for any well-typed expression $e : t$ in our language, either e is a value, or e evaluates in one step to some other expression $e^\prime$ in our language.

  • TODO: Do progress for one case.

Preservation

Preservation says that, for any well-typed expression $e : t$ in our language, either e is a value, or e evaluates in one step to some other expression $e^\prime$ in our language.

Preservation is usually slightly more tricky than progress: you typically need some intermediate lemmas. In particular, renaming and substitution are lemmas you often need to prove.

Weakening is the idea that extending a context doesn’t affect whether an expression produced by that context is well-typed. It can be formulated like this:

\begin{prooftree} \AxiomC{$\Gamma \vdash e : t_1$} \UnaryInfC{$\Gamma, x : t_2 \vdash e : t_1$} \end{prooftree}

Type Safety