P and NP. Or, how to make $1,000,000.

Similar documents
Computability Theory

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

Computational Models Lecture 11, Spring 2009

Theory of Computation Time Complexity

Computability and Complexity

CISC 4090 Theory of Computation

Chapter 7: Time Complexity

Time Complexity. CS60001: Foundations of Computing Science

BBM402-Lecture 11: The Class NP

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

CSE 105 THEORY OF COMPUTATION

CSE 105 Theory of Computation

CSE 135: Introduction to Theory of Computation NP-completeness

Applied Computer Science II Chapter 7: Time Complexity. Prof. Dr. Luc De Raedt. Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CS154, Lecture 13: P vs NP

CS154, Lecture 13: P vs NP

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

Computational Complexity

Chapter 2 : Time complexity

Friday Four Square! Today at 4:15PM, Outside Gates

Lecture 19: Finish NP-Completeness, conp and Friends

Time and space classes

CS154, Lecture 17: conp, Oracles again, Space Complexity

Intractable Problems [HMU06,Chp.10a]

CP405 Theory of Computation

Lecture 20: conp and Friends, Oracles in Complexity Theory

1 Non-deterministic Turing Machine

22c:135 Theory of Computation. Analyzing an Algorithm. Simplifying Conventions. Example computation. How much time does M1 take to decide A?

ECS 120 Lesson 24 The Class N P, N P-complete Problems

Computational complexity

Lecture 3: Nondeterminism, NP, and NP-completeness

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Complexity. Complexity Theory Lecture 3. Decidability and Complexity. Complexity Classes

Complexity (Pre Lecture)

Intro to Theory of Computation

Advanced topic: Space complexity

Lecture 16: Time Complexity and P vs NP

Finish K-Complexity, Start Time Complexity

NP, polynomial-time mapping reductions, and NP-completeness

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

CS311 Computational Structures. NP-completeness. Lecture 18. Andrew P. Black Andrew Tolmach. Thursday, 2 December 2010

conp, Oracles, Space Complexity

Complexity Theory Part II

Definition: conp = { L L NP } What does a conp computation look like?

1 Computational Problems

P = k T IME(n k ) Now, do all decidable languages belong to P? Let s consider a couple of languages:

Computer Sciences Department

Notes for Lecture Notes 2

Introduction to Complexity Theory

Space Complexity. The space complexity of a program is how much memory it uses.

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

Intractable Problems. Time-Bounded Turing Machines Classes P and NP Polynomial-Time Reductions

CSCI3390-Lecture 14: The class NP

TIME COMPLEXITY AND POLYNOMIAL TIME; NON DETERMINISTIC TURING MACHINES AND NP. THURSDAY Mar 20

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

UNIT-VIII COMPUTABILITY THEORY

Polynomial time reduction and NP-completeness. Exploring some time complexity limits of polynomial time algorithmic solutions

Week 2: Defining Computation

The purpose here is to classify computational problems according to their complexity. For that purpose we need first to agree on a computational

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) Spring l. Blum TIME COMPLEXITY AND POLYNOMIAL TIME;

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

CMPT307: Complexity Classes: P and N P Week 13-1

6.840 Language Membership

CSCE 551: Chin-Tser Huang. University of South Carolina

Computational Models Lecture 8 1

Complexity Theory Part I

1 Computational problems

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

Limits of Feasibility. Example. Complexity Relationships among Models. 1. Complexity Relationships among Models

CPSC 421: Tutorial #1

NP-Completeness and Boolean Satisfiability

SOLUTION: SOLUTION: SOLUTION:

Advanced Topics in Theoretical Computer Science

The space complexity of a standard Turing machine. The space complexity of a nondeterministic Turing machine

: Computational Complexity Lecture 3 ITCS, Tsinghua Univesity, Fall October 2007

CS294: Pseudorandomness and Combinatorial Constructions September 13, Notes for Lecture 5

15.1 Proof of the Cook-Levin Theorem: SAT is NP-complete

Variations of the Turing Machine

Computational Models Lecture 8 1

CS 6505, Complexity and Algorithms Week 7: NP Completeness

Theory of Computation

Essential facts about NP-completeness:

Computational Models Lecture 8 1

Could we potentially place A in a smaller complexity class if we consider other computational models?

Chapter 1 - Time and Space Complexity. deterministic and non-deterministic Turing machine time and space complexity classes P, NP, PSPACE, NPSPACE

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

Complexity Theory Part I

Computability Theory

Final exam study sheet for CS3719 Turing machines and decidability.

Data Structures in Java

