You are on page 1of 3

Question: Is there a polynomial algorithm for solving 2-SAT?

Proposition 1 2SAT P.

Proof. Given a formula F on variables {x1, x2, . . . , xn},


construct a directed graph G whose vertices are
{x1, x2, . . . , xn, x1, x2, . . . , xn}.
For every clause l1 l2, add two edges to G: l1l2 and l2l1.
For example, let F = (x y) (y z) (x z) (y z).

x y z

x y z

Claim. F is satisfiable iff no strongly connected compo-


nent of G contains a variable and its negation.
=:
Let F be satisfiable and let ab be an edge in G. Then,
if val(a) = TRUE, then val(b) = TRUE.
Indeed, ab was added to the graph because of the clause
a b. Therefore, if val(a) = T RU E, then val(a) =
F alse, and val(b) = T RU E.
1
x x

For any literal x, since x and x are not both TRUE, or


both F ALSE, if there is a directed path from x to x,
then the value of xi must be FALSE.
Similarly, if there is a path from literal x to literal x, then
the value of x under any satisfying assignment must be
FALSE.
The previous imply that if F has a satisfying assignment,
then for no literal x, there are both a path from x to
x and a path from x to x. In other words, no strongly
connected component of G contains x and x.

2
=
The reverse: let no strongly connected component of G
contain xi and xi for any i [1, n]. Order the strongly
connected components C1, . . . , Cm of G in a topological
order.
The assignment: for any variable x, val(x) =TRUE
iff x appears after x; else val(x) =FALSE. To prove that
this assignment satisfies the formula, we prove
Claim: for no edge ab of the graph, vertex a assigned
TRUE and vertex b assigned F ALSE.
Proof of the Claim. Assuming it is incorrect, let edge
ab be a counterexample: val(a) = T RU E and val(b) =
F ALSE. Let a appears in the biconnected component
Bi. The reason edge ab is in the graph is clause ab which
also generated edge ba. Since val(a) = T RU E, val(a) =
F ALSE, vertex a appears before the biconnected com-
ponent Bi, say Bj where j < i. Since val(b) = F ALSE,
vertex b appears after Bi, say in Bk , where k > j. But
any edge from Bk to Bj with j < k contradicts the topo-
logical order of the biconnected components.
Now, the Claim guarantees that F is satisfied by the
assignment. Indeed, if there were a clause x y with
val(x) = val(y) = F ALSE we would have an edge xy
with val(x) = T RU E and val(y) = F ALSE, contra-
dicting the Claim.
3

You might also like