Midterm Midterm Meeting 22, CSCI 5535, Spring 2009 3 4 High-Level Hints Exercise 4 • Ex 2: Language is like IMP and like λcalculus in ways • Ex 3: Did “preservation” in class with big-step semantics • Ex 4: Try an example derivation in ⊢ and “convert it” to ⊢0 • Ex5: Think about using references: storing and reading • Consider the simply-typed lambda calculus with subtyping: e ::= x | λx.e | e1 e2 τ ::= τ → τ | … • Typing rule for λ-expression: 5 Γ, x : τ ⊢ e : τ ′ Γ ⊢ λx. e : τ → τ ′ 6 1 Exercise 4 Exercise 4 • Standard subsumption • Prove “completeness of variable-only subsumption typing” Γ ⊢ e : τ τ <: τ ′ Γ ⊢ e : τ′ If T:: · ⊢ e : τ, then · ⊢0 e : τ . • Replaced with restricted variable-only subsumption ′ Γ(x) = τ τ <: τ Γ ⊢0 x : τ ′ 7 Exercise 4 8 Exercise 4 If T:: · ⊢ e : τ, then · ⊢0 e : τ . Need generalization! If T:: · ⊢ e : τ, then · ⊢0 e : τ . • Try proof by induction on T. • Case x : τ ⊢ e : τ′ T :: · ⊢ λx. e : τ → τ ′ 9 Exercise 4 10 Need generalization! Corollary: If T:: · ⊢ e : τ, then · ⊢0 e : τ . • Try Theorem: If T:: Γ ⊢ e : τ, then Γ ⊢0 e : τ . • Resolves issue with λ-expression • If we can prove the theorem, then that (trivially) implies the corollary we want • Think about: The case where T ends in the subsumption rule. 11 12 2