newtonian program analysis solving sharir and pnueli s
play

Newtonian Program Analysis: Solving Sharir and Pnuelis Equations - PowerPoint PPT Presentation

Newtonian Program Analysis: Solving Sharir and Pnuelis Equations Javier Esparza Technische Universit at M unchen Joint work with Stefan Kiefer and Michael Luttenberger From programs to equations: Intraprocedural x > 0 x = 0 x x


  1. Newtonian Program Analysis: Solving Sharir and Pnueli’s Equations Javier Esparza Technische Universit¨ at M¨ unchen Joint work with Stefan Kiefer and Michael Luttenberger

  2. From programs to equations: Intraprocedural x > 0 x = 0 x ← x + 1 x < 10 x ≥ 10

  3. From programs to equations: Intraprocedural One-step relations X a , . . . , e ⊆ (I N × I N) a c = { ( x , x + 1) | x ≥ 0 } Y Big-step relations c d b X , Y , Z ⊆ I N × I N X = a · Y + b Z Y = c · Z e Z = d · Y + e

  4. From programs to equations: Intraprocedural One-step relations X a , . . . , e ⊆ (I N × I N) a c = { ( x , x + 1) | x ≥ 0 } Y Big-step relation c d b X ⊆ I N × I N X = a · Y + b Z Y = c · Z e Z = d · Y + e

  5. From programs to equations: Intraprocedural One-step relations X a , . . . , e ⊆ (I N × I N) a c = { ( x , x + 1) | x ≥ 0 } Y Big-step relations c d b X , Y , Z ⊆ I N × I N X = a · Y + b Z Y = c · Z e Z = d · Y + e

  6. From programs to equations: Intraprocedural One-step relations X a , . . . , e ⊆ (I N × I N) a c = { ( x , x + 1) | x ≥ 0 } Y Big-step relations c d b X , Y , Z ⊆ I N × I N X = a · Y + b Z Y = c · Z e Z = d · Y + e

  7. From programs to equations: Intraprocedural Program �→ system X = f ( X ) of linear fixed-point equations Least solution non-computable in general N �→ domain 2 I Program analysis: abstract domain D transformer f �→ abstract transformer f # Sufficient condition for existence of least solution: ( D , + , · ) is a ( ω -continuous) semiring

  8. From programs to equations: Intraprocedural Program �→ system X = f ( X ) of linear fixed-point equations Least solution non-computable in general N �→ domain 2 I Program analysis: abstract domain D transformer f �→ abstract transformer f # Sufficient condition for existence of least solution: ( D , + , · ) is a ( ω -continuous) semiring

  9. From programs to equations: Intraprocedural Program �→ system X = f ( X ) of linear fixed-point equations Least solution non-computable in general N �→ domain 2 I Program analysis: abstract domain D transformer f �→ abstract transformer f # Sufficient condition for existence of least solution: ( D , + , · ) is a ( ω -continuous) semiring

  10. From programs to equations: Intraprocedural Program �→ system X = f ( X ) of linear fixed-point equations Least solution non-computable in general N �→ domain 2 I Program analysis: abstract domain D transformer f �→ abstract transformer f # Sufficient condition for existence of least solution: ( D , + , · ) is a ( ω -continuous) semiring

  11. Quantitative program analysis: Expected time X 0 . 7 Y X = 0 . 7 · Y + 1 1 0 . 6 0 . 3 Y = Z + 1 Z = 0 . 6 · Y + 1 Z 0 . 4

  12. From programs to equations: Interprocedural Q P x > 0 x ≥ 3 x < 3 x = 0 x < 10 call Q call Q call P x ← x ∗ 2 x ≥ 10

  13. From programs to equations: Interprocedural P Q P 0 Q 0 P 0 = a · P 1 + b a e f P 1 = ?? · P 2 Q 1 P 1 Q 2 P 2 = c · P 1 + d c b call Q Q 0 = e · Q 1 + f · Q 2 call Q call P Q 1 = ?? · Q 3 Q 3 P 2 Q 2 = ?? · Q 3 g d Q 3 = g

  14. From programs to equations: Interprocedural P Q P 0 = a · P 1 + b P 0 Q 0 P 1 = ?? · P 2 a e f P 2 = c · P 1 + d Q 1 P 1 Q 2 Q 0 = e · Q 1 + f · Q 2 Q 1 = ?? · Q 3 c b call Q call Q call P Q 2 = ?? · Q 3 Q 3 P 2 Q 3 = g g d

  15. Sharir and Pnueli’s functional approach P Q P 0 = a · P 1 + b P 0 Q 0 Q 0 P 1 = Q 0 · P 2 a e f P 2 = c · P 1 + d Q 1 P 1 Q 2 Q 0 = e · Q 1 + f · Q 2 Q 1 = ?? · Q 3 c b call Q call Q call P Q 2 = ?? · Q 3 Q 3 P 2 Q 3 = g g d

  16. Sharir and Pnueli’s functional approach P Q P 0 = a · P 1 + b P 0 Q 0 Q 0 P 1 = Q 0 · P 2 a e f P 2 = c · P 1 + d Q 1 P 1 Q 2 Q 0 = e · Q 1 + f · Q 2 Q 0 Q 1 = ?? · Q 3 c b call Q call Q call P Q 2 = ?? · Q 3 Q 3 P 2 Q 3 = g g d

  17. Sharir and Pnueli’s functional approach P Q P 0 = a · P 1 + b P 0 Q 0 Q 0 P 1 = Q 0 · P 2 a e f P 2 = c · P 1 + d Q 1 P 1 Q 2 Q 0 = e · Q 1 + f · Q 2 Q 0 Q 1 = ?? · Q 3 c b call Q call Q call P P 0 Q 2 = ?? · Q 3 Q 3 P 2 Q 3 = g g d

  18. Sharir and Pnueli’s interprocedural equations Program �→ system X = f ( X ) of polynomial, non-linear fixed-point equations Least solution non-computable in general N �→ domain 2 I Program analysis: abstract domain D transformer f �→ abstract transformer f # Sufficient condition for existence of least solution: ( D , + , · ) is a ( ω -continuous) semiring

  19. Sharir and Pnueli’s interprocedural equations Program �→ system X = f ( X ) of polynomial, non-linear fixed-point equations Least solution non-computable in general N �→ domain 2 I Program analysis: abstract domain D transformer f �→ abstract transformer f # Sufficient condition for existence of least solution: ( D , + , · ) is a ( ω -continuous) semiring

  20. Solving the equations: Kleene iteration Theorem [Kleene]: The least solution µ f of X = f ( X ) is the supremum of { k i } i ≥ 0 , where = f (0) k 0 = f ( k i ) k i +1 Basic algorithm: compute k 0 , k 1 , k 2 , . . . until either k i = k i +1 , which implies k i = µ f , or the approximation is considered adequate.

  21. Kleene iteration is slow Set domains: Kleene iteration never terminates for X = f ( X ) if least solution µ f is an infinite set. µ f = a ∗ b • X = a · X + b • Kleene approximants are finite sets: k i = ( ǫ + a + . . . + a i ) b Probabilistic interpretation: convergence can be very slow for polynomial equations [EY STACS05]. • X = 1 2 X 2 + 1 µ f = 1 = 0 . 99999 . . . 2 • “Logarithmic convergence”: k iterations to get log k bits of accuracy. 1 k n ≤ 1 − k 2000 = 0 . 9990 n + 1

  22. Kleene Iteration for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  23. Kleene Iteration for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  24. Kleene Iteration for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  25. Kleene Iteration for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  26. Kleene Iteration for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  27. Kleene Iteration for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  28. Kleene Iteration for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  29. Kleene Iteration for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  30. Newton’s Method for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  31. Newton’s Method for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  32. Newton’s Method for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  33. Newton’s Method for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  34. Newton’s Method for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  35. Newton’s Method for X = f ( X ) (univariate case) 1 . 2 1 µ f 0 . 8 f ( X ) 0 . 6 0 . 4 0 . 2 0 0 . 2 0 . 4 0 . 6 0 . 8 1 1 . 2

  36. Kleene vs. Newton Program analysis: • Kleene iteration is applicable to arbitrary ω -continuous semirings • . . . but converges slowly. Numerical mathematics: • Newton’s Method converges fast • . . . but can only be applied to the real field Can Newton’s method be generalized to arbitrary ω -continuous semirings?

  37. Kleene vs. Newton Program analysis: • Kleene iteration is applicable to arbitrary ω -continuous semirings • . . . but converges slowly. Numerical mathematics: • Newton’s Method converges fast • . . . but can only be applied to the real field Can Newton’s method be generalized to arbitrary ω -continuous semirings?

  38. Mathematical formulation of Newton’s Method Elementary analysis yields for the i -th Newton iterant ν i : ν 0 = 0 ν i +1 = ν i + ∆ i where ∆ i least solution of X = Df ν i ( X ) + f ( ν i ) − ν i Df ν i ( X ) differential of f ( X ) at the point ν i

  39. Generalizing Newton’s method X = Df ν ( X ) + f ( ν ) − ν Key point: generalize to arbitrary ω -continuous semirings In an arbitrary ω -continuous semiring • neither the differential Df ν ( X ) , nor • the difference f ( ν ) − ν are defined.

  40. Overcoming the obstacles (1) Use the algebraic definition of differential (recall that we only have polynomial functions!)  0 if f ( X ) = c      if f ( X ) = X X  Df ( X ) = Dg ( X ) + Dh ( X ) if f ( X ) = g ( X ) + h ( X )     Dg ( X ) · h ( X ) + g ( X ) · Dh ( X ) if f ( X ) = g ( X ) · h ( X )   (2) Replace f ( ν i ) − ν i by any δ i such that f ( ν i ) = ν i + δ i Define ∆ i as the least solution of X = Df ν i ( X ) + δ i

Recommend


More recommend