Automating Regression Verification
Dennis Felsing, Sarah Grebing, Vladimir Klebanov, Mattias Ulbrich, Philipp R¨ ummer 2014-07-23
1 / 16
Automating Regression Verification Dennis Felsing , Sarah Grebing, - - PowerPoint PPT Presentation
Automating Regression Verification Dennis Felsing , Sarah Grebing, Vladimir Klebanov, Mattias Ulbrich, Philipp R ummer 2014-07-23 1 / 16 Introduction How to prevent regressions in software development? 2 / 16 Introduction How to prevent
Dennis Felsing, Sarah Grebing, Vladimir Klebanov, Mattias Ulbrich, Philipp R¨ ummer 2014-07-23
1 / 16
2 / 16
Formal Verification
Formally prove correctness of software ⇒ Requires formal specification
Regression Testing
Discover new bugs by testing for them ⇒ Requires test cases
2 / 16
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
2 / 16
Formally prove there are no new bugs
programming language using SMT solvers
3 / 16
1 Overapproximation using Uninterpreted Functions 2 Approximation using Uninterpreted Predicates 3 Results and Future Work
4 / 16
1 Overapproximation using Uninterpreted Functions 2 Approximation using Uninterpreted Predicates 3 Results and Future Work
5 / 16
Existing approach by Strichman & Godlin
Function f (val n1; ret r1) Function f without recursion Static Single Assignment Sf Function g (val n2; ret r2) Function g without recursion Static Single Assignment Sg (n1 = n2 ∧ Sf ∧ Sg) → r1 = r2 Valid / Invalid Equivalent? Uninterpreted Function U for recursive calls in both f and g SMT Solver
6 / 16
Function f (val n1; ret r1) Sf Function g (val n2; ret r2) Sg (n1 = n2 ∧ Sf ∧ Sg) → r1 = r2 Valid / Invalid Single Static Assignment Form Equivalent? SMT Solver
7 / 16
Function f (val n1; ret r1) Sf Function g (val n2; ret r2) Sg (n1 = n2 ∧ Sf ∧ Sg) → r1 = r2 Valid / Invalid Equivalent! Single Static Assignment Form Equivalent? SMT Solver
7 / 16
Function f (val n1; ret r1) Sf Function g (val n2; ret r2) Sg (n1 = n2 ∧ Sf ∧ Sg) → r1 = r2 Valid / Invalid Equivalent! Counterexample: n = 0: r1 = −1 r2 = −3 Single Static Assignment Form Equivalent? SMT Solver
7 / 16
Function f (val n1; ret r1) Sf Function g (val n2; ret r2) Sg (n1 = n2 ∧ Sf ∧ Sg) → r1 = r2 Valid / Invalid Equivalent! Counterexample: n = 0: r1 = −1 r2 = −3 f (0) = g(0) = 0 Single Static Assignment Form Equivalent? SMT Solver Execute
7 / 16
Function f (val n1; ret r1) Sf Function g (val n2; ret r2) Sg (n1 = n2 ∧ Sf ∧ Sg∧ U(0) = 0 ) → r1 = r2 Valid / Invalid Equivalent! Counterexample: n = 0: r1 = −1 r2 = −3 f (0) = g(0) = 0 Single Static Assignment Form Equivalent? rerun SMT Solver Execute Add
7 / 16
Approach
function ⇒ Is a simple form of Counter Example Guided Abstraction Refinement (CEGAR)
Successful when
imply equivalence
8 / 16
1 Overapproximation using Uninterpreted Functions 2 Approximation using Uninterpreted Predicates 3 Results and Future Work
9 / 16
First approach (just shown)
∀U.constraints(U) ∧ Sf ∧ Sg ∧ ... → r1 = r2
New approach
∃C.(C(...) ∧ ... → r1 = r2) ∧ “C couples f and g”
automatically find such a C or prove that is does not exist ⇒ Example will show loops with coupling loop invariants
10 / 16
int f1 ( int n) { int r = 0; i f (n == 0) return 1; while (n > 0) { n /= 10; r++; } return r ; }
11 / 16
int f1 ( int n) { int r = 0; i f (n == 0) return 1; while (n > 0) { n /= 10; r++; } return r ; } int f2 ( int n) { int r = 1; while ( true ) { i f (n < 10) return r ; i f (n < 100) return r +1; i f (n < 1000) return r +2; i f (n < 10000) return r +3; n /= 10000; r += 4; } }
11 / 16
Loop synchronisation
f1 f2
gives equal output
12 / 16
Loop synchronisation
f1 f2
gives equal output
12 / 16
Loop synchronisation
f1 f2
gives equal output
12 / 16
Loop synchronisation
f1 f2
gives equal output
12 / 16
Loop synchronisation
f1 f2
gives equal output
synchronised
12 / 16
Loop synchronisation
f1 f2
C
gives equal output
synchronised
12 / 16
Loop synchronisation
f1 f2
C
gives equal output
synchronised ⇒ Use C as loop invariant for both programs. (→coupling invariant)
12 / 16
Loop synchronisation
f1 f2
C
gives equal output
synchronised ⇒ Use C as loop invariant for both programs. (→coupling invariant)
12 / 16
Loop synchronisation
f1 f2
=
C
gives equal output
synchronised ⇒ Use C as loop invariant for both programs. (→coupling invariant)
12 / 16
Loop synchronisation
f1 f2
=
C C
gives equal output
synchronised ⇒ Use C as loop invariant for both programs. (→coupling invariant)
12 / 16
Loop synchronisation
f1 f2
=
C C C
gives equal output
synchronised ⇒ Use C as loop invariant for both programs. (→coupling invariant)
12 / 16
Loop synchronisation
f1 f2
=
C C C
gives equal output
synchronised ⇒ Use C as loop invariant for both programs. (→coupling invariant)
Automatic Regression Verification:
Do not specify C but infer it automatically.
12 / 16
Three cases to consider:
1 Initially coupling loop invariant C holds 2 After both loop steps (or one if other finished), C holds 3 After both loops finished, C implies equality of results
13 / 16
Three cases to consider:
1 Initially coupling loop invariant C holds 2 After both loop steps (or one if other finished), C holds 3 After both loops finished, C implies equality of results
Automatically inferred coupling loop invariant: (Using Eldarica)
(n1 > 0 → (n1 = n2 ∧ r1 + 1 = r2)) ∧(n2 ≤ 0 → return2 = r1) ∧n1 ≥ n2
13 / 16
Three cases to consider:
1 Initially coupling loop invariant C holds 2 After both loop steps (or one if other finished), C holds 3 After both loops finished, C implies equality of results
Automatically inferred coupling loop invariant: (Using Eldarica)
(n1 > 0 → (n1 = n2 ∧ r1 + 1 = r2)) ∧(n2 ≤ 0 → return2 = r1) ∧n1 ≥ n2
10r
13 / 16
1 Overapproximation using Uninterpreted Functions 2 Approximation using Uninterpreted Predicates 3 Results and Future Work
14 / 16
Approaches implemented for a subset of C: simplRV, Rˆ eve Usable with webinterface: http://formal.iti.kit.edu/ improve/deduktionstreffen2014/
Rˆ eve evaluation (uninterpreted predicates)
15 / 16
Regression Verification
techniques in SMT solvers like Eldarica and Z3
Future Work
16 / 16