pmaf an algebraic framework for static analysis of
play

PMAF : AN ALGEBRAIC FRAMEWORK FOR STATIC ANALYSIS OF PROBABILISTIC - PowerPoint PPT Presentation

PMAF : AN ALGEBRAIC FRAMEWORK FOR STATIC ANALYSIS OF PROBABILISTIC PROGRAMS Di Wang 1 , Jan Hoffmann 1 , Thomas Reps 2 1 Carnegie Mellon University 2 University of Wisconsin; GrammaTech, Inc. PROBABILISTIC PROGRAMS Draw random data from


  1. PMAF : AN ALGEBRAIC FRAMEWORK FOR STATIC ANALYSIS OF PROBABILISTIC PROGRAMS Di Wang 1 , Jan Hoffmann 1 , Thomas Reps 2 1 Carnegie Mellon University 2 University of Wisconsin; GrammaTech, Inc.

  2. PROBABILISTIC PROGRAMS Draw random data from distributions Condition control-flow at random

  3. PROBABILISTIC PROGRAMS b1 ~ Bernoulli (0.5); b2 ~ Bernoulli (0.7); while (b1 && b2) do if prob (0.6) then True randomness b1 ~ Bernoulli (0.5) else b2 ~ Bernoulli (0.7) Distributions on executions fi ; tick (1.0) od ; return (b1, b2)

  4. BAYESIAN NETWORKS Conditional distributions Pollution Smoker Query about the posterior Cancer Xray Res Dyspnea

  5. BAYESIAN NETWORKS Conditional distributions Pollution Smoker Query about the posterior Cancer Prob [ Cancer ∣ Smoker ∧ Xray Res ] = ? Xray Res Dyspnea

  6. BAYESIAN NETWORKS AS PROB. PROG. p b1 b2 0.6 0.5 0.7 p b1 b2 0.6 0.5 0.7

  7. BAYESIAN NETWORKS AS PROB. PROG. if prob (0.6) then p b1 ~ Bernoulli (0.5) else b1 b2 0.6 b2 ~ Bernoulli (0.7) fi 0.5 0.7 p b1 b2 0.6 0.5 0.7

  8. BAYESIAN NETWORKS AS PROB. PROG. 0.5 0.7 b1 ~ Bernoulli (0.5); ret b2 ~ Bernoulli (0.7); b1 b2 while (b1 && b2) do if prob (0.6) then b1 ~ Bernoulli (0.5) else && b2 ~ Bernoulli (0.7) fi ; tick (1.0) od ; p p return (b1, b2) b1 b1 b2 b2 0.6 0.6 0.5 0.5 0.7 0.7

  9. BAYESIAN NETWORKS AS PROB. PROG. 0.5 0.7 b1 ~ Bernoulli (0.5); ret b2 ~ Bernoulli (0.7); b1 b2 while (b1 && b2) do if prob (0.6) then b1 ~ Bernoulli (0.5) else && b2 ~ Bernoulli (0.7) fi ; tick (1.0) od ; p p return (b1, b2) b1 b1 b2 b2 0.6 0.6 Query: probability that b1 and b2 are both false ? 0.5 0.5 0.7 0.7

  10. BAYESIAN NETWORKS AS PROB. PROG. 0.5 0.7 b1 ~ Bernoulli (0.5); ret b2 ~ Bernoulli (0.7); b1 b2 while (b1 && b2) do if prob (0.6) then b1 ~ Bernoulli (0.5) else && b2 ~ Bernoulli (0.7) fi ; tick (1.0) od ; p p return (b1, b2) b1 b1 b2 b2 0.6 0.6 Query: expected termination time? 0.5 0.5 0.7 0.7

  11. SAMPLING-BASED TECHNIQUES Simulation & frequency count sample Flexible & universal Potentially unsound & inefficient approximate

  12. SAMPLING-BASED TECHNIQUES Simulation & frequency count sample Flexible & universal Potentially unsound & inefficient approximate What about static analysis ?

  13. ABSTRACT INTERPRETATION Cousot et al. proposed Probabilistic Abstract Interpretation 1 Sound , flexible, and universal 1 P . Cousot and M. Monerau. Probabilistic Abstract Interpretation. In ESOP’12 .

  14. ABSTRACT INTERPRETATION Cousot et al. proposed Probabilistic Abstract Interpretation 1 Sound , flexible, and universal Their concrete semantics resolves probabilities prior to nondeterminism 1 P . Cousot and M. Monerau. Probabilistic Abstract Interpretation. In ESOP’12 .

  15. ABSTRACT INTERPRETATION Cousot et al. proposed Probabilistic Abstract Interpretation 1 Sound , flexible, and universal Their concrete semantics resolves probabilities prior to nondeterminism Sometimes desirable to revolve nondeterminism prior to probabilities 1 P . Cousot and M. Monerau. Probabilistic Abstract Interpretation. In ESOP’12 .

  16. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi

  17. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi with prob. 1 4

  18. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi

  19. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi with prob. 1 4

  20. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi

  21. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi with prob. 1 4

  22. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi

  23. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi with prob. 1 4

  24. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi

  25. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi else if prob (0.5) then tick (1.0) else tick (2.0) fi fi Their concrete semantics yields 𝔽 [ T ] ∈ 1 4 ⋅ {1} + 1 4 ⋅ {2} + 1 4 ⋅ {1,2} + 1 4 ⋅ {1,2} = {1.25,1.5,1.75}

  26. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi Identical! else if prob (0.5) then tick (1.0) else tick (2.0) fi fi Their concrete semantics yields 𝔽 [ T ] ∈ 1 4 ⋅ {1} + 1 4 ⋅ {2} + 1 4 ⋅ {1,2} + 1 4 ⋅ {1,2} = {1.25,1.5,1.75}

  27. COUSOT ET AL.’S SEMANTICS * denotes nondeterministic choice tick(q) increases by q T if * then if prob (0.5) then tick (1.0) else tick (2.0) fi Identical! else if prob (0.5) then tick (1.0) else tick (2.0) fi fi Their concrete semantics yields 𝔽 [ T ] ∈ 1 4 ⋅ {1} + 1 4 ⋅ {2} + 1 4 ⋅ {1,2} + 1 4 ⋅ {1,2} = {1.25,1.5,1.75} while our semantics yields 𝔽 [ T ] = 1.5

  28. CONTRIBUTIONS A denotational semantics with nondeterminism resolved first An algebraic framework for interprocedural dataflow analysis of first-order probabilistic programs PMAF Recursion Unstructured control-flow Divergence Nondeterminism …

  29. CONTRIBUTIONS A denotational semantics with nondeterminism resolved first An algebraic framework for interprocedural dataflow analysis of first-order probabilistic programs PMAF

  30. CONTRIBUTIONS A denotational semantics with nondeterminism resolved first An algebraic framework for interprocedural dataflow analysis of first-order probabilistic programs PMAF Implement Prove Design

  31. CONTRIBUTIONS A denotational semantics with nondeterminism resolved first An algebraic framework for interprocedural dataflow analysis of first-order probabilistic programs PMAF

  32. CONTRIBUTIONS A denotational semantics with nondeterminism resolved first An algebraic framework for interprocedural dataflow analysis of first-order probabilistic programs Existing PMAF Bayesian Inference Markov Decision Problem

  33. CONTRIBUTIONS A denotational semantics with nondeterminism resolved first An algebraic framework for interprocedural dataflow analysis of first-order probabilistic programs Existing New PMAF Bayesian Inference Expectation-Invariant Analysis Markov Decision Problem

  34. EXAMPLE ANALYSES b1 ~ Bernoulli (0.5); Our framework can be b2 ~ Bernoulli (0.7); instantiated to prove : while (b1 && b2) do if prob (0.6) then b1 ~ Bernoulli (0.5) the probability that b1 and b2 else are both false at the end of b2 ~ Bernoulli (0.7) the program = 0.15 fi ; tick (1.0) the expected termination time od ; (ticks) = 5/6 return (b1, b2)

  35. OVERVIEW Motivation The Algebraic Framework Hyper-Graph Analysis Evaluation

  36. THE ALGEBRAIC FRAMEWORK Any static analysis method performs reasoning in some space of program properties and property operations Sequencing Cond.-choice Actions Prob.-choice Semantic Nondet.-choice skip Function Program x := x + 5 Properties b ~ Bernoulli (0.4) tick (1.0) …

  37. THE ALGEBRAIC FRAMEWORK Concrete Concrete Semantic Function Semantics Actions Concrete Operations skip Sound x := x + 5 Abstraction b ~ Bernoulli (0.4) tick (1.0) Abstract … Abstract Semantic Abstract Operations Function Semantics

  38. THE ALGEBRAIC FRAMEWORK Characterize program properties and property operations by algebraic laws

  39. THE ALGEBRAIC FRAMEWORK Characterize program properties and property operations by algebraic laws ⟨ M , ⊑ , ⊗ , φ ⋄ , p ⊕ , ⋓ , ⊥ , 1 ⟩

  40. THE ALGEBRAIC FRAMEWORK Characterize program properties and property operations by algebraic laws ⟨ M , ⊑ , ⊗ , φ ⋄ , p ⊕ , ⋓ , ⊥ , 1 ⟩ Program properties and approximation order

  41. THE ALGEBRAIC FRAMEWORK Characterize program properties and property operations by algebraic laws ⟨ M , ⊑ , ⊗ , φ ⋄ , p ⊕ , ⋓ , ⊥ , 1 ⟩ Program properties and approximation order Sequencing, cond.-choice, prob.-choice, and nondet.-choice

Recommend


More recommend