I’m having trouble understanding the DPLL algorithm for checking satisfiability of a sentence in propositional logic.
http://books.google.co.in/books?id=4fyShrIFXg4C&pg=PA250&lpg=PA250&dq=DPLL+algorithm+from+artificial+intelligence+A+modern+approach&source=bl&ots=oOoZsT8KFd&sig=pdmyUsQZZWw76guWY9eFJKyNsH0&hl=en&sa=X&ei=vBFeUOf1EMLrrQeanoG4DQ&ved=0CD0Q6AEwAw#v=onepage&q&f=false
This algorithm is taken from the book Artificial Intelligence A modern approach. I’m finding it really confusing with those many function recursions. In particular, what does the EXTEND()
function do, and what’s the purpose behind the recursive calls to DPLL()
?
2
Answers
The DPLL is essentially a backtracking algorithm, and that’s the main idea behind the recursive calls.
The algorithm is building solution while trying assignments, you have a partial solution which might prove successful or not-successful as you go on. The geniusity of the algorithm is how to build the partial solution.
First, let’s define what a unit clause is:
A unit clause is a clause which has exactly one literal which is still unassigned, and the other (assigned) literals – are all assigned to false.
The importance of this clause is that if the current assignment is valid – you can determine what is the value of the variable which is in the unassigned literal – because the literal must be true.
For example: If we have a formula:
And we already assigned:
Then
(~x1 / ~x4 / x5)
is a unit clause, because you must assignx5=true
in order to satisfy this clause in the current partial assignment.The basic idea of the algorithm is:
Termination:
You can also have a look at these lecture slides for more information and an example.
Usage example and importance:
The DPLL, though 50 years old – is still the basis for most SAT solvers.
SAT Solvers are very useful for solving hard problems, one example in software verification – where you represent your model as a set of formulas, and the condition you want to verify – and invoke the SAT solver over it. Although exponential worst case – the average case is fast enough and is widely used in the industry (mainly for verifying Hardware components)
I will note that the technique used in DPLL is a common technique used in proofs in complexity theory, where you guess a partial assignment to things, and then try to fill in the rest. For more references or inspiration as to why DPLL works the way it does, you might try reading some of the complexity theoretic material surrounding SAT (in any good textbook on complexity theory).
Using DPLL “off the shelf” actually leads to a pretty crappy solution, and there are a few key tricks that you can play to do much better! Along with Amit’s answer, I will give some practical references for understanding how realistic DPLL works:
{x1,...,xn}
, you will find that the DPLL algorithm will terminate much more quickly (in the case that the formula is satisfiable) depending on which variable you choose. You will also find that choosing correctly is (obviously) more helpful.So, at its core, SAT is a very important problem from a theoretical perspective (first NP complete reduction via Karp, interesting and tedious constructive technique that any complexity book will introduce), but also has very practical applications in model checking and software verification. If you are interested in a classic example of how to solve an NP complete problem very quickly, give a look to the implementation of industrial strength SAT solvers, it’s fun!