# COMS W3261 Computer Science Theory Homework Assignment #4 November 14, 2012 Due in class 1:10pm, November 28, 2012

## Instructions

• Problems (1)-(5) are each worth 20 points.
• This assignment may be handed in December 3, 2012 for 50% credit.

## Problems

1. Classify each of the following languages as being (i) recursive, (ii) recursively enumerable but not recursive, or (iii) not recursively enumerable. In each case briefly justify your answer.
1. { D | D is a deterministic finite automaton that accepts at least one string with an equal number of a's and b's }
2. { (M, w) | M is a Turing machine that halts on input w }
3. { (D1, D2) | D1 and D2 are deterministic finite automata and L(D1) = L(D2) }
4. { (M1, M2) | M1 and M2 are Turing machines and L(M1) = L(M2) }

2. Boolean expressions
1. Describe an algorithm in high-level pseudocode to evaluate a boolean expression given a truth assignment to its variables. Describe how your algorithm evaluates the boolean expression x ∨ ¬(yz) for the truth assignment T(x) = 0, T(y) = 0, T(z) = 1. (1 is true, 0 is false.)
2. What is the time complexity of your algorithm?
3. Describe an algorithm in high-level pseudocode to determine whether a boolean expression always evaluates to true on all truth assignments to its variables (is a tautology). Illustrate how your algorithm performs on the boolean expression x ∨ ¬(yx).
4. What is the time complexity of your algorithm?

3. The game PEBBLES is played on an k × n chessboard. Initially each square of the chessboard has a black pebble, or a white pebble, or no pebble. You play the game by removing pebbles one at a time. You win the game if you can end up with a board in which each column contains only pebbles of a single color and each row contains at least one pebble.
1. Show that the set of winnable PEBBLES games is in NP. Hint: Describe a nondeterministic polynomial-time algorithm to determine whether a given PEBBLES board is winnable.
2. Given a boolean expression E in 3-CNF with k clauses and n variables, construct the following k × n board: If literal xi is in clause cj, put a black pebble in column xi, row cj. If literal ¬xi is in clause cj, put a white pebble in column xi, row cj. Show that E is satisfiable if and only if this PEBBLES game is winnable.
3. What can you conclude from showing (a) and (b)?

4. Show that NP is equivalent to the class of languages that have polynomial-time verifiers.

5. The classes P and NP
1. Show that if A is NP-complete and A is in P, then P = NP.
2. Show that if A is NP-complete and A is polynomially reducible to a problem B in NP, then B is NP-complete.

aho@cs.columbia.edu