Mohamed G. Gouda CS 313K Fall 2012 Exercise 2 1. Use equivalence laws to show that the following two formulas are equivalent. f = (x and y) g = (x and y) and ((not x or not z) or (y and x)) Sol: g = {second formula} (x and y) and ((not x or not z) or (y and x)) = {Symmetry} (x and y) and ((not x or not z) or (x and y)) = {Symmetry} (x and y) and ((x and y) or (not x or not z)) = {Absorption} (x and y) = {first formula} f 2. Use truth table to show that the following two formulas are equivalent. f = (x and y) g = (x and y) and ((not x or not z) or (y and x)) Sol: Consider two cases (x and y) = F and (x and y) = T. In the first case, f = F and g = F and (..) = F. In the second case, f = T and g = T and ((..) or T) = T and T = T. 3. Consider the following formula. f = x and not y and not (x and not y or z) How many value combinations of x, y, and z that make f = F? How many value combinations of x, y, and z that make f = T? Is f satisfiable or not? Sol: If x = F, then f = F. (These four value combinations make f = F) Otherwise, if x = T and y = T, then f = F. (These two value combinations make f = F) Otherwise, x = T and y = F and in this case, f = T and T and not (T and T or z) = F. (These two value combinations make f = F) Therefore, 8 value combinations of x, y, and z make f = F. Therefore, 0 value combinations of x, y, and z make f = T. Therefore, f is not satisfiable. 4. Use equivalence laws to show that the following two formulas are equivalent. f = (x and (not y or not z)) or (z and y and x) g = x Sol: f = {first formula} (x and (not y or not z)) or (z and y and x) = {Symmetry, Symmetry, Symmetry} (x and (not y or not z)) or (x and y and z) = {De-Morgan's} (x and not (y and z)) or (x and y and z) = {Distribution} (x and (not (y and z) or (y and z))) = {not h(y,z) or h(y,z) = T} x and T = {x and T = x} x = {second formula} g 5. Use equivalence laws to show that the following two formulas are equivalent. f = (x and y) -> (y or z) g = T Sol: f = {first formula} (x and y) -> (y or z) = {Implication} not (x and y) or (y or z) = {De-Morgan's} (not x or not y) or (y or z) = {Associativity} not x or (not y or y) or z = {not y or y = T} not x or T or z = {Symmetry and g(x, z) or T = T} T = {second formula} g 6. Use equivalence laws to show that the following two formulas are equivalent. f = ((x and y) = x) g = x -> y Sol: f = {first formula} (x and y) = x = {Equality} ((x and y) and x) or (not (x and y) and not x) = {Symmetry, Associativity, x and x = x} (x and y) or (not (x and y) and not x) = {De-Morgan's, Absorption} (x and y) or not x = {Distribution} (x or not x) and (y or not x) = {x or not x = T} T and (y or not x) = {T and h(x,y) = h(x,y)} y or not x = {Implication} x -> y = {second formula} g 7. Use Problems 5 and 6 and equivalence laws to show that the following two formulas are equivalent. f = ((x and y) -> (y or z)) and ((x and y) = x) g = (x -> y) Sol: f = {first formula} ((x and y) -> (y or z)) and ((x and y) = x) = {Problem 5} T and ((x and y) = x) = {T and h(x,y) = h(x,y)} (x and y) = x = {Problem 6} x -> y = {second formula} g 8. Let x be T iff "Alice attends today's lecture". Let y be T iff "Bob attends today's lecture". Write a boolean formula f, involving x and y, whose value is T iff either Alice or Bob attends today's lecture. Sol: f = (not x and y) or (x and not y) = x xor y 9. Formula f(x,y,z) = not x and y and z is in Conjunctive Normal Form (CNF). Find an equivalent formula g(x,y,z) that is in Disjunctive Normal Form (DNF). Sol: f(x,y,z) = {CNF} not x and y and z = {h(x,y,z) = h(x,y,z) or F} (not x and y and z) or F = {DNF} g(x,y,z) Note that the formula (not x and y and z) is in both CNF and DNF 10. Formula f(x,y,z) = (not x and y) or z is in DNF. Find an equivalent formula g(x,y,z) that is in CNF. Sol: f(x,y,z) = {DNF} (not x and y) or z = {Distribution} (not x or z) and (y or z) = {CNF} g(x,y,z) 11. Let x be a parameter whose domain of values is the set {2, 3, 5}. A. Define two predicates P(x) and Q(x) such that (Exist x, (P(x) and Q(x))) = (Exist x, P(x)) and (Exist x, Q(x)) B. Define two predicates P(x) and Q(x) such that (Exist x, (P(x) and Q(x))) != (Exist x, P(x)) and (Exist x, Q(x)) Sol: A. P(x) = (x > 2), Q(x) = (x < 5) B. P(x) = (x = 2), Q(x) = (x = 5)