# Final Exam, Spring 2015

### Directions:

• Answer the problems on the exam pages.
• There are eight problems for 120 total points plus 10 extra credit. Actual scale was A = 105, C = 60.
• If you need extra space use the back of a page.
• No books, notes, calculators, or collaboration.
• Many useful definitions are given in a body before the questions.
• The first five questions are statements -- in each case say whether the statement is true or false and give a convincing justification of your answer -- a proof, counterexample, quotation from the book or from lecture, etc. You get five points for the correct boolean answer (so there is no reason not to guess if you don't know) and up to five for the justification.

```  Q1: 10 points
Q2: 10 points
Q3: 10 points
Q4: 10 points
Q5: 10 points
Q6: 30 points
Q7: 40+10 points
Total: 120+10 points
```

If C is any class of computers, such as DFA's, CFG's, LBA's, TM's, strange variant TM's, etc.:

• AC = {(M, w): M is a computer in C and w ∈ L(M)}
• EC = {(M): M is a computer in C and L(M) = ∅}
• ALLC = {(M): M is a computer in C and L(M) = Σ*}

A language A is Turing decidable if A = L(M) for some Turing machine M that always halts.

A function f is Turing computable if there exists a Turing machine M such that for any string w, M when started on w halts with f(w) on its tape.

Recall that if A and B are two languages, A is mapping reducible to B, written A ≤m B, if there exists a function f: Σ* → Σ* such that for any string w, w ∈ A ↔ f(w) ∈ B. If such an f exists that is computable in polynomial time, we say that A is poly-time reducible to B, written A ≤p B. If f is computable in log space, we say that A is log-space reducible to B, written A ≤L B.

The following languages were proved to be NP-complete in the text or in Exercises, and you may assume without proof that each of them is NP-complete:

• 3-SAT = {φ: φ is a satisfiable formula in 3-CNF}

• 3-COLOR = {G: G is an undirected graph and the vertices of G may each be assigned one of three colors so that no edge connects two vertices of the same color}

• DHAMPATH = {(G, s, t): G is a directed graph in which there is a directed path from vertex s to another vertex t such that the path visits each vertex of G exactly once}

• UHAMPATH = {(S, s, t): G is an undirected graph in which there is an undirected path from vertex s to another vertex t such that the path visits each vertex of G exactly once}

• SUBSET-SUM = {(a1, a2,..., ak, t): the ai's and t are binary positive integers and there is a subset of the ai's that adds to exactly t}

• CLIQUE = {(G, k): G is an undirected graph and G has a set S of k vertices such that every two distinct vertices in S have an edge between them}

• VERTEX-COVER = {(G, k): G is an undirected graph and G has a set S of k vertices such that every edge in G has at least one endpoint in S}

King Arthur has n knights, including Sir Galahad and Sir Lancelot, and at any given time some of them may be quarreling with others. The relation Q(a, b) is defined to mean "knight a is quarreling with knight b", and this relation is assumed to be symmetric (that is, Q(a, b) → Q(b, a)). King Arthur himself is not quarreling with any knights.

Arthur of course has a Round Table at which he wishes to seat all the knights, without having two quarreling knights seated next to one another. Sometimes he sits at the table himself, with Sir Lancelot at his right and Sir Galahad on his left, but other times only the n knights are seated. (There is no empty seat in the latter case -- assume that the number of seats is always exactly what is needed.)

The language SEAT-CHECK is the set of pairs (Q, S) where Q is a list of which knights are quarreling with which, S is a seating arrangement for the table, and S does not have two quarreling knights seated next to one another.

The language SEAT-WITH-ARTHUR is the set of quarreling lists Q such that Q permits some arrangement of the n knights and Arthur at the table, with Galahad and Lancelot on either side of Arthur, and no quarreling knights seated next to one another. The language SEAT-WITHOUT-ARTHUR is the similar language where only the n knights must be seated.

Arthur also periodically sends all the knights out on quests, and he does not want to send two quarreling knights on the same quest. The language TWO-QUEST is the set of quarreling lists Q such that Q allows for a division of all the knights into two sets, neither of which contains a quarreling pair. The problem (not language) MIN-QUEST is to input a quarreling list Q and determine the minimum number of quests on which all the knights could be sent without a quarreling pair being sent on the same quest. (For example, if no knights are quarreling at all, the output of MIN-QUEST is 1.)

A Limited Alphabet Turing Machine is a two-tape deterministic Turing machine with a read-only input tape and a single read-write work tape. The input tape contains the input string w ∈ Σ*, with a special symbol \$ on each end that is not part of Σ. The work tape alphabet Γ contains a blank symbol but need not include any letters of the input alphabet Σ. The leftmost cell of the work tape contains a special symbol \$ that is not part of Γ and may not be overwritten.

In an LATM(k), the alphabet Γ has exactly k symbols, including the blank symbol but not including the special symbol \$. The transition function δ of the machine is this a function from Q × (Σ∪{\$}) × (Γ∪{\$}) to Q × Σ × Γ × {L, R}2.

• Question 1 (10): True or false with justification: Every DFA whose language is ab*a ∪ ba*b has six or more states.

• Question 2 (10): True or false with justification: Let G be a grammar in Chomsky Normal Form, with k non-terminals, such that L(G) ≠ ∅. Then the shortest string in L(G) has fewer than 2k+3 letters.

• Question 3 (10): True or false with justification: Assume for this question only that P ≠ NP. Let G1 and G2 be any two context-free grammars with the same alphabet. Then the language (L(G1) ∩ L(G2))* may be NP-complete.

• Question 4 (10): True or false with justification: It is not the case that ALLCFGp ECFG.

• Question 5 (10): True or false with justification: Recall that CVP = {(C, w): C is a boolean circuit with n inputs, w ∈ {0, 1}n, and C(w) = 1}. If R is any regular expression, then L(R) ≤L CVP.

• Question 6 (30): These questions use the definition of Limited Alphabet Turing Machines (LATM's) given above.

• (a, 10) Describe an LATM(1) whose language is not context-free. You may use English or pseudocode as long as the operation of your machine is clear.

• (b, 10) Prove that if X is the language of an LATM(1), then X is in the class P.

• (c, 10) Prove that the language ALATM(2) is not Turing decidable.

• Question 7 (40+10): These questions all involve the problems and languages given above concerning King Arthur and his knights.

• (a, 10): Prove that the language TWO-QUEST is in the class NL.

• (b, 10): Prove that if the MIN-QUEST problem can be solved in polynomial time, then P = NP.

• (c, 10): Prove that the language SEAT-CHECK is in the class L.

• (d, 10): Prove that the language SEAT-WITH-ARTHUR is NP-complete.

• (e, 10XC): Prove that the language SEAT-WITHOUT-ARTHUR is NP-complete.