Max-SAT random approximation algorithm
This is a naïve approximate solution to the Max-SAT problem. If the formula has
Pseudocode
Name(f):
Input: Boolean formula in CNF form f, with variables x_i and clauses c_j.
Output: An assignment to x_i that satisified m/2 clauses.
1. Let C be the set of clauses and build assignment a : x_i |-> T/F.
2. For each x_i:
1. Let A be all the clauses in C containing the x_i literal.
2. Let B be all the clauses in C containing the not x_i literal.
3. If A is bigger than or equal to B, set a(x_i) = T and remove A from C.
4. Else set a(x_i) = F and remove B from C.
3. Return assignment a.
Run time
We loop
Correctness
We show this by induction on the number of variables.
If we have a single variable, then all clauses are either
Assume we have proven that on
Suppose we have formula
Similarly to case
When we run our algorithm on
The steps that return this assignment are identical to that of running it on the first
In the last step we consider
Therefore the assignment
clauses and we have proved the induction case for