Proofs, Recursion and Analysis of AlgorithmsProof TechniquesDeductive Reasoning: Counter ExampleCounterexampleExhaustive ProofExample: Exhaustive ProofDirect ProofDirect Proof Example (contd.)Indirect Proof: Proof by ContradictionProof by ContradictionProof by ContrapositionSerendipitySummarizing Proof techniquesClass ExerciseProofs, Recursion and Analysis of AlgorithmsMathematical Structures for Computer ScienceChapter 2Copyright © 2006 W.H. Freeman & Co. MSCS Slides Proofs, Recursion and Analysis of AlgorithmsSection 2.1 Proof Techniques 2Proof TechniquesInformal proof methods :Inductive reasoningDeductive reasoningProof by exhaustionDirect proofProof by contrapositionSerendipityA few terms to remember:Axioms: Statements that are always true.•Example: Given two distinct points, there is exactly one line that contains them.Definitions: Used to create new concepts in terms of existing ones.Theorem: A proposition that has been proved to be true.•Two special kinds of theorems: Lemma and Corollary.•Lemma: A theorem that is usually not too interesting in its own right but is useful in proving another theorem.•Corollary: A theorem that follows quickly from another theorem.Section 2.1 Proof Techniques 3Deductive Reasoning: Counter ExampleDeductive Reasoning: Drawing a conclusion from a hypothesis based on experience. Hence the more cases you find where P follows from Q, the more confident you are about the conjecture P Q.Usually, deductive reasoning is also applied to the same conjecture to ensure that it is indeed valid. Deductive reasoning looks for a counterexample that disproves the conjecture, i.e. a case when P is true but Q is false.Example: Prove that “For every positive integer n, n! n2.”Start testing some cases say, n = 1, 2, 3 etc.It might seem like it is true for some cases but how far do you test, say n = 4.We get n! = 24 and n2 = 16 which is a counter example for this theorem. Hence,even finding a single case that doesn’t satisfy the condition is enough to disprove the theorem.Section 2.1 Proof Techniques 4CounterexampleMore examples of counterexample:All animals living in the ocean are fish.Every integer less than 10 is bigger than 5.Counter example is not trivial for all cases, so we have to use other proof methods.Section 2.1 Proof Techniques 5Exhaustive ProofIf dealing with a finite domain in which the proof is to be shown to be valid, then using the exhaustive proof technique, one can go over all the possible cases for each member of the finite domain. Final result of this exercise: you prove or disprove the theorem but you could be definitely exhausted.Example: For any positive integer less than or equal to 5, the square of the integer is less than or equal to the sum of 10 plus 5 times the integer.n n210+5n n2 < 10+5n0 0 10 yes1 1 15 yes2 4 20 yes3 9 25 yes4 16 30 yes5 25 35 yesSection 2.1 Proof Techniques 6Example: Exhaustive ProofExample 1: If an integer between 1 and 20 is divisible by 6, then it is also divisible by 3.QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.Section 2.1 Proof Techniques 7Direct ProofDirect Proof:Used when exhaustive proof doesn’t work. Using the rules of propositional and predicate logic, prove P Q.Hence, assume the hypothesis P and prove Q. Hence, a formal proof would consist of a proof sequence to go from P to Q.Consider the conjecture x is an even integer Λ y is an even integer the product xy is an even integer.A complete formal proof sequence might look like the following: x is an even integer Λ y is an even integer hyp (x)[x is even integer (k)(k is an integer Λ x = 2k)] number fact (definition of even integer) x is even integer (k)(k is an integer Λ x = 2k) 2,ui y is even integer (k)(k is an integer Λ y = 2k) 2,ui x is an even integer 1,sim (k)(k is an integer Λ x = 2k) 3,5,mp m is an integer Λ x = 2m 6, ei y is an even integer 1,simSection 2.1 Proof Techniques 8Direct Proof Example (contd.)9. (k)(k is an integer Λ y = 2k) 4,8,mp 10. n is an integer and y = 2n 9, ei 11. x = 2m 7,sim 12. y = 2n 10, sim 13. xy = (2m)(2n) 11, 12, substitution of equals 14. xy = 2(2mn) 13, multiplication fact 15. m is an integer 7,sim 16. n is an integer 10, sim 17. 2mn is an integer 15, 16, number fact 18. xy = 2(2mn) Λ 2mn is an integer 14, 17, con 19. (k)(k is an integer Λ xy = 2k) 18,eg 20. (x)((k)(k is an integer Λ x = 2k) x is even integer) number fact (definition of even integer) 21. (k)(k an integer Λ xy = 2k) xy is even integer 20, ui 22. xy is an even integer 19, 21, mpSection 2.1 Proof Techniques 9Indirect Proof: Proof by ContradictionDerived from the definition of contradiction which says P Λ Q 0Hence, (P Λ Q 0) (P Q) is a tautology.In a proof of contradiction, one assumes that the hypothesis and the negation of the conclusion are true and then to deduce some contradiction from these assumptions.Example 1: Prove that “If a number added to itself gives itself, then the number is 0.”The hypothesis (P) is x + x = x and the conclusion (Q) is x = 0. Hence, the hypotheses for the proof by contradiction are:x + x = x and x 0 (the negation of the conclusion)Then 2x = x and x 0, hence dividing both sides by x, the result is 2 = 1, which is a contradiction. Hence, (x + x = x) (x = 0).Section 2.1 Proof Techniques 10Proof by ContradictionExample 2: Prove “For all real numbers x and y, if x + y 2, then either x 1 or y 1.”Proof: Say the conclusion is false, i.e. x < 1 and y < 1. (Note: or becomes and in negation.)Adding the two conditions, the result is x + y < 2. At this point, this condition is P if P = x + y 2, hence, P Λ P which is a contradiction. Hence, the statement above is true.Example 3: The sum of even integers is even.Proof: Let x = 2m, y = 2n for integers m and n and assume that x + y is odd.Then x + y = 2m + 2n = 2k + 1 for some integer k.Hence, 2*(m + k - n) = 1, where m + n - k is some integer.This is a contradiction since 1 is not even.Section 2.1 Proof Techniques 11Proof by ContrapositionUse the variants of P Q to prove the conjecture. From the inference rules of propositional logic, we know a rule called contraposition (termed “cont” in short). It
View Full Document