Satisfiability Modulo Theories and DPLL(T) Andrew Reynolds March 18, 2015.

Slides:



Advertisements
Similar presentations
SMELS: Sat Modulo Equality with Lazy Superposition Christopher Lynch – Clarkson Duc-Khanh Tran - MPI.
Advertisements

From Propositional SAT to SMT
Satisfiability modulo the Theory of Bit Vectors
50.530: Software Engineering
Satisfiability Modulo Theories (An introduction)
SMT Solvers (an extension of SAT) Kenneth Roe. Slide thanks to C. Barrett & S. A. Seshia, ICCAD 2009 Tutorial 2 Boolean Satisfiability (SAT) ⋁ ⋀ ¬ ⋁ ⋀
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)
Logic.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
Nikolaj Bjørner Microsoft Research Lecture 4. DayTopicsLab 1Overview of SMT and applications. SAT solving, Z3 Encoding combinatorial problems with Z3.
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.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
Nikolaj Bjørner Microsoft Research Lecture 3. DayTopicsLab 1Overview of SMT and applications. SAT solving, Z3 Encoding combinatorial problems with Z3.
1 Boolean Satisfiability in Electronic Design Automation (EDA ) By Kunal P. Ganeshpure.
1 Satisfiability Modulo Theories Sinan Hanay. 2 Boolean Satisfiability (SAT) Is there an assignment to the p 1, p 2, …, p n variables such that  evaluates.
Presented by Ed Clarke Slides borrowed from P. Chauhan and C. Bartzis
1 Quantified Formulas Acknowledgement: QBF slides borrowed from S. Malik.
Methods of Proof Chapter 7, second half.
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.
1 A theory-based decision heuristic for DPLL(T) Dan Goldwasser Ofer Strichman Shai Fine Haifa university TechnionIBM-HRL.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
1 A propositional world Ofer Strichman School of Computer Science, Carnegie Mellon University.
1 A Combination Method for Generating Interpolants by G. Yorsh and M. Masuvathi Presentation by: Emilia Katz.
Ofer Strichman, Technion Deciding Combined Theories.
Daniel Kroening and Ofer Strichman Decision Procedure
1 First order theories. 2 Satisfiability The classic SAT problem: given a propositional formula , is  satisfiable ? Example:  Let x 1,x 2 be propositional.
Leonardo de Moura Microsoft Research. Many approaches Graph-based for difference logic: a – b  3 Fourier-Motzkin elimination: Standard Simplex General.
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.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
Logics for Data and Knowledge Representation Propositional Logic: Reasoning Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto.
Quantified Formulas - Decision Procedure Daniel Kroening, Ofer Strichman Presented by Changki Hong 07 NOV 08.
CMU, Oct 4 DPLL-based Checkers for Satisfiability Modulo Theories Cesare Tinelli Department of Computer Science The University of Iowa Joint work with.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
CHAPTERS 7, 8 Oliver Schulte Logical Inference: Through Proof to Truth.
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.
Introduction to Satisfiability Modulo Theories
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.
Decision methods for arithmetic Third summer school on formal methods Leonardo de Moura Microsoft Research.
First-Order Logic and Inductive Logic Programming.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
© 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.
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
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.
1/20 Arrays Changki PSWLAB Arrays Daniel Kroening and Ofer Strichman Decision Procedure.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
Finding Conflicting Instances of Quantified Formulas in SMT Andrew Reynolds Cesare Tinelli Leonardo De Moura July 18, 2014.
Selected Decision Procedures and Techniques for SMT More on combination – theories sharing sets – convex theory Un-interpreted function symbols (quantifier-free.
1 A framework for eager encoding Daniel Kroening ETH, Switzerland Ofer Strichman Technion, Israel (Executive summary) (submitted to: Formal Aspects of.
Deciding Combined Theories Presented by Adi Sosnovich Based on presentation from: Decision Procedures An Algorithmic Point of View Daniel Kroening and.
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.
Lazy Proofs for DPLL(T)-Based SMT Solvers
8/2/2018 4:21 AM Lifting SAT to richer theories: bit-vectors, finite bases, and theory combination Christoph M. Wintersteiger © 2013 Microsoft Corporation.
Solving Linear Arithmetic with SAT-based MC
Satisfiability Modulo Theories
GRASP-an efficient SAT solver
Presentation transcript:

Satisfiability Modulo Theories and DPLL(T) Andrew Reynolds March 18, 2015

Overview SAT : Satisfiability for Propositional Logic ( A  B )  ( C  D )   B Does there exist truth values for A, B, C, D that make this formula true? SMT : Satisfiability Modulo Theories ( x+1>0  x+y>0 )  ( x 4)   x+y>0 Does there exist integer values for x, y that make this formula true? Theories: Linear Integer Arithmetic (LIA) Inductive Datatypes (DT) Additional Topics: Combination of Theories (DT+LIA) Quantified Formulas

SAT DPLL algorithm Input : clauses in Clausal Normal Form (CNF) Alternates between: Propagations : assign values to atoms whose value is forced Decisions : choose an arbitrary value for an unassigned atom Answers SAT when all clauses have one literal  true Answer UNSAT when made no decisions, one clause has all of its literals  false ( A  B )  ( C  D )   B

DPLL algorithm SAT ( A  B )  ( C  D )   B

SAT DPLL algorithm Propagate : B  false ( A  B )  ( C  D )   B

SAT DPLL algorithm Propagate : B  false Propagate : A  true ( A  B )  ( C  D )   B

SAT DPLL algorithm Propagate : B  false Propagate : A  true Decide : C  true ( A  B )  ( C  D )   B

DPLL algorithm Propagate : B  false Propagate : A  true Decide : C  true  Input is satisfiable SAT ( A  B )  ( C  D )   B

SAT Optimizations: Two watched literals Conflict-driven clause learning (CDCL) Inprocessing Using an encoding of problems into propositional SAT: Pro : Very efficient methods available Con : Not expressive  Motivation for Satisfiability Modulo Theories

Satisfiability Modulo Theories (SMT) Extend SAT problems with reasoning about theories E.g. linear integer arithmetic (LIA) : ( x+1>0  x+y>0 )  ( x 4) Formally, a theory T is a pair (  T, I T ), where:  T  is set of function symbols, the signature of T E.g.  LIA  = { +, -,, ≥, 0, 1, 2, 3, … } I T is a set of interpretations for T E.g. each I  I LIA interpret functions in  LIA in standard way: 1+1 = 2, 1+2 = 3, … 1 > 0 = true, 0 > 1 = false, … …

SMT DPLL(T) algorithm Extends DPLL algorithm to incorporate reasoning about a theory T Idea: Use DPLL algorithm to find assignments for propositional abstraction of formula Use off-the-shelf SAT solver Check the T-satisfiability of assignments found by SAT solver Use Theory Solver for T ( x+1>0  x+y>0 )  ( x 4)   x+y>0

SMT DPLL(LIA) algorithm ( x+1>0  x+y>0 )  ( x 4)   x+y>0 Invoke DPLL(T) for theory T = LIA (linear integer arithmetic)

SMT DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } ( x+1>0  x+y>0 )  ( x 4)   x+y>0

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: ( x+1>0  x+y>0 )  ( x 4)  x0 A B C D  B SMT

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true  Are LIA literals corresponding to {A,  B, C } LIA-satisfiable? ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } x+1>0  x<0 is LIA-unsatisfiable! ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } (  A   C ) added to list of clauses  Since one of x+1>0, x<0 must be false ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B  (  A   C )

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } (  A   C ) added to list of clauses Invoke SAT solver: Backtrack decision on C ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B  (  A   C )

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } (  A   C ) added to list of clauses Invoke SAT solver: Propagate : C  false ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B  (  A   C )

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } (  A   C ) added to list of clauses Invoke SAT solver: Propagate : C  false, Propagate : D  true ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B  (  A   C )

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } (  A   C ) added to list of clauses Invoke SAT solver: Propagate : C  false, Propagate : D  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x 4 } ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B  (  A   C )

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } (  A   C ) added to list of clauses Invoke SAT solver: Propagate : C  false, Propagate : D  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x 4 }  x+y>0  x+y>4 is LIA-unsatisfiable! ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B  (  A   C )

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } (  A   C ) added to list of clauses Invoke SAT solver: Propagate : C  false, Propagate : D  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x 4 } ( B   D ) added to list of clauses ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B  (  A   C )  ( B   D )

