This action might not be possible to undo. Are you sure you want to continue?

BooksAudiobooksComicsSheet Music### Categories

### Categories

### Categories

Editors' Picks Books

Hand-picked favorites from

our editors

our editors

Editors' Picks Audiobooks

Hand-picked favorites from

our editors

our editors

Editors' Picks Comics

Hand-picked favorites from

our editors

our editors

Editors' Picks Sheet Music

Hand-picked favorites from

our editors

our editors

Top Books

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Audiobooks

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Comics

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Sheet Music

What's trending, bestsellers,

award-winners & more

award-winners & more

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

NP-Completeness

A given problem can be solved by many different algorithms. Which ALGORITHMS will be useful in practice? A working definition: (Jack Edmonds, 1962)

s

Efficient: polynomial time for ALL inputs. Inefficient: "exponential time" for SOME inputs.

s

**Robust definition has led to explosion of useful algorithms for wide spectrum of problems.
**

s

Notable exception: simplex algorithm.

Princeton University • COS 423 • Theory of Algorithms • Spring 2001 • Kevin Wayne

2

Exponential Growth

Exponential growth dwarfs technological change.

s

Properties of Problems

Which PROBLEMS will we be able to solve in practice?

s

Suppose each electron in the universe had power of today’s supercomputers. And each works for the life of the universe in an effort to solve TSP problem using N! algorithm. Some Numbers Quantity Home PC instructions / second Supercomputer instructions / second Seconds per year Age of universe † Electrons in universe † Number 109 1012 109 1013 1079 † Estimated

Those with efficient algorithms. How can I tell if I am trying to solve such a problem? ! Theory of NP-completeness helps. Yes Shortest path Euler cycle Min cut 2-SAT PLANAR-2-COLOR PLANAR-4-COLOR Matching Probably No Longest path Hamiltonian cycle Max cut 3-SAT PLANAR-3-COLOR PLANAR-3-COLOR 3D-Matching Soccer elimination Vertex cover

4

s

s

Unknown Primality Factoring Graph isomorphism

s

**Will not succeed for 1,000 city TSP! 1000! >> 101000 >> 1079 × 1013 × 109 × 1012
**

3

Baseball elimination Bipartite vertex cover

A terminates in at most p(s) "steps". Algorithm A solves X if A(s) = YES ⇔ s ∈ X. s Evidence supporting thesis: True for all physical computers. Accepts if and only if given a "short" proof of this fact. Certifier: Is s a multiple of t? YES NO s s s s is a YES instance 7 no conclusion 8 . s is composite ⇔ there exists an integer 1 < t < s such that s is a multiple of t. s Polynomial time. Set of all decision problems solvable in polynomial time on a deterministic Turing machine. s Definition of P. s s Examples: MULTIPLE: Is the integer y a multiple of x? RELPRIME: Are the integers x and y relatively prime? PERFECT-MATCHING: Given graph G. YES instance: s = 437. of length |s|. Instance: finite binary string s. it evaluates a proposed proof t that s ∈ X. s 5 6 Efficient Certification Certification algorithm. s s s Strong Church-Turing Thesis Definition of P fundamental because of SCT. Rather. s Efficient certifier views things from "managerial" viewpoint. Algorithm C is an efficient certifier for X if: s C is a polynomial-time algorithm that takes two inputs s and t. There exists a polynomial p( ) so that for every string s. is there a perfect matching? s s s Possible exception? Quantum computers: no conventional gates. s ∈ X ⇔ there exists a string t such that |t| ≤ p(|s|) and C(s.669 Certificate t: 541 s Intuition. t) = YES. It doesn’t determine whether s ∈ X on its own. is s composite? Observation. where p is some polynomial. Can create deterministic TM that efficiently simulates any real general-purpose machine (and vice versa). Strong Church-Turing thesis: P is the set of decision problems solvable in polynomial time on REAL computers.P Decision problem X.669. s Certifiers and Certificates COMPOSITE: Given integer s. X is a (possibly infinite) set of binary strings. Algorithm A runs in polynomial-time if for every instance s. – certificate t = 541 or 809 (a factor) Input s: 437. s Design an algorithm that checks whether proposed solution is a YES instance.

