15-853:Algorithms in the Real World

Slides:



Advertisements
Similar presentations
Exploiting SAT solvers in unbounded model checking
Advertisements

Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Propositional and First Order Reasoning. Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p 
Proofs from SAT Solvers Yeting Ge ACSys NYU Nov
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View SAT.
1/30 SAT Solver Changki PSWLAB SAT Solver Daniel Kroening, Ofer Strichman.
1 Backdoor Sets in SAT Instances Ryan Williams Carnegie Mellon University Joint work in IJCAI03 with: Carla Gomes and Bart Selman Cornell University.
The Theory of NP-Completeness
Properties of SLUR Formulae Ondřej Čepek, Petr Kučera, Václav Vlček Charles University in Prague SOFSEM 2012 January 23, 2012.
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
SAT and Model Checking. Bounded Model Checking (BMC) A.I. Planning problems: can we reach a desired state in k steps? Verification of safety properties:
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Methods for SAT- a Survey Robert Glaubius CSCE 976 May 6, 2002.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
08/1 Foundations of AI 8. Satisfiability and Model Construction Davis-Putnam, Phase Transitions, GSAT Wolfram Burgard and Bernhard Nebel.
Ryan Kinworthy 2/26/20031 Chapter 7- Local Search part 1 Ryan Kinworthy CSCE Advanced Constraint Processing.
Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis
GRASP-an efficient SAT solver Pankaj Chauhan. 6/19/ : GRASP and Chaff2 What is SAT? Given a propositional formula in CNF, find an assignment.
The Theory of NP-Completeness
Methods of Proof Chapter 7, second half.
1 Backdoors To Typical Case Complexity Ryan Williams Carnegie Mellon University Joint work with: Carla Gomes and Bart Selman Cornell University.
1 Understanding the Power of Clause Learning Ashish Sabharwal, Paul Beame, Henry Kautz University of Washington, Seattle IJCAI ConferenceAug 14, 2003.
1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: Satisfiability (Reading R&N: Chapter 7)
Knowledge Representation II (Inference in Propositional Logic) CSE 473 Continued…
1 Paul Beame University of Washington Phase Transitions in Proof Complexity and Satisfiability Search Dimitris Achlioptas Michael Molloy Microsoft Research.
SAT Solving Presented by Avi Yadgar. The SAT Problem Given a Boolean formula, look for assignment A for such that.  A is a solution for. A partial assignment.
Logic - Part 2 CSE 573. © Daniel S. Weld 2 Reading Already assigned R&N ch 5, 7, 8, 11 thru 11.2 For next time R&N 9.1, 9.2, 11.4 [optional 11.5]
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Satisfiability Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Boolean Satisfiability and SAT Solvers
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
CHAPTERS 7, 8 Oliver Schulte Logical Inference: Through Proof to Truth.
INTRODUCTION TO ARTIFICIAL INTELLIGENCE COS302 MICHAEL L. LITTMAN FALL 2001 Satisfiability.
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module Logic Representations.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
On the Relation between SAT and BDDs for Equivalence Checking Sherief Reda Rolf Drechsler Alex Orailoglu Computer Science & Engineering Dept. University.
First-Order Logic and Inductive Logic Programming.
SAT 2009 Ashish Sabharwal Backdoors in the Context of Learning (short paper) Bistra Dilkina, Carla P. Gomes, Ashish Sabharwal Cornell University SAT-09.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
Review of Propositional Logic Syntax
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Accelerating Random Walks Wei Wei and Bart Selman.
Heuristics for Efficient SAT Solving As implemented in GRASP, Chaff and GSAT.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Satisfiability and SAT Solvers CS 270 Math Foundations of CS Jeremy Johnson.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
Inference in Propositional Logic (and Intro to SAT) CSE 473.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Inference in Propositional Logic (and Intro to SAT)
Inference and search for the propositional satisfiability problem
Computability and Complexity
First-Order Logic and Inductive Logic Programming
Complexity 6-1 The Class P Complexity Andrei Bulatov.
ECE 667 Synthesis and Verification of Digital Circuits
Decision Procedures An Algorithmic Point of View
Artificial Intelligence
GRASP-an efficient SAT solver
Presentation transcript:

15-853:Algorithms in the Real World Satisfiability Solvers (Lectures 1 & 2)

Satisfiability (SAT) Input: Output: The “original” NP-Complete Problem. Input: Variables V = {x1, x2, …, xn}, Boolean Formula Φ (typically in conjunctive normal form (CNF)). e.g., Φ = (x1 v x2 v ¬x3) & (¬x1 v ¬x2 v x3) & … Output: Either a satisfying assignment f:V → {True, False} that makes Φ evaluate to True, OR “Unsatisfiable” if no such assignment exists.