DPLL(LIA) algorithm Map : { A  x+1>0, B  x+y>0, C  x 4 } Invoke SAT solver: Propagate : B  false, Propagate : A  true, Decide : C  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x<0 } (  A   C ) added to list of clauses Invoke SAT solver: Propagate : C  false, Propagate : D  true Invoke theory solver for LIA on: { x+1>0,  x+y>0, x 4 } ( B   D ) added to list of clauses No decisions to backtrack  input is LIA-unsatisfiable ( x+1>0  x+y>0 )  ( x 4)  x0 SMT A B C D  B  (  A   C )  ( B   D )

SMT : Exercise Determine if above formula is LIA-satisfiable ( x>y  x>z )  ( x+1 y )  ( x>y  z>y )

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y }  ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) A B C  A A D

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } If SAT, give values for { x, y, z } If UNSAT, give a set of clauses C 1,..., C n, where: , C 1,..., C n, is UNSAT Each C i is of the form ( l 1  …  l m ), where: Each l i is one of (  )A, (  )B, (  )C, (  )D Negation of formulas mapped to by l 1 … l m are LIA-unsatisfiable  ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) A B C  A A D

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) A B C  A A D 

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } Invoke SAT solver: Decide : A  true, Propagate : C  true ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) A B C  A A D 

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } Invoke SAT solver: Decide : A  true, Propagate : C  true Invoke theory solver for LIA on: { x>y, x+1<y } ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) A B C  A A D 

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } Invoke SAT solver: Decide : A  true, Propagate : C  true Invoke theory solver for LIA on: { x>y, x+1<y } x>y  x+1<y is LIA-unsatisfiable, add (  A   C ) (  A   C ) ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) A B C  A A D 

