P vs NP: what is efficient computation? Great Theoretical Ideas In Computer Science Anupam GuptaCS 15-251 Fall 2005 Lecture 29Dec 8, 2005Carnegie Mellon.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Great Theoretical Ideas in Computer Science.
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.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Lecture 21 NP-complete problems
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.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Discrete Structures & Algorithms The P vs. NP Question EECE 320.
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
CS21 Decidability and Tractability
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
Graphs 4/16/2017 8:41 PM NP-Completeness.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
NP-Completeness NP-Completeness Graphs 4/17/2017 4:10 AM x x x x x x x
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
February 20, 2015CS21 Lecture 191 CS21 Decidability and Tractability Lecture 19 February 20, 2015.
Complexity Theory: The P vs NP question Lecture 28 (Dec 4, 2007)
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.
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.
Great Theoretical Ideas in Computer Science.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
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.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
COMPSCI 102 Introduction to Discrete Mathematics.
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
COMPSCI 102 Introduction to Discrete Mathematics.
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
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.
Great Theoretical Ideas In Computer Science Anupam GuptaCS Fall 2006 Lecture 28Dec 5th, 2006Carnegie Mellon University Complexity Theory: A graph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
Inspiration Versus Perspiration: The P = ? NP Question.
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.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
NP-Completeness Note. Some illustrations are taken from (KT) Kleinberg and Tardos. Algorithm Design (DPV)Dasgupta, Papadimitriou, and Vazirani. Algorithms.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
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.
Great Theoretical Ideas in Computer Science.
1 CSE 326: Data Structures: Graphs Lecture 23: Wednesday, March 5 th, 2003.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
Conceptual Foundations © 2008 Pearson Education Australia Lecture slides for this course are based on teaching materials provided/referred by: (1) Statistics.
The NP class. NP-completeness
Richard Anderson Lecture 26 NP-Completeness
Great Theoretical Ideas in Computer Science
Introduction to Discrete Mathematics
Some Great Theoretical Ideas in Computer Science for.
NP-Completeness Yin Tat Lee
Intro to Theory of Computation
Great Theoretical Ideas in Computer Science
NP-Completeness Yin Tat Lee
Great Theoretical Ideas In Computer Science
Presentation transcript:

P vs NP: what is efficient computation? Great Theoretical Ideas In Computer Science Anupam GuptaCS Fall 2005 Lecture 29Dec 8, 2005Carnegie Mellon University

A Graph Named “Gadget”

NODES or VERTICES

EDGES

K-COLORING We define a k-coloring of a graph: 1.Each node get colored with one color 2.At most k different colors are used 3.If two nodes have an edge between them, then they must have different colors A graph is called k-colorable iff it has a k-coloring Sometimes also called “proper” colorings.

A 2-CRAYOLA Question! Is Gadget 2-colorable?

A 2-CRAYOLA Question! Is Gadget 2-colorable? No, it contains a triangle.

Is Gadget 3-colorable? A 3-CRAYOLA Question!

Is Gadget 3-colorable? A 3-CRAYOLA Question!

Is Gadget 3-colorable? A 3-CRAYOLA Question!

Is Gadget 3-colorable? A 3-CRAYOLA Question! Yes.

A 3-CRAYOLA Question.

3-Coloring Is Decidable by brute force Try out all 3 n colorings until you determine if G has a 3-coloring. Membership in 3COLOR is not undecidable. But is it efficient to decide this?

What is an efficient algorithm? Is an O(n) time algorithm efficient? How about O(n log n)? O(n 2 ) ? O(n 10 ) ? O(n log n ) ? O(2 n ) ? O(n!) ? O(2 2 2 n ) ? polynomial time O(n c ) for some constant c non-polynomial time

Does an algorithm running in O(n 100 ) time count as efficient?

We consider non-polynomial time algorithms to be inefficient. And hence a necessary condition for an algorithm to be efficient is that it should run in poly-time.

Asking for a poly-time algorithm for a problem sets a (very) low bar when asking for efficient algorithms. The question is: can we achieve even this?

I see! Once we know that our favorite problems have polynomial time algorithms, we can then worry about making them run in O(n log n) or O(n 2 ) time! But we don’t know that yet for many common problems…

The class P defined in the 50’s. Paths, Trees and Flowers, Jack Edmonds, The Intrinsic Computational Difficulty of Functions, Alan Cobham, not the correct Alan Cobham this is indeed Jack Edmonds

Paths, Trees and Flowers, Jack Edmonds, An explanation is due on the use of the words "efficient algorithm"…I am not prepared to set up the machinery necessary to give it formal meaning, nor is the present context appropriate for doing this…For practical purposes the difference between algebraic and exponential order is more crucial than the difference between [computable and not computable]… It would be unfortunate for any rigid criterion to inhibit the practical development of algorithms which are either not known or known not to conform nicely to the criterion… However, if only to motivate the search for good, practical algorithms, it is important to realize that it is mathematically sensible even to question their existence. Edmonds called them “good algorithms”

The Intrinsic Computational Difficulty of Functions, Alan Cobham, For several reasons the class P seems a natural one to consider. For one thing, if we formalize the definition relative to various general classes of computing machines we seem always to end up with the same well-defined class of functions. Thus we can give a mathematical characterization of P having some confidence it characterizes correctly our informally defined class. This class then turns out to have several natural closure properties, being closed in particular under explicit transformation, composition and limited recursion on notation (digit-by-digit recursion). if p( ) and q( ) are polynomials, then p(q( )) is also a polynomial

The class P Definition: We say a language L µ Σ* is in P if there is a program A and a polynomial p() such that for any x in Σ*, A (given x as input) runs for ≤ p(|x|) time and answers question “is x in L?” correctly.

The class P Definition: We say function F: Σ*  Σ* is in P if there is a program A and a polynomial p() such that for any x in Σ*, A (given x as input) runs for ≤ p(|x|) time and A(x) = F(x). technically called FP, but we will blur the distinction for this lecture

The class P The set of all languages L that can be recognized in polynomial time. The set of functions that can be computed in polynomial time.

Why are we looking only at languages  Σ*? What if we want to work with graphs or boolean formulas?

Requiring that L  Σ* is not really restrictive, since we can encode graphs and Boolean formulas as strings of 0’s and 1’s. In fact, we do this all the time: inputs for all our programs are just sequences of 0’s and 1’s encoded in some suitable format.

Languages/functions in P? Example 1: CONN = {graph G: G is a connected graph} Algorithm A 1 : If G has n nodes, then run depth first search from any node, and count number of distinct nodes you see. If you see n nodes, G  CONN, else not. Time: p 1 (|x|) = Θ (|x|).

Languages/functions in P? Example 2: 2COLOR = {connected G : vertices of G can be 2-colored so that adjacent nodes don’t have same color} (Such colorings are called “proper colorings”.) Program A2: Pick a vertex and color it red. Repeat { if uncolored node has both red and blue neighbors, abort. if uncolored node has some neighbors red, color it blue. if uncolored node has some neighbors blue, color it red. } If aborted, then G not 2-colorable, else have 2-coloring.

Languages/functions in P? Example 3: 3COLOR = {G : vertices of G can be 3-colored} NOT KNOWN!

Languages/functions in P? And now a problem for Boolean circuits C:

Languages/functions in P? And, now a problem dealing with Combinational Circuits: AND, OR, NOT, 0, 1 gates wired together with no feedback allowed.

x3x3 x2x2 x1x1 OR AND OR

CIRCUIT-SATISFIABILITY Given a circuit with n-inputs and one output, is there a way to assign 0-1 values to the input wires so that the output value is 1 (true)? AND NOT Yes, this circuit is satisfiable. It has satisfying assignment 110.

Example 4: CIRCUIT-SATISFIABILITY Given: A circuit with n-inputs and one output, is there a way to assign 0-1 values to the input wires so that the output value is 1 (true)? “Brute force”: try all 2^n assignments. Exponential time… Languages/functions in P? NOT KNOWN!

Onto the new class, NP

Recall the class P We say a language L µ Σ* is in P if there is a program A and a polynomial p() such that for any x in Σ*, A (given x as input) runs for ≤ p(|x|) time and answers question “is x in L?” correctly. can think of A as “proving” that x in L.

The new class NP We say a language L µ Σ* is in NP if there is a program A and a polynomial p() such that for any x in Σ*, If x  L, there exists a “proof” y with |y| ≤ p(|x|) A(x, y) runs for ≤ p(|x|) time and answers question “x in L” correctly. If x  L, for all “proofs” y A(x, y) answers “x not in L” correctly. a short proof that x in L that can be quickly “verified” Verifier rejects all “fake” proofs

The class NP The set of languages L for which there exist “short” proofs of membership (of polynomial length) that can “quickly” verified (in polynomial time). Recall: A doesn’t have to find these proofs y; it just needs to be able to verify that y is a “correct” proof.

Which languages are in NP?

P  NP For any L in P, we can just take y to be the empty string and satisfy the requirements. Hence, every language in P is also in NP. $10 6 question: is NP  P ?

