[Algorithm notes] How to prove that a problem is an NPC problem

[Algorithm notes] How to prove that a problem is an NPC problem

Step

Before getting into the topic, I want to explain to you the concepts of reduction, P and NP.

Expectation (Desiderata'): If we can solve problem Y in polynomial-time, what other problems can we consider on the current basis?

Reduction (Reduction): When problem X can be reduced to problem Y in polynomial time, and any sample of problem X can be solved in the following ways:
· polynomial standard algorithm complexity calculation steps
· polynomial order call Steps to solve problem Y

Notation: X ≤ P Y. (When this mark is encountered, it can usually be understood that Y is harder than X, and Y can solve X)

Corollary:
1) If X ≤ PY and Y can be solved in polynomial time, then X can be solved in polynomial time
2) If X ≤ PY and X cannot be solved in polynomial time, then Y cannot be solved in polynomial time either
3) If X ≤ PY and Y ≤ PX, denote X ≡ PY. In this case, X can be solved in polynomial time if and only if Y can solve

P in polynomial time.
Definition: A set of decision questions that each have a polynomial algorithm (that is, the answer is yes or no ) In layman's terms, it is a
NP problem that can be solved in polynomial time.
Definition: A set of decision-making problems that each have a polynomial time certificate (certifier). In layman's terms, it is a problem that can be proved in polynomial time.
So the P problem is also an NP problem. The so-called NPC problem is that for any NP problem, it can be reduced to this problem in polynomial time. That is to say, it is more difficult than all NP problems (of course there are equally difficult).
At present, most scholars believe that NP problems really include P problems and have intersections with NP-Hard problems. The intersection is the NPC problem
Insert picture description here
Figure 0

1. Proof of NP
First of all, for any NP problem, it can be an NPC problem, but if you give us a problem alone, it is really difficult for us to prove that it is an NPC problem, so we take tricks. Remember this problem as Y, first prove that this problem is an NP problem

2. Structure
Find an NPC problem, record it as X, prove: X ≤ PY

3. Sufficient
and Necessity of Solution Prove: X has solution if and only if Y has solution

Example

According to the difficulty, I provide two examples of problem solving for your reference.
1.
If you plan to arrange courses for this semester and want to ensure that the number of conflicting courses does not exceed K. You have 3 inputs: C={…},S={…},R={ {…},{…},…}. C is a collection of different courses, S is the time interval available for all courses, and R is the student’s requirement, which contains the collection of courses that each student wants to learn (for example, there are two people, one wants to learn A, one wants to learn B, then R={ {A},{B}}). When two courses are arranged in the same time interval and conflict (even if there is a student who wants to learn both), it proves that the problem is an NPC problem

