compiling finite domain constraints to sat with boolean equi -propagation
DESCRIPTION
Compiling Finite Domain Constraints to SAT with Boolean Equi -Propagation. Amit Metodi. Outline. Amit Metodi Michael Codish Vitaly Lagoon Peter J. Stuckey ; CP 2011. Boolean Equi -propagation for Optimized SAT Encoding Compiling Finite Domain Constraints to SAT with BEE - PowerPoint PPT PresentationTRANSCRIPT
Compiling Finite DomainConstraints to SAT with
Boolean Equi-Propagation
Amit Metodi
OUTLINE Boolean Equi-propagation
for Optimized SAT Encoding Compiling Finite Domain
Constraints to SAT with BEE Encoding process Design choices
Compiling Model-Based Diagnosisto Boolean Satisfaction using BEE
Amit MetodiMichael CodishVitaly LagoonPeter J. Stuckey; CP 2011
Amit MetodiMichael Codish; TPLP 2012
Amit MetodiRoni SternMeir KalechMichael Codish; AAAI 2012
Problem(hard)
Solution
CNF
Satisfied assignment
Encoding
FINITE DOMAIN PROBLEM SOLVING
Model ConstraintModel
Dire
ct
CS
P s
olvi
ng
ModelSolutionTranslate Decoding
SAT
sol
ving
CNF
Constraint ModelC1 C2 C3 Cnen
code
enco
de
enco
de
enco
de
Sim
plifyTools such as: SatELite, ReVivAl
Based on Unit Propagationand Resolution.
Problems:• Constraint / Bits
relation lost• Large CNF
CNF CNF CNF CNF
THE USUAL APPROACH
Simplified CNF
Simplified CNF
Constraint ModelC1 C2 C3 Cnen
code
enco
de
enco
de
enco
de
CNF CNF CNF CNF
OUR APPROACH
simplification propagation
Constraint ModelC1 C2 C3en
code
enco
de
enco
de
THE EQUI-PROPAGATION PROCESS
Equi-propagation is a process of inferring equational consequences from a Boolean formula andgiven equational information.
of the form X=L where Lis a constant or a literal:X=Y, X= -Y, X=0, X=1
such X can be removed fromALL
Boolean formulas / constraints.
Cn
CNF CNF CNF
Ben-Gurion-UniversityEqui-propagationEncoder
CNFEncodingConstraintModel
Equi-propagation Partial evaluation
view each single constraint as a Boolean formula
CNF CNF CNF CNF
BEE PROCESS – BY EXAMPLE
Constraint ModelC1 C2 C3 Cn
enco
de
enco
de
enco
de
enco
debool_array_sum_eq( [ A,B,C,D,E,F,G],3)
Step 1: Encode each constraint
Constraint ModelC1 C2 C3 Cn
enco
de
BEE PROCESS – BY EXAMPLE
enco
de
enco
de
enco
debool_array_sum_eq( [ A,B,C,D,E,F,G],3)
A=1, D= -E
CNF CNF CNF CNF
Step 2: Apply Equi-Propagation
Constraint ModelC3
bool_array_sum_eq( [ A,B,C,D,E,F,G],3)
C1 C2 Cn
enco
de
BEE PROCESS – BY EXAMPLE
upda
te
enco
de
upda
te
enco
de
upda
te
enco
de
upda
tebool_array_sum_eq( [ A,B,C,D,E,F,G],3)bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3)
A=1, D= -E
CNF CNF CNF CNF
Step 3: Update the Constraints Model
Constraint ModelC1 C2 C3 Cn
enco
de
BEE PROCESS – BY EXAMPLE
upda
te
enco
de
upda
te
enco
de
upda
te
enco
de
upda
tebool_array_sum_eq( [ A,B,C,D,E,F,G],3)bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3)bool_array_sum_eq( [ B,C, F,G],1)
A=1, D= -E
CNF CNF CNF CNF
Step 4: Apply Partial Evaluation
Constraint ModelC1 C2 C3 Cn
enco
de
BEE PROCESS – BY EXAMPLE
upda
te
enco
de
upda
te
enco
de
upda
te
enco
de
upda
tebool_array_sum_eq( [ A,B,C,D,E,F,G],3)bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3)bool_array_sum_eq( [ B,C, F,G],1)
A=1, D= -E
CNF CNF CNF’ CNF
Step 5: Encode with a better encoding
Constraint ModelC1 C2 C3 Cn
enco
de
BEE PROCESS – BY EXAMPLE
upda
te
enco
de
upda
te
enco
de
upda
te
enco
de
upda
tebool_array_sum_eq( [ A,B,C,D,E,F,G],3)bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3)bool_array_sum_eq( [ B,C, F,G],1)CNF CNF CNF’ CNF
Step 6: Merge the optimized CNF
Optimized CNF
mer
ge
mer
ge
mer
ge
mer
ge
Ben-Gurion-UniversityEqui-propagationEncoder
THE DESIGN CHOICESRepresenting numbersImplementing Equi-Propagation
MODELING FINITE DOMAIN CSPrepresenting numbers (integers)
BinaryNumber X with a domain {0,1,2, …, d} will be represented using b= Boolean variables [ x1,x2,…xb]
Number X = k ↔ = k
UnaryNumber X with a domain {0,1,2, …, d} will be represented using n= Boolean variables.
Order encodingxi ↔ (X ≥ i)
(X = 3) = [1,1,1,0,0]
Direct encodingxi ↔ (X = i)
(X = 3) = [0,0,0,1,0,0]
SMALL
IMPLEMENTING EQUI-PROPAGATION
1. Using BDD’s. • Prohibitive for global constraints.• Complete
2. Using SAT (on small groups of constraints)• In practice, surprisingly, “not slow”• Complete
3. Ad-Hoc rules (per constraint type)• Fast, precise in practice• Incomplete
AD-HOC RULES Equi-Propagation
Partial Evaluation
int_plus(<1,x2,x3>,<y1,y2,y3>,<z1,z2,z3,0,0,0>)
int_plus(<1,x2,x3>,<y1,y2,y3>,<1,z2,z3,0,0,0>)int_plus(<1,x2,x3>,<y1,y2,0>,<1,z2,z3,0,0,0>)
Example:
int_plus(<1,x2,x3>,<y1,y2,0>,<1,z2,z3,0,0,0>)Example:
int_plus(<x2,x3>,<y1,y2,0>,<z2,z3,0,0,0>)int_plus(<x2,x3>,<y1,y2>,<z2,z3,0,0>)
THE IMPACT OF BEE
909 clauses136 Bits
298 clauses49 Bits
Kakuro
QCP / Sudoku
BIBD
Nonograms
Ben-Gurion-University Equi-propagation Encoder
Graph Crossing
N-Queens
Magic Square
MAS
SCM / MCM
Model BasedDiagnostic
Proteinfolding
Model-Based Diagnosis
MODEL BASED DIAGNOSIS An important problem which researched by
many researches. There is standard benchmarks.
Encoding to SAT is straightforward But previous attempts concluded that SAT
isn’t competitive with other tools. We show that by using BEE, not only SAT is
able to compete with other tools, it is faster. We solve the entire benchmark
for the first time.
1SymptomDiagnoses:
ABC
D
E
Z1
Z2
Z3
1
0
Observation
001
Full Adder
MODEL BASED DIAGNOSIS
0
00
System (model)0
Diagnoses:
ABC
D
E
Z1
Z2
Z3
Full Adder
min min-cardinality
1
0
001
MODEL BASED DIAGNOSIS
We focus on minimal cardinality diagnosis of Boolean Circuits, given a single observation.
H-H
purple means “encapsulated with a health
variable”
MODELING MBD:THE WEAK FAULT MODEL
(we can assume that) a faulty component flips its output.
Introduce “health variables”:
minimize
1
0
ABC
D
E
X1X2
A2
A1O1
Z1
Z2
Z3
001
Full Adder
H1H2
H3
H4
H5
sum( [ -H1, -H2, -H3, -H4, -H5 ] ) ≤ K
MODELING MBD:INTRODUCE HEALTH VARIABLES
Modeling as CSP where the constraints are:1. components (logic gates)2. sum of bits / comparison
minimize
sum( [ -H1, -H2, -H3, -H4, -H5 ] ) ≤ 1Modeling as CSP where the constraints are:1. components (logic gates)2. sum of bits / comparison
1
0
ABC
D
E
X1X2
A2
A1O1
001
Full Adder
H1H2
H3
H4
H5green means “healthy”
MODELING MBD:INTRODUCE HEALTH VARIABLES
1
0
ABC
D
E
X1X2
A2
A1O1
Z1
Z2
Z3
001
Full Adder
H1H2
H3
H4
H5
H-H
10
1
001
0-H
gray means "melted”
Z
partial evaluation
SIMPLIFYING THE ENCODINGequi-
propagationZ=-H
H1
-H3
vanillasimplified330 components60 x 26 (input/output)1182 observationsTimeout 180sec
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 260.01
0.1
1
10
100
1000
c880 - Average time to find MC di-agnosis
Minimal Cardinality
Avg
Tim
e in
Sec
onds
MBD TO SATWe can go “just so far” (and not very);
We can not “push” the inputs through the circuit because of the health variables.
What can we do ? Better modeling Better preprocessing
ABC
D
E
Z1
Z2
Z3
Full Adder
dominator
BETTER MODELING: CONESDef: gate G dominates gate X, if any path from
X to a system output passes through G
Def: the cone corresponding to gate G is the set of gates dominated by G
BETTER MODELING: CONESthese prune the search space
break a symmetry
claim: A minimal cardinality diagnosis willalways indicate at most one unhealthygate per cone. We can assume w.l.o.g.that this gate is the dominator.
(or: in the search for a single minimalcardinality diagnosis, all dominated gates may be assumed healthy)
1
0
ABC
D
E
X1X2
A2
A1O1
Z3
001
Full Adder
H1H2
H3
H4
H5
sum( [ -H1, -H2, -H3, -H4, -H5 ] ) ≤ K
H1
-H3
a cone
THE IMPACT OF CONES
1
0
ABC
D
E
X1X2
A2
A1O1
Z3
001
Full Adder
H1H2
H3
H4
H5
H1
0
sum( [ -H1, -H2, 0, 0, -H5 ] ) ≤ K
green means “healthy”
gray means "melted”
THE IMPACT OF CONES
1
0
ABC
D
E
X1X2
A2
A1O1
001
Full Adder
H1H2
H3
H4
H5
H1
0
H
1H1
H1
sum( [ -H1, -H2, -H5 ] ) ≤ K
THE IMPACT OF CONES
sum( [ -H1, -H2, H1 ] ) ≤ K
1
0
ABC
D
E
X1X2
A2
A1O1
001
Full Adder
H1H2
H3
H4
H5
H1
0
H1=-H5H1
THE IMPACT OF CONES
1
0
ABC
D
E
X1X2
A2
A1O1
001
Full Adder
H1H2
H3
H4
H5
sum( [ -H1, -H1, H1 ] ) ≤ K
H1
0
H1=-H5
H1=H2
THE IMPACT OF CONES
1
0
ABC
D
E
X1X2
A2
A1O1
001
Full Adder
H1H2
H3
H4
H5
sum( [ -H1, -H1, H1 ] ) ≤ K
H1
0
H1=-H5
H1=H2
minimize K H1 =1
THE IMPACT OF CONES
1
0
ABC
D
E
X1X2
A2
A1O1
001
Full Adder
H1H2
H3
H4
H5
No SAT solving;Diagnostics (min-cardinality) found by:
preprocessing(cones)partial evaluationequi-propagation
THE IMPACT OF CONES
vanillasimplifiedcones
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 260.01
0.1
1
10
100
1000
c880 - Average time to find MC Diagnosis
Minimal Cardinality
Avg
Tim
e in
Sec
onds
SystemsName |C| |IN| |OUT| Obsrs
74181 65 14 8 350
74182 19 9 5 250
74283 36 9 5 202
c432 160 36 7 301c499 202 41 32 835
c880 383 60 26 1182c1355 546 41 32 836
c1908 880 33 25 846
c2670 1193 233 140 1162c3540 1669 50 22 756c5315 2307 178 123 2038c6288 2416 32 32 404c7552 3512 207 108 1557
There are standard benchmarks for finding a minimal cardinality diagnosis of Boolean Circuits, given a single observation.
BENCHMARKS
System HA* CDA* SAFARI SAT
Name%Succ
. Time %Succ. Time %Succ. Time %Succ. Time74181 68.3 3.15 46.3 4.51 100.0( 44) 0.00 100.0 0.0274182 100.0 0.00 100.0 0.01 100.0( 91) 0.00 100.0 0.0174283 100.0 0.04 100.0 1.45 100.0( 57) 0.00 100.0 0.02c432 78.1 3.63 38.2 5.15 100.0( 28) 0.03 100.0 0.03c499 24.1 5.45 10.1 1.22 100.0( 7) 0.05 100.0 0.04c880 11.9 3.76 6.3 6.66 100.0( 48) 0.18 100.0 0.05
c1355 11.4 3.90 0.0 - 100.0( 5) 0.37 100.0 0.07c1908 6.4 1.75 0.0 - 100.0( 17) 1.08 100.0 0.14c2670 12.3 4.83 0.0 - 100.0( 14) 2.71 100.0 0.15c3540 3.7 4.30 0.0 - 100.0( 9) 5.25 100.0 0.27c5315 2.7 11.94 0.0 - 100.0( 9) 13.34 100.0 0.42c6288 13.6 7.87 0.0 - 53.5( 25) 16.18 100.0 0.56c7552 4.2 1.06 0.0 - 0.0 - 99.3 1.07
Average time (sec) on those that do not t/o
30 seconds timeoutEXPERIMENTS
CONCLUSIONS Equi-Propagation process apply powerful reasoning
techniques to separate parts of the model and maintain efficient preprocessing.
BEE encodes finite domain constraints to CNF uses ad-hoc equi-propagation and partial evaluation rules which keeps compilation times typically small. And the reduction in SAT solving time can be larger in orders of magnitude.
By using BEE the user may focus on better modeling which will result better preprocessing and faster solving time. (MBD as an example)
FUTURE WORK Other number representations
Binary, Mix Radix, RNS, and more… Partition for Complete Equi-Propagation. Additional applications to Model Based
Diagnosis.
QUESTIONS ?