------------------------------------------------------------------------------ Mohamed G. Gouda CS 311 Summer 2014 Midterm 1 ------------------------------------------------------------------------------ 1. (5 points) Let Dx and Dy be the set of all integers. Which of the following quantified predicates is T and which of them is F: a. (All x, y, (x =< y)) b. (All x, y, (x =< y) or (y =< x)) = (All x, y, (x =< y)) or (All x, y, (y =< x)) Explain your answers. 2. (7 points) Let x, y, and z be Boolean parameters. Show that there is no combination of Boolean values for these parameters that makes the following formula f(x, y, z) F. f(x, y, z) = y or ((x --> (y and not z)) or not y) (Hint: Show that the two formulas f(x, y, z) and T are equivalent.) 3. (8 points) Let Dx and Dy be the set of all integers. Use direct inference to prove the following two predicates: a. (All x, y, ((x =< y) and (max(x, y) =< min(x, y)) => x=y) b. (All x, y, ((x >= y) and (max(x, y) =< min(x, y)) => x=y) Solutions 1. a. The predicate (All x, y, (x =< y)) is F choose for example x to be 1 and y to be 0 b. The predicate (All x, y, (x =< y) or (y =< x)) is T The predicate (All x, y, (x =< y)) is F from Part a The predicate (All x, y, (y =< x)) is F from Part a The total predicate is (T = (F or F)) is F 2. f(x, y, z) = {definition of formula f} y or ((x --> (y and not z)) or not y) = {symmetry and associativity of or} (x --> (y and not z)) or (not y or y) = {idempotence of or} (x --> (y and not z)) or T = {elementary} T 3. a. ((x =< y) and (max(x, y) =< min(x, y)) => {definition of max} ((x =< y) and (y =< min(x, y)) => {definition of min} ((x =< y) and (y =< x)) => {arithmetics} (x = y) b. ((x >= y) and (max(x, y) =< min(x, y)) => {definition of max} ((x >= y) and (x =< min(x, y)) => {definition of min} ((x >= y) and (x =< y)) => {arithmetics} (x = y)