3.1 Davis–Putnam ....................................... 2
3.2 Davis–Putnam–Logemann–Loveland ........................... 3
Satisfiability,the firstNP-completeproblem, 1 isaclassicproblemin constraintsatisfaction. Inthis lecture, we describe complete and incomplete algorithms designed to solve satisfiability. Given a formula of propositional logic, complete methods, such as Davis–Putnam, are guaranteed to find a satisfying assignment, if one exists; on the other hand, incomplete methods such as GSAT and WalkSAT, which are based on local search techniques, need not return a satisfying assignment even if one exists, but perform surprisingly well in practice.
Let A = {x1 ,...,xn} be an alphabet of propositional variables. Elements of this alphabet are called positive literals. For each positive literal x ∈A, there exists the corresponding negative literal ¬x. A set ofliterals,bothpositive and negative,forms a clause, and a formula consists of a set of clauses. By convention, a clause is interpreted as the disjunction of its literals, whereas a formula is interpreted as the conjunction of its clauses. Formulas expressed in this way are said to be in conjunctive normal form.
A truth assignment is a function v : A→{t, f}. Atruth assignment overpropositional variables can be extended to a truth assignment over literals as follows: if v(x)= t, then v(¬x)= f; otherwise, if v(x)= f, then v(¬x)= t. Given a truth assignment, a literal is said to be satisfied iff it is assigned the value t. A conjunction is satisfied iff all its conjuncts are satisfied. A disjunction is satisfied iff at least one of its disjuncts are satisfied. Given a CNF formula φ of propositional logic,the satisfiabilityproblem(SAT) canbe stated asfollows:
1 An NP-complete problem is a decision problem for which a solution can be verified in polynomial time, but there is no known efficient means of generating such a solution in the first place.
“does there exist a truth assignment under which φ is satisfied?”
If such an assignment exists, then φ is satisfiable. Otherwise, φ is unsatisfiable.
Remark: An arbitrary formula ofpropositionallogic constructed using the connectives ¬, ∧, ∨, → , ←, ↔ and an alphabet of propositional variables can be systematically converted into a CNF formula.
Example: The negation of the formula
(A → (B → C))→ ((A → B)→ (A → C))
can be converted into CNF as follows:
¬((A → (B → C))→ ((A → B)→ (A → C))) iff ¬(¬(¬A ∨ (¬B ∨ C))∨ (¬(¬A ∨ B)∨ (¬A ∨ C))) iff (¬A ∨ (¬B ∨ C))∧ ((¬A ∨ B)∧¬(¬A ∨ C)) iff (¬A ∨¬B ∨ C)∧ (¬A ∨ B)∧ A ∧¬C
The logical laws used in this derivation are as follows: (A → B)↔ (¬A ∨ B)(line 2); the law of double negation: ¬¬A ↔ A (line 3);and, DeMorgan’s law: ¬(A ∨ B)↔¬A ∧¬B (lines 3and 4).
The original satisfiability algorithm, due to Davis and Putnam, involves repeated application of the resolutioninference rule ofpropositionallogic(seeLecture09):
x ∨ y1 ∨ ... ∨ yn ¬x ∨ z1 ∨ ... ∨ zn
y1 ∨ ... ∨ yn ∨ z1 ∨ ... ∨ zn
Animprovement uponthis algorithm,DPLL(Davis,Putnam,Logemann, andLoveland),involves repeated application of unit resolution inference rule of propositional logic:
x ∨ y1 ∨ ... ∨ yn ¬x y1 ∨ ... ∨ yn
Observethatthe conclusions of thesetwo rules are satisfiableiffthe correspondingpair ofpremises is. Hence, we can reduce the problem of determining whether a pair of clauses that matches the form of one of these pairs of premises is satisfiable to one of determining whether a clause that matches the form of the corresponding conclusion is satisfiable.
Given aformulaφ , theDavis-Putnam(DP)procedure(seeTable1)tackles the satisfiabilityproblem by attempting toapply theresolution ruletoeach variablethat appearsin φ in turn. DP simplifies φ down to φ ′ , until either φ ′ contains the empty clause, which is not satisfiable, implying that φ itself is not satisfiable; or φ ′ can be simplified no further but does not contain the empty clause, implying that φ itself is satisfiable.
DP(φ)
Inputs CNF formula φ
Output satisfiable or unsatisfiable
Initialize N = number of propositional variables in φ
1. for i =1 to N
i. ψ = resolution(C1 ,C2 ): i.e., ψ = C1 \{x}∪ C2 \ {¬x}
ii. eliminate any redundancies that appear in ψ
iii. if ψ = {}, return unsatisfiable
iv. if ψ is not tautological, R = R ∪{ψ}
(d) Cx = {C ∈ φ | x ∈ C or ¬x ∈ C}
(e) φ = φ \ Cx ∪ R
2. return satisfiable
Table 1: Davis–Putnam.
In addition to the application of resolution, after resolving clauses of the form {x, y} and {¬x, y} on variable x, DP simplifies the resolvent {y, y} to {y}; and after resolving clauses of the form {x, ¬y} and {¬x, y} on variable x, DP omits the resolvent {¬y, y} since it is tautological.
A tautology is a formula whichis true under all truth assignments. Aformulais a tautology iff its negation is unsatisfiable. We can use Davis-Putnam to show that φ ≡ (A → (B → C))→ ((A → B)→ (A → C))is a tautology by determining that the negation of φ is unsatisfiable.
The negation of φ, in conjuctive normal form, is: {{¬A, ¬B, C}, {¬A, B}, {A}, {¬C}}. First select variable A. Resolving all clauses that contain A and ¬A yields: {{¬B, C}, {B}, {¬C}}. Next select variable B. Resolving all clauses that contain B and ¬B yields: {{C}, {¬C}}. Lastly, select variable C. Resolving all clauses that contain C and ¬C yields the empty clause. Therefore, the negation of φ is unsatisfiable: i.e., φ is a tautology.
Unlike the originalDavis-Putnam algorithm, whichcannot construct a satisfying assignment,DPLL does return a satisfying assignment, if one exists. (In fact, withthe appropriate extensions, DPLL is capable of returning all satisfying assignments.) DPLL incorporates the following three ideas (whichspecialize forward checking in CSPs to satisfiability):
1. eliminate singleton clauses: Given singleton clause {l}, remove all clauses that contain the literal l, including the singleton clause itself, and remove all occurrences of the literal ¬l in other clauses. Moreover, if l = x, then let v(x)= t; else if l = ¬x, then let v(x)= f. (This step, which implements unit resolution, is called unit propagation.)
DPLL(φ, v)
| Inputs | CNF formula φ |
| truth assignment v | |
| Output | satisfying assignment v or fail |
Table 2: DPLL. If DPLL fails, then the formula φ is unsatisfiable.
DPLL can be augmented with heuristics for selecting the next variable on which to branch, such as: select the variable that occurs most often; select the variable that induces the most unit propagations. Branching decisions can have tremendous impact on the size of the search space.
Reduce(φ, l) Inputs CNF formula φ, literal l Output reduced CNF formula φ ′ Initialize = ∅
φ ′ for all C ∈ φ
1. if ¬l ∈ C, then φ ′ = φ ′ ∪{C \ {¬l}}
2. /* else ifl ∈ C, then φ ′ = φ ′ */ return φ ′
Table 3: DPLL: Reduce Subroutine.
As an example, consider the formula φ = {{x, ¬y, ¬z}, {¬x, y, ¬z}, {¬x, ¬y, z}}, which contains no singleton clauses nor pure literals. To branch on the variable x, DPLL recurs on the formula φ ∪ {{x}}, which contains the singleton clause {x}. DPLL eliminates {x}, {x, ¬y, ¬z}, and any occurrences of theliteral ¬x. Next, DPLL checks the satisfiability of φ ′ = {{y, ¬z}, {¬y, z}}, which contains no singleton clauses or pure literals. To branch on the variable y, DPLL recurs on the formula φ ′ ∪ {{y}}, which contains the singleton clause {y}. DPLL eliminates {y}, {y, ¬z}, and any occurrences of the literal ¬y. Next, DPLL checks the satisfiability of φ ′′ = {{z}}. Since φ ′′ is easily satisfiable, DPLL returns the satisfying assignment v(x)= v(y)= v(z)= t.
Exercise: Trace DPLL on the formula φ = {{¬A, ¬B, C}, {¬A, B}, {A}, {¬C}}.
Some of the most powerful algorithms for solving satisfiability are hill-climbing-style algorithms that viewsatisfiability as anoptimizationproblem. Thesealgorithms returnsatisfying assignments whenthey arefound;butthey arenotguaranteed to find asatisfying assignment,evenif oneexists.
Consider an instance of SAT with n distinct propositional variables and m disjunctive clauses. Viewed as an optimization problem, the set of states V is the set of truth assignments. If SAT is viewed as a maximization problem, the objective function Obj(v) ≤ m denotes the number of clauses that are satisfied in state v; alternatively, if SAT is viewed as a minimization problem, Obj(v)≥ 0 denotes the number of clauses that are not satisfied in state v.
GSAT is one specialization of hill-climbing that is tailored to the satisfiability problem. States are assignments of the n propositional variables to {0, 1}. A convenient representation for such an assignment is a bit string bn ∈{0, 1}n, where bi denotes the truth value of the ith propositional variable. Based on this state representation, GSAT uses the following neighborhood operation. N(v)is the set of states that are reachable from v via exactly one bit flip: i.e.,
N(v)= {u ∈ V | HammingDistance(u, v)=1}
Given start state v = {v(P )= t, v(Q)= f, v(R)= t, v(S)= f, v(T )= t}, we now trace the behavior of GSAT on the following formula:
(P ∨ Q ∨ R)∧ (¬P ∨ R ∨¬T )∧ (Q ∨¬R ∨ S)∧ (¬R ∨ S ∨¬T )∧ (P ∨ R ∨ T )
Representing the start state as a bit string yields v =10101. At state v,(assuming minimization) the objective function Obj(v)=2((Q ∨¬R ∨ S)and(¬R ∨ S ∨¬T )are not satisfied), and
N(v)= {00101, 11101, 10001, 10111, 10100}
The truth values of the clauses are listed below, for each successor state. All clauses are satisfied at
state 10111: i.e., Obj(10111) state 10111.
u ∈ N(v) P ∨ Q ∨ R 00101 T 11101 T 10001 T 10111 T 10100 T
=0. Therefore, GSAT terminates after a single iteration at optimal
¬P ∨ R ∨¬T T T F T T
Q ∨¬R ∨ S F T T T F
¬R ∨ S ∨¬T F F T T T
| P ∨ R ∨ T | Obj |
| T | 2 |
| T | 1 |
| T | 1 |
| T | 0 |
| T | 1 |
Exercise: Rerun the GSAT algorithm on this sentence starting at state 00000.
In practice, GSAT implements the “force-best-move” heuristic, which forces it to accept some move, evenif thebest-movebeyond thecurrentstateisnotinfact animprovement. Thisapproach enables the algorithm toproceedbeyondlocal optima. TheGSAT algorithmisdepictedinTable 4.
GSAT(φ, N, M)
| Inputs | CNF formula φ |
| number of restarts N | |
| number of trials per restart M | |
| Output | satisfying assignment v or fail |
for i =1 to N
1. initialize random start state: i.e., random assignment v
(a) for j =1 to M
i. if v satisfies φ, return v
ii. let v ∈ argminu∈N (v) Obj(u)
fail
Table4: GSAT:Selman,Levesque,andMitchell[1992]. Ifanincompletesearch methodlike GSAT fails, then no satisfying assignment was found—however, a satisfying assignment might still exist.
GSAT with random walks is a probabilistic variant of GSAT inspired by Papadimitrou’s random walk algorithm for 2SAT, 2 which finds a satisfying assignment in O(n2 ) bit flips for any 2SAT formula with n variables, with probability 1. Given 2SAT formula φ,
REPEAT
UNTIL all clauses are satisfied
GSAT + Walk, that is, with random walks, acts like GSAT with probability p, but otherwise chooses an unsatisfied clause C ∈ φ at random; chooses a variable x ∈ C at random; and flips the assignment of x. (See Table 5.)
Empirically, the best algorithm for solving SAT is known as WalkSAT. Like GSAT + Walk, WalkSAT flips the assignment of some variable x that appears in an unsatisfied clause C. Doing so instantly renders C satisfied,butalsohas atendency to render somepreviously satisfied clauses unsatisfied. The break-value of a variable x at state v is defined as the number of clauses that are satisfiedby v butbreak when the value of x is flipped. Withprobability p, WalkSAT greedily flips the value of a variable x ∈ C of minimalbreak value,forsomeunsatisfied clause C ∈ φ. Otherwise, WalkSAT flips the value of a random variable x ∈ C.
2 The kSAT problem restricts the number of literals per clause to k. 2SAT can be solved in polynomial time.
GSAT+Walk(φ, N, M, p)
Inputs CNF formula φ number of restarts N number of trials per restart M probability p
Output satisfying assignment v or fail
for i =1 to N
1. initialize random start state: i.e., random assignment v
(a) forj =1 to M
i. if v satisfies φ, return v
ii. with probability p
A. let v ∈ argminu∈N(v) Obj(u)
iii. with probability 1− p
A. choose unsatisfied clause C ∈ φ at random
B. choose variable x ∈ C at random
C. let v ← v with bit x flipped
fail
Table 5: GSAT+Walk [Selman, Kautz, and Cohen, 1994]. If GSAT+Walk fails, then no satisfying assignment was found—still a satisfying assignment might exist.
WalkSAT(φ, N, M, p)
| Inputs | CNF formula φ |
| number of restarts N | |
| number of trials per restart M | |
| probability p | |
| Output | satisfying assignment v or fail |
for i =1 to N
1. initialize random start state: i.e., random assignment v
(a) forj =1 to M
i. if v satisfies φ, return v
ii. choose unsatisfied clause C ∈ φ at random
iii. with probability p
A. choose a variable x ∈ C of minimal break-value
fail
Table 6: WalkSAT [Selman, Kautz, and Cohen, 1994]. If WalkSAT fails, then no satisfying assignment was found—still a satisfying assignment might exist.