Complexity: moving from qualitative to quantitative considerations

Transcription:

P and NP Or, how to make $1,000,000. http://www.claymath.org/millennium-problems/p-vs-np-problem

Review: Polynomial time difference between single-tape and multi-tape TMs Exponential time difference between deterministic and non-deterministic TMs. Time Complexity The Practical and Impractical Polynomial considered small. All reasonable, deterministic programming models are polynomially equivalent. Reasonable is loosely defined, but includes models that closely resemble running time on actual computers. Exponential considered big. Common in brute-force searches.

The class P plays a central role in our theory and is important because 1. The Class P P is the class of languages that are decidable in polynomial time on a deterministic single-tape Turing machine. P is invariant for all models of computation that are polynomially equivalent to the deterministic single-tape Turing machine, and a. 2. E.g., mathematically robust, unaffected by computation model. P roughly corresponds to the class of problems that are realistically solvable on a computer. a. E.g., is practically relevant.

General Approach Guidelines for proving that some problem/algorithm is in P 1. Give algorithms in numbered stages. 2. Give a polynomial upper bound (e.g., big-o) on the # of stages for input of length n. 3. Ensure that each stage can be completed in polynomial time on a reasonable deterministic model. 4. Input must be reasonably encoded.

Example: The PATH problem PATH = { G, s, t G is a directed graph that has a directed path from s to t} Brute force: Examine all possible paths and accept if one path is from s to t. Too slow!!! PROOF: M = On input G, s, t, where G is a directed graph with nodes s and t: 1. Place a mark on node s. 2. Repeat the following until no additional nodes are marked: 3. Scan all the edges of G. If an edge(a, b) is found going from a marked node a to an unmarked node b, mark node b. 4. If t is marked, accept. Otherwise, reject. What is the total number of stages? Can each stage be executed in polynomial time?

Example: Relative Primes (i.e., GCD is 1) RELPRIME = { x, y x and y are relatively prime} If E runs in polynomial time, then so will R. E = On input x, y, where x and y are natural numbers in binary: 1. Repeat until y = 0 : 2. Assign x x mod y. 3. Exchange x and y. 4. Output x. How many stages are run by E? If x / 2 y, then x mod y < y x / 2 and x drops by at least half. If x / 2 < y, then x mod y = x y < x / 2 and x drops by at least half. X and y are exchanged at end of loop Max executions of 2 & 3 is min(2 log2 x, 2 log2 y). R = On input x, y, where x and y are natural numbers in binary: 1. Run E on x, y. 2. If the result is 1, accept. Otherwise, reject. # of stages is O(n). Each stage of E is polynomial, therefore algorithm is polynomial.

