# CMPSCI 601: Theory of Computation

### Due Wednesday 18 Feb 2004 in class

#### (Wed 25 Feb for off-campus students)

• Question 1 (15): Using the definition of boolean straight-line program (SLP) from Lecture 1, prove that any fixed finite boolean function can be computed by an SLP. That is, let k be a number and let f(x1,...,xk) be any boolean-valued function on k boolean inputs. Prove that there is an SLP whose output is f.

• Question 2 (20): Describe two different SLP's that input a string of n boolean values and output 1 iff the input has exactly two ones. Your first SLP should separately consider each possible pair of locations for the two ones, and have length O(n3). The other should have length O(n) -- it is probably easiest to simulate the action of a finite-state machine.

• Question 3 (10): The depth of an SLP instruction is one greater than the maximum of the depth of its inputs, where input variables have depth zero. The depth of an SLP is the depth of its return instruction. Determine the depth of your SLP's in Question 2, in big-O terms. Can you get depth O(log n)? Depth O(1)?

• Question 4 (15): Using Question 1 and quoting Kleene's Theorem, prove that any regular language can be decided by an SLP with length O(n).

• Question 5 (10): Using the definition in Lecture 1, show that the set of numbers that have exactly two ones in their binary expansion is Bloop-definable and hence primitive recursive. (Hint: First define a function `isPowerOfTwo(x)` that returns 1 if its input x is a power of two and returns zero otherwise.)

• Question 6 (10): Let X be the regular language 1(01+10)*0. Find all the Myhill-Nerode equivalence classes for X (that is, the equivalence classes of the relation ~X defined so that u ~X v iff for all strings w, uw is in X iff vw is in X) and give a regular expression for each.

• Question 7 (10): Write a first-order sentence, with input predicate I(x), that is true for an input string w iff w is in the regular language (0+01)*.

• Question 8 (10): Describe a PDA whose language is given by the grammar with rules:
```         S --> aSb
S --> cSd
S --> eS
S --> e
```