advertisement

CS 454 Theory of Computation HW # 1solution 1) Exercise 0.6, page 26. (a) (b) (c) (d) (e) f(2) = 7 The domain is X, the range is Y. g(2, 10) = 6 X x Y and Y g(4, f(4)) = 8 2) Exercise 0.7, page 26. In all cases, relations are defined on {a, b, c} (a) {(a,a), (b, b), (c, c), (a,b), (b,a), (b, c), (c,b)} (b) {(a,a), (b,b), (c, c), (a,b), (b,c), (a,c)} (c) {(a,a), (b,b), (a,b), (b,a)} 3) Problem 0.12, page 27. Let n > 1 be the number of vertices. Possible degrees can be {0, 1, 2, …, n-1}. However, choices 0 and n – 1 are not simultaneously possible. (If there is a node with degree 0, then this node is not connected to any vertex. But a node of degree n-1 is connected to every other node. These two options are not simultaneously possible,) Thus the possible degree sequences are either {1, 2, …, n – 1} or {0, 1, …, n-2}. In both cases, the number of possible values of degree is at most n – 1, but there are n vertices. So by pigeonhole principle, two of the vertices must have the same degree. 4) A circuit designer has access to AND and OR gates, and wires to connect them, but NOT gates are not available. Which of the following functions can he/she implement in hardware under this constraint? If your answer is in the affirmative, you should exhibit the circuit. If it is in the negative, you have to give a proof. x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 f 0 0 0 1 0 1 1 1 g 0 1 1 0 1 0 0 1 Answer: f can be implemented by using AND and OR gates since f = (y & z) V (x & z) V (x & z). However, g can’t be implemented by a circuit containing only AND, OR gates. This can be proved using the following lemma: Lemma: Suppose g is a Boolean function on n variables x1, x2, …, xn that can be implemented using AND and OR gates. Suppose (x1 = b1, x2 = b2, … , xn = bn) is an input for which f(b1, b2, … , bn) = 1. Suppose one of the bits bi = 0. Then, f( b1, …, bi-1 , 1, bi+1, …, bn) is also 1. In other words, changing one of 0 inputs to 1 can’t change the output from 1 to 0. Proof can be given by induction of the number of gates in the circuit that implements the function g. We will leave the proof as exercise. Now it is easy to see that the above function g can’t be implemented using AND and OR gates only. Suppose it is possible that such a circuit exists. Consider the input (0, 0, 1). The value of g(0, 0, 1) = 1. Now consider the first bit 0. If we change it 1, the output on the input (1, 0, 1) should be 1, according to the lemma. However, g(1, 0, 1) is 0. This is a contradiction and it completes the proof.