Data Structures and Algorithm Analysis Lecture 23

Slides:



Advertisements
Similar presentations
The Theory of NP-Completeness
Advertisements

1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
The Theory of NP-Completeness
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Piyush Kumar (Lecture 7: Reductions)
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CSEP 521 Applied Algorithms Richard Anderson Lecture 10 NP Completeness.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
Sailesh Prabhu Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 29.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
28.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
CSC 413/513: Intro to Algorithms
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
The NP class. NP-completeness
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
Data Structures and Algorithm Analysis Lecture 24
P & NP.
Chapter 10 NP-Complete Problems.
Computational Complexity Theory
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Polynomial-Time Reduction
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Proofs
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
Richard Anderson Lecture 25 Min Cut Applications and NP-Completeness
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
Intro to Theory of Computation
Intro to Theory of Computation
ICS 353: Design and Analysis of Algorithms
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
Intro to Theory of Computation
Richard Anderson Lecture 25 NP-Completeness
Chapter 8 NP and Computational Intractability
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
CS 3343: Analysis of Algorithms
NP-Completeness Yin Tat Lee
CSE 6408 Advanced Algorithms.
P, NP and NP-Complete Problems
NP-Completeness Yin Tat Lee
The Theory of NP-Completeness
P, NP and NP-Complete Problems
Instructor: Aaron Roth
Instructor: Aaron Roth
Our old list of problems
RAIK 283 Data Structures & Algorithms
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Lecture 23 NP-Hard Problems
Presentation transcript:

Data Structures and Algorithm Analysis Lecture 23 CSCI 256 Data Structures and Algorithm Analysis Lecture 23 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some by Iker Gondra

Satisfiability Literal: A Boolean variable or its negation Clause: A disjunction of literals Conjunctive normal form (CNF): A propositional formula  that is the conjunction of clauses. Any logical formula can be written in CNF

Satisfiability SAT: Given CNF formula , does it have a satisfying truth assignment? 3-SAT: SAT where each clause contains exactly 3 literals each corresponds to a different variable Ex: Yes: x1 = true, x2 = true x3 = false

Satisfiability Fundamental combinatorial search problem Contains basic ingredients of a hard computational problem in very “bare-bones” fashion Have to make n independent decisions (i.e., assignments for each xi) so as to satisfy a set of constraints Have to arrange decisions so that all constraints are satisfied simultaneously

Find a Satisfying Truth Assignment (DONE IN CLASS)

Reduction again We now relate the computational hardness embodied in satisfaction problems like SAT and 3-SAT to the superficially different sort of hardness represented by the search for independent sets and vertex covers in graphs. Indeed we will show: 3-SAT  P INDEPENDENT-SET

Claim: 3-SAT  P INDEPENDENT-SET Suppose we have a black box for Independent Set and want to solve 3-Sat consisting of variables X ={x1,…,xn} and clauses C1,…,Ck. Can think of this in 2 different ways: make an independent 0/1 decision about each variable and succeed if you find one of 3 ways to satisfy each of the clauses Choose one term(literal) from each clause and find a truth ass that causes all these terms to evaluate to 1, thereby satisfying all the clauses; this can only happen if whenever a term is chosen in one clause, its negation is not chosen in any other clause – say the terms don’t conflict. We focus on (2)

Claim: 3-SAT  P INDEPENDENT-SET Pf: Given an instance  of 3-SAT, we construct an instance (G, k) of INDEPENDENT-SET; this instance has an independent set of size k iff  is satisfiable Construction (in example here,  has 3 clauses) G contains 3 vertices for each clause, one for each literal Connect 3 literals in a clause in a triangle with edges (remark these are now not independent vertices) Use edges to connect each literal to each of its negations (conflicting terms) G k = 3

3-SAT Reduces to Independent Set Claim: G contains an independent set S of size k = || ( = number of clauses) iff  is satisfiable Pf:  Let S be independent set in G of size k There are k triangles so S must contain exactly one vertex in each triangle and there are no conflicts in the vertices chosen (recall S indep) Set these literals to true; This truth assignment is consistent (no conflicts) so all clauses are satisfied Pf:  Given satisfying assignment, use it to select one true literal from each triangle which does not conflict with another literal selected ---- this gives an independent set of size k G k = 3