Extensions/Related Problems Satisfiability Modulo Theories Input: a formula Φ in quantifier-free first-order logic. Output: is Φ satisfiable? Theorem Provers Pseudo-boolean optimization Planners (Quantified SAT Solvers)

Applications Verification: Optimization Hardware: Electronic design automation market is about $6 Billion Protocols: e.g., use temporal logic to reason about concurrency Software Optimization Competitor to Integer Programming solutions in some domains Math: Prove conjectures in finite algebra

An Aside: Example Proof by Machine Thm: Robbins Algebra = Boolean Algebra Robbins Algebra: values {0,1} and 3 axioms: x v (y v z) = (x v y) v z x v y = y v z ¬ (¬(x v y) v ¬(x v ¬y)) = x Conjectured in 1933 Proved in 1996 by prover EQP running for 8 days (RS/6000 with ~30 MB RAM) Limited success since 1990s.

Annual Competitions SAT Competition CADE ATP System Competition ASP Solver Competition SMT-COMP Constraint Satisfaction Solver Competition Competitition/Exhibition of Termination Tools TANCS QBF Solvers Evaluation Open Source Solvers: SATLIB, SATLive

Algorithms for SAT Complete (satisfying assignment or UNSAT) Davis-Putnam-Logemann-Loveland algorithm (DPLL) Incomplete (satisfying assignment or FAILURE) GSAT WalkSAT

Prerequisite: Proof Systems What constitutes a proof of unsatisfiability? For a language L in {0,1}*, a proof system for membership in L is a poly-time computable function P such that For all x in L, there is a witness y with P(x,y) = 1 For all x not in L, for all y, P(x,y) = 0 Complexity: worst case length of shortest witness for an x in L.

Proof System Examples L = satisfiable boolean formulae What’s the lowest complexity proof system for this you can come up with? What about for L = unsatisfiable boolean formulae?

Proof System Examples For unsatisfiability: Witness = truth table T of Φ P(Φ, T) checks that T is indeed the truth table for Φ, and all entries are zero Corresponds to a (failed) brute force search for a solution Exponential Complexity Is there a proof system for UNSAT with poly complexity? (Does NP = Co-NP?)

Resolution Proof System The Resolution Rule: Witness = a sequence of valid derivations starting from the clauses of Φ. Sound: (B v x) & (C v ¬x) implies (B v C) Complete for unsatisfiability: Every unsatisfiable formula has a derivation of a contradiction (i.e., the empty clause). For clauses B, C and variable x, From (B v x) & (C v ¬x) derive (B v C)

Duality Truth table proof system gives proofs by failed search for a satisfying assignment. Resolution proof system gives proofs by showing the initial clauses (constraints) yield a contradiction. This is a systematic search for additional constraints the solution must satisfy.

High level idea for many solvers Alternate search for solution with search for properties of any solution: Search for solution in some small part S of the space If search in S fails, search for a reason for this failure, in the form of a new constraint C the solution must satisfy. Search for a solution in a new part of the space, using new constraint to help guide the search Repeat

{{a, ¬b, c}, {¬a, b, d}} |{¬a} = {{¬b, c}} Notation Convenient notational change for SAT: Clauses are sets: (a v ¬b v c) becomes {a, ¬b, c} Formulae become sets of clauses Partial assignments become sets of literals that contain at most one of {xi, ¬xi} for each i. Assignments contain exactly one of {xi, ¬xi} for each i. Restriction: Φ|{x} is the residual formula under partial assignment {x}, e.g., {{a, ¬b, c}, {¬a, b, d}} |{¬a} = {{¬b, c}}

Basic DPLL (‘60, ‘62) Simple tree search for a solution, guided by the clauses of Φ. DPLL-recursive(formula F, partial assignment p) (F,p) = Unit-Propagate(F, p); If F contains clause {} then return (UNSAT, null); If F = {} then return (SAT, p); x = literal such that x and ¬x are not in p; (status, p’) = DPLL-recursive(F|{x}, pU{x}); If status == SAT then return (SAT, p’); Else return DPLL-recursive(F|{¬x}, pU{¬x}); If a clause tells you the value of a var, set it appropriately. Choose a branch. Many heuristics to choose from.

Basic DPLL If a clause tells you the value of a variable, set it appropriately. Unit-Propagate(formula F, partial assignment p) If F has no empty clause then While F has a unit clause {x} F = F|{x}; p = p U {x}; return (F,p)

Embellishing DPLL Branch Selection Heuristics Clause Learning Backjumping heuristics Watched literals Randomized Restarts Symmetry breaking More powerful proof systems …

Branch Selection Heuristics Random Max occurrence in clauses of min size Max occurrence in as yet unsatisfied clauses With probability proportional to some function of how often the literal appears in partial assignments that lead to unsatisfiable restricted formulae. …

Clause Learning When DPLL discovers F|p is unsatisfiable, it derives (learns) a reason for this in the form of new clauses to add to F. What clauses are learned, and how, make huge differences in performance. Trivially learned clause: if F|p is unsatisfiable for p = {x1, x2, …, xk}, derive clause {¬x1, ¬x2, …, ¬xk} But we want short clauses that constrain the solution space as much as possible…

Clause Learning Use the clauses to guide the search: So far we’ve seen unit-propagation, and search with restriction. We want to learn clauses that let us prune effectively – this requires us to deduce “higher level” reasons why some partial assignment is no good. Use resolution (or some technique) to try to prove that F|p is unsatisfiable for nodes p high up the tree.

High level: DPLL w/Clause Learning DPLL-CL (formula F) p = {} While(true) Choose a literal x such that x and ¬x are not in p; p = pU{x}; Deduce status from (F, p); // SAT, UNSAT, or unknown If status == SAT then return (SAT, p); If status == UNSAT then Analyze-Conflict(p); // Add learned clause(s) to F if p = {} then return (UNSAT, null); Else backtrack; // remove literals from p // based on learned clause(s) If status == unknown then continue; // branch again

Deduce Tradeoff between searching more partial assignments (going deeper in the tree), and searching for proofs of unsatisfiability higher up in the tree. Currently, deduction is typically just iterated unit-propagation. (Other embellishments to DPLL seem to render more complex deduction unhelpful in practice.)

Analyze Conflict: Implication Graph p = {¬x1, x3 , ¬x4} F = {{x1, x5}, {¬x3,x4, ¬x5}} {x1, x5} ¬x1 x5 {¬x3,x4, ¬x5} {¬x3,x4, ¬x5} x4 x3 conflict conflict ¬x4 From p

Implication Graph x6 ¬x1 x5 x4 ¬x7 x2 ¬x6 ¬x8 x3 ¬x5 May contain several sources of conflicts. x6 ¬x1 x5 x4 ¬x7 x2 ¬x6 ¬x8 x3 ¬x5

Implication Graph x6 ¬x1 x5 x4 ¬x7 x2 ¬x6 ¬x8 x3 ¬x5 The conflict graph for conflict variable x5 (solid edges). x6 ¬x1 x5 x4 ¬x7 x2 ¬x6 ¬x8 x3 ¬x5

Conflict Graphs x6 ¬x1 x5 x4 ¬x7 x2 ¬x6 ¬x8 x3 ¬x5 The conflict graph for conflict variable x6 (solid edges). x6 ¬x1 x5 x4 ¬x7 x2 ¬x6 ¬x8 x3 ¬x5

Analyze Conflict Every nontrivial cut of each conflict graph yields a conflict clause. Which one(s) do we add to the clause set? {x1, ¬x3 , x4} {¬x3 , x4, ¬x5} ¬x1 x5 the trivial cut (not useful) x4 x3 conflict ¬x4

What Clauses to Learn? Can’t keep everything -- space is a major bottleneck in practice. Various heuristics: First unique implication point First new cut Decision cut …

Backtracking/Backjumping For each x in p, maintain: Int depth(x): number of literals in p immediately after x was added to p. Bool flipped(x): did we try the partial assignment with ¬x and all literals at lower depth than x in p? If we can derive a conflict clause C containing only x and literals of lower depth in p, then we can backtrack to x: delete all literals with depth > depth(x) from p, If flipped(x) = true, then delete x as well. Other heuristics backtrack more aggressively.

Random Restarts Restart: keep learned clauses, but throw away p, resample random bits, and start again. Essentially a very aggressive backjump. Can help performance a lot. Run time distributions appear to be heavy-tailed.

Random Restarts: Heuristics Fixed cutoff (always restart after T seconds) Cutoff after k restarts is some function f(k) Luby et. al. universal restart strategy for f(k) f(k) = c*k, c^k, … Restart policies based on predictive models of solver behavior: Bayesian approaches, Dynamic Programming, Online submodular function maximization*

Embellishing DPLL Branch Selection Heuristics Clause Learning Backjumping heuristics Watched literals Randomized Restarts Symmetry breaking More powerful proof systems …

Watched Literals Clever lazy data structure Maintain two literals {x,y} per active clause C that are not set to false. (“C watches x,y”) If x set to true, do nothing If x set to false, For each C watching x, either find another variable for C to watch, or do unit-propagation on C as appropriate. For each previously active C’ containing ¬x, set C’ to watch ¬x If x is unset, do nothing (!)

Watched Literals Helps quickly find if a clause is satisfied (just look at its watched literals) Helps quickly identify clauses ripe for unit-propagation. “now a standard method used by most SAT solvers for efficient constraint propagation” – Gomes et. al. “Satisfiability Solvers” Partially explains why deduce step is typically just iterated unit-propagation

Symmetry Breaking Symmetry is common in practice (e.g., identical trucks in vehicle routing) SAT encoding throws away this info. Symmetry is useful for some proofs: e.g., Pigeon-hole principle: Impossible to place (n+1) birds into n bins, such that each bin gets at most one bird.

Pigeon Hole Principle Exponentially long proofs via resolution. Polynomially long proofs via cutting planes Binary var x(i,j) = assign bird i to bin j. 1) Each bird i gets a bin: ∑(bins j) x(i,j) = 1 2) Each bin j has capacity one: ∑(birds i) x(i,j) ≤ 1 Summing (1) over birds: ∑(birds i)∑(bins j) x(i,j) = n+1 Summing (2) over bins: ∑(bins j)∑(birds i) x(i,j) ≤ n Combine these to get 0 ≤ -1.

Symmetry Breaking Symmetries provided as part of input, or automatically detected (typically via graph isomorphism) Impose lexicographically minimal constraints Simple case: If {xi : i = 1,2,…, k} are all interchangeable, add constraints (xi v ¬xj) for all i < j. “If there’s a solution with r of k vars set true, let them be x1 through xr”

Symmetry Breaking x xπ Example: π = (2, 1, 3) Order the variables, imagine assignment as a vector x. Identify permutations π on variables, such that if p is a satisfying assignment, then p•π is. Add constraints x ≤ xπ Example: π = (2, 1, 3) x xπ

Other Proof Systems Truth Tables Frege Systems (includes resolution as a special case) Extended Resolution: Add new vars Resolution w/symmetry detection Geometric systems (infer cutting planes) … “Frey-guh”

Incomplete Algorithms Returns satisfying assignment or FAILURE Based on heuristic search for a solution Faster than complete algorithms for many classes of satisfiable instances. Examples: GSAT, WalkSAT, Survey Propagation/Belief Propagation Local search algs, Simulated Annealing, ILP, …

Greedy-SAT GSAT(formula F) For(r = 0 to MAX-ROUNDS) Pick random assignment p. For (t=0 to MAX-FLIPS) If p satisfies F, return p; Else Find the variable v that if flipped maximizes the increase in satisfied clauses of F. Flip(v); Return FAILURE; Flip(boolean v) v = ¬v;

WalkSAT Local Search Heuristic WalkSAT(formula F) For(r = 0 to MAX-ROUNDS) Pick random assignment p. For (t=0 to MAX-FLIPS) If p satisfies F, return p; Else Find the variable v that if flipped maximizes the increase in satisfied clauses of F. Flip(v); Return FAILURE; WalkSAT Local Search Heuristic

WalkSAT Local Search Heuristic Def: Break count of v relative to p = number of clauses that flipping v in p renders unsatisfied. Pick unsatisfied clause C at random; If some v in C has break count = 0, flip v. Else With probability β, flip a random variable in C; Else with probability (1-β), flip a variable in C with minimum break count. Greedy Move Random Walk Move

Survey Propagation Derived from the cavity method in statistical physics. Like DPLL with a special branching heuristic: belief-propagation on objects related to SAT solutions (“covers”) Works really well in practice on some random instances – unclear why.

Phase Transitions in SAT For random k-SAT instances, time to solve an instance depends on #clauses/#vars Easy to prove satisfiability Threshold Easy to prove unsatisfiability Source: Satisfiability Solvers Gomes, Kautz, Sabharwal, Selman

Backdoor Sets Given a polynomial time subsolver A and formula F, a set S of variables is a strong backdoor if, whenever the vars in S are fixed by partial assignment p, A solves F|p. Some real-world instances of SAT have small backdoor sets (e.g., < 1% of vars). Useful in explaining success of certain solvers and restart policies

Model Counting Count # of solutions (#P-Complete) One idea: Add random parity constraints, until unsatisfiable Each parity constraint eliminates ~1/2 of the solutions. Add k constraints  ~2(k-1) solutions

Encoding Problems in SAT If x then y: {¬x, y} z = (x and y): {x, ¬z}, {y, ¬z}, {¬x, ¬y, z} z = (x XOR y): {¬x, ¬y, ¬z}, {x, y, ¬z}, {¬x, y, z}, {x, ¬y, z} Planning instances: Constrain length of the plan. bit-wise encoding of arithmetic …