SAT Solver. CS 680 Formal Methods Jeremy Johnson

Similar documents
Propositional Calculus. Math Foundations of Computer Science

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

PROPOSITIONAL LOGIC (2)

8 NP-complete problem Hard problems: demo

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Decision Procedures. An Algorithmic Point of View. Decision Procedures for Propositional Logic. D. Kroening O. Strichman.

Deductive Methods, Bounded Model Checking

Propositional Calculus. Math Foundations of Computer Science

Computability Theory

NP-Completeness. Algorithms

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Seminar decision procedures: Certification of SAT and unsat proofs

1.4 Normal Forms. We define conjunctions of formulas as follows: and analogously disjunctions: Literals and Clauses

Mixed Integer Linear Programming

Symbolic Methods. The finite-state case. Martin Fränzle. Carl von Ossietzky Universität FK II, Dpt. Informatik Abt.

Implementation of a Sudoku Solver Using Reduction to SAT

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

EECS 219C: Formal Methods Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley

NP-Completeness of 3SAT, 1-IN-3SAT and MAX 2SAT

NP and computational intractability. Kleinberg and Tardos, chapter 8

Boolean Functions (Formulas) and Propositional Logic

Where Can We Draw The Line?

8.1 Polynomial-Time Reductions

Integrating a SAT Solver with Isabelle/HOL

SAT Solvers. Ranjit Jhala, UC San Diego. April 9, 2013

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Normal Forms for Boolean Expressions

Computer-Aided Program Design

NP-Complete Reductions 2

Massively Parallel Seesaw Search for MAX-SAT

DM841 DISCRETE OPTIMIZATION. Part 2 Heuristics. Satisfiability. Marco Chiarandini

SAT and Termination. Nao Hirokawa. Japan Advanced Institute of Science and Technology. SAT and Termination 1/41

CSP- and SAT-based Inference Techniques Applied to Gnomine

Boolean Representations and Combinatorial Equivalence

Reductions and Satisfiability

Formally Certified Satisfiability Solving

4.1 Review - the DPLL procedure

CS February 17

Satisfiability (SAT) Applications. Extensions/Related Problems. An Aside: Example Proof by Machine. Annual Competitions 12/3/2008

The Satisfiability Problem [HMU06,Chp.10b] Satisfiability (SAT) Problem Cook s Theorem: An NP-Complete Problem Restricted SAT: CSAT, k-sat, 3SAT

EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving. Sanjit A. Seshia EECS, UC Berkeley

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

SAT-CNF Is N P-complete

2SAT Andreas Klappenecker

Dipartimento di Elettronica Informazione e Bioingegneria. Cognitive Robotics. SATplan. Act1. Pre1. Fact. G. Gini Act2

What's the difference between the entailment symbol with the equals vs the entailment symbol with one line? Single turnstile meaning

Chapter 2 PRELIMINARIES

BITCOIN MINING IN A SAT FRAMEWORK

Improving Coq Propositional Reasoning Using a Lazy CNF Conversion

Learning a SAT Solver from Single-

EXTENDING SAT SOLVER WITH PARITY CONSTRAINTS

SAT Solver Heuristics

An Introduction to SAT Solvers

CS 267: Automated Verification. Lecture 13: Bounded Model Checking. Instructor: Tevfik Bultan

Study of efficient techniques for implementing a Pseudo-Boolean solver based on cutting planes

Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

Satisfiability. Michail G. Lagoudakis. Department of Computer Science Duke University Durham, NC SATISFIABILITY

CSE 20 DISCRETE MATH. Fall

(p 300) Theorem 7.27 SAT is in P iff P=NP

SAT Solver and its Application to Combinatorial Problems

versat: A Verified Modern SAT Solver

Some Hardness Proofs

Combining forces to solve Combinatorial Problems, a preliminary approach

Planning as Search. Progression. Partial-Order causal link: UCPOP. Node. World State. Partial Plans World States. Regress Action.

SAT-based Model Checking for C programs

Randomness and Computation March 25, Lecture 5

Induction Schemes. Math Foundations of Computer Science

Answer Key #1 Phil 414 JL Shaheen Fall 2010

SAT/SMT Solvers and Applications

Lecture 14: Lower Bounds for Tree Resolution

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

New Encodings of Pseudo-Boolean Constraints into CNF

QuteSat. A Robust Circuit-Based SAT Solver for Complex Circuit Structure. Chung-Yang (Ric) Huang National Taiwan University

Lecture 2: Symbolic Model Checking With SAT

Example: Map coloring

Binary Decision Diagrams

CSE 20 DISCRETE MATH. Winter

Practical SAT Solving

CS-E3220 Declarative Programming

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

A Satisfiability Procedure for Quantified Boolean Formulae

1 Definition of Reduction

Solving Constraint Satisfaction Problems by a SAT Solver

1 Introduction. 1. Prove the problem lies in the class NP. 2. Find an NP-complete problem that reduces to it.

W4231: Analysis of Algorithms

CS 512, Spring 2017: Take-Home End-of-Term Examination

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

