18.404/6.
840 Lecture 14
(midterm replaced lecture 13)
Last time:
- TIME
-P
-
Today: (Sipser §7.2 – §7.3)
- NTIME
- NP
- P vs NP problem
- Dynamic Programming
- Polynomial-time reducibility
1
Quick Review
Defn: TIMEsome deterministic 1-tape TM decides
and runs in time
Defn: P
polynomial time decidable languages
is a directed graph with a path from to
Theorem:
𝐺
is a directed graph with a path from to
𝑠 𝑡
that goes through every node of
? Unsolved Problem
[connection to factoring]
2
Nondeterministic Complexity
In a nondeterministic TM (NTM) decider, all branches halt on all inputs.
Defn: An NTM runs in time if all branches halt within steps on all
inputs of length .
Defn: NTIME𝐵| some 1-tape NTM decides 𝐵
Computation tree
for NTM on input .
and runs in time }
Defn: NP
nondeterministic polynomial time decidable languages 𝑡 ( 𝑛)
...
• Invariant for all reasonable nondeterministic models
• Corresponds roughly to easily verifiable problems
all branches halt
within steps
3
NP
Computation of
M on
Theorem: NP
Proof: Guess
“On input (Say has nodes.) bits of
1. Nondeterministically write a ⋮
sequence
Guess
of nodes.
⋮ bits of
2. Accept if
⋮
each is an edge Guess
and no repeats. bits of
⋮
3. Reject if any condition fails.”
⋯ Check
works
c/ rej c/ rej
ac ac
4
NP
Defn: is not prime and is written in binary}
for integers , in binary}
Theorem: NP
Proof: “On input
1. Nondeterministically write where .
2. Accept if divides with remainder .
Reject if not.”
Note: Using base 10 instead of base 2 wouldn’t matter because can
convert in polynomial
Bad encoding: writetime.
number in unary: , exponentially longer.
Theorem (2002): P
We won’t cover this proof.
5
Intuition for P and NP
NP = All languages where can verify membership quickly
P = All languages where can test membership quickly
Examples of quickly verifying membership:
- : Give the Hamiltonian path.
- : Give the factor.
The Hamiltonian path and the factor are called short certificates of membership.
P NP
Check-in
Question: 14.1
P = NP? Famous unsolved problem (Cook 1971). P NP
Let be the complement
Conjecture: of . problems are NP and not in P.
P ≠ NP. Some
So
Hardif to
does notthe
prove have a Hamiltonian
conjecture path
because from to .
polynomial-time algorithms are powerful.
Is NP?
Example: Show P.
(a) Yes, we can invert the accept/reject output of the NTM for .
(b) No, we cannot give a short certificate for a graph not to have a Hamiltonian path.
(c) I don’t know.
6 Check-in 14.1
Recall
Recall:
Theorem: is decidable
Proof: “On input Chomsky Normal Form (CNF):
1. Convert into Chomsky Normal Form. A BC
2. Try all derivations of length . B b
3. Accept if any generate . Reject if not. Let’s always assume is in CNF.
Theorem: NP
Proof: “On input
4. Nondeterministically pick some derivation of length .
5. Accept if it generates . Reject if not.
7
Attempt to show P
Theorem: P
Proof attempt:
Recursive algorithm tests if generates , starting at any specified variable R.
“On input
1. For each way to divide and for each rule R ST
2. Use to test and R
3. Accept if both accept
4. Reject if none of the above accepted.”
Then decide by starting from ’s start variable. S T
is a correct algorithm, but it takes non-polynomial time.
(Each recursion makes calls and depth is roughly .)
Fix: Use recursion + memory called Dynamic Programming (DP)
Observation: String of length has substrings 𝑥 𝑦
therefore there are only possible sub-problems to solve. 𝑤
8
DP shows P
Theorem: P
Proof : Use DP (Dynamic Programming) = recursion + memory.
“On input “memoization”
0.
1. If
Forpreviously
each waysolved then
to divide answer
and same,
for each ruleelse
R STcontinue.
2. Use to test and
3. Accept if both accept same as before R
4. Reject if none of the above accepted.”
Then decide by starting from G’s start variable.
S T
Check-in 14.2
Total number of calls is so time used is polynomial. Suppose is a CFL.
Alternately, solve all smaller sub-problems first: “bottom up” Does that imply that P?
(a) Yes
𝑥 𝑦
(b) No.
𝑤
9 Check-in 14.2
P & Bottom-up DP
Theorem: P
Proof : Use bottom-up DP.
“On input
1. For each and variable R Solve for substrings
of length 1
Solve by checking if R is a rule.
2. For and each substring of where and variable R Solve for substrings of length
Solve by checking for each R ST and each division by using previous answers for
if both and were positive. substrings of length .
3. Accept if is positive where S is the original start variable.
4. Reject if not.”
Total number of calls is so time used is polynomial.
Often, bottom-up DP is shown as filling out a table.
10
Satisfiability Problem
Defn: A Boolean formula has Boolean variables
(TRUE/FALSE values)
and Boolean operations AND (), OR (), and NOT ().
Defn: is satisfiable if evaluates to TRUE for some assignment to
its variables.
Sometimes we use 1 for True and 0 for False.
Example: Let (Notation: means )
Check-in 14.3
Then is satisfiable (x=1, y=0)
Is NP?
Defn: is a satisfiable Boolean formula}
(a) Yes.
Theorem (Cook, Levin 1971): P P = NP (b) No.
Proof method: polynomial time (mapping) reducibility
(c) I don’t know.
(d) No one knows.
11
Check-in 14.3
Polynomial Time Reducibility
Defn: is polynomial time reducible to () if
by a reduction function that is computable in polynomial time.
Theorem: If and P then P.
𝐴 𝑓 𝐵
NP is computable in polynomial time
𝑆𝐴𝑇
cog ni zable
T-re
P ≤P 𝐴 TM
decidable ≤m
Idea to show P P = NP
Analogy with
12
Quick review of today
1. NTIME and NP
2. and NP
3. P versus NP question
4. P via Dynamic Programming
5. The Satisfiability Problem
6. Polynomial time reducibility
13
MIT OpenCourseWare
https://ocw.mit.edu
18.404J Theory of Computation
Fall 2020
For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.