a posteriori soundness for nondeterministic abstract
play

A posteriori soundness for nondeterministic abstract - PowerPoint PPT Presentation

A posteriori soundness for nondeterministic abstract interpretations Matthew Might (University of Utah) Panagiotis Manolios (Northeastern University) Questions you dont want at your defense Questions you dont want at your defense


  1. A posteriori soundness for nondeterministic abstract interpretations Matthew Might (University of Utah) Panagiotis Manolios (Northeastern University)

  2. Questions you don’t want at your defense

  3. Questions you don’t want at your defense • “But, why did you prove it that way?”

  4. Questions you don’t want at your defense • “But, why did you prove it that way?” • “But, why is that necessary ?”

  5. Questions you don’t want at your defense • “But, why did you prove it that way?” • “But, why is that necessary ?” • “So, why did the Cousots do it that way?”

  6. Nondeterministic Abstract Interpretation • Where did it come from? • How do you prove it sound? • Why would you want to use it?

  7. Nondeterministic Abstract Interpretation • Where did it come from? • Frustration with the standard recipe. • How do you prove it sound? • Why would you want to use it?

  8. Nondeterministic Abstract Interpretation • Where did it come from? • Frustration with the standard recipe. • How do you prove it sound? • A posteriori proof technique. • Why would you want to use it?

  9. Nondeterministic Abstract Interpretation • Where did it come from? • Frustration with the standard recipe. • How do you prove it sound? • A posteriori proof technique. • Why would you want to use it? • Better speed, better precision.

  10. Outline • Review standard recipe. • Find annoyances. • Get rid of them.

  11. The Standard Recipe Define concrete state-space: L Define concrete semantics: f : L → L Define abstract state-space: ˆ L Define abstraction map: α : L → ˆ L Define abstract semantics: ˆ f : ˆ L → ˆ L ˆ Prove simulates under . f f α

  12. The A Posteriori Recipe Define concrete state-space: L Define concrete semantics: f : L → L Define abstract state-space: ˆ L Define abstract semantics: ˆ f : ˆ L → ˆ L ℓ ′ = ˆ ˆ f (ˆ Execute abstract semantics to obtain . ℓ ) Define abstraction map: α : L → ˆ L ˆ Prove simulates under . f f α

  13. The A Posteriori Recipe Define concrete state-space: L Define concrete semantics: f : L → L Define abstract state-space: ˆ L Define abstract semantics: ˆ f : ˆ L → ˆ L ℓ ′ = ˆ ˆ f (ˆ Execute abstract semantics to obtain . ℓ ) Define abstraction map: α : L → ˆ L ˆ Prove simulates under . ℓ ′ f α

  14. The A Posteriori Recipe Define concrete state-space: L Define concrete semantics: f : L → L Define abstract state-space: ˆ L ˆ f : ˆ ˆ Define abstract semantics: L L → 2 ℓ ′ = ˆ ˆ f (ˆ Execute abstract semantics to obtain . ℓ ) Define abstraction map: α : L → ˆ L ˆ Prove simulates under . ℓ ′ f α

  15. Illustrating the Standard Recipe

  16. Malloc: The Language v := malloc()

  17. Malloc: The Language lab : v := malloc()

  18. Concrete Semantics State = Instruction × Store

  19. Concrete Semantics State = Instruction × Store f ( ς ) = ς ′

  20. Concrete Semantics State = Instruction × Store Fresh ] : � � i, σ [ v �→ a ′ ]) f ([ [ v := malloc() ] i, σ ) = (

  21. Concrete Semantics State = Instruction × Store Fresh ] : � � i, σ [ v �→ a ′ ]) f ([ [ v := malloc() ] i, σ ) = ( a ′ = alloc( ς )

  22. Concrete Semantics State = Instruction × Store Fresh ] : � � i, σ [ v �→ a ′ ]) f ([ [ v := malloc() ] i, σ ) = ( a ′ = alloc( ς ) = max(range( σ )) + 1

  23. Abstract Semantics State = Instruction × � � Store ˆ ] : � � f ([ [ v := malloc() ] i, ˆ σ ) = ( i, ˆ σ [ v �→ ˆ a ]) a = � (from some finite set) ˆ alloc(ˆ ς )

  24. What to allocate? • Abstract addresses = Scarce resource • Avoid over-allocation: Good for speed • Avoid under-allocation: Good for precision

  25. Example: Over-allocation 3 ˆ a 1 ˆ a 2

  26. Example: Over-allocation 3 ˆ a 1 , 2

  27. Example: Under-allocation 3 a ′ ˆ 4

  28. Example: Under-allocation 3 ˆ a 1 4 ˆ a 2

  29. Allocation heuristics Observation: Objects from like contexts act alike.

  30. Allocation heuristics Observation: Objects from like contexts act alike. � ] : � Example: alloc([ [ lab : . . . ] i, ) = lab

  31. Annoyance: Soundness If α ( ς ) ⊑ ˆ ς then α ( f ( ς )) ⊑ ˆ f (ˆ ς )

  32. Annoyance: Soundness If α ( ς ) ⊑ ˆ ς then α Addr (alloc( ς )) ⊑ � alloc(ˆ ς )

  33. The Issue alloc( , σ ) = max(range( σ )) + 1 � ] : � alloc([ [ lab : . . . ] i, ) = lab What abstraction map will work here?

  34. Example A : x := malloc() B : y := malloc() [x → , y → ] 1 σ = 2 [ → A , → B ] 2 α Addr = 1

  35. Example B : y := malloc() A : x := malloc() [x → , y → ] 1 σ = 2 [ → A , → B ] 2 α Addr = 1

  36. Example B : y := malloc() A : x := malloc() [x → , y → ] 2 σ = 1 [ → A , → B ] 2 α Addr = 1

  37. Example B : y := malloc() A : x := malloc() [x → , y → ] 2 σ = 1 [ → A , → B ] α Addr = 2 1

  38. Standard Solution Change the concrete semantics!

  39. Standard Solution Change the concrete semantics! Addr = N alloc( , σ ) = max(range( σ )) + 1

  40. Standard Solution Change the concrete semantics! Addr = N × Lab alloc([ [ lab : . . . ] ] , σ ) = (max(range( σ ) 1 ) + 1 , lab )

  41. Standard Solution Change the concrete semantics! Addr = N × Lab alloc([ [ lab : . . . ] ] , σ ) = (max(range( σ ) 1 ) + 1 , lab ) α ( , lab ) = lab

  42. Another problem: Heuristics sometimes make stupid decisions

  43. Another problem: Heuristics sometimes make stupid decisions Why not adapt on the fly?

  44. Example: Greedy Strategy Heuristic says, “Allocate , and bind 4.” ˆ a 1 3 ˆ a 1

  45. Example: Greedy Strategy Heuristic says, “Allocate , and bind 4.” ˆ a 1 3 ˆ a 1 4

  46. Example: Greedy Strategy Heuristic says, “Allocate , and bind 4.” ˆ a 1 3 ˆ a 1 4 Adaptive allocator says, “Try first.” r (ˆ a 1 )

  47. Example: Greedy Strategy Heuristic says, “Allocate , and bind 4.” ˆ a 1 3 ˆ a 1 4 r (ˆ a 1 ) Adaptive allocator says, “Try first.” r (ˆ a 1 )

  48. Example: Greedy Strategy Heuristic says, “Allocate , and bind 3.” ˆ a 2 3 ˆ a 1

  49. Example: Greedy Strategy Heuristic says, “Allocate , and bind 3.” ˆ a 2 3 ˆ a 1 ˆ a 2

  50. Example: Greedy Strategy Heuristic says, “Allocate , and bind 3.” ˆ a 2 3 ˆ a 1 ˆ a 2 Adaptive allocator says, “Just use .” ˆ a 1

  51. Example: Greedy Strategy Heuristic says, “Allocate , and bind 3.” ˆ a 2 3 ˆ a 1 Adaptive allocator says, “Just use .” ˆ a 1

  52. Dynamic Optimization Given m abstract addresses, how should they be allocated to maximize precision?

  53. So, why not? Can’t within confines of standard recipe. (Counter-example in paper.)

  54. Making it so

  55. Making it so • Factor allocation out of semantics. • Make allocation nondeterministic. • Prove nondeterministic allocation sound.

  56. Locative = Address (But also times, bindings, contours, etc .)

  57. Factoring out allocation

  58. f : State → State ς

  59. f : State → State ς ′ ς

  60. f : State → State ς

  61. F : State → Loc → State ς

  62. F : State → Loc → State ς

  63. F : State → Loc → State ℓ ς ′ ς

  64. � f : � ˆ State State → 2 ˆ ς

  65. � f : � ˆ State State → 2 ς ′ ˆ ˆ ς ′′ ς ˆ ς ′′′ ˆ

  66. � f : � ˆ State State → 2 ˆ ς

  67. d Loc → � F : � ˆ State State → 2 ˆ ς

  68. d Loc → � F : � ˆ State State → 2 ˆ ς

  69. d Loc → � F : � ˆ State State → 2 ς ′ ˆ ˆ ℓ ′ ˆ ℓ ′′ ˆ ς ′′ ς ˆ ˆ ℓ ′′′ ς ′′′ ˆ

  70. Nondeterministic Abstract Interpretation

  71. Nondeterministic Abstract Interpretation • Sealed abstract transition graphs. • Factored abstraction maps. • A posteriori soundness condition.

  72. Transition Graphs • Nodes = States • Edge = Transition labeled by chosen locative

  73. Sealed Graphs Graph is sealed under factored semantics iff every state has an edge to cover every transition.

  74. Example: Un sealed Graph 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 82 24 26 73 74 75 76 77 78 79 80 81 72 35 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 58 59 60 61 62 71 70 25 69 27 68 28 29 30 31 32 33 34 36 37 57 63 64 65 66 67

  75. Example: Un sealed Graph 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 82 24 26 73 74 75 76 77 78 79 80 81 72 35 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 58 59 60 61 62 71 70 25 69 27 68 28 29 30 31 32 33 34 36 37 57 63 64 65 66 67

  76. ˆ ℓ 1 ˆ ℓ 2 ˆ ς

  77. ˆ h 1 (ˆ ℓ 1 ) ˆ ℓ 1 ˆ ˆ h 2 (ˆ ℓ 2 ℓ 2 ) ˆ ς ς ) = { ˆ h 1 , ˆ h 2 , ˆ ˆ F (ˆ h 3 }

Recommend


More recommend