Formal Methods Midterm 1, Spring, 2007 Name Show Your Work! Point values are in square brackets. There are 35 points possible. Tables of tautologies and contradictions are on the last page. 1. Use truth tables to prove that the following logical expressions are tautologies. [6 points] (a) P (P Q) (b) (P Q) P (c) [P (P Q)] Q (a) (b) (c) P Q P Q P (P Q) T T T T T F T T F T T T F F F T P Q P Q (P Q) P T T T T T F F T F T F T F F F T P Q P Q P (P Q) [P (P Q)] Q T T T T T T F F F T F T T F T F F T F T 1
2. Without using a truth table, prove that (P Q) (P Q) is a tautology. You can use any of the facts on page 7. [3] We give two proofs. The first uses the table of tautologies. The second uses our knowledge of the various logical operators. First Proof. (P Q) (P Q) (P Q) (P Q) Tautology 5 ( P Q) (P Q) Tautology 1.1d (P P ) (Q Q) Tautologies 6 and 1.2i T T Tautology 1 T Tautology 2 Second Proof. An implication can be false only if the hypothesis is true and the conclusion is false. Our hypothesis is P Q, which can only be true if both P and Q are true. But if both P and Q are true, then our conclusion, P Q, must also be true. So whenever the hypothesis is true, the conclusion must also be true. So the implication (P Q) (P Q) is always true, and hence a tautology. 3. Which (if any) of the following expressions are tautologies? Which (if any) are contradictions? You don t need to prove anything. [4] (a) P P Neither (b) P P Neither (c) P Neither (d) P P A tautology 2
4. Suppose that f(x) is a real-valued function defined on all the real numbers. Consider the following definitions. i. f(x) is injective iff for all real numbers x and for all real numbers y, f(x) = f(y) implies x = y. ii. f(x) is surjective iff for each real number y, there exists a real number x such that f(x) = y. Give clear, idiomatic definitions of the following expressions. (a) f(x) is not injective. (b) f(x) is not surjective. [4] (a) f(x) is not injective iff there exists a real number x and there exists a real number y, such that f(x) = f(y) but x y. (b) f(x) is not surjective iff there exists a real number y such that for each real number x, f(x) y. 5. Sally wants to prove that if n 2 is odd, then n is odd. She s decided to prove the contrapositive. (a) What can Sally assume? (b) What should she prove? (You don t need to prove anything.) [4] The contrapositive of P Q is Q P. In Sally s theorem, P is n 2 is odd, and Q is n is odd. (a) So Sally should assume that n is not odd. In light of a theorem proved in class, this is equivalent to assuming that n is even. (b) Sally should prove that n 2 is not odd. Once again, in light of a theorem proved in class, this is equivalent to proving that n 2 is even. 3
6. Bob is trying to prove the following theorem. If n is a positive integer that is not a perfect square, then n is irrational. He s decided to try using proof by contradiction. (a) What should Bob assume? (b) At some point in his proof, Bob deduces that 0 = 1. He asserts that this is the desired contradiction. Sally says that Bob is mistaken: a contradiction must have the form R R for some statement R. Who s right? Bob or Sally? (You don t need to prove anything.) [4] Bob wants to prove P Q by contradiction, where P is n is a positive integer that is not a perfect square, and Q is n is irrational. (a) In a proof by contradiction, you assume P Q. So Bob should assume that n is a positive integer that is not a perfect square. He should also assume that n is not irrational, i.e., n is rational. (b) Contrary to what the text says, a proof by contradiction does not require that we deduce a statement having the form R R. It only requires that we deduce a false statement. Since 0 = 1 is false, it will serve as the desired contradiction. Bob is right. 7. Bob and Sally have determined that the following statement is false. There exist positive integers n, a, b, and c such that n 3 and a n + b n = c n. However, they can t agree on how to show the statement is false. Bob says that they just need to find a counterexample. Sally says that they need to prove a theorem. Who s right? (You don t need to prove anything.) [2] This time Sally wins the prize. A counterexample will disprove a statement that has the form xp (x). In order to disprove a statement that has the form yq(y), you need to show y Q(y). So they need to prove that for all positive integers n, a, b, and c such that n 3, a n + b n c n. (This, by the way, is known as Fermat s last theorem, and, until recently, it was one of the most famous unsolved problems in mathematics.) 4
8. Suppose x is an irrational number. Prove that 1/x is also irrational. [3] Proof. First note that 0 = 0/1 is rational. So if x is irrational, x 0. So 1/x is a real number. Furthermore, since x 1/x = 1, 1/x 0. Now in order to prove that 1/x is irrational, we use contradiction. So we assume that x is irrational, but 1/x is rational. Since 1/x is rational, there exist integers m and n with n nonzero such that 1/x = m/n. Then since n 0 and 1/x 0, n 1/x = m is nonzero. Multiplying both sides of this equation by x gives n = xm, and since m is nonzero, n/m = x. But this says that x is rational, contradicting our assumption that x is irrational. Thus, the assumption that 1/x is rational must be false, and if x is irrational, then 1/x is also irrational. 5
9. Consider the following two statements. i. There exists a nonzero integer n such that for every real number x, x n. ii. For every real number x, there exists an integer n such that x n. One statement is true. The other is false. Which is which? (You don t need to prove anything.) [2] The first statement says that there is an integer n with the property that every real number is less than or equal to n. Clearly, this is false. For example, if n is any integer, then n + 1 is a real number, and n < n + 1. The second statement says that given a real number x, there is an integer that s at least as large as x. This, of course, is true. For example, if the decimal expansion of x is y.d 1 d 2 d 3..., then y is an integer and y + 1 is an integer that s greater than or equal to x. 10. Give a direct proof of the fact that for every rational number q, there exists a nonzero integer n such that nq is an integer. [3] Proof. Suppose that q is a rational number. Then there exist integers r and s, such that s 0 and q = r/s. So if n = s, we have n q = n r s = s r s = r, which, of course, is an integer. So n is a nonzero integer such that nq is an integer. 6
Tautologies 1. P P 2. P T 3. (P F) P 4. (P Q) ( Q P ) 5. (P Q) ( P Q) 6. (P Q) (Q P ) Commutativity 7. (P Q) (Q P ) Commutativity 8. (P P ) P 9. (P P ) P 1.1a (P Q) ( P Q) 1.1b (P Q) P Q 1.1c (P Q) P Q de Morgan Law 1.1d (P Q) P Q de Morgan Law 1.1e ( P ) P 1.2a P P 1.2b (P Q) (Q P ) 1.2c (P Q) ( P Q) 1.2d [(P Q) (Q P )] (P Q) 1.2e [(P Q) (Q R)] (P R) Transitivity 1.2f [(P Q) (Q R)] (P R) Transitivity 1.2g [P (Q R)] [(P Q) (P R)] Distributivity 1.2h [P (Q R)] [(P Q) (P R)] Distributivity 1.2i [(P Q) R)] [P (Q R)] Associativity 1.2j [(P Q) R)] [P (Q R)] Associativity 1.2k ( P Q Q) P 1.3a (P Q) (R P R Q) 1.3b (P Q) (R P R Q) Contradictions 1. P P 2. P F 1.4a (P Q) (P Q) 1.4b [(P Q) P ] Q 1.4c (P Q) P 7