



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




As a computer scientist it is not enough to dream up an algorithm and verify that it works for your favorite test cases. Mathematical proof is what converts today’s intellectual gossip, speculation, and heresy into tomorrow’s textbook subject. In short, “you have not shown me anything until you’ve proved it.” For this class, proofs come in handy for three important reasons:
Proof strategies:
Name of Strategy Goal Strategy Direct proof prove p → q assume p, show q Indirect proof prove p → q assume ¬q, show ¬p Proof by contradiction prove p → q assume ¬q, p, show a contradiction Proof by cases prove p 1 ∨ · · · ∨ pn → q ∀i ∈ { 1 ,... , n} prove pi → q Counterexample prove p → q show by example that q is false
Example 1. Recall the linear-search algorithm from Example 1 of Lecture 2. By examining the code, give both a direct and indirect proof of the following statement: “If x is a member of array a[], then the algorithm returns “true”.
Example 2. Prove by cases that the linear-search algorithm from Example 1 of Lecture 2 is correct.
Mathematical Induction
A proof by induction is analogous to knocking over a row of dominoes by pushing over the fist dominoe in the row.
Example 5. Use mathematical induction to prove that
1 + 2 + · · · + n =
n(n + 1) 2
Example 6. Use mathematical induction to prove that n! > 2 n^ for n ≥ 4
Example 7. Determine which amounts of postage can be formed using just 5-cent and 6-cent stamps. Prove your answer using math induction.
Example 8. For nonnegative integers x and y with x < y, prove that
x ≤
x + y 3
≤ y.