06.03.2017 Views

Mathematics for Computer Science

e9ck2Ar

e9ck2Ar

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

236<br />

Chapter 7<br />

Recursive Data Types<br />

(g) Verify that if R and S are boring, then so is R [ S.<br />

(h) Verify that if R and S are boring, then so is R S.<br />

Hint: By cases: whether R and S are both 0-finite, whether R or S contains no<br />

all-0 words at all (including the empty word ), and whether neither of these cases<br />

hold.<br />

(i) Conclude by structural induction that all C-D languages are boring.<br />

So we have proved that the set .00/ of even length all-0 words is not a C-D<br />

language.<br />

Problem 7.23.<br />

We can explain in a simple and precise way how digital circuits work, and gain the<br />

powerful proof method of structural induction to verify their properties, by defining<br />

digital circuits as a recursive data type DigCirc. The definition is a little easier to<br />

state if all the gates in the circuit take two inputs, so we will use the two-input NOR<br />

gate rather than a one-input NOT, and let the set of gates be<br />

Gates WWD fNOR; AND; OR; XORg:<br />

A digital circuit will be a recursively defined list of gate connections of the <strong>for</strong>m<br />

.x; y; G; I / where G is a gate, x and y are the input wires, and I is the set of wires<br />

that the gate output feeds into as illustrated in Figure 7.5.<br />

Formally, we let W be a set w 0 ; w 1 ; : : : whose elements are called wires, and<br />

O … W be an object called the output.<br />

Definition. The set of digital circuit DigCirc, and their inputs and internal wires,<br />

are defined recursively as follows:<br />

Base case: If x; y 2 W , then C 2 DigCirc, where<br />

Constructor cases: If<br />

C D list..x; y; G; fOg// <strong>for</strong> some G 2 Gates;<br />

inputs.C/ WWD fx; yg;<br />

internal.C/ WWD ;:<br />

C 2 DigCirc;<br />

I inputs.C/; I ¤ ;;<br />

x; y 2 W .I [ internal.C//

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

Saved successfully!

Ooh no, something went wrong!