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 205 — #213<br />

7.1. Recursive Definitions and Structural Induction 205<br />

Definition 7.1.3. The concatenation s t of the strings s; t 2 A is defined recursively<br />

based on Definition 7.1.1:<br />

Base case:<br />

Constructor case:<br />

t WWD t:<br />

ha; si t WWD ha; s ti :<br />

7.1.1 Structural Induction<br />

Structural induction is a method <strong>for</strong> proving that all the elements of a recursively<br />

defined data type have some property. A structural induction proof has two parts<br />

corresponding to the recursive definition:<br />

Prove that each base case element has the property.<br />

Prove that each constructor case element has the property, when the constructor<br />

is applied to elements that have the property.<br />

For example, in the base case of the definition of concatenation 7.1.3, we defined<br />

concatenation so the empty string was a “left identity,” namely, s WWDs. We want<br />

the empty string also to be “right identity,” namely, s D s. Being a right identity<br />

is not part of Definition 7.1.3, but we can prove it easily by structural induction:<br />

Lemma 7.1.4.<br />

s D s<br />

<strong>for</strong> all s 2 A .<br />

Proof. The proof is by structural induction on the recursive definition 7.1.3 of concatenation.<br />

The induction hypothesis will be<br />

P.s/ WWD Œs D s:<br />

Base case: (s D ).<br />

s D <br />

D ( is a left identity by Def 7.1.3)<br />

D s:

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

Saved successfully!

Ooh no, something went wrong!