Boolean Satisfaction - SAT - PowerPoint PPT Presentation

1 / 103
About This Presentation
Title:

Boolean Satisfaction - SAT

Description:

... at placing n queens in an n*n chess board so that no two queens attack each other. ... There must be at least a queen in some sets of positions (rows and columns) ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 104
Provided by: pedroba
Category:

less

Transcript and Presenter's Notes

Title: Boolean Satisfaction - SAT


1
Boolean Satisfaction - SAT
Among all possible finite domains, the Booleans
is a specially interesting case, where all
variables take values 0/1. In Computer Science
and Engineering the importance of this domain is
obvious ultimately, all programs are compiled
into machine code, i.e. to specifications coded
in bits, to be handled by some processor. More
pragmatically, a vast number of problems may be
naturally specified through a set of boolean
constraints, coded in a variety of forms. Among
these forms, a quite useful one is the clausal
form, which corresponds to the Conjunctive Normal
Form (CNF) of any Boolean function. In such
cases, Boolean SATisfiability is often referred
to as SAT.
2
SAT Modelling
  • Example_1 n-queens
  • This is the classic problem that aims at placing
    n queens in an nn chess board so that no two
    queens attack each other.
  • Associating the presence of a queen in any of the
    n2 positions with a 0/1 variable, the problem is
    modelled through two types of constraints
  • There must be at least a queen in some sets of
    positions (rows and columns)
  • There must be at most one queen in some sets of
    positions (rows, columns and diagonals)
  • Such constraints are easily coded in clausal form.

3
SAT Modelling
  • Example_1 n-queens
  • R1 There must be at least a queen in the set
    of positions Q1 to Qn
  • 1 single n-ary clause
  • Q1 ? Q2 ? ... ? Qn
  • R2 There must be at most one queen in the
    set of positions Q1 to Qn
  • Several (n(n-1)/2) binary clauses are required
  • ? Q1 ? ? Q2 ,
  • ? Q1 ? ? Q3 ..
  • ? Q1 ? ? Qn
  • ...
  • ? Qn-1 ? ? Qn

4
SAT Modelling
Example_2 Graph Colouring Given a certain
graph, check whether it is possible to guarantee
that adjacent nodes (i.e. connected by an arc)
have different colours. This example has a less
obvious coding. Firstly, the colours have to be
coded. We notice that k colours require
ceiling(log2(k)) bits to be coded. Assuming 4
colours, each of the colour is coded in a
different combination of two boolean
variables. Hence, we boolean variables will use
Ci,1 e Ci,2 to encode the colour assigned to node
i.
5
SAT Modelling
Example_2 Graph Colouring Secondly, one must
constrain adjacent nodes to have diferent
colours. For nodes i e j, such constraint can be
coded through (Ci,1 ? Cj,1 ) ? (Ci,2 ? Cj,2 )
But a ? b ? (a ? ? b) ? (? a ? b) ? (a ?
b) ? (?a ? ?b) Hence the above constraint can be
coded as (Ci,1 ? Cj,1)?(?Ci,1 ? ?Cj,1)?(Ci,2
? Cj,2)?(?Ci,2 ??Cj,2) which is equivalent to
the four clauses Ci,1 ? Cj,1 ? Ci,2 ?
Cj,2 Ci,1 ? Cj,1 ? ?Ci,2 ? ?Cj,2
?Ci,1 ? ?Cj,1 ? Ci,2 ? Cj,2 ?Ci,1 ?
?Cj,1 ? ?Ci,2 ? ?Cj,2
6
SAT Modelling
  • Example_3 Knapsack (Decision)
  • Given
  • a set of n objects
  • each occupying a certain (integer) volume vi
  • and worth zi
  • check whether in a knapsack with volume capacity
    it is possible to place a set of objects with
    worth in total no less than Z.
  • This problem can be modelled by means of n
    boolean variables, Xi, that denote whether the
    corresponding object goes into the knapsack or
    not.
  • Hence, the constraint of not to exceed the
    capacity of the knapsack is expressed as
  • v1 X1 v2 X2 ... vn Xn lt V

7
SAT Modelling
  • Example_3 Knapsack (Decision)
  • v1 X1 v2 X2 ... vn Xn lt V
  • Although numerical, this constraint may be
    modelled with boolean constraints (clauses) by
    encoding
  • the multiplication of an integer by one bit (0/1)
  • vi Xi
  • the sum of 2 integers
  • S vi Xi
  • the comparison of 2 integers
  • S lt V

8
SAT Modelling
  • Example_3 Knapsack (Decision)
  • the multiplication of an integer by a bit (0/1)
  • Given an integer B represented in binary by bits
    Bk to B0, its multiplication by a bit X results
    in another integer M, coded with a similar number
    of bits Mk to M0, such that
  • Mi X ? Bi
  • This equality may be imposed through the
    following clauses
  • (?X ? ?Mi) ? ( X ? MiBi)
  • ? (X ? ?Mi) ? (?X ? Mi Bi)
  • ? (X ? ?Mi) ? (?X ? ( (Mi ? ?Bi) ? (? Mi ? Bi))
  • ? (X ? ?Mi) ?
  • (?X ? Mi? ?Bi) ?
  • (?X ? ?Mi? Bi)

9
SAT Modelling
  • Example_3 Knapsack (Decision)
  • the sum of 2 integers
  • Given integers A e B represented in binary with
    bits ak/bk to ak/b0, its sum S may be
    represented through the following constraints
  • First bit S0 A0 ? B0 C1 A0 ? B0
  • Last bit Sn1 Cn1
  • Other bits Si Ai ? Bi ? Ci
  • Ci1 (Ai?Bi) ? (Ai?Ci) ? (Bi?Ci)
  • that are converted in the clausal form as before.

10
SAT Modelling
  • First bit
  • S0 A0 ? B0
  • ? (S0 ? (A0 ? B0)) ? (?S0 ? ?(A0 ? B0))
  • ? (S0?((A0?B0)?(?A0??B0)))?(? S0
    ?((?A0?B0)?(A0??B0)))
  • ? (S0 ?A0??B0 )?(S0??A0?B0)?(?S0??A0??B0)?(?S0?A0
    ?B0)
  • C1 A0 ? B0
  • ? (C1 ? ?(A0 ? B0)) ? (?C1 ? (A0 ? B0))
  • ? (C1 ? ?A0 ? ?B0) ? (?C1 ? A0 ) ? (?C1 ? B)
  • Last bit
  • Sn1 Cn1
  • ? (Sn1 ? ? Cn1) ? (? Sn1 ? Cn1)

11
SAT Modelling
  • Other bits
  • Si Ai ? Bi ? Ci
  • ? (Si ? (Ai ? Bi ? Ci)) ? (?Si ? ?(Ai ? Bi ?
    Ci))
  • ...
  • ? (?Si ? Ai ? Bi ? Ci) ? (Si ? ?Ai ? ?Bi ? ?Ci)
    ?
  • (Si ? ?Ai ? Bi ? Ci) ? (?Si ? Ai ? ?Bi ? ?Ci)
    ?
  • (Si ? Ai ? ?Bi ? Ci) ? (?Si ? ?Ai ? Bi ? ?Ci) ?
  • (Si ? Ai ? Bi ? ?Ci) ? (?Si ? ?Ai ? ?Bi ? Ci)
  • Ci1 (Ai?Bi) ? (Ai?Ci) ? (Bi?Ci)
  • ...
  • ? (Ai ? Bi ? ?Ci1) ? (?Ai ? ?Bi ? Ci1) ?
  • (Ai ? Ci ? ?Ci1) ? (?Ai ? ?Ci ? Ci1) ?
  • (Bi ? Ci ? ?Ci1) ? (?Bi ? ?Ci ? Ci1)

12
SAT Modelling
  • Example_3 Knapsack (Decision)
  • the comparison (lt) of 2 integers
  • Given integers A and B, coded in binary with bits
    Ak/Bk to A0/B0, its comparison (A lt B) may use
    additional variables X0 to Xk, where Xi
    indicates that Ai ... A0 lt Bi ... B0. Hence,
  • X0 (A0 lt B0)
  • ?
  • (?A0 ? ?X0)?(A0 ? ?B0 ? X0)?(A0 ? B0 ? ?X0)
  • Xk (Ak lt Bk) ? ((AkBk) ? Xk-1) for k ? 1
  • ? ....

13
SAT and 3SAT
  • Although some clauses have more than 3 variables,
    they can always be converted in a set of clauses
    with 3 variables alone, which are equivalent.
  • Example The satisfaction of clause P
  • P A ? B ? C ? D
  • is equivalent to the satisfaction of clauses Q e
    R below
  • Q A ? B ? X and R C ? D ? ?
    X
  • where X is a new variable (i.e. resolution, the
    other way round).
  • In fact, one may prove
  • P ? Q, R if P is satisfiable Q and R are also
    satisfiable
  • Q,R ? P if Q and R are satisfiable P is also
    satisfiable

14
SAT and 3SAT
  • P A ? B ? C ? D ? Q A ? B ? X and R C ? D ?
    ? X
  • If clause P may be satisfied, then at least one
    variable A to D takes value T (1). Without loss
    of generality, let us assume it is A. Then
  • clause Q is satisfied and
  • clause R can be satisfied with X 0.
  • Q A ? B ? X and R C ? D ? ? X ? P A ? B ? C
    ? D
  • If both Q and R are satisfied, and since X T or
    XF, then
  • either clause A ? B is satisfied (for X0) or
  • clause C ? D is satisfied (for X1)
  • But then one of the variables A to D takes value
    T, guaranteeing the satisfaction of clause P A ?
    B ? C ? D.

15
Importance of SAT
As can be easily seen, many decision problems can
be modelled as Boolean satisfaction problems
(SAT). In fact, all decision problems in finite
domains may be modelled as a Boolean satisfaction
problem Hence, a general algorithm to solve
this type of SAT problems, would solve any
decision problem. Of course, one would only be
interested in having an eficient algorithm for
SAT.
16
Importance of SAT
  • A SAT problem with n variables (or rather, that
    can be described with a string with size
    proportional to n) may be solved in polinomial
    time in a non-deterministic machine.
  • (A non-deterministic machine is one that
    correctly guesses the appropriate values to the n
    variables).
  • Such decision problems, such as SAT, are thus
    problems that belong to class NP.
  • More realistically, a deterministic machine
    (those that exist) may verify, in polinomial
    time, whether a potential solution satisfies all
    the constraints, i.e. O(nk).

17
Importance of SAT
  • Considering n boolean variables, there are 2n
    potential solutions.
  • The satisfiability test with clauses on n
    variables may thus be performed with a generate
    and test procedure
  • Generate each of the 2n possibilities
  • Test each of these possibilities.
  • This procedure is of course very inneficient. In
    the worst case, it has an exponential
    complexity, O(2n).
  • Of course, not all decision problems have the
    same complexity.

18
Importance of SAT
  • For certain problems there are polinomial
    algorithms (in n) that allow decisions on the
    satisfiability of the problem.
  • Such problems, that form the class P, are clearly
    polinomial.
  • For example, many list processing algorithms,
    e.g. to obtain a sorted list of n integers from a
    non-sorted one, have quadratic complexity O(n2).
    (quick-sort has a better complexity O(n log n)).
  • For other problems, even those not in this class,
    there might be instances particularly simple to
    solve (with a certain solver).
  • For example, the knapsack is trivial if all
    objects have the same volume (not the same value
    !). A greedy heuristics that chooses first the
    most valuable items may be used.

19
Importance of SAT
  • Naturally, all problems P belong to class NP
  • if a deterministic machine solves them in
    polinomial time, so would do a non-deterministic
    machine.
  • What is not so clear is whether the class NP
    contains problems that are not P. This is, by
    now, an important conjecture, known as
  • P ? NP
  • In practice, no one has ever found any algorithm
    that solves an arbitrary instance of SAT in
    polinomial time, which suggests that P is indeed
    strictly contained in NP.
  • From a theoretical viewpoint, if that will ever
    happen, (highly improbable), than P NP.

20
Importance of SAT
  • From a more practical viewpoint, if such an
    algorithm is ever found, then all decision
    problems that are interesting, would be solved
    in polinomial time.
  • In fact, one must only guarantee that the
    transformation of the problem in a SAT problem
    takes polinomial time.
  • These transformations may usually be made in a
    way similar to that that was used in previous
    examples (queens, graph colouring and knapsack).
  • This result is one of the motivations for the
    thorough study that has been done to the SAT (or
    3SAT) problem.

21
Importance of SAT
  • The generality of the SAT approach, in which all
    decision problems may be converted, is another
    reason for the study of the SAT / 3SAT problem.
  • Although it is extremely unlikely that a general
    polinomial algorithm will ever be found, there
    are many algorithms and software packages that
    solve very satisfactorily a large number of
    instances of SAT.
  • In particular, there are SAT solvers that can
    handle problems with millions of variables and
    tens of millions of clauses.
  • However, these problems must have a structure
    random problems are harder to tackle.
  • We should however analyse the possibilities of LP
    and CLP to solve these problems.

22
SAT Solving - Generate and Test
The generation of all solutions may be obtained
by the backtracking mechanism built-in in Logic
Programming languages (e.g. Prolog). Example
queens_4(L)- generate(L), test(L),
report(L). generate(). generate(HT)-
member(H,1,0), generate(T).
test(Q1, Q2, Q3, ..., Q16)-
at_most_one(Q1,Q2,Q3,Q4), at_least_one(Q1,Q2
,Q3,Q4), ... at_most_one(Q9,Q14).
23
SAT Solving - Generate and Test
For simplicity, in program queens4_sat_gt all the
tests are programmed explicitely.
1ª line at_most_one(Q1,Q2,Q3,Q4) Q1
Q2, Q1 Q3, Q2 Q3, Q1 Q4, Q2
Q4, Q3 Q4
at_least_one(Q1,Q2,Q3,Q4), Q1 Q2 Q3
Q4,
24
SAT Solving - Generate and Test
This program queens4_sat_gt also makes use of the
usual syntatic facilities available in Logic
Programming, namely the definition of operators.
boolean operators - op(300,fy,).
negation - op(400,xfy,). disjunction
25
SAT Solving - Backtracking
  • Many potential solutions can be discarded by
    simple analysis of partial solutions.
  • For example, any potential solution that includes
    Q1 Q2 1 can be discarded, since no two queens
    can be in the same row (namely the first row).
  • A more efficient way to check the satisfaction of
    a problem is the utilization of a constructive
    method, in which partial solutions (i.e. with
    only a few variables instantiated) are being
    completed, as long as they do not violate any
    constraint.
  • If the partial solution violates any constraint,
    it is not completed. Instead, one of its values
    is backtracked, thus enabling the exploitation of
    other alternative solutions.

26
SAT Solving - Backtracking
If partial solution a b 1 violates some
constraint, (e.g. ?a ? ?b) no complete solutions
including a b 1 are worth considered. The
first solution lta,b,c,dgt lt1,0,0,1gt is thus
found avoiding the test of 6 leafs and 2 internal
nodes.
27
SAT Solving - Backtracking
  • The completion of partial solutions can be easily
    performed by the backtracking mechanism built-in
    in Logic Programming.
  • The main problem here is to guarantee that the
    tests are performed as soon as adequate. For
    example,
  • After instantiation of variables Qi and Qj, in
    the same row, they must not take both the same
    value 1.
  • ...
  • After instantiating the last variable of a row,
    it must be guaranteed that at least one of the
    variables in the row (for example, one from Q1
    to Q4 must take value 1).

28
SAT Solving - Backtracking
Again, to simplify the program, all these
checkings are performed explicitely in program
queens4_sat_bk.
queens_4(_)- label(Q1), 1st line
label(Q2), Q1 Q2, label(Q3), Q1
Q3, Q2 Q3, label(Q4), Q1 Q2 Q3
Q4, Q1 Q4, Q2 Q4, Q3 Q4, ...
the labeling uses the member predicate
label(Q)- mb(Q,0,1).
29
SAT Solving - Backtracking
As easily understood, the backtracking version is
much more efficient. The account of the tests
done and the valuations performed is maintained
by the use of counters (impure LP, using asserts
and retracts).
counting of the valuations performed mb(X,X_)
- inc(l). mb(X,_T)- mb(X,T). counting of
the tests performed X Y - exp(X Y,
Exp), inc(t), Exp gt 1.
30
Backtracking
Tests 0 Backtracks 0
31
Backtracking
Q1 Q2, ... Q1 Q8, Q1 Q9, ...
32
Backtracking
33
Backtracking
34
Backtracking
35
Backtracking
36
Backtracking
37
Backtracking
38
Backtracking
39
Backtracking
40
Backtracking
41
Backtracking
42
Backtracking
43
Backtracking
44
Backtracking
45
Backtracking
46
Backtracking
47
Backtracking
48
Backtracking
49
Backtracking
Fails 6 Backtracks 5
50
Backtracking
51
Backtracking
52
Backtracking
53
Backtracking
54
Backtracking
55
Backtracking
Fails 6 Backtracks 5 and 4
56
Backtracking
57
Backtracking
58
Backtracking
59
Backtracking
60
Backtracking
Fails 8 Backtracks 7
61
Backtracking
Fails 7 Backtracks 6
62
Backtracking
Fails 6 Backtracks 5
63
Backtracking
64
Backtracking
Fails 6 Backtracks 5
65
Backtracking
Fails 5 Backtracks 4
66
Backtracking
67
Backtracking
68
Backtracking
69
Backtracking
70
Backtracking
Fails 8 Backtracks 7
71
Backtracking
Fails 7 Backtracks 6
72
Backtracking
Fails 6 Backtracks 5
73
Backtracking
74
Backtracking
Fails 6 Backtracks 5
75
Backtracking
Fails 5 Backtracks 4 e 3
76
Backtracking
X11 X23 X35 Impossible !
77
Constraint Propagation
  • An alternative to checking the compatibility
    between the values of past variables (with
    values already assigned) consists of eliminating
    from the future variables (with values yet to
    be assigned), those values that are incompatible
    with those already assigned.
  • These alternative method should enable, and in
    many cases it actually enables
  • Detect more quickly the impossibility of
    completing a partial solution.
  • Backtrack to the relevant causes of the failure.
  • In the case of SAT, this propagation is known as
    BCP (Boolean Constraint Propagation) and occurs
    as soon as all but one of the literals of a
    clause take value 0 (FALSE) enforcing the
    remaining literal to be 1 (TRUE).

78
Constraint Propagation
  • For example, take the clause
  • c (?x1 ? x2)
  • Suppose that x1 is assigned value 1. In this
    case the clause is simplified to the unit clause
  • c x2
  • which clearly enforces x2 to become 1 (true).
  • The following slides will illustrate these effects

79
Propagation
80
Propagation
Q1 Q2, Q1 Q2, ... , Q1 Q9, ...
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Q1 1 implies Q2 Q3 ... Q8 0 Q1
1 implies Q9 Q17 ... Q57 0 Q1 1
implies Q10 Q19 ... Q64 0
81
Propagation
1
1
1
1
2
2
1
1
2
2
1
1
2
2
1
1
2
2
1
1
2
2
1
2
1
82
Propagation
1
1
1
1
2
2
3
1
1
2
2
1
1
2
2
3
3
1
1
2
2
3
3
1
1
2
2
3
1
2
1
3
83
Propagation
1
1
X6 só pode tomar o valor 4
1
1
2
2
3
1
1
2
2
1
1
2
2
3
3
1
1
2
2
3
3
1
1
2
2
3
1
2
1
3
If Q41 Q42 Q43 Q45 Q46 Q47 Q48 0
then Q44 1
84
Propagation
1
1
1
1
2
2
X8 só pode tomar o valor 7
3
1
1
2
2
6
1
1
2
2
3
6
3
1
1
2
2
3
3
6
1
1
2
2
3
1
2
6
1
3
6
6
If Q57 Q58 Q59 Q60 Q61 Q62 Q64 0
then Q63 1
85
Propagation
1
1
1
1
2
2
3
1
1
2
2
6
1
1
2
2
3
6
3
1
1
2
2
3
3
6
1
1
2
2
3
1
2
2
1
3
6
6
86
Propagation
1
1
X4 só pode tomar o valor 8
1
1
2
2
8
3
1
1
2
2
6
1
1
2
2
3
6
3
1
1
2
2
3
3
6
8
1
1
2
2
3
1
2
2
1
3
6
6
Tests 125222131
Backtracks 0
87
Propagation
1
1
1
1
2
2
8
3
1
1
2
2
6
1
1
2
2
3
6
3
1
1
2
2
3
3
6
8
1
1
2
2
3
1
2
2
1
3
6
6
88
Propagation
1
1
X5 só pode tomar o valor 2
1
1
2
2
8
3
1
1
2
2
6
1
1
2
2
3
6
4
3
1
1
2
2
3
3
6
8
1
1
2
2
3
1
2
2
1
3
6
6
89
Propagation
1
1
1
1
2
2
8
3
1
1
2
2
6
1
1
2
2
3
6
4
3
1
1
2
2
3
3
6
8
1
1
2
2
3
5
1
2
2
1
3
6
6
90
Propagation
1
1
Fails 7 Backtracks 3 !
1
1
2
2
8
3
1
1
2
2
6
1
1
2
2
3
6
4
3
1
1
2
2
3
3
6
8
1
1
2
2
3
5
1
2
2
1
3
6
6
One of Q49 , Q50 , Q51 , Q52 , Q53 , Q54 , Q55 or
Q56 should be 1 !
91
Constraint Propagation
The programming of this propagation mechanism in
Constraint Logic Programming follows the
following programming pattern. Problem (
Vars)- Variables and Domains
Declaration, Specification of Constraints,
Labelling of the Variables. In CLP, whenever a
variable is labelled, the effects of this
labelling are propagated automatically through
the relevant constraints, possibly pruning the
domains of the remaining variables. (This is
applicable in particular to constraints that
encode SAT clauses.) Whenever a domain becomes
empty, a failure is detected, and backtracking
(on labeled values) is performed.
92
Constraint Propagation
This is the programming style adopted in program
queens4_sat_fd.
Domains Declaration domain(Q1,Q2,Q3,Q4,...,Q
13,Q14,Q15,Q16,0,1) Specification of
Constraints (1st row) Q1 Q2, Q1 Q3,
Q2 Q3, Q1 Q4, Q2 Q4, Q3 Q4,
Q1 Q2 Q3 Q4, Labeling of variables
labeling(, Q1,Q2,Q3,Q4,...,Q13,Q14,Q15,Q16)
93
Constraint Propagation
The specification of constraints (in SICStus)
adopts the usual relational operators, but
preceded by the character... ... and assumes
that the module for finite domains is loaded with
command - use_module(library(clpfd)).
X Y - exp(X Y, Exp), Exp gt 1. exp(X,
X)- var(X), !. exp(X, X)- atom(X), !. exp(X,
Exp)- !, exp(X, ExpX), Exp 1-ExpX. exp(X Y,
Exp)- !, exp(X, ExpX), exp(Y, ExpY), Exp
ExpX ExpY.
94
Constraint Propagation
For example
X ?- domain(X,Y, 0,1), X Y. X in 0..1,Y
in 0..1 ? does not propagate no ?-
domain(X,Y, 0,1), X Y, X 1. X 1,Y in
0..1 ? does not propagate no ?-
domain(X,Y, 0,1), X Y, X 0. X 0,Y 1
? propagates X to Y no ?-
domain(X,Y, 0,1), X Y gt 1. X 1,Y 1 ?
propagates to X and Y no
95
Constraint Propagation
In general, solving a problem using constraint
propagation is (much) more efficient than the
alternative of using pure backtracking. In
SICStus Prolog, the measuring of efficiency can
be made with built-in predicates fd_statistics/0
and fd_statistics/2
?- fd_statistics. Resumptions 28
Entailments 2 Prunings 23
Backtracks 0 Constraints created
4 yes
96
Constraint Propagation
  • For problems as small as 4-queens, the difference
    in efficiency is not meaningful.
  • However, this is not the case with larger
    instances of the N-queens problem.
  • Such difference may be observed in the execution
    of programs
  • queens_sat_bk
  • and
  • queens_sat_fd
  • that are parameterisable to the intended
    dimension of the problem.

97
Advanced Techniques in SAT Solvers
  • Advanced SAT solvers use techniques common to
    other Finite Domains solvers, namely
  • (boolean) constraint propagation
  • Heuristics to select the next variable and value
    to select, so that search is guided towards most
    promising regions of the search space.
  • The specificity of SA, enables specialised
    solvers to use additional advanced techniques,
    not commonly used in more general FD solvers,
    namely
  • Diagnosis of failure
  • Non-chronological backtracking
  • Learning of nogood clauses

98
Advanced Techniques in SAT Solvers
  • To illustrate these techniques, we should
    consider the assignment of values to variables
    are made. Two different situations occur
  • Some assignments are explicit decisions made by
    the solver, selecting the variable and the value.
  • Other assignments are due to propagation on the
    former.
  • For example, take the following labeling on these
    3 clauses
  • c1(?x1 ? x2)
  • c2(?x2 ? x3)
  • c3(?x1 ? ?x4 ? x5)
  • A first decision (at level 1) makes x1 1
  • Propagation enforces x2 1 and x3 1
  • A second decision (at level 2) makes x5 0
  • Propagation enforces x4 0

99
Diagnosis of Failures
  • By maintaining such graph it is easy to detect
    the real causes of the failures, as illustrated
    in the graph below.
  • Clearly, the conflict has been caused by
    assignments x11, x90, x100 and x11 0,
    although it was detected in clause c6, envolving
    variables x4 and x5.

c1(?x1 ? x2) c2(?x1 ? x3 ? x9) c3(?x2 ? ?x3 ?
x4) c4(?x4 ? x5 ? x10) c5(?x4 ? x6 ?
x11) c6(?x5 ? ?x6) c7(x1 ? x7 ? ?x12) c8(x1 ?
x8) c9(?x7 ? ?x8 ? ?x13) ...
100
Learning Nogood Clauses
  • Since, the conflict has been caused by
    assignments x11, x90, x100 and x11 0, then
    one may add the clause
  • c0(?x1 ? x9 ? x10 ? x11)
  • to prevent repetition of this impossible
    assignment.

In fact, one may notice that this clause could
have been obtained throug resolution on
clauses c1 c3(?x1 ? ?x3 ? x4) c4(?x1 ?
?x3 ? x5 ? x10) c6(?x1 ? ?x3 ? ?x6 ? x10)
c5(?x1 ? ?x3 ? ?x4 ? x10 ? x11) c3(?x1 ?
?x2 ? ?x3 ? x10 ? x11) c1(?x1 ? ?x3 ? x10 ?
x11) c2(?x1 ? x9 ? x10 ? x11) But... how
could one guess?
c1(?x1 ? x2) c2(?x1 ? x3 ? x9) c3(?x2 ? ?x3 ?
x4) c4(?x4 ? x5 ? x10) c5(?x4 ? x6 ?
x11) c6(?x5 ? ?x6) c7(x1 ? x7 ? ?x12) c8(x1 ?
x8) c9(?x7 ? ?x8 ? ?x13) ...
101
Non-chronological Backtracking
  • Nogood clauses may also aid to relevant
    backtracking levels. Carrying on with the
    previous example, where it was enforced x10 due
    to the clause learned, the dependency graph
    expands to
  • Although the conflict has been detected at level
    6, by impossibility of assigning a value to
    variable x1, the cause of the conflict is at
    level 3, since the decisions taken at levels 4
    and 5 had no influence on the graph.

c0(?x1 ? x9 ? x10 ? x11) c1(?x1 ? x2)
c2(?x1 ? x3 ? x9) c3(?x2 ? ?x3 ? x4) c4(?x4
? x5 ? x10) c5(?x4 ? x6 ? x11) c6(?x5 ?
?x6) c7( x1 ? x7 ? ?x12) c8( x1 ? x8) c9(?x7
? ?x8 ? ?x13) ...
102
SAT solvers and models
  • Of course, things are not so simple.
  • Not all learned clauses are useful. SAT solvers
    are ususally paramaterised in order to determine
    which learned clauses are to be maintained.
  • The overhead for carrying on with the analysis
    for non chronological backtracking might not pay
    off (which may depend on the heuristics used for
    variable/value selection). Again parameterisation
    may help.
  • The tuning of all these parameters may be very
    difficult, and may differ considerably for
    aparently similar problems.
  • Nevertheless current solvers may handle benchmark
    instances with tens of millions of clauses on
    around one million variables (not random
    instances).

103
SAT solvers and models
  • The critics will say
  • These numbers are misleading. Much less variables
    and constraints are required if problems are
    modelled with FD constraints.
  • Processing nogoods is simply learning a
    structured model that was destroyed when encoding
    the problem into the poorly expressive SAT
    clauses.
  • Despite criticisms, it is clear that SAT solving
    is quite interesting, and offers possibilities
    for hybridization with FD solvers.
  • This is the goal of project PRACTIC (UNL/INESC).
Write a Comment
User Comments (0)
About PowerShow.com