This homework (and all previous homeworks) are due no later than 9 May 2005. In class, we constructed a partial-equivalence-relation for the CBV, simply-typed lambda calculus extended with fix and recursive types using the indexed model of Appel & McAllester. To keep things simple here, I'm going to consider the subset of the language that omits recursive types. The syntax of the language is as follows: x in Var t in Type ::= int | t1 -> t2 e in Exp ::= x | i | \x.e | e1 e2 | fix f(x).e v in Val ::= i | \x.e G in Tenv = Var -> Type g in Subst = Var -> Exp The evaluation rules are: e1 -> e1' e2 -> e2' --------------- ------------- e1 e2 -> e1' e2 v e2 -> v e2' (\x.e) v -> e[v/x] fix f(x).e -> e[fix f(x).e/f] and the typing rules are: G |- i : int G |- x : G(x) G,x:t' |- e : t G |- e1 : t'->t G |- e2 : t' ----------------- ------------------------------ G |- \x.e : t'->t G |- e1 e2 : t G,f:t1->t2 |- \x.e : t1->t2 --------------------------- G |- fix f(x).e : t1->t2 The model for this subset of the language looks like this: V[int] = { (k,i,i) | k in Nat, i in Z } V[t1->t2] = { (k,\x.e1,\x.e2) | All j (j,e1[v1/x],e2[v2/x]) in C[t2] } C[t] = { (k,e1,e2) | All j.All e1'.(0 < j < k & e1 ->j e1' -/->) => Exists e2'.e2 ->* e2' & (k-j, e1', e2') in V[t] } C[G] = { (k,g1,g2) | All x in Dom(G).(k,g1(x),g2(x)) in C[G[x]] } We say that G |= e1 <= e2 : t when G |- e1 : t, G |- e2 : t and for all k and g1,g2 such that (k,g1,g2) in C[G], (k,g1(x),g2(x)) in C[t]. Intuitively, |= e1 <= e2 : int tells us that if e1 terminates with an integer i, then e2 must also terminate with an integer i. If e1 doesn't terminate, then e2 can do anything it likes. We say that G |= e1 = e2 : t when G |= e1 <= e2 : t and G |= e2 <= e1 : t. Intuitively, |= e1 = e2 : int tells us that e1 terminates with an integer i if and only if e2 also terminates with an integer i. The following proof rules are ones that we might expect for the language. They include reflexivity, symmetry, transitivity, congruences, and the beta-value rule. G |- e : t G |- e1 = e2 : t -------------- ---------------- G |- e = e : t G |- e2 = e1 : t G |- e1 = e2 : t G |- e2 = e3 : t ----------------------------------- G |- e1 = e3 : t G |- e1 = e2 : t'->t G |- e1' = e2' : t' ------------------------------------------ G |- e1 e1' = e2 e2' : t G,x:t' |- e1 = e2 : t -------------------------- G |- \x.e1 = \x.e2 : t'->t G |- \x.e : t'->t G |- v : t' ----------------------------------- G |- (\x.e) v = e[v/x] : t Using the definitions above, prove that if G |- e1 = e2 : t is derivable, then G |= e1 = e2 : t. That is, if we can prove e1 = e2 using the proof rules, then it is indeed the case that e1 = e2 in the model.