1 / 16

An Introduction to Graph Rewriting

An Introduction to Graph Rewriting. Thomas Huining Feng http://www.eecs.berkeley.edu/~tfeng/ CHESS, UC Berkeley May 1, 2007 Inspired by Tutorial Introduction to Graph Transformation: A Software Engineering Perspective . Luciano Baresi, Reiko Heckel. ICGT 2002. PacMan: a Motivating Example.

theola
Télécharger la présentation

An Introduction to Graph Rewriting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Introduction to Graph Rewriting Thomas Huining Fenghttp://www.eecs.berkeley.edu/~tfeng/CHESS, UC Berkeley May 1, 2007 Inspired by Tutorial Introduction to Graph Transformation: A Software Engineering Perspective. Luciano Baresi, Reiko Heckel. ICGT 2002

  2. PacMan: a Motivating Example : PacMan : Field : Field : Field : Ghost : Marble : Field : Field : Field : Field : Field : Field Type 1..4 1 0..1 1 1 0..1 Ghost Field PacMan 1 0..1 Marble

  3. Our 1st Rule: pmove LHS (Left Hand Side) RHS (Right Hand Side) : PacMan : PacMan pmove a : Field a : Field b : Field b : Field Redex finding is a sub-graph isomorphism problem). Multiple redexes? Redex : PacMan : Field : Field : Field : Ghost : Marble : Field : Field : Field : Field Host Graph : Field : Field

  4. Our 2nd Rule: gmove : Ghost : Ghost gmove a : Field a : Field b : Field b : Field : PacMan : Field : Field : Field : Ghost : Marble : Field : Field : Field : Field : Field : Field

  5. Combining pmove and gmove • pmove and gmove do not “interfere” with each other. • I.e., applying any one does not affect applicability of the other. : Ghost : Ghost pmove gmove : PacMan : PacMan a : Field a : Field b : Field b : Field a : Field a : Field b : Field b : Field

  6. catch Rule : Ghost : Ghost : PacMan catch a : Field a : Field b : Field b : Field : PacMan : Field : Field : Field : Ghost : Marble : Field : Field : Field : Field : Field : Field

  7. Important Decision: Which Rule to Choose? • catch is actually a “sub-case” of gmove, because: LHS(gmove)  LHS(catch) • Assign priority (almost always the same for sub-cases): P(catch) > P(gmove) : Ghost : Ghost : PacMan catch gmove : Ghost : Ghost a : Field a : Field b : Field b : Field a : Field a : Field b : Field b : Field

  8. Attribute Binding: collect Rule : PacMan 4 : marble : PacMan 3 : marble : Field : Field : Field : Ghost : Marble : Field : Field : Field : Field : Field : Field

  9. Attribute Binding: collect Rule • Here, m on the LHS serves as a bound variable; on the RHS, it refers to the value bound to. : PacMan m : marble : PacMan m+1 : marble : Marble : PacMan 3 : marble collect : Field : Field : Field a : Field a : Field b : Field b : Field : Ghost : Marble : Field : Field : Field : Field : Field : Field 1..4 1 Type 0..1 1 1 0..1 Ghost Field PacMan int marble 1 0..1 Marble

  10. Completing the PacMan Game Priority: : PacMan : PacMan 3 : PacMan m : marble : Ghost : PacMan m+1 : marble : Ghost : Marble collect gmove pmove catch interfering a : Field a : Field b : Field b : Field a : Field a : Field a : Field a : Field b : Field b : Field b : Field b : Field 3 sub-case 1 : Ghost : PacMan : Ghost a : Field a : Field b : Field b : Field sub-case 2 n P

  11. The Graph Rewriting Problem • Common components in the problem • Host graph • A set of rewriting rules • LHS and RHS • Attribute binding and transfer • Application condition • Embedding information Host Graph – Redex : PacMan m : marble : PacMan m+1 : marble : Marble a : Field a : Field b : Field b : Field m < BAG_SIZE

  12. The Graph Rewriting Problem • Common components in the problem: • Host graph • A set of rewriting rules • LHS and RHS • Attribute binding and transfer • Application condition • Embedding information • Rule application • In the host graph, find all redexes according to the rules. • Match LHS • Check application condition • Choose a redex and a rule to apply. • Apply the rule. • Generate a substitution (unique) isomorphic to RHS • Compute new attributes • Make substitution (“bridge” w.r.t embedding information)

  13. More on Application Decision • We have seen priorities (as a partial order of rules). • Applications may require other approaches. • More flexible rule choosing: • Combine with control structure • Event-driven • Combine with state machine C? Y N e1 e2 C1? C2?

  14. More on Application Decision • We have seen priorities (as a total order of rules). • Applications may require other approaches. • Maze walking (goal-directed searching) 1..4 1 0..1 1 1 0..1 Entrance Field Kid 1 0..1 Exit

  15. More on Application Decision • We have seen priorities (as a total order of rules). • Applications may require other approaches. • Shortest path (optimizing an objective function) Start 3 6 End 0 5 1 2 0 Man 8 : Man t : time : Man t+d : time * 1 0..1 1 1 0..1 Field int delay Man int time Start a : Field b : Field d : delay a : Field b : Field d : delay 1 0..1 End

  16. Conclusion • Key idea is simple. • User-friendly. • Expressive. • Transformation problems • Analysis problems • Search problems • Optimization problems • Complexity due to sub-graph isomorphism on the LHS. • Rules need to be carefully designed and chosen at run time. • Depending on the problem and the goal. • Problem formulation and algorithm are application dependent.

More Related