Mohamed G. Gouda CS 313K Fall 2012 Exercise 3 1. Show that the following quantified predicate R is equivalent to another quantified predicate that has no "not". R = not (All x, (P(x) -> (Exist y, not Q(x,y)))) Sol: R = {Predicate R} not (All x, (P(x) -> (Exist y, not Q(x,y)))) = {Implication} not (All x, (not P(x) or (Exist y, not Q(x,y)))) = {De-Morgan's} (Exist x, not (not P(x) or (Exist y, not Q(x,y)))) = {De-Morgan's} (Exist x, (P(x) and (not (Exist y, not Q(x,y))))) = {De-Morgan's} (Exist x, (P(x) and (All y Q(x,y)))) 2. Let the domains of x and y be the set of all integers. Compute the Boolean values of the following quantified predicates: All x, Exist y, (x^2 < y) Exist y, All x, (x^2 < y) Exist x, All y, (x^2 >= y) All y, Exist x, (x^2 >= y) Sol: All x, Exist y, (x^2 < y) = T Exist y, All x, (x^2 < y) = F Exist x, All y, (x^2 >= y) = F All y, Exist x, (x^2 >= y) = T 3. Let the domain of x be the set of all objects and define the following predicates: B(x) = x is a book E(x) = x is expensive G(x) = x is good Express the following English statement as quantified predicates: - Some books are not good - No book is expensive - All expensive books are good - Not all expensive books are good Sol: - Some books are not good = Exist x, (B(x) and not G(x)) - No book is expensive = All x, (B(x) -> not E(x)) - All expensive books are good = All x, (B(x) and E(x) -> G(x)) - Not all expensive books are good = Exist x, (B(x) and E(x) and not G(x)) 4. Let the domain of x be {2, 3, 7} and the domain of y be {1, 7}. Express the following quantified predicates as non-quantified predicates: Exist x, P(x) All x, P(x) Exist x, Q(x,1) All y, Q(2,y) Sol: Exist x, P(x) = P(2) or P(3) or P(7) All x, P(x) = P(2) and P(3) and P(7) Exist x, Q(x,1) = Q(2,1) or Q(3,1) or Q(7,1) All y, Q(2,y) = Q(2,1) and Q(2,7) 5. Compute the Boolean value of predicate P: P = All x Exist z (x < z and not Exist y (x < y and y < z)) in the following two cases: Case 1. The domains of x, y, and z are the set of all integers Case 2. The domains of x, y, and z are the set of all rational numbers Sol: 1. P = T {choose for example z = x + 1, and so there is no y such that x < y and y < z} 2. P = F {choose for example y = (x + z)/2 and so x < y and y < z} 6. Use equivalence laws to prove that the following two formulas are equivalent x and (not z -> (x and y)) and y x and y Sol: x and (not z -> (x and y)) and y = {Associativity and Symmetry} (x and y) and (not z -> (x and y)) = {Implication} (x and y) and (z or (x and y)) = {Symmetry and Absorption} x and y 7. Use equivalence laws to prove that the following two formulas are equivalent: x -> y not y -> not x Sol: x -> y = {Implication} not x or y = {Symmetry} y or not x = {not (not y) = y} not (not y) or not x = {Implication} not y -> not x {Comment: If (x -> y) is called direct implication, then (not y -> not x) is called indirect implication. And if (not y -> not x) is called direct implication, then (x -> y) is called indirect implication.} 8. Let the domains of x, y, and z be the set of all positive integers. Give a guessing proof to prove Exist x, y, z, x^2 + y^2 = z^2 Sol: If x = 3, y = 4, and z = 5, then x^2 + y^2 = 9 + 16 = 25 = z^2. 9. Let the domain of x be the set of all integers. Give a case analysis proof to prove (All x, x^2 != 5) Sol: Case 1: (x >= -2 and x =< 2): x^2 =< 4 < 5 Case 2: (x < -2 or x > 2): x^2 >= 9 > 5 10. Give a guessing proof to prove (Exist x, (2^x + 3) is not prime) The domain of x is the set of all positive integers. Sol: x = 1 2^1 + 3 = 5 is prime x = 2 2^2 + 3 = 7 is prime x = 3 2^3 + 3 = 11 is prime x = 4 2^4 + 3 = 19 is prime x = 5 2^5 + 3 = 35 is not prime {Comment: Poor man's induction does not always work.} 11. Give a direct inference proof to prove (All m,n, (m and n are odd) => (m+n is even)) where the domains of m and n are the set of all non-negative integers. Sol: m and n are odd => {definition of odd} m = 2k+1 and n = 2l+1, for some integers k and l => {add m + n} m+n = (2k+1) + (2l+1), for some integers k and l => {arithmetics} m+n = 2(k+l+1), for some integers k and l => {(k+l+1) is an integer} m+n = 2p, for some integer p => {definition of even} m+n is even