Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2012 IBM Corporation Perfect Hashing and CNF Encodings of Cardinality Constraints Yael Ben-Haim Alexander Ivrii Oded Margalit Arie Matsliah SAT 2012.

Similar presentations


Presentation on theme: "© 2012 IBM Corporation Perfect Hashing and CNF Encodings of Cardinality Constraints Yael Ben-Haim Alexander Ivrii Oded Margalit Arie Matsliah SAT 2012."— Presentation transcript:

1 © 2012 IBM Corporation Perfect Hashing and CNF Encodings of Cardinality Constraints Yael Ben-Haim Alexander Ivrii Oded Margalit Arie Matsliah SAT 2012 IBM Research - Haifa

2 © 2007 IBM Corporation 2 © 2012 IBM Corporation 2 Talk outline  Introduction to cardinality constraints and their encodings.  Definition of perfect hash families.  New encodings for the “at most k” constraint based on perfect hash families – An encoding that preserves arc consistency under unit propagation. – A “hybrid” encoding that partially preserves arc consistency under unit propagation.  Encoding the “at least k” constraint.

3 © 2007 IBM Corporation 3 © 2012 IBM Corporation 3 Cardinality constraints  Let be Boolean variables.  A cardinality constraint is of the form “at most / at least / exactly k out of are TRUE”, i.e., in the at most case:  Cardinality constraints are common in many problems – In constraint programming. – In formal verification. – MAXSAT and other optimization problems.

4 © 2007 IBM Corporation 4 © 2012 IBM Corporation 4 Cardinality constraints (cont.)  Handling of cardinality constraints – Treat them as linear inequalities or Pseudo-Boolean constraints. – Enhance a SAT solver. – Encode to CNF and run with a regular SAT solver.

5 © 2007 IBM Corporation 5 © 2012 IBM Corporation 5 Definition of encoding  A CNF encoding of a cardinality constraint is a formula F on the variables and the auxiliary variables such that: – SAT before remains SAT after: Every assignment to with at most k TRUEs, can be extended to an assignment on that satisfies F. – UNSAT before remains UNSAT after: for any assignment to with more than k TRUEs, there is no extension to such that F is satisfied.

6 © 2007 IBM Corporation 6 © 2012 IBM Corporation 6 Properties of efficient encodings  An efficient encoding encodes problems with cardinality constraints to CNF formulas that can be quickly solved by a SAT solver.  Typically, an efficient encoding has the following properties: – Few clauses. – Few auxiliary variables. – If a partial assignment on assigns TRUE to exactly k variables, then unit propagation assigns FALSE to all other Xs. In this case, we say that the encoding preserves arc consistency under unit propagation.

7 © 2007 IBM Corporation 7 © 2012 IBM Corporation 7 Example: the naïve encoding  The naïve encoding of the constraint :  Properties: – clauses. – 0 auxiliary variables. – Arc consistency is preserved under unit propagation.

8 © 2007 IBM Corporation 8 © 2012 IBM Corporation 8 Known and new encodings  An encoding that does not preserve arc consistency under unit propagation – Parallel counter [Sin05]  An encoding that partially preserves arc consistency under unit propagation – Hybrid PHF – new  Encodings that preserve arc consistency under unit propagation – Naïve – Sequential counter [Sin05] – Cardinality networks [ANOR09] – PHF – new

9 © 2007 IBM Corporation 9 © 2012 IBM Corporation 9 Perfect hashing  Perfect hash families are known and well studied combinatorial structures.  A handful of applications – Database management. – Group testing algorithms. – Cryptography: secret sharing, key distribution patterns.  We will use PHFs as ingredients of our encodings.

10 © 2007 IBM Corporation 10 © 2012 IBM Corporation 10 An (n,l,r,m) perfect hash family  is a collection of functions Each function maps to such that for every subset S of, of size, there is a function such that

11 © 2007 IBM Corporation 11 © 2012 IBM Corporation 11 Encodings based on perfect hash families  Task: encode the constraint  Ingredient: an (n,k+1,r,m) perfect hash family  Encoding steps: after the example.

12 © 2007 IBM Corporation 12 © 2012 IBM Corporation 12

13 © 2007 IBM Corporation 13 © 2012 IBM Corporation 13 Encodings based on perfect hash families  Assuming that we have an (n,l=k+1,r,m) perfect hash family  Encoding steps: for each – Introduce r auxiliary variables – Add clauses for all – Encode the constraint using the sequential counter encoding.  A reduction – From one cardinality constraint on n variables – To a set of implication clauses and several cardinality constraints on r variables

14 © 2007 IBM Corporation 14 © 2012 IBM Corporation 14 Encodings based on perfect hash families  It remains to choose the underlying perfect hash family.  A handful of constructions, striving to minimize m (the number of hash functions) – Random and explicit. – For various ranges of the parameters. – Related to error correcting codes, combinatorial designs, Latin squares and orthogonal arrays, and more.  For, random constructions yield perfect hash families with

15 © 2007 IBM Corporation 15 © 2012 IBM Corporation 15 Known and new encodings  An encoding that does not preserve arc consistency under unit propagation – Parallel counter [Sin05]  An encoding that partially preserves arc consistency under unit propagation – Hybrid PHF – new  Encodings that preserve arc consistency under unit propagation – Naïve – Sequential counter [Sin05] – Cardinality networks [ANOR09] – PHF – new

16 © 2007 IBM Corporation 16 © 2012 IBM Corporation 16 Hybrid encodings  Ingredient: a collection of m hash functions not necessarily forming a perfect hash family.  Encoding steps – Encode to CNF using some encoding. AND IN ADDITION – Follow the same encoding steps as for perfect hash families: introduce auxiliary variables, add implication clauses, encode m “at most k constraints” on r variables.  For a choice of a nearly perfect hash family, we obtain a nearly perfect consistency preservation: for most of k-triplets of Xs, if a partial assignment sets them to TRUE then unit propagation will assign FALSE to all other Xs.

17 © 2007 IBM Corporation 17 © 2012 IBM Corporation 17 At least constraints  Our encodings (as well as others) are designed to be efficient when k is small relative to n. – An approach saying that the “at least k constraint” is equivalent to the “at most n-k constraint” will not work for small k.  We designed a sequential counter encoding for the “at least k constraint” with clauses and auxiliary variables.  We designed a PHF encoding for the “at least k constraint” with clauses and auxiliary variables. – Number of clauses is small but their length is not constant.

18 © 2007 IBM Corporation 18 © 2012 IBM Corporation 18 Summary  Our contribution – A new encoding of cardinality constraints to CNF based on perfect hash families. – A new hybrid encoding. – Similar encodings for the “at least k constraint”. – Empirical results.  Take home message – Use combinatorial structures (e.g. block designs or error- correcting codes) as building blocks in encodings of constraints to CNF.


Download ppt "© 2012 IBM Corporation Perfect Hashing and CNF Encodings of Cardinality Constraints Yael Ben-Haim Alexander Ivrii Oded Margalit Arie Matsliah SAT 2012."

Similar presentations


Ads by Google