0

Let's say you have a boolean function that takes two numbers (in binary) and returns true if they equal sixteen:

01000 + 01000 = 10000
  8   +   8   =  16    -> true


00110 + 01000 = 01110
  6   +   8   =  14    -> false

In this example, the function takes ten inputs, let's call them abcde + fghij.

Under the hood, it is directly modeled on gate logic and uses two adders and some xnor gates to check for equivalence to the binary string 10000.

We then feed this binary function into a boolean satisfiability algorithm to find a set of inputs that yields a true output (the first example above, for example).

My question is: Would the SAT algorithm find a solution more quickly if we were to be explicit about observed constraints?

What do I mean by "observed constraints"? Well, one observed constraint might be "if either number is greater than 16, then don't bother carrying out the addition and return false".

You might include this constraint like so:

(a ^ ¬b ^ ¬c ^ ¬d ^ ¬e) ^ (f ^ ¬g ^ ¬h ^ ¬i ^ ¬j) ^ ( the function you had before )

Another constraint might be "if one number is even and the other is odd then return false".

((e ^ ¬j) v (¬e ^ j)) ^ ( the function you had before )

These boolean functions are equivalent in correctness, but in gate logic, the latter would (probably) be more efficient. Is modeling the problem the only concern when reducing to SAT, or does it help to include these observed constraints?

I realise this isn't a great example, but hopefully it explains what I'm asking.

Thanks in advance

Chris
  • 1,501
  • 17
  • 32
  • I'm a bit confused; I don't really understand what you're asking, and I'm not sure whether this is asking something about the SAT-problem? – G. Bach May 26 '13 at 21:28

1 Answers1

1

Your sample function results to true in 17 of 2^10 = 1,024 possible input combinations.

This can be implemented as a multi-level logic circuit like this: enter image description here

The main area of SAT solvers are problems where it is not feasible to enumerate all input combinations. 10 inputs is a rather modest size. SAT solvers typically have to cope with hundreds, thousands or even millions of input variables. It is pretty easy to evaluate several 100.000 input combinations (~ 20 inputs) on a PC. But it becomes inpractical if not impossible beyond billions of combinations.

The usual way is to first encode a problem in Conjunctive Normal Form (CNF) and then let the SAT solver find one solution or find the problem to be not satisfiable. It is uncommon for most SAT solvers to find all solutions.

If you have a boolean expression for your problem, you first have to translate this formula into CNF or into a format the solver is able to process. Suitable tools include bc2cnf. More general solvers like Z3 support SMT 2.0 and other formats besides CNF (aka DIMACS).

Apart from enumerating the truthtable or asking a SAT solver like Cryptominisat 2 , you could use constraint driven solvers. Other terms to ask Google include "Answer set programming".

Axel Kemper
  • 10,544
  • 2
  • 31
  • 54