------------------------------------------------------------------------------ Mohamed G. Gouda CS 311 Fall 2014 Homework 1 ------------------------------------------------------------------------------ 1. (2 points) Use Formula Equivalence Laws to prove that the following two formulas are equivalent f(x) and (g(x) and h(x)) (f(x) and g(x)) and (f(x) and h(x)) 2. and 3. Let x and y be two parameters whose domains Dx and Dy, respectively, are the set {Amy, Barb, Cindy}. 2. (2 points) Define a parameterized predicate P(x, y) such the following predicate is T (All x, Exist y, P(x, y)) = (Exist y, All x, P(x, y)) Explain your answer. 3. (2 points) Define a parameterized predicate P(x, y) such the following predicate is T not (Exist y, P(Barb, y)) Explain your answer. 4. and 5. Consider the following three definitions: A non-negative integer x is called 0-third iff x = 3m for some non-negative integer m. A non-negative integer x is called 1-third iff x = 3m+1 for some non-negative integer m. A non-negative integer x is called 2-third iff x = 3m+2 for some non-negative integer m. 4. (2 points) Let Dx be the set of all non-negative integers, use direct inference to verify the following predicate (All x, (x is 2-third) ==> (x^2 is 1-third)) 5. (2 points) Let Dx and Dy be the set of all non-negative integers, use direct inference to verify the following predicate (All x, y, ((x is 1-third) and (y is 2-third)) ==> (xy is 2-third)) ------------------------------------------------------------------------------- Solutions: -------------------------------------------------------------------------------- 1. f(x) and (g(x) and h(x)) ==> {idempotence} (f(x) and f(x)) and (g(x) and h(x)) ==> {associativity} f(x) and (f(x) and g(x)) and h(x) ==> {symmetry} f(x) and (g(x) and f(x)) and h(x) ==> {associativity} (f(x) and g(x)) and (f(x) and h(x)) 2. Define P(x, y) as follows: P(Amy, Amy) = T P(Barb, Amy) = T P(Cindy, Amy) = T P(x, y) = F for all other x and y In this case, (All x, Exist y, P(x, y)) = T and (Exist y, All x, P(x, y)) = T 3. Define P(x, y) as follows: P(Barb, Amy) = F P(Barb, Barb) = F P(Barb, Cindy) = F P(x, y) = T for all other x and y In this case, not(Exist y, P(Barb, y)) = (All y, not(P(Barb, y))) = T 4. (x is 2-third) ==> {definition of 2-third} x = (3m+2) for some non-negative integer m ==> {compute x^2} x^2 = (3m+2)^2 for some non-negative integer m ==> {analysis} x^2 = (9m^2 + 12m + 4) for some non-negative integer m ==> {analysis} x^2 = 3(3m^2 + 4m + 1) + 1 for some non-negative integer m ==> {(3m^2 + 4m + 1) is non-negative integer} x^2 = 3n + 1 for some non-negative integer n ==> {definition of 1-third} x^2 is 1-third 5. ((x is 1-third) and (y is 2-third)) ==> {definitions of 1-third and 2-third} x = 3m+1 and y = 3n+2 for some non-negative inetgers m and n ==> {compute xy} xy = (9mn + 6m + 3n + 2) for some non-negative inetgers m and n ==> {analysis} xy = (3(3mn + 2m + n) + 2) for some non-negative inetgers m and n ==> {(3mn + 2m + n) is a non-negative integer} xy = (3r + 2) for some non-negative inetger r ==> {definition of 2-third} xy is 2-third ------------------------------------------------------------------------------------