
Verification by Reduction to SAT Problem
Explore the significance of verifying properties through reductions to the SAT problem, showing how it aids in essential applications like artificial intelligence, electronic design, and more. Gain insights into representing formulas in CNF and converting them, all while understanding the crux of the SAT problem and its real-world implications.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Satisfiability of Propositional Formulas Mooly Sagiv Slides by Sharad Malik, Ohad Shacham, Daniel Kroening and Ofer Strichman
The SAT Problem Given a propositional formula (Boolean function) =(a b) ( a b c) Determine if is valid true in all assignments Determine if is satisfiable Find a satisfying assignment or report that such does not exit For n variables, there are 2n possible truth assignments to be checked a 0 1 b b 0 0 1 1 c c c c 0 1 0 1 0 1 0 1
Why Bother? Core computational engine for major applications Artificial Intelligence Knowledge base deduction Automatic theorem proving Electronic Design Automaton Testing and Verification Logic synthesis FPGA routing Path delay analysis And more Software Verification
Verification by reductions to SAT Desired Property Program P Front-End Formula P SAT(DPLL) Counterexample Proof
Verification by reduction to SAT a 1 0 SAT Query: ((a x) ( a x)) ((b y) ( b y)) ((x y) ( x y) ? x:=1 x:=0 b 1 0 y:=0 y:=1 assert x==y 5
Verification by reduction to SAT a 1 0 SAT Query: ((a x) ( a x)) ((b y) ( b y)) ((x y) ( x y) ? x:=1 SAT Answer: Satisfiable by a=0, b = 1 x:=0 b 1 0 y:=0 y:=1 assert x==y 6
Verification by reduction to SAT a 1 0 SAT Query: ((a x b) ( a x b)) ((b y) ( b y)) ((x y) ( x y) ? x:=0;b:=0 x:=1;b:=1 b SAT Answer: Unsatisfiable 1 0 y:=0 y:=1 assert x==y 7
Problem Representation Represent the formulas in Conjunctive Normal Form (CNF) Conversion to CNF is straightforward a (b (c d)) (a (b c (a (b c d)) (a b) (a c) (a d) May need to add variables Notations Literals Variable or its negation Clauses Disjunction of literals =(a b) ( a b c) (a + b)(a + b + c) Advantages of CNF Simple data structure Compact Compositional All the clauses need to be satisfied d))
Complexity Results First established NP-Complete problem Even when at most 3 literals per clause (3-SAT) S. A. Cook, The complexity of theorem proving procedures, Proceedings, Third Annual ACM Symp. on the Theory of Computing,1971, 151-158 No polynomial algorithm for all instances unless P = NP Becomes polynomial when At most two literals per clause (2-SAT) At most one positive literal in every clause (Horn)
Goals Develop algorithms which solve all SAT instances Exponential worst case complexity Sometimes in space too But works well on many instances Interesting Heuristics Annual SAT conferences SAT competitions Randomly, Handmade, Industrial, AI 10 Millions variables!
SAT made some progress 100000 10000 1000 Vars 100 10 1 1960 1970 1980 1990 2000 2010 Year
Nave SAT solving (DFS) Enumerate all truths assignments X1, X2, , Xn Pseudo code main= if sat(0, ) then return SAT(X) else return UNSAT boolean sat(i, )= if i = n then return false else j :=i+1 x[j] := 0; := simp( , j, 0) if sat(j, ) then return true else x[j] := 1; := simp( , j, 1) return sat(j, )
The intuition behind resolution A B B C A C A B B C A C A B B C A C
Clause Resolution Resolution of a pair of clauses with exactly ONE incompatible variable a + b + c + f g + h + c + f a + b + g + h + f a + b + g + h What if more than one incompatible variables?
Davis Putnam Algorithm M .Davis, H. Putnam, A computing procedure for quantification theory", J. of ACM, Vol. 7, pp. 201-214, 1960 Iteratively select a variable for resolution till no more variables are left Report UNSAT when the empty clause occurs Can discard resolved clauses after each iteration
Davis Putnam Algorithm dp(CL)= for i = 1 to n do CL := eliminate(Xi, CL) ; if () CL then return UNSAT; else return SAT; eliminate(x, CL)= new := {} for each c1, c2 CL such that x c1 and x c2 new := new (c1-x c2- x ) return CL x new
Davis Putnam Algorithm (a + b + c)(b + c + f )(b + e) (a + b) (a + b ) (a + c)(a + c ) (a + c + e)(c + e + f ) (a) (a + c)(a + c ) (c)(c ) (a + e + f ) ( ) SAT UNSAT Potential memory explosion problem!
DLL Algorithm Davis, Logemann and Loveland M. Davis, G. Logemann and D. Loveland, A Machine Program for Theorem- Proving", Communications of ACM, Vol. 5, No. 7, pp. 394-397, 1962 Basic framework for many modern SAT solvers Also known as DPLL for historical reasons
Basic DLL Procedure - DFS (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c)
Basic DLL Procedure - DFS a (a + b + c) (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c)
Basic DLL Procedure - DFS a (a + b + c) 0 Decision (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c)
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 Decision
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 c 0 Decision
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 c 0 (a + c + d) a=0 d=1 Conflict! Implication Graph c=0 d=0 (a + c + d )
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 c 0 (a + c + d) a=0 d=1 Conflict! Implication Graph c=0 d=0 (a + c + d )
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 Backtrack c 0
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 c 1 Forced Decision 0 (a + c + d) a=0 d=1 Conflict! c=1 d=0 (a + c + d )
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 Backtrack c 0 1
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 1 Forced Decision 0 c 0 1
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 1 c c 0 0 1 Decision (a + c + d) a=0 d=1 Conflict! c=0 d=0 (a + c + d )
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 1 Backtrack c c 0 0 1
Basic DLL Procedure - DFS a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 1 c c 0 0 1 Forced Decision 1 (a + c + d) a=0 d=1 Conflict! c=1 d=0 (a + c + d )
Basic DLL Procedure - DFS Backtrack a (a + b + c) 0 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 1 c c 0 0 1 1
Basic DLL Procedure - DFS a (a + b + c) 0 Forced Decision 1 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b 0 1 c c 0 0 1 1
Basic DLL Procedure - DFS a (a + b + c) 0 1 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b b 0 1 0 Decision c c 0 0 1 1
Basic DLL Procedure - DFS a (a + b + c) 0 1 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b b 0 1 0 c c 0 0 1 1 (a + b + c) a=1 c=1 Conflict! b=0 c=0 (a + b + c )
Basic DLL Procedure - DFS a (a + b + c) 0 1 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b b Backtrack 0 1 0 c c 0 0 1 1
Basic DLL Procedure - DFS a (a + b + c) 0 1 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b b 0 1 Forced Decision 0 1 c c 0 0 1 1 (a + b + c) a=1 c=1 b=1
Basic DLL Procedure - DFS a (a + b + c) 0 1 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b b 0 1 0 1 c c 0 0 1 1 (b + c + d) (a + b + c) a=1 c=1 d=1 b=1
Basic DLL Procedure - DFS a (a + b + c) 0 1 (a + c + d) (a + c + d ) (a + c + d) (a + c + d ) (b + c + d) (a + b + c ) (a + b + c) b b 0 1 0 1 SAT c c 0 0 1 1 (a + b + c) (b + c + d) a=1 c=1 d=1 b=1
Implications and Boolean Constraint Propagation Implication A variable is forced to be assigned to be True or False based on previous assignments Unit clause rule (rule for elimination of one literal clauses) An unsatisfied clause is a unit clause if it has exactly one unassigned literal Satisfied Literal Satisfied Literal Unsatisfied Literal Unsatisfied Literal Unassigned Literal Unassigned Literal (a +b +c)(b +c )(a +c ) a = T, b = T, c is unassigned The unassigned literal is implied because of the unit clause Boolean Constraint Propagation (BCP) Iteratively apply the unit clause rule until there is no unit clause available Workhorse of DLL based algorithms
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) Apply repeatedly the unit clause rule. Return False if reached a conflict Backtrack until no conflict. Return False if impossible
Conflict Driven Learning and Non-chronological Backtracking x1 + x4 x1 + x3 + x8 x1 + x8 + x12 x2 + x11 x7 + x3 + x9 x7 + x8 + x9 x7 + x8 + x10 x7 + x10 + x12 x1=0 x1 x1=0
Conflict Driven Learning and Non-chronological Backtracking x1 + x4 x1 + x3 + x8 x1 + x8 + x12 x2 + x11 x7 + x3 + x9 x7 + x8 + x9 x7 + x8 + x10 x7 + x10 + x12 x1=0, x4=1 x1 x4=1 x1=0
Conflict Driven Learning and Non-chronological Backtracking x1 + x4 x1 + x3 + x8 x1 + x8 + x12 x2 + x11 x7 + x3 + x9 x7 + x8 + x9 x7 + x8 + x10 x7 + x10 + x12 x1=0, x4=1 x1 x3=1 x3 x4=1 x1=0 x3=1
Conflict Driven Learning and Non-chronological Backtracking x1 + x4 x1 + x3 + x8 x1 + x8 + x12 x2 + x11 x7 + x3 + x9 x7 + x8 + x9 x7 + x8 + x10 x7 + x10 + x12 x1=0, x4=1 x1 x3=1, x8=0 x3 x4=1 x1=0 x3=1 x8=0
Conflict Driven Learning and Non-chronological Backtracking x1 + x4 x1 + x3 + x8 x1 + x8 + x12 x2 + x11 x7 + x3 + x9 x7 + x8 + x9 x7 + x8 + x10 x7 + x10 + x12 x1=0, x4=1 x1 x3=1, x8=0, x12=1 x3 x4=1 x1=0 x3=1 x8=0 x12=1
Conflict Driven Learning and Non-chronological Backtracking x1 + x4 x1 + x3 + x8 x1 + x8 + x12 x2 + x11 x7 + x3 + x9 x7 + x8 + x9 x7 + x8 + x10 x7 + x10 + x12 x1=0, x4=1 x1 x3=1, x8=0, x12=1 x3 x2 x2=0 x4=1 x1=0 x3=1 x8=0 x12=1 x2=0
Conflict Driven Learning and Non-chronological Backtracking x1 + x4 x1 + x3 + x8 x1 + x8 + x12 x2 + x11 x7 + x3 + x9 x7 + x8 + x9 x7 + x8 + x10 x7 + x10 + x12 x1=0, x4=1 x1 x3=1, x8=0, x12=1 x3 x2 x2=0, x11=1 x4=1 x1=0 x3=1 x8=0 x11=1 x12=1 x2=0