Exercises Computational Complexity

Similar documents
8.1 Polynomial-Time Reductions

CS 125 Section #10 Midterm 2 Review 11/5/14

More on Polynomial Time and Space

9.1 Cook-Levin Theorem

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

NP-Completeness. Algorithms

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

Computability Theory

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

8 NP-complete problem Hard problems: demo

CS 151 Complexity Theory Spring Final Solutions. L i NL i NC 2i P.

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

NP and computational intractability. Kleinberg and Tardos, chapter 8

8.1 Polynomial-Time Reductions

USING QBF SOLVERS TO SOLVE GAMES AND PUZZLES. Zhihe Shen. Advisor: Howard Straubing

W4231: Analysis of Algorithms

ALGORITHMS EXAMINATION Department of Computer Science New York University December 17, 2007

Reductions and Satisfiability

1 Definition of Reduction

Complexity Classes and Polynomial-time Reductions

NP versus PSPACE. Frank Vega. To cite this version: HAL Id: hal

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

P and NP (Millenium problem)

arxiv: v2 [cs.cc] 29 Mar 2010

6.045J/18.400J: Automata, Computability and Complexity Final Exam. There are two sheets of scratch paper at the end of this exam.

The Complexity of Camping

Some Hardness Proofs

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

CS 580: Algorithm Design and Analysis

3/7/2018. CS 580: Algorithm Design and Analysis. 8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability

The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

1 Introduction. 1. Prove the problem lies in the class NP. 2. Find an NP-complete problem that reduces to it.

NP-Complete Reductions 2

6.045 Final Exam. Name: Please write your name on each page. This exam is open book, open notes.

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

1. [5 points each] True or False. If the question is currently open, write O or Open.

FINAL EXAM SOLUTIONS

CS521 \ Notes for the Final Exam

Lecture 14: Lower Bounds for Tree Resolution

Finding a winning strategy in variations of Kayles

Fixed Parameter Algorithms

Solutions for the Exam 6 January 2014

CMPSCI611: The SUBSET-SUM Problem Lecture 18

NP-Complete Problems

PCP and Hardness of Approximation

2SAT Andreas Klappenecker

CS 512, Spring 2017: Take-Home End-of-Term Examination

PSPACE Problems. The Class PSPACE. PSPACE Problems are interesting since: They form the first interesting class potentially

W[1]-hardness. Dániel Marx 1. Hungarian Academy of Sciences (MTA SZTAKI) Budapest, Hungary

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Algorithms For Inference Fall 2014

Where Can We Draw The Line?

Lecture 21: Other Reductions Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

Final Exam May 8, 2018

Theory of Computations Spring 2016 Practice Final Exam Solutions

Lecture 21: Other Reductions Steven Skiena

Complexity of unique list colorability

We ve studied the main models and concepts of the theory of computation:

P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang

Chapter 8. NP-complete problems

COMP260 Spring 2014 Notes: February 4th

Online Ramsey Theory

Umans Complexity Theory Lectures

(p 300) Theorem 7.27 SAT is in P iff P=NP

1. Suppose you are given a magic black box that somehow answers the following decision problem in polynomial time:

Examples of P vs NP: More Problems

14.1 Encoding for different models of computation

1 Undirected Vertex Geography UVG

The Resolution Algorithm

Randomness and Computation March 25, Lecture 5

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Steven Skiena. skiena

Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

CS154, Lecture 18: PCPs, Hardness of Approximation, Approximation-Preserving Reductions, Interactive Proofs, Zero-Knowledge, Cold Fusion, Peace in

Copyright 2000, Kevin Wayne 1

P -vs- NP. NP Problems. P = polynomial time. NP = non-deterministic polynomial time

Theory Bridge Exam Example Questions Version of June 6, 2008

On Covering a Graph Optimally with Induced Subgraphs

Vertex Cover Approximations

SAT-CNF Is N P-complete

CSE 105 THEORY OF COMPUTATION

Linear Time Unit Propagation, Horn-SAT and 2-SAT

Chapter 10 Part 1: Reduction

An IPS for TQBF Intro to Approximability

NP-complete Reductions

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

6.006 Introduction to Algorithms. Lecture 25: Complexity Prof. Erik Demaine

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

END-TERM EXAMINATION

Boolean Functions (Formulas) and Propositional Logic

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

5. Lecture notes on matroid intersection

1. Provide two valid strings in the languages described by each of the following regular expressions, with alphabet Σ = {0,1,2}.

