1 - Technion moodle

advertisement
Agenda








Modeling problems in Propositional Logic
SAT basics
Decision heuristics
Non-chronological Backtracking
Learning with Conflict Clauses
SAT and resolution
More techniques: decision heuristics, deduction.
Stochastic SAT solvers: the GSAT approach
1
Conflict clauses and Resolution

Binary-resolution is a sound inference rule:

Example:
2
Conflict clauses and resolution

Consider the following example:

Conflict clause: c5: (x2 Ç :x4 Ç x10)

We show that c5 is inferred by resolution from c1,…,c4
3
Conflict clauses and resolution

Conflict clause: c5: (x2 Ç :x4 Ç x10)

BCP order: x4,x5,x6,x7



T1 = Res(c4,c3,x7) = (:x5 Ç :x6)
T2 = Res(T1, c2, x6) = (:x4 Ç :x5 Ç X10 )
T3 = Res(T2,c1,x5) = (x2 Ç :x4 Ç x10 )
4
Finding the conflict clause:
cl is asserting
the first UIP
Applied to our example:
5
Conflict clauses and resolution
This will be part of the
(Hyper) Resolution Graph:
c1
c2
c3
c5
c4
6
The resolution graph
What is it good for ?
Example: for computing an Unsatisfiable core
[Picture Borrowed from Zhang, Malik SAT’03]
7
Minimizing the core

The proof is not unique.


Different proofs / different cores.
Can we find a minimum / minimal / smaller cores/proofs?
8
Minimizing the core

Core compression [ZM03,…]…


Min-core-biased search [NRS’13]
Proof compression:

Exponential-time transformations [GKS’06].

Linear time transformations

“Recycle units” [BFHSS’08]
9
Core compression (smaller core)

A basic approach: run until reaching a fixpoint [chaff]
initially last_core = ;

SAT solver
core
core ==
last_core ?
core
no
last_core = core
yes
10
Core compression (minimal core)
Initially ’s clauses are unmarked
Return 
Remove an unmarked clause c 2 
SAT() ?
yes
mark c
no
 := core
11
Proof compression
Example of a linear-time transformation / “Recycle-units”

Observation:
When learning (resolving) a new clause in SAT,


The resolving clauses are not satisfied
Hence, the resolution-variable is unassigned
:l l2
l l1
l1 l2
12
Example (cont’d)


13
Suppose that the pivot’s constant value is learned later
on.
We will use it to simplify the resolution proof.
Recycle-units / easy case
-1 2 5
13
235
-1 4
1 -2
-1
135
35
14
-1 -4
Recycle-units / easy case
-1 2 5
13
235
-1 4
1 -2
-1
135
35
15
-1 -4
Recycle-units
13
-1 4
3
1 -2
-1
135
335
16
-1 -4
Recycle-units
13
-1 4
-1 -4
-1
3


17
Reduced proof by 4 clauses
Reduced core by 2 clauses
Recycle-units / beware of cycles
13
-1 4
235
135
18
1 -2
-1 -4
-1
By making this
connection we created
cyclic reasoning
Recycle-units / beware of cycles

Solution:


mark antecedents of units
apply only to unmarked nodes
-1 2 5
13
235
-1 4
1 -2
-1
135
19
-1 -4
35
Agenda








Modeling problems in Propositional Logic
SAT basics
Decision heuristics
Non-chronological Backtracking
Learning with Conflict Clauses
SAT and resolution
More techniques: decision heuristics, deduction.
Stochastic SAT solvers: the GSAT approach
20
Decision heuristics
VSIDS (Variable State Independent Decaying Sum)
(Implemented in Chaff)
1. Each variable in each polarity has a counter initialized to 0.
2. When a clause is added, the counters are updated.
3. The unassigned variable with the highest counter is chosen.
4. Periodically, all the counters are divided by a constant.
21
Decision heuristics
VSIDS (cont’d)
• Chaff holds a list of unassigned variables sorted by the counter
value.
• Updates are needed only when adding conflict clauses.
• Thus - decision is made in constant time.
22
Decision heuristics
VSIDS (cont’d)
VSIDS is a ‘quasi-static’ strategy:
- static because it doesn’t depend on current assignment
- dynamic because it gradually changes. Variables that appear
in recent conflicts have higher priority.
This strategy is a conflict-driven decision strategy.
“..employing this strategy dramatically (i.e. an order
of magnitude) improved performance ... “
23
Decision Heuristics - Berkmin


Keep conflict clauses in a stack
Choose the first unresolved clause in the stack

If there is no such clause, use VSIDS

Choose from this clause a variable + value according to some
scoring (e.g. VSIDS)

This gives absolute priority to conflicts.
24
Berkmin heuristic
tailfirst conflict clause
25
More engineering aspects of SAT solvers
Observation: More than 90% of the time SAT solvers perform
Deduction().
Deduction() allocates new implied variables and conflicts.
How can this be done efficiently ?
26
Grasp implements Deduction() with counters
Hold 2 counters for each clause :
val1( ) - # of negative literals assigned 0 in  +
# of positive literals assigned 1 in .
val0() - # of negative literals assigned 1 in  +
# of positive literals assigned 0 in .
27
Grasp implements Deduction() with counters
 is satisfied
iff
val1() > 0
 is unsatisfied
iff
val0() = ||
 is unit
iff
val1() = 0  val0() = || - 1
 is unresolved
iff
val1() = 0  val0() < || - 1
.
.
Every assignment to a variable x results in updating the counters
for all the clauses that contain x.
Backtracking: Same complexity.
28
Chaff implements Deduction() with 2 ‘watchers’



Observation: during Deduction(), we are only
interested in newly implied variables and conflicts.
These occur only when the number of literals in 
with value ‘false’ is greater than || - 2
Conclusion: no need to visit a clause unless
(val0() > || - 2)

How can this be implemented ?
29
Chaff implements Deduction() with 2 ‘watchers’

For each clause ¼, define two ‘watchers’: w1(), w2().

w1() and w2(): two  literals which are not ‘false’.

Visit clause  only if w1() or w2() become ‘false’.
30
Chaff implements Deduction() with 2 ‘watchers’
w1
w2
1
2
3
4
5
1
2
3
4
5
V[2]=0
V[5]=0, v[4]= 0
1 2 3 4 5
1
2
3
4
Unit clause
5
V[1]=0
Backtrack
v[4] = v[5]= X
v[1] = 1
1 2 3 4 5
31
Chaff implements Deduction() with 2 ‘watchers’

Complexity of Backtracking:



Observers of a unit clause are on the highest decision level
present in the clause.
Hence backtracking will un-assign them first.
Conclusion: when backtracking, observers stay in place.
32
Chaff implements Deduction() with 2 ‘watchers’

Which observing literals?


Strategy: the least frequently updated variables
The observers method has a learning curve


Initial observers: chosen arbitrarily.
Then: shifted from variables that were recently updated


These variables will most probably be reassigned soon.
In our example: the next time v[5] is updated, it will point
to a significantly smaller set of clauses.
33
Agenda








Modeling problems in Propositional Logic
SAT basics
Decision heuristics
Non-chronological Backtracking
Learning with Conflict Clauses
SAT and resolution
More techniques: decision heuristics, deduction.
Stochastic SAT solvers: the GSAT approach
34
GSAT: stochastic SAT solving
Given a CNF formula , choose max_tries and max_flips
for i = 1 to max_tries {
T := randomly generated truth assignment
for j = 1 to max_flips {
if T satisfies  return TRUE
Many alternative
heuristics
choose v s.t. flipping v’s value gives largest increase in
the # of satisfied clauses (break ties randomly).
T := T with v’s assignment flipped. } }
35
Numerous progressing heuristics






Hill-climbing
Tabu-list
Simulated-annealing
Random-Walk
Min-conflicts
...
36
Improvement # 1: clause weights




Initial weight of each clause: 1
Increase by k the weight of unsatisfied clauses.
Choose v according to maximum increase in weight
Clause weights is another example of conflict-driven
decision strategy.
37
Improvement # 2: Averaging-in
Q: Can we reuse information gathered in previous tries in order
to speed up the search ?
A: Yes!
Rather than choosing T randomly each time, repeat
‘good assignments’ and choose randomly the rest.
38
Improvement # 2: Averaging-in
Let X1, X2 and X3 be equally wide bit vectors.
Define a function bit_average : X1  X2  X3
as follows:
b1i
b3 :=
random
i
b1i = b2i
otherwise
(where bji is the i-th bit in Xj, j {1,2,3})
39
Improvement # 2: Averaging-in
Notation:
Tiinit : The initial assignment T in cycle i.
Tibest : The assignment with highest # of satisfied clauses in
cycle i.
T1init := random assignment.
T2init := random assignment.
i > 2, Tiinit := bit_average(Ti-1best, Ti-2best)
40
Download