is there a subset S of k nodes such that there is an arc connecting every pair of nodes in S? k=4 z y x YES instance: s = 437. YES NO s CLIQUE ∈ NP. Input s: 437. w. 2. s Certifier: 1.Certifiers and Certificates COMPOSITE: Given integer s. w) is an edge in the graph. YES NO Claim: P ⊆ NP. Count number of distinct colors in t. v." Input s: Certificate t: Definition of NP: s Set of all decision problems for which there exists an efficient certifier. – certificate t = 541 or 809 (a factor) NO instance: s = 437.677. Check that s and t describe same map. s is a YES instance no conclusion 11 12 . – no witness can fool verifier into saying YES Conclusion: COMPOSITE ∈ NP. is s composite? Observation. Check all pairs of adjacent states. t): return A(s). x} s Certifier: Is s a multiple of t? YES NO Certifier: 1.669. s Certifiers and Certificates CLIQUE: Given an undirected graph. 2.677 Certificate t: ??? u v Input s: w Certificate t: {u. Efficient certifier B(s. s Then. For all pairs of nodes v and w in t. Proof: Consider problem X ∈ P. s is composite ⇔ there exists an integer 1 < t < s such that s is a multiple of t. check that (v. s is a YES instance no conclusion 9 s is a YES instance no conclusion 10 Certifiers and Certificates 3-COLOR: Given planar map. can it be colored with 3 colors? Definition of NP: s NP Does NOT mean "not polynomial. Definition important because it links many fundamental problems. s 3-COLOR ∈ NP. Check that number of nodes in t ≤ k. there exists efficient algorithm A(s) that solves X. 3.

Return YES. s s s Useful alternate definition of NP: s Set of all decision problems solvable in polynomial time on a NONDETERMINISTIC Turing machine. theorems. bridges. . 13 EXP P NP EXP P = NP s If P ≠ NP If P = NP 14 The Main Question Generator (P) s The Main Question Does P = NP? s Certifier (NP) n n Factor integer s. Know when you’ve heard one. Devise a good joke. 15 16 . Design airfoil of minimum drag. . To solve input s. Is s a multiple of t? Check if all adjacent regions have different colors. If yes. Proof: Consider problem X ∈ NP. Color a map with minimum # colors. rockets. run C(s. then: s Can’t hope to write efficient algorithm for TSP. Harmonial bliss. music. jokes. But maybe efficient algorithm still exists for FACTOR . . Cryptography is impossible (except for one-time pads) on conventional machines. s s The Main Question Does P = NP? (Edmonds. . s Imagine the wealth of a society that produces optimal planes. t) for X.NP Definition of EXP: Set of all decision problems solvable in exponential time on a deterministic Turing machine. 1962) Is the original DECISION problem as easy as CERTIFICATION? Does nondeterminism help you solve problems faster? s Claim: NP ⊆ EXP. Prove a beautiful theorem. t) on all strings t with |t| ≤ p(|s|). Verify TA’s solutions. if C(s. Be a wine snob. Vinify fine wine. Ace an exam. FACTOR. Appreciate it. Laugh at it. Modern banking system will collapse. t) returns YES for any of these. art. Compute drag of airfoil. Nondeterministic TM can try all possible solutions in parallel. s Then. Clay Foundation Millennium $1 million prize. . Is the original DECISION problem as easy as CERTIFICATION? s If yes. TSP. . Write a beautiful sonnet. s Most important open problem in computer science. wine. staggering practical significance. Orate a good lecture. then: s s n n n n n n n Efficient algorithms for 3-COLOR. there exists efficient certifier C(s. Understand its proof. Intuition: act of searching for t is viewed as a non-deterministic search over the space of possible proofs. s s s s s s s s s If no.