1. First of all, for any time schedule (as a certificate. In fact, most certificates can be chosen at will, such as your friend's name, although it sounds very outrageous). We traverse the requirements of all students, check whether their requirements conflict, and count the number of conflicts. Finally, check whether the total is less than K. The above steps can be completed in polynomial time. (It is strongly recommended to write each step separately, and then write the respective complexity) So this problem is NP. (To prove that the polynomial is solvable in time, most of the time we choose the most stupid method, namely traversal, and then prove that the traversal is polynomial time)

2. We choose the three-color problem (3-Color problem. Give a picture, color points with three colors, and find a coloring scheme to make any two adjacent points different colors) as the NPC problem selected in this question. For any three-coloring scheme, remember this picture as G, we construct the example under this question: let each point represent a course, construct C; let (u, v) represent a student with u, v in the requirement, Construct R; let us use the color to represent the time gap, construct S; finally, set K to 0

3. We prove that G is the correct three-color scheme, if and only if (C,S,R,K) is the correct solution to this problem:
LHS->RHS: If G is the correct three-color scheme, then follow the course Arrange them in different colors. Because for any edge (u, v), u and v will be colored by different colors, so for each student, his requirements will not be arranged in the same time interval, which also means that this scheme is feasible of

RHS->LHS: If (C, S, R, K) is the solution to this problem, then the points in G are colored according to their time gaps. Because K=0, then for all students, there is no conflict between their requirements. This means that for each edge (u, v), u and v will not be colored by the same color. So this is a correct staining scheme for the triple staining problem.
In summary, this problem is an NPC problem

Isn't it a bit embarrassing to see it? This is a difficult question in my homework, so don’t be discouraged. I will give you a simple question below.

二、4-COLOR

Given an undirected graph and four different colors, can we provide a coloring scheme to make adjacent points have different colors? Prove that the 4-COLOR problem is an NPC problem

1. Assuming any coloring scheme is given, first assign this scheme to G (O(|V|), V represents the number of vertices of G), we traverse this scheme in the graph, and every time a point is traversed, we judge Whether it has the same color as its neighbors, since the degree of each point is at most |V-1|, the complexity of this step is O(|V-1||V|). So this problem can be solved in polynomial time given the certificate.

Insert picture description here
Figure 1
Actually, it is enough to have this picture, but to be on the safe side, let me explain it for everyone. Add a point (θ(1)), assign this point to the fourth color (θ(1)), and set This point is all connected with the points in G (θ(|V|)), we get a four-color example
3.
LHS->RHS: If the three-color example is true, then add the new point v to G to get A four-staining scheme

RHS->LHS: If the four-coloring example is true, delete v and the edge of it and G to get a three-coloring.
The above is the Chinese version of my homework, but as a qualified CS major, I suggest you read more English materials. I put the original version of my homework below for your reference

Insert picture description here
Figure 2

Problem-making experience

I suggest that you prepare a few more NPC questions when doing similar questions and preparing for the exam. After all, although all NP questions can be reduced to NPC questions, the difficulty of reduction is obviously different.
Insert picture description here
Figure 3

The common ones are independent set, set cover, vertex cover, Hamilton road, circuit satisfiability problem (circuit set, the oldest NPC problem), clique, Traveling salesman problem, subset sum problem (subset sum), 3-SAT (the most classic NPC problem), three-coloring problem (3-C), and some other blablabla
Insert picture description here
Figure 4

Insert picture description here
Figure 5 3-SAT

Analysis

Generally speaking, the decision problem is weaker than the search problem, and the search problem is weaker than the optimization problem. But these three have no insurmountable boundaries. The following introduces an example.
First, let’s introduce the vertex cover. Given a G=(V,E) and an integer k, a vertex cover of size k of G means that there is a subset of k points. For any edge in G, there is a point inside this subset (cover all edges with points)
Insert picture description here
Figure 6
As in this graph, there is a vertex cover of size 4 (white point set).
Back to my thoughts In the example to be talked about: for graph G

1) Decision problem: whether there is a vertex cover less than or equal to k

2) Search problem: find a vertex cover less than or equal to k

3) Optimal problem: find the smallest vertex cover

First of all, obviously, if there is a solution to 3), then 2) and 1) can be solved easily, and if there is a solution to 2), then 1) has a solution. Let's think about these three issues carefully. Maybe the gap between them is not that big.
If we can solve 1), we solve 2) through the following steps. For graph G, we remove a point to see if there is a vertex coverage less than or equal to k-1 in the remaining graph, because this removed point There are options in |V|, so we can solve the above problems separately for these |V| subgraphs, repeat the above steps, and get the solution of 2)
OK according to the points we took out , we have already seen 1) and 2 ) The gap is not that big. It is nothing more than a traversal problem. We can use dynamic programming to solve it (note that taking v_1 and then v_2 is the same as taking v_2 and then v_1). Of course, this will be introduced later.
Now we assume that we know the solution of 2) and want to know the solution of 3). This is even simpler. We only need to take k, k-1... until t is found that there is no vertex cover less than t in G, then the minimum of G The vertex cover is t+1, and the solution can be found when t+1 is taken

Sum up

In short, the NPC problem is a very difficult problem, but you can stand on the shoulders of the predecessors when you prove it, and use the existing NPC problems to prove that 2021 is over. One of my wishes in 2019 is that within five years I opened a blog. This is my first one. As I am very busy with my studies, I can only write a little bit during the holidays. Although the teacher has taught NPC issues, I don’t feel that I have studied very deeply. Those who are interested can find something. Take a look at the papers and books, and finally Chuanbao fell down, pay me a tribute to Chuanbao, oooooo
Insert picture description here

Guess you like

Origin blog.csdn.net/Cplus_ruler/article/details/112390803