calculating graph algorithms for dominance and shortest
play

Calculating Graph Algorithms for Dominance and Shortest Path Ilya - PowerPoint PPT Presentation

Calculating Graph Algorithms for Dominance and Shortest Path Ilya Sergey Jan Midtgaard Dave Clarke MPC 2012 How to derive two graph algorithms by means of Abstract Interpretation ? Abstract Interpretation Abstract Interpretation


  1. Factors R ⊆ A × B S ⊆ B × C T ⊆ A × C Left factor: [ x T/S y ⌘ h8 z : y S z : x T z i ] Right factor: [ x R \ T y ⌘ h8 z : z R x : z T y i ]

  2. A Nice Thing about Factors R ⊆ A × B S ⊆ B × C T ⊆ A × C [ S v γ ( R ) ] α ( S ) R ⇐ ≤ ⇒ [ T/S ⊇ R ⇐ ⇒ S ⊆ R \ T ] γ ( X ) = X\ T α ( X ) = T/ X

  3. A Nice Thing about Factors R ⊆ A × B S ⊆ B × C T ⊆ A × C ( T/ ) = λ X .T/ X ( \ T ) = λ X . X\ T [ S v γ ( R ) ] α ( S ) R ⇐ ≤ ⇒ [ T/S ⊇ R ⇐ ⇒ S ⊆ R \ T ] ( \ T ) � � � � � h ℘ ( B ⇥ C ) , ✓i � h ℘ ( A ⇥ B ) , ◆i � � � � ! ( T/ ) γ ( X ) = X\ T α ( X ) = T/ X

  4. Back to Dominance

  5. Decomposing Dominance [ u dom ( X ) v = h8 σ : σ ∈ X ∧ last ( σ ) = v : u in σ i ] v f ( X ) σ | {z } in /f ( X ) f ( X ) = { σ : σ 2 X : h last ( σ ) , σ i }

  6. Decomposing Dominance dom = ( in / ) � f [ u dom ( X ) v = h8 σ : v f ( X ) σ : u in σ i ] | {z } in /f ( X ) f ( X ) = { σ : σ 2 X : h last ( σ ) , σ i }

  7. Decomposing Dominance dom = ( in / ) � f In the paper Factors ( \ in ) f � � � � � � � � h ℘ ( V + ) ✓i � h ℘ ( last ) , ✓i � h ℘ ( V ⇥ V ) , ◆i h ℘ ( last ) , ✓i � � � � ! � � ! ( in / ) f f ( X ) = { σ : σ 2 X : h last ( σ ) , σ i } dom � � � � h ℘ ( V + ) , ✓i � h ℘ ( V ⇥ V ) , ◆i � � � ! dom

  8. Goals Done 1. Prove a Galois Connection dom � � � � h ℘ ( V + ) , ✓i � h ℘ ( V ⇥ V ) , ◆i � � � ! dom To do F D 2. Find such that dom � p G = F D � dom

  9. 2. Computing a Dominance Functional

  10. dom � p G = ( in / ) � f � p G k ( X ) = { σ , u, v : h u, σ i 2 X ^ ( u ! v ) : h v, σ v i } f � p G = k � f

  11. dom � p G = ( in / ) ( in / ) � k � f � f � p G k ( X ) = { σ , u, v : h u, σ i 2 X ^ ( u ! v ) : h v, σ v i } f � p G = k � f Details in the paper

  12. dom � p G = ( in / ) � k � f F D ( X ) = id ∪ X / pred k ( X ) = { σ , u, v : h u, σ i 2 X ^ ( u ! v ) : h v, σ v i } [ v pred u ≡ u → v ] f � p G = k � f ( in / ) � k = F D � ( in / ) Details in the paper

  13. F D � ( in / ) � f ( in / ) � k � f dom � p G = F D ( X ) = id ∪ X / pred [ v pred u ≡ u → v ] ( in / ) � k = F D � ( in / ) Details in the paper

  14. F D � ( in / ) � f dom � p G = F D � dom F D ( X ) = id ∪ X / pred [ v pred u ≡ u → v ] ( in / ) � k = F D � ( in / ) Details in the paper

  15. dom � p G = F D � dom F D ( X ) = id ∪ X / pred [ v pred u ≡ u → v ] ⇓ ( in / ) � k = F D � ( in / ) dom ( P G ) = lfp ⊇ ( λ X . dom ( { v 0 } ) ∩ F D ( X ))

  16. Goals Done 1. Prove a Galois Connection dom � � � � h ℘ ( V + ) , ✓i � h ℘ ( V ⇥ V ) , ◆i � � � ! dom Done F D 2. Find such that dom � p G = F D � dom

  17. dom ( P G ) = lfp ⊇ ( λ X . dom ( { v 0 } ) ∩ F D ( X ))

  18. Algorithm

  19. Dom( v ) = { u : u dom ( P G ) v : u }

  20. A Straightforward Algorithm for v 2 V do { ⊥  Dom[ v ] V Dom’ dom ( { v 0 } ) \ F D (Dom) dom ( { v 0 } )  while Dom 6 = Dom’ do Dom Dom’ t lfp ( . . . )  Dom’ dom ( { v 0 } ) \ F D (Dom)

  21. Can we do better?

  22. Dominance Equivalences [ u dom ( P G ) v 0 ⇐ ⇒ u = v 0 ] [ u dom ( P G ) v ( ) u = v _ h8 w : w ! v : u dom ( P G ) w i ]

  23. Dominance Equations Dom( v 0 ) = { v 0 } \ Dom( v ) = Dom( w ) ∪ { v } w ∈ pred ( v )

  24. An Optimized Algorithm * for v 2 V do Dom[ v ] V Dom[ v 0 ] { v 0 } Changed true while Changed do Changed false for v 2 V do ⇣T ⌘ newSet w ∈ pred ( v ) Dom[ w ] [ { v } if newSet 6 = Dom[ v ] then Dom[ v ] newSet Changed true * K. D. Cooper, T. J. Harvey, and K. Kennedy. A simple, fast dominance algorithm.

  25. Complexity

  26. { for v 2 V do O ( | V | 2 ) Dom[ v ] V Dom[ v 0 ] { v 0 } Changed true while Changed do Changed false for v 2 V do ⇣T ⌘ newSet w ∈ pred ( v ) Dom[ w ] [ { v } if newSet 6 = Dom[ v ] then Dom[ v ] newSet Changed true

  27. { for v 2 V do O ( | V | 2 ) Dom[ v ] V Dom[ v 0 ] { v 0 } Changed true while Changed do Changed false  for v 2 V do ⇣T ⌘  newSet w ∈ pred ( v ) Dom[ w ] [ { v }   O ( | V | × | E | ) if newSet 6 = Dom[ v ] then Dom[ v ] newSet    Changed true

  28. { for v 2 V do O ( | V | 2 ) Dom[ v ] V Dom[ v 0 ] { v 0 } Changed true  while Changed do  Changed false     for v 2 V do   ⇣T ⌘ O ( | V | 3 × | E | ) newSet w ∈ pred ( v ) Dom[ w ] [ { v } if newSet 6 = Dom[ v ] then     Dom[ v ] newSet    Changed true

  29. O ( | V | 3 × | E | )

  30. Bottleneck: naïve iteration

  31. for v 2 V do Dom[ v ] V Dom[ v 0 ] { v 0 } Changed true while Changed do Changed false for v 2 V do ⇣T ⌘ newSet w ∈ pred ( v ) Dom[ w ] [ { v } if newSet 6 = Dom[ v ] then Dom[ v ] newSet Changed true

  32. Usual Hacks for Performance * Reverse postorder O ( | V | × | E | ) Using priority queue O ( | V | 2 ) * K. D. Cooper, T. J. Harvey, and K. Kennedy. A simple, fast dominance algorithm.

  33. The Pattern Summarized

  34. 1. A concrete domain h ℘ ( V + ) , ✓i 2. A concrete functional p G : ℘ ( V + ) → ℘ ( V + ) 3. An abstract domain h ℘ ( V ⇥ V ) , ◆i 4. An abstraction dom = ( in / ) � f 5. A Galois connection dom � � � � h ℘ ( V + ) , ✓i � h ℘ ( V ⇥ V ) , ◆i � � � ! dom 6. “Pushing alphas” dom � p G = F D � dom 7. An iterative algorithm lfp ⊇ F D

  35. Shortest Path Algorithm (an overview)

  36. 1. A concrete domain h ℘ ( V + w ) , ✓i 2. A concrete functional p G w : ℘ ( V + w ) → ℘ ( V + w ) 3. An abstract domain h V ! ( N [ { 1 } ) , ˙ �i 4. An abstraction dist ( X ) = λ v. min { τ : τ 2 X ^ last ( τ ) = v : k τ k } 5. A Galois connection dist h V ! ( N [ { 1 } ) , ˙ � � � � h ℘ ( V + w ) , ✓i � �i � � � ! dist 6. “Pushing alphas” dist � p G w = F δ � dist 7. An iterative algorithm lfp ˙ ≥ F δ Details in the paper

  37. An algorithm * for u ∈ V do δ [ u ] ← ∞ δ [ v 0 ] ← 0 Changed ← true while Changed do Changed ← false for v ∈ V do for u ∈ pred ( v ) do if δ [ u ] + W [ u, v ] < δ [ v ] then δ [ v ] ← δ [ u ] + W [ u, v ] Changed ← true * R. Bellman. On a routing problem. 1958

  38. Conclusion

  39. • Various graph problems can be formulated as properties of sets of finite paths • Sets of paths can be taken as a concrete domain • A property can be taken as an abstract domain • A mapping from paths to a property can be proved to be a lower adjoint in a Galois connection • Fixpoint fusion law to obtain an algorithm • Correctness is by construction

Recommend


More recommend