Problem 1. Lambda calculus. The goal of this problem is to give you practice with lambda calculus. Each part of this problem will have an expression that you are asked to evaluate or simplify as much as possible. The following are some examples Example 1. plus2 = ?n. succ (succ n) what does the following evaluate to: 4 plus 2 Answer. 10 Example 2. quad = ?x. ?y. ?z. ?w. pair (pair x y) (pair z w) what does the following evaluate to: succ (fst (snd (quad 1 3 5 7))) Answer. 6 We will use the following definitions in what follows quad = ?x. ?y. ?z. ?w. pair (pair x y) (pair z w) 1st = ?p. fst (fst p) 2nd = ?p. snd (fst p) 3rd = ?p. fst (snd p) 4th = ?p. snd (snd p) tri = ?x. ?y. ?z. pair x (pair y z) f0 = ?p. pair (PLUS (fst p) (snd p)) (PLUS (succ (fst p)) (snd p)) f1 = ?q. quad (2nd q) (3rd q) (4th q) (1st q) f2 = ?r. tri (OR (fst r) (EQUAL (snd r) (snd (snd r)))) (TIMES (fst (snd r)) 2) (snd (snd r)) For each of the following, give the value that the expressions evaluate to: 1. What is f0 (pair 1 1)? 2. What is f0 (pair 1 1)? 3. What is f0 (f0 (pair 1 1))? 4. What does the function ?n. fst (n next0 (pair 1 1)) calculate? Give a compact description. Assume n is a Church numeral. 5. What is f1 (quad a b c d)? 6. What is f1 (quad a b c d)? 7. What does the function ?n. First (n f1 (quad 0 1 2 3)) calculate? Give a compact description. 8. What is Tri f0 40 45? 9. What is f2 (Tri f1 40 45)? 10. What is f2 (next2 (Tri f1 40 45))? 11. What does the function ?n. First (n f2 (Tri f1 p q)) calculate? Give a compact description. Assume n is a Church numeral greater than 0 and p and q are Church numerals.
Added by Sean G.
Close
Step 1
Step 1: Evaluate (pir Whal 0 (@U (pair I?) Show more…
Show all steps
Your feedback will help us improve your experience
Sri K and 74 other Physics 101 Mechanics educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Note: for this problem, because later answers depend on earlier ones, you must enter answers for all answer blanks for the problem to be correctly graded. If you would like to get feedback before you completed all computations, enter a "1" for each answer you did not yet compute and then submit the problem. (But note that this will, obviously, result in a problem submission.) (a) What is the exact value of ∫₀⁴ eˣ dx? ∫₀⁴ eˣ dx = e^4-1 (b) Find LEFT(2), RIGHT(2), TRAP(2), MID(2), and SIMP(2); compute the error for each. LEFT(2) value 16.778, error [(e^(4))-(16.778)] RIGHT(2) value 123.974, error [(e^(4)-123.974)] TRAP(2) value 70.376, error -16.778 MID(2) value 45.607, error 7.99 SIMP(2) value 56.769, error -3.171 (c) Repeat part (b) with n = 4 (instead of n = 2). LEFT(4) value 31.193, error [e^(4)-31.193] RIGHT(4) value 84.791, error [e^(4)-84.791] TRAP(4) value 57.99, error -4.394 MID(4) value 51.428, error 2.17 SIMP(4) value 53.864, error -0.266 (d) For each rule in part (b), as n goes from n = 2 to n = 4, does the error go down approximately as you would expect? Explain by calculating the ratios of the errors: Error LEFT(2)/Error LEFT(4) = 1.643 Error RIGHT(2)/Error RIGHT(4) = 2.256 Error TRAP(2)/Error TRAP(4) = 3.818 Error MID(2)/Error MID(4) = 3.682 Error SIMP(2)/Error SIMP(4) = 11.921 (Be sure that you can explain in words why these do (or don't) make sense.)
Adi S.
Recommended Textbooks
University Physics with Modern Physics
Physics: Principles with Applications
Fundamentals of Physics
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD