Lambda Calculus Homework: Reducing Lambda Terms and Translating C Code, Assignments of Programming Languages

A lambda calculus homework assignment consisting of reducing lambda terms to normal forms using given steps and translating c code into lambda calculus. The assignment includes four exercises, each with a lambda term or c code snippet to be processed. The goal is to understand the concepts of lambda calculus and its relationship with functional programming.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-bcx-1
koofers-user-bcx-1 🇺🇸

8 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework 4 (25pts)
Due before class Feb 18, 2009
1. Reduce the following lambda terms to normal forms. For each reduction step, mark
the function abstraction and the parameter value being reduced.
(a) (λx. λy. y x) 5
(b) (λx. λy. y x) 5 (λz .z + 3)
(c) (λx. λy. x y) (λz .z +y) 7
(d) (λy.(λx. λy. x y) (λz.y z) 7) (λx.x + 1)
2. Translate the following C code to lambda calculus.
int apply_twice (int (*f) (...), int x) { return f(x); }
int twice (int (*g)(...), int y) { return y + apply_twice(g, y); }
int foo(int x) { return x + x; }
int main() { return twice(foo, 5); }
1

Partial preview of the text

Download Lambda Calculus Homework: Reducing Lambda Terms and Translating C Code and more Assignments Programming Languages in PDF only on Docsity!

Homework 4 (25pts)

Due before class Feb 18, 2009

  1. Reduce the following lambda terms to normal forms. For each reduction step, mark the function abstraction and the parameter value being reduced.

(a) (λx. λy. y x) 5 (b) (λx. λy. y x) 5 (λz.z + 3) (c) (λx. λy. x y) (λz.z + y) 7 (d) (λy.(λx. λy. x y) (λz.y z) 7) (λx.x + 1)

  1. Translate the following C code to lambda calculus.

int apply_twice (int (f) (...), int x) { return f(x); } int twice (int (g)(...), int y) { return y + apply_twice(g, y); } int foo(int x) { return x + x; } int main() { return twice(foo, 5); }