SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving
Advertisements

Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License:
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
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Effective Propositional Reasoning CSE 473 – Autumn 2003.
Technion 1 Generating minimum transitivity constraints in P-time for deciding Equality Logic Ofer Strichman and Mirron Rozanov Technion, Haifa, Israel.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View SAT.
1/30 SAT Solver Changki PSWLAB SAT Solver Daniel Kroening, Ofer Strichman.
SAT and Model Checking. Bounded Model Checking (BMC) A.I. Planning problems: can we reach a desired state in k steps? Verification of safety properties:
Plan for today Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search.
Automated Theorem Proving Lecture 4.   Formula := A |  |    A  Atom := b | t = 0 | t < 0 | t  0 t  Term := c | x | t + t | t – t | ct | Select(m,t)
Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis
GRASP-an efficient SAT solver Pankaj Chauhan. 6/19/ : GRASP and Chaff2 What is SAT? Given a propositional formula in CNF, find an assignment.
Technion 1 Generating minimum transitivity constraints in P-time for deciding Equality Logic Ofer Strichman and Mirron Rozanov Technion, Haifa, Israel.
GRASP SAT solver Presented by Constantinos Bartzis Slides borrowed from Pankaj Chauhan J. Marques-Silva and K. Sakallah.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Technion 1 (Yet another) decision procedure for Equality Logic Ofer Strichman and Orly Meir Technion.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
Knowledge Representation II (Inference in Propositional Logic) CSE 473.
1 A propositional world Ofer Strichman School of Computer Science, Carnegie Mellon University.
Knowledge Representation II (Inference in Propositional Logic) CSE 473 Continued…
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.
Logic - Part 2 CSE 573. © Daniel S. Weld 2 Reading Already assigned R&N ch 5, 7, 8, 11 thru 11.2 For next time R&N 9.1, 9.2, 11.4 [optional 11.5]
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
1 First order theories. 2 Satisfiability The classic SAT problem: given a propositional formula , is  satisfiable ? Example:  Let x 1,x 2 be propositional.
SAT Solver Math Foundations of Computer Science. 2 Boolean Expressions  A Boolean expression is a Boolean function  Any Boolean function can be written.
Deciding a Combination of Theories - Decision Procedure - Changki pswlab Combination of Theories Daniel Kroening, Ofer Strichman Presented by Changki.
Satisfiability Introduction to Artificial Intelligence COS302 Michael L. Littman Fall 2001.
Boolean Satisfiability and SAT Solvers
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
INTRODUCTION TO ARTIFICIAL INTELLIGENCE COS302 MICHAEL L. LITTMAN FALL 2001 Satisfiability.
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Introduction to Satisfiability Modulo Theories
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
Decision methods for arithmetic Third summer school on formal methods Leonardo de Moura Microsoft Research.
First-Order Logic and Inductive Logic Programming.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Nikolaj Bjørner Microsoft Research DTU Winter course January 2 nd 2012 Organized by Flemming Nielson & Hanne Riis Nielson.
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Satisfiability and SAT Solvers CS 270 Math Foundations of CS Jeremy Johnson.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
SAT Solving As implemented in - DPLL solvers: GRASP, Chaff and
Inference in Propositional Logic (and Intro to SAT) CSE 473.
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.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
1 A framework for eager encoding Daniel Kroening ETH, Switzerland Ofer Strichman Technion, Israel (Executive summary) (submitted to: Formal Aspects of.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
Satisfiability Modulo Theories and DPLL(T) Andrew Reynolds March 18, 2015.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Inference in Propositional Logic (and Intro to SAT)
Gábor Kusper University of Linz RISC Austria
EA C461 – Artificial Intelligence Logical Agent
The Propositional Calculus
Lazy Proofs for DPLL(T)-Based SMT Solvers
A theory-based decision heuristic for DPLL(T)
Introduction to Software Verification
Lecture 2 Propositional Logic
ECE 667 Synthesis and Verification of Digital Circuits
Logics for Data and Knowledge Representation
Decision Procedures An Algorithmic Point of View
Methods of Proof Chapter 7, second half.
GRASP-an efficient SAT solver
Presentation transcript:

SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014

Motivation Institute for Applied Information Processing and Communications 2 SAT solvers: ­ They rocketed the model checking First-Order Theories ­ Very expressive ­ Efficient SMT Solvers But: What are they? How do solvers work?

Outline Institute for Applied Information Processing and Communications 3 Propositional SAT solver ­ DPLL algorithm Predicate Logic (aka. First-Order Logic) ­ Syntax ­ Semantics First Order Logic First-Order Theories SMT solver ­ Eager Encoding ­ Lazy Encoding ­ DPLL(T)

Scope of Solvers propositional logic SAT solvers first order logic theory of equality difference logic Theorem provers SMT solvers linear integer arithmetic … theory of arrays

Notation propositional variables ­ e.g., a, b, c, d, … literal is a variable or its negation ­ e.g.,  a, b, … partial assignment A is a conjunction of literals ­ e.g., A =  a  d clause is a disjunction of literals ­ e.g., c = a   b  is a CNF formula (i.e. conjunction of clauses): ­ e.g.,  = (a  b   d)  c  [A] is  with all variables set according to A ­ e.g.,  [A] = (FALSE  b   TRUE)  c = b  c

SAT Solver Formula in CNF Satisfiable (+ model) Unsatisfiable (+ refutation proof)

DPLL Algorithm Due to Davis, Putnam, Loveland, Logemann ­ two papers: 1960, 1962 Basis for all modern SAT solvers

CNF as a Set of Clauses

Idea of DPLL-based SAT Solvers Recursively search an A: ­  [A] is TRUE Proves  satisfiable “A” is a satisfying model No such A exists ­  is unsatisfiable

Setting Literals

Truth Value of a CNF At least one clause is empty: ­ FALSE Clause set empty: ­ TRUE Otherwise: ­ Unassigned Literals left

DPLL Algorithm // sat( , A)=TRUE iff  [A] is satisfiable // sat( , true)=TRUE iff  is satisfiable sat( , A){ if(  [A] = true) return TRUE; if(  [A] = false) return FALSE; // Some unassigned variables left l = pick unassigned variable; AT = A  l; if(sat( , AT)) return TRUE; AF = A   l; if(sat( , AF)) return TRUE; return FALSE; }

DPLL Example Formula to check: (  a  b)  (  b  c)  (  c   a) 1.sat((  a  b)  (  b  c)  (  c   a), true) 2.sat( (  a  b)  (  b  c)  (  c   a), a) 3.sat( (  a  b)  (  b  c)  (  c   a), a  b) 4.sat( (  a  b)  (  b  c)  (  c   a), a  b  c) unsat 5.sat( (  a  b)  (  b  c)  (  c   a), a  b  c) unsat 6.sat( (  a  b)  (  b  c)  (  c   a), a  b) unsat 7.sat( (  a  b)  (  b  c)  (  c   a),  a) 8.sat((  a  b)  (  b  c)  (  c   a),  a  b) 9.sat((  a  b)  (  b  c)  (  c   a),  a  b  c) sat

Boolean Constraint Propagation (BCP) Unit clause: ­ a clause with a single unassigned literal ­ Examples: (a) (  b) Unit Clause exists  set its literal ­ Very simple but very important heuristic!

DPLL with BCP sat( , A){ while(unit clause occurs){ // l is only unassigned literal in // unit clause; A = A  l; } if(  [A] = true) return TRUE; if(  [A] = false) return FALSE; l = pick unassigned variable; AT = A  l; if(sat( , AT)) return TRUE; AF = A   l; if(sat( , AF)) return TRUE; return FALSE; }

Example Formula to check: (  a  b)  (  b  c)  (  c   a) 1.sat((  a  b)  (  b  c)  (  c   a), true) 2.sat( (  a  b)  (  b  c)  (  c   a), a) 3.[BCP]: sat( (  a  b)  (  b  c)  (  c   a), a  b) 4.[BCP]: sat( (  a  b)  (  b  c)  (  c   a), a  b  c) unsat 5.sat( (  a  b)  (  b  c)  (  c   a),  a) 6.sat( (  a  b)  (  b  c)  (  c   a),  a  b) 7.sat((  a  b)  (  b  c)  (  c   a),  a  b  c) sat

Can we do better? sat( , A){ while(unit clause occurs){ // l is only unassigned literal in // unit clause; A = A  l; } if(  [A] = true) return TRUE; if(  [A] = false) return FALSE; l = pick unassigned variable; AT = A  l; if(sat( , AT)) return TRUE; AF = A   l; if(sat( , AF)) return TRUE; return FALSE; }

Pure Literals Pure literal: ­ Literal for unassigned variable ­ The variable appears in one phase only Pure literals  true them

DPLL with BCP and Pure Literals sat( , A){ while(unit clause occurs){ // BCP let l be only unassigned literal in c; A = A  l; } while(pure literal l exists){ // Pure literals A = A  l; } if(  [A] = true) return TRUE; if(  [A] = false) return FALSE; l = pick a literal that does not occur in A; AT = A  l; if(sat( , AT)) return TRUE; AL = A   l; if(sat( , AL)) return TRUE; return FALSE; }

Example Formula to check: (  a  b)  (  b  c)  (  c   a) 1.sat((  a  b)  (  b  c)  (  c   a), true) [  a pure] 2.sat( (  a  b)  (  b  c)  (  c   a),  a) [  b pure] 3.sat( (  a  b)  (  b  c)  (  c   a),  a  b) sat

Can we do better? Institute for Applied Information Processing and Communications 21 sat( , A){ while(unit clause l occurs) A = A  l; while(pure literal l exists) A = A  l; if(  [A] = true) return TRUE; if(  [A] = false) return FALSE; l = pick a literal that does not occur in A; AT = A  l; if(sat( , AT)) return TRUE; AL = A   l; if(sat( , AL)) return TRUE; return FALSE; }

Whenever we get the conflict ­ analyze it add clauses to avoid in future Institute for Applied Information Processing and Communications 22 Learning: informal

Learning 1.(a   c) 2.(b   c) 3.(  a   b  c) 4.(  a   b) 5.(  a  b) 6.(a   b) 7.(a  b) cc aa UNSAT

Learning 1.(a   c) 2.(b   c) 3.(  a   b  c) 4.(  a   b) 5.(  a  b) 6.(a   b) 7.(a  b) cc aa UNSAT a The problem is with a: no need to set c=true! aa UNSAT a Without learning

Learning 1.(a   c) 2.(b   c) 3.(  a   b  c) 4.(  a   b) 5.(  a  b) 6.(a   b) 7.(a  b) cc aa UNSAT aa false 7 We learn: a bb 6

Learning & Backtracking 1.(a   c) 2.(b   c) 3.(  a   b  c) 4.(  a   b) 5.(  a  b) 6.(a   b) 7.(a  b) 8.a cc aa UNSAT Jump back to level 0 is smart LEVEL 0 LEVEL 1 LEVEL 2 aa false 7 We learn: a bb 6

Learning & Backtracking 1.(a   c) 2.(b   c) 3.(  a   b  c) 4.(  a   b) 5.(  a  b) 6.(a   b) 7.(a  b) 8.a cc aa UNSAT a Jump back to level 0 is smart LEVEL 0 LEVEL 1 LEVEL 2

Learning & Backtracking 1.(a   c) 2.(b   c) 3.(  a   b  c) 4.(  a   b) 5.(  a  b) 6.(a   b) 7.(a  b) 8.a cc aa UNSAT a bb 4 false 5 LEVEL 0 LEVEL 1 LEVEL 2

Learning & Backtracking 1.(a   c) 2.(b   c) 3.(  a   b  c) 4.(  a   b) 5.(  a  b) 6.(a   b) 7.(a  b) 8.a cc aa UNSAT a bb 4 false 5 UNSAT We learn: UNSAT, because no decision was necessary LEVEL 0 LEVEL 1 LEVEL 2

Backtrack Level Three important possibilities 1.Backtrack as usual 2.Restart for every learned clause 3.Go to the earliest level in which the conflict clause is a unit clause Option 3 often performs better

Can we do better? (learning is not shown) 31 sat( , A){ while(unit clause l occurs) A = A  l; while(pure literal l exists) A = A  l; if(  [A] = true) return TRUE; if(  [A] = false) return FALSE; l = pick a literal that does not occur in A; AT = A  l; if(sat( , AT)) return TRUE; AF = A   l; if(sat( , AF)) return TRUE; return FALSE; } how to pick literals?

Institute for Applied Information Processing and Communications 32 Source: Armin Biere’s slides: Effect of picking heuristics on SAT solver performance

Can we do better? -- Special cases Institute for Applied Information Processing and Communications 33 Horn clauses can be solved in polynomial time Cut width algorithm

source:

Syntax of Predicate Logic Two sorts: ­ Objects Numbers Strings Elements of sets … ­ Truth values IsEven(42) “Terms” “Formulas”

From Terms to Formulas Term Formula Predicate

FOL formulae: informal definition quantifiers over variables unary predicates: binary, etc. functions can FO formulae quantify over functions/predicates? can FO formulae have free (non-quantified) variables? * can FO formulae have ‘uninterpreted’ functions? * can FO formula has infinite number of atoms?

Syntax of Predicate Logic Variables ­ x, y, z, … Functions ­ f, g, h, … (arity > 0) ­ constants (arity = 0) Predicates ℙ ­ P, Q, R, … (with arity > 0) Terms and Formulae defined next

Terms

Formulae

True and False FO formulae

Semantics of Predicate Logic  Inductive Definition

Semantics of Predicate Logic

Institute for Applied Information Processing and Communications 46 Examples

Satisfiable FO formulae

Valid FO formulae

Some facts about our world Gödel proved that ­ every valid FO formula has a finite proof. Church-Turing proved that ­ no algorithm exists that can decide if FO formula is invalid proof deduction algorithm FO formula may never terminate if valid if invalid

Notion of “Theory” Application Domain Structures & Objects Predicates & Functions Arithmetic Numbers (Integers, Rationals, Reals) Computer Programs Arrays,Bitvectors Array-Read, Array-Write, …

Definition of a Theory

Model View We check satisfiability and validity only wrt models that satisfy axioms ­  “Satisfiability modulo (=‘with respect to’) theories” All possible Models Models satisfying all axioms

Green: Models Satisfying all Axioms Violet: Models Satisfying Formula in Question

Green: Models Satisfying all Axioms Violet: Models Satisfying Formula in Question

Theory Formulas vs. FO Formulas equivalid equisatisfiable

Fragment of a Theory

Scope of Solvers propositional logic SAT solvers first order logic theory of equality difference logic Theorem provers SMT solvers linear integer arithmetic … theory of arrays

Deciding Satisfiability (quantifier free theory): main methods 1. Eager Encoding ­ Equisatisfiable propositional formula ­ one fat SAT call 2. Lazy Encoding  Theory Solver  Conjunctive Fragment  Blocking Clauses  numerous SAT calls 3. DPLL (T)

Axiom Schema: Template for (infinite number of) axioms

Two-Stage Eager Encoding equisatisfiable propositional formula equisatisfiable propositional formula Ackermann’s Reduction Graph-based Reduction SAT Solver

63

Non-Polar Equality Graph ­ Node per variable ­ Edge per (dis)equality Make it chordal ­ No chord-free cycles (size > 3) a b c d e f g

 SAT Solver

66

Summary: Eager Encoding equisatisfiable propositional formula equisatisfiable propositional formula Ackermann’s Reduction Graph-based Reduction SAT Solver

Lazy Encoding SAT Solver Theory Solver Assignment of Literals Blocking Clause SAT UNSAT

Congruence-Closure Algorithm

71

Lazy Encoding SAT Solver Theory Solver Assignment of Literals Blocking Clause SAT UNSAT

DPLL(T) Decide Start full assignment SAT BCP/PL partial assignment Analyze Conflict conflict UNSAT Learn & Backtrack Theory Solver Add Clauses partial assignment theory propagation / conflict partial assignment

Scope of Solvers propositional logic SAT solvers first order logic theory of equality difference logic Theorem provers SMT solvers linear integer arithmetic … theory of arrays

Summary 75

Self-check: learning targets Institute for Applied Information Processing and Communications 76 Explain Satisfiability Modulo Theories Describe Theory of Uninterpreted Functions and Equality Explain and use ­ Ackermann’s Reduction ­ Graph-based Reduction ­ Congruence Closure ­ DPLL ­ DPLL(T)

History of satisfiability: pdfhttp://gauss.ececs.uc.edu/SAT/articles/FAIA pdf SAT basics: Conflict Driven Clause Learning: Armin Biere’s slides: SAT game artois.fr/~roussel/satgame/satgame.php?level=1&lang=enghttp:// artois.fr/~roussel/satgame/satgame.php?level=1&lang=eng Logic and Computability classes by Georg echenbarkeit/ echenbarkeit/ Institute for Applied Information Processing and Communications 77 some reading