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?

Slides:



Advertisements
Similar presentations
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
Advertisements

NP-Completeness: Reductions
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
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 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
NP-completeness Sipser 7.4 (pages 271 – 283). CS 311 Mount Holyoke College 2 The classes P and NP NP = ∪ k NTIME(n k ) P = ∪ k TIME(n k )
NP-completeness Sipser 7.4 (pages 271 – 283). CS 311 Fall The classes P and NP NP = ∪ k NTIME(n k ) P = ∪ k TIME(n k )
Complexity Theory CSE 331 Section 2 James Daly. Reminders Project 4 is out Due Friday Dynamic programming project Homework 6 is out Due next week (on.
Transitivity of  poly Theorem: Let ,  ’, and  ’’ be three decision problems such that   poly  ’ and  ’  poly  ’’. Then  poly  ’’. Proof:
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
NP-complete and NP-hard problems
Time Complexity.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
Chapter 11: Limitations of Algorithmic Power
Clique Cover Cook’s Theorem 3SAT and Independent Set
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
Robbie Hott Department of Computer Science University of Virginia Theory of Computation CS3102.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
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.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
CSC 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.
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.
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.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
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.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
CS 3813: Introduction to Formal Languages and Automata Chapter 14 An Introduction to Computational Complexity These class notes are based on material from.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
CSE 6311 – Spring 2009 ADVANCED COMPUTATIONAL MODELS AND ALGORITHMS Lecture Notes – Feb. 3, 2009 Instructor: Dr. Gautam Das notes by Walter Wilson.
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
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
CS623: Introduction to Computing with Neural Nets (lecture-7) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
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.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
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.
 2005 SDU Lecture15 P,NP,NP-complete.  2005 SDU 2 The PATH problem PATH = { | G is a directed graph that has a directed path from s to t} s t
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
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
NP-Completeness A problem is NP-complete if: It is in NP
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Intro to Theory of Computation
Computational Complexity
CS 3343: Analysis of Algorithms
NP-Completeness Lecture for CS 302.
CSE 589 Applied Algorithms Spring 1999
Presentation transcript:

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? What if you had a machine that could guess?

Non-deterministic polynomial time Deterministic Polynomial Time: The TM takes at most O(n c ) steps to accept a string of length n Non-deterministic Polynomial Time: The TM takes at most O(n c ) steps on each computation path to accept a string of length n

The Class P and the Class NP P = { L | L is accepted by a deterministic Turing Machine in polynomial time } NP = { L | L is accepted by a non- deterministic Turing Machine in polynomial time } They are sets of languages

P vs NP? Are non-deterministic Turing machines really more powerful (efficient) than deterministic ones? Essence of P vs NP problem

Does Non-Determinism matter? DFA ≈ NFA DFA not ≈ NFA (PDA) Finite Automata? No! Push Down Automata? Yes!

P = NP? No one knows if this is true How can we make progress on this problem?

Progress P = NP if every NP problem has a deterministic polynomial algorithm We could find an algorithm for every NP problem Seems… hard… We could use polynomial time reductions to find the “hardest” problems and just work on those

Reductions Real world examples:  Finding your way around the city reduces to reading a map  Traveling from Richmond to Cville reduces to driving a car  Other suggestions?

Polynomial time reductions PARTITION = { n 1,n 2,… n k | we can split the integers into two sets which sum to half } SUBSET-SUM = { | there exists a subset which sums to m } 1) If I can solve SUBSET-SUM, how can I use that to solve an instance of PARTITION? 2) If I can solve PARTITION, how can I use that to solve an instance of SUBSET-SUM?

Polynomial Reductions 1) Partition REDUCES to Subset-Sum  Partition < p Subset-Sum 2) Subset-Sum REDUCES to Partition  Subset-Sum < p Partition Therefore they are equivalently hard

How long does the reduction take? How could you take advantage of an exponential time reduction?

NP-Completeness How would you define NP-Complete? They are the “hardest” problems in NP P NP NP-Complete

Definition of NP-Complete Q is an NP-Complete problem if: 1) Q is in NP 2) every other NP problem polynomial time reducible to Q

Getting Started How do you show that EVERY NP problem reduces to Q? One way would be to already have an NP- Complete problem and just reduce from that P1P1 P2P2 P3P3 P4P4 Mystery NP-Complete Problem Q

Reminder: Undecidability How do you show a language is undecidable? One way would be to already have an undecidable problem and just reduce from that L1L1 L2L2 L3L3 L4L4 Halting Problem Q

SAT SAT = { f | f is a Boolean Formula with a satisfying assignment } Is SAT in NP?

Cook-Levin Theorem (1971) SAT is NP-Complete If you want to see the proof it is Theorem 7.37 in Sipser (assigned reading!) or you can take CS 660 – Graduate Theory. You are not responsible for knowing the proof.

3-SAT 3-SAT = { f | f is in Conjunctive Normal Form, each clause has exactly 3 literals and f is satisfiable } 3-SAT is NP-Complete (2-SAT is in P)

NP-Complete To prove a problem is NP-Complete show a polynomial time reduction from 3-SAT Other NP-Complete Problems:  PARTITION  SUBSET-SUM  CLIQUE  HAMILTONIAN PATH (TSP)  GRAPH COLORING  MINESWEEPER (and many more)

NP-Completeness Proof Method To show that Q is NP-Complete: 1) Show that Q is in NP 2) Pick an instance, R, of your favorite NP- Complete problem (ex: Φ in 3-SAT) 3) Show a polynomial algorithm to transform R into an instance of Q

Example: Clique CLIQUE = { | G is a graph with a clique of size k } A clique is a subset of vertices that are all connected Why is CLIQUE in NP?

Reduce 3-SAT to Clique Pick an instance of 3-SAT, Φ, with k clauses Make a vertex for each literal Connect each vertex to the literals in other clauses that are not the negation Any k-clique in this graph corresponds to a satisfying assignment

Example: Independent Set INDEPENDENT SET = { | where G has an independent set of size k } An independent set is a set of vertices that have no edges How can we reduce this to clique?

Independent Set to CLIQUE This is the dual problem!

Doing Your Homework Think hard to understand the structure of both problems Come up with a “widget” that exploits the structure These are hard problems Work with each other! Advice from Grad Students: PRACTICE THEM

Take Home Message NP-Complete problems are the HARDEST problems in NP The reductions MUST take polynomial time Reductions are hard and take practice Always start with an instance of the known NP-Complete problem Next class: More examples and Minesweeper!

Papers Read one (or more) of these papers:  March Madness is (NP-)Hard  Some Minesweeper Configurations  Pancakes, Puzzles, and Polynomials: Cracking the Cracker Barrel and Knuth’s Complexity of Songs Each paper proves that a generalized version of a somewhat silly problem is NP- Complete by reducing 3SAT to that problem (March Madness pools, win-able Minesweeper configurations, win-able pegboard configurations) Optional, but it is hard to imagine any student who would not benefit from reading a paper by Donald Knuth including the sentence, “However, the advent of modern drugs has led to demands for still less memory…”