(  A   C ) SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } Invoke SAT solver: Decide : A  true, Propagate : C  true Invoke theory solver for LIA on: { x>y, x+1<y } x>y  x+1<y is LIA-unsatisfiable, add (  A   C ) Invoke SAT solver: Backtrack decision on A ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) A B C  A A D 

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } Invoke SAT solver: Decide : A  true, Propagate : D  false, Propagate : C  true Invoke theory solver for LIA on: { x>y, x+1<y } x>y  x+1<y is LIA-unsatisfiable, add (  A   C ) Invoke SAT solver: Propagate : A  false, Propagate : B  true, Propagate : D  true ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) (  A   C ) A B C  A A D 

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } Invoke SAT solver: Decide : A  true, Propagate : D  false, Propagate : C  true Invoke theory solver for LIA on: { x>y, x+1<y } x>y  x+1<y is LIA-unsatisfiable, add (  A   C ) Invoke SAT solver: Propagate : A  false, Propagate : B  true, Propagate : D  true Invoke theory solver for LIA on: {  x>y, x>z, z>y } ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) (  A   C ) A B C  A A D 

SMT : Exercise Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } Invoke SAT solver: Decide : A  true, Propagate : D  false, Propagate : C  true Invoke theory solver for LIA on: { x>y, x+1<y } x>y  x+1<y is LIA-unsatisfiable, add (  A   C ) Invoke SAT solver: Propagate : A  false, Propagate : B  true, Propagate : D  true Invoke theory solver for LIA on: {  x>y, x>z, z>y }  x>y  x>z  z>y is LIA-unsatisfiable, add ( A   B   D ) ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) (  A   C )  ( A   B   D ) A B C  A A D 

SMT : Exercise ( x>y  x>z )  ( x+1 y )  ( x>y  z>y ) (  A   C )  ( A   B   D ) A B C  A A D  Determine if  is LIA-satisfiable Map : { A  x>y, B  x>z, C  x+1 y } Invoke SAT solver: Decide : A  true, Propagate : D  false, Propagate : C  true Invoke theory solver for LIA on: { x>y, x+1<y } x>y  x+1<y is LIA-unsatisfiable, add (  A   C ) Invoke SAT solver: Propagate : A  false, Propagate : B  true, Propagate : D  true Invoke theory solver for LIA on: {  x>y, x>z, z>y }  x>y  x>z  z>y is LIA-unsatisfiable, add ( A   B   D ) No decisions to backtrack  input is LIA-unsatisfiable

DPLL(T) UNSAT SAT Solver Theory Solver Satisfying Assignment M for  Clauses to add to   is sat  is unsat M is T-sat M is T-unsat Clause set 

DPLL(T) Theory Solvers Input : A set of T-literals M Output : either 1.M is T-satisfiable 2.{ l 1, …, l n }  M is T-unsatisfiable 3.Don’t know: return lemma

DPLL(T) Theory Solvers Input : A set of T-literals M Output : either 1.M is T-satisfiable Return model, e.g. { x  2, y  3, z  -3, … } 2.{ l 1, …, l n }  M is T-unsatisfiable 3.Don’t know: return lemma

DPLL(T) Theory Solvers Input : A set of T-literals M Output : either 1.M is T-satisfiable Return model, e.g. { x  2, y  3, z  -3, … } 2.{ l 1, …, l n }  M is T-unsatisfiable Add T-conflict clause (  l 1  …   l n ) to  3.Don’t know: return lemma

DPLL(T) Theory Solvers Input : A set of T-literals M Output : either 1.M is T-satisfiable Return model, e.g. { x  2, y  3, z  -3, … } 2.{ l 1, …, l n }  M is T-unsatisfiable Add T-conflict clause (  l 1  …   l n ) to  3.Don’t know: return lemma Add clause to , e.g. splitting on demand ( x = y   x=y )

DPLL(T) Theory Solvers Input : A set of T-literals M Output : either 1.M is T-satisfiable Return model, e.g. { x  2, y  3, z  -3, … }  Should be solution-sound Answers “M is T-satisfiable” only if M is T-satisfiable 2.{ l 1, …, l n }  M is T-unsatisfiable Add T-conflict clause (  l 1  …   l n ) to  3.Don’t know: return lemma Add clause to , e.g. splitting on demand ( x = y   x=y )

DPLL(T) Theory Solvers Input : A set of T-literals M Output : either 1.M is T-satisfiable Return model, e.g. { x  2, y  3, z  -3, … }  Should be solution-sound Answers “M is T-satisfiable” only if M is T-satisfiable 2.{ l 1, …, l n }  M is T-unsatisfiable Add T-conflict clause (  l 1  …   l n ) to   Should be refutation-sound Anwers “{ l 1, …, l n } is T-unsatisfiable” only if { l 1, …, l n } is T-unsatisfiable 3.Don’t know: return lemma Add clause to , e.g. splitting on demand ( x = y   x=y )

DPLL(T) Theory Solvers Input : A set of T-literals M Output : either 1.M is T-satisfiable Return model, e.g. { x  2, y  3, z  -3, … }  Should be solution-sound Answers “M is T-satisfiable” only if M is T-satisfiable 2.{ l 1, …, l n }  M is T-unsatisfiable Add T-conflict clause (  l 1  …   l n ) to   Should be refutation-sound Anwers “{ l 1, …, l n } is T-unsatisfiable” only if { l 1, …, l n } is T-unsatisfiable 3.Don’t know: return lemma Add clause to , e.g. splitting on demand ( x = y   x=y )  If solver is solution-sound, refutation-sound, and terminating, Then it is a decision procedure for T

Design of DPLL(T) Theory Solvers A DPLL(T) theory solver: Should be solution-sound, refutation-sound, terminating Should produce models when M is T-satisfiable Should produce T-conflicts of minimal size when M is T-unsatisfiable Should be designed to work incrementally M is constantly being appended to/backtracked upon Can be designed to check T-satisfiability either: Eagerly: Check if M is T-satisfiable immediately when any literal is added to M Lazily: Check if M is T-satisfiable only when M is complete Should cooperate with other theory solvers when combining theories (see later)

DPLL(T) Theory Solvers : Examples SMT solvers incorporate: Theory solvers that are decision procedures for e.g.: Theory of Equality and Uninterpreted Functions (EUF) Congruence closure algorithm Theory of Linear Integer/Real Arithmetic Simplex algorithm Theory of Arrays Theory of Bit Vectors Theory of Inductive Datatypes … Theory solvers that are incomplete procedures for e.g.: Theory of Non-Linear Arithmetic Theory of Strings + Length constraints Quantified formulas

DPLL(T) Theory Solvers : Examples SMT solvers incorporate: Theory solvers that are decision procedures for e.g.: Theory of Equality and Uninterpreted Functions (EUF) Congruence closure algorithm Theory of Linear Integer/Real Arithmetic Simplex algorithm Theory of Arrays Theory of Bit Vectors Theory of Inductive Datatypes … Theory solvers that are incomplete procedures for e.g.: Theory of Non-Linear Arithmetic Theory of Strings + Length constraints Quantified formulas Focus of the next part

Theory of Inductive Datatypes Family of theories specified by a set of types with constructors: D 1, …, D m are datatypes C 1, …, C j are the constructors of datatype type D 1 C 1 has subfields of type T 1 …T i s 1, …, s i are the selectors for constructor C 1 D 1 := C 1 ( s 1 : T 1, …, s i : T i ) | … | C j ( … ) … D m := C m1 ( … ) | … | C mk ( … )

Theory of Inductive Datatypes : Example ClrList := cons( head : Clr, tail : ClrList ) | nil Clr := red | green | blue

Theory of Inductive Datatypes : Example Theory of Inductive Datatypes (DT) for ClrList and Clr  DT : { cons, head, tail, nil, red, green, blue } Interpretations I DT are such that: Terms with different constructors are distinct red  green Constructors are injective If cons( c 1, l 1 ) = cons( c 2, l 2 ), then c 1 = c 2 and l 1 = l 2 Terms of a datatype must have one of its constructors as its topmost symbol Each c is such that c = red or c = green or c = blue Selectors access subfields head( cons( c, l ) ) = c Terms do not contain themselves as subterms l  cons( c, l ) ClrList := cons( head : Clr, tail : ClrList ) | nil Clr := red | green | blue

Theory of Inductive Datatypes : Example DPLL(DT) algorithm cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green A B C D

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green A B C D

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green A B C D

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } cons( x, nil ) = cons( y, z )  x = red  y = green is DT-unsatisfiable!  Since cons( x, nil ) = cons( y, nil ), we have x = y, but x = red and y = green and red  green cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green A B C D

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } (  A   B   D ) added to list of clauses cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green A B C D (  A   B   D )

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } (  A   B   D ) added to list of clauses Invoke SAT solver Backtrack decision on B cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green A B C D (  A   B   D )

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } (  A   B   D ) added to list of clauses Invoke SAT solver Propagate : B  false, Propagate : C  true cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green (  A   B   D ) A B C D

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } (  A   B   D ) added to list of clauses Invoke SAT solver Propagate : B  false, Propagate : C  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ),  x = red, x=blue, y = green } cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green (  A   B   D ) A B C D

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } (  A   B   D ) added to list of clauses Invoke SAT solver Propagate : B  false, Propagate : C  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ),  x = red, x=blue, y = green } cons( x, nil ) = cons( y, z )  x = blue  y = green is DT-unsatisfiable!  Since cons( x, nil ) = cons( y, nil ), we have x = y, but x = red and y = green and red  green cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green (  A   B   D ) A B C D

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } (  A   B   D ) added to list of clauses Invoke SAT solver Propagate : B  false, Propagate : C  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ),  x = red, x=blue, y = green } (  A   C   D ) added to list of clauses cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green (  A   B   D )  (  A   C   D ) A B C D

Theory of Inductive Datatypes : Example DPLL(DT) algorithm Map : { A  cons( x, nil )=cons( y, z ), B  x=red, C  x=blue, D  y=green } Invoke SAT solver Propagate : A  true, Propagate : D  true, Decide : B  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ), x = red, y = green } (  A   B   D ) added to list of clauses Invoke SAT solver Propagate : B  false, Propagate : C  true Invoke theory solver for DT on: { cons( x, nil ) = cons( y, z ),  x = red, x=blue, y = green } (  A   C   D ) added to list of clauses No decisions to backtrack  input is DT-unsatisfiable cons(x,nil)=cons(y,z)  ( x=red  x = blue )  y = green (  A   B   D )  (  A   C   D ) A B C D

Combination of Theories What if we have: Example input: ( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1  Requires reasoning about datatypes and integers. IntList := cons( head : Int, tail : IntList ) | nil

Combination of Theories What if we have: Example input: ( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Idea: Purify the literals in the input Use DPLL(LIA+DT): find satisfying assignments M = M LIA  M DT Use existing solver for LIA to check if M LIA is LIA-satisfiable Use existing solver for DT to check if M DT is DT-satisfiable If either of { M LIA, M DT } is T-unsatisfiable, then M is T-unsatisfiable If both { M LIA, M DT } are T-satisfiable, then solvers must combine models Communicate equalities between shared terms IntList := cons( head : Int, tail : IntList ) | nil

Combination of Theories : Example DPLL(LIA+DT) algorithm ( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1

Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } A B C

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Purify A, B, C, e.g. introduce fresh “shared” variables such that: Each literal contains function symbols only belonging to one theory (DT or LIA) A B C

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } A B C u 1 u 2 u 1

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true A B C u 1 u 2 u 1

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers on : { u1 + 3 = y, u1 > y+1 }  { u 1 = head(x), u 2 = y+1 } A B C u 1 u 2 u 1

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 } A B C u 1 u 2 u 1

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 } A B C u 1 u 2 u 1

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) A B C u 1 u 2 u 1 (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Backtrack decision on A u 1 u 2 u 1 A B C

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true u 1 u 2 u 1 A B C (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers on : {  u 1 +3=y, x=cons( u 2, nil ), u 1 > y+1 }  { u 1 = head(x), u 2 = y+1 } u 1 u 2 u 1 A B C (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1 } u 1 u 2 u 1 A B C (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } … DT-satisfiable Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1 } u 1 u 2 u 1 A B C (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } … DT-satisfiable Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1 } … LIA-satisfiable u 1 u 2 u 1 A B C (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } … DT-satisfiable Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1 } … LIA-satisfiable  To answer “satisfiable”, theory solvers must agree on equalities between shared variables u 1, u 2 u 1 u 2 u 1 A B C (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } … DT-satisfiable. Is u 1 = u 2 ? Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1 } … LIA-satisfiable. Is u 1 = u 2 ? u 1 u 2 u 1 A B C (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } … DT-satisfiable. Is u 1 = u 2 ? YES: u 1 = head( x ) = u 2 Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1 } … LIA-satisfiable. Is u 1 = u 2 ? NO: u 2 = y+1 < u 1 u 1 u 2 u 1 A B C (  A   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1, u 1 = u 2 } u 1 u 2 u 1 A B C (  A   C ) DT-solver tells LIA-solver u 1 =u 2 …since x = cons( u 2, nil )  u 1 = head(x)

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1, u 1 = u 2 } u 1 > y+1  u 2 = y+1  u 1 = u 2 is LIA-unsatisfiable! u 1 u 2 u 1 A B C (  A   C ) DT-solver tells LIA-solver u 1 =u 2 …since x = cons( u 2, nil )  u 1 = head(x)

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1, u 1 = u 2 } Construct conflict based on explanation of u 1 > y+1, u 2 = y+1, u 1 = u 2 u 1 u 2 u 1 A B C (  A   C ) DT-solver tells LIA-solver u 1 =u 2 …since x = cons( u 2, nil )  u 1 = head(x)

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1, u 1 = u 2 } Add (  B   C ) u 1 u 2 u 1 A B C DT-solver tells LIA-solver u 1 =u 2 …since x = cons( u 2, nil )  u 1 = head(x) (  A   C )  (  B   C )

