programming with boolean satisfaction michael codish
play

Programming with Boolean Satisfaction Michael Codish Department of - PowerPoint PPT Presentation

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


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

  2. I. Its all about solving hard problems

  3. Solving hard problems (Programming) Theory tells us Problem • Look for approximations (hard) • 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 problems via SAT encodings Problem CNF encoding (hard) sat solving direct hype! SAT ’ ing Solution decoding Assignment

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

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

  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 $ 17 challenge : $ prize unclaimed 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 problems via SAT encodings tedious; often repetitive; generating millions of clauses This was a great talk…. “ and i have some (a few years ago) conclusions” Problem I have been doing CNF encoding (hard) this for the past few years sat solving hype! direct Me: primarily for applications SAT ’ ing decoding of termination analysis Solution Assignm.

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

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

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

  14. Q. What makes a program work better? higher-level languages compilers & tools (p.e.) Data Structures / algorithms 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 CNF encoding (hard) Constraint Problem CNF encoding modeling Model (hard)

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

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

  19. user compiler Constraint Problem CNF encoding modeling Model (hard) 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 Constraint Problem CNF encoding modeling Model (hard) 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 CryptoMiniSAT tries to add “ xor clauses” CNF

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

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

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

  24. Equi-propagation for Optimized SAT Encoding; Amit Metodi, 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 Full Adder 1 A Z1 0 D 0 B 1 C Z3 0 E Z2 1 Diagnoses: min-cardinality

  27. Modeling MBD: introduce health variables 1 A Z1 0 X1 0 D B X2 H 1 H 2 1 C Z3 A2 0 E O1 H 4 Z2 A1 H 5 H 3 H - H sum( [ -H 1 , -H 2 , -H 3 , -H 4 , -H 5 ] ) ≤ K

  28. Modeling MBD: introduce health variables 1 A Z1 0 X1 0 D B X2 H 1 H 2 1 C Z3 A2 0 E O1 H 4 Z2 A1 H 5 H 3 green means “healthy” sum( [ -H 1 , -H 2 , -H 3 , -H 4 , -H 5 ] ) ≤ 1 encoding to SAT is Not competitive straighforward standard: with other MBD tools Smith 2005

  29. Simplify the encoding 1 A Z1 0 X1 0 D B X2 H 1 H 2 1 C Z3 A2 0 E O1 H 4 Z2 A1 H 5 H 3 equi-propagation Z2=-H3 partial evaluation 1 1 1 A1 -H3 0 Z2 0 0 0 H3 -H 3 gray means "melted”

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

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

  32. Simplify the encoding - II 1 A H1 0 X1 0 D B X2 H 1 H 2 1 C Z3 A2 0 E O1 H 4 -H3 A1 H 5 H 3 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 0 X1 0 D B X2 H 1 H 2 1 C Z3 A2 0 E O1 H 4 -H3=0 A1 H 5 H 3 green means “healthy” sum( [ -H 1 , -H 2 , 0, 0, -H 5 ] ) ≤ K

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

  35. Compiling Model-Based Diagnosis to Boolean Satisfaction; Amit Metodi, 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. Modeling Finite Domain CSP representing numbers (integers) Binary Unary integer variable X integer variable X with domain {0 ,…,d} with domain {0 ,…,d} is represented in is represented in bits bits Direct encoding Order encoding x i ↔ ( X = i) x i ↔ ( X ≥ i) (X = 3) = [0,0,0,1,0,0] (X = 3) = [1,1,1,0,0]

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

  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 1. Using BDD’s. Can be prohibitive for global constraints. • Complete • 2. Ad-Hoc rules (per constraint type) Fast, precise in practice • Incomplete • 3. Using SAT (on small groups of constraints) Not too slow • Complete •

  42. B en-Gurion E qui-propagation E ncoder BEE compiler Constraint Problem CNF encoding modeling Model (hard)

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

Recommend


More recommend