SlideShare a Scribd company logo
CSE 135: Introduction to Theory of
Computation P, NP, and NP-
completeness
Sungjin Im
University of California,
Merced
04-23-2015
Significance of P ƒ=? NP
Perhaps you have heard of (some of) the following
terms: P, NP, NP-complete, NP-hard.
And the famous question if P = NP or not.
Significance of P ƒ=? NP
Why do we care about P ƒ=?
NP?
Significance of P ƒ=? NP
Why do we care about P ƒ=? NP?
› A central question in computer science and
mathematics.
Significance of P ƒ=? NP
Why do we care about P ƒ=? NP?
› A central question in computer science and
mathematics.
› A lot of practical implications.
Significance of P ƒ=? NP
Why do we care about P ƒ=? NP?
› A central question in computer science and mathematics.
› A lot of practical implications.
› P and NP problems are widely found in practice.
Significance of P ƒ=? NP
The Millennium Prize Problems are seven problems in
mathematics that were stated by the Clay Mathematics
Institute in 2000. As of April 2015, six of the problems remain
unsolved. A correct solution to any of the problems results in
a US $1,000,000 prize (sometimes called a Millennium Prize)
being awarded by the institute. The Poincare conjecture was
solved by Grigori Perelman, but he declined the award in
2010.
The question P ƒ=? NP is the first in the list... (source:
wikipedia)
Class P
Formal definition
Definition
P is the class of languages that are decidable in polynomial
time on a deterministic single-tape Turing machine. In other
words,
P =
[
Time(nk
)
k
Motivation: To define a class of problems that can be solved
efficiently.
› P is invariant for all models of computation that are
polynomially equivalent to the deterministic single-tape Turing
Machine.
› P roughly corresponds to the class of problems that are
Class P
Justification
P is invariant for all models of computation that are
polynomially equivalent to the deterministic single-tape
Turing Machine.
Example.
Theorem
Let t(n) be a function, where t(n) ≥ n. Then every t(n) time
multitape Turing machine has an equivalent O(t2(n)) time
single-tape Turing machine.
In fact, it can be shown that all reasonable deterministic
computational models are polynomially equivalent.
Class P
Formal definition
Definition
P is the class of languages that are decidable in polynomial
time on a deterministic single-tape Turing machine. In
other words,
P =
[
Time(nk
)
k
Hence, a language is in P if and only if one can write a
pseudo-code that decides the language in polynomial time
in the input length; the code must terminate for any input.
Class P
Example
PATH =
{(G, s, t) | G is a directed graph that has a directed path from s
to t}.
Class P
Less formal definition of P
Definition
P is the set of decision problems that can be solved in
polynomial time (in the input size).
22
Examples of polynomial time: O(n), O(log n), O(n100), O(n22
).
Class P
Less formal definition of P
Definition
P is the set of decision problems that can be solved in
polynomial time (in the input size).
22
Examples of polynomial time: O(n), O(log n), O(n100), O(n22
).
From now on, we will use this less formal and simpler
definition of
P.
Simple description of decision problems
Problem PATH:
Input: an directed graph G , and two distinct nodes s and t in
G . Question: Does G has a directed path from s to t?
In the remainder of this course, we will adopt this simple
description of decision problems over languages.
Simple description of decision problems
Problem PATH:
Input: an directed graph G , and two distinct nodes s and t in
G . Question: Does G has a directed path from s to t?
In the remainder of this course, we will adopt this simple
description of decision problems over languages.
A yes-instance is an instance where the answer is yes. No-
instance is similarly defined.
Class NP
Example
Problem HAMPATH:
Input: an directed graph G , and two distinct nodes s and t in
G . Question: Does G have a Hamiltonian path from s to t?
A Hamiltonian path in a directed graph G is a directed path
that visits every node exactly once.
Class NP
Example
Problem HAMPATH:
Input: an directed graph G , and two distinct nodes s and t in
G . Question: Does G have a Hamiltonian path from s to t?
A Hamiltonian path in a directed graph G is a directed path
that visits every node exactly once.
We are not aware of any algorithm that solves HAMPATH in
polynomial time. But we know a brute-force algorithm finds a
s-t Hamiltonian path in exponential time. Also we can
verify/check if a given path is a s-t Hamiltonian path or not.
Class NP
Example
We do not know how to answer in polynomial time if a given
instance is a yes-instance or not. However, if it is a yes-
instance, there is a proof I can easily check (in polynomial
time). A s-t Hamiltonian path of the instance can be such a
‘proof’. Once we are given this proof, we can check in
polynomial time if the instance is indeed a yes-instance
Class NP
Formal definition
Definition
A verifier for a language A is an algorithm V , where
A = {w | V accepts < w, c > for some string c}
(c is called a certificate or proof).
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.
Note that a polynomial time verifier A can only read a
certificate of size polynomial in |w|; so c must have size
polynomial in |w|.
Class NP
Formal definition
Definition
NP is the class of languages that have polynomial time
verifiers.
Class NP
Formal definition
Class NP
Formal definition
The term NP comes from nondeterministic polynomial time and
has an alternative characterization by using nondeterministic
polynomial time Turing machines.
Theorem
A language is in NP iff it is decided by some nondeterministic
polynomial time Turing machine.
Proof.
(⇒) Convert a polynomial time verifier V to an equivalent
polynomial time NTM N. On input w of length n:
› Nondeterministically select string c of length at most nk
(assuming that V runs in time nk ).
› Run V on input < w, c >.
› If V accepts, accept; otherwise, reject.
Class NP
Formal definition
Theorem
A language is in NP iff it is decided by some nondeterministic
polynomial time Turing machine.
Proof.
(⇐) Convert a polynomial time NTM N to an equivalent
polynomial time verifier V . On input w of length n:
› Simulate N on input w , treating each symbol of c as a
description of the nondeterministic choice to make at each
step.
› If this branch of N’s computation accepts, accept; otherwise,
reject.
Q
Class NP
Examples
A clique in an undirected graph is a subgraph, wherein every
two nodes are connected by an edge. A k -clique is a clique
that contains k nodes.
CLIQUE = {< G, k > | G is an undirected graph with a k
-clique}
Lemma
CLIQUE is in NP.
Proof.
Let w =< G, k >. The certificate c is a k -clique. We can
easily test if c is a clique in polynomial time in w and c , and
has k nodes. Q
Class NP
Examples
HAMPATH = {< G, s, t >
| G is a directed graph with a Hamiltonian path from s to t}.
Lemma
HAMPATH is in NP.
Simple definition of P
From now on, we will use the following simpler definition of
P.
Definition
P is the set of decision problems that can be solved in
polynomial time (in the input size).
22
Examples of polynomial time: O(n), O(log n), O(n100), O(n22
),
etc.
Class NP
Less formal definition
From now on, we will use the following simpler definition of
NP.
Definition
NP is the set of decision problems with the following
property: If the answer is Yes, then there is a proof of this
fact that can be checked in polynomial time.
(The size of the proof must be polynomially bounded by n).
Class NP
Example
Problem CLIQUE :
Input: an undirected graph G and an integer k ≥ 1.
Question: Does G have a k -clique?
A clique in an undirected graph is a subgraph, wherein every
two nodes are connected by an edge. A k -clique is a clique
that contains k nodes.
Proposition
CLIQUE is in NP.
Proof.
The certificate is a set of k vertices that form a clique which
can be checked in polynomial time. Q
Class NP
Example
Problem HAMPATH:
Input: an directed graph G , and two distinct nodes s and t in G
. Question: Does G have a Hamiltonian path from s to t?
Proposition
HAMPATH is in NP.
Proof.
Consider any yes-instance. The certificate is the following: a
Hamiltonian path from s to t which must exist from the
definition of the problem, and can easily be checked in
polynomial time. Q
P ⊆ NP
Think about any decision problem A in the class P. Why is it
in
NP?
P ⊆ NP
Think about any decision problem A in the class P. Why is it
in
NP?
In other words, if an input/instance is a Yes-instance, how
can we check it in polynomial time? We can solve the
problem from scratch in polynomial time. No certificates are
needed.
P ⊆ NP
Think about any decision problem A in the class P. Why is it
in
NP?
In other words, if an input/instance is a Yes-instance, how
can we check it in polynomial time? We can solve the
problem from scratch in polynomial time. No certificates are
needed.
For example, think about the probelm PATH.
NP ⊆ EXP
Here, EXP is the class of problems that can be
solved in exponential time.
NP ⊆ EXP
Here, EXP is the class of problems that can be
solved in exponential time.
Think about any decision problem A in the class NP.
NP ⊆ EXP
Here, EXP is the class of problems that can be solved in
exponential time.
Think about any decision problem A in the class NP. If a
yes-instance has a ‘short’ certificate. We can try each
certificate (by brute force). So the checking can be done in
exponential time.
NP ⊆ EXP
Here, EXP is the class of problems that can be solved in
exponential time.
Think about any decision problem A in the class NP. If a
yes-instance has a ‘short’ certificate. We can try each
certificate (by brute force). So the checking can be done in
exponential time.
For example, think about CLIQUE or HAMPATH.
P vs. NP ?
Either of the following two must be true:
P = NP or P Ç NP.
We know that NP ⊆ EXP, but we do not even know if NP = EXP
or NP Ç EXP
NP-completeness
Cook-Levin Theorem
Most researchers, however, believe that P ƒ= NP becuase of
the existence of some problems that capture the entire NP
class.
Problem Satisfiability (SAT): Input: a boolean formula Φ.
Question: is Φ satisfiable?
A Boolean formula is an expression involving Boolean variables and
operations. For example, Φ = (x¯ ∧ y ) ∨ (x ∧ z¯) is a boolean
formula. We say a boolean formula is satisfiable if some assignment
of 0s and 1s to the variables makes the formula evaluate to 1. Note
that Φ is satisfiable (x = 0, y = 1, z = 0).
Theorem (Cook-Levin Theorem)
SAT ∈ P iff P = NP.
NP-completeness
Polynomial Time Reducibility
There are two different types of reductions: Turing reduction
vs. Karp reduction. For simplicity, in this course we will only
focus on Turing reduction. See Section 30.4 in Jeff
Erickson’s note for the difference.
Definition
We say that problem A is polynomial-time reducible to
problem B if we can solve problem A in polynomial time using
a (possibly hypothetical) polynomial time algorithm for
problem B as a black box. This is often denoted as A ≤p B.
For simplicity, sometimes, we say that A is reducible to B, and
denote it as A ≤ B.
NP-completeness
NP-hardness
Definition
We say that problem B is NP-hard if for every A in NP, A ≤P B.
NP-completeness
NP-hardness
Theorem
If A ≤P B and B ∈ P, then A ∈ P.
NP-completeness
NP-hardness
Theorem
If A ≤P B and B ∈ P, then A ∈ P.
Proof.
Immediately follows from the definition of ≤p . Q
NP-completeness
Definition
Definition
A language B is NP-complete if it is NP-hard and is in
NP.
NP-completeness
Definition
Definition
A language B is NP-complete if it is NP-hard and is in NP.
Theorem
If B is NPC (NP-complete) and B ∈ P, then P = NP.
Proof.
We already know P ⊆ NP. So it suffices to show NP ⊆ P.
NP-completeness
Definition
Definition
A language B is NP-complete if it is NP-hard and is in
NP.
Theorem
If B is NPC (NP-complete) and B ∈ P, then P = NP.
Proof.
We already know P ⊆ NP. So it suffices to show NP ⊆ P.
Consider any problem A in NP. By definition of NP-
hardness, A ≤p B. Since B is in P, it implies A is in P.
Q
NP-completeness
Let’s say that B ∈ NPC if B is NP-complete.
Theorem
A language C is NP-complete if B ≤P C for some B ∈ NPC, and
C ∈ NP.
Similarly,
Theorem
A language C is NP-hard if B ≤P C for some NP-hard language
B.
NP-completeness
Cook-Levin Theorem
Theorem
SAT is NP-
complete.
NP-completeness
NPC derivation tree
Theorem
SAT is
NP-
complete.

More Related Content

What's hot

Introduction to NP Completeness
Introduction to NP CompletenessIntroduction to NP Completeness
Introduction to NP Completeness
Gene Moo Lee
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
Jyotsna Suryadevara
 
lecture 29
lecture 29lecture 29
lecture 29sajinsc
 
P versus NP
P versus NPP versus NP
P versus NP
Farid El Hajj
 
A comprehensive view on P vs NP
A comprehensive view on P vs NPA comprehensive view on P vs NP
A comprehensive view on P vs NP
Abhay Pai
 
P vs NP
P vs NP P vs NP
P vs NP
Mikel Qafa
 
Np completeness
Np completenessNp completeness
Np completeness
Muhammad Saim
 
Np completeness-Design and Analysis of Algorithms
Np completeness-Design and Analysis of Algorithms Np completeness-Design and Analysis of Algorithms
Np completeness-Design and Analysis of Algorithms
adeel990
 
NP Complete Problems in Graph Theory
NP Complete Problems in Graph TheoryNP Complete Problems in Graph Theory
NP Complete Problems in Graph Theory
Seshagiri Rao Kornepati
 
Algorithm_NP-Completeness Proof
Algorithm_NP-Completeness ProofAlgorithm_NP-Completeness Proof
Algorithm_NP-Completeness Proof
Im Rafid
 
Daa notes 3
Daa notes 3Daa notes 3
Daa notes 3
smruti sarangi
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10chidabdu
 
NP Complete Problems
NP Complete ProblemsNP Complete Problems
NP Complete Problems
Nikhil Joshi
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
Animesh Chaturvedi
 
Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Traian Rebedea
 
NP completeness
NP completenessNP completeness
NP completeness
Amrinder Arora
 
lecture 30
lecture 30lecture 30
lecture 30sajinsc
 

What's hot (20)

Introduction to NP Completeness
Introduction to NP CompletenessIntroduction to NP Completeness
Introduction to NP Completeness
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
Np complete
Np completeNp complete
Np complete
 
lecture 29
lecture 29lecture 29
lecture 29
 
P versus NP
P versus NPP versus NP
P versus NP
 
A comprehensive view on P vs NP
A comprehensive view on P vs NPA comprehensive view on P vs NP
A comprehensive view on P vs NP
 
P vs NP
P vs NP P vs NP
P vs NP
 
Np completeness
Np completenessNp completeness
Np completeness
 
Np completeness-Design and Analysis of Algorithms
Np completeness-Design and Analysis of Algorithms Np completeness-Design and Analysis of Algorithms
Np completeness-Design and Analysis of Algorithms
 
NP Complete Problems in Graph Theory
NP Complete Problems in Graph TheoryNP Complete Problems in Graph Theory
NP Complete Problems in Graph Theory
 
Algorithm_NP-Completeness Proof
Algorithm_NP-Completeness ProofAlgorithm_NP-Completeness Proof
Algorithm_NP-Completeness Proof
 
Daa notes 3
Daa notes 3Daa notes 3
Daa notes 3
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
NP Complete Problems
NP Complete ProblemsNP Complete Problems
NP Complete Problems
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6
 
Np hard
Np hardNp hard
Np hard
 
NP completeness
NP completenessNP completeness
NP completeness
 
AA ppt9107
AA ppt9107AA ppt9107
AA ppt9107
 
lecture 30
lecture 30lecture 30
lecture 30
 

Similar to Np completeness h4

class23.ppt
class23.pptclass23.ppt
class23.ppt
AjayPratap828815
 
UNIT-V.pdf daa unit material 5 th unit ppt
UNIT-V.pdf daa unit material 5 th unit pptUNIT-V.pdf daa unit material 5 th unit ppt
UNIT-V.pdf daa unit material 5 th unit ppt
JyoReddy9
 
UNIT-V.ppt
UNIT-V.pptUNIT-V.ppt
UNIT-V.ppt
rajinooka
 
lect5-1.ppt
lect5-1.pptlect5-1.ppt
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdf
T17Rockstar
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2
S.Shayan Daneshvar
 
Ads unit 3 ppt
Ads unit 3 pptAds unit 3 ppt
Ads unit 3 ppt
praveena p
 
Webinar : P, NP, NP-Hard , NP - Complete problems
Webinar : P, NP, NP-Hard , NP - Complete problems Webinar : P, NP, NP-Hard , NP - Complete problems
Webinar : P, NP, NP-Hard , NP - Complete problems
Ziyauddin Shaik
 
Design and analysis of algorithms unit 6 non deterministic polynomial
Design and analysis of algorithms unit 6 non deterministic polynomialDesign and analysis of algorithms unit 6 non deterministic polynomial
Design and analysis of algorithms unit 6 non deterministic polynomial
nowicam882
 
Why machines can't think (logically)
Why machines can't think (logically)Why machines can't think (logically)
Why machines can't think (logically)Andre Vellino
 
NP-Completeness-myppt.pptx
NP-Completeness-myppt.pptxNP-Completeness-myppt.pptx
NP-Completeness-myppt.pptx
SanchayKedia2
 
Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2
Techglyphs
 
Complexity theory
Complexity theory Complexity theory
Complexity theory
Dr Shashikant Athawale
 
teteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxm
teteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxmteteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxm
teteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxm
zoobiarana76
 
Isolation Lemma for Directed Reachability and NL vs. L
Isolation Lemma for Directed Reachability and NL vs. LIsolation Lemma for Directed Reachability and NL vs. L
Isolation Lemma for Directed Reachability and NL vs. L
cseiitgn
 
2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練
Abner Huang
 

Similar to Np completeness h4 (20)

class23.ppt
class23.pptclass23.ppt
class23.ppt
 
UNIT-V.pdf daa unit material 5 th unit ppt
UNIT-V.pdf daa unit material 5 th unit pptUNIT-V.pdf daa unit material 5 th unit ppt
UNIT-V.pdf daa unit material 5 th unit ppt
 
UNIT-V.ppt
UNIT-V.pptUNIT-V.ppt
UNIT-V.ppt
 
lect5-1.ppt
lect5-1.pptlect5-1.ppt
lect5-1.ppt
 
practice-final-soln.pdf
practice-final-soln.pdfpractice-final-soln.pdf
practice-final-soln.pdf
 
P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2P, NP and NP-Complete, Theory of NP-Completeness V2
P, NP and NP-Complete, Theory of NP-Completeness V2
 
Ads unit 3 ppt
Ads unit 3 pptAds unit 3 ppt
Ads unit 3 ppt
 
PNP.pptx
PNP.pptxPNP.pptx
PNP.pptx
 
PNP.pptx
PNP.pptxPNP.pptx
PNP.pptx
 
Webinar : P, NP, NP-Hard , NP - Complete problems
Webinar : P, NP, NP-Hard , NP - Complete problems Webinar : P, NP, NP-Hard , NP - Complete problems
Webinar : P, NP, NP-Hard , NP - Complete problems
 
Internship
InternshipInternship
Internship
 
UNIT -IV DAA.pdf
UNIT  -IV DAA.pdfUNIT  -IV DAA.pdf
UNIT -IV DAA.pdf
 
Design and analysis of algorithms unit 6 non deterministic polynomial
Design and analysis of algorithms unit 6 non deterministic polynomialDesign and analysis of algorithms unit 6 non deterministic polynomial
Design and analysis of algorithms unit 6 non deterministic polynomial
 
Why machines can't think (logically)
Why machines can't think (logically)Why machines can't think (logically)
Why machines can't think (logically)
 
NP-Completeness-myppt.pptx
NP-Completeness-myppt.pptxNP-Completeness-myppt.pptx
NP-Completeness-myppt.pptx
 
Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2
 
Complexity theory
Complexity theory Complexity theory
Complexity theory
 
teteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxm
teteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxmteteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxm
teteuueieoeofhfhfjffkkkfkfflflflhshssnnvmvvmvv,v,v,nnxmxxm
 
Isolation Lemma for Directed Reachability and NL vs. L
Isolation Lemma for Directed Reachability and NL vs. LIsolation Lemma for Directed Reachability and NL vs. L
Isolation Lemma for Directed Reachability and NL vs. L
 
2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練
 

More from Rajendran

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
Rajendran
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding Costs
Rajendran
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower bounds
Rajendran
 
Red black tree
Red black treeRed black tree
Red black tree
Rajendran
 
Hash table
Hash tableHash table
Hash table
Rajendran
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
Rajendran
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
Rajendran
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
Rajendran
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
Rajendran
 
Master method
Master method Master method
Master method
Rajendran
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
Rajendran
 
Hash tables
Hash tablesHash tables
Hash tables
Rajendran
 
Lower bound
Lower boundLower bound
Lower bound
Rajendran
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
Rajendran
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
Rajendran
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
Rajendran
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
Rajendran
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of Quicksort
Rajendran
 
computer languages
computer languagescomputer languages
computer languages
Rajendran
 
proving non-computability
proving non-computabilityproving non-computability
proving non-computability
Rajendran
 

More from Rajendran (20)

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding Costs
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower bounds
 
Red black tree
Red black treeRed black tree
Red black tree
 
Hash table
Hash tableHash table
Hash table
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
 
Master method
Master method Master method
Master method
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Hash tables
Hash tablesHash tables
Hash tables
 
Lower bound
Lower boundLower bound
Lower bound
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of Quicksort
 
computer languages
computer languagescomputer languages
computer languages
 
proving non-computability
proving non-computabilityproving non-computability
proving non-computability
 

Recently uploaded

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 

Recently uploaded (20)

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 

Np completeness h4

  • 1. CSE 135: Introduction to Theory of Computation P, NP, and NP- completeness Sungjin Im University of California, Merced 04-23-2015
  • 2. Significance of P ƒ=? NP Perhaps you have heard of (some of) the following terms: P, NP, NP-complete, NP-hard. And the famous question if P = NP or not.
  • 3. Significance of P ƒ=? NP Why do we care about P ƒ=? NP?
  • 4. Significance of P ƒ=? NP Why do we care about P ƒ=? NP? › A central question in computer science and mathematics.
  • 5. Significance of P ƒ=? NP Why do we care about P ƒ=? NP? › A central question in computer science and mathematics. › A lot of practical implications.
  • 6. Significance of P ƒ=? NP Why do we care about P ƒ=? NP? › A central question in computer science and mathematics. › A lot of practical implications. › P and NP problems are widely found in practice.
  • 7. Significance of P ƒ=? NP The Millennium Prize Problems are seven problems in mathematics that were stated by the Clay Mathematics Institute in 2000. As of April 2015, six of the problems remain unsolved. A correct solution to any of the problems results in a US $1,000,000 prize (sometimes called a Millennium Prize) being awarded by the institute. The Poincare conjecture was solved by Grigori Perelman, but he declined the award in 2010. The question P ƒ=? NP is the first in the list... (source: wikipedia)
  • 8. Class P Formal definition Definition P is the class of languages that are decidable in polynomial time on a deterministic single-tape Turing machine. In other words, P = [ Time(nk ) k Motivation: To define a class of problems that can be solved efficiently. › P is invariant for all models of computation that are polynomially equivalent to the deterministic single-tape Turing Machine. › P roughly corresponds to the class of problems that are
  • 9. Class P Justification P is invariant for all models of computation that are polynomially equivalent to the deterministic single-tape Turing Machine. Example. Theorem Let t(n) be a function, where t(n) ≥ n. Then every t(n) time multitape Turing machine has an equivalent O(t2(n)) time single-tape Turing machine. In fact, it can be shown that all reasonable deterministic computational models are polynomially equivalent.
  • 10. Class P Formal definition Definition P is the class of languages that are decidable in polynomial time on a deterministic single-tape Turing machine. In other words, P = [ Time(nk ) k Hence, a language is in P if and only if one can write a pseudo-code that decides the language in polynomial time in the input length; the code must terminate for any input.
  • 11. Class P Example PATH = {(G, s, t) | G is a directed graph that has a directed path from s to t}.
  • 12. Class P Less formal definition of P Definition P is the set of decision problems that can be solved in polynomial time (in the input size). 22 Examples of polynomial time: O(n), O(log n), O(n100), O(n22 ).
  • 13. Class P Less formal definition of P Definition P is the set of decision problems that can be solved in polynomial time (in the input size). 22 Examples of polynomial time: O(n), O(log n), O(n100), O(n22 ). From now on, we will use this less formal and simpler definition of P.
  • 14. Simple description of decision problems Problem PATH: Input: an directed graph G , and two distinct nodes s and t in G . Question: Does G has a directed path from s to t? In the remainder of this course, we will adopt this simple description of decision problems over languages.
  • 15. Simple description of decision problems Problem PATH: Input: an directed graph G , and two distinct nodes s and t in G . Question: Does G has a directed path from s to t? In the remainder of this course, we will adopt this simple description of decision problems over languages. A yes-instance is an instance where the answer is yes. No- instance is similarly defined.
  • 16. Class NP Example Problem HAMPATH: Input: an directed graph G , and two distinct nodes s and t in G . Question: Does G have a Hamiltonian path from s to t? A Hamiltonian path in a directed graph G is a directed path that visits every node exactly once.
  • 17. Class NP Example Problem HAMPATH: Input: an directed graph G , and two distinct nodes s and t in G . Question: Does G have a Hamiltonian path from s to t? A Hamiltonian path in a directed graph G is a directed path that visits every node exactly once. We are not aware of any algorithm that solves HAMPATH in polynomial time. But we know a brute-force algorithm finds a s-t Hamiltonian path in exponential time. Also we can verify/check if a given path is a s-t Hamiltonian path or not.
  • 18. Class NP Example We do not know how to answer in polynomial time if a given instance is a yes-instance or not. However, if it is a yes- instance, there is a proof I can easily check (in polynomial time). A s-t Hamiltonian path of the instance can be such a ‘proof’. Once we are given this proof, we can check in polynomial time if the instance is indeed a yes-instance
  • 19. Class NP Formal definition Definition A verifier for a language A is an algorithm V , where A = {w | V accepts < w, c > for some string c} (c is called a certificate or proof). 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. Note that a polynomial time verifier A can only read a certificate of size polynomial in |w|; so c must have size polynomial in |w|.
  • 20. Class NP Formal definition Definition NP is the class of languages that have polynomial time verifiers.
  • 22. Class NP Formal definition The term NP comes from nondeterministic polynomial time and has an alternative characterization by using nondeterministic polynomial time Turing machines. Theorem A language is in NP iff it is decided by some nondeterministic polynomial time Turing machine. Proof. (⇒) Convert a polynomial time verifier V to an equivalent polynomial time NTM N. On input w of length n: › Nondeterministically select string c of length at most nk (assuming that V runs in time nk ). › Run V on input < w, c >. › If V accepts, accept; otherwise, reject.
  • 23. Class NP Formal definition Theorem A language is in NP iff it is decided by some nondeterministic polynomial time Turing machine. Proof. (⇐) Convert a polynomial time NTM N to an equivalent polynomial time verifier V . On input w of length n: › Simulate N on input w , treating each symbol of c as a description of the nondeterministic choice to make at each step. › If this branch of N’s computation accepts, accept; otherwise, reject. Q
  • 24. Class NP Examples A clique in an undirected graph is a subgraph, wherein every two nodes are connected by an edge. A k -clique is a clique that contains k nodes. CLIQUE = {< G, k > | G is an undirected graph with a k -clique} Lemma CLIQUE is in NP. Proof. Let w =< G, k >. The certificate c is a k -clique. We can easily test if c is a clique in polynomial time in w and c , and has k nodes. Q
  • 25. Class NP Examples HAMPATH = {< G, s, t > | G is a directed graph with a Hamiltonian path from s to t}. Lemma HAMPATH is in NP.
  • 26. Simple definition of P From now on, we will use the following simpler definition of P. Definition P is the set of decision problems that can be solved in polynomial time (in the input size). 22 Examples of polynomial time: O(n), O(log n), O(n100), O(n22 ), etc.
  • 27. Class NP Less formal definition From now on, we will use the following simpler definition of NP. Definition NP is the set of decision problems with the following property: If the answer is Yes, then there is a proof of this fact that can be checked in polynomial time. (The size of the proof must be polynomially bounded by n).
  • 28. Class NP Example Problem CLIQUE : Input: an undirected graph G and an integer k ≥ 1. Question: Does G have a k -clique? A clique in an undirected graph is a subgraph, wherein every two nodes are connected by an edge. A k -clique is a clique that contains k nodes. Proposition CLIQUE is in NP. Proof. The certificate is a set of k vertices that form a clique which can be checked in polynomial time. Q
  • 29. Class NP Example Problem HAMPATH: Input: an directed graph G , and two distinct nodes s and t in G . Question: Does G have a Hamiltonian path from s to t? Proposition HAMPATH is in NP. Proof. Consider any yes-instance. The certificate is the following: a Hamiltonian path from s to t which must exist from the definition of the problem, and can easily be checked in polynomial time. Q
  • 30. P ⊆ NP Think about any decision problem A in the class P. Why is it in NP?
  • 31. P ⊆ NP Think about any decision problem A in the class P. Why is it in NP? In other words, if an input/instance is a Yes-instance, how can we check it in polynomial time? We can solve the problem from scratch in polynomial time. No certificates are needed.
  • 32. P ⊆ NP Think about any decision problem A in the class P. Why is it in NP? In other words, if an input/instance is a Yes-instance, how can we check it in polynomial time? We can solve the problem from scratch in polynomial time. No certificates are needed. For example, think about the probelm PATH.
  • 33. NP ⊆ EXP Here, EXP is the class of problems that can be solved in exponential time.
  • 34. NP ⊆ EXP Here, EXP is the class of problems that can be solved in exponential time. Think about any decision problem A in the class NP.
  • 35. NP ⊆ EXP Here, EXP is the class of problems that can be solved in exponential time. Think about any decision problem A in the class NP. If a yes-instance has a ‘short’ certificate. We can try each certificate (by brute force). So the checking can be done in exponential time.
  • 36. NP ⊆ EXP Here, EXP is the class of problems that can be solved in exponential time. Think about any decision problem A in the class NP. If a yes-instance has a ‘short’ certificate. We can try each certificate (by brute force). So the checking can be done in exponential time. For example, think about CLIQUE or HAMPATH.
  • 37. P vs. NP ? Either of the following two must be true: P = NP or P Ç NP. We know that NP ⊆ EXP, but we do not even know if NP = EXP or NP Ç EXP
  • 38. NP-completeness Cook-Levin Theorem Most researchers, however, believe that P ƒ= NP becuase of the existence of some problems that capture the entire NP class. Problem Satisfiability (SAT): Input: a boolean formula Φ. Question: is Φ satisfiable? A Boolean formula is an expression involving Boolean variables and operations. For example, Φ = (x¯ ∧ y ) ∨ (x ∧ z¯) is a boolean formula. We say a boolean formula is satisfiable if some assignment of 0s and 1s to the variables makes the formula evaluate to 1. Note that Φ is satisfiable (x = 0, y = 1, z = 0). Theorem (Cook-Levin Theorem) SAT ∈ P iff P = NP.
  • 39. NP-completeness Polynomial Time Reducibility There are two different types of reductions: Turing reduction vs. Karp reduction. For simplicity, in this course we will only focus on Turing reduction. See Section 30.4 in Jeff Erickson’s note for the difference. Definition We say that problem A is polynomial-time reducible to problem B if we can solve problem A in polynomial time using a (possibly hypothetical) polynomial time algorithm for problem B as a black box. This is often denoted as A ≤p B. For simplicity, sometimes, we say that A is reducible to B, and denote it as A ≤ B.
  • 40. NP-completeness NP-hardness Definition We say that problem B is NP-hard if for every A in NP, A ≤P B.
  • 41. NP-completeness NP-hardness Theorem If A ≤P B and B ∈ P, then A ∈ P.
  • 42. NP-completeness NP-hardness Theorem If A ≤P B and B ∈ P, then A ∈ P. Proof. Immediately follows from the definition of ≤p . Q
  • 43. NP-completeness Definition Definition A language B is NP-complete if it is NP-hard and is in NP.
  • 44. NP-completeness Definition Definition A language B is NP-complete if it is NP-hard and is in NP. Theorem If B is NPC (NP-complete) and B ∈ P, then P = NP. Proof. We already know P ⊆ NP. So it suffices to show NP ⊆ P.
  • 45. NP-completeness Definition Definition A language B is NP-complete if it is NP-hard and is in NP. Theorem If B is NPC (NP-complete) and B ∈ P, then P = NP. Proof. We already know P ⊆ NP. So it suffices to show NP ⊆ P. Consider any problem A in NP. By definition of NP- hardness, A ≤p B. Since B is in P, it implies A is in P. Q
  • 46. NP-completeness Let’s say that B ∈ NPC if B is NP-complete. Theorem A language C is NP-complete if B ≤P C for some B ∈ NPC, and C ∈ NP. Similarly, Theorem A language C is NP-hard if B ≤P C for some NP-hard language B.