Q1: 10 points Q2: 10 points Q3: 10 points Q4: 10 points Q5: 10 points Q6: 25 points Q7: 30+10 points Q8: 20 points Total: 125+10 points
Question text is in black, solutions in blue.
If C is any class of computers, such as DFA's, CFG's, LBA's TM, strange variant TM's, etc.:
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.
Although we did not prove this in lecture, you may assume both:
Define a weighted graph to be an undirected graph where each vertex has a positive integer weight -- you may assume that each weight is at most n, the number of vertices. The language WC (weighted clique) is the set {(G, S, k): S is a clique in the weighted graph G and the sum of the weights of the vertices in S is at least k}. The language MWC (maximum weighted clique) is the set {(G, k): there exists a clique in the weighted graph G such that the sum of the vertex weights in the clique is at least k}.
A directed graph is strongly connected if for every pair of vertices u and v, there is a (directed) path from u to v. The language STRCONN is the set of all strongly connected directed graphs.
TRUE. A CFG generates an infinite language if and only if it contains
a string w such that p ≤ |w| ≤ 2p, where p is the pumping
length
of the grammar. If it contains such a string, pumping up shows
infinitely many other strings to be in the langauge. And if the
language is infinite, there must be a string of length at least 2p,
and we can pump that string down until it is in the desired range.
Since ACFG is TD, there is a Turing machine that can
test all possible strings in that range.
TRUE. Let X be a TD language that is not in P, and let Y = {a} for
some letter a in Σ. Then X ≤m Y because the
function can test whether its input w is in X, and output a or aa
accordingly. But if X ≤p Y, X would be in P because Y
is in P.
The fact that there exist TD languages that are not in P is a
consequence of the Time Hierarchy Theorem, mentioned but not proved
in class.
FALSE. Our standard non-CFL {anbncn: n ≥ 0} is easily seen to be in L, since a TM can count the number of each letter, keeping the answers in binary on its work tape, and compare the three numbers for equality.
FALSE. It is true that X* is TD if X is. But let X be any non-TD language that happens to contain all one-letter strings. Then X* = Σ* which is TD.
FALSE. The intersection of this CFL with the regular language b*ca* is {bncan: n ≥ 0}, because every string in the CFL has an equal number of b's and a's. But this intersection is easily shown not regular by Myhill-Nerode: the set {λ, b, bb, bbb,...} is pairwise inequivalent.
Given (G, S, k), we need to verify that S is a clique and that the sum of the weights of the vertices in S is at least k. Since each weight is at most n, the sum of weights is at most n2 and we can be sure that we can add up the weights on our worktape. To verify that S is a clique, we need merely loop through all pairs of distinct vertices {x, y} in S and verify that there is an edge between x and y. This takes two loop variables of O(log n) bits each.
MWC is in NP because any clique S with the proper weight, so that (G, S, k) is in WC, is a certificate for (G, k) being in MWC. Our verifier tests membership in WC, which is in P because we showed it to be in L above and L ⊆ P. To prove NP-completeness we reduce from CLIQUE, which was shown to be NP-complete in the text. Given an input (G, k), our reduction function will output (G', k), where G' is the weighted graph made from G by giving each vertex a weight of 1. Then (G, k) is in CLIQUE if and only if a clique of size at least k exists in G, which is true if and only if a clique of weight at least k exists in G'.
On input graph G, loop over all vertices x. For each x, carry out a depth-first search of G starting from x and verify that every vertex is reachable from x. If every vertex is reachable from every other, accept G, otherwise reject it. This is polynomial time because we know that DFS takes O(e) = O(n2) operations on a graph with n vertices, and each basic operation takes only polynomial time on a Turing machine.
For every vertex x and for every vertex y ≠ x, test whether there
is a path from x to y using the Savitch's Theorem argument
(middle-first search). This means testing each predicate
PATH(s, t, 2k) by looping through all possible vertices
u and testing whether both PATH(s, u, 2k-1) and
PATH(u, t, 2
We know that PATH(x, y) is in the class NL for any vertices x and y. Our nondeterministic log-space Turimg machine must be able to accept a directed graph G if and only if it is strongly connected. What it does is to loop over all pairs of vertices (x, y), guess a path out of x for each, and accept if and only if each of these guessed paths reaches its respective y. If the graph is strongly connected, it is possible for the machine to guess correctly. If it is not, for some choice of x and y there will be no path from x to y, and thus whatever path the machine guesses will fail and the machine will reject G no matter how it guesses.
We have shown that STRCONN is in NL -- it remains to show that PATH
≤L STRCONN. Let (G, s, t) be an input to PATH, so that
G is a directed graph and s and t are vertices. Let G' be a directed
graph with the same vertices as G as follows. G' includes all the
edges
of G, but in addition for every vertex z other than s and t, it has
an edge from z to s and an edge from t to z. I claim that G has a
path
from s to t if and only if G' is strongly connected.
Clearly if there is a path from s to t in G, then for any vertices
x and y in G', there is a path from x to s to t to y in G' and so G'
is strongly connected. Now suppose that G' is strongly connected.
There
must be a path from s to t in G'. But if this path exists, there must
also
be such a path that does not use any of the new edges and is thus also
a
path from s to t in G. This is because the shortest path from s to t
in
G' cannot use any new edges -- if it uses an edge from z to s, then
the portion of the path following that edge is a shorter path from s
to t, and if it uses an edge from t to z, the portion of the path
before
that edge is a shorter path from s to t.
I claim that M is in ALLSTARDFA if and only if L(M) contains all one-letter strings, that is, if and only if Σ ⊆ L(M). If it does, Σ* ⊆ L(M)* by the regular language identity X ⊆ Y → X* ⊆ Y*. If it does not, some single-letter string a is not in L(M), and that string cannot be in L(M)* either because there is no way to make up a as a concatenation of other strings.
We reduce the undecidable language ATM to ALLSTARTM. Let M be any TM and w be any string over M's input alphabet. We define f(M, w) to be a Turing machine N that ignores its input and simulates M on w. If (M, w) ∈ ATM, then L(N) = Σ* so clearly L(N)* = Σ* and N ∈ ALLSTARTM. If (M, w) ∉ ATM, then L(N) = ∅ and L(N)* ≠ Σ*, so N ∉ ALLSTARTM.
Last modified 1 May 2014