Complexity Classes: P and NP

Slides:



Advertisements
Similar presentations
Computational Complexity
Advertisements

Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
NP-Completeness.
NP-Hard Nattee Niparnan.
Time Complexity P vs NP.
JAYASRI JETTI CHINMAYA KRISHNA SURYADEVARA
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?
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
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 
Lecture 21 Nondeterministic Polynomial time, and the class NP FIT2014 Theory of Computation Monash University Faculty of Information Technology Slides.
Complexity 12-1 Complexity Andrei Bulatov Non-Deterministic Space.
Complexity 11-1 Complexity Andrei Bulatov Space Complexity.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
The Theory of NP-Completeness
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
Machines with Memory Chapter 3 (Part B). Turing Machines  Introduced by Alan Turing in 1936 in his famous paper “On Computable Numbers with an Application.
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.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
NP Complexity By Mussie Araya. What is NP Complexity? Formal Definition: NP is the set of decision problems solvable in polynomial time by a non- deterministic.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
CSC 413/513: Intro to Algorithms NP Completeness.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
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.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
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.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
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.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
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.
Given this 3-SAT problem: (x1 or x2 or x3) AND (¬x1 or ¬x2 or ¬x2) AND (¬x3 or ¬x1 or x2) 1. Draw the graph that you would use if you want to solve this.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
Prof. Busch - LSU1 Time Complexity. Prof. Busch - LSU2 Consider a deterministic Turing Machine which decides a language.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
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.
Turing Machines CS 130 Theory of Computation HMU Textbook: Chap 8.
NP-Completeness A problem is NP-complete if: It is in NP
The NP class. NP-completeness
P & NP.
Chapter 10 NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
Part VI NP-Hardness.
Richard Anderson Lecture 26 NP-Completeness
Intro to Theory of Computation
Intro to Theory of Computation
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Computational Complexity
NP-Complete Problems.
Prabhas Chongstitvatana
Time Complexity Classes
CSE 6408 Advanced Algorithms.
CSE 589 Applied Algorithms Spring 1999
Presentation transcript:

Complexity Classes: P and NP CS 130 Theory of Computation HMU Textbook: Chap 10

Turing machines and complexity Time and space complexity The class P Non-determinism The class NP Reduction and NP-Completeness

Time and space complexity Running time (or time complexity) for a TM is f(n), where n is the length of the input tape f(n) maximum number of steps/transitions the TM makes before halting Could be infinite if the TM does not halt on some inputs Space complexity is the maximum number of cells on the tape used/encountered by the TM during execution

The class P The class P describes all languages (or problems) described by a Turing Machine decider, whose time complexity is bounded by a polynomial on n Examples: Divisibility of a number by another number Recognizing palindromes Matching symbols in a string Many other more complex problems (e.g., searching, shortest paths, min-cost spanning tree)

The class P solvable (decidable) recursive problems P solvable within polynomial time

Extensions to the basic TM Multi-tape turing machine multiple tapes, input placed on first tape, other tapes filled with blanks multiple heads, moving independently Nondeterminism: allow several possible transitions, given a state and symbol Alternatives to TMs Counter machines, stack machines, etc… None of these extensions extend the capability of TMs, but may impact on time/space complexity

Non-deterministic Turing Machine An non-deterministic turing machine, or NDTM, is a tuple M = (Q, , , , q0, B, F), where Q is a set of states  is the input alphabet  is the tape alphabet =   {B}  other tape symbols : Q    (Q    D)* is the state transition function mapping (state, symbol) to (state, symbol, direction) possibilities; D = {,};  may be empty/undefined for some pairs q0 is the start state of M B is the blank symbol (default symbol on input tape) F  Q is the set of accepting states or final states of M (if applicable)

Non-deterministic Turing Machine Difference from a regular TM: : Q    (Q    D)* Multiple transitions, given a state and a symbol, are now possible Impact on the turing machine as a recognizer String is acceptable as long as at least one path of transitions leads to a final state Impact on the turing machine as a decider String is acceptable as long as at least one path of transitions leaves a YES on the tape; not acceptable if all paths leave a NO on the tape

The class NP The class NP describes all languages (or problems) described by an NDTM decider, whose time complexity is bounded by a polynomial on n Clearly P  NP, but it is not yet known or proven that P  NP (though many believe this is true)

The classes P and NP not yet proven that this region is empty, but it likely isn’t solvable (decidable) problems recursive NP P solvable within polynomial time

Some problems in NP Independent set Hamiltonian cycle Satisfiability Vertex cover “Student Reps”

Independent set Given a graph G = (V,E) and an integer K, is there a subset S of K vertices in V such that no two vertices in S are connected by an edge? There is an easy brute-force method to solve this problem: for each possible subset S of V (2n such subsets): check if S contains K vertices and then check if each pair in S is connected by an edge Answer yes if there is an S that satisfies the condition, answer no if all subsets do not

