From SAT To SMT: Part 1. Vijay Ganesh MIT

Similar documents
VLSI CAD: Lecture 4.1. Logic to Layout. Computational Boolean Algebra Representations: Satisfiability (SAT), Part 1

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 3: Practical SAT Solving

Pythagorean Triples and SAT Solving

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Classical Propositional Logic

An instance of SAT is defined as (X, S)

Tutorial 1: Modern SMT Solvers and Verification

Introduction to SAT (constraint) solving. Justyna Petke

Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel

Topics in Model-Based Reasoning

Satisifiability and Probabilistic Satisifiability

Lecture 2 Propositional Logic & SAT

Solving SAT Modulo Theories

Satisfiability Modulo Theories

Understanding and using SAT solvers

SAT-Solving: From Davis- Putnam to Zchaff and Beyond Day 3: Recent Developments. Lintao Zhang

Solving SAT and SAT Modulo Theories: From an Abstract Davis Putnam Logemann Loveland Procedure to DPLL(T)

An Introduction to SAT Solving

Satisfiability Checking of Non-clausal Formulas using General Matings

Formal Verification Methods 1: Propositional Logic

Satisfiability Modulo Theories

Logical Agents. Chapter 7

CS156: The Calculus of Computation

Satisfiability Modulo Theories (SMT)

Propositional Logic: Methods of Proof (Part II)

WHAT IS AN SMT SOLVER? Jaeheon Yi - April 17, 2008

Verification using Satisfiability Checking, Predicate Abstraction, and Craig Interpolation. Himanshu Jain THESIS ORAL TALK

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Foundations of Artificial Intelligence

Intelligent Agents. Pınar Yolum Utrecht University

Lecture Notes on SAT Solvers & DPLL

LOGIC PROPOSITIONAL REASONING

Chapter 7 Propositional Satisfiability Techniques

arxiv: v1 [cs.ai] 8 Jun 2015

Propositional Logic: Evaluating the Formulas

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Advanced Artificial Intelligence, DT4048

Abstract Answer Set Solvers with Backjumping and Learning

A Constraint Programming Approach for Enumerating Motifs in a Sequence

Abstract DPLL and Abstract DPLL Modulo Theories

Towards Understanding and Harnessing the Potential of Clause Learning

Proof Methods for Propositional Logic

Propositional Logic: Methods of Proof (Part II)

Foundations of Artificial Intelligence

Decision Procedures for Satisfiability and Validity in Propositional Logic

Artificial Intelligence

Propositional Logic: Methods of Proof. Chapter 7, Part II

Propositional Calculus

Chapter 7 Propositional Satisfiability Techniques

SAT Solvers: Theory and Practice

SAT-based Combinational Equivalence Checking

Artificial Intelligence

CSE507. Introduction. Computer-Aided Reasoning for Software. Emina Torlak courses.cs.washington.edu/courses/cse507/17wi/

CS:4420 Artificial Intelligence

Using Graph-Based Representation to Derive Hard SAT instances

Planning as Satisfiability

SAT, CSP, and proofs. Ofer Strichman Technion, Haifa. Tutorial HVC 13

Practical SAT Solving

Logic in AI Chapter 7. Mausam (Based on slides of Dan Weld, Stuart Russell, Subbarao Kambhampati, Dieter Fox, Henry Kautz )

Machine Learning and Logic: Fast and Slow Thinking

CS156: The Calculus of Computation Zohar Manna Autumn 2008

The SAT Revolution: Solving, Sampling, and Counting

SMT Unsat Core Minimization

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

Integrating a SAT Solver with an LCF-style Theorem Prover

EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization

SAT Solving: Theory and Practice of efficient combinatorial search

IntSat: From SAT to Integer Linear Programming

Rewriting for Satisfiability Modulo Theories

Preprocessing QBF: Failed Literals and Quantified Blocked Clause Elimination

Logic in AI Chapter 7. Mausam (Based on slides of Dan Weld, Stuart Russell, Dieter Fox, Henry Kautz )

Fast SAT-based Answer Set Solver

A Tool for Measuring Progress of Backtrack-Search Solvers

Propositional and First Order Reasoning

Solving QBF with Combined Conjunctive and Disjunctive Normal Form

Solving QBF with Free Variables

Logical Agents. Santa Clara University

Satisfiability and SAT Solvers. CS 270 Math Foundations of CS Jeremy Johnson

Logic and Inferences

Lecture 9: The Splitting Method for SAT

EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving III & Binary Decision Diagrams. Sanjit A. Seshia EECS, UC Berkeley

Foundations of Lazy SMT and DPLL(T)

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

A brief introduction to practical SAT solving

Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World

Deliberative Agents Knowledge Representation I. Deliberative Agents

7. Logical Agents. COMP9414/ 9814/ 3411: Artificial Intelligence. Outline. Knowledge base. Models and Planning. Russell & Norvig, Chapter 7.

Clause/Term Resolution and Learning in the Evaluation of Quantified Boolean Formulas

Robust SAT-Based Search Algorithm for Leakage Power Reduction

Propositional Logic: Methods of Proof (Part II)

Price: $25 (incl. T-Shirt, morning tea and lunch) Visit:

Logical agents. Chapter 7. Chapter 7 1

CS 380: ARTIFICIAL INTELLIGENCE

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

Artificial Intelligence

RESOLUTION TREES WITH LEMMAS: RESOLUTION REFINEMENTS THAT CHARACTERIZE DLL ALGORITHMS WITH CLAUSE LEARNING

Logical Inference. Artificial Intelligence. Topic 12. Reading: Russell and Norvig, Chapter 7, Section 5

Propositional and Predicate Logic. jean/gbooks/logic.html

SAT-Based Verification with IC3: Foundations and Demands

Transcription:

From SAT To SMT: Part 1 Vijay Ganesh MIT

Software Engineering & SMT Solvers An Indispensable Tactic for Any Strategy Formal Methods Program Analysis SE Goal: Reliable/Secure Software Automatic Testing Program Synthesis 2

Software Engineering & SMT Solvers An Indispensable Tactic for Any Strategy Formal Methods Program Analysis SE Goal: SAT/SMT Reliable/Secure Software Solvers Automatic Testing Program Synthesis 2

Foundation of Sofware Engineering Logic Abstractions of Computation Formal Methods Program Analysis Program Reasoning Automatic Testing Program Synthesis 3

Foundation of Sofware Engineering Logic Abstractions of Computation Formal Methods Program Analysis Program Logics (Boolean,...) Reasoning Automatic Testing Program Synthesis 3

Software Engineering using Solvers Engineering, Usability, Novelty Program Specification Logic Formulas Program Reasoning Tool SAT/SMT Solver SAT/UNSAT Program is Correct? or Generate Counterexamples (Test cases) 4

SAT/SMT Solver Research Story A 1000x Improvement 1,000,000 Constraints Solver-based programming languages Compiler optimizations using solvers Solver-based debuggers Solver-based type systems Solver-based concurrency bugfinding Solver-based synthesis Bio & Optimization 100,000 Constraints Concolic Testing Program Analysis Equivalence Checking Auto Configuration 10,000 Constraints Bounded MC Program Analysis AI 1,000 Constraints 1998 2001 2004 2007 2010 5

The SAT/SMT Problem Logic Formula (q p r) (q p r)... Solver SAT UNSAT Rich logics (Modular arithmetic, Arrays, Strings,...) NP-complete, PSPACE-complete,... Practical, scalable, usable, automatic Enable novel software reliability approaches 6

Lecture Outline Topics Covered Motivation for SAT/SMT solvers in software engineering High-level description of the SAT/SMT problem & logics Rest of the lecture Modern SAT solver architecture & techniques Modern SMT solver architecture & techniques My own contributions: STP & HAMPI SAT/SMT-based applications Future of SAT/SMT solvers Some history (who, when,...) and references sprinkled throughout the talk 7

The Boolean SAT Problem Basic Definitions and Format A literal p is a Boolean variable x or its negation x. A clause C is a disjunction of literals: x 2 x 41 x 15 A CNF is a conjunction of clauses: (x 2 x 1 x 5 ) (x 6 x 2 ) (x 3 x 4 x 6 ) All Boolean formulas assumed to be in CNF Assignment is a mapping (binding) from variables to Boolean values (True, False). A unit clause C is a clause with a single unbound literal The SAT-problem is: Find an assignment s.t. each input clause has a true literal (aka input formula has a solution or is SAT) OR establish input formula has no solution (aka input formula is UNSAT) The Input formula is represented in DIMACS Format: c DIMACS p cnf 6 3 2-1 5 0 6-2 0 3-4 -6 0

DPLL SAT Solver Architecture The Basic Solver DPLL(Θcnf, assign) { Propagate unit clauses; if conflict : return FALSE; if complete assign : return TRUE; pick decision variable x ; return DPLL(Θcnf x=0, assign[x=0]) DPLL(Θcnf x=1, assign[x=1]); Propagate (Boolean Constant Propagation): Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: Conflict: partial assignment is not satisfying Decide (Branch): Choose a variable & assign some value Backtracking: Implicitly done by the recursion } 9

Key Steps and Data-structures Input SAT Instance Propagate() (BCP) No Key steps Decide() Propagate() (BCP: Boolean constraint propagation) Conflict analysis and learning() Backjump() Forget() Restart() All Vars Assigned? Conflict Analysis() CDCL: Conflict-Driven Clause-Learning Conflict analysis is a key step Results in learning a conflict clause Prunes the search space SAT Decide() UNSAT TopLevel BackJump() Key data-structures (State): Stack or trail of partial assignments (AT) Input clause database Conflict clause database Conflict graph Decision level (DL) of a variable 10

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate (Boolean Constant Propagation): Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide: Choose a variable & assign some value (decision) Each decision is a decision level Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Analyze the reason (learn conflict clause) Conflict clause blocks the non-satisfying & a large set of other no-good assignments Marques-Silva & Sakallah (1999) BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Marques-Silva & Sakallah (1999) Backtrack (Davis, Putnam, Loveland, Logemann 1962) 11

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate (Boolean Constant Propagation): Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide: Choose a variable & assign some value (decision) Each decision is a decision level Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Analyze the reason (learn conflict clause) Conflict clause blocks the non-satisfying & a large set of other no-good assignments Marques-Silva & Sakallah (1999) BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Marques-Silva & Sakallah (1999) Backtrack (Davis, Putnam, Loveland, Logemann 1962) 11

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate (Boolean Constant Propagation): Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide (Branch): Choose a variable & assign some value (decision) Basic mechanism to do search Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Analyze the reason (learn conflict clause) Conflict clause blocks the non-satisfying & a large set of other no-good assignments Marques-Silva & Sakallah (1999) BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Marques-Silva & Sakallah (1999) Backtrack (Davis, Putnam, Loveland, Logemann 1962) 12

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate (Boolean Constant Propagation): Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide (Branch): Choose a variable & assign some value (decision) Basic mechanism to do search Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Analyze the reason (learn conflict clause) Conflict clause blocks the non-satisfying & a large set of other no-good assignments Marques-Silva & Sakallah (1999) BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Marques-Silva & Sakallah (1999) Backtrack (Davis, Putnam, Loveland, Logemann 1962) 12

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate (Boolean Constant Propagation): Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide (Branch): Choose a variable & assign some value (decision) Basic mechanism to do search Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Analyze the reason (learn conflict clause) Conflict clause blocks the non-satisfying & a large set of other no-good assignments Marques-Silva & Sakallah (1999) BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Marques-Silva & Sakallah (1999) Backtrack (Davis, Putnam, Loveland, Logemann 1962) 13

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate (Boolean Constant Propagation): Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide (Branch): Choose a variable & assign some value (decision) Basic mechanism to do search Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Analyze the reason (learn conflict clause) Conflict clause blocks the non-satisfying & a large set of other no-good assignments Marques-Silva & Sakallah (1999) BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Marques-Silva & Sakallah (1999) Backtrack (Davis, Putnam, Loveland, Logemann 1962) 13

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate: Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide (Branch): Choose a variable & assign some value (decision) Each decision is a decision level Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Compute assignments that lead to conflict (analysis) Construct conflict clause blocks the non-satisfying & a large set of other no-good assignments (learning) Marques-Silva & Sakallah (1996) BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Marques-Silva & Sakallah (1999) Backtrack (Davis, Putnam, Loveland, Logemann 1962) 14

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate: Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide (Branch): Choose a variable & assign some value (decision) Each decision is a decision level Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Compute assignments that lead to conflict (analysis) Construct conflict clause blocks the non-satisfying & a large set of other no-good assignments (learning) Marques-Silva & Sakallah (1996) BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Marques-Silva & Sakallah (1999) Backtrack (Davis, Putnam, Loveland, Logemann 1962) 14

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate: Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide: Choose a variable & assign some value (decision) Each decision is a decision level Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Compute assignments that lead to conflict (analysis) Construct conflict clause blocks the non-satisfying & a large set of other no-good assignments (learning) Marques-Silva & Sakallah (1996) Conflict-driven BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Backjump: Marques-Silva, Sakallah (1999) Backtrack: Davis, Putnam, Loveland, Logemann (1962) 15

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT All Vars Assigned? Propagate() (BCP) No Decide() Conflict Analysis() UNSAT TopLevel BackJump() Propagate: Propagate inferences due to unit clauses Most time in solving goes into this Detect Conflict: partial assignment is not satisfying Decide: Choose a variable & assign some value (decision) Each decision is a decision level Imposes dynamic variable order Decision Level (DL): variable natural number Conflict analysis and clause learning: Compute assignments that lead to conflict (analysis) Construct conflict clause blocks the non-satisfying & a large set of other no-good assignments (learning) Marques-Silva & Sakallah (1996) Conflict-driven BackJump: Undo the decision(s) that caused no-good assignment Assign decision variables different values Go back several decision levels Backjump: Marques-Silva, Sakallah (1999) Backtrack: Davis, Putnam, Loveland, Logemann (1962) 15

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance SAT Propagate() (BCP) All Vars Assigned? No Decide() Conflict Analysis() TopLevel {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} {3, 6, -7, 8} {1, 4, 7} {-8, 4} Decide {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} Another unit clause (more BCP) {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} Unit clause (BCP)... {3, 6, -7, 8} CONFLICT! (Trigger to {1, 4, 7} analyze & backjump) {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} UNSAT BackJump() 16

Decide() Details: VSIDS Heuristic Input SAT Instance Propagate() (BCP) No Decide() or Branching(): Choose a variable & assign some value (decision) Imposes dynamic variable order (Malik et al. 2001) All Vars Assigned? Conflict Analysis() How to choose a variable: VSIDS heuristics Each variable has an activity Activity is bumped additively, if variable occurs in conflict clause Activity of all variables is decayed by multiplying by const < 1 SAT Decide() TopLevel Next decision variable is the variable with highest activity Over time, truly important variables get high activity UNSAT BackJump() This is pure magic, and seems to work for many problems 17

Propagate() Details: Two-watched Literal Scheme Input SAT Instance Propagate() (BCP) No {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} Decide {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} Unit clause (BCP)... SAT All Vars Assigned? Decide() Conflict Analysis() UNSAT TopLevel BackJump() Watched Literal Watcher List -1 {-1, -3, 8},... -3 {-1, -3, 8},......... Watched Literal -1... -3... Watcher List 8 {-1, -3, 8},......... Watched Literal Watcher List -1 {-1, -3, 8},... -3... 8 {-1, -3, 8},......... The constraint propagates 8 18

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance Propagate() (BCP) No {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} Decide {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} Unit clause (BCP)... SAT All Vars Assigned? Decide() Conflict Analysis() TopLevel {3, 6, -7, 8} {1, 4, 7} {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} Another unit clause (more BCP) Basic Backtracking Search {3, 6, -7, 8} CONFLICT! (Trigger to {1, 4, 7} analyze & backjump) {-8, 4} {-1, -3, 8} {-3, -4, -8} {-1, -2, 3, 4, -6} UNSAT BackJump() Flip the last decision 1 Try setting 1 to False Highly inefficient No learning from mistakes 19

Conflict Analysis/Learn() Details Input SAT Instance Propagate() (BCP) No Some Definitions Decision Level (DL) Map from Boolean variables in input to natural numbers All unit clauses in input & resultant propagations get DL = 0 Every decision var gets a DL in increasing order >= 1 All Vars Assigned? Conflict Analysis() All propagations due to decision var at DL=x get the DL=x Conflict Graph (CG) or Implication Graph Directed Graph that records decisions & propagations Vertices: literals, Edge: unit clauses SAT Decide() TopLevel Conflict Clause (CC) Clause returned by Conflict Analysis(), added to conflict DB Implied by the input formula A cut in the CG UNSAT BackJump() Prunes the search Assignment Trail (AT) A stack of partial assignment to literals, with DL info 20

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) = ( X1 + X3 + X9) = ( X2 + X3 + X4) W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) X9 = 0@1 X11 = 0@3 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) X9 = 0@1 X11 = 0@3 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) = ( X1 + X3 + X9) = ( X2 + X3 + X4) W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) X1 = 1@6 W1 W6 = ( X5 + X6) W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) X9 = 0@1 X11 = 0@3 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) X9 = 0@1 X11 = 0@3 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X2 = 1@6 W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) X9 = 0@1 X11 = 0@3 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 X5 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 X5 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W5 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 X5 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W5 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 X5 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 X6 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W5 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 X5 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W6 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 X6 = 1@6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W5 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 X5 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W6 W4 = ( X4 + X5 + X10) X3 = 1@6 W5 X6 = 1@6 W6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W5 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 X5 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W6 Conflict W4 = ( X4 + X5 + X10) X3 = 1@6 W5 X6 = 1@6 W6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W5 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Implication Graph Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Clause DB CONFLICT GRAPH X10 = 0@3 W1 = ( X1 + X2) X2 = 1@6 W4 X5 = 1@6 = ( X1 + X3 + X9) = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W6 Conflict W4 = ( X4 + X5 + X10) X3 = 1@6 W5 X6 = 1@6 W6 W5 = ( X4 + X6 + X11) W6 = ( X5 + X6) X9 = 0@1 X11 = 0@3 W5 W7 = (X1 + X7 + X12) W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 21

Conflict Analysis/Learn() Details: Conflict Clause Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current Decision: {X1 = 1@6} Simplest strategy is to traverse the conflict graph backwards until decision variables: conflict clause includes only decision variables ( X1 + X9 + X10 + X11) Clause DB CONFLICT GRAPH X10 = 0@3 W1 = ( X1 + X2) Reason Side Conflict Side = ( X1 + X3 + X9) X2 = 1@6 W4 X5 = 1@6 = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W6 Conflict W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) X3 = 1@6 W5 X6 = 1@6 W6 W6 = ( X5 + X6) W7 = (X1 + X7 + X12) X9 = 0@1 X11 = 0@3 W5 W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 22

Conflict Analysis/Learn() Details: Conflict Clause Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current Decision: {X1 = 1@6} Another strategy is to use First Unique Implicant Point (UIP): Traverse graph backwards in breadth-first, expand literals of conflict, stop at first UIP Clause DB CONFLICT GRAPH X10 = 0@3 W1 = ( X1 + X2) = ( X1 + X3 + X9) Reason Side X2 = 1@6 W4 X5 = 1@6 Conflict Side = ( X2 + X3 + X4) W4 = ( X4 + X5 + X10) X1 = 1@6 W1 X4 = 1@6 W4 W6 Conflict W5 = ( X4 + X6 + X11) X3 = 1@6 W5 X6 = 1@6 W6 W6 = ( X5 + X6) W7 = (X1 + X7 + X12) X9 = 0@1 X11 = 0@3 W5 W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 23

Conflict Analysis/Learn() Details: BackTrack Current Assignment Trail: {X9 = 0@1, X10 = 0@3, X11 = 0@3, X12 = 1@2, X13 = 1@2,...} Current decision: {X1 = 1@6} Strategy: Closest decision level (DL) current DL for which conflict clause is unit. Undo {X1 = 1@6} Clause DB CONFLICT GRAPH X10 = 0@3 W1 = ( X1 + X2) Reason Side Conflict Side = ( X1 + X3 + X9) X2 = 1@6 W4 X5 = 1@6 = ( X2 + X3 + X4) X1 = 1@6 W1 X4 = 1@6 W4 W6 Conflict W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) X3 = 1@6 W5 X6 = 1@6 W6 W6 = ( X5 + X6) W7 = (X1 + X7 + X12) X9 = 0@1 X11 = 0@3 W5 W8 = (X1 + X8) W9 = ( X7 + X8 + X13) 24

Conflict Analysis/Learn() Details: BackJump Conflict clause: (X9 + X10 + X11 + X12 + X13) BackJump strategy: Closest decision level (DL) current DL for which conflict clause is unit. Undo {X10 = 0@3} CLAUSE DB CONFLICT GRAPH TRAIL W1 = ( X1 + X2) Reason Side DL = ( X1 + X3 + X9) = ( X2 + X3 + X4) W4 = ( X4 + X5 + X10) W5 = ( X4 + X6 + X11) X10 = 0@3 X9 = 0@1 X1 = 0@6 W8 X8 = 1@6 W9 Conflict W9 X13 = 1@2 3 4 5 W6 = ( X5 + X6) W7 X7 = 1@6 W9 W7 = (X1 + X7 + X12) W8 = (X1 + X8) X11 = 0@3 X12 = 1@2 W7 Conflict Side X1 6 W9 = ( X7 + X8 + X13) 1 0 BackJump 25

Restarts and Forget Input SAT Instance Propagate() (BCP) No Restarts Clear the Trail and start again Start searching with a different variable order All Vars Assigned? Conflict Analysis() Only Conflict Clause (CC) database is retained Forget: throw away less active learnt conflict clauses routinely Routinely throw away very large CC Logically CC are implied SAT Decide() TopLevel Hence no loss in soundness/completeness Time Savings: smaller DB means less work in propagation Space savings UNSAT BackJump() 26

Why is SAT efficient? Input SAT Instance Propagate() (BCP) VSIDS branching heuristic and propagate (BCP) No Conflict-Driven Clause-Learning (CDCL) Forget conflict clauses if DB goes too big All Vars Assigned? Conflict Analysis() BackJump Restarts All the above elements are needed for efficiency Deeper understanding lacking SAT Decide() TopLevel No predictive theory UNSAT BackJump() 27

Propagate(), Decide(), Analyze/Learn(), BackJump() Input SAT Instance Propagate() (BCP) No Conflict-Driven Clause-Learning (CDCL) (Marques-Silva & Sakallah 1996) Decide/branch and propagate (BCP) (Malik et al. 2001, Zabih & McAllester 1988) All Vars Assigned? Conflict Analysis() BackJump (McAllester 1980, Marques-Silva & Sakallah 1999) Restarts (Selman & Gomes 2001) SAT Decide() TopLevel Follows MiniSAT (Een & Sorensson 2003) UNSAT BackJump() 28

Soundness, Completeness & Termination Input SAT Instance Propagate() (BCP) Soundness: A solver is said to be sound, if, for any input formula F, the solver terminates and produces a solution, then F is indeed SAT No Proof: (Easy) SAT is returned only when all vars have been assigned a value (True, False) by Decide or BCP, and solver checks the solution. All Vars Assigned? Conflict Analysis() SAT Decide() TopLevel UNSAT BackJump() 29

Soundness, Completeness & Termination Input SAT Instance Propagate() (BCP) No Completeness: A solver is said to be complete, if, for any input formula F that is SAT, the solver terminates and produces a solution (i.e., solver does not miss solutions) Proof: (Harder) Backtracking + BCP + decide is complete (easy) All Vars Assigned? Conflict Analysis() Conflict clause is implied by input formula (easy) Only need to see backjumping does not skip assignments Observe backjumping occurs only when conflict clause (CC) vars < decision level (DL) of conflicting var Backjumping to max(dl of vars in CC) SAT Decide() TopLevel Decision tree rooted at max(dl of vars in CC)+1 is guaranteed to not satisfy CC Hence, backjumping will not skip assignments UNSAT BackJump() 30

Soundness, Completeness & Termination Input SAT Instance Propagate() (BCP) No Termination: Some measure decreases every iteration Proof Sketch: Loop guarantees either conflict clause (CC) added OR assign extended All Vars Assigned? Conflict Analysis() CC added. What stops CC addition looping forever? Recall that CC is remembered No CC duplication possible CC blocks UNSAT assign exploration in decision tree. No duplicate UNSAT assign exploration possible SAT Decide() TopLevel Size of decision tree explored decreases for each CC add UNSAT BackJump() 31

References & Important SAT Solvers 1. Marques-Silva, J.P. and K.A. Sakallah. GRASP: A Search Algorithm for Propositional Satisfiability. IEEE Transactions on Computers 48(5), 1999, 506-521. 2. Marques-Silva, J.P. and K.A. Sakallah. GRASP: A Search Algorithm for Propositional Satisfiability. Proceedings of ICCAD, 1996. 3. M. Moskewicz, C. Madigan, Y. Zhao, L. Zhang, and S. Malik. CHAFF: Engineering an efficient SAT solver. Proceedings of the Design Automation Conference (DAC), 2001, 530-535. 4. L. Zhang, C. F. Madigan, M. H. Moskewicz and S. Malik. Efficient Conflict Driven Learning in a Boolean Satisfiability Solver. Proceedings of ICCAD, 2001, 279-285. 5. Armin Bierre, Marijn Heule, Hans van Maaren, and Toby Walsh (Editors). Handbook of Satisfiability. 2009. IOS Press. http:// www.st.ewi.tudelft.nl/sat/handbook/ 6. M. Davis, G. Logemann, and D. Loveland. A machine program for theorem proving. Communications of the ACM.1962. 7. zchaff SAT Solver by Lintao Zhang 2002. 8. GRASP SAT Solver by Joao Marques-Silva and Karem Sakallah 1999. 9. MiniSAT Solver by Niklas Een and Niklas Sorenson 2005 - present 10. SAT Live: http://www.satlive.org/ 11. SAT Competition: http://www.satcompetition.org/ 12. SAT/SMT summer school: http://people.csail.mit.edu/vganesh/summerschool/ 32

Important Ideas and Conclusions 1. SAT solvers are crucial for software engineering 2. Huge impact in formal methods, program analysis and testing 3. Key ideas that make SAT efficient 1. Conflict-driven clause learning 2. VSIDS (or similar) variable selection heuristics 3. Backjumping 4. Restarts 4. Techniques I didn t discuss 1. Survey propagation (belief propagation) by Selman & Gomes 2. Works well for randomized SAT, not yet for industrial instances 3. Physics-inspired 4. Combining CDCL with survey propagation (?) 33