## 1. Introduction

There is still no proof of the problem whether . The answer is likely to be “No”.

In this tutorial, assuming that , we’ll learn how to prove the -Completeness of the problem. Also, we’ll take real algorithmic problems and prove that they are -Complete.

Finally, we’ll also use Big-O notation to describe time complexity.

## 2. NP-Hard and NP-Complete Problems

Let’s classify the decision problems – problems that have the “Yes” or “No” answers.

### 2.1. P and NP

The problem belongs to class if it can be solved in polynomial time.

Similarly, the problem belongs to class if it can be solved in non-deterministic polynomial time. Intuitively, this set of problems is considered to be “hard” problems. Technically, we can’t solve them in polynomial time. However, their “runtime” might be a polynomial.

### 2.2. Reduction

Reduction of a problem to problem   is a conversion of inputs of problem to the inputs of problem . This conversion is a polynomial-time algorithm itself. The complexity depends on the length of the input.

Let’s classify the inputs of the decision problems. “Yes” – input of the problem is the one that has a “Yes” answer to it. Likewise, “No” – input to the problem is the one that has a “No” answer to it.

If then every “Yes” – input of converts to “Yes” – input of . And every “No” – input of converts to “No” – input of with the reduction algorithm. However, the alternate is that we can also prove that every “Yes” – input of converts to “Yes” – input of , instead of working with no inputs. We’ll implement our own reduction algorithms later in the article.

Important to know, the polynomial reduction is a transitive relation. It means, that if problem reduces to with an algorithm , and problem reduces to with an algorithm , then problem reduces to with an algorithm . It can be achieved by applying algorithm first to the inputs to the problem . Then we’d get the inputs to the problem and can apply algorithm to convert those inputs to the input to problem .

### 2.3. NP-Hardness

The problem is -Hard if every problem from polynomially reduces to it. We may assume that -Hard problems are at least as hard as any problem in and might be even harder. However, the -Hard problem might or might not belong to .

### 2.4. NP-Completeness

The problem is -Complete if it belongs to , and every problem from polynomially reduces to it.

As we may notice, every -Complete problem is -Hard. But not every -Hard problem is -Complete. The example of -Hard but not the -Complete problem is the Halting Problem. This problem is hard but doesn’t belong to . Boolean satisfiability (SAT) is the first problem from that was proven to be -Complete. We can also find the 3SAT problem definition while reading about the Cook-Levin theorem.

## 3. Algorithm to Prove That a Problem Is NP-Complete

-Complete problems are the ones that are both in and -Hard.

So, to prove that problem is -Complete we need to show that the problem:

1. belongs to
2. is -Hard

### 3.1. How to Show a Problem Is NP?

There exists a certificate verification strategy to show that the problem belongs to . A certificate is an answer to our problem. Verifier is a polynomial algorithm that can tell us whether the answer to the problem is “Yes” or “No”.

For instance, let’s take the Hamiltonian Cycle problem. The certificate to the problem might be vertices in order of Hamiltonian cycle traversal. We can check if this cycle is Hamiltonian in linear time. It is called verification. So, the problem belongs to . Moreover, it can be proven that the Hamiltonian Cycle is -Complete by reducing this problem to 3SAT.

### 3.2. How to Show a Problem Is NP-Hard?

To show that the problem is -Hard, we have to choose another -Hard problem and reduce the chosen problem to ours. Importantly, every -Hard problem is -Complete. Thus, we can also reduce any -Complete problem.

Remember, the relation of polynomial reduction is transitive. Therefore, we can reduce just one problem, not all the problems with .

### 3.3. Proof Strategy

Here are the main goals we need to achieve in order to prove the problem is -Complete:

As mentioned, firstly, we have to prove that the problem is in class. If we cannot prove that, then we cannot move further. The -Complete problems always belong to .