Independent set and TMs A vertex subset can be represented by an n-bit string (string of 0’s and 1’s: 1 means a vertex is part of the subset) Deterministic TM solution Loop that generates each subset on the tape and then checks if a subset satisfies the condition Exponential time complexity because there are 2n subsets NDTM solution Non-deterministically write a subset on the tape, then check if the subset satisfies the condition Polynomial-time complexity because there is no exponential loop involved

NDTM and possibilities q1 q2 q3 q4 writes one of the following 3-bit strings on the tape: 000,001,010,011,100,101,110,111

Hamiltonian cycle Given a graph G = (V,E), is there a simple cycle containing all vertices in V? Easy brute-force method to solve this problem: for each possible permutation P of V (n! possibilities): check if the appropriate edges implied by the permutation exist, forming the cycle Answer yes if there is a P that forms a cycle, answer no if all permutations do not

Alternative characterization of NP A problem is in NP if a feasible solution to the problem can be verified in polynomial time A problem is in NP if it can be solved by the following “framework”: for each possibility P: check (in polynomial time) if the possibility P satisfies the condition stated in the problem Answer yes if there is a P that satisfies the condition, answer no if all possibilities do not

Satisfiability Given a set V of variables, and a boolean expression E over V, consisting of a conjunction of clauses of disjunctions of literals (conjunctive normal form), is there a truth assignment for V that satisfies E (E evaluates to true under the assignment)? Example: V = {a,b,c}, E = (a+b)(b+c)(c) Assignment that satisfies E: A=true, B=true, c=false Easy brute-force method to solve this problem: for each possible truth assignment A (2n possibilities): evaluate E under A Answer yes if there is an A that satisfies E, answer no if all assignments do not

Vertex cover Given a graph G = (V,E) and an integer K, is there a subset S of K vertices in V such that every edge in E has at least one endpoint in S? There is an easy brute-force method to solve this problem: for each possible subset S of V (2n such subsets): check if S contains K vertices and then check if edges in E have an incident vertex in S Answer yes if there is an S that satisfies the condition, answer no if all subsets do not

Student reps Given: Question: A set S of all students in a university A set O of student organizations, each having members that comprise a subset of S An integer K Question: Can I find K students from S such that all organizations are represented? Exercise: Formulate a brute-force solution to this problem following the framework mentioned, thereby showing that this problem is in NP

NP-complete problems The problems we have identified so far are “hard” in the sense that there are no known polynomial-time solutions using a regular TM but there are “easy” exponential-time solutions (or, polynomial solutions in an NDTM) Some of these problems have been shown “complete” in the sense that all problems in NP reduce to these problems

Reduction Reduction entails converting an instance of one problem into an equivalent instance of another If a problem A reduces to a problem B, then a solution to B can be used to solve A Means that B is at least as hard as A Remember HP and HPA? Cook’s Theorem: Satisfiability (SAT) is NP-complete; all problems in NP reduce to SAT What does this mean? If someone discovers a polynomial-time solution for SAT, all other problems are solved

Reduction Important condition: the reduction has to be carried out in polynomial-time How does one show that a problem P is NP-complete? Use a proof similar to Cook’s theorem (too hard, and too much work!) Easier option: reduce a known NP-complete problem (such as SAT) to P, so that P is NP-complete by transitivity Thousands of problems in NP have already been shown NP-complete If any one of these problems turns out to be solvable in polynomial time, it is a proof that P=NP! ($1M prize)

Reduction and NP-completeness SAT is NP-complete by Cook’s theorem Proof is beyond the scope of this course SAT reduces to Vertex Cover (VC) Convert variables and clauses to a graph and an integer such that a truth assignment corresponds to a vertex cover in the converted graph With a successful polynomial-time reduction, this shows that VC is NP-complete VC reduces to Independent Set (IS) and to Student Reps (SR) Which means IS and SR are NP-complete

SAT to VC V = {a,b,c,d} E = (c)(a+b)(b+c+d) - + - + - + - + K = 4 + 0+1+2 = 7 G b c a b c d (b+c+d) (c) (a+b)

Reduction and NP-completeness all other NP problems All other NP problems SAT VC HC IS SR

Summary Turing machines model computability The class P: problems (languages) that can be solved in polynomial time using a TM decider The class NP: problems that can be solved in polynomial time using a NDTM (they can be solved in exponential time using a regular TM) Not yet proven whether P  NP There are problems in NP that are NP-complete; i.e., all other NP problems reduce to it Saying that a problem is NP-complete is a statement of “hardness” of that problem Proving NP-completeness: reduce from a known NP-complete problem