Lambda Calculus Homework: Abstract Syntax Trees and Translation, Assignments of Programming Languages

A lambda calculus homework assignment from october 1st, 2008. The assignment includes four problems: drawing abstract syntax trees (ast) and reducing each lambda term to normal form for given terms, and translating c code to lambda calculus. The first problem involves drawing asts and reducing normal forms for four lambda terms. The second problem requires translating a c function and its main function to lambda calculus.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-hgs
koofers-user-hgs 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework 3
Due before class Oct 1st, 2008
1. (28pts) Draw an AST (Abstract Syntax Tree) for each of the following lambda terms.
Then reduce each lambda term to a normal form.
(a) (λx. λy. x y+z) 8 7
(b) (λx. λy. y x) 3 (λx. x)
(c) (λz. (λx. λy. y x)z) (λx. x + 3)
(d) λz. (λz. (λx. λy . y x)z) (λx. x +z)
2. (7pts) Translate the following C code to lambda calculus.
int f(int (*g)(...)) {/* g points to a function that returns an int */
return g(g);
}
int main() {
int x;
x = f(f);
return x;
}
1

Partial preview of the text

Download Lambda Calculus Homework: Abstract Syntax Trees and Translation and more Assignments Programming Languages in PDF only on Docsity!

Homework 3

Due before class Oct 1st, 2008

  1. (28pts) Draw an AST (Abstract Syntax Tree) for each of the following lambda terms. Then reduce each lambda term to a normal form.

(a) (λx. λy. x − y + z) 8 7 (b) (λx. λy. y x) 3 (λx. x) (c) (λz. (λx. λy. y x) z) (λx. x + 3) (d) λz. (λz. (λx. λy. y x) z) (λx. x + z)

  1. (7pts) Translate the following C code to lambda calculus.

int f(int (g)(...)) { / g points to a function that returns an int */ return g(g); } int main() { int x; x = f(f); return x; }