Chapter 10: NP Complete
NP - A class of problems
Efficient Algorithm was Found | No Efficient Algorithm till Date |
---|---|
Shortest Path | Longest Path |
Minimum Spanning Tree | Travelling Sales Person |
Euler Tour | Hamiltonian Cycle |
Min Cut | Balanced Cut |
Is in Bipartite Graph | Independent Set |
Bipartite Matching | 3D Matching |
Linear Programming | Integer Programming |
Longest Path Problem
Vertex Cover
NP Class Definitions
: any decision problem
: any (input) instance of X
Efficient Certifier for :
- A polynomial time algorithm with output
{yes, no}
- Input: (), where is the certificate, usually a proposed solution
- Behaviour: There is a polynomial function such that is a yes-instance of X if and only if there exists a string with such that outputs yes on i().
Definition of NP
- The set of all decision problems which have an efficient certifier.
- NP = "Non-deterministic polynomial time"
Hamiltonian Cycle (HC)
- In Ham-Cycle, given a graph , the problem is to decide whether there is a (simple) cycle that visits each vertex exactly once.
- Certificate is the cycle itself. Verifier checks in polynomial time whether it is a cycle and visits each vertex once.
- Hence, Ham-Cycle is in NP
P Class
Definition of P
- The set of all decision problems which have an efficient (poly-time) algorithm.
- What is the relationship between P and NP?
Certifier for P?
: any decision problem in P
: any (input) instance of X
- Let be a polynomial time algorithm for solving Efficient Certifier for X:
- A polynomial time algorithm with output
{yes, no}
- Input:
- Behaviour: On getting input , just ignore and execute the algorithm on input . If the answer is yes, output yes; if the answer is no, output no.
NP vs P
- Verifying a proposed solution versus finding a solution
NP Complete
- A problem in class is -complete if for every in , they are poly-time reducible to X.
- If is not known to be in , then we say is just -"hard".
Does any NP-Complete problem exist?
It really needs:
- courage to ask such a question and
- great insight to pursue its answer
Because:
- Every problem, known as well as unknown, from class NP has to be reducible to this problem.
Circuit Satisfiability Problem:
- Given a DAG with nodes corresponding to AND, NOT, OR gates and binary inputs, does there exist any binary input which gives output 1?
- Why is in NP?
- Certificate is a binary input that gives output 1.
Question: How can every problem from NP be reduced to circuit satisfiability?
Answer:
- Consider any problem .
- What we know is that it has an efficient certifier, say .
- Any algorithm which outputs yes/no can be represented as a DAG where internal nodes are gates, leaves are binary inputs, and output is 1/0. So Cook & Levin essentially transform into the corresponding DAG and thus simulate on the proposed solution.
Satisfiability (CNF-SAT)
- Literal: A Boolean variable or its negation. ,
- Clause: A disjunction (OR) of literals.
- Conjunctive Normal Form (CNF): a formula that is a conjunction (AND) of clauses.
- CNF-SAT: Given a CNF formula , does it have a satisfying truth assignment?
3-SAT
- SAT where each clause contains exactly 3 literals corresponding to different variables.
- Satisfying assignment:
- Unsatisfying assignment:
Got it! Here's the corrected version with LaTeX math notation:
Proof for CNF-SAT being NP-Complete
To prove that if there is a polynomial-time reduction from the Circuit Satisfiability problem to the Conjunctive Normal Form Satisfiability problem (CNF-SAT), then CNF-SAT is NP-complete, we need to demonstrate two things:
CNF-SAT is in NP:
To show that CNF-SAT is in NP, we need to demonstrate that given a Boolean formula in Conjunctive Normal Form (CNF), we can verify whether it is satisfiable in polynomial time.
Verification in this case involves checking whether a given truth assignment satisfies all the clauses in the CNF formula. This process can be done in polynomial time by simply evaluating each clause and ensuring that at least one literal in each clause evaluates to true under the given truth assignment.
Since the verification process can be performed in polynomial time, CNF-SAT is in NP.
Reduction from Circuit Satisfiability to CNF-SAT:
Assuming we have a polynomial-time reduction from Circuit Satisfiability to CNF-SAT, we need to show that every problem in NP can be reduced to CNF-SAT in polynomial time.
Given an arbitrary problem A in NP, we can construct a polynomial-time reduction from A to Circuit Satisfiability (Circuit-SAT). Then, using the assumed polynomial-time reduction from Circuit-SAT to CNF-SAT, we can compose these reductions to obtain a polynomial-time reduction from A to CNF-SAT.
The composition of polynomial-time reductions preserves polynomial-time complexity, so if there exists a reduction from Circuit-SAT to CNF-SAT, then every problem in NP can be reduced to CNF-SAT in polynomial time.
Conclusion:
By demonstrating that CNF-SAT is in NP and showing that every problem in NP can be reduced to CNF-SAT in polynomial time given the assumed reduction from Circuit Satisfiability to CNF-SAT, we establish that CNF-SAT is NP-complete.
Therefore, if there is a polynomial-time reduction from Circuit Satisfiability to CNF-SAT, then CNF-SAT is indeed NP-complete.
NP Vs P
If any NP-complete problem is solved in polynomial time,
How to show a problem to be NP-complete?
Let be a problem we wish to show to be -complete:
- Show that is in
- Pick a problem which is already known to be -complete
- Show that
Independent-Set
Definition: Given an undirected graph , a subset is said to be an independent set if for each .
- Optimization Version: Compute the independent set of Largest Size.
- Decision Version: Does there exist an independent set of size ?
Prove that 3-SAT Independent-Set
Given an instance of 3-SAT, the goal is to construct an instance of Independent-Set so that has an independent set of size if and only if is satisfiable.
Reduction:
- contains 3 vertices for each clause, one for each literal.
- Connect 3 literals in a clause in a triangle.
- Connect a literal to each of its negations.
- Set "number of clauses".
- Reduction clearly runs in polynomial time.
- Suppose is a YES-instance. Take any satisfying assignment for and select a true literal from each clause. Corresponding vertices form an independent set in .
- Suppose is a YES-instance. Let be the independent set of size . Each of the triangles must contain exactly one vertex in . Set these literals to true, so all clauses satisfied.
Worst Case Analysis
- Proof shows that some instances of "Independent-Set" are as hard to solve as the 3-SAT problem. This does not mean that all instances of the "Independent-Set" problem are hard!
- So, if there is no poly-time algorithm that solves 3-SAT on all instances, there is no poly-time algorithm that solves "Independent-Set" on all instances.
- A few things to notice:
- Independent Set is NP-Complete
- We also know, Independent Set Vertex Cover
- So Vertex Cover is also NP-complete.
- Another Problem: Max-Clique: Given an undirected graph and an integer , whether there exists a clique of size at least or not in ?
- Exercise: Show Max-Clique is NP-complete (Hints: Try to prove Independent Set Max-Clique)
Hitting Set Problem
- For a set of sets , a set is said to be a hitting set if for all (i.e., has a non-empty intersection with all ).
- Hitting Set Problem: Given and a non-negative integer , decide whether there exists a hitting set of size at most .
- Show that the Hitting Set Problem is NP-complete (Hints: Try a reduction from Vertex Cover)
Hitting Set is in NP
Status of SAT
- Fastest algorithm known for 3-SAT runs in time approximately . It is believed that there is no -time algorithm for 3-SAT (Exponential Time Hypothesis).
- Often very convenient to reduce from 3-SAT to other problems, showing that those will also be hard if 3-SAT is hard.
Question
Suppose 3-SAT A for some decision problem A. Assume that there is no -time algorithm for 3-SAT. Then, there is no -time algorithm for A. True or false?
- False
- If the reduction runs in time , then a -time algorithm for A implies a -time
algorithm for 3-SAT.
- So by the assumption, there is no -time algorithms for A.
- The lower bound for A depends on the running time of the reduction.