# Proof that Almost-SAT is NP Complete

Prerequisite: NP-Completeness, NP Class, SAT

**Problem**– The **Almost-SAT problem** which is built on top of SAT(Boolean Satisfiability Problem) problem takes a boolean formula in conjunctive normal form with m clauses as input. If such an assignment exists, the result is an assignment of the literals such that exactly *m-1 *clauses evaluate to TRUE, otherwise NO. Demonstrate that Almost-SAT is NP-Complete.

**Solution- **

SAT, sometimes called as B-SAT(Boolean Satisfiability Problem)which is the problem of determining if there exists an interpretation that satisfies a given Boolean formula.It asks whether the variables of a given Boolean formula can be consistently replaced by the values TRUE or FALSE in such a way that the formula evaluates to TRUE

Almost-SAT is the minimum satisfiability problem, is an FNP generalisation of SAT. It asks for the minimum number of clauses which can be satisfied by any assignment and for the given problem minimum clauses satisfied should be m-1 where the total number of clauses are m.

Given Almost-SAT problem can be described as follows:

**Input**– Conjunctive normal forms of*m*clauses and*n*literals in Boolean formula**Output**– If exactly*m-1*clauses are evaluated to*TRUE*, then assignment of literals is returned, otherwise*NO*.

To prove a problem NP-Complete, there are two steps involved:

- Prove given problem belong to NP Class.
- All other problems in the NP class can be polynomial time reducible to that problem. (This is the prove of being NP-Hard)
Now it is not possible to reduce every NP problem to another NP problem to prove it’s NP completeness all the time. That’s why we show that any known NP complete problem is reducible to that problem in polynomial time.

__Proof:__

To prove that Almost-SAT is NP-complete we need to prove the above two conditions.

**1. Almost-SAT belongs to NP Class:** A problem is classified to be in NP Class if the solution for the problem can be verified in polynomial time.

- So, given an input to Almost-SAT and a solution
**S***,*we can check whether each literal is evaluated to TRUE/FALSE*,*and there are**n**literals in a clause. - So time complexity is
**O(n)**per clause, and there are**m**clauses. - So total running time is
**O(nm)**, which is polynomial in nature. So Almost-SAT belongs to the NP Class.

**2. Almost-SAT is an NP-Hard Problem:**

Now we need to show that MAX-SAT is ass hard as a known NP-Complete Problem. By using a reduction strategy we can show that MAX-SAT is as least as difficult as a known NP-Complete Problem (the known problem here will be the **SAT problem**). See here for the “Proof of SAT Is an NP-Complete“.

We are going to show the reduction from

SAT -> Almost-SAT

**Input Conversion:** We need to transform the SAT input to Almost-SAT input.

In SAT, we are given a function **f** in CNF form with **n** literals and **m** clauses. The input function for Almost-SAT will be **f’** with **m’** clauses and **n’** literals.

To transform the given input from SAT -> Almost-SAT

- Take SAT problem input in CNF form
**f**with**n**literals and**m**clauses. - Add a new literal
**u**and its negation such as:

f’ = f ∧ u ∧ ¬u

In Almost-SAT, the number of clauses is **m’ = m + 2**. Because we only need to add one variable and its negation, the transformation will be O(1), and the input conversion will be polynomial in time.

**Output Conversion:** We need to transform the output from Almost -SAT to output to SAT

- If Almost-SAT returns NO, then return NO for SAT.
- If Almost-SAT returns the solution as the assignment of literals then return the same solution for all literals except the newly added one
**u**and**¬u***.*

Assigning values to **n** literals requires **O(n)** time, resulting in polynomial output conversion.

**Correctness:** Now we need to prove the correctness of the claim which says

f is satisfied ↔ f’ is satisfied

**Forward Implication:****f**is satisfied then**f’**is satisfied i.e**f →f’**- We will set the value of
**u = TRUE**in a given assignment in which**f****u = FALSE**in**f’**, this means**m+1 = m’-1**, therefore exactly**m’-1**clauses will be satisfied in**f’**. - So the solution for
**f**will likewise satisfy**f’**. This demonstrates forward implication.

- We will set the value of
**Reverse Implication:****f’**is satisfied then**f****f’ →f**- If
**f’**is TRUE for a particular assignment, then either**u****¬u**can be set to TRUE, and the**m’-1**clauses should be true. - So, out of the total
**m’**clauses, either**u**or**¬u**will be FALSE, while the rest will be TRUE, indicating that we may simply delete the values for both**u**and**¬u**, resulting in the satisfaction of assignment for**f**. - This demonstrates the reverse implication

- If

So, this means that claim **f is satisfied ↔ f’ is satisfied** is correct.

__Conclusion:__

So, Almost-SAT is an NP-Complete problem.