1 / 54

Joint work with: Vitaly Lagoon, Amit Metodi & Peter Stuckey

Programming with Boolean Satisfaction Michael Codish Department of Computer Science Ben Gurion University Beer- Sheva , Israel CP meets CAV - 2012. Joint work with: Vitaly Lagoon, Amit Metodi & Peter Stuckey . I. Its all about solving hard problems.

marc
Download Presentation

Joint work with: Vitaly Lagoon, Amit Metodi & Peter Stuckey

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. Programming with Boolean SatisfactionMichael CodishDepartment of Computer Science Ben Gurion UniversityBeer-Sheva , IsraelCP meets CAV - 2012 Joint work with: Vitaly Lagoon, AmitMetodi& Peter Stuckey

  2. I. Its all about solving hard problems

  3. Solving hard problems(Programming) Theory tells us Problem (hard) • Look for approximations • Look for easier sub-classes direct Practice tells us • Apply heuristics • Try to be clever Solution Theory also tells us • It is all equivalent to SAT

  4. Solving hard problemsvia SAT encodings Problem (hard) CNF encoding direct sat solving hype! Solution SAT ’ing Assignment decoding

  5. Solving hard problemsvia SAT encodings Improved techniques CNF Problem (hard) SAT solvers are getting stronger by the day encoding direct sat solving hype! Solution SAT ’ingAssignm. Emerging tools like “Sugar”, “Bee”, andothers decoding Many success stories

  6. Example: encoding Sudoku  cells rows columns boxes “unit clauses” At least = cell (i,j) contains value k At most

  7. Example: solving Sudoku  SAT Solver solution

  8. We Can Solve Also More Interesting Problems But, there are also less interesting problems that we cannot solve Eternity II:2 million $ prize unclaimed 17 challenge:$ prize unclaimed 3 months ago ! (Steinbach & Posthoff)

  9. We will always have the phase transition How hard interesting problem instances Problem size We seek better encodings so that our preferred problem instances will be solvable

  10. Solving hard problemsvia SAT encodings tedious; often repetitive; generating millions of clauses This was a great talk…. CNF Problem (hard) encoding “and i have someconclusions” (a few years ago) direct sat solving I have been doing this for the past few years hype! Solution SAT ’ingAssignm. decoding Me:primarily for applications of termination analysis

  11. II. Programming with Boolean Satisfaction (CP meets CAV 2012) CNF Problem (hard) encoding direct sat solving hype! Solution SAT ’ingAssignm. decoding

  12. II. Programming with Boolean Satisfaction mer CNF Problem (hard) encoding Q. What makes a program work better? higher-level languages (optimizing) compilers & tools (p.e.) (what costs) Data Structures / algorithms (understanding it) hardware

  13. Q. What makes a program work better? • SAT encoding mer unit propagation /arc consistency default value (1 or 0) clause / variable ordering Choice of SAT solver • SAT solver hardware

  14. Q. What makes a program work better? • SAT encoding mer higher-level languages • SAT encoding compilers & tools (p.e.) • representation • & modeling Data Structures / algorithms • SAT solver hardware

  15. Outline • Introduction: • Solving hard problems via SAT • Focus on programming with SAT • The need for higher-level languages • Higher low-level Language • (the basics for) A Compiler to CNF • Example: Model Based Diagnosis • Representing Finite Domain Integers • Example: Magic Labels • Conclusion

  16. higher-level language ? Problem (hard) CNF encoding Problem (hard) Constraint Model CNF encoding modeling

  17. higher-level language Finite Domain & Boolean Constraints Subset of FlatZinc The language The compiler Problem (hard) Constraint Model CNF encoding modeling

  18. Example: encoding Sudoku Problem (hard) Constraint Model CNF encoding modeling

  19. user compiler Problem (hard) Constraint Model CNF encoding modeling The CNF per constraint is small & gives context for the bits (word-level) The CNF is large & we have no context for the bits (bit-level)

  20. user compiler Problem (hard) Constraint Model CNF encoding modeling simplification Tools such: SatELite, ReVivAl Based on Unit Propagation and Resolution. remove redundant variable X if the CNF implies X=Y, X= -Y, X=0, X=1 smaller CNF CryptoMiniSAT tries to add “xor clauses”

  21. user compiler Problem (hard) Constraint Model CNF encoding modeling simplification apply constraint simplification (partial evaluation smaller CNF encoding remove redundant variable X if the Constraint implies X=Y, X= -Y, X=0, X=1 smaller Constraint Model even smaller CNF bit-level techniques

  22. Equi-propagation is the process ofinferring equations implied by a “few” constraints. Constraint Model such x can be removed from all constraints. simplification of the form X=L where L is a constant or a literal: X=Y, X= -Y, X=0, X=1 smaller Constraint Model Implemented: complete / adhoc equi-propagation

  23. constraint simplification is word-level (looking at the bits) Constraint ( C2, φ2 ) Constraint ( C3, φ3 ) Constraint ( Cn, φn ) Constraint ( C1, φ1 ) … M = Simplify Boolean techniques (equi-propagation) CSP techniques (partial evaluation) Constraint ( C1, φ1 ) Constraint ( C2, φ2 ) Constraint ( C’3, φ‘3 ) Constraint ( C’n, φ’n) M’ = …

  24. Equi-propagation for Optimized SAT Encoding; • AmitMetodi, Michael Codish, Vitaly Lagoon • and Peter Stuckey; CP 2011

  25. Outline • Introduction: • Solving hard problems via SAT • Focus on programming with SAT • The need for higher-level languages • Higher low-level Language • (the basics for) A Compiler to CNF • Example: Model Based Diagnosis • Representing Finite Domain Integers • Example: Magic Labels • Conclusion

  26. Example:Model Based Diagnosis Observation Full Adder 1 A Z1 D 0 B 0 C 1 Z3 0 E Z2 1 Diagnoses: min-cardinality

  27. Modeling MBD: introduce health variables 1 A Z1 X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 Z2 A1 H5 H3 H minimize -H sum( [ -H1, -H2, -H3, -H4, -H5 ] ) ≤ K

  28. Modeling MBD: introduce health variables 1 A Z1 X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 Z2 A1 H5 H3 green means “healthy” minimize sum( [ -H1, -H2, -H3, -H4, -H5 ] ) ≤ 1 encoding to SAT isstraighforward Not competitive with other MBD tools standard: Smith 2005

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

  30. Simplify the encoding - I 1 A H1 X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 -H3 A1 H5 H3 equi-propagation Z2=-H partial evaluation 1 1 1 A1 -H3 0 Z2 0 0 0 H3 -H3 gray means "melted”

  31. Simplify the encoding - I 1 A H1 X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 -H3 A1 H5 H3 equi-propagation Z2=-H partial evaluation 1 1 1 A1 -H3 0 Z2 0 0 0 H3 -H3 gray means "melted”

  32. Simplify the encoding - II 1 A H1 X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 -H3 A1 H5 H3 a cone dominator claim: A minimal cardinality diagnosis will always indicate at most one unhealthy gate per “cone”. And wlog it is the “dominator”

  33. Simplify the encoding - II 1 A H1 X1 0 D B 0 X2 H1 H2 1 C Z3 A2 0 E H4 O1 -H3=0 A1 H5 H3 green means “healthy” sum( [ -H1, -H2, 0, 0, -H5 ] ) ≤ K

  34. Simplify the encoding - II 1 A H1 X1 H1=H2 0 D B 0 X2 H1 H2 1 C H1 H1=-H5 A2 0 E H4 O1 -H3=0 A1 H5 H3 No SAT solving; Diagnostics (min-cardinality) found by: preprocessing(cones) partial evaluation equi-propagation sum( [ -H1, -H2, -H5 ] ) ≤ K minimize K  H1 =1 sum( [ -H1, -H2, H1 ] ) ≤ K sum( [ -H1, -H1, H1 ] ) ≤ K

  35. Compiling Model-Based Diagnosis to Boolean Satisfaction; • AmitMetodi, Roni Stern, Meir Kalech, • Michael Codish; AAAI 2012 (to appear) • very good experimental results. • overtakes all current MBD systems • finds (for the first time) minimal cardinality diagnosis for the entire standard benchmarks

  36. Outline • Introduction: • Solving hard problems via SAT • Focus on programming with SAT • The need for higher-level languages • Higher low-level Language • (the basics for) A Compiler to CNF • Example: Model Based Diagnosis • Representing Finite Domain Integers • Example: Magic Labels • Conclusion

  37. small Modeling Finite Domain CSP representing numbers (integers) Order encoding xi ↔ (X ≥ i) (X = 3) = [1,1,1,0,0] Binary Unary integer variable X with domain {0,…,d} is represented in bits integer variable X with domain {0,…,d} is represented in bits Direct encoding encode “ordered” encode “exactly-one” xi ↔ (X = i) (X = 3) = [0,0,0,1,0,0]

  38. Why Order Encoding ? • good for representing ranges (Sugar) X 1 0 X ≥ i X < j i j b=c e=f=g a b d c e f g • good for arbitrary sets (Bee) X v u i

  39. Why Order Encoding ? • Lots of equi-propagation The Encoding to SAT needs NO Clauses. It is obtained by unification order encoding

  40. Why Order Encoding ? • Lots of equi-propagation

  41. Implementing Equi-propagation • Using BDD’s. • Can be prohibitive for global constraints. • Complete • Ad-Hoc rules (per constraint type) • Fast, precise in practice • Incomplete • Using SAT (on small groups of constraints) • Not too slow • Complete

  42. Ben-Gurion • Equi-propagation • Encoder BEElanguage BEEcompiler Problem (hard) Constraint Model CNF encoding modeling

  43. bit-blasting constraint simplification CNF Constraint Model encoding choice of representation (default is order encoding) Constraint ( C1, φ1 ) standard techniques (but encoding technique may differ after simplification) partial evaluation equi-propagation decomposition

  44. Example: Magic Labels (VMTL) v4 v4 e34 8 v3 v3 e23 2 e13 3 v1 v1 v2 v2 e12 7 6 1 4 5

  45. simplifying sum constraints bound propagation ? A & B take values {6,7,8} is it a CSP thing? no. it is equi-propagation

  46. simplifying sum constraints e.p. p.e. e.p.

  47. back to the VMTL example v4 v4 e34 8 v3 v3 e23 2 e13 3 v1 v1 v2 v2 e12 7 6 1 4 5

  48. VMTL: Simplifying Constraints could take values 6,7,8 could take values 6,8

  49. Example: Magic Labels (VMTL) 909 clauses 136 Bits 298 clauses 49 Bits

  50. Graph Crossing BIBD MAS Kakuro BEE (BGU equi-propagation encoder) Protein folding N-Queens System Diagnostic Magic Square SCM / MCM QCP / Sudoku Nonograms

More Related