1 / 44

Compiling Finite Domain Constraints to SAT with Boolean Equi -Propagation

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

olympe
Télécharger la présentation

Compiling Finite Domain Constraints to SAT with Boolean Equi -Propagation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Compiling Finite DomainConstraints to SAT withBoolean Equi-Propagation AmitMetodi

  2. 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 • Encoding process • Design choices • Compiling Model-Based Diagnosis • to Boolean Satisfaction using BEE Amit Metodi Michael Codish ; TPLP 2012 Amit Metodi Roni Stern Meir Kalech Michael Codish ; AAAI 2012

  3. Finite Domain Problem Solving Problem (hard) Constraint Model CNF Model Encoding Direct CSP solving SAT solving Solution Model Solution Satisfied assignment Decoding Translate

  4. The Usual Approach Constraint Model C1 C2 C3 Cn encode encode encode encode • Problems: • Constraint / Bits relation lost • Large CNF CNF CNF CNF CNF CNF Simplify Tools such as: SatELite, ReVivAl Based on Unit Propagation and Resolution. Simplified CNF

  5. Our Approach Constraint Model C1 C2 C3 Cn encode encode encode encode Simplified CNF CNF CNF CNF CNF simplification propagation

  6. The Equi-Propagation Process Constraint Model C1 C2 C3 Cn encode encode encode Equi-propagation is a process of inferring equational consequences from a Boolean formula andgiven equational information. CNF CNF CNF of the form X=L where L is a constant or a literal: X=Y, X= -Y, X=0, X=1 such X can be removed fromALL Boolean formulas / constraints.

  7. Ben-Gurion-University Equi-propagation Encoder Constraint Model CNF Encoding Equi-propagation Partial evaluation view each single constraint as a Boolean formula

  8. BEE Process – By Example Step 1: Encode each constraint Constraint Model C1 C2 C3 Cn encode encode encode encode bool_array_sum_eq( [ A,B,C,D,E,F,G],3) CNF CNF CNF CNF

  9. BEE Process – By Example Step 2: Apply Equi-Propagation Constraint Model C1 C2 C3 Cn encode encode encode encode bool_array_sum_eq( [ A,B,C,D,E,F,G],3) CNF CNF CNF CNF A=1, D= -E

  10. BEE Process – BY Example Step 3: Update the Constraints Model Constraint Model C1 C2 C3 Cn encode update encode update encode update encode update bool_array_sum_eq( [ A,B,C,D,E,F,G],3) bool_array_sum_eq( [ A,B,C,D,E,F,G],3) bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3) CNF CNF CNF CNF A=1, D= -E

  11. BEE Process – BY Example Step 4: Apply Partial Evaluation Constraint Model C1 C2 C3 Cn encode update encode update encode update encode update bool_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 A=1, D= -E

  12. BEE Process – BY Example Step 5: Encode with a better encoding Constraint Model C1 C2 C3 Cn encode update encode update encode update encode update bool_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 A=1, D= -E

  13. BEE Process – BY Example Step 6: Merge the optimized CNF Constraint Model C1 C2 C3 Cn encode update encode update encode update encode update bool_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 merge merge merge merge Optimized CNF

  14. Ben-Gurion-University Equi-propagation Encoder The Design Choices • Representing numbers • Implementing Equi-Propagation

  15. small Modeling Finite Domain CSP representing numbers (integers) Binary Unary Order encoding Direct encoding Number Xwith a domain {0,1,2, …, d} will be represented using b=Boolean variables [ x1,x2,…xb] Number X = k ↔ = k Number Xwith a domain {0,1,2, …, d} will be represented using n=Boolean variables. xi ↔ (X ≥ i) (X = 3) = [1,1,1,0,0] xi ↔ (X = i) (X = 3) = [0,0,0,1,0,0]

  16. Implementing Equi-Propagation • Using BDD’s. • Prohibitive for global constraints. • Complete • Using SAT (on small groups of constraints) • In practice, surprisingly, “not slow” • Complete • Ad-Hoc rules (per constraint type) • Fast, precise in practice • Incomplete

  17. Ad-Hoc Rules • Equi-Propagation • Partial Evaluation Example: 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>) int_plus(<x2,x3>,<y1,y2,0>,<z2,z3,0,0,0>) int_plus(<x2,x3>,<y1,y2>,<z2,z3,0,0>)

  18. The Impact of BEE 909 clauses 136 Bits 298 clauses 49 Bits

  19. Graph Crossing BIBD MAS Ben-Gurion-UniversityEqui-propagationEncoder Kakuro Protein folding N-Queens Model Based Diagnostic Magic Square SCM / MCM QCP / Sudoku Nonograms

  20. Model-Based Diagnosis

  21. 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 benchmarkfor the first time.

  22. Model Based Diagnosis Observation System (model) 0 Full Adder 1 0 A Z1 0 D B 0 1 C 0 Z3 0 E Z2 0 1 Symptom Diagnoses:

  23. Model Based Diagnosis Full Adder 1 A Z1 0 0 D B 1 C Z3 0 E Z2 We focus on minimal cardinality diagnosis of Boolean Circuits, given a single observation. Diagnoses: min min-cardinality

  24. Modeling MBD: The weak Fault Model (we can assume that) a faulty component flips its output. Introduce “health variables”: H -H purple means “encapsulated with a health variable”

  25. Modeling MBD: Introduce health variables 1 A Full Adder Z1 X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 Z2 minimize A1 H5 H3 sum( [ -H1, -H2, -H3, -H4, -H5 ] ) ≤ K Modeling as CSP where the constraints are: 1. components (logic gates) 2. sum of bits / comparison

  26. Modeling MBD: Introduce health variables 1 A Full Adder X1 0 D B 0 X2 H1 H2 1 C A2 0 E H4 O1 minimize A1 H5 green means “healthy” H3 sum( [ -H1, -H2, -H3, -H4, -H5 ] ) ≤ 1 Modeling as CSP where the constraints are: 1. components (logic gates) 2. sum of bits / comparison

  27. Simplifying the encoding equi-propagation Z=-H partial evaluation 1 1 1 -H 0 Z 0 0 0 H -H gray means "melted” 1 A Full Adder Z1 X1 0 D B 0 X2 H1 H1 H2 1 C Z3 A2 0 E H4 O1 Z2 A1 H5 H3 -H3

  28. 330 components 60 x 26 (input/output) 1182 observations Timeout 180sec simplified vanilla

  29. MBD To SAT We 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

  30. Better Modeling: Cones Def: 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 dominator Full Adder A Z1 D B C Z3 E Z2

  31. Better Modeling: Cones these prune the search space break a symmetry claim: A minimal cardinality diagnosis will always indicate at most one unhealthy gate per cone. We can assume w.l.o.g. that this gate is the dominator. (or: in the search for a single minimal cardinality diagnosis, all dominated gates may be assumed healthy)

  32. The impact Of Cones 1 A Full Adder H1 X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 -H3 A1 H5 H3 a cone sum( [ -H1, -H2, -H3, -H4, -H5 ] ) ≤ K

  33. The impact Of Cones 1 A H1 Full Adder X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 0 A1 H5 H3 gray means "melted” green means “healthy” sum( [ -H1, -H2, 0, 0, -H5 ] ) ≤ K

  34. The impact Of Cones 1 H1 H1 H 1 A H1 Full Adder X1 0 D B 0 X2 H1 H2 1 C A2 0 E H4 O1 0 A1 H5 H3 sum( [ -H1, -H2, -H5 ] ) ≤ K

  35. The impact Of Cones 1 A H1 Full Adder X1 0 D B 0 X2 H1 H2 1 C H1=-H5 H1 A2 0 E H4 O1 0 A1 H5 H3 sum( [ -H1, -H2, H1 ] ) ≤ K

  36. The impact Of Cones 1 A H1 Full Adder H1=H2 X1 0 D B 0 X2 H1 H2 1 C H1=-H5 A2 0 E H4 O1 0 A1 H5 H3 sum( [ -H1, -H1, H1 ] ) ≤ K

  37. The impact Of Cones minimize K  H1 =1 1 A H1 Full Adder H1=H2 X1 0 D B 0 X2 H1 H2 1 C H1=-H5 A2 0 E H4 O1 0 A1 H5 H3 sum( [ -H1, -H1, H1 ] ) ≤ K

  38. The impact Of Cones No SAT solving; Diagnostics (min-cardinality) found by: preprocessing(cones) partial evaluation equi-propagation 1 A Full Adder X1 0 D B 0 X2 H1 H2 1 C A2 0 E H4 O1 A1 H5 H3

  39. cones simplified vanilla

  40. Benchmarks • There are standard benchmarks for finding a minimal cardinality diagnosis of Boolean Circuits, given a single observation.

  41. Experiments 30 seconds timeout Average time (sec) on those that do not t/o

  42. 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)

  43. Future work • Other number representations • Binary, Mix Radix, RNS, and more… • Partition for Complete Equi-Propagation. • Additional applications to Model Based Diagnosis.

  44. Questions ?

More Related