# Final Exam, Spring 2009

### Directions:

• Answer the problems on the exam pages.
• There are eight problems for 120 total points plus 15 extra credit. Actual scale is A = 100, C = 65.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.
• The first five questions are true/false, with five points for the correct boolean answer and up to five for a correct justification of your answer -- a proof, counterexample, quotation from the book or from lecture, etc. -- note that there is no reason not to guess if you don't know.

```  Q1: 10 points
Q2: 10 points
Q3: 10 points
Q4: 10 points
Q5: 10 points
Q6: 10+15 points
Q7: 30 points
Q8: 30 points

Total: 120+15 points
```

The following formal languages are each used in one or more problems:

• Recall from Sipser that an LBA is a deterministic one-tape Turing machine that is restricted to the portion of the tape that originally contains the input, and that ALBA is the set of pairs (M, w) such that M is an LBA and w ∈ L(M). Similarly, we define an NLBA to be a nondeterministic one-tape Turing machine that is restricted to the portion of the tape that originally contains its input, and define ANLBA to be the set of pairs (M, w) such that M is an NLBA and w ∈ L(M).

• Sipser defines the language SUBSET-SUM to be {(s1, ..., sk; t): Each si is a positive integer written in binary, t is a positive integer written in binary, and there exists a subset of the si's that adds up to exactly t}. Although we did not present the proof in lecture, Sipser proves that SUBSET-SUM is an NP-complete language.

• We define the language 3WS (for "three-way split") to be the set {(si, ..., sk): Each si is a positive integer written in binary and there exists a partition of the multiset S of si's into three pairwise disjoint submultisets A, B, and C, where A ∪ B ∪ C = S and the sums of the numbers in each of A, B, and C is the same.

• The language SD (for "same direction") is the set of strings over the alphabet {A, F, L, R} such that if a marching band begins facing north and executes the sequence of commands given by the string, they will end up again facing north. The command A ("about face") means to turn 180 degrees, F ("forward march") means not to turn at all, L ("left face") means to turn 90 degrees to the left, and R ("right face") means to turn 90 degrees to the right.

• The language RS (for "return to start") is the set of strings over the alphabet {N, E, S, W} such that if a marching band executes the sequence of commands given by the string, on an arbitrarily large flat field, they will return to their original position. The command N means to march one unit to the north, and similarly the commands E, S, and W mean to march one unit east, south, or west respectively.

• The language CCFL ("contains a CFL") is the set {M: M is a Turing machine and there exists a context-free grammar G such that L(G) ⊆ L(M)}.

• Question 1 (10): True or false with justification: Let L ⊆ {0, 1}* be a language. Let f be a Turing computable function such that if w is a binary string denoting a positive integer n, then f(w) is a description of a boolean circuit Cn, with n inputs, such that if x is any binary string of length n, x ∈ L if and only if Cn outputs 1 on input x. Then L is a Turing decidable language.

• Question 2 (10): True or false with justification: There exists a regular expression denoting the language SD defined above.

• Question 3 (10): True or false with justification: There exists a three-state DFA that decides the language SD defined above.

• Question 4 (10): True or false with justification: The language CCFL defined above is not Turing decidable.

• Question 5 (10): True or false with justification: If P ≠ NP, there cannot be a polynomial-time reduction from the language RS to the language 3WS -- that is, the statement "RS ≤p 3WS" is false. (Both these languages are defined above.)

• Question 6 (10+15): These three questions involve the language RS defined above.

• (a,10) Prove carefully that RS is not a regular language.

• (b, 5XC) Is RS in the class L (also known as DSPACE(log n))? Prove your answer.

• (c, 10XC) Is RS a context-free language? Prove your answer.

• Question 7 (30): This question involves the languages SUBSET-SUM and 3WS defined above. You may assume without proof that SUBSET-SUM is NP-complete (as this is proved in Sipser).

• (a,10) Prove carefully that 3WS is in the class NP.

• (b,20) Complete the proof that 3WS is NP-complete, by building the appropriate poly-time reduction involving SUBSET-SUM, or otherwise.

• Question 8 (30): This question involves the language ANLBA defined above.

• (a,10) Prove by any method that ANLBA is Turing decidable. (Note that a correct answer to part (b) suffices.)

• (b,20) Give a deterministic algorithm that decides ANLBA and uses O(n2) space on inputs of size n.