Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views

5 - Algorithms For Some Classes of Propositional

This document summarizes algorithms for solving propositional satisfiability problems, specifically for conjunctive normal form (CNF) formulas. It discusses that: 1) CNF satisfiability can be reduced to 3CNF satisfiability by replacing clauses with more than 3 literals with multiple 3-literal clauses. 2) 2CNF satisfiability can be solved in polynomial time by checking for paths between variables and their negations in a directed graph, or using resolution to derive an empty clause. 3) Finding an assignment that maximizes the number of satisfied clauses (MAX-SAT) is NP-hard, but randomization gives a 7/8 approximation algorithm for 3CNF formulas.

Uploaded by

kunjbhai
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

5 - Algorithms For Some Classes of Propositional

This document summarizes algorithms for solving propositional satisfiability problems, specifically for conjunctive normal form (CNF) formulas. It discusses that: 1) CNF satisfiability can be reduced to 3CNF satisfiability by replacing clauses with more than 3 literals with multiple 3-literal clauses. 2) 2CNF satisfiability can be solved in polynomial time by checking for paths between variables and their negations in a directed graph, or using resolution to derive an empty clause. 3) Finding an assignment that maximizes the number of satisfied clauses (MAX-SAT) is NP-hard, but randomization gives a 7/8 approximation algorithm for 3CNF formulas.

Uploaded by

kunjbhai
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CS601: Notes on logic

5. Algorithms for some classes of Propositional


Satisfiability

Somenath Biswas
CSE, IITK.

1 Formulas in normal forms

We know that every propositional formula can be represented in certain


normal forms. Two well-known normal forms are: conjunctive normal form
(CNF), and disjunctive normal form (DNF). We recall the definitions.

Definition 1 A CNF formula is a conjunction of clauses, where each clause


is a disjunction of literals, each literal being either a propositional variable
or its negations.
A DNF formula is a disjunction of terms, where each term is a conjunction
of literals.

An important subclass of CNF formulas is k-CNF formulas which is defined


as:

Definition 2 A CNF formula is called a kCNF formula if each clause in


the formula has exactly k literals.

2 Satisfiability of normal form formulas

Checking satisfiability of a DNF formula is trivial– clearly such a formula


is satisfiable iff any of its terms is satisfiable, where a term is satisfiable
iff it does not contain both a propositional variable and the negation of

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.

2.1 2CNF satisfiability

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.

Thus, the 2CNF satisfiability redeuces to the reachability problem in di-


rected graphs. Since checking whether or not a vertex is reachable from
some other vertex in a directed graph can be done in time linear in the size
of the graph, what we have outlined above can be implemented in O(n3 )
time.

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 )

provided one of ai , bj is a propositional variable, and the other is the negation


of the same variable.

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).

It is not difficult to see that

Fact 7 For every finite set S of clauses, Resolution-closure(S) exists, and


is finite.

Another important definition is:

Definition 8 An empty clause is a clause with no literals in it.

Now we state a very important result which is the basis of resolution based
theorem proving programs:

Fact 9 A finite set S of clauses is unsatisfiable iff Resolution-closure(S)


contains the empty clause.

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

Claim 11 Resolution-closure(S) of a set of n two literal clauses can have at


most 4n2 + 2n + 1 clauses. Therefore, we can compute Resolution-closure(S)
in time polynomial in S.

Therefore, a polynomial time algorithm to test satisfiability of a 2SAT for-


mula is to first compute the Resolution-Closure(S) where S constitutes the
set of clauses in the formula. Report ‘unsatisfiable’ if the closure set contains
the empty clause, else report ‘satisfiable’.

Remark. A CNF formula is said to be a Horn formula where every clause


has at most one non-negated literal. Testing for satisfiability of Horn for-
mulas can also be done in polynomial time. Similarly, if a CNF formula has
at most one negated literal per clause, then its satisfiability can be reduced
to a Horn formula satisfiability, therefore efficiently solvable. Apart from
these classes, the affine class of formulas is also known to admit efficient
satisfiability testing.

3 MAX-SAT: an optimization version of satisfia-


bility problem

Suppose we are given a CNF formula with n clauses. An optimization


problem is: find an assignment of truth values to the propositional variables
which maximizes the number of clauses in the formula evaluating to true.
This problem is known as MAX-SAT.
Clearly, if we could efficiently solve MAX-SAT, then we would be able to
solve CNF satisfiability also efficiently. As there is evidence that the latter is
unlikely, we cannot hope to have an efficient algorithm for MAX-SAT. There-
fore, we discuss below approximation algorithms for MAX-SAT: algorithms
which will run in polynomial time and will output a truth assignment which
has a certain performance guarantee. Usually, this guarantee is of the form
that there is some non-zero fraction α, such that on all instances of MAX-
SAT, the ratio of number of clauses satisfied by the assignment found by the
approximation algorithm, to the number of clauses satisfied by the optimal
assignment, is at least α. Such an alogorithm is called an α-approximation
algorithm.

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.

The Fact above gives us a very simple 1/2–approximation algorithm for


MAX-SAT. We can do far better using randomization.

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.

Proof: Consider a 3CNF formula ψ with n clauses, and a random assignment


to its propositional variables. Let Xi be a random variable which takes the
value 1 if the ith clause of ψ evaluates to true under the random assignment,
else the Xi takes the value 0. The clause i evaluates to false when all its
literals get the value false, and clearly this happens with probability (1/2)3 ,
i.e., 1/8. The expected value E[Xi ] therefore, is 7/8.
We define another random variable X,

n
def X
X = Xi
i=1

Clearly, X takes as value the total number of clauses of ψ that evaluates to


true under the random assignment. Now,
n
X n
X
E[X] = E[ Xi ] = (E[Xi ])
i=1 i=1

(We get the second equality using linearity of exectations).

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

Remark. We see that all we need to do to satisfy 7/8th of the clauses in


the average is to simply use a random assignment. This is an example of
randomized approximation algorithm. We should mention here that there
also exists a deterministic 7/8-approximation algorithm for MAX-SAT. In
fact, even better approximation algorithms are known too. From a recent
area called probabilistically checkable proofs, one can obtain an upper bound
on the factor α of approximation. Current research one direction is trying
to get as low an upper bound as possible; and in the other direction, en-
deavouring to get as high a lower bound, by designing better and better
approximation algorithm for the problem.

You might also like