Upcoming SlideShare
×

# CP 2011

438 views

Published on

Boolean Equi-Propagation for Optimized SAT Encoding

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
438
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
2
0
Likes
0
Embeds 0
No embeds

No notes for slide
• In this talk I will present the paper“Boolean Equi-propagation for Optimized SAT Encoding” which is ajoint work of mine with Michal Codish, Vitaly Lagoon, and Peter Stuckey.
• Given an hard finite domain problem there are several ways to solve it:Taking the direct approach by writing a dedicated algorithm.Or model the problem as set of constraints and using CSP solver to solve it.In recent years an alternative approach is becoming increasingly popular, solving finite domain constraint model via encoding to SAT.This popularity arise from two aspects:SAT solvers became increasingly stronger. (Modern SAT solvers can handle large size CNF that involving hundreds of thousands of literals and millions of clauses.)encoding techniques become increasingly sophisticated.Two comments on such CNF encodings:When encoding a constraint and modeling finite domain (integer) variables as bits, we lose in the CNF the relation between bits of an individual constraint.The resulting CNF is typically extremely large, often at the limit of what sat solvers can handle.We will focus on Encoding the Constraint Model to CNF and how to optimized it, in practical how to make it smaller.
• In order to reduce CNF size we can apply CNF level simplifications on the entire CNF in order to find equivalent literals or assignments.But when trying to apply optimizations on the entire CNF the two comments become problems:The relation between bits of an individual constraint is lost and there might be some relevant information lost with it.The large CNF size prevents the ability to run a complete simplification on the CNF. Therefore we have to use tools such SatELite and ReVivAl which based on Unit Propagation and Resolution in order to reduce CNF size.Another way to optimize CNF is performing partial evaluation on the Constraint Model using CSP techniques in order to receive a Simplified Model before encoding. In this case during the partial evaluation we ignores the literals representation in the CNF.Using those techniques isn’t enough.I will show a new technique for “compile” Constraint Model to CNF which produce a better and smaller CNF by taking advantage of CSP techniques and Boolean techniques.
• Our approach is:Given a Constraint Model, for each constraint we keeping two representations : CSP representation (Ci) and Boolean representation (Bi).We simplify the Constraint Model by applying CSP techniques and Boolean techniques on each constraint in the model.The Simplified Constraint Model will contain some of the original constraints, some constraints might been dropped and some constraints might be altered.After receiving a simplified model we generates a CNF formula for the entire problem by encoding each constraint using standard encodings.
• Next I will talk about:Modeling Finite Domain Constraint Satisfaction Problem and focus on number representation.Define what is Equi-Propagation and demonstrate how it works.ExperimentationConclusions
• When encoding Finite Domain CSP to CNF we have to represent the numbers using Boolean variables.There are two main representations: Binary and Unary.Because we dealing with small Finite Domain Problems, we chose to represent integers using Unary.There are two way to represent a number using Unary: Direct Encoding and the Order Encoding.We, as many before us, chose to represent integers using Order encoding.In this representation the bit in location i represent that the number X is great equals i.
• So why Order Encoding ?It is well known that Order Encoding is good for representing ranges – set lower and upper bounds is done by assign the bits outside the range.We saw that Order Encoding is also good for representing arbitrary sets:If we want to set the number X to be different from i , we simply have to unify the ith and the ith+1 bits.Another good feature of Order Encoding is that some arithmetic operations involving constants doesn’t have to be encoded to CNF.Our approach takes advantage of all those features of the order encoding in order to reduce CNF size.
• So what is Equi-Propagation:Equi-propagation is the process of inferring new equational consequences (such as x=y) from a single constraint in the model (and other existing equational information).When inferring such equational consequence, x can be removed from all the constraints by replacing x with it’s equivalent.
• So how is itworks ?We receives a constraint model. For each variable` in the model we holding its “CSP representation” and “Boolean representation”.Here we will focus on two constraints from a model and the relevant data for those constraints.We start by go over the model and simplify one constraint at the time.Lets assume that during the simplification of the last constraints we learned the following information.The information we learned can be in CSP style or Boolean unifiers.Each time we learning, we update the model accordingly (both representations) – for example if we learned that x1=true we will replace each instance of x1 in the model with true. The boolean variable x1 will be dropped from the model.We will keep go over the model and simplify the constraints until there is nothing more to learn.Here we still have information to learn and when reaching diff(U1,U2) we learns that the only way this constraint can be satisfied is when y2= -x2.We update the data accordingly (replace y2 with –x2) and as we can see it is only effect the “Boolean representation”.We give the diff constraint another look and we see there is no need to keep it or encode it because any satisfied assignment will satisfied the constraint.Therefore it can be dropped from the model.(This couldn’t be done if we where looking on the constraints in CSP style alone)We keep going and getting to sumBits constraint. We looking on the bits participate in the constraints and we see there is true bit, false bit and x2 and –x2. This means the sum of those four bits will always be equals to two. Therefore we can replace the constraint with simpler constraint sumBits=1.After there is no more information to learn we will generate the CNF formula for the constraint model by encoding each constraint in the model.Some constraint will be encoded as they were encoded before the simplify step but some constraint will be encoded differently – more efficiently – in the case, instead of encode normal sum of bits and compare the result to 3, we now encode exactly-one which have more efficient encoding.(If we didn’t kept the constraint information and only the CNF formula for each constraint we couldn’t perform such optimization).
• When looking on a valid solution to a problem, we can swap between two rows or two columns to generate another valid solution.We can break symmetry by adding lexical order constraints on the rows and columns.Orwe can do something smarter – assign the first two rows and column as followed…Those assignments gives starting point for the partial evaluation process.
• First lets compare BEE to Sugar which is a well known SAT-based constraint solver based on order encoding.We took our model for BIBD which we break symmetry by assignments, and generated CNF using BEE and Sugar. Then solved the generated CNF on the same SAT solver (CryptoMinisat 2.5.1).First we can see that BEE generate a smaller CNF than Sugarwhich effect solving time.We can also see the CNF generating time of BEE is much smaller than Sugar.
• Second we compared BEE to SatELite which is a well known CNF-level preprocessor.We took our model and encode it without using Equi-Propagation technique. The generated CNF was preprocessed by SatELite before solving it.We can see the CNF generated by BEE and the simplified CNF generated by SatELite is about the same size.Solving time of BEE is usually betterandsometimes the preprocess of SatELite is extremely long.If we look on the highlighted example we can see SatELite is generate a smaller and faster solved CNF but its preprocess time is extremely long.
• CNF IN THIS SLIDE IS AFTER ADDING ANOTHER OPTIMIZATION TO BEE (BEE compile time and solving time is actually better that what written with the new optimization – compile and SAT for BEE copy&amp;paste from previous version – didn’t had time to update).
• At last we compared BEE to MINION which is a general-purpose constraint solver.The 2006 paper contains experiments on large scale BIBD instances.We took the model represented in the paper which includes search order.It seems for the large size BIBD, MINION is very fast and scales well as problem size increases but for other hard instances our tool acts better.But that not a fair comparison. Therefore we gave MINION the same model as ours – the results seem to improved compare to MINION model in most cases but in the instances from 2006 paper it was slower.Unlike MINION, We looking on the SAT solver as black box and have no way to effect search order, therefore, our model didn’t contained any information about search order.By adding search order to our model we manage to reduce solving time even more.
• ### CP 2011

1. 1. Boolean Equi-propagation for Optimized SAT Encoding<br />AmitMetodi, Michael Codish, Vitaly Lagoon, and Peter J. Stuckey<br />
2. 2. Finite Domain Problem Solving<br /><ul><li>Constraint / Bits relation lost
3. 3. Large CNF</li></ul>Problem<br />(hard)<br />Constraint<br />Model<br />CNF<br />Encoding<br />Model<br />Direct<br />CSP solving<br />SAT solving<br />Solution<br />Satisfied assignment<br />Model<br />Solution<br />Decoding<br />Translate<br />
4. 4. Optimized SAT Encoding<br />Problems:<br /><ul><li>Constraint / Bits relation lost
5. 5. Large CNF</li></ul>Constraint<br />Model<br />Encoding<br />CNF<br />Simplify<br />CNF’<br />Simplified<br />Model<br />Encoding<br />Partial Evaluation<br />CNF’’<br />Simplified<br />Model’<br />Encoding<br />Partial Evaluationusing Equi-Propagation<br />Tools such as: SatELite, ReVivAl<br />Based on Unit Propagation and Resolution.<br />Simplified<br />CNF<br />
6. 6. Our Approach<br />Constraint<br />( C2, B2 )<br />Constraint<br />( C3, B3 )<br />Constraint<br />( Cn, Bn )<br />Constraint<br />( C1, B1 )<br />…<br />M =<br />Simplify<br />Boolean techniques<br />CSP techniques<br />Equi-Propagation<br />Constraint<br />( C1, B1 )<br />Constraint<br />( C’3, B‘3 )<br />Constraint<br />( C’n, B’n)<br />Constraint<br />( C2, B2 )<br />…<br />M’ =<br />Encoding<br />Standard encodings<br />φ1<br />φ'3<br />φ'n<br />…<br />φ =<br />
7. 7. Outline<br /><ul><li>Modeling Finite Domain CSP
8. 8. Equi-Propagation
9. 9. Experimentation
10. 10. Conclusions</li></li></ul><li>small<br />Modeling Finite Domain CSP<br />representing numbers (integers)<br />Binary<br />Unary<br />Order encoding<br />Direct encoding<br />Number Xwith a domain {0,1,2, …, d} will be represented using b=log𝑑Boolean variables [ x1,x2,…xb]<br />Number X = k ↔ 𝑖=1𝑏2𝑥𝑖 = k<br /> <br />Number Xwith a domain {0,1,2, …, d} will be represented using n=𝑂(𝑑)Boolean variables.<br /> <br />xi ↔ (X ≥ i)<br />(X = 3) = [1,1,1,0,0]<br />xi ↔ (X = i)<br />(X = 3) = [0,0,0,1,0,0]<br />
11. 11. Why Order Encoding ?<br /><ul><li>good for representing ranges</li></ul>X<br />1<br />0<br />X ≥ i<br />X < j<br />i<br />j<br /><ul><li>good for arbitrary sets</li></ul>X<br />v<br />u<br />i<br />b=c<br />e=f=g<br />a<br />b<br />d<br />c<br />e<br />f<br />g<br /><ul><li>good for arithmetic operations with constants:</li></ul>+ 3 = <br />* 3 = <br />a<br />a<br />a<br />b<br />b<br />b<br />c<br />c<br />c<br />a<br />c<br />b<br />a<br />c<br />b<br />c<br />f<br />1<br />1<br />1<br />c<br />b<br />a<br />div 3 = <br />c<br />b<br />a<br />f<br />e<br />d<br />g<br />
12. 12. Equi-Propagation<br />Equi-propagation is the process of inferring new equationalconsequences from a constraint in the model (and other existing equational information).<br />x= -y, x=y,<br />x=0, x=1<br />single<br />x can now be removed from all constraints.<br />
13. 13. Equi-Propagation Example<br />Learned:<br />Partial Data:<br />U1 { 0..4 } U1 = [x1,x2,x3,x4]<br />U2 { 0..4 } U2 = [y1,y2,y3,y4]<br />Xs = [a,d,b,x3,y2,c,y4]<br />U1 { 1,3 } U1 = [1,x2,x2,0]<br />U2 { 1,3 } U2 = [1,y2,y2,0]<br />Xs = [a,1,b,x2,y2,c,0]<br />U1 { 1,3 } U1 = [1,x2,x2,0]<br />U2 { 1,3 } U2 = [1,-x2,-x2,0]<br />Xs = [a,1,b,x2,-x2,c,0]<br />1≤U1≤3 and U1 ≠ 2 <br />1≤U2≤3 and U2 ≠ 2 <br />d = 1<br />x1=1, x3=x2 , x4=0<br />y1=1, y3=y2 , y4=0<br />d = 1<br />U1 ≠ U2 (y2= -x2)<br />diff(U1,U2)<br />sumBits(Xs)=3<br />Constraints<br />Constraints<br />…<br />…<br />diff(U1,U2)<br />…<br />sumBits([a,b,c])=1<br />Constraints<br />Encoding<br />Encoding<br />Encoding<br />Simplify<br />Simplify<br />Simplify<br />Simplify<br />φsumBits([a,b,c])=1<br />φConstraints<br />φConstraints<br />…<br />…<br />
14. 14. Equi-Propagation<br /><ul><li>A complete equi-propagator for a constraint can be implemented using binary decision diagrams (BDDs) and can be evaluate in polynomial time.When C(X1,…,Xk) a constraint about (fixed) “k” integers with n bits each, the BDD representing it is of size O(n^k)
15. 15. Global constraints (such as allDiff) implemented using Ad-Hoc rules.
16. 16. There is a strong connection between Simplify and Encoding because Simplify done on the “encoding bits” and might change the encoding accordingly.</li></li></ul><li>Graph Crossing<br />BIBD<br />MAS<br />Ben-Gurion-UniversityEqui-propagationEncoder<br />Kakuro<br />Protein<br />folding<br />N-Queens<br />System<br />Diagnostic<br />Magic Square<br />SCM / MCM<br />QCP / Sudoku<br />Nonograms<br />
17. 17. balanced incomplete block designs (BIBD)<br />Definition: a 5-tuple of positive integers <v, b, r, k, l> and require to partition v distinct objects into b blocks such that each block contains k different objects, exactly r objects occur in each block, and every two distinct objects occur in exactly l blocks.<br />Variables: B11, …, Bbv<br />Domains:Bijϵ{0,1}<br />Constraints: <br />each row constraint: sum(Bi1,…,Biv) = r<br />each column constraint: sum(B1i,…,Bbi) = k<br />each two rows constraint: sum(Bi1*Bj1, …,Biv*Bjv)= l<br />b=10<br />v=6<br />BIBD <6,10,5,3,2><br />
18. 18. We can swap between two rows or two columns to generate another valid solution.<br />Balanced Incomplete Block Designs (BIBD)<br />r<br />k<br />r-l<br />l<br /><v, b, r, k, l><br />
19. 19. BIBD – BEEvs Sugar<br />(CSP to CNF Encoder)<br />Faster time to generate CNF<br />Smaller CNF<br />Faster SAT solving time<br />
20. 20. BIBD – BEEvsSatELite<br />(CNF-Level preprocessor)<br />Preprocess time<br />About the same size<br />Solving time<br />
21. 21. Conclusions<br />Constraint<br />( C2, φ2 )<br />Constraint<br />( C3, φ3 )<br />Constraint<br />( Cn, φn )<br />Constraint<br />( C1, φ1 )<br />…<br />M =<br />Constraint<br />Model<br />Encoding<br />CNF<br /><ul><li>When encoding CSP model to SAT holding both representation for each constraint gives the ability to apply simplify techniques from both worlds on each constraint.
22. 22. Apply complete CNF simplification on each constraint is possible in polynomial time.
23. 23. By using the Equi-Propagation technique we generates a small optimized CNF which than can be simplify using CNF-Level simplifications.</li></ul>Simplify<br />CNF’<br />Simplified<br />Model<br />Encoding<br />Boolean techniques<br />CSP techniques<br />Equi-Propagation<br />Partial Evaluation<br />Constraint<br />( C1, φ1 )<br />Constraint<br />( C’3, φ‘3 )<br />Constraint<br />( C’n, φ’n)<br />Constraint<br />( C2, φ2 )<br />…<br />M’ =<br />CNF’’<br />Simplified<br />Model<br />Encoding<br />Partial Evaluationusing Equi-Propagation<br />Simplified<br />CNF<br />
24. 24. Questions ?<br />
25. 25. BIBD – BEE + SatELite<br />(CNF-Level preprocessor)<br />
26. 26. BIBD – BEEvs MINION<br />(Constraint solver)<br />Modeling control<br />
27. 27. Nonograms<br />Definition: an nXm board of cells to color black or white and given clues per row and column of a board. A clue is a number sequence indicating blocks of cells to be colored black.<br />Variables: B11, …, Bnm<br />R11,…R1k,…,Rm1,…Rmp<br />C11,…C1q,…,Cn1,…,Cnr<br />Domains:Bijϵ{0,1} Rmoϵ{0,..,n} Cnoϵ{0,..,m}<br />Constraints: <br />block constraint: block(Rij,Rij+<ij size>,[B1i,…,Bni])<br />space constraint: block(Rij+<ij size>,Rij+1,[-B1i,…,-Bni]) <br />no overlap constraint: leq(Rij+<ij size>+1, Rij+1)<br />
28. 28. Nonograms<br />There are dedicates solvers such as<br /><ul><li>Jan Wolter'spbnsolve</li></ul> (http://webpbn.com/pbnsolve.html)<br /><ul><li>Ben-Gurion University Solver</li></ul> (http://www.cs.bgu.ac.il/~benr/nonograms/)<br />BEE is faster than the dedicated<br />solvers on the hard puzzles.<br />5,000 random 30x30 puzzles<br />Selected human puzzles<br />