P vs. NP Classes. Prof. (Dr.) K.R. Chowdhary.

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

Advanced Topics in Theoretical Computer Science

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

Computability and Complexity CISC462, Fall 2018, Space complexity 1

CS5371 Theory of Computation. Lecture 23: Complexity VIII (Space Complexity)

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

Complexity Theory 112. Space Complexity

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

Chapter 7: Time Complexity

Time Complexity. CS60001: Foundations of Computing Science

conp, Oracles, Space Complexity

Time Complexity. Definition. Let t : n n be a function. NTIME(t(n)) = {L L is a language decidable by a O(t(n)) deterministic TM}

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

Lecture 21: Space Complexity (The Final Exam Frontier?)

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

Space Complexity. Master Informatique. Université Paris 5 René Descartes. Master Info. Complexity Space 1/26

Lecture 22: PSPACE

COMPLEXITY THEORY. PSPACE = SPACE(n k ) k N. NPSPACE = NSPACE(n k ) 10/30/2012. Space Complexity: Savitch's Theorem and PSPACE- Completeness

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

Polynomial Time Computation. Topics in Logic and Complexity Handout 2. Nondeterministic Polynomial Time. Succinct Certificates.

CS154, Lecture 13: P vs NP

Space Complexity. Huan Long. Shanghai Jiao Tong University

Resource-Bounded Computation

CS5371 Theory of Computation. Lecture 23: Complexity VIII (Space Complexity)

CISC 4090 Theory of Computation

Computational Models Lecture 11, Spring 2009

Lecture 19: Finish NP-Completeness, conp and Friends

CS154, Lecture 13: P vs NP

CSE 105 Theory of Computation

Computational Complexity IV: PSPACE

Notes on Space-Bounded Complexity

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

Complexity: Some examples

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan 9/6/2004. Notes for Lecture 3

Lecture 20: PSPACE. November 15, 2016 CS 1010 Theory of Computation

Outline. Complexity Theory. Example. Sketch of a log-space TM for palindromes. Log-space computations. Example VU , SS 2018

CSE 105 THEORY OF COMPUTATION

Notes on Space-Bounded Complexity

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

CSCI 1590 Intro to Computational Complexity

CSE 105 THEORY OF COMPUTATION

Intractable Problems [HMU06,Chp.10a]

CSE200: Computability and complexity Space Complexity

De Morgan s a Laws. De Morgan s laws say that. (φ 1 φ 2 ) = φ 1 φ 2, (φ 1 φ 2 ) = φ 1 φ 2.

satisfiability (sat) Satisfiability unsatisfiability (unsat or sat complement) and validity Any Expression φ Can Be Converted into CNFs and DNFs

Theory of Computation. Ch.8 Space Complexity. wherein all branches of its computation halt on all

Computational Complexity

1 Computational Problems

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

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

Notes for Lecture Notes 2

CSE 105 THEORY OF COMPUTATION

1 Non-deterministic Turing Machine

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

Mm7 Intro to distributed computing (jmp) Mm8 Backtracking, 2-player games, genetic algorithms (hps) Mm9 Complex Problems in Network Planning (JMP)

The Cook-Levin Theorem

Principles of Knowledge Representation and Reasoning

Theory of Computation Time Complexity

CSE 135: Introduction to Theory of Computation NP-completeness

Introduction to Computational Complexity

CS20a: NP completeness. NP-complete definition. Related properties. Cook's Theorem

Introduction to Computational Complexity

Algorithms & Complexity II Avarikioti Zeta

INAPPROX APPROX PTAS. FPTAS Knapsack P

NP Complete Problems. COMP 215 Lecture 20

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

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

Computability and Complexity

Space is a computation resource. Unlike time it can be reused. Computational Complexity, by Fu Yuxi Space Complexity 1 / 44

Lecture 16: Time Complexity and P vs NP

NP-Completeness and Boolean Satisfiability

CSCI 1590 Intro to Computational Complexity

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

ECE 695 Numerical Simulations Lecture 2: Computability and NPhardness. Prof. Peter Bermel January 11, 2017

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan August 30, Notes for Lecture 1

