Programming with Boolean Satisfaction Michael Codish Department of Computer Science Ben Gurion University Beer-Sheva, Israel CP meets CAV - 2012 Joint.

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Hybrid BDD and All-SAT Method for Model Checking Orna Grumberg Joint work with Assaf Schuster and Avi Yadgar Technion – Israel Institute of Technology.
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
OUTLINE Boolean Equi-propagation for Optimized SAT Encoding Compiling Finite Domain Constraints to SAT with BEE Encoding process Design choices Compiling.
NP-Completeness.
Big Ideas in Cmput366. Search Blind Search State space representation Iterative deepening Heuristic Search A*, f(n)=g(n)+h(n), admissible heuristics Local.
Course Summary What have we learned and what are we expected to know?
Order encoding x i ↔ (X ≥ i)(X = 3) = [1,1,1,0,0] Problem (hard) Problem (hard) Solution CNF Encoding Finite Domain Problem Solving Model Constraint Model.
Interactive Configuration
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
This lecture topic (two lectures) Chapter 6.1 – 6.4, except 6.3.3
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
Artificial Intelligence Constraint satisfaction problems Fall 2008 professor: Luigi Ceccaroni.
Proofs from SAT Solvers Yeting Ge ACSys NYU Nov
“Using Weighted MAX-SAT Engines to Solve MPE” -- by James D. Park Shuo (Olivia) Yang.
1 Integrating CSP Decomposition Techniques and BDDs for Compiling Configuration Problems Sathiamoorthy Subbarayan IT University of Copenhagen.
IBM Labs in Haifa © 2005 IBM Corporation Adaptive Application of SAT Solving Techniques Ohad Shacham and Karen Yorav Presented by Sharon Barner.
Pairwise Cardinality Networks Michael Codish and Moshe Zazon-Ivry Department of Computer Science B en-Gurion University.
4 Feb 2004CS Constraint Satisfaction1 Constraint Satisfaction Problems Chapter 5 Section 1 – 3.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
1 Boolean Satisfiability in Electronic Design Automation (EDA ) By Kunal P. Ganeshpure.
1 Optimisation Although Constraint Logic Programming is somehow focussed in constraint satisfaction (closer to a “logical” view), constraint optimisation.
Constraint Satisfaction Problems
AAAI00 Austin, Texas Generating Satisfiable Problem Instances Dimitris Achlioptas Microsoft Carla P. Gomes Cornell University Henry Kautz University of.
Integer Programming Difference from linear programming –Variables x i must take on integral values, not real values Lots of interesting problems can be.
1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: Satisfiability (Reading R&N: Chapter 7)
Constraint Satisfaction Problems
1 Constraint Programming: An Introduction Adapted by Cristian OLIVA from Peter Stuckey (1998) Ho Chi Minh City.
Structural Abstraction for Strong Fault Models Diagnosis (DX 2014 BISFAI 2015) Roni SternMeir KalechOrel Elimelech Ben Gurion University of the Negev,
Tractable Symmetry Breaking Using Restricted Search Trees Colva M. Roney-Dougal, Ian P. Gent, Tom Kelsey, Steve Linton Presented by: Shant Karakashian.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Boolean Satisfiability and SAT Solvers
Problem (hard) Solution CNF Satisfied assignment Encoding FINITE DOMAIN PROBLEM SOLVING Model Constraint Model Direct Constraint / Bits relation lost.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 3 Logic Representations (Part 2)
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
Modelling for Constraint Programming Barbara Smith CP 2010 Doctoral Programme.
Stocs – A Stochastic CSP Solver Bella Dubrov IBM Haifa Research Lab © Copyright IBM.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
Hande ÇAKIN IES 503 TERM PROJECT CONSTRAINT SATISFACTION PROBLEMS.
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module Logic Representations.
On the Relation between SAT and BDDs for Equivalence Checking Sherief Reda Rolf Drechsler Alex Orailoglu Computer Science & Engineering Dept. University.
Chapter 5 Constraint Satisfaction Problems
SAT 2009 Ashish Sabharwal Backdoors in the Context of Learning (short paper) Bistra Dilkina, Carla P. Gomes, Ashish Sabharwal Cornell University SAT-09.
CHAPTER 5 SECTION 1 – 3 4 Feb 2004 CS Constraint Satisfaction 1 Constraint Satisfaction Problems.
G51IAI Introduction to Artificial Intelligence
Making Path-Consistency Stronger for SAT Pavel Surynek Faculty of Mathematics and Physics Charles University in Prague Czech Republic.
Custom Computing Machines for the Set Covering Problem Paper Written By: Christian Plessl and Marco Platzner Swiss Federal Institute of Technology, 2002.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
PhD March The Evergreen Project: How To Learn From Mistakes Caused by Blurry Vision in MAX-CSP Solving Karl J. Lieberherr Northeastern University.
SAT Encodings for Sudoku Bug Catching in 2006 Fall Sep. 26, 2006 Gi-Hwon Kwon.
2009/6/30 CAV Quantifier Elimination via Functional Composition Jie-Hong Roland Jiang Dept. of Electrical Eng. / Grad. Inst. of Electronics Eng.
1 Constraint Satisfaction Problems (CSP). Announcements Second Test Wednesday, April 27.
Sudoku Solutions Using Logic Equations Christian Posthoff The University of The West Indies, Trinidad & Tobago Bernd Steinbach Freiberg University of Mining.
Hybrid BDD and All-SAT Method for Model Checking
Michael Codish, Michael Frank, Amit Metodi
Inference and search for the propositional satisfiability problem
Recovering and Exploiting Structural Knowledge from CNF Formulas
A Boolean Paradigm in Multi-Valued Logic Synthesis
SAT-Based Area Recovery in Technology Mapping
Modeling Sudoku as a CNF Formula
Modeling Sudoku as a CNF Formula
Constraint satisfaction problems
Modeling Sudoku as a CNF Formula
CS 8520: Artificial Intelligence
SAT-based Methods: Logic Synthesis and Technology Mapping
Constraint Satisfaction Problems
Constraint satisfaction problems
Presentation transcript:

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

