The Davis-Putnam-Logemann-Loveland procedure is a decision procedure for CNF formulae in propositional logic. To prove logical consequence take the axioms and negated conjecture in CNF, and check for unsatisfiability.
function DPLL(S) { if (S is empty) { return("satisfiable"); } while (there is some unit clause {p}, or some pure literal p) { if ({p} and {~p} are both in S) { return("unsatisfiable"); } else { S = Simplify(S,p); } } if (S is empty) { return("satisfiable"); } pick some literal p from a shortest clause in S; if (DPLL(Simplify(S,p))=="satisfiable") { //----Assign it TRUE return("satisfiable"); } else { return(DPLL(Simplify(S,~p)); //----Assign it FALSE } } function Simplify(S,p) { delete every clause in S containing p; delete every occurrence in S of ~p; return(S); }
Example | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
S1 = { ~n | ~t, m | q | n, l | ~m, l | ~q, ~l | ~p, r | p | n, ~r | ~l, t }
|
Example | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
S1 = { p | q | r, p | q | ~r, p | ~q | r, p | ~q | ~r, ~p | q | r, ~p | q | ~r, ~p | ~q | r }
|