( head( x )+3 = y  x = cons( y+1, nil ) )  head( x ) > y+1 Combination of Theories : Example DPLL(LIA+DT) algorithm Map : { A  head( x )+3 =y, B  x=cons( y+1, nil ), C  head( x ) > y+1 } Map shared variables : { u 1  head( x ), u 2  y+1 } Invoke SAT solver: Propagate : C  true, Decide : A  true Invoke theory solvers Solver for DT on : { u 1 = head( x ) } … DT-satisfiable Solver for LIA on : { u = y, u 1 > y+1, u 2 = y+1 }… u = y  u 1 > y+1 is LIA-unsatisfiable! Add (  A   C ) Invoke SAT solver : Propagate A  false, Propagate : B  true Invoke theory solvers Solver for DT on : { x = cons( u 2, nil ), u 1 = head( x ) } Solver for LIA on : {  u 1 +3=y, u 1 > y+1, u 2 = y+1, u 1 = u 2 } Add (  B   C )  Input is DT+LIA-unsatisfiable! u 1 u 2 u 1 A B C DT-solver tells LIA-solver u 1 =u 2 …since x = cons( u 2, nil )  u 1 = head(x) (  A   C )  (  B   C )

SMT : Theory Combination Nelson-Oppen Theory Combination SMT solvers use preexisting theory solvers for combined theories T 1 + … + T n Basic idea given purified set of literals M: Partition and distribute M to T1-solver, …, Tn-solver If any T i -solver says “unsat”, then M is unsatisfiable If each T i -solver says “sat”, then solvers must agree on equalities between shared variables Requires theory solvers to: Have disjoint signatures E.g. arithmetic has functions { +, <, 0, 1, … }, datatypes has functions { cons, head, tail, … } Know equalities/disequalities between shared variables E.g. are u 1 = u 2 equal? Theories agree on cardinalities for shared types E.g. LIA and DT may agree that Int has infinite cardinality

Quantified Formulas What if input has quantifiers: (  x. P( x )   x.  P( x ) )  P( a )   x.  P( x ) for all Int xthere exists an Int x

Quantified Formulas What if input has quantifiers: (  x. P( x )   x.  P( x ) )  P( a )   x.  P( x ) Problem is generally undecidable E.g. no procedure for checking T-satisfiability of {  x. P( x ), P( a ), … }

Quantified Formulas What if input has quantifiers: (  x. P( x )   x.  P( x ) )  P( a )   x.  P( k ) Problem is generally undecidable E.g. no procedure for checking T-satisfiability of {  x. P( x ), P( a ), … } Witness existential quantification Introduce a fresh constant that witnesses the formula, so  x.  P( x ) becomes  P( k )

Quantified Formulas What if input has quantifiers: (  x. P( x )   x.  P( x ) )  P( a )   x.  P( k ) (  x. P( x )  P( a ) )  (  x. P( x )  P( k ) ), …. Problem is generally undecidable E.g. no procedure for checking T-satisfiability of {  x. P( x ), P( a ), … } Witness existential quantification Introduce a fresh constant that witnesses the formula, so  x.  P( x ) becomes  P( k ) Instantiate universal quantification Add clauses of the form (  x. P( x )  P( a ) ) Either P does not hold for all x, or it holds for a

Quantified Formulas What if input has quantifiers: (  x. P( x )   x.  P( x ) )  P( a )   x.  P( k ) (  x. P( x )  P( a ) )  (  x. P( x )  P( k ) ), …. Problem is generally undecidable E.g. no procedure for checking T-satisfiability of {  x. P( x ), P( a ), … } Witness existential quantification Introduce a fresh constant that witnesses the formula, so  x.  P( x ) becomes  P( k ) Instantiate universal quantification Add clauses of the form (  x. P( x )  P( a ) )  Sound but incomplete, thus may be unable to answer “sat”

SMT Solver for Quantifiers : Summary  Module SAT Solver Arithmetic UF Datatypes … Theory Solvers Assignments Conflict Clauses T-sat assignments Instantiations UNSAT (SAT?) Equalities over shared variables

SMT Summary SMT solvers use DPLL(T) algorithm for theory T, which uses: Off-the-shelf SAT solver Theory solver for T Nelson-Oppen theory combination for combined theories T 1 + T 2, which uses: Existing theory solvers for T 1 and T 2 Incomplete methods for quantified formulas Primarily use instantiation-based procedure for (universal) quantification