BU CS 332 – Theory of Computation
Lecture 19:
- More on P
- Nondeterministic time, NP
Reading: Sipser Ch 7.2‐7.3
Mark Bun April 8, 2020
BU CS 332 Theory of Computation Lecture 19: Reading: More on P - - PowerPoint PPT Presentation
BU CS 332 Theory of Computation Lecture 19: Reading: More on P Sipser Ch 7.2 7.3 Nondeterministic time, NP Mark Bun April 8, 2020 First topic: Time complexity Last time: Answering the basic questions 1. How do we measure complexity?
Reading: Sipser Ch 7.2‐7.3
Mark Bun April 8, 2020
Last time: Answering the basic questions
measuring complexity?
notion of “efficient algorithms”?
4/8/2020 CS332 ‐ Theory of Computation 2
Let A TM runs in time if on every input
,
halts on within at most steps is a class (i.e., set) of languages: A language if there exists a basic single‐ tape (deterministic) TM that 1) Decides , and 2) Runs in time
4/8/2020 CS332 ‐ Theory of Computation 3
4/8/2020 CS332 ‐ Theory of Computation 4
Definition: is the class of languages decidable in polynomial time on a basic single‐tape (deterministic) TM
reasonable deterministic model (Extended Church‐Turing)
are feasible to solve on computers
4/8/2020 CS332 ‐ Theory of Computation 5
We’ll still use the notation for “any reasonable” encoding of the input to a TM…but now we have to be more careful about what we mean by “reasonable” How long is the encoding of a ‐vertex graph… … as an adjacency matrix? … as an adjacency list? How long is the encoding of a natural number … in binary? … in decimal? … in unary?
4/8/2020 CS332 ‐ Theory of Computation 6
high‐level descriptions on multi‐tape machines
executions of ‐time subroutines run on ‐ size inputs gives an algorithm running in time. => Can freely use algorithms we’ve seen before as subroutines if we’ve analyzed their runtime
represented in binary unless otherwise stated.)
4/8/2020 CS332 ‐ Theory of Computation 7
𝐻, 𝑡, 𝑢 𝐻 is a directed graph with a directed path from 𝑡 to 𝑢
𝐸 𝐸 is a DFA that recognizes the empty language
4/8/2020 CS332 ‐ Theory of Computation 8
CS332 ‐ Theory of Computation 9
2006 Gödel Prize citation The 2006 Gödel Prize for outstanding articles in theoretical computer science is awarded to Manindra Agrawal, Neeraj Kayal, and Nitin Saxena for their paper "PRIMES is in P." In August 2002 one of the most ancient computational problems was finally solved….
Consider the following algorithm for On input For : Try to divide by If divides , accept If all fail to divide , reject How many divisions does this algorithm require in terms
?
4/8/2020 CS332 ‐ Theory of Computation 10
Theorem: Every context‐free language is in Chomsky Normal Form for CFGs:
Lemma: Any CFG can be converted into an equivalent CFG in Chomsky Normal Form Lemma: If is in Chomsky Normal Form, any nonempty string w that can be derived from has a derivation with at most steps
4/8/2020 CS332 ‐ Theory of Computation 11
Theorem: Every context‐free language is in Proof attempt: Let be a CFL with a CFG in Chomsky Normal
recognizing : On input : (Let )
steps
What is the running time of this algorithm? A better idea: Use dynamic programming ‐ Identify subproblems ‐ Record solutions to subproblems in a table ‐ Solve bigger subproblems by combining solutions to smaller subproblems
4/8/2020 CS332 ‐ Theory of Computation 12
4/8/2020 CS332 ‐ Theory of Computation 13
4/8/2020 CS332 ‐ Theory of Computation 14
Problem Description Algorithm Yes No MULTIPLE Is x a multiple of y? Grade school division 51, 17 51, 16 RELPRIME Are x and y relatively prime? Euclid (300 BCE) 34, 39 34, 51 PRIMES Is x prime? AKS (2002) 53 51 all CFLs (e.g. the language of balanced parentheses and brackets) Is a given string in a fixed CFL? (E.g., is the string of parentheses and brackets balanced?) Dynamic programming Depends on the language; e.g. (([])[]) Depends on the language; e.g. ([)], (() LSOLVE Is there a vector x that satisfies Ax = b? Gauss-Edmonds elimination 2 1 4 3 1 2 15 , 2 4 36 1 1 1 1 1 1 , 1 1 1
Definition: is the class of languages decidable in exponential time on a basic single‐tape (deterministic) TM
CS332 ‐ Theory of Computation 15
4/8/2020 CS332 ‐ Theory of Computation 16
Let A NTM runs in time if on every input
,
halts on within at most steps on every computational branch
4/8/2020 CS332 ‐ Theory of Computation 17
4/8/2020 CS332 ‐ Theory of Computation 18
Deterministic Nondeterministic
accept or reject reject accept
𝒖𝒐
reject accept reject
4/8/2020 CS332 ‐ Theory of Computation 19
𝑥 𝑥 𝑥 𝑥 Finite control 𝑥 ⊔ # 𝑥 𝑥 1 3 3 7 Input 𝑥 to 𝑂 (read‐only) Simulation tape (run 𝑂 on 𝑥 using nondeterministic choices from tape 3) Address in computation tree
Theorem: Let be a function. Every NTM running in time has an equivalent single‐tape TM running in time Proof: Simulate NTM by 3‐tape TM
4/8/2020 CS332 ‐ Theory of Computation 20
Theorem: Let be a function. Every NTM running in time has an equivalent single‐tape TM running in time Proof: Simulate NTM by 3‐tape TM
Running time: To simulate one root‐to‐node path: Total time:
input simulation address
4/8/2020 CS332 ‐ Theory of Computation 21
Theorem: Let be a function. Every NTM running in time has an equivalent single‐tape TM running in time Proof: Simulate NTM by 3‐tape TM in time We know that a 3‐tape TM can be simulated by a single‐ tape TM with quadratic overhead, hence we get running time
= · =