Languages/functions in NP? Example 3: 3COLOR = {G : vertices of G can be 3-colored so} Short proof y: a color C v for each node v of G. Verifier A: For each edge (u,v) in G, ensure C u  C v Ensure only 3 colors were used. Proof length: a list of n colors. Verifier runs in time O(number of edges + number of nodes). YES

Languages/functions in NP? Example 4: CIRCUIT-SAT Given: A circuit with n-inputs and one output, is there a way to assign 0-1 values to the input wires so that the output value is 1 (true)? Proof: satisfying assignment Verifier just evaluates circuit. YES

Summary: P versus NP Language L is in P if membership in L can be decided in poly-time. Language L is in NP if each x in L has a short “proof of membership” that can be verified in poly-time. Fact: P  NP Question: Does NP  P ?

Hamilton Cycle b a e c d f h i g a cycle that passes through every node exactly once

NP contains lots of problems we don’t know to be in P Classroom Scheduling Packing objects into bins Scheduling jobs on machines Finding cheap tours visiting a subset of cities Allocating variables to registers Finding good packet routings in networks Decryption … Hence proving P = NP would break cryptosystems

The $1,000,000 question In order to celebrate mathematics in the new millennium, The Clay Mathematics Institute of Cambridge, Massachusetts (CMI) has named seven Prize Problems. The Scientific Advisory Board of CMI selected these problems, focusing on important classic questions that have resisted solution over the years. The Board of Directors of CMI designated a $7 million prize fund for the solution to these problems, with $1 million allocated to each. Problem #4: The P vs NP problem.

How can we prove that NP  P? I would have to show that every language in NP has a polynomial time algorithm… How do I do that? It may take forever! Also, what if I forgot one of the languages in NP?

Relax, Bonzo! We can describe one language L in NP, such that if this language L is in P, then NP  P. It is a language that can capture all other languages in NP.

The Magic Language: CIRCUITSAT Example 6: CSAT = {circuit C: C has at least 1 satisfying assignment} If we can write a program A that takes as input a circuit C A(C) runs in time polynomial(|C|) correctly decides if C is satisfiable then NP  P Steven CookLeonid Levin

Theorem [Cook/Levin]: CIRCUITSAT is one language in NP, such that if we can show CIRCUITSAT is in P, then we have shown NP  P. CIRCUITSAT is a language in NP that can capture all other languages in NP. We say CIRCUITSAT is NP-complete. Proof not difficult, but we defer the proof to (Algos) or (FLAC)

AND NOT 3-colorabilityCircuit Satisfiability

CIRCUIT-SAT and 3COLOR Two problems that seem quite different, but are substantially the same

A Graph Named “Gadget”

TF X Y Output

T F X Y XY FFF FTT TFT TTT

T F X Y XYOR FFF FTT TFT TTT

NOT xy z x y z

OR NOT xy z x y z How do we force the graph to be 3 colorable exactly when the circuit is satifiable?

OR NOT xy z x y z Satisfiability of this circuit = 3-colorability of this graph TRUE

Let C be an n-input circuit. GIVEN: 3-color Oracle C BUILD: SAT Oracle Graph composed of gadgets that mimic the gates in C with one edge from output to false.

You can quickly transform a method to decide 3-coloring into a method to decide circuit satifiability!

Any language in NP SAT can be reduced (in polytime to) an instance of hence SAT is NP-complete

Any language in NP SAT 3COLOR can be reduced (in polytime to) an instance of can be reduced (in polytime to) an instance of

Any language in NP 3COLOR can be reduced (in polytime to) an instance of can be reduced (in polytime to) an instance of Hence: SAT hence 3COLOR is NP-complete

To show a language L is NP-complete To show L is NP-complete, we must a)Show L is in NP b)Reduce all problems in NP to L or b)Reduce some NP-complete language (e.g. C-SAT) to L (by exhibiting a function F such that C is satisfiable  F(C) is in L)

NP-complete problems 3COLOR, SAT, bin-packing, classroom scheduling, many other problems NP-complete. proofs follow above pattern. NP-complete problems: “Hardest” problems in NP (if any of these problems in P, then all NP in P.) NP-complete problems come up all the time Many problems of practical importance are NP-complete If P  NP, we will not have poly-time algorithms for them. Right now, we don’t know.

Reference Computers and Intractablity: A guide to the Theory of NP-completeness by Mike Garey and David Johnson

References The NP-completeness Column: by David Johnson The P versus NP problem Official Description, Clay Institute by Steve Cook