SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment...

129
SAT Solvers Ranjit Jhala, UC San Diego April 9, 2013

Transcript of SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment...

Page 1: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

SAT Solvers

Ranjit Jhala, UC San Diego

April 9, 2013

Page 2: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures

We will look very closely at the following

1. Propositional Logic

2. Theory of Equality

3. Theory of Uninterpreted Functions

4. Theory of Difference-Bounded Arithmetic

Decision Problem: Satisfaction

I Does eval s p return True for some assignment s ?

I “Can we assign the variables to make the formula true” ?

Page 3: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures

We will look very closely at the following

1. Propositional Logic

2. Theory of Equality

3. Theory of Uninterpreted Functions

4. Theory of Difference-Bounded Arithmetic

Why?

I RepresentativeI Have “efficient” algorithms

Page 4: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures

We will look very closely at the following

1. Propositional Logic

2. Theory of Equality

3. Theory of Uninterpreted Functions

4. Theory of Difference-Bounded Arithmetic

Plan

I First in isolationI Then in combinationI Very slick SW-Eng, based on logic

Page 5: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures: Propositional Logic

Popularly called SAT Solvers

Page 6: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures: Propositional Logic

Basics

I Propositional Logic 101I Conjunctive Normal FormI Resolution

Algorithms

I ResolutionI Backtracking SearchI Boolean Constraint PropagationI Conflict Driven Learning & Backjumping

Page 7: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures: Propositional Logic

Basics

I Propositional Logic 101I Conjunctive Normal FormI Resolution

Algorithms

I ResolutionI Backtracking SearchI Boolean Constraint PropagationI Conflict Driven Learning & Backjumping

Page 8: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Propositional Logic 101

Propositional Variables

data PVar

Propositional Formulas

data Formula = Prop PVar

| Not Formula

| Formula ‘And‘ Formula

| Formula ‘Or‘ Formula

Page 9: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures: Propositional Logic

Basics

I Propositional Logic 101I Conjunctive Normal FormI Resolution

Algorithms

I ResolutionI Backtracking SearchI Boolean Constraint PropagationI Conflict Driven Learning & Backjumping

Page 10: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conjunctive Normal Form

Restricted representation of Formula

Literals: Variables or Negated Variables

data Literal = Pos PVar | Neg PVar

Clauses: Disjunctions (Or) of Literals

data Clauses = [Literal]

CNF Formulas: Conjunctions (And) of Clauses

data CnfFormula = [Clauses]

Page 11: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conjunctive Normal Form: Example

Consider a Formula

(x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ ¬x3

Represented as a Formula

(Prop 1 ‘Or‘ Prop 2)

‘And‘ (Not (Prop 1) ‘Or‘ Prop 3)

‘And‘ (Not (Prop 3) )

Represented as a CnfFormula

[ [Pos 1 , Pos 2]

, [Neg 1 , Pos 3]

, [Neg 3 ] ]

Page 12: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conjunctive Normal Form Conversion

Theorem There is a poly-time function

toCNF :: Formula -> CnfFormula

toCNF = error "Exercise For The Reader"

Such that any f is satisfiable iff (toCNF f) is satisfiable.

I toCNF adds new variables for sub-formulas

I otherwise, an exponential blowup in CnfFormula size

Page 13: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conjunctive Normal Form Conversion

Theorem There is a poly-time function

toCNF :: Formula -> CnfFormula

toCNF = error "Exercise For The Reader"

Such that any f is satisfiable iff (toCNF f) is satisfiable.

Henceforth Only consider formulas in Conjunctive Normal FormFormulas

Page 14: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures: Propositional Logic

Basics

I Propositional Logic 101I Conjunctive Normal Form

Algorithms

I ResolutionI Backtracking SearchI Boolean Constraint PropagationI Conflict Driven Learning & Backjumping

Page 15: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Properties of CNF

Pure Variable

I One which appears only +ve or −ve in a CnfFormula

Empty Clause

I If a CnfFormula has some Clause without LiteralsI Then the CnfFormula is UNSAT

Trivial Formula

I If a CnfFormula has no Clause

I Or every variable is pureI Then the CnfFormula is SAT

Page 16: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Goal

Determine satisfaction by reducing CnfFormula to one of

I Empty Clause (ie UNSAT), or

I Trivial Formula (ie SAT).

Page 17: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Reducing Formulas By Resolution

(“Reduce” is, perhaps, not the best word. . . )

Resolution: For any A,B and variable x , the formula

(A ∨ x) ∧ (B ∨ ¬x)

is equivalent to the formula

(A ∨ B)

I The variable x is called a pivot variable

Page 18: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

General Resolution

Resolution: For any Ai ,Bj and variable x , the formula

∧i

(Ai ∨ x) ∧∧j

(Bj ∨ ¬x)

is equivalent to the formula

∧i ,j

(Ai ∨ Bj)

I Pivot variable x is eliminated by resolution

Page 19: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Davis-Putnam Algorithm: Example 1

Input Formula

I (x1 ∨ x2 ∨ x3) ∧ (x2 ∨ ¬x3 ∨ x5) ∧ (¬x2 ∨ x4))

Pivot on x2

I (x1 ∨ x3 ∨ x4) ∧ (¬x3 ∨ x5 ∨ x4)

Pivot on x3

I (x1 ∨ x4 ∨ x5)

All variables are pure . . . hence, SAT

Page 20: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Davis-Putnam Algorithm: Example 2

Input Formula

I (x1 ∨ x2) ∧ (x1 ∨ ¬x2) ∧ (¬x1 ∨ x3) ∧ (¬x1 ∨ ¬x3)

Pivot on x2

I (x1) ∧ (¬x1 ∨ x3) ∧ (¬x1 ∨ ¬x3)

Pivot on x3

I (x1) ∧ (¬x1)

Pivot on x1

I ()

Empty clause . . . hence, UNSAT

Page 21: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Davis-Putnam Algorithm

Algorithm

1. Select pivot and perform resolution

2. Repeat until SAT or UNSAT

Issues?

I Space blowup (formula size blows up on resolution)

Page 22: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures: Propositional Logic

Basics

I Propositional Logic 101I Conjunctive Normal Form

Algorithms

I ResolutionI Backtracking SearchI Boolean Constraint PropagationI Conflict Driven Learning & Backjumping

Page 23: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Tree: Describes Space of All Assignments

Figure: SAT Decision Tree (Courtesy: Lintao Zhang)

Page 24: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Tree: SAT via Depth First Search

Figure: DFS On Decision Tree (Courtesy: Lintao Zhang)

Page 25: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search

Don’t build whole tree, but lazily search solutions

I Choose a variable x , set to True

I Remove constraints where x appearsI Recurse on remaining constraintsI Backtrack if a contradiction is found

Page 26: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (1/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 27: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (2/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 28: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (3/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 29: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (4/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 30: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (5/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 31: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (6/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 32: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (7/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 33: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (8/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 34: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (9/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 35: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (10/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 36: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (11/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 37: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (12/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 38: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (13/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 39: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (14/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 40: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (15/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 41: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (16/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 42: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (17/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 43: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (18/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 44: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (19/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 45: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (20/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 46: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search (21/21)

Figure: Basic DLL (Courtesy: Lintao Zhang)

Page 47: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Search

Don’t build whole tree, but lazily search solutions

I Choose a variable x , set to True

I Remove constraints where x appearsI Recurse on remaining constraintsI Backtrack if a contradiction is found

(whew!)

I DFS avoids space blowup (only need to save stack) . . .I . . . but not time (natch)

Page 48: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures: Propositional Logic

Basics

I Propositional Logic 101I Conjunctive Normal Form

Algorithms

I ResolutionI Backtracking SearchI Boolean Constraint PropagationI Conflict Driven Learning & Backjumping

Page 49: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation

Often, we don’t really have a choice. . .

Page 50: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation

Unit Clause Rule

I If an (unsatisfied) Clause has one unassigned Literal

I Then that Literal must be True in any SAT assignment

Example

I Formula (x1 ∨ ¬x2 ∨ x3) ∧ (x2 ∨ ¬x3) ∧ (¬x1 ∨ ¬x3)

I Assignment x1 = T , x2 = T

I The last clause is a unit clause

I Any SAT assigment must set ¬x3 = T (i.e. x3 = F )

Page 51: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation

Unit Clause Rule

I If an (unsatisfied) Clause has one unassigned Literal

I Then that Literal must be True in any SAT assignment

BCP or Unit Propagation

I Repeat applying unit clause ruleI Until no unit clause remains.

Page 52: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation: Example

Revisit Example With BCP

Figure: Boolean Constraint Propagation (Courtesy: Lintao Zhang)

Page 53: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation

DPLL = Backtracking Search + BCP

I Backtracking: Avoids space blowup

I BCP: Avoid doing obvious work

I Still repeatedly explore all choices (e.g. whole left subtree)

Wanted

I Means to learn to repeat dead ends

I Key to scaling to practical problems

Page 54: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Decision Procedures: Propositional Logic

Basics

I Propositional Logic 101I Conjunctive Normal Form

Algorithms

I ResolutionI Backtracking SearchI Boolean Constraint PropagationI Conflict Driven Learning & Backjumping

Page 55: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning

Key Insight

I On finding conflict, don’t (just) backtrack

I Learn new clause to prevent same conflict in future

Major breakthrough

I J. P. Marques-Silva and K. A. Sakallah, “GRASP – A NewSearch Algorithm for Satisfiability,” Proc. ICCAD 1996.

I R. J. Bayardo Jr. and R. C. Schrag “Using CSP look-backtechniques to solve real world SAT instances.” Proc. AAAI,1997

Page 56: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning

I Resolve on conflict variable to learn new conflict clause

I Add clause to set of clauses

I Backjump using conflict clause

Page 57: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven LearningRevisit Example With CDL

I Learn, Add, BackjumpI Vastly faster search

Figure: Boolean Constraint Propagation (Courtesy: Lintao Zhang)

Page 58: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (01/26)

Figure: Backtracking Only

Page 59: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (02/26)

Figure: Backtracking Only

Page 60: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (03/26)

Figure: Backtracking Only

Page 61: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (04/26)

Figure: Backtracking Only

Page 62: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (05/26)

Figure: Backtracking Only

Page 63: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (06/26)

Figure: Backtracking Only

Page 64: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (07/26)

Figure: Backtracking Only

Page 65: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (08/26)

Figure: Backtracking Only

Page 66: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (09/26)

Figure: Backtracking Only

Page 67: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (10/26)

Figure: Backtracking Only

Page 68: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (11/26)

Figure: Backtracking Only

Page 69: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (12/26)

Figure: Backtracking Only

Page 70: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (13/26)

Figure: Backtracking Only

Page 71: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (14/26)

Figure: Backtracking Only

Page 72: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (15/26)

Figure: Backtracking Only

Page 73: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (16/26)

Figure: Backtracking Only

Page 74: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (17/26)

Figure: Backtracking Only

Page 75: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (18/26)

Figure: Backtracking Only

Page 76: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (19/26)

Figure: Backtracking Only

Page 77: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (20/26)

Figure: Backtracking Only

Page 78: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (21/26)

Figure: Backtracking Only

Page 79: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (22/26)

Figure: Backtracking Only

Page 80: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (23/26)

Figure: Backtracking Only

Page 81: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (24/26)

Figure: Backtracking Only

Page 82: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (25/26)

Figure: Backtracking Only

Page 83: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Backtracking Only (26/26)

Figure: Backtracking Only

Page 84: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (01/23)

Figure: BCP

Page 85: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (02/23)

Figure: BCP

Page 86: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (03/23)

Figure: BCP

Page 87: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (04/23)

Figure: BCP

Page 88: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (05/23)

Figure: BCP

Page 89: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (06/23)

Figure: BCP

Page 90: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (07/23)

Figure: BCP

Page 91: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (08/23)

Figure: BCP

Page 92: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (09/23)

Figure: BCP

Page 93: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (10/23)

Figure: BCP

Page 94: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (11/23)

Figure: BCP

Page 95: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (12/23)

Figure: BCP

Page 96: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (13/23)

Figure: BCP

Page 97: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (14/23)

Figure: BCP

Page 98: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (15/23)

Figure: BCP

Page 99: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (16/23)

Figure: BCP

Page 100: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (17/23)

Figure: BCP

Page 101: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (18/23)

Figure: BCP

Page 102: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (19/23)

Figure: BCP

Page 103: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (20/23)

Figure: BCP

Page 104: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (21/23)

Figure: BCP

Page 105: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (22/23)

Figure: BCP

Page 106: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Boolean Constraint Propagation (23/23)

Figure: BCP

Page 107: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (01/21)

Figure: CDL

Page 108: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (02/21)

Figure: CDL

Page 109: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (03/21)

Figure: CDL

Page 110: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (04/21)

Figure: CDL

Page 111: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (05/21)

Figure: CDL

Page 112: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (06/21)

Figure: CDL

Page 113: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (07/21)

Figure: CDL

Page 114: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (08/21)

Figure: CDL

Page 115: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (09/21)

Figure: CDL

Page 116: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (10/21)

Figure: CDL

Page 117: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (11/21)

Figure: CDL

Page 118: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (12/21)

Figure: CDL

Page 119: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (13/21)

Figure: CDL

Page 120: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (14/21)

Figure: CDL

Page 121: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (15/21)

Figure: CDL

Page 122: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (16/21)

Figure: CDL

Page 123: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (17/21)

Figure: CDL

Page 124: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (18/21)

Figure: CDL

Page 125: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (19/21)

Figure: CDL

Page 126: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (20/21)

Figure: CDL

Page 127: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Conflict Driven Learning (21/21)

Figure: CDL

Page 129: SAT Solvers - Herbgrind · 2013. 5. 16. · I Then that Literal must be True in any SAT assignment Example I Formula (x 1 _:x 2 _x 3) ^(x 2 _:x 3) ^(:x 1 _:x 3) I Assignment x 1 =

Next Time: SMT = SAT + Theories

1. Propositional Logic

2. Combining Theories

I Equality + Uninterpreted FunctionsI Difference-Bounded Arithmetic

3. Combining SAT + Theories