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

Slides:



Advertisements
Similar presentations
SAT Solver CS 680 Formal Methods Jeremy Johnson. 2 Disjunctive Normal Form  A Boolean expression is a Boolean function  Any Boolean function can be.
Advertisements

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
Disjunctive Normal Form CS 680: Formal Methods Jeremy Johnson.
Properties of SLUR Formulae Ondřej Čepek, Petr Kučera, Václav Vlček Charles University in Prague SOFSEM 2012 January 23, 2012.
ECE 667 Synthesis & Verification - SAT 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Boolean SAT CNF Representation Slides adopted (with.
Boolean Satisfiability Solvers Wonhong Nam
1 Boolean Satisfiability in Electronic Design Automation (EDA ) By Kunal P. Ganeshpure.
Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis
Efficient SAT Solving for Non- clausal Formulas using DPLL, Graphs, and Watched-cuts Himanshu Jain Edmund M. Clarke.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
1 CS 4700: Foundations of Artificial Intelligence Carla P. Gomes Module: Satisfiability (Reading R&N: Chapter 7)
ENGG3190 Logic Synthesis “Boolean Satisfiability” Winter 2014 S. Areibi School of Engineering University of Guelph.
GRASP: A Search Algorithm for Propositional Satisfiability EE878C Homework #2 2002/11/1 KAIST, EECS ICS Lab Lee, Dongsoo.
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.
Propositional Calculus CS 680: Formal Methods in Verification Computer Systems Jeremy Johnson.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
SAT-solving An old AI technique becomes very popular in modern A.I.
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.
Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.
Boolean Satisfiability and SAT Solvers
Quantified Formulas - Decision Procedure Daniel Kroening, Ofer Strichman Presented by Changki Hong 07 NOV 08.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
10/9/2015COSC , Lecture 51 Real-Time Systems, COSC , Lecture 5 Stefan Andrei.
MBSat Satisfiability Program and Heuristics Brief Overview VLSI Testing B Marc Boulé April 2001 McGill University Electrical and Computer Engineering.
Lecture 22 More NPC problems
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
INTRODUCTION TO ARTIFICIAL INTELLIGENCE COS302 MICHAEL L. LITTMAN FALL 2001 Satisfiability.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 3 Logic Representations (Part 2)
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Motivation & Goal SAT and Constraint Processing (CP) are fundamental areas of Computer Science that address the same computational questions. Compare SAT.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
HW #1. Due Mar 22 Midnight Verify the following program using SAT solver 1. Translate the program into a SSA form 2. Create a Boolean formula from.
Sudoku Jordi Cortadella Department of Computer Science.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module Logic Representations.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson.
First-Order Logic and Inductive Logic Programming.
Tommy Messelis * Stefaan Haspeslagh Patrick De Causmaecker *
Finding Models for Blocked 3-SAT Problems in Linear Time by Systematical Refinement of a Sub- Model Gábor Kusper Eszterházy Károly.
Nikolaj Bjørner Microsoft Research DTU Winter course January 2 nd 2012 Organized by Flemming Nielson & Hanne Riis Nielson.
Planning as Satisfiability (SAT-Plan). SAT-Plan Translate the planning problem into a satisfiability problem for length n of Plan garb 0 (proposition)present.
Backtracking & Brute Force Optimization Intro2CS – weeks
Solving the Logic Satisfiability problem Solving the Logic Satisfiability problem Jesus De Loera.
NPC.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
1 Boolean Satisfiability (SAT) Class Presentation By Girish Paladugu.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
Boolean Expression Evaluation CS 270: Math Foundations of CS Jeremy Johnson.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CS 270 Math Foundations of CS
Disjunctive Normal Form
First-Order Logic and Inductive Logic Programming
Logic Synthesis CNF Satisfiability.
Intro to Theory of Computation
Intro to Theory of Computation
Propositional Calculus: Boolean Algebra and Simplification
Elementary Metamathematics
NP-Completeness Proofs
Introduction to the Boolean Satisfiability Problem
Logics for Data and Knowledge Representation
Introduction to the Boolean Satisfiability Problem
NP-Complete Problems.
Presentation transcript:

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

2 Conjunctive Normal Form s x 0 x 1 f

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

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

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

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

Constaints in CNF

DIMACS Format

Avionics Example

p cnf c clauses for valid map forall a exists c AC^c_a

Avionics Example c constaints ~AC^c_1 + ~AC^c_2 and ~AC^c_1 + ~AC^c_ c constraint ~AC^c_2 + ~AC^c_

Avionics Example Programs]$./MiniSat_v1.14_linux aircraft assignment ==================================[MINISAT]=================================== | Conflicts | ORIGINAL | LEARNT | Progress | | | Clauses Literals | Limit Clauses Literals Lit/Cl | | ============================================================================== | 0 | | nan | % | ============================================================================== 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 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)

N-Queens Problem  Given an N x N chess board  Find a placement of N queens such that no two queens can take each other

N Queens

Backtrack

N Queens

Backtrack

N Queens Backtrack

N Queens

Solution Found

Recursive Solution to N-Queens Define Queens(board, current, size) Input: board a size x size chess board with placement of current queens in positions without conflict only using the first current columns Output: true if board is a conflict free placement of size queens if (current = size) then return true for row = 0 to size-1 do position := (row,column+1) if ConflictFree(board,position) Update(board,position) done := Queens(board,column+1,size) if done = true return true return false

N-Queens as a SAT Problem  Introduce variables B ij for 0 ≤ i,j < N  B ij = T if queen at position (i,j) F otherwise  Constraints  Exactly one queen per row  Row i = B ij, j=0…N-1  Exactly one queen per column  Column j = B ij, i=0…N-1  At most one queen on diagonal  Diagonal k- = B ij, i-j = k = -N+1…,N-1  Diagonal k+ = B ij, i+j = k = 0…,2N

4-Queens SAT input  Exactly one queen in row i  B i0  B i1  B i2  B i3  B i0   B i1   B i2   B i3  B i1   B i2   B i3  B i2   B i3

4-Queens SAT input  Exactly one queen in column j  B 0j  B 1j  B 2j  B 3j  B 0j   B 1j   B 2j   B 3j  B 1j   B 2j   B 3j  B 2j   B 3j

4-Queens SAT input  At most one queen in diagonal k-  B 20   B 31 …  B 00   B 11   B 22   B 33  B 11   B 22   B 33  B 22   B 33 …  B 02   B 13

4-Queens SAT input  At most one queen in diagonal k+  B 01   B 10 …  B 30   B 21   B 12   B 03  B 21   B 12   B 03  B 12   B 03  …  B 32   B 23

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 OperationAssignFormula

DPLL Example OperationAssignFormula Deduce1

DPLL Example OperationAssignFormula Deduce1

DPLL Example OperationAssignFormula Deduce1 Guess

DPLL Example OperationAssignFormula Deduce1 Guess Deduce Inconsistency

DPLL Example OperationAssignFormula Deduce 11 Guess 3 Deduce 4 Undo 3 Backtrack

DPLL Example OperationAssignFormula Deduce 11 Guess 3 Deduce 4 Undo 3 Assignment found