Fall 98, CSE 520: Solution of Assignment 3

Exercise 1

Let M be a typeable term of measure k (where the measure of a term is defined as the greatest of the orders of its beta-redexes, if they exist, and 0 otherwise). If k = 0 then M is already in normal form. If k > 0, we show by structural induction that we can reduce M to a term with measure < k.

Exercise 2

  1. (A -> (B -> C)) -> (A -> B) -> (A -> C) is inhabited. One term with this type is \x\y\z.(xz)(yz).
  2. (A -> B) -> (B -> A) is not inhabited. In fact (A -> B) -> (B -> A) (seen as a propositional formula, where -> represent implication) is not classically valid. In fact, for A=false and B=true the formula is false.
  3. (A * B) -> A is inhabited. One term with this type is \x.(fst x)
  4. A -> (A * B) is not inhabited. In fact A -> (A * B) (seen as a propositional formula, where * represent conjunction) is is not classically valid. In fact, for A=true and B=false the formula is false.
  5. (A -> (B -> C)) -> ((A * B) -> C) is inhabited. One term with this type is \x\y.(x (fst y)(snd y))
The term for an inhabited type can be obtained by constructing the proof that a generic lambda term M has such type.

Exercise 3

One possible recursive definition of a buffer with n cells (for n arbitrary) is the following: This definition constructs Bk+1 from Bk by adding a one-cell buffer at the end. Other solutions are of course possible.