Lecture 20: conp and Friends, Oracles in Complexity Theory

Lecture 6: Oracle TMs, Diagonalization Limits, Space Complexity

Complexity (Pre Lecture)

CS601 DTIME and DSPACE Lecture 5. Time and Space functions: t,s : N N +

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

Intro to Theory of Computation

6.045 Final Exam Solutions

Lecture 9: Polynomial-Time Hierarchy, Time-Space Tradeoffs

NP-Completeness. A language B is NP-complete iff B NP. This property means B is NP hard

Turing Machine Extensions, and Enumerators

Computability Theory

Comparison of several polynomial and exponential time complexity functions. Size n

Intro to Theory of Computation

Lecture 17: Cook-Levin Theorem, NP-Complete Problems

Welcome to... Problem Analysis and Complexity Theory , 3 VU

Complete problems for classes in PH, The Polynomial-Time Hierarchy (PH) oracle is like a subroutine, or function in

SOLUTION: SOLUTION: SOLUTION:

Planning and Optimization

Logarithmic space. Evgenij Thorstensen V18. Evgenij Thorstensen Logarithmic space V18 1 / 18

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

Finish K-Complexity, Start Time Complexity

Lecture 18: PCP Theorem and Hardness of Approximation I

Undirected ST-Connectivity in Log-Space. Omer Reingold. Presented by: Thang N. Dinh CISE, University of Florida, Fall, 2010

Non-Deterministic Time

Transcription:

P vs. NP Classes Prof. (Dr.) K.R. Chowdhary Email: kr.chowdhary@iitj.ac.in Formerly at department of Computer Science and Engineering MBM Engineering College, Jodhpur Monday 10 th April, 2017 kr chowdhary TOC 1/ 16

Complexity of computation Adding two n-digit numbers: n+1 steps usually. But if we look at minor steps then 5n+1 steps( n additions of digits, n additions of carry, n comparisons if sum of two digits is greater than 10, n steps to print lower digit, n steps to save carry). The last step is for carry save from last sum. Even further smaller steps are taken, it comes out to be an+b, where a,b are constants, not dependent on n. Thus time complexity of add, is θ(n). Multiplication: To multiply x and y, one approach if add x to 0, y times. If both numbers are n digit long, then θ(n.10 n ). Other method is θ(n 2 ) complexity. The best known algorithm for multiplication is θ(n 1.1 ). Factoring: of n digit number. Some times not well defined, as 1001=77 13 or 91 11. To factor Z we need to divide it by range 2 to Z 1. If Z =n, complexity is 10 n. No solution like, θ(n) or θ(n c ), where c is constant, is available. kr chowdhary TOC 2/ 16

Complexity terms T(n): Time complexity of standard Turing Machine. Function T(n) is called time-constructible if there exists a time-bound Deterministic TM that with input makes w =n moves. T(n): Nondeterministic Turing machine Time complexity. S(n): Space complexity of standard Turing Machine. Function S(n) is called space-constructible, if there exists a space-bound standard TM, that for each input of length n, requires exactly S(n) space. DTIME(T(n)): class of languages that have deterministic time complexity of O(T(n)). NTIME(T(n)): class of languages that have nondeterministic time complexity of O(T(n)). kr chowdhary TOC 3/ 16

The class P Let L Σ. L is polynomial if membership of w can be determined in polynomial function of n, where w =n. Polynomial time is in terms of number of transitions in TM. L is decidable in polynomial time if standard std TM M can decide L in tc M O(n r ), where r is natural number, not related to n. The family of L is Class-P. A language accepted by multi-tape TM in time O(n r ) is accepted by STD TM in time complexity O(n 2r ), which is also polynomial. This invariant shows the robustness of TM. P : Class of membership problems for the languages in DTIME(P(n)); where P(n) is polynomial in n. P(n) 1 Acceptance of palindromes: Output is YES if w Σ is palindrome, else NO. Complexity Class=P. 2 Path problem in directed graphs: Input is G=(V,E). Output is YES if there is a path from v i to v j in the graph, else NO. Complexity class=p, as complexity = O(n 2 ) due to Dijkstra s algorithm. 3 Deriviability in CNF: Input: CNF G, w, output=yes, if S w else No. Complexity: P= yes. kr chowdhary TOC 4/ 16

