0% found this document useful (0 votes)
108 views1 page

EECE 334 - Final Exam Notes

1) Type derivations show that an expression has a particular type by using type judgement rules and axioms. 2) The type judgement has the form Γ |- e : τ, where Γ is the environment mapping variables to types, e is the expression, and τ is the type of e. 3) The type checking rules allow deriving a conclusion C if all premises P1 ... Pn hold, where the premises typically state the types of subexpressions.

Uploaded by

. .
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views1 page

EECE 334 - Final Exam Notes

1) Type derivations show that an expression has a particular type by using type judgement rules and axioms. 2) The type judgement has the form Γ |- e : τ, where Γ is the environment mapping variables to types, e is the expression, and τ is the type of e. 3) The type checking rules allow deriving a conclusion C if all premises P1 ... Pn hold, where the premises typically state the types of subexpressions.

Uploaded by

. .
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

& Inference

Type Derivation
Type Derivations

Type Judgement : ¥É~ , where f: environment /


mapping ( { x :O , . . .
}) ; 1- : entails ; exp program expression ;
: 7 :
type of exp

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 : •

Integer constants : Tt n : int


,
assuming n is an integer constant


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

ft " " "" "" " i"

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)

must be the same


Fte : boot Ttez : Tr+ez:÷
4) If then else
- - :
ft if e , then ez else e3

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 :

T 1- let Val ✗ = e, in ez end : 72

[+ {f Tx → % X: Tx } ten :X, ft { f Tx : → Ya } 1- ez : Tz
8) Let fun
:
,
:

f 1- let fun f- ✗ = e, in ez end : Ya

Type Inference

Unification Algorithm for 5={6--1-1} u s


'


Delete : if Unify Is)
'

s = = t → =
Unify IS )

Decompose if f- Iq & t f- Ira rm) Unify 1st Unity ( { 19 rml} us )


'
S
gm) Cqm
:
=
, , . . -
,
=
, . . -
, →
=
,
= r )
, , . . -
, =

Orient : if
'
&
t is variable variable
Unify G) Unify({ (✗ s) } us )

a ✗ s is not a
→ = =

• Eliminate if: s is a variable ✗ & ✗ does not occur in t →


1) Let D= { ✗ → t } ( substitution for all ✗ with t )

2) Let Y= Unity 1415 '


) ) ( substitute all ✗ in
'
S with t )

3) Unity IS) = Yo {✗→t}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy