Tractable classes of satisfiability problems
We now discuss two special cases of satisfiability problems that can be solved in polynomial time, Horn SAT and 2-SAT. These problems define subclasses of general CNF formulas which satisfy some specific structure. By restricting the expressive power of the language, these subclasses of problems become easier to solve. The algorithms for solving these problems are essentially based on unit propagation.
Horn SAT
We begin with the relevant definitions for a Horn formula:
- A literal is a positive literal if it is some variable. A literal is a negative literal if it is the negation of some variable.
- A clause is positive if all of the literals are positive. A clause is negative if all of the literals are negative.
- A clause is Horn if it has at most one literal that is positive. For example, the implication is equivalent to which is horn.
- A formula is Horn if it is a formula formed by the conjunction of Horn clauses. For example, the formula is Horn while is not Horn.
Lemma: Let be a set of unsatisfiable clauses. Then contains at least one positive clause and one negative clause.
Proof: Suppose that the formula contains no positive clause. Then every clause contains at least one negative literal. We can satisfy the formula with a truth assignment that assigns false to all of the variables.
Theorem: Let be a set of Horn clauses. Let be the set of clauses obtained by running unit propagation on . Then is satisfiable if and only if the empty clause does not belong to .
Proof (): If the empty clause belongs to , then cannot be satisfiable because unit propagation is sound.
Proof (): If is horn, then is also horn. Assume is unsatisfiable. By Lemma 1, contains at least 1 positive clause and 1 negative clause. A clause that is both positive and horn must either be a unit clause or an empty clause. We cannot derive a unit clause since we’ve run unit propagation until a fixed point, so there must exist an empty clause.
2-SAT
A formula is in k-CNF if it is in CNF and each clause has at most k literals. For example, the formula is in 2-CNF while is not in 2-CNF. The following algorithm can be used to determine the satisfiability of a 2-CNF formula in polynomial time.
- while is not empty do:
- if then
- if then return unsatisfiable
- if then
- Return satisfiable
Lemma: If is a 2-CNF formula in which the literal occurs, then either:
- UP contains the empty clause , so .
- UP is a proper subset of .
Proof: For each clause, we consider one of the three cases.
- If the clause contains , then the clause is satisfied.
- If the clause contains , then this clause becomes a unit clause and unit propagation is triggered.
- Otherwise, the clause remains unchanged.
Proof of correctness (): If the algorithm returns satisfiable, the formula is satisfiable since the algorithm relies on unit propagation and branching.
Proof of correctness (): Consider the formula at the beginning of the iteration in which we return unsatisfiable. Since is a 2-CNF formula, (meaning the set of clauses in is always a subset of the clauses in ), so if is unsatisfiable, then is unsatisfiable. We know that both and are unsatisfiable. This implies that is unsatisfiable, so is unsatisfiable.