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
Exam text is in black, solutions in blue
If C is any class of computers, such as DFA's, CFG's, LBA's, TM's, strange variant TM's, etc.:
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:
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.
FALSE. There is a correct DFA with five states {1, 2, 3, 4, 5}, where 1 is the start state, δ(1, a) = 2, δ(1, b) = 3, δ(2, a) = 4, δ(2, b) = 2, δ(3, a) = 3, δ(3, b) = 4, 4 is the only final state, δ(4, a) = δ(4, b) = 5, and 5 is a death state.
TRUE. Following the proof of the CFL Pumping Lemma, we observe that if any string w of length n is in L(G), it has a parse tree of depth at least log2 n. (The tree has degree 2 since the grammar is in Chomsky Normal Form.) If log n > k+1, this tree must have two copies of the same non-terminal on a single path, and we can create a new parse tree for a shorter string by collapsing these two non-terminals into one. Thus any string longer than 2k+1 cannot be the shortest string in the language. Since there is at least one string, there must be a shortest string, and it can be no longer than this.
FALSE. Every context-free language is in the class P, and the languages in P are closed under both intersection and star. So this language is in P, and if P ≠ NP there are no NP-complete languages in P.
TRUE. We know that ALLCFG is an undecidable language, and that ECFG is decidable. If there were a poly-time reduction from ALLCFG to ECFG, this reduction would also be a mapping reduction. We would then have a violation of the downward closure of the class of decidable languages under ≤m.
TRUE. We know that CVP is complete for the class P under ≤L reductions, and thus that any language in P reduces to CVP under such reductions. If R is any regular expression, L(R) is in P because the DFA equivalent to can be simulated in time polynomial in the length of the input string.
We can build an LATM(1) whose language is {anbncn: n ≥ 0}, a language that we know not to be context-free. The machine first scans the input and rejects if it is not in the language a*b*c*. It then returns both heads to the left endmarkers of their tapes. Now it moves right on the input tape to the first b, moving right on the worktape at the same time so that the distances moved on the two tapes is the same. Then it moves left on the input tape to the first c, moving left on the worktape at the same time so that if the number of a's and b's is the same, it reaches the $ on the work tape at the same time it reaches the first c on the input tape. It rejects if this does not happen. Finally, it similarly checks whether the number of b's and the number of c's in the input string is the same, rejecting if it is not and accepting if it is. This behavior depends on the worktape contents only in that the machine checks for the $ there.
There are several possible proofs here. Perhaps the simplest is to note that
the configuration of an LATM(1) can be defined by the state and two natural
numbers, the head positions on the two tapes. The input head position is
limited by n, the input size, and we can argue that if the LATM(1) has run
more than O(n) steps, it has repeated a state and input head position. If it
is in the same work tape position both times, it is in an infinite loop. If
between those two times it moved right on the work tape, it will repeat that
loop forever. If between those two times it moved left, it will eventually
reach the $ on the work tape. If it reaches the $ on the work tape more than
O(n) times, it must again be in a loop.
So no terminating computation can last more than O(n2) time, and
a simulation of the machine for that long can be carried out in polynomial
time.
We can convert an arbitrary one-tape TM M into an equivalent LATM(2) M',
so that the function that takes (M, w) to (M', w) is a mapping reduction from
the undecidable language ATM to ALATM(2). The
existence of this reduction proves that ALATM(2) is not TD.
To make M', we choose an encoding of letters of the tape alphabet of M
as binary strings of some fixed length. M' will translate its input tape into
a binary version on its work tape, then simulate M on its work tape. For
each step of M, it must read the string representing the currrent letter of
M's work tape, deetermine what to do based on that string, the input letter it
sees, and M's state, and then rewrite the string to represent the new letter
on M's tape and move to the left or right an appropriate distance. A much
larger but still finite state table for M' can do this.
As many of you noticed, TWO-QUEST is a thinly disguised version of the language
BIPARTITE, shown to be in NL on the homework. If we define an undirected
graph with a node for each knight and an edge between the nodes for any two
knights who are quarrelling, then the knights may be sent on two quests if
and only if this graph is bipartite.
The homework solution used the fact that the graph is bipartite if and only
if there is not an odd-length path from any vertex to itself. Thus the
set of non-bipartite graphs is in NL because a log-space TM could guess such
a path and verify that its length is odd by counting the edges as it proceeds
-- this is possible if and only if
such a path exists. But by the Immerman-Szelepcsenyi Theorem, putting the
language in co-NL suffices to put it in NL.
We could use a solution to MIN-QUEST to solve the NP-complete problem 3-COLOR. Given an undirected graph G, we create a quarrelling list with two knights quarreling if and only if their nodes have an edge in G. Then we use the solution to determine the minimum number of quests needed to have no two quarrelling knights on the same quest. If this number is at most 3, then G can be three-colored -- if not, it cannot.
To tell whether a pair (Q, S) is in SEAT-CHECK, we need to loop through each position i at the table, rejecting if the knight seated at i is quarrelling with the knight seated at i+1. If Arthur is not at the table, we also have to check whether the knight in position n is quarrelling with the knight at position 1 (if we have no position 0). To do this, the only memory we need is to store i and the numbers of two knights, which are three numbers of O(log n) bits each. This can clearly be done by a logspace TM.
Clearly this language is in NP because the seating arrangement is the
certificate and we just showed that we can check a seating arrangement in
L, and therefore in P.
We show it to be NP-complete by giving a poly-time
reduction from the NP-complete language UHAM-PATH to SEAT-WITH-ARTHUR.
Given an undirected graph G with vertices s and t, we make a quarrelling list
where two knights are quarrelling if and only if their nodes do not
have an edge between them. We map node s to Lancelot and node t to
Galahad, or vice versa. Then a Hamilton path from s to t exists if and only
if the knights can be seated with no quarrelling pair next to one another.
Again this language is in NP because the seating arrangement is the
certificate and we just showed that we can check a seating arrangement in
L, and therefore in P.
To show this language NP-complete, we can give a poly-time reduction from
SEAT-WITH-ARTHUR (which we just proved to be NP-complete) to
SEAT-WITHOUT-ARTHUR. Given a quarrelling list Q for n knights,
including Galahad and Lancelot, create a new list Q' by adding a new knight
Mordred, who is quarrelling with every knight except Galahad and
Lancelot. There is a seating arrangment for Q with Arthur if and only if
there is a seating arrangement for Q' without Arthur, because Mordred can
only be seated between Galahad and Lancelot, exactly where Arthur would sit
in the first arrangement.
Last modified 24 June 2015