
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Progrmg Languages & Compilers; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Fall 2006;
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

1 CS 421 Midterm Name:______________________________ Rules for type derivations: Constants:
Γ|- n : int (assuming n is an integer constant)
Γ|- true : bool Γ|- false : bool Variables:
Γ |- x : σ if Γ(x) = σ Primitive operators ( ⊕ ∈ { +, -, *, …}): Γ |- e 1 : int Γ |- e 2 : int Γ |- e 1 ⊕ e 2 : int Relations ( (^) ˜ ∈ { < , > , =, <=, >= }): Γ |- e 1 : int Γ |- e 2 : int Γ |- e 1 ˜ e 2 :bool Connectives : Γ |- e 1 : bool Γ |- e 2 : bool Γ |- e 1 : bool Γ |- e 2 : bool Γ |- e 1 && e 2 : bool Γ |- e 1 || e 2 : bool If_then_else rule: Γ |- e 1 : bool Γ |- e 2 : τ Γ |- e 3 : τ Γ |- (if e 1 then e 2 else e 3 ) : τ Application rule: fun rule: Γ |- e 1 : τ 1 → τ 2 Γ |- e 2 : τ 1 [x : τ 1 ] + Γ |- e : τ 2 Γ |- (e 1 e 2 ) : τ 2 Γ |- fun x -> e : τ 1 → τ 2 let rule: let rec rule: Γ |- e 1 : τ 1 [x : τ 1 ] + Γ |- e 2 : τ 2 [x: τ 1 ] + Γ |- e 1 :τ 1 [x: τ 1 ] + Γ |- e 2 :τ 2 Γ |- (let x = e 1 in e 2 ) : τ 2 Γ |- (let rec x = e 1 in e 2 ) : τ 2