5 - Algorithms For Some Classes of Propositional
5 - Algorithms For Some Classes of Propositional
Somenath Biswas
CSE, IITK.
1
the variable. For CNF formulas on the other hand, no efficient algorithm
is known, and it is unlikely that such an algorithm exists (as the set of
satisfiable CNF formulas constitutes an NP-complete set).
Net we show that the problem of general CNF satisfiability is no harder
than 3CNF satisfiability.
Claim 3 Given any CNF formula ψ, one can efficiently obtain a 3CNF
formula ψ1 such that ψ is satisfiable iff ψ1 is.
Proof: The proof is by replacing each clause that does not have exactly three
literals equivalently by a number of clauses. By ‘equivalently’ we mean that
when a clause is thus replaced, the formula that results is satisfiable iff the
old formula was. The essential idea comes from resolution which we will see
later.
Clauses which have less than three literals cause no problem, each such clause
can be replaced equivalently by a number of 3CNF clauses. For example,
(p∨q) can be replaced by the two clauses (p∨q∨y), (p∨q∨¬y), where y is a
new propositional variable.
A clause with more than three literals can also be equivalently replaced by
a number of clauses with exactly three literals. Consider the clause
(l1 ∨l2 ∨ · · · ∨lm )
This is clause can be equivalently replaced by the following two clauses:
(l1 ∨l2 ∨ · · · ∨ldm/2e ∨yi ), and
(ldm/2e+1 ∨....∨lm ∨¬yi )
where yi is a new variable.
Because, if the replaced clause evaluated true in an assignment then one of
its literals got the truth value true in the assignment. This literal occurs in
one of the new clauses, hence that clause evaluates true under the same as-
signment. The other clause can be made to get truth value true by assigning
an appropriate value to the new variable yi .
On the other hand, consider any assignment in which both the new clauses
get the truth value true. It is not possible that all literals of the original
clause to get false in this assignment in which case, the two new clauses
simplify to (yi ) and (¬yi ), therefore the same assignment would satisfy the
original clause too.
2
Use the above idea recursively to replace every clause with more than three
literals equivalently by a number of clauses with exactly three literals.
We notice that in the proof above, we cannot use the idea for getting smaller
cluases from bigger clauses for breaking down a clause with three literals
equivalently to clauses with two literals. In fact, the case of 2CNF is very
different from 3CNF– we do have efficient algorithms to check 2CNF satis-
fiability. We shall give two different algorithms.
First algorithm
Let Φ be a 2CNF formula built from n propositional variables y1 , y2 , . . . , yn .
Build a directed graph GΦ with 2n vertices as follows. Each vertex of the
graph represents a propositional variable or its negation. Put an edge from
the vertex that represents the literal li to the vertex representing the literal
lj , if a clause in Φ implies the implication (li ⇒lj ); notice that a 2CNF clause
(a∨b) implies two implications: (¬a⇒b), and (¬b⇒a).
Claim 4 The formula Φ is not satisfiable iff there are two vertices in GΦ ,
one representing a propositional variable and the other representing the nega-
tion of the same variable, such that there is a path in the graph from each
vertex to the other.
Second algorithm
We show another way of obtaining a polynomial time algorithm for 2CNF
satisfiability using the notion of resolution.
3
Definition 5 A clause (a1 ∨a2 ∨ · · · ∨am ) can be resolved with another clause
(b1 ∨b2 ∨ · · · ∨bn ) where ai s, bi s are literals, to obtain the clause
(a1 ∨a2 ∨ · · · ai−1 ∨ai+1 · · · ∨am ∨b1 ∨b2 ∨ · · · bj−1 ∨bj+1 · · · ∨bn )
Suppose we start with a finite set S of clauses. Resolving two clauses in the
set, we may get a new clause not in S. Keep augmenting S with all such
new clauses. We keep on resolving pairs of clauses, and augmenting S with
new clauses, till the set S can be augmented no more.
Definition 6 The final set that results from S by the above process is called
the Resolution-closure(S).
Now we state a very important result which is the basis of resolution based
theorem proving programs:
We proceed to use the above to get an efficient algorithm for 2SAT satisfia-
bility.
It is easy to see that
Fact 10 When two clauses are resolved, each with at most two literals, then
the resultant clause too will have at most two literals.
4
From this we can argue that
5
First, a simple result. In any CNF formula with n clauses either there are
at least dn/2e clauses each with one or more negated literals, or not. In the
former case, the truth assignment that sets false to all propositional variables
will satisfy at least dn/2e clauses, and in the latter case the assignment
setting every variable to true will satisfy at least dn/2e clauses. Therefore,
Fact 12 For any CNF formula with n clauses, it is trivial to find a truth
assignment that will satisfy at least dn/2e clauses of the formula.
Claim 13 For any 3CNF formula with n clauses, the expected value of the
number of clauses satisfied by a random assignment1 is 7n/8.
n
def X
X = Xi
i=1
Therefore, as each individual term inside the last sum is 7/8, we get that
1
By a random assignment we mean that the assignment is obtained by setting every
propositional variable true with probability 1/2, (and therefore, false with probability 1/2)
independently of the other variables.
6
E[X] = 7n/8