ДискретнаяМатематика / Student Solutions Manual / chapter 6
.pdf(c) Stop when part (b) can no longer be implemented. 7. 1-2-3-4-5-6-7-1-4-6-1-5-7-2-4-7-3-5-2-6-3-1 1-2-5-4-3-2-10-9-11-10-5-9-8-7-11-6-4-7-6-1-3-5-8-4-1
9.Recall the discussion of satis ability in propositional logic from Section
2.3.1.One of the cases in which satis ability is easy to check is the case of 2-CNF formulas | conjunctions such as
= (:p _ :q) ^ (:p _ q) ^ (p _ :q) ^ (p _ q)
= (:p _ q) ^ (p _ :q) ^ (p _ q)
where each clause has just two literals. That is, each clause is of the form1 _ 2 where each i is either a proposition letter xi or its negation :xi .
In this problem, the negation of a literal i is the negation of i, denoted : i , and the negation of : i is i. That is, when negating : i , rst form :: i and then drop the double negation sign.
Given a 2-CNF formula 0, construct a digraph as follows. The vertices are all literals i and : i , where i is a propositional variable in the program. For each clause i _ j , add directed edges from vertex : i to vertex j and from vertex : j to i.
(a)Draw the digraph constructed for the sample formulas and given previously.
(b)Show that, for literals 1 and 2, if there is a directed trail from vertex 1 to vertex 2, then j= 1 ! 2.
(c)Call a strongly connected component of the graph self-contradictory if it includes both i and : i for some literal i. Show that if the graph has a self-contradictory, strongly connected component, thenis unsatis able.
(d)Use part ( c) to show that formula 0 is unsatis able.
(e)For a directed graph G, de ne a binary relation on the strongly
connected components of the graph as follows: C1 C2 if there are vertices a1 2 C1 and a2 2 C2 where there is a directed trail from in G from a1 to a2. Show that if C1 C2, then for every vertex a1 2 C1 and every vertex a2 2 C2, there is a directed trail in G from a1 to a2. (Remember that there is always a directed trail, of length zero, from any vertex to itself.)
(f)Continue part ( e): Show that is a partial ordering of the strongly connected components of G.
(g)Return to the graph de ned from the 2-CNF formula . Since the formula has only nitely many proposition letters, it has only nitely many literals, and the graph has only nitely many strongly connected components. For the partial ordering de ned in part (e), pick a strongly connected component C0 that is minimal in the ordering.
Assume that C0 is not self-contradictory. Start constructing a truth assignment for by setting each literal in C0 to F : that is, if xi 2 C0, set x0 to F , and if :xi 2 C0, set xi to T . Show that, if c is any clause of , either this assignment sets one of the literals in c to T , or this assignment does not assign truth values to any literal in the clause. (Such a partial truth assignment is called an autark assignment.)
(h)Challenge: Prove the converse of part ( c). (Hint: Use induction.)
(i)Challenge: Earlier we presented an algorithm to check whether a 2-CNF formula is unsatis able: Form the graph, nd the strongly connected components, and check whether any strongly connected component is self-contradictory. Analyze the complexity of this algorithm.
9.(a)
p |
q |
p |
q |
|
|||
|
|
|
p |
q |
p |
q |
|
|
||
|
φ |
|
χ |
|
|
|
9. (b) For an edge ( 1; 2) there is a clause in of the form (: 1 _ 2). (: 1 _ 2 $ 1 ! 2. The transitivity of implication now gives the result.
9. (c) If a strongly connected component contains both and : , there is an edge ( ; : ) which means there is a clause of the form _ : or a directed trail in the strongly connected component that by (b) implies a contradiction.
9. (d) The strongly connected component of the 0 contains both x1and
:x1.
9. (e) From any vertex in component C1 the strongly connected relation gives a directed trail to a1. Now use the directed trail of the relation to get to a2 and then use the strongly connected relation to get to any other vertex in C1
9. (f) We must show the relation is re exive, transitive, and antisymmetric. (e) shows the relation is transitive. Clearly, the relation is re exive by the nature of the relation strongly connected. Finally, the relation is antisymmetric if C1 C2 and C2 C1 then C1 = C2 since there is a directed trail from any vertex to any other vertex which makes all the vertices be in the same strongly connected component.
9. (g) The two strongly connected components consists of the sets of vertices fp; qg and f:p; :qg. The minimal component consists of the vertices f:p; :qg. Assign p = T and q = T .
9. (h) |
|
|
|
|
|
|
|
|
|
|
|
|
|
Lemma 0: Let G = (V; E) be a directed graph, and let C10 |
; C2; : :0: ; C0k be |
||||||||||||
its strongly0 |
connected components. De ne a new0 |
graph G |
= (V ; E ) as |
||||||||||
follows: V |
= |
C |
; : : : ; C |
k g |
. |
And (C |
; Cj ) |
2 |
E |
if i = j and there is a |
|||
directed0 |
|
|
|
fout1 |
in |
|
i |
out |
|
6 |
in |
||
edge (vi ; vj ) 2 E from some vi |
2 Ci |
to some vj 2 Cj . Then |
|||||||||||
G is a DAG. |
|
|
|
|
|
|
|
|
|
|
|||
Proof: Suppose there is cycle (Ci1 ; Ci2 ); (Ci2 ; Ci3 ); : : : ; (Cim ; Ci1 ) |
|||||||||||||
|
0 |
. |
|
|
|
|
|
|
|
|
|
|
out |
in G |
For each edge (Cih ; Cih+1 ) in the cycle, pick vih ; vih+1 |
||||||||||||
as above. Since each Ci is strongly connected, there are paths from each viin to the viout in the same component. Gluing all these together, we get a path from viout1 to viin2 to viout2 to viin3 to
. . . to vout to vin to vout. But then the vin's and vout's must all
im i1 i1 ij ij
be in the same component, contradicting the assumption that they were distinct components.
Form the graph G described at the start of the problem, and form G0 as described in Lemma 1. Topologically sort G0. For notational convenience, reorder the strongly connected components C1; C2; : : : in the order of the topological sort. The graph is not self-contradictory, for no proposition letter p are both p and :p in the same Ci.
We de ne a truth assignment I in stages.
(a)Set all literals in C1 to FALSE: that is, if p 2 C1, I(p) =FALSE, and if :p 2 C1, I(p) =FALSE.
Lemma 1: Consider, for any such p, any clause ( 1 _ 2) in which either p or :p occurs in C1. I( 1 _ 2 =TRUE.
Proof: Break into cases depending upon which literal is in C1: : 1 2 C1: Then I( 1) =TRUE, so I( 1 _ 2) =TRUE.
1 2 C1: Since ( 1 _ 2) is one of the clauses, ( 1; : 2) 2 E. Since C1 is minimal in the topological sorting, there can be no edges into C1 from outside C1, so : 2 2 C1 also. So I( 2) =FALSE, so I( 2) =TRUE, so I( 1 _ 2) =TRUE.
: 2 2 C1: Analogous to the rst case.2 2 C1: Analogous to the second case.
(b)Set all literals in C2 which have not already been given values to FALSE. Lemma 2: Consider, for any such p, any clause ( 1 _ 2) in which either p or :p occurs in C1. I( 1 _ 2 =TRUE.
Proof: Analogous to proof of Lemma 1.
(c)Continue this way until I(p) is de ned for all proposition letters p. The analogous lemmas hold.
So I is a model of the 2-CNF formula.
9. (i) Find the strongly connected components of the formula. Starting with a minimal component for the partial order, make the autark assignment. Check to see if the component is self contradictory. This can be done using an array with xi associated with entry i. Initialize the array to having entries of -1. When a literal is assigned T , change its entry to 1 and when a literal is assigned F change its entry to 0. If the assignment of a value to a literal nds the location already assigned the other value, the component is self contradictory and the formula is not satis able. Repeat this process for each strongly connected component by choosing a minimal component remaining at each step. The assignments and checks are all polynomial operations.