The Class NP Definition: A language is in NP iff it is decided by some NDTM in polynomial time. NDTM guesses the alternatives. Polynomial solution for these are not known to exist. in NDTM the solution is selected nondeterministically rather than systematically examining all the possibilities. P NP, because a P problem is also NP. NP : The class of membership problems for languages in NTIME(P(n)) P(n) Examples: 1. SATISFIABILITY problem: Input Boolean expression u in CNF, Output = YES if there is an assignment that satisfies u else NO.Complexity: In P - Unknown, in NP - YES. 2. Hamiltonian path problem: Input directed graph G, Output: YES if there is a single cycle that visits all nodes, No other wise. Complexity: P-unknown, NP- YES. Hamiltonian path problem is in NP, but its solution can be verified in P. 3. Subset sum problem: Input: Set S, number k, output: Yes if there is P S, whose toatl is k, else No. Complexity: P - unknown, NP - kr chowdhary TOC 5/ 16

Primality test and Compositeness PRIMES ={x x is prime}, COMPOSITS ={y y is Composite number},,primes =COMPOSITS,, if COMPOSITS is NP then PRIMES is Co NP (Complement of NP). COMPOSITNESS can be determined by NDTM by guessing Nondterministically. COMPOSITNESS is in NP but its solution can be verified in P time. Fermat s Little theorem for primality test: If p is prime and a is integer, then: a p a(mod p), i.e., a p a is evenly divisible by p. This problem is NP because exponential component a p. Example: 2 11 2 is divisible by 11. Sets of primes are in NP but not in NP-complete, similarly the COMPOSITS. The language of PRIMES is NP Co NP,and hence of COMPOSITS also. Because, if that is not the case then NP =Co NP. kr chowdhary TOC 6/ 16

Primality test and Compositeness... Theorem COMPOSITS are NP Proof. 1 Input on NDTM = p, p =n. Guess a factor f of at most n bits (f 1,f p). This part is non-deterministic. The time taken by any sequence of choice is O(n). 2 Divide p by f, check if remainder is 0. Accept if so. Part 2 is deterministic O(n 2 ) on STD 2-tape TM. Definition: If there is a polynomial time algorithm for one NP-problem, then all NP problems are solvable in P time, are called NP-complete. This is because, if A is NP-complete, then all NP-problems are reducible to it. And, if A P, then all those NP are P. Adv: 1. if one can be solved, then all rest are automatically solved, 2. One may choose only one of the most appropriate NP problem for solution. kr chowdhary TOC 7/ 16

Complexity classes-time Class Machine Time constraint DTIME(f(n)) DTM f(n) P DTM poly(n) NTIME(f(n)) NDTM f(n) NP NDTM poly(n) EXPTIME DTM 2 poly(n) EXPTIME : The class of membership problems for this languages in DTIME(2 P(n) ). P(n) Satisfiability is NP-complete. A Boolean expression φ ={ x y) (x z) is satisfiable for x=0, y=1, z=0, as it evaluates φ to 1 (TRUE). SAT is languages of all satisfiable formulas, SAT ={< φ > φ is satisfiable Boolean formula }. Cook-Levin theorem links the complexity of SAT problem to complexities of all problems in NP. kr chowdhary TOC 8/ 16

Polynomial reduction Polynomial time reducibility: If problem A reduces to problem B, then solution of B can be used to solve A. 1. Definition: A function f :Σ Σ is polynomial time computable if some polynomial TM M, which when started with input w, halts with f(w) on tape. 2. Definition: Language A is polynomial reducible to lang. B, expressed as A P B, if a polynomial function f such that f :Σ Σ for every w A f(w) B. 3. To test whether w A, we use the reduction f to map w to f(w) and then test whether f(w) B? 4. If one language is polynomial time reducible to a language already known to have polynomial time solution, we obtain a polynomial solution to original. kr chowdhary TOC 9/ 16

