* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Chpt-3-Proof - WordPress.com
Foundations of mathematics wikipedia , lookup
Quantum logic wikipedia , lookup
Analytic–synthetic distinction wikipedia , lookup
Modal logic wikipedia , lookup
Statistical inference wikipedia , lookup
Mathematical logic wikipedia , lookup
Gödel's incompleteness theorems wikipedia , lookup
Intuitionistic logic wikipedia , lookup
Turing's proof wikipedia , lookup
Laws of Form wikipedia , lookup
Georg Cantor's first set theory article wikipedia , lookup
Sequent calculus wikipedia , lookup
Curry–Howard correspondence wikipedia , lookup
Law of thought wikipedia , lookup
Truth-bearer wikipedia , lookup
Propositional calculus wikipedia , lookup
Discrete Structures CSC 281 Logic Module – Part I (Propositional Logic) Review 1 Conditional propositions and logical equivalence A conditional proposition is of the form “If p then q” In symbols: p q Example: – p = " John is a programmer" – q = " Mary is a lawyer " – p q = “If John is a programmer then Mary is a lawyer" 5/23/2017 2 Truth table of p q p q pq T T T T F F F T T F F T or when p is false p q is true when both p and q are true 5/23/2017 3 Hypothesis and conclusion In a conditional proposition p q, p is called the antecedent or hypothesis q is called the consequent or conclusion If "p then q" is considered logically the same as "p only if q" 5/23/2017 4 Necessary and sufficient A necessary condition is expressed by the conclusion. A sufficient condition is expressed by the hypothesis. – Example: If John is a programmer then Mary is a lawyer" – Necessary condition: “Mary is a lawyer” – Sufficient condition: “John is a programmer” 5/23/2017 5 Logical equivalence Two propositions are said to be logically equivalent if their truth tables are identical. p q ~p q pq T T T F T F T F F F T F T T T T Example: ~p q is logically equivalent to p q 5/23/2017 6 Converse The converse of p q is q p p T q T pq T qp T T F F F T F F T T T F T These two propositions are not logically equivalent 5/23/2017 7 Contrapositive The contrapositive of the proposition p q is ~q ~p. p T q T pq T ~q ~p T T F F T F T F T F F T T They are logically equivalent. 5/23/2017 8 Double implication The double implication “p if and only if q” is defined in symbols as p q p q pq (p q) ^ (q p) T T T T T F F F F T F F F F T T p q is logically equivalent to (p q)^(q p) 5/23/2017 9 Tautology A proposition is a tautology if its truth table contains only true values for every case – Example: p p v q p q ppvq T T T T F T F T T F F T 5/23/2017 10 Contradiction A proposition is a tautology if its truth table contains only false values for every case – Example: p ^ ~p p p ^ (~p) T F F F 5/23/2017 11 De Morgan’s laws for logic The following pairs of propositions are logically equivalent: – ~ (p q) and (~p)^(~q) – ~ (p ^ q) and (~p) (~q) 5/23/2017 12 Quantifiers A propositional function P(x) is a statement involving a variable x For example: – P(x): 2x is an even integer x is an element of a set D – For example, x is an element of the set of integers D is called the domain of P(x) 13 5/23/2017 Domain of a propositional function In the propositional function P(x): “2x is an even integer”, the domain D of P(x) must be defined, for instance D = {integers}. D is the set where the x's come from. 5/23/2017 14 For every and for some Most statements in mathematics and computer science use terms such as for every and for some. For example: – For every triangle T, the sum of the angles of T is 180 degrees. – For every integer n, n is less than p, for some prime number p. 5/23/2017 15 Universal quantifier One can write P(x) for every x in a domain D – In symbols: x P(x) is called the universal quantifier 5/23/2017 16 Truth of as propositional function The statement x P(x) is – True if P(x) is true for every x D – False if P(x) is not true for some x D Example: Let P(n) be the propositional function n2 + 2n is an odd integer n D = {all integers} P(n) is true only when n is an odd integer, false if n is an even integer. 5/23/2017 17 Existential quantifier For some x D, P(x) is true if there exists an element x in the domain D for which P(x) is true. In symbols: x, P(x) The symbol is called the existential quantifier. 5/23/2017 18 Counterexample The universal statement x P(x) is false if x D such that P(x) is false. The value x that makes P(x) false is called a counterexample to the statement x P(x). – Example: P(x) = "every x is a prime number", for every integer x. – But if x = 4 (an integer) this x is not a primer number. Then 4 is a counterexample to P(x) being true. 5/23/2017 19 Generalized De Morgan’s laws for Logic If P(x) is a propositional function, then each pair of propositions in a) and b) below have the same truth values: a) ~(x P(x)) and x: ~P(x) "It is not true that for every x, P(x) holds" is equivalent to "There exists an x for which P(x) is not true" b) ~(x P(x)) and x: ~P(x) "It is not true that there exists an x for which P(x) is true" is equivalent to "For all x, P(x) is not true" 5/23/2017 20 Summary of propositional logic In order to prove the universally quantified statement x P(x) is true – It is not enough to show P(x) true for some x D – You must show P(x) is true for every x D In order to prove the universally quantified statement x P(x) is false – It is enough to exhibit some x D for which P(x) is false – This x is called the counterexample to the statement x P(x) is true Discrete Structures CSC 281 Logic Module – Part II (proof methods) 22 Acknowledgement Most of these slides were either created by Professor Bart Selman at Cornell University or else are modifications of his slides 23 Methods for Proving Theorems 24 Theorems, proofs, and Rules of Inference When is a mathematical argument correct? What techniques can we use to construct a mathematical argument? Theorem – is a true proposition that is guaranteed by a proof. Axioms or postulates – statements which are given and assumed to be true. Proof – sequence of statements, a valid argument, to show that a theorem is true. Rules of Inference – rules used in a proof to draw conclusions from assertions known to be true. Note: • Lemma is a small theorem which is used to prove a bigger theorem. • A corollary is a theorem that can be proven to be a logical consequence of another theorem. • Conjecture is a statement believed to be true but for which there is not a proof yet. If the conjecture is proved true it becomes a thereom. o Fermat’s theorem was a conjecture for a long time. 25 Rules of Inference 26 Propositional logic: Rules of Inference or Methods of Proof How to produce additional wffs (sentences) from other ones? What steps can we perform to show that a conclusion follows logically from a set of hypotheses? Example Modus Ponens P PQ ______________ Q The hypotheses (premises) are written in a column and the conclusions below the bar The symbol denotes “therefore”. Given the hypotheses, the conclusion follows. The basis for this rule of inference is the tautology (P (P Q)) Q) [aside: check tautology with truth table to make sure] In words: when P and P Q are True, then Q must be True also. (meaning of second implication) 27 Propositional logic: Rules of Inference or Methods of Proof Example: Modus Ponens If you study the CSC281 material You will pass You study the CSC281 material ______________ you will pass Nothing “deep”, but again remember the formal reason is that ((P ^ (P Q)) Q is a tautology. 28 Propositional logic: Rules of Inference See Table 1, p. 66, Rosen. Rule of Inference Tautology (Deduction Theorem) Name P PQ P (P Q) Addition PQ P (P Q) P Simplification P Q PQ [(P) (Q)] (P Q) Conjunction P PQ Q [(P) (P Q)] P Modus Ponens Q PQ P [(Q) (P Q)] P Modus Tollens PQ QR P R [(PQ) (Q R)] (PR) Hypothetical Syllogism (“chaining”) PQ P Q [(P Q) (P)] Q Disjunctive syllogism PQ P R QR [(P Q) (P R)] (Q R) Resolution Rules of inference for quantified statements 1. Universal instantiation – xD, P(x) – dD – Therefore P(d) 2. Universal generalization – P(d) for any d D – Therefore x, P(x) 3. Existential instantiation – x D, P(x) – Therefore P(d) for some d D 4. Existential generalization – P(d) for some d D – Therefore x, P(x) 30 5/23/2017 Valid Arguments An argument is a sequence of propositions. The final proposition is called the conclusion of the argument while the other proposition are called the premises or hypotheses of the argument. An argument is valid whenever the truth of all its premises implies the truth of its conclusion. How to show that q logically follows from the hypotheses (p1 p2 …pn)? Show that (p1 p2 …pn) q is a tautology One can use the rules of inference to show the validity of an argument. 31 Proof Tree Proofs can also be based on partial orders – we can represent them using a tree structure: – Each node in the proof tree is labeled by a wff, corresponding to a wff in the original set of hypotheses or be inferable from its parents in the tree using one of the rules of inference; – The labeled tree is a proof of the label of the root node. Example: Given the set of wffs: P, R, PQ Give a proof of Q R 32 Tree Proof P, P Q, Q, R, Q R P PQ R MP Q Conj. QR What rules of inference did we use? 33 Length of Proofs Why bother with inference rules? We could always use a truth table to check the validity of a conclusion from a set of premises. But, resulting proof can be much shorter than truth table method. Consider premises: p_1, p_1 p_2, p_2 p_3, …, p_(n-1) p_n To prove conclusion: p_n Inference rules: n-1 MP steps Truth table: 2n Key open question: Is there always a short proof for any valid conclusion? Probably not. The NP vs. co-NP question. (The closely related: P vs. NP question carries a $1M prize.) Valid Arguments An argument is a sequence of propositions. The final proposition is called the conclusion of the argument while the other propositions are called the premises or hypotheses of the argument. An argument is valid whenever the truth of all its premises implies the truth of its conclusion. How to show that q logically follows from the hypotheses (p1 p2 …pn)? Show that (p1 p2 …pn) q is a tautology One can use the rules of inference to show the validity of an argument. Vacuous proof - if one of the premises is false then (p1 p2 …pn) q is vacuously True, since False implies anything. 35 Arguments involving universally quantified variables Note: Many theorems involve statements for universally quantified variables: e.g., the following statements are equivalent: • “If x>y, where x and y are positive real numbers, then x2 > y2 ” • “xy (if x > y > 0 then x2 > y2) ” Quite often, when it is clear from the context, theorems are proved without explicitly using the laws of universal instantiation and universal generalization. 36 Methods of Proof Direct Proof Proof by Contraposition Proof by Contradiction Proof of Equivalences Proof by Cases Exhaustive Proof Existence Proofs Uniqueness Proofs Counterexamples 37 Direct Proof Proof of a statement pq Assume p From p derive q. 38 Example - direct proof Here’s what you know: Premises: Mary is a Math major or a CS major. If Mary does not like discrete math, she is not a CS major. If Mary likes discrete math, she is smart. Let Mary is not a math major. Can you conclude Mary is smart? Informally, what’s the chain of reasoning? M - Mary is a Math major C – Mary is a CS major D – Mary likes discrete math S – Mary is smart ((M C) (D C) (D S) (M)) S ? 39 Example - direct proof In general, to prove p q, assume p is true and show that q must also be true ((M C) (D C) (D S) (M)) S ? • Since, p is a conjunction of all the premises, we instead make the equivalent assumption that all of the following premises are true M C D C D S M • Then the truth of these premises are used to prove S is true 40 Example - direct proof 1. M C 2. D C 3. D S 4. M Given Given Given Given 5. C 6. D 7. S Disjunctive Syllogism (1,4) Modus Tollens (2,5) Modus Ponens (3,6) Mary is smart! QED QED or Q.E.D. --- quod erat demonstrandum “which was to be demonstrated” or “I rest my case” 41 Example 2: Direct Proof Theorem: If n is odd integer, then n2 is odd. n (n is odd) (n2 is odd) Two definitions: • The integer is even if there exists an integer k such that n = 2k. • An is odd if there exists an integer k such that n = 2k+1. • Note: An integer is either even or odd, but not both. • This is an immediate consequence of the division algorithm: If a and b are positive integers, then there exist unique integers q and r with a = qb + r and 0 r < b • Other proofs can also be given, depending on what previous facts have already been established. • This fact is not needed in the first proof, is needed in a later proofs. 42 Example 2: Direct Proof Theorem: (n) P(n) Q(n), where P(n) is “n is an odd integer” and Q(n) is “n2 is odd.” We will show P(n) Q(n) 43 Example 2: Direct Proof Theorem: If n is odd integer, then n2 is odd. Proof: Let p denote “n is odd integer” and q denote “n2 is odd”; we want to show that p q • Assume p, i.e., n is odd. • By definition n = 2k + 1, where k is some integer. • Therefore n2 = (2k + 1)2 = 4k2 + 4k + 1 = 2 (2k2 + 2k ) + 1, which is by definition an odd number (k’ = (2k2 + 2k ) ). QED Proof strategy hint: Go back to definitions of concepts and start by trying a direct proof. Proof by Contraposition Proof of a statement p q by contraposition • Recall the tautology of the equivalence of a implication and its contrapositive. p q q p (the contrapositive) • So, we can prove p q by establishing the equivalent statement that ¬q ¬ p • So, we prove the implication p q by first assuming q, and showing that p follows 45 Example 1: Proof by Contraposition Example: Prove that if a and b are integers, and a + b ≥ 15, then a ≥ 8 or b ≥ 8. (a + b ≥ 15) (a ≥ 8) v (b ≥ 8) (Assume q) (Show p) Suppose (a < 8) (b < 8). Then (a ≤ 7) (b ≤ 7), and (a + b) ≤ 14, and (a + b) < 15. Proof strategy: Note that negation of conclusion is easier to start with here. QED 46 Example 2: Proof by Contraposition Theorem For an integer n, if 3n + 2 is odd, then n is odd. I.e. For n integer, 3n+2 is odd n is odd Again, negation of conclusion is easy to start with. Try direct proof. Proof by Contraposition: Let p denote “3n + 2” is odd and q denote “n is odd”; we must show that p q • The contraposition of our theorem is ¬q ¬p n is even 3n + 2 is even • Now we can use a direct proof • Assume ¬q , i.e, n is even therefore n = 2 k for some k • Therefore 3 n + 2 = 3 (2k) + 2 = 6 k + 2 = 2 (3k + 1) which is even. QED Proof by Contradiction A – We want to prove p. We show that: (1) ¬p F (i.e., a False statement , say r ¬r) (2) We conclude that ¬p is false since (1) is True and therefore p is True. B – We want to show p q (1) Assume the negation of the conclusion, i.e., ¬q (2) Show that (p ¬q ) F (3) Since ((p ¬q ) F) (p q) (why?) we are done ((p ¬q ) F) (p ¬q ) p q 48 Example 1: Proof by Contradiction Example: Hmm. We will assume “not Hot” ≡ “Cold” Rainy days make gardens grow. Gardens don’t grow if it is not hot. When it is cold outside, it rains. Let R – Rainy day G – Garden grows H – It is hot Prove that it’s hot. Given: R G H G H R Show: H ((R G) (H G) (H R)) H ? 49 Example 1: Proof by Contradiction Given: R G H G H R Show: H 1. R G 2. H G 3. H R 4. H Aside: we assume it’s either Hot or it is not Hot. Called the “law of excluded middle”. In certain complex arguments, it’s not so clearly valid. (hmm…) This led to “constructive mathematics” and “intuitionistic mathematics”. Given Given Given assume negation of conclusion 5. R 6. G MP (3,4) MP (1,5) 7. G 8. G G MP (2,4) contradiction H 50 Example2: Proof by Contradiction Classic proof that 2 is irrational. It’s quite clever!! Suppose 2 is rational. Then 2 = a/b for some integers a and b (relatively prime; no factor in common). Note: Here we again first go to the definition of concepts (“rational”). Makes sense! Definitions provide 2 = a/b implies information about important concepts. 2 = a2/b2 In a sense, math is all about “What 2b2 = a2 follows from the definitions and premises! a2 is even, and so a is even (a = 2k for some k) 2b2 = (2k)2 = 4k2 b2 = 2k2 b2 is even, and so b is even (b = 2k for some k) But if a and b are both even, then they are not relatively prime! Q.E.D. 51 Example2: Proof by Contradiction You’re going to let me get away with that? Lemma: a2 is even implies that a is even (i.e., a = 2k for some k)?? Suppose to the contrary that a is not even. Then a = 2k + 1 for some integer k Then a2 = (2k + 1)(2k + 1) = 4k2 + 4k + 1 and a2 is odd. Then, as discussed earlier, a2 is not even So, a really is even. contradiction Corollary: An integer n is even if and only if n2 is even Why does the above statement follow immediately from previous work??? 52 Example 3: Proof Theorem: “There are infinitely many prime numbers” by Contradiction (Euclid’s proof, c 300 BC) One of the most famous early proofs. An early Proof by contradiction intellectual “tour the force”. Let P – “There are infinitely many primes” • Assume ¬P, i.e., “there is a finite number of primes” , call largest p_r. • Let’s define R the product of all the primes, i.e, R = p_1 × p_2 × … × p_r. • Consider R + 1. (Clever “trick”. The key to the proof.) • Now, R+1 is either prime or not: – If it’s prime, we have prime larger than p_r. – If it’s not prime, let p* be a prime dividing (R+1). But p* cannot be any of p_1, p_2, … p_r (remainder 1 after division); so, p* not among initial list and thus p* is larger than p_r. • This contradicts our assumption that there is a finite set of primes, and therefore such an assumption has to be false which means that there are infinitely many primes. Also, non-constructive. See e.g. http://odin.mdacc.tmc.edu/~krc/numbers/infitude.html http://primes.utm.edu/notes/proofs/infinite/euclids.html Example 4: Proof by Contradiction Theorem “If 3n+2 is odd, then n is odd” Let p = “3n+2 is odd” and q = “n is odd” 1 – assume p and ¬q i.e., 3n+2 is odd and n is not odd 2 – because n is not odd, it is even 3 – if n is even, n = 2k for some k, and therefore 3n+2 = 3 (2k) + 2 = 2 (3k + 1), which is even 4 – So, we have a contradiction, 3n+2 is odd and 3n+2 is even. Therefore, we conclude p q, i.e., “If 3n+2 is odd, then n is odd” Q.E.D. 54 Proof of Equivalences To prove p q show that p q and q p. The validity of this proof results from the fact that (p q) [ (p q) (q p)] is a tautology 55 Counterexamples Show that (x) P(x) is false We need only to find a counterexample. 56 Counterexample Show that the following statement is false: “Every day of the week is a weekday” Proof: Saturday and Sunday are weekend days. 57 Proof by Cases To show (p1 p2 … pn ) q We use the tautology [(p1 p2 … pn ) q ] [(p1 q ) (p2 q) … (pn q )] A particular case of a proof by cases is an exhaustive proof in which all the cases are considered 58 Theorem “If n is an integer, then n2 ≥ n ” Proof by cases Case 1 n=0 02 = 0 Case 2 n > 0, i.e., n 1. We get n2 ≥ n since we can multiply both sides of the inequality by n, which is positive. Case 3 n < 0. Then nn > 0n since n is negative and multiplying both sides of inequality by n changes the direction of the inequality). So, we have n2 > 0 in this case. In conclusion, n2 ≥ n since this is true in all cases. 59 Existence Proofs Existence Proofs: • Constructive existence proofs o Example: “there is a positive integer that is the sum of cubes of positive integers in two different ways” o Proof: Show by brute force using a computer 1729 = 103 + 93 = 123 + 13 • Non-constructive existence proofs o Example: “n (integers), p so that p is prime, and p > n.” o Proof: Recall proof used to show there were infinitely many primes. o Very subtle – does not give an example of such a number, but shows one exists. (Let P = product of all primes < n and consider P+1. ) Uniqueness proofs involve • Existence proof • Uniqueness proof 60 NON-CONSTRUCTIVE Example 1 - Existence Proofs n (integers), p so that p is prime, and p > n. Proof: Let n be an arbitrary integer, and consider n! + 1. If (n! + 1) is prime, we are done since (n! + 1) > n. But what if (n! + 1) is composite? If (n! + 1) is composite then it has a prime factorization, p1p2…pn = (n! + 1) Consider the smallest pi, and call it p. How small can it be? Can it be 2? Can it be 3? Can it be 4? So, p > n, and we are done. BUT WE DON’T KNOWCan it be n? WHAT p IS!!! 61 Example 2: Existence proof Thm. There exists irrational numbers x and y such that xy is rational. Proof. 2 is irrational (see earlier proof). Consider: z = 2 2 “Start with something you know about rational / irrational numbers.” Non-constructive! We have two possible cases: 1) z is rational. Then, we’re done (take x = 2 and y = 2 ). 2) z is irrational. Now, let x = z and y = 2. And consider: x y = ( 2 2 ) 2 = 2(2 2) = 22 = 2 , which is rational. So, we’re done. Since, either 1) or 2) must be true, it follows that there does exist irrational x and y such that xy is rational. Q.E.D. Poisonous Example 3: Non-constructive proof From game theory. Consider the game “Chomp”. Two players. Players take turn eating at least one of the remaining cookies. At each turn, the player also eats all cookies to the left and below the cookie he or she selects. The player who is “forced” to eat the poisened cookie loses. Is there a winning strategy for either player? m x n cookies Winning strategy for a player: “A way of making moves” that is guaranteed to lead to a win, no matter what the opponent does. (How big to write down?) Claim: First player has a winning strategy! Proof. (non-constructive) First, note that the game cannot end in a “draw”. After at most m x n moves, someone has eaten the last cookie. Consider the following strategy for the first player: --- Start by eating the cookie in the bottom right corner. --- Now, two possibilities: 1) This is part of a winning strategy for 1st player (and thus player has winning strategy). OR 2) 2nd player can now make a move that is part of the winning strategy for the 2nd player. But, if 2) is the case, then 1st player can follow a winning strategy by on the first move making the move of the second player and following his or her winning strategy! So, again, 1st player has winning strategy. Q.E.D. Three possible moves This is called a “strategy stealing” argument. Think through carefully to convince yourself! (Actual strategy not known for general boards!) Corner is “null move” Is first choice of the bottom right cookie essential? If so, why? Fallacies Fallacies are incorrect inferences. Some common fallacies: 1. The Fallacy of Affirming the Consequent 2. The Fallacy of Denying the Antecedent 3. Begging the question or circular reasoning 65 The Fallacy of Affirming the Consequent If the butler did it he has blood on his hands. The butler had blood on his hands. Therefore, the butler did it. This argument has the form PQ Q P or ((PQ) Q)P which is not a tautology and therefore not a valid rule of inference 66 The Fallacy of Denying the Antecedent If the butler is nervous, he did it. The butler is really mellow. Therefore, the butler didn't do it. This argument has the form PQ ¬P ¬Q or ((PQ) ¬P) ¬Q which is not a tautology and therefore not a valid rule of inference 67 Begging the question or circular reasoning This occurs when we use the truth of the statement being proved (or something equivalent) in the proof itself. Example: Conjecture: if n2 is even then n is even. Proof: If n2 is even then n2 = 2k for some k. Let n = 2m for some m. Hence, x must be even. Note that the statement n = 2m is introduced without any argument showing it. 68 Notoriously hard problem automated theorem prover --- requires “true cleverness” Final example Tiling 62 squares: 32 black 30 white 31 doms.: 31 black 31 white squares! A domino Can you use 32 dominos to cover the board? Easily! (many ways!) What about the mutilated checkerboard? Hmm… No! Why? Use counting? X X Standard checkerboard. 8x8 = 64 squares What is the proof based upon? Proof uses clever coloring and counting argument. Note: also valid for board and dominos without b&w pattern! (use proof by contradiction) 69 Additional Proof Methods Covered in CSC281 • Induction Proofs • Combinatorial proofs But first we have to cover some basic notions on sets, functions, and counting. 70