Transitivity of Reductions Transitivity: If X  P Y and Y  P Z, then X  P Z Pf idea: Compose the two algorithms (composition of poly functions is poly): run the algorithm for X using a black box for Y; each time the black box for Y is called, simulate it in a polynomial number of steps using the algorithm that solves instances of Y using a black box for Z. Ex: 3-SAT  P INDEPENDENT-SET  P VERTEX-COVER  P SET-COVER

Decision Problems Theory developed in terms of yes/no problems Independent set Given a graph G and an integer K, does G have an independent set of size at least K Vertex cover Given a graph G and an integer K, does the graph have a vertex cover of size at most K

Decision Problems Decision problem X is a set of strings Instance: string s Algorithm A solves problem X: A(s) = yes iff s  X Polynomial time: Algorithm A runs in poly-time if for every string s, A(s) terminates in at most p(|s|) "steps", where p() is some polynomial PRIMES: X = { 2, 3, 5, 7, 11, 13, 17, 23, 29, 31, 37, …. } Algorithm: [Agrawal-Kayal-Saxena, 2002] p(|s|) = |s|8 length of s

P P: Decision problems for which there is a poly-time algorithm Description Algorithm Yes No MULTIPLE Is x a multiple of y? Grade school division 51, 17 51, 16 RELPRIME Are x and y relatively prime? Euclid (300 BCE) 34, 39 34, 51 PRIMES Is x prime? AKS (2002) 53 51 EDIT- DISTANCE Is the edit distance between x and y less than 5? Dynamic programming niether neither acgggt ttttta LSOLVE Is there a vector x that satisfies Ax = b? Gauss- Edmonds elimination

Backgrounder on Primality Testing en. wikipedia Backgrounder on Primality Testing en.wikipedia.org/wiki/AKS_primality_tes The AKS primality test (also known as Agrawal–Kayal–Saxena primality test and cyclotomic AKS test) is a deterministic primality-proving algorithm created and published by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena, computer scientists at the Indian Institute of Technology Kanpur, on August 6, 2002, in a paper titled "PRIMES is in P".[1] The authors received many accolades, including the 2006 Gödel Prize and the 2006 Fulkerson Prize, for this work. The algorithm determines whether a number is prime or composite within polynomial time.

Backgrounder on Primality Testing en. wikipedia Backgrounder on Primality Testing en.wikipedia.org/wiki/AKS_primality_tes The key significance of AKS is that it was the first published primality-proving algorithm to be simultaneously general, polynomial, deterministic, and unconditional. Previous algorithms had achieved three of these properties at most, but not all four. The AKS algorithm can be used to verify the primality of any general number given. Many fast primality tests are known that work only for numbers with certain properties. For example, the Lucas–Lehmer test for Mersenne numbers works only for Mersenne numbers, while Pépin's test can be applied to Fermat numbers only. The maximum running time of the algorithm can be expressed as a polynomial over the number of digits in the target number. ECPP and APR conclusively prove or disprove that a given number is prime, but are not known to have polynomial time bounds for all inputs. The algorithm is guaranteed to distinguish deterministically whether the target number is prime or composite. Randomized tests, such as Miller–Rabin and Baillie–PSW, can test any given number for primality in polynomial time, but are known to produce only a probabilistic result. The correctness of AKS is not conditional on any subsidiary unproven hypothesis. In contrast, the Miller test is fully deterministic and runs in polynomial time over all inputs, but its correctness depends on the truth of the yet-unproven generalized Riemann hypothesis.

NP Certification algorithm intuition Certifier views things from "managerial" viewpoint Certifier doesn't determine whether s  X on its own; rather, it checks a proposed proof t that s  X Def: Algorithm C(s, t) is a certifier for problem X if for every string s, s  X iff there exists a string t such that C(s, t) = yes NP: Decision problems for which there exists a poly-time certifier Indeed Remark: NP stands for nondeterministic polynomial-time "certificate" or "witness" C(s, t) is a poly-time algorithm and |t|  p(|s|) for some polynomial p().

