Skip to main content
Log in

Converting metamodels to graph grammars: doing without advanced graph grammar features

  • Regular Paper
  • Published:
Software & Systems Modeling Aims and scope Submit manuscript

Abstract

In this paper, we present a method to convert a metamodel in the form of a UML class diagram into a context-sensitive graph grammar whose language comprises precisely the set of model graphs (UML object diagrams) that conform to the input metamodel. Compared to other approaches that deal with the same problem, we use a graph grammar formalism that does not employ any advanced graph grammar features, such as application conditions, precedence rules, and production schemes. Specifically, we use Rekers and Schürr’s Layered Graph Grammars, which may be regarded as a pure generalization of standard context-sensitive string grammars. We show that elementary grammatical features, i.e., grammar labels and context-sensitive graph rewrite rules, suffice to represent metamodels with arbitrary multiplicities and inheritance. Inspired by attribute string grammars, we also propose a graph-grammar-based approach to the semantic analysis of model graphs.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7

Similar content being viewed by others

Notes

  1. http://www.uml.org.

  2. Ehrig et al. also use the term LGG for their output formalism, although it is unrelated to the formalism of Rekers and Schürr. In this paper, the term “Layered Graph Grammars” will invariably refer to the formalism of Rekers and Schürr.

  3. http://user.cs.tu-berlin.de/~gragra/agg/.

  4. http://www.eclipse.org/Xtext/.

  5. http://alloy.mit.edu.

