Docsity

U.C. Berkeley CS172 Midterm 2 Solutions: Automata, Computability and Complexity, Exams of Advanced Algorithms

Toggle sidebar
bg1
U.C. Berkeley — CS172: Automata, Computability and Complexity Solutions to Midterm 2
Professor Luca Trevisan 4/18/2007
Solutions to Midterm 2
1. Prove or disprove:
(a) Let Mbe a deterministic Turing machine that, on inputs of length n, uses space O(n2).
Then for every input x, and every configuration Cof the computation of Mon input x,
K(C)≤O(|x|) there Kis Kolmogorov complexity and |x|is the length of x.
(b) Let Mbe a deterministic Turing machine that, on inputs of length n, uses space O(n2)
and time O(n3). Then for every input x, and every configuration Cof the computation
of Mon input x, K(C)≤O(|x|) where Kis Kolmogorov complexity and |x|is the length
of x.
[30 points]
Solution Outline:
(a) The statement is false. Consider a machine Mwhich simply looks at the length nof the
input and then enumerates all possible strings of length n2on its tape. Since there is a
string Cof length n2such that K(C)≥O(n), we get a contradiction.
(b) This statement is true. Any configuration Cof the machine can be describes by spec-
ifying the code of the machine, the input and the time at which the configuration
occurs. Since the code of the machine is a constant, the time can be specified in
O(log |x|3) = O(log x) bits and the input is |x|bits, this gives K(C)≤O(|x|).
2. We define #SAT to be the language
#SAT = {hϕ,k i | ϕhas exactly ksatisfying assignments}
Show that:
(a) #SAT is coNP hard (recall that coNP ={L|L∈NP}).
(b) #SAT ∈PSPACE.
[40 points]
Solution Outline:
(a) To show #SAT is coNP hard, note that ϕ∈SAT ⇔ hϕ, 0i ∈ #SAT as SAT is the
set of all the formulas which are unsatisfiable i.e. have exactly 0 satisfying assignments.
This shows that SAT ≤p#SAT which proves the claim.
(b) We enumerate all possible assignments to the variables and for each assignment, we can
check if it satisfies the formula. We also keep a count of the satisfying assignments.
Since it takes nbits to store an assignment, nbits to store the counter (as there can
be at most 2nsatisfying assignments), polynomial space to check if a given assignment
satisfies the formula, the algorithm uses polynomial space overall.
1
pf2

Partial preview of the text

Download U.C. Berkeley CS172 Midterm 2 Solutions: Automata, Computability and Complexity and more Exams Advanced Algorithms in PDF only on Docsity!

U.C. Berkeley — CS172: Automata, Computability and Complexity Solutions to Midterm 2 Professor Luca Trevisan 4/18/

Solutions to Midterm 2

  1. Prove or disprove:

(a) Let M be a deterministic Turing machine that, on inputs of length n, uses space O(n^2 ). Then for every input x, and every configuration C of the computation of M on input x, K(C) ≤ O(|x|) there K is Kolmogorov complexity and |x| is the length of x. (b) Let M be a deterministic Turing machine that, on inputs of length n, uses space O(n^2 ) and time O(n^3 ). Then for every input x, and every configuration C of the computation of M on input x, K(C) ≤ O(|x|) where K is Kolmogorov complexity and |x| is the length of x.

[30 points] Solution Outline:

(a) The statement is false. Consider a machine M which simply looks at the length n of the input and then enumerates all possible strings of length n^2 on its tape. Since there is a string C of length n^2 such that K(C) ≥ O(n), we get a contradiction. (b) This statement is true. Any configuration C of the machine can be describes by spec- ifying the code of the machine, the input and the time at which the configuration occurs. Since the code of the machine is a constant, the time can be specified in O(log |x|^3 ) = O(log x) bits and the input is |x| bits, this gives K(C) ≤ O(|x|).

  1. We define #SAT to be the language

#SAT = {〈ϕ, k〉 | ϕ has exactly k satisfying assignments}

Show that:

(a) #SAT is coNP hard (recall that coNP = {L | L ∈ NP}). (b) #SAT ∈ PSPACE.

[40 points] Solution Outline:

(a) To show #SAT is coNP hard, note that ϕ ∈ SAT ⇔ 〈ϕ, 0 〉 ∈ #SAT as SAT is the set of all the formulas which are unsatisfiable i.e. have exactly 0 satisfying assignments. This shows that SAT ≤p #SAT which proves the claim. (b) We enumerate all possible assignments to the variables and for each assignment, we can check if it satisfies the formula. We also keep a count of the satisfying assignments. Since it takes n bits to store an assignment, n bits to store the counter (as there can be at most 2n^ satisfying assignments), polynomial space to check if a given assignment satisfies the formula, the algorithm uses polynomial space overall.

  1. Let T h(N, +, ≤) denote theory of the model whose universe is the set of natural numbers (including 0) and the relations are the usual + and ≤ relations as defined on natural numbers. Show that T h(N, +, ≤) is NP-hard. [30 points] Solution Outline: We reduce 3SAT to deciding statements in T h(N, +, ≤). Let ϕ be a 3SAT formula with variables x 1 ,... , xn. We create a logical sentence with quantifiers ∃x 1 ,... , xn. To simulate xi, for each variable xi, we add the clause ∃xi (xi + xi = 1). Here, we think of 1 as true and 0 as false. Note that since xi and xi are both non-negative, they can be only 0 or 1 by the above clauses. Finally, we two clauses for checking every clause of ϕ is satisfied. Say cj = (xi 1 ∨ xi 2 ∨ xi 3 ) is a clause in ϕ. Then we add ∃yj (yj = xi 1 + xi 2 ) ∧ (1 ≤ yj + xi 3 ). Note that we need to add an extra variable yj for each clause cj since the ‘+’ relation only allows us to add two numbers at a time. It is easy to see that the reduction is polynomial time and the new sentence is true if and only if ϕ is satisfiable.