When we choose a certificate, it must have a polynomial length. So, if the input to our problem is , but the length of the certificate is , then we can’t verify this certificate. A verifier algorithm must have polynomial time complexity based on the length of the certificate.

After we checked that our problem is in , we have to prove that the problem is -Hard. The -Complete class of problems is the intersection of and -Hard. For any -Hard problem, we know that every problem from polynomially reduces to it.

We should also remember, that the reduction algorithm must convert “Yes” – and “No” – inputs of chosen -Hard or -Complete problem to the equivalent “Yes” –  and “No” – inputs of our problem.

Let’s see two examples of proving that the problem is -Complete. We’ll reduce 3SAT to 4SAT and Independent Set problems.

## 4. 3SAT to 4SAT Reduction

Here is the 4SAT problem definition:

“Given a Boolean formula, which consists of clauses, each clause is a disjunction of 4 literals or their negations.  Is there an interpretation of variables such that every clause is satisfied?”

### 4.1. Certificate Verification of 4SAT

Firstly, let’s prove the problem belongs to . Suppose the formula has input variables. It means that the answer and our certificate is an interpretation of variables. They might be set to true or false. Moreover, we can check whether the formula is satisfied at a linear time. As a result, we verify our certificate in polynomial time. So, the problem is in .

### 4.2. Reduction of 3SAT to 4SAT

Secondly, we have to prove 4SAT is -Hard. Let’s take 3SAT, which is -Complete, and reduce 3SAT to 4SAT.

Our reduction gadget will be an algorithm, which converts inputs of 3SAT to the inputs of 4SAT.

Given an input 3SAT formula , we construct the input formula of 4SAT by expanding each clause with the new variable: .

It is clear that we can do it in polynomial time. Let’s now check that “Yes” – inputs of 3SAT are converted to “Yes” – inputs of 4SAT and vice versa.

If a given clause is satisfied, then is satisfied. Variable can be either true or false. Thus, if is satisfiable, is satisfiable.

Suppose is satisfied. Let the satisfiable interpretation of variables be . consists of assignments of each variable.  Then must be true under . Variables and have different values. If variable is true then is false and vice versa. So, must be true under as well. Thus, is satisfiable.

As a result, we created a polynomial algorithm that converts the inputs of 3SAT to the inputs of 4SAT. It means that 4SAT is -Hard.

Finally, we’ve proved 4SAT is in  and -Hard. Therefore, we can say that 4SAT is -Complete.

## 5. 3SAT to Independent Set Reduction

In graph theory, the Independent Set is a problem of finding a set of vertices of size in a graph, such that no two of which are adjacent.

### 5.1. Certificate Verification of Independent Set

Let’s prove this problem belongs to . The certificate of the problem might be a set of chosen vertices. We can check in polynomial time whether any two of them are adjacent or no. Therefore, the problem is in .

### 5.2. Reduction of 3SAT to Independent Set

Suppose we have a 3SAT input formula, consisting of clauses: .

Let’s now reduce the 3SAT to Independent Set by building a graph, which would have an independent set of size if and only if the given formula is satisfied. To do it, for each clause, we create a triangle graph and add the edges to all pairs of vertices, which consist of the variable and its negation:

If a given formula is satisfied, then at least one variable in each clause is true. Let be a set of such true variables. The formula consists of clauses. Thus, is the size of , and the set of corresponding vertices in a built graph is independent and has a size of .

Next, if the graph has an independent set of size , we know that it has one node from each “clause triangle.” We can set chosen variables to true. This is possible because no two are negations of each other, and the boolean formula will be satisfied.

We’ve proved already that the Independent Set problem is in and -Hard. Therefore, we can say that the Independent Set is -Complete.

## 6. Conclusion

In this tutorial, we’ve learned the most important definitions of the theory of complexities. Also, we’ve learned how to prove the  -Completeness of the problem, using certificate verification and reduction strategy. Furthermore, we’ve shown two examples of  -Completeness proof.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.