Computational Complexity Ref: Algorithm Design (Ch 8) on Blackboard Mohammad T. Irfan Email: mirfan@bowdoin.edu Web: www.bowdoin.edu/~mirfan Famous complexity classes u NP (non-deterministic polynomial time) u Class of decision problems for which we can verify a solution (certificate/ witness) in polynomial time u P (deterministic polynomial time) u Class of decision problems that can be solved in polynomial time 1
Famous complexity classes u NP-Hard u "As hard as NP" u Every NP problem reduces to problems in this class in polynomial time u May not be in NP (e.g., may not have polynomialtime verifier) u NP-Complete u Decision problems that are: 1. In NP 2. NP-Hard (i.e., every NP problem reduces to these problem!) Millennium prize problem: P=NP? Unresolved! Implication Fact? Alternative Fact? 2
Other classes u EXPTIME u Evaluating a position in chess/checkers/go u Undecidable u Halting problem u A ton of other classes... NP-completeness proof recipe u Want to prove problem B is NP-complete u 2 main steps: 1. Prove that B is in NP u Show that we can verify an answer to B in polynomial time 2. Prove that B is NP-hard u Pick a known NP-complete problem A Caution: not the other way! u Reduce A to B in a polynomial-time (i.e., A is not harder than B è B is at least as hard as the already-known hard problem A) 3
First NP-complete problem Stephen Cook u Boolean satisfiability problem (SAT) is NPcomplete (Stephen Cook, 1971) u P = NP if and only if SAT is in P SAT u Operators u AND u OR u NOT (also, over-score) u Given a boolean formula, is there a satisfying assignment to the boolean variables? (x 1 v v x 3 ) x 1 x 3? ( x 1 v ) ( x 1 v ) (x 1 v ) (x 1 v )? 4
3-SAT u Stylized version of SAT u (... V... V...) (... V... V...) (... V... V...)... u Each parenthetic expression is a clause u Each green box is a literal (e.g., x 1,, etc.) u 3-SAT is NP-complete Application: Electronic Design Automation (EDA) 5
Prove that CLIQUE is NP-complete CLIQUE u Clique: A subset of nodes of a graph such that there is an edge between every pair of nodes in that subset. A clique of size 5 u CLIQUE problem: Given a graph and a number k, Is there a clique of size >= k? Example: Costas Busch- LSU 6
Proof: CLIQUE is NP-complete 1. CLIQUE is in NP u We can verify a solution (k-clique) in polynomial time u Check whether there is an edge between every pair of nodes in that clique Proof: CLIQUE is NP-complete 2. CLIQUE is NP-Hard u Take our favorite NP-complete problem 3- SAT (that's the only one we know...) u Reduce 3-SAT to CLIQUE u u u Given k, take any instance of 3-SAT with k clauses Convert it to an instance of CLIQUE in polynomial time Show that the answer to CLIQUE is yes if and only if the answer to 3-SAT is yes Caution: not the other way! 7
Reduction Node: every literal of 3-SAT instance ( x1 x2 x4) ( x1 x2 x4) ( x1 x2 x3) ( x2 x3 x4) Clause 2 x1 x x 2 4 Clause 3 x 1 x 1 Clause 1 x 4 Clause 4 x 3 x 3 x 4 Costas Busch - LSU Reduction Edge: Connect each node/literal with every literal of a different clause, except two literals that are negations of each other. ( x1 x2 x4) ( x1 x2 x4) ( x1 x2 x3) ( x2 x3 x4) Do it for every node! x 1 x1 x x 2 4 x 1 x 4 x 3 x 3 x 4 Costas Busch - LSU 8
( x1 x2 x4) ( x1 x2 x4) ( x1 x2 x3) ( x2 x3 x4) x1 x x 2 4 x 1 x 1 x 4 x 3 x 3 x 4 Resulting Graph: CLIQUE instance Costas Busch - LSU Prove: The graph has a k-clique if and only if 3-SAT has a solution (k = 4 here) ( 4 4 4 x1 x2 x ) ( x1 x2 x ) ( x1 x2 x3) ( x2 x3 x ) = 1 x = 1 1 x = 0 2 x = 0 3 x = 1 4 x 1 x1 x x 2 4 x 1 x 4 x 3 x 3 x 4 This proves CLIQUE is NP-Hard (3-SAT is not harder than CLIQUE!) Costas Busch - LSU 9
Review u NP (non-deterministic polynomial time) u Class of decision problems for which we can verify a solution (certificate/ witness) in polynomial time u P (deterministic polynomial time) u Class of decision problems that can be solved in polynomial time Review u NP-Hard u "As hard as NP" u Every NP problem reduces to problems in this class in polynomial time u NP-Complete u Decision problems that are: 1. In NP 2. NP-Hard (i.e., every NP problem reduces to these problem!) 10
Examples HALTING PROBLEM [Optimization versions of NP-complete prob.] TSP CLIQUE INDEPENDENT SET FACTORIZATION/RSA GRAPH ISOMORPHISM SHORTEST-PATH FRACTIONAL KNAPSACK INDEPENDENT SET is NP-Complete You do the proof! 11
INDEPENDENT SET problem u Independent set: a subset of nodes of a graph such that there is no edge between any two nodes in that subset u INDEPNDENT SET problem u Given a graph and a number k, does there exist an independent set of size >= k? Example u Is there an independent set of size 6? Yes u Is there an independent set of size 7? No independent set Hantao Zhang U Iowa 12
Proof recipe 1. INDEPENDENT SET is in NP 2. INDEPENDENT SET is NP-hard u Reduce a known NP-complete problem to INDEPENDENT SET u Art: Which NP-complete problem would you like to pick? How would you do the reduction? REDUCTION: A à B Given any instance of problem A, convert it to an instance of B in polynomial time such that B instance has answer yes if and only if A instance has answer yes VERTEX COVER is NP-complete You do the proof! 13
VERTEX COVER problem u Vertex cover: a subset of nodes of a graph such that every edge has at least one endpoint in that subset u VERTEX COVER problem: u Given a graph and a number k, is there a vertex cover of size <= k? Example u Is there a vertex cover of size 4? Yes. u Is there a vertex cover of size 3? No. vertex cover Hantao Zhang U Iowa 14
Proof recipe 1. VERTEX COVER is in NP 2. VERTEX COVER is NP-hard u Reduce a known NP-complete problem to VERTEX COVER vertex cover independent set Hantao Zhang U Iowa Other NP-Complete problems u Special cases of 3-SAT u SET COVER u HITTING SET u SUBSET-SUM u PARTITION u GRAPH COLORING u HAMILTONIAN PATH (TSP) u... 15
Complexity of computing pure-strategy NE "Pure Nash Equilbria: Hard and Easy Games" Gottlob et al. [Blackboard] Is there a pure-strategy NE? u (Gottlob et al., 2005) Deciding whether a graphical game (GG) has a PSNE is NP-complete, even for max degree 3 and max # of actions 3. u Proof. 1. GG is in NP 2. GG is NP-Hard u Reduction: 3-SAT' à GG u For any 3-SAT' instance, create a GG instance u Each clause and variable is a player u Neighbors/friends based on clause-var relations u Actions: {t, f, u} u Payoffs: next slide 16
Payoffs of GG instance Payoff of a clause player c Pay off Case 3 c plays t & all neighboring variables play t/f making the clause true 2 c plays u & all neighboring variables play t/f making the clause false 2 c plays f & some neighboring variable plays u 1 All other cases Payoff of a variable player v Pay off Case 3 v plays t/f & all neighboring clauses play t/f 2 v plays u & some neighboring clause plays u 1 All other cases 3-SAT' instance is satisfiable GG instance has a pure NE Is there a pure-strategy NE? u NP-complete, even for very special types of "graphical games" u Games in "normal form" (with payoff matrices) is a different story Representation size is important! 17
Computing a mixed-strategy NE u Always exists (so not NP-complete!) u PPAD-complete even for 2-player games (with m actions) [Chen et al. (2009), Daskalakis et al. (2009)] u PPAD: Polynomial Parity Arguments on Directed graphs (Papadimitriou, 1994) 18