csps adding structure to sat n.
Skip this Video
Loading SlideShow in 5 Seconds..
CSPs: Adding Structure to SAT PowerPoint Presentation
Download Presentation
CSPs: Adding Structure to SAT

Loading in 2 Seconds...

  share
play fullscreen
1 / 94
Download Presentation

CSPs: Adding Structure to SAT - PowerPoint PPT Presentation

mahsa
115 Views
Download Presentation

CSPs: Adding Structure to SAT

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CSPs: Adding Structure to SAT George Katsirelos Fahiem Bacchus University of Toronto

  2. Introduction • Finite domain Constraint Satisfaction Problems (CSPs). • Formally equivalent to SAT • Important practical differences. • Different algorithmic techniques have been developed in the two areas. • Understanding these can help cross fertilize both fields.

  3. BackgroundThe SAT and CSP Formalisms

  4. Formalism

  5. Formalism • SAT = hV, Ci • V = {V1, V2, …, Vn} is a set of Boolean variables • C = {c1, c2, …, ck} a set of clauses. • CSP = hV, D, Ci • V = {V1, V2, …, Vn} is a set of multi-valued variables • D = {D1, D2, …, Dn} is a set of value domains, with Di being the domain of values for variable Vi • C = {C1, C2, …, Ck} is a set of constraints. • In both CSP and SAT the aim is to find an assignment of values for all of the variables: • In SAT these values must satisfy the clauses • In CSPs these values must satisfy the constraints.

  6. Constraints • A constraint C(X1,X2, …, Xk) over the variables X1, …, Xk is a Boolean function • It maps assignments to these variables to {0,1} C(X1,X2, …, Xk) : DX1££ DXk {0,1} • If a tuple of assignments maps to 1, then these assignments satisfy the constraint, otherwise these assignments the falsify the constraint.

  7. Extensionally vs Intensionally Represented Constraints • We can specify the constraint with a table • C(X,Y,Z) with DX = DY = DZ = {1, 2, 3}

  8. Extensionally vs Intensionally Represented Constraints • Thus we can represent the constraint as a set of satisfying assignment tuples

  9. Extensionally vs Intensionally Represented Constraints • Or as a set of falsifying assignment tuples

  10. Extensionally vs Intensionally Represented Constraints • Extensionalrepresentations specify the constraint as an explicit list of satisfying assignments (or falsifying assignments). • Extensional representations were used in the 2005 CSP solver competition. But are almost never used in practice. • The extensional representation becomes very large, growing exponentially with the number of variables the constraint is over.

  11. Extensionally vs Intensionally Represented Constraints • Constraint could also be represented intensionally as an algorithm for computing the Boolean function.

  12. Extensionally vs Intensionally Represented Constraints = X · Y · Z

  13. Extensionally vs Intensionally Represented Constraints • Intensional representations are typical in practice. • To specify a CSP problem in a CSP solver one supplies subroutines to implementing the constraints of the problem. • Commercial CSP solvers supply a large library of predefined common constraints. • You then simply specify the variables of the CSP, their domains, and the constraints that are over them.

  14. Translating between SAT and CSPs • Further insight into the relation between SAT and CSPs is provided by looking at how we can translate between the formalisms.

  15. SAT  CSP • Translating in this direction is trivial • Each SAT variable becomes a CSP variable, with {0,1} as its domain of values. • Each clause is equivalent to a Boolean function from the variables it is over • (x, y, -z) A function mapping (x=0,y=0,z=1) to 0, all other assignments of x,y,z to 1.

  16. CSP SAT • The other direction requires two steps • Converting the multi-valued variables into a set of Boolean assignment variables. • Converting the constraints into clauses over the assignment variables.

  17. CSP SATConverting the Multi-Valued Variables • Let X be a CSP variable with Dx = {d1, …, dm} • We create m Boolean assignment variables x1, x2, …, xm these have the the interpretation xi is true iff X=di.

  18. CSP SAT • The CSP variable X must have a value and it must have a unique value. • Hence the Boolean assignment variables x1, x2, …, xm associated with a particular CSP variable are mutually exclusive and exhaustive. • This is captured by adding the clauses • (x1, x2, …, xm) X must have a value • (-xi, -xj) for all (i  j) X has a unique value

  19. CSP SATConverting the Constraints into Clauses • Now we convert the constraints to clauses. • Each falsifying assignment tuple in the constraint’s extensional representation is equivalent to a clause. • So a constraint becomes a set of clauses, one for each falsifying assignment.

  20. CSP SAT • Each falsifying tuple is a set of assignment variables that cannot be simultaneously true. • E.g.. –(x1^ y2^ z1) • Pushing the negation in we get a clause(-x1_ -y2_ -z1)

  21. CSP SAT • There are various optimizations that can be applied to this basic translation. • Specific constraints admit more compact encodings.

  22. Modeling with CSPs

  23. Modeling with CSPs • CSPs offer • Multi valued variables: more natural for modeling real problems. • Constraints over groups of variables that permit a more natural encoding of the constraints of the problem. • Industrial applications are much easier to formalize using CSPs, and the range of application of CSP technology in industry far exceeds that of SAT.

  24. N-Queens • Place N queens on an NxN chess board so that no queen can attack any other queen.

  25. N-Queens • Place N queens on an NxN chess board so that queen can attack any other queen. • N, Queen variables, one for each column

  26. N-Queens • Place N queens on an NxN chess board so that queen can attack any other queen. • N values for each variable: • The row we place that column’s queen on.

  27. N-Queens • Constraints • AllDiff(Q1, …, QN) each Queen has a unique value (can’t be in the same row) • Cij(Qi,Qj): |Qi – Qj|  |i-j| (for each i  j) • can’t be on same diagonal

  28. Modeling with CSPs • A SAT encoding of N-Queens more complex to specify. • SAT encodings almost impossible to generate by hand.

  29. Modeling with CSPs • Modeling using the richer language of CSPs, translate to SAT (automatically), solve using standard SAT solver. • Understanding the pros and cons of this approach gives us further insight into the algorithmic differences between CSP and SAT solvers.

  30. Solving CSPs

  31. Backtracking Search • SAT and CSP backtracking solvers differ in the three main parts of backtracking • Propagation as we descend the search tree • Learning as we ascend from failed subtrees • Heuristics for guiding the branching decisions

  32. Translation to SAT • The clause learning in SAT solvers can be exploited. • The mutually exclusive and exhaustive clauses for the multi-valued variables are not fully exploited. • Branching heuristics insensitive to CSP structure. • Unit propagation weaker than propagation methods employed in CSP solvers.

  33. Disadvantages:(a) Clauses for Multi-valued Variables

  34. Disadvantages:(a) Clauses for Multi-valued Variables • These clauses impose a useful structure on the assignment variables. • (x1, x2, …, xm) X must have a value • (-xi, -xj) for all (i  j) X has a unique value

  35. Disadvantages:(a) Clauses for Multi-valued Variables • In general, the disjunction of any subset of positive literals is equivalent to the conjunction of the complimentary set of negative literals. E.g., if m=4 • x1_ x2 ´ –x3^ –x4 • x3´ -x1^ -x2^ -x4

  36. Disadvantages:(a) Clauses for Multi-valued Variables • This structure could be exploited in various ways. For example, • Two negative assignment literals  clause is redundant • (y1, y2, -x1, -x2, -z3) subsumed by (-x1,-x2)

  37. Disadvantages:(a) Clauses for Multi-valued Variables • Negative assignment literal  remove all positive literals from same variable. • (y1, y2, -y3, x1, -x2, -z3) • Resolve with (-y1, -y3) and (-y2, -y3) to obtain subsuming clause (-y3, -x2, -z3).

  38. Disadvantages:(a) Clauses for Multi-valued Variables • Sets of clauses can be replaced by a single clause. • Dx = Dy = {1, 2, 3, 4}(R, -x1, -y1) (R, -x1, -y2) (R, -x2, -y1) (R, -x2, -y2) (R, -x1, -y1) (R, -x1, -y2) (R, -x2, -y1) (R, -x2, -y2)Equivalent to single clause(R, x3, x4, y3 , y4).

  39. Disadvantages:(a) Clauses for Multi-valued Variables • (R, x3, x4, y3 , y4) ´ (R, (-x2^ -x1), (-y2^ -y1)) • Multiply this out and you get 8 clauses.

  40. Disadvantages:(b) Heuristics

  41. Disadvantages: (b) Heuristics • Under unit propagation contradictions arise when –x is inferred in a context where x is already true • This causes some clause to be falsified (conflict clause).

  42. Disadvantages: (b) Heuristics • With multi-valued variables we always have • xi´ -x1^ –xi-1^ –xi+1^ -xm • Hence conflicts arise only from refuting all values from some CSP variable’s domain • -x1^^ -xm

  43. Disadvantages: (b) Heuristics • In CSP solvers the number of unrefuted values of a variable is always considered in the branching heuristic. • In a SAT solver we shouldn’t choose to branch on xi without considering the status of other associated assignment variables. Ansótegui1 et al 2003.

  44. Disadvantages:(c) Propagation

  45. Disadvantages: (c) Propagation • Unit Prop in a SAT solver on the clauses generated by a constraint is equivalent to Forward Checking in CSPs. • Forward Checking. Wait until all but one variable of the constraint is instantiated, and then prune incompatible values from the domain of the sole remaining uninstantiated variable.

  46. Disadvantages: (c) Propagation • (-x1_ -y2_ -z1) • (-x1_ –y3_ –z1) • …

  47. Disadvantages: (c) Propagation • Each clause contains one negated assignment literal from each CSP variable in the constraint. • To make the clause unit one has to make all but of these assignment variables true: • Equivalent to assigning the corresponding CSP variable • x1´ X=1, y2´ Y=2

  48. Disadvantages: (c) Propagation • Then unit propagation will falsify all assignments to the remaining unassigned CSP variable that would violate the constraint • (-x1_ –y3_ –z1), (-x1_ –y3_ –z2)X=1 ^ Y=3  Z  1 & Z  2

  49. Disadvantages: (c) Propagation • However, in practice, FC does not perform particularly well. • A superior form of propagation is GAC.

  50. GAC (Macworth & Freuder 1977-79) • Given a constraint C(X1,X2, …, Xk) • di2 DXi is supported(in C) if there exists a set of assignments{X1 = d1, …, Xi = di ,…, Xk = dk} that satisfies C:C(X1=d1, …, Xk = dk) = 1. • This set is called a support for di.