I must be dumb | Wonderings of a SAT geek

# I must be dumb

May 23, 2010 SAT binary clauses, hyper-binary resolution, PrecoSat msoos

Apparently, hyper-binary resolution is not easy. However, I have been reading the paper by Gershman and Strichman, and they make it sound like it’s the easiest thing of all — especially if you don’t do it the way they are doing it, of course.

Hyper-binary resolution is essentially very easy. Let’s say you have three clauses:

    -a V b
    -a V c
    d V -b V -c

(where `V` is the binary OR, `-` is the binary negation, and each line must be satisfied)

If we set `a=true` and propagate this, then we get to the result that `d=true`. Which can be coded down as the clause:

    -a V d

More interestingly, this new clause actually helps: if you only use the original 3 clauses, and you set `d = false` and propagate, nothing happens. However, if you add the new clause to the clause list, then `a=false` propagates automatically.

The way these kind of new binary clauses (like `-a V d`) could be found has been done before as follows:

1. Build graph from binary clauses: literals are vertices and there are edges between vertices `a` and `b` if there is a binary clause `-a V b`
2. Set `a=true` and propagate
3. Check if every propagated fact can be reached starting from the vertex corresponding to `a` in the graph. If it cannot be reached, add the binary clause that represents the edge.

One can say that this algorithm works perfectly. But I am a lazy coder, and I don’t want to implement a graph library into CryptoMiniSat. What’s there to do then? Well, we can achieve the same thing with data structures already present in all modern solvers!

The trick to use is that binary clauses are propagated in a very different manner than normal clauses: they have their own watchlists, and propagating binary clauses is extremely fast. So, instead of trying to fiddle with some overoptimised graph library, we can simply write a routine, called propagateBin(), which only propagates binary clauses already inside the code. We then compare the propagate() and the results of propagateBin() and if something is missing, we add it.

In fact, implementing this algorithm using the above trick is trivial. No use of graph libraries, nothing to do really, just write a 20-line propagateBin(), which itself is just a copy-paste of the first couple of lines of propagate() . A very short side-note: it’s also very fast. We can find 100’000 binary clauses in less than 0.1 seconds. Here is the commit that implements this in CrptoMiniSat. I think it makes sense even for those unfamiliar with the code.

Finally, why am I dumb? Because there must be something amiss here. I can’t believe that people much more knowledgeable in the subject didn’t come up with this idea before. So, they must have, and probably already published it, or, the idea must be really bad, missing elements or is incomplete. If it is complete, however, then hyper-binary resolution is once and for all fast and efficient. Can’t wait for someone to prove me wrong.