Polynomial reduction Theorem If A P B and B P, then A P. Proof. Let M be polynomial time algorithm deciding B, and f be polynomial time reduction from A to B. We describe polynomial time algorithm for M for A as follows: M = Input w, step 1. compute f(w) on TM R (reducer for f), step 2. Run M on input f(w)., M is polynomial because each of above steps are polynomial (Note: Composition of two polynomial functions is polynomial). kr chowdhary TOC 10/ 16

NP-Complete and NP-Hard Definition: NP-Complete: A language B is NP-complete if it satisfies two-conditions: (1) B NP, (2) Every A NP is polynomial time reducible to B, i.e., B NP A:A NP A P B B NP-Complete. A language Q is NP-hard if every L NP is polynomially reducible to Q. L:L NP L P Q Q NP hard. The NP-hard problem that is also NP is called NP-complete. Co-NP is complement of NP,, Co-NP is set of all the complements of all the NP problems. kr chowdhary TOC 11/ 16

NP-Complete Theorem Theorem If B is NP-Complete and B P, then P =NP. Proof. If B is NP-Complete then every problem in NP is polynomially reducible to B. Since B P,, every NP problem is polynomially reducible to to B, which is P. Hence, every NP is P, i.e. P = NP. Once we get NP-Complete, other NP problems can be reduced to it. However, establishing first NP-Complete problem is difficult. kr chowdhary TOC 12/ 16

NP-Complete Theorem Theorem If B NP-Complete and B P C for C NP, then C NP-Complete. Proof. We must show that every A NP is polynomially reducible to C. Because B is NP-Complete,, every A NP is polynomially reducible to B. (as per property of NP-Complete). And B in turn is polynomially reducible to C (given). Because the property of polynomial is closed under the composition, We conclude that every A NP is polynomially reducible to C. Therefore C is NP-Complete. kr chowdhary TOC 13/ 16

Cook-Levin Theorem Theorem SAT is NP-Complete. Proof. Proof Idea: It is easy to show that SAT is NP, the hard part is to show that any language in NP is polynomially reducible to SAT., we construct a polynomial time reduction for every A NP to SAT. Reduction for a language A takes input w and produces Boolean formula φ that simulates the NP machine for A on input w. If machine accepts, φ has a satisfying assignment, that corresponds to accepting computation, otherwise NO., w A iff φ is satisfiable. NP-Complete problems: 3-SAT, Hamiltonian path problem, subset construction problem. kr chowdhary TOC 14/ 16

Space - Complexity S(n): The function S(n) is called space constructible if there exists an S(n) space-binded Det. TM that for each input w =n requires exactly S(n) space.,s(n)= Space complexity of a Det. Turing Machine. DSPACE(S(n)): class of languages that have deterministic space complexity of O(S(n)). PSPACE: The class of membership problems for the languages decidable in polynomial space on deterministic TM: PSPACE = k DSPACE(n k ) class machine Space constraint DSPACE(f(n)) DTM f(n) L DTM O(log n ) PSPACE DTM poly(n) EXPSPACE DTM 2 poly(n) NSPACE(f(n)) NDTM f(n) NL NDTM poly(n) NEXPSPACE NDTM 2 poly(n) kr chowdhary TOC 15/ 16

Space - Complexity DSPACE(f(n))={L L is decidable by O(f(n)) space on DTM}. NSPACE(f(n))={L L is decidable by O(f(n)) space on NDTM} Savitch s Theorem: If a NDTM uses f(n) space, it can be converted into a DTM that uses f 2 (n) space. As per Savitch s theorem: PSPACE = NSPACE, EXPSPACE = NEXPSPACE. For NDTM, if f(n) is maximum number of tape-cells scan in any branch of computation, then its complexity if f(n). SAT which is NP Complete in time, is linear space. (because is reusable). PSPACE =NSPACE, P PSPACE. NP NSPACE,,NP PSPACE.,P NP PSPACE =NPSPACE EXPTIME. P NP PSPACE NPSPACE EXPTIME kr chowdhary TOC 16/ 16