Regression Verification: Status Report



Similar documents
A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation

Section IV.1: Recursive Algorithms and Recursion Trees

Static Program Transformations for Efficient Software Model Checking

8 Primes and Modular Arithmetic

Loop Invariants and Binary Search

Solving Rational Equations

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!

Lecture Notes on Linear Search

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Termination Checking: Comparing Structural Recursion and Sized Types by Examples

Boogie: A Modular Reusable Verifier for Object-Oriented Programs

Today s Topics. Primes & Greatest Common Divisors

3. Mathematical Induction

Introduction. Appendix D Mathematical Induction D1

Section 4.2: The Division Algorithm and Greatest Common Divisors

ML for the Working Programmer

QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall

Practice with Proofs

FACTORING LARGE NUMBERS, A GREAT WAY TO SPEND A BIRTHDAY

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Lecture 13 - Basic Number Theory.

Math 55: Discrete Mathematics

Mathematical Induction. Lecture 10-11

Rigorous Software Engineering Hoare Logic and Design by Contracts

Homework until Test #2

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Near Optimal Solutions

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Binary Multiplication

SECTION 10-2 Mathematical Induction

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.

MATH 4330/5330, Fourier Analysis Section 11, The Discrete Fourier Transform

Sources: On the Web: Slides will be available on:

Verification of Imperative Programs in Theorema

What Is Recursion? Recursion. Binary search example postponed to end of lecture

Software Testing & Analysis (F22ST3): Static Analysis Techniques 2. Andrew Ireland

µz An Efficient Engine for Fixed points with Constraints

Introduction to Static Analysis for Assurance

Notes from Week 1: Algorithms for sequential prediction

Linear Programming. March 14, 2014

Why? A central concept in Computer Science. Algorithms are ubiquitous.

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

Chapter 7: Functional Programming Languages

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION

InvGen: An Efficient Invariant Generator

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Introduction to Computers and Programming. Testing

Cassandra. References:

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

CS510 Software Engineering

Pseudo code Tutorial and Exercises Teacher s Version

Model Checking: An Introduction

Software Testing. Quality & Testing. Software Testing

Pretty-big-step semantics

Total Degrees and Nonsplitting Properties of Σ 0 2 Enumeration Degrees

[Refer Slide Time: 05:10]

Lecture 9. Semantic Analysis Scoping and Symbol Table

Outline. 1 Denitions. 2 Principles. 4 Implementation and Evaluation. 5 Debugging. 6 References

Algebra Unpacked Content For the new Common Core standards that will be effective in all North Carolina schools in the school year.

CS 103X: Discrete Structures Homework Assignment 3 Solutions

Introduction to Programming System Design. CSCI 455x (4 Units)

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

8 Divisibility and prime numbers

Formal Verification and Linear-time Model Checking

GameTime: A Toolkit for Timing Analysis of Software

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

csci 210: Data Structures Recursion

minimal polyonomial Example

Cartesian Products and Relations

1 if 1 x 0 1 if 0 x 1

Maple Mini-Course, Summer 2001

CHAPTER SIX IRREDUCIBILITY AND FACTORIZATION 1. BASIC DIVISIBILITY THEORY

Lecture 1: Course overview, circuits, and formulas

Rigorous Software Development CSCI-GA

recursion, O(n), linked lists 6/14

Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006. Final Examination. January 24 th, 2006

Functions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; }

Recursion and Dynamic Programming. Biostatistics 615/815 Lecture 5

How To Write A Program Verification And Programming Book

10.2 Series and Convergence

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Model Driven Security: Foundations, Tools, and Practice

Specification and Analysis of Contracts Lecture 1 Introduction

Lecture 3: Finding integer solutions to systems of linear equations

Vieta s Formulas and the Identity Theorem

Chapter 3. if 2 a i then location: = i. Page 40

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

6.2 Permutations continued

3 Monomial orders and the division algorithm

Proseminar on Semantic Theory Fall 2013 Ling 720. Problem Set on the Formal Preliminaries : Answers and Notes

Programming Languages CIS 443

Transcription:

Regression Verification: Status Report Presentation by Dennis Felsing within the Projektgruppe Formale Methoden der Softwareentwicklung 2013-12-11 1/22

Introduction How to prevent regressions in software development? 2/22

Introduction Formal Verification Formally prove correctness of software Requires formal specification Regression Testing Discover new bugs by testing for them Requires test cases 3/22

Introduction Formal Verification Formally prove correctness of software Requires formal specification Regression Testing Discover new bugs by testing for them Requires test cases Regression Verification Formally prove there are no new bugs 3/22

Project Objectives 1 Develop a tool for Regression Verification for recursive programs in a simple imperative programming language 2 Case study to evaluate how well our approaches work for different examples in comparison to other systems 3 Extend the tool to work with more programs and to be more general 4/22

Preliminary Considerations I Unbounded Integers vs Bit Vectors Unbounded Integers don t overflow Bit Vectors can be limited to simplify the problem Solution: Support both: Proofs are supposed to be over unbounded Integers For comparison Bit Vectors can also be used 5/22

Preliminary Considerations II Division by 0 In Z3, division by zero is allowed, but the result is not specified. Division is not a partial function. Actually, in Z3 all functions are total, although the result may be underspecified in some cases like division by zero. Possible Solutions: Check that there are no divisions by 0 It could be verified that the result is independent of the result of division by 0 6/22

Preliminary Considerations III Array Access over Boundaries Arrays have infinite size in Z3 Possibility: Check array boundaries on every access Programs can be proven to honor array boundaries Solution: Assume programs have been proven to honor array boundaries 7/22

Tool for Regression Verification Overview Function f (val n; ret r) Function f without recursions Equivalent? Uninterpreted Functions Function g (val x; ret y) Function g without recursions Static Single Assignment S f Static Single Assignment S g (n = x S f S g ) r = y SMT Solver Valid / Invalid 8/22

Tool for Regression Verification Formally prove there are no new bugs Goal: Proving the equivalence of two closely related programs No formal specification or test cases required Instead use old program version Make use of similarity between programs 9/22

Formally prove there are no new bugs Tool for Regression Verification Goal: Proving the equivalence of two closely related programs No formal specification or test cases required Instead use old program version Make use of similarity between programs int gcd1( int a, int b) { int g = 0; if (b == 0) { g = a; } else { a = a % b; g = gcd1(b, a); } return g; } int gcd2( int x, int y) { int z = x; if (y > 0) { z = gcd2(y, z % y); } return z; } 9/22

Uninterpreted Functions Overview Function f (val n; ret r) Function f without recursions Equivalent? Uninterpreted Functions Function g (val x; ret y) Function g without recursions Static Single Assignment S f Static Single Assignment S g (n = x S f S g ) r = y SMT Solver Valid / Invalid 10/22

Uninterpreted Functions Given the same inputs an Uninterpreted Function always returns the same outputs. Motivation: Proof by Induction, to prove f(n) = g(n) assume f(n 1) = g(n 1) int gcd1( int a, int b) { int g = 0; if (b == 0) { g = a; } else { a = a % b; g = U (b, a); } return g; } int gcd2( int x, int y) { int z = x; if (y > 0) { z = U (y, z % y); } return z; } 11/22

Conversion of Programs to Formulae Overview Function f (val n; ret r) Function f without recursions Equivalent? Uninterpreted Functions Function g (val x; ret y) Function g without recursions Static Single Assignment S f Static Single Assignment S g (n = x S f S g ) r = y Valid / Invalid SMT Solver 12/22

General idea Conversion of Programs to Formulae I Walk Abstract Syntax Tree of both programs Convert every SimPL construct to SMT formula: int x = y; declare fun x 0 () Int assert (x 0 = y i ) if (y) { x = b; } else { x = c; }. assert ( x i = b) assert (x ( i+1) = c) assert (x ( i+2) = ( ite y x i x ( i +1))) ; Phi node Use new variable for every assignment 13/22

Conversion of Programs to Formulae II Regression Verification Uninterpreted Functions: assert ( forall ((u Int ) (v Int ) ((gcd1 u v) = (gcd2 u v)))) Proof f = g: assert (not ( gcd1 result = gcd2 result )) check sat get model exit Objective Regression Verification proofs : Done 14/22

Case Study Done Collect examples: Papers, Refactoring Rules,... 51 program pairs so far Planned Framework for testing them Check how well extensions work More (interesting) examples Objective Case Study : Work in Progress 15/22

Convert Loops to Recursions Idea Convert every loop to a new recursive function Handling multiple loop variables: Return a tuple while (x < 10) { y = y + x; x = x 1; } Initial work (x,y) = loop(x,y); Added tuples to SimPL grammar and AST. tuple loop(int x, int y) { if (x < 10) { y = y + x; x = x 1; (x,y) = loop(x,y); } return (x,y); } 16/22

Idea Specify how often a function call is inlined: y = f (x) inline 3; Same for loops (converted to functions): while (x < y) inline 5 { z; } Possibility later: Inlining strategies Function Inlining Initial work Modified grammar to support inlining 17/22

Abstraction Refinement I Recursive Functions are the main problem Two ways of dealing with them: Most general abstraction Classical Regression Verification approach Uninterpreted functions x : f(x) = g(x) No further information about the functions Only works when the function bodies are equivalent 18/22

No abstraction Give recursive definition: Abstraction Refinement II forall x. f (n) = let r0 = 0 r1 = n r2 = f (n 1) r3 = n + r2 r4 = ite (n <= 1, r1, r3) in r4 Experiments for a few simple functions Only works when the function bodies differ for finite number of inputs 19/22

Abstraction Refinement III Problem: Find an abstraction inbetween CEGAR Loop Counter Example Guided Abstraction Refinement Start with simple over-approximation Extract patterns from counter examples Refine Abstraction Repeat if proof still fails 20/22

Abstraction Refinement IV Problem: Find an abstraction inbetween Horn Clauses (p q t) u Postcondition PC is true after recursive call r = f(n) PC(n,r) Solver figures out Postcondition on its own (e.g. using CEGAR) 21/22

Summary Regression Verification Prove that two similar programs are equivalent Better chance of being adopted than Formal Verification More powerful than Regression Testing Project Status 1 Develop Regression Verification tool: Basic tool: Done Loops to Recursions: WIP Function Inlining: WIP 2 Case study to compare approaches: WIP 3 Extend tool: Planning and Experimentation 22/22