NP Poly time finding solution versus poly time checking if proposed soln is a soln -- are very different; often one can easily check if a proposed sol is a sol, when finding a sol is much more difficult Easy to check if a particular truth assignment satisfies some formula θ; much harder to determine if there is or there is not a truth assignment to satisfy some formula θ.

Certificate Examples Independent set of size K Satifisfiable formula The Proposed Independent Set Satifisfiable formula Truth assignment to the variables Hamiltonian Circuit Problem A cycle including all of the vertices K-coloring a graph Assignment of colors to the vertices

Are There Even Harder Problems? Simple game: Players alternating selecting nodes in a graph Score points associated with node Remove node’s neighbors When neither can move, player with most points wins

Competitive Facility Location For a particular player Pi, is there a strategy so that, no matter how the other players play, Pi will be able to select a set of nodes with a total value of at least X? Hard to convince someone of the answer to this question (i.e., no short proof, lengthy case-by-case analysis), compare with Independent Set Problem PSPACE-complete

Certifiers and Certificates: Composite COMPOSITES: Given an integer s, is s composite? Certificate: A nontrivial factor t of s. Note that such a certificate exists iff s is composite. Moreover |t|  |s| Certifier Instance: s = 437,669 Certificate: t = 541 or 809 Conclusion: COMPOSITES is in NP boolean C(s, t) { if (t  1 or t  s) return false else if (s is a multiple of t) return true else }

Certifiers and Certificates: 3-SAT SAT: Given a CNF formula , is there a satisfying assignment? Certificate: An assignment of truth values to the n boolean variables Certifier: Evaluate each clause in  to determine if it has at least one true literal Ex: Conclusion: SAT is in NP instance s certificate t

Certifiers and Certificates: Hamiltonian Cycle HAM-CYCLE: Given an undirected graph G = (V, E), does there exist a simple cycle C that visits every node? Certificate: A permutation of the n nodes Certifier: Check that the permutation contains each node in V exactly once, and that there is an edge between each pair of adjacent nodes in the permutation Conclusion: HAM-CYCLE is in NP instance s certificate t

P, NP, EXP P: Decision problems for which there is a poly-time algorithm EXP: Decision problems for which there is an exponential-time algorithm NP: Decision problems for which there is a poly-time certifier Claim: P  NP Pf: Consider any problem X in P By definition, there exists a poly-time algorithm A(s) that solves X Certificate: t = , certifier: C(s, t) = A(s) Claim: NP  EXP Pf: Consider any problem X in NP By definition, there exists a poly-time certifier C(s, t) for X To solve input s, run C(s, t) on all strings t with |t|  p(|s|) Return yes, if C(s, t) returns yes for any of these

Extra Credit Homework Question Does P = NP? [Cook 1971, Edmonds, Levin, Yablonski, Gödel] Is the decision problem as easy as the certification problem? $1 million prize (plus the extra credit) If yes: Efficient algorithms for 3-COLOR, TSP, FACTOR, SAT, … If no: No efficient algorithms possible for 3-COLOR,TSP, SAT,… Consensus opinion on P = NP? Probably no EXP NP EXP P P = NP If P  NP If P = NP would break RSA cryptography (and potentially collapse economy)

X  p Y Recall X  p Y iff an arbitrary instance of X can be solved using a poly # of standard computational steps ** plus a poly # of calls to a black box that solves problems Y By poly # we mean poly function on the input ** we think of this as kind of preprocessing – the work involved to transform (or “reduce”) an instance of X to an instance of Y

NP-Complete NP-complete: A problem Y in NP with the property that for every problem X in NP, X  p Y Theorem: Suppose Y is an NP-complete problem. Then Y is solvable in poly-time iff P = NP Pf:  If P = NP then Y can be solved in poly-time since Y is in NP Pf:  Suppose Y can be solved in poly-time Let X be any problem in NP. Since X  p Y, and Y can be solved in poly-time, we can solve X in poly-time. This implies NP  P We already know P  NP. Thus P = NP Fundamental question: Do there exist "natural" NP-complete problems?