------------------------------------------------------------------------------ Mohamed G. Gouda CS 311 Spring 2015 Homework 1 ------------------------------------------------------------------------------ 1. (2.5 points) a. Use equivalence laws to prove that the following two formulas are equivalent: f(x,y) = x and (x=y) g(x,y) = x and y b. Use equivalence laws to prove that the following two formulas are equivalent: f(x,y) = x or (x=y) g(x,y) = x or (not y) 2. (2.5 points) Let Dx be the set {1, 2} and Dy be the set {a, b} a. Define the parameterized predicate P(x,y) such that the following quantified predicate is T: (All x, Exist y, P(x, y)) b. Define the parameterized predicate P(x,y) such that the following quantified predicate is T: (All x, All y, not(P(x, y))) c. Define the parameterized predicate P(x,y) such that the following quantified predicate is F: (All x, Exist y, P(x, y)) 3. (2.5 points) Let Dx be the set {1, 2, ...}. Use case analysis to prove that the Boolean value of the following quantified predicate is F: (Exist x, x^3 = 120) 4. (2.5 points) Let Dx and Dy be the set of all integers. Write a direct inference proof to prove the following quantified predicate: (All x, All y, T => (max(x,y) >= x)) You can use the following hints in your proof: {H1}: {(All x, All y, (max(x,y)=x) --> (max(x,y)>=x))} {H2}: {(All x, All y, (y>=x) --> (max(x,y)>=x))} {H3}: {(All x, All y, (x>=y) --> (max(x,y)=x))} {H4}: {(All x, All y, (x>=y) or (y>=x))} --------------------------------------------------------------------------------- Solutions: --------------------------------------------------------------------------------- 1.a. f(x,y) = {definition of f(x,y)} x and (x=y) = {definition of =} x and ((x and y) or (not x and not y)) = {distribution of and over or and associativity of and} (x and x and y) or (x and not x and not y) = {idempotence of and, idempotence of and, and elementary} (x and y) or (F) = {elementary} (x and y) = {defintion of g(x,y)} g(x,y) 1.b. f(x,y) = {definition of f(x,y)} x or (x=y) = {definition of =} x or ((x and y) or (not x and not y)) = {associativity of or} x or (x and y) or (not x and not y) = {absorption} x or (not x and not y) = {distribution of or over and} (x or not x) and (x or not y) = {idempotence of or} T and (x or not y) = {elementary} x or not y = {definition of g(x,y)} g(x,y) -------------------------------------------------------------------------------- 2.a. For (All x, Exist y, P(x,y)) to be T, define P(x,y) as follows: P(1,a)= T P(1,b)= don't-care P(2,a)= don't-care P(2,b)= T 2.b. For (All x, All y, not P(x,y)) to be T, define P(x,y) as follows: P(1,a)= F P(1,b)= F P(2,a)= F P(2,b)= F 2.c. For (All x, Exist y, P(x,y)) to be F, define P(x,y) such that (Exist x, All y, not P(x,y)) is T Thus define P(x,y) as follows: P(1,a)= F P(1,b)= F P(2,a)= don't-care P(2,b)= don't-care -------------------------------------------------------------------------------- 3. To prove (Exist x, x^3 = 120) is F, one needs to prove (All x, x^2 != 120) is T which can be proven by case analysis as follows: Step 1: Partition Dx into two subsets d1 and d2 where d1 = (x =< 4) d2 = (x >= 5) Step 2: (All x, x =< 4, x^3 =< 64 != 120) is T (All x, x >= 5, x^3 >= 125 != 120) is T Thus (All x, x in Dx, x^3 != 120) is T --------------------------------------------------------------------------------- 4. A direct inference proof of the quantified predicate (All x, All y, T => (max(x,y) >= x)) proceeds as follows T => {H4: (All x, All y, (x>=y) or (y>=x))} (x>=y) or (y>=x) => {H3: (All x, All y, (x>=y) --> (max(x,y)=x))} (max(x,y)=x)) or (y>=x) => {H2: (All x, All y, (y>=x) --> (max(x,y)>=x))} (max(x,y)=x) or (max(x,y)>=x) => {H1: (All x, All y, (max(x,y)=x) --> (max(x,y)>=x))} (max(x,y)>=x) or (max(x,y)>=x) => {idempotence of or} max(x,y)>=x ---------------------------------------------------------------------------------