Mohamed G. Gouda CS 313K Summer 2013 Midterm 1 1) Simplify the formula f(x,y) = (x and y) or (y and not x) or (not (x or not y)) Sol: (x and y) or (y and not x) or (not (x or not y)) = {symmetry} (y and x) or (y and not x) or (not (x or not y)) = {distribution} (y and (x or not x)) or (not (x or not y)) = {x or not x is T and y and T is y} y or (not (x or not y)) = {De Morgan's} y or (not x and not (not y)) = {not (not y) is y and symmetry} y or (y and not x) = {absorption} y 2) Let Dx and Dy be the set of all integers. Compute the boolean values of the following predicates: All x, Exist y, (x < y+x) Exist x, All y, (x < y+x) All x, All y, (x < y+x) Exist x, Exist y, (x < y+x) Exist y, All x, (x < y+x) All y, Exist x, (x < y+x) Sol: All x, Exist y, (x < y+x) = T Exist x, All y, (x < y+x) = F All x, All y, (x < y+x) = F Exist x, Exist y, (x < y+x) = T Exist y, All x, (x < y+x) = T All y, Exist x, (x < y+x) = F 3) Give an inducton proof to prove that, for every positive integer n, (5^n - 1) is divisible by 2. Sol: Let P(n) be the predicate: (5^n - 1) is divisible by 2 Base Case: n = 1: P(1) <=> (5 - 1 is divisible by 2) <=> T Induction Step: for every n > 0, P(n) => P(n+1) P(n) <=> {Definitions of P(n) and of divisible by 2} 5^n - 1 = 2k, for some integer k <=> {Arithmetic} 5^n = 2k+1, for some integer k <=> {Multiply 5 to both sides of "="} 5^(n+1) = 5*(2k+1), for some integer k <=> {Arithmetic} (5^(n+1) - 1) = (5*(2k+1) - 1), for some integer k <=> {Arithmetic} (5^(n+1) - 1) = 2*(5k+2), for some integer k => {Definition of divisible by 2} (5^(n+1) - 1) is divisible by 2 <=> {Definition of P(n+1)} P(n+1) 4) Let G be a graph with 6 vertices and 8 edges. (a) What is the maximum possible value x for max-deg(G)? (b) Draw a graph G where max-deg(G) is x (from part a). (c) What is the minimum possible value y for max-deg(G)? (d) Draw a graph G where max-deg(G) is y (from part c). Sol: (a) 5 (b) G = (V,E) where V = {1, .., 6} E = {(1,2), (1,3), (1,4), (1,5), (1,6), (2,3), (3,4), (4,5)} (c) 3 (d) G = (V,E) where V = {1, .., 6} E = {(1,2), (1,5), (1,6), (2,3), (2,6), (3,4), (4,5), (5,6)}