Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Negative numbers Fortunately, once you can represent natural numbers, integers are quite easy to represent. The idea is quite straightforward and simply consist of representing

image text in transcribed
Negative numbers Fortunately, once you can represent natural numbers, integers are quite easy to represent. The idea is quite straightforward and simply consist of representing an integer by a pair of naturals. Namely, let the integer = = (a,b) with a > 0,8 2 0. For instance, the number 20 could be represented by (20,0). An alternative representation would be (25,5). Indeed, the number 20 can be seen as 20 20-0 20 25 - 5 1 Namely, 2 = 2 - 5. The advantage arises for making the number negative. For instance, -20 = (0,20) = 0 - 20. In other words, to negate an integer you only need to swap the two naturals! Thankfully, addition is equally simple as 21+ where 21 = (a, b) and >=(c,d) is simply 21 +22=a-+c-d=a +c-b-d=a+c-(b + d) = (a + cb+d) To get a lambda expression implementing addition, it suffices to leverage the pair utilty alongside the addition over naturals (Church Numerals) to get a full fledged solution. Implement the above ideas for the following functions 1. Lambda expression for unary riegation of an integer 2. Lambda expression for successor of an integer 3. Lambda expression for predecessor of an integer 4. Lambda expression for binary addition of integers 5. Lambda expression for binary substraction of two integers 6. Lambda expression for binary multiplication of two integers Naturally, you should first follow the outline above and write the arithmetic specification of the operation before encoding it as a lambda expression

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions