15 exhaustjve graph rewrite systems xgrs for refactorings
play

15 Exhaustjve Graph Rewrite Systems (XGRS) for Refactorings and - PowerPoint PPT Presentation

Fakultt Informatik - Institut Software- und Multimediatechnik - Softwaretechnologie Prof. Amann - Softwaretechnologie II 15 Exhaustjve Graph Rewrite Systems (XGRS) for Refactorings and Other Transformatjons Prof. Dr. Uwe Amann 1)


  1. Fakultät Informatik - Institut Software- und Multimediatechnik - Softwaretechnologie – Prof. Aßmann - Softwaretechnologie II 15 Exhaustjve Graph Rewrite Systems (XGRS) for Refactorings and Other Transformatjons Prof. Dr. Uwe Aßmann 1) Termination of EARS Softwaretechnologie 2) Termination of AGRS Technische Universität Dresden 3) SGRS Version 15-0.4, 02.01.16 4) XGRS 5) Refactoring Example (c) Prof. U. Aßmann Model Structurings

  2. Obligatory Literature S o f t w a r e t e c h n o l o g i e I I [ A ß m a n n 0 0 ] U w e A ß m a n n . G r a p h r e w r i t e s y s t e m s f o r p r o g r a m o p t i m i z a t i o n . A C M ● Transactions on Programming Languages and Systems (TOPLAS), 22(4):583-637, June 2000. h t t p : / / p o r t a l . a c m . o r g / c i t a t i o n . c f m ? i d = 3 6 3 9 1 4 – Alexander Christoph. Graph rewrite systems for software design transformations. In M. ● Aksit, editor, Proceedings of Net Object Days 2002, Erfurt, Germany, October 2002. Alexander Christoph. GREAT - a graph rewriting transformation framework for designs. ● Electronic Notes in Theoretical Computer Science (ENTCS), 82 (4), April 2003. Alexander Christoph. Describing horizontal model transformations with graph rewriting ● rules. In Uwe Aßmann, Mehmet Aksit, and Arend Rensink, editors, MDAFA, volume 3599 of Lecture Notes in Computer Science, pages 93-107. Springer, 2004. Tom Mens. On the Use of Graph Transformations for Model Refactorings. GTTSE 2005, ● Springer, LNCS 4143 (c) Prof. U. Aßmann http://www.springerlink.com/content/5742246115107431/ –

  3. Mo 3 U Dr el Co es Remember: Rename Refactorings in Programs nsi de ste n, ncy Pro f. U. Aß S o f t w a r e t e c h n o l o g i e I I ma Refactor the name Person to Human, using bidirectional use-def-use links: nn class Person { .. } Definition class Course { Person teacher = new Person(“Jim”); Reference (Use) Person student = new Person(“John”); } class Human { .. } class Course { Human teacher = new Human(“Jim”); Human student = new Human(“John”); }

  4. Mo 4 U Dr el Co es Refactoring as Graph Transformatjon nsi de ste n, ncy Pro f. U. Aß S o f t w a r e t e c h n o l o g i e I I ma nn Refactoring works always in the same way: ● Change a defjnition – Find all dependent references – Change them – Recurse handling other dependent defjnitions – Refactoring can be supported by Graph Rewrite Tools ● The Use-Def-Use-graph (UDUG) forms the basis of refactoring tools – Build up the UDUG with graph analysis (EARS) – Rewrite it with graph rewriting (XGRS) –

  5. Fakultät Informatik - Institut Software- und Multimediatechnik - Softwaretechnologie – Prof. Aßmann - Softwaretechnologie II 15.1 Terminatjon and Confmuence of EARS A Fujaba GRS (in one activity of the storyboard) may terminate and deliver a unique result. (c) Prof. U. Aßmann Model Structurings

  6. Problems with GRS S o f t w a r e t e c h n o l o g i e I I W i t h g r a p h r e w r i t i n g f o r m o d e l a n d p r o g r a m a n a l y s i s , r e f a c t o r i n g , a n d t r a n s f o r m a t i o n , there are some problems: T e r m i n a t i o n : The r u l e s o f a G R S G a r e a p p l i e d i n c h a o t i c o r d e r t o t h e ● manipulated graph. W hen does G terminate for a start graph? I d e a : c a n w e „ f o r c e d l y “ t e r m i n a t e t h e r e w r i t i n g ? – Idea: identify a t e r m i n a t i o n g r a p h which stops the rewriting when completed – Non-convergence (indeterminism) : when does a GRS deliver a deterministic ● solution (unique normal form)? Can we automatically select a “standard” normal form? – Idea: unique normal forms by rule stratification – (c) Prof. U. Aßmann

  7. Additjve Terminatjon S o f t w a r e t e c h n o l o g i e I I A t e r m i n a t i o n s u b g r a p h is a subgraph of the manipulated graph, which is step by step ● completed Conditions in the additive case: ● nodes of termination (sub-)graph are not added (remain unchanged) – its edges are only added – If the termination graph is complete, the system terminates ● (c) Prof. U. Aßmann

  8. Transitjvising (Flatuening) the Inheritance Hierarchy S o f t w a r e t e c h n o l o g i e I I Does this rule terminate? ● Yes, because EARS complete graphs and shorten paths – “is-a” is the termination subgraph – Fujaba GRS rule “FlattenInheritanceHierarchy”: ● C:Class F l a t t e n I n h e r i t a n c e Hierarchy() B:Class <<create>> (c) Prof. U. Aßmann A:Class [Christoph04]

  9. Run-Time Derivatjon (Snapshots): Transitjvising the Inheritance Hierarchy S o f t w a r e t e c h n o l o g i e I I Ex.: A simple class inheritance tree (acyclic) is “shortened” ● “is-a” is completed step by step ● Object:Class Object:Class Person:Class Person:Class Student:Class Professor:Class Student:Class Professor:Class (c) Prof. U. Aßmann Freshman:Class Freshman:Class 1 2

  10. Transitjvising the Inheritance Hierarchy S o f t w a r e t e c h n o l o g i e I I Ex.: A simple class inheritance tree (acyclic) is “shortened” ● Object:Class Object:Class Person:Class Person:Class Student:Class Professor:Class Student:Class Professor:Class (c) Prof. U. Aßmann Freshman:Class Freshman:Class 3 4

  11. Transitjvising the Inheritance Hierarchy S o f t w a r e t e c h n o l o g i e I I If every indirect path is shortened, rewriting stops ● Object:Class Person:Class Student:Class Professor:Class (c) Prof. U. Aßmann Freshman:Class 5 END

  12. Example: Collect Subexpressions S o f t w a r e t e c h n o l o g i e I I EARS also work on bipartite graphs ● Query to build up the use-defjnition-use graph (UDUG) between Statements and ● Expressions: ''Find all subexpressions which are reachable from a statement'‘ – ● // F-Datalog: // F-Datalog: ExprsOfStmt(Stmt:Statement,Expr:Expr) :- Child(Stmt,Expr). ExprsOfStmt(Stmt:Statement,Expr:Expr) :- Child(Stmt,Expr). ExprsOfStmt(Stmt:Statement,Expr:Expr) :- ExprsOfStmt(Stmt:Statement,Expr:Expr) :- Child(Stmt,Expr2), Descendant(Expr2,Expr). Child(Stmt,Expr2), Descendant(Expr2,Expr). // Descendant is transitive closure of Child // Descendant is transitive closure of Child Descendant(Expr1:Expr,Expr2:Expr) :- Child(Expr1,Expr2). Descendant(Expr1:Expr,Expr2:Expr) :- Child(Expr1,Expr2). Descendant(Expr1:Expr,Expr2:Expr) :- Descendant(Expr1,Expr3), Descendant(Expr1:Expr,Expr2:Expr) :- Descendant(Expr1,Expr3), Child(Expr3,Expr2). Child(Expr3,Expr2). (c) Prof. U. Aßmann Features of graph rewrite system: ● terminating, strong confmuent – convergent (unique normal form) – recursive –

  13. EARS CollectExpressions S o f t w a r e t e c h n o l o g i e I I Two transitive closures, specifjed as path abbreviations ● <<create>> ExprsOfStmt Stmt:Statement Expr:Expr Child <<create>> ExprsOfStmt Collect Expressions() Stmt:Statement Expr:Expr Expr2:Expr Child Descendant <<create>> Descendant Expr1:Expr Expr2:Expr Child (c) Prof. U. Aßmann <<create>> Descendant Expr1:Expr Expr2:Expr Expr3:Expr Descendant Child

  14. Executjon of „Reachable Subexpressions“ S o f t w a r e t e c h n o l o g i e I I Start situation ● Assign Child Child Expr Plus 1 Const Var (c) Prof. U. Aßmann 1 X

  15. Executjon of „Reachable Subexpressions“ S o f t w a r e t e c h n o l o g i e I I Why do such graph rewrite systems terminate? Answer: ExprsOfStmt and Descendants ● are termination subgraphs, completed step by step Assign ExprsOfStmt Child Descendants Expr Plus 2 Const Var (c) Prof. U. Aßmann Descendants 1 X

  16. Executjon of „Reachable Subexpressions“ S o f t w a r e t e c h n o l o g i e I I Assign ExprsOfStmt Child Descendants Expr Plus 3 Const Var (c) Prof. U. Aßmann Descendants 1 X

  17. Executjon of „Reachable Subexpressions“ S o f t w a r e t e c h n o l o g i e I I Assign ExprsOfStmt Child Descendants Expr Plus 4 Const Var (c) Prof. U. Aßmann Descendants 1 X

  18. Executjon of „Reachable Subexpressions“ S o f t w a r e t e c h n o l o g i e I I Assign ExprsOfStmt Child Descendants Expr Plus 5 Const Var (c) Prof. U. Aßmann Descendants 1 X

  19. EARS - Simple Edge-Additjve GRS S o f t w a r e t e c h n o l o g i e I I EARS (Edge addition rewrite systems) only add edges to graphs ● They can be used for the construction of graphs – For the building up analysis information about a program or a model ● For abstract interpretation on an abstract domain represented by a graph ● terminating : terminating on the fjnite lattice of subgraphs of the manipulated graph ● Added edges form the termination subgraph – strongly confmuent : direct derivations can always be interchanged. ● congruent : unique normal form (result) ● ==> If a Fujaba activity contains an EARS, it terminates and delivers a unique result ● (c) Prof. U. Aßmann

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