




















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: Compiler Constr; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Fall 2003;
Typology: Study notes
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















» Means “In the context A, the expression E is awell-typed expression with type T”
» (i.e. type context = symbol table)» b: bool, x: int
b: bool
» b: bool, x: int
if (b) 2 else x : int
2 + 2 : int
if (E) S1 else S2 : T
E : bool » A
premises
E : bool
if (E) S1 else S2 : T
conclusion
substitutions for A, E1, E2) » Then, the conclusion is true (with consistentsubstitution)
E
:int
E
:int
E^
A^
E1 : int A^ ⊥ ⊥E2 : int
(+)
A^ ⊥E1 + E2 : int
:int
A^
2 : int ⊥
A^
3 : int ⊥
A^
b : bool ⊥ A^
!b : bool ⊥
A^
2 + 3 : int ⊥
A^
x : int ⊥
b : bool, x : int
⊥if (!b) 2 + 3 else x : int
id : T
(variable-assign)
id = E : T ⊥ A
E2 : int A^
⊥ E1 : array[T] A^
(array-assign)
E : bool A^
(if-then-else)
if (E) S1 else S2 : T ⊥
E : bool A^
(if-then)
if (E) S : unit ⊥
⊥ ⊥(S2; .... ; Sn) : Tn
(sequence)
⊥(S1; S2; .... ; Sn) : Tn
= unit if no E
id : T [ = E ] : T A, id : T
(S2; .... ; Sn) : Tn
⊥
(declaration)
⊥(id : T [ = E ]; S2; .... ; Sn) : Tn Declarations add entries to the environment (e.g., the symbol table)
y^ Tr fun (T1 a1, ..., Tn an) {return E;}
y^ Tr fun (T1 a1, ... , Tn an) = E » Is well-formed if
y^ A, a1 : T1 , ... , an : Tn
⊥E : Tr
» Need: fun: T1 x T2 x ... x Tn
Tr