CSCI 1010 Theory of Computation HW11 Due: December 8, 2016 Attach a fully filled-in cover sheet to the front of your printed homework. Your name should not appear anywhere except on the cover sheet; each individual page of the homework should include your Banner ID instead. While collaboration is encouraged in this class, please remember not to take away notes from any collaboration sessions. Also please list the names and logins of any of your collaborators at the beginning of each homework. Please monitor Piazza, as we will post clarifications of questions there. You should hand in your solutions by 12:55 to the CSCI 1010 bin on the second floor of the CIT. Late homeworks are not accepted. Problem 1 Walter Chestnutt has been sent to jail. Due to his lack of knowledge about PSPACE, he was unable to win his trial by LosingSubset, and has thus lost his freedom and root vegetable status. However, the obfuscated mangelwurzel he stole from the O Nions has yet to be found, and some of Walter s henchmen are still at large. In the meantime, Töhm Eric has finally passed his Turing test thanks, in part, to the help of unsuspecting humans. As a key player in Walter s support of turmeric, Töhm has some ideas about where the mangelwurzel might be. The only problem is transportation, as Töhm knows that Walter s genetic experiments produced some crazy mangelwurzel specimens. Töhm wants to transport the mangelwurzel in as few root vegetable crates as possible. Each crate can hold a total volume of b mangelwurzels. There are n mangelwurzels in Walter s secret lair, and their volumes are represented as S = {x 1,x 2,...,x n } where x i is the volume of the ith mangelwurzel. Some mangelwurzels are massive, but none are of so large a volume that they will not fit into a root vegetable crate. Although he wants to pack all of the mangelwurzels into the minimum number of crates, Töhm doesn t want to encounter any of Walter s other henchmen or competitors, so he uses an approximation algorithm to save time. The following algorithm adds mangelwurzels one by one to the root vegetable crates. It starts with the first crate. Once Töhm encounters a mangelwurzel
that does not fit into the first crate, he places it in the second crate. He then adds mangelwurzels to the second crate until he encounters a mangelwurzel for which there is no room. After all mangelwurzels are loaded into crates, Töhm returns the number of crates he used. Algorithm MangelwurzelCrates = On input S = {x 1,...,x n },b: 1. Let k = 1,v k = 0. 2. For each i where 1 i n: If x i +v k > b, let k := k +1 and let v k = x i. Otherwise, let v k := x i +v k. 3. Return k. Prove that this algorithm is a polynomial-time 2-approximation for the task of finding the smallest number of crates. Note: Töhm s dilemma is very similar to the situation described in Problem 1 of Homework 9. Problem 2 For the last week, we have been looking at problems that are NP-hard not only to solve exactly, but even to approximate. In the travelling salesman problem, an instance is a fully connected weighted undirected graph G = (V,E) with a starting vertex s and ending vertex t. A solution is a simple path from s to t that visits every vertex in the graph. The cost of a solution is the sum of weights of the edges of the path; this cost function is called MIN-TSP ( TSP stands for the travelling salesman problem ). The decision variant of this problem, in which we are given the instance and a maximum cost and need to decide whether a solution of at most that cost exists, is NP-hard, which you could easily show by reduction from HamiltonianPath. However, the problem is also NP-hard to approximate. We can show this by again using HamiltonianPath. a. Suppose that there is a polynomial-time c-approximation to the travelling salesman problem for some constant c. Using such an approximation 2
algorithm, show that one can solve any instance of HamiltonianPath. Conclude that the travelling salesman problem is NP-hard to approximate. b. Using the fact that HamiltonianPath is NP-hard, conclude that if we, for any constant c, have a polynomial-time c-approximation algorithm for the travelling salesman problem, then P must equal NP. Note: There are approximation algorithms for some variants of the TSP. For example, the Christofides algorithm provides a 1.5-approximation for metric-tsp, which is an instance of the TSP such that all edges satisfy the triangle inequality. Because these algorithms do not cover all cases for the TSP, they do not contradict the result of this problem. The following questions are lab problems. Lab Problem 1 Ever since Ginger and Rudy returned to Myami and stopped meeting with each other, Ginger 2.0, Ginger s robotic doppelgänger, has been on the loose. At one point, Ginger 2.0 decided to construct her own robotic friend. BecauseGinger2.0wascreatedatatimewhenRudyandGingerwereblissfully in love, she naturally decided to make Rudy 2.0. To test whether Rudy 2.0 was a sufficient copy of Rudy, Ginger 2.0 developed a 3CNF to test the Rudy-ness of a root vegetable AI. Recall that in the decision problem 3SAT, we have to determine whether there is some assignment of truth values that satisfies every clause of a 3CNF. In the optimization version MAX-3SAT, the goal is to find some assignment of truth values that satisfies the maximum possible number of clauses, even if it is not possible to satisfy every clause. As she plans for future endeavours and competition with her nemesis Töhm Eric, Ginger 2.0 wonders if she could have constructed Rudy 2.0 so that he passed more clauses of the 3CNF. Help Ginger 2.0 design a polynomial-time algorithm that, given as input a Boolean formula in 3CNF, finds an assignment of values that satisfies at least 7/8 as many clauses as the maximum possible number of satisfiable clauses. You should assume that each clause contains exactly 3 literals of distinct variables. 3
Hint: The algorithm should set each variable in the formula one by one, depending on the expected number of satisfied clauses given a particular assignment. That is, the algorithm should choose an assignment to variable x i based on the expected number of satisfied clauses given that x i = 1 and the expected number of satisfied clauses given x i = 0. Lab Problem 2 We have previously dealt with LOGSPACE, in which a machine can read from the input tape but not modify it, and has another working tape of logarithmic size relative to the input. NL is the nondeterministic version of LOGSPACE, with the same size restrictions but allowing the machine to make nondeterministic choices. Reductions to show problems are NL-hard are defined differently from those that show NP and PSPACE-hardness. The machine performing the reduction has three tapes: an input tape which can be read but not modified, a logarithmic-size working tape, and a polynomialsize output tape that can be written to but not read. For example, a language that is NL-complete is PATH: PATH = { G,s,t G is a directed graph that has a path from s to t} One fateful day in Myami, Ginger is busy avoiding Rudy. Just as she manages to stay away from him, she runs straight into another Rudy! Little does she know that it is actually Rudy 2.0, but she is even more shocked when he is joined by another Ginger. Realizing that it s her robotic replica, Ginger confronts Ginger 2.0 to find out just what s going on. Ginger 2.0 explains that she created Rudy 2.0 as a friend, but he then decided to go undercover as Walter Chestnutt s lover to dig up dirt on his illegal obfuscation empire. Rudy never loved Walter, Ginger 2.0 says. And Rudy 2.0 only did it to protect the O Nions monopoly on mangelwurzel! Astonished by this news, Ginger sets out to find Rudy and apologize. The four of them Ginger, Rudy, Ginger 2.0, and Rudy 2.0 1 decide to tackle some of Myami s computational problems and stop the increasingly nefarious activities of Töhm Eric. Their first step is to establish a map system so that they can travel along a directed path between any two meeting points in Myami. They realize that 1 For the sake of clarity, Ginger 2.0 and Rudy 2.0 change their names to Potata Lovelace and Alan Turnip. They will come to be remembered as pioneers in the theory of yamputation. 4
this is actually a dircted graph problem and construct the language: MyamiMap = { G v 1,v 2, a path from v 1 to v 2 and v 2 to v 1 } Their intuition tells them that this language might be NL-complete. Prove to them that it is, by a logarithmic-space reduction from PATH. Lab Problem 3 A probabilistic Turing machine is a Turing machine that, in addition to the usual tape, has a second tape filled with random bits. This machine may sometimes accept, and sometimes reject the same input x, depending on the content of the random tape. The concept of a probabilistic Turing machine gives rise to a whole new set of complexity classes; namely probabilistic polynomial time complexity classes. Some of the main ones are BPP, RP, corp, and ZPP 2, and they are defined as follows: A language L is in BPP if there exists a probabilistic Turing machine M that runs in polynomial time such that the following two conditions hold: Completeness For every x L, Pr[M accepts x] 2/3. Soundness For every x / L, Pr[M accepts x] 1/3. This Turing machine M is called a Monte-Carlo algorithm for L. A language L is in RP if there exists a probabilistic Turing machine M that runs in polynomial time such that the following two conditions hold: Completeness For every x L, Pr[M accepts x] 2/3. Perfect soundness For every x / L, Pr[M accepts x] = 0. A language L is in corp if its complement is in RP. Equivalently, a language L is in corp if there exists a Turing machine M that runs in polynomial time such that the following two conditions hold: 2 For the curious: BPP stands for bounded-error probabilistic polynomial time, RP stands for randomized polynomial time, and ZPP stands for zero-error probabilistic polynomial time! 5
Perfect completeness For every x L, Pr[M accepts x] = 1. Soundness For every x / L, Pr[M accepts x] 1/3. A language L is in ZPP if there exists a probabilistic Turing machine M that, in addition to the usual accepting and rejecting states, has an unsure state in which the machine can halt. M will run in polynomial time and at termination time will be in the accept, reject, or unsure state, such that the following two conditions hold: Completeness Foreveryx L,Pr[M accepts x] 2/3,Pr[M rejects x] = 0, and Pr[M is unsure on x] 1/3. Soundness For every x / L, Pr[M accepts x] = 0, Pr[M rejects x] 2/3, and Pr[M is unsure on x] 1/3. a. Show that P RP BPP and P corp BPP. b. Show that ZPP = RP corp. c. UsingeitherthegivendefinitionforZPPortheoneyoujustderivedinb., demonstrate that the following definition is also equivalent: A language L is in ZPP if there exists a probabilistic Turing machine M (which does not have unsure states) and some polynomial p such that: Runtime For all inputs x of length n, E[runtime of M on x] O(p(n)). Completeness For every x L, Pr[M accepts x] = 1. Soundness For every x / L, Pr[M accepts x] = 0. 6