Regression Verification: Project Proposal Presentation by Dennis - - PowerPoint PPT Presentation

regression verification project proposal
SMART_READER_LITE
LIVE PREVIEW

Regression Verification: Project Proposal Presentation by Dennis - - PowerPoint PPT Presentation

Regression Verification: Project Proposal Presentation by Dennis Felsing within the Projektgruppe Formale Methoden der Softwareentwicklung SS 2013 1 / 18 Introduction How to prevent regressions in software development? 2 / 18 Introduction


slide-1
SLIDE 1

Regression Verification: Project Proposal

Presentation by Dennis Felsing within the Projektgruppe Formale Methoden der Softwareentwicklung SS 2013

1 / 18

slide-2
SLIDE 2

Introduction

How to prevent regressions in software development?

2 / 18

slide-3
SLIDE 3

Introduction

Formal Verification

Formally prove correctness of software ⇒ Requires formal specification

Regression Testing

Discover new bugs by testing for them ⇒ Requires test cases

3 / 18

slide-4
SLIDE 4

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 / 18

slide-5
SLIDE 5

Regression Verification

Overview

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg (n = x ∧ Sf ∧ Sg) → r = y Valid / Invalid Equivalent? Uninterpreted Functions SMT Solver

4 / 18

slide-6
SLIDE 6

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

5 / 18

slide-7
SLIDE 7

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

int f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + f (n − 1 ) ; } return r ; } int g ( int x ) { int y = 0; i f (x ≤ 1) { y = x ; } else { y = x + g ( x − 1 ) ; } return y ; }

5 / 18

slide-8
SLIDE 8

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

int f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + f (n − 1 ) ; } return r ; } int g ( int x ) { int y = 0; i f (x ≤ 1) { y = x ; } else { y = x + g ( x − 1 ) ; } return y ; }

5 / 18

slide-9
SLIDE 9

Uninterpreted Functions

Overview

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg (n = x ∧ Sf ∧ Sg) → r = y Valid / Invalid Equivalent? Uninterpreted Functions SMT Solver

6 / 18

slide-10
SLIDE 10

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 f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + U (n − 1 ) ; } return r ; } int g ( int x ) { int y = 0; i f (x ≤ 1) { y = x ; } else { y = x + U ( x − 1 ) ; } return y ; }

7 / 18

slide-11
SLIDE 11

Static Single Assignment

Overview

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg (n = x ∧ Sf ∧ Sg) → r = y Valid / Invalid Equivalent? Uninterpreted Functions SMT Solver

8 / 18

slide-12
SLIDE 12

Static Single Assignment

  • Translate program functions to formulas
  • Recursions: Abstraction by Uninterpreted Function
  • In assignments x = exp replace x with a new variable x1
  • Represents the states of the program

9 / 18

slide-13
SLIDE 13

Static Single Assignment

  • Translate program functions to formulas
  • Recursions: Abstraction by Uninterpreted Function
  • In assignments x = exp replace x with a new variable x1
  • Represents the states of the program

int f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + U (n − 1 ) ; } return r ; } Sf =     r0 = 0

9 / 18

slide-14
SLIDE 14

Static Single Assignment

  • Translate program functions to formulas
  • Recursions: Abstraction by Uninterpreted Function
  • In assignments x = exp replace x with a new variable x1
  • Represents the states of the program

int f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + U (n − 1 ) ; } return r ; } Sf =     r0 = 0 ∧ n ≤ 0 → r1 = n

9 / 18

slide-15
SLIDE 15

Static Single Assignment

  • Translate program functions to formulas
  • Recursions: Abstraction by Uninterpreted Function
  • In assignments x = exp replace x with a new variable x1
  • Represents the states of the program

int f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + U (n − 1 ) ; } return r ; } Sf =     r0 = 0 ∧ n ≤ 0 → r1 = n ∧ n > 0 → r1 = n + U(n − 1)

9 / 18

slide-16
SLIDE 16

Static Single Assignment

  • Translate program functions to formulas
  • Recursions: Abstraction by Uninterpreted Function
  • In assignments x = exp replace x with a new variable x1
  • Represents the states of the program

int f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + U (n − 1 ) ; } return r ; } Sf =     r0 = 0 ∧ n ≤ 0 → r1 = n ∧ n > 0 → r1 = n + U(n − 1) ∧ r = r1    

9 / 18

slide-17
SLIDE 17

Formula

Overview

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg ( n = x

Equal inputs

∧Sf ∧ Sg) → r = y

Equal outputs

Equivalent? Uninterpreted Functions

10 / 18

slide-18
SLIDE 18

SMT Solver

Overview

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg (n = x ∧ Sf ∧ Sg) → r = y Valid / Invalid Equivalent? Uninterpreted Functions SMT Solver

11 / 18

slide-19
SLIDE 19

Extensions

  • SMT solver still complains:

f (n) = −1 if n = 0 g(n)

  • therwise

12 / 18

slide-20
SLIDE 20

Extensions

  • SMT solver still complains:

f (n) = −1 if n = 0 g(n)

  • therwise

int f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + f (n − 1 ) ; } return r ; } int g ( int x ) { int y = 0; i f ( x ≤ 1) { y = x ; } else { y = x + g ( x − 1 ) ; } return y ; }

12 / 18

slide-21
SLIDE 21

Extensions

  • SMT solver still complains:

f (n) = −1 if n = 0 g(n)

  • therwise

int f ( int n) { int r = 0; i f (n ≤ 0) { r = n ; } else { r = n + f (n − 1 ) ; } return r ; } int g ( int x ) { int y = 0; i f ( x ≤ 1) { y = x ; } else { y = x + g ( x − 1 ) ; } return y ; }

  • But we can fix it:

f (0) = 0

12 / 18

slide-22
SLIDE 22

Extensions

Finding Counter Examples

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg (n = x ∧ Sf ∧ Sg) → r = y Valid / Invalid Counter Example Equivalent? Uninterpreted Functions SMT Solver Execute

13 / 18

slide-23
SLIDE 23

Extensions

Determining Corner Cases

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg (n = x ∧ Sf ∧ Sg∧ U(0) = 0 ) → r = y Valid / Invalid Counter Example Equivalent? Uninterpreted Functions SMT Solver Execute Add

14 / 18

slide-24
SLIDE 24

Extensions

Functional Condition Extraction

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg (n = x ∧ Sf ∧ Sg∧ α ) → r = y Valid / Invalid Functional Condition Equivalent? SMT Solver Add

15 / 18

slide-25
SLIDE 25

Extensions

Relational Equivalence

Function f (val n; ret r) Function f without recursions Static Single Assignment Sf Function g (val x; ret y) Function g without recursions Static Single Assignment Sg ( n ≥ 0 ∧ n = x ∧Sf ∧ Sg) → r ∼ y Valid / Invalid Equivalent? Uninterpreted Functions SMT Solver

16 / 18

slide-26
SLIDE 26

Example Catalog

  • Collect examples: Papers, Refactoring Rules, ...
  • 51 program pairs so far
  • Test how well approach and extensions work

17 / 18

slide-27
SLIDE 27

Conclusion

Regression Verification

  • Better chance of being adopted than Formal Verification
  • More powerful than Regression Testing
  • Extensions to cover more cases
  • Example Catalog for evaluation

18 / 18