This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS 473 Homework 10 Solutions Spring 2010 1. Show that 2SAT is NP-hard, or describe a polynomial-time algorithm to solve it. Solution: We describe a polynomial-time algorithm to solve 2SAT. Given a 2CNF boolean formula , the implication graph G is defined as follows. For each variable x i in , the graph contains two vertices x i and x i . For each clause ( u v ) in , the graph contains two edges u v and u v . (Here, x i = x i .) The disjunction ( u v ) is logically equivalent to the implications u v and v u . Thus, the graph G is a direct encoding of with edges representing implications. w x y z w x y z The implication graph for the formula ( x y ) ( y z ) ( x z ) ( w y ) ( y z ) We say that two vertices are strongly connected if there is a directed cycle in G that passes through both of them. Strong connectivity is clearly an equivalence relation; the equivalence classes are called the strong components of G . y x z x z y w w 1 2 3 4 Strong components of the implication graph shown above. We claim that is satisfiable if and only if every variable x i is in a different strong component than its negation x i . = Because implication is transitive, any path from a node x to another node z indicates the implication x z . Thus, if G contains a path from a variable x i to its negation x i , then x i must be F ALSE in every satisfying assignment. Symmetrically, if there is a path from x i to x i in G , then x i must be T RUE in every satisfying assignment. Suppose G contains a cycle through both x i and x i . That cycle can be decomposed into a directed path from x i to x i and a path from x i to x i . The first path implies that x i must be T RUE in every satisfying assignment, and the second implies that x i must be F ALSE. We conclude that is not satisfiable....
View Full Document
- Spring '08