EECE 334 - Final Exam Notes
EECE 334 - Final Exam Notes
Type Derivation
Type Derivations
•
R Pz - - -
Pn
Type checking conclusion C holds if premises Pr
•
: C , where . . . .
.
Pn all hold
Axioms
no no premise →
unconditionally true
1) Constant Axioms : •
•
Boolean Constants : F 1- true : boot and I 1- false boot :
2) Variable Axiom : •
Variable References → ¥0 if FCX ) = 6 ( a reference to var ✗ has
type 6 if ✗ has
type 6 in the environment )
Rules
1) Arithmetic Operators ( ② c- { + ,
-
,
*
,
- }) :
T te, ① ez : int ( e. ⑤ ez has type int if e, has type int & ez has type int )
assume int
Fte , :X Ttez : it
2) Relational Operators In c- { <, >
,
=
, .. .
}) :
r te , uez : bool ( ein ez has type boot if e, has type int & ez has type int )
ft el :b001 ft ez :b001
3) Logical Connectives ( NN C- {andalso , orelse}) :
ri -
e, un ez : boot
(e ,
n ~ ez has type boot if e, has type boot & ez has type boot)
ft { ✗ Tx } : t e : Te
5) Anonymous Functions :
rtfn ✗ e : ex → Te
- function - argument
T te, : Tz → T Tt ez Tz :
6) Function Application :
ft e. ez : 7
Ttei % ft { x :P, } 1- ez : K
7)
:
Let Val :
[+ {f Tx → % X: Tx } ten :X, ft { f Tx : → Ya } 1- ez : Tz
8) Let fun
:
,
:
Type Inference
•
Delete : if Unify Is)
'
s = = t → =
Unify IS )
•
Orient : if
'
&
t is variable variable
Unify G) Unify({ (✗ s) } us )
•
a ✗ s is not a
→ = =