A First Step Towards a Unified Proof Checker for QBF

Decision Procedures for Equality Logic. Daniel Kroening and Ofer Strichman 1

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

Solving 3-SAT. Radboud University Nijmegen. Bachelor Thesis. Supervisors: Henk Barendregt Alexandra Silva. Author: Peter Maandag s

Decision Procedures in First Order Logic

Better test results for the graph coloring and the Pigeonhole Problems using DPLL with k-literal representation

Constraint Reasoning Part 2: SAT, PB, WCSP

Markov Logic: Representation

Multi Domain Logic and its Applications to SAT

Transcription:

SAT Solver CS 680 Formal Methods Jeremy Johnson

Disjunctive Normal Form A Boolean expression is a Boolean function Any Boolean function can be written as a Boolean expression s x 0 x 1 f Disjunctive normal form (sums of products) For each row in the truth table where the output is true, write a product such that the corresponding input is the only input combination that is true Not unique E.G. (multiplexor function) 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 2

Conjunctive Normal Form Conjunctive normal form (products of sums) For each row in the truth table where the output is false, write a sum such that the corresponding input not in that row Alternatively use Demorgan s law for the negation of dnf for f (zero rows) E.G. (multiplexor function) (s + x 0 + x 1 ) (s + x 0 + x 1 ) (s + x 0 + x 1 ) (s + x 0 + x 1 ) s x 0 x 1 f 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 3

Satisfiability A formula is satisfiable if there is an assignment to the variables that make the formula true A formula is unsatisfiable if all assignments to variables eval to false A formula is falsifiable if there is an assignment to the variables that make the formula false A formula is valid if all assignments to variables eval to true (a valid formula is a theorem or tautology)

Satisfiability Checking to see if a formula f is satisfiable can be done by searching a truth table for a true entry Exponential in the number of variables Does not appear to be a polynomial time algorithm (satisfiability is NP-complete) There are efficient satisfiability checkers that work well on many practical problems Checking whether f is satisfiable can be done by checking if f is not valid An assignment that evaluates to false provides a counter example to validity

DNF vs CNF It is easy to determine if a boolean expression in DNF is satisfiable but difficult to determine if it is valid It is easy to determine if a boolean expression in CNF is valid but difficult to determine if it is satisfiable It is possible to convert any boolean expression to DNF or CNF; however, there can be exponential blowup

Propositional Logic in ACL2 In beginner mode and above ACL2S B!>QUERY (thm (implies (and (booleanp p) (booleanp q)) (iff (implies p q) (or (not p) q)))) << Starting proof tree logging >> Q.E.D. Summary Form: ( THM...) Rules: NIL Time: 0.00 seconds (prove: 0.00, print: 0.00, proof tree: 0.00, other: 0.00) Proof succeeded.

Propositional Logic in ACL2 ACL2 >QUERY (thm (implies (and (booleanp p) (booleanp q)) (iff (xor p q) (or p q)))) **Summary of testing** We tested 500 examples across 1 subgoals, of which 1 (1 unique) satisfied the hypotheses, and found 1 counterexamples and 0 witnesses. We falsified the conjecture. Here are counterexamples: [found in : "Goal''"] (IMPLIES (AND (BOOLEANP P) (BOOLEANP Q) P) (NOT Q)) -- (P T) and (Q T)

SAT Solvers Input expected in CNF Using DIMACS format One clause per line delimited by 0 Variables encoded by integers, not variable encoded by negating integer We will use MiniSAT (minisat.se)

MiniSAT Example (x1 -x5 x4) & (-x1 x5 x3 x4) & (-x3 x4). DIMACS format (c = comment, p cnf = SAT problem in CNF) c SAT problem in CNF with 5 variables and 3 clauses p cnf 5 3 1-5 4 0-1 5 3 4 0-3 -4 0

MiniSAT Example (x1 -x5 x4) & (-x1 x5 x3 x4) & (-x3 x4). This is MiniSat 2.0 beta ============================[ Problem Statistics ]================== Number of variables: 5 Number of clauses: 3 Parsing time: 0.00 s. SATISFIABLE v -1-2 -3-4 -5 0

Avionics Application Aircraft controlled by (real time) software applications (navigation, control, obstacle detection, obstacle avoidance ) Applications run on computers in different cabinets 500 apps 20 cabinets Apps 1, 2 and 3 must run in separate cabinets Problem: Find assignment of apps to cabinets that satisfies constraints

Corresponding SAT problem AC is a map from apps to cabinents [indicator variable] AC(app,cab) = t iff AC(app) = cab [Valid Mapping] a c AA a c a A c C AA a c [constaints] c AA 1 c AA 2 c AA 3 c c AA 2 c AA 3 c c C AA 1 c AA 2 c AA 3 c c C AA 2 c AA 3 c

Constaints in CNF c C AA 1 c AA 2 c AA 3 c c C AA 1 c AA 2 c AA 1 c AA 3 c c C AA c c 2 AA 3 c c c C AA 2 AA 3

