Design of Programming Languages  Fall 2005
Final Exam
December 20, 2005
Do any 9.
1. (10 pts)
Operational Semantics and Type Judgments in Impcore
.
(5 pts) Give the operational semantics for
(begin e1 ... en)
, where
n
≥
0.
(5 pts) You are given the ARRAYSET
type
judgment:
Γ
ξ
,
Γ
φ
,
Γ
ρ
⊢
e
1
: ARRAY(
τ
)
Γ
ξ
,
Γ
φ
,
Γ
ρ
⊢
e
2
: INT
Γ
ξ
,
Γ
φ
,
Γ
ρ
⊢
e
3
:
τ
Γ
ξ
,
Γ
φ
,
Γ
ρ
⊢
ARRAYSET(
e
1
, e
2
, e
3
) :
τ
Within the functiom
fun typeof (e, globals, functions, formals)
of typed Impcore, you have the function
ty
, which takes only the expression
e
as
an argument, using the remaining arguments of
typeof
as free variables and returns
the type of its argument according to the type judgment above.
Write the code
completing
ty(ASET(a, i, t))
where
(ASET(a, i, t))
is the appropriate form of
the expression
e
.
2. (10 pts)
Higher Order Functions  either
μ
Scheme or ML.
foldl
is a function
that normally takes three parameters, a binary operator
⊕
, a default value
ℵ
and a
list. Its semantics can be described as:
(foldl
⊕ ℵ
’(
v
1
, v
2
,
· · ·
, v
n
))
=
v
n
⊕
(
v
n
−
1
⊕
(
· · · ⊕
(
v
1
⊕ ℵ
)
· · ·
)).
(5 pts) Define a
Curried
version of
foldl
.
(5 pts) Using
this version
of
foldl
define a function  in the same language as
the first part  that will take a list of integers and return the sum of their squares.
You must apply
foldl
to an appropriate binary operator and an appropriate default
value.
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
3. (10 pts)
Lambda Calculus
.
(5 pts) Consider the
λ
expression
Θ
1
= (
λx.λy.
(
y
(
x x y
)))(
λx.λy.
(
y
(
x x y
)))
.
Show that it is a
fixedpoint combinator
. This is known as the
Turing fixedpoint
combinator
.
(5 poits) Consider
Θ
2
= (
λx.λy.
(
y
(
λz.x x y z
)))(
λx.λy.
(
y
(
λz.x x y z
)))
This is a second form of Turing’s fixedpoint combinator. Explain the conditions under
which you would use one or the other form of the combinator. A simple example would
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '09
 Giam
 Kate, Combinatory logic, Fixed point, Fixed points

Click to edit the document details