Satisfiability Modulo Theories (An introduction)

Slides:



Advertisements
Similar presentations
Logical Abstract Interpretation Sumit Gulwani Microsoft Research, Redmond.
Advertisements

SMELS: Sat Modulo Equality with Lazy Superposition Christopher Lynch – Clarkson Duc-Khanh Tran - MPI.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Satisfiability modulo the Theory of Bit Vectors
Syntax-Guided Synthesis Rajeev Alur Joint work with R.Bodik, G.Juniwal, M.Martin, M.Raghothaman, S.Seshia, R.Singh, A.Solar-Lezama, E.Torlak, A.Udupa 1.
Course Summary What have we learned and what are we expected to know?
Satisfiability Modulo Theories and Network Verification Nikolaj Bjørner Microsoft Research Formal Methods and Networks Summer School Ithaca, June
Synthesis, Analysis, and Verification Lecture 04c Lectures: Viktor Kuncak VC Generation for Programs with Data Structures “Beyond Integers”
Linear real and integer arithmetic. Fixed-size bit-vectors Uninterpreted functions Extensional arrays Quantifiers Model generation Several input formats.
50.530: Software Engineering
Finding bugs: Analysis Techniques & Tools Symbolic Execution & Constraint Solving CS161 Computer Security Cho, Chia Yuan.
SMT Solvers (an extension of SAT) Kenneth Roe. Slide thanks to C. Barrett & S. A. Seshia, ICCAD 2009 Tutorial 2 Boolean Satisfiability (SAT) ⋁ ⋀ ¬ ⋁ ⋀
Verification of Functional Programs in Scala Philippe Suter (joint work w/ Ali Sinan Köksal and Viktor Kuncak) ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE,
Linked List Implementation class List { private List next; private Object data; private static List root; private static int size; public static void addNew(Object.
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Proofs from SAT Solvers Yeting Ge ACSys NYU Nov
Programming with Constraint Solvers CS294: Program Synthesis for Everyone Ras Bodik Emina Torlak Division of Computer Science University of California,
Panel on Decision Procedures Panel on Decision Procedures Randal E. Bryant Lintao Zhang Nils Klarlund Harald Ruess Sergey Berezin Rajeev Joshi.
Leonardo de Moura and Nikolaj Bjørner Microsoft Research.
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:
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.
1 Predicate Abstraction of ANSI-C Programs using SAT Edmund Clarke Daniel Kroening Natalia Sharygina Karen Yorav (modified by Zaher Andraus for presentation.
Yeting Ge Leonardo de Moura New York University Microsoft Research.
Stanford University CS243 Winter 2006 Wei Li 1 Data Dependences and Parallelization.
The Theory of NP-Completeness
Counterexample Generation for Separation-Logic-Based Proofs Arlen Cox Samin Ishtiaq Josh Berdine Christoph Wintersteiger.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Program Exploration with Pex Nikolai Tillmann, Peli de Halleux Pex
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
Nikolaj Bjørner Leonardo de Moura Nikolai Tillmann Microsoft Research August 11’th 2008.
Quantifier Elimination Procedures in Z3 Support for Non-linear arithmetic Fixed-points – features and a preview.
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Mathematics in OI Prepared by Ivan Li. Mathematics in OI Greatest Common Divisor Finding Primes High Precision Arithmetic Partial Sum and Differencing.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Introduction to Satisfiability Modulo Theories
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Advanced Computer Architecture and Parallel Processing Rabie A. Ramadan http:
CJAdviser: SMT-based Debugging Support for ContextJ* Shizuka Uchio(Kyushu University, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module Logic Representations.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
Symbolic and Concolic Execution of Programs Information Security, CS 526 Omar Chowdhury 10/7/2015Information Security, CS 5261.
Arithmetic Test Pattern Generation: A Bit Level Formulation of the Optimization Problem S. Manich, L. García and J. Figueras.
A Test Case + Mock Class Generator for Coding Against Interfaces Mainul Islam, Christoph Csallner Software Engineering Research Center (SERC) Computer.
CUTE: A Concolic Unit Testing Engine for C Koushik SenDarko MarinovGul Agha University of Illinois Urbana-Champaign.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
Selected Decision Procedures and Techniques for SMT More on combination – theories sharing sets – convex theory Un-interpreted function symbols (quantifier-free.
HW7: Due Dec 5th 23:59 1.Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
On the Relation Between Simulation-based and SAT-based Diagnosis CMPE 58Q Giray Kömürcü Boğaziçi University.
Bit-Vector Optimization ALEXANDER NADER AND VADIM RYVCHIN INTEL TACAS 2016.
Satisfiability Modulo Theories and DPLL(T) Andrew Reynolds March 18, 2015.
SAT for Software Model Checking Introduction to SAT-problem for newbie
Logical path planning Róbert Baláž Technical University of Košice
SS 2017 Software Verification Bounded Model Checking, Outlook
Satisfiability Modulo Theories
SMT-Based Verification of Parameterized Systems
Solving Linear Arithmetic with SAT-based MC
Automating Induction for Solving Horn Clauses
Introduction to Software Verification
Satisfiability Modulo Theories
LPSAT: A Unified Approach to RTL Satisfiability
Complexity 6-1 The Class P Complexity Andrei Bulatov.
Graphs and Algorithms (2MMD30)
CS21 Decidability and Tractability
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
Presentation transcript:

Satisfiability Modulo Theories (An introduction) Magnus Madsen

What are SMT solvers? How are they used in practice? Todays Talk What are SMT solvers? How are they used in practice?

Knowledge of prop. logic Motivation Find 𝒙 and 𝒚 s.t.: 𝑥≥3∧ 𝑥≤0∨𝑦≥0 𝑥≥3∧𝑥≤0 ∨ 𝑥≥3∧𝑦≥0 𝑥=3∧𝑦=0 Knowledge of prop. logic Knowledge of integers Knowledge of integers Solution

What is SMT? Satisfiability Modulo Theories +

What is a SMT instance? A logical formula built using negation, conjunction and disjuction e.g. 𝑎∧ 𝑏∨𝑐 e.g. 𝑎∨¬𝑏∨𝑐 ∧ ¬𝑏∨¬𝑥∨𝑦 ∧ 𝑏∨𝑏∨𝑥 theory specific operators e.g. 𝑥≤5, 𝑦≠𝑧 e.g. 𝑚⊕𝑛 ⊕𝑛=𝑚 e.g. 𝑓 𝑥 =𝑓(𝑦)∧𝑓(𝑓 𝑥 )≠𝑓(𝑓 𝑦 ) k-SAT theory of bitwise operators theory of integers theory of uninterpreted functions

Recall k-SAT The Boolean SATisfiability Problem: 𝑎∨¬𝑏∨𝑐 ∧ ¬𝑏∨¬𝑥∨𝑦 ∧ 𝑏∨𝑏∨𝑥 ∧… 2SAT is solveable in polynomial time 3SAT is NP-complete (solveable in exponential time) clause literal or negated literal

Q: Why not encode every formula in SAT? A: Theory solvers have very efficient algorithms Graph Problems: Shortest-Path Minimum Spanning Tree Optimization: Max-Flow Linear Programming (just to name a few)

Q: But then, Why not get rid of the SAT solver? A: SAT solvers are very good at case analysis

SAT Theory Formula 𝑥≥3∧ 𝑥≤0∨𝑦≥0 SMT Solver 𝑥≥3∧𝑥≤0 𝑎∧ 𝑏∨𝑐 𝑥≥3∧𝑦≥0 𝑎∧𝑏 YES 𝑎∧𝑐 NO NO YES 𝑥=3 𝑦=0 add clause: ¬ 𝑎∧𝑏

Important Properties Efficiency of both SAT and Theory solver! SAT Solver Incremental (supports adding new clauses) Theory Solver Ability to construct blocking clauses Ability to create so-called "theory lemmas"

Theories Theory of: Difference Arithemetic Linear Arithmetic Arrays Bit Vectors Algebraic Datatypes Uninterpreted Functions

SMT-LIB A modeling language for SMT instances A declarative language with Lisp-like syntax Defines common/shared terminology e.g. LRA = Closed linear formulas in linear real arithmetic e.g. QF_BC = Closed quantifier-free formulas over the theory of fixed-size bitvectors. http://www.smtlib.org/

Example 1 𝒙=𝟑∧𝒚=𝟎 Solution

Example 2

Applications Dynamic Symbolic Execution Program Verification Extended Static Checking Model Checking Termination Analysis See Also: Tapas: Theory Combinations and Practical Applications

Dynamic Symbolic Execution combines dynamic and symbolic execution step 1: execute the program recording the branches taken and their symbolic constraints step 2: negate one constraint step 3: solve the constraints to generate new input to the program (e.g. by using a SMT solver) step 4: if a solution exists then execute the program on the new input

Program Path ¬𝑐 1 Negate ¬𝑐 3 𝑐 2 ¬𝑐 3 Run SMT Solver 𝑐 4

New Program Path ¬𝑐 1 𝑐 2 𝑐 3 𝑐 5

Example: Greatest Common Divisor Original program SSA unfolding int gcd(int x, int y) { while (true) { int m = x % y; if (m == 0) return y; x = y; y = m; } int result = gcd(2, 4) int gcd(int x0, int y0) { while (true) { int m0 = x0 % y0; assert(m0 != 0) if (m0 == 0) return y0; x1 = y0; y1 = m0; int m1 = x1 % y1; assert(m1 == 0) if (m1 == 0) return y1; }

Collecting Constraints Collected constraints SSA unfolding int result = gcd(2, 4) (assert (= m0 (mod x0 y0))) (assert (not (= m0 0))) (assert (= x1 y0)) (assert (= y1 m0)) (assert (= m1 (mod x1 y1))) (assert (= m1 0)) int gcd(int x0, int y0) { while (true) { int m0 = x0 % y0; assert(m0 != 0) if (m0 == 0) return y0; x1 = y0; y1 = m0; int m1 = x1 % y1; assert(m1 == 1) if (m1 == 0) return y1; } (assert (not (= m1 0)))

Computing a new path Solution: x = 2 and y = 3 int gcd(int x, int y) { while (true) { int m = x % y; if (m == 0) return y; x = y; y = m; } Solution: x = 2 and y = 3 Iteration 1: x = 2 & y = 3 Iteration 2: x = 3 & y = 2 Iteration 3: x = 2 & y = 1

Program Verification Assertion Violation: low = 230, high = 230+1 int binary_search(int[] arr, int low, int height, int key) { assert(low > high || 0 <= < high); while (low <= high) { // Find middle value int mid = (low + high) / 2; assert(0 <= mid < high); int val = arr[mid]; // Refine range if (key == val) return mid; if (val > key) low = mid + 1; else high = mid – 1; } return -1; Assertion Violation: low = 230, high = 230+1

SMT Solvers Z3 MathSAT5 CVC4 Many more Microsoft Research University of Trento CVC4 New York University Many more

SMT-COMP A yearly competition between SMT solvers Z3

Research Directions in SMT Improving the efficiency of SAT/Theory solvers Improving the interplay between the SAT solver and the theory solver e.g. "online" solvers (partial truth assignment) Developing solvers for new theories Combining different theories

With Thanks to Evan Driscoll

References Satisfiability Modulo Theories: Introduction and Applications Leonardo De Moura & Nikolaj Bjørner Tapas: Theory Combinations and Practical Applications Z3 Tutorial Guide http://rise4fun.com/z3/tutorial/guide

Summary Satisfiability Modulo Theory (SMT): constraint systems involving SAT + Theory SMT solvers combine the best of: SAT solvers and theory solvers SMTs have applications in program analysis

More Work To Be Done?