Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(2 pages). Please help me by showing in Latex format if possible. Much appreciated! 2. (10 points) Let BinNum be the inductive set defined by

image text in transcribedimage text in transcribed

(2 pages). Please help me by showing in Latex format if possible. Much appreciated!

2. (10 points) Let BinNum be the inductive set defined by the following constructors: Zero : Bin Num. One : Bin Num. JoinZero : Bin Num Bin Num. Join One : BinNum Bin Num. The members of Bin Num represent binary numerals like 1011 and 010. Zero represents 0: One represents 1; and if u represents U, then JoinZero(u) represents UO and Join One(u) represents U1. For example, Join One (JoinZero (JoinOneOne)) represents the binary number 1101. The function len : Bin Num N maps a member of BinNum to its length. len is defined by the following equations using recursion and patter matching: len (Zero) = 1 len(One) = 1. len (JoinZero(u)) = len(u) +1. len (Join One()) = 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 One (JoinZero(Join One (One)))) = (1101)2 = 13. val is defined by the following equations using recursion and pattern matching val(Zero) = 0. val(One) = 1. val(JoinZero(u) = 2 *valu). val(Join One(u) = (2 val()) + 1. The function add : Bin Num x Bin Num Bin Num is intended to implement addition on members of BinNum. It is defined by the following equations using recursion and pattern matching add(u, Zero) = u. add (Zero.u) = u add(One, One) = JoinZero(One). add(JoinZero(u), One) = JoinOne(u). add(One, JoinZero(u)) = Joinoneu). add (JoinOneu), One) = JoinZero (add(u, One). add(One, Join One()) = JoinZero (add(u, One). add (JoinZero(u), JoinZero(u)) = JoinZero(add(u, v). add(JoinOne(u), JoinZero(u)) = Join One(add(u, v). add(JoinZero(u), Join One(u)) = Join One(add(u, v). add(JoinOne(u), JoinOne()) = JoinZero(add(add(u, v), One)). 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 BinNum, 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

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions