1 / 18

Perfect Hashing and CNF Encodings of Cardinality Constraints

Learn about efficient encodings, perfect hash families, encodings based on perfect hash families, properties of encodings, and related applications. Discover known and new encodings for handling cardinality constraints.

billc
Download Presentation

Perfect Hashing and CNF Encodings of Cardinality Constraints

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. Perfect Hashing and CNF Encodings of Cardinality Constraints Yael Ben-Haim Alexander Ivrii Oded Margalit Arie Matsliah SAT 2012 IBM Research - Haifa

  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. 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. 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. 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. 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. 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. 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. 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. An (n,l,r,m) perfect hash family is a collection of functions Each function maps to such that (9,3,3,4) for every subset S of , of size ,there is a function such that

  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. 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 clausesand several cardinality constraints on r variables

  13. 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

  14. 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

  15. 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.

  16. 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.

  17. 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.

More Related