Presentation is loading. Please wait.

Presentation is loading. Please wait.

Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,

Similar presentations


Presentation on theme: "Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,"— Presentation transcript:

1 Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs, Recursion and Analysis of Algorithms

2 Section 2.1Proof Techniques1 Section 2.1: Proof Techniques Chapter 1: formal proofs The problem: show the validity of theorems represented in the form P  Q, where P and Q may be compound statements. Validity proof: Given a set of hypotheses (the antecedent of the implication) and using equivalence rules and rules of inference from predicate logic, show that Q follows logically from P. Validity of the implication is based on its structure so if a proof is valid it is universally valid, regardless of the semantics of the individual components of the antecedent and the consequent. For example, it was shown that if (P  Q)  (Q  R), then (P  R) This is valid regardless of what P, Q, and R represent. (Remember, we say if the antecedent is true then the consequent is true.)

3 Section 2.1Proof Techniques2 Section 2.1: Proof Techniques In Chapter 2, we deal with proofs for things that aren’t universally true but only apply within a certain context – graph theory, number theory, the animal kingdom, etc. To prove theorems of this sort we can add facts from the context that act as hypotheses. For example, if the context is number theory, and we are asked to prove that the product of two even integers is also even, we can use knowledge about number theory. In particular, we could use the fact that an even integer is divisible by 2, or that an even integer m can be rewritten as 2k for some integer k. In this example, P(x, y) : x is an even integer  y is an even integer Q(x, y): xy is an even integer It can be proven that P(x,y)  Q(x, y), but this is true only for the domain of integers. Proofs of this sort are often presented in a more informal manner, and don’t rely solely on rules of inference and equivalences.

4 Section 2.1Proof Techniques3 A few terms to remember: Axioms: Statements that are assumed true. Example: Given two distinct points, there is exactly one line that contains them. Axioms can be used as hypotheses in proofs Definitions: Used to create new concepts in terms of existing ones. Theorem: A proposition that has been proven to be true. Conjecture: an opinion based on incomplete information. In order to turn a conjecture into a theorem, we must find a way to prove it. Or, by disproving it, show that no proof exists Definitions and axioms can be used in the proof process..

5 Section 2.1Proof Techniques4 Inductive reasoning versus deductive reasoning Inductive reasoning is drawing conclusions based on experience A way of developing conjectures Not a proof Deductive reasoning: determines the truth or falsity of a conjecture through proofs or counter examples Informal proof methods : Proof by exhaustive enumeration Direct proof Proof by contraposition Proof by contradiction Serendipity (not really a proof technique)

6 Section 2.1Proof Techniques5 Deductive Reasoning: Using Counterexamples Inductive reasoning: Drawing a conclusion from a hypothesis based on experience. Usually, deductive reasoning is also applied to the same conjecture to ensure that it is indeed correct. Deductive reasoning may start by looking 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!  n 2.” Start testing some cases say, n = 1, 2, 3 etc. This is true for some cases but now let n = 4. We get n! = 24 and n 2 = 16; a counterexample for this conjecture. Note that finding a single case that doesn’t satisfy the condition is enough to disprove the theorem, because formally our conjecture states  (x) P(x)  Q(x) On the other hand, finding a single example where the conjecture is true (or even many examples) is not enough to prove it is true.

7 Section 2.1Proof Techniques6 Counterexample Practice: Find a counterexample for each of the following conjectures: All animals living in the ocean are fish. Everyone in this class is a computer engineer. Disproof by counterexample: relatively common Proof by example: not so much. Works only if you are able to consider every case that the conjecture applies to. This leads to the following definition: Exhaustive enumeration (proof by exhaustion) is a proof technique that can be applied to conjectures that are applied to a finite set of objects.

8 Section 2.1Proof Techniques7 Exhaustive Proof In a finite domain in which the conjecture is to be proven valid, then to use the exhaustive proof technique, you must try all possible cases for each member of the domain. Final result of this exercise: you prove or disprove the theorem but you could be definitely exhausted. Example: For any non-negative 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. nn2n2 10+5nn 2 < 10+5n 0010yes 1115yes 2420yes 3925yes 41630yes 52535yes

9 Section 2.1Proof Techniques8 Example: Exhaustive Proof Example : If an integer between 1 and 20 is divisible by 6, then it is also divisible by 3. See the proof in Table 2.1, page 91 Example: Prove the conjecture “It is not possible to trace all the lines in Figure 2.1 without lifting your pencil and without retracing any lines” Tedious, but possible, to enumerate and try all possible cases The number of theorems that are proven using proof by exhaustion is relatively small.

10 Section 2.1Proof Techniques9 Direct Proof Proof methods: Proof by exhaustive enumeration Direct proof Proof by contraposition Proof by contradiction Serendipity (not really a proof technique) and disproof by counterexample Direct Proof: Used when exhaustive proof/disproof by counterexample don’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 formal direct proof would start by listing the hypotheses and then applying inference rules and equivalence rules to (hopefully) produce the desired result.