Theorem: Every context-free language is a member of P. Theorem 4.9 proved that every CFL is decidable. Unfortunately, that algorithm tried all possible derivations, and is therefore exponential. :( Requires dynamic programming. Overlapping subproblems, optimal substructure. Often uses a matrix for memoization. Create a n n table. For i j, the (i,j)th entry of the table contains the collection of variables that generate the substring wiwi+1 wj. Algorithm is O(n3). Let G be a CFG in Chomsky normal form generating the CFL L.

The Class NP Making complexity more complex. There are problems for which we have not found polynomial algorithms. Maybe they don t exist. Maybe we re just not smart enough yet.

Intuition Builder: Hamiltonian Paths A Hamiltonian path in a directed graph G is a directed path that goes through each node exactly once. HAMPATH = { G, s, t G is a directed graph with a Hamiltonian path from s to t } What algorithm can we use to decide HAMPATH? Is the algorithm polynomial? Nobody has found a polynomial solution for HAMPATH. However, HAMPATH exhibits polynomial verifiability, which means that if a solution (path) were proposed, then it s membership could be decided in polynomial time. I.e., verifying existence may be easier than determining existence. HAMPATH is not polynomial, neither is it even polynomial verifiable. Verification would be no simpler than the original computation!

Verifiers DEFINITION: A verifier for a language A is an algorithm V, where A = {w V accepts w, c for some string c}. We measure the time of a verifier only in terms of the length of w, so a polynomial time verifier runs in polynomial time in the length of w. A language A is polynomially verifiable if it has a polynomial time verifier. The symbol c represents a certificate, or proof, of w s membership in A. In HAMPATH, c would be the path to verify between s and t. EXAMPLE: Composite numbers are numbers which are not prime. COMPOSITES = {x x = pq, for integers p, q > 1}. COMPOSITES is polynomially verifiable, because a divisor can serve as c. (Note: It is not trivial to assume that COMPOSITES is in P. Why?)

Definition: NP NP is the class of languages that have polynomial time verifiers. NP does not mean Not-P. It is an unfortunate coincidence that causes confusion. NP comes from Nondeterministic Polynomial, as related to nondeterministic, polynomial-time Turing Machines. P NP HAMPATH on a NTM: N1 = On input G, s, t, where G is a directed graph with nodes s and t: 1. Write a list of m numbers, p1,...,pm, where m is the number of nodes in G. Each number in the list is nondeterministically selected to be between 1 and m. 2. Check for repetitions in the list. If any are found, reject. 3. Check whether s = p1 and t = pm. If either fail, reject. 4. For each i between 1 and m 1, check whether (pi, pi+1) is an edge of G. If any are not, reject. Otherwise, all tests have been passed, so accept.

Theorem: NP Languages A language is in NP iff it is decided by some nondeterministic polynomial time Turing machine. IDEA: Show how to convert a polynomial time verifier to an equivalent polynomial time NTM and vice versa. The NTM simulates the verifier by guessing the certificate. The verifier simulates the NTM by using the accepting branch as the certificate. Let A NP and show that A is decided by a polynomial time NTM N. LetV be the polynomial time verifier for A that exists by the definition of NP. Assume that V is a TM that runs in time nk and construct N as follows. N = On input w of length n: 1. Nondeterministically select string c of length at most nk. 2. Run V on input w, c. 3. If V accepts, accept; otherwise, reject. V = On input w, c, where w and c are strings: 1. Simulate N on input w, treating each symbol of c as a description of the nondeterministic choice to make at each step (as in the proof of Theorem 3.16). 2. If this branch of N s computation accepts, accept; otherwise, reject.

NP Definition NTIME(t (n)) = {L L is a language decided by an O(t(n)) time nondeterministic Turing machine}. NP is insensitive to the choice of a reasonable nondeterministic computation model, because they are polynomially equivalent. Restrictions on algorithm stages are similar to those of class P. Each stage must have an obvious implementation on a reasonable nondeterministic model.

Example NP Problem: k-cliques Clique: fully-connected subgraph. K-clique: clique containing exactly k nodes. (example picture is a 5-clique) Problem is to determine if a k-clique exists in a graph. CLIQUE ={ G, k G is an undirected graph with a k-clique} THEOREM: CLIQUE is in NP. PROOF: Clique is the certificate. V = On input G, k, c : 1. Test whether c is a subgraph with k nodes in G. 2. Test whether G contains all edges connecting nodes in c. 3. If both pass, accept; otherwise, reject.

Example NP Problem: k-cliques (alternate proof) Clique: fully-connected subgraph. K-clique: clique containing exactly k nodes. (example picture is a 5-clique) Problem is to determine if a k-clique exists in a graph. CLIQUE ={ G, k G is an undirected graph with a k-clique} THEOREM: CLIQUE is in NP. PROOF: Nondeterministically decide CLIQUE. V = On input G, k : 1. Nondeterministically select a subset c of k nodes of G. 2. Test whether G contains all edges connecting nodes in c. 3. If both pass, accept; otherwise, reject.

Example NP Problem: SUBSET-SUM SUBSET-SUM = { S, t S = {x1,...,xk}, and for some {y1,...,yl} {x1,...,xk}, we have Σyi = t}. Simply put: From a group of numbers, is there a subset of them that add up to a target number? EXAMPLE: {4, 11, 16, 21, 27}, 25 SUBSET-SUM because 4 + 21 = 25. NOTE: Repetition is allowed, because {x } and {y } are defined as multisets. PROOF: Verifier with subset as certificate. V = On input S, t, c : 1. Test whether c is a collection of numbers that sum to t. 2. Test whether S contains all the numbers in c. 3. If both pass, accept; otherwise, reject. ALTERNATIVE PROOF: Nondeterministic TM. N = On input S, t : 1. Nondeterministically select a subset c of the numbers in S. 2. Test whether c is a collection of numbers that sum to t. 3. If the test passes, accept; otherwise, reject.

conp: The dark side. Like HAMPATH, CLIQUE and SUBSET-SUM are not obviously in NP. We define conp as the languages which are the complements of NP. Problem: Verifying that something is not present seems much more difficult than verifying that something is present. Reality: We don t know if conp is different from NP.

P = the class of languages for which membership can be decided quickly. P vs NP https://www.win.tue.nl/~gwoegi/p-versus-np.htm NP = the class of languages for which membership can be verified quickly. The best deterministic method currently known for deciding languages in NP uses exponential time. E.g.,