Mohamed G. Gouda CS 313K Summer 2013 Homework 1 1) Let x and y be two parameters whose values are in the set D = {a,b}. Define two predicates P(x,y) and Q(x,y) such that (Exist x, y, P(x,y) and Q(x,y)) != (Exist x, y, P(x,y)) and (Exist x, y, Q(x,y)) Explain your answer. Sol: Define P(x,y) and Q(x,y) as follows: P(a,a)=T P(a,b)=F P(b,a)=T P(b,b)=F Q(a,a)=F Q(a,b)=T Q(b,a)=F Q(b,b)=T Explanation: (Exist x, y, P(x,y) and Q(x,y)) = F (Exist x, y, P(x,y)) = T (Exist x, y, Q(x,y)) = T (Exist x, y, P(x,y)) and (Exist x, y, Q(x,y)) = T Thus, (Exist x, y, P(x,y) and Q(x,y)) != (Exist x, y, P(x,y)) and (Exist x, y, Q(x,y)) 2) Let x be a parameter whose value is in the set Dx={a,b}, and let y be a parameter whose value is in the set Dy={1,2,3}. (a) Define a predicate P(x,y) such that (All v in Dx, Exist w in Dy, P(v,w)) = (Exist w in Dy, All v in Dx, P(v,w)) (b) Define a predicate Q(x,y) such that (All v in Dx, Exist w in Dy, Q(v,w)) != (Exist w in Dy, All v in Dx, Q(v,w)) Explain your answers. Sol: (a) P(a,1)=F P(a,2)=T P(a,3)=F P(b,1)=T P(b,2)=T P(b,3)=F Explanation: (All v in Dx, Exist w in Dy, P(v,w)) = T (Exist w in Dy, All v in Dx, P(v,w)) = T Thus, (All v in Dx, Exist w in Dy, P(v,w)) = (Exist w in Dy, All v in Dx, P(v,w)) (b) Q(a,1)=F Q(a,2)=T Q(a,3)=F Q(b,1)=T Q(b,2)=F Q(b,3)=T Explanation: (All v in Dx, Exist w in Dy, Q(v,w)) = T (Exist w in Dy, All v in Dx, Q(v,w)) = F Thus, (All v in Dx, Exist w in Dy, Q(v,w)) != (Exist w in Dy, All v in Dx, Q(v,w)) 3) Prove by contradiction the predicate ((x is odd) and (y is odd)) => (x*y is odd) Sol: (x is odd) and (y is odd) and not(x*y is odd) => {integer is either odd or even} (x is odd) and (y is odd) and (x*y is even) => {definitions of odd and of even} (x = 2m+1) and (y = 2n+1) and (x*y = 2k) for integers m, n, k => {compute x*y} (x*y = 2(2mn + (m+n)) + 1 and (x*y = 2k) for integers m, n, k => {2mn + (m+n) is an integer r} (x*y = (2r+1)) and (x*y = 2k) for integers r, k => {arithmetics} 2r+1 = 2k for integers r, k => {arithmetics} (k-r) = 1/2 for integers r, k => {definition of integers subtraction} F 4) Prove by indirect inference the following predicate: (x*y is odd) => ((x is odd) and (y is odd)) Sol: not (x is odd) or not (y is odd) => {an integer is either odd or even} (x is even) or (y is even) => {an integer is either odd or even} (x is even) and (y is even or y is odd) => {distribution of and over or} (x is even and y is even) or (x is even and y is odd) => {definitions of odd and of even} (x=2m and y=2n) or (x=2m and y=2n+1) for integers m, n => {compute x*y} (x*y=2r) or (x*y=2r) for integer r => {definition of even} (x*y is even) => {an integer is either odd or even} not (x*y is odd)