what is static analysis by abstract interpretation
play

What is static analysis by abstract interpretation? Example of - PowerPoint PPT Presentation

What is static analysis by abstract interpretation? Example of static analysis (input) {n0>=0} n := n0; {n0=n,n0>=0} i := n; {n0=i,n0=n,n0>=0} while (i <> 0 ) do {n0=n,i>=1,n0>=i} j := 0; {n0=n,j=0,i>=1,n0>=i}


  1. Prefix trace semantics Trace semantics: maximal finite and infinite behaviors Prefix trace semantics: finite prefixes of the maximal be- haviors

  2. Abstraction This is an abstraction. For example: Trace semantics: f a n b j n – 0 g Prefix trace semantics: f a n j n – 0 g[f a n b j n – 0 g Is there of possible behavior with infinitely many succes- sive a ? – Trace semantics: no – Prefix trace semantics: I don’t know

  3. Prefix trace semantics in fixpoint form

  4. Least Fixpoint Prefix Trace Semantics Prefixes = f› j › is an initial state g [ f› ` ` ` ` ` ` › ` ` ` › j › ` ` ` ` ` ` › 2 Prefixes : : : : : : & › ` ` ` › is a transition step g › In general, the equation Prefixes = F ( Prefixes ) may have multiple solutions; › Choose the least one for subset inclusion „ . › Abstractions of this equation lead to effective iterative analysis algorithms.

  5. Collecting semantics

  6. Collecting semantics – Collect all states that can appear on some trace at any given discrete time: � � ������ � � ��������� � � ����������� ��������� � � � � � � � � � � � � � � � � �� � � � �������� ���� � �

  7. Collecting abstraction – This is an abstraction. Does the red trace exists? Trace semantics: no, collecting semantics: I don’t know. �������������� � � ������ � � ��������� � � ����������� ��������� � � � � � � � � � � � � � � � � �� � � � �������� ���� � �

  8. Graphic example: collecting semantics x ( t ) t

  9. Collecting semantics in fixpoint form

  10. Graphic example: collecting semantics in fixpoint form x ( t ) t

  11. Graphic example: collecting semantics in fixpoint form x ( t ) t

  12. Graphic example: collecting semantics in fixpoint form x ( t ) t

  13. Graphic example: collecting semantics in fixpoint form x ( t ) t

  14. Graphic example: collecting semantics in fixpoint form x ( t ) t

  15. Graphic example: collecting semantics in fixpoint form x ( t ) t

  16. Graphic example: collecting semantics in fixpoint form x ( t ) t

  17. Graphic example: collecting semantics in fixpoint form x ( t ) t

  18. Graphic example: collecting semantics in fixpoint form x ( t ) t

  19. Graphic example: collecting semantics in fixpoint form x ( t ) t

  20. Graphic example: collecting semantics in fixpoint form x ( t ) t

  21. Graphic example: collecting semantics in fixpoint form x ( t ) t

  22. Graphic example: collecting semantics in fixpoint form x ( t ) t

  23. Graphic example: collecting semantics in fixpoint form x ( t ) t

  24. Interval Abstraction (in iterative fixpoint form)

  25. Graphic example: traces of intervals in fixpoint form x ( t ) t

  26. Graphic example: traces of intervals in fixpoint form x ( t ) t

  27. Graphic example: traces of intervals in fixpoint form x ( t ) t

  28. Graphic example: traces of intervals in fixpoint form x ( t ) t

  29. Graphic example: traces of intervals in fixpoint form x ( t ) t

  30. Graphic example: traces of intervals in fixpoint form x ( t ) t

  31. Graphic example: traces of intervals in fixpoint form x ( t ) t

  32. Graphic example: traces of intervals in fixpoint form x ( t ) t

  33. Graphic example: traces of intervals in fixpoint form x ( t ) t

  34. Graphic example: traces of intervals in fixpoint form x ( t ) t

  35. Graphic example: traces of intervals in fixpoint form x ( t ) t

  36. Graphic example: traces of intervals in fixpoint form x ( t ) t

  37. Graphic example: traces of intervals in fixpoint form x ( t ) t

  38. Graphic example: traces of intervals in fixpoint form x ( t ) t

  39. Graphic example: traces of intervals in fixpoint form x ( t ) t

  40. Abstraction by Galois connections

  41. Abstracting sets (i.e. properties) – Choose an abstract domain, replacing sets of objects (states, traces, . . . ) S by their abstraction ¸ ( S ) – The abstraction function ¸ maps a set of concrete ob- jects to its abstract interpretation; – The inverse concretization function ‚ maps an abstract set of objects to concrete ones; – Forget no concrete objects: (abstraction from above) S „ ‚ ( ¸ ( S )) .

  42. Interval abstraction ¸ � �� f x : [1 ; 99] ; y : [2 ; 77] g � � � ��

  43. Interval concretization ‚ � �� f x : [1 ; 99] ; y : [2 ; 77] g � � � ��

  44. The abstraction ¸ is monotone � �� �� f x : [33 ; 89] ; y : [48 ; 61] g v �� f x : [1 ; 99] ; y : [2 ; 90] g � � � �� �� �� X „ Y ) ¸ ( X ) v ¸ ( Y )

  45. The concretization ‚ is monotone f x : [33 ; 89] ; y : [48 ; 61] g v f x : [1 ; 99] ; y : [2 ; 90] g X v Y ) ‚ ( X ) „ ‚ ( Y )

  46. The ‚ ‹ ¸ composition is extensive � �� f x : [1 ; 99] ; y : [2 ; 77] g � � �� � X „ ‚ ‹ ¸ ( X )

  47. The ¸ ‹ ‚ composition is reductive � �� f x : [1 ; 99] ; y : [2 ; 77] g = = v f x : [1 ; 99] ; y : [2 ; 77] g � � � �� ¸ ‹ ‚ ( Y ) = = v Y

  48. Correspondance between concrete and abstract properties – The pair h ¸; ‚ i is a Galois connection: ‚ ` ` ` h } ( S ) ; „i ` hD ; vi ` ` ! ¸ ‚ ` ` ` ` – h } ( S ) ; „i ` hD ; vi when ¸ is onto (equivalently ` `! ` ! ¸ ¸ ‹ ‚ = 1 or ‚ is one-to-one).

  49. Galois connection ‚ ` ` ` hD ; „i ` hD ; vi ` ` ! ¸ iff 8 x; y 2 D : x „ y = ) ¸ ( x ) v ¸ ( y ) ^ 8 x; y 2 D : x v y = ) ‚ ( x ) „ ‚ ( y ) ^ 8 x 2 D : x „ ‚ ( ¸ ( x )) ^ 8 y 2 D : ¸ ( ‚ ( y )) v x iff 8 x 2 D ; y 2 D : ¸ ( x ) v y ( ) x „ ‚ ( y )

  50. Example: Set of traces to trace of intervals abstraction Set of traces: ¸ 1 # Trace of sets: ¸ 2 # Trace of intervals

  51. Example: Set of traces to reachable states abstraction Set of traces: ¸ 1 # Trace of sets: ¸ 3 # Reachable states

  52. Composition of Galois Connections The composition of Galois connections: ‚ 1 ` ` ` h L; »i ` h M; vi ` ` ! ¸ 1 and: ‚ 2 ` ` ` h M; vi ` h N; —i ` ` ! ¸ 2 is a Galois connection: ‚ 1 ‹ ‚ 2 ` ` ` ` ` ` h L; »i ` h N; —i ` ` ` ` ` ! ¸ 2 ‹ ¸ 1

  53. Convergence acceleration by widening/narrowing

  54. Graphic example: upward iteration with widening x ( t ) �������������� t

  55. Graphic example: upward iteration with widening x ( t ) ������������������� t

  56. Graphic example: upward iteration with widening x ( t ) ��������������������������������� t

  57. Graphic example: upward iteration with widening x ( t ) ��������������������������������� t

  58. Graphic example: stability of the upward iteration x ( t ) t

  59. Interval widening – L = f?g[f [ ‘; u ] j ‘; u 2 Z [f`1g^ u 2 Z [fg^ ‘ » u g – The widening extrapolates unstable bounds to infinity: � ? X = X � X ? = X � [ ‘ 0 ; u 0 ] [ ‘ 1 ; u 1 ] = [if ‘ 1 < ‘ 0 then ` 1 else ‘ 0 ; if u 1 > u 0 then + 1 else u 0 ] � Not monotone. For example [0 ; 1] v [0 ; 2] but [0 ; 1] � [0 ; 2] = [0 ; + 1 ] 6v [0 ; 2] = [0 ; 2] [0 ; 2]

  60. Example: Interval analysis (1975) Program to be analyzed: 8 X 1 = [1 ; 1] > > > X 2 = ( X 1 [ X 3 ) \ [ `1 ; 9999] < x := 1; X 3 = X 2 ˘ [1 ; 1] 1: > > X 4 = ( X 1 [ X 3 ) \ [10000 ; + 1 ] > : while x < 10000 do 2: 8 X 1 = [1 ; 1] x := x + 1 > > > X 2 = ( X 1 [ X 3 ) \ [ `1 ; 9999] < 3: X 3 = X 2 ˘ [1 ; 1] od; > > X 4 = ( X 1 [ X 3 ) \ [10000 ; + 1 ] > 4: :

  61. Example: Interval analysis (1975) Equations (abstract interpretation of the semantics): 8 X 1 = [1 ; 1] > > > X 2 = ( X 1 [ X 3 ) \ [ `1 ; 9999] < x := 1; X 3 = X 2 ˘ [1 ; 1] 1: > > X 4 = ( X 1 [ X 3 ) \ [10000 ; + 1 ] > : while x < 10000 do 2: 8 X 1 = [1 ; 1] x := x + 1 > > > X 2 = ( X 1 [ X 3 ) \ [ `1 ; 9999] < 3: X 3 = X 2 ˘ [1 ; 1] od; > > X 4 = ( X 1 [ X 3 ) \ [10000 ; + 1 ] > 4: :

  62. Example: Interval analysis (1975) Resolution by chaotic increasing iteration: 8 X 1 = [1 ; 1] > > > X 2 = ( X 1 [ X 3 ) \ [ `1 ; 9999] < x := 1; X 3 = X 2 ˘ [1 ; 1] 1: > > X 4 = ( X 1 [ X 3 ) \ [10000 ; + 1 ] > : while x < 10000 do 2: 8 X 1 = ; x := x + 1 > > > X 2 = ; < 3: X 3 = ; od; > > X 4 = ; > 4: :

  63. Example: Interval analysis (1975) Increasing chaotic iteration: 8 X 1 = [1 ; 1] > > > X 2 = ( X 1 [ X 3 ) \ [ `1 ; 9999] < x := 1; X 3 = X 2 ˘ [1 ; 1] 1: > > X 4 = ( X 1 [ X 3 ) \ [10000 ; + 1 ] > : while x < 10000 do 2: 8 X 1 = [1 ; 1] x := x + 1 > > > X 2 = ; < 3: X 3 = ; od; > > X 4 = ; > 4: :

  64. Example: Interval analysis (1975) Increasing chaotic iteration: 8 X 1 = [1 ; 1] > > > X 2 = ( X 1 [ X 3 ) \ [ `1 ; 9999] < x := 1; X 3 = X 2 ˘ [1 ; 1] 1: > > X 4 = ( X 1 [ X 3 ) \ [10000 ; + 1 ] > : while x < 10000 do 2: 8 X 1 = [1 ; 1] x := x + 1 > > > X 2 = [1 ; 1] < 3: X 3 = ; od; > > X 4 = ; > 4: :

Recommend


More recommend