חישוביות וסיבוכיות Computability and Complexity Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AAAA.

Slides:



Advertisements
Similar presentations
Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
Advertisements

1 Nondeterministic Space is Closed Under Complement Presented by Jing Zhang and Yingbo Wang Theory of Computation II Professor: Geoffrey Smith.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
The class NP Section 7.3 Giorgi Japaridze Theory of Computability.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Lecture 21 Nondeterministic Polynomial time, and the class NP FIT2014 Theory of Computation Monash University Faculty of Information Technology Slides.
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.2: Variants of Turing Machines) David Martin With.
The diagonalization method The halting problem is undecidable Decidability.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
P and NP Sipser (pages ). CS 311 Fall Polynomial time P = ∪ k TIME(n k ) … P = ∪ k TIME(n k ) … TIME(n 3 ) TIME(n 2 ) TIME(n)
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 )
More Turing Machines Sipser 3.2 (pages ). CS 311 Fall Multitape Turing Machines Formally, we need only change the transition function to.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
More Turing Machines Sipser 3.2 (pages ).
Complexity ©D.Moshkovitz 1 Turing Machines. Complexity ©D.Moshkovitz 2 Motivation Our main goal in this course is to analyze problems and categorize them.
CS5371 Theory of Computation Lecture 11: Computability Theory II (TM Variants, Church-Turing Thesis)
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
CS 310 – Fall 2006 Pacific University CS310 P vs NP the steel cage death match Section 7.2 November 29, 2006.
Time Complexity.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture NP-Completeness Jan Maluszynski, IDA, 2007
January 28, 2015CS21 Lecture 101 CS21 Decidability and Tractability Lecture 10 January 28, 2015.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CS 461 – Nov. 21 Sections 7.1 – 7.2 Measuring complexity Dividing decidable languages into complexity classes. Algorithm complexity depends on what kind.
Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Computer Language Theory
CSCI 2670 Introduction to Theory of Computing November 23, 2004.
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.
Measuring complexity Section 7.1 Giorgi Japaridze Theory of Computability.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
Lecture 12 P and NP Introduction to intractability Class P and NP Class NPC (NP-complete)
Computability Heap exercise. The class P. The class NP. Verifiers. Homework: Review RELPRIME proof. Find examples of problems in NP.
NP-completeness Class of hard problems. Jaruloj ChongstitvatanaNP-complete Problems2 Outline  Introduction  Problems and Languages Turing machines and.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 7 Time complexity Contents Measuring Complexity Big-O and small-o notation.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 7 Time Complexity Some slides are in courtesy.
CS 461 – Nov. 18 Section 7.1 Overview of complexity issues –“Can quickly decide” vs. “Can quickly verify” Measuring complexity Dividing decidable languages.
Chapter 15 P, NP, and Cook’s Theorem. 2 Computability Theory n Establishes whether decision problems are (only) theoretically decidable, i.e., decides.
Lecture 24UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 24.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
Umans Complexity Theory Lectures Lecture 1b: Turing Machines & Halting Problem.
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.
Theory of Computational Complexity TA : Junichi Teruyama Iwama lab. D3
CSCI 2670 Introduction to Theory of Computing November 15, 2005.
 2005 SDU Lecture14 Mapping Reducibility, Complexity.
CSE 105 theory of computation
CSCI 2670 Introduction to Theory of Computing
Time complexity Here we will consider elements of computational complexity theory – an investigation of the time (or other resources) required for solving.
Part VI NP-Hardness.
Turing Machines Acceptors; Enumerators
COSC 3340: Introduction to Theory of Computation
Intractable Problems Time-Bounded Turing Machines Classes P and NP
Space Complexity Costas Busch - LSU.
CLASSES P AND NP.
CS21 Decidability and Tractability
CSC 4170 Theory of Computation The class NP Section 7.3.
CS154, Lecture 13: P vs NP.
CSC 4170 Theory of Computation Time complexity Section 7.1.
Turing Machines Complexity ©D.Moshkovitz.
CS21 Decidability and Tractability
Time Complexity Classes
CSC 4170 Theory of Computation The class NP Section 7.3.
Umans Complexity Theory Lectures
CSE 589 Applied Algorithms Spring 1999
Instructor: Aaron Roth
CSE 105 theory of computation
CSC 4170 Theory of Computation Time complexity Section 7.1.
Theory of Computability
Presentation transcript:

חישוביות וסיבוכיות Computability and Complexity Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A AAAA

Outline Last week: Time complexity The class P Today: Non-deterministic TM The class NP

