lecture09 - 3/3/2009 Induction COMPUTER SCIENCE 51 Spring...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 COMPUTER SCIENCE 51 Spring 2009 cs51.seas.harvard.edu Prof. Greg Morrisett Prof. Ramin Zabih Induction But we don’t want to argue based on their current hardware Want our programs to run correctly and efficiently on arbitrary inputs Prove an infinite set of statements? P[1] = “my factorial program is correct when the input is 1” P[2], P[3], … Gets old fast! Induction recipe 1. What variable n are you doing induction on, and what is its type? 2. What statement P[n] will you prove? 3. Prove P[1] (first element, can be 0) 4. For an arbitrary n, prove P[n+1] follows from P[n]. Induction Hypothesis (must be used!) Recipe use (math) 1. Variable is positive integer n 2. Statement: 3. Proof of P[1] 4. Want to show (via IH!): English ambiguity in IH Need: for all n, P[n] implies P[n+1] We pick an n and assume P[n] (IH) Then derive P[n+1] It’s always true that For all n, P[n] implies For all n, P[n+1] Math notation helps n ( P[n] P[n+1] ) versus n ( P[n]) n(P[n+1] ) Example notes IH versus statement This theorem is very easy in binary Related to many exponentially growing functions “Everything is at the leaves” Explains iterative deepening
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/26/2009 for the course COMPUTERSC CS51 taught by Professor Gregmorrisett during the Spring '09 term at Harvard.

Page1 / 4

lecture09 - 3/3/2009 Induction COMPUTER SCIENCE 51 Spring...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online