DIMACS Format Var(AA a c ) = 20(a-1)+c c c AA 1 AA 2 = -c (20+c) c c AA 1 AA 3 = -c -(40+c) AA 1 20 a AA a = 20(a-1)+1 20(a-1)+20-1 -21 0-1 -41 0 1 2 3 20 0 9981 10000 0

Avionics Example 10 apps and 5 cabinets Var(AA c a ) = 5(a-1)+c 50 variables 25 clauses Valid Map a=1 10 AA a 1 AA a 5 Constaints c c c C AA 1 AA 2 c c c C AA 1 AA 3 c c c C AA 2 AA 3

Avionics Example p cnf 50 25 c clauses for valid map forall a exists c AC^c_a 1 2 3 4 5 0 6 7 8 9 10 0 11 12 13 14 15 0 16 17 18 19 20 0 21 22 23 24 25 0 26 27 28 29 30 0 31 32 33 34 35 0 36 37 38 39 40 0 41 42 43 44 45 0 46 47 48 49 50 0

Avionics Example c constaints ~AC^c_1 + ~AC^c_2 and ~AC^c_1 + ~AC^c_3-1 -6 0-1 -11 0-2 -7 0-2 -12 0-3 -8 0-3 -13 0-4 -9 0-4 -14 0-5 -10 0-5 -15 0 c constraint ~AC^c_2 + ~AC^c_3-6 -11 0-7 -12 0-8 -13 0-9 -14 0-10 -15 0

Avionics Example [jjohnson@tux64-12 Programs]$./MiniSat_v1.14_linux aircraft assignment ==================================[MINISAT]=================================== Conflicts ORIGINAL LEARNT Progress Clauses Literals Limit Clauses Literals Lit/Cl ============================================================================== 0 25 80 8 0 0 nan 0.000 % ============================================================================== restarts : 1 conflicts : 0 (nan /sec) decisions : 39 (inf /sec) propagations : 50 (inf /sec) conflict literals : 0 ( nan % deleted) Memory used : 1.67 MB CPU time : 0 s SATISFIABLE

Avionics Assignment SAT -1-2 3-4 -5-6 7-8 -9-10 11-12 -13-14 -15 16-17 -18-19 -20 21-22 -23-24 -25 26-27 -28-29 -30 31-32 -33-34 -35 36-37 -38-39 -40 41-42 -43-44 -45 46-47 -48-49 -50 0 True indicator variables: 3 = 5*0 + 3 => AC(1,3) 7 = 5*1 + 2 => AC(2,2) 11 = 5*2 + 1 => AC(3,1) 16 = 5*3+1 => AC(4,1) 21 = 5*4+1 => AC(5,1) 26 = 5*5=1 => AC(6,1) 31 = 5*6+1 => AC(7,1) 36 = 5*7+1 => AC(8,1) 41 = 5*8 + 1 => AC(9,1) 46 = 5*9+1 => AC(10,1)

DPLL Algorithm Tries to incrementally build a satisfying assignment A: V {T,F} (partial assignment) for a formula ϕ in CNF A is grown by either Deducing a truth value for a literal Whenever all literals except one are F then the remaining literal must be T (unit propagation) Guessing a truth value Backtrack when guess (leads to inconsistency) is wrong

DPLL Example Operation Assign Formula 1 2, 2 3 4, 1 2, 1 3 4, 1

DPLL Example Operation Assign Formula 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1 1 2, 2 3 4, 1 2, 1 3 4, 1

DPLL Example Operation Assign Formula 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 2 1 2, 2 3 4, 1 2, 1 3 4, 1

DPLL Example Operation Assign Formula 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1, 2 1 2, 2 3 4, 1 2, 1 3 4, 1 Guess 1, 2, 3 1 2, 2 3 4, 1 2, 1 3 4, 1

DPLL Example Operation Assign Formula 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1, 2 1 2, 2 3 4, 1 2, 1 3 4, 1 Guess 1, 2, 3 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1, 2, 3, 4 1 2, 2 3 4, 1 2, 1 3 4, 1 Inconsistency

DPLL Example Operation Assign Formula 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1 1 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 2 1, 2 1 2, 2 3 4, 1 2, 1 3 4, 1 Guess 3 1, 2, 3 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 4 1, 2, 3, 4 1 2, 2 3 4, 1 2, 1 3 4, 1 Undo 3 1, 2 1 2, 2 3 4, 1 2, 1 3 4, 1 Backtrack

DPLL Example Operation Assign Formula 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 1 1 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 2 1, 2 1 2, 2 3 4, 1 2, 1 3 4, 1 Guess 3 1, 2, 3 1 2, 2 3 4, 1 2, 1 3 4, 1 Deduce 4 1, 2, 3, 4 1 2, 2 3 4, 1 2, 1 3 4, 1 Undo 3 1, 2 1 2, 2 3 4, 1 2, 1 3 4, 1 Guess 3 1, 2, 3 1 2, 2 3 4, 1 2, 1 3 4, 1 Assignment found