Mohamed G. Gouda CS 311 Fall 2013 Homework 1 1) Show that formula f(x,y) below is equivalent to formula T. f(x,y) = ((x and y) -> (x or y)) Sol. f(x,y) = {definition of ->} not (x and y) or (x or y) = {De Morgan's} (not x or not y) or (x or y) = {associativity and symmetry} (not x or x) or (not y or y) = {idempotence} T or T = {truth table of "or" operator} T 2) Use truth table to show that the "=" Boolean operator is associative. Sol. We show that for every possible combination of x, y, and z, the following formula ((x = y) = z) = (x = (y = z)). 1. x=F, y=F, z=F: Left handside = (F = F) = F) = F Right handside = (F = (F = F) = F 2. x=F, y=F, z=T: Left handside = (F = F) = T) = T Right handside = (F = (F = T) = T 3. x=F, y=T, z=F: Left handside = (F = T) = F) = T Right handside = (F = (T = F) = T 4. x=T, y=F, z=F: Left handside = (T = F) = F) = T Right handside = (T = (F = F) = T 5. x=F, y=T, z=T: Left handside = (F = T) = T) = F Right handside = (F = (T = T) = F 6. x=T, y=F, z=T: Left handside = (T = F) = T) = F Right handside = (T = (F = T) = F 7. x=T, y=T, z=F: Left handside = (T = T) = F) = F Right handside = (T = (T = F) = F 8. x=T, y=T, z=T: Left handside = (T = T) = T) = T Right handside = (T = (T = T) = T 3) Use equivalence laws to prove that formula f(x) below is not satisfiable. f(x) = not(x xor not x) Sol. We need to show that formula f(x) is equivalent to formula F. f(x) = {definition of f(x)} not(x xor not x) = {definition of xor} not((x and not not x) or (not x and not x)) = {not not x = x} not((x and x) or (not x and not x)) = {g(x) and g(x) = g(x)} not((x or not x)) = {x or not x = T} not T = {truth table of "not"} F 4) Let Dx and Dy be the set of all students (attending the CS311 class). Also let Dg and Dh be the set of all study groups (in the CS311 class). Let (x belong g) denote that student x belongs to study group g. Define the following as quantified predicates: 1. No study group has no student or has only one student. 2. Each student belongs to at least one study group. 3. No student belongs to two or more study groups. 4. Each student belongs to at most one study group. Sol. 1. (All g, Exist x, Exist y, (x belong g) and (y belong g) and not (x = y)) 2. (All x, Exist g, (x belong g)) 3. (All x, All g, All h, ((x belong g) and (x belong h)) -> (g = h)) 4. (All x, All g, All h, ((x belong g) and (x belong h)) -> (g = h)) Notice that the quantified predicate of 3 and 4 are identical. 5) Let m and n be two positive integers where m is at most n. What is the number of even integers that are at least m and at most n? What is the number of odd integers that are at least m and at most n? Sol. There are four cases to consider: 1. Both m and n are even: The number of even integers = (n-m+2)/2 The number of odd integers = (n-m)/2 2. Both m and n are odd: The number of even integers = (n-m)/2 The number of odd integers = (n-m+2)/2 3. m is even and n is odd: The number of even integers = (n-m+1)/2 The number of odd integers = (n-m+1)/2 4. m is odd and n is even: The number of even integers = (n-m+1)/2 The number of odd integers = (n-m+1)/2.