1 / 26

SAT-solving

SAT-solving. An old AI technique becomes very popular in modern A.I. O verview:. Unit propagation SAT-solving. Basics on SAT. Local Search SAT-solving. What is SAT-solving?. Given KR: a set of propositional formula’s. Find a model for KR. More specifically:.

buckleym
Download Presentation

SAT-solving

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. SAT-solving An old AI technique becomes very popular in modern A.I.

  2. Overview: Unit propagation SAT-solving Basics on SAT Local Search SAT-solving

  3. What is SAT-solving? • Given KR: a set of propositional formula’s • Find a model for KR. More specifically: • Let X1, X2, …, Xn be all the variables in KR, • Find an assignment I; Xi -> {T,F} , for i=1,n , such that all formula’s in KR become true. Useful ?

  4. X1,1 X1,2 X1,3 Representation: X2,1 X2,2 X2,3 Example: 3-queens X3,1 X3,2 X3,3 represents: there is a queen on i,j Xi,j At least one queen on each row: Xi,1  Xi,2 Xi,3 (i=1,3) At most one queen on each row: Xi,1  ~Xi,2 ~Xi,3 ,Xi,2  ~Xi,1 ~Xi,3 , Xi,3  ~Xi,1 ~Xi,2 (i=1,3) Plus: similar formulas for columns and diagonals. 33 formula’s ! Generalisation to q-queens ? Very many formula’s !

  5. Representation: - For every employee, i, - For every shift in the day, j, - For every day in the month, k : Example: personel rostering represents: i works on shift j of day k Xi,j,k At least one person works on every shift of every day: Xi,j,k (j=1,5, k=1,30) i=1,35 An interpretation assigns to each Xi,j,k: true or false Is a personel assignment ! Often this is more elegantly done with assignments to {0,1} and sums instead of  Generalise to higher numbers than just 1

  6. SAT-solving and NP-completeness • SAT-solving: one of the first identified as NP-complete Means: all other NP-problems are technically equivalent with this problem • If you find a P-algorithm for SAT: you get a P-algorithm for all the others. • Also means: most problems can be encoded as SAT-problems and solved using SAT-techniques.

  7. Although NP(-complete) • Has led to: • Many areas in CS and AI convert problems to SAT • Then use SAT-solvers. But why practically useful? Very efficient heuristic approaches exist that work well on certain classes of problems.

  8. Compute a finite grounding of the predicate logic theory. • Marcus example: 2 constants: Marcus and Ceasar. Example: Automated Reasoning 1.man(Marcus) is ground 2.Pompeian(Marcus) is ground 3. x Pompeian(x)  Roman(x) Pompeian(Marcus)  Roman(Marcus) Pompeian(Ceasar)  Roman(Ceasar) 4.ruler(Caesar) is ground x Roman(x)  loyal_to(x,Caesar)  hates(x,Caesar) 5. Roman(Marcus)  loyal_to(Marcus,Caesar)  hates(Marcus,Caesar) Roman(Ceasar)  loyal_to(Ceasar,Caesar)  hates(Ceasar,Caesar) Ect. ….

  9. Example: continued • Ground predicate logic is equivalent to propositional ! Example: Pompeian(Marcus) converts to Pompeian_Marcus loyal_to(Marcus,Caesar) converts to loyal_to_Marcus_Caesar • Add the propositional version of the negation of the theorem ~loyal_to(Marcus,Caesar) converts to loyal_to_Marcus_Caesar • The theorem follows if and only if this propositional KB in unsatisfiable ! SAT-solving

  10. Idea: p  q p  q push all ~ as deep as possible apply distributivity of  and  p  q  q  p q  ~p • Every formula is equivalent to a formula of the form: (A1  ...  An)  (B1  … Bm)  …  (C1  … Ck) Conjunctive Normal Form • where all Ai, Bi, …, Ci are either atomic or ~atomic. • SAT-solving will work on a collection of disjunctions: X1 … Xn ~Y1  … ~Ym

  11. Naive SAT-solving Depth-first left-to-right enumeration of all interpretations

  12. X~Y~W, ~XYZ, ~XW X=F X=T T~Y~W, FYZ, FW F~Y~W, TYZ, TW SAT - Standard backtracking Y=T Y=F Y=T Y=F FZ, W F~W, T~W TZ, W Success W=T W=F Z=F Z=T Z=F Z=T F T F, W T, W T, W F, W Fail Fail Fail Success W=T W=F W=T W=F T F T F Success Fail Success Fail

  13. NaiveSAT(i) Naïve SAT-solving algorithm Form is a CNF-formula with variables X1, X2, ...Xn S:= { Dj | Dj is a disjunction in Form} ForTruth = T, Fdo Xi := Truth; Remove all Dj containing T from S; Remove all F and Ffrom all Dj; If no Dj in S is equal to Fthen IfS= {}then return( X1, X2, … , Xn); Elsei := i + 1; NaiveSAT( i); i := i - 1; End-For Call: NaiveSAT(1)

  14. Davis-Putman (1960):unit propagation The basis for VERY efficient SAT-solvers An early form of Dynamic Search Rearrangement

  15. 1. Dealing with pure symbols • A variable Xi is pure if it only appears with one sign in all disjunctions. • Assign a pure variable the value that makes it true everywhere (don’t consider the other assignment). Example: S = { X ~Y , ~Y ~Z, Z X } X is pure: only occurs positive Y is pure: only occurs negative Z is not pure.

  16. X~Y~W, ~XYZ, ~XW Z is pure Z=T SAT + treating pure symbols X~Y~W, ~XY T, ~XW Y is pure Y=F XT~W, ~XW X is pure X=F T W Success

  17. We get a _much_ smaller search space ! The order of choosing variables has become dynamic. Effect of dealing with pure symbols: But we are no longer considering all assignments. • Yet: we do not loose completeness: • If another solution exist, then the current assignment is ok too. • + If unsatisfiable: this will fail too. But not first-fail based.

  18. 1. Unit propagation • A disjunction is unit if it only contains one variable Xi. • Assign a unit the value that makes it true (don’t consider the other assignment). Example: S = { X ~Y , ~Y, X } ~Y and X are units

  19. X~Y~W, ~XYZ, ~XW X=F X=T T~Y~W, FYZ, FW F~Y~W, TYZ, TW SAT – with unit propagation unit ! W=T Y=T Y=F YZ, T F~W T~W unit ! W=F Success Y=T Y=F T TZ, unit ! FZ Success Success Z=T T Success

  20. Smaller search space again. Many more optimzations in real SAT-solvers! Effect of unit propagation But example is not well suited for unit propagation. • Obviously: combine both optimizations! • - Components analysis. • - More Dynamic Search Rearrangement • Eg.: take most frequent variable first • - Intelligent backtracking, Indexing, …

  21. Marcus as SAT-solving: • Part of the grounding of Marcus-example • plus the negation of the theorem: man_Marcus, ruler_Caesar, try_assassinate_Marcus_Ceasar, loyal_to_Marcus_Caesar, ~man_Marcus  ~ruler_Ceasar  ~try_assassinate_Marcus_Ceasar  ~local_to_Marcus_Ceasar, ... try_assassinate_Marcus_Ceasar = T man_Marcus = T ruler_Caesar = T loyal_to_Marcus_Caesar = T 4 unit propagations: T, T, T, T, F F F F, ... Fails ! Theorem proved.

  22. SAT-solvingby Local Search WalkSAT algorithm

  23. Local Search representation: States are n-tuples: (T,F,F,T, …,F) Xi , i=1,n propositional variables Dj, j=1,m the disjunctions in the CNF Neighbors: flip one truth value of an Xi in failing Dj Objective function: the number of Dj ‘s that evaluate to F To avoid local minima: probabilistically do Not take the best flip = an interpretation for the Xi ‘s Find the global minimum

  24. The WalkSAT algorithm: Max_flip:= some number; P:= some probability; S:= { Dj | Dj disjunction}; State:= some interpretation for X1, X2, ...Xn; Fori= 1 to Max_flipdo IF all Dj’s are true in StateThenreturnState; Else Disj:= random Dj that is false under State; With probability P flip random Xi in Dj; Else flip the Xi of Dj that minimizes false Dj’s; End-For Report Failure

  25. Evaluation: • Unclear whether optimized SAT-solving or Local Search is better. • but today more people are using local search • Efficiency of methods depends on underconstraint versus overconstraintness of problems • see Norvig & Russel for a discussion

  26. What about Disjunctive Normal From? • DNF: a dual representation for propositional formulas: (A1  ...  An)  (B1  … Bm)  …  (C1  … Ck) • Satisfiability of DNF can be checked in linear time! • Find 1 conjunction that does not contain a variable and the negation of that variable. But: conversion to DNF requires exponential time and exponential space ! • CNF and DNF are dual: so conversion to CNF is also exponential !!! So why do we still prefer CNF ?? Think about it.

More Related