Assignment 5 - Functional Programming
Lambda Calculus
Apply beta reduction to the following expressions. Solve it on paper and upload a scanned version.
a) y) ( lambda x*x a)
b) (lambda z*z)(lambda z*z,z)(lambda z*zy)
c) ( lambda x*lambda y*x y y) ( lambda a*a b
d) y y) ( lambda y*y
e) x) x) z
f) y) z
g) x) (lambda y*y)
h) (((lambda x*lambda y*(xy))(lambda y*y)),w)
i) y y) ( lambda x*x x x) )
Prove the following using lambda calculus encodings.
Refer to the paper I have uploaded on Google Classroom for the encodings.
Solve it on paper and upload a scanned version.
a) or false true = true
b) +22=4
c) succ2=3
Use a recursive definition to define a function that adds up the first n natural numbers. Refer to Recursion section (section 4) in the paper I have provided. Encode the Y combinator in Python and then find the sum. For the most part, you have to read the paper and write Python code verbatim, just make sure your solution works. Upload a Python file.
Haskell Programming
Solve the following exercises in Haskell and upload only .hs files.
Exercises 1 - 5 are supposed to be solved after Week 11.
Exercises 6 - 14 are supposed to be solved after Week 12.
Exercise 14 and 15 are supposed to be solved after Week 13.
Assignment 5 -- Functional Programming
Lambda Calculus
l) Apply beta reduction to the following expressions. Solve it on paper and upload a scanned version.
a) (Xz.z)(Xy.y y) (Xx.x a) b) (Xz.z) (Xz.z z) (Xz.z y) c) Xx.Xy.x y y)(Xa.a) b d (Xx.Xy.xy y)(Xy.y)y e)(Xx.x x)(Xy.y x) z f)Xx.(Xy.x yy)z gXx.xxXy.yXy.y hXx.Xy.xy)Xy.y))w) i)(Xx.y)((Xy.y y y)(Xx.x x x))
2) Prove the following using lambda calculus encodings. Refer to the paper I have uploaded on Google classroom for the encodings. Solve it on paper and upload a scanned version.
a) or false true = true b)+22=4 csucc 2 =3
3) Use a recursive definition to define a function that adds up the first n natural numbers. Refer to Recursion section (section 4) in the paper I have provided. Encode the Y combinator in Python and then find the sum. For the most part, you have to read the paper and write Python code verbatim, just make sure your solution works. Upload a Python file.
Haskell Programming
Solve the following exercises in Haskell and upload only.hs files. Exercises l - 5 are supposed to be solved after Week ll. Exercises 6 - l4 are supposed to be solved after Week l2. Exercise l4 and 15 are supposed to be solved after Week 13.