An overview of the AC-3 Algorithm on which this SAT-Solver is based.
Variable - This refers to a single variable in an expression. For example, the expression a = b + c
contains three variables: a
,b
and c
.
Domain - The domain of a variable is the set of all possible values it can take. If a
is a binary variable, then it's domain is {0, 1}
because these are the only values a binary variable can take. If b
is an 8-bit binary number, then it's domain is {0 .. 255}
. We will refer to the domain of variable X
using D(X)
.
Constraints - The domain of a variable may be constrained to be smaller than it could possibly be. For example if we say that a = b + c
and that a = 10
, then this limits the possible values which b
and c
can have in order for a = 10
to be satisfiable. We have constrained the set of possible values of b
and c
.
The inputs to AC-3 are:
X
, where D(x)
returns the domain of the variable x
, which is a member of the set X
U
which constrain the domains of individual variables in 'X' in relation to themselves.B
which constrain pairs of variables x,y
in X
such that they meet some condition.For an expresion of the form a = b + c
to be satisfiable under the constraint a == 10
, there must be some values in the domains D(b)
and D(c)
such that when we add them together, we get 10.
We can start by narrowing the domains of our input variables such that all of the unary constraints are satisfied:
Next, we construct a set of pairs of variables, where there is some relation between those variables implied by the set of binary constraints B
. We will call this set W
.
We now iterate over all of the pairs (x,y)
in W
and remove values from the domains of x
and y
which do not satisfy the relation. If at any point we find a variable which has an empty domain, we stop. A variable with an empty domain has no value it can legally take without resulting in a contradiction, therefore the expresison in question is not satisfiable.