Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.

Slides:



Advertisements
Similar presentations
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
Advertisements

David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Intractable Problems (Smiley Puzzles.
Cs3102: Theory of Computation Class 25: NP-Complete Appetizers Spring 2010 University of Virginia David Evans PS6 is due Tuesday, April 27 (but don’t wait.
Polynomial-time reductions We have seen several reductions:
Department of Computer Science & Engineering
1 The Limits of Computation Intractable and Non-computable functions.
NP-Completeness Lecture for CS 302. Traveling Salesperson Problem You have to visit n cities You want to make the shortest trip How could you do this?
Lecture 21 NP-complete problems
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Great Theoretical Ideas in Computer Science for Some.
CSE373: Data Structures & Algorithms Lecture 24: The P vs. NP question, NP-Completeness Nicki Dell Spring 2014 CSE 373 Algorithms and Data Structures 1.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
Discrete Structures & Algorithms The P vs. NP Question EECE 320.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
NP and NP-completeness
Analysis of Algorithms CS 477/677
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Chapter 11: Limitations of Algorithmic Power
Complexity Theory: The P vs NP question Lecture 28 (Dec 4, 2007)
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
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.
Review Byron Gao. Overview Theory of computation: central areas: Automata, Computability, Complexity Computability: Is the problem solvable? –solvable.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
1 1. Draw the machine schema for a TM which when started with input 001 halts with abbb on the tape in our standard input format. 2. Suppose you have an.
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science.
Theory of Computing Lecture 17 MAS 714 Hartmut Klauck.
David Evans CS588: Security and Privacy University of Virginia Computer Science Lecture 15: Complexity Notes This is selected.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
CSCI 2670 Introduction to Theory of Computing December 1, 2004.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
MA/CSSE 473 Day 38 Problems Decision Problems P and NP.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
COMPSCI 102 Introduction to Discrete Mathematics.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 Design and Analysis of Algorithms Yoram Moses Lecture 11 June 3, 2010
COMPSCI 102 Introduction to Discrete Mathematics.
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Class 24: P=NP? David Evans cs302: Theory of Computation University of Virginia Computer Science PS6 (the last one) is.
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.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 15: Intractable Problems (Smiley.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 7 Time Complexity Some slides are in courtesy.
David Evans Class 15: P vs. NP (Smiley Puzzles and Curing Cancer) CS150: Computer Science University of Virginia Computer.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
NP-complete Languages
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 14: P = NP?
Pancakes, Puzzles, and Polynomials: Cracking the Cracker Barrel Game Christopher Frost Michael Peck.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 23: Intractable Problems (Smiley Puzzles.
Theory of Computational Complexity Yuji Ishikawa Avis lab. M1.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
CS 154 Formal Languages and Computability May 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
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.
Great Theoretical Ideas In Computer Science Anupam GuptaCS Fall 2006 Lecture 28Dec 7th, 2006Carnegie Mellon University Complexity Theory: the P.
NP and NP-completeness
Class 14: Intractable Problems CS150: Computer Science
Lecture 22: P = NP? CS200: Computer Science University of Virginia
Presentation transcript:

cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans

Menu Dilbert and Decidability P = NP Recap Proving a problem is in NP NP-Complete If you haven’t yet, read PS7 today! It is different from previous PS and you should start thinking about it. You are not expect to wait until PS6 is due to start PS7.

Hat tip: Robyn Short Dilbert on Decidability

Complexity Classes Recap Polynomial time: languages that can be decided by a deterministic TM in  (N k ) steps. Nondeterministic Polynomial time: languages that can be decided by a nondeterministic TM in  (N k ) steps. NP does not stand for “Non-Polynomial” time. If you say so on the final, you’ll get an automatic 0 for all the complexity questions! (and at least one question on the final will try to trick you this way)

P = NP ? P NP P Option 2: P = NP Option 1: P  NP How important is this?

1900 Hilbert’s 23 Problems for the 20 th century 2000 Clay Mathematics Institute 7 problems, each with $1M

Seven Millennium Prize Problems Birch and Swinnerton-Dyer Conjecture Hodge Conjecture Navier-Stokes Equations P vs NP Poincaré Conjecture (resolved March 2010) Riemann Hypothesis Yang-Mills Theory

P “versus” NP P NP

P = NP ? P NP P Option 2: P = NP Option 1: P  NP How can we distinguish these two possibilities?

P NP P Option 2: P = NP Option 1: P  NP L (DFA) L (NFA) Simulate an NFA with a DFA L (DPDA) L (NPDA) Identify a language that is in L(NPDA) but not L(DPDA) According to a 2002 poll of CSists, 61 think Option 1 is right vs. 9 for Option 2

Problems in NP All problems we know are in P Some problems we don’t know if they are in P but do know they are in NP: problems where the answer can be checked in P Note: we should really be talking about languages, not problems. We’ll see how to convert a problem to a language soon.

Smiley Puzzle Problem Input: n square tiles Output: Arrangement of the tiles in a square, where the colors and shapes match up, or “no, its impossible”.

Smiley Puzzle Problem Input: n square tiles Output: Arrangement of the tiles in a square, where the colors and shapes match up, or “no, its impossible”. “Not possible”

What is the running time complexity of Smiley Puzzle Problem? Upper bound: ( O ) In O(n!) : Try all possible permutations Lower bound: (  ) In  (n) : Must at least look at every tile Tight bound: (  ) N o one knows!

Check Smiley Puzzle Problem Input: n square tiles arranged in a square Output: True if the arrangement satisfies the puzzle, False otherwise. False

What is the running time complexity of Check Smiley Puzzle Problem? Upper bound: ( O ) In O(n) : Constant work to check each square Lower bound: (  ) In  (n) : Must at least look at every tile Tight bound: (  ) In  (n) : In O(n) and in  (n)

Pegboard Puzzle

Generalized Pegboard Puzzle Problem Input: a string of 0s and 1s (of any length), representing a triangular- shaped board and whether or not hole contains a peg Output: True if there is a sequence of moves that wins the game, False otherwise. Is this a language?

Pegboard Language

Would a decider for WINNINGBOARD allow you to win the game? Sure: try all possible sequences of moves. (actually, we don’t even need the WINNINGBOARD decider to do that!)

Would a polynomial-time decider for WINNINGBOARD allow you to win the game in polynomial-time?

Winning the Game Input: WINNINGBOARD( )  Accept Two possible moves, try each until you find a position that accepts How many invocations of WINNINGBOARD are needed?

Winning the Game Input: WINNINGBOARD( )  Accept WINNINGBOARD( )  Accept Two possible moves, try each until you find a position that accepts How many invocations of WINNINGBOARD are needed? At more n possible moves at each step, each step removes one peg:  n 2 WINNINGBOARD( )  Reject

What is the running time complexity of Pegboard Puzzle Language? Upper bound: ( O ) In O(n!) : Try all possible permutations Lower bound: (  ) In  (n) : Must at least look at every position Tight bound: (  ) N o one knows!

Winning Pegboard Sequence Input: A pegboard description, P, and a sequence of moves, S. Ouput: True iff S is a valid sequence of moves that wins the game starting from P.

What is the running time complexity of the Winning Pegboard Sequence Language? Upper bound: ( O ) In O(n) : Check each move is valid Lower bound: (  ) In  (n) : Must at least look at each move Tight bound: (  ) In  (n) : In O(n) and in  (n)

Polynomial Time Verifiers SmileyPuzzle  NP CheckSmileyPuzzle  P The puzzle arrangement is a certificate. WinningPegboard  NP WinningPegboardSequence  P The sequence of moves is a certificate.

Have we Proven P  NP ? P NP Smiley Puzzle In O(n!) n!  O(n k ) No! We need to know Smiley Puzzle is in  (n!). Maybe there is a better algorithm!

Would finding one prove P=NP ? P NP Smiley Puzzle In O(n ) Yes! Smiley Puzzle is as hard as any other problem in NP. (Goal of rest of today is to understand why and how we know.) Suppose you found a  (n ) algorithm that solves the Simley Puzzle.

NP-Complete A language B is in NP-complete iff: 2. There is a polynomial- time reduction from every problem A  NP to B. 1. B  NP B NP B Is NP-Complete a Ring or a Circle?

NP-Complete A language B is in NP-complete if: 2. There is a polynomial- time reduction from every problem A  NP to B. 1. B  NP B NP B What does NP-Hard look like? Hard Not necessary for NP-Hard

NP-Hard (if P  NP ) P NP-C Option 1a: P  NP, NP-C  P  NP Option 1b: P  NP, NP-C  P = NP NP-Hard P NP-C

NP-Hard (if P = NP ) P NP Option 2: P = NP NP-C ≈ NP-Complete NP-Hard = All Languages - {A = {}, A = Σ*}

Proving NP-Hardness Show there is a polynomial-time reduction from every problem A  NP to B. B NP Show there is a polynomial-time reduction from one problem X  NP-Hard to B. X NP B This assume we already know some problem X that is in NP-Hard. To get the first one, we need to prove it the hard way! (Next class and book: Cook-Levin Theorem proves 3SAT is NP-Hard.) This assume we already know some problem X that is in NP-Hard. To get the first one, we need to prove it the hard way! (Next class and book: Cook-Levin Theorem proves 3SAT is NP-Hard.)

Season 1, Episode 2

Reducing Reduction Proofs Conjecture: A has some property Y. Proof by reduction from B to A : – Assume A has Y. Then, we know there is an M that decides A. – We already know B does not have property Y. – Show how to build S that solves B using M. Since we know B does not have Y, but having S would imply B has Y, S cannot exist. Therefore, M cannot exist, and A does not have Y.

Undecidability Proofs Conjecture: A has some property Y. Proof by reduction from B to A : – Assume A has Y. Then, we know an M exists. – We already know B does not have property Y. – Show how to build S that solves B using M. Since we know B does not have Y, but having S would imply B has Y, S cannot exist. Therefore, M cannot exist, and A does not have Y. Undecidability: Y = “can be decided by a TM” B = a known undecidable problem (e.g., A TM, HALT TM, EQ TM, …) M = “a TM that decides A ”

NP-Hardness Proofs Conjecture: A has some property Y. Proof by reduction from B to A : – Assume A has Y. Then, we know an M exists. – We already know B does not have property Y. – Show how to build S that solves B using M. Since we know B does not have Y, but having S would imply B has Y, S cannot exist. Therefore, M cannot exist, and A does not have Y. NP-Hardness: Y = “is NP-Hard” B = a known NP-Hard problem (e.g., 3-SAT, SUBSET-SUM, …) M = “a TM that decides A in polynomial-time”

The Hard Part Conjecture: A has some property Y. Proof by reduction from B to A : – Assume A has Y. Then, we know an M exists. – We already know B does not have property Y. – Show how to build S that solves B using M. Since we know B does not have Y, but having S would imply B has Y, S cannot exist. Therefore, M cannot exist, and A does not have Y.

Legal Transformations Undecidability proofs: your transformation can do anything a TM can do, but must be guaranteed to terminate – E.g., cannot include, “simulate M and if it halts, accept” NP-Hardness proofs: your transformation must finish in polynomial time – E.g., cannot include, “do an exponential search to find the answer, and output that”

Reducing 3SAT to Simley Puzzle If we had a fast (polynomial time) procedure to solve the smiley puzzle, we would also have a fast procedure to solve the 3/stone/apple/tower puzzle: 3 Assume: Known to be NP-Hard Not Known to be NP-Hard

3SAT  Smiley     Step 1: Transform into smileys Step 2: Solve (using our fast smiley puzzle solving procedure) Step 3: Invert transform (back into 3SAT problem

The Real 3SAT Problem (also can be reduced to the Smileys Puzzle)

The 3SAT Language

Conjunctive Normal Form

Satisfiability A 3CNF-formula is satisfiable if there is a way to assign values to the variables that makes it true.

3SAT Is 3SAT in NP? Yes: the assignment of values to variables is a polynomial- time certificate. Its easy to check if an assignment is correct.

3SAT Is 3SAT in P? Unknown: no one knows a polynomial-time algorithm for deciding 3SAT, but no proof one does not exist.

Cook-Levin Theorem 3SAT is NP-Complete There is a polynomial-time reduction from every problem X  NP to 3SAT. 3SAT NP

Recap - Charge A problem is in NP if there is a polynomial- time algorithm to check the answer A problem is NP-complete if it is as hard as the hardest problem in NP Either all NP-complete problems are tractable (in P) or none of them are! Next class: – Cook-Levin proof that 3SAT is NP-Complete – Some non-trivial NP-Hard reduction proofs