------------------------------------------------------------------------------ Mohamed G. Gouda CS 311 Fall 2015 Midterm 1 ------------------------------------------------------------------------------ 50 minutes ------------------------------------------------------------------------------ 1. (5 points) Are there Boolean values x and y that make the following formula true (not y) = ((not x = y) xor (x -> y)) Explain your answer. ------------------------------------------------------------------------------- 2. (5 points) Let Dx be the set {a, b, c, d} and let P(x) be the predicate defined as follows: P(a) = F P(b) = T P(c) = F P(d) = T What are the Boolean values of the following predicates: 1. (All u in Dx, P(u)) -> (Exist u in Dx, P(u)) 2. (P(a)) -> (Exist u in Dx, P(u)) Explain your answers. -------------------------------------------------------------------------------- 3. (5 points) Definition: Let u and v be positive integers. Integer u is said to be bigger than integer v, denoted u >> v, iff there is a positive integer m such that u = (v+m). Let Dx, Dy, and Dz be the set of all positive integers. Use direct inference to prove the following predicate: (All x, y, z, ((x >> y) and (y >> z)) => (x >> z)) --------------------------------------------------------------------------------- 4. (5 points) Refer to the definition of >> in Problem 3. Let Dx and Dy be the set of all positive integers. Use indirect inference to prove the following predicate: (All x, y, (x >> y) => (not (x=y))) --------------------------------------------------------------------------------- Solutions ---------------------------------------------------------------------------------- 1. x y not y (not x)=y x->y xor = F F T F T T F F T F T T F T T F T T F T T T T F F T T T Thus, x=T and y=T will make the predicate T ---------------------------------------------------------------------------------- 2. 1. (All u in Dx, P(u)) = F Thus, the predicate is (F -> anything) = T 2. (P(a)) = F Thus, the predicate is (F -> anything) = T ---------------------------------------------------------------------------------- 3. (x >> y) and (y >> z) => {definition of >>} (x = y+m) and (y = z+n) for some positive integers m and n => {replace y by z+n} x = z+m+n for some positive integers m and n => {m+n is a positive integer r} x = z+r for some positive integer r => {definition of >>} x >> z ---------------------------------------------------------------------------------- 4. not(not (x=y)) => {idempotence} x = y => {arithmetics} x =! y+m for every positive integer m => {definition of not(x >> y)} not(x >> y) ------------------------------------------------------------------------------ Mohamed G. Gouda CS 311 Fall 2015 Midterm 1 ------------------------------------------------------------------------------ 50 minutes ------------------------------------------------------------------------------ 1. (5 points) Are there Boolean values x and y that make the following formula true (not y) = ((x = not y) xor (x -> y)) Explain your answer. ------------------------------------------------------------------------------- 2. (5 points) Let Dx be the set {a, b, c, d} and let P(x) be the predicate defined as follows: P(a) = T P(b) = F P(c) = T P(d) = F What are the Boolean values of the following predicates: 1. (All u in Dx, P(u)) -> (Exist u in Dx, P(u)) 2. (P(a)) -> (Exist u in Dx, P(u)) Explain your answers. -------------------------------------------------------------------------------- 3. (5 points) Definition: Let u and v be positive integers. Integer u is said to be bigger than integer v, denoted u >> v, iff there is a positive integer m such that u = (v+m). Let Dx, Dy, and Dz be the set of all positive integers. Use direct inference to prove the following predicate: (All x, y, z, ((x >> y) and (y >> z)) => (x >> z)) --------------------------------------------------------------------------------- 4. (5 points) Refer to the definition of >> in Problem 3. Let Dx and Dy be the set of all positive integers. Use indirect inference to prove the following predicate: (All x, y, (x >> y) => (not (x=y))) --------------------------------------------------------------------------------- Solutions --------------------------------------------------------------------------------- 1. x y not y (x = not y) x->y xor = F F T F T T T F T F T T F T T F T T F T T T T F F T T F Thus, x=F and y=F will make the predicate T ---------------------------------------------------------------------------------- 2. 1. (All u in Dx, P(u)) = F Thus, the predicate is (F -> anything) = T 2. (P(a)) = T (Exist u in Dx, P(u)) = T Thus, the predicate is (T -> T) = T ---------------------------------------------------------------------------------- 3. (x >> y) and (y >> z) => {definition of >>} (x = y+m) and (y = z+n) for some positive integers m and n => {replace y by z+n} x = z+m+n for some positive integers m and n => {m+n is a positive integer r} x = z+r for some positive integer r => {definition of >>} x >> z ---------------------------------------------------------------------------------- 4. not(not (x=y)) => {idempotence} x = y => {arithmetics} x =! y+m for every positive integer m => {definition of not(x >> y)} not(x >> y) ----------------------------------------------------------------------------------