the key platform for verification and analysis of java
play

The KeY Platform for Verification and Analysis of Java Programs - PowerPoint PPT Presentation

The KeY Platform for Verification and Analysis of Java Programs Reiner H ahnle Technische Universit at Darmstadt Department of Computer Science, Software Engineering Group Dagstuhl Seminar 16131: Language Based Verification Tools for


  1. The KeY Platform for Verification and Analysis of Java Programs Reiner H¨ ahnle Technische Universit¨ at Darmstadt Department of Computer Science, Software Engineering Group Dagstuhl Seminar 16131: Language Based Verification Tools for Functional Programs

  2. Joint Work with. . . Wolfgang Ahrendt, Bernhard Beckert, Richard Bubel, Christoph Gladisch, Daniel Grahl, Sarah Grebing, Martin Hentschel, Mihai Herda, Vladimir Klebanov, Wojciech Mostowski, Christoph Scheben, Peter H. Schmitt, Mattias Ulbrich, Nathan Wasser and many others over the last 12 years

  3. The KeY Platform

  4. The KeY Platform Target Languages ◮ sequential Java ◮ without floats, reflexion, lambdas

  5. The KeY Platform Properties ◮ functional correctness ◮ framing ◮ information flow ◮ resource consumption

  6. The KeY Platform Threorem Proving Test Cases Symbolic Execution Engine for Debugging Dynamic Logic Counter Examples Visualization

  7. Deductive Verification of OO-Programs The Ke Y Approach Program Theorem Prover File.java Proof Obligation DL Formula Generator Specification ?

  8. Deductive Verification of OO-Programs The Ke Y Approach Program Theorem Prover File.java Proof Obligation DL Formula Generator Specification ?

  9. Formal Specification of OO-Programs Program Specification Follows design-by-contract methodology ◮ Behavior of programs specified on level of classes and methods ◮ Contracts are used to specify methods ◮ precondition must be established by caller ◮ postcondition guaranteed by callee if precondition holds at invocation time ◮ Invariants attached to classes to specify ◮ global system properties ◮ data consistency properties

  10. The Java Modeling Language (JML) A Specification Language for Java Sum and Maximum (VSComp 2010) ◮ Description: Given an N -element array of natural numbers, write a program to compute the sum and the maximum of the elements in the array. ◮ Properties: Given that N ≥ 0 and a [ i ] ≥ 0 for 0 ≤ i < N , prove the post-condition that sum ≤ N · max . ❝❧❛ss SumAndMax { ✐♥t sum; ✐♥t max; /*@ normal_behaviour @ r❡q✉✐r❡s ( ❭❢♦r❛❧❧ ✐♥t i; 0 <= i && i < a.length; 0 <= a[i]); @ ❛ss✐❣♥❛❜❧❡ sum, max; @ ❡♥s✉r❡s ( ❭❢♦r❛❧❧ ✐♥t i; 0 <= i && i < a.length; a[i] <= max); @ ❡♥s✉r❡s ( ❭❡①✐sts ✐♥t i; 0 <= i && i < a.length; max == a[i]); @ ❡♥s✉r❡s sum == ( ❭s✉♠ ✐♥t i; 0 <= i && i < a.length; a[i]); @ ❡♥s✉r❡s sum <= a.length * max; @*/ ✈♦✐❞ sumAndMax( ✐♥t [] a) { ... } }

  11. Deductive Verification of OO-Programs The Ke Y Approach Program Theorem Prover File.java Proof Obligation DL Formula Generator Specification ?

  12. Java Dynamic Logic

  13. Java Dynamic Logic FOL ∃ x .φ

  14. Java Dynamic Logic Modal logic ∃ x . ♦� φ

  15. Java Dynamic Logic Multi-modal logic ∃ x . ♦ ∗ � ♥ φ

  16. Java Dynamic Logic Dynamic logic ∃ x . � x < 0? y := − x ; x ≥ 0? y := x � y ≥ 0

  17. Java Dynamic Logic Java DL � for (Integer i: c) y+= i*i; � y ≥ 0

  18. Java Dynamic Logic Java DL with updates ∃ s : java . util . Set . { c := s } � for (Integer i: c) y+= i*i; � y ≥ 0

  19. Java Dynamic Logic Java DL with updates ∃ s : java . util . Set . { c := s } � for (Integer i: c) y+= i*i; � y ≥ 0 ◮ � p � φ : Program p terminates and formula φ holds in its final state. ◮ [ p ] φ : If program p terminates then formula φ holds in the final state.

  20. Java DL

  21. Java DL Hoare logic vs. DL { φ } P { ψ } can be represented as φ → [ P ] ψ

  22. Java DL Hoare logic vs. DL { φ } P { ψ } can be represented as φ → [ P ] ψ Multiple programs: Noninterference “Self composition” (Darvas, H¨ ahnle, Sands 2003) ∀ sec 1 , sec 2 , in , out 1 , out 2 . ( { x := sec 1 � y := in } [ P ] res = out 1 ∧ { x := sec 2 � y := in } [ P ] res = out 2 → out 1 = out 2 )

  23. Deductive Verification of OO-Programs The Ke Y Approach Program Theorem Prover File.java Proof Obligation DL Formula Generator Specification ?

  24. Dynamic Logic Calculus Analysis Technique: Sequent Calculus realizes symbolic interpreter

  25. Dynamic Logic Calculus Analysis Technique: Sequent Calculus realizes symbolic interpreter ifStatement Γ , b . Γ , b . = true = ⇒ [ p; rest ] φ, ∆ = false = ⇒ [ q; rest ] φ, ∆ Γ = ⇒ [ if (b) { p } else { q }; rest ] φ, ∆ Γ , { x := e } = ⇒ [ rest ] φ, ∆ simpleAssigment Γ = ⇒ [ x = e; rest ] φ, ∆ Γ = ⇒ [ if(b) {p; while(b) p} rest ] φ, ∆ unwindLoop Γ = ⇒ [ while(b) p rest ] φ, ∆

  26. Proof Construction x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x )

  27. Proof Construction x > y = ⇒ { y := y + x } [ x=y-x; y-=x; ]( y > x ) x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x )

  28. Proof Construction x > y = ⇒ { y := y + x }{ x := y − x } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x } [ x=y-x; y-=x; ]( y > x ) x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x )

  29. Proof Construction x > y = ⇒ { y := y + x || x := y } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x }{ x := y − x } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x } [ x=y-x; y-=x; ]( y > x ) x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x )

  30. Proof Construction x > y = ⇒ { y := y + x || x := y }{ y := y − x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x }{ x := y − x } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x } [ x=y-x; y-=x; ]( y > x ) x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x )

  31. Proof Construction x > y = ⇒ { x := y || y := x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y }{ y := y − x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x }{ x := y − x } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x } [ x=y-x; y-=x; ]( y > x ) x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x )

  32. Proof Construction x > y = ⇒ { x := y || y := x } ( y > x ) x > y = ⇒ { x := y || y := x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y }{ y := y − x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x }{ x := y − x } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x } [ x=y-x; y-=x; ]( y > x ) x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x )

  33. Proof Construction x > y = ⇒ x > y x > y = ⇒ { x := y || y := x } ( y > x ) x > y = ⇒ { x := y || y := x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y }{ y := y − x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x }{ x := y − x } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x } [ x=y-x; y-=x; ]( y > x ) x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x )

  34. Proof Construction x > y = ⇒ x > y x > y = ⇒ { x := y || y := x } ( y > x ) x > y = ⇒ { x := y || y := x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y }{ y := y − x } [ ]( y > x ) x > y = ⇒ { y := y + x || x := y } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x }{ x := y − x } [ y-=x; ]( y > x ) x > y = ⇒ { y := y + x } [ x=y-x; y-=x; ]( y > x ) x > y = ⇒ [ y+=x; x=y-x; y-=x; ]( y > x ) Updates facilitate forward symbolic execution

  35. Symbolic Execution public static int sum( int [] a) throws Exception { if (a == null ) { throw new Exception(); } else { int sum = 0; for ( int i = 0; i < a.length; i++) { sum += a[i]; } return sum; } }

  36. Symbolic Execution public static int sum( int [] a) if (a == null ) throws Exception { a: a0 if (a == null ) { throw new Exception(); } else { int sum = 0; for ( int i = 0; i < a.length; i++) { sum += a[i]; } return sum; } }

  37. Symbolic Execution public static int sum( int [] a) if (a == null ) throws Exception { a: a0 if (a == null ) { a0 = null throw throw new new Exception(); Exception(); } else { a: a0 { a0 = null } int sum = 0; for ( int i = 0; i < a.length; i++) { sum += a[i]; } return sum; } }

  38. Symbolic Execution public static int sum( int [] a) if (a == null ) throws Exception { a: a0 if (a == null ) { a0 = null a0 ≠ null throw throw new int sum = 0; new Exception(); Exception(); } a: a0 { a0 ≠ null } else { a: a0 { a0 = null } int sum = 0; for ( int i = 0; i < a.length; i++) { sum += a[i]; } return sum; } }

  39. Symbolic Execution public static int sum( int [] a) if (a == null ) throws Exception { a: a0 if (a == null ) { a0 = null a0 ≠ null throw throw new int sum = 0; new Exception(); Exception(); } a: a0 { a0 ≠ null } else { a: a0 { a0 = null } int sum = 0; int i = 0; for ( int i = 0; sum: 0 i < a.length; i++) { sum += a[i]; } return sum; } }

  40. Symbolic Execution public static int sum( int [] a) if (a == null ) throws Exception { a: a0 if (a == null ) { a0 = null a0 ≠ null throw throw new int sum = 0; new Exception(); Exception(); } a: a0 { a0 ≠ null } else { a: a0 { a0 = null } int sum = 0; int i = 0; for ( int i = 0; sum: 0 i < a.length; i++) { i < a.length; sum += a[i]; i: 0 } return sum; } }

Recommend


More recommend