Last Week: Time Complexity Definition: Let M be a TM that halts on all inputs. The time complexity of M is a function f:N  N, where f(n) is the maximum number of steps that M performs on any input of length n. Definition: Let t: N  R +. The complexity class TIME(t(n)), is the collection of all languages that are decidable by an O(t(n)) time Turing machine.

Complexity vs. Computability Computability: Church-Turing thesis “all reasonable models of computation are equivalent” Complexity: Choice of model may affect running time. Which model should we use to classify the time complexity of problems? Idea: choose a classification system that is not sensitive to relatively small differences in complexity.

Single and Multi-tape TM’s Theorem: Let t(n) be a function, where t(n)  n. Then every t(n)-time multiple TM has an equivalent O(t 2 (n))-time single-tape TMs. All reasonable (deterministic) computational models are polynomially equivalent.

The Class P Definition: P is the class of languages that are decidable in polynomial time on a deterministic single-tape TM. In other words,

Nondeterministic TM At any point in a computation the machine may proceed according to several possibilities.  : Q x   P(Q x  x {L,R}) Definition: A NTM accepts an input if there is a branch of computation that leads to the accept state.

The Computation Tree: Each node: represents a configuration. Each edge: a deterministic transition between two configurations. Each branch: a deterministic computation. The root: the initial configuration.

The Computation Tree On input w=010:  (q 0,0)=({q 1,1,R}, {q 1,0,R})  (q 1,1)=({q 1,1,R}, {q 1,0,R},{q 1,1,L})  (q 1,0)=({q 2,1,L}, {q 1,1,R}) q q q q 1 0 q q 1 0

Simulating an NTM with a DTM Theorem: Every non-deterministic TM has an equivalent deterministic TM. Note: No reference to running time. Proof:  Every deterministic TM is a special case of non deterministic TM.  Simulating a NTM N with a DTM D:

Construct a tree with all possible branches of the computation. Search on the tree for accept state. Using depth first search (DFS)? May not halt! Every node has a finite number of branches, but every branch can be infinitely long. Use breadth first search (BFS). Simulating an NTM with a DTM

Use 3 tapes: Input tape: contains the input. Simulation tape: maintains a copy of N’s tape on some non-deterministic branch. Address tape: keeps track of D’s location in N’s computation tree (‘performs’ the BFS).

The Address Tape: Encodes in a lexicographic order the branches of the computation tree _ _ _

1.Initially tape 1 contains w. Other tapes are empty. 2.Copy tape 1 to tape 2. 3.Use tape 2 to simulate N on one branch of its non deterministic computation determined by tape 3. 4.Replace the string with the lexicographically next string. Go back to 2. Simulating an NTM with a DTM

In stage 3: 1.Before each step - consult the next symbol on tape 3. 2.When should go directly to 4: a)If no more symbols remain on tape 3. b)If nondeterministic choice is ‘invalid’ c)In case of a reject configuration. Accept: if an accept configuration occurs.

Time Complexity of NTM Definition: Let N be a nondeterministic decider TM. The running time of N is the function f:N  N, where f(n) is the max. number of steps that N performs on any branch of its computation on any input of length n. Theorem: Let t(n) be a function, where t(n)  n. Then every t(n) time nondeterministic single-tape TM has an equivalent 2 O(t(n)) time deterministic single-tape TM.

reject accept Proof by Picture t(n) O(b t(n) ) b – max degree

Deterministic vs Non-deterministic Time Complexity Last week: at most polynomial difference between single-tape TM and multiple-tape TM. Today: at most exponential difference between deterministic single-tape TM and nondeterministic single-tape TM. Can we simulate NTM on DTM with only polynomial slowdown?

The PATH Problem Given two nodes, s and t, in a graph G, is there a directed path from s to t? PATH={ | G is a directed graph that has a directed path from s to t } Theorem: PATH  P c a d b s te

Hamiltonian Path A path in a directed graph G that goes through each node of G exactly once. HAMPATH={ |G is a directed graph with a Hamiltonian path from s to t} c a d b s te

Brute-Force Search for HAMPATH Given G with m nodes, and two nodes s, t: 1.Go over all permutations of the nodes in G. 2.For each permutation verify whether it is a Hamiltonian path that starts with s and ends with t. Number of possible paths m! = θ (m m ) => Exponential complexity

Polynomial Verifiability Finding a Hamiltonian path seems to be hard. However, given a path, it is possible to verify that it is Hamiltonian in polynomial time. c a d b s te

Another Example: Compositeness A natural number is composite if it is a product of two integers greater than 1. COMPOSITES = {x | x=pq, for integers p,q>1} COMPOSITES can be verified in poly-time: any divisor of x can serve as a certificate.