References

  1. Alanen, M., Porres, I.: A Relation Between Context-Free Grammars and Meta Object Facility Metamodels. Technical Report 606, Turku Centre for Computer Science, Mar 2003

  2. Anastasakis, K., Bordbar, B., Georg, G., Ray. I.: UML2Alloy: A challenging model transformation. In: Engels, G., Opdyke, B., Schmidt, D.C., Weil, F. (eds.) Model Driven Engineering Languages and Systems. 10th International Conference, MoDELS 2007, Nashville, USA, September 30–October 5, 2007, Proceedings. Lecture Notes in Computer Science, vol. 4735, pp. 436–450 (2007)

  3. Bottoni, P., Taentzer, G., Schürr, A.: Efficient parsing of visual languages based on critical pair analysis and contextual layered graph transformation. In: Proceedings of 2000 IEEE International Symposium on Visual Languages (VL’00), IEEE Computer, Seattle, WA, USA, pp. 59–60 Society (2000)

  4. Büttner, F., Gogolla, M.: Realizing UML metamodel transformations with AGG. Electron. Notes Theor. Comput. Sci. 109, 31–42 (2004)

    Article  Google Scholar 

  5. Cabot, J., Clarisó, R., Riera, D.: UMLtoCSP: a tool for the formal verification of UML/OCL models using constraint programming. In: Stirewalt, R.E.K., Egyed, A., Fischer B. (eds.) Automated Software Engineering, ASE, pp. 547–548. ACM (2007)

  6. Chen, K., Sztipanovits, J., Neema, S.: Compositional specification of behavioral semantics. In: Proceedings of Conference on Design, Automation, and Test in Europe, pp. 906–911 (2007)

  7. de Lara, J., Vangheluwe, H., Alfonseca, M.: Metamodelling and graph grammars for multi-paradigm modelling in AToM\(^3\). Softw. Syst. Model. 3(3), 194–209 (2004)

    Google Scholar 

  8. Di Ruscio, D., Jouault, F., Kurtev, I., Bézivin, J., Pierantonio, A.: Extending AMMA for supporting dynamic semantics specifications of DSLs. Technical Report 06.02, INRIA/LINA (2006)

  9. Dinh-Trong, T.T., Ghosh, S., France, R.B.: A systematic approach to generate inputs to test UML design models. In: Proceedings on 17th International Symposium on Software Reliability Engineering, pp. 95–104. IEEE Computer Society (2006)

  10. Drewes, F., Hoffmann, B., Janssens, D., Minas, M.: Adaptive star grammars and their languages. Theor. Comput. Sci. 411(34–36), 3090–3109 (2010)

    Article  MathSciNet  MATH  Google Scholar 

  11. Ehrig, H., Engels, G., Kreowski, H.-J., Rozenberg, G., Montanari, U., (eds).: Handbook of graph grammars and computing by graph transformation (vols. 1.–3.). World Scientific (1997–1999)

  12. Ehrig, K., Küster, J., Taentzer, G.: Generating instance models from meta models. Softw. Syst. Model. 8, 479–500 (2009)

    Article  Google Scholar 

  13. Engels, G., Hausmann, J.H., Heckel, R., Sauer, S.: Dynamic meta modeling: a graphical approach to the operational semantics of behavioral diagrams in UML. In: Proceedings of 3rd International Conference on the Unified Modeling Language: Advancing the Standard, pp. 323–337. Springer (2000)

  14. Fürst, L., Mernik, M., Mahnič, V.: Improving the graph grammar parser of Rekers and Schürr. IET Softw. 5(2), 246–261 (2011)

    Article  Google Scholar 

  15. Gogolla, M., Bohling, J., Richters, M.: Validating UML and OCL models in USE by automatic snapshot generation. Softw. Syst. Model. 4(4), 386–398 (2005)

    Article  Google Scholar 

  16. Gray, J., Tolvanen, J.-P., Kelly, S., Gokhale, A., Neema, S., Sprinkle, J.: Domain-specific modeling. In: Fishwick, P.A. (ed.) Handbook of Dynamic System Modeling. CRC Press, Florida (2007)

    Google Scholar 

  17. Harel, D., Rumpe, B.: Meaningful modeling: what’s the semantics of “semantics”? Computer 37(10), 64–72 (2004)

    Article  Google Scholar 

  18. Hoffmann, B., Minas, M.: Generating instance graphs from class diagrams with adaptive star grammars. In: Proceedings of 3rd International Workshop on Graph Computation Models (GCM 2010), volume 39 of Electronic Communications of the EASST (2011)

  19. Javed, F., Mernik, M., Bryant, B.R., Sprague, A.: An unsupervised incremental learning algorithm for domain-specific language development. Appl. Artif. Intell. 22(7–8), 707–729 (2008)

    Article  Google Scholar 

  20. Javed, F., Mernik, M., Gray, J., Bryant, B.R.: MARS: a metamodel recovery system using grammar inference. Inf. Softw. Technol. 50(9–10), 948–968 (2008)

    Article  Google Scholar 

  21. Kelly, S., Tolvanen, J.-P.: Domain-Specific Modeling: Enabling Full-Code Generation. Wiley, New York (2008)

    Book  Google Scholar 

  22. Königs, A., Schürr, A.: Tool integration with Triple Graph Grammars—a survey. Electron. Notes Theor. Comput. Sci. 148(1), 113–150 (2006)

    Article  Google Scholar 

  23. Kuhlmann, M., Hamann, L., Gogolla, M.: Extensive validation of OCL models by integrating SAT solving into USE. In: Bishop, J., Vallecillo, A. (eds.) TOOLS 2011, volume 6705 of LNCS, pp. 290–306. Springer, New York (2011)

  24. Mens, T., Van Gorp, P., Varró, D., Karsai, G.: Applying a model transformation taxonomy to graph transformation technology. Electron. Notes Theor. Comput. Sci. 152, 143–159 (2006)

    Article  Google Scholar 

  25. Mougenot, A., Darrasse, A., Blanc, X., Soria, M.: Uniform random generation of huge metamodel instances. In: European Conference on Model Driven Architecture, pp. 130–145. Springer (2009)

  26. Paakki, J.: Attribute grammar paradigms—a high-level methodology in language implementation. ACM Comput. Surv. 27(2), 196–255 (1995)

    Article  Google Scholar 

  27. Queralt, A., Teniente, E.: Verification and validation of UML conceptual schemas with OCL constraints. ACM Trans. Softw. Eng. Methodol. 21(2), 13:1–13:41, (2012)

    Google Scholar 

  28. Rekers, J., Schürr, A.: Defining and parsing visual languages with Layered Graph Grammars. J. Vis. Lang. Comput. 8(1), 27–55 (1997)

    Article  Google Scholar 

  29. Sadilek, D.A., Wachsmuth, G.: Using grammarware languages to define operational semantics of modelled languages. In: 47th International Conference on Objects, Models, Components, and Patterns (TOOLS-EUROPE’09), pp. 348–356. Springer (2009)

  30. Schürr, A.: Specification of graph translators with Triple Graph Grammars. In: Proceedings on 20th International Workshop on Graph-Theoretic Concepts in Computer Science, pp. 151–163. Springer (1994)

  31. Sen, S., Baudry, B., Mottu, J.-M.: On combining multi-formalism knowledge to select models for model transformation testing. In: International Conference on Software Testing, Verification, and Validation, pp. 328–337 (2008)

  32. Sprinkle, J., Mernik, M., Tolvanen, J.-P., Spinellis, D.: Guest editors’ introduction: what kinds of nails need a domain-specific hammer? IEEE Softw. 26(4), 15–18 (2009)

    Article  Google Scholar 

  33. Taentzer, G.: Instance generation from type graphs with arbitrary multiplicities. In: Proceedings of 11th International Workshop on Graph Transformation and Visual Modeling Techniques (GT-VMT 2012), volume 47 of Electronic Communications of the EASST (2012)

  34. Winkelmann, J., Taentzer, G., Ehrig, K., Küster, J.M.: Translation of restricted OCL constraints into graph constraints for generating meta model instances by graph grammars. Electron. Notes Theor. Comput. Sci. 211, 159–170 (2008)

    Article  Google Scholar 

  35. Yu, L., France, R.B., Ray, I.: Scenario-based static analysis of UML class models. In: Czarnecki, K., Ober, I., Bruel, J.-M., Uhl, A., Völter, M. (eds.) Model-Driven Engineering Languages and Systems, pp. 234–248. Springer, New York (2008)

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Luka Fürst.

Additional information

Communicated by Prof. Hong Mei.

Appendix: Auxiliary statements

Appendix: Auxiliary statements

In this appendix, we present and prove three auxiliary statements upon which the proofs of Theorems 30 (Sect. 4.4.2) and 31 (Sect. 4.4.3) directly or indirectly depend.

Lemma 36

Let \(P\) be a metamodel class with the associated classes \(Q_1,\) \(\ldots ,\) \(Q_p\) arranged as in Eq. (1) (Sect. 4.2). Then, in any graph \(G\) derivable in \({ GG }({ MM })\), the following statements are true for each terminal vertex \(P\):

  1. (1)

    For each \(i \in {1\,.\,.\,k}\), the vertex \(P\) is connected with \(u_i\) terminals \(Q_i\) and \(v_i\) nonterminals \(Q_i^1\) such that \(u_i \ge 0\), \(v_i \ge 0\), and \(u_i + v_i = a_i\).

  2. (2)

    For each \(i \in {k+1\,.\,.\,l}\), the vertex \(P\) is connected with \(u_i\) terminals \(Q_i\) and \(v_i\) nonterminals \(Q_i^1\) such that \(u_i \ge 0\), \(v_i \ge 0\), and \(u_i + v_i \ge a_i\).

  3. (3)

    For each \(i \in {l+1\,.\,.\,m}\), the vertex \(P\) is connected with \(u_i\) terminals \(Q_i\), \(v_i\) nonterminals \(Q_i^1\), and at most one nonterminal \(Q_i^{w_i}\) such that \(u_i \ge 0\), \(v_i \ge 0\), and \(2 \le w_i \le b_i-a_i+1\). If \(P\) is indeed connected with a nonterminal \(Q_i^{w_i}\), then it holds that \(u_i + v_i + w_i = b_i\). Otherwise, it holds that \(a_i \le u_i + v_i \le b_i\).

  4. (4)

    For each \(i \in {m+1\,.\,.\,p}\), the vertex \(P\) is connected with \(u_i\) terminals \(Q_i\), \(v_i\) nonterminals \(Q_i^1\), at most one nonterminal \(\overline{Q_i}\), and at most one nonterminal \(Q_i^{w_i}\) such that \(u_i \ge 0\), \(v_i \ge 0\), and \(2 \le w_i \le b_i\). If \(P\) is indeed connected with a nonterminal \(Q_i^{w_i}\), then it holds that \(u_i + v_i + w_i = b_i\). Otherwise, it holds that \(0 \le u_i + v_i \le b_i\).

Proof

To prove that the stated property holds for all graphs derivable in grammar \({ GG }({ MM })\), we have to verify that it holds for the initial vertex, \({\mathsf{V}}\) (which it does, since the statements only apply to terminal vertices), and that any production application preserves it. In other words, assuming that the lemma is valid before a particular production application, we have to show that it remains valid afterward. Let us verify this claim for individual production families:

  • Family 1: Both productions of this family trivially preserve the stated property, since they do not introduce any terminal vertices.

  • Family 2: Let us focus on family 2.2; the proof for family 2.1 is similar. The family-2.2 production for the class \(P\) creates the following star:

    $$\begin{aligned}&P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\{a_1 Q_1^1,\ldots , a_l Q_l^1,\\&\quad (a_{l+1}-1)\, Q_{l+1}^1,\ldots , (a_m-1)\, Q_m^1,\\&\quad Q_{l+1}^{b_{l+1}-a_{l+1}+1},\ldots , Q_m^{b_m-a_m+1},\, \overline{Q_{m+1}}\}. \end{aligned}$$

    The terminal vertex \(P\) in the center of this star complies with statements (1) and (2), since \(u_i + v_i = 0 + a_i = a_i\) for all \(i \in {1\,.\,.\,l}\). Statement (3) is also valid for \(P\), because \(u_i + v_i + w_i = 0 + (a_i-1) + (b_i-a_i+1) = b_i\) for all \(i \in {l+1\,.\,.\,m}\). The vertex \(P\) is connected only with the nonterminal \(\overline{Q_{m+1}}\). Therefore, we have \(u_i + v_i = 0 \in {0\,.\,.\,b_i}\) for all \(i \in {m+1\,.\,.\,p}\), which makes statement (4) valid. To summarize, the productions of family 2 preserve the property stated in the lemma.

  • Family 3: An application of a family-3 production enlarges the term \(v_i\) in the sum \(u_i + v_i\) for some \(i \in {k+1\,.\,.\,l}\). This change certainly preserves the fact that \(u_i + v_i \ge a_i\) from statement (2). Other statements of the lemma could not be affected by a family-3 production application. Therefore, family 3 maintains the lemma.

  • Family 4: The proof that family-4 productions preserve the stated property is based on the following statement: There is no subscript \(i\) such that the vertex \(P\) is connected with both \(\overline{Q_i}\) and \(Q_i^{d}\) for some \(d \ge 1\). To see this, note that families 2.2 and 4, which deal with “overlined” nonterminals, ensure that the vertex \(P\) is connected with at most one “overlined” nonterminal (say, \(\overline{Q_r}\) for some \(r \in {m+1\,.\,.\,p}\)) and that its subscript (\(r\)) is always greater than the subscripts of all nonterminals \(Q_j^d\). Let us return to Lemma 36. Family-4 productions manipulate nonterminals \(\overline{Q_i}\) with \(i \in {m+1\,.\,.\,p}\) and can thus affect only statement (4). Family 4.3 preserves the sums \(u_i + v_i\) and \(u_i + v_i + w_i\) and hence the lemma, since it neither adds nor removes any nonterminal of the form \(Q_j^d\) with \(d \ge 1\). Families 4.1 and 4.2 attach a new nonterminal \(Q_i^{b_i}\) (for a certain subscript \(i \in {m+1\,.\,.\,p}\)) to the vertex \(P\). Since—according to the statement from the preceding paragraph—the vertex \(P\) cannot be connected with both \(\overline{Q_i}\) and \(Q_i^d\) simultaneously, the nonterminal \(Q_i^{b_i}\) introduced by productions 4.1 and 4.2 is the only nonterminal with subscript \(i\) connected to \(P\). The sum \(u_i + v_i + w_i\) therefore amounts to \(0 + 0 + b_i = b_i\), which complies with statement (4) from the lemma.

  • Family 5: Productions 5.1 and 5.2 can be applied only to a subgraph \(P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}Q_i^{w_i}\) with \(2 \le w_i \le b_i-a_i+1\) for some \(i \in {l+1\,.\,.\,m}\) or \(2 \le w_i \le b_i\) for some \(i \in {m+1\,.\,.\,p}\). Let us prove the lemma for a subscript \(i \in {l+1\,.\,.\,m}\); the proof for \(i \in {m+1\,.\,.\,p}\) is similar. For a subscript \(i \in {l+1\,.\,.\,m}\), statement (3) of the lemma requires that the sum \(u_i + v_i + w_i\) amounts to \(b_i\). Production 5.1 reduces the superscript \(w_i\) by \(1\) and simultaneously increases the term \(v_i\) (the number of \(P\)’s connections with nonterminals \(Q_i^1\)) by \(1\). The sum thus remains intact, so the lemma is proved for family 5.1. Production 5.2 replaces the nonterminal \(Q_i^{w_i}\) in the subgraph \(P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}Q_i^{w_i}\) with \(Q_i^1\). This action does not affect the term \(u_i\) (\(u_i' = u_i\)), but enlarges the term \(v_i\) (\(v_i' = v_i + 1\)). Since the vertex \(P\) is not connected with a nonterminal of the form \(Q_i^{w_i}\) (with \(w_i \ge 2\)) any more, we have to verify that \(a_i \le u_i' + v_i' \le b_i\). This is true, since \(u_i' + v_i' = u_i + (v_i+1) = (u_i + v_i + w_i) + (1-w_i) = b_i + 1 - w_i\), which, given that \(2 \le w_i \le b_i-a_i+1\), lies somewhere between \(a_i\) and \(b_i-1\). In summary, \(a_i \le u_i' + v_i' \le b_i\). We can therefore conclude that family 5.2, too, preserves the stated property.

  • Family 7: An application of a family-7 production to a pair of terminals \(P\) and \(Q\) does not change individual sums \(u_i + v_i\) and \(u_i + v_i + w_i\), since the terminal \(P\) loses a connection with a nonterminal \(Q^1\) and simultaneously gains a connection with a terminal \(Q\) (hence \(u' + v' = (u+1)+(v-1) = u+v\)), and the same goes for the terminal \(Q\). The family-7 productions thus preserve the lemma. \(\square \)

Lemma 37

Let \(P\) be a metamodel class associated with classes \(Q_1,\) \(\ldots ,\) \(Q_p\). Then, in any graph \(G\) derivable in \({ GG }({ MM })\), the following property holds for each terminal vertex \(P\):

For each \(i \in {1\,.\,.\,p}\), the vertex \(P\) is connected with \(u_i\) vertices \(Q_i\), \(v_i\) vertices \(Q_i^1\), \(y_i\) vertices \(Q_i^{w_i}\) (where \(w_i \ge 2\)), and at most one vertex \(\overline{Q_i}\) such that \(u_i \ge 0\), \(v_i \ge 0\), \(y_i \in \{0,\) \(1\}\), and \(u_i + v_i + y_i w_i \in { mult }(P,\) \(Q_i)\).

Proof

Lemma 37 follows directly from the stronger Lemma 36, since every equation or inequality involving the sum \(u_i + v_i\) or \(u_i + v_i + w_i\) can be rewritten or generalized as \(u_i + v_i + y_i w_i \in { mult }(P, Q_i)\). For example, the equation \(u_i + v_i + w_i = b_i\) and inequality \(a_i \le u_i + v_i \le b_i\) from Statement (3) of Lemma 36 can be united and generalized (weakened) as \(u_i + v_i + y_i w_i \in {a_i\,.\,.\,b_i}\). The case \(y_i = 1\) generalizes the equation, while the case \(y_i = 0\) matches the inequality. \(\square \)

Lemma 38

Given a metamodel class \(P\) with the associated classes \(Q_1,\) \(\ldots ,\) \(Q_p\) arranged as in Eq. (1), any graph of the form \(P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\{ Q_{i[1]}^{b_{i[1]}},\) \(\ldots ,\) \(Q_{i[r]}^{b_{i[r]}} \}\), where \(1 \le r \le p-m\) and \(m+1 \le i[1] < \cdots < i[r] \le p\), can be reduced to the graph \(G_I \equiv P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\overline{Q_{m+1}}\) using family-4 productions in reverse.

Proof

Let \(G\) be a graph of the form \(P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\{ Q_{i[1]}^{b_{i[1]}}\), ..., \(Q_{i[r]}^{b_{i[r]}} \}\), where \(1 \le r \le p-m\) and \(m+1 \le i[1] < \cdots < i[r] \le p\). A single reverse application of production 4.1 converts this graph into the graph \(H_r \equiv P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\{ Q_{i[1]}^{b_{i[1]}}\),..., \(Q_{i[r-1]}^{b_{i[r-1]}}\), \(\overline{Q_{i[r]}} \}\). We now have to prove that the graph \(H_r\) can be reduced to the graph \(G_I \equiv P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\overline{Q_{m+1}}\) for all \(r \ge 1\):

  • (Case \(r = 1\)) To reduce the graph \(H_1 = P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\overline{Q_{i[1]}}\) to the graph \(G_I = P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\overline{Q_{m+1}}\), reverse-apply production 4.3 \((i[1]-m-1)\) times.

  • (The general case) The graph \(H_r\) for a general \(r\) can be converted into the graph \(H_{r-1}\) as follows: If \(i[r] > i[r-1]+1\), reverse-apply production 4.3 \((i[r]-i[r-1]-1)\) times to convert the graph \(H_r\) into the graph \(P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\{ Q_{i[1]}^{b_{i[1]}}\),..., \(Q_{i[r-2]}^{b_{i[r-2]}}\), \(Q_{i[r-1]}^{b_{i[r-1]}}\), \(\overline{Q_{i[r-1]+1}} \}\). Now, a single reverse application of production 4.2 converts the resulting graph (or the graph \(H_r\) if \(i[r] = i[r-1]+1\) was initially the case) into the graph \(H_{r-1} = P {\textstyle {\frac{\ {\mathsf{v}}\ }{}}}\{ Q_{i[1]}^{b_{i[1]}}\), ..., \(Q_{i[r-2]}^{b_{i[r-2]}}\), \(\overline{Q_{i[r-1]}} \}\). Since this \(H_r \rightarrow H_{r-1}\) transformation procedure is valid for all \(r > 1\), the graph \(H_r\) can be gradually converted to \(H_1\) and thence to \(G_I\). \(\square \)

Rights and permissions

Reprints and permissions

About this article

Cite this article

Fürst, L., Mernik, M. & Mahnič, V. Converting metamodels to graph grammars: doing without advanced graph grammar features. Softw Syst Model 14, 1297–1317 (2015). https://doi.org/10.1007/s10270-013-0380-2

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10270-013-0380-2

Keywords

Navigation