A New Reduction from 3-SAT to Graph K- Colorability for Frequency Assignment Problem

Problem set 2. Problem 1. Problem 2. Problem 3. CS261, Winter Instructor: Ashish Goel.

Transcription:

Exercises Computational Complexity March 22, 2017 Exercises marked with a are more difficult. 1 Chapter 7, P and NP Exercise 1. Suppose some pancakes are stacked on a surface such that no two pancakes have the same size. For convenience denote the smallest pancake by 1, the second smallest by 2, etc. The only permissible operation on the stack of pancakes is as follows: Insert a spatula between 2 pancakes or between the bottom pancake and the surface, then rotate the pancakes above the spatula. Give an algorithm that sorts any stack of n pancakes (smallest at the top largest at the bottom) with at most poly(n) many flips. 3 1 4 2 4 1 3 2 = A solution for this example: 314 2 4132 23 14 321 4 1234. Exercise 2. Show that TIME(f(n)) TIME(n + εf(n)) for every f : N N and every ε > 0. We use multitape Turing machines. Why do we need to add n to εf(n)? (Hint: simulate any machine by an other machine with a large enough alphabet that encodes several tape-cells in one cell.) Exercise 3. Show that P and NP are closed under intersection, union and star operator. (Hint: the hardest part is to show that P is closed under the star operator. Use dynamic programming, i.e., the technique in the proof of Theorem 7.16.) Ex. 7.13 and 7.43. Exercise 4. Show that subset sum in unary notation is in P, i.e., show that Unary SUBSET- SUM= {1 t #1 w 1 #... #1 wn : x {0, 1} n : t = x i w i } is in P. Ex. 7.44. Exercise 5. Show that if P = NP, then all languages A P, except A = and A = Σ, are NP-complete. Ex. 7.45. Date: March 22, 2017. Many exercises are copied or copied with small variations from the book Introduction to the theory of computation by Michael Sipser. 1

Exercise 6. Show that if P = NP, then there exists an algorithm that on input a Boolean formula φ decides whether φ is satisfiable, and if it is satisfiable, returns an assignment of the variables that makes φ true. Moreover, the algorithm runs in time polynomial in the size of φ. (Note that with this technique, one can compute certificates for any problem in NP.) A variant of ex. 7.35. Exercise 7. Let CNF k be the set { φ : φ is a satisfiable cnf-formula where each variable appears in at most k places}. (This is not the same kcnf, where each term has at most k literals.) Show that CNF 2 P. Show that CNF 3 is NP-complete. Exercise* 8. Let OneSAT be the set of cnf-formula for which an assignment exists for which each clause contains exactly one true literal. Prove that OneSAT is NP-complete. Let One3SAT be the set of 3cnf-formula for which such an assignment exists. Show that also One3SAT is NP-complete. Exercise 9. A colouring of a graph is an assignment of colours to nodes so that no two nodes that are connected by an edge have the same colour. Let 3COLOUR be the set of such graphs. Show that 3COLOUR is NP-complete. (Hint: Let the 3 colours be T, F and N. Interpret the first as True and False, and represent them on a palette.) Ex. 7.38. F T palette N variable OR-gadget Exercise 10. Consider the following scheduling problem. You are given a list of final exams F 1,..., F k to be scheduled, and a list of students S 1,..., S l. Each student is taking some specified subset of these exams. You must schedule each exam into exactly one slot such that no student is required to take two exams in the same slot. The problem is to determine if such a schedule exists that uses only h slots. Formulate this problem as a language and show that it is NP-complete. Ex. 7.30. Exercise 11. In the following solitaire game, you are given an m m board. On each of its m 2 positions lies either a green stone, a red stone, or nothing at all. You play by removing stones from the board. You win if each column contains only stones of a single colour and each row contains at least one stone. Winning may or may not be possible depending upon the initial configuration. Prove that the set of winnable game configurations is NP-complete. Ex. 7.28 2

Exercise* 12. Let f be a function for which f(n) o(n log n). Show that all languages that can be decided in time f(n) are regular. Ex. 7.20 Exercise 13. This problem investigates resolution, a method for proving the unsatisfiability of cnf-formulas. Let φ = C 1 C 2 C m be a formula in cnf, where C i are its clauses. Let C = {C 1,..., C m }. In a resolution step we take two clauses C a and C b in C such that some variable occurs positively in C a and negatively in C b. Thus C a = (x y 1 y 2 y k ) and C b = (x z 1 z 2 z l ). We form the new clause (y 1 y k z 1 z l ) and remove repeated literals. Add this new clause to C. Repeat the resolution steps until no additional clauses can be obtained. If the empty clause () is in C, then declare φ unsatisfiable. Show that resolution is sound, i.e., it never declares satisfiable formulas to be unsatisfiable. Show that resolution is complete, i.e., every unsatisfiable formula is declared to be unsatisfiable A 2CNF -formula is a conjunction of clauses of 2 variables. Let 2SAT be the set of satisfiable 2CNF -formulas. Show that 2SAT P. 2 Chapter 8: Space complexity Exercise 14. A ladder is a sequence in of strings s 1, s 2,..., s k such that each strings differs from the previous one by replacing exactly one character. For example: Let LADDER DFA be head, hear, near, bear, beer, deer, deed, feed, feet, fret, free { M, s, e : M is a DFA and L(M) contains a ladder starting in s and ending in e}. Show that this set is in PSPACE. Ex. 8.25. Exercise 15. Show that if A PSPACE, then A PSPACE. Part of Ex. 8.4. Exercise 16. Show that if every NP-hard language is also PSPACE-hard, then NP = PSPACE. Ex. 8.27. Exercise 17. Show that TQBF restricted to the formulas where the part following the quantifiers is in 3CNF form is still PSPACE-complete. Ex. 8.28. Exercise 18. Let A LBA = { M, w : M is a linear bounded automaton that accepts w}. Show that A LBA is PSPACE-complete. Ex. 8.29. Exercise 19. Two Boolean formulas are equivalent if they have the same set of variables and are true on the same set of assignments to those variables (i.e., they describe the same Boolean function). A Boolean formula is minimal if no shorter Boolean function is equivalent to it. Let MIN -FORMULA be the collection of minimal Boolean formulas. 3

Show that MIN -FORMULA PSPACE. Explain why this argument fails to show that MIN -FORMULA conp: If φ MIN -FORMULA, then φ has a smaller equivalent formula. A non-deterministic Turing machine can verify that φ MIN -FORMULA. Ex. 8.32. Exercise 20. In exercise 17 you showed that the set of TQBF in 3CNF -form is PSPACEcomplete. Now, consider Boolean formula that have no negations, i.e., formula that are constructed with only AND and OR operations. Such formula are called monotone. { } x 1 x 2... x 2n 1 x 2n Φ(x 1,..., x 2n ) : Φ is a monotone Boolean formula Do one of the following things: (a) show that this set is in P or (b) show that it is PSPACEcomplete. Hint: think about why these formula are called monotone? Exercise 21. Exercise 8.31. Exercise* 22. In the game generalized geography, two players alternate turns and construct a single path in a directed graph. A player looses if he can not extend the end of the path with a vertex that does not belong to the path. In a variant of this game, both players alternate turns and each player constructs his own path. A player looses if in his turn he can not extend his path with a vertex that does not appear in his and the other players path. Let GG be the set of triples (G, a, b) where the first player has a winning strategy in the modified geography game when he starts in vertex a and the second player starts in vertex b. Show that GG is PSPACE-complete. Hint: There are several solutions. It might help to note that the reduction for GG works with arbitrary Boolean formula. Rewrite a given Boolean formula such that it is build from literals, OR operations, and binary AND operations. The basic ideas are similar from the construction of GG, but the forall player can one of the options while the exist player goes through an AND-gate. Exercise 23. During the lectures, it was shown that (directed) Generalized Geography is PSPACE-complete. Surprisingly, the undirected variant is in P. The goal of the exercise is to prove this. In the game undirected vertex geography two players alternate moves and construct together a single path in an undirected graph. Initially, the beginning and the end of the path coincide with a given start vertex s. At his turn a player should select a vertex that is connected with the end of the path and that does not already appear in the path. This vertex becomes the new end of the path. A player looses if he can not select such a neighbouring vertex. Let UVG be the set of pairs (G, s) where G is a graph and the first player has a winning strategy when he starts playing. A matching in a graph is a set of edges without common neighbours, i.e., no pair of edges is incident on a common vertex. A maximum matching is a matching of maximal cardinality. Show that the first player has a winning strategy in the game (G, s) if and only if every maximum matching has an edge that is incident on s. There exists an algorithm, called Blossom algorithm, that computes the maximal size of a matching in a graph in polynomial time. Assume you can use this algorithm. Use it to construct an algorithm that decides UVG in polynomial time 4

Exercise 24. The cat-and-mouse game is played by two players, Cat and Mouse, on an arbitrary undirected graph. At a given point each player occupies a vertex of the graph. The players take turns moving to a vertex adjacent to the one that they currently occupy. A special vertex of the graph is called Hole. Cat wins if the two players ever occupy the same vertex. He looses if Mouse reaches the Hole before the preceding happens. He also looses if a situation repeats (i.e., the two players simultaneously occupy positions that they simultaneously occupied previously and it is the same player s turn to move). Let HAPPY -CAT be the set of quadruples (G, c, m, h) such that G is a graph, and c, m and h are the positions of Cat, Mouse and Whole, for which Cat has a winning strategy if he moves first. Show that HAPPY -CAT P. Hint: the solution is not too hard. Ex. 8.30. 3 Chapter 9: Intractability Exercise 25. What is the error in the following fallacious argument that P NP? Assume that P = NP, then SAT P and so for some k, SAT TIME(n k ). Therefore P TIME(n k ). But by the time hierarchy theorem, TIME(n k+1 ) contains a language not in TIME(n k ), which contradicts P TIME(n k ). Therefore P NP. Ex 9.20. Exercise 26. Consider the function pad : Σ N (Σ {#}) defined by pad(s, l) = s# j with j = max(0, l s ). For any language A and any function f, let pad(a, f) be the language of elements pad(x, f( x )) for all x A. Prove that A TIME(n 6 ), then pad(a, n 2 ) TIME(n 3 ). If NEXPTIME EXPTIME, then P NP. P SPACE(n 2 ). Ex. 9.21-23. Exercise 27. Let L be the language over the alphabet A = {a, b} that contains all strings that start with at most N symbols a, in other words L = ɛ ba aba aaba a N ba. This is a regular expression with exponentiation. Give a more compact regular expression with exponentiation that uses a single union operation. Exercise 28. Define the USAT problem to be { φ : φ is a Boolean formula that has a single satisfying assignment} Show that USAT P SAT. Ex. 9.18. Exercise 29. Consider the set { φ : φ SAT and the lexicographically first x 1... x n for which φ(x 1,..., x n ) is true, has x n = 0}. Show that this set is in P SAT. 5

Exercise 30. Let MIN -FORMULA be the language defined in exercise 19. Show that the complement of this language is in NP SAT. Exercise 31. Show that if P SAT = NP then NP = conp. Ex. 9.9. Exercise 32. Let P A,1 be the class of languages that can be decided in polynomial time with oracle A, but for which for each input, the machine makes at most one query on the oracle. Show that NP conp P SAT,1, If NP conp, then NP conp P SAT,1. Ex. 9.17. Exercise 33. Define a language L to be downward-self-reducible if there is a polynomial-time algorithm R that for any n and x Σ n, decides whether x L using the oracle L n 1, which solves membership of L for inputs of size at most n 1. In other words, R L n 1 (x) = L(x) for all n and all x of length n. Prove that if L is downward-self-reducible, then L PSPACE. (From the previous edition of Sipser s book.) Exercise 34. Imagine you are given two oracles and one of them is the set TQBF. You don t know which one. Design an algorithm that can access the two oracles A and B and that decides TQBF in polynomial time. Ex.9.15. Exercise 35. Adapt the proof of Theorem 9.20 to show that there exists a decidable set B such that conp B NP B. Ex. 9.16. Exercise* 36. Suppose we generate a random language B in the following way: for every n, with probability 1/2, B has no strings of length n, and with probability 1/2 we pick a random string to be in B. Show that for each ε > 0 we have that P B NP B with probability at least 1 ε. 4 Chapter 10: Advanced topics Exercise 37. Show that if NP BP P, then NP = RP. Ex. 10.11. Exercise 38. Show that: The parity function for n-bit strings can be computed by a branching program of size O(n). Ex. 10.4. The majority function for n-bit strings, i.e., the function x n i=1 x i > n/2, can be computed by a branching program of size O(n 2 ). Ex. 10.5. Any function on n-bit strings can be computed by branching programs of size 2 n. Ex. 10.6. Exercise 39. Show that if A is a regular language, then a family of branching programs B 1, B 2,... exists such that B n accepts exactly the n-bit strings in A and the size of B n is bounded by a constant times n. Ex. 10.12. Exercise 40. Let EQ BP be the set of pairs (B 1, B 2 ) of equivalent branching programs. Show that EQ BP is conp-complete. Ex. 10.9. 6