Final Exam Foundations of Software January 22, 2008 Last Name : First Name : Section : Exercise Points Achieved Points 1 10 2 10 3 10 Total 30 Exercise 1 : Types and terms (10 points) For each of the following types, write down a term in lambda calculus that has that type. You should give the terms in the untyped lambda calculus, and the given type should be the type inferred by the Hindley–Milner type inferencer. A→A (A → A) → A → A (A → B) → (B → C) → A → C (A → B → C) → (B → A → C) (A → B) → (A → C) → (B → C → D) → A → D 2 Exercise 2 : Featherweight Java (10 points) Consider the Featherweight Java language without casts. Prove the following theorem: Progress: If t is a well typed term, it is either a value or can take a step. Proceed by induction on typing derivations. 3 Exercise 3 : Type inference (10 points) Consider the lambda calculus with Hindley–Milner type inference and let–polymorphism. Adding mutable cells (references) to this language makes the type inference unsound. Complete the following program so that it is well–typed, and its evaluation leads to a type–error (gets stuck). Explain why. l e t v = r e f id in ... (where id is the identity function). 4