Are all problems Verifiable in Polynomial Time? HAMPATH – complement of HAMPATH: determine whether a graph does not have a Hamiltonian path. But how can you verify nonexistence of something? Seems like we must go over all paths… It is unknown whether HAMPATH can be verified in polynomial time.

Verifier for a Language Definition: A verifier for a language A is an algorithm V, where A = {w |  string c s.t. V accepts } V’s running time is measured in terms of |w| A is polynomially verifiable if it has a poly-time V c is the certificate or proof of membership in A V can verify that w is in A, given a certificate, c

The Class NP Definition: NP is the class of languages that have a polynomial time verifier. NP is an important class: 1.Contains problems of practical interest, such as HAMPATH and COMPOSITES (we’ll see many more). 2.Captures the notion of efficiently verifiable ‘proof’ (we may try and use it to model abstract things such as ‘creativity’). 3.Related to THE central open question in computer science (is P equal to NP?).

NP: Non-deterministic Poly-time Example: Nondeterministic TM that decides HAMPATH N 1 = “On input 1.Write a list of m numbers, p 1,…p m, where m is the number of nodes in G. (Nondeterministic) 2.Check for repetitions in the list – if exists reject. 3.Check that s=p 1 and t=p m if not- reject. 4.For 1  i<m, check that all (p i,p i+1 ) are edges in G. If not reject, otherwise, accept.” Note: N 1 runs in polynomial time.

NP – Alternative Definition Theorem: A language is in NP iff it can be decided by some non-deterministic polynomial time TM. Corollary: Any language in NP can be decided in exponential time (why?). Proof idea (of theorem):  NTM simulates verifier by guessing the certificate.  Verifier simulates NTM by using the accepting branch of the NTM.

Let A  NP and let V be a polynomial time verifier for A. The following NTM N decides A in polynomial time. N = “On input w of length n. 1.Non-deterministically select string c of length ≤ n k. 2.Run V on input. 3.If V accepts, accept; Otherwise, reject.” Proof: First Direction

Assume that A is decided by a polynomial time NTM N. The following V is a polynomial time verifier. V = “ On input. 1.Simulate N on input w (c is the choices made along the nondeterministic computation of N). 2.If this branch of N’s computation accepts, accept; Otherwise, reject. Proof: Second Direction

Non-deterministic Time Complexity Definition: Let t: N  R +. The time complexity class NTIME(t(n)), is the collection of all languages that are decidable by an O(t(n)) time non-deterministic Turing machine. NTIME(t(n)) = {L | L is a language decided by a O(t(n)) time non-deterministic TM}

Example of a Problem in NP: CLIQUE A clique in an undirected graph is a subgraph for which every two nodes are connected. CLIQUE={ |G is undirected graph with a k-clique} 4-clique 2-clique

Theorem: CLIQUE ∈ NP. Proof 1: We construct a polynomial-time verifier V for CLIQUE. V = “On input,c> 1.Test whether c is a set of k nodes in G. 2.Test whether G contains all edges connecting nodes in c. 3.If both pass, accept; Otherwise, reject. “ CLIQUE is in NP

Proof 2: We construct a polynomial NTM N that decides CLIQUE. N = “On input 1.Non-deterministically select subset c of k nodes in G. 2.Test if G contains all edges connecting nodes in c. 3.If yes, accept; Otherwise, reject.” CLIQUE is in NP: Alternative Proof

Example II: SUBSET-SUM X = {x 1,…,x k } – a collection of numbers (with repetitions) t – a target number is there a subset of the collection that adds up to t? Example: ∈ SUBSET-SUM because = 25

Theorem: SUBSET-SUM ∈ NP. Proof 1: We construct a polynomial-time verifier V for SUBSET-SUM. V = “On input,c> 1.Test whether c is a collection of numbers that sum to t. 2.Test whether S contains all numbers in c. 3.If both pass, accept; Otherwise, reject. “ SUBSET-SUM is in NP

Proof 2: We construct a polynomial NTM N that decides SUBSET-SUM. N = “On input 1.Non-deterministically select subset c of numbers in S. 2.Test if c is a collection of numbers that sum to t. 3.If yes, accept; Otherwise, reject.” SUBSET-SUM is in NP: Alternative Proof

Question: What about CLIQUE and SUBSET-SUM? As with HAMPATH, we do not know if they are in NP. These languages belong to coNP – languages whose complement is in NP. We do not know whether coNP is different from NP. coNP

P vs. NP P = class of languages where membership can be decided in polynomial time (quickly). NP = class of languages where membership can be verified in polynomial time (quickly).

P = NP ? P NP NP=P ? One of the greatest unsolved problems in theoretical Computer Science and Mathematics Best known method -- brute force:

עיתון הארץ