Its all about solving hard problems I.

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

Solving hard problems via SAT encodings Problem (hard) Solution direct CNF SAT ’ing Assignment encoding decoding sat solving hype!

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

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

Example: solving Sudoku  SAT Solver solution

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)

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

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

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

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

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

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

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

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

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

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

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

Problem (hard) CNF encoding Constraint Model modeling usercompiler simplification smaller CNF Tools such: SatELite, ReVivAl Based on Unit Propagation and Resolution. 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 CryptoMiniSAT tries to add “xor clauses”

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

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

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

Equi-propagation for Optimized SAT Encoding; Amit Metodi, Michael Codish, Vitaly Lagoon and Peter Stuckey; CP 2011

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

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

minimize 1 0 A B C D E X1 X2 A2 A1 O1 Z1 Z2 Z Modeling MBD: introduce health variables H1H1 H2H2 H3H3 H4H4 H5H5 sum( [ -H 1, -H 2, -H 3, -H 4, -H 5 ] ) ≤ K H -H-H

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

1 0 A B C D E X1 X2 A2 A1 O1 Z1 Z2 Z Simplify the encoding H1H1 H2H2 H3H3 H4H4 H5H5 H H3 gray means "melted” Z2 partial evaluation equi-propagation Z2=-H3 A1 -H 3

1 0 A B C D E X1 X2 A2 A1 O1 Z Simplify the encoding - I H1H1 H2H2 H3H3 H4H4 H5H5 H H3 gray means "melted” Z2 partial evaluation equi-propagation Z2=-H A1 -H 3 H1

1 0 A B C D E X1 X2 A2 A1 O1 Z Simplify the encoding - I H1H1 H2H2 H3H3 H4H4 H5H5 H H3 gray means "melted” Z2 partial evaluation equi-propagation Z2=-H A1 -H 3 H1

1 0 A B C D E X1 X2 A2 A1 O1 Z Simplify the encoding - II H1H1 H2H2 H3H3 H4H4 H5H5 -H3 H1 claim: A minimal cardinality diagnosis will always indicate at most one unhealthy gate per “cone”. And wlog it is the “dominator” a cone dominator

1 0 A B C D E X1 X2 A2 A1 O1 Z Simplify the encoding - II H1H1 H2H2 H3H3 H4H4 H5H5 -H3=0 H1 green means “healthy” sum( [ -H 1, -H 2, 0, 0, -H 5 ] ) ≤ K

1 0 A B C D E X1 X2 A2 A1 O Simplify the encoding - II H1H1 H2H2 H3H3 H4H4 H5H5 -H3=0 H1 sum( [ -H 1, -H 2, -H 5 ] ) ≤ K H1 H1=-H5 sum( [ -H 1, -H 2, H 1 ] ) ≤ K H1=H2 sum( [ -H 1, -H 1, H 1 ] ) ≤ K minimize K  H 1 =1 No SAT solving; Diagnostics (min-cardinality) found by: preprocessing(cones) partial evaluation equi-propagation

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

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

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

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

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

Why Order Encoding ? Lots of equi-propagation

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

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

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

Example: Magic Labels (VMTL) v1v1 v2v2 v3v3 v4v4 e 12 e 23 e 13 e 34 v1v1 v2v2 v3v3 v4v

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

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

back to the VMTL example v1v1 v2v2 v3v3 v4v4 e 12 e 23 e 13 e 34 v1v1 v2v2 v3v3 v4v

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

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

Kakuro QCP / Sudoku BIBD Nonograms Graph Crossing N-Queens Magic Square MAS SCM / MCM System Diagnostic Protein folding

Compiling Finite Domain Constraints to SAT with Bee (tool paper & release); Amit Metodi and Michael Codish; ICLP 2012

Implementation Currently we use CryptoMiniSAT (or MiniSAT) The compiler is written in Prolog (SWI) (equating Boolean variables using unification) SAT, BDD and Adhoc rules to implement E.P.

Where now? applications implementation complete equi-propagation (on chunks) how to implement it how to decide where to apply it

Conclusions New Emerging Paradigm where we program with SAT (or SMT) solvers; High”er-level (constraint based) language to aid in the encoding lets us focus on the modeling The notion of E.P. captures many standard CSP techniques and more. Making the CNF smaller is not the real goal; It is more about restricting the search space by identifying equalities that must hold