smt style program analysis with value based refinements
play

SMT-Style Program Analysis with Value-based Refinements Vijay - PowerPoint PPT Presentation

SMT-Style Program Analysis SMT-Style Program Analysis with Value-based Refinements Vijay DSilva Leopold Haller Daniel Kr oning NSV-3 July 15, 2010 SMT-Style Program Analysis Outline Imprecision and Refinement in Abstract


  1. SMT-Style Program Analysis SAT Style Abstract Analysis Value-based Trace Partitionings ◮ If the abstract transformer ˆ F is too imprecise, find a set of transformers ˆ F 1 , . . . , ˆ F k , such that � γ ( µ X . ˆ F i ( X )) ⊇ µ X . F ( X ) 1 ≤ i ≤ k ◮ This can be done by clipping the analysis by an abstract element: F i = ˆ ˆ F ⊓ a i = +

  2. SMT-Style Program Analysis SAT Style Abstract Analysis Value-based Trace Partitionings New question:

  3. SMT-Style Program Analysis SAT Style Abstract Analysis Value-based Trace Partitionings New question: How can we find such a set of elements a 1 , . . . , a k ?

  4. SMT-Style Program Analysis SAT Style Abstract Analysis Value-based Trace Partitionings New question: How can we find such a set of elements a 1 , . . . , a k ? Use the search architecture of a SAT solver!

  5. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL framework DPLL procedure Conflict learn propagate decide backtrack

  6. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL framework DPLL procedure Conflict learn propagate decide backtrack ◮ Main phases of the DPLL procedure:

  7. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL framework DPLL procedure Conflict learn propagate decide backtrack ◮ Main phases of the DPLL procedure: Decision Assume a value for an undetermined variable

  8. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL framework DPLL procedure Conflict learn propagate decide backtrack ◮ Main phases of the DPLL procedure: Decision Assume a value for an undetermined variable Propagation Deduce implied variable values

  9. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL framework DPLL procedure Conflict learn propagate decide backtrack ◮ Main phases of the DPLL procedure: Decision Assume a value for an undetermined variable Propagation Deduce implied variable values Learning Learn reason for conflict and backtrack

  10. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL framework DPLL procedure Conflict learn propagate decide backtrack ◮ Main phases of the DPLL procedure: Decision Assume a value for an undetermined variable Propagation Deduce implied variable values Learning Learn reason for conflict and backtrack

  11. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL Procedure Is φ ( x , y , z ) satisfiable?

  12. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL Procedure Is φ ( x , y , z ) satisfiable? Decision x = 1

  13. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL Procedure Is φ ( x , y , z ) satisfiable? Propagation x = 1 z = 0

  14. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL Procedure Is φ ( x , y , z ) satisfiable? Decision x = 1 z = 0 y = 1

  15. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL Procedure Is φ ( x , y , z ) satisfiable? Propagation x = 1 z = 0 y = 1 z = 1

  16. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL Procedure Is φ ( x , y , z ) satisfiable? Propagation x = 1 z = 0 y = 1 z = 1 Conflict

  17. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL Procedure Is φ ( x , y , z ) satisfiable? Learning x = 1 z = 0 y = 1 z = 1

  18. SMT-Style Program Analysis SAT Style Abstract Analysis DPLL Procedure Is φ ( x , y , z ) satisfiable? Learning x = 0

  19. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis SAT-Style Program Analysis Safety proven generalize clipped fixpoint decide backtrack

  20. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis SAT-Style Program Analysis Safety proven generalize clipped fixpoint decide backtrack Decision Refine current element a by a ′ ⊏ a

  21. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis SAT-Style Program Analysis Safety proven generalize clipped fixpoint decide backtrack Decision Refine current element a by a ′ ⊏ a Propagation Compute clipped fixpoint µ X . ˆ T ( X ) ⊓ a ′

  22. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis SAT-Style Program Analysis Safety proven generalize clipped fixpoint decide backtrack Decision Refine current element a by a ′ ⊏ a Propagation Compute clipped fixpoint µ X . ˆ T ( X ) ⊓ a ′ Learning Find a ′′ ⊒ a ′ , such that µ X . ˆ F ( X ) ⊓ a ′′ is safe.

  23. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Decision Initially, a = ⊤ ⊤ ⊤ A 1 A 2 A 3 A 4 B 1 B 2 B 3 B 4 B 5 C 1 C 2 C 3 C 4 ⊥

  24. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Propagation µ X . ˆ Initially, a = ⊤ ⊤ ⊤ F ( X ) not safe A 1 A 2 A 3 A 4 B 1 B 2 B 3 B 4 B 5 C 1 C 2 C 3 C 4 ⊥

  25. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Decision ⊤ ⊤ A 1 A 1 A 2 A 3 A 4 Decision: refine a B 1 B 2 B 3 B 4 B 5 C 1 C 2 C 3 C 4 ⊥

  26. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Propagation ⊤ ⊤ µ X . (ˆ A 1 A 1 A 2 A 3 A 4 Decision: refine a F ( X ) ⊓ A 1 ) not safe B 1 B 2 B 3 B 4 B 5 C 1 C 2 C 3 C 4 ⊥

  27. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Decision ⊤ ⊤ A 1 A 1 A 2 A 3 A 4 Decision: refine a B 1 B 2 B 2 B 3 B 4 B 5 C 1 C 2 C 3 C 4 ⊥

  28. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Propagation ⊤ ⊤ A 1 A 1 A 2 A 3 A 4 µ X . (ˆ Decision: refine a B 1 B 2 B 2 B 3 B 4 B 5 F ( X ) ⊓ B 2 ) safe C 1 C 2 C 3 C 4 ⊥

  29. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Generalization ⊤ A 1 A 1 A 2 A 3 A 4 B 1 B 2 B 2 B 3 B 4 B 5 C 1 C 2 C 3 C 4 ⊥

  30. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Generalization ⊤ A 1 A 1 A 2 A 2 A 3 A 4 µ X . ˆ B 1 B 2 B 2 B 3 B 4 B 5 F ( X ) ⊓ A 2 safe C 1 C 2 C 3 C 4 ⊥

  31. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Generalization ⊤ A 1 A 1 A 2 A 2 A 3 A 4 µ X . ˆ B 1 B 2 B 2 B 3 B 4 B 5 F ( X ) ⊓ A 2 safe C 1 C 2 C 3 C 4 ⊥

  32. SMT-Style Program Analysis SAT Style Abstract Analysis SAT-Style Program Analysis Generalization ⊤ Backtrack and continue A 1 A 1 A 2 A 2 A 3 A 4 B 1 B 2 B 2 B 3 B 3 B 4 B 5 C 1 C 1 C 2 C 2 C 3 C 3 C 4 ⊥ ⊥

  33. SMT-Style Program Analysis SAT Style Abstract Analysis Comments on Analysis ◮ When can we efficiently prove safety with this?

  34. SMT-Style Program Analysis SAT Style Abstract Analysis Comments on Analysis ◮ When can we efficiently prove safety with this? ◮ When there is a small and finite number of elements a 1 , . . . , a k such that the fixpoints µ X . (ˆ F ( X ) ⊓ a i ) can be put together to form a concrete postfixpoint.

  35. SMT-Style Program Analysis SAT Style Abstract Analysis Comments on Analysis ◮ When can we efficiently prove safety with this? ◮ When there is a small and finite number of elements a 1 , . . . , a k such that the fixpoints µ X . (ˆ F ( X ) ⊓ a i ) can be put together to form a concrete postfixpoint. ◮ Specific implementation issues: ◮ Generalization step ◮ Decision heuristic

  36. SMT-Style Program Analysis Value-based Refinement for Intervals Value-based Refinement for Intervals We have created a preliminary instantiation of this framework for the domain of intervals.

  37. SMT-Style Program Analysis Value-based Refinement for Intervals Value-based Refinement for Intervals We have created a preliminary instantiation of this framework for the domain of intervals. Decision : Choose an initial assignment for all variables

  38. SMT-Style Program Analysis Value-based Refinement for Intervals Value-based Refinement for Intervals We have created a preliminary instantiation of this framework for the domain of intervals. Decision : Choose an initial assignment for all variables Propagation : Compute forward interpretation for this initial value

  39. SMT-Style Program Analysis Value-based Refinement for Intervals Value-based Refinement for Intervals We have created a preliminary instantiation of this framework for the domain of intervals. Decision : Choose an initial assignment for all variables Propagation : Compute forward interpretation for this initial value Generalization and Learning : Generalize the result by locally generalizing intervals. Re- move generalized initial values from selection pool

  40. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Decision Choose initial: x = 0 , y = 0 [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0);

  41. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Propagation Choose initial: x = 0 , y = 0 [x > 5] [x<= 5] x = 0 , y = 0 ⊥ y:=-1 y:=1 x = 0 , y = 1 assert(y!=0); x = 0 , y = 1

  42. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Generalization Choose initial: x = 0 , y = 0 [x > 5] [x<= 5] x = 0 , y = 0 ⊥ y:=-1 y:=1 x = 0 , y = 1 assert(y!=0); ⊤

  43. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Generalization Choose initial: x = 0 , y = 0 [x > 5] [x<= 5] x = 0 , y = 0 ⊥ y:=-1 y:=1 y > 0 assert(y!=0); ⊤

  44. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Generalization Choose initial: x = 0 , y = 0 [x > 5] [x<= 5] x = 0 , y = 0 ⊥ y:=-1 y:=1 y > 0 assert(y!=0); ⊤

  45. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Generalization Choose initial: x = 0 , y = 0 [x > 5] [x<= 5] ⊥ ⊤ y:=-1 y:=1 y > 0 assert(y!=0); ⊤

  46. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Generalization Generalized init: x ≤ 5 [x > 5] [x<= 5] ⊥ ⊤ y:=-1 y:=1 y > 0 assert(y!=0); ⊤

  47. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Decision ¬ x ≤ 5 Choose initial: x = 8 , y = 0 [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0);

  48. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Propagation ¬ x ≤ 5 Choose initial: x = 8 , y = 0 [x > 5] [x<= 5] x = 8 , y = 0 ⊥ y:=-1 y:=1 x = 8 , y = − 1 assert(y!=0); x = 8 , y = − 1

  49. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Generalization ¬ x ≤ 5 Generalized init: x > 5 [x > 5] [x<= 5] ⊤ ⊥ y:=-1 y:=1 y < 0 assert(y!=0); ⊤

  50. SMT-Style Program Analysis Value-based Refinement for Intervals Example 1 Generalization ¬ x ≤ 5 ¬ x > 5 [x > 5] [x<= 5] y:=-1 y:=1 assert(y!=0);

  51. SMT-Style Program Analysis Value-based Refinement for Intervals Example 2 x = 0 , y = 1 Decision x:=y [x<5] [x>=5] assert(y<5)

  52. SMT-Style Program Analysis Value-based Refinement for Intervals Example 2 Propagation x = 0 , y = 1 x:=y x = 1 , y = 1 [x<5] x = 1 , y = 1 [x>=5] assert(y<5) x = 1 , y = 1

  53. SMT-Style Program Analysis Value-based Refinement for Intervals Example 2 Generalized init: y < 5 Generalization x:=y y < 5 [x<5] y < 5 [x>=5] assert(y<5) ⊤

  54. SMT-Style Program Analysis Value-based Refinement for Intervals Example 2 ¬ y < 5 Generalization x:=y [x<5] [x>=5] assert(y<5)

  55. SMT-Style Program Analysis Value-based Refinement for Intervals Example 2 ¬ y < 5 x = 0 , y = 6 Decision x:=y [x<5] [x>=5] assert(y<5)

  56. SMT-Style Program Analysis Value-based Refinement for Intervals Example 2 ¬ y < 5 Propagation x = 0 , y = 6 x:=y x = 6 , y = 6 [x<5] [x>=5] ⊥ assert(y<5) x = 6 , y = 6

  57. SMT-Style Program Analysis Value-based Refinement for Intervals Example 2 ¬ y < 5 Generalized init: y ≥ 5 Generalization x:=y x ≥ 5 [x<5] y < 5 [x>=5] assert(y<5) ⊤

  58. SMT-Style Program Analysis Value-based Refinement for Intervals Example 2 ¬ y < 5 ¬ y ≥ 5 x:=y [x<5] [x>=5] assert(y<5)

  59. SMT-Style Program Analysis Value-based Refinement for Intervals Notes on Implementation ◮ Initial values chosen by call to a SAT solver.

  60. SMT-Style Program Analysis Value-based Refinement for Intervals Notes on Implementation ◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP): ◮ Set every location to ⊤ ◮ For each invalid triple { pre } stmt { post } ◮ repair with { pre } from forward analysis. ◮ generalize using search on bounds.

  61. SMT-Style Program Analysis Value-based Refinement for Intervals Notes on Implementation ◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP): ◮ Set every location to ⊤ ◮ For each invalid triple { pre } stmt { post } ◮ repair with { pre } from forward analysis. ◮ generalize using search on bounds. ◮ Generalization step: 0 ≤ a ≤ 5 , b > 5 , c < 10 Repair using SAT solver assert(a <= 10 || a >= -10) b > 5

  62. SMT-Style Program Analysis Value-based Refinement for Intervals Notes on Implementation ◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP): ◮ Set every location to ⊤ ◮ For each invalid triple { pre } stmt { post } ◮ repair with { pre } from forward analysis. ◮ generalize using search on bounds. ◮ Generalization step: 0 ≤ a ≤ 5 , b > 5 , c < 10 Repair using SAT solver Increase bounds by search assert(a <= 10 || a >= -10) b > 5

  63. SMT-Style Program Analysis Value-based Refinement for Intervals Notes on Implementation ◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP): ◮ Set every location to ⊤ ◮ For each invalid triple { pre } stmt { post } ◮ repair with { pre } from forward analysis. ◮ generalize using search on bounds. ◮ Generalization step: 0 ≤ a ≤ ∞ , b > 5 , c < 10 Repair using SAT solver Increase bounds by search assert(a <= 10 || a >= -10) b > 5

  64. SMT-Style Program Analysis Value-based Refinement for Intervals Notes on Implementation ◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP): ◮ Set every location to ⊤ ◮ For each invalid triple { pre } stmt { post } ◮ repair with { pre } from forward analysis. ◮ generalize using search on bounds. ◮ Generalization step: 0 ≤ a ≤ ∞ , b > 5 , c < 10 Repair using SAT solver Increase bounds by search assert(a <= 10 || a >= -10) b > 5

  65. SMT-Style Program Analysis Value-based Refinement for Intervals Notes on Implementation ◮ Initial values chosen by call to a SAT solver. ◮ Generalization uses local repair (SMPP): ◮ Set every location to ⊤ ◮ For each invalid triple { pre } stmt { post } ◮ repair with { pre } from forward analysis. ◮ generalize using search on bounds. ◮ Generalization step: − 10 ≤ a ≤ ∞ , b > 5 , c < 10 Repair using SAT solver Increase bounds by search assert(a <= 10 || a >= -10) b > 5

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend