SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
-
Upload
sibyl-harrison -
Category
Documents
-
view
216 -
download
1
Transcript of SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
![Page 1: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/1.jpg)
SAT and SMT solversAyrat Khalimov
(based on Georg Hofferek‘s slides)
AKDV 2014
![Page 2: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/2.jpg)
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?
![Page 3: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/3.jpg)
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)
![Page 4: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/4.jpg)
Scope of Solvers
propositional logicSAT solvers
first order logic
theory of equality
difference logic
Theorem provers
SMT solvers
linear integer arithmetic
…
theory of arrays
![Page 5: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/5.jpg)
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
![Page 6: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/6.jpg)
SAT Solver
SAT Solver
Formula in CNF
Satisfiable(+ model)
Unsatisfiable(+ refutation
proof)
![Page 7: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/7.jpg)
DPLL Algorithm
• Due to Davis, Putnam, Loveland, Logemann
two papers: 1960, 1962
• Basis for all modern SAT solvers
![Page 8: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/8.jpg)
CNF as a Set of Clauses
• Formula: • Set Representation
![Page 9: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/9.jpg)
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
![Page 10: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/10.jpg)
Setting Literals
• Compute [l], for a literal l:
Remove all clauses that contain l:• They are true
Remove all literals l: • They are false (i.e., becomes a, becomes empty)
An empty clause is false
An empty set of clauses is true
![Page 11: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/11.jpg)
Truth Value of a CNF
• At least one clause is empty: FALSE
• Clause set empty: TRUE
• Otherwise: Unassigned Literals left
![Page 12: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/12.jpg)
DPLL Algorithm
// sat(, A)=TRUE iff [A] is satisfiable// sat(, true)=TRUE iff is satisfiablesat(, 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;}
![Page 13: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/13.jpg)
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), ab)4. sat( (a b) (b c) (c a), abc) unsat5. sat( (a b) (b c) (c a), abc) unsat
6. sat( (a b) (b c) (c a), ab) unsat7. sat( (a b) (b c) (c a), a)
8. sat((a b) (b c) (c a), ab)9. sat((a b) (b c) (c a), abc) sat
![Page 14: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/14.jpg)
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!
![Page 15: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/15.jpg)
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;}
![Page 16: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/16.jpg)
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), ab)4. [BCP]: sat( (a b) (b c) (c a), abc) unsat5. sat( (a b) (b c) (c a), a)
6. sat( (a b) (b c) (c a), ab)7. sat((a b) (b c) (c a), abc) sat
![Page 17: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/17.jpg)
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;}
![Page 18: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/18.jpg)
Pure Literals
• Pure literal: Literal for unassigned variable The variable appears in one phase only
• Pure literals true them
![Page 19: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/19.jpg)
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;}
![Page 20: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/20.jpg)
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), ab) sat
![Page 21: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/21.jpg)
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;}
![Page 22: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/22.jpg)
• Whenever we get the conflict analyze it
• add clauses to avoid in future
2013-03-08 Institute for Applied Information Processing and Communications
Learning: informal
![Page 23: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/23.jpg)
Learning
1. (a c)2. (b c)3. (a b c)4. (a b)5. (a b)6. (a b)7. (a b)
c
a
UNSAT
![Page 24: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/24.jpg)
Learning
1. (a c)2. (b c)3. (a b c)4. (a b)5. (a b)6. (a b)7. (a b)
c
a
UNSAT
a
UNSAT
The problem is with a: no need to set c=true!
a
UNSAT
a
UNSAT
Without learning
![Page 25: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/25.jpg)
Learning
1. (a c)2. (b c)3. (a b c)4. (a b)5. (a b)6. (a b)7. (a b)
c
a
UNSAT
a false7
We learn: a
b6
![Page 26: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/26.jpg)
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
a
UNSAT
Jump back to level 0 is smart
LEVEL 0
LEVEL 1
LEVEL 2a false
7
We learn: a
b6
![Page 27: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/27.jpg)
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
a
UNSAT
a
Jump back to level 0 is smart
LEVEL 0
LEVEL 1
LEVEL 2
![Page 28: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/28.jpg)
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
a
UNSAT
a b4 false5 LEVEL 0
LEVEL 1
LEVEL 2
![Page 29: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/29.jpg)
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
a
UNSAT
a b4 false5
UNSAT
We learn: UNSAT, becauseno decision was necessary
LEVEL 0
LEVEL 1
LEVEL 2
![Page 30: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/30.jpg)
Backtrack Level
• Three important possibilities1. Backtrack as usual2. Restart for every learned clause3. Go to the earliest level in which the conflict
clause is a unit clause
• Option 3 often performs better
![Page 31: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/31.jpg)
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?
![Page 32: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/32.jpg)
Institute for Applied Information Processing and Communications 32Source: Armin Biere’s slides: http://fmv.jku.at/rerise14/rerise14-sat-slides.pdf
Effect of picking heuristics on SAT solver performance
![Page 33: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/33.jpg)
Can we do better? -- Special cases
2013-03-08 Institute for Applied Information Processing and Communications 33
• Horn clauses can be solved in polynomial time• Cut width algorithm
![Page 34: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/34.jpg)
source: http://gauss.ececs.uc.edu/SAT/
![Page 35: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/35.jpg)
![Page 36: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/36.jpg)
Syntax of Predicate Logic
• Two sorts:
Objects• Numbers• Strings• Elements of sets• …
Truth values• IsEven(42)
“Terms”
“Formulas”
![Page 37: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/37.jpg)
From Terms to Formulas
Term Term
Formula
Predicate
![Page 38: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/38.jpg)
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?
![Page 39: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/39.jpg)
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𝕋
![Page 40: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/40.jpg)
Terms 𝕋
• Variable is a term
• Constant is a term
• If are terms, is -ary function then is a term
![Page 41: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/41.jpg)
Formulae
Preconditions:
• Terms
• -ary predicate symbol
• formulae
• Variable
![Page 42: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/42.jpg)
True and False FO formulae
• Functions and predicates in FO formulae are ‘uninterpreted’ they can be any
• Variables in FO formulae have no domains what can x, y be?
• What does it mean that this formula is true? or false?
• Depends..
![Page 43: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/43.jpg)
Model for ( , , )𝔽 ℙ 𝕍
• Non-empty set Domain for variables Possibly infinite Non-empty
• For constansts : concrete element • For functions : concrete function • For predicates : subset ℙ (of arity n)
i.e., set of tuples on which is true
![Page 44: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/44.jpg)
Semantics of Predicate Logic
• Formula Over , , 𝔽 ℙ 𝕍
• Model For , , 𝔽 ℙ 𝕍
• ? ( has no free variables)
Inductive Definition
![Page 45: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/45.jpg)
Semantics of Predicate Logic• For of the form
iff , for all
• For of the form iff , for at least one
• For of the form , , Like in propositional logic
• No free variables => any predicate has concrete arguments
![Page 46: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/46.jpg)
• Let model M be: D = {1,2} , others gives F f(1, ..)=1, f(2, 1)=1, f(2,2)=2
Does
2013-03-08 Institute for Applied Information Processing and Communications
Examples
![Page 47: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/47.jpg)
Satisfiable FO formulae is sat
means there is a model:• there is a non-empty domain D for x, y
for example, D={1,2}• there is predicate P, function :
for example, i.e. P(1,2)=true, P(2,.)=false for example, , i.e.
such that
![Page 48: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/48.jpg)
Valid FO formulae
is validiff it is satisfied by any model
Let us check for example the model:• D={1,2}• P={1,2}
i.e., P(1)=P(2)=T• function is any from {1,2} to {1,2}
![Page 49: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/49.jpg)
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
deductionalgorithm
FO formula
may never terminate
if valid
if invalid
![Page 50: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/50.jpg)
Notion of “Theory”
Application Domain
Structures & Objects
Predicates &Functions
ArithmeticNumbers (Integers,
Rationals, Reals)
ComputerPrograms
Arrays, BitvectorsArray-Read,
Array-Write, …
![Page 51: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/51.jpg)
Definition of a Theory
First-Order Theory :
1. Signature Constants Predicates Functions
2. Set of Axioms Sentences (=Formulas without free variables) with
symbols from only
-formula:(non-logic) symbols
from only
: possibly infinite
![Page 52: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/52.jpg)
Example: Theory of Equality
• Signature
Binary equality predicate
Arbitrary constant symbols (no function/predicate symbols!)
• Axioms :
1. (reflexivity)
2. (symmetry)
3. (transitivity)
![Page 53: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/53.jpg)
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
![Page 54: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/54.jpg)
-Satisfiability
• Green: Models Satisfying all Axioms• Violet: Models Satisfying Formula in Question
-Satisfiable
-Satisfiable
Not -Satisfiable
![Page 55: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/55.jpg)
-Validity
• Green: Models Satisfying all Axioms• Violet: Models Satisfying Formula in Question
-Valid
-Valid
Not -Valid
![Page 56: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/56.jpg)
Theory Formulas vs. FO Formulas
TheoryFormula
𝒜→𝝓 𝒜∧𝝓
equiv
alid
equisatisfiable
![Page 57: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/57.jpg)
Fragment of a Theory
• Syntactically restricted subset
Quantifier-free fragment
Conjunctive fragment • e.g.:
![Page 58: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/58.jpg)
Scope of Solvers
propositional logicSAT solvers
first order logic
theory of equality
difference logic
Theorem provers
SMT solvers
linear integer arithmetic
…
theory of arrays
![Page 59: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/59.jpg)
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)
![Page 60: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/60.jpg)
Example: Theory of Uninterpreted Functions and Equality
• Signature Binary equality predicate Arbitrary constant- and function-symbols
• Axioms :
1.-3. same as in (reflexivity), (symmetry), (transitivity)
4.
(function congruence)Axiom Schema: Template for (infinite number of) axioms
![Page 61: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/61.jpg)
Two-Stage Eager Encoding
(quant.-free) formula
equisatisfiable formula
equisatisfiablepropositional formula
Ackermann’s Reduction
Graph-based Reduction
SAT Solver
![Page 62: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/62.jpg)
Ackermann’s Reduction (from to
• Fresh Variables
, , ...
• Functional Constraints
• formula:
![Page 63: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/63.jpg)
Perform Ackermann’s Reduction for
![Page 64: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/64.jpg)
Graph-Based Reduction (from to propositional)
• Non-Polar Equality Graph
Node per variable
Edge per (dis)equality
• Make it chordal
No chord-free cycles (size > 3)
a
b
c
de
f
g
![Page 65: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/65.jpg)
Graph-Based Reduction (from to propositional)
• Fresh Propositional Variables
Order!
• Triangle : Transitivity Constraints
𝒄 𝒃
𝒂
SAT Solver
![Page 66: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/66.jpg)
Perform Graph-Based Reduction for
![Page 67: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/67.jpg)
Summary: Eager Encoding
(quant.-free) formula
equisatisfiable formula
equisatisfiablepropositional formula
Ackermann’s Reduction
Graph-based Reduction
SAT Solver
𝝓𝑬=𝝓𝑭𝑪∧ �̂�𝑼𝑬
𝝓𝒑𝒓𝒐𝒑=𝝓𝑻𝑪∧ �̂�𝑬
![Page 68: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/68.jpg)
Lazy Encoding
SAT Solver
Theory Solver
Assignment of Literals
Blocking Clause
𝒔𝒌𝒆𝒍 (𝝓)
SATUNSAT
![Page 69: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/69.jpg)
Conjunctive (quant-free) Fragment of
• Conjunction of theory literals, where literals
are:
![Page 70: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/70.jpg)
Congruence-Closure Algorithm
• Equivalence Classes introduce class for each term
: merge classes of into one larger class
two classes shared terms -- merge classes! (repeat)
from same class:
Merge classes of (repeat)
• Check Disequalities in same class: UNSAT!
Otherwise: SAT!
![Page 71: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/71.jpg)
Perform Congruence Closure for
![Page 72: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/72.jpg)
Lazy Encoding
SAT Solver
Theory Solver
Assignment of Literals
Blocking Clause
𝒔𝒌𝒆𝒍 (𝝓)
SATUNSAT
![Page 73: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/73.jpg)
DPLL(T)
Decide
Start
full assignmentSAT
BCP/PL
partial assignment
Analyze Conflict
conflictUNSAT
Learn & Backtrack
Theory Solver Add Clauses
partial assignment
theory propagation / conflict
partial assignment
![Page 74: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/74.jpg)
Scope of Solvers
propositional logicSAT solvers
first order logic
theory of equality
difference logic
Theorem provers
SMT solvers
linear integer arithmetic
…
theory of arrays
![Page 75: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/75.jpg)
Summary
75
• Propositional SAT Problem DPLL
• First-Order Theories Examples:
• Satisfiability modulo theories Eager Encoding Lazy Encoding DPLL(T)
![Page 76: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/76.jpg)
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)
![Page 77: SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.](https://reader036.fdocuments.in/reader036/viewer/2022070409/56649e9f5503460f94ba227b/html5/thumbnails/77.jpg)
• History of satisfiability: http://gauss.ececs.uc.edu/SAT/articles/FAIA185-0003.pdf
• SAT basics: http://gauss.ececs.uc.edu/SAT/articles/sat.pdf
• Conflict Driven Clause Learning: http://gauss.ececs.uc.edu/SAT/articles/FAIA185-0131.pdf
• Armin Biere’s slides: http://fmv.jku.at/rerise14/rerise14-sat-slides.pdf
• SAT game http://www.cril.univ-artois.fr/~roussel/satgame/satgame.php?level=1&lang=eng
• Logic and Computability classes by Georg http://www.iaik.tugraz.at/content/teaching/bachelor_courses/logik_und_berechenbarkeit/ Institute for Applied Information Processing and Communications
some reading