Proofs from SAT Solvers Yeting Ge ACSys NYU Nov 20 2007 SAT solvers and proofs SAT problem and solvers Given a propositional logic formula, a SAT solver outputs sat or unsat Proofs from SAT solvers are needed 11/20/2007 A certificate to show the solver is correct Required by applications Planning Calculation of interpolants …… 2 A bunch of SAT solvers Complete / incomplete Internal representation Search method BDD, circuit, CNF,…… Depth first, breadth first Most modern SAT solvers 11/20/2007 Complete, CNF, breadth first DPLL based 3 Naïve SAT algorithm To solve: ( x1 x 2) (x1 x 2) (x1 x 2) ( x1 x 2) x1 Τ UNSAT x1 F x2 x2 UNSAT UNSAT x2 Τ UNSAT 11/20/2007 x2 F UNSAT x2 Τ UNSAT x2 x2 x2 F UNSAT 4 DPLL algorithm dpll(Clauses C){ C = simplify(C); if ( C contains contradictions ) return UNSAT ; if ( no more free variables in C) return SAT ; choose a free variable v in C ; C1 = substitute(C, v, T ) ; if (SAT == dpll(Clauses C1)) return SAT ; else { C2 = substitute(C, v, F ) ; return dpll(Clauses C2) ; } } 11/20/2007 5 DPLL algorithm Two rules to simplify the CNF clauses Unit propagation rule and { x3 }, then x3 F One literal rule 11/20/2007 If there is a clause contains only one literal, the literal is forced to be true. Propagate this new assignment immediately. Given { x1 x3 , x1 }, deduce x1 F Not used in most modern SAT solvers 6 Modern SAT solvers Efficient unit propagation Efficient back-tracking Iterative algorithm Almost constant cost back-tracking Better heuristics on what to do next BCP(Boolean Constraints Propagation) Conflict analysis Look ahead heuristics Fine tuning 11/20/2007 Restart, preprocessing,… 7 Resolution and SAT problem Resolution Given two clauses l1 l 2 ... lk and j1 j 2 ... lk , derive l1 l 2 ... j1 j 2 ... From x and x, derive empty clause Theorem 11/20/2007 A set of CNF clauses is unsatisfiable if and only if there is a resolution derivation of empty clause Proof: Based on induction. 8 From DPLL search tree to resolution proof ( x1 x 2) (x1 x 2) (x1 x 2) ( x1 x 2) UNSAT x1 x 2 x2 x2 1 x x 21 x1x x1 Τ x1 , x1 x1 F UNSAT UNSAT x1 x1 Observation: 11/20/2007 A contraction a resolution 9 Naïve proof generation Record the entire proof tree and reconstruct the resolution proof Dump search trace Modern SAT solvers employ unit propagation Modern SAT solvers employ some learning techniques 11/20/2007 New clauses are learned and added into the CNF clause set. New clause could be used later 10 Unit propagation (BCP) and resolution Given a unit clause x , only if there is a clause x y1 y ... , we can generate a new clause y1 y ... 2 2 A special case of resolution New unit clauses will be linked to their source clauses (implication graph) Modern SAT solvers spent most of the time on BCP 11/20/2007 11 Learning and resolution: Implication graph x5 T ...... x2 T 1) x1 x 2 2) x1 x3 3) x 2 x3 x 4 4) x 4 x5 5) x 4 x5 x 6 ...... 1) 5) 3) x1 F 5) x5 F x4 T 2) 3) 4) x5 F x3 T 11/20/2007 12 Implication graph x6 F ...... x2 T 1) x1 x 2 2) x1 x3 3) x 2 x3 x 4 4) x 4 x5 5) x 4 x5 x 6 ...... 1) 5) 3) x1 F 5) x5 F x4 T 2) 3) 4) x5 F x3 T The contraction is due to: ( x 4 x 6) or x4 x6 We can learn a clause x4 x6, which is the result of resolution of clause 4) and 5) contraction resolution 11/20/2007 13 Implication graph: more learned clause x6 F ...... x2 T 1) x1 x 2 2) x1 x3 3) x 2 x3 x 4 4) x 4 x5 5) x 4 x5 x 6 ...... 1) 5) 3) x1 F 5) x5 F x4 T 2) 3) 4) x5 F x3 T Another clause 11/20/2007 ( x 2 x3 x 6) 14 Implication graph: more learned clause x6 F ...... x2 T 1) x1 x 2 2) x1 x3 3) x 2 x3 x 4 4) x 4 x5 1) 5) 3) x1 F 5) x 4 x5 x 6 5) x5 F x4 T 2) ...... 3) 4) x5 F x3 T Yet another clause 11/20/2007 x1 x6 15 Implication graph: more learned clause x6 F ...... x2 T 1) x1 x 2 2) x1 x3 3) x 2 x3 x 4 4) x 4 x5 1) 3) x1 F ...... 6) x 4 x 6 4) 5) 7) x 2 x 3 x 6 6) 3) 8) x1 x 2 x 6 7) 2) 9) x1 x 6 8) 1) 5) x5 F x4 T 2) 5) x 4 x5 x 6 11/20/2007 5) 3) 4) x5 F x3 T 16 Resolution and learned clauses Conflict clause The learned clause that are fed back into SAT solver Conflict clauses can be seen as the result of some resolution Conflict clauses are redundant 11/20/2007 Could be deleted later 17 Proof generation Whenever a learned clause is generated, record the clause and dump the reason for that clause Recode all variables assigned at root level and the reasons Re-construct the resolution proof from the last contradiction by searching the dumped trace and recorded information 11/20/2007 Learned clauses are constructed if necessary 18 Application of proofs: Small unsat core Some applications require small unsat core Given a set of unsatisfiable CNF clauses C, if S C and t.t S t is satisfiabl e , then S is a minimal unsat core of C If s is the smallest among all minimal unsat core, then s is the minimum unsat core It is difficult to obtain a minimum unsat core 11/20/2007 19 Small unsat core from proofs By Zhang et al. Given a unsatisfiable set of clauses C Collect all clauses appears in the unsat proof, say C1, which must be unsatifiable Run SAT solver on C1 and collect all clauses appears in the unsat proof of C1, say C2 Repeat until reach a fixpoint There is no guarantee that the fixpoint is minimal 11/20/2007 20 Another kind of proof Given a set of unsatisfiable CNF clauses F and all conflict clauses C found by the SAT solver, a conflict pair {x, x} can be derived by performing BCP on F C only If a set of CNF clauses is unsatisfiable, a conflict pair can be derive by resolution All the result of non-BCP resolution are in C The proof checking is time consuming The checking procedure could give a small unsat core as a by-product 11/20/2007 21 Some future problems A standard proof format Dump of the resolution proof Dump of conflict clauses Better proof generation and checking Big proofs Proofs from SMT solvers 11/20/2007 More difficult There is no general standard format 22 Summary Proofs from SAT solvers are useful Modern CNF based SAT solvers can generate proofs with little overhead Construct the resolution proof might be a problem for large cases Small unsat core could be obtained from proofs 11/20/2007 23