# lecture04 - CS 70 Discrete Mathematics for CS Spring 2005...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 70 Discrete Mathematics for CS Spring 2005 Clancy/Wagner Notes 4 This lecture completes our general introduction to proof methods. We begin with examples of induction principles for domains other than the natural numbers, including strings, trees, and pairs of numbers. We then introduce the general principle of well-founded induction , which yields as special cases all sorts of induction principles for all sorts of domains. Induction over things besides numbers Persons other than pure mathematicians often write programs that manipulate objects other than natural numbersfor example, strings, lists, trees, arrays, hash tables, programs, airline schedules, and so on. So far, the examples of induction we have seen deal with induction over the natural numbers. How does this help with these other domains? One answer is that we can do inductive proofs over natural numbers that correspond to the size of the objects under consideration. Suppose we want to prove that 2200 s P ( s ) for the domain of strings . Then define STRINGS a proposition on natural numbers as follows: Q ( n ) is the property that every string s of length n satisfies P ( s ) . Then a proof that 2200 n Q ( n ) by induction on n establishes that 2200 s P ( s ) . Similarly, we can prove things about trees by induction on the depth of the tree, or about programs by induction on the number of symbols in the program. These inductions can become quite cumbersome and unnatural. Lets suppose we had never heard of the natural numbers; could we still do anything with strings and trees and programs? It turns out that we can define very natural induction principles for these sorts of objects without mentioning numbers at all. An induction principle for strings Lets write a recursive algorithm for reversing a string and show that it works correctly. First, we will need to say what strings are. The elements of a string are symbols drawn from a set of SYMBOLS symbols called an alphabet , which is usually denoted . For example, if = { a , b } , then strings can consist ALPHABET of sequences of a s and b s. * denotes the set of all possible strings on the alphabet , and always includes the empty string, which is denoted . Every symbol of is also a string of length 1. (Note: this property in particular distinguishes strings from lists; but in general reasoning about strings is quite similar to reasoning about lists.) The basic way to construct strings is by concatenation . If s 1 and s 2 are strings, then their concatenation is CONCATENATION also a string and is written s 1 s 2 or s 1 s 2 if punctuation is needed for clarity. Concatenation is defined as follows: Axiom 4.1 (Concatenation) : CS 70, Spring 2005, Notes 4 1 2200 s * s = s = s 2200 a 2200 s 1 , s 2 * ( a s 1 ) s 2 = a ( s 1 s 2 ) Just as Peano did for the natural numbers, we now provide axioms concerning what strings are, then we state an induction principle that allows proofs for all strings. Strings satisfy the following axioms:state an induction principle that allows proofs for all strings....
View Full Document

## This note was uploaded on 09/03/2011 for the course CS 70 taught by Professor Papadimitrou during the Fall '08 term at University of California, Berkeley.

### Page1 / 7

lecture04 - CS 70 Discrete Mathematics for CS Spring 2005...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online