motivation no formal theory motivation no formal theory
play

Motivation: No Formal Theory Motivation: No Formal Theory Master - PowerPoint PPT Presentation

On the Nature of Symbolic Execution 1 Frank de Boer (Joint work with Marcello Bonsangue) IFIP WG 2.2, 2019 1 FM 2019 Motivation: No Formal Theory Motivation: No Formal Theory Master course at Leiden University Motivation: No Formal Theory


  1. On the Nature of Symbolic Execution 1 Frank de Boer (Joint work with Marcello Bonsangue) IFIP WG 2.2, 2019 1 FM 2019

  2. Motivation: No Formal Theory

  3. Motivation: No Formal Theory Master course at Leiden University

  4. Motivation: No Formal Theory Master course at Leiden University Tools ◮ No formal specification (of correctness/completeness)

  5. Basic Symbolic Execution

  6. Basic Symbolic Execution Programming expressions e := x | op ( e 1 , . . . , e n ) where x is a simple variable of a basic type.

  7. Basic Symbolic Execution Programming expressions e := x | op ( e 1 , . . . , e n ) where x is a simple variable of a basic type. Substitution σ : Var → Expr x σ = σ ( x ) op ( e 1 , . . . , e n ) σ = op ( e 1 σ, . . . , e n σ )

  8. Basic Symbolic Execution Programming expressions e := x | op ( e 1 , . . . , e n ) where x is a simple variable of a basic type. Substitution σ : Var → Expr x σ = σ ( x ) op ( e 1 , . . . , e n ) σ = op ( e 1 σ, . . . , e n σ ) Symbolic configuration � S , σ, φ � where ◮ S denotes the statement to be executed, ◮ σ denotes the current substitution, ◮ Boolean condition φ denotes the path condition.

  9. Symbolic Transition System

  10. Symbolic Transition System Assignment � x = e ; S , σ, φ � → � S , σ [ x = e σ ] , φ � where σ [ x = e ]( y ) = σ ( y ) if x and y are distinct variables, and σ [ x = e ]( x ) = e otherwise.

  11. Symbolic Transition System Assignment � x = e ; S , σ, φ � → � S , σ [ x = e σ ] , φ � where σ [ x = e ]( y ) = σ ( y ) if x and y are distinct variables, and σ [ x = e ]( x ) = e otherwise. Choice ◮ � if B { S 1 }{ S 2 } ; S , σ, φ � → � S 1 ; S , σ, φ ∧ B σ � ◮ � if B { S 1 }{ S 2 } ; S , σ, φ � → � S 2 ; S , σ, φ ∧ ¬ B σ �

  12. Symbolic Transition System Assignment � x = e ; S , σ, φ � → � S , σ [ x = e σ ] , φ � where σ [ x = e ]( y ) = σ ( y ) if x and y are distinct variables, and σ [ x = e ]( x ) = e otherwise. Choice ◮ � if B { S 1 }{ S 2 } ; S , σ, φ � → � S 1 ; S , σ, φ ∧ B σ � ◮ � if B { S 1 }{ S 2 } ; S , σ, φ � → � S 2 ; S , σ, φ ∧ ¬ B σ � Iteration ◮ � while B { S } ; S ′ , σ, φ � → � S ; while B { S } ; S ′ , σ, φ ∧ B σ � ◮ � while B { S } ; S ′ , σ, φ � → � S ′ , σ, φ ∧ ¬ B σ �

  13. Correctness

  14. Correctness Concrete transitions � S , V � → � S ′ , V ′ � where V : Var → Val

  15. Correctness Concrete transitions � S , V � → � S ′ , V ′ � where V : Var → Val Theorem If � S , id , true � → ∗ � S ′ , σ, φ � and V ( φ ) = true then � S , V � → ∗ � S ′ , V ◦ σ � where V ◦ σ ( x ) = V ( σ ( x )) .

  16. Completeness

  17. Completeness Relating symbolic and concrete configurations � S , V � ≃ � S , σ, φ � if V = V 0 ◦ σ and V 0 ( φ ) = true , for some valuation V 0 .

  18. Completeness Relating symbolic and concrete configurations � S , V � ≃ � S , σ, φ � if V = V 0 ◦ σ and V 0 ( φ ) = true , for some valuation V 0 . Theorem (simulation) � S , V � ≃ � S , σ, φ � and � S , V � → � S ′ , V ′ � implies the existence of a corresponding symbolic transition � S , σ, φ � → � S ′ , σ ′ , φ ′ � such that � S ′ , V ′ � ≃ � S ′ , σ ′ , φ ′ � .

  19. OO

  20. OO Variables ◮ Global variables (main statement) ◮ Local variables (formal parameters of methods) ◮ Instance variables (class definitions)

  21. OO Variables ◮ Global variables (main statement) ◮ Local variables (formal parameters of methods) ◮ Instance variables (class definitions) Programming expressions e := x | op ( e 1 , . . . , e n ) (In the main statement only global variables are used).

  22. OO Variables ◮ Global variables (main statement) ◮ Local variables (formal parameters of methods) ◮ Instance variables (class definitions) Programming expressions e := x | op ( e 1 , . . . , e n ) (In the main statement only global variables are used). Syntax of heap variables H and heap expressions E H := x | H . y E := H | op ( E 1 , . . . , E n ) , where x is a global variable.

  23. Symbolic Heap Representation

  24. Symbolic Heap Representation Symbolic heap σ σ denotes a substitution which assigns to each heap variable H a heap expression E .

  25. Symbolic Heap Representation Symbolic heap σ σ denotes a substitution which assigns to each heap variable H a heap expression E . Local environment τ τ denotes a substitution which assigns to each formal parameter x a heap expression E .

  26. Symbolic Heap Representation Symbolic heap σ σ denotes a substitution which assigns to each heap variable H a heap expression E . Local environment τ τ denotes a substitution which assigns to each formal parameter x a heap expression E . Application substitution θ = τ ∪ σ x θ = σ ( x ) global variable x θ = τ ( x ) local variable x θ = σ ( τ ( this ) . x ) instance variable op ( E 1 , . . . , E n ) θ = op ( E 1 θ, . . . , E n θ )

  27. Symbolic Heap Update

  28. Symbolic Heap Update Update global variable ◮ σ [ x = E ]( x ) = E ◮ σ [ x = E ]( H ) = σ ( H ) , for any other heap variable H

  29. Symbolic Heap Update Update global variable ◮ σ [ x = E ]( x ) = E ◮ σ [ x = E ]( H ) = σ ( H ) , for any other heap variable H Update instance variable ◮ σ [ H . x = E ]( H ′ . x ) = if σ ( H ′ ) = σ ( H ) then E else σ ( H ′ . x ) fi ◮ σ [ H . x = E ]( H ′ ) = σ ( H ′ ) , for any other heap variable H ′

  30. Symbolic Transition System

  31. Symbolic Transition System Assignment global variable � ( ⊥ , x = e ; S ) , σ, φ � → � ( ⊥ , S ) , σ [ x = e σ ] , φ �

  32. Symbolic Transition System Assignment global variable � ( ⊥ , x = e ; S ) , σ, φ � → � ( ⊥ , S ) , σ [ x = e σ ] , φ � Assignment instance variable � ( τ, x = e ; S ) · Σ , σ, φ � → � ( τ, S ) · Σ , σ [ τ ( this ) . x = e θ ] , φ � where θ = τ ∪ σ .

  33. Symbolic Transition System Assignment global variable � ( ⊥ , x = e ; S ) , σ, φ � → � ( ⊥ , S ) , σ [ x = e σ ] , φ � Assignment instance variable � ( τ, x = e ; S ) · Σ , σ, φ � → � ( τ, S ) · Σ , σ [ τ ( this ) . x = e θ ] , φ � where θ = τ ∪ σ . Object creation � ( τ, x = new C ; S ) · Σ , σ, φ � → � ( τ [ x = y ] , S ) · Σ , σ ′ , φ � where σ ′ ( y . z ) = nil .

  34. Symbolic Transition System (Cont’d)

  35. Symbolic Transition System (Cont’d) Method call Given a method declaration m (¯ u ) { S } , we have � ( τ, y = e 0 . m (¯ e ); S ′ ) · Σ , σ, φ � → � ( τ ′ . S ) · ( τ, y =?; S ′ ) · Σ , σ, φ ′ � where ◮ τ ′ (¯ u ) = ¯ e ( τ ∪ σ ) ◮ τ ′ ( this ) = e 0 ( τ ∪ σ )

  36. Symbolic Transition System (Cont’d) Method call Given a method declaration m (¯ u ) { S } , we have � ( τ, y = e 0 . m (¯ e ); S ′ ) · Σ , σ, φ � → � ( τ ′ . S ) · ( τ, y =?; S ′ ) · Σ , σ, φ ′ � where ◮ τ ′ (¯ u ) = ¯ e ( τ ∪ σ ) ◮ τ ′ ( this ) = e 0 ( τ ∪ σ ) Method return � ( τ, return e ) · ( τ ′ , x =?; S ) · Σ , σ, φ � → � ( τ ′ [ x = e θ ] , S ) · Σ , σ, φ � where θ = ( τ ∪ σ ) .

  37. Concrete Transition System

  38. Concrete Transition System Valuation ◮ V ( H ) = V ( H ′ ) implies V ( H . x ) = V ( H ′ . x ) , ◮ V ( x ) � = V ( x ′ ) , for any two distinct global variables x and x ′ which do not appear in the main statement ( unique name assumption ).

  39. Concrete Transition System Valuation ◮ V ( H ) = V ( H ′ ) implies V ( H . x ) = V ( H ′ . x ) , ◮ V ( x ) � = V ( x ′ ) , for any two distinct global variables x and x ′ which do not appear in the main statement ( unique name assumption ). Heap update � v if V ( H ′ ) = V ( H ) ◮ V [ H . x = v ]( H ′ . x ) = V ( H ′ . x ) otherwise ◮ V [ H . x = v ]( H ′ ) = V ( H ′ ) , for any other heap variable H ′ .

  40. Concrete Transition System Valuation ◮ V ( H ) = V ( H ′ ) implies V ( H . x ) = V ( H ′ . x ) , ◮ V ( x ) � = V ( x ′ ) , for any two distinct global variables x and x ′ which do not appear in the main statement ( unique name assumption ). Heap update � v if V ( H ′ ) = V ( H ) ◮ V [ H . x = v ]( H ′ . x ) = V ( H ′ . x ) otherwise ◮ V [ H . x = v ]( H ′ ) = V ( H ′ ) , for any other heap variable H ′ . Assignment instance variable � ( L , x = e ; S ) · Σ , V � → � ( L , S ) · Σ , V [ H . x = v ] � where V ( H ) = L ( this ) and v = ( L ∪ V )( e ) .

  41. Correctness

  42. Correctness Theorem If � ( ⊥ , S ) , id , true � → ∗ � ( τ, S ′ ) · Σ , σ, φ � and V ( φ ) = true , where V is an initial valuation, then � ( ⊥ , S ) , V � → ∗ � ( V ◦ τ, S ′ ) · V ◦ Σ , V ◦ σ � where ◮ ( V ◦ τ )( x ) = V ( τ ( x )) ◮ ( V ◦ σ )( H ) = V ( σ ( H ))

  43. Conclusion

  44. Conclusion Extensions ◮ Arrays ◮ Multithreading (Java) ◮ Concurrent objects ◮ Concolic execution ◮ Backward symbolic execution

Recommend


More recommend