06.03.2017 Views

Mathematics for Computer Science

e9ck2Ar

e9ck2Ar

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

“mcs” — 2017/3/3 — 11:21 — page 228 — #236<br />

228<br />

Chapter 7<br />

Recursive Data Types<br />

(b) Let rev.s/ be the reversal of the string s. For example, rev.001/ D 100. A<br />

palindrome is a string s such that s D rev.s/. For example, 11011 and 010010<br />

are palindromes.<br />

Give a cat-OK definition of the palindromes.<br />

(c) Give a cat-OK definition of the set P of strings consisting solely of 0’s whose<br />

length is a power of two.<br />

Problems <strong>for</strong> Section 7.2<br />

Practice Problems<br />

Problem 7.16.<br />

Define the sets F 1 and F 2 recursively:<br />

F 1 :<br />

F 2 :<br />

– 5 2 F 1 ,<br />

– if n 2 F 1 , then 5n 2 F 1 .<br />

– 5 2 F 2 ,<br />

– if n; m 2 F 1 , then nm 2 F 2 .<br />

(a) Show that one of these definitions is technically ambiguous. (Remember that<br />

“ambiguous recursive definition” has a technical mathematical meaning which does<br />

not imply that the ambiguous definition is unclear.)<br />

(b) Briefly explain what advantage unambiguous recursive definitions have over<br />

ambiguous ones.<br />

(c) A way to prove that F 1 D F 2 , is to show first that F 1 F 2 and second that<br />

F 2 F 1 . One of these containments follows easily by structural induction. Which<br />

one? What would be the induction hypothesis? (You do not need to complete a<br />

proof.)<br />

Problem 7.17. (a) To prove that the set RecMatch, of matched strings of Definition<br />

7.2.1 equals the set AmbRecMatch of ambiguous matched strings of Defini-

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!