Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. (10 pointsLet Bit be the inductive set defined by the following con- structors: Zero : Bit. One : Bit. The members of Bit represent

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

2. (10 pointsLet Bit be the inductive set defined by the following con- structors: Zero : Bit. One : Bit. The members of Bit represent 0 and 1. Let BinNum be the inductive set defined by the following constructors: Nil : Bin Num. Join : BinNum x Bit Bin Num. The members of Bin Num not equal to Nil represent binary numerals; Nil represents an empty numeral. For example, Join(Join(Join(Nil, One), Zero), One), represents the binary number 101. The function len : Bin Num +N maps a member of Bin Num to its length. len is defined by the following equations using recursion and pattern matching: len(Nil) = 0. len(Join(u,b)) = len(u) +1. The function val : BinNum N maps a member of Bin Num to the value of the binary numeral it rep- resents. For example, val(Join(Join(Join(Nil, One), Zero), One)) = (101)2 = 5. val is defined by the following equations using recursion and pattern matching val(Nil) = 0. val(Join(u, Zero)) = 2 * val(u). val(Join(u, One)) = (2 * val(u)) +1. The function add : Bin Num x Bin Num Bin Num is intended to implement addition on members of Bin Num. It is defined by the following equations using recursion and pattern matching: add(u, Nil) = u. add(Nil, u) = u. add(Join(u, Zero), Join(v, Zero)) = Join(add(u, v), Zero). add(Join(u, One), Join(v, Zero)) = Join(add(u, v), One). add(Join(u, Zero), Join(v, One)) = Join(add(u, v), One). add(Join(u, One), Join(v, One)) = Join(add(add(u, v), Join(Nil, One)), Zero). Notice that the algorithm behind the definition is essentially the same algorithm that children learn to add numbers represented as decimal numerals. The last equation is a bit complicated because it involves a carry of 1. Lemma 1. For all u, v E Bin Num, len(add(u, v))

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

=+a. What is the numerical value of k?

Answered: 1 week ago

Question

Is conflict always unhealthy? Why or why not? (Objective 4)

Answered: 1 week ago