











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












290G - Lecture 2
-^ A language^ –^ Lambda calculus •^ Types^ –^ Type checking
290G - Lecture 2
beta reduction
290G - Lecture 2
290G - Lecture 2
-^ Intuitively, a type
290G - Lecture 2
→ →
→ α int
int
α
290G - Lecture 2
-^ To determine whether the types in an expression are consistentwe perform
type checking.
-^ But we need types for free variables, too!•^ Atype environment is a function from variables to types.
|^ ,^ : A^
A x^ τ= ∅
x^ y
A x^
y^ A y
x
y τ τ^
290G - Lecture 2
-^ Type checking is done by structural induction.– One inference rule for each form– Assumptions contain types of free variables– A term is
well-typed if
1 2 1 2 1 1
2 2
3 1 2
: : int : int^
: int^
i : int^
: int^
if^
d dd → +
d^
d^
d d d^
d d^
d
d^
d^
d
290G - Lecture 2
?^ :?? :^ x.^ : ?y x :.^ :^.^ :? x^ λ^ β y^ x λ^ α λ
β ∅
d d d
290G - Lecture 2
-^ Walk the proof tree from the root to the leaves,generating the correct environments. •^ Assumptions are simply gathered from lambdaabstractions.
:^ ,^ :
:? :^
:^.^ :? :. :^.^
:?
x^ y
x x
y^ x x y^
x α^
β α^ λ
β λ^ α λ
β ∅
d d d
290G - Lecture 2
16 / 19
:^ ,^
:^ : :^
:^.^ :^
:^ :
:^.^
:^.^ : (^
)^
:^.^ :
(^ :^
.^ :^.^
)^ :^.^
: (^ )
x
y^ x x
y^ x
z^ z
x
y^ x
z^ z
x
y^ x^
z^ z α^ α^
β^ α^
α α^ α^
λ^ β^
β^ α^
α
α^ α
λ^ α^
α λ^ β^
α^ α^
β^ α^
α^ λ^
α^ α^
α
λ^ α^
α λ^ β^
λ^ α^
α^ α^
β^ α^
α
→^
→ →^
→^ →
∅^
→^
→^ →^
→^ →^
∅^
→
∅^
→^
→^ →^
→^ →
d d^
d
d^
d
d
290G - Lecture 2
-^ Thm.
∗e → d, then Aβ^
290G - Lecture 2