210 likes | 472 Views
Satisfiability modulo theories. SPb SU ITMO Software Engineering Seminar July 2011. Anton Bannykh. Introduction. Appeared at late 70’s – early 80’s SAT + background theories First-order logic Quantifier-free Motivation Consider formula: x < y ∧ ¬ (x < y + 0) Inconsistent
E N D
Satisfiability modulo theories SPb SU ITMO Software Engineering Seminar July 2011 Anton Bannykh
Introduction Appeared at late 70’s – early 80’s SAT + background theories • First-order logic • Quantifier-free Motivation • Consider formula: x < y ∧¬(x < y + 0) • Inconsistent • Nontrivial task for general-purpose prover Satisfiability Modulo Theories
General idea Take a formula Replace theory-specific predicates with variables Split task into: • Finding a SAT solution • 1 ∧ 3 ∧ ¬ 4 • Checking consistence of a conjunction of predicates • g(a) = c ∧ g(a) = d ∧ c ≠ d 1 ∧ (¬2 ∨ 3) ∧¬ 4 g(a) = c ∧ ( f(g(a)) ≠ f(c) ∨ g(a) = d ) ∧ c ≠ d 1: g(a) = c 2: f(g(a)) = f(c) 3: g(a) = d 4: c = d 1 ¬ 2 3 ¬ 4 Satisfiability Modulo Theories
SAT Propositional logic • CNF Performance • NP-complete • Expressive • Requires encoding • Fast in practice • 104 variables • 106 clauses Satisfiability Modulo Theories
Theories Equality and Uninterpreted Functions (EUF) Bit-Vectors Arrays Lists Linear Arithmetic Non-Linear Arithmetic Satisfiability Modulo Theories
EUF Consider formula: • a · (f(b) + f(c)) = d ∧b · (f(a) + f(c)) ≠ d ∧ a = b Facts: • Inconsistent • No arithmetic reasoning is needed Rewritein a more abstract way • h(a, g(f(b), f(c))) = d ∧ h(b, g(f(a), f(c))) ≠ d ∧ a = b • Still inconsistent Satisfiability Modulo Theories
Linear Arithmetic Domain • Reals • Integers Subtheories • Difference logic • Unit-Two-Variable-Per-Inequality Satisfiability Modulo Theories
Eager approach Encode SMT into SAT • Translate problem into equisatisfiable propositional formula and use any SAT solver • Use optimizations to get small SAT problem Benefits • Use best available SAT solver Drawbacks • Sophisticated encoding of theories • Theory-specific • Multiple approaches • Low performance Satisfiability Modulo Theories
Lazy approach Methodology • Get SAT solution • Check T-consistence • If fail then learn and repeat Example • Formula: • Problem: 1 ∧ (¬2∨3) ∧¬4 • SAT solver returns 1 ∧ ¬2 ∧¬4 • T-solver says inconsistent • SAT solver returns 1 ∧ 2 ∧ 3 ∧¬4 • T-solver says inconsistent • SAT solver detects unsatisfiable g(a) = c ∧ ( f(g(a)) ≠ f(c) ∨ g(a) = d ) ∧ c ≠ d 1 ¬ 2 3 ¬ 4 ∧ (¬1∨2∨4) • ∧ (¬1∨¬2∨¬3∨4) Satisfiability Modulo Theories
Lazy approach Benefits • No theory translation • SAT solver takes care of Boolean information • Theory solver takes care of theory information • Theory solver receives conjunction of literals • Modular and flexible • New theory requires only a new T-solver • Simple communication API Drawbacks • Theory information does not guide the search Satisfiability Modulo Theories
DPLL Overview • Davis-Putnam-Logemann-Loveland (1962) • Key to effective SAT solver implementation • Backtracking with optimizations Features • Unit propagate • Learn • Branching heuristics • Backjump • Restart Satisfiability Modulo Theories
DPLL(T) T-propagation • Find T-consequences instead of only validating • Naïve implementation • Add ¬P • Check consistency • Need fast T-solvers specialized in T-propagation Usage • DPLL + T-solver • Call T-solver in process • Use T-propagations Theory information used in the search Satisfiability Modulo Theories
DPLL(T) example Consider formula: Process: • ∅ • UnitPropagate • 1 • UnitPropagate • 1 ∧ ¬4 • T-propagate: g(a)=c ⇒ f(g(a)) = f(c) • 1∧ ¬4 ∧ 2 • T-propagate: g(a)=c ∧ c ≠ d ⇒ g(a) ≠ d • 1∧ ¬4 ∧ 2 ∧¬3 • Fail g(a) = c ∧ ( f(g(a)) ≠ f(c) ∨ g(a) = d ) ∧ c ≠ d 1 ¬ 2 3 ¬ 4 Satisfiability Modulo Theories
Theory solvers Is given conjunction of literals T-satisfiable? Key features • Model generation • Conflict set generation • Incrementality • Backtrackability • Deduction of unassigned literals • Deduction of interface equalities Satisfiability Modulo Theories
Optimizations Layered solvers Preprocessing • Normalizing T-atoms • Static learning Look-ahead and look-back Splitting on demand Assignment simplification • Clustering • T-literal filtering Solver1 UNSAT SAT Solver2 UNSAT Abstraction SAT Solver2 UNSAT SAT SAT UNSAT Satisfiability Modulo Theories
Theories combination Theories are not isolated Ackermann’s expansion • EUF • Replace function applications with fresh variables • Add all needed functional congruence constraints Nelson-Oppen combination • T-solvers exchage deduced information Delayed Theory combination • T-solvers interact only with SAT solver Satisfiability Modulo Theories
Problems and limitations Expressivity • Quantifier-free (most) DPLL-related • Generating partial assignments • Avoiding ghost literals • T-backjumping not perfect • T-propagation • Branching heuristics General • Producing proofs • Model generation • Identifying unsatisfiable cores Satisfiability Modulo Theories
Related approaches OBDD • Ordered binary decision diagrams • Exponential space in worst case Circuit-based techniques • Booleans circuits instead of CNF • Efficient boolean constraint propagation • Don’t care values Rewrite-based • Superposition calculus • Applied to theories axiomatizable by a small set of F.O. clauses • Simplified prove of correctness and theory combination • Sophisticated implementation Mixed Satisfiability Modulo Theories
SMTLIB & SMTCOMP Created in 2003 Goals • Standard descriptions of background theories • Standard input and output language for SMT solvers • Benchmarking Satisfiability Modulo Theories
Ask Z3 http://rise4fun.com/Z3 Satisfiability Modulo Theories
Conclusion SMT adds domain-specific reasoning to SAT Lots of applications: • Resource planning • Temporal reasoning • Formal verification • Compiler optimization • Model checking • Test generation • … Significant performance improvement Satisfiability Modulo Theories