11 Section 2.1Proof Techniques10 Direct Proof For example (see pages 92-93 for complete proof sequence) 1. x is an even integer Λ y is an even integer hyp 2. (  x)[x is even integer  (  k)(k is an integer Λ x = 2k)] number fact (definition of even integer) 3. x is even integer  (  k)(k is an integer Λ x = 2k) 2,ui 4. y is even integer  (  k)(k is an integer Λ y = 2k) 2,ui 5. x is an even integer 1,sim 6. (  k)(k is an integer Λ x = 2k) 3,5,mp 7. m is an integer Λ x = 2m 6, ei 8. y is an even integer 1,sim …. xy is an even integer 19, 21, mp Note That in step 2, a fact has been introduced that is unique to the domain of integers. The use of new inference rules: ui = universal instantiation, and ei = existential instantiation

12 Section 2.1Proof Techniques11 Informal Direct Proof Informal direct proofs simplify the process of writing out a proof but they do not skip any essential steps – they are just as complete in terms of rigor and correctness. Example: a theorem might be stated as P(x)  Q(x). If the proof is made for an arbitrary element of the domain, we can safely generalize to the more formal statement  (x) P(x)  Q(x). Informal proof that the product of two even integers, x & y, is also even: (page 93) Let x = 2m and y = 2n, where m & n are integers Then xy = (2m)(2n) = 2(2mn). Thus the product xy has the form 2k, where k is an integer. The proof doesn’t explicitly state the hypothesis, (that x and y are even) or the definition of even integer, which is used in the first step. Nevertheless it is clear about each step and doesn’t leave out any important information. There are times, even in an informal proof, when it is useful to explain the reason for a step in the proof. It’s better to be too complete than to leave out something significant.

13 Section 2.1Proof Techniques12 Proof by Contraposition Sometimes you aren’t successful generating a direct proof of P  Q. In this case, consider using one of the inference rules of propositional logic, known as contraposition (termed “cont” in short). See Table 1.14 (page 133). It states that (Q  P)  (P  Q) (a Tautology). Remember that a tautology is a wff that is true in every case, regardless of the truth values assigned to the individual components. Q  P is the contrapositive of P  Q. Hence, proving the contrapositive proves the conjecture.

14 Proof by Contraposition Example: Prove that if the square of an integer is odd, then the integer must be odd Hence, prove n 2 odd  n odd To do a proof by contraposition prove n even  n 2 even If n is even, then it can be written as 2m where m is an integer, i.e. even/odd. Then, n 2 = 4m 2 which is always even no matter what m 2 is because of the factor 4. We’ve proved that if the square of an integer is even, then the integer is even. Since this is the contrapositive of what we set out to prove, we have also proven our original conjecture. Section 2.1Proof Techniques13

15 If and Only If Theorems A theorem that states “Q is true if and only if P is true” means that you must prove both P → Q and Q → P Q → P is the converse of P → Q Example 9 (p. 94): xy is odd if and only if both x and y are odd integers. Assume both are odd. Then x = 2n +1, y = 2m +1 xy = (2n + 1)(2m +1) = 2(wnm + m + n) + 1 or 2k +1 We’ve proven the “if” part – now the “only if”. i.e., if xy is odd then both x and y are odd – or, easier, prove the contrapositive: (x odd and y odd) → (xy even) Use DeMorgan’s law, rewrite as x even or y even → xy even There are then three cases, based on the possible values of x and y Section 2.1Proof Techniques14

16 Section 2.1Proof Techniques15 Proof by Contradiction Derived from the definition of contradiction which says P Λ Q  0 Hence, (P Λ Q  0)  (P  Q) is a tautology. In a proof by contradiction, one assumes that the hypothesis is true, the negation of the conclusion is true, and that these assumptions lead to a contradiction. 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).

17 Section 2.1Proof Techniques16 Proof by Contradiction Example 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 + n - k) = 1, where m + n - k is some integer. This is a contradiction since 1 is not even.

18 Section 2.1Proof Techniques17 Serendipity Serendipity: Fortuitous happening or something by chance or good luck. Not a formal proof technique. Interesting proofs provided by this method although other methods can be used as well. Example: 342 players in a tennis tournament. One winner in the end. Each match is between two players with exactly one winner and the loser gets eliminated. Prove the total number of matches played in the tournament are 341. Solution: Only one champion at the end of the tournament, hence ???

19 Section 2.1Proof Techniques18 Summarizing Proof techniques Proof Technique Approach to prove P  Q Remarks Exhaustive Proof Demonstrate P  Q for all cases May only be used for finite number of cases Direct ProofAssume P, deduce QThe standard approach- usually the thing to try Proof by Contraposition Assume Q, derive PUse this Q if as a hypothesis seems to give more ammunition then P would Proof by Contradiction Assume P Λ Q, deduce a contradiction Use this when Q says something is not true SerendipityNot really a proof technique Try thinking outside the box

20 Section 2.1Proof Techniques19 Class Exercise 1. Product of any 2 consecutive integers is even. 2. Product of 3 consecutive integers is even. 3. The square of an odd integer equals 8k+1 for some integer k. 4. The sum of two rational numbers is rational. 5. For some positive integer x, x + 1/x ≥ 2.


Download ppt "Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,"

Similar presentations


Ads by Google