Question

these questions are about LISP please explain the reason In the following Fun language example, which...

these questions are about LISP

please explain the reason

In the following Fun language example, which expressions can we get by some series of reductions? Assume that we can reduce the built-in function + in the usual way that addition works.

Definitions:

f(x, y) = x+y

g(x) = x+1

h(x) = 7

Example:

f(g(h(4)), h(g(5)))

1.Select all that apply:

a. g(h(4)) + h(g(5))

b. f(g(7), h(g(5)))

c. f(8, 7)

d. 15

e. f(g(h(4)) + h(g(5)))

f. f(5, h(g(5)))

g. f(h(g(4)), g(h(5)))

h. 42

2.In ((lambda (x) (x 2)) (lambda (z) (+ z 1))) we can choose both orders of reduction: reduce lambda (x)... first, or lambda (z)... first T or F

3. Assume that a sequence of reductions leads to a normal form. Then none of the intermediate expressions before the last reduction was in normal form T or F

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Options a, b, c, d, g are all correct answers.

Explanation:

(Observation: f(x,y) is a sum function,

Given expression: f( g(h(4)), h(g(5)) )

From definitions, let's simplify the innermost expressions first:

h(4) = 7, g(5) = 5 + 1 = 6

Substituting these in the expression:

f( g(7), h(6) ) ... [1]

From definition: g(7) = 7 + 1 = 8, h(6) = 7, and substituting these again in [1]

f ( 8, 7) = 8 + 7 = 15 ... [2]

From [2] it is immediately obvious that the options c and d are correct.

Let's try simplifying the remaining options:

a. g(h(4)) + h(g(5)) = g(7) + h(6) = 8 + 7 = 15; (correct)

b. f( g(7), h(g(5)) ) = f( 8, h(6) ) = f( 8, 7 ) = 8 + 7 = 15; (correct)

e. f( g(h(4)) + h(g(5)) ) -> function takes 2 parameters but just 1 parameter is supplied here; (incorrect)

f. f( 5, h(g(5)) ) = f( 5, h(6) ) = f( 5, 7 ) = 5 + 7 = 12; (incorrect)

g. f( h(g(4)), g(h(5)) ) = f( h(5), g(7) ) = f( 7, 8 ) = 7 + 8 = 15; (correct)

h. 42; (incorrect)

2. T (true). Explanation: From the Church Rosser theorem, it does not matter what reduction strategy is used initially. Either reduction will converge to the same final expression.

3. T (true). Explanation: When an expression cannot be further beta reduced, it is in normal form. So reaching normal form is the final state of the reduction.

Add a comment
Know the answer?
Add Answer to:
these questions are about LISP please explain the reason In the following Fun language example, which...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • LISP lambda calculate, expression 3) Consider reducing the following λ-expression to its normal form. Show the...

    LISP lambda calculate, expression 3) Consider reducing the following λ-expression to its normal form. Show the sequence of normal order reductions the sequence of applicative order reductions. · · 4) Consider the following function: Fx) ifx-0) then return 0 else return x+1 a) Express F as a lambda calculus expression b) Evaluate F(0) as a lambda expressiorn c) Evaluate F(1) as a lambda expression HINT: Use the representations introduces in Section 10. 5) Describe a function to compute the sum...

  • In Lisp 2. Code the function (replaceIn list possibleList repValue) which constructs a new list. It...

    In Lisp 2. Code the function (replaceIn list possibleList repValue) which constructs a new list. It examines list for occurrences of any of the atoms from the possibleList. Those are replaced with repValue. This only examines the top-level items in list. Example: > (replaceIn '(P A T T E R) '(T R) 'S) (P A S S E S) 3.   Code the function (insertAfter list atm insValue) which constructs a new list by inserting the specified insValue into the list...

  • Consider the following Python program: def fun(x, y): return x + y # [2] # [1]...

    Consider the following Python program: def fun(x, y): return x + y # [2] # [1] a = fun(2, 3) b = fun("2", 3) print a, b What does it evaluate to? Replace the last statement print a, b with print a + b and explain the traceback. What's wrong? Now eliminate the line marked [1] and change line [2] to read return x + y. Run the program and explain the traceback. Consider the following definition: def fun(n, m):...

  • Please help with all four questions regarding LISP Programming. Thank you. Please answer all questions with...

    Please help with all four questions regarding LISP Programming. Thank you. Please answer all questions with output plesase. LISP Programming Assignment It is a good idea to start this assignment early; Lisp programming, while not inherently difficult, often seem somewhat foreign at first, particularly when it comes to recursion and list manipulation. This assignment is loosely based on material by Dr. Henri Casanova.   Problem #1 Define a function that takes two arguments and returns the greater of the two. Problem...

  • MATLAB Define the following computer programming terms and give an example of each. MATLAB example Sequence...

    MATLAB Define the following computer programming terms and give an example of each. MATLAB example Sequence Selection structure- Repetition structure - Relational operators (True = 1, False = 0) Logical operators (True = 1, False =0) And Or Less than Less than or equal to Greater than Greater than or equal to Equal to Not equal to Not ans ans Type the following relational operator commands into MATLAB in the command window one at a time. Write the results to...

  • Please help me with these questions, show working. thankyou A space curve is defined by C: T(s) 2si+(5s2+4)j+(s+7)k. De...

    Please help me with these questions, show working. thankyou A space curve is defined by C: T(s) 2si+(5s2+4)j+(s+7)k. Determine parametric equations for the tangent line to the space curve C at the point P: (2, 9, 8) Your answer should consist of three expressions for the Cartesian variables x, y and z in terms of the parameter t, using the correct syntax. For example: x 2+4*t, y 7-3*t, z 15+2*t Do not use decimal approximations all numbers should be entered...

  • Determine which of the following pairs of functions are linearly independent.

    Determine which of the following pairs of functions are linearly independent. 1. \(f(x, y)=2 x-4 y-12, \quad g(x, y)=-3 x+6 y+18\)2. \(f(t)=17 t^{3} \quad, \quad g(t)=e^{x}\)3. \(f(\theta)=\cos (3 \theta) \quad, \quad g(\theta)=4 \cos ^{3}(\theta)-8 \cos (\theta)\)4. \(f(x)=x^{3} \quad, \quad g(x)=|x|^{3}\)5. \(f(t)=e^{\lambda t} \cos (\mu t) \quad, \quad g(t)=e^{\lambda t} \sin (\mu t) \quad, \mu \neq 0\)6. \(f(t)=4 t^{2}+28 t \quad, \quad g(t)=4 t^{2}-28 t\)7. \(f(\theta)=\cos (3 \theta) \quad, \quad g(\theta)=4 \cos ^{3}(\theta)-4 \cos (\theta)\)8. \(f(x)=e^{4 x} \quad, \quad g(x)=e^{4(x-3)}\)9. \(f(x)=x^{2} \quad,...

  • (2) Why First-Order Systems (of a Specific Form) Are Sufficient: In class I stated that all syste...

    Please be specific, thanks! (2) Why First-Order Systems (of a Specific Form) Are Sufficient: In class I stated that all systems of differential equations can be turned into first-order systems. And I wrote that first-order systems can be written in the form: For 3-by-3 system, the form is: r-f(r, y,z,t) y- g(x, y, z, t) , = h(z,y,z, This can be generalized to any number of unknown functions. a) Notice that r', y', and z are not included in the...

  • Solution please, previous are wrong ! thanks A space curve is defined by C: (s)=(3s2+4)2+(s+7)j+4sk. Find the Cartesian...

    Solution please, previous are wrong ! thanks A space curve is defined by C: (s)=(3s2+4)2+(s+7)j+4sk. Find the Cartesian form of the equation for the plane that is perpendicular to the space curve C at the point where s 2 Your answer should be an equation, expressed in terms of the Cartesian variables x, y and z using the correct syntax. For example: 3*x-2*y+5*z-2, or, 2 (x-1)+4*(y-2)+z-1-0, or 3*x+ 6*z=12-y, or y-x+35*(z-256)-20 Do not use decimal approximations all numbers should be...

  • 4. (25 points) Which of the following subsets of R3 are subspaces.Explain. a) {(x, y, z)...

    4. (25 points) Which of the following subsets of R3 are subspaces.Explain. a) {(x, y, z) 1 x 0, y 0, z ? c) {(z, y, z) | x2 + y2 + z2-1} d) Is the set H of all matrices of the form |(a,0)T, (b,d)T] a subspace of the space of all 2x2 matrices with the usual matrix addition and scalar multiplica- tion?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT