Satisfiability Checking



Similar documents
University of Potsdam Faculty of Computer Science. Clause Learning in SAT Seminar Automatic Problem Solving WS 2005/06

MPBO A Distributed Pseudo-Boolean Optimization Solver

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

CS510 Software Engineering

Memory Efficient All-Solutions SAT Solver and its Application for Reachability Analysis

Memory Efficient All-Solutions SAT Solver and Its Application for Reachability Analysis

Lecture 7: NP-Complete Problems

Optimizing Description Logic Subsumption

Generating models of a matched formula with a polynomial delay

Chaff: Engineering an Efficient SAT Solver

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Between Restarts and Backjumps

Data Structures Fibonacci Heaps, Amortized Analysis

Rigorous Software Development CSCI-GA

Resolution. Informatics 1 School of Informatics, University of Edinburgh

npsolver A SAT Based Solver for Optimization Problems

Analysis of Algorithms I: Optimal Binary Search Trees

Introduction to Logic in Computer Science: Autumn 2006

Scheduling Shop Scheduling. Tim Nieberg

The Goldberg Rao Algorithm for the Maximum Flow Problem

Y. Xiang, Constraint Satisfaction Problems

Approximation Algorithms

Lecture 19: Introduction to NP-Completeness Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

The Basics of Graphical Models

Static Program Transformations for Efficient Software Model Checking

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Logic in general. Inference rules and theorem proving

Sudoku as a SAT Problem

OHJ-2306 Introduction to Theoretical Computer Science, Fall

Computational Methods for Database Repair by Signed Formulae

CSC 373: Algorithm Design and Analysis Lecture 16

Lecture 1: Oracle Turing Machines

Data Structures and Algorithms Written Examination

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs

Analysis of Algorithms I: Binary Search Trees

Bounded Treewidth in Knowledge Representation and Reasoning 1

Guessing Game: NP-Complete?

Exponential time algorithms for graph coloring

NP-complete? NP-hard? Some Foundations of Complexity. Prof. Sven Hartmann Clausthal University of Technology Department of Informatics

Smart Graphics: Methoden 3 Suche, Constraints

Logical Agents. Explorations in Artificial Intelligence. Knowledge-based Agents. Knowledge-base Agents. Outline. Knowledge bases

Verifying Refutations with Extended Resolution

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

OPTIMAL BINARY SEARCH TREES

each college c i C has a capacity q i - the maximum number of students it will admit

Discuss the size of the instance for the minimum spanning tree problem.

A SAT Based Scheduler for Tournament Schedules

AUTOMATED TEST GENERATION FOR SOFTWARE COMPONENTS

Ant Colony Optimization and Constraint Programming

Instruction scheduling

CoNP and Function Problems

Single machine models: Maximum Lateness -12- Approximation ratio for EDD for problem 1 r j,d j < 0 L max. structure of a schedule Q...

Portable Bushy Processing Trees for Join Queries

On the Unique Games Conjecture

A first step towards modeling semistructured data in hybrid multimodal logic

Lecture 5 - CPA security, Pseudorandom functions

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

On the Efficiency of Backtracking Algorithms for Binary Constraint Satisfaction Problems

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

CHAPTER 7 GENERAL PROOF SYSTEMS

A Branch and Bound Algorithm for Solving the Binary Bi-level Linear Programming Problem

Introduction to Algorithms. Part 3: P, NP Hard Problems

Jedd: A BDD-based Relational Extension of Java

Tests for Divisibility, Theorems for Divisibility, the Prime Factor Test

Lecture 1: Course overview, circuits, and formulas

Integration of ACO in a Constraint Programming Language

Foundational Proof Certificates

Chapter. NP-Completeness. Contents

Chapter 13: Binary and Mixed-Integer Programming

Chapter 7: Termination Detection

Chapter 1. NP Completeness I Introduction. By Sariel Har-Peled, December 30, Version: 1.05

University of Ostrava. Reasoning in Description Logic with Semantic Tableau Binary Trees

Constraint Optimization for Highly Constrained Logistic Problems

Topology-based network security

Solving the Employee Timetabling Problem Using Advanced SAT & ILP Techniques

Scheduling Home Health Care with Separating Benders Cuts in Decision Diagrams

A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called heap-order property

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course

3. The Junction Tree Algorithms

Near Optimal Solutions

Algorithm Design and Analysis

6.852: Distributed Algorithms Fall, Class 2

Using Adversary Structures to Analyze Network Models,

Bayesian Networks. Mausam (Slides by UW-AI faculty)

Transcription:

Satisfiability Checking SAT-Solving Prof. Dr. Erika Ábrahám Theory of Hybrid Systems Informatik 2 WS 10/11 Prof. Dr. Erika Ábrahám - Satisfiability Checking 1 / 40

A basic SAT algorithm Assume the CNF formula φ : (x y z) ( x y) ( y z) ( x y z) φ x x Decide() (y) ( y z) ( y z) y y (y z) ( y z) z z (z) ( z) () (y), ( y) z z X y y () () () () X X X X BCP() Resolve_Conflict() Prof. Dr. Erika Ábrahám - Satisfiability Checking 2 / 40

A basic SAT algorithm Choose the next variable and value. Return false if all variables are assigned. while (true) { if (!decide()) return SAT; while (!BCP()) if (!resolve_conflict()) return UNSAT; } Boolean Constraint Propagation. Return false if reached a conflict. Conflict resolution and backtracking. Return false if impossible. Prof. Dr. Erika Ábrahám - Satisfiability Checking 3 / 40

SAT-solving: Components Decision Boolean Constraint Propagation (BCP) Conflict resolution and backtracking Prof. Dr. Erika Ábrahám - Satisfiability Checking 4 / 40

SAT-solving: Components Decision Boolean Constraint Propagation (BCP) Conflict resolution and backtracking Prof. Dr. Erika Ábrahám - Satisfiability Checking 5 / 40

Decision heuristics - DLIS DLIS (Dynamic Largest Individual Sum) choose the assignment that increases the most the number of satisfied clauses For a given variable x: C xp # unresolved clauses in which x appears positively C xn - # unresolved clauses in which x appears negatively Let x be the literal for which C xp is maximal Let y be the literal for which C yn is maximal If C xp > C yn choose x and assign it TRUE Otherwise choose y and assign it FALSE Requires O(#literals) queries for each decision. Prof. Dr. Erika Ábrahám - Satisfiability Checking 6 / 40

Decision heuristics - DLIS Jersolow-Wang method Compute for every clause c and every literal l: J(l) : l c,c φ 2 c Choose a literal l that maximizes J(l). This gives an exponentially higher weight to literals in shorter clauses Prof. Dr. Erika Ábrahám - Satisfiability Checking 7 / 40

Pause... We will see other (more advanced) decision heuristics soon. These heuristics are integrated with a mechanism called learning of conflict clauses, which we will learn soon. Prof. Dr. Erika Ábrahám - Satisfiability Checking 8 / 40

SAT-solving: Components Decision Boolean Constraint Propagation (BCP) Conflict resolution and backtracking Prof. Dr. Erika Ábrahám - Satisfiability Checking 9 / 40

Status of clause A clause can be satisfied: at least one literal is satisfied unsatisfied: all literals are assigned but none are statisfied unit: all but one literals are assigned but none are satisfied unresolved: all other cases Example: c = (x 1 x 2 x 3 ) x 1 x 2 x 3 c 1 0 satisfied 0 0 0 unsatisfied 0 0 unit 0 unresolved BCP: Unit clauses are used to imply consequences of decisions. Prof. Dr. Erika Ábrahám - Satisfiability Checking 10 / 40

Implication graph Organize the search in the form of an implication graph Each node corresponds to a variable assignment Definition: Decision Level (DL) is the depth of the node in the decision tree. Notation: x = v@d x is assigned to v {0, 1} at the decision level d Prof. Dr. Erika Ábrahám - Satisfiability Checking 11 / 40

Formalisation: Implication graph Definition An implication graph is a labeled directed acyclic graph G(V, E), where V represents the literals of the current partial assignment. Each node is labeled with the literal that it represents and the decision level at which it entered the partial assignment. E with E = {(v i, v j ) v i, v j V, v i v j, v i Antecedent(v j )} denotes the set of directed edges where each edge (v i, v j ) is labeled with Antecedent(v j ). G can also contain a single conflict node labeled with κ and incoming edges {(v, κ) v c} labeled with c for some conflicting clause c. Prof. Dr. Erika Ábrahám - Satisfiability Checking 12 / 40

Implication graph: Example Current truth assignment: {x 7 = 0@1, x 8 = 0@2, x 9 = 0@3} Current decision assignment: {x 1 = 1@4} x 8 = 0@2 x 2 = 1@4 c 4 x 5 = 1@4 c 1 = ( x 1 x 2 ) c 2 = ( x 1 x 3 x 7 ) c 3 = ( x 2 x 3 x 4 ) c 4 = ( x 4 x 5 x 8 ) c 5 = ( x 4 x 6 x 9 ) c 6 = ( x 5 x 6 ) c 1 c3 c 4 c6 x 1 = 1@4 x 4 = 1@4 κ c c 3 2 c c 6 5 conflict c 2 x 3 = 1@4 c 5 x 6 = 1@4 x 7 = 0@1 x 9 = 0@3 Prof. Dr. Erika Ábrahám - Satisfiability Checking 13 / 40

Watches For BCP, it would be a large effort to check for each propagation the value of each literal in each clause. One could keep for each literal a list of clauses in which it occurs. It is even enough to watch two literals in each clause such that either one of them is true or both are unassigned. If a literal l gets true, we check each clause in which l is a watch literal (which is now false). If the other watch is true, the clause is satisfied. Else, if we find a new watch position, we are done. Else, if the other watch is unassigned, the clause is unit. Else, if the other watch is false, the clause is conflicting. Prof. Dr. Erika Ábrahám - Satisfiability Checking 14 / 40

SAT-solving: Components Decision Boolean Constraint Propagation (BCP) Conflict resolution and backtracking Basic backtracking Non-chronological backtracking Conflict-driven backtracking Prof. Dr. Erika Ábrahám - Satisfiability Checking 15 / 40

Basic backtracking search in action c 1 = (x 2 x 3 ) c 2 = ( x 1 x 4 ) c 3 = ( x 2 x 4 ) No backtrack in this example! x 1 x 1 = 1@1 x 4 = 0@1 x 2 = 0@1 x 3 = 1@1 x 1 = 0@1 x 2 x 2 = 0@2 x 3 = 1@2 {(x 1, 1), (x 2, 0), (x 3, 1), (x 4, 0)} {(x 1, 0), (x 2, 0), (x 3, 1)} Prof. Dr. Erika Ábrahám - Satisfiability Checking 16 / 40

Basic backtracking search in action c 1 = (x 2 x 3 ) c 2 = ( x 1 x 4 ) c 3 = ( x 2 x 4 ) c 4 = ( x 1 x 2 x 3 ) x 1 = 1@1 x 4 = 0@1 x 2 = 0@1 x 3 = 1@1 x 1 x 1 = 0@1 x 2 x 2 = 0@2 x 3 = 1@2 conflict {(x 1, 0), (x 2, 0), (x 3, 1)} Prof. Dr. Erika Ábrahám - Satisfiability Checking 17 / 40

SAT-solving: Components Decision Boolean Constraint Propagation (BCP) Conflict resolution and backtracking Basic backtracking Non-chronological backtracking Conflict-driven backtracking Prof. Dr. Erika Ábrahám - Satisfiability Checking 18 / 40

Non-chronological backtracking Current truth assignment: {x 7 = 0@1, x 8 = 0@2, x 9 = 0@3} Current decision assignment: {x 1 = 1@4} x 8 = 0@2 x 2 = 1@4 c 4 x 5 = 1@4 c 1 = ( x 1 x 2 ) c 2 = ( x 1 x 3 x 7 ) c 3 = ( x 2 x 3 x 4 ) c 4 = ( x 4 x 5 x 8 ) c 5 = ( x 4 x 6 x 9 ) c 6 = ( x 5 x 6 ) c 1 c3 c 4 c6 x 1 = 1@4 x 4 = 1@4 κ c c 3 2 c c 6 5 conflict c 2 x 3 = 1@4 c 5 x 6 = 1@4 x 7 = 0@1 x 9 = 0@3 We learn the conflict clause c 7 : ( x 1 x 7 x 8 x 9 ) Prof. Dr. Erika Ábrahám - Satisfiability Checking 19 / 40

Non-chronological backtracking What to do now? Undo decision level 4. Propagate in the new clause c 7 at decision level 3. It leads to a new assignment at decision level 3. Propagate the newly assigned literals. So the rule is: Backtrack to the largest decision level in the conflict clause, propagate in the learned clause, and propagate all new assignments. Prof. Dr. Erika Ábrahám - Satisfiability Checking 20 / 40

SAT-solving: Components Decision Boolean Constraint Propagation (BCP) Conflict resolution and backtracking Basic backtracking Non-chronological backtracking Conflict-driven backtracking Prof. Dr. Erika Ábrahám - Satisfiability Checking 21 / 40

More conflict clauses Def: A conflict clause is any clause implied by the formula. Let L be a set of literals labeling nodes that form a cut in the implication graph, seperating the conflict node from the roots. Claim: l L l is a conflict clause. x 8 = 0@2 2 c 4 x 2 = 1@4 x 5 = 1@4 1 1.(x 8 x 1 x 7 x 9 ) c 1 c3 c 4 c6 x 1 = 1@4 x 4 = 1@4 κ 2.(x 8 x 4 x 9 ) 3.(x 8 x 2 x 3 x 9 ) c 2 c 3 c 5 c 6. c 2 c 5 x 3 = 1@4 x 6 = 1@4 conflict. x 7 = 0@1 x 9 = 0@3 3 Prof. Dr. Erika Ábrahám - Satisfiability Checking 22 / 40

Conflict clauses How many clauses should we add? If not all, then which ones? Shorter ones? Check their influence on the backtracking level? The most "influential"? Prof. Dr. Erika Ábrahám - Satisfiability Checking 23 / 40

Conflict clauses Def: An asserting clause is a conflict clause with a single literal from the current decision level. Backtracking (to the right level) makes it a unit clause. Asserting clauses are those that force an immediate change in the search path. Modern solvers only consider asserting clauses. Prof. Dr. Erika Ábrahám - Satisfiability Checking 24 / 40

Unique Implication Points (UIP s) Definition: A Unique Implication Point (UIP) is an internal node in the implication graph such that all paths from the last decision to the conflict node go through it. The first UIP is the UIP closest to the conflict. c 4 UIP c 1 c3 UIP c 4 c6 κ c 2 c 3 c 5 c 6 c 2 c 5 conflict Prof. Dr. Erika Ábrahám - Satisfiability Checking 25 / 40

Conflict-driven backtracking So the rule is: backtrack to the second highest decision level dl, but do not erase it. This way the literal with the currently highest decision level will be implied at decision level dl. Question: What if the conflict clause has a single literal? For example, from (x y) (x y) and decision x = 0, we learn the conflict clause (x). Prof. Dr. Erika Ábrahám - Satisfiability Checking 26 / 40

Progress of a SAT solver work invested in refuting x = 1 x = 1 C Refutation of x = 1 Decision Level C 1 C 2 C 4 C 5 C 3 Time Decision Conflict Prof. Dr. Erika Ábrahám - Satisfiability Checking 27 / 40

Conflict clauses and resolution The binary resolution is a sound (and complete) inference rule: Example: (β a 1... a n ) ( β b 1... b m ) (Binary Resolution) (a 1... a n b 1... b m ) (x 1 x 2 ) ( x 1 x 3 x 4 ) (x 2 x 3 x 4 ) What is the relation of resolution and conflict clauses? Prof. Dr. Erika Ábrahám - Satisfiability Checking 28 / 40

Conflict clauses and resolution Consider the following example: x 2 = 0@2 c 1 = ( x 4 x 2 x 5 ) c 2 = ( x 4 x 10 x 6 ) c 3 = ( x 5 x 6 x 7 ) c 4 = ( x 6 x 7 ).. c 1 c 1 x 5 = 1@5 c 3 x 4 = 1@5 c 2 c 3 x 7 = 0@5 c x 6 = 1@5 4 c 2 c 4 x 10 = 0@3 Conflict clause: c 5 : (x 2 x 4 x 10 ) κ Prof. Dr. Erika Ábrahám - Satisfiability Checking 29 / 40

Conflict clauses and resolution Conflict clause: c 5 : (x 2 x 4 x 10 ) x 2 = 0@2 c 1 = ( x 4 x 2 x 5 ) c 2 = ( x 4 x 10 x 6 ) c 3 = ( x 5 x 6 x 7 ) c 4 = ( x 6 x 7 ).. c 1 c 1 x 5 = 1@5 c 3 x 4 = 1@5 c 2 c 3 x 7 = 0@5 c x 6 = 1@5 4 c 2 c 4 x 10 = 0@3 κ Assigment order: x 4, x 5, x 6, x 7 T1 = Res(c 4, c 3, x 7 ) = ( x 5 x 6 ) T2 = Res(T1,c 2, x 6 ) = ( x 4 x 5 x 10 ) T3 = Res(T2,c 1, x 5 ) = (x 2 x 4 x 10 ) Prof. Dr. Erika Ábrahám - Satisfiability Checking 30 / 40

Finding the conflict clause p r o c e d u r e a n a l y z e _ c o n f l i c t ( ) { i f ( c u r r e n t _ d e c i s i o n _ l e v e l = 0 ) return f a l s e ; c l : = c u r r e n t _ c o n f l i c t i n g _ c l a u s e ; while ( not s t o p _ c r i t e r i o n _ m e t ( c l ) ) do { l i t := l a s t _ a s s i g n e d _ l i t e r a l ( c l ) ; v a r := v a r i a b l e _ o f _ l i t e r a l ( l i t ) ; ante := a n t e c e d e n t ( v a r ) ; c l := r e s o l v e ( c l, ante, v a r ) ; } add_clause_to_database ( c l ) ; return true ; } Applied to our example: name cl lit var ante c 4 ( x 6 x 7 ) x 7 x 7 c 3 ( x 5 x 6 ) x 6 x 6 c 2 ( x 4 x 10 x 5 ) x 5 x 5 c 1 c 5 ( x 4 x 2 x 10 ) Prof. Dr. Erika Ábrahám - Satisfiability Checking 31 / 40

Unsatisfiable core Definition An unsatisfiable core of an unsatisfiable CNF formula is an unsatisfiable subset of the original set of clauses. The set of all original clauses is an unsatisfiable core. The set of those original clauses that were used for resolution in conflict analysis during SAT-solving (inclusively the last conflict at decision level 0) gives us an unsatisfiable core which is in general much smaller. However, this unsatifiable core is still not always minimal (i.e., we can remove clauses from it still having an unsatisfiable core). Prof. Dr. Erika Ábrahám - Satisfiability Checking 32 / 40

The resolution graph A resolution graph gives us more information to get a minimal unsatisfiable core. Involved Clauses Empty Clause Original Clause Learned Clause Prof. Dr. Erika Ábrahám - Satisfiability Checking 33 / 40

Resolution graph: Example () Empty Clause learning (x1) Inferred Clauses (x1 x6) (x1 x3 x6) ( x3) (x4) L: (x1 x3 x2) (x2 x6) ( x3 x4) ( x3 x4) ( x6) ( x1) (x3) Original Clauses Unsatisfiable Core Prof. Dr. Erika Ábrahám - Satisfiability Checking 34 / 40

Termination Theorem It is never the case that the solver enters decision level dl again with the same partial assignment. Proof. Define a partial order on partial assignments: α < β iff either α is an extension of β or α has more assignments at the smallest decision level at that α and β do not agree. BCP decreases the order, conflict-driven backtracking also. Since the order always decreases during the search, the theorem holds. Prof. Dr. Erika Ábrahám - Satisfiability Checking 35 / 40

SAT-solving: Components Back to decision heuristics... Decision Boolean Constraint Propagation (BCP) Conflict resolution and backtracking Basic backtracking Non-chronological backtracking Conflict-driven backtracking Prof. Dr. Erika Ábrahám - Satisfiability Checking 36 / 40

Decision heuristics - VSIDS VSIDS(Variable State Independent Decaying Sum) Gives priority to variables involved in recent conflicts. Involved can have different definitions. We take those variables that occur in clauses used for conflict resolution. 1 Each variable in each polarity has a counter initialized to 0. 2 We define an increment value (e.g., 1). 3 When a conflict occurs, we increase the counter of each variable, that occurs in at least one clause used for conflict resolution, by the increment value. Afterwards we increase the increment value (e.g., by 1). 4 For decisions, the unassigned variable with the highest counter is chosen. 5 Periodically, all the counters and the increment value are divided by a constant. Prof. Dr. Erika Ábrahám - Satisfiability Checking 37 / 40

Decision heuristics - VSIDS (cont d) Chaff holds a list of unassigned variables sorted by the counter value. Updates are needed only when adding conflict causes. Thus - decision is made in constant time. Prof. Dr. Erika Ábrahám - Satisfiability Checking 38 / 40

Decision heuristics VSIDS is a quasi-static strategy: static because it doesn t depend on current assignment dynamic because it gradually changes. Variables that appear in recent conflicts have higher priority. This strategy is a conflict-driven decision strategy. "...employing this strategy dramatically (i.e., an order of magnitude) improved performance..." Prof. Dr. Erika Ábrahám - Satisfiability Checking 39 / 40

The SAT competitions taken from http://baldur.iti.uka.de/sat-race-2008/analysis.html Prof. Dr. Erika Ábrahám - Satisfiability Checking 40 / 40