Skip to content
Related Articles

Related Articles

Prove Max2SAT is NP-Complete by Generalisation

Improve Article
Save Article
  • Last Updated : 14 Sep, 2022
Improve Article
Save Article

Prerequisites: NP-Completeness, NP Class, Max2SAT, 3SAT

Problem: Given a 2-CNF (Conjunctive Normal Form) Boolean expression (with m clauses, n variables) and an integer k, Decide if there is an assignment satisfying at least ‘k’ of the total clauses and then prove Max2SAT belongs to NP-Complete

Explanation:

In the maximum-2-satisfiability problem (MAX-2-SAT), the input is a formula in conjunctive normal form with two literals per clause, and the task is to determine the maximum number of clauses that can be simultaneously satisfied by an assignment. MAX2SAT is a generalisation of 2SAT since the latter is a special case of the former where k is equal to the number of clauses

We will prove Max2SAT as NP-Complete using the 3SAT problem which is a known NP-Complete Problem.

In the 3SAT, the input is a formula in conjunctive normal form with three literals per clause, and the task is to determine the maximum number of clauses that can be simultaneously satisfied by an assignment.

Proof:

1. Input Conversion: To show the conversion, we will convert the input from 3SAT to Max2SAT.

If one of a clause in 3SAT is  c= (x ∨ y ∨ z) then this would be converted into Max2SAT input such that all the clauses would have at most 2 literals. An extra literal d which can be 0 or 1 is added such that  d does not interfere with the satisfiability of x, y and z since we add clauses “q ∨ ¬d “ for all q ∈ {x, y, z} and the final input conversion would be as:

(x)∧(y)∧(z)∧(d)∧(¬x ∨ ¬y)∧(¬y ∨ ¬z)∧(¬x ∨ ¬z)∧(x ∨ ¬d)∧(y ∨ ¬d)∧(z ∨ ¬d)

c = (x ∨ y ∨ z)  
⇒ (x)∧(y)∧(z)∧(d)∧(¬x ∨ ¬y)∧(¬y ∨ ¬z)∧(¬x ∨ ¬z)∧(x ∨ ¬d)∧(y ∨ ¬d)∧(z ∨ ¬d)

So 1 clause in 3SAT would be converted into 10 clauses in Max2SAT. So for 3SAT if there were m clauses then Max2SAT will have 10m clauses.

2. Output Conversion: We need to convert the solution from Max2SAT to the solution for the 3SAT. 

  • If Max2SAT returns NO then return NO for SAT.
  • If Max2SAT returns the solution as an assignment of literals, then return the same solution for all literals

So, assigning values to n literals takes O(n) time. So output conversion is polynomial in time.

3. Correctness: Now let’s check the assignment for the converted input. 

For this, we will group the above converted input into 3 groups.

  1. (x)∧(y)∧(z)∧(d)
  2. (¬x ∨ ¬y)∧(¬y ∨ ¬z)∧(¬x ∨ ¬z)
  3. (x ∨ ¬d)∧(y ∨ ¬d)∧(z ∨ ¬d)

We will check by testing some truth value assignments.

  • If all x, y and z are satisfied: In this case, none of the clauses in Group 2 would be satisfied. For Group 3, all of them would be satisfied since d would be satisfied. So maximum number of clauses satisfied in this case would be 7 (4 from Group 1 and 3 from Group 3)out of 10.
  • If two of x, y and z are satisfied:  In this case, 2 of the 3 clauses from Group 2 would be satisfied. For Group 3, the same 2 of the 3 clauses would be satisfied if d is satisfied. So maximum number of clauses satisfied in this case would be 7 (3 from Group 1, 2 from Group 2 and 2 from Group 3)out of 10.
  • If one of x, y and z are satisfied: In this case, all 3 clauses from Group 3 would be satisfied and by satisfying d, 2 clauses from Group 3 would be satisfied. So maximum number of clauses satisfied in this case would be 7 (2 from Group 1, 3 from Group 2, and 2 from Group 3)out of 10.
  • If none of x, y and z are satisfied: In this case, all 3 clauses from Group 3 would be satisfied and by setting d = False, all 3 clauses from Group 3 would be satisfied. So total number of clauses satisfied in this case would be 6 ( 3 from Group 2 and 3 from Group 3)out of 10.

From the above testing, we can make the following conclusion: 

Any assignment that satisfies the 3SAT formula must satisfy all m clauses. Satisfying 1 clause in 3SAT(where at least one of x, y, and z is satisfied) satisfies exactly 7 clauses in the corresponding 10 clauses of Max2SAT.

Hence, satisfying all m clauses in 3SAT means satisfying exactly 7m clauses in Max2SAT. So, set k = 7m in the Max2SAT problem.

Conclusion:

So, since we know 3SAT is NP-Complete, this means that unless P = NP, that Max2SAT must also be NP-Complete.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!