"Hardest computational problems" in NP. X polynomial transforms to Y. X polynomial transforms to Y. . Called "intractable" . . But maybe yes. If P ≠ NP If P = NP s Only exponential algorithms known for these problems. Consensus opinion: P ≠ NP. s s We require |y| to be of size polynomial in |x|. we can construct an input y such that x is a YES instance of X if and only if y is a YES instance of Y.The Main Question Does P = NP? s Polynomial Transformation Problem X polynomial reduces (Cook-Turing) to problem Y (X ≤ P Y) if arbitrary instances of problem X can be solved using: s Is the original DECISION problem as easy as CERTIFICATION? Polynomial number of standard computational steps. . s Significance. . s EXP P NP NPcomplete EXP P = NP s Notorious complexity class. since: s s Thousands of researchers have spent four frustrating decades in search of polynomial algorithms for many fundamental NP problems without success. . Can implement any computer program in 3-COLOR. CNF-SAT. . since: s No success in proving P ≠ NP either. Links together a huge and diverse number of fundamental problems: – TSP. CLIQUE. 20 s 19 . . plus Polynomial number of calls to oracle that solves problem Y.unlikely that they can be solved given limited computing resources. Probably no. exactly at the end of the algorithm for X. . Problem X polynomial transforms (Karp) to problem Y if given any input x to X. . Polynomial transformation is polynomial reduction with just one call to oracle for Y. 3-COLOR. A problem Y in NP with the property that for every problem X in NP. Note: all previous reductions were of this form! 17 18 NP-Complete Definition of NP-complete: s NP-Complete Definition of NP-complete: s A problem Y in NP with the property that for every problem X in NP. s Efficient algorithm for any NP-complete problem ⇒ efficient algorithm for every other problem in NP.

Six basic genres and paradigmatic examples of NP-complete problems. Partitioning problems: 3-COLOR. KNAPSACK. s s Given problem X in NP. VERTEX-COVER. s Example: CLIQUE is NP-complete. Show that CNF-SAT (or any other NP-complete problem) transforms to Y. X polynomial transforms to Y. Use polynomial number of clauses to ensure machine makes legal moves. starts and ends in appropriate configurations. Step 1. by definition. state of finite control. Recipe to establish NP-completeness of problem Y. M is polynomial time ⇒ polynomial tree depth ⇒ polynomial number of tape cells in play. (Cook-Levin. Sequencing problems: HAMILTONIAN-CYCLE. where each configuration gives snapshot of M (tape contents. there exists nondeterministic TM M that solves X in polynomial time. Some squares conceal mines. Use polynomial number of Boolean variables to model which symbol occupies cell i at time t. CLIQUE. head position. etc. CLIQUE ∈ NP. INDEPENDENT-SET. 23 24 . TSP. Find location of mines without detonating any. s s 21 22 Establishing NP-Completeness Definition of NP-complete: s Minesweeper Consistency Problem Minesweeper. Covering problems: SET-COVER. Step 2. Choose a square. CNF-SAT is NP-complete. location of read head at time t. 3-SAT. s The "World’s First" NP-Complete Problem CNF-SAT is NP-complete. – if mine underneath. it detonates and you lose – If no mine. state of finite control) at some time step t. s A problem Y ∈ NP with the property that for every problem X in NP. etc. PARTITION. Step 2. Start: blank grid of squares. s s Step 1. computer tells you how many total mines in 8 neighboring squares s s Cook’s theorem.Some NP-Complete Problems Most natural problems in NP are either in P or NP-complete. 1960’s) Idea of proof: s Packing problems: SET-PACKING. CNF-SAT polynomial transforms to CLIQUE. Possible execution of M on input string s forms a branching tree of configurations. FACTOR not known to be NP-complete. Show that Y ∈ NP. Constraint satisfaction problems: SAT. Numerical problems: SUBSET-SUM. s s s Stephen Cook s s Caveat: PRIME. the rest are safe.

YES s NO A Minesweeper Wire 25 26 Minesweeper Consistency Problem Minesweeper Consistency Problem A NOT Gate A 3-way Splitter A OR Gate An AND Gate 27 A Phase Changer 28 . Claim. Given a state of what purports to be a Minesweeper games. is it logically consistent. Build circuit by laying out appropriate minesweeper configurations.Minesweeper Consistency Problem Minesweeper consistency problem. Minesweeper consistency is NP-complete. s Minesweeper Consistency Problem Minesweeper consistency problem. s Given a state of what purports to be a Minesweeper games. is it logically consistent. s Proof idea: reduce from circuit satisfiability.

1998) 29 30 Coping With NP-Completeness Hope that worst case doesn’t occur." – TSP where all points are on a line or circle – 13. s Develop a heuristic. The instance(s) you want to solve may be "easy.Minesweeper Consistency Problem s Coping With NP-Completeness Hope that worst case doesn’t occur. s Coping With NP-Completeness Hope that worst case doesn’t occur. but not always possible unless P = NP! – Euclidean TSP tour within 1% of optimal – stay tuned Cryptography.509 US city TSP problem solved A Wire Crossing (Cook et. s Sanjeev Arora (1997) 31 32 . Exploit intractability. Design an approximation algorithm: algorithm that is guaranteed to find a high-quality solution in polynomial time. and hope it produces a good solution. Complexity theory deals with worst case behavior.. – active area of research. al. Change the problem. Change the problem.

! Intelligent. t) s. hard to assert that it is not Hamiltonian. ! A politician. C(s.t. COMPOSITE. ! Solve arbitrary instances of the problem.Coping With NP-Completeness Hope that worst case doesn’t occur. s Input string s is a YES instance if and only if there exists a short certificate t such that C(s. NO-HAM-CYCLE. HAM-CYCLE vs. t) = NO. you design an algorithm to do at most two of the following three things: ! Solve the problem exactly. 33 34 Asymmetry of NP Definition of NP: X ∈ NP if there exists a certifier C(s. t) s. Change the problem. Appears harder to assert that an integer is not composite. easy to if check if it really is a Hamiltonian cycle. C(s. Exploit intractability. Keep trying to prove P = NP. t) = NO. s s Ex. Alternatively. it is easy to check if s is a multiple of t. Alternatively. input string s is a YES instance if and only if for all short t. s s Ex. t) = YES. ! Guarantee to solve the problem in polynomial time.t. Alternatively. input string s is a NO instance if and only if for all short t. s 35 36 . t) such that: s Co-NP NP: Decision problem X ∈ NP if there exists a certifier C(s. t) = NO. PRIME vs. If a problem is NP-complete. t) = YES. Input string s is a NO instance if and only if there exists a short certificate t such that C(s. s co-NP: X ∈ co-NP if there exists a certifier C(s. Given G. s Given integer s and proposed factor t. input string s is a NO instance if and only if for all short t. Input string s is a YES instance if and only if there exists a short certificate t such that C(s. s Given G and a proposed Hamiltonian cycle. t) = YES. Coping With NP-Completeness A person can be at most two of the following three things: ! Honest. C(s.

NP s X ∈ co .669 Certificate t: 541 t s −1 Conclusions. Input s: 437. s Key idea: P is closed under complementation.473 17^(s-1)/2 mod s = 437. can exhibit s-t flow that achieves this value – if no. PRIME ∈ NP.677. s is composite if and only if there exists an integer 1 < t < s such that s is a multiple of t.676 17^(s-1)/3 mod s = 329.415 17^(s-1)/36.t. – if yes. s If problem X is in NP and co-NP. s Co-NP Verifiers and Certificates COMPOSITE: Given integer s. s Examples. so co-NP = NP.677 Certificate t: 17 NO instance: s = 437. We prove if P = NP. Proof. using the assumption P = NP: s MAX-FLOW: given a network. can exhibit a perfect matching – if no. Certifier: Is s a multiple of t? YES NO s ≡ 1 (mod s ) ≡ 1 (mod s ) t for all prime divisors p of s-1 ( s −1) / p s NO instance: 437. 39 . then P ≠ NP. Conclusions.NP ⇒ X ∈ NP ⇒ X ∈ P ⇒ X ∈ P ⇒ X ∈ NP s Thus. so if P = NP.1 = 2 × 2 × 3 × 36. there is a short certificate Provides conceptual leverage for reasoning about a problem. s s is a NO instance no conclusion s is a NO instance 37 no conclusion 38 NP = co-NP ? Fundamental question: does NP = co-NP? s Good Characterizations Good characterization: NP I co-NP. More formally. is s composite? Fact (Pratt).452 YES NO COMPOSITE ∈ co-NP. then NP = co-NP. COMPOSITE ∈ P. then NP is closed under complementation as well. then: – for YES instance. – if yes. s Certifier: 17^(s-1) mod s = 1 s .Co-NP Certifiers and Certificates PRIME: Given integer s. If NP ≠ co-NP. s Theorem. can exhibit a set of vertices S ⊆ L such that the total number of neighbors of S is strictly less than |S| 40 X ∈ NP ⇒ X ∈ P ⇒ X ∈ P ⇒ X ∈ NP ⇒ X ∈ co . is s prime? Observation. Input s: 437. there is a short certificate – for NO instance.669. Consensus opinion: no.473 mod s = 305. s is prime if and only if s > 2 is odd and there exists an integer 1 < t < s s. NP ⊆ co-NP and co-NP ⊆ NP. s PRIME ∈ co-NP. can exhibit s-t cut whose capacity is less than W PERFECT-MATCHING: given a bipartite graph. is there a perfect matching. s Do YES-instances have short certificates if and only if NOinstances have short certificates. is there an s-t flow of value ≥ W.

Problem: Sisyphus never finished his task ⇒ unsolvable. Intractable. P ⊆ NP I co-NP. Knuth's original suggestions. Arduous. It is x to decide whether a given graph has a Hamiltonian cycle. s s Hard-ass. 42 s s s s 41 A Note on Terminology Some English word write-ins. (Bob Floyd) s s Problem of Sisyphus was time-consuming. Formidable. s 43 44 . Obdurate. Sometimes finding a good characterization seems easier than finding an efficient algorithm: linear programming. Prodigious. Many examples where problem found to have a non-trivial good characterization. January 1974. (Al Meyer) s s Hard as satisfiability. Herculean. s A Note on Terminology Hard-boiled. s s Hard. Interminable. but not known to be in P. Heavy. (Don Knuth) s s Ulysses was note for his persistence and also finished. Tough. Tricky. In honor of Cook. s Proof of max-flow min-cut theorem and Hall’s theorem led to stronger results that max-flow and bipartite matching are in P. s s Fundamental question: does P = NP I co-NP? s Mixed opinions. s A Note on Terminology Knuth. Hercules needed great strength. Bad. Costly. (SIGACT News 6. but only years later discovered to be in P. It is unknown whether FACTOR is an x problem. p. 12 – 18) Find an adjective x that sounds good in sentences like. (Ken Steiglitz) s Impractical. Obstinate. Note: PRIME ∈ NP I co-NP. s FIND-TSP-TOUR is x. s s Sisyphean.Good Characterizations Observation. s Note: x does not necessarily imply that a problem is in NP or even a decision problem. Difficult. s s s s s s Ulyssean. Exorbitant. Intricate.

3-COLOR. Sartaj Sahni) s A problem such that every problem in NP transforms to it. (Bell Labs. NP-hard. s A problem in NP such that every other problem in NP transforms to it. Supersat. Provably exponential time. Steve Cook. . in space or time + completely GNP. s You will likely run into these problems in your scientific life.A Note on Terminology: Made-Up Words Exparent. (Al Meyer) s s greater than or equal to satisfiability s Polychronious. (Ed Reingold) s enduringly long. . s s "create research workers are as full of ideas for new terminology as they are empty of enthusiasm for adopting it. s Perarduous. 3-CNF-SAT. (Mike Paterson) s A Note on Terminology: Acronyms PET. s Summary Many fundamental problems are NP-complete. (Shen Lin) s exponential + apparent Probably exponential time. If you know about NP-completeness. Costing more than GNP to resolve. chronic Appears in Webster’s 2nd unabridged. s 45 46 A Note on Terminology: Consensus NP-complete. Theory says we probably won’t be able to design efficient algorithms for NP-complete problems. CLIQUE. . previously exponential time. Knuth’s conclusion. ." 47 48 . (Al Meyer) Greater than or equal to NP in difficulty. but apparently in no other dictionary. TSP. you can identify them and avoid wasting time. (Mike Paterson) s through. Ron Rivest.

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd