SAT was the first problem shown to be NP-complete.
- All NP problems can be reduced to SAT.
- FInding a polynomial time algorithm for SAT proves that .
A lot of problems can be translated into SAT, hence a lot of time and effort has gone into finding the most efficient algorithms for solving instances of SAT. Modern solvers can cope with formulas with millions of literals.
Greedy SAT Algorithm
This is an example of a greedy search algorithm:
- Guess a variable assignment at random
- Evaluate your guess by counting number of satisfied clauses.
- Consider the effect of swapping a single variable from to or vice-versa.
- Update the assignment to the assignment that leads to the biggest increase in the number of satisfied clauses.
- Repeat until no further improvements are possible.
We find that this algorithm runs in polynomial time:
- Selecting a random assignment and evaluating the ‘score’ of the assignment can both be done in linear time, .
- Each iteration involves evaluating at most assignments that different in a single variable, which requires at most a polynomial number of steps.
- We can never decrease ‘score’, so we iterate at most polynomial times.
This algorithm is not complete and may sometimes report unsatisfiable when it actually is. Despite this, it is a relatively quick algorithm and may be used as the first part of a SAT solver to help improve performance.
Naive Branching SAT Algorithm
As a precursor to the DPLL algorithm, this is a divide-and-conquer algorithm for SAT solving.
- The algorithm takes two inputs:
- A set of clauses
- A partial assignment
- We branch of any variable appearing in :
- Choose to make by adding to
- Choose to make by adding to
- We eliminate any satisfied clauses from and simplify any remaining clauses.
- The remaining set of clauses is self-similar to the original set of clauses but with one fewer variable.
- Hence we can continue by recursively calling this algorithm until either:
- all clauses are satisfied and
- a conflict is detected in the partial assignment
