Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 2 [10 Points). Using the definitions of boolean constants and operators presented in class, show that the following evaluates to true. Show all your
Problem 2 [10 Points). Using the definitions of boolean constants and operators presented in class, show that the following evaluates to true. Show all your steps for a perfect mark. Always evaluate the "outer" applications first i.e., use lazy evaluation), but continue to evaluate further until you obtain true. or false (and true (not false)) Problem 3 [5 + 5 Points). Consider a function if which takes three arguments: a boolean, an expression to evaluate if the boolean is true, and a second expression to evaluate if the boolean is false. a) Given the lambda expressions for boolean constants and operators presented in class, write the lambda expression for this if function. b) Write the lambda expression for a function ifthenelse which takes five arguments: a boolean, an expression to evaluate if the boolean is true, another boolean, an expression to evaluate if the second boolean is true, and a third expression to evaluate if both booleans are false. You may assume that a correct implementation of function if from (a) is available to you, and use it if you like. Problem 4 [10 Points). The Fibonacci series contains numbers 0, 1, 1, 2, 3, 5, ... where each number is the sum of the preceding two. The nth fibonacci number can be computed recursively as follows: fib(1) = 0 fib(2) - 1 fib(n) = fib(n-1) + fib(n-2) Write a lambda expression this functi You may assume that the funct required in Problem 3 (a) and (b) are already available to you, and you may use them if you like. You may also assume that if you use the functions from Problem 3, you are simply able to state the condition as logical statements. Because this is a recursive function, you will have to nest the lambda expression taking argument n within another lambda taking f - the function which you will then recursively call within the body. Plus, you will have to precede this definition with the letter Y, which represents a special kind of lambda expression called the Y combinator, which actually makes the recursion happen. So, your solution will look something like: Y lambda f. [rest of your solution] Problem 5. [10 Points] Consider a function compose3, which takes three functions f(x), g(x) and h(x) as arguments, and evaluates to a function to compute f(g(h(x))). Define compose3 in lambda calculus. Submission: You have two options for submission. Either